MARS 1.0 links every requirement to its formal model, empirical run records, and audited Lean proofs in one content-addressed graph—and shows exactly what is still OWED. Jump straight to Run your first check or Use MARS without Selûne.
Follow one requirement—“A transfer must conserve tokens”—from prose to machine-checked closure:
Prose or DrWatt EARS: Write the requirement in Markdown (spec.md) or a structured DrWatt manifest (requirements.json).
Quint state machine & exploration: Model allowed transitions and inv_conserved in Quint, then run bounded searches and deliberate mutants to catch broken designs early.
Veil embedding & Lean proof: Veil translates the compiled Quint IR into a Lean transition system (quint_module) where Lean checks an inductive proof over all reachable model states.
MARS obligation graph: One .mars file pins the requirement digest, Quint source/IR, empirical run receipts, and Lean proof name—flagging drift the moment any input changes.
Separate code refinement: Connecting concrete implementation code to the proved model stays an explicit OWED obligation until a separate implementation-scope refinement proof passes audit.
Run Your First Check
The canonical MARS 1.0 compiler lives in libs/mars/ as a pure MoonBit 1.0 RC1 toolchain (zero Python dependency). Invoke it via ./bin/selune mars (which builds the native release binary automatically on first use) or build directly with (cd libs/mars && moon build --frozen --target native --release --deny-warn cmd). Save this complete module as inventory.mars at the repository root:
mars 1.0
module Inventory version 1.0.0
requirement NextCount:
status signature
priority MUST
subject count : `Nat`
THE `count` SHALL PROVE `Nat.succ count ≠ count`
conclusion `Nat.succ count ≠ count`
end
./bin/selune mars check inventory.mars
./bin/selune mars status inventory.mars --json
Expected output:check prints OK Inventory (exit 0); status --json reports "owed": 1, "release_ready": false, and "blockers": ["NextCount"] until an audited Lean proof discharges it.
Use MARS 1.0 Without Selûne
MARS 1.0 is project-agnostic and language-agnostic. Adopt it on any codebase with Markdown specs and Lean alone—no Selûne cells, Quint, Python, or DrWatt required. Build the standalone native MoonBit binary once with (cd libs/mars && moon build --frozen --target native --release --deny-warn cmd) and copy mars-next/lean/MarsAudit.lean for Lean audits:
# spec.md: - INV-001: The counter shall always advance to a distinct successor value.
# standalone.mars:
mars 1.0
module Inventory version 1.0.0
source markdown "spec.md" ids INV-001
requirement NextCount:
status signature
priority MUST
subject count : `Nat`
THE `count` SHALL PROVE `Nat.succ count ≠ count`
conclusion `Nat.succ count ≠ count`
covers INV-001
end
./bin/selune mars check standalone.mars
./bin/selune mars coverage standalone.mars --json
# -> OK Inventory | coverage links INV-001 -> ["NextCount"] with priority ["MUST"]
MoonBit 1.0 RC1 (libs/mars native binary; zero Python)
Grammar, typed USES/subject, Markdown/DrWatt pins, and deltas are consistent.
check FILE --exercise --format json
+ Quint 0.35.0 (Node) & Veil 2.0 workspace
Baseline invariants hold under declared bounds, reachability witness is observed, every mutant violates exactly its declared invariants, and ITF replays succeed.
audit FILE / status FILE --audit --json
+ Lean 4.35.0 & Lake (and Veil for proof veil)
MarsAudit.lean verifies rigid universe equality, standard axioms, non-vacuity, and trust budgets; prints typed OWED rows for signatures.
Verifies pure MoonBit Draft 2020-12 schema conformance, M1–M11 negative mutations, and all 10 checklist steps live.
Linux resource-cap note: Plain ./bin/selune mars (or direct native binary) commands work on Linux, macOS, and WSL. On shared Linux hosts, optionally cap heavy --exercise or audit runs with systemd-run --user --scope -p MemoryMax=12G -p MemorySwapMax=2G -- ./bin/selune mars ....
Soundness Rules & Three-Level Claim Separation
Evidence Discharges Nothing
Tests, simulations, ITF replays, and bounded finite-instance exhaustive model checks stay in separate evidence blocks. They supply observations at declared bounds and never upgrade an open, signature, or stubbed proof obligation.
Soundness Core
Typed USES & Named subject
Requirements bind quantified variables explicitly (subject amount : `Nat`). Declaring USES UpstreamRow instantiates the upstream theorem on shared subject names and types—or requires an explicit rebinds old to new "reason" clause.
Compositional
Exact Non-Vacuity Controls
Witness: applies to allstubbed propositions (∃ x, A₁(x) ∧ … ∧ Aₖ(x), empty conjunction is True; reachability witness allowed for model invariants). Drop: each named WHERE p requires an existential countermodel satisfying remaining premises while falsifying both p and the consequence. Closed-prop: rejects subject-independent conclusions, reducible True / reflexive equalities, and conclusions repeating an antecedent (unless explicitly waived via trivial "reason").
Anti-Vacuity
Independent MarsAudit.lean
Checks kernel definitional equality under rigid universe parameters (loadExts := false), rejects sorryAx, checks logical axioms separately from compiler-hook flags (extern, implemented_by, unsafe, partial, Lean 4.35 per-decision native_decide), enforces #mars_depends/#mars_signature/#mars_literals, and prints typed OWED entries on partial modules.
Observed outcomes for the pinned Quint model, instance constants, state constraints, and bounds (bounded, finite-instance exhaustive, or simulation).
evidence (row stays owed)
2. Model Proof
proof veil `decl` from quint Q invariant inv
The Veil-embedded predicate holds in every reachable model state of the pinned Quint IR under its parameters and trust budget. Trusted step: Quint→Veil (quint_module) translation is trusted; the Lean kernel checks the embedded model, not Quint's runtime semantics.
model-proved
3. Code Refinement
scope implementationPROVE row with code artifact pin and typed USES of an audited model row
Pinned implementation code preserves the stated representation relation to the model invariant under audited hypotheses.
implementation-proved
Syntax, 8 Block Kinds & Annotated Excerpts
Every file begins with mars 1.0, followed by module Name version SEMVER or delta Name: (mars-next/spec/GRAMMAR.ebnf). Directives pin dependencies: import, lean-import, source drwatt (native UUIDs or pinned identities companion), source markdown ... ids (ranges A-001..A-010, braces IL-010{A,B}), and ruling ... from ... sha256.
Block Kind
Role in Resolved Graph
Primary Fields
requirement
Normative formal obligation linked to source requirements
status (open|signature|stubbed|blocked "reason"), priority, scope, subject, WHERE, USES, rebinds, THE ... SHALL PROVE|REFUSE|ACCEPT|REFUTE|CERTIFY|DEFINE, conclusion, proof, witness, drop, trust, covers
statement
Named mathematical lemma or claim
status (open|claimed|assumed|proved|refuted), subject, lean, proof lean, trust, error
Module-wide prohibitions overriding any trust catalog
THE MODULE SHALL NOT USE `term`, DECLARE axioms, DEPEND ON `term`
Excerpt 1: Compile Quint IR & Bind a Veil Proof
Excerpt from mars-next/examples/token_escrow/obligations.mars (omits LeanRuntime and sibling rows; see the full file to run). Generate escrow.ir.json with quint compile --target json --flatten=false --main token_escrow --init init --step step --invariant inv_conserved,inv_nonnegative,inv_receipted,inv_all token_escrow.qnt > escrow.ir.json, hash the raw stdout bytes with sha256sum, pin them below, and run ./bin/selune mars audit to move status stubbed to audited model-proved:
-- Excerpt from mars-next/examples/token_escrow/obligations.mars (complete module linked above)
quint Protocol:
file "token_escrow.qnt" sha256 "1d8b987afae5084f0447f09f2db3aad724626d04f1045c2bf2a3db976e4d0daf"
main token_escrow
version "0.35.0"
checks inv_conserved, inv_nonnegative, inv_receipted, inv_all
ir "escrow.ir.json" sha256 "b561d04a61758e3bb8c849ddbc5ac082b8063dcf53c299992078bf0ccb74f214"
proofs "token_escrow_proofs.lean" sha256 "6169483a52e7ced01cf79784ec3c45f023377c2c0e946aad6793a812d595b6ee"
witness wit_settled
mode exhaustive
mutant "Duplicated lock" file "mutants/duplicated.qnt" sha256 "5f500ae9379830e27403f79b60f5730c68df2e732b12bc01e592d22e943a24d3" expect violates inv_conserved, inv_all
models inv_conserved Conservation
models inv_all CombinedSafety
conjunction inv_all = inv_conserved, inv_nonnegative, inv_receipted
end
requirement Conservation:
trust LeanRuntime
status stubbed
scope model
priority MUST
THE `inv_conserved` SHALL PROVE `holds% inv_conserved`
proof veil `token_escrow.inv_conserved_holds` from quint Protocol invariant inv_conserved
covers "96e708c6-1190-4f00-b2f9-90f1dcf85f96" digest "sha256-ears-utf8-v1:a51aa484d29771291ffc32d175fc77ee086401e95f761b2f2b5fe2c608f02053"
end
Excerpt from token_escrow/obligations.mars. The default MARS trust budget allows standard logical axioms alone; every audited proof in both shipped examples runs under an explicit 78-entry LeanRuntime catalog enumerating Lean 4.35.0 compiler-hook flags (extern, implemented_by, unsafe including lcProof and unsafeCast)—not kernel axioms. Note that Debit is a standalone arithmetic lemma at implementation scope (no model USES, no code pin—not a full Level 3 refinement proof). The policy block shown beneath it is illustrative syntax (not in the shipped escrow module).
-- Excerpt of the actual 78-entry LeanRuntime catalog (compiler hooks, not kernel axioms)
trust LeanRuntime:
note "Compiler hooks inspected by the Lean 4.35.0 audit of the model proof. The kernel uses standard logical axioms."
flag extern `Nat.add`
flag extern `Nat.sub`
-- ... 72 additional Lean 4.35.0 stdlib extern/implemented_by/unsafe hooks (see full fixture)
flag implemented_by `Nat.repr`
flag unsafe `lcProof`
flag unsafe `unsafeCast`
flag unsafe `unsafeCast._proof_1`
end
-- Standalone arithmetic lemma at implementation scope (no USES, no code pin; not Level 3 refinement)
requirement Debit:
trust LeanRuntime
status stubbed
scope implementation
priority MUST
subject amount : `Nat`
WHERE funded : `0 < amount`
THE `withdraw` SHALL PROVE `amount - 1 < amount`
proof lean `Escrow.withdraw`
witness `Escrow.fundedWitness`
drop funded `Escrow.fundedDrop`
fidelity exact
covers "ddf5c076-b4ec-46f4-8caa-659763e00abe" digest "sha256-ears-utf8-v1:13bebbf8f378159baf4556d69aff02b8507f3c51e379d004d02565985bfbfaa8"
end
-- Illustrative module-wide policy (not present in token_escrow/obligations.mars)
policy StandardLogicOnly:
THE MODULE SHALL NOT USE `sorryAx`
THE MODULE SHALL NOT DECLARE axioms
end
CI Freshness Failure & OpenSpec Governance Deltas
When a requirement sentence changes in requirements.json without reconciling its formal obligation, check --fresh fails immediately with exit code 1 and marks the covering row stale-source:
# Baseline passes (exit 0 -> OK TokenEscrow)
./bin/selune mars check mars-next/examples/token_escrow/obligations.mars --fresh
# After editing ESC-001 in a disposable copy of requirements.json (exit 1):
./bin/selune mars check /tmp/escrow-copy/obligations.mars --fresh
# /tmp/escrow-copy/obligations.mars:123:3 stale-source [Conservation] Changed requirement ESC-001.
# Review the revised statement and bind its current statement_digest.
To govern changes to a requirement's THE clause, pair an OpenSpec Markdown delta with an obligations.delta.mars file referencing a SHA-256-pinned ruling from the base module (illustrative syntax; replace <64-hex> with your ruling file's digest):
mars 1.0
delta Catalog:
ADDED
requirement RateLimit:
status open
priority SHOULD
subject count : `Nat`
THE `limiter` SHALL REFUSE "bursts exceeding configured quota"
end
MODIFIED
requirement MissingKey:
status open
subject key : `Option Nat`
WHERE missing : `key = none`
THE `catalog` SHALL REFUSE "a sample with a missing primary key"
covers "18018f72-7194-4af9-b585-0756d8eb3e2c" digest "sha256-ears-utf8-v1:e4c241bde322a6534762d775ff12c88d23c10d85b446099c1bf65a40b37feddb"
end
authorized-by D1 sha256 "<64-hex>"
REMOVED
LegacyCheck reason "Superseded by typed schema validation in v1.1"
RENAMED
OldKeyCheck to PrimaryKeyCheck
end
Verified Case Studies & Implementations
Token Escrow shows greenfield MARS 1.0 adoption: duplicating a lock violates inv_conserved, omitting a receipt violates inv_receipted, and even after proving 4 model invariants + 1 arithmetic lemma, 3 journal obligations stay visibly OWED (10/10 checklist steps via mars1 verify-checklist + native mars1 self-test PASS, zero Python in MARS). Selûne Commit Queue shows incremental MARS 1.0 adoption on an existing repository: binding 1/18 requirements (SEL-005 via pinned identities.json) and 7/7 audited model proofs while keeping code refinement (QueueImplementation) explicitly open.
Canonical pure MoonBit implementation (hoskinson/agentic_mars: src/syntax, src/checker, src/emit with built-in Draft 2020-12 structural schema checks, and cmd native CLI with live Quint/Veil/Lean 4.35.0 auditing, self-test, and verify-checklist; zero Python). Beta · Pure MoonBit
Normative MARS 1.0 grammar and specs (mars-next/spec/), independent Lean 4.35.0 kernel auditor (mars-next/lean/MarsAudit.lean), three Draft 2020-12 schemas (mars-{graph,diagnostic,gate-sidecar}.v1.schema.json), and worked examples. Beta · Standalone