muro-lang.dev / docs
How we know the checker is right
You trust the checker, so its rules are written as a formal model and machine-checked. The model lives under agda/, in Agda, a proof assistant. The program you run is Elixir: muro check. You never install Agda, and you never read those files, to check a book. This page says what the model proves, for which fragment, and what it does not prove. The theorem-by-theorem list is Limits. Changing the model is Extending the kernel.
What is proved
The fragment is Π, λ, application, Nat, Unit, Empty, identity, rewrite, def, annotation, pairs (A × B, (a, b), let (a, b) = e in t), data (constructor applications and match, indexed data too), and ν (Stream, Always, ~, and declared families).
Three results hold for that fragment. The modules are checked under --safe: no postulates, no TERMINATING pragmas.
-
Soundness (
agda/Muro/Soundness.agda). When the checker accepts a definition, the rules derive it. One direction only. It holds at every fuel, for a signature whose constructor types are well-formed telescopes (GoodSig). -
The wall (
agda/Muro/Wall.agda). A spec or a proof cannot become running code. In the words of the emitters, those terms are erased: checked by the compiler, then left out of the emitted code. -
Consistency (
agda/Muro/Consistency.agda). No closed normal evidence term has type Empty. Closed evidence terms make progress, and a reduction step keeps the type of closed evidence. The full statementEmpty-evidis not proved. Its open hypothesis is normalisation of closed evidence (Empty-evid-from). Do not citeEmpty-evid.
Muro.IR.Soundness proves elaboration and erasure for a closed fragment, under --safe. The modules are Muro.IR.Soundness, Muro.IR.Soundness.Run, Muro.IR.Soundness.Match, and Muro.IR.Soundness.Preserve.
elabRuns-skips drops every spec and evidence definition from the list of runs. finishDef-not-run and elab-def-not-run say such a definition does not elaborate to Call. erased-arg-irr says an erased argument does not change the elaborated term when the body is in the pure fragment. ctor-erased-irr and call-erased-irr say the same for an erased constructor field and for an erased argument of a run. ctor-core-irr lifts the constructor fact to elaborate when every live field is in the pure fragment.
toIR-preserves is the pure fragment: zero, successor, unit, pairs, letp, variables, a let at Nat (erased, affine, or reuse), a word operation the step function runs, a Nat or Unit match whose motive is var zero (which motiveLay reads as the scrutinee’s layout), and a constructor with no fields. When source evaluation produces a value and elaboration succeeds (ok ir), the IR evaluator returns that value.
toIR-runs is the larger fragment. A term there is a pure term, a constructor applied to live fields and erased fields, a match on declared data whose motive is var zero and whose arms are the towers the elaborator builds, or a run applied to live arguments and erased arguments whose body is again in the fragment. dropTo drops leading parameters before the field telescope. An erased field is omitted from the value and is bound by Let x erasedL affineG Ze. The callee body’s elaboration is a hypothesis, and the fuel of ev bounds the call depth. A call derivation has depth at least one. The closed examples are opt-pres (an Opt with an erased field; the match returns zero), w-pres (indexed data whose first field is erased; the match returns one), and use-pres (use calls id and drops an erased argument; the evaluator fuel is 2).
Source evaluation on this fragment is big-step. It is not the parallel reduction in Muro.Reduction. The table below is the whole boundary.
What those theorems do not cover
Some checks are decided in Elixir and sit outside the theorems above.
- Termination of accepted recursion. The checker requires a recursive call to descend on a smaller argument. That decision is not an Agda theorem.
-
A party marked
may fail. Temporal checks for that meeting are decided in Elixir. The Agda temporal modules stay the meeting that does not mark a party. See Temporal and Limits. - Tensors and atoms. Tensor and Atom remain outside the judgment the theorems talk about.
-
The rest of the pipeline. A motive other than
var zero, closures, streams,uncons,Abort, loops,bfold, the passesShare,Loop,ANF, andRep, session IR, and every backend sit outsidetoIR-runs. The table marks each one. -
Fold fusion.
Muro.IR.Loopmay turn adjacent folds of one slice, or a fold whose start is another fold of that slice, into one loop.Muro.IR.Evaland the compiled C are the check. There is no Agda theorem for that rewrite.
Sessions, the projection of a choreography, and temporal checks for a meeting that does not mark a party have their own modules under agda/Muro/. Limits names each one and what it does not claim. An example file that checks is not, by itself, a proof that the model is complete.
Trusted Computing Base
Six compiled backends read Muro.IR: c, rust, zig, asm, js, and go. go_pure is the Go path for run functions, inside go. Expression IR and the session machines are different layers. The session layer is Muro.IR.Session: fsm labels the protocols, Muro.IR.Session.lower/3 takes that image, and Muro.IR.Session.machine/2 lowers one end to states. Muro.IR.Session.Check checks both. Nothing in this table is verified compilation.
| Stage | Status |
|---|---|
Checker: Muro.Soundness, Muro.Wall, Muro.Consistency |
Proved in Agda. One direction. Empty-evid is not proved. Termination of accepted recursion is not a theorem. Tensors, atoms, and a party marked may fail sit outside. |
| Meetings and temporal properties |
Proved in Agda for the fragment Limits names. A party marked may fail is decided in Elixir. |
Muro.IR elaboration (elaborate, elabRuns) and erasure |
Proved in Agda for the fragment named above (elabRuns-skips, finishDef-not-run, elab-def-not-run, erased-arg-irr, ctor-erased-irr, call-erased-irr, ctor-core-irr, toIR-preserves, toIR-runs). Outside that fragment the same elaborator is tested. |
IR passes Share, Loop, ANF, Rep |
Differential-tested. Fold fusion in Loop is Muro.IR.Eval against the compiled C, not an Agda theorem. |
Compiled backends that consume Muro.IR: c, rust, zig, asm, js, go |
Differential-tested. Emit tests, not Agda. |
Session IR Muro.IR.Session (labelled ends, dual templates, and the state machine of an end) |
Built from the fsm labelling. Muro.IR.Session.Check checks every end and dual (string steps, no dangling recursion variable, every jump names an end or a dual, case arms with distinct tags) and every machine (dense state ids, labels per kind, the entry state exists, every target exists, the kind’s direction, type, binder, and bound, a bound or a case scrutinee — including a :raw {:name, n} — reads a name in scope on every path that reaches it, no refused transition, every state reachable). A session entry that is not a map is an error, not a raise. A jump whose argument count is not the parameter list is still well-formed; the lowering follows it. Tested, and not an Agda theorem. |
Session emitters that consume Muro.IR.Session: rust_session and go_session (the machine, machine/2 and lower_machine/2), c_session and js_session (the checked ends and templates) |
Trusted. Tested against the emitted-examples digest, and not an Agda theorem. |
Emitters that walk the source AST: default elixir, --node, otp, fsm, nif, exunit, pytest, rust-test, csharp-test, family-outline, mbi, go_choreo, go_family |
Trusted. The AST is the source of the image. Tested, and not an Agda theorem. |
Outside that fragment, and left for a later proof: a motive other than var zero, closures and the closures: true image (Lam, Appv), streams, Uncons, Abort, loops, bfold, the four IR passes, session and protocol IR, backend correctness, linear endpoint consumption, and stability of a body hash. The proof does not extend the checker proof or the meeting proofs.
What runs in CI
make agda checks that tree. CI runs it on every push to main, on a manual run, and on a pull request that changes agda/, the Makefile, or a file under .github/workflows/. On any other pull request the Agda check reports as skipped, which the required check accepts. The schedule is written in Extending.
A person writing a .muro file does not clone vendor/agda-stdlib and does not run make agda. That clone is for the job that changes the type theory.
Source on GitHub
· fetched from murolang/muro manual/