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

Control Flow, Rewriting & Linear Math

Verifying real branching code cleanly with `fun_cases`, surgical `simp only`, `omega`, and `@[grind =]` / `grind`.

5-Line Maintainability Puzzle · Fragile vs. Resilient Proofs
def backoffMs (attempt cap : Nat) : Nat :=
  let raw := 100 * (attempt + 1)
  if raw <= cap then raw else cap
-- Question: How do we prove `cap ≥ 100 → backoffMs a cap ≤ cap`
-- without brittle 15-line manual case splits?
Socratic Gate · Commit to a Prediction Unanswered · Locks on commit

Why do production Lean codebases prefer `simp only [lemma1, lemma2]` and `@[grind =]` over unrestricted `simp` in the middle of a proof?

`fun_cases`: Let the Function's Own Branches Drive the Proof

Manually nested split calls lose track of let-bindings and multi-pattern match arms. Lean 4's fun_cases f x y automatically generates one goal per execution path of f x y, naming the exact branch hypotheses for you.

Closing Leaf Goals with `omega` and `grind`

Once control flow is split, most systems verification leaves boil down to linear inequalities (omega) or congruence closure + equality chaining + case splitting (grind, guided by @[grind =] annotations on domain definitions). Together, fun_cases ... <;> grind or fun_cases ... <;> omega turns 25 lines of tedious bookkeeping into 2 readable lines.

⊢ ProveIt/Ch06.lean · `fun_cases` + `omega` + `grind`
Step 1 / 1
Lean Infoview Open Goal
Hands-On Exercise (ProveIt/Ch06.lean):

In `ProveIt/Ch06.lean`, verify a multi-tier retry/circuit-breaker controller using `fun_cases`, `simp only`, `omega`, and `grind`.

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