text
stringlengths 0
89.3k
|
---|
benchmark in Proceedings of the 28th International Conference on
|
Computational Linguistics pp 47624772 2020miniCodeProps a Minimal Benchmark for Proving
|
Code Properties
|
Evan Lohn
|
Carnegie Mellon University
|
evanlohncmueduSean Welleck
|
Carnegie Mellon University
|
welleckscmuedu
|
Abstract
|
Neural networks have shown initial promise in automating mathematical theorem
|
proving in proof assistants such as Lean The same proof assistants can be used to
|
verify the correctness of code by pairing code with specifications and proofs that
|
the specifications hold Automating the writing of code specifications and proofs
|
could lower the cost of verification or ambitiously enable a machine learning sys
|
tem to output provably correct code However it remains unclear whether current
|
neural theorem provers can automatically verify even relatively simple programs
|
We present miniCodeProps a benchmark of 177 program specifications in the
|
Lean proof assistant aimed at the subproblem of automatically generating a proof
|
for a provided program and specification miniCodeProps contains specifications
|
about simple selfcontained programs eg lists natural numbers binary trees
|
with varied proof difficulty Despite its simplicity miniCodeProps is challenging
|
for current LLMbased provers which succeed in proving about 25 percent of the
|
specifications We publicly release miniCodeProps as a benchmark for furthering
|
automated theorem proving in the context of formally verified code
|
1 Introduction
|
Writing code that meets a specification is a desirable yet difficult task In safetycritical contexts
|
users require stronger safeguards than code reviews and test cases provide To address this need the
|
formal methods community has produced a variety of tools for specifying and proving properties
|
of code 12345 One approach uses interactive theorem provers ITPs such as Isabelle 6
|
Coq 7 and Lean 8 In an ITP a user writes code a specification and a proof that the specification
|
holds Figure 1 The ITP checks each step of the proof as it is written and a complete proof means
|
that the specification is guaranteed to hold A complete proof thus gives guarantees on the underlying
|
code which is valuable in practice For instance the Lean proof assistant was recently used to verify
|
properties of Amazons Cedar Policy language1More speculatively future code generation models
|
could in principle output provably correct code if they are able to write code specifications and
|
proofs 9
|
Despite its promise interactive theorem proving remains a difficult task and better automationbe
|
it writing specifications proofs or combinations thereofcould help make it easier to verify code
|
Recently machine learning techniques based on large language models LLMs have shown promise
|
in automatically generating code 10 proving mathematical theorems in ITPs 11 and generating
|
proofs of properties from verification projects 12 However evaluating the capabilities of LLMs for
|
program verification remains a challenge For example benchmarks often evaluate across projects
|
with complex dependencies such as the CompCert compiler or Archive of Formal Proofs 1312
|
making it difficult to isolate and reason about a models core capabilities and weaknesses
|
1httpsgithubcomcedarpolicycedarspec
|
Preprint Under reviewarXiv240611915v1 csSE 16 Jun 2024Figure 1 Formal verification of code in an interactive proof assistant here Lean consists of writing
|
i code eg an implementation of a Tree ii a property that you want to verify eg that the size of
|
a balanced tree is odd and iii a proof that the code satisfies the property The underlying language
|
verifies that the proof is correct providing certainty that the property holds miniCodeProps focuses
|
on the important subproblem of proof generation given a property and associated code a model must
|
generate a proof eg shown here in green that the property holds miniCodeProps contains 177
|
properties about simple and selfcontained code blocks and measures a range of proving abilities
|
To address this need we introduce miniCodeProps a benchmark for evaluating the ability to prove
|
properties of relatively simple selfcontained programs in the Lean proof assistant miniCodeProps
|
contains 177 specifications about simple selfcontained programs involving eg lists natural
|
numbers binary trees with varied proof difficulty sourced by translating Haskell programs from
|
Tons of Inductive Programs 14 into Lean 4 Despite its simplicity miniCodeProps is challenging
|
for current LLMbased provers For example our best baseline approach based on GPT4 proved very
|
few specifications requiring proofs longer than a few lines We publicly release miniCodeProps as
|
a benchmark for furthering automated theorem proving in the context of formally verified code2
|
2 Related Work
|
Automating mathematical theorem proving Recently there has been wide interest in automating
|
mathematical theorem proving in interactive proof assistants see 1511 for surveys A typical
|
approach 16 is to train on a large corpus of mathematical proofs such as Leans Mathlib 1718
|
192021 A model learns to call automation that is designed for mathematics such as nonlinear
|
arithmetic tactics and to use definitions and theorems from within the corpus It is unclear whether
|
such methods transfer to the distribution of proofs encountered in program verification which may
|
rely on calling different automation using programspecific definitions or lemmas or different
|
proof strategies By focusing on Lean miniCodeProps allows for testing this transferability A
|
second class of methods design prompting strategies with mathematical problems in mind such as
|
conditioning generation on an informal proof 222324 or examples from Mathlib 25 We hope
|
thatminiCodeProps motivates development of similar methods for program verification
|
Automating formal code verification There is a rich history of developing automation for formal
|
verification of code see 4 for a survey For machine learning in interactive theorem proving
|
many methods that preceded large language models focused on Coq such as ProverBot9000 26
|
ASTactic 13 TacTok 27 Diva 28 and Passport 29 Recent work with LLMs includes exploring
|
prompting strategies in Coq 30 and Baldur 12 which explores proof generation and repair in
|
Isabelles Archive of Formal Proofs We are not aware of machine learningbased proof automation
|
targeting program verification in Lean despite the activity in automated mathematical proving in
|
2Our benchmark and baselines can be found here httpshuggingfacecodatasetselohnminiCodeProps
|
2Figure 2 miniCodeProps is sourced from Tons of Inductive Problems 14 a collection of programs
|
and specifications written in Haskell We translate the programs into Lean and write and prove
|
termination lemmas that are needed to state and prove properties of recursive functions
|
Lean One of our motivations is bridging this gap Finally some methods such as COPRA 24 aim to
|
be languageagnostic miniCodeProps could participate in evaluating and developing such systems
|
A second paradigm of verification is based on automated reasoning SATSMTbased languages such
|
as Dafny 1 and Verus 5 Rust Recent work explores LLMbased automation in these languages
|
such as Clover 9 for Dafny and 31 for Verus These are complementary to studying automated
|
ITP verification Finally Tons of Inductive Problems 14from which we derive our datatargets
|
automated reasoningbased verification while miniCodeProps targets interactive theorem proving
|
Interactive theorem proving benchmarks The CoqGym 13 benchmark tests on over 100 repos
|
itories in Coq while some papers use code properties from a single large complex repository such as
|
the CompCert compiler verification project in Coq 3224 which arguably tests different aspects of
|
automated code verification than those tested by miniCodeProps In Isabelle the Archive of Formal
|
Proofs contains some verificationrelated sections that are used for evaluation eg in Baldur 12
|
Benchmarks for automated theorem proving in Lean are focused on theorems from mathematical
|
domains For example miniF2F 33 contains 488 selfcontained easytostate theorems from math
|
competitions while ProofNet 34 contains selfcontained textbook problems miniF2Fs simplicity
|
and impact as a benchmark motivated the creation and naming of miniCodeProps
|
3 Benchmark Contents
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.