Pure-MoonBit TLA+ distributed protocol model checker, official TLC-compatible engine, native SVG counterexample trace visualizer, and zero-upload browser studio
| Protocol | Verdict (Both) | Distinct States (moon-tla / TLC) | Diameter (moon-tla / TLC) | Trace / Lasso | Native moon-tla | JVM TLC v1.7.4 | End-to-End Ratio |
|---|---|---|---|---|---|---|---|
| DieHard | INVARIANT:NotSolved | 14 / 14 | — | 7 states | 128.6 ms | 1022.4 ms | 8.0x |
| TwoPhase | OK | 288 / 288 | 11 / 11 | — | 38.2 ms | 722.9 ms | 18.9x |
| TwoPhaseBuggy | INVARIANT:TCConsistent | 158 / 158 | — | 6 states | 41.1 ms | 897.1 ms | 21.8x |
| TwoPhaseSym (SYMMETRY) | OK | 80 / 80 | 11 / 11 | — | 28.0 ms | 746.0 ms | 26.6x |
| MutexPeterson | OK | 26 / 26 | 8 / 8 | — | 22.7 ms | 703.5 ms | 31.0x |
| MutexBuggy | INVARIANT:MutualExclusion | 9 / 9 | — | 5 states | 28.6 ms | 711.2 ms | 24.8x |
| PetersonLiveness (Per-Action WF) | OK | 26 / 26 | 8 / 8 | — | 20.5 ms | 739.9 ms | 36.1x |
| StarvationBuggy (Per-Action WF) | LIVENESS:StarvationFree | 8 / 8 | — | 5 states (loop@2) | 14.8 ms | 898.3 ms | 60.6x |
| RaftElection | OK | 282 / 282 | 8 / 8 | — | 48.1 ms | 751.0 ms | 15.6x |
| RaftSplitBrainBuggy | INVARIANT:ElectionSafety | 597 / 597 | — | 7 states | 47.2 ms | 947.3 ms | 20.1x |
| PaxosConsensus (Synod Paxos) | OK | 3,921 / 3,921 | 17 / 17 | — | 1167.6 ms | 946.3 ms | 0.8x |
| BankTransfer | OK | 5 / 5 | 3 / 3 | — | 30.1 ms | 693.5 ms | 23.0x |
| BankTransferBuggy | INVARIANT:NoOverdraft | 15 / 15 | — | 5 states | 27.9 ms | 708.8 ms | 25.4x |
| DiningPhilosophers | DEADLOCK | 14 / 14 | — | 4 states | 29.5 ms | 708.5 ms | 24.0x |
| TokenRing | OK | 8 / 8 | 5 / 5 | — | 29.0 ms | 720.9 ms | 24.8x |
| TokenRingLiveness ([]<>) | OK | 4 / 4 | 4 / 4 | — | 16.8 ms | 883.4 ms | 52.6x |
| Total (16 specs) | 16/16 EXACT | 16/16 EXACT | 9/9 EXACT | 7/7 EXACT | 1718.8 ms | 12801.3 ms | 7.4x |
import {
"Sam-Hui-dot/moon-tla@0.2.0",
}fn main raise {
let tla =
#|---- MODULE Counter ----
#|EXTENDS Integers
#|VARIABLE x
#|Init == x = 0
#|Step == x < 5 /\ x' = x + 1
#|Next == Step
#|Bound == x < 3
#|====
let cfg = "INIT Init\nNEXT Next\nINVARIANT Bound"
let result = @moon-tla.check_spec_sources(tla, cfg)
println(@moon-tla.render_result_text(result))
let svg = @moon-tla.render_trace_svg(result)
println("SVG length: \{svg.length()}")
}moon build --target native --release cmd/main# Terminal summary + shortest counterexample trace
./_build/native/release/build/cmd/main/main check demo/specs/RaftSplitBrainBuggy.tla \
--cfg demo/specs/RaftSplitBrainBuggy.cfg
# Export native SVG counterexample timeline
./_build/native/release/build/cmd/main/main check demo/specs/RaftSplitBrainBuggy.tla \
--cfg demo/specs/RaftSplitBrainBuggy.cfg \
--format trace-svg --out trace.svg --exit-zero
# Export layered BFS state-space graph SVG
./_build/native/release/build/cmd/main/main check demo/specs/TwoPhaseBuggy.tla \
--cfg demo/specs/TwoPhaseBuggy.cfg \
--format graph-svg --out graph.svg --exit-zero
# Evaluate a standalone TLA+ expression
./_build/native/release/build/cmd/main/main eval "(-1) % 3"# Format check + 4-target verification
moon fmt --check
for t in wasm wasm-gc js native; do
moon check --target "$t" --deny-warn
moon test --target "$t" --deny-warn
done
# Build and V8 smoke-test the zero-upload browser studio
python3 demo/build_web.py
# Run official Java TLC v1.7.4 differential oracle across all 11 specs
python3 demo/verify_tlc.pypub(all) struct CheckResult {
module_name : String
status : CheckStatus
status_text : String
states_generated : Int
distinct_states : Int
diameter : Int
transitions : Int
symmetry_applied : Bool
variables : Array[String]
invariants_checked : Array[String]
properties_checked : Array[String]
trace : Array[TraceStep]
lasso_loop_start : Int?
graph_nodes : Array[GraphNode]
graph_edges : Array[GraphEdge]
} derive(Eq, Debug, ToJson)pub(all) enum Expr {
BoolLit(Bool)
IntLit(Int64)
StrLit(String)
BuiltinSet(String)
Ident(String)
At
Call(String, Array[Expr])
Unary(UnaryOp, Expr)
Bin(BinOp, Expr, Expr)
ConjList(Array[Expr])
DisjList(Array[Expr])
IfThenElse(Expr, Expr, Expr)
CaseExpr(Array[(Expr, Expr)], Expr?)
LetIn(Array[OpDef], Expr)
ForAll(Array[BoundGroup], Expr)
Exists(Array[BoundGroup], Expr)
Choose(BoundPat, Expr, Expr)
SetEnum(Array[Expr])
SetFilter(BoundPat, Expr, Expr)
SetMap(Expr, Array[BoundGroup])
TupleLit(Array[Expr])
RecordLit(Array[(String, Expr)])
RecordSet(Array[(String, Expr)])
FuncDef(Array[BoundGroup], Expr)
FuncSet(Expr, Expr)
FuncApply(Expr, Array[Expr])
RecordField(Expr, String)
Except(Expr, Array[ExceptClause])
StutterAction(Expr, Expr)
Fairness(FairnessKind, Expr, Expr)
} derive(Eq, Debug)fn check_module(tla_mod : TlaModule, cfg : TlaConfig, options? : CheckOptions) -> CheckResult raise TlaErrorfn check_options(max_states? : Int, max_graph_nodes? : Int, check_deadlock? : Bool?, use_symmetry? : Bool) -> CheckOptionsfn check_spec_sources(tla_src : String, cfg_src : String, options? : CheckOptions) -> CheckResult raise TlaErrorfn error_message(error : Error) -> StringInstall
Download zipPure-MoonBit TLA+ distributed protocol model checker, official TLC-compatible engine, native SVG counterexample trace visualizer, and zero-upload browser studio