Lean 4 skills for Claude enable systematic development of formal proofs in Lean 4. Benefits operations teams by automating theorem proving tasks. Connects to Lean 4 environments and integrates with Claude agents.
git clone https://github.com/cameronfreer/lean4-skills.gitLean 4 skills for Claude enable systematic development of formal proofs in Lean 4. Benefits operations teams by automating theorem proving tasks. Connects to Lean 4 environments and integrates with Claude agents.
[{"step":"Identify the theorem you need to prove. Write the theorem statement in Lean 4 syntax, including any necessary imports (e.g., `import Mathlib.Data.Real.Basic`).","tip":"Use the Lean 4 VS Code extension to check syntax and get real-time feedback on errors."},{"step":"Choose the proof style and method. Decide whether to use a tactic-based proof (`by ...`), a term-based proof, or a structured proof (e.g., `begin ... end`). Specify the proof method (e.g., induction, contradiction, or direct proof).","tip":"For beginners, tactic mode is often easier. For advanced users, term mode can be more concise."},{"step":"Provide the theorem statement and constraints to the AI. Include any specific libraries, proof styles, or methods you want the AI to use. For example: 'Prove that for all natural numbers n, n + 0 = n using induction.'","tip":"Be as specific as possible about the libraries (e.g., `Mathlib`, `Std`) to ensure the AI generates compatible code."},{"step":"Review the generated proof. Check for correctness, idiomatic Lean 4 style, and compatibility with your Lean 4 environment. Test the proof with `#eval` or `#check` commands in the Lean 4 REPL or VS Code extension.","tip":"Use `#print axioms` to verify that the proof doesn't rely on non-constructive axioms like `Classical.choice` unless explicitly intended."},{"step":"Integrate the proof into your project. Copy the generated code into your Lean 4 file and ensure it compiles without errors. Use the proof in larger theorems or applications as needed.","tip":"If the proof fails to compile, check for version mismatches in the libraries or syntax errors in the theorem statement."}]
No install command available. Check the GitHub repository for manual installation instructions.
git clone https://github.com/cameronfreer/lean4-skillsCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Develop a Lean 4 proof for [THEOREM_STATEMENT] using the [TARGET_LIBRARY] library. Structure the proof with [PREFERRED_STYLE] style (e.g., tactic, term, or structured). Include comments explaining each major step. Use [PROOF_METHOD] (e.g., induction, contradiction, or direct proof) where applicable. Ensure the proof compiles in Lean 4 version [VERSION_NUMBER].
```lean4 import Mathlib.Data.Real.Basic import Mathlib.Tactic -- Theorem: For all real numbers x, x² ≥ 0 -- Proof: Using the `sq_nonneg` lemma from Mathlib /-- The square of any real number is non-negative. -/ theorem square_nonneg (x : ℝ) : x ^ 2 ≥ 0 := by -- Apply the standard library lemma for non-negativity of squares exact sq_nonneg x -- Alternative implementation using ring_nf and positivity: -- ring_nf -- positivity -- Verification: -- #eval square_nonneg 3 -- Returns true -- #eval square_nonneg (-2.5) -- Returns true -- #eval square_nonneg 0 -- Returns true ``` ### Explanation: 1. **Imports**: We use `Mathlib.Data.Real.Basic` for real number definitions and `Mathlib.Tactic` for proof tactics. 2. **Theorem Statement**: The theorem `square_nonneg` states that for any real number `x`, `x²` is greater than or equal to zero. 3. **Proof**: The proof leverages the existing `sq_nonneg` lemma from Mathlib, which is a pre-proven theorem in the standard library. This demonstrates how Lean 4 skills can reuse existing work to avoid redundant proofs. 4. **Verification**: The commented `#eval` lines show how to test the theorem with specific values. These would compile and run successfully in a Lean 4 environment. ### Key Observations: - The proof is concise because it relies on Mathlib's existing infrastructure. - The `sq_nonneg` lemma is a fundamental result, and its use here ensures correctness and efficiency. - The proof structure is idiomatic Lean 4, using the `by` tactic block for clarity. This example illustrates how Lean 4 skills can automate theorem proving by leveraging libraries and pre-existing proofs, reducing the manual effort required for formal verification.
AI assistant built for thoughtful, nuanced conversation
IronCalc is a spreadsheet engine and ecosystem
ITIL-aligned IT service management platform
Customer feedback management made simple
Enterprise workflow automation and service management platform
Automate your spreadsheet tasks with AI power
Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan