ClassInvGen: Class Invariant Synthesis using Large Language Models
Not on the map. Why?
Abstract (arXiv)
Formal program specifications in the form of preconditions, postconditions, and class invariants have several benefits for the construction and maintenance of programs. They not only aid in program understanding due to their unambiguous semantics but can also be enforced dynamically (or even statically when the language supports a formal verifier). However, synthesizing high-quality specifications in an underlying programming language is limited by the expressivity of the specifications or the need to express them in a declarative manner. Prior work has demonstrated the potential of large language models (LLMs) for synthesizing high-quality method pre/postconditions for Python and Java, but does not consider class invariants. In this work, we describe ClassInvGen, a method for co-generating executable class invariants and test inputs to produce high-quality class invariants for a mainstream language such as C++, leveraging LLMs' ability to synthesize pure functions. We show that ClassInvGen outperforms a pure LLM-based technique to generate specifications (from code) as well as prior data-driven invariant inference techniques such as Daikon. We contribute a benchmark of standard C++ data structures along with a harness that can help measure both the correctness and completeness of generated specifications using tests and mutants. We also demonstrate its applicability to real-world code by performing a case study on several classes within a widely used and high-integrity C++ codebase.
Key facts. Cited by 11 papers in the map (data through 7 Oct 2026). Builds on 14 of its 50 references that are in the map. First posted on arXiv 26 Feb 2025.
Builds on
14 of 50 references.
References · 14
- 2023Lost in the Middle: How Language Models Use Long Contextscited by 3,383
- 2023Retrieval-Augmented Generation for Large Language Models: A Surveycited by 2,185
- 2023An Empirical Evaluation of Using Large Language Models for Automated Unit Test Generationcited by 193
- 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
- 2024SpecGen: Automated Generation of Formal Program Specifications via Large Language Modelscited by 51
- 2023Verus: Verifying Rust Programs using Linear Ghost Types (extended version)cited by 50
- 2023WhiteFox: White-Box Compiler Fuzzing Empowered by Large Language Modelscited by 37
- 2023Finding Inductive Loop Invariants using Large Language Modelscited by 35
- 2024Evaluating LLM-driven User-Intent Formalization for Verification-Aware Languagescited by 16
- 2019SLING: Using Dynamic Analysis to Infer Program Invariants in Separation Logiccited by 7
- 2022Fuzzing Class Specificationscited by 3
2 more
Built on by
Citing papers per year: 2025: 3; 2026: 8.
11 papers.
- 2025VeriStruct: AI-assisted Automated Verification of Data-Structure Modules in Veruscited by 8
- 2026Doc2Spec: Synthesizing Formal Programming Specifications from Natural Language via Grammar Inductioncited by 2
- 2025A Blueprint for AI-Driven Software Quality: Integrating LLMs with Established Standardscited by 1
- 2025Watchdogs and Oracles: Runtime Verification Meets Large Language Models for Autonomous Systemscited by 1
- 2026Intent-aligned Formal Specification Synthesis via Traceable Refinementcited by 1
- 2026Not All Invariants Are Equal: Curating Training Data to Accelerate Program Verification with SLMscited by 0
- 2026Agentic Separation Logic Specification Synthesiscited by 0
- 2026AutoACSL: Synthesizing ACSL Specifications by Integrating LLMs with CPG-Based Static Analysiscited by 0
- 2026An Empirical Study of LLM-Generated Specifications for VeriFastcited by 0
- 2026Multi-Large Language Model Orchestrated Severity Assessment of Clinical Records (MOSAIC)cited by 0
- 2026Self-Spec Verifiable Code Generationcited by 0
- 2026Self-Spec Verifiable Code Generation30 Sep 2026
- 2026Multi-Large Language Model Orchestrated Severity Assessment of Clinical Records (MOSAIC)6 Jul 2026
- 2026An Empirical Study of LLM-Generated Specifications for VeriFast25 Jun 2026
- 2026AutoACSL: Synthesizing ACSL Specifications by Integrating LLMs with CPG-Based Static Analysis18 Jun 2026
- 2026Agentic Separation Logic Specification Synthesis26 May 2026
- 2026Intent-aligned Formal Specification Synthesis via Traceable Refinement12 Apr 2026
- 2026Not All Invariants Are Equal: Curating Training Data to Accelerate Program Verification with SLMs16 Mar 2026
- 2026Doc2Spec: Synthesizing Formal Programming Specifications from Natural Language via Grammar Induction30 Jan 2026
- 2025Watchdogs and Oracles: Runtime Verification Meets Large Language Models for Autonomous Systems18 Nov 2025
- 2025VeriStruct: AI-assisted Automated Verification of Data-Structure Modules in Verus28 Oct 2025
- 2025A Blueprint for AI-Driven Software Quality: Integrating LLMs with Established Standards19 May 2025