Beyond Postconditions: Can Large Language Models infer Formal Contracts for Automatic Software Verification?
Not on the map. Why?
Abstract (arXiv)
Automatic software verifiers have become increasingly effective at the task of checking software against (formal) specifications. Yet, their adoption in practice has been hampered by the lack of such specifications in real world code. Large Language Models (LLMs) have shown promise in inferring formal postconditions from natural language hints embedded in code such as function names, comments or documentation. Using the generated postconditions as specifications in a subsequent verification, however, often leads verifiers to suggest invalid inputs, hinting at potential issues that ultimately turn out to be false alarms. To address this, we revisit the problem of specification inference from natural language in the context of automatic software verification. In the process, we introduce NL2Contract, the task of employing LLMs to translate informal natural language into formal functional contracts, consisting of postconditions as well as preconditions. We introduce metrics to validate and compare different NL2Contract approaches, using soundness, bug discriminative power of the generated contracts and their usability in the context of automatic software verification as key metrics. We evaluate NL2Contract with different LLMs and compare it to the task of postcondition generation nl2postcond. Our evaluation shows that (1) LLMs are generally effective at generating functional contracts sound for all possible inputs, (2) the generated contracts are sufficiently expressive for discriminating buggy from correct behavior, and (3) verifiers supplied with LLM inferred functional contracts produce fewer false alarms than when provided with postconditions alone. Further investigations show that LLM inferred preconditions generally align well with developers intentions which allows us to use automatic software verifiers to catch real-world bugs.
Key facts. Cited by 5 papers in the map (data through 7 Oct 2026). Builds on 16 of its 58 references that are in the map. First posted on arXiv 14 Oct 2025.
Builds on
16 of 58 references.
References · 16
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2023SWE-bench: Can Language Models Resolve Real-World GitHub Issues?cited by 3,193
- 2023Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generationcited by 1,332
- 2020Unit Test Case Generation with Transformers and Focal Contextcited by 118
- 2021TOGA: A Neural Method for Test Oracle Generationcited by 57
- 2024Enchanting Program Specification Synthesis by Large Language Models using Static Analysis and Program Verificationcited by 55
- 2023Can Large Language Models Transform Natural Language Intent into Formal Method Postconditions?cited by 53
- 2022Interactive Code Generation via Test-Driven User-Intent Formalizationcited by 50
- 2022Pynguin: Automated Unit Test Generation for Pythoncited by 49
- 2020Generating Accurate Assert Statements for Unit Test Cases using Pretrained Transformerscited by 30
- 2024TOGLL: Correct and Strong Test Oracle Generation with LLMscited by 23
- 2019CLN2INV: Learning Loop Invariants with Continuous Logic Networkscited by 20
4 more
- 2024Doc2OracLL: Investigating the Impact of Documentation on LLM-based Test Oracle Generationcited by 10
- 2025AsserT5: Test Assertion Generation Using a Fine-Tuned Code Language Modelcited by 7
- 2024ESBMC-Python: A Bounded Model Checker for Python Programscited by 4
- 2025Breaking the Myth: Can Small Models Infer Postconditions Too?cited by 1
Built on by
Citing papers per year: 2026: 5.
5 papers.
- 2026VeriContest: A Competitive-Programming Benchmark for Verifiable Code Generationcited by 1
- 2026Agentic Interpretation: Lattice-Structured Evidence for LLM-Based Program Analysiscited by 0
- 2026Viverra: Text-to-Code with Guaranteescited by 0
- 2026Partial Contracts Suffice: Sound, LLM-Inferred Regression Verificationcited by 0
- 2026Faithful Autoformalization of Natural Language Assertionscited by 0
- 2026Faithful Autoformalization of Natural Language Assertions14 Jul 2026
- 2026Partial Contracts Suffice: Sound, LLM-Inferred Regression Verification11 Jul 2026
- 2026Viverra: Text-to-Code with Guarantees14 May 2026
- 2026Agentic Interpretation: Lattice-Structured Evidence for LLM-Based Program Analysis12 May 2026
- 2026VeriContest: A Competitive-Programming Benchmark for Verifiable Code Generation8 May 2026