Ledger.lean
Lean 4 source, lean/DataMiningAsObservation/Ledger.lean at commit bccca4f. Appendix C, Machine-checked statements, says what each file proves. All Lean files.
/- Ledger.lean. Chapter 8 section 8.10 and chapter 1 section 1.5, the six ledger classes. Every headline claim carries one of six classes. A class changes only on a sealed event. A sealed miss sends the claim to refuted. A sealed pass raises an exploratory claim to demonstrated, a predicted claim to demonstrated, a demonstrated claim to replicated, and leaves replicated and proved where they are. A proof, which is not an experiment, is the only way to reach proved. This file states that rule as a function and checks the three properties the book relies on. Nothing changes without a sealed event, a sealed miss never raises a class, and a sealed pass never lowers one. -/ import Mathlib namespace DMO.Ledger /-- The six classes, in the order the book ranks them. -/ inductive Class | refuted | exploratory | predicted | demonstrated | replicated | proved deriving DecidableEq, Repr /-- The rank of a class, refuted lowest and proved highest. -/ def Class.rank : Class → ℕ | .refuted => 0 | .exploratory => 1 | .predicted => 2 | .demonstrated => 3 | .replicated => 4 | .proved => 5 /-- What can happen to a claim. -/ inductive Event | none | sealedPass | sealedMiss | proof deriving DecidableEq, Repr /-- The ledger rule. -/ def step : Class → Event → Class | c, .none => c | _, .proof => .proved | .proved, _ => .proved | _, .sealedMiss => .refuted | .exploratory, .sealedPass => .demonstrated | .predicted, .sealedPass => .demonstrated | .demonstrated, .sealedPass => .replicated | .replicated, .sealedPass => .replicated | .refuted, .sealedPass => .demonstrated /-- **Nothing changes without an event.** -/ theorem step_none (c : Class) : step c .none = c := by cases c <;> rfl /-- **A sealed miss never raises a class.** -/ theorem step_miss_le (c : Class) : (step c .sealedMiss).rank ≤ c.rank := by cases c <;> decide /-- **A sealed pass never lowers a class.** -/ theorem step_pass_ge (c : Class) : c.rank ≤ (step c .sealedPass).rank := by cases c <;> decide /-- A sealed miss on an experimental claim lands at refuted, whatever the class was. -/ theorem step_miss_refuted (c : Class) (h : c ≠ .proved) : step c .sealedMiss = .refuted := by cases c <;> first | rfl | exact absurd rfl h /-- A number without a sealed bar stays exploratory. It may motivate a claim and may not carry one. -/ theorem exploratory_stays (n : ℕ) : (Nat.iterate (fun c => step c .none) n) .exploratory = .exploratory := by induction n with | zero => rfl | succ n ih => rw [Function.iterate_succ_apply', ih]; rfl end DMO.Ledger