Platform Overview
Unlike the Java-based TLC model checker, MacTLA is built entirely in Swift using a from-scratch implementation of the TLA+ toolchain:MacTLA runs entirely on-device with no network dependencies, making it suitable for air-gapped environments and offline formal verification workflows.
Architecture
MacTLA follows an MVVM architecture, separating the TLA+ toolchain from the user interface:
Core Components
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.
Model Checker Implementation
MacTLA includes a production-grade explicit-state model checker implementing TLC-style verification:State Exploration
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 theInit 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.
Property Checking
Counterexample Generation
When a property violation is detected, the model checker produces a trace:Checker Configuration
Configuration is managed through.cfg files or the GUI:
Proof Checker
MacTLA includes a TLAPS-style proof system for deductive verification of TLA+ theorems.Theorem Declarations
The proof checker supports standard theorem constructs:Proof Syntax
Proofs can be structured hierarchically with numbered steps:Proof Step Types
Proof Status
The checker tracks proof status with visual indicators:Obligation Management
Complex proofs are decomposed into proof obligations—individual goals that must be verified. The proof checker:- Tracks hypotheses at each proof level
- Generates sub-obligations for each step
- Validates proof structure up to 100 levels deep
- Reports detailed error messages for failed proofs
TLA+ Language Support
MacTLA implements the complete TLA+ language specification:Operators
Logic:\/(disjunction),/\(conjunction),~(negation)=>(implication),<=>(equivalence)
\A x \in S : P(universal)\E x \in S : P(existential)CHOOSE x \in S : P(choice)
\in,\notin,\subseteq,\cup,\cap,\SUBSET S(powerset),UNION S(distributed union){x \in S : P}(set filter),{e : x \in S}(set map)
[x \in S |-> e](function definition)f[x](function application)DOMAIN f(function domain)[f EXCEPT ![a] = b](function update)
[]P(always),<>P(eventually)[]<>P(always eventually),<>[]P(eventually always)P ~> Q(leads-to)WF_vars(A)(weak fairness),SF_vars(A)(strong fairness)P'(next-state value)
- Ordering:
\prec,\preceq,\succ,\succeq - Similarity:
\sim,\simeq,\approx,\cong,\asymp - Lattice:
\sqcap,\sqcup,\sqsubseteq,\sqsupseteq - Circle:
\oplus,\ominus,\otimes,\oslash,\odot - Other:
\cdot,\bullet,\star,\bigcirc,:>,@@
Specification Declarations
MacTLA supports formal specification declarations:PlusCal Support
MacTLA includes a built-in PlusCal translator for algorithm specifications:- Process interleaving semantics
- Label-based atomicity
- Automatic
pc(program counter) variable generation
State Visualization
MacTLA provides interactive visualization of the state space:Force-Directed Graph
States are rendered as a navigable graph using force-directed layout:- Nodes represent states with variable assignments
- Edges represent transitions (actions)
- Colors indicate state type:
- Green: Initial states
- Red: Error states (invariant violation)
- Blue: Selected state
Interaction
- Pan: Drag to navigate the graph
- Zoom: Pinch or scroll to zoom in/out
- Select: Click a state to inspect its variables
- Trace: View counterexample as highlighted path
Trace Viewer
For counterexamples, the trace viewer shows:- Step-by-step state progression
- Action labels between states
- Variable diff highlighting
- Navigation controls
IDE Features
Editor
- Syntax highlighting for TLA+ and PlusCal
- Real-time error diagnostics
- Line numbers and minimap
- Bracket matching and auto-indentation
- Search and replace with regex support
- Auto-save with file persistence
Code Intelligence
- Context-aware code completion
- Symbol navigator for definitions
- Go-to-definition support
- Keyboard shortcuts (⌘R to run, ⌘F to find)
File Management
- Native macOS file dialogs
- Project organization with multiple files
- Auto-save to prevent data loss
Built-in Templates
MacTLA includes starter templates for common distributed systems patterns:
Templates provide a starting point for learning TLA+ and can be customized for your specific verification needs.
Requirements
Comparison with TLC and TLAPS
Example: Two-Phase Commit
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.
Related Resources
AD Tier Model TLA+ Specification
Use MacTLA to verify the AD Tier Model’s 10 safety invariants and explore state transitions
Formal Models Overview
Learn how TLA+ and Alloy specifications work together to verify AD security