lean-wf-recursion

Guide Lean 4 proofs for well-founded recursive functions with induction and termination measures.

112|9|Updated Feb 17, 2026
One-click install
npx skills add https://github.com/kim-em/lean-zip --skill lean-wf-recursion
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: lean-wf-recursion
Source: https://github.com/kim-em/lean-zip/tree/main/.claude/skills/lean-wf-recursion
Command: npx skills add https://github.com/kim-em/lean-zip --skill lean-wf-recursion

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers navigate the complexities of proving properties about well-founded recursive functions in Lean 4, a common pattern in formal verification.

Core Features & Use Cases

  • Proof Strategies: Provides guidance on unfolding WF functions, using f.induct for induction, and managing termination measures.
  • Fuel-to-WF Migration: Offers a checklist and patterns for converting older fuel-based functions to the more robust WF style.
  • Use Case: When proving a complex property about a Lean 4 function that uses well-founded recursion, consult this Skill for the correct tactics and patterns to avoid common pitfalls like infinite loops during simplification.

Quick Start

Use the lean-wf-recursion skill to understand how to unfold a well-founded recursive function named my_func in a Lean 4 proof.

Frequently Asked Questions about lean-wf-recursion

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prove properties of well-founded recursive functions in Lean 4?

To prove properties of well-founded recursive functions in Lean 4, use specific proof strategies like unfolding the functions and applying custom induction principles such as `f.induct` to manage termination measures.

What is the best way to migrate a fuel-based recursive function to well-founded recursion in Lean 4?

Migrating from fuel-based recursion to well-founded recursion in Lean 4 involves following a structured checklist to convert older functions, ensuring a more robust termination definition and simplifying subsequent property proofs.

Why does `simp` loop infinitely when unfolding well-founded recursion in Lean 4?

The `simp` tactic loops infinitely when unfolding well-founded recursion in Lean 4 if the simplification engine repeatedly triggers the recursive definition, requiring specific proof patterns to break the cycle and control the unfolding.

How do I define a termination measure for a recursive function in Lean 4?

Defining a termination measure for a recursive function in Lean 4 requires specifying a decreasing metric that the well-founded recursion mechanism can verify, ensuring the function structurally reduces its input on each recursive call.

How do I handle dependent `if` guards in well-founded recursion proofs?

Handling dependent `if` guards in well-founded recursion proofs requires careful management of the guard conditions during simplification to avoid breaking the termination measure assumptions and failing the proof.

When should I use `f.induct` instead of standard structural induction in Lean 4?

You should use `f.induct` instead of standard structural induction in Lean 4 when proving properties of well-founded recursive functions, as it directly mirrors the function's specific recursive structure and termination logic.