Lasso: Verified LTL Model Checking

Research internship at the National University of Singapore. Lasso, a formally verified alternative to the TLA+ model checker that matches it on performance.

A research internship at the VERSE Lab, National University of Singapore, advised by Prof. Dr. Ilya Sergey. The result is Lasso, a formally verified alternative to TLC, the model checker behind TLA+: a model checker for Linear Temporal Logic implemented and proved correct inside the Lean proof assistant, and built from the start to match TLC on performance. No previously verified LTL model checker had managed that, and the one prior effort runs about an order of magnitude slower than the heavily optimized but unverified tools. A paper on the work is currently under submission.

Why this is hard. The interesting properties of distributed protocols are liveness properties (“something good eventually happens”), and they almost always hold only under fairness assumptions that rule out runs starting some component forever. The textbook approach translates the whole formula, fairness included, into a Büchi automaton. Fairness assumptions cause that translation to explode exponentially: a conjunction of \(n\) strong-fairness assumptions is a conjunction of \(n\) disjunctions, so the translator faces \(2^n\) possible combinations.

\[\begin{aligned} \phi_{\mathit{fair}} &= \bigwedge_{i<n} \texttt{SF}(\mathtt{e}_i, \mathtt{t}_i) \\ &\equiv \bigwedge_{i<n} \big( \mathbf{G}\mathbf{F}\, \mathtt{e}_i \rightarrow \mathbf{G}\mathbf{F}\, \mathtt{t}_i \big) \\ &\equiv \bigwedge_{i<n} \big( \mathbf{F}\mathbf{G}\, \neg \mathtt{e}_i \vee \mathbf{G}\mathbf{F}\, \mathtt{t}_i \big) \end{aligned}\]

On one of my benchmark families the standard translation produces 356 343 automaton states and 12.8 million transitions at \(n=12\) strong fairness assumptions, taking 3 h 14 m for the automata translation alone, before running any checks. The cost is entirely in the fairness. This is also why liveness sometimes even gets skipped in practice, and why the model checkers that do handle it are large, aggressively optimized programs whose results are hard to trust. During the evaluation, one of the tools we compared against returned a wrong result on two of my models, reproduced on two machines and two architectures. This is reported to the authors.

The approach: get fairness out of the formula. Lasso never hands the fairness to the LTL-to-Büchi automata translator. It classifies the conjuncts of the negated formula, recognises which ones are fairness assumptions, normalises each into fair normal form, and hoists them out, so that only the remaining property is translated. The hoisted assumptions become a condition that an accepting strongly connected component of the product must additionally satisfy, checked on the fly by an SCC-based emptiness check refining Tarjan’s SCC finding procedure.

Pruning. The standard way to discharge that condition enumerates all \(2^n\) combinations for n strong-fairness assumptions and runs a separate search for each, meaning it stays exponential and runs four million searches at \(n=22\). I built a recursive prune based approach instead. The insight is that a fairness assumption is a restriction on an SCC, so any candidate SCC is either already fair, contains a smaller fair subgraph, or can never yield a fair counterexample at all. The prune therefore does not commit to any of the combinations up front, it searches once, and reduces a candidate SCC into its fair subgraph. When a candidate SCC is not yet fair according to the assumptions a user wrote, only then does it commit to the option that could still repair it, and recurse. For standard fairness notions like weak and strong fairness, at most one option could ever repair it, so it never branches at all, keeping the check polynomial in \(n\). For the earlier example of \(n=22\), Lasso finishes it in \(< 50\) ms while most tools timeout in \(10\) min and TLC runs into a java.lang.OutOfMemory exception at \(4\) GB.

Verification. Every component (formula rewriting, translation through very weak alternating automata, SCC enumeration, prune) is written and verified in Lean, in roughly 60 000 lines with no sorry anywhere. Each entry point carries a matched pair of theorems: soundness, an empty result means every run of the system satisfies the formula, and completeness, a reported counterexample really is a run of the system that violates it. The trusted base is reduced to Lean’s three axioms and its kernel. No test suite is enough to make such a statement.

Usability. Lasso is integrated into Veil, a foundational verifier embedded in Lean for specifying and verifying distributed protocols, which already had a safety model checker and now, with Lasso, has a liveness one as well. I extended Veil’s syntax with LTL properties, including TLA-style enabled and taken action primitives, of all the other tools I compared against only TLC supports these natively.

Results. I evaluated against seven model checkers (TLC, SPOT, PAT, SPIN, NuSMV, LTSmin and CAVA) on the official TLA+ examples and on families built to vary the fairness cost along each axis independently, plus an ablation across six routes through my own pipeline so that each design decision is isolated with everything else held fixed. Porting every model by hand required me to validate each port against TLC’s own state graph. On TLA+’s own examples Lasso tracks TLC closel in performance and is faster at the median. Where fairness drives the cost it is faster by an order of magnitude at the median and slightly slower on only two of forty-seven cases. Across both test suites it decides every benchmark TLC decides within the timeout and twelve that TLC does not, with no disagreement anywhere. Against CAVA, the only other fully verified LTL model checker, it is orders of magnitude faster.

What this is for. Previously, the field accepted a trade-off: verified or usable. This work shows that we can, in fact, eat our cake and have it too :). A model checker can be machine-checked correct and still land in the same bracket as the industry-standard tool used for decades. And because Lasso is implemented in Lean, the specification a user model checks is the same specification they can go on to prove formally as well, with Mathlib and the rest of the ecosystem available.