Abstract
Proving the equivalence of functional programs is a fundamental challenge in formal verification, typically requiring structural induction. However, induction often fails when the induction hypothesis does not align with the syntactic structure of the goal, necessitating the discovery of intermediate lemmas. Traditional automated tools rely on heuristic lemma enumeration, which is computationally expensive and often fails to find critical helper theorems. This paper introduces Directed Lemma Synthesis, a method implemented in the tool AutoProof. By identifying specific "induction-friendly" syntactic forms and using program synthesis to transform goals into these forms, AutoProof achieves a 95% speedup over state-of-the-art solvers and demonstrates superior performance on complex, multi-theory benchmarks.
Introduction
In functional programming, verifying that two different implementations of a function are equivalent—such as proving that sum(reverse(list)) equals sum(sort(list))—is essential for optimization and correctness. The standard approach for such proofs is structural induction.
Despite its utility, structural induction frequently encounters a "matching problem." When a theorem involves a composition of functions, the Induction Hypothesis (the assumption that the theorem holds for a smaller data structure) often fails to match the structure of the transformed goal. To bridge this gap, human mathematicians synthesize lemmas—auxiliary theorems that rewrite the goal into a form where induction can proceed. Existing automated theorem provers attempt to replicate this by enumerating thousands of potential lemmas, a "guess-and-check" strategy that is both slow and prone to failure on complex tasks.
Directed Lemma Synthesis
AutoProof replaces the search-heavy enumeration strategy with a directed approach. The core insight is that a lemma's value is determined by its ability to transform a goal into a specific syntactic shape where induction is guaranteed to make progress.
Induction-Friendly Forms
The authors define two primary syntactic patterns, termed Induction-Friendly Forms, which ensure that structural induction can be applied successfully:
- Form 1 (F1): One side of the equation consists of a single call to a recursive function.
- Form 2 (F2): Both sides of the equation are single recursive calls, each operating on distinct variables.
Directed Tactics
When a proof goal does not satisfy these forms, AutoProof applies targeted tactics to synthesize the necessary lemmas:
- Tactic 1 (Composition Elimination): If a goal contains nested functions (e.g.,
f(g(xs))), the system synthesizes a new recursive functionhsuch thatf(g(xs)) = h(xs). This transforms a complex composition into a single recursive call, satisfying Form F1. - Tactic 2 (Argument Switching): If recursion occurs on an inconvenient variable, AutoProof synthesizes a lemma to swap or reorder arguments, reaching Form F2.
Synthesis via AutoLifter
To generate these helper functions and lemmas, AutoProof utilizes AutoLifter, a program synthesizer. Because the high-level structure of recursive functions is often fixed (following the data type's structure), the synthesizer only needs to discover the specific logic for the base case and the combining step. This constrained search space allows for highly efficient synthesis compared to general-purpose lemma discovery.
Experimental Evaluation
The researchers evaluated AutoProof against Cvc4Ind, a state-of-the-art solver using heuristic lemma enumeration, across a suite of 270 benchmarks.
Benchmarks
- Standard Set (248 tasks): Derived from established induction benchmarks including CLAM, Isaplanner, and TIP (Tons of Inductive Problems).
- Extension Set (22 tasks): A new set of challenges combining Algebraic Data Types (ADTs) with Linear Integer Arithmetic (LIA), representing real-world optimization scenarios.
Results
AutoProof significantly outperformed the baseline in both speed and reliability:
- Efficiency: AutoProof was 95.47% faster on average. While Cvc4Ind required an average of 80.36 seconds per task, AutoProof completed tasks in just 3.64 seconds.
- Effectiveness: AutoProof successfully solved 161 tasks, compared to 123 for Cvc4Ind.
- Theory Agnosticism: On the Extension benchmarks, which mix ADTs and math, AutoProof solved 21 out of 22 tasks, whereas the baseline solved only 3. This success stems from the fact that AutoProof’s tactics are based on program syntax rather than specific underlying theories.
Discussion and Future Work
The success of AutoProof highlights a shift from creative search to structural transformation. By defining "progress" through syntactic forms, the authors provide a roadmap for automating the most difficult parts of inductive reasoning.
However, limitations remain. The underlying synthesizer may struggle with lemmas involving high-complexity functions (e.g., exponential growth). Additionally, the current implementation focuses on Canonical Structural Recursions (CSRs) and may require further development to handle nested or mutual recursion. Future research may also explore applying these directed tactics to imperative programming to assist in the discovery of loop invariants.
Summary updated