Sorrifier

From MechMath/MechMath-agent-team · View interactive version

Sorrifier is an AI agent skill from the GitHub repository MechMath/MechMath-agent-team. Use when a complex Lean proof has a localized failing step that should be isolated manually: replace the failing subgoal with sorry, verify the file, write a helper lemma for that exact goal, and replace the placeholder with a helper call.

How to use this skill

Skill file

Sorrifier — Proof Isolation Workflow

Structural refactoring workflow for isolating broken proof steps. Replace failing logic with sorry, manually extract the subgoal into a standalone helper lemma, and reconstruct the call site so the main theorem stays readable.

Tools Used

| Tool | Skill | Purpose |

|------|-------|---------|

| python cli_tools/lean.py check FILE | verification | Diagnose compilation errors and pinpoint failing lines |

Execution Workflow

Follow these steps sequentially:

Step 1: Diagnose

Run python cli_tools/lean.py check FILE to identify failing lines.

Step 2: Inject `sorry`

Edit the Lean code: replace the failing tactic/expression with sorry.

Step 3: Verify sorrified state

Run python cli_tools/lean.py check FILE again.

Step 4: Extract a helper lemma manually

Create a helper lemma near the parent theorem:

Step 5: Final verification

Run python cli_tools/lean.py check FILE one last time.

Example

Broken state:

import Mathlib.Tactic

theorem sum_of_squares_helper (n : ℕ) : (n + 1)^2 = n^2 + 2*n + 1 := by
  have h1 : (n + 1)^2 = (n + 1) * (n + 1) := by ring
  rw [h1]
  exact magic_solve n  -- error: unknown identifier

After manual extraction:

import Mathlib.Tactic

lemma sum_of_squares_helper_lemma_1 (n : ℕ) (h1 : (n + 1) ^ 2 = (n + 1) * (n + 1)) :
  (n + 1) * (n + 1) = n ^ 2 + 2 * n + 1 := by
  sorry

theorem sum_of_squares_helper (n : ℕ) : (n + 1)^2 = n^2 + 2*n + 1 := by
  have h1 : (n + 1)^2 = (n + 1) * (n + 1) := by ring
  rw [h1]
  exact sum_of_squares_helper_lemma_1 n h1

Best Practices

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.