lean-monad-proofs

Guide Lean 4 proofs involving Option and Except monads with tactical advice.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides expert guidance and tactical advice for navigating complex proof patterns in Lean 4, specifically when dealing with monads like Option and Except.

Core Features & Use Cases

  • Monad Proof Strategies: Offers detailed explanations and solutions for common pitfalls in Option/Except monad proofs, do-notation unfolding, and bind handling.
  • Loop Invariants: Explains how to handle for/while loops in specifications and prove properties about them, including the critical distinction between pure functions and partial definitions.
  • Use Case: When stuck on a Lean 4 proof involving Except.bind or Option.pure, consult this Skill for the precise tactic sequence or lemma to apply.

Quick Start

Use the lean-monad-proofs skill to understand how to correctly use Except.mapError in simp sets.

Frequently Asked Questions about lean-monad-proofs

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

FAQPage Schema
How do I prove properties of Lean 4 code using Option and Except monads?

Proving properties of Lean 4 Option and Except monads requires advanced tactical guidance for unfolding do-notation, handling bind operations, and resolving constructor inequalities. This provides precise tactic sequences for these specific monadic proof scenarios.

Why does nomatch fail in Lean 4 monad proofs, and how do I fix it?

nomatch failures in Lean 4 monad proofs occur when the tactic cannot resolve contradictory constructor states. You can fix this by applying specific case analysis tactics like `cases hrd : expr` to explicitly expose the contradiction.

How do I handle forIn loop invariants in the Id monad in Lean 4?

Handling forIn loop invariants in the Id monad involves proving properties across loop iterations while distinguishing between pure function definitions and partial definitions. This ensures specifications hold correctly throughout the loop execution.

What is the best way to use Except.mapError in Lean 4 simp sets?

Using Except.mapError in Lean 4 simp sets requires careful tactical placement to simplify error handling during proofs. Correctly adding it to simp sets allows automated rewriting of error-mapping operations in Except monads.

Can I use this Lean 4 tactical guidance for loop invariants in partial definitions?

This Lean 4 tactical guidance addresses loop invariants by explicitly distinguishing between pure functions and partial definitions. It provides specific solutions to prove specifications correctly depending on whether the definition is pure or partial.

How do I resolve constructor inequalities when proving Lean 4 monad properties?

Resolving constructor inequalities when proving Lean 4 monad properties involves using targeted case analysis and specific tactical sequences. This Skill offers solutions for navigating these structural inequalities during Option and Except bind operations.