arXiv:2610.29046cs.AIOct 2026

Manuscript Offprint

arXiv:2610.29046

AutoFraming: Synthesizing Dynamic Frames of C Code with LLMs

Han Zhou, Yu Luo, Dianxiang Xu

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Han Zhou

University of Missouri–Kansas City

Kansas City, USA

hzb4f@umkc.edu

Yu Luo

University of Central Missouri

Warrensburg, USA

yuluo@ucmo.edu

Dianxiang Xu

University of Missouri–Kansas City

Kansas City, USA

dxu@umkc.edu

Abstract—Large language models (LLMs) have shown considerable promise in synthesizing formal specifications from source code. However, existing approaches primarily focus on functional contracts and loop invariants, while largely neglecting frame conditions, which specify the memory locations that may or may not be modified during execution and constitute an essential part of formal specifications. To address this limitation, we propose an LLM-based approach for synthesizing ACSL frame specifications alongside functional contracts from C code. Our approach analyzes code property graphs (CPGs) to extract frame-relevant information from the input code and leverages this information to guide the LLM in generating accurate frame conditions. The resulting specifications capture both region-separation constraints and data dependencies that govern variable modifications. Experimental results demonstrate the effectiveness of our approach. On a benchmark of 84 ACSL-compliant functions from non-trivial real-world systems, our method successfully synthesizes error-free frame specifications for 92.9% of the functions, representing a 179% relative improvement over state-of-the-art techniques. On a second benchmark consisting of 51 functions, the success rate increases from 80.4% to 96.1%. Furthermore, when integrated as an auxiliary component into existing LLM-based ACSL-synthesis frameworks, our approach improves frame-specification generation performance by up to 61.9%.

Index Terms—deductive verification, frame specification, ACSL, Frama-C, code property graph, large language models, program analysis

I. INTRODUCTION

Large language models (LLMs) have recently shown strong potential for generating formal specifications from source code. For C programs, several approaches [1]−[5][1]-[5] have explored using LLMs to synthesize ACSL specifications, often with feedback from static analyzers or verification tools. These techniques can generate useful functional specifications, such as preconditions, postconditions, and loop invariants, and can substantially reduce the manual effort required for deductive verification. However, little attention has been paid to frame conditions: the part of a specification that describes what memory a function may affect, what values those effects depend on, and what memory must remain independent. Without accurate frame information, a verified function cannot be safely reused by callers, because the caller cannot know which parts of the program state are preserved.

This limitation is especially important for C programs. Recent approaches such as AutoSpec [4] and Preguss [5] push LLM-based specification generation further by combining models with program information and verification feedback. However, their treatment of frame information remains limited. They primarily optimize for whether the generated specification can help discharge verification conditions, while frame completeness is not directly measured. In particular, evaluations based mainly on WP proof success may overlook missing memory-dependence information or imprecise aliasing assumptions, because a proof can succeed even when the contract does not fully describe what state a caller may rely on after the function returns. This gap is difficult to close for C: pointers, arrays, pointer arithmetic, loops, and library calls can hide which memory regions may overlap and which input values may influence each write. As a result, a generated contract may look correct to the verifier but still be too weak for precise modular reasoning. Section II shows a small example where an apparently verified contract still permits an invalid aliased call.

To address this problem, we propose AutoFraming, an approach for synthesizing frame specifications for C programs. AutoFraming analyzes frame-relevant information from a code property graph (CPG) [6], including possible memory interference, caller-visible writes, loop-indexed write ranges, and data dependencies. It then projects this information into a fixed-frame skeleton that captures which memory regions must be kept independent and which inputs may influence each written location. The LLM is used to assemble the full contract and repair remaining verification failures, while the frame-critical structure is generated and preserved during refinement.

We evaluate AutoFraming on two benchmarks: 84 functions from real-world C systems and 51 academic verification examples. On the real-world benchmark, AutoFraming synthesizes error-free frame specifications for 92.9% of functions, a 179% relative improvement over the state-of-the-art baseline. On the academic benchmark, it improves the error-free frame rate from 80.4% to 96.1%. When used as an auxiliary frame-synthesis component for existing specification-generation tools, AutoFraming further improves error-free frame performance by up to 61.9%. Ablation results show that the CPG-derived frame information and deterministic projections are essential to the improvement.

The contribution of this paper is summarized as follows: AutoFraming provides an effective approach to the novel problem of synthesizing error-free frame conditions with LLMs. It conducts frame analysis, including caller-visible roots, access windows, interfering pointer pairs, write-set locations, and dependence footprints. It then projects frame-related information into ACSL specification, including region separation for caller-visible memory regions and data dependence for write-set locations. Moreover, AutoFraming can be used in other ACSL synthesis frameworks, such as Preguss and AutoSpec, to improve their capability of synthesizing frame conditions.

References (28)