Makoto

A systems language that ships a proof with every release. Write a contract for your program and anyone can verify the certificate.

Install Makoto

Run in a macOS, Linux or Windows WSL terminal.

curl --proto '=https' -fsSL https://makoto-lang.org/install.sh | sh

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);
examples/search
$ 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.

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.

Package and what is proved
Obligations by kind
Proved
By hand
transferexact debit and credit, conservation, no change on failure
28
0
searchbinary search: found index matches, None excludes every index, terminates
53
0
fillin-place range fill with its frame
54
0
maskbit-mask toggle against a pure model, involution
11
0
codeclittle-endian u16 codec against pure models, both round trips
52
2
divremtruncating quotient and remainder laws, the two exceptional cases
42
4
ledgertwo-slot transfer in a slice; sum conserved, by induction
77
4
317 / 317obligations accepted by the kernel; none open
96.8%discharged by the automation: 307 obligations
10needed a hand-written proof script, in codec, divrem and ledger
0assumptions: a release refuses a non-empty assumption ledger

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.

  1. .mkt

    Source

    Code, specifications and proof scripts

  2. 誠

    Makotoc

    Parse, type and mode checking, lowering

  3. 注連縄

    Shimenawa

    Ownership, loans, effects, capabilities

  4. Core

    Makoto Core

    One typed program, one digest

  5. 誓約

    Ukehi

    Proof obligations and their goals

  6. search

    Producers

    Scripts and automation, sandboxed

  7. 審神者

    Saniwa

    Kernel replay of every proof

  8. 御札

    Ofuda

    Verdicts, digests and the trusted base

  9. 理

    kamotsu verify

    Kotowari policy and a rebuild: accept or refuse

Trusted at stage S0 Untrusted: anything may search, nothing it says is believed The gate

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.

policy check trusted
貨物

Kamotsu cargo

Build tool and package manager. Your one command, and host of the release gate.

orchestration
makotoc

Makotoc

The compiler: front end, lowering to Core, C back end.

trusted
注連縄

Shimenawa sacred boundary rope

Ownership, loan, effect and capability checking; also the sandbox for untrusted tools.

trusted
誓約

Ukehi trial by pledge

Generates proof obligations from Core and encodes them in the logic.

generator trusted
審神者

Saniwa judge of oracles

The proof kernel and replay driver, on the Lean 4 kernel.

trusted
御札

Ofuda talisman

The verification certificate.

trusted format
狛犬

Komainu guardian lion-dogs

Dependency, capability and assumption auditor, as kamotsu audit.

trusted for confinement
祓

Harae purification

Linter, including lints on the quality of specifications.

untrusted
禊

Misogi cleansing

Formatter.

untrusted
思兼

Omoikane kami of wisdom

AI proof and invariant synthesis.

planned
直毘

Naobi setting right

AI repair of code and annotations.

planned
文

Fumi writing

Documentation generator.

planned
神楽

Kagura sacred dance

Debugger.

planned

From 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.

  1. 0.1

    Bootstrap

    Sequential, total, allocation-free programs; stage S0.

    Here now
  2. 0.2

    Reach

    Library ABIs, enums with payloads, Result, methods, for loops, the AI protocol.

  3. S1

    Foundational

    Core's semantics in the logic; Ukehi leaves the trusted base.

  4. 0.3

    Abstraction

    Generics, traits whose laws are proved, a verified core library.

  5. 0.4

    Memory

    Heap allocation, raw pointers with ghost permissions, references.

  6. S2

    Validated front end

    Surface-to-Core translation validated independently.

  7. 0.5

    Concurrency

    Threads, lock-order proofs, linearizability.

  8. S3

    Verified code generation

    Translation validation from Core to machine code.

  9. 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 mark: a white 貨 on asagi blue with the dandara hem

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 explain
Visit kamotsu.io

Run 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.

Installation and native builds

Terminal

kamotsu new hello
cd hello
kamotsu run

You should see hello, world.