SpecGen: Automated Generation of Formal Program Specifications via Large Language Models
Not on the map. Why?
Abstract (arXiv)
Formal program specifications play a crucial role in various stages of software development. However, manually crafting formal program specifications is rather difficult, making the job time-consuming and labor-intensive. It is even more challenging to write specifications that correctly and comprehensively describe the semantics of complex programs. To reduce the burden on software developers, automated specification generation methods have emerged. However, existing methods usually rely on predefined templates or grammar, making them struggle to accurately describe the behavior and functionality of complex real-world programs. To tackle this challenge, we introduce SpecGen, a novel technique for formal program specification generation based on Large Language Models. Our key insight is to overcome the limitations of existing methods by leveraging the code comprehension capability of LLMs. The process of SpecGen consists of two phases. The first phase employs a conversational approach that guides the LLM to generate appropriate specifications for a given program. The second phase, designed for where the LLM fails to generate correct specifications, applies four mutation operators to the model-generated specifications and selects verifiable specifications from the mutated ones through a novel heuristic selection strategy. We evaluate SpecGen on two datasets, including the SV-COMP Java category benchmark and a manually constructed dataset. Experimental results demonstrate that SpecGen succeeds in generating verifiable specifications for 279 out of 385 programs, outperforming the existing purely LLM-based approaches and conventional specification generation tools like Houdini and Daikon. Further investigations on the quality of generated specifications indicate that SpecGen can comprehensively articulate the behaviors of the input program.
Key facts. Cited by 51 papers in the map (data through 7 Oct 2026). First posted on arXiv 16 Jan 2024.
Builds on
No reference list yet.
Built on by
Citing papers per year: 2024: 6; 2025: 18; 2026: 27.
51 papers.
Sort:
By area:
- 2024Large Language Model-Based Agents for Software Engineering: A Surveycited by 173
- 2024From LLMs to LLM-based Agents for Software Engineering: A Survey of Current, Challenges and Futurecited by 85
- 2024SpecRover: Code Intent Extraction via LLMscited by 71
- 2024Automated Proof Generation for Rust Code via Self-Evolutioncited by 31
- 2025VERINA: Benchmarking Verifiable Code Generationcited by 30
- 2024The Fusion of Large Language Models and Formal Methods for Trustworthy AI Agents: A Roadmapcited by 20
- 2025Autoformalization in the Era of Large Language Models: A Surveycited by 19
- 2025ClassInvGen: Class Invariant Synthesis using Large Language Modelscited by 11
- 2026LLM-Based Agentic Systems for Software Engineering: Challenges and Opportunitiescited by 7
- 2025Beyond Correctness: Exposing LLM-generated Logical Flaws in Reasoning via Multi-step Automated Theorem Provingcited by 6
- 2026Specification-Based Code-Text-Code Reengineering for LLM-Mediated Software Evolutioncited by 5
- 2025EditLord: Learning Code Transformation Rules for Code Editingcited by 4
38 more
- 2025Requirements Development and Formalization for Reliable Code Generation: A Multi-Agent Visioncited by 3
- 2025Agentic Specification Generator for Move Programscited by 3
- 2024Generative transformations and patterns in LLM-native approaches for software verification and falsificationcited by 2
- 2025FormalSpecCpp: A Dataset of C++ Formal Specifications created using LLMscited by 2
- 2025Formalising Software Requirements using Large Language Modelscited by 2
- 2025SysMoBench: Evaluating AI on Formally Modeling Complex Real-World Systemscited by 2
- 2025Evaluating Program Semantics Reasoning with Type Inference in System Fcited by 2
- 2025Large Language Models for Software Testing: A Research Roadmapcited by 2
- 2026Doc2Spec: Synthesizing Formal Programming Specifications from Natural Language via Grammar Inductioncited by 2
- 2026FormalJudge: A Neuro-Symbolic Paradigm for Agentic Oversightcited by 2
- 2026Spec-Harness: Measuring and Improving Behavioral Adequacy of LLM-Synthesized Formal Specificationscited by 2
- 2026CodeSpecBench: Benchmarking LLMs for Executable Behavioral Specification Generationcited by 2
- 2025Goal2Story: A Multi-Agent Fleet based on Privately Enabled sLLMs for Impacting Mapping on Requirements Elicitationcited by 1
- 2025Proof2Silicon: Prompt Repair for Verified Code and Hardware Generation via Reinforcement Learningcited by 1
- 2025TREAT: A Code LLMs Trustworthiness / Reliability Evaluation and Testing Frameworkcited by 1
- 2026ModelWisdom: An Integrated Toolkit for TLA+ Model Visualization, Digest and Repaircited by 1
- 2026Can LLM Aid in Solving Constraints with Inductive Definitions?cited by 1
- 2026Intent-aligned Formal Specification Synthesis via Traceable Refinementcited by 1
- 2026Can LLMs Write Correct TLA+ Specifications? Evaluating Natural-Language-to-TLA+ Generationcited by 1
- 2026Brick-DICL: Dynamic In-Context Learning for Automated Brick Schema Classificationcited by 1
- 2025Working Document -- Formalising Software Requirements with Large Language Modelscited by 0
- 2025From Benchmark Data To Applicable Program Repair: An Experience Reportcited by 0
- 2025A Neurosymbolic Approach to Loop Invariant Generation via Weakest Precondition Reasoningcited by 0
- 2026AutoFlows++: Hierarchical Message Flow Mining for System on Chip Designscited by 0
- 2026LiveFMBench: Unveiling the Power and Limits of Agentic Workflows in Specification Generationcited by 0
- 2026Natural Language based Specification and Verificationcited by 0
- 2026BODHI: Precise OS Kernel Specification Inferencecited by 0
- 2026Agentic Separation Logic Specification Synthesiscited by 0
- 2026Code-Augur: Agentic Vulnerability Detection via Specification Inferencecited by 0
- 2026Analyzing the Narration Gap in LLM-Solver Loopscited by 0
- 2026AutoACSL: Synthesizing ACSL Specifications by Integrating LLMs with CPG-Based Static Analysiscited by 0
- 2026Diversifying to Verify: When Task-Equivalent Programs Differ in Verifiabilitycited by 0
- 2026Faithful Autoformalization of Natural Language Assertionscited by 0
- 2026How Well Can AI Generate Backlogs from App Mockups?cited by 0
- 2026Specula: Scaling formal specifications for autonomous model checking of system codecited by 0
- 2026SkillSpec: Intent-Masked Specification Reasoning for Agent Skill Correctnesscited by 0
- 2026OSFoundry: Building and Evolving Operating Systems with Specification-Guided Agentscited by 0
- 2026From Verification Failures to Reusable Guidance for Coding Agentscited by 0
50 most cited of 51 All 51 (JSON)
- 2026Self-Spec Verifiable Code Generation30 Sep 2026
- 2026From Verification Failures to Reusable Guidance for Coding Agents30 Sep 2026
- 2026SkillSpec: Intent-Masked Specification Reasoning for Agent Skill Correctness5 Sep 2026
- 2026OSFoundry: Building and Evolving Operating Systems with Specification-Guided Agents8 Aug 2026
- 2026Specula: Scaling formal specifications for autonomous model checking of system code28 Jul 2026
- 2026How Well Can AI Generate Backlogs from App Mockups?24 Jul 2026
- 2026Faithful Autoformalization of Natural Language Assertions14 Jul 2026
- 2026Diversifying to Verify: When Task-Equivalent Programs Differ in Verifiability10 Jul 2026
- 2026AutoACSL: Synthesizing ACSL Specifications by Integrating LLMs with CPG-Based Static Analysis18 Jun 2026
- 2026Analyzing the Narration Gap in LLM-Solver Loops17 Jun 2026
- 2026Code-Augur: Agentic Vulnerability Detection via Specification Inference17 Jun 2026
- 2026Brick-DICL: Dynamic In-Context Learning for Automated Brick Schema Classification16 Jun 2026
38 more
- 2026Can LLMs Write Correct TLA+ Specifications? Evaluating Natural-Language-to-TLA+ Generation4 Jun 2026
- 2026Agentic Separation Logic Specification Synthesis26 May 2026
- 2026Specification-Based Code-Text-Code Reengineering for LLM-Mediated Software Evolution24 May 2026
- 2026Natural Language based Specification and Verification11 May 2026
- 2026LiveFMBench: Unveiling the Power and Limits of Agentic Workflows in Specification Generation2 May 2026
- 2026BODHI: Precise OS Kernel Specification Inference22 Apr 2026
- 2026CodeSpecBench: Benchmarking LLMs for Executable Behavioral Specification Generation14 Apr 2026
- 2026AutoFlows++: Hierarchical Message Flow Mining for System on Chip Designs12 Apr 2026
- 2026Intent-aligned Formal Specification Synthesis via Traceable Refinement12 Apr 2026
- 2026Spec-Harness: Measuring and Improving Behavioral Adequacy of LLM-Synthesized Formal Specifications31 Mar 2026
- 2026Can LLM Aid in Solving Constraints with Inductive Definitions?4 Mar 2026
- 2026ModelWisdom: An Integrated Toolkit for TLA+ Model Visualization, Digest and Repair12 Feb 2026
- 2026FormalJudge: A Neuro-Symbolic Paradigm for Agentic Oversight11 Feb 2026
- 2026Doc2Spec: Synthesizing Formal Programming Specifications from Natural Language via Grammar Induction30 Jan 2026
- 2026LLM-Based Agentic Systems for Software Engineering: Challenges and Opportunities14 Jan 2026
- 2025Beyond Correctness: Exposing LLM-generated Logical Flaws in Reasoning via Multi-step Automated Theorem Proving29 Dec 2025
- 2025A Neurosymbolic Approach to Loop Invariant Generation via Weakest Precondition Reasoning17 Dec 2025
- 2025TREAT: A Code LLMs Trustworthiness / Reliability Evaluation and Testing Framework20 Oct 2025
- 2025Large Language Models for Software Testing: A Research Roadmap29 Sep 2025
- 2025Agentic Specification Generator for Move Programs29 Sep 2025
- 2025Evaluating Program Semantics Reasoning with Type Inference in System F28 Sep 2025
- 2025SysMoBench: Evaluating AI on Formally Modeling Complex Real-World Systems27 Sep 2025
- 2025Proof2Silicon: Prompt Repair for Verified Code and Hardware Generation via Reinforcement Learning7 Sep 2025
- 2025Requirements Development and Formalization for Reliable Code Generation: A Multi-Agent Vision26 Aug 2025
- 2025From Benchmark Data To Applicable Program Repair: An Experience Report22 Aug 2025
- 2025Working Document -- Formalising Software Requirements with Large Language Models17 Jun 2025
- 2025Formalising Software Requirements using Large Language Models12 Jun 2025
- 2025Autoformalization in the Era of Large Language Models: A Survey29 May 2025
- 2025VERINA: Benchmarking Verifiable Code Generation29 May 2025
- 2025Goal2Story: A Multi-Agent Fleet based on Privately Enabled sLLMs for Impacting Mapping on Requirements Elicitation17 Mar 2025
- 2025EditLord: Learning Code Transformation Rules for Code Editing10 Mar 2025
- 2025ClassInvGen: Class Invariant Synthesis using Large Language Models26 Feb 2025
- 2025FormalSpecCpp: A Dataset of C++ Formal Specifications created using LLMs21 Feb 2025
- 2024The Fusion of Large Language Models and Formal Methods for Trustworthy AI Agents: A Roadmap9 Dec 2024
- 2024Automated Proof Generation for Rust Code via Self-Evolution21 Oct 2024
- 2024Large Language Model-Based Agents for Software Engineering: A Survey4 Sep 2024
- 2024From LLMs to LLM-based Agents for Software Engineering: A Survey of Current, Challenges and Future5 Aug 2024
- 2024SpecRover: Code Intent Extraction via LLMs5 Aug 2024
50 newest of 51 All 51 (JSON)
- 2024Large Language Model-Based Agents for Software Engineering: A Surveycited by 173
- 2024From LLMs to LLM-based Agents for Software Engineering: A Survey of Current, Challenges and Futurecited by 85
- 2024SpecRover: Code Intent Extraction via LLMscited by 71
- 2024The Fusion of Large Language Models and Formal Methods for Trustworthy AI Agents: A Roadmapcited by 20
- 2026LLM-Based Agentic Systems for Software Engineering: Challenges and Opportunitiescited by 7
- 2025Requirements Development and Formalization for Reliable Code Generation: A Multi-Agent Visioncited by 3
- 2025Agentic Specification Generator for Move Programscited by 3
- 2026FormalJudge: A Neuro-Symbolic Paradigm for Agentic Oversightcited by 2
- 2025Goal2Story: A Multi-Agent Fleet based on Privately Enabled sLLMs for Impacting Mapping on Requirements Elicitationcited by 1
- 2026LiveFMBench: Unveiling the Power and Limits of Agentic Workflows in Specification Generationcited by 0
- 2026Agentic Separation Logic Specification Synthesiscited by 0
- 2026Code-Augur: Agentic Vulnerability Detection via Specification Inferencecited by 0
12 most cited of 14 All 14 (JSON)
- 2026From Verification Failures to Reusable Guidance for Coding Agents30 Sep 2026
- 2026OSFoundry: Building and Evolving Operating Systems with Specification-Guided Agents8 Aug 2026
- 2026Code-Augur: Agentic Vulnerability Detection via Specification Inference17 Jun 2026
- 2026Agentic Separation Logic Specification Synthesis26 May 2026
- 2026LiveFMBench: Unveiling the Power and Limits of Agentic Workflows in Specification Generation2 May 2026
- 2026FormalJudge: A Neuro-Symbolic Paradigm for Agentic Oversight11 Feb 2026
- 2026LLM-Based Agentic Systems for Software Engineering: Challenges and Opportunities14 Jan 2026
- 2025Agentic Specification Generator for Move Programs29 Sep 2025
- 2025Requirements Development and Formalization for Reliable Code Generation: A Multi-Agent Vision26 Aug 2025
- 2025Goal2Story: A Multi-Agent Fleet based on Privately Enabled sLLMs for Impacting Mapping on Requirements Elicitation17 Mar 2025
- 2024The Fusion of Large Language Models and Formal Methods for Trustworthy AI Agents: A Roadmap9 Dec 2024
- 2024Large Language Model-Based Agents for Software Engineering: A Survey4 Sep 2024
12 newest of 14 All 14 (JSON)
- 2025Beyond Correctness: Exposing LLM-generated Logical Flaws in Reasoning via Multi-step Automated Theorem Provingcited by 6
- 2025Evaluating Program Semantics Reasoning with Type Inference in System Fcited by 2
- 2025A Neurosymbolic Approach to Loop Invariant Generation via Weakest Precondition Reasoningcited by 0
- 2026Analyzing the Narration Gap in LLM-Solver Loopscited by 0
- 2026Analyzing the Narration Gap in LLM-Solver Loops17 Jun 2026
- 2025Beyond Correctness: Exposing LLM-generated Logical Flaws in Reasoning via Multi-step Automated Theorem Proving29 Dec 2025
- 2025A Neurosymbolic Approach to Loop Invariant Generation via Weakest Precondition Reasoning17 Dec 2025
- 2025Evaluating Program Semantics Reasoning with Type Inference in System F28 Sep 2025
- 2024Automated Proof Generation for Rust Code via Self-Evolutioncited by 31
- 2025VERINA: Benchmarking Verifiable Code Generationcited by 30
- 2025Autoformalization in the Era of Large Language Models: A Surveycited by 19
- 2025ClassInvGen: Class Invariant Synthesis using Large Language Modelscited by 11
- 2026Specification-Based Code-Text-Code Reengineering for LLM-Mediated Software Evolutioncited by 5
- 2025EditLord: Learning Code Transformation Rules for Code Editingcited by 4
- 2024Generative transformations and patterns in LLM-native approaches for software verification and falsificationcited by 2
- 2025FormalSpecCpp: A Dataset of C++ Formal Specifications created using LLMscited by 2
- 2025Formalising Software Requirements using Large Language Modelscited by 2
- 2025SysMoBench: Evaluating AI on Formally Modeling Complex Real-World Systemscited by 2
- 2025Large Language Models for Software Testing: A Research Roadmapcited by 2
- 2026Doc2Spec: Synthesizing Formal Programming Specifications from Natural Language via Grammar Inductioncited by 2
12 most cited of 33 All 33 (JSON)
- 2026Self-Spec Verifiable Code Generation30 Sep 2026
- 2026SkillSpec: Intent-Masked Specification Reasoning for Agent Skill Correctness5 Sep 2026
- 2026Specula: Scaling formal specifications for autonomous model checking of system code28 Jul 2026
- 2026How Well Can AI Generate Backlogs from App Mockups?24 Jul 2026
- 2026Faithful Autoformalization of Natural Language Assertions14 Jul 2026
- 2026Diversifying to Verify: When Task-Equivalent Programs Differ in Verifiability10 Jul 2026
- 2026AutoACSL: Synthesizing ACSL Specifications by Integrating LLMs with CPG-Based Static Analysis18 Jun 2026
- 2026Brick-DICL: Dynamic In-Context Learning for Automated Brick Schema Classification16 Jun 2026
- 2026Can LLMs Write Correct TLA+ Specifications? Evaluating Natural-Language-to-TLA+ Generation4 Jun 2026
- 2026Specification-Based Code-Text-Code Reengineering for LLM-Mediated Software Evolution24 May 2026
- 2026Natural Language based Specification and Verification11 May 2026
- 2026BODHI: Precise OS Kernel Specification Inference22 Apr 2026
12 newest of 33 All 33 (JSON)