Formal Methods Meet LLMs: Auditing, Monitoring, and Intervention for Compliance of Advanced AI Systems

Parand A. Alamdari, Toryn Q. Klassen, Sheila A. McIlraitharXiv 2026 · arXiv

TL;DR

While Large Language Models (LLMs) are increasingly deployed as autonomous agents, they struggle to reliably follow complex, time-dependent rules (e.g., "do X only after Y happens"). This paper introduces TRAC (Temporal Rule Assessment and Compliance), a framework that combines LLMs with formal verification methods to audit, monitor, and proactively steer AI behavior. By offloading temporal reasoning to exact mathematical logic, TRAC allows even small language models to outperform frontier models at safety and compliance monitoring.

What Problem Does This Paper Address?

As LLMs transition from passive chatbots to active agents in sectors like banking, aviation, and healthcare, ensuring they comply with safety regulations and business norms is critical. Many of these rules are temporally extended—meaning they dictate patterns of behavior over time with highly variable gaps between events (e.g., "If a valid invoice is received, it must eventually be paid").

Currently, the industry relies heavily on "LLM-as-a-Judge" setups, where a powerful model evaluates whether an agent followed the rules. However, this paper demonstrates that LLMs are fundamentally poor at tracking long-term temporal dependencies. Their reasoning accuracy degrades sharply as the time gap between events grows, when multiple rules must be tracked simultaneously, or when the environment contains distracting information.

Methods

The authors propose a clever division of labor: use LLMs for what they do best (semantic perception) and use classical formal methods for what they do best (exact logical reasoning).

The core framework, TRAC, breaks monitoring down into two steps:

  1. The Labeler (LLM): Translates unstructured natural language actions or environment states at each timestep into simple, atomic propositions (e.g., invoice_received = True).
  2. The Monitor (Formal Logic): Evaluates these propositions using Linear Temporal Logic (LTL) progression. Instead of compiling rules into a rigid state machine (automaton), LTL progression incrementally rewrites the logical formula at each step, generating a "residual" formula representing what must still happen in the future to maintain compliance.
Fig. 1. Overview of Temporal Rule Assessment and Compliance (TRAC): This figure depicts the base TRAC algorithm (inner green box) and TRAC with predictive and intervening capabilities (TRACP+I) (outer blue box). An AI agent interacts with an environment over time, producing a sequence of inputs (from the environment) and outputs (from the agent). The Labeler extracts atomic propositions from the sequence of inputs and outputs so far, which then are used by the Monitor to progressively evaluate the monitoring objective (i.e., a behavioral pattern represented as an LTL formula). The Predictor estimates the risk of future violations, enabling the Intervenor to modify the agent’s inputs or substitute its outputs before an undesirable outcome occurs.

The authors expand this into a family of algorithms:

  • TRAC: The base real-time monitoring and offline auditing algorithm.
  • $\text{TRAC}_R$: Introduces a reset mechanism to continuously track rule compliance over long horizons, even after a rule is temporarily violated or satisfied.
  • $\text{TRAC}_{P+I}$ (Predictive + Intervening): Uses trajectory sampling to forecast the probability of a future violation within a short horizon ($k$ steps). If the risk exceeds a threshold, it triggers a black-box intervention—such as rejection sampling (regenerating the action), constraint-guided prompting (injecting the residual rule into the prompt), or model substitution (switching to a safer, highly constrained model).

Datasets

The framework was evaluated across three distinct sequential decision-making environments featuring complex temporal constraints:

  • IPC (Trucks): A logistics planning domain from the International Planning Competition where agents transport packages subject to strict delivery order preferences.
  • TextWorld (Cooking Domain): A text-based interactive environment where agents must follow multi-step recipes while adhering to safety constraints (e.g., examining items before using them).
  • ScienceWorld: A text-based environment for grounded scientific reasoning where agents perform elementary science experiments (e.g., measuring substance temperatures before moving them).
  • Synthetic Traces: Procedurally generated event logs used to stress-test LLMs on temporal reasoning across varying event distances, constraint counts, and proposition densities.

Key Insights and Ideas

  • Decomposition Wins: LLMs are highly accurate at identifying individual facts or events within a single text snippet, but they fail at stringing those facts together logically over long horizons. Separating perception from reasoning solves this.
  • The "Frontier Budget" Illusion: You don't need expensive frontier models like Gemini 1.5 Pro or GPT-4 to act as compliance judges. A small model (like Qwen-7B) acting as a simple labeler inside the TRAC framework achieves superior auditing accuracy at a fraction of the cost.
  • Quantifying LLM Blindspots: Controlled experiments revealed that native LLM temporal reasoning suffers from severe "temporal elasticity" degradation—smaller models drop to near-random accuracy when dependent events are separated by more than 10 steps, and even frontier models struggle when formulas scale in structural complexity.

Key Results

  • Auditing Superiority: In all three environments, $\text{TRAC}_R$ paired with an LLM labeler consistently achieved near-perfect F1 scores (~0.95 to 1.0) for detecting rule violations, vastly outperforming standard zero-shot and few-shot LLM-as-a-Judge baselines.
  • Proactive Risk Reduction: The predictive and intervening framework ($\text{TRAC}_{P+I}$) successfully slashed constraint violation rates across all tested agent models. For instance, in the IPC-Trucks domain, interventions dropped violation rates significantly while fully preserving the agent's underlying task performance (cumulative reward).

Limitations and Future Work

  • The Labeling Bottleneck: TRAC's soundness relies on the accuracy of the underlying labeling function. If the LLM labeler misidentifies an event, the formal monitor will process incorrect data.
  • The Formalism Trap: Translating vague, nuanced human values or regulations into rigid LTL formulas remains a challenging sociotechnical hurdle.
  • Future Directions: The authors point toward fine-tuning smaller models specifically for the proposition labeling task, using LLMs to automatically generate code-based monitors, and expanding the framework to evaluate quantitative properties like fairness.

Summary updated

Abstract

We examine one particular dimension of AI governance: how to monitor and audit AI-enabled products and services throughout the AI development lifecycle, from pre-deployment testing to post-deployment auditing. Combining principles from formal methods with SoTA machine learning, we propose techniques that enable AI-enabled product and service developers, as well as third party AI developers and evaluators, to perform offline auditing and online (runtime) monitoring of product-specific (temporally extended) behavioral constraints such as safety constraints, norms, rules and regulations with respect to black-box advanced AI systems, notably LLMs. We further provide practical techniques for predictive monitoring, such as sampling-based methods, and we introduce intervening monitors that act at runtime to preempt and potentially mitigate predicted violations. Experimental results show that by exploiting the formal syntax and semantics of Linear Temporal Logic (LTL), our proposed auditing and monitoring techniques are superior to LLM baseline methods in detecting violations of temporally extended behavioral constraints; with our approach, even small-model labelers match or exceed frontier LLM judges. Our predictive and intervening monitors significantly reduce the violation rates of LLM-based agents while largely preserving task performance. We further show through controlled experiments that LLMs' temporal reasoning shows a pronounced degradation in accuracy with increasing event distance, number of constraints, and number of propositions.
BibTeX
@misc{alamdari2026formal,
  author = {Parand A. Alamdari and Toryn Q. Klassen and Sheila A. McIlraith},
  title = {{Formal Methods Meet LLMs: Auditing, Monitoring, and Intervention for Compliance of Advanced AI Systems}},
  year = {2026},
  eprint = {2605.16198},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2605.16198},
}

Loading related content...

Figure