Proving Functional Program Equivalence via Directed Lemma Synthesis

Yican Sun, Ruyi Ji, Jian Fang, Xuanlin Jiang, Mingshuai Chen, Yingfei Xiong · DOI

Here is a concise, engaging summary of the paper "Proving Functional Program Equivalence via Directed Lemma Synthesis".

TL;DR

Automating equivalence proofs for functional programs often stalls because standard mathematical induction isn't powerful enough without helper lemmas. This paper introduces directed lemma synthesis, a technique that uses program synthesis to automatically discover targeted lemmas that transform complex proof goals into "induction-friendly" forms. By avoiding blind lemma guessing, this approach solves significantly more verification tasks while cutting average runtime by over 95%.

What Problem Does This Paper Address?

Verifying that two functional programs behave identically (e.g., proving that sorting a list before summing it yields the same result as reversing it before summing it) is a cornerstone of software verification. Modern theorem provers rely on structural induction to reason about these programs and their Algebraic Data Types (ADTs).

However, direct induction on the main theorem frequently fails. The proof gets "stuck" because expanding the functions produces complex, nested terms that no longer match the inductive hypothesis. To break the deadlock, provers need helper lemmas. Existing tools usually find these lemmas via brute-force enumeration or machine-learning heuristics. This "directionless" guessing wastes massive amounts of time evaluating useless lemma candidates.

Methods

The authors propose AutoProof, a framework that replaces random guessing with a goal-driven strategy called directed lemma synthesis.

The core idea relies on identifying two Induction-Friendly Forms (F1 and F2)—syntactic structures of equations that mathematically guarantee structural induction will successfully apply. If a proof goal isn't induction-friendly, AutoProof applies two targeted tactics to transform it:

  1. Removing Compositions: Breaks down complex, nested function compositions into a single canonical structural recursion call on one side of the equation.
  2. Switching Recursive Arguments: Swaps the positions of variables to align mismatched recursive arguments.

To generate the exact lemma needed for these transformations, AutoProof reduces the problem to small, independent program synthesis tasks. Because structural recursions follow strict templates, an off-the-shelf program synthesizer (AutoLifter) can rapidly fill in the missing code blocks based on simple test cases.

The overall workflow is illustrated below, showing how a difficult equivalence goal is split into two induction-friendly subgoals:

Fig. 2. Workflow of AutoProof

Datasets

The authors evaluated their approach using a test suite of 270 benchmarks:

  • 248 standard benchmarks collected from established inductive reasoning datasets: CLAM, Isaplaaner, and TIP (Tons of Inductive Problems).
  • 22 new extension benchmarks created by the authors. These combine ADTs with Linear Integer Arithmetic (LIA) to evaluate how well the tool handles "mixed theories" (e.g., converting natural number types into primitive integers).

Key Insights and Ideas

  • Syntax as a Guide: Instead of treating lemma generation as a search through an infinite space of logical formulas, AutoProof uses the syntactic structure of the failed proof goal to dictate exactly what shape the helper lemma must take.
  • Divide and Conquer Synthesis: Synthesizing recursive functions from scratch is notoriously hard. However, by leveraging structural recursion templates, the authors split the synthesis problem into independent, trivial tasks for each data constructor (e.g., one small task for the nil list case, one for the cons case).
  • Theory-Agnostic Power: Because the tactics are purely syntactic, they don't care about the underlying data theories. This makes the approach uniquely effective at handling mixed-theory problems that cause traditional SMT-based solvers to choke.

Key Results

AutoProof was evaluated against Cvc4Ind, a state-of-the-art equivalence checker that uses heuristic-based lemma enumeration.

  • More Problems Solved: AutoProof successfully proved 161 benchmarks, compared to Cvc4Ind’s 123—a 30.89% increase in solved tasks.
  • Massive Speedups: On mutually solved benchmarks, AutoProof dropped the average runtime from 80.36 seconds down to just 3.64 seconds (a 95.47% time savings).
  • Mixed-Theory Dominance: On the 22 newly introduced mixed-theory extension benchmarks, Cvc4Ind only solved 3 tasks due to theory conflicts, whereas AutoProof solved 21 out of 22.

Limitations and Future Work

Despite its success, AutoProof has a few limitations:

  • Synthesizer Dependency: If the underlying program synthesizer fails to find a solution (which happened on complex exponential functions that are slow to evaluate during testing), the proof fails.
  • Canonical Restrictions: The framework currently only supports canonical structural recursions (functions that pattern-match on a single argument and keep other parameters unchanged). It cannot yet synthesize non-canonical recursions.

For future work, the authors suggest exploring how directed lemma synthesis can be adapted from functional programs to imperative programs to assist with automated invariant generation.

Summary updated

BibTeX
@inproceedings{sun2024proving,
  author = {Yican Sun and Ruyi Ji and Jian Fang and Xuanlin Jiang and Mingshuai Chen and Yingfei Xiong},
  title = {{Proving Functional Program Equivalence via Directed Lemma Synthesis}},
  booktitle = {FM (1)},
  year = {2024},
  doi = {10.1007/978-3-031-71162-6\_28},
}
Figure