Title: Fun2spec: Code Contract Synthesis At Scale
Primary area: neurosymbolic & hybrid AI systems (physics-informed, logic & formal reasoning, etc.)
Keywords: Specification, LLM, Code Contracts, Postconditions, Software

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.