SpecMAS: A Multi-Agent System for Self-Verifying System Generation via Formal Model Checking

Rishabh Agrawal, Kaushik Tushar Ranade, Aja Khanal, Kalyan Shankar Basu, Apurva NarayanNeurIPS 2025

As software systems grow more autonomous and complex, ensuring they behave exactly as intended is no longer just a "nice-to-have"—it is a strict safety requirement for mission-critical domains like healthcare, automotive, and aviation. Traditionally, engineers rely on Formal Verification, a mathematical process where a system model is rigorously checked against specific safety and liveness properties (e.g., "the elevator must never move with the door open").

However, a massive expertise gap exists. Writing formal models in specialized languages like NuSMV requires deep domain knowledge that most developers lack. While Large Language Models (LLMs) can generate code from natural language, they frequently "hallucinate" or produce models that appear correct but fail under edge cases.

This paper introduces SpecMAS, a multi-agent framework that autonomously transforms natural language Standard Operating Procedures (SOPs) into formally verified, executable system models. By integrating an industry-standard model checker into a recursive "generate-verify-debug" loop, SpecMAS ensures that AI-generated systems are provably correct by construction.

System Architecture and Methods

SpecMAS bridges the gap between informal natural language specifications and rigorous symbolic formal verification without requiring a human expert in the loop. It operates through two tightly coupled pipelines:

  1. Model & Specification Synthesis: This pipeline ingests an SOP and uses LLM-based agents to extract operational modes, variables, and transitions. It constructs a formal graph of system states (a Kripke structure) and identifies both explicit properties stated in the text and implicit properties inferred via reasoning. The output is a preliminary model and a set of properties written in NuSMV syntax.
  2. Model-Checking and Debugging: The generated model is fed directly into NuSMV, an industry-standard symbolic model checker. If NuSMV finds a bug, it produces a counterexample—a specific sequence of events leading to a failure. A dedicated Debugging Agent analyzes this trace, identifies the logical flaw, and revises the model. This loop repeats until the model checker confirms that all properties are satisfied.
SpecMAS Architecture and Debugging Loop

By using NuSMV directly, SpecMAS avoids the "black box" problem typical of many AI tools, producing interpretable code that can be seamlessly integrated into existing engineering toolchains.

The MiniSpecBench Dataset

To evaluate the system, the researchers introduced MiniSpecBench, a new benchmark dataset designed to test how well AI can generate formal models. It contains 10 diverse systems, including the Bounded Retransmission Protocol (BRP), a Shuttle Autopilot Guidance System, Mutual Exclusion protocols, and a Robot Controller. The dataset provides ground truth by pairing expert-written NuSMV files with natural language SOPs, synthesized using a variant of SYNTHIA to ensure strict semantic alignment.

Key Insights and Results

SpecMAS was evaluated against state-of-the-art models including Claude 3.7-Sonnet, DeepSeek-R1, Gemini 2.5, and Qwen. The results highlight several critical insights into how AI should approach formal verification.

The "Paradox of Detail": Interestingly, SpecMAS often generates more initial syntax errors than baseline LLMs like DeepSeek. This occurs because SpecMAS attempts to model complex edge cases and nuanced transitions that baselines simply ignore. Once the debugging loop is applied, SpecMAS's detailed models become far more robust than the "shallow" but syntactically perfect models of its competitors.

Execution over Alignment: The authors argue that "Code Compliance" (how closely the code resembles a human expert's syntax) is less important than "Execution Compliance" (whether the code actually compiles, runs, and passes verification). SpecMAS prioritizes the latter, trading off surface-level similarity for mathematical correctness.

Compliance and Performance Radar Charts

As shown in the performance benchmarks, SpecMAS dominates in practical application:

  • Stability: SpecMAS achieved the highest Final Score in 4 out of 5 primary system categories (Protocols, Sync/Concurrency, Memory Mgmt, Digital Logic, Reactive Ctrl, Safety-Critical).
  • Reliability: While models like Gemini failed to produce executable code in 60% of tasks (scoring 0.0 in execution compliance), SpecMAS maintained exceptionally high execution scores (e.g., 0.97 for the Shuttle Autopilot).
  • Efficiency: On average, the system required only 18 additional debugging steps to reach full compliance on even the most complex tasks, demonstrating strong convergence.

Limitations and Future Work

Despite its success, SpecMAS faces a few known hurdles:

  • State-Space Explosion: Like all model checkers, SpecMAS can struggle with "state-space explosion" in extremely high-complexity systems where the number of possible states becomes astronomical.
  • Ambiguous Specs: If an SOP is fundamentally contradictory or missing critical information, the system may still require a "human-in-the-loop" to clarify intent.
  • Expanding Backends: Currently, the system is optimized for NuSMV. The authors plan to extend it to other verification backends like SPIN to support probabilistic and stochastic systems.

Ultimately, SpecMAS represents a significant step toward "self-verifying" AI—systems that don't just do what they are told, but can mathematically prove they are doing it right.

Summary updated

BibTeX
@inproceedings{agrawal2025specmas,
  author = {Rishabh Agrawal and Kaushik Tushar Ranade and Aja Khanal and Kalyan Shankar Basu and Apurva Narayan},
  title = {{SpecMAS: A Multi-Agent System for Self-Verifying System Generation via Formal Model Checking}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=Cl45XdnCoK},
}
Figure