Getting started
The toolchain
Section titled “The toolchain”The compiler, deducible, is written in Rust. Clone it and build:
git clone https://github.com/dihannahdi/deduciblecd deducible/fiqh-compiler
# build & run the test suitecargo test
# the CLI lives in crates/fiqhccargo run --bin deducible -- --helpdeducible exposes a small set of verbs:
deducible parse <spec.fiqh> # show the parsed ASTdeducible check <spec.fiqh> # run the fiqh invariant engine onlydeducible build <spec.fiqh> # check, then emit Solidity + tests + manifestdeducible nl <prompt.txt> # draft a .fiqh from natural language, then re-check itdeducible lsp # language server (diagnostics in your editor)Your first spec
Section titled “Your first spec”A diminishing-partnership home-finance contract, home.fiqh (paste it into the
Playground to follow along):
instrument HomeFinance : musharakah_mutanaqisah { meta { basis: "AAOIFI Shari'ah Standard No. 12"; currency: tinybar; } parties { bank : financier; client : acquirer; valuer : oracle independent; } capital { bank : 8000 bps; client : 2000 bps; require bank + client == 10000 bps; } returns { rent { basis: bank.share; rate: 1 per_bps_period; } buyout { price: oracle.fairValue * bps; transfers: bank.share -> client.share; } } risk { loss: proportional_to_ownership; capital_guarantee: none; } invariant ownership_conserved { bank.share + client.share == 10000 } invariant loss_follows_capital { loss == proportional_to_ownership } invariant role_separation { valuer != bank } lifecycle { fund; payRent; buyShare(bps); settle; }}Check it:
$ deducible check home.fiqh✓ consistentNow slip in the quiet clause that turns it back into a loan — set capital_guarantee: bank and
loss: none:
$ deducible check home.fiqh✗ RIBA-1 38:5 capital_guarantee returns capital whole regardless of outcome — riba. al-Baqarah 2:275 · AAOIFI SS No. 12✗ RISK-1 37:5 loss must follow ownership (al-ghunm bi-l-ghurm). 2 errors · no contract emitted$ echo $?1Build artifacts
Section titled “Build artifacts”deducible build home.fiqh --target all emits, into out/:
| Artifact | What it is |
|---|---|
<Name>Gen.sol |
a Solidity contract whose invariants mirror the checked rules |
<Name>Gen.test.js |
a Hardhat test asserting those invariants on-chain |
<Name>.deploy.json |
a deploy descriptor (oracle mode, parties, params) |
<Name>.manifest.json |
a portable, ledger-agnostic invariant manifest |
Choose a single target with --target solidity | manifest | zk | all, and a jurisdiction’s
rule-base with --rules aaoifi | dsn-mui.
- The .fiqh DSL — the grammar and sections.
- The five C’s — composite contracts, capacity, zakat, contingencies, zero-knowledge.
- Diagnostics reference — every code the engine can raise.