A native macOS TLA+ verification toolbox with built-in model checking and state visualization
MacTLA is a native macOS TLA+ verification toolbox built in Swift, providing a complete specification and model checking environment without external dependencies. It implements the full TLA+ language with a BFS model checker, PlusCal translation, and interactive state graph visualization.
Lexer: Tokenizes TLA+ source into a stream of tokens including all standard operators (/\, \/, \A, \E, [], <>, ~>, etc.) and keywords.Parser: Recursive descent parser produces a complete abstract syntax tree (AST) representing modules, declarations, operators, and expressions.Interpreter: Evaluates TLA+ expressions in given environments, supporting set operations, function application, quantifiers, and recursion with depth limiting.Model Checker: Swift actor performing async BFS state space exploration with invariant checking, deadlock detection, counterexample generation, and cancellation support for long-running verifications.PlusCal Translator: Converts PlusCal algorithm blocks into pure TLA+ specifications for model checking.Proof Checker: TLAPS-style proof verification with theorem parsing, obligation generation, and hierarchical proof step validation.
Breadth-First Search: Systematic exploration of the state space level by level, ensuring shortest counterexamples are found first.Initial State Generation: Computes all states satisfying the Init predicate as starting points for exploration.Next-State Relation: Applies the Next action to generate successor states, detecting when no successors exist (deadlock).State Hashing: Efficient duplicate state detection using hash-based state storage.Async Execution: Verification runs asynchronously as a Swift actor, keeping the UI responsive during long-running checks. Users can cancel verification at any time without losing progress information.Error Reporting: Detailed diagnostics for verification failures including the specific invariant violated, the state where violation occurred, and actionable suggestions for debugging.
Configuration is managed through .cfg files or the GUI:
Workers: 1-16 parallel workersMax States: 1,000 to 100,000,000 statesMax Depth: Configurable trace depth limitDeadlock: Enable/disable deadlock checkingConstants: Value assignments for CONSTANTSInvariants: Properties to check in every stateProperties: Temporal formulas to verify
MacTLA includes a built-in PlusCal translator for algorithm specifications:
--algorithm Examplevariables x = 0, y = 0;process Worker \in 1..Nbegin Loop: while TRUE do x := x + 1; Checkpoint: y := x; end while;end process;end algorithm;
The translator converts PlusCal to pure TLA+ with:
Process interleaving semantics
Label-based atomicity
Automatic pc (program counter) variable generation
MacTLA is particularly well-suited for learning TLA+ and rapid prototyping where the interactive state visualization helps build intuition about system behavior.
This specification models two-phase commit with the Consistency invariant ensuring no resource manager commits while another aborts. MacTLA can visualize the state space and find counterexamples if the protocol is incorrectly specified.