TL;DR
Synthesizing Linear Temporal Logic (LTL) specifications from finite system traces is notoriously difficult due to ambiguity and scalability issues. This paper introduces Janaka, a hybrid tool that combines the natural language understanding of Large Language Models (LLMs) with the formal rigor of constraint solvers to translate human explanations and system demonstrations into accurate, verified LTL formulas.
What Problem Does This Paper Address?
Writing formal specifications like Linear Temporal Logic (LTL) is a major bottleneck in formal verification, synthesis, and reinforcement learning. It requires deep mathematical expertise, making it manual, slow, and error-prone.
Automated "specification mining" attempts to learn LTL formulas directly from system demonstrations (traces). However, because these demonstrations are finite, they are inherently ambiguous. For example, a trace showing a property $p$ true for three steps could be explained by "globally $p$," "eventually $p$," or "$p$ holds for exactly three steps." Traditional optimization methods rely on arbitrary rules of thumb (like Occam's razor) to pick a formula, but they struggle to scale and cannot leverage human intuition.
While LLMs can easily ingest natural language explanations to understand human intent, they lack formal guarantees and frequently "hallucinate" syntactically or semantically flawed formulas. This paper addresses the challenge of combining the intuitive, natural-language capacity of LLMs with the absolute correctness of formal optimization methods.
Methods
The authors introduce a framework called Janaka, which splits the specification mining problem into a two-stage pipeline:
- LLM Candidate Generation: Janaka prompts an LLM (such as ChatGPT-4.0) with a combination of system traces, a natural language explanation of the desired behavior, and basic LTL syntax rules. The LLM outputs a set of candidate LTL formulas.
- Quantitative Fitness Evaluation & Repair: Janaka evaluates these candidates using quantitative semantics (specifically, Robust Semantics and Discounted Semantics), which assign a numerical score to how well a formula fits the finite traces. If a candidate passes a specific threshold, it is accepted. If not, Janaka breaks the best candidate formulas down into syntax trees, introduces "template holes" (mutations), and feeds these templates into an optimization-based constraint solver (Gurobi). The solver fills in the holes to synthesize a formally verified, optimal LTL formula.
Datasets
The authors evaluated Janaka on 17 case studies representing diverse, realistic system requirements (e.g., smart home security systems, financial transaction monitoring, and complex manufacturing processes).
To build the dataset:
- Ground-truth LTL formulas were converted into Büchi automata using the Spot platform.
- Traces were generated by non-deterministically walking these automata to accepting states.
- Corresponding natural language descriptions were manually written to capture the underlying logic of each scenario.
Key Insights and Ideas
- Complementary Strengths: LLMs excel at identifying salient features from natural language descriptions but struggle with precise logic. Constraint solvers excel at precise logic but cannot read natural language. Janaka uses the LLM to radically narrow down the search space for the constraint solver.
- The "Syntax-Semantics" Gap: LLMs often generate formulas that match the vocabulary of the English description but miss critical temporal operators (e.g., using a next-step operator
Xinstead of a global operatorG). Janaka exploits this by keeping the LLM's core variables and predicates intact while letting the constraint solver fix the temporal structure. - Mutual Dependency: An ablation study revealed that LLMs fail completely when given only traces without natural language descriptions. Conversely, when the constraint solver was given an empty template (trying to solve from scratch without LLM guidance), it timed out without finding a solution.
Key Results
- High Success Rate: In 16 out of the 17 case studies, the combination of the LLM and Janaka's repair algorithm successfully produced formulas that accurately captured the human designer's intent.
- Substantial Quality Improvement: Janaka improved the quality of the raw LLM output in 12 of the test cases.
- The Value of Traces: Providing the LLM with both natural language descriptions and system traces yielded significantly better initial formulas in 10 cases compared to prompting the LLM with descriptions alone.
A clear example of this interaction is shown in the paper's motivating example, where the LLM's flawed formula is successfully repaired by Janaka to match the ground truth:
Limitations and Future Work
- LLM Failure Cascades: Janaka relies on the LLM to provide a reasonable structural starting point. In 1 of the 17 cases, the LLM failed to generate any useful response, leaving Janaka with nothing to repair.
- Solver Bottlenecks: While the LLM step is fast (leveraging cloud infrastructure), the optimization query executed by Gurobi runs locally and takes significantly longer. For highly complex formulas requiring deep structural repairs, the constraint solver could become a bottleneck.
- Prompt Sensitivity: The framework relies heavily on structured, one-shot prompting to keep the LLM within valid LTL syntax boundaries. Changes in underlying LLM behavior could impact the stability of the pipeline.
Summary updated