Learning to Estimate System Specifications in Linear Temporal Logic using Transformers and Mamba

Ilker Isik, Ebru Aydin Gol, Ramazan Gokberk CinbisarXiv 2024

Abstract

Temporal logic is a framework for representing and reasoning about propositions that evolve over time. It is commonly used for specifying requirements in various domains, including hardware and software systems, as well as robotics. Specification mining or formula generation involves extracting temporal logic formulae from system traces and has numerous applications, such as detecting bugs and improving interpretability. Although there has been a surge of deep learning-based methods for temporal logic satisfiability checking in recent years, the specification mining literature has been lagging behind in adopting deep learning methods despite their many advantages, such as scalability. In this paper, we introduce autoregressive models that can generate linear temporal logic formulae from traces, towards addressing the specification mining problem. We propose multiple architectures for this task: transformer encoder-decoder, decoder-only transformer, and Mamba, which is an emerging alternative to transformer models. Additionally, we devise a metric for quantifying the distinctiveness of the generated formulae and a straightforward algorithm to enforce the syntax constraints. Our experiments show that the proposed architectures yield promising results, generating correct and distinct formulae at a fraction of the compute cost needed for the combinatorial baseline.

Introduction

In the development of complex hardware and software systems, ensuring correct behavior is paramount. Formal methods utilize Linear Temporal Logic (LTL) to define precise requirements, such as "if the engine starts, the cargo must be carried until the destination is reached." However, manually authoring these specifications is a significant bottleneck. Specification mining seeks to automate this by extracting LTL formulas from system execution traces.

Traditional approaches to specification mining often rely on combinatorial search or SAT-solvers, which face exponential time complexity as system requirements grow. This research explores the potential of modern autoregressive architectures—specifically Transformers and Mamba—to treat specification mining as a sequence-to-sequence translation task, mapping system traces directly to logical formulas.

Figure 1: Overview of the specification mining task, showing an input trace of system states being mapped to an output LTL formula.

Methodology

The researchers framed the problem as translating a sequence of system states into a sequence of logical operators. To handle the complexities of LTL, several technical innovations were implemented:

  1. Architectural Diversity: The study evaluated three models: a standard Transformer Encoder-Decoder, a decoder-only Transformer (Llama-style), and Mamba, a State Space Model (SSM) designed for efficient long-sequence processing.
  2. Polish Notation: Formulas were generated in prefix notation (e.g., &ab for a ∧ b) to eliminate the ambiguity of parentheses and simplify the generation process.
  3. Syntax-Enforcing Algorithm: To prevent the generation of invalid logical expressions, a sampling-time constraint algorithm was introduced. This algorithm masks tokens that would violate LTL grammar, ensuring that every output is a syntactically valid formula.
  4. Distinctiveness Metric: To ensure the generated formulas are meaningful and not trivial (like the formula True), the authors introduced a metric to measure how specifically a formula describes its corresponding trace.

Results and Discussion

The experimental results demonstrate that neural models can effectively learn the semantics of LTL. The Mamba-based model achieved a semantic correctness rate of 98.23%, indicating that it captures the underlying logic rather than merely memorizing strings.

The most significant advantage of this approach is its computational efficiency. While combinatorial methods scale poorly with formula complexity, neural models provide near-constant inference time. As shown in Figure 4, the neural models (Mamba, Transformer, Llama) operate orders of magnitude faster than the combinatorial baseline, especially as the number of operators increases.

Figure 4: Comparison of inference time between combinatorial baselines and neural models. Note the log scale on the y-axis, highlighting the massive speed advantage of the neural approach.

Quantitatively, the Mamba model was approximately 8,327x faster than the combinatorial baseline for formulas with up to 4 operators. When the baseline included distinctiveness analysis to find high-quality formulas, the speedup reached a staggering 264,019x.

Conclusion

This work demonstrates that autoregressive models can revolutionize specification mining by providing a scalable, high-accuracy alternative to traditional search-based methods. While challenges remain—such as the tendency of models to "stutter" certain operators and the need for more diverse real-world datasets—the massive leap in inference speed opens new possibilities for real-time system monitoring and automated verification. Future work will focus on improving the qualitative "readability" of generated formulas and expanding the training sets to better reflect real-world system behaviors.

Summary updated

BibTeX
@misc{isik2024learning,
  author = {Ilker Isik and Ebru Aydin Gol and Ramazan Gokberk Cinbis},
  title = {{Learning to Estimate System Specifications in Linear Temporal Logic using Transformers and Mamba}},
  year = {2024},
  eprint = {2405.20917},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2405.20917},
}
Figure