Repair a specific proof goal at a given line using compiler-guided feedback
Repair a specific proof goal at a given line using compiler-guided feedback. Use when you know exactly which goal is failing and want focused repair without touching other parts of the file.
/plugin marketplace add cameronfreer/lean4-skills/plugin install lean4-theorem-proving@lean4-skillsRun compiler-guided repair on a specific goal at <PATH>:<LINE>.
Use when: You know exactly which goal is failing and want focused repair.
Strategy: Same as repair-file, but stops after fixing the target goal.
<PATH>: Path to Lean file (required)<LINE>: Line number of failing goal (required)--max-attempts=12: Maximum attempts (default: 12, lower than full file)--context-lines=5: Lines of context to show (default: 5)Read file to verify goal exists:
Read(<PATH>, offset=<LINE>-5, limit=10)
Extract goal via LSP (if available):
mcp__lean-lsp__lean_goal(<PATH>, <LINE>, column=0)
This gives you the precise goal state and local context.
Compile to get error:
lake build <PATH> 2> .repair/errs.txt
Verify error is at target line:
Parse error, check if error.line == <LINE>.
If not at target line:
⚠️ Target line <LINE> compiles successfully.
The actual error is at line {error.line}.
Would you like to repair line {error.line} instead? [y/N]
Same as repair-file, but with constraints:
Additional checks each iteration:
Success condition:
Stop conditions:
Success:
✅ Goal at line <LINE> repaired!
Before:
42 | theorem foo : P := by
43 | exact bar -- ❌ type mismatch
After:
42 | theorem foo : P := by
43 | convert bar using 2
44 | simp
Attempts: N
Strategy: {solver_cascade / agent_stage1 / agent_stage2}
Partial success:
⚠️ Goal at line <LINE> fixed, but file has other errors
Fixed goal:
Line <LINE>: ✓
Remaining errors:
Line 58: unsolved goals
Line 91: type mismatch
Run /lean4-theorem-proving:repair-file to fix all errors.
User runs:
/lean4-theorem-proving:repair-goal MyProof.lean 42
You execute:
Target: MyProof.lean:42
Reading goal state...
⊢ Continuous f
Compiling...
❌ type mismatch at line 42
Attempt 1/12:
Error at target: ✓
Solver cascade: ❌
Agent (Stage 1): ✓ Generated patch
Applied: ✓
Compiling...
✅ Goal at line 42 now compiles!
✅ Goal repaired successfully!
1. Interactive development
/repair-goal Foo.lean 42 for each2. Incremental fixes
3. Testing repair strategies
Prefer LSP when available:
goal_state = mcp__lean-lsp__lean_goal(<PATH>, <LINE>, 0)
This gives exact goal and context without compilation.
Focus attention:
Early exit: As soon as target line compiles, STOP. Don't continue to fix other errors.
Compiler-guided repair inspired by APOLLO (https://arxiv.org/abs/2505.05758)