Part II · The Proof Engine & Gear 2 Ch 08 · 40 min · ProveIt/Ch08.lean

Gear 2: Inductive Invariants & Strengthening

Why true safety properties fail naive induction on 'Garden-of-Eden' states—and how invariant strengthening seals infinite runs.

5-Line Induction Paradox · A True Theorem That Cannot Prove Itself
structure CounterPair where
  issued    : Nat  -- tickets issued so far
  redeemed  : Nat  -- tickets redeemed (incremented only when redeemed < issued)
  vaultCash : Nat  -- incremented on issue, decremented on redeem
-- Safety goal: Reachable s → s.redeemed ≤ s.issued + s.vaultCash (TRUE, yet consider vaultCash ≥ 0...)
Socratic Gate · Commit to a Prediction Unanswered · Locks on commit

Suppose our fenced storage from Chapter 04 tracks `leaderEpoch`, `storageEpoch`, and `committedEpoch2 : Bool`. Safety says `Safe s := ¬s.corrupted`. Why does proving `Safe s → Step s s' → Safe s'` FAIL on its own even when the protocol is 100% bug-free?

The Three Obligations of Gear 2

To prove ∀ s, Reachable s → Safe s across infinitely many steps and unbounded Nat epochs without enumerating states, you pick a strengthened predicate Inv : State → Prop and prove three finite, step-local theorems: (1) Initiation: Init s → Inv s; (2) Consecution (Inductiveness): Inv s → Next s s' → Inv s'; and (3) Safety Entailment: Inv s → Safe s.

Think of Inv as a protective fence drawn cleanly around Reachable and strictly inside Safe (explore this live in Browser Lab 2's State-Space Funnel!).

How Stuck Consecution Tells You Exactly How to Strengthen `Inv`

Whenever Inv s → Next s s' → Inv s' gets stuck on an impossible-looking state s (like committedEpoch2 = true while storageEpoch = 0), ask: why can't the real system ever reach s? The answer (committedEpoch2 = true → storageEpoch ≥ 2) is literally the missing conjunct to add to Inv!

⊢ ProveIt/Ch08.lean · Unbounded Fenced-Storage Inductive Invariant
Step 1 / 1
Lean Infoview Open Goal
Hands-On Exercise (ProveIt/Ch08.lean):

In `ProveIt/Ch08.lean`, strengthen a naive safety invariant on a multi-epoch lease protocol and prove `∀ s, Reachable s → Safe s` across infinite runs.

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