Part II · The Proof Engine & Gear 2 Ch 07 · 30 min · ProveIt/Ch07.lean

Unprovable on Purpose

How to read a stuck Infoview goal and triage between (A) Buggy Code, (B) False Spec, and (C) Weak Invariant.

5-Line Debugging Puzzle · Why Won't `omega` Close This Goal?
def rebalance (a b : Nat) : Nat × Nat :=
  let half := (a + b) / 2
  (half, half)
-- Attempted theorem: `(rebalance a b).1 + (rebalance a b).2 = a + b`
-- Infoview gets stuck at: `⊢ (a + b) / 2 + (a + b) / 2 = a + b`
Socratic Gate · Commit to a Prediction Unanswered · Locks on commit

Look at the stuck goal `⊢ (a + b) / 2 + (a + b) / 2 = a + b`. Why did `omega` refuse to prove it?

The 3-Way Stuck-Goal Triage Protocol

Whenever a leaf goal refuses to close, stop guessing tactics and classify it into one of three buckets: (A) Buggy Implementation (your code mishandles an edge case like odd sums, empty lists, or 0; write a #guard failing test immediately); (B) Over-Strong / Missing-Precondition Spec (the code works as designed, e.g., integer division rounds down, so the spec forgot a hypothesis like Even (a + b) or cap > 0); or (C) Weak Inductive Hypothesis (the claim is true on reachable states, yet your induction hypothesis threw away a structural link—solved in Chapter 08).

Turning Stuck Goals into `#guard` Regression Tests

A stuck Infoview goal lists the exact constraints (h1, h2, ¬h3) leading to the failure branch. Solve those constraints on paper for the smallest Nat values (0, 1, 2), run #eval on your function, and you have a concrete reproducible bug report.

⊢ ProveIt/Ch07.lean · Diagnosing & Fixing Odd-Unit Loss
Step 1 / 1
Lean Infoview Open Goal
Hands-On Exercise (ProveIt/Ch07.lean):

In `ProveIt/Ch07.lean`, diagnose three broken theorem attempts (one buggy implementation, one missing precondition, one off-by-one boundary), record `#guard` counterexamples, and prove the repaired versions.

Finished the Socratic gate, Infoview trace, and playground run?
Record completion in local browser storage to track your 20-unit progress.