Abstract
We present CycleQ, a novel cyclic proof system designed to automate equational reasoning for pure functional programs. CycleQ addresses the limitations of traditional automated induction, such as the need for manual induction schemes and difficulties with mutual induction. By employing a flexible contextual substitution rule and an incremental size-change verification mechanism, CycleQ efficiently proves complex properties. Evaluation on the IsaPlanner benchmark and mutual induction problems demonstrates that CycleQ is both highly performant and capable of solving problems that challenge state-of-the-art tools.
Introduction
Proving the correctness of functional programs typically involves equational reasoning—demonstrating that two expressions $A$ and $B$ are equivalent—and induction. However, traditional automated induction is notoriously difficult. Provers often require a fixed induction scheme chosen upfront or struggle with mutual induction, where multiple functions depend on each other.
Existing cyclic proof systems offer a solution: instead of a finite tree, a proof is represented as a graph with cycles. Soundness is guaranteed if every infinite path in the graph involves a "decrease" in some value (the principle of infinite descent). While powerful, previous cyclic provers were often computationally expensive or required human-provided lemmas for complex equational goals like commutativity.
Methodology
CycleQ bridges the gap between equational logic and cyclic proofs through three primary innovations:
1. Contextual Substitution (The Subst Rule)
This core innovation allows the system to use an existing node in the proof tree as a "lemma" to simplify the current goal. Unlike previous systems with restrictive matching, CycleQ’s substitution rule is flexible enough to handle complex equational identities. This allows the system to "close" a cycle even if the current goal is not an exact match for an ancestor, provided an ancestor can simplify the goal.
2. Subsuming Implicit Induction
The authors demonstrate that CycleQ encompasses several older, specialized techniques, such as "inductionless induction" and "rewriting induction." By treating equations as unoriented (unordered), CycleQ can prove symmetries that typically stymie tools relying on fixed rewrite directions.
3. Incremental Size-Change Verification
To ensure soundness, cyclic proofs must verify that every cycle eventually terminates. CycleQ utilizes Size-Change Graphs to check this condition incrementally as the proof is constructed. By restricting traces to variables, the authors transformed a potentially undecidable problem into an efficient, decidable process suitable for a compiler workflow. CycleQ is implemented as a GHC plugin, enabling Haskell developers to verify properties at compile-time.
Evaluation and Results
CycleQ was evaluated using the IsaPlanner benchmark suite (85 problems) and a custom set of mutual induction benchmarks involving recursive syntax trees.
- Performance: CycleQ solved 44 of the 85 IsaPlanner benchmarks, with 40 solved in under 100ms.
- Mutual Induction: The system solved all mutual induction problems in an average of 5.3ms.
- Efficiency Case Study: For the
butLastproperty, CycleQ found a proof in 40ms without external lemmas. In contrast, the state-of-the-art tool HipSpec required 40 seconds and attempted 22 lemmas to achieve the same result.
Discussion and Future Work
CycleQ demonstrates that a "less is more" approach—using only four basic inference rules—can lead to superior automation. However, limitations remain. The current system does not support conditional equations (e.g., "if $x > 0$"), which accounted for several unsolved benchmarks. Additionally, while CycleQ is adept at using discovered nodes as lemmas, it does not yet "invent" entirely new lemmas from scratch. Future work may involve integrating theory exploration tools to generate conjectures and expanding trace tracking beyond simple variables to handle more complex mathematical proofs.
Summary updated