All skills

Use when editing .lean files, debugging Lean 4 builds (type mismatch, sorry, failed to synthesize instance, axiom warnings, lake build errors), searching mathlib for lemmas, formalizing mathematics in Lean, finding a counterexample to, refuting, or disproving a Lean statement, or learning Lean 4 concepts. Also trigger when the user asks for help with Lean 4, mathlib, or lakefile. Do NOT trigger for Coq/Rocq, Agda, Isabelle, HOL4, Mizar, Idris, Megalodon, or other non-Lean theorem provers.

Use this Skill: https://skilld.dev/gh/cameronfreer/lean4-skills/lean4

This session only. Nothing lands on disk.

referencesproof-templates.md

≈936 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Proof Templates

Structured proof skeletons for common proof patterns.

General Theorem Template

theorem my_theorem (n : ℕ) : conclusion := by
  -- TODO: Strategy - Describe proof approach here
  -- Step 1: [Describe what needs to be shown]
  have h1 : _ := by
    sorry
    -- TODO: Prove first key property

  -- Step 2: [Describe next step]
  have h2 : _ := by
    sorry
    -- TODO: Prove second key property

  -- Step 3: Combine results
  sorry
  -- TODO: Apply h1 and h2 to conclude

Induction Template

theorem induction_example (n : ℕ) : P n := by
  induction n with
  | zero =>
    -- Base case: n = 0
    sorry
    -- TODO: Prove base case

  | succ n ih =>
    -- Inductive step: assume P(n), prove P(n+1)
    -- Inductive hypothesis: ih : P(n)
    sorry
    -- TODO: Use ih to prove P(n+1)
    -- Strategy: [Describe how to use ih]

Case Analysis Template

theorem cases_example (h : a ∨ b) : c := by
  cases h with
  | inl h_left =>
    -- Case 1: Left branch
    sorry
    -- TODO: Handle left case
    -- Available: h_left

  | inr h_right =>
    -- Case 2: Right branch
    sorry
    -- TODO: Handle right case
    -- Available: h_right

Calculation Chain Template

theorem calc_example : a = d := by
  calc a = b := by
      sorry
      -- TODO: Prove a = b
      -- Hint: [Which lemma applies?]
    _ = c := by
      sorry
      -- TODO: Prove b = c
      -- Hint: [Simplify or rewrite?]
    _ = d := by
      sorry
      -- TODO: Prove c = d
      -- Hint: [Final step]

Existential Proof Template

theorem exists_example : ∃ x, P x ∧ Q x := by
  -- Strategy: Construct witness, then prove property
  use witness_value
  -- TODO: Provide the witness value

  constructor
  · -- Prove first property
    sorry
    -- TODO: Show witness satisfies first condition

  · -- Prove second property
    sorry
    -- TODO: Show witness satisfies second condition

Strong Induction Template

theorem strong_induction (n : ℕ) : P n := by
  induction n using Nat.strong_induction_on with
  | _ n ih =>
    -- ih : ∀ m < n, P m
    sorry
    -- TODO: Use ih for all smaller values

Well-Founded Induction Template

theorem wf_induction [WellFoundedRelation α] (a : α) : P a := by
  induction a using WellFounded.induction with
  | _ a ih =>
    -- ih : ∀ b < a, P b
    sorry

If-Then-Else Template

theorem ite_example (h : if P then A else B) : C := by
  by_cases hP : P
  · -- Case: P is true
    simp only [hP, if_true] at h
    sorry
  · -- Case: P is false
    simp only [hP, if_false] at h
    sorry

Uniqueness Proof Template

theorem unique_example : ∃! x, P x := by
  use witness
  constructor
  · -- Existence: P witness
    sorry
  · -- Uniqueness: ∀ y, P y → y = witness
    intro y hy
    sorry

Equivalence Proof Template

theorem iff_example : P ↔ Q := by
  constructor
  · -- Forward: P → Q
    intro hp
    sorry
  · -- Backward: Q → P
    intro hq
    sorry

Tips for Using Templates

  1. Start with the easiest sorry - Often the base case or simple properties
  2. Fill in TODOs - Replace placeholders with actual proof steps
  3. Verify frequently — lean_diagnostic_messages(file) after each sorry; lake env lean <path/to/File.lean> for file gate (run from project root)
  4. Search before proving - Most lemmas exist in mathlib
  5. One sorry at a time - Commit after each successful fill

See Also

Source: SKILL.md on GitHub

2 warnings2d5 checks · Risk MEDIUM
  • Gen Agent Trust Hub2d

    The skill provides a specialized environment for Lean 4 theorem proving. It includes functionality for generating and executing dynamic scripts to refute mathematical statements and processes data from external sources such as PDFs and web pages, which introduces an indirect prompt injection surface.

  • Socket2d

    No alerts

  • Snyk2d

    Risk: LOW · No issues

  • Runlayer6mo

    14/36 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 818c19a. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 15 hours ago.

Activeupdated last week

README badge

README badge for cameronfreer/lean4-skills