Write the promise beside the code
A contract lives in a .spec.mkt file next to its implementation. requires and ensures say what callers may assume and what the function guarantees. example lines are proved too, as evidence that the contract is not vacuous. Loop invariants and a decreases clause carry the proof through the loop.
/// `a` is sorted in non-decreasing order. pub spec fn sorted(a: Seq<u32>) -> bool { forall |i in 0..a.len(), j in i..a.len()| a[i] <= a[j] } /// Finds an index of `target` in the sorted slice `data`, if there is one. pub fn binary_search(data: &[u32], target: u32) -> Option<usize> requires sorted(data) ensures match result { Some(k) => k < data.len() && data[k] == target, None => forall |i in 0..data.len()| data[i] != target, }; example binary_search([1, 3, 5], 3) == Some(1); example binary_search([1, 3, 5], 4) == None; example binary_search([], 7) == None; example binary_search([2, 2, 2], 2) != None; example binary_search([1, 3, 5], 4) != Some(0);
pub fn binary_search(data: &[u32], target: u32) -> Option<usize> { let mut lo: usize = 0; let mut hi: usize = data.len(); while lo < hi invariant lo <= hi <= data.len() invariant forall |i in 0..lo| data[i] < target invariant forall |i in hi..data.len()| data[i] > target decreases hi - lo { // The midpoint never overflows: `hi - lo` is at most `data.len()`. let mid = lo + (hi - lo) / 2; let v = data[mid]; if v < target { lo = mid + 1; } else if v > target { hi = mid; } else { return Some(mid); } } None }
$ kamotsu build --release Kamotsu building search 0.1.0 (release) Ukehi generated 53 obligations and their goals Saniwa elaborated the definitions and goals into replay base sha256:a2b8e2fb… Producer producing evidence for 53 goals (untrusted, sandboxed; 8 at a time) Saniwa accepted …binary_search#s7.bounds.1 Saniwa accepted …binary_search#s2.termination.1 Saniwa accepted …binary_search#s19.postcondition.1 … 50 more Kamotsu wrote Kamotsu.lock (53 entries) Saniwa replay accepted evidence for all 53 goals Makotoc native code generated (trusted back end, stage S0) cc built 33656 bytes; a second build reproduced the bytes Kotowari bootstrap floor and package policy pass Ofuda wrote search.ofuda and the evidence bundle (53 objects) Kamotsu published release sha256:dcc08295… stage S0
Release of the search acceptance package, abridged: long lines wrapped, digests and paths shortened.
- Assumed
- 0
- Open
- 0
- Stage
- S0
- Kernel
- lean4 4.30.0
- Sources
- 5 files
- Core
- sha256:127b9e2f…
- Artifact
- sha256:96066f97…
- Rebuild
- reproducible
- Capabilities
- io
Every release carries its own evidence
Next to the executable, a release writes an Ofuda: what was proved, by which kernel, from which sources, into which bytes. Anyone holding the sources, the Ofuda and the artifact can run kamotsu verify and reach the same verdict without trusting the publisher.
- Goals are regenerated, not read. The verifier recompiles the sources and requires the certificate's goals to match exactly: none missing, none extra.
- The kernel replays every proof. Saniwa checks the evidence with no cache and no proof search. How a proof was found, by script, automation or eventually AI, makes no difference.
- The verifier brings its own policy. Kotowari rules decide what must be proved, and the verifier's policy applies alongside the package's.
- The executable is rebuilt byte for byte. A release that a second build does not reproduce is refused.
What a release does not claim
0.1 is assurance stage S0. The front end, the obligation generator and the C back end, with the system C compiler, are trusted and not yet verified; only the proofs are kernel-checked, and every Ofuda names that trusted base. Makoto proves conformance to a specification. It cannot establish that the specification says what its authors meant. Read the charter
317 obligations in the acceptance suite. None assumed.
Seven packages define done for 0.1. Each releases and verifies offline under the strict policy, and each deliberate mutation of them is refused for the reason the specification gives.
One road from source to certificate
Proof search is untrusted and may be anything. Proof checking is deterministic and done by a small kernel. Only what Saniwa accepts reaches the Ofuda, and only an Ofuda that passes policy becomes a release.
- .mkt
Source
Code, specifications and proof scripts
- 誠
Makotoc
Parse, type and mode checking, lowering
- 注連縄
Shimenawa
Ownership, loans, effects, capabilities
- Core
Makoto Core
One typed program, one digest
- 誓約
Ukehi
Proof obligations and their goals
- search
Producers
Scripts and automation, sandboxed
- 審神者
Saniwa
Kernel replay of every proof
- 御札
Ofuda
Verdicts, digests and the trusted base
- 理
kamotsu verify
Kotowari policy and a rebuild: accept or refuse
Names that say what each part does
The toolchain takes its names from Shinto practice. 誠, makoto, is sincerity: fidelity to one's word. Here the word is the specification.
Makoto sincerity
The language.
Kotowari reason, principle
The specification, and the verification policy in Kotowari.toml.
Kamotsu cargo
Build tool and package manager. Your one command, and host of the release gate.
orchestrationMakotoc
The compiler: front end, lowering to Core, C back end.
trustedShimenawa sacred boundary rope
Ownership, loan, effect and capability checking; also the sandbox for untrusted tools.
trustedUkehi trial by pledge
Generates proof obligations from Core and encodes them in the logic.
generator trustedSaniwa judge of oracles
The proof kernel and replay driver, on the Lean 4 kernel.
trustedOfuda talisman
The verification certificate.
trusted formatKomainu guardian lion-dogs
Dependency, capability and assumption auditor, as kamotsu audit.
Harae purification
Linter, including lints on the quality of specifications.
untrustedMisogi cleansing
Formatter.
untrustedOmoikane kami of wisdom
AI proof and invariant synthesis.
plannedNaobi setting right
AI repair of code and annotations.
plannedFumi writing
Documentation generator.
plannedKagura sacred dance
Debugger.
plannedFrom bootstrap to a verified, self-hosted toolchain
Ordered by what most reduces the risk of failure, not by what is most visible. Numbered releases widen the language; S stages shrink what has to be trusted.
- 0.1
Bootstrap
Sequential, total, allocation-free programs; stage S0.
Here now - 0.2
Reach
Library ABIs, enums with payloads,
Result, methods,forloops, the AI protocol. - S1
Foundational
Core's semantics in the logic; Ukehi leaves the trusted base.
- 0.3
Abstraction
Generics, traits whose laws are proved, a verified core library.
- 0.4
Memory
Heap allocation, raw pointers with ghost permissions, references.
- S2
Validated front end
Surface-to-Core translation validated independently.
- 0.5
Concurrency
Threads, lock-order proofs, linearizability.
- S3
Verified code generation
Translation validation from Core to machine code.
- S4
Self-hosting
The toolchain in Makoto, verified, with an independent kernel.
The ecosystem
A registry with Ofudas as first-class metadata and policy-aware resolution, Omoikane and Naobi providers, a documentation generator, a debugger and editor support.
The first workloads
Iroha components with crisp specifications: Norito codecs, IVM instruction execution, transaction validation and ledger state transitions. Kotodama stays the smart-contract language and shares this verification infrastructure.
Kamotsu, the one command
Kamotsu is Makoto's build tool and package manager. It checks, tests, proves, builds and verifies, and it hosts the release gate. Twenty-nine libraries are already packaged for it, from SHA-2 and Ed25519 to Iroha's Norito codec.
kamotsu checkkamotsu test --nativekamotsu provekamotsu build --releasekamotsu verifykamotsu explainRun your first Makoto program
After installation, open a new terminal. Kamotsu creates a project with a working src/main.mkt and runs it in the interpreter.
Terminal
kamotsu new hello cd hello kamotsu run
You should see hello, world.