Garlene: Guarded Recursion in Lean
Abstract
Extending the recursion principles of a formal system is an enticing but dangerous endeavour with a well-documented history of leading to consistency bugs. Nakano's guarded recursion is an elegant, type-based approach to soundly extend type theory with a powerful recursion principle. This makes guarded recursion useful for many applications, from programming with infinite structures such as streams to reasoning about advanced programming language features using synthetic guarded domain theory. Sadly, guarded recursion is not directly supported by any major interactive theorem prover, which leaves users of guarded recursion with unmechanised pen-and-paper proofs or mechanisations that depend on unmaintained theorem provers. In this paper, we present an implementation of guarded recursion as an embedded language in Lean consisting of a simply-typed lambda calculus for definitions and a higher-order logic for reasoning. Using Lean's excellent support for metaprogramming, our language allows users to write guarded recursive definitions in an intuitive syntax and to prove properties about them using a dedicated proof mode. We give our language a presheaf model, which we use to prove the soundness of our language and to allow users to export guarded recursive definitions and their theorems into standard Lean developments. To demonstrate the usefulness of our language, we present several case studies for programming and reasoning with guarded recursion.
Create a lesson
Metadata
- Categories
- cs.LO, cs.PL
Related papers
Formal Semantics and Machine-Checked Metatheory for General Fault Trees in Lean 4
Shared title terminologycs.LOAdnan Rashid
From Proof Construction to Independent Checking: Reproducing the Lean Verification of RH and Dirichlet GRH on AArch64
Shared title terminologycs.LOZoltán Gábor Molnár
ProofVMM: A Maturity Model for Auditing Lean Proofs
Shared title terminologycs.LOGustas Mickus, Linas Petkevicius
Does a Trivially True Predicate Invalidate a Kernel-Checked Proof? An Independent Build and Dependency Audit of the Alpöge Lean Archive for the Riemann Hypothesis
Shared title terminologycs.LOEryk Schiller
Composing SAT and Algebraic Certificates in Lean for End-to-End Circuit Verification
Shared title terminologycs.LODaniela Kaufmann, Pedro Saccomani
Lean-PEP: Performance-Estimation Certificates to Formally Verified Algorithmic Bounds
Shared title terminologycs.LOXinyuan Guo, Andersen Ang