Bridging Natural Language and Formal Specification – Automated Translation of Software Requirements to LTL via Hierarchical Semantics Decomposition Using LLMs
Zhi Ma 1 , Cheng Wen 2 , Zhexin Su 1 , Xiao Liang 1 , Cong Tian 1* , Shengchao Qin 1 and Mengfei Yang 3 · 2025
Read Bridging Natural Language and Formal Specification – Automated Translation of Software Requirements to LTL via Hierarchical Semantics Decomposition Using LLMs by Zhi Ma 1 , Cheng Wen 2 , Zhexin Su 1 , Xiao Liang 1 , Cong Tian 1* , Shengchao Qin 1 and Mengfei Yang 3 (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2512-17334.txt.
Introduction
Zhi Ma and six co-authors built Req2LTL, a tool that turns plain-English software demands into exact logic a checker can verify. Such formal specs matter most in safety-critical fields such as aerospace, where a vague demand can hide a deadly flaw. Language models read meaning well, but they stumble on tangled, deep, real-world demands.
Req2LTL splits the job. A language model breaks each demand into layers, stored in a stepped form the team calls OnionL. Fixed rules then assemble the final logic, which keeps every output well formed. On real aerospace demands, the tool reached 88.4 percent semantic accuracy and 100 percent syntactic correctness. Both scores beat the older methods it was tested against.
Catalog record
| CREATOR | Zhi Ma 1 , Cheng Wen 2 , Zhexin Su 1 , Xiao Liang 1 , Cong Tian 1* , Shengchao Qin 1 and Mengfei Yang 3 |
|---|---|
| YEAR | 2025 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 58 KB |
| VERSION | 1.0 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2512-17334
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
Bridging Natural Language and Formal Specification – Automated Translation of Software Requirements to LTL via Hierarchical Semantics Decomposition Using LLMs Zhi Ma 1 , Cheng Wen 2 , Zhexin Su 1 , Xiao Liang 1 , Cong Tian 1* , Shengchao Qin 1 and Mengfei Yang 3 Abstract Automating the translation of natural language (NL) software requirements into formal specifications remains a critical challenge in scaling formal verification practices to industrial settings, particularly in safety-critical domains. Existing approaches, both rule-based and learning-based, face significant limitations. While large language models (LLMs) like GPT-4o demonstrate proficiency in semantic extraction, they still encounter difficulties in addressing the complexity, ambiguity, and logical depth of real-world industrial requirements. In this paper, we propose Req2LTL , a modular framework that bridges NL and Linear Temporal Logic (LTL) through a hierarchical intermediate representation called OnionL . Req2LTL leverages LLMs for semantic decomposition and combines them with deterministic rule-based synthesis to ensure both syntactic validity and semantic fidelity. Our comprehensive evaluation demonstrates that Req2LTL achieves 88.4% semantic accuracy and 100% syntactic correctness on real-world aerospace requirements, significantly outperforming existing methods. TABLE I: Natural Language and Corresponding LTL Specifications Natural Language LTL Formula Once red, the light cannot become green next. G(\textnormal{red}\rightarrow X\neg\textnormal{green}) Once the light is red, it must remain red until it turns yellow. G(\textnormal{red}\rightarrow\textnormal{red}\,U\,\textnormal{yellow}) If b holds, next c holds until a holds or always c holds. G(\textnormal{b}\rightarrow X((\textnormal{c}\,U\,\textnormal{a})\lor G\textnormal{c})) If a holds then c is true until b. G(\textnormal{a}\rightarrow(\textnormal{c}\,U\,\textnormal{b})) Navigate to the green room while avoiding landmark 1. (F\textnormal{ green})\land G(\neg\textnormal{ landmark 1}) Swing by landmark 1 before ending up in the red room. F(\textnormal{landmark 1}\land F\textnormal{ red}) I Introduction The accurate and automated translation of natural language (NL) software requirements into formal language (FL) program specifications is crucial for leveraging formal verification techniques in industrial applications, particularly within safety-critical domains such as aerospace [ 1 ] , operating systems [ 2 , 3 ] , compilers [ 4 ] , and embedded controllers [ 5 ] . Linear Temporal Logic (LTL) is widely used to formally specify temporal behaviors of reactive and embedded systems due to its precision in expressing complex safety and liveness properties and the availability of powerful verification tools ( e.g. , NuSMV [ 6 ] , Spot [ 7 ] ). However, the current industry practice predominantly relies on human experts with deep domain and formal reasoning knowledge to manually translate natural language requirements into LTL formulas. This process is both time-consuming and prone to errors [ 8 , 9 , 10 , 11 ] . Existing approaches aimed at automating NL-to-LTL translation are either rule-based or learning-based, each exhibiting significant drawbacks. Rule-based methods [ 12 , 13 ] generally lack flexibility and are limited by variability and narrow scope. In contrast, learning-based approaches [ 14 , 15 , 16 ] require extensive labeled datasets and often struggle to generalize beyond their training examples. Recent advancements in large language models (LLMs), such as GPT-4o [ 17 ] , have shown potential in related domains like code generation and logical inference [ 18 , 19 , 20 , 11 , 21 , 22 ] , yet directly applying these models to complex NL-to-LTL translation tasks remains problematic due to the implicit temporal semantics, deeply nested logical structures, and context-specific constraints inherent in industrial requirements. Three primary challenges limit the effectiveness of applying LLMs directly to this translation task. First, natural language often conveys temporal semantics implicitly through nuanced expressions ( e.g. , will be set or unless ), which require deeper semantic interpretation beyond surface-level syntactic analysis. Second, industrial requirements often involve deeply nested logical constructs, including multiple conditionals, exceptions, and working mode-based constraints within single statements, posing significant challenges to the attention allocation and structural fidelity of LLMs. Third, LLMs are autoregressive and prone to error compounding: if a partial formula is generated incorrectly, subsequent completions are likely to deviate further from the intended semantics. These challenges are exacerbated by the absence of structural validation mechanisms in most LLM-based methods, resulting in silent failures that are difficult to detect or rectify. To effectively address these issues, we propose a novel intermediate representation called OnionL , specifically designed to bridge the gap between natural language semantics and formal logic. OnionL is a tree-structured intermediate language that reflects the compositional syntax of LTL while maintaining semantic alignment with domain-specific expressions. It provides a hierarchical, structured representation of requirements by explicitly modeling scopes , relations , and atomic propositions . This structured abstraction serves as a semantic bridge, allowing LLMs to focus on local semantic extraction while delegating global logical composition to rule-based synthesis. Building on the OnionL representation, we propose the Req2LTL framework, which comprises two primary components: (1) the Req2OnionL module utilizes prompt-guided LLMs to decompose natural language requirements into structured OnionL trees hierarchically; (2) the OnionL2LTL module employs a deterministic, rule-based approach to validate and translate these OnionL structures into correct and standardized LTL formulas. The entire pipeline is fully automated, and it supports optional human-in-the-loop refinement via visualized intermediate structures. Our evaluation shows that Req2LTL substantially surpasses existing state-of-the-art methods, such as NL2SPEC [ 23 ] , NL2LTL [ 24 ] , and NL2TL [ 16 ] , on both academic benchmarks and real-world aerospace datasets. Specifically, Req2LTL achieves 88.4% semantic accuracy and 100% syntactic correctness, clearly demonstrating its efficacy in practical industrial contexts. Ablation studies confirm the importance of hierarchical decomposition and rule-based validation in handling complex, nested logic. Our contributions are summarized as follows: • OnionL Intermediate Representation : We introduce OnionL , a hierarchical intermediate language explicitly encoding temporal semantics, scopes, and logical relations. OnionL serves as a robust semantic bridge between natural language requirements and LTL formulas. • Hierarchical Semantic Decomposition : We present a two-stage, prompt-driven decomposition algorithm ( Building-OnionL ) leveraging LLMs. This systematic approach significantly improves semantic accuracy and structural integrity in the translation process. • Req2LTL Framework : We present Req2LTL , an automated framework combining LLM-based semantic decomposition ( Req2OnionL ) and deterministic rule-based translation ( OnionL2LTL ), supported by automated validation. It achieves superior accuracy (88.4%) and perfect syntactic correctness (100%) compared to existing approaches, across both academic and industrial benchmarks. II Background and Motivation Fig. 1: Examples showcasing the discrepancy between LLM generated LTL and ground truth for complex requirements. The red-circle indicates errors in the LLM’s output due to missing details, contrasted with the manually corrected specification. II-A Background Linear Temporal Logic (LTL) is a formal modal logic extensively used to specify temporal properties over infinite execution paths. Formally, given a finite set of atomic propositions \mathit{AP} , LTL formulas follow the grammar: \varphi::=p\;|\;\neg\varphi\;|\;\varphi_{1}\land\varphi_{2}\;|\;\mathbf{X}\varphi\;|\;\mathbf{F}\varphi\;|\;\mathbf{G}\varphi\;|\;\varphi_{1}\;\mathbf{U}\;\varphi_{2} where p\in\mathit{AP} . The temporal operators in LTL convey critical aspects of system dynamics: \mathbf{X}\varphi specifies that \varphi holds in the next state; \mathbf{F}\varphi indicates \varphi eventually holds at some future state; \mathbf{G}\varphi demands \varphi to always hold; and \varphi_{1}\mathbf{U}\varphi_{2} requires \varphi_{1} to hold \varphi_{2} until becomes true. Table I provides common examples from academic benchmarks [ 16 , 23 , 25 , 26 , 24 ] , where the natural language statements are typically concise, grammatically regular, and temporally explicit. The inclusion of keywords such as always or if…then allows for a