Function Contracts for Bounded Model Checking of C Programs
Weiqi Wang, Marie Farrell, Liping Zhao, Lucas C. Cordeiro
Abstract
Bounded model checking unrolls a program into a single formula, so a function holding a loop costs the solver a fresh copy of that loop at every call site. Function contracts break that coupling. Verify the body once against its contract, then replace each call by a stub derived from it. CBMC supports this through dynamic frame condition checking, applied at industrial scale, but with no formal account of why the replacement is sound and no characterisation of what the frame check costs. We present the function-contract framework for ESBMC. The clause syntax, both phases, and the first assigns enforcement the tool has had are all introduced here. Its technical core is an observational frame rule: snapshot the locations the contract does not permit the function to write, then compare them at exit. The encoding emits a number of verification conditions set by how many globals the program has, not by how many writes the body performs, while dynamic frame condition checking grows with the write count. That is a property of the encoding rather than a timing, so it moves with neither the machine nor the solver. The rule itself is the classical one; what we add is its bounded form inside a BMC encoding, with the pipeline's algebraic skeleton machine-checked in Lean 4 and the limits of that model stated. We evaluate on synthetic sweeps, SV-COMP tasks, an ANSSI X.509 parser, the FreeRTOS heap1 allocator, and the ML-KEM reference implementation whose CBMC contracts we reuse unchanged. At the coefficient count FIPS-203 mandates, neither tool finishes on the monolithic route inside ten minutes, and both finish on the modular one. The framework is merged into ESBMC master. Contracts are what is left when unrolling runs out of room.
Create a lesson
Related papers
VerusEval: Evaluating LLM-Generated Verus Specifications Beyond Verifier Acceptance
Ding Wang, Chao Jiang, Dugang Liu et al.
When Coding Agents Outpace Review: Evaluating PRD-Driven Development in Mature Enterprise Repositories
Tianqi Liu, Yandong Guan, Songze Li et al.
The EBC Proportionality Law: A Recurring Architectural-Role Pattern Across Java Software
Dzikri Rahadian Fudholi, Andrea Capiluppi
SWE-Residual: Evaluating Starting-State Robustness of Coding Agents
Jinze Li, Weijie Liu, Jinfeng Xu et al.
From Finding to Fixing: How Useful is Fault Localization for Agentic Program Repair?
Xinyu Shi, Zhou Yang, An Ran Chen
What Is Under the Hood? A Cross-Ecosystem Study of Vulnerable Dependencies in Construction Software
Mahzabin Tamanna, S M Jamil Uddin