Muro

Write the program and its proof in one file. Ship ordinary code.

Hex version

muro checks your spec when you compile, then ships only the code that runs: no proof overhead in the binary. Targets include Elixir (BEAM), C, Rust, Zig, Go, and JavaScript.

Nothing is inferred. An agent writes every type and every proof step. The checker accepts the file or names each definition that fails, so you can trust the check without trusting the agent.

60-second tour · Install · Docs · For agents

Muro is a programming language for programs that come with proofs. A .muro file holds three kinds of definition: spec (what something means), evidence (a proof about a program) and run (the program). muro check accepts the file or names each definition that fails; nothing is inferred. Proofs are checked at compile time and gone at run time: only run definitions are compiled, to Elixir, C, Rust, Zig, Go or JavaScript, among other targets. Muro also checks protocols between processes (sessions, choreographies, and temporal properties such as leads_to). It is designed for AI agents to write and for people to review.

muro on Hex is published by the murolang organization. Current release: 0.24.0. Releases are listed in CHANGELOG.md.

Why muro

60-second tour

The self-contained binary carries its own Erlang runtime. This page names the version this release ships:

mise use -g github:murolang/muro@0.24.0

The transcript below was run with muro 0.22.64. The acceptance line is the same. The first line of muro check is the version that ran.

curl -fsSL -o half_ok.muro https://raw.githubusercontent.com/murolang/muro/main/examples/half_ok.muro
muro check half_ok.muro
Muro v0.22.64
All terms check. Evidence never becomes a run.

Three definitions, trimmed. IsEven is the spec, half is the program, half_ok is the proof that twice half n is n when n is even. The file also defines plus and plus_suc.

-- What "even" means. Not a program.
def IsEven : spec Π (n : Nat) → Type := …

-- The program. This is what will run.
def half : run Π (n : Nat) → Nat :=
  λ (n : Nat) →
    match n motive (λ _ → Nat)
      | 0 => 0
      | suc n1 =>
        match n1 motive (λ _ → Nat)
          | 0 => 0
          | suc p => suc(half p)

-- Twice half n is n, when n is even.
def half_ok : evidence Π (n : Nat) → Π (e : IsEven n) →
                          {plus (half n) (half n) ≡ n : Nat} := …

Break half: in the last arm, change suc(half p) to half p. Check exits 1 and names the proof:

Muro v0.22.64
half_ok.muro:37:1: half_ok body: cannot convert suc(plus (half n) suc(half n)) ≁ match match n motive (λ x → Nat) | 0 => 0 | suc n => …

Restore the file. Emit JavaScript and run it. Node on the machine that recorded this was v26.8.2.

muro emit half_ok.muro --backend js
node -e 'import("./half_ok.mjs").then(m => console.log(m.half(8n)))'
./half_ok.mjs
./half_ok.d.ts
./half_ok.d.mts
4n

The proof is gone from the output. The program is what runs.

Protocols in 15 lines

examples/may-fail-free.muro is a server and a task. The task may crash. The checker accepts that the server still finishes. Comments at the top of the file are omitted here.

data Report : Type where
  ok : Report

session task-work := send Report end
session server-wait := recv Report end

conform task : task-work := put ok done

conform server : server-wait :=
  get (r : Report) done
  fail
    done

meet free : server with task may fail buffer 1

temporal freed : free := (server at first get) leads_to (server done)
muro check may-fail-free.muro
Muro v0.22.64
temporal freed: holds in 5 reachable states, 6 transitions
All terms check. Evidence never becomes a run.

Both arms are done, so the server finishes on the report and on the crash. leads_to says that waiting is followed by done.

Several parties share one script in examples/two-phase-commit.muro: a coordinator and two participants prepare, then commit or abort together.

What you get

Target Flag What it writes
Elixir (default) module on stdout; public run is def
OTP --backend otp a GenServer per session
State machine --backend fsm machines, dispatchers, monitors, on stdout
C --backend c .h and .c; a Nat run is a NIF
Rust --backend rust .rs
Zig --backend zig .zig
Go --backend go .go: machines, monitors, dispatchers, runs
JavaScript --backend js .mjs, .d.ts, .d.mts; a cross is create(host)
Assembly --backend asm Cortex-M0 .s, Nat runs
MBI --backend mbi one graded .mbi run, for muro-beam
ExUnit --backend exunit closed equations as ExUnit
pytest --backend pytest the same equations as pytest
Rust tests --backend rust-test the same equations as Rust tests
C# tests --backend csharp-test the same equations as C# xUnit
Family JSON --backend family-json hold graph as JSON
Mermaid --backend mermaid one flowchart per family; one sequence per choreography family

--backend otp and --backend fsm run a may fail arm (down on the machine). --backend go emits it when every failure arm is finish or leave. Elixir, C, Rust, Zig, JavaScript, assembly, and the four test backends refuse that book with c:mayfail.

Install

Three ways. Which copy of the compiler runs, and how words and host codecs are emitted, is in Start and The executable.

Binary (no Elixir required):

mise use -g github:murolang/muro@0.24.0
muro check path.muro

Mix archive, in any directory:

mix archive.install hex muro

Pinned: mix archive.install hex muro 0.24.0. From a checkout: mix archive.build && mix archive.install muro-0.24.0.ez. From GitHub, Mix fetches the default branch and builds the archive: mix archive.install github murolang/muro.

Hex dependency:

def deps do
  [
    {:muro, "~> 0.24.0"}
  ]
end

Built with muro

How we know the checker is right

The checker is what you trust. Its rules are a formal model, machine-checked in Agda (a proof assistant) under agda/. You never install Agda. muro check is the whole interface.

For the core (functions, data, pairs, equality, streams), acceptance means the rules derive the definition, a spec or proof never becomes running code, and no closed normal evidence term has type Empty. Normalisation of every closed proof is not proved. Outside those theorems: termination of accepted recursion, temporal checks including may fail, tensors, and atoms. CI checks the Agda tree under --safe, with no postulates, on every push to main. See How we know the checker is right and Limits.

Docs

The book is manual/. muro-lang.dev/docs renders it. The list is manual/manifest.yml.

Contributing

Two jobs. Do not mix them.

You want to… Do this
Write a program Add a .muro file. Check it with mix muro.check. Do not change the kernel.
Change the type theory Follow Extending. Agda first, then the matching Elixir.
mise install
mix deps.get
mix test
mix muro.check
mix muro.check examples/half_ok.muro

Kernel only, Agda 2.8+ and standard library 2.3:

git clone --depth 1 --branch v2.3 https://github.com/agda/agda-stdlib.git vendor/agda-stdlib
make agda

Muro.Lexer.tokenize/1 returns {kind, start, stop} spans. A rejected snippet still yields spans, and joining them gives the source back. Muro.MakeupLexer maps them to Makeup tags ("muro", .muro) when the app starts. Muro.Check.check_sig/2 returns :ok or every definition error, in book order, each on its own process. Names: Muro, theory MuroTT, files .muro, Elixir Muro.Check / Muro.Emit / Muro.Parser, Agda Muro.*.

Agents follow manual/for-agents.md. If this file and that page disagree, that page wins.