Fun2spec: Code Contract Synthesis At Scale
Shubham Ugare, Tarun Suresh, Sasa Misailovic, Julien Vanegue
ICLR 2026 submission
Abstract. Specification synthesis -- the problem of inferring program specification from program implementation -- is an undecidable problem. Therefore, machine learning and more specifically, autoregressive large language models (LLMs) are a good fit for solving this problem. We demonstrate that code contracts, the most widespread software specification mechanism, can be generated by LLMs and validated using a software testing oracle on large real-world codebases. This oracle acts as an approximate code contract verifier. It only selects LLM-generated contracts that are test-valid, guaranteeing that the obtained contracts are at least as good as the test suite provided by the program. Our tool Fun2spec is the first code contract synthesis tool applied to real-world large-scale low-level C and C++ programs of millions of lines of code, raising the state-of-the-art of automated software verification using LLMs.
Are you an author? Claim this paper to see who's reading it, with views and other statistics, and to write about it here.
Claim this paperadd · history
Loading the discussion…