Imports
/-
Copyright (c) 2026 Google LLC. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
-/
module
public import Cryptids.WeakCollatz41
public import Cryptids.Semantics.WeakCollatz75
WeakCollatz27 (weak_collatz_27)
The 27-state, 2-symbol Turing machine weak_collatz_27 compresses weak_collatz_41 (41 → 27
states, -14 states / -34.15%; 75 → 41 → 27 overall, -48 states / -64.00%) while
constructively preserving blank-tape halting equivalence (candidate_equivalent, proved without
Classical.choice).
Compression Ideas (41 → 27 states)
At canonical checkpoint stageCfg x y (x ≥ 1, y ≥ 1), the tape holds only two unary
blocks 0^∞ 1^x 0 [1] 1^(y - 1) 0^∞ in state 24, with no step-counter block 1^c:
Zero-Counter Cycle-Maximum Dovetailing: Instead of maintaining and copying a third unary
counter block 1^c (tripleCfg + postDecCfg = 19 states in weak_collatz_41), stage x
aborts and advances to x + 1 whenever y = 1 (exiting the trivial {1, 2} basin) or
terras y > x (exceeding the candidate cycle maximum). Constructive finite pigeonhole shows:
Every nontrivial cycle C attains a maximum M = max C ≥ 3 whose orbit stays inside
[3, M] (3 ≤ terras^[t] M ≤ M for all t) and returns in 1 ≤ j ≤ M - 2 steps, so the
smallest such cycle maximum halts;
Conversely, if stage x ≥ 3 stayed inside [2, x - 1] for x rounds without hitting 1,
its iterates would repeat a periodic point u ≥ 3 (u = 2 hits 1 next) whose entire cycle
lies below x, contradicting absence of an earlier halting cycle maximum, even if divergent
Collatz trajectories existed.
Shared restCfg Stage-Advance Splitter: Both abort paths (y = 1 via 3-state doubler
dblCfg, and z > x via rightward 0^∞ erasure of 1^(z - x) onto the 1^(2x) block already
built during cmpCfg) feed 0^∞ [0] 1^(2(x + 1)) 0^∞ directly into restCfg 0 0 (x + 1),
splitting 1^(2(x + 1)) into stageCfg (x + 1) (x + 1) with zero copy states.
Zero-State Blank-Tape Warm-Up (53/53 Active Transitions Visited): Starting in state 0
on the blank tape enters restCfg 0 0 1 in 5 steps and naturally steps through stageCfg 1 1
(t = 18) and stageCfg 2 2 (t = 56, where 2 ↦ 1 ≠ 2 aborts at y = 1) into
stageCfg 3 3 (t = 148) without dedicated boot states, visiting all 53 non-halting cells by
step 507.
@[expose] public sectionnamespace ConjectureMachines.WeakCollatz27open Turing (Dir)open StateTransitionopen ErdosTernary15 (B0 B0_cons_zero nSteps nSteps_zero nSteps_succ nSteps_reaches
nSteps_bind_eq step_one reaches_imp_nSteps nSteps_eq_none_of_step_none)open ErdosTernary14 (ones ones_succ' ones_add)local notation "mkL" => ErdosTernary15.Tape.mkL
41-state Weak Collatz reference machine (weak_collatz_41).
abbrev reference : BundledMachine 2 := Machines.weakCollatz41.bundle
27-state Weak Collatz candidate machine (weak_collatz_27).
abbrev candidate : BundledMachine 2 := Machines.weakCollatz27.bundle
The candidate as a Machine 27 2.
abbrev weakCollatz27 : Machine 27 2 := Machines.weakCollatz27private theorem mkL_B0 (R : ListBlank (Fin 2)) : mkL B0 R = ⟨0, B0, R⟩ := rflprivate theorem ones_zero (X : ListBlank (Fin 2)) : ones 0 X = X := rflprivate theorem ones_succ (k : ℕ) (X : ListBlank (Fin 2)) : ones (k + 1) X = (ones k X).cons 1 :=
rflprivate theorem stepR {q q' : Fin 27} {a b : Fin 2}
(h : weakCollatz27.transition q a = some (b, .right, q'))
(L R : ListBlank (Fin 2)) :
step weakCollatz27 ⟨q, ⟨a, L, R⟩⟩ = some ⟨q', Tape.mk' (L.cons b) R⟩ := q:Fin 27q':Fin 27a:Fin 2b:Fin 2h:weakCollatz27.transition q a = some (b, Dir.right, q')L:ListBlank (Fin 2)R:ListBlank (Fin 2)⊢ step weakCollatz27 { state := q, tape := { head := a, left := L, right := R } } =
some { state := q', tape := Tape.mk' (ListBlank.cons b L) R }
q:Fin 27q':Fin 27a:Fin 2b:Fin 2h:weakCollatz27.transition q a = some (b, Dir.right, q')L:ListBlank (Fin 2)R:ListBlank (Fin 2)⊢ some { state := q', tape := Tape.move Dir.right (Tape.write b { head := a, left := L, right := R }) } =
some { state := q', tape := Tape.mk' (ListBlank.cons b L) R }; All goals completed! 🐙private theorem stepL {q q' : Fin 27} {a b : Fin 2}
(h : weakCollatz27.transition q a = some (b, .left, q'))
(L R : ListBlank (Fin 2)) :
step weakCollatz27 ⟨q, ⟨a, L, R⟩⟩ = some ⟨q', mkL L (R.cons b)⟩ := q:Fin 27q':Fin 27a:Fin 2b:Fin 2h:weakCollatz27.transition q a = some (b, Dir.left, q')L:ListBlank (Fin 2)R:ListBlank (Fin 2)⊢ step weakCollatz27 { state := q, tape := { head := a, left := L, right := R } } =
some { state := q', tape := mkL L (ListBlank.cons b R) }
q:Fin 27q':Fin 27a:Fin 2b:Fin 2h:weakCollatz27.transition q a = some (b, Dir.left, q')L:ListBlank (Fin 2)R:ListBlank (Fin 2)⊢ some { state := q', tape := Tape.move Dir.left (Tape.write b { head := a, left := L, right := R }) } =
some { state := q', tape := mkL L (ListBlank.cons b R) }; All goals completed! 🐙Transition Table
private theorem tr0_0 (L R) :
step weakCollatz27 ⟨0, ⟨0, L, R⟩⟩ = some ⟨2, Tape.mk' (L.cons 1) R⟩ := stepR rfl L Rprivate theorem tr0_1 (L R) :
step weakCollatz27 ⟨0, ⟨1, L, R⟩⟩ = some ⟨0, Tape.mk' (L.cons 0) R⟩ := stepR rfl L Rprivate theorem tr1_0 (L R) :
step weakCollatz27 ⟨1, ⟨0, L, R⟩⟩ = some ⟨5, Tape.mk' (L.cons 0) R⟩ := stepR rfl L Rprivate theorem tr1_1 (L R) :
step weakCollatz27 ⟨1, ⟨1, L, R⟩⟩ = some ⟨0, Tape.mk' (L.cons 0) R⟩ := stepR rfl L Rprivate theorem tr2_0 (L R) : step weakCollatz27 ⟨2, ⟨0, L, R⟩⟩ = some ⟨3, mkL L (R.cons 1)⟩ :=
stepL rfl L Rprivate theorem tr2_1 (L R) :
step weakCollatz27 ⟨2, ⟨1, L, R⟩⟩ = some ⟨2, Tape.mk' (L.cons 1) R⟩ := stepR rfl L Rprivate theorem tr3_0 (L R) : step weakCollatz27 ⟨3, ⟨0, L, R⟩⟩ = some ⟨1, mkL L (R.cons 0)⟩ :=
stepL rfl L Rprivate theorem tr3_1 (L R) : step weakCollatz27 ⟨3, ⟨1, L, R⟩⟩ = some ⟨3, mkL L (R.cons 1)⟩ :=
stepL rfl L Rprivate theorem tr4_0 (L R) :
step weakCollatz27 ⟨4, ⟨0, L, R⟩⟩ = some ⟨22, Tape.mk' (L.cons 1) R⟩ := stepR rfl L Rprivate theorem tr4_1 (L R) : step weakCollatz27 ⟨4, ⟨1, L, R⟩⟩ = some ⟨4, mkL L (R.cons 1)⟩ :=
stepL rfl L Rprivate theorem tr5_0 (L R) :
step weakCollatz27 ⟨5, ⟨0, L, R⟩⟩ = some ⟨6, Tape.mk' (L.cons 1) R⟩ := stepR rfl L Rprivate theorem tr5_1 (L R) :
step weakCollatz27 ⟨5, ⟨1, L, R⟩⟩ = some ⟨5, Tape.mk' (L.cons 1) R⟩ := stepR rfl L Rprivate theorem tr6_0 (L R) : step weakCollatz27 ⟨6, ⟨0, L, R⟩⟩ = some ⟨19, mkL L (R.cons 0)⟩ :=
stepL rfl L Rprivate theorem tr6_1 (L R) :
step weakCollatz27 ⟨6, ⟨1, L, R⟩⟩ = some ⟨23, Tape.mk' (L.cons 1) R⟩ := stepR rfl L Rprivate theorem tr7_0 (L R) :
step weakCollatz27 ⟨7, ⟨0, L, R⟩⟩ = some ⟨24, Tape.mk' (L.cons 0) R⟩ := stepR rfl L Rprivate theorem tr7_1 (L R) : step weakCollatz27 ⟨7, ⟨1, L, R⟩⟩ = some ⟨7, mkL L (R.cons 1)⟩ :=
stepL rfl L Rprivate theorem tr8_0 (L R) : step weakCollatz27 ⟨8, ⟨0, L, R⟩⟩ = some ⟨3, mkL L (R.cons 1)⟩ :=
stepL rfl L Rprivate theorem tr8_1 (L R) :
step weakCollatz27 ⟨8, ⟨1, L, R⟩⟩ = some ⟨9, Tape.mk' (L.cons 0) R⟩ := stepR rfl L Rprivate theorem tr9_0 (L R) : step weakCollatz27 ⟨9, ⟨0, L, R⟩⟩ = some ⟨10, mkL L (R.cons 0)⟩ :=
stepL rfl L Rprivate theorem tr9_1 (L R) :
step weakCollatz27 ⟨9, ⟨1, L, R⟩⟩ = some ⟨9, Tape.mk' (L.cons 1) R⟩ := stepR rfl L Rprivate theorem tr10_0 (L R) : step weakCollatz27 ⟨10, ⟨0, L, R⟩⟩ = some ⟨16, mkL L (R.cons 0)⟩ :=
stepL rfl L Rprivate theorem tr10_1 (L R) : step weakCollatz27 ⟨10, ⟨1, L, R⟩⟩ = some ⟨11, mkL L (R.cons 0)⟩ :=
stepL rfl L Rprivate theorem tr11_0 (L R) :
step weakCollatz27 ⟨11, ⟨0, L, R⟩⟩ = some ⟨25, Tape.mk' (L.cons 0) R⟩ := stepR rfl L Rprivate theorem tr11_1 (L R) : step weakCollatz27 ⟨11, ⟨1, L, R⟩⟩ = some ⟨12, mkL L (R.cons 1)⟩ :=
stepL rfl L Rprivate theorem tr12_0 (L R) :
step weakCollatz27 ⟨12, ⟨0, L, R⟩⟩ = some ⟨8, Tape.mk' (L.cons 1) R⟩ := stepR rfl L Rprivate theorem tr12_1 (L R) : step weakCollatz27 ⟨12, ⟨1, L, R⟩⟩ = some ⟨12, mkL L (R.cons 1)⟩ :=
stepL rfl L Rprivate theorem tr13_0 (L R) :
step weakCollatz27 ⟨13, ⟨0, L, R⟩⟩ = some ⟨26, Tape.mk' (L.cons 0) R⟩ := stepR rfl L Rprivate theorem tr13_1 (L R) :
step weakCollatz27 ⟨13, ⟨1, L, R⟩⟩ = some ⟨24, Tape.mk' (L.cons 0) R⟩ := stepR rfl L Rprivate theorem tr14_0 (L R) :
step weakCollatz27 ⟨14, ⟨0, L, R⟩⟩ = some ⟨25, Tape.mk' (L.cons 1) R⟩ := stepR rfl L Rprivate theorem tr14_1 (L R) :
step weakCollatz27 ⟨14, ⟨1, L, R⟩⟩ = some ⟨14, Tape.mk' (L.cons 1) R⟩ := stepR rfl L Rprivate theorem tr15_0 (L R) : step weakCollatz27 ⟨15, ⟨0, L, R⟩⟩ = some ⟨13, mkL L (R.cons 0)⟩ :=
stepL rfl L Rprivate theorem tr15_1 (L R) : step weakCollatz27 ⟨15, ⟨1, L, R⟩⟩ = some ⟨15, mkL L (R.cons 1)⟩ :=
stepL rfl L Rprivate theorem tr16_0 (L R) : step weakCollatz27 ⟨16, ⟨0, L, R⟩⟩ = some ⟨18, mkL L (R.cons 0)⟩ :=
stepL rfl L Rprivate theorem tr16_1 (L R) : step weakCollatz27 ⟨16, ⟨1, L, R⟩⟩ = some ⟨17, mkL L (R.cons 1)⟩ :=
stepL rfl L Rprivate theorem tr17_0 (L R) : step weakCollatz27 ⟨17, ⟨0, L, R⟩⟩ = some ⟨20, mkL L (R.cons 0)⟩ :=
stepL rfl L Rprivate theorem tr17_1 (L R) : step weakCollatz27 ⟨17, ⟨1, L, R⟩⟩ = some ⟨17, mkL L (R.cons 1)⟩ :=
stepL rfl L Rprivate theorem tr18_0 (L R : ListBlank (Fin 2)) : step weakCollatz27 ⟨18, ⟨0, L, R⟩⟩ = none := rflprivate theorem tr18_1 (L R) :
step weakCollatz27 ⟨18, ⟨1, L, R⟩⟩ = some ⟨19, Tape.mk' (L.cons 1) R⟩ := stepR rfl L Rprivate theorem tr19_0 (L R) :
step weakCollatz27 ⟨19, ⟨0, L, R⟩⟩ = some ⟨5, Tape.mk' (L.cons 0) R⟩ := stepR rfl L Rprivate theorem tr19_1 (L R) : step weakCollatz27 ⟨19, ⟨1, L, R⟩⟩ = some ⟨7, mkL L (R.cons 0)⟩ :=
stepL rfl L Rprivate theorem tr20_0 (L R) :
step weakCollatz27 ⟨20, ⟨0, L, R⟩⟩ = some ⟨22, Tape.mk' (L.cons 0) R⟩ := stepR rfl L Rprivate theorem tr20_1 (L R) :
step weakCollatz27 ⟨20, ⟨1, L, R⟩⟩ = some ⟨23, Tape.mk' (L.cons 0) R⟩ := stepR rfl L Rprivate theorem tr21_0 (L R) : step weakCollatz27 ⟨21, ⟨0, L, R⟩⟩ = some ⟨25, mkL L (R.cons 1)⟩ :=
stepL rfl L Rprivate theorem tr21_1 (L R) :
step weakCollatz27 ⟨21, ⟨1, L, R⟩⟩ = some ⟨21, Tape.mk' (L.cons 1) R⟩ := stepR rfl L Rprivate theorem tr22_0 (L R) :
step weakCollatz27 ⟨22, ⟨0, L, R⟩⟩ = some ⟨0, Tape.mk' (L.cons 0) R⟩ := stepR rfl L Rprivate theorem tr22_1 (L R) :
step weakCollatz27 ⟨22, ⟨1, L, R⟩⟩ = some ⟨5, Tape.mk' (L.cons 0) R⟩ := stepR rfl L Rprivate theorem tr23_0 (L R) :
step weakCollatz27 ⟨23, ⟨0, L, R⟩⟩ = some ⟨21, Tape.mk' (L.cons 1) R⟩ := stepR rfl L Rprivate theorem tr23_1 (L R) : step weakCollatz27 ⟨23, ⟨1, L, R⟩⟩ = some ⟨4, mkL L (R.cons 0)⟩ :=
stepL rfl L Rprivate theorem tr24_0 (L R) :
step weakCollatz27 ⟨24, ⟨0, L, R⟩⟩ = some ⟨14, Tape.mk' (L.cons 1) R⟩ := stepR rfl L Rprivate theorem tr24_1 (L R) :
step weakCollatz27 ⟨24, ⟨1, L, R⟩⟩ = some ⟨8, Tape.mk' (L.cons 1) R⟩ := stepR rfl L Rprivate theorem tr25_0 (L R) : step weakCollatz27 ⟨25, ⟨0, L, R⟩⟩ = some ⟨15, mkL L (R.cons 1)⟩ :=
stepL rfl L Rprivate theorem tr25_1 (L R) : step weakCollatz27 ⟨25, ⟨1, L, R⟩⟩ = some ⟨26, mkL L (R.cons 1)⟩ :=
stepL rfl L Rprivate theorem tr26_0 (L R) : step weakCollatz27 ⟨26, ⟨0, L, R⟩⟩ = some ⟨17, mkL L (R.cons 1)⟩ :=
stepL rfl L Rprivate theorem tr26_1 (L R) : step weakCollatz27 ⟨26, ⟨1, L, R⟩⟩ = some ⟨16, mkL L (R.cons 0)⟩ :=
stepL rfl L RSweep & Reachability Combinators
private def reachPos (c₁ c₂ : Cfg 27 2) : Prop :=
∃ s : ℕ, 1 ≤ s ∧ nSteps weakCollatz27 s c₁ = some c₂private theorem reachPos_step {c₁ c₂ : Cfg 27 2}
(h : step weakCollatz27 c₁ = some c₂) : reachPos c₁ c₂ :=
⟨1, le_rfl, step_one h⟩private theorem reachPos_trans {c₁ c₂ c₃ : Cfg 27 2}
(h₁ : reachPos c₁ c₂) (h₂ : reachPos c₂ c₃) : reachPos c₁ c₃ := c₁:Cfg 27 2c₂:Cfg 27 2c₃:Cfg 27 2h₁:reachPos c₁ c₂h₂:reachPos c₂ c₃⊢ reachPos c₁ c₃
c₁:Cfg 27 2c₂:Cfg 27 2c₃:Cfg 27 2h₂:reachPos c₂ c₃s₁:ℕhs₁:1 ≤ s₁heq₁:nSteps weakCollatz27 s₁ c₁ = some c₂⊢ reachPos c₁ c₃
c₁:Cfg 27 2c₂:Cfg 27 2c₃:Cfg 27 2s₁:ℕhs₁:1 ≤ s₁heq₁:nSteps weakCollatz27 s₁ c₁ = some c₂s₂:ℕhs₂:1 ≤ s₂heq₂:nSteps weakCollatz27 s₂ c₂ = some c₃⊢ reachPos c₁ c₃
exact ⟨s₁ + s₂, c₁:Cfg 27 2c₂:Cfg 27 2c₃:Cfg 27 2s₁:ℕhs₁:1 ≤ s₁heq₁:nSteps weakCollatz27 s₁ c₁ = some c₂s₂:ℕhs₂:1 ≤ s₂heq₂:nSteps weakCollatz27 s₂ c₂ = some c₃⊢ 1 ≤ s₁ + s₂ All goals completed! 🐙, nSteps_bind_eq heq₁ heq₂⟩private theorem step_then_reachPos {c₁ c₂ c₃ : Cfg 27 2}
(h₁ : step weakCollatz27 c₁ = some c₂) (h₂ : reachPos c₂ c₃) : reachPos c₁ c₃ :=
reachPos_trans (reachPos_step h₁) h₂private theorem nSteps_then_reachPos {k : ℕ} {c₁ c₂ c₃ : Cfg 27 2}
(h₁ : nSteps weakCollatz27 k c₁ = some c₂) (h₂ : reachPos c₂ c₃) : reachPos c₁ c₃ := k:ℕc₁:Cfg 27 2c₂:Cfg 27 2c₃:Cfg 27 2h₁:nSteps weakCollatz27 k c₁ = some c₂h₂:reachPos c₂ c₃⊢ reachPos c₁ c₃
k:ℕc₁:Cfg 27 2c₂:Cfg 27 2c₃:Cfg 27 2h₁:nSteps weakCollatz27 k c₁ = some c₂s:ℕhs:1 ≤ sheq:nSteps weakCollatz27 s c₂ = some c₃⊢ reachPos c₁ c₃
exact ⟨k + s, k:ℕc₁:Cfg 27 2c₂:Cfg 27 2c₃:Cfg 27 2h₁:nSteps weakCollatz27 k c₁ = some c₂s:ℕhs:1 ≤ sheq:nSteps weakCollatz27 s c₂ = some c₃⊢ 1 ≤ k + s All goals completed! 🐙, nSteps_bind_eq h₁ heq⟩private theorem reachPos_then_nSteps {k : ℕ} {c₁ c₂ c₃ : Cfg 27 2}
(h₁ : reachPos c₁ c₂) (h₂ : nSteps weakCollatz27 k c₂ = some c₃) : reachPos c₁ c₃ := k:ℕc₁:Cfg 27 2c₂:Cfg 27 2c₃:Cfg 27 2h₁:reachPos c₁ c₂h₂:nSteps weakCollatz27 k c₂ = some c₃⊢ reachPos c₁ c₃
k:ℕc₁:Cfg 27 2c₂:Cfg 27 2c₃:Cfg 27 2h₂:nSteps weakCollatz27 k c₂ = some c₃s:ℕhs:1 ≤ sheq:nSteps weakCollatz27 s c₁ = some c₂⊢ reachPos c₁ c₃
exact ⟨s + k, k:ℕc₁:Cfg 27 2c₂:Cfg 27 2c₃:Cfg 27 2h₂:nSteps weakCollatz27 k c₂ = some c₃s:ℕhs:1 ≤ sheq:nSteps weakCollatz27 s c₁ = some c₂⊢ 1 ≤ s + k All goals completed! 🐙, nSteps_bind_eq heq h₂⟩private theorem sweep1R {q : Fin 27}
(h : ∀ L R, step weakCollatz27 ⟨q, ⟨1, L, R⟩⟩ = some ⟨q, Tape.mk' (L.cons 1) R⟩)
(k : ℕ) (L R : ListBlank (Fin 2)) :
nSteps weakCollatz27 k ⟨q, Tape.mk' L (ones k R)⟩ = some ⟨q, Tape.mk' (ones k L) R⟩ := q:Fin 27h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz27 { state := q, tape := { head := 1, left := L, right := R } } =
some { state := q, tape := Tape.mk' (ListBlank.cons 1 L) R }k:ℕL:ListBlank (Fin 2)R:ListBlank (Fin 2)⊢ nSteps weakCollatz27 k { state := q, tape := Tape.mk' L (ones k R) } =
some { state := q, tape := Tape.mk' (ones k L) R }
induction k generalizing L with
q:Fin 27h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz27 { state := q, tape := { head := 1, left := L, right := R } } =
some { state := q, tape := Tape.mk' (ListBlank.cons 1 L) R }R:ListBlank (Fin 2)L:ListBlank (Fin 2)⊢ nSteps weakCollatz27 0 { state := q, tape := Tape.mk' L (ones 0 R) } =
some { state := q, tape := Tape.mk' (ones 0 L) R } All goals completed! 🐙
q:Fin 27h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz27 { state := q, tape := { head := 1, left := L, right := R } } =
some { state := q, tape := Tape.mk' (ListBlank.cons 1 L) R }R:ListBlank (Fin 2)k:ℕih:∀ (L : ListBlank (Fin 2)),
nSteps weakCollatz27 k { state := q, tape := Tape.mk' L (ones k R) } =
some { state := q, tape := Tape.mk' (ones k L) R }L:ListBlank (Fin 2)⊢ nSteps weakCollatz27 (k + 1) { state := q, tape := Tape.mk' L (ones (k + 1) R) } =
some { state := q, tape := Tape.mk' (ones (k + 1) L) R }
All goals completed! 🐙private theorem sweep1L {q : Fin 27}
(h : ∀ L R, step weakCollatz27 ⟨q, ⟨1, L, R⟩⟩ = some ⟨q, mkL L (R.cons 1)⟩)
(k : ℕ) (L R : ListBlank (Fin 2)) :
nSteps weakCollatz27 k ⟨q, mkL (ones k L) R⟩ = some ⟨q, mkL L (ones k R)⟩ := by q:Fin 27h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz27 { state := q, tape := { head := 1, left := L, right := R } } =
some { state := q, tape := mkL L (ListBlank.cons 1 R) }k:ℕL:ListBlank (Fin 2)R:ListBlank (Fin 2)⊢ nSteps weakCollatz27 k { state := q, tape := mkL (ones k L) R } = some { state := q, tape := mkL L (ones k R) }
induction k generalizing R with
| zero => zero q:Fin 27h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz27 { state := q, tape := { head := 1, left := L, right := R } } =
some { state := q, tape := mkL L (ListBlank.cons 1 R) }L:ListBlank (Fin 2)R:ListBlank (Fin 2)⊢ nSteps weakCollatz27 0 { state := q, tape := mkL (ones 0 L) R } = some { state := q, tape := mkL L (ones 0 R) } rfl All goals completed! 🐙
| succ k ih => succ q:Fin 27h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz27 { state := q, tape := { head := 1, left := L, right := R } } =
some { state := q, tape := mkL L (ListBlank.cons 1 R) }L:ListBlank (Fin 2)k:ℕih:∀ (R : ListBlank (Fin 2)),
nSteps weakCollatz27 k { state := q, tape := mkL (ones k L) R } = some { state := q, tape := mkL L (ones k R) }R:ListBlank (Fin 2)⊢ nSteps weakCollatz27 (k + 1) { state := q, tape := mkL (ones (k + 1) L) R } =
some { state := q, tape := mkL L (ones (k + 1) R) }
rw [nSteps_succ, succ q:Fin 27h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz27 { state := q, tape := { head := 1, left := L, right := R } } =
some { state := q, tape := mkL L (ListBlank.cons 1 R) }L:ListBlank (Fin 2)k:ℕih:∀ (R : ListBlank (Fin 2)),
nSteps weakCollatz27 k { state := q, tape := mkL (ones k L) R } = some { state := q, tape := mkL L (ones k R) }R:ListBlank (Fin 2)⊢ (step weakCollatz27 { state := q, tape := mkL (ones (k + 1) L) R }).bind (nSteps weakCollatz27 k) =
some { state := q, tape := mkL L (ones (k + 1) R) } ones_succ, succ q:Fin 27h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz27 { state := q, tape := { head := 1, left := L, right := R } } =
some { state := q, tape := mkL L (ListBlank.cons 1 R) }L:ListBlank (Fin 2)k:ℕih:∀ (R : ListBlank (Fin 2)),
nSteps weakCollatz27 k { state := q, tape := mkL (ones k L) R } = some { state := q, tape := mkL L (ones k R) }R:ListBlank (Fin 2)⊢ (step weakCollatz27 { state := q, tape := mkL (ListBlank.cons 1 (ones k L)) R }).bind (nSteps weakCollatz27 k) =
some { state := q, tape := mkL L (ones (k + 1) R) } ErdosTernary15.Tape.mkL_cons, succ q:Fin 27h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz27 { state := q, tape := { head := 1, left := L, right := R } } =
some { state := q, tape := mkL L (ListBlank.cons 1 R) }L:ListBlank (Fin 2)k:ℕih:∀ (R : ListBlank (Fin 2)),
nSteps weakCollatz27 k { state := q, tape := mkL (ones k L) R } = some { state := q, tape := mkL L (ones k R) }R:ListBlank (Fin 2)⊢ (step weakCollatz27 { state := q, tape := { head := 1, left := ones k L, right := R } }).bind (nSteps weakCollatz27 k) =
some { state := q, tape := mkL L (ones (k + 1) R) } h, succ q:Fin 27h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz27 { state := q, tape := { head := 1, left := L, right := R } } =
some { state := q, tape := mkL L (ListBlank.cons 1 R) }L:ListBlank (Fin 2)k:ℕih:∀ (R : ListBlank (Fin 2)),
nSteps weakCollatz27 k { state := q, tape := mkL (ones k L) R } = some { state := q, tape := mkL L (ones k R) }R:ListBlank (Fin 2)⊢ (some { state := q, tape := mkL (ones k L) (ListBlank.cons 1 R) }).bind (nSteps weakCollatz27 k) =
some { state := q, tape := mkL L (ones (k + 1) R) } Option.bind_some, succ q:Fin 27h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz27 { state := q, tape := { head := 1, left := L, right := R } } =
some { state := q, tape := mkL L (ListBlank.cons 1 R) }L:ListBlank (Fin 2)k:ℕih:∀ (R : ListBlank (Fin 2)),
nSteps weakCollatz27 k { state := q, tape := mkL (ones k L) R } = some { state := q, tape := mkL L (ones k R) }R:ListBlank (Fin 2)⊢ nSteps weakCollatz27 k { state := q, tape := mkL (ones k L) (ListBlank.cons 1 R) } =
some { state := q, tape := mkL L (ones (k + 1) R) } ih, succ q:Fin 27h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz27 { state := q, tape := { head := 1, left := L, right := R } } =
some { state := q, tape := mkL L (ListBlank.cons 1 R) }L:ListBlank (Fin 2)k:ℕih:∀ (R : ListBlank (Fin 2)),
nSteps weakCollatz27 k { state := q, tape := mkL (ones k L) R } = some { state := q, tape := mkL L (ones k R) }R:ListBlank (Fin 2)⊢ some { state := q, tape := mkL L (ones k (ListBlank.cons 1 R)) } = some { state := q, tape := mkL L (ones (k + 1) R) } ones_succ' succ q:Fin 27h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz27 { state := q, tape := { head := 1, left := L, right := R } } =
some { state := q, tape := mkL L (ListBlank.cons 1 R) }L:ListBlank (Fin 2)k:ℕih:∀ (R : ListBlank (Fin 2)),
nSteps weakCollatz27 k { state := q, tape := mkL (ones k L) R } = some { state := q, tape := mkL L (ones k R) }R:ListBlank (Fin 2)⊢ some { state := q, tape := mkL L (ones k (ListBlank.cons 1 R)) } =
some { state := q, tape := mkL L (ones k (ListBlank.cons 1 R)) }] All goals completed! 🐙private theorem erase1R {q : Fin 27}
(h : ∀ L R, step weakCollatz27 ⟨q, ⟨1, L, R⟩⟩ = some ⟨q, Tape.mk' (L.cons 0) R⟩)
(k : ℕ) (R : ListBlank (Fin 2)) :
nSteps weakCollatz27 k ⟨q, Tape.mk' B0 (ones k R)⟩ = some ⟨q, Tape.mk' B0 R⟩ := by q:Fin 27h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz27 { state := q, tape := { head := 1, left := L, right := R } } =
some { state := q, tape := Tape.mk' (ListBlank.cons 0 L) R }k:ℕR:ListBlank (Fin 2)⊢ nSteps weakCollatz27 k { state := q, tape := Tape.mk' B0 (ones k R) } = some { state := q, tape := Tape.mk' B0 R }
induction k with
| zero => zero q:Fin 27h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz27 { state := q, tape := { head := 1, left := L, right := R } } =
some { state := q, tape := Tape.mk' (ListBlank.cons 0 L) R }R:ListBlank (Fin 2)⊢ nSteps weakCollatz27 0 { state := q, tape := Tape.mk' B0 (ones 0 R) } = some { state := q, tape := Tape.mk' B0 R } rfl All goals completed! 🐙
| succ k ih => succ q:Fin 27h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz27 { state := q, tape := { head := 1, left := L, right := R } } =
some { state := q, tape := Tape.mk' (ListBlank.cons 0 L) R }R:ListBlank (Fin 2)k:ℕih:nSteps weakCollatz27 k { state := q, tape := Tape.mk' B0 (ones k R) } = some { state := q, tape := Tape.mk' B0 R }⊢ nSteps weakCollatz27 (k + 1) { state := q, tape := Tape.mk' B0 (ones (k + 1) R) } =
some { state := q, tape := Tape.mk' B0 R }
rw [nSteps_succ, succ q:Fin 27h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz27 { state := q, tape := { head := 1, left := L, right := R } } =
some { state := q, tape := Tape.mk' (ListBlank.cons 0 L) R }R:ListBlank (Fin 2)k:ℕih:nSteps weakCollatz27 k { state := q, tape := Tape.mk' B0 (ones k R) } = some { state := q, tape := Tape.mk' B0 R }⊢ (step weakCollatz27 { state := q, tape := Tape.mk' B0 (ones (k + 1) R) }).bind (nSteps weakCollatz27 k) =
some { state := q, tape := Tape.mk' B0 R } ones_succ, succ q:Fin 27h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz27 { state := q, tape := { head := 1, left := L, right := R } } =
some { state := q, tape := Tape.mk' (ListBlank.cons 0 L) R }R:ListBlank (Fin 2)k:ℕih:nSteps weakCollatz27 k { state := q, tape := Tape.mk' B0 (ones k R) } = some { state := q, tape := Tape.mk' B0 R }⊢ (step weakCollatz27 { state := q, tape := Tape.mk' B0 (ListBlank.cons 1 (ones k R)) }).bind (nSteps weakCollatz27 k) =
some { state := q, tape := Tape.mk' B0 R } ErdosTernary15.Tape.mk'_cons, succ q:Fin 27h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz27 { state := q, tape := { head := 1, left := L, right := R } } =
some { state := q, tape := Tape.mk' (ListBlank.cons 0 L) R }R:ListBlank (Fin 2)k:ℕih:nSteps weakCollatz27 k { state := q, tape := Tape.mk' B0 (ones k R) } = some { state := q, tape := Tape.mk' B0 R }⊢ (step weakCollatz27 { state := q, tape := { head := 1, left := B0, right := ones k R } }).bind
(nSteps weakCollatz27 k) =
some { state := q, tape := Tape.mk' B0 R } h, succ q:Fin 27h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz27 { state := q, tape := { head := 1, left := L, right := R } } =
some { state := q, tape := Tape.mk' (ListBlank.cons 0 L) R }R:ListBlank (Fin 2)k:ℕih:nSteps weakCollatz27 k { state := q, tape := Tape.mk' B0 (ones k R) } = some { state := q, tape := Tape.mk' B0 R }⊢ (some { state := q, tape := Tape.mk' (ListBlank.cons 0 B0) (ones k R) }).bind (nSteps weakCollatz27 k) =
some { state := q, tape := Tape.mk' B0 R } B0_cons_zero, succ q:Fin 27h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz27 { state := q, tape := { head := 1, left := L, right := R } } =
some { state := q, tape := Tape.mk' (ListBlank.cons 0 L) R }R:ListBlank (Fin 2)k:ℕih:nSteps weakCollatz27 k { state := q, tape := Tape.mk' B0 (ones k R) } = some { state := q, tape := Tape.mk' B0 R }⊢ (some { state := q, tape := Tape.mk' B0 (ones k R) }).bind (nSteps weakCollatz27 k) =
some { state := q, tape := Tape.mk' B0 R } Option.bind_some, succ q:Fin 27h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz27 { state := q, tape := { head := 1, left := L, right := R } } =
some { state := q, tape := Tape.mk' (ListBlank.cons 0 L) R }R:ListBlank (Fin 2)k:ℕih:nSteps weakCollatz27 k { state := q, tape := Tape.mk' B0 (ones k R) } = some { state := q, tape := Tape.mk' B0 R }⊢ nSteps weakCollatz27 k { state := q, tape := Tape.mk' B0 (ones k R) } = some { state := q, tape := Tape.mk' B0 R } ih succ q:Fin 27h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz27 { state := q, tape := { head := 1, left := L, right := R } } =
some { state := q, tape := Tape.mk' (ListBlank.cons 0 L) R }R:ListBlank (Fin 2)k:ℕih:nSteps weakCollatz27 k { state := q, tape := Tape.mk' B0 (ones k R) } = some { state := q, tape := Tape.mk' B0 R }⊢ some { state := q, tape := Tape.mk' B0 R } = some { state := q, tape := Tape.mk' B0 R }] All goals completed! 🐙Canonical 2-Block Checkpoint, Restoration Splitter & Doubler
Canonical stage checkpoint: 0^∞ 1^x 0 [1] 1^(y - 1) 0^∞ in state 24.
private def stageCfg (x y : ℕ) : Cfg 27 2 :=
⟨24, Tape.mk' ((ones x B0).cons 0) (ones y B0)⟩
Restoration / even-block splitter configuration: 0^∞ 1^u 0 1^v [0] 1^(2p) 0^∞ in state 5.
private def restCfg (u v p : ℕ) : Cfg 27 2 :=
⟨5, Tape.mk' (ones v ((ones u B0).cons 0)) ((ones (2 * p) B0).cons 0)⟩private theorem rest_step (u v p : ℕ) :
reachPos (restCfg u v (p + 1)) (restCfg (u + 1) (v + 1) p) := by u:ℕv:ℕp:ℕ⊢ reachPos (restCfg u v (p + 1)) (restCfg (u + 1) (v + 1) p)
unfold restCfg u:ℕv:ℕp:ℕ⊢ reachPos
{ state := 5, tape := Tape.mk' (ones v (ListBlank.cons 0 (ones u B0))) (ListBlank.cons 0 (ones (2 * (p + 1)) B0)) }
{ state := 5,
tape := Tape.mk' (ones (v + 1) (ListBlank.cons 0 (ones (u + 1) B0))) (ListBlank.cons 0 (ones (2 * p) B0)) }
let Lu := (ones u B0).cons 0 u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos
{ state := 5, tape := Tape.mk' (ones v (ListBlank.cons 0 (ones u B0))) (ListBlank.cons 0 (ones (2 * (p + 1)) B0)) }
{ state := 5,
tape := Tape.mk' (ones (v + 1) (ListBlank.cons 0 (ones (u + 1) B0))) (ListBlank.cons 0 (ones (2 * p) B0)) }
change reachPos ⟨5, Tape.mk' (ones v Lu) ((ones (2 * (p + 1)) B0).cons 0)⟩ _ u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos { state := 5, tape := Tape.mk' (ones v Lu) (ListBlank.cons 0 (ones (2 * (p + 1)) B0)) }
{ state := 5,
tape := Tape.mk' (ones (v + 1) (ListBlank.cons 0 (ones (u + 1) B0))) (ListBlank.cons 0 (ones (2 * p) B0)) }
rw [ErdosTernary15.Tape.mk'_cons u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos { state := 5, tape := { head := 0, left := ones v Lu, right := ones (2 * (p + 1)) B0 } }
{ state := 5,
tape := Tape.mk' (ones (v + 1) (ListBlank.cons 0 (ones (u + 1) B0))) (ListBlank.cons 0 (ones (2 * p) B0)) }] u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos { state := 5, tape := { head := 0, left := ones v Lu, right := ones (2 * (p + 1)) B0 } }
{ state := 5,
tape := Tape.mk' (ones (v + 1) (ListBlank.cons 0 (ones (u + 1) B0))) (ListBlank.cons 0 (ones (2 * p) B0)) }
refine step_then_reachPos (tr5_0 _ _) ?_ u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos { state := 6, tape := Tape.mk' (ListBlank.cons 1 (ones v Lu)) (ones (2 * (p + 1)) B0) }
{ state := 5,
tape := Tape.mk' (ones (v + 1) (ListBlank.cons 0 (ones (u + 1) B0))) (ListBlank.cons 0 (ones (2 * p) B0)) }
rw [show (ones v Lu).cons 1 = ones (v + 1) Lu from rfl, u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos { state := 6, tape := Tape.mk' (ones (v + 1) Lu) (ones (2 * (p + 1)) B0) }
{ state := 5,
tape := Tape.mk' (ones (v + 1) (ListBlank.cons 0 (ones (u + 1) B0))) (ListBlank.cons 0 (ones (2 * p) B0)) }
show 2 * (p + 1) = (2 * p + 1) + 1 by u:ℕv:ℕp:ℕ⊢ reachPos (restCfg u v (p + 1)) (restCfg (u + 1) (v + 1) p) omega All goals completed! 🐙, ones_succ (2 * p + 1) B0, u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos { state := 6, tape := Tape.mk' (ones (v + 1) Lu) (ListBlank.cons 1 (ones (2 * p + 1) B0)) }
{ state := 5,
tape := Tape.mk' (ones (v + 1) (ListBlank.cons 0 (ones (u + 1) B0))) (ListBlank.cons 0 (ones (2 * p) B0)) }
ErdosTernary15.Tape.mk'_cons u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos { state := 6, tape := { head := 1, left := ones (v + 1) Lu, right := ones (2 * p + 1) B0 } }
{ state := 5,
tape := Tape.mk' (ones (v + 1) (ListBlank.cons 0 (ones (u + 1) B0))) (ListBlank.cons 0 (ones (2 * p) B0)) }] u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos { state := 6, tape := { head := 1, left := ones (v + 1) Lu, right := ones (2 * p + 1) B0 } }
{ state := 5,
tape := Tape.mk' (ones (v + 1) (ListBlank.cons 0 (ones (u + 1) B0))) (ListBlank.cons 0 (ones (2 * p) B0)) }
refine step_then_reachPos (tr6_1 _ _) ?_ u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos { state := 23, tape := Tape.mk' (ListBlank.cons 1 (ones (v + 1) Lu)) (ones (2 * p + 1) B0) }
{ state := 5,
tape := Tape.mk' (ones (v + 1) (ListBlank.cons 0 (ones (u + 1) B0))) (ListBlank.cons 0 (ones (2 * p) B0)) }
rw [show (ones (v + 1) Lu).cons 1 = ones (v + 2) Lu from rfl, u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos { state := 23, tape := Tape.mk' (ones (v + 2) Lu) (ones (2 * p + 1) B0) }
{ state := 5,
tape := Tape.mk' (ones (v + 1) (ListBlank.cons 0 (ones (u + 1) B0))) (ListBlank.cons 0 (ones (2 * p) B0)) }
ones_succ (2 * p) B0, u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos { state := 23, tape := Tape.mk' (ones (v + 2) Lu) (ListBlank.cons 1 (ones (2 * p) B0)) }
{ state := 5,
tape := Tape.mk' (ones (v + 1) (ListBlank.cons 0 (ones (u + 1) B0))) (ListBlank.cons 0 (ones (2 * p) B0)) } ErdosTernary15.Tape.mk'_cons u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos { state := 23, tape := { head := 1, left := ones (v + 2) Lu, right := ones (2 * p) B0 } }
{ state := 5,
tape := Tape.mk' (ones (v + 1) (ListBlank.cons 0 (ones (u + 1) B0))) (ListBlank.cons 0 (ones (2 * p) B0)) }] u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos { state := 23, tape := { head := 1, left := ones (v + 2) Lu, right := ones (2 * p) B0 } }
{ state := 5,
tape := Tape.mk' (ones (v + 1) (ListBlank.cons 0 (ones (u + 1) B0))) (ListBlank.cons 0 (ones (2 * p) B0)) }
refine step_then_reachPos (tr23_1 _ _) ?_ u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos { state := 4, tape := mkL (ones (v + 2) Lu) (ListBlank.cons 0 (ones (2 * p) B0)) }
{ state := 5,
tape := Tape.mk' (ones (v + 1) (ListBlank.cons 0 (ones (u + 1) B0))) (ListBlank.cons 0 (ones (2 * p) B0)) }
refine nSteps_then_reachPos (sweep1L tr4_1 (v + 2) Lu _) ?_ u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos { state := 4, tape := mkL Lu (ones (v + 2) (ListBlank.cons 0 (ones (2 * p) B0))) }
{ state := 5,
tape := Tape.mk' (ones (v + 1) (ListBlank.cons 0 (ones (u + 1) B0))) (ListBlank.cons 0 (ones (2 * p) B0)) }
dsimp only [Lu] u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos { state := 4, tape := mkL (ListBlank.cons 0 (ones u B0)) (ones (v + 2) (ListBlank.cons 0 (ones (2 * p) B0))) }
{ state := 5,
tape := Tape.mk' (ones (v + 1) (ListBlank.cons 0 (ones (u + 1) B0))) (ListBlank.cons 0 (ones (2 * p) B0)) }
rw [ErdosTernary15.Tape.mkL_cons u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos
{ state := 4, tape := { head := 0, left := ones u B0, right := ones (v + 2) (ListBlank.cons 0 (ones (2 * p) B0)) } }
{ state := 5,
tape := Tape.mk' (ones (v + 1) (ListBlank.cons 0 (ones (u + 1) B0))) (ListBlank.cons 0 (ones (2 * p) B0)) }] u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos
{ state := 4, tape := { head := 0, left := ones u B0, right := ones (v + 2) (ListBlank.cons 0 (ones (2 * p) B0)) } }
{ state := 5,
tape := Tape.mk' (ones (v + 1) (ListBlank.cons 0 (ones (u + 1) B0))) (ListBlank.cons 0 (ones (2 * p) B0)) }
refine step_then_reachPos (tr4_0 _ _) ?_ u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos
{ state := 22, tape := Tape.mk' (ListBlank.cons 1 (ones u B0)) (ones (v + 2) (ListBlank.cons 0 (ones (2 * p) B0))) }
{ state := 5,
tape := Tape.mk' (ones (v + 1) (ListBlank.cons 0 (ones (u + 1) B0))) (ListBlank.cons 0 (ones (2 * p) B0)) }
rw [← ones_succ u B0, u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos { state := 22, tape := Tape.mk' (ones (u + 1) B0) (ones (v + 2) (ListBlank.cons 0 (ones (2 * p) B0))) }
{ state := 5,
tape := Tape.mk' (ones (v + 1) (ListBlank.cons 0 (ones (u + 1) B0))) (ListBlank.cons 0 (ones (2 * p) B0)) } show v + 2 = (v + 1) + 1 by u:ℕv:ℕp:ℕ⊢ reachPos (restCfg u v (p + 1)) (restCfg (u + 1) (v + 1) p) omega All goals completed! 🐙, ones_succ (v + 1) _, u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos
{ state := 22,
tape := Tape.mk' (ones (u + 1) B0) (ListBlank.cons 1 (ones (v + 1) (ListBlank.cons 0 (ones (2 * p) B0)))) }
{ state := 5,
tape := Tape.mk' (ones (v + 1) (ListBlank.cons 0 (ones (u + 1) B0))) (ListBlank.cons 0 (ones (2 * p) B0)) }
ErdosTernary15.Tape.mk'_cons u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos
{ state := 22,
tape := { head := 1, left := ones (u + 1) B0, right := ones (v + 1) (ListBlank.cons 0 (ones (2 * p) B0)) } }
{ state := 5,
tape := Tape.mk' (ones (v + 1) (ListBlank.cons 0 (ones (u + 1) B0))) (ListBlank.cons 0 (ones (2 * p) B0)) }] u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos
{ state := 22,
tape := { head := 1, left := ones (u + 1) B0, right := ones (v + 1) (ListBlank.cons 0 (ones (2 * p) B0)) } }
{ state := 5,
tape := Tape.mk' (ones (v + 1) (ListBlank.cons 0 (ones (u + 1) B0))) (ListBlank.cons 0 (ones (2 * p) B0)) }
have h22 : reachPos ⟨22, ⟨1, ones (u + 1) B0, ones (v + 1) ((ones (2 * p) B0).cons 0)⟩⟩
⟨5, Tape.mk' ((ones (u + 1) B0).cons 0) (ones (v + 1) ((ones (2 * p) B0).cons 0))⟩ :=
reachPos_step (tr22_1 (ones (u + 1) B0) (ones (v + 1) ((ones (2 * p) B0).cons 0))) u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)h22:reachPos
{ state := 22,
tape := { head := 1, left := ones (u + 1) B0, right := ones (v + 1) (ListBlank.cons 0 (ones (2 * p) B0)) } }
{ state := 5,
tape := Tape.mk' (ListBlank.cons 0 (ones (u + 1) B0)) (ones (v + 1) (ListBlank.cons 0 (ones (2 * p) B0))) }⊢ reachPos
{ state := 22,
tape := { head := 1, left := ones (u + 1) B0, right := ones (v + 1) (ListBlank.cons 0 (ones (2 * p) B0)) } }
{ state := 5,
tape := Tape.mk' (ones (v + 1) (ListBlank.cons 0 (ones (u + 1) B0))) (ListBlank.cons 0 (ones (2 * p) B0)) }
exact reachPos_then_nSteps h22
(sweep1R tr5_1 (v + 1) ((ones (u + 1) B0).cons 0) ((ones (2 * p) B0).cons 0)) All goals completed! 🐙private theorem rest_many (u v p k : ℕ) :
k = 0 ∨ reachPos (restCfg u v (p + k)) (restCfg (u + k) (v + k) p) := by u:ℕv:ℕp:ℕk:ℕ⊢ k = 0 ∨ reachPos (restCfg u v (p + k)) (restCfg (u + k) (v + k) p)
induction k generalizing u v with
| zero => zero p:ℕu:ℕv:ℕ⊢ 0 = 0 ∨ reachPos (restCfg u v (p + 0)) (restCfg (u + 0) (v + 0) p) exact Or.inl rfl All goals completed! 🐙
| succ k ih => succ p:ℕk:ℕih:∀ (u v : ℕ), k = 0 ∨ reachPos (restCfg u v (p + k)) (restCfg (u + k) (v + k) p)u:ℕv:ℕ⊢ k + 1 = 0 ∨ reachPos (restCfg u v (p + (k + 1))) (restCfg (u + (k + 1)) (v + (k + 1)) p)
refine Or.inr ?_ succ p:ℕk:ℕih:∀ (u v : ℕ), k = 0 ∨ reachPos (restCfg u v (p + k)) (restCfg (u + k) (v + k) p)u:ℕv:ℕ⊢ reachPos (restCfg u v (p + (k + 1))) (restCfg (u + (k + 1)) (v + (k + 1)) p)
rw [show p + (k + 1) = (p + k) + 1 by u:ℕv:ℕp:ℕk:ℕ⊢ k = 0 ∨ reachPos (restCfg u v (p + k)) (restCfg (u + k) (v + k) p) omega All goals completed! 🐙] succ p:ℕk:ℕih:∀ (u v : ℕ), k = 0 ∨ reachPos (restCfg u v (p + k)) (restCfg (u + k) (v + k) p)u:ℕv:ℕ⊢ reachPos (restCfg u v (p + k + 1)) (restCfg (u + (k + 1)) (v + (k + 1)) p)
have hfirst := rest_step u v (p + k) succ p:ℕk:ℕih:∀ (u v : ℕ), k = 0 ∨ reachPos (restCfg u v (p + k)) (restCfg (u + k) (v + k) p)u:ℕv:ℕhfirst:reachPos (restCfg u v (p + k + 1)) (restCfg (u + 1) (v + 1) (p + k))⊢ reachPos (restCfg u v (p + k + 1)) (restCfg (u + (k + 1)) (v + (k + 1)) p)
rcases ih (u + 1) (v + 1) with rfl | hrest succ.inl p:ℕu:ℕv:ℕih:∀ (u v : ℕ), 0 = 0 ∨ reachPos (restCfg u v (p + 0)) (restCfg (u + 0) (v + 0) p)hfirst:reachPos (restCfg u v (p + 0 + 1)) (restCfg (u + 1) (v + 1) (p + 0))⊢ reachPos (restCfg u v (p + 0 + 1)) (restCfg (u + (0 + 1)) (v + (0 + 1)) p)succ.inr p:ℕk:ℕih:∀ (u v : ℕ), k = 0 ∨ reachPos (restCfg u v (p + k)) (restCfg (u + k) (v + k) p)u:ℕv:ℕhfirst:reachPos (restCfg u v (p + k + 1)) (restCfg (u + 1) (v + 1) (p + k))hrest:reachPos (restCfg (u + 1) (v + 1) (p + k)) (restCfg (u + 1 + k) (v + 1 + k) p)⊢ reachPos (restCfg u v (p + k + 1)) (restCfg (u + (k + 1)) (v + (k + 1)) p)
· succ.inl p:ℕu:ℕv:ℕih:∀ (u v : ℕ), 0 = 0 ∨ reachPos (restCfg u v (p + 0)) (restCfg (u + 0) (v + 0) p)hfirst:reachPos (restCfg u v (p + 0 + 1)) (restCfg (u + 1) (v + 1) (p + 0))⊢ reachPos (restCfg u v (p + 0 + 1)) (restCfg (u + (0 + 1)) (v + (0 + 1)) p) rw [Nat.add_zero succ.inl p:ℕu:ℕv:ℕih:∀ (u v : ℕ), 0 = 0 ∨ reachPos (restCfg u v (p + 0)) (restCfg (u + 0) (v + 0) p)hfirst:reachPos (restCfg u v (p + 0 + 1)) (restCfg (u + 1) (v + 1) (p + 0))⊢ reachPos (restCfg u v (p + 1)) (restCfg (u + (0 + 1)) (v + (0 + 1)) p)] succ.inl p:ℕu:ℕv:ℕih:∀ (u v : ℕ), 0 = 0 ∨ reachPos (restCfg u v (p + 0)) (restCfg (u + 0) (v + 0) p)hfirst:reachPos (restCfg u v (p + 0 + 1)) (restCfg (u + 1) (v + 1) (p + 0))⊢ reachPos (restCfg u v (p + 1)) (restCfg (u + (0 + 1)) (v + (0 + 1)) p)
exact hfirst All goals completed! 🐙
· succ.inr p:ℕk:ℕih:∀ (u v : ℕ), k = 0 ∨ reachPos (restCfg u v (p + k)) (restCfg (u + k) (v + k) p)u:ℕv:ℕhfirst:reachPos (restCfg u v (p + k + 1)) (restCfg (u + 1) (v + 1) (p + k))hrest:reachPos (restCfg (u + 1) (v + 1) (p + k)) (restCfg (u + 1 + k) (v + 1 + k) p)⊢ reachPos (restCfg u v (p + k + 1)) (restCfg (u + (k + 1)) (v + (k + 1)) p) rw [show u + (k + 1) = u + 1 + k by u:ℕv:ℕp:ℕk:ℕ⊢ k = 0 ∨ reachPos (restCfg u v (p + k)) (restCfg (u + k) (v + k) p) omega All goals completed! 🐙, show v + (k + 1) = v + 1 + k by u:ℕv:ℕp:ℕk:ℕ⊢ k = 0 ∨ reachPos (restCfg u v (p + k)) (restCfg (u + k) (v + k) p) omega All goals completed! 🐙] succ.inr p:ℕk:ℕih:∀ (u v : ℕ), k = 0 ∨ reachPos (restCfg u v (p + k)) (restCfg (u + k) (v + k) p)u:ℕv:ℕhfirst:reachPos (restCfg u v (p + k + 1)) (restCfg (u + 1) (v + 1) (p + k))hrest:reachPos (restCfg (u + 1) (v + 1) (p + k)) (restCfg (u + 1 + k) (v + 1 + k) p)⊢ reachPos (restCfg u v (p + k + 1)) (restCfg (u + 1 + k) (v + 1 + k) p)
exact reachPos_trans hfirst hrest All goals completed! 🐙private theorem rest_exit (x z : ℕ) :
reachPos (restCfg x z 0) (stageCfg x z) := by x:ℕz:ℕ⊢ reachPos (restCfg x z 0) (stageCfg x z)
unfold restCfg stageCfg x:ℕz:ℕ⊢ reachPos { state := 5, tape := Tape.mk' (ones z (ListBlank.cons 0 (ones x B0))) (ListBlank.cons 0 (ones (2 * 0) B0)) }
{ state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones x B0)) (ones z B0) }
let Lx := (ones x B0).cons 0 x:ℕz:ℕLx:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)⊢ reachPos { state := 5, tape := Tape.mk' (ones z (ListBlank.cons 0 (ones x B0))) (ListBlank.cons 0 (ones (2 * 0) B0)) }
{ state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones x B0)) (ones z B0) }
change reachPos ⟨5, Tape.mk' (ones z Lx) ((ones (2 * 0) B0).cons 0)⟩
⟨24, Tape.mk' Lx (ones z B0)⟩ x:ℕz:ℕLx:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)⊢ reachPos { state := 5, tape := Tape.mk' (ones z Lx) (ListBlank.cons 0 (ones (2 * 0) B0)) }
{ state := 24, tape := Tape.mk' Lx (ones z B0) }
rw [Nat.mul_zero, x:ℕz:ℕLx:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)⊢ reachPos { state := 5, tape := Tape.mk' (ones z Lx) (ListBlank.cons 0 (ones 0 B0)) }
{ state := 24, tape := Tape.mk' Lx (ones z B0) } ones_zero, x:ℕz:ℕLx:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)⊢ reachPos { state := 5, tape := Tape.mk' (ones z Lx) (ListBlank.cons 0 B0) }
{ state := 24, tape := Tape.mk' Lx (ones z B0) } B0_cons_zero, x:ℕz:ℕLx:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)⊢ reachPos { state := 5, tape := Tape.mk' (ones z Lx) B0 } { state := 24, tape := Tape.mk' Lx (ones z B0) } ErdosTernary15.Tape.mk'_B0 x:ℕz:ℕLx:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)⊢ reachPos { state := 5, tape := { head := 0, left := ones z Lx, right := B0 } }
{ state := 24, tape := Tape.mk' Lx (ones z B0) }] x:ℕz:ℕLx:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)⊢ reachPos { state := 5, tape := { head := 0, left := ones z Lx, right := B0 } }
{ state := 24, tape := Tape.mk' Lx (ones z B0) }
refine step_then_reachPos (tr5_0 _ _) ?_ x:ℕz:ℕLx:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)⊢ reachPos { state := 6, tape := Tape.mk' (ListBlank.cons 1 (ones z Lx)) B0 }
{ state := 24, tape := Tape.mk' Lx (ones z B0) }
rw [ErdosTernary15.Tape.mk'_B0 x:ℕz:ℕLx:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)⊢ reachPos { state := 6, tape := { head := 0, left := ListBlank.cons 1 (ones z Lx), right := B0 } }
{ state := 24, tape := Tape.mk' Lx (ones z B0) }] x:ℕz:ℕLx:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)⊢ reachPos { state := 6, tape := { head := 0, left := ListBlank.cons 1 (ones z Lx), right := B0 } }
{ state := 24, tape := Tape.mk' Lx (ones z B0) }
refine step_then_reachPos (tr6_0 _ _) ?_ x:ℕz:ℕLx:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)⊢ reachPos { state := 19, tape := mkL (ListBlank.cons 1 (ones z Lx)) (ListBlank.cons 0 B0) }
{ state := 24, tape := Tape.mk' Lx (ones z B0) }
rw [B0_cons_zero, x:ℕz:ℕLx:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)⊢ reachPos { state := 19, tape := mkL (ListBlank.cons 1 (ones z Lx)) B0 } { state := 24, tape := Tape.mk' Lx (ones z B0) } ErdosTernary15.Tape.mkL_cons x:ℕz:ℕLx:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)⊢ reachPos { state := 19, tape := { head := 1, left := ones z Lx, right := B0 } }
{ state := 24, tape := Tape.mk' Lx (ones z B0) }] x:ℕz:ℕLx:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)⊢ reachPos { state := 19, tape := { head := 1, left := ones z Lx, right := B0 } }
{ state := 24, tape := Tape.mk' Lx (ones z B0) }
refine step_then_reachPos (tr19_1 _ _) ?_ x:ℕz:ℕLx:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)⊢ reachPos { state := 7, tape := mkL (ones z Lx) (ListBlank.cons 0 B0) } { state := 24, tape := Tape.mk' Lx (ones z B0) }
rw [B0_cons_zero x:ℕz:ℕLx:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)⊢ reachPos { state := 7, tape := mkL (ones z Lx) B0 } { state := 24, tape := Tape.mk' Lx (ones z B0) }] x:ℕz:ℕLx:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)⊢ reachPos { state := 7, tape := mkL (ones z Lx) B0 } { state := 24, tape := Tape.mk' Lx (ones z B0) }
refine nSteps_then_reachPos (sweep1L tr7_1 z Lx B0) ?_ x:ℕz:ℕLx:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)⊢ reachPos { state := 7, tape := mkL Lx (ones z B0) } { state := 24, tape := Tape.mk' Lx (ones z B0) }
dsimp only [Lx] x:ℕz:ℕLx:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)⊢ reachPos { state := 7, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones z B0) }
{ state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones x B0)) (ones z B0) }
rw [ErdosTernary15.Tape.mkL_cons x:ℕz:ℕLx:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)⊢ reachPos { state := 7, tape := { head := 0, left := ones x B0, right := ones z B0 } }
{ state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones x B0)) (ones z B0) }] x:ℕz:ℕLx:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)⊢ reachPos { state := 7, tape := { head := 0, left := ones x B0, right := ones z B0 } }
{ state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones x B0)) (ones z B0) }
exact reachPos_step (tr7_0 _ _) All goals completed! 🐙private theorem rest_from_zero (A : ℕ) (hA : 1 ≤ A) :
reachPos (restCfg 0 0 A) (stageCfg A A) := by A:ℕhA:1 ≤ A⊢ reachPos (restCfg 0 0 A) (stageCfg A A)
rcases rest_many 0 0 0 A with rfl | hmany inl hA:1 ≤ 0⊢ reachPos (restCfg 0 0 0) (stageCfg 0 0)inr A:ℕhA:1 ≤ Ahmany:reachPos (restCfg 0 0 (0 + A)) (restCfg (0 + A) (0 + A) 0)⊢ reachPos (restCfg 0 0 A) (stageCfg A A)
· inl hA:1 ≤ 0⊢ reachPos (restCfg 0 0 0) (stageCfg 0 0) exfalso inl hA:1 ≤ 0⊢ False; omega All goals completed! 🐙
· inr A:ℕhA:1 ≤ Ahmany:reachPos (restCfg 0 0 (0 + A)) (restCfg (0 + A) (0 + A) 0)⊢ reachPos (restCfg 0 0 A) (stageCfg A A) rw [Nat.zero_add inr A:ℕhA:1 ≤ Ahmany:reachPos (restCfg 0 0 A) (restCfg A A 0)⊢ reachPos (restCfg 0 0 A) (stageCfg A A)] at hmany inr A:ℕhA:1 ≤ Ahmany:reachPos (restCfg 0 0 A) (restCfg A A 0)⊢ reachPos (restCfg 0 0 A) (stageCfg A A)
exact reachPos_trans hmany (rest_exit A A) All goals completed! 🐙private def dblCfg (m p : ℕ) : Cfg 27 2 :=
⟨1, mkL (ones m B0) ((ones (2 * p) B0).cons 0)⟩private theorem dbl_step (m p : ℕ) :
reachPos (dblCfg (m + 1) p) (dblCfg m (p + 1)) := by m:ℕp:ℕ⊢ reachPos (dblCfg (m + 1) p) (dblCfg m (p + 1))
unfold dblCfg m:ℕp:ℕ⊢ reachPos { state := 1, tape := mkL (ones (m + 1) B0) (ListBlank.cons 0 (ones (2 * p) B0)) }
{ state := 1, tape := mkL (ones m B0) (ListBlank.cons 0 (ones (2 * (p + 1)) B0)) }
rw [ones_succ m B0, m:ℕp:ℕ⊢ reachPos { state := 1, tape := mkL (ListBlank.cons 1 (ones m B0)) (ListBlank.cons 0 (ones (2 * p) B0)) }
{ state := 1, tape := mkL (ones m B0) (ListBlank.cons 0 (ones (2 * (p + 1)) B0)) } ErdosTernary15.Tape.mkL_cons m:ℕp:ℕ⊢ reachPos { state := 1, tape := { head := 1, left := ones m B0, right := ListBlank.cons 0 (ones (2 * p) B0) } }
{ state := 1, tape := mkL (ones m B0) (ListBlank.cons 0 (ones (2 * (p + 1)) B0)) }] m:ℕp:ℕ⊢ reachPos { state := 1, tape := { head := 1, left := ones m B0, right := ListBlank.cons 0 (ones (2 * p) B0) } }
{ state := 1, tape := mkL (ones m B0) (ListBlank.cons 0 (ones (2 * (p + 1)) B0)) }
refine step_then_reachPos (tr1_1 _ _) ?_ m:ℕp:ℕ⊢ reachPos { state := 0, tape := Tape.mk' (ListBlank.cons 0 (ones m B0)) (ListBlank.cons 0 (ones (2 * p) B0)) }
{ state := 1, tape := mkL (ones m B0) (ListBlank.cons 0 (ones (2 * (p + 1)) B0)) }
rw [ErdosTernary15.Tape.mk'_cons m:ℕp:ℕ⊢ reachPos { state := 0, tape := { head := 0, left := ListBlank.cons 0 (ones m B0), right := ones (2 * p) B0 } }
{ state := 1, tape := mkL (ones m B0) (ListBlank.cons 0 (ones (2 * (p + 1)) B0)) }] m:ℕp:ℕ⊢ reachPos { state := 0, tape := { head := 0, left := ListBlank.cons 0 (ones m B0), right := ones (2 * p) B0 } }
{ state := 1, tape := mkL (ones m B0) (ListBlank.cons 0 (ones (2 * (p + 1)) B0)) }
refine step_then_reachPos (tr0_0 _ _) ?_ m:ℕp:ℕ⊢ reachPos { state := 2, tape := Tape.mk' (ListBlank.cons 1 (ListBlank.cons 0 (ones m B0))) (ones (2 * p) B0) }
{ state := 1, tape := mkL (ones m B0) (ListBlank.cons 0 (ones (2 * (p + 1)) B0)) }
change reachPos ⟨2, Tape.mk' (ones 1 ((ones m B0).cons 0)) (ones (2 * p) B0)⟩ _ m:ℕp:ℕ⊢ reachPos { state := 2, tape := Tape.mk' (ones 1 (ListBlank.cons 0 (ones m B0))) (ones (2 * p) B0) }
{ state := 1, tape := mkL (ones m B0) (ListBlank.cons 0 (ones (2 * (p + 1)) B0)) }
refine nSteps_then_reachPos (sweep1R tr2_1 (2 * p) _ B0) ?_ m:ℕp:ℕ⊢ reachPos { state := 2, tape := Tape.mk' (ones (2 * p) (ones 1 (ListBlank.cons 0 (ones m B0)))) B0 }
{ state := 1, tape := mkL (ones m B0) (ListBlank.cons 0 (ones (2 * (p + 1)) B0)) }
rw [← ones_add (2 * p) 1 ((ones m B0).cons 0), m:ℕp:ℕ⊢ reachPos { state := 2, tape := Tape.mk' (ones (2 * p + 1) (ListBlank.cons 0 (ones m B0))) B0 }
{ state := 1, tape := mkL (ones m B0) (ListBlank.cons 0 (ones (2 * (p + 1)) B0)) } ErdosTernary15.Tape.mk'_B0 m:ℕp:ℕ⊢ reachPos { state := 2, tape := { head := 0, left := ones (2 * p + 1) (ListBlank.cons 0 (ones m B0)), right := B0 } }
{ state := 1, tape := mkL (ones m B0) (ListBlank.cons 0 (ones (2 * (p + 1)) B0)) }] m:ℕp:ℕ⊢ reachPos { state := 2, tape := { head := 0, left := ones (2 * p + 1) (ListBlank.cons 0 (ones m B0)), right := B0 } }
{ state := 1, tape := mkL (ones m B0) (ListBlank.cons 0 (ones (2 * (p + 1)) B0)) }
refine step_then_reachPos (tr2_0 _ _) ?_ m:ℕp:ℕ⊢ reachPos { state := 3, tape := mkL (ones (2 * p + 1) (ListBlank.cons 0 (ones m B0))) (ListBlank.cons 1 B0) }
{ state := 1, tape := mkL (ones m B0) (ListBlank.cons 0 (ones (2 * (p + 1)) B0)) }
change reachPos ⟨3, mkL (ones (2 * p + 1) ((ones m B0).cons 0)) (ones 1 B0)⟩ _ m:ℕp:ℕ⊢ reachPos { state := 3, tape := mkL (ones (2 * p + 1) (ListBlank.cons 0 (ones m B0))) (ones 1 B0) }
{ state := 1, tape := mkL (ones m B0) (ListBlank.cons 0 (ones (2 * (p + 1)) B0)) }
refine nSteps_then_reachPos (sweep1L tr3_1 (2 * p + 1) _ (ones 1 B0)) ?_ m:ℕp:ℕ⊢ reachPos { state := 3, tape := mkL (ListBlank.cons 0 (ones m B0)) (ones (2 * p + 1) (ones 1 B0)) }
{ state := 1, tape := mkL (ones m B0) (ListBlank.cons 0 (ones (2 * (p + 1)) B0)) }
rw [← ones_add (2 * p + 1) 1 B0, m:ℕp:ℕ⊢ reachPos { state := 3, tape := mkL (ListBlank.cons 0 (ones m B0)) (ones (2 * p + 1 + 1) B0) }
{ state := 1, tape := mkL (ones m B0) (ListBlank.cons 0 (ones (2 * (p + 1)) B0)) } show 2 * p + 1 + 1 = 2 * (p + 1) by m:ℕp:ℕ⊢ reachPos (dblCfg (m + 1) p) (dblCfg m (p + 1)) omega All goals completed! 🐙,
ErdosTernary15.Tape.mkL_cons m:ℕp:ℕ⊢ reachPos { state := 3, tape := { head := 0, left := ones m B0, right := ones (2 * (p + 1)) B0 } }
{ state := 1, tape := mkL (ones m B0) (ListBlank.cons 0 (ones (2 * (p + 1)) B0)) }] m:ℕp:ℕ⊢ reachPos { state := 3, tape := { head := 0, left := ones m B0, right := ones (2 * (p + 1)) B0 } }
{ state := 1, tape := mkL (ones m B0) (ListBlank.cons 0 (ones (2 * (p + 1)) B0)) }
exact reachPos_step (tr3_0 _ _) All goals completed! 🐙private theorem dbl_many (m p : ℕ) :
m = 0 ∨ reachPos (dblCfg m p) (dblCfg 0 (p + m)) := by m:ℕp:ℕ⊢ m = 0 ∨ reachPos (dblCfg m p) (dblCfg 0 (p + m))
induction m generalizing p with
| zero => zero p:ℕ⊢ 0 = 0 ∨ reachPos (dblCfg 0 p) (dblCfg 0 (p + 0)) exact Or.inl rfl All goals completed! 🐙
| succ m ih => succ m:ℕih:∀ (p : ℕ), m = 0 ∨ reachPos (dblCfg m p) (dblCfg 0 (p + m))p:ℕ⊢ m + 1 = 0 ∨ reachPos (dblCfg (m + 1) p) (dblCfg 0 (p + (m + 1)))
refine Or.inr ?_ succ m:ℕih:∀ (p : ℕ), m = 0 ∨ reachPos (dblCfg m p) (dblCfg 0 (p + m))p:ℕ⊢ reachPos (dblCfg (m + 1) p) (dblCfg 0 (p + (m + 1)))
rcases ih (p + 1) with rfl | hrest succ.inl p:ℕih:∀ (p : ℕ), 0 = 0 ∨ reachPos (dblCfg 0 p) (dblCfg 0 (p + 0))⊢ reachPos (dblCfg (0 + 1) p) (dblCfg 0 (p + (0 + 1)))succ.inr m:ℕih:∀ (p : ℕ), m = 0 ∨ reachPos (dblCfg m p) (dblCfg 0 (p + m))p:ℕhrest:reachPos (dblCfg m (p + 1)) (dblCfg 0 (p + 1 + m))⊢ reachPos (dblCfg (m + 1) p) (dblCfg 0 (p + (m + 1)))
· succ.inl p:ℕih:∀ (p : ℕ), 0 = 0 ∨ reachPos (dblCfg 0 p) (dblCfg 0 (p + 0))⊢ reachPos (dblCfg (0 + 1) p) (dblCfg 0 (p + (0 + 1))) rw [Nat.add_zero succ.inl p:ℕih:∀ (p : ℕ), 0 = 0 ∨ reachPos (dblCfg 0 p) (dblCfg 0 (p + 0))⊢ reachPos (dblCfg 1 p) (dblCfg 0 (p + 1))] succ.inl p:ℕih:∀ (p : ℕ), 0 = 0 ∨ reachPos (dblCfg 0 p) (dblCfg 0 (p + 0))⊢ reachPos (dblCfg 1 p) (dblCfg 0 (p + 1))
exact dbl_step 0 p All goals completed! 🐙
· succ.inr m:ℕih:∀ (p : ℕ), m = 0 ∨ reachPos (dblCfg m p) (dblCfg 0 (p + m))p:ℕhrest:reachPos (dblCfg m (p + 1)) (dblCfg 0 (p + 1 + m))⊢ reachPos (dblCfg (m + 1) p) (dblCfg 0 (p + (m + 1))) rw [show p + (m + 1) = p + 1 + m by m:ℕp:ℕ⊢ m = 0 ∨ reachPos (dblCfg m p) (dblCfg 0 (p + m)) omega All goals completed! 🐙] succ.inr m:ℕih:∀ (p : ℕ), m = 0 ∨ reachPos (dblCfg m p) (dblCfg 0 (p + m))p:ℕhrest:reachPos (dblCfg m (p + 1)) (dblCfg 0 (p + 1 + m))⊢ reachPos (dblCfg (m + 1) p) (dblCfg 0 (p + 1 + m))
exact reachPos_trans (dbl_step m p) hrest All goals completed! 🐙private theorem stage_y1_advance (x : ℕ) (hx : 1 ≤ x) :
reachPos (stageCfg x 1) (stageCfg (x + 1) (x + 1)) := by x:ℕhx:1 ≤ x⊢ reachPos (stageCfg x 1) (stageCfg (x + 1) (x + 1))
unfold stageCfg x:ℕhx:1 ≤ x⊢ reachPos { state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones x B0)) (ones 1 B0) }
{ state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones (x + 1) B0)) (ones (x + 1) B0) }
rw [ones_succ 0 B0, x:ℕhx:1 ≤ x⊢ reachPos { state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones x B0)) (ListBlank.cons 1 (ones 0 B0)) }
{ state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones (x + 1) B0)) (ones (x + 1) B0) } ones_zero, x:ℕhx:1 ≤ x⊢ reachPos { state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones x B0)) (ListBlank.cons 1 B0) }
{ state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones (x + 1) B0)) (ones (x + 1) B0) } ErdosTernary15.Tape.mk'_cons x:ℕhx:1 ≤ x⊢ reachPos { state := 24, tape := { head := 1, left := ListBlank.cons 0 (ones x B0), right := B0 } }
{ state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones (x + 1) B0)) (ones (x + 1) B0) }] x:ℕhx:1 ≤ x⊢ reachPos { state := 24, tape := { head := 1, left := ListBlank.cons 0 (ones x B0), right := B0 } }
{ state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones (x + 1) B0)) (ones (x + 1) B0) }
refine step_then_reachPos (tr24_1 _ _) ?_ x:ℕhx:1 ≤ x⊢ reachPos { state := 8, tape := Tape.mk' (ListBlank.cons 1 (ListBlank.cons 0 (ones x B0))) B0 }
{ state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones (x + 1) B0)) (ones (x + 1) B0) }
rw [ErdosTernary15.Tape.mk'_B0 x:ℕhx:1 ≤ x⊢ reachPos { state := 8, tape := { head := 0, left := ListBlank.cons 1 (ListBlank.cons 0 (ones x B0)), right := B0 } }
{ state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones (x + 1) B0)) (ones (x + 1) B0) }] x:ℕhx:1 ≤ x⊢ reachPos { state := 8, tape := { head := 0, left := ListBlank.cons 1 (ListBlank.cons 0 (ones x B0)), right := B0 } }
{ state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones (x + 1) B0)) (ones (x + 1) B0) }
refine step_then_reachPos (tr8_0 _ _) ?_ x:ℕhx:1 ≤ x⊢ reachPos { state := 3, tape := mkL (ListBlank.cons 1 (ListBlank.cons 0 (ones x B0))) (ListBlank.cons 1 B0) }
{ state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones (x + 1) B0)) (ones (x + 1) B0) }
change reachPos ⟨3, mkL (ones 1 ((ones x B0).cons 0)) (ones 1 B0)⟩ _ x:ℕhx:1 ≤ x⊢ reachPos { state := 3, tape := mkL (ones 1 (ListBlank.cons 0 (ones x B0))) (ones 1 B0) }
{ state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones (x + 1) B0)) (ones (x + 1) B0) }
refine nSteps_then_reachPos (sweep1L tr3_1 1 ((ones x B0).cons 0) (ones 1 B0)) ?_ x:ℕhx:1 ≤ x⊢ reachPos { state := 3, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones 1 (ones 1 B0)) }
{ state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones (x + 1) B0)) (ones (x + 1) B0) }
rw [show ones 1 (ones 1 B0) = ones (2 * 1) B0 from rfl, x:ℕhx:1 ≤ x⊢ reachPos { state := 3, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (2 * 1) B0) }
{ state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones (x + 1) B0)) (ones (x + 1) B0) } ErdosTernary15.Tape.mkL_cons x:ℕhx:1 ≤ x⊢ reachPos { state := 3, tape := { head := 0, left := ones x B0, right := ones (2 * 1) B0 } }
{ state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones (x + 1) B0)) (ones (x + 1) B0) }] x:ℕhx:1 ≤ x⊢ reachPos { state := 3, tape := { head := 0, left := ones x B0, right := ones (2 * 1) B0 } }
{ state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones (x + 1) B0)) (ones (x + 1) B0) }
refine step_then_reachPos (tr3_0 _ _) ?_ x:ℕhx:1 ≤ x⊢ reachPos { state := 1, tape := mkL (ones x B0) (ListBlank.cons 0 (ones (2 * 1) B0)) }
{ state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones (x + 1) B0)) (ones (x + 1) B0) }
change reachPos (dblCfg x 1) _ x:ℕhx:1 ≤ x⊢ reachPos (dblCfg x 1) { state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones (x + 1) B0)) (ones (x + 1) B0) }
rcases dbl_many x 1 with rfl | hmany inl hx:1 ≤ 0⊢ reachPos (dblCfg 0 1) { state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones (0 + 1) B0)) (ones (0 + 1) B0) }inr x:ℕhx:1 ≤ xhmany:reachPos (dblCfg x 1) (dblCfg 0 (1 + x))⊢ reachPos (dblCfg x 1) { state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones (x + 1) B0)) (ones (x + 1) B0) }
· inl hx:1 ≤ 0⊢ reachPos (dblCfg 0 1) { state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones (0 + 1) B0)) (ones (0 + 1) B0) } exfalso inl hx:1 ≤ 0⊢ False; omega All goals completed! 🐙
· inr x:ℕhx:1 ≤ xhmany:reachPos (dblCfg x 1) (dblCfg 0 (1 + x))⊢ reachPos (dblCfg x 1) { state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones (x + 1) B0)) (ones (x + 1) B0) } rw [show 1 + x = x + 1 by x:ℕhx:1 ≤ x⊢ reachPos (stageCfg x 1) (stageCfg (x + 1) (x + 1)) omega All goals completed! 🐙] at hmany inr x:ℕhx:1 ≤ xhmany:reachPos (dblCfg x 1) (dblCfg 0 (x + 1))⊢ reachPos (dblCfg x 1) { state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones (x + 1) B0)) (ones (x + 1) B0) }
refine reachPos_trans hmany ?_ inr x:ℕhx:1 ≤ xhmany:reachPos (dblCfg x 1) (dblCfg 0 (x + 1))⊢ reachPos (dblCfg 0 (x + 1)) { state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones (x + 1) B0)) (ones (x + 1) B0) }
unfold dblCfg inr x:ℕhx:1 ≤ xhmany:reachPos (dblCfg x 1) (dblCfg 0 (x + 1))⊢ reachPos { state := 1, tape := mkL (ones 0 B0) (ListBlank.cons 0 (ones (2 * (x + 1)) B0)) }
{ state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones (x + 1) B0)) (ones (x + 1) B0) }
rw [ones_zero, inr x:ℕhx:1 ≤ xhmany:reachPos (dblCfg x 1) (dblCfg 0 (x + 1))⊢ reachPos { state := 1, tape := mkL B0 (ListBlank.cons 0 (ones (2 * (x + 1)) B0)) }
{ state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones (x + 1) B0)) (ones (x + 1) B0) } mkL_B0 inr x:ℕhx:1 ≤ xhmany:reachPos (dblCfg x 1) (dblCfg 0 (x + 1))⊢ reachPos { state := 1, tape := { head := 0, left := B0, right := ListBlank.cons 0 (ones (2 * (x + 1)) B0) } }
{ state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones (x + 1) B0)) (ones (x + 1) B0) }] inr x:ℕhx:1 ≤ xhmany:reachPos (dblCfg x 1) (dblCfg 0 (x + 1))⊢ reachPos { state := 1, tape := { head := 0, left := B0, right := ListBlank.cons 0 (ones (2 * (x + 1)) B0) } }
{ state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones (x + 1) B0)) (ones (x + 1) B0) }
refine step_then_reachPos (tr1_0 _ _) ?_ inr x:ℕhx:1 ≤ xhmany:reachPos (dblCfg x 1) (dblCfg 0 (x + 1))⊢ reachPos { state := 5, tape := Tape.mk' (ListBlank.cons 0 B0) (ListBlank.cons 0 (ones (2 * (x + 1)) B0)) }
{ state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones (x + 1) B0)) (ones (x + 1) B0) }
have hrest_eq : (⟨5, Tape.mk' (B0.cons 0) ((ones (2 * (x + 1)) B0).cons 0)⟩ : Cfg 27 2) =
restCfg 0 0 (x + 1) := by x:ℕhx:1 ≤ x⊢ reachPos (stageCfg x 1) (stageCfg (x + 1) (x + 1))
simp only [restCfg, ones_zero, B0_cons_zero] inr x:ℕhx:1 ≤ xhmany:reachPos (dblCfg x 1) (dblCfg 0 (x + 1))hrest_eq:{ state := 5, tape := Tape.mk' (ListBlank.cons 0 B0) (ListBlank.cons 0 (ones (2 * (x + 1)) B0)) } = restCfg 0 0 (x + 1)⊢ reachPos { state := 5, tape := Tape.mk' (ListBlank.cons 0 B0) (ListBlank.cons 0 (ones (2 * (x + 1)) B0)) }
{ state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones (x + 1) B0)) (ones (x + 1) B0) }
rw [hrest_eq inr x:ℕhx:1 ≤ xhmany:reachPos (dblCfg x 1) (dblCfg 0 (x + 1))hrest_eq:{ state := 5, tape := Tape.mk' (ListBlank.cons 0 B0) (ListBlank.cons 0 (ones (2 * (x + 1)) B0)) } = restCfg 0 0 (x + 1)⊢ reachPos (restCfg 0 0 (x + 1)) { state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones (x + 1) B0)) (ones (x + 1) B0) }] inr x:ℕhx:1 ≤ xhmany:reachPos (dblCfg x 1) (dblCfg 0 (x + 1))hrest_eq:{ state := 5, tape := Tape.mk' (ListBlank.cons 0 B0) (ListBlank.cons 0 (ones (2 * (x + 1)) B0)) } = restCfg 0 0 (x + 1)⊢ reachPos (restCfg 0 0 (x + 1)) { state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones (x + 1) B0)) (ones (x + 1) B0) }
exact rest_from_zero (x + 1) (by x:ℕhx:1 ≤ xhmany:reachPos (dblCfg x 1) (dblCfg 0 (x + 1))hrest_eq:{ state := 5, tape := Tape.mk' (ListBlank.cons 0 B0) (ListBlank.cons 0 (ones (2 * (x + 1)) B0)) } = restCfg 0 0 (x + 1)⊢ 1 ≤ x + 1 omega All goals completed! 🐙)
Zero-Gap In-Place terras Evaluation (y ≥ 2)
private def evenCfg (L0 : ListBlank (Fin 2)) (a b : ℕ) : Cfg 27 2 :=
⟨9, Tape.mk' ((ones a L0).cons 0) (ones b B0)⟩private theorem even_step (L0 : ListBlank (Fin 2)) (a b : ℕ) :
reachPos (evenCfg L0 a (b + 2)) (evenCfg L0 (a + 1) b) := by L0:ListBlank (Fin 2)a:ℕb:ℕ⊢ reachPos (evenCfg L0 a (b + 2)) (evenCfg L0 (a + 1) b)
unfold evenCfg L0:ListBlank (Fin 2)a:ℕb:ℕ⊢ reachPos { state := 9, tape := Tape.mk' (ListBlank.cons 0 (ones a L0)) (ones (b + 2) B0) }
{ state := 9, tape := Tape.mk' (ListBlank.cons 0 (ones (a + 1) L0)) (ones b B0) }
refine nSteps_then_reachPos (sweep1R tr9_1 (b + 2) _ B0) ?_ L0:ListBlank (Fin 2)a:ℕb:ℕ⊢ reachPos { state := 9, tape := Tape.mk' (ones (b + 2) (ListBlank.cons 0 (ones a L0))) B0 }
{ state := 9, tape := Tape.mk' (ListBlank.cons 0 (ones (a + 1) L0)) (ones b B0) }
rw [ErdosTernary15.Tape.mk'_B0 L0:ListBlank (Fin 2)a:ℕb:ℕ⊢ reachPos { state := 9, tape := { head := 0, left := ones (b + 2) (ListBlank.cons 0 (ones a L0)), right := B0 } }
{ state := 9, tape := Tape.mk' (ListBlank.cons 0 (ones (a + 1) L0)) (ones b B0) }] L0:ListBlank (Fin 2)a:ℕb:ℕ⊢ reachPos { state := 9, tape := { head := 0, left := ones (b + 2) (ListBlank.cons 0 (ones a L0)), right := B0 } }
{ state := 9, tape := Tape.mk' (ListBlank.cons 0 (ones (a + 1) L0)) (ones b B0) }
refine step_then_reachPos (tr9_0 _ _) ?_ L0:ListBlank (Fin 2)a:ℕb:ℕ⊢ reachPos { state := 10, tape := mkL (ones (b + 2) (ListBlank.cons 0 (ones a L0))) (ListBlank.cons 0 B0) }
{ state := 9, tape := Tape.mk' (ListBlank.cons 0 (ones (a + 1) L0)) (ones b B0) }
rw [B0_cons_zero, L0:ListBlank (Fin 2)a:ℕb:ℕ⊢ reachPos { state := 10, tape := mkL (ones (b + 2) (ListBlank.cons 0 (ones a L0))) B0 }
{ state := 9, tape := Tape.mk' (ListBlank.cons 0 (ones (a + 1) L0)) (ones b B0) } ones_succ (b + 1) _, L0:ListBlank (Fin 2)a:ℕb:ℕ⊢ reachPos { state := 10, tape := mkL (ListBlank.cons 1 (ones (b + 1) (ListBlank.cons 0 (ones a L0)))) B0 }
{ state := 9, tape := Tape.mk' (ListBlank.cons 0 (ones (a + 1) L0)) (ones b B0) } ErdosTernary15.Tape.mkL_cons L0:ListBlank (Fin 2)a:ℕb:ℕ⊢ reachPos { state := 10, tape := { head := 1, left := ones (b + 1) (ListBlank.cons 0 (ones a L0)), right := B0 } }
{ state := 9, tape := Tape.mk' (ListBlank.cons 0 (ones (a + 1) L0)) (ones b B0) }] L0:ListBlank (Fin 2)a:ℕb:ℕ⊢ reachPos { state := 10, tape := { head := 1, left := ones (b + 1) (ListBlank.cons 0 (ones a L0)), right := B0 } }
{ state := 9, tape := Tape.mk' (ListBlank.cons 0 (ones (a + 1) L0)) (ones b B0) }
refine step_then_reachPos (tr10_1 _ _) ?_ L0:ListBlank (Fin 2)a:ℕb:ℕ⊢ reachPos { state := 11, tape := mkL (ones (b + 1) (ListBlank.cons 0 (ones a L0))) (ListBlank.cons 0 B0) }
{ state := 9, tape := Tape.mk' (ListBlank.cons 0 (ones (a + 1) L0)) (ones b B0) }
rw [B0_cons_zero, L0:ListBlank (Fin 2)a:ℕb:ℕ⊢ reachPos { state := 11, tape := mkL (ones (b + 1) (ListBlank.cons 0 (ones a L0))) B0 }
{ state := 9, tape := Tape.mk' (ListBlank.cons 0 (ones (a + 1) L0)) (ones b B0) } ones_succ b _, L0:ListBlank (Fin 2)a:ℕb:ℕ⊢ reachPos { state := 11, tape := mkL (ListBlank.cons 1 (ones b (ListBlank.cons 0 (ones a L0)))) B0 }
{ state := 9, tape := Tape.mk' (ListBlank.cons 0 (ones (a + 1) L0)) (ones b B0) } ErdosTernary15.Tape.mkL_cons L0:ListBlank (Fin 2)a:ℕb:ℕ⊢ reachPos { state := 11, tape := { head := 1, left := ones b (ListBlank.cons 0 (ones a L0)), right := B0 } }
{ state := 9, tape := Tape.mk' (ListBlank.cons 0 (ones (a + 1) L0)) (ones b B0) }] L0:ListBlank (Fin 2)a:ℕb:ℕ⊢ reachPos { state := 11, tape := { head := 1, left := ones b (ListBlank.cons 0 (ones a L0)), right := B0 } }
{ state := 9, tape := Tape.mk' (ListBlank.cons 0 (ones (a + 1) L0)) (ones b B0) }
refine step_then_reachPos (tr11_1 _ _) ?_ L0:ListBlank (Fin 2)a:ℕb:ℕ⊢ reachPos { state := 12, tape := mkL (ones b (ListBlank.cons 0 (ones a L0))) (ListBlank.cons 1 B0) }
{ state := 9, tape := Tape.mk' (ListBlank.cons 0 (ones (a + 1) L0)) (ones b B0) }
change reachPos ⟨12, mkL (ones b ((ones a L0).cons 0)) (ones 1 B0)⟩ _ L0:ListBlank (Fin 2)a:ℕb:ℕ⊢ reachPos { state := 12, tape := mkL (ones b (ListBlank.cons 0 (ones a L0))) (ones 1 B0) }
{ state := 9, tape := Tape.mk' (ListBlank.cons 0 (ones (a + 1) L0)) (ones b B0) }
refine nSteps_then_reachPos (sweep1L tr12_1 b _ _) ?_ L0:ListBlank (Fin 2)a:ℕb:ℕ⊢ reachPos { state := 12, tape := mkL (ListBlank.cons 0 (ones a L0)) (ones b (ones 1 B0)) }
{ state := 9, tape := Tape.mk' (ListBlank.cons 0 (ones (a + 1) L0)) (ones b B0) }
rw [← ones_add b 1 B0, L0:ListBlank (Fin 2)a:ℕb:ℕ⊢ reachPos { state := 12, tape := mkL (ListBlank.cons 0 (ones a L0)) (ones (b + 1) B0) }
{ state := 9, tape := Tape.mk' (ListBlank.cons 0 (ones (a + 1) L0)) (ones b B0) } ErdosTernary15.Tape.mkL_cons L0:ListBlank (Fin 2)a:ℕb:ℕ⊢ reachPos { state := 12, tape := { head := 0, left := ones a L0, right := ones (b + 1) B0 } }
{ state := 9, tape := Tape.mk' (ListBlank.cons 0 (ones (a + 1) L0)) (ones b B0) }] L0:ListBlank (Fin 2)a:ℕb:ℕ⊢ reachPos { state := 12, tape := { head := 0, left := ones a L0, right := ones (b + 1) B0 } }
{ state := 9, tape := Tape.mk' (ListBlank.cons 0 (ones (a + 1) L0)) (ones b B0) }
refine step_then_reachPos (tr12_0 _ _) ?_ L0:ListBlank (Fin 2)a:ℕb:ℕ⊢ reachPos { state := 8, tape := Tape.mk' (ListBlank.cons 1 (ones a L0)) (ones (b + 1) B0) }
{ state := 9, tape := Tape.mk' (ListBlank.cons 0 (ones (a + 1) L0)) (ones b B0) }
rw [← ones_succ a L0, L0:ListBlank (Fin 2)a:ℕb:ℕ⊢ reachPos { state := 8, tape := Tape.mk' (ones (a + 1) L0) (ones (b + 1) B0) }
{ state := 9, tape := Tape.mk' (ListBlank.cons 0 (ones (a + 1) L0)) (ones b B0) } ones_succ b B0, L0:ListBlank (Fin 2)a:ℕb:ℕ⊢ reachPos { state := 8, tape := Tape.mk' (ones (a + 1) L0) (ListBlank.cons 1 (ones b B0)) }
{ state := 9, tape := Tape.mk' (ListBlank.cons 0 (ones (a + 1) L0)) (ones b B0) } ErdosTernary15.Tape.mk'_cons L0:ListBlank (Fin 2)a:ℕb:ℕ⊢ reachPos { state := 8, tape := { head := 1, left := ones (a + 1) L0, right := ones b B0 } }
{ state := 9, tape := Tape.mk' (ListBlank.cons 0 (ones (a + 1) L0)) (ones b B0) }] L0:ListBlank (Fin 2)a:ℕb:ℕ⊢ reachPos { state := 8, tape := { head := 1, left := ones (a + 1) L0, right := ones b B0 } }
{ state := 9, tape := Tape.mk' (ListBlank.cons 0 (ones (a + 1) L0)) (ones b B0) }
exact reachPos_step (tr8_1 _ _) All goals completed! 🐙private theorem even_many (L0 : ListBlank (Fin 2)) (a k r : ℕ) :
k = 0 ∨ reachPos (evenCfg L0 a (2 * k + r)) (evenCfg L0 (a + k) r) := by L0:ListBlank (Fin 2)a:ℕk:ℕr:ℕ⊢ k = 0 ∨ reachPos (evenCfg L0 a (2 * k + r)) (evenCfg L0 (a + k) r)
induction k generalizing a with
| zero => zero L0:ListBlank (Fin 2)r:ℕa:ℕ⊢ 0 = 0 ∨ reachPos (evenCfg L0 a (2 * 0 + r)) (evenCfg L0 (a + 0) r) exact Or.inl rfl All goals completed! 🐙
| succ k ih => succ L0:ListBlank (Fin 2)r:ℕk:ℕih:∀ (a : ℕ), k = 0 ∨ reachPos (evenCfg L0 a (2 * k + r)) (evenCfg L0 (a + k) r)a:ℕ⊢ k + 1 = 0 ∨ reachPos (evenCfg L0 a (2 * (k + 1) + r)) (evenCfg L0 (a + (k + 1)) r)
refine Or.inr ?_ succ L0:ListBlank (Fin 2)r:ℕk:ℕih:∀ (a : ℕ), k = 0 ∨ reachPos (evenCfg L0 a (2 * k + r)) (evenCfg L0 (a + k) r)a:ℕ⊢ reachPos (evenCfg L0 a (2 * (k + 1) + r)) (evenCfg L0 (a + (k + 1)) r)
rw [show 2 * (k + 1) + r = (2 * k + r) + 2 by L0:ListBlank (Fin 2)a:ℕk:ℕr:ℕ⊢ k = 0 ∨ reachPos (evenCfg L0 a (2 * k + r)) (evenCfg L0 (a + k) r) omega All goals completed! 🐙] succ L0:ListBlank (Fin 2)r:ℕk:ℕih:∀ (a : ℕ), k = 0 ∨ reachPos (evenCfg L0 a (2 * k + r)) (evenCfg L0 (a + k) r)a:ℕ⊢ reachPos (evenCfg L0 a (2 * k + r + 2)) (evenCfg L0 (a + (k + 1)) r)
rcases ih (a + 1) with rfl | hrest succ.inl L0:ListBlank (Fin 2)r:ℕa:ℕih:∀ (a : ℕ), 0 = 0 ∨ reachPos (evenCfg L0 a (2 * 0 + r)) (evenCfg L0 (a + 0) r)⊢ reachPos (evenCfg L0 a (2 * 0 + r + 2)) (evenCfg L0 (a + (0 + 1)) r)succ.inr L0:ListBlank (Fin 2)r:ℕk:ℕih:∀ (a : ℕ), k = 0 ∨ reachPos (evenCfg L0 a (2 * k + r)) (evenCfg L0 (a + k) r)a:ℕhrest:reachPos (evenCfg L0 (a + 1) (2 * k + r)) (evenCfg L0 (a + 1 + k) r)⊢ reachPos (evenCfg L0 a (2 * k + r + 2)) (evenCfg L0 (a + (k + 1)) r)
· succ.inl L0:ListBlank (Fin 2)r:ℕa:ℕih:∀ (a : ℕ), 0 = 0 ∨ reachPos (evenCfg L0 a (2 * 0 + r)) (evenCfg L0 (a + 0) r)⊢ reachPos (evenCfg L0 a (2 * 0 + r + 2)) (evenCfg L0 (a + (0 + 1)) r) rw [Nat.mul_zero, succ.inl L0:ListBlank (Fin 2)r:ℕa:ℕih:∀ (a : ℕ), 0 = 0 ∨ reachPos (evenCfg L0 a (2 * 0 + r)) (evenCfg L0 (a + 0) r)⊢ reachPos (evenCfg L0 a (0 + r + 2)) (evenCfg L0 (a + (0 + 1)) r) Nat.zero_add, succ.inl L0:ListBlank (Fin 2)r:ℕa:ℕih:∀ (a : ℕ), 0 = 0 ∨ reachPos (evenCfg L0 a (2 * 0 + r)) (evenCfg L0 (a + 0) r)⊢ reachPos (evenCfg L0 a (r + 2)) (evenCfg L0 (a + (0 + 1)) r) Nat.zero_add succ.inl L0:ListBlank (Fin 2)r:ℕa:ℕih:∀ (a : ℕ), 0 = 0 ∨ reachPos (evenCfg L0 a (2 * 0 + r)) (evenCfg L0 (a + 0) r)⊢ reachPos (evenCfg L0 a (r + 2)) (evenCfg L0 (a + 1) r)] succ.inl L0:ListBlank (Fin 2)r:ℕa:ℕih:∀ (a : ℕ), 0 = 0 ∨ reachPos (evenCfg L0 a (2 * 0 + r)) (evenCfg L0 (a + 0) r)⊢ reachPos (evenCfg L0 a (r + 2)) (evenCfg L0 (a + 1) r)
exact even_step L0 a r All goals completed! 🐙
· succ.inr L0:ListBlank (Fin 2)r:ℕk:ℕih:∀ (a : ℕ), k = 0 ∨ reachPos (evenCfg L0 a (2 * k + r)) (evenCfg L0 (a + k) r)a:ℕhrest:reachPos (evenCfg L0 (a + 1) (2 * k + r)) (evenCfg L0 (a + 1 + k) r)⊢ reachPos (evenCfg L0 a (2 * k + r + 2)) (evenCfg L0 (a + (k + 1)) r) rw [show a + (k + 1) = (a + 1) + k by L0:ListBlank (Fin 2)a:ℕk:ℕr:ℕ⊢ k = 0 ∨ reachPos (evenCfg L0 a (2 * k + r)) (evenCfg L0 (a + k) r) omega All goals completed! 🐙] succ.inr L0:ListBlank (Fin 2)r:ℕk:ℕih:∀ (a : ℕ), k = 0 ∨ reachPos (evenCfg L0 a (2 * k + r)) (evenCfg L0 (a + k) r)a:ℕhrest:reachPos (evenCfg L0 (a + 1) (2 * k + r)) (evenCfg L0 (a + 1 + k) r)⊢ reachPos (evenCfg L0 a (2 * k + r + 2)) (evenCfg L0 (a + 1 + k) r)
exact reachPos_trans (even_step L0 a (2 * k + r)) hrest All goals completed! 🐙private def oddCfg (L0 : ListBlank (Fin 2)) (m r : ℕ) : Cfg 27 2 :=
⟨13, mkL (ones m L0) ((ones r B0).cons 0)⟩private theorem odd_step (L0 : ListBlank (Fin 2)) (m r : ℕ) :
reachPos (oddCfg L0 (m + 1) r) (oddCfg L0 m (r + 3)) := by L0:ListBlank (Fin 2)m:ℕr:ℕ⊢ reachPos (oddCfg L0 (m + 1) r) (oddCfg L0 m (r + 3))
unfold oddCfg L0:ListBlank (Fin 2)m:ℕr:ℕ⊢ reachPos { state := 13, tape := mkL (ones (m + 1) L0) (ListBlank.cons 0 (ones r B0)) }
{ state := 13, tape := mkL (ones m L0) (ListBlank.cons 0 (ones (r + 3) B0)) }
rw [ones_succ m L0, L0:ListBlank (Fin 2)m:ℕr:ℕ⊢ reachPos { state := 13, tape := mkL (ListBlank.cons 1 (ones m L0)) (ListBlank.cons 0 (ones r B0)) }
{ state := 13, tape := mkL (ones m L0) (ListBlank.cons 0 (ones (r + 3) B0)) } ErdosTernary15.Tape.mkL_cons L0:ListBlank (Fin 2)m:ℕr:ℕ⊢ reachPos { state := 13, tape := { head := 1, left := ones m L0, right := ListBlank.cons 0 (ones r B0) } }
{ state := 13, tape := mkL (ones m L0) (ListBlank.cons 0 (ones (r + 3) B0)) }] L0:ListBlank (Fin 2)m:ℕr:ℕ⊢ reachPos { state := 13, tape := { head := 1, left := ones m L0, right := ListBlank.cons 0 (ones r B0) } }
{ state := 13, tape := mkL (ones m L0) (ListBlank.cons 0 (ones (r + 3) B0)) }
refine step_then_reachPos (tr13_1 _ _) ?_ L0:ListBlank (Fin 2)m:ℕr:ℕ⊢ reachPos { state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones m L0)) (ListBlank.cons 0 (ones r B0)) }
{ state := 13, tape := mkL (ones m L0) (ListBlank.cons 0 (ones (r + 3) B0)) }
rw [ErdosTernary15.Tape.mk'_cons L0:ListBlank (Fin 2)m:ℕr:ℕ⊢ reachPos { state := 24, tape := { head := 0, left := ListBlank.cons 0 (ones m L0), right := ones r B0 } }
{ state := 13, tape := mkL (ones m L0) (ListBlank.cons 0 (ones (r + 3) B0)) }] L0:ListBlank (Fin 2)m:ℕr:ℕ⊢ reachPos { state := 24, tape := { head := 0, left := ListBlank.cons 0 (ones m L0), right := ones r B0 } }
{ state := 13, tape := mkL (ones m L0) (ListBlank.cons 0 (ones (r + 3) B0)) }
refine step_then_reachPos (tr24_0 _ _) ?_ L0:ListBlank (Fin 2)m:ℕr:ℕ⊢ reachPos { state := 14, tape := Tape.mk' (ListBlank.cons 1 (ListBlank.cons 0 (ones m L0))) (ones r B0) }
{ state := 13, tape := mkL (ones m L0) (ListBlank.cons 0 (ones (r + 3) B0)) }
change reachPos ⟨14, Tape.mk' (ones 1 ((ones m L0).cons 0)) (ones r B0)⟩ _ L0:ListBlank (Fin 2)m:ℕr:ℕ⊢ reachPos { state := 14, tape := Tape.mk' (ones 1 (ListBlank.cons 0 (ones m L0))) (ones r B0) }
{ state := 13, tape := mkL (ones m L0) (ListBlank.cons 0 (ones (r + 3) B0)) }
refine nSteps_then_reachPos (sweep1R tr14_1 r _ B0) ?_ L0:ListBlank (Fin 2)m:ℕr:ℕ⊢ reachPos { state := 14, tape := Tape.mk' (ones r (ones 1 (ListBlank.cons 0 (ones m L0)))) B0 }
{ state := 13, tape := mkL (ones m L0) (ListBlank.cons 0 (ones (r + 3) B0)) }
rw [← ones_add r 1 ((ones m L0).cons 0), L0:ListBlank (Fin 2)m:ℕr:ℕ⊢ reachPos { state := 14, tape := Tape.mk' (ones (r + 1) (ListBlank.cons 0 (ones m L0))) B0 }
{ state := 13, tape := mkL (ones m L0) (ListBlank.cons 0 (ones (r + 3) B0)) } ErdosTernary15.Tape.mk'_B0 L0:ListBlank (Fin 2)m:ℕr:ℕ⊢ reachPos { state := 14, tape := { head := 0, left := ones (r + 1) (ListBlank.cons 0 (ones m L0)), right := B0 } }
{ state := 13, tape := mkL (ones m L0) (ListBlank.cons 0 (ones (r + 3) B0)) }] L0:ListBlank (Fin 2)m:ℕr:ℕ⊢ reachPos { state := 14, tape := { head := 0, left := ones (r + 1) (ListBlank.cons 0 (ones m L0)), right := B0 } }
{ state := 13, tape := mkL (ones m L0) (ListBlank.cons 0 (ones (r + 3) B0)) }
refine step_then_reachPos (tr14_0 _ _) ?_ L0:ListBlank (Fin 2)m:ℕr:ℕ⊢ reachPos { state := 25, tape := Tape.mk' (ListBlank.cons 1 (ones (r + 1) (ListBlank.cons 0 (ones m L0)))) B0 }
{ state := 13, tape := mkL (ones m L0) (ListBlank.cons 0 (ones (r + 3) B0)) }
rw [← ones_succ (r + 1) _, L0:ListBlank (Fin 2)m:ℕr:ℕ⊢ reachPos { state := 25, tape := Tape.mk' (ones (r + 1 + 1) (ListBlank.cons 0 (ones m L0))) B0 }
{ state := 13, tape := mkL (ones m L0) (ListBlank.cons 0 (ones (r + 3) B0)) } ErdosTernary15.Tape.mk'_B0 L0:ListBlank (Fin 2)m:ℕr:ℕ⊢ reachPos { state := 25, tape := { head := 0, left := ones (r + 1 + 1) (ListBlank.cons 0 (ones m L0)), right := B0 } }
{ state := 13, tape := mkL (ones m L0) (ListBlank.cons 0 (ones (r + 3) B0)) }] L0:ListBlank (Fin 2)m:ℕr:ℕ⊢ reachPos { state := 25, tape := { head := 0, left := ones (r + 1 + 1) (ListBlank.cons 0 (ones m L0)), right := B0 } }
{ state := 13, tape := mkL (ones m L0) (ListBlank.cons 0 (ones (r + 3) B0)) }
refine step_then_reachPos (tr25_0 _ _) ?_ L0:ListBlank (Fin 2)m:ℕr:ℕ⊢ reachPos { state := 15, tape := mkL (ones (r + 1 + 1) (ListBlank.cons 0 (ones m L0))) (ListBlank.cons 1 B0) }
{ state := 13, tape := mkL (ones m L0) (ListBlank.cons 0 (ones (r + 3) B0)) }
change reachPos ⟨15, mkL (ones (r + 2) ((ones m L0).cons 0)) (ones 1 B0)⟩ _ L0:ListBlank (Fin 2)m:ℕr:ℕ⊢ reachPos { state := 15, tape := mkL (ones (r + 2) (ListBlank.cons 0 (ones m L0))) (ones 1 B0) }
{ state := 13, tape := mkL (ones m L0) (ListBlank.cons 0 (ones (r + 3) B0)) }
refine nSteps_then_reachPos (sweep1L tr15_1 (r + 2) _ _) ?_ L0:ListBlank (Fin 2)m:ℕr:ℕ⊢ reachPos { state := 15, tape := mkL (ListBlank.cons 0 (ones m L0)) (ones (r + 2) (ones 1 B0)) }
{ state := 13, tape := mkL (ones m L0) (ListBlank.cons 0 (ones (r + 3) B0)) }
rw [← ones_add (r + 2) 1 B0, L0:ListBlank (Fin 2)m:ℕr:ℕ⊢ reachPos { state := 15, tape := mkL (ListBlank.cons 0 (ones m L0)) (ones (r + 2 + 1) B0) }
{ state := 13, tape := mkL (ones m L0) (ListBlank.cons 0 (ones (r + 3) B0)) } show r + 2 + 1 = r + 3 by L0:ListBlank (Fin 2)m:ℕr:ℕ⊢ reachPos (oddCfg L0 (m + 1) r) (oddCfg L0 m (r + 3)) omega All goals completed! 🐙, ErdosTernary15.Tape.mkL_cons L0:ListBlank (Fin 2)m:ℕr:ℕ⊢ reachPos { state := 15, tape := { head := 0, left := ones m L0, right := ones (r + 3) B0 } }
{ state := 13, tape := mkL (ones m L0) (ListBlank.cons 0 (ones (r + 3) B0)) }] L0:ListBlank (Fin 2)m:ℕr:ℕ⊢ reachPos { state := 15, tape := { head := 0, left := ones m L0, right := ones (r + 3) B0 } }
{ state := 13, tape := mkL (ones m L0) (ListBlank.cons 0 (ones (r + 3) B0)) }
exact reachPos_step (tr15_0 _ _) All goals completed! 🐙private theorem odd_many (L0 : ListBlank (Fin 2)) (m r : ℕ) :
m = 0 ∨ reachPos (oddCfg L0 m r) (oddCfg L0 0 (r + 3 * m)) := by L0:ListBlank (Fin 2)m:ℕr:ℕ⊢ m = 0 ∨ reachPos (oddCfg L0 m r) (oddCfg L0 0 (r + 3 * m))
induction m generalizing r with
| zero => zero L0:ListBlank (Fin 2)r:ℕ⊢ 0 = 0 ∨ reachPos (oddCfg L0 0 r) (oddCfg L0 0 (r + 3 * 0)) exact Or.inl rfl All goals completed! 🐙
| succ m ih => succ L0:ListBlank (Fin 2)m:ℕih:∀ (r : ℕ), m = 0 ∨ reachPos (oddCfg L0 m r) (oddCfg L0 0 (r + 3 * m))r:ℕ⊢ m + 1 = 0 ∨ reachPos (oddCfg L0 (m + 1) r) (oddCfg L0 0 (r + 3 * (m + 1)))
refine Or.inr ?_ succ L0:ListBlank (Fin 2)m:ℕih:∀ (r : ℕ), m = 0 ∨ reachPos (oddCfg L0 m r) (oddCfg L0 0 (r + 3 * m))r:ℕ⊢ reachPos (oddCfg L0 (m + 1) r) (oddCfg L0 0 (r + 3 * (m + 1)))
rcases ih (r + 3) with rfl | hrest succ.inl L0:ListBlank (Fin 2)r:ℕih:∀ (r : ℕ), 0 = 0 ∨ reachPos (oddCfg L0 0 r) (oddCfg L0 0 (r + 3 * 0))⊢ reachPos (oddCfg L0 (0 + 1) r) (oddCfg L0 0 (r + 3 * (0 + 1)))succ.inr L0:ListBlank (Fin 2)m:ℕih:∀ (r : ℕ), m = 0 ∨ reachPos (oddCfg L0 m r) (oddCfg L0 0 (r + 3 * m))r:ℕhrest:reachPos (oddCfg L0 m (r + 3)) (oddCfg L0 0 (r + 3 + 3 * m))⊢ reachPos (oddCfg L0 (m + 1) r) (oddCfg L0 0 (r + 3 * (m + 1)))
· succ.inl L0:ListBlank (Fin 2)r:ℕih:∀ (r : ℕ), 0 = 0 ∨ reachPos (oddCfg L0 0 r) (oddCfg L0 0 (r + 3 * 0))⊢ reachPos (oddCfg L0 (0 + 1) r) (oddCfg L0 0 (r + 3 * (0 + 1))) rw [Nat.zero_add, succ.inl L0:ListBlank (Fin 2)r:ℕih:∀ (r : ℕ), 0 = 0 ∨ reachPos (oddCfg L0 0 r) (oddCfg L0 0 (r + 3 * 0))⊢ reachPos (oddCfg L0 1 r) (oddCfg L0 0 (r + 3 * 1)) Nat.mul_one succ.inl L0:ListBlank (Fin 2)r:ℕih:∀ (r : ℕ), 0 = 0 ∨ reachPos (oddCfg L0 0 r) (oddCfg L0 0 (r + 3 * 0))⊢ reachPos (oddCfg L0 1 r) (oddCfg L0 0 (r + 3))] succ.inl L0:ListBlank (Fin 2)r:ℕih:∀ (r : ℕ), 0 = 0 ∨ reachPos (oddCfg L0 0 r) (oddCfg L0 0 (r + 3 * 0))⊢ reachPos (oddCfg L0 1 r) (oddCfg L0 0 (r + 3))
exact odd_step L0 0 r All goals completed! 🐙
· succ.inr L0:ListBlank (Fin 2)m:ℕih:∀ (r : ℕ), m = 0 ∨ reachPos (oddCfg L0 m r) (oddCfg L0 0 (r + 3 * m))r:ℕhrest:reachPos (oddCfg L0 m (r + 3)) (oddCfg L0 0 (r + 3 + 3 * m))⊢ reachPos (oddCfg L0 (m + 1) r) (oddCfg L0 0 (r + 3 * (m + 1))) rw [show r + 3 * (m + 1) = r + 3 + 3 * m by L0:ListBlank (Fin 2)m:ℕr:ℕ⊢ m = 0 ∨ reachPos (oddCfg L0 m r) (oddCfg L0 0 (r + 3 * m)) omega All goals completed! 🐙] succ.inr L0:ListBlank (Fin 2)m:ℕih:∀ (r : ℕ), m = 0 ∨ reachPos (oddCfg L0 m r) (oddCfg L0 0 (r + 3 * m))r:ℕhrest:reachPos (oddCfg L0 m (r + 3)) (oddCfg L0 0 (r + 3 + 3 * m))⊢ reachPos (oddCfg L0 (m + 1) r) (oddCfg L0 0 (r + 3 + 3 * m))
exact reachPos_trans (odd_step L0 m r) hrest All goals completed! 🐙private theorem terras_pos_of_pos {y : ℕ} (hy : 1 ≤ y) : 1 ≤ terras y := by y:ℕhy:1 ≤ y⊢ 1 ≤ terras y
unfold terras y:ℕhy:1 ≤ y⊢ 1 ≤ if y % 2 = 0 then y / 2 else (3 * y + 1) / 2
split_ifs pos y:ℕhy:1 ≤ yh✝:y % 2 = 0⊢ 1 ≤ y / 2neg y:ℕhy:1 ≤ yh✝:¬y % 2 = 0⊢ 1 ≤ (3 * y + 1) / 2 <;> pos y:ℕhy:1 ≤ yh✝:y % 2 = 0⊢ 1 ≤ y / 2neg y:ℕhy:1 ≤ yh✝:¬y % 2 = 0⊢ 1 ≤ (3 * y + 1) / 2 omega All goals completed! 🐙private theorem terras_eval (x y : ℕ) (hy : 2 ≤ y) :
reachPos (stageCfg x y) ⟨17, mkL ((ones x B0).cons 0) (ones (terras y) B0)⟩ := by x:ℕy:ℕhy:2 ≤ y⊢ reachPos (stageCfg x y) { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) B0) }
let L0 := (ones x B0).cons 0 x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)⊢ reachPos (stageCfg x y) { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) B0) }
rcases Nat.mod_two_eq_zero_or_one y with hev | hodd inl x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0⊢ reachPos (stageCfg x y) { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) B0) }inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1⊢ reachPos (stageCfg x y) { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) B0) }
· inl x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0⊢ reachPos (stageCfg x y) { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) B0) } let k := y / 2 - 1 inl x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1⊢ reachPos (stageCfg x y) { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) B0) }
have hy_eq : y = 2 * k + 2 := by dsimp [k] x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1⊢ y = 2 * (y / 2 - 1) + 2; omega inl x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2⊢ reachPos (stageCfg x y) { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) B0) }
have hty : terras y = k + 1 := by unfold terras x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2⊢ (if y % 2 = 0 then y / 2 else (3 * y + 1) / 2) = k + 1; simp [hev] x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2⊢ y / 2 = k + 1; dsimp [k] x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2⊢ y / 2 = y / 2 - 1 + 1; omega inl x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1⊢ reachPos (stageCfg x y) { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) B0) }
rw [hty, inl x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1⊢ reachPos (stageCfg x y) { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (k + 1) B0) } hy_eq inl x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1⊢ reachPos (stageCfg x (2 * k + 2)) { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (k + 1) B0) }] inl x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1⊢ reachPos (stageCfg x (2 * k + 2)) { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (k + 1) B0) }
unfold stageCfg inl x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1⊢ reachPos { state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones x B0)) (ones (2 * k + 2) B0) }
{ state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (k + 1) B0) }
change reachPos ⟨24, Tape.mk' L0 (ones (2 * k + 2) B0)⟩ ⟨17, mkL L0 (ones (k + 1) B0)⟩ inl x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1⊢ reachPos { state := 24, tape := Tape.mk' L0 (ones (2 * k + 2) B0) } { state := 17, tape := mkL L0 (ones (k + 1) B0) }
rw [show 2 * k + 2 = (2 * k + 1) + 1 by x:ℕy:ℕhy:2 ≤ y⊢ reachPos (stageCfg x y) { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) B0) } omega All goals completed! 🐙, ones_succ (2 * k + 1) B0, inl x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1⊢ reachPos { state := 24, tape := Tape.mk' L0 (ListBlank.cons 1 (ones (2 * k + 1) B0)) }
{ state := 17, tape := mkL L0 (ones (k + 1) B0) }
ErdosTernary15.Tape.mk'_cons inl x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1⊢ reachPos { state := 24, tape := { head := 1, left := L0, right := ones (2 * k + 1) B0 } }
{ state := 17, tape := mkL L0 (ones (k + 1) B0) }] inl x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1⊢ reachPos { state := 24, tape := { head := 1, left := L0, right := ones (2 * k + 1) B0 } }
{ state := 17, tape := mkL L0 (ones (k + 1) B0) }
refine step_then_reachPos (tr24_1 _ _) ?_ inl x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1⊢ reachPos { state := 8, tape := Tape.mk' (ListBlank.cons 1 L0) (ones (2 * k + 1) B0) }
{ state := 17, tape := mkL L0 (ones (k + 1) B0) }
rw [ones_succ (2 * k) B0, inl x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1⊢ reachPos { state := 8, tape := Tape.mk' (ListBlank.cons 1 L0) (ListBlank.cons 1 (ones (2 * k) B0)) }
{ state := 17, tape := mkL L0 (ones (k + 1) B0) } ErdosTernary15.Tape.mk'_cons inl x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1⊢ reachPos { state := 8, tape := { head := 1, left := ListBlank.cons 1 L0, right := ones (2 * k) B0 } }
{ state := 17, tape := mkL L0 (ones (k + 1) B0) }] inl x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1⊢ reachPos { state := 8, tape := { head := 1, left := ListBlank.cons 1 L0, right := ones (2 * k) B0 } }
{ state := 17, tape := mkL L0 (ones (k + 1) B0) }
refine step_then_reachPos (tr8_1 _ _) ?_ inl x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1⊢ reachPos { state := 9, tape := Tape.mk' (ListBlank.cons 0 (ListBlank.cons 1 L0)) (ones (2 * k) B0) }
{ state := 17, tape := mkL L0 (ones (k + 1) B0) }
change reachPos (evenCfg L0 1 (2 * k + 0)) _ inl x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1⊢ reachPos (evenCfg L0 1 (2 * k + 0)) { state := 17, tape := mkL L0 (ones (k + 1) B0) }
have hev_end : reachPos (evenCfg L0 (k + 1) 0) ⟨17, mkL L0 (ones (k + 1) B0)⟩ := by x:ℕy:ℕhy:2 ≤ y⊢ reachPos (stageCfg x y) { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) B0) }
unfold evenCfg x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1⊢ reachPos { state := 9, tape := Tape.mk' (ListBlank.cons 0 (ones (k + 1) L0)) (ones 0 B0) }
{ state := 17, tape := mkL L0 (ones (k + 1) B0) }
rw [ones_zero, x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1⊢ reachPos { state := 9, tape := Tape.mk' (ListBlank.cons 0 (ones (k + 1) L0)) B0 }
{ state := 17, tape := mkL L0 (ones (k + 1) B0) } ErdosTernary15.Tape.mk'_B0 x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1⊢ reachPos { state := 9, tape := { head := 0, left := ListBlank.cons 0 (ones (k + 1) L0), right := B0 } }
{ state := 17, tape := mkL L0 (ones (k + 1) B0) }] x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1⊢ reachPos { state := 9, tape := { head := 0, left := ListBlank.cons 0 (ones (k + 1) L0), right := B0 } }
{ state := 17, tape := mkL L0 (ones (k + 1) B0) }
refine step_then_reachPos (tr9_0 _ _) ?_ x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1⊢ reachPos { state := 10, tape := mkL (ListBlank.cons 0 (ones (k + 1) L0)) (ListBlank.cons 0 B0) }
{ state := 17, tape := mkL L0 (ones (k + 1) B0) }
rw [B0_cons_zero, x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1⊢ reachPos { state := 10, tape := mkL (ListBlank.cons 0 (ones (k + 1) L0)) B0 }
{ state := 17, tape := mkL L0 (ones (k + 1) B0) } ErdosTernary15.Tape.mkL_cons x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1⊢ reachPos { state := 10, tape := { head := 0, left := ones (k + 1) L0, right := B0 } }
{ state := 17, tape := mkL L0 (ones (k + 1) B0) }] x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1⊢ reachPos { state := 10, tape := { head := 0, left := ones (k + 1) L0, right := B0 } }
{ state := 17, tape := mkL L0 (ones (k + 1) B0) }
refine step_then_reachPos (tr10_0 _ _) ?_ x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1⊢ reachPos { state := 16, tape := mkL (ones (k + 1) L0) (ListBlank.cons 0 B0) }
{ state := 17, tape := mkL L0 (ones (k + 1) B0) }
rw [B0_cons_zero, x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1⊢ reachPos { state := 16, tape := mkL (ones (k + 1) L0) B0 } { state := 17, tape := mkL L0 (ones (k + 1) B0) } ones_succ k L0, x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1⊢ reachPos { state := 16, tape := mkL (ListBlank.cons 1 (ones k L0)) B0 }
{ state := 17, tape := mkL L0 (ones (k + 1) B0) } ErdosTernary15.Tape.mkL_cons x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1⊢ reachPos { state := 16, tape := { head := 1, left := ones k L0, right := B0 } }
{ state := 17, tape := mkL L0 (ones (k + 1) B0) }] x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1⊢ reachPos { state := 16, tape := { head := 1, left := ones k L0, right := B0 } }
{ state := 17, tape := mkL L0 (ones (k + 1) B0) }
have h16 : reachPos ⟨16, ⟨1, ones k L0, B0⟩⟩ ⟨17, mkL (ones k L0) (ones 1 B0)⟩ :=
reachPos_step (tr16_1 (ones k L0) B0) x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1h16:reachPos { state := 16, tape := { head := 1, left := ones k L0, right := B0 } }
{ state := 17, tape := mkL (ones k L0) (ones 1 B0) }⊢ reachPos { state := 16, tape := { head := 1, left := ones k L0, right := B0 } }
{ state := 17, tape := mkL L0 (ones (k + 1) B0) }
have hsw := sweep1L tr17_1 k L0 (ones 1 B0) x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1h16:reachPos { state := 16, tape := { head := 1, left := ones k L0, right := B0 } }
{ state := 17, tape := mkL (ones k L0) (ones 1 B0) }hsw:nSteps weakCollatz27 k { state := 17, tape := mkL (ones k L0) (ones 1 B0) } =
some { state := 17, tape := mkL L0 (ones k (ones 1 B0)) }⊢ reachPos { state := 16, tape := { head := 1, left := ones k L0, right := B0 } }
{ state := 17, tape := mkL L0 (ones (k + 1) B0) }
rw [← ones_add k 1 B0 x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1h16:reachPos { state := 16, tape := { head := 1, left := ones k L0, right := B0 } }
{ state := 17, tape := mkL (ones k L0) (ones 1 B0) }hsw:nSteps weakCollatz27 k { state := 17, tape := mkL (ones k L0) (ones 1 B0) } =
some { state := 17, tape := mkL L0 (ones (k + 1) B0) }⊢ reachPos { state := 16, tape := { head := 1, left := ones k L0, right := B0 } }
{ state := 17, tape := mkL L0 (ones (k + 1) B0) }] at hsw x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1h16:reachPos { state := 16, tape := { head := 1, left := ones k L0, right := B0 } }
{ state := 17, tape := mkL (ones k L0) (ones 1 B0) }hsw:nSteps weakCollatz27 k { state := 17, tape := mkL (ones k L0) (ones 1 B0) } =
some { state := 17, tape := mkL L0 (ones (k + 1) B0) }⊢ reachPos { state := 16, tape := { head := 1, left := ones k L0, right := B0 } }
{ state := 17, tape := mkL L0 (ones (k + 1) B0) }
exact reachPos_then_nSteps h16 hsw inl x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1hev_end:reachPos (evenCfg L0 (k + 1) 0) { state := 17, tape := mkL L0 (ones (k + 1) B0) }⊢ reachPos (evenCfg L0 1 (2 * k + 0)) { state := 17, tape := mkL L0 (ones (k + 1) B0) }
rcases even_many L0 1 k 0 with hk0 | hmany inl.inl x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1hev_end:reachPos (evenCfg L0 (k + 1) 0) { state := 17, tape := mkL L0 (ones (k + 1) B0) }hk0:k = 0⊢ reachPos (evenCfg L0 1 (2 * k + 0)) { state := 17, tape := mkL L0 (ones (k + 1) B0) }inl.inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1hev_end:reachPos (evenCfg L0 (k + 1) 0) { state := 17, tape := mkL L0 (ones (k + 1) B0) }hmany:reachPos (evenCfg L0 1 (2 * k + 0)) (evenCfg L0 (1 + k) 0)⊢ reachPos (evenCfg L0 1 (2 * k + 0)) { state := 17, tape := mkL L0 (ones (k + 1) B0) }
· inl.inl x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1hev_end:reachPos (evenCfg L0 (k + 1) 0) { state := 17, tape := mkL L0 (ones (k + 1) B0) }hk0:k = 0⊢ reachPos (evenCfg L0 1 (2 * k + 0)) { state := 17, tape := mkL L0 (ones (k + 1) B0) } rw [hk0 inl.inl x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1hev_end:reachPos (evenCfg L0 (0 + 1) 0) { state := 17, tape := mkL L0 (ones (0 + 1) B0) }hk0:k = 0⊢ reachPos (evenCfg L0 1 (2 * 0 + 0)) { state := 17, tape := mkL L0 (ones (0 + 1) B0) }] at hev_end ⊢ inl.inl x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1hev_end:reachPos (evenCfg L0 (0 + 1) 0) { state := 17, tape := mkL L0 (ones (0 + 1) B0) }hk0:k = 0⊢ reachPos (evenCfg L0 1 (2 * 0 + 0)) { state := 17, tape := mkL L0 (ones (0 + 1) B0) }
exact hev_end All goals completed! 🐙
· inl.inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1hev_end:reachPos (evenCfg L0 (k + 1) 0) { state := 17, tape := mkL L0 (ones (k + 1) B0) }hmany:reachPos (evenCfg L0 1 (2 * k + 0)) (evenCfg L0 (1 + k) 0)⊢ reachPos (evenCfg L0 1 (2 * k + 0)) { state := 17, tape := mkL L0 (ones (k + 1) B0) } rw [show 1 + k = k + 1 by x:ℕy:ℕhy:2 ≤ y⊢ reachPos (stageCfg x y) { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) B0) } omega All goals completed! 🐙] at hmany inl.inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hev:y % 2 = 0k:ℕ := y / 2 - 1hy_eq:y = 2 * k + 2hty:terras y = k + 1hev_end:reachPos (evenCfg L0 (k + 1) 0) { state := 17, tape := mkL L0 (ones (k + 1) B0) }hmany:reachPos (evenCfg L0 1 (2 * k + 0)) (evenCfg L0 (k + 1) 0)⊢ reachPos (evenCfg L0 1 (2 * k + 0)) { state := 17, tape := mkL L0 (ones (k + 1) B0) }
exact reachPos_trans hmany hev_end All goals completed! 🐙
· inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1⊢ reachPos (stageCfg x y) { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) B0) } let k' := y / 2 - 1 inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1⊢ reachPos (stageCfg x y) { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) B0) }
have hy_eq : y = 2 * (k' + 1) + 1 := by dsimp [k'] x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1⊢ y = 2 * (y / 2 - 1 + 1) + 1; omega inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1⊢ reachPos (stageCfg x y) { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) B0) }
have hty : terras y = 3 * (k' + 1) + 2 := by
unfold terras x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1⊢ (if y % 2 = 0 then y / 2 else (3 * y + 1) / 2) = 3 * (k' + 1) + 2
have hne : ¬ (y % 2 = 0) := by x:ℕy:ℕhy:2 ≤ y⊢ reachPos (stageCfg x y) { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) B0) } omega x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hne:¬y % 2 = 0⊢ (if y % 2 = 0 then y / 2 else (3 * y + 1) / 2) = 3 * (k' + 1) + 2
simp [hne] x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hne:¬y % 2 = 0⊢ (3 * y + 1) / 2 = 3 * (k' + 1) + 2; dsimp [k'] x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hne:¬y % 2 = 0⊢ (3 * y + 1) / 2 = 3 * (y / 2 - 1 + 1) + 2; omega inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2⊢ reachPos (stageCfg x y) { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) B0) }
rw [hty, inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2⊢ reachPos (stageCfg x y) { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (3 * (k' + 1) + 2) B0) } hy_eq inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2⊢ reachPos (stageCfg x (2 * (k' + 1) + 1))
{ state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (3 * (k' + 1) + 2) B0) }] inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2⊢ reachPos (stageCfg x (2 * (k' + 1) + 1))
{ state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (3 * (k' + 1) + 2) B0) }
unfold stageCfg inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2⊢ reachPos { state := 24, tape := Tape.mk' (ListBlank.cons 0 (ones x B0)) (ones (2 * (k' + 1) + 1) B0) }
{ state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (3 * (k' + 1) + 2) B0) }
change reachPos ⟨24, Tape.mk' L0 (ones (2 * (k' + 1) + 1) B0)⟩
⟨17, mkL L0 (ones (3 * (k' + 1) + 2) B0)⟩ inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2⊢ reachPos { state := 24, tape := Tape.mk' L0 (ones (2 * (k' + 1) + 1) B0) }
{ state := 17, tape := mkL L0 (ones (3 * (k' + 1) + 2) B0) }
rw [show 2 * (k' + 1) + 1 = (2 * k' + 2) + 1 by x:ℕy:ℕhy:2 ≤ y⊢ reachPos (stageCfg x y) { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) B0) } omega All goals completed! 🐙,
ones_succ (2 * k' + 2) B0, inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2⊢ reachPos { state := 24, tape := Tape.mk' L0 (ListBlank.cons 1 (ones (2 * k' + 2) B0)) }
{ state := 17, tape := mkL L0 (ones (3 * (k' + 1) + 2) B0) } ErdosTernary15.Tape.mk'_cons inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2⊢ reachPos { state := 24, tape := { head := 1, left := L0, right := ones (2 * k' + 2) B0 } }
{ state := 17, tape := mkL L0 (ones (3 * (k' + 1) + 2) B0) }] inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2⊢ reachPos { state := 24, tape := { head := 1, left := L0, right := ones (2 * k' + 2) B0 } }
{ state := 17, tape := mkL L0 (ones (3 * (k' + 1) + 2) B0) }
refine step_then_reachPos (tr24_1 _ _) ?_ inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2⊢ reachPos { state := 8, tape := Tape.mk' (ListBlank.cons 1 L0) (ones (2 * k' + 2) B0) }
{ state := 17, tape := mkL L0 (ones (3 * (k' + 1) + 2) B0) }
rw [show 2 * k' + 2 = (2 * k' + 1) + 1 by x:ℕy:ℕhy:2 ≤ y⊢ reachPos (stageCfg x y) { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) B0) } omega All goals completed! 🐙,
ones_succ (2 * k' + 1) B0, inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2⊢ reachPos { state := 8, tape := Tape.mk' (ListBlank.cons 1 L0) (ListBlank.cons 1 (ones (2 * k' + 1) B0)) }
{ state := 17, tape := mkL L0 (ones (3 * (k' + 1) + 2) B0) } ErdosTernary15.Tape.mk'_cons inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2⊢ reachPos { state := 8, tape := { head := 1, left := ListBlank.cons 1 L0, right := ones (2 * k' + 1) B0 } }
{ state := 17, tape := mkL L0 (ones (3 * (k' + 1) + 2) B0) }] inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2⊢ reachPos { state := 8, tape := { head := 1, left := ListBlank.cons 1 L0, right := ones (2 * k' + 1) B0 } }
{ state := 17, tape := mkL L0 (ones (3 * (k' + 1) + 2) B0) }
refine step_then_reachPos (tr8_1 _ _) ?_ inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2⊢ reachPos { state := 9, tape := Tape.mk' (ListBlank.cons 0 (ListBlank.cons 1 L0)) (ones (2 * k' + 1) B0) }
{ state := 17, tape := mkL L0 (ones (3 * (k' + 1) + 2) B0) }
change reachPos (evenCfg L0 1 (2 * k' + 1)) _ inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2⊢ reachPos (evenCfg L0 1 (2 * k' + 1)) { state := 17, tape := mkL L0 (ones (3 * (k' + 1) + 2) B0) }
have hto_odd : reachPos (evenCfg L0 (k' + 1) 1) (oddCfg L0 (k' + 1) 1) := by x:ℕy:ℕhy:2 ≤ y⊢ reachPos (stageCfg x y) { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) B0) }
unfold evenCfg oddCfg x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2⊢ reachPos { state := 9, tape := Tape.mk' (ListBlank.cons 0 (ones (k' + 1) L0)) (ones 1 B0) }
{ state := 13, tape := mkL (ones (k' + 1) L0) (ListBlank.cons 0 (ones 1 B0)) }
refine nSteps_then_reachPos (sweep1R tr9_1 1 _ B0) ?_ x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2⊢ reachPos { state := 9, tape := Tape.mk' (ones 1 (ListBlank.cons 0 (ones (k' + 1) L0))) B0 }
{ state := 13, tape := mkL (ones (k' + 1) L0) (ListBlank.cons 0 (ones 1 B0)) }
rw [ErdosTernary15.Tape.mk'_B0 x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2⊢ reachPos { state := 9, tape := { head := 0, left := ones 1 (ListBlank.cons 0 (ones (k' + 1) L0)), right := B0 } }
{ state := 13, tape := mkL (ones (k' + 1) L0) (ListBlank.cons 0 (ones 1 B0)) }] x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2⊢ reachPos { state := 9, tape := { head := 0, left := ones 1 (ListBlank.cons 0 (ones (k' + 1) L0)), right := B0 } }
{ state := 13, tape := mkL (ones (k' + 1) L0) (ListBlank.cons 0 (ones 1 B0)) }
refine step_then_reachPos (tr9_0 _ _) ?_ x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2⊢ reachPos { state := 10, tape := mkL (ones 1 (ListBlank.cons 0 (ones (k' + 1) L0))) (ListBlank.cons 0 B0) }
{ state := 13, tape := mkL (ones (k' + 1) L0) (ListBlank.cons 0 (ones 1 B0)) }
rw [B0_cons_zero, x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2⊢ reachPos { state := 10, tape := mkL (ones 1 (ListBlank.cons 0 (ones (k' + 1) L0))) B0 }
{ state := 13, tape := mkL (ones (k' + 1) L0) (ListBlank.cons 0 (ones 1 B0)) } ones_succ 0 _, x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2⊢ reachPos { state := 10, tape := mkL (ListBlank.cons 1 (ones 0 (ListBlank.cons 0 (ones (k' + 1) L0)))) B0 }
{ state := 13, tape := mkL (ones (k' + 1) L0) (ListBlank.cons 0 (ones 1 B0)) } ErdosTernary15.Tape.mkL_cons x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2⊢ reachPos { state := 10, tape := { head := 1, left := ones 0 (ListBlank.cons 0 (ones (k' + 1) L0)), right := B0 } }
{ state := 13, tape := mkL (ones (k' + 1) L0) (ListBlank.cons 0 (ones 1 B0)) }] x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2⊢ reachPos { state := 10, tape := { head := 1, left := ones 0 (ListBlank.cons 0 (ones (k' + 1) L0)), right := B0 } }
{ state := 13, tape := mkL (ones (k' + 1) L0) (ListBlank.cons 0 (ones 1 B0)) }
refine step_then_reachPos (tr10_1 _ _) ?_ x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2⊢ reachPos { state := 11, tape := mkL (ones 0 (ListBlank.cons 0 (ones (k' + 1) L0))) (ListBlank.cons 0 B0) }
{ state := 13, tape := mkL (ones (k' + 1) L0) (ListBlank.cons 0 (ones 1 B0)) }
rw [B0_cons_zero, x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2⊢ reachPos { state := 11, tape := mkL (ones 0 (ListBlank.cons 0 (ones (k' + 1) L0))) B0 }
{ state := 13, tape := mkL (ones (k' + 1) L0) (ListBlank.cons 0 (ones 1 B0)) } ones_zero, x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2⊢ reachPos { state := 11, tape := mkL (ListBlank.cons 0 (ones (k' + 1) L0)) B0 }
{ state := 13, tape := mkL (ones (k' + 1) L0) (ListBlank.cons 0 (ones 1 B0)) } ErdosTernary15.Tape.mkL_cons x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2⊢ reachPos { state := 11, tape := { head := 0, left := ones (k' + 1) L0, right := B0 } }
{ state := 13, tape := mkL (ones (k' + 1) L0) (ListBlank.cons 0 (ones 1 B0)) }] x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2⊢ reachPos { state := 11, tape := { head := 0, left := ones (k' + 1) L0, right := B0 } }
{ state := 13, tape := mkL (ones (k' + 1) L0) (ListBlank.cons 0 (ones 1 B0)) }
refine step_then_reachPos (tr11_0 _ _) ?_ x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2⊢ reachPos { state := 25, tape := Tape.mk' (ListBlank.cons 0 (ones (k' + 1) L0)) B0 }
{ state := 13, tape := mkL (ones (k' + 1) L0) (ListBlank.cons 0 (ones 1 B0)) }
rw [ErdosTernary15.Tape.mk'_B0 x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2⊢ reachPos { state := 25, tape := { head := 0, left := ListBlank.cons 0 (ones (k' + 1) L0), right := B0 } }
{ state := 13, tape := mkL (ones (k' + 1) L0) (ListBlank.cons 0 (ones 1 B0)) }] x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2⊢ reachPos { state := 25, tape := { head := 0, left := ListBlank.cons 0 (ones (k' + 1) L0), right := B0 } }
{ state := 13, tape := mkL (ones (k' + 1) L0) (ListBlank.cons 0 (ones 1 B0)) }
refine step_then_reachPos (tr25_0 _ _) ?_ x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2⊢ reachPos { state := 15, tape := mkL (ListBlank.cons 0 (ones (k' + 1) L0)) (ListBlank.cons 1 B0) }
{ state := 13, tape := mkL (ones (k' + 1) L0) (ListBlank.cons 0 (ones 1 B0)) }
rw [ErdosTernary15.Tape.mkL_cons x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2⊢ reachPos { state := 15, tape := { head := 0, left := ones (k' + 1) L0, right := ListBlank.cons 1 B0 } }
{ state := 13, tape := mkL (ones (k' + 1) L0) (ListBlank.cons 0 (ones 1 B0)) }] x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2⊢ reachPos { state := 15, tape := { head := 0, left := ones (k' + 1) L0, right := ListBlank.cons 1 B0 } }
{ state := 13, tape := mkL (ones (k' + 1) L0) (ListBlank.cons 0 (ones 1 B0)) }
exact reachPos_step (tr15_0 _ _) inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2hto_odd:reachPos (evenCfg L0 (k' + 1) 1) (oddCfg L0 (k' + 1) 1)⊢ reachPos (evenCfg L0 1 (2 * k' + 1)) { state := 17, tape := mkL L0 (ones (3 * (k' + 1) + 2) B0) }
have hev_part : reachPos (evenCfg L0 1 (2 * k' + 1)) (oddCfg L0 (k' + 1) 1) := by x:ℕy:ℕhy:2 ≤ y⊢ reachPos (stageCfg x y) { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) B0) }
rcases even_many L0 1 k' 1 with hk0 | hmany inl x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2hto_odd:reachPos (evenCfg L0 (k' + 1) 1) (oddCfg L0 (k' + 1) 1)hk0:k' = 0⊢ reachPos (evenCfg L0 1 (2 * k' + 1)) (oddCfg L0 (k' + 1) 1)inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2hto_odd:reachPos (evenCfg L0 (k' + 1) 1) (oddCfg L0 (k' + 1) 1)hmany:reachPos (evenCfg L0 1 (2 * k' + 1)) (evenCfg L0 (1 + k') 1)⊢ reachPos (evenCfg L0 1 (2 * k' + 1)) (oddCfg L0 (k' + 1) 1)
· inl x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2hto_odd:reachPos (evenCfg L0 (k' + 1) 1) (oddCfg L0 (k' + 1) 1)hk0:k' = 0⊢ reachPos (evenCfg L0 1 (2 * k' + 1)) (oddCfg L0 (k' + 1) 1) rw [hk0 inl x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2hto_odd:reachPos (evenCfg L0 (0 + 1) 1) (oddCfg L0 (0 + 1) 1)hk0:k' = 0⊢ reachPos (evenCfg L0 1 (2 * 0 + 1)) (oddCfg L0 (0 + 1) 1)] at hto_odd ⊢ inl x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2hto_odd:reachPos (evenCfg L0 (0 + 1) 1) (oddCfg L0 (0 + 1) 1)hk0:k' = 0⊢ reachPos (evenCfg L0 1 (2 * 0 + 1)) (oddCfg L0 (0 + 1) 1)
exact hto_odd All goals completed! 🐙
· inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2hto_odd:reachPos (evenCfg L0 (k' + 1) 1) (oddCfg L0 (k' + 1) 1)hmany:reachPos (evenCfg L0 1 (2 * k' + 1)) (evenCfg L0 (1 + k') 1)⊢ reachPos (evenCfg L0 1 (2 * k' + 1)) (oddCfg L0 (k' + 1) 1) rw [show 1 + k' = k' + 1 by x:ℕy:ℕhy:2 ≤ y⊢ reachPos (stageCfg x y) { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) B0) } omega All goals completed! 🐙] at hmany inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2hto_odd:reachPos (evenCfg L0 (k' + 1) 1) (oddCfg L0 (k' + 1) 1)hmany:reachPos (evenCfg L0 1 (2 * k' + 1)) (evenCfg L0 (k' + 1) 1)⊢ reachPos (evenCfg L0 1 (2 * k' + 1)) (oddCfg L0 (k' + 1) 1)
exact reachPos_trans hmany hto_odd inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2hto_odd:reachPos (evenCfg L0 (k' + 1) 1) (oddCfg L0 (k' + 1) 1)hev_part:reachPos (evenCfg L0 1 (2 * k' + 1)) (oddCfg L0 (k' + 1) 1)⊢ reachPos (evenCfg L0 1 (2 * k' + 1)) { state := 17, tape := mkL L0 (ones (3 * (k' + 1) + 2) B0) }
refine reachPos_trans hev_part ?_ inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2hto_odd:reachPos (evenCfg L0 (k' + 1) 1) (oddCfg L0 (k' + 1) 1)hev_part:reachPos (evenCfg L0 1 (2 * k' + 1)) (oddCfg L0 (k' + 1) 1)⊢ reachPos (oddCfg L0 (k' + 1) 1) { state := 17, tape := mkL L0 (ones (3 * (k' + 1) + 2) B0) }
rcases odd_many L0 (k' + 1) 1 with h0 | hmany inr.inl x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2hto_odd:reachPos (evenCfg L0 (k' + 1) 1) (oddCfg L0 (k' + 1) 1)hev_part:reachPos (evenCfg L0 1 (2 * k' + 1)) (oddCfg L0 (k' + 1) 1)h0:k' + 1 = 0⊢ reachPos (oddCfg L0 (k' + 1) 1) { state := 17, tape := mkL L0 (ones (3 * (k' + 1) + 2) B0) }inr.inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2hto_odd:reachPos (evenCfg L0 (k' + 1) 1) (oddCfg L0 (k' + 1) 1)hev_part:reachPos (evenCfg L0 1 (2 * k' + 1)) (oddCfg L0 (k' + 1) 1)hmany:reachPos (oddCfg L0 (k' + 1) 1) (oddCfg L0 0 (1 + 3 * (k' + 1)))⊢ reachPos (oddCfg L0 (k' + 1) 1) { state := 17, tape := mkL L0 (ones (3 * (k' + 1) + 2) B0) }
· inr.inl x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2hto_odd:reachPos (evenCfg L0 (k' + 1) 1) (oddCfg L0 (k' + 1) 1)hev_part:reachPos (evenCfg L0 1 (2 * k' + 1)) (oddCfg L0 (k' + 1) 1)h0:k' + 1 = 0⊢ reachPos (oddCfg L0 (k' + 1) 1) { state := 17, tape := mkL L0 (ones (3 * (k' + 1) + 2) B0) } exfalso inr.inl x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2hto_odd:reachPos (evenCfg L0 (k' + 1) 1) (oddCfg L0 (k' + 1) 1)hev_part:reachPos (evenCfg L0 1 (2 * k' + 1)) (oddCfg L0 (k' + 1) 1)h0:k' + 1 = 0⊢ False; omega All goals completed! 🐙
· inr.inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2hto_odd:reachPos (evenCfg L0 (k' + 1) 1) (oddCfg L0 (k' + 1) 1)hev_part:reachPos (evenCfg L0 1 (2 * k' + 1)) (oddCfg L0 (k' + 1) 1)hmany:reachPos (oddCfg L0 (k' + 1) 1) (oddCfg L0 0 (1 + 3 * (k' + 1)))⊢ reachPos (oddCfg L0 (k' + 1) 1) { state := 17, tape := mkL L0 (ones (3 * (k' + 1) + 2) B0) } refine reachPos_trans hmany ?_ inr.inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2hto_odd:reachPos (evenCfg L0 (k' + 1) 1) (oddCfg L0 (k' + 1) 1)hev_part:reachPos (evenCfg L0 1 (2 * k' + 1)) (oddCfg L0 (k' + 1) 1)hmany:reachPos (oddCfg L0 (k' + 1) 1) (oddCfg L0 0 (1 + 3 * (k' + 1)))⊢ reachPos (oddCfg L0 0 (1 + 3 * (k' + 1))) { state := 17, tape := mkL L0 (ones (3 * (k' + 1) + 2) B0) }
unfold oddCfg inr.inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2hto_odd:reachPos (evenCfg L0 (k' + 1) 1) (oddCfg L0 (k' + 1) 1)hev_part:reachPos (evenCfg L0 1 (2 * k' + 1)) (oddCfg L0 (k' + 1) 1)hmany:reachPos (oddCfg L0 (k' + 1) 1) (oddCfg L0 0 (1 + 3 * (k' + 1)))⊢ reachPos { state := 13, tape := mkL (ones 0 L0) (ListBlank.cons 0 (ones (1 + 3 * (k' + 1)) B0)) }
{ state := 17, tape := mkL L0 (ones (3 * (k' + 1) + 2) B0) }
rw [ones_zero inr.inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2hto_odd:reachPos (evenCfg L0 (k' + 1) 1) (oddCfg L0 (k' + 1) 1)hev_part:reachPos (evenCfg L0 1 (2 * k' + 1)) (oddCfg L0 (k' + 1) 1)hmany:reachPos (oddCfg L0 (k' + 1) 1) (oddCfg L0 0 (1 + 3 * (k' + 1)))⊢ reachPos { state := 13, tape := mkL L0 (ListBlank.cons 0 (ones (1 + 3 * (k' + 1)) B0)) }
{ state := 17, tape := mkL L0 (ones (3 * (k' + 1) + 2) B0) }] inr.inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2hto_odd:reachPos (evenCfg L0 (k' + 1) 1) (oddCfg L0 (k' + 1) 1)hev_part:reachPos (evenCfg L0 1 (2 * k' + 1)) (oddCfg L0 (k' + 1) 1)hmany:reachPos (oddCfg L0 (k' + 1) 1) (oddCfg L0 0 (1 + 3 * (k' + 1)))⊢ reachPos { state := 13, tape := mkL L0 (ListBlank.cons 0 (ones (1 + 3 * (k' + 1)) B0)) }
{ state := 17, tape := mkL L0 (ones (3 * (k' + 1) + 2) B0) }
dsimp only [L0] inr.inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2hto_odd:reachPos (evenCfg L0 (k' + 1) 1) (oddCfg L0 (k' + 1) 1)hev_part:reachPos (evenCfg L0 1 (2 * k' + 1)) (oddCfg L0 (k' + 1) 1)hmany:reachPos (oddCfg L0 (k' + 1) 1) (oddCfg L0 0 (1 + 3 * (k' + 1)))⊢ reachPos { state := 13, tape := mkL (ListBlank.cons 0 (ones x B0)) (ListBlank.cons 0 (ones (1 + 3 * (k' + 1)) B0)) }
{ state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (3 * (k' + 1) + 2) B0) }
rw [ErdosTernary15.Tape.mkL_cons inr.inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2hto_odd:reachPos (evenCfg L0 (k' + 1) 1) (oddCfg L0 (k' + 1) 1)hev_part:reachPos (evenCfg L0 1 (2 * k' + 1)) (oddCfg L0 (k' + 1) 1)hmany:reachPos (oddCfg L0 (k' + 1) 1) (oddCfg L0 0 (1 + 3 * (k' + 1)))⊢ reachPos
{ state := 13, tape := { head := 0, left := ones x B0, right := ListBlank.cons 0 (ones (1 + 3 * (k' + 1)) B0) } }
{ state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (3 * (k' + 1) + 2) B0) }] inr.inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2hto_odd:reachPos (evenCfg L0 (k' + 1) 1) (oddCfg L0 (k' + 1) 1)hev_part:reachPos (evenCfg L0 1 (2 * k' + 1)) (oddCfg L0 (k' + 1) 1)hmany:reachPos (oddCfg L0 (k' + 1) 1) (oddCfg L0 0 (1 + 3 * (k' + 1)))⊢ reachPos
{ state := 13, tape := { head := 0, left := ones x B0, right := ListBlank.cons 0 (ones (1 + 3 * (k' + 1)) B0) } }
{ state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (3 * (k' + 1) + 2) B0) }
refine step_then_reachPos (tr13_0 _ _) ?_ inr.inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2hto_odd:reachPos (evenCfg L0 (k' + 1) 1) (oddCfg L0 (k' + 1) 1)hev_part:reachPos (evenCfg L0 1 (2 * k' + 1)) (oddCfg L0 (k' + 1) 1)hmany:reachPos (oddCfg L0 (k' + 1) 1) (oddCfg L0 0 (1 + 3 * (k' + 1)))⊢ reachPos
{ state := 26, tape := Tape.mk' (ListBlank.cons 0 (ones x B0)) (ListBlank.cons 0 (ones (1 + 3 * (k' + 1)) B0)) }
{ state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (3 * (k' + 1) + 2) B0) }
rw [ErdosTernary15.Tape.mk'_cons inr.inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2hto_odd:reachPos (evenCfg L0 (k' + 1) 1) (oddCfg L0 (k' + 1) 1)hev_part:reachPos (evenCfg L0 1 (2 * k' + 1)) (oddCfg L0 (k' + 1) 1)hmany:reachPos (oddCfg L0 (k' + 1) 1) (oddCfg L0 0 (1 + 3 * (k' + 1)))⊢ reachPos
{ state := 26, tape := { head := 0, left := ListBlank.cons 0 (ones x B0), right := ones (1 + 3 * (k' + 1)) B0 } }
{ state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (3 * (k' + 1) + 2) B0) }] inr.inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2hto_odd:reachPos (evenCfg L0 (k' + 1) 1) (oddCfg L0 (k' + 1) 1)hev_part:reachPos (evenCfg L0 1 (2 * k' + 1)) (oddCfg L0 (k' + 1) 1)hmany:reachPos (oddCfg L0 (k' + 1) 1) (oddCfg L0 0 (1 + 3 * (k' + 1)))⊢ reachPos
{ state := 26, tape := { head := 0, left := ListBlank.cons 0 (ones x B0), right := ones (1 + 3 * (k' + 1)) B0 } }
{ state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (3 * (k' + 1) + 2) B0) }
have hstep := tr26_0 ((ones x B0).cons 0) (ones (1 + 3 * (k' + 1)) B0) inr.inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2hto_odd:reachPos (evenCfg L0 (k' + 1) 1) (oddCfg L0 (k' + 1) 1)hev_part:reachPos (evenCfg L0 1 (2 * k' + 1)) (oddCfg L0 (k' + 1) 1)hmany:reachPos (oddCfg L0 (k' + 1) 1) (oddCfg L0 0 (1 + 3 * (k' + 1)))hstep:step weakCollatz27
{ state := 26, tape := { head := 0, left := ListBlank.cons 0 (ones x B0), right := ones (1 + 3 * (k' + 1)) B0 } } =
some { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ListBlank.cons 1 (ones (1 + 3 * (k' + 1)) B0)) }⊢ reachPos
{ state := 26, tape := { head := 0, left := ListBlank.cons 0 (ones x B0), right := ones (1 + 3 * (k' + 1)) B0 } }
{ state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (3 * (k' + 1) + 2) B0) }
rw [← ones_succ (1 + 3 * (k' + 1)) B0, inr.inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2hto_odd:reachPos (evenCfg L0 (k' + 1) 1) (oddCfg L0 (k' + 1) 1)hev_part:reachPos (evenCfg L0 1 (2 * k' + 1)) (oddCfg L0 (k' + 1) 1)hmany:reachPos (oddCfg L0 (k' + 1) 1) (oddCfg L0 0 (1 + 3 * (k' + 1)))hstep:step weakCollatz27
{ state := 26, tape := { head := 0, left := ListBlank.cons 0 (ones x B0), right := ones (1 + 3 * (k' + 1)) B0 } } =
some { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (1 + 3 * (k' + 1) + 1) B0) }⊢ reachPos
{ state := 26, tape := { head := 0, left := ListBlank.cons 0 (ones x B0), right := ones (1 + 3 * (k' + 1)) B0 } }
{ state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (3 * (k' + 1) + 2) B0) }
show 1 + 3 * (k' + 1) + 1 = 3 * (k' + 1) + 2 by x:ℕy:ℕhy:2 ≤ y⊢ reachPos (stageCfg x y) { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) B0) } omega All goals completed! 🐙] at hstep inr.inr x:ℕy:ℕhy:2 ≤ yL0:ListBlank (Fin 2) := ListBlank.cons 0 (ones x B0)hodd:y % 2 = 1k':ℕ := y / 2 - 1hy_eq:y = 2 * (k' + 1) + 1hty:terras y = 3 * (k' + 1) + 2hto_odd:reachPos (evenCfg L0 (k' + 1) 1) (oddCfg L0 (k' + 1) 1)hev_part:reachPos (evenCfg L0 1 (2 * k' + 1)) (oddCfg L0 (k' + 1) 1)hmany:reachPos (oddCfg L0 (k' + 1) 1) (oddCfg L0 0 (1 + 3 * (k' + 1)))hstep:step weakCollatz27
{ state := 26, tape := { head := 0, left := ListBlank.cons 0 (ones x B0), right := ones (1 + 3 * (k' + 1)) B0 } } =
some { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (3 * (k' + 1) + 2) B0) }⊢ reachPos
{ state := 26, tape := { head := 0, left := ListBlank.cons 0 (ones x B0), right := ones (1 + 3 * (k' + 1)) B0 } }
{ state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (3 * (k' + 1) + 2) B0) }
exact reachPos_step hstep All goals completed! 🐙
Local 2p Comparison, Cycle Halt & z > x Stage Advance
private def cmpCfg (u v p : ℕ) : Cfg 27 2 :=
⟨16, mkL (ones v ((ones u B0).cons 0)) ((ones (2 * p) B0).cons 0)⟩private theorem cmpFrom17 (u v p : ℕ) :
reachPos ⟨17, mkL ((ones (u + 1) B0).cons 0) (ones (v + 1) ((ones (2 * p) B0).cons 0))⟩
(cmpCfg u v (p + 1)) := by u:ℕv:ℕp:ℕ⊢ reachPos
{ state := 17, tape := mkL (ListBlank.cons 0 (ones (u + 1) B0)) (ones (v + 1) (ListBlank.cons 0 (ones (2 * p) B0))) }
(cmpCfg u v (p + 1))
let Lu := (ones u B0).cons 0 u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos
{ state := 17, tape := mkL (ListBlank.cons 0 (ones (u + 1) B0)) (ones (v + 1) (ListBlank.cons 0 (ones (2 * p) B0))) }
(cmpCfg u v (p + 1))
rw [ErdosTernary15.Tape.mkL_cons u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos
{ state := 17,
tape := { head := 0, left := ones (u + 1) B0, right := ones (v + 1) (ListBlank.cons 0 (ones (2 * p) B0)) } }
(cmpCfg u v (p + 1))] u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos
{ state := 17,
tape := { head := 0, left := ones (u + 1) B0, right := ones (v + 1) (ListBlank.cons 0 (ones (2 * p) B0)) } }
(cmpCfg u v (p + 1))
refine step_then_reachPos (tr17_0 _ _) ?_ u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos
{ state := 20, tape := mkL (ones (u + 1) B0) (ListBlank.cons 0 (ones (v + 1) (ListBlank.cons 0 (ones (2 * p) B0)))) }
(cmpCfg u v (p + 1))
rw [ones_succ u B0, u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos
{ state := 20,
tape := mkL (ListBlank.cons 1 (ones u B0)) (ListBlank.cons 0 (ones (v + 1) (ListBlank.cons 0 (ones (2 * p) B0)))) }
(cmpCfg u v (p + 1)) ErdosTernary15.Tape.mkL_cons u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos
{ state := 20,
tape :=
{ head := 1, left := ones u B0, right := ListBlank.cons 0 (ones (v + 1) (ListBlank.cons 0 (ones (2 * p) B0))) } }
(cmpCfg u v (p + 1))] u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos
{ state := 20,
tape :=
{ head := 1, left := ones u B0, right := ListBlank.cons 0 (ones (v + 1) (ListBlank.cons 0 (ones (2 * p) B0))) } }
(cmpCfg u v (p + 1))
refine step_then_reachPos (tr20_1 _ _) ?_ u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos
{ state := 23,
tape :=
Tape.mk' (ListBlank.cons 0 (ones u B0)) (ListBlank.cons 0 (ones (v + 1) (ListBlank.cons 0 (ones (2 * p) B0)))) }
(cmpCfg u v (p + 1))
rw [ErdosTernary15.Tape.mk'_cons u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos
{ state := 23,
tape :=
{ head := 0, left := ListBlank.cons 0 (ones u B0), right := ones (v + 1) (ListBlank.cons 0 (ones (2 * p) B0)) } }
(cmpCfg u v (p + 1))] u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos
{ state := 23,
tape :=
{ head := 0, left := ListBlank.cons 0 (ones u B0), right := ones (v + 1) (ListBlank.cons 0 (ones (2 * p) B0)) } }
(cmpCfg u v (p + 1))
refine step_then_reachPos (tr23_0 _ _) ?_ u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos
{ state := 21,
tape :=
Tape.mk' (ListBlank.cons 1 (ListBlank.cons 0 (ones u B0))) (ones (v + 1) (ListBlank.cons 0 (ones (2 * p) B0))) }
(cmpCfg u v (p + 1))
change reachPos ⟨21, Tape.mk' (ones 1 Lu) (ones (v + 1) ((ones (2 * p) B0).cons 0))⟩ _ u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos { state := 21, tape := Tape.mk' (ones 1 Lu) (ones (v + 1) (ListBlank.cons 0 (ones (2 * p) B0))) }
(cmpCfg u v (p + 1))
refine nSteps_then_reachPos (sweep1R tr21_1 (v + 1) (ones 1 Lu) _) ?_ u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos { state := 21, tape := Tape.mk' (ones (v + 1) (ones 1 Lu)) (ListBlank.cons 0 (ones (2 * p) B0)) }
(cmpCfg u v (p + 1))
rw [← ones_add (v + 1) 1 Lu, u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos { state := 21, tape := Tape.mk' (ones (v + 1 + 1) Lu) (ListBlank.cons 0 (ones (2 * p) B0)) }
(cmpCfg u v (p + 1)) show v + 1 + 1 = v + 2 by u:ℕv:ℕp:ℕ⊢ reachPos
{ state := 17, tape := mkL (ListBlank.cons 0 (ones (u + 1) B0)) (ones (v + 1) (ListBlank.cons 0 (ones (2 * p) B0))) }
(cmpCfg u v (p + 1)) omega All goals completed! 🐙, ErdosTernary15.Tape.mk'_cons u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos { state := 21, tape := { head := 0, left := ones (v + 2) Lu, right := ones (2 * p) B0 } } (cmpCfg u v (p + 1))] u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos { state := 21, tape := { head := 0, left := ones (v + 2) Lu, right := ones (2 * p) B0 } } (cmpCfg u v (p + 1))
refine step_then_reachPos (tr21_0 _ _) ?_ u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos { state := 25, tape := mkL (ones (v + 2) Lu) (ListBlank.cons 1 (ones (2 * p) B0)) } (cmpCfg u v (p + 1))
rw [show (ones (2 * p) B0).cons 1 = ones (2 * p + 1) B0 from rfl, u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos { state := 25, tape := mkL (ones (v + 2) Lu) (ones (2 * p + 1) B0) } (cmpCfg u v (p + 1))
show v + 2 = (v + 1) + 1 by u:ℕv:ℕp:ℕ⊢ reachPos
{ state := 17, tape := mkL (ListBlank.cons 0 (ones (u + 1) B0)) (ones (v + 1) (ListBlank.cons 0 (ones (2 * p) B0))) }
(cmpCfg u v (p + 1)) omega All goals completed! 🐙, ones_succ (v + 1) Lu, u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos { state := 25, tape := mkL (ListBlank.cons 1 (ones (v + 1) Lu)) (ones (2 * p + 1) B0) } (cmpCfg u v (p + 1)) ErdosTernary15.Tape.mkL_cons u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos { state := 25, tape := { head := 1, left := ones (v + 1) Lu, right := ones (2 * p + 1) B0 } }
(cmpCfg u v (p + 1))] u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos { state := 25, tape := { head := 1, left := ones (v + 1) Lu, right := ones (2 * p + 1) B0 } }
(cmpCfg u v (p + 1))
refine step_then_reachPos (tr25_1 _ _) ?_ u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos { state := 26, tape := mkL (ones (v + 1) Lu) (ListBlank.cons 1 (ones (2 * p + 1) B0)) } (cmpCfg u v (p + 1))
rw [← ones_succ (2 * p + 1) B0, u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos { state := 26, tape := mkL (ones (v + 1) Lu) (ones (2 * p + 1 + 1) B0) } (cmpCfg u v (p + 1)) ones_succ v Lu, u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos { state := 26, tape := mkL (ListBlank.cons 1 (ones v Lu)) (ones (2 * p + 1 + 1) B0) } (cmpCfg u v (p + 1)) ErdosTernary15.Tape.mkL_cons u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos { state := 26, tape := { head := 1, left := ones v Lu, right := ones (2 * p + 1 + 1) B0 } }
(cmpCfg u v (p + 1))] u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)⊢ reachPos { state := 26, tape := { head := 1, left := ones v Lu, right := ones (2 * p + 1 + 1) B0 } }
(cmpCfg u v (p + 1))
have h26 := tr26_1 (ones v Lu) (ones (2 * p + 2) B0) u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)h26:step weakCollatz27 { state := 26, tape := { head := 1, left := ones v Lu, right := ones (2 * p + 2) B0 } } =
some { state := 16, tape := mkL (ones v Lu) (ListBlank.cons 0 (ones (2 * p + 2) B0)) }⊢ reachPos { state := 26, tape := { head := 1, left := ones v Lu, right := ones (2 * p + 1 + 1) B0 } }
(cmpCfg u v (p + 1))
rw [show 2 * p + 2 = 2 * (p + 1) by u:ℕv:ℕp:ℕ⊢ reachPos
{ state := 17, tape := mkL (ListBlank.cons 0 (ones (u + 1) B0)) (ones (v + 1) (ListBlank.cons 0 (ones (2 * p) B0))) }
(cmpCfg u v (p + 1)) omega All goals completed! 🐙] at h26 u:ℕv:ℕp:ℕLu:ListBlank (Fin 2) := ListBlank.cons 0 (ones u B0)h26:step weakCollatz27 { state := 26, tape := { head := 1, left := ones v Lu, right := ones (2 * (p + 1)) B0 } } =
some { state := 16, tape := mkL (ones v Lu) (ListBlank.cons 0 (ones (2 * (p + 1)) B0)) }⊢ reachPos { state := 26, tape := { head := 1, left := ones v Lu, right := ones (2 * p + 1 + 1) B0 } }
(cmpCfg u v (p + 1))
exact reachPos_step h26 All goals completed! 🐙private theorem terras_to_cmp1 (x y : ℕ) (hx : 2 ≤ x) (hy : 2 ≤ y) :
reachPos (stageCfg x y) (cmpCfg (x - 1) (terras y - 1) 1) := by x:ℕy:ℕhx:2 ≤ xhy:2 ≤ y⊢ reachPos (stageCfg x y) (cmpCfg (x - 1) (terras y - 1) 1)
have hz : 1 ≤ terras y := terras_pos_of_pos (by x:ℕy:ℕhx:2 ≤ xhy:2 ≤ y⊢ 1 ≤ y omega All goals completed! 🐙) x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhz:1 ≤ terras y⊢ reachPos (stageCfg x y) (cmpCfg (x - 1) (terras y - 1) 1)
have heval := terras_eval x y hy x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhz:1 ≤ terras yheval:reachPos (stageCfg x y) { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) B0) }⊢ reachPos (stageCfg x y) (cmpCfg (x - 1) (terras y - 1) 1)
have htarget : (⟨17, mkL ((ones x B0).cons 0) (ones (terras y) B0)⟩ : Cfg 27 2) =
⟨17, mkL ((ones ((x - 1) + 1) B0).cons 0)
(ones ((terras y - 1) + 1) ((ones (2 * 0) B0).cons 0))⟩ := by
rw [show (x - 1) + 1 = x by x:ℕy:ℕhx:2 ≤ xhy:2 ≤ y⊢ reachPos (stageCfg x y) (cmpCfg (x - 1) (terras y - 1) 1) omega All goals completed! 🐙, show (terras y - 1) + 1 = terras y by x:ℕy:ℕhx:2 ≤ xhy:2 ≤ y⊢ reachPos (stageCfg x y) (cmpCfg (x - 1) (terras y - 1) 1) omega All goals completed! 🐙,
Nat.mul_zero, x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhz:1 ≤ terras yheval:reachPos (stageCfg x y) { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) B0) }⊢ { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) B0) } =
{ state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) (ListBlank.cons 0 (ones 0 B0))) } ones_zero, x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhz:1 ≤ terras yheval:reachPos (stageCfg x y) { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) B0) }⊢ { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) B0) } =
{ state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) (ListBlank.cons 0 B0)) } B0_cons_zero x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhz:1 ≤ terras yheval:reachPos (stageCfg x y) { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) B0) }⊢ { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) B0) } =
{ state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) B0) }] x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhz:1 ≤ terras yheval:reachPos (stageCfg x y) { state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) B0) }htarget:{ state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) B0) } =
{ state := 17,
tape :=
mkL (ListBlank.cons 0 (ones (x - 1 + 1) B0)) (ones (terras y - 1 + 1) (ListBlank.cons 0 (ones (2 * 0) B0))) }⊢ reachPos (stageCfg x y) (cmpCfg (x - 1) (terras y - 1) 1)
rw [htarget x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhz:1 ≤ terras yheval:reachPos (stageCfg x y)
{ state := 17,
tape :=
mkL (ListBlank.cons 0 (ones (x - 1 + 1) B0)) (ones (terras y - 1 + 1) (ListBlank.cons 0 (ones (2 * 0) B0))) }htarget:{ state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) B0) } =
{ state := 17,
tape :=
mkL (ListBlank.cons 0 (ones (x - 1 + 1) B0)) (ones (terras y - 1 + 1) (ListBlank.cons 0 (ones (2 * 0) B0))) }⊢ reachPos (stageCfg x y) (cmpCfg (x - 1) (terras y - 1) 1)] at heval x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhz:1 ≤ terras yheval:reachPos (stageCfg x y)
{ state := 17,
tape :=
mkL (ListBlank.cons 0 (ones (x - 1 + 1) B0)) (ones (terras y - 1 + 1) (ListBlank.cons 0 (ones (2 * 0) B0))) }htarget:{ state := 17, tape := mkL (ListBlank.cons 0 (ones x B0)) (ones (terras y) B0) } =
{ state := 17,
tape :=
mkL (ListBlank.cons 0 (ones (x - 1 + 1) B0)) (ones (terras y - 1 + 1) (ListBlank.cons 0 (ones (2 * 0) B0))) }⊢ reachPos (stageCfg x y) (cmpCfg (x - 1) (terras y - 1) 1)
exact reachPos_trans heval (cmpFrom17 (x - 1) (terras y - 1) 0) All goals completed! 🐙private theorem cmp_step (u v p : ℕ) :
reachPos (cmpCfg (u + 1) (v + 1) p) (cmpCfg u v (p + 1)) := by u:ℕv:ℕp:ℕ⊢ reachPos (cmpCfg (u + 1) (v + 1) p) (cmpCfg u v (p + 1))
unfold cmpCfg u:ℕv:ℕp:ℕ⊢ reachPos
{ state := 16, tape := mkL (ones (v + 1) (ListBlank.cons 0 (ones (u + 1) B0))) (ListBlank.cons 0 (ones (2 * p) B0)) }
{ state := 16, tape := mkL (ones v (ListBlank.cons 0 (ones u B0))) (ListBlank.cons 0 (ones (2 * (p + 1)) B0)) }
let Lu1 := (ones (u + 1) B0).cons 0 u:ℕv:ℕp:ℕLu1:ListBlank (Fin 2) := ListBlank.cons 0 (ones (u + 1) B0)⊢ reachPos
{ state := 16, tape := mkL (ones (v + 1) (ListBlank.cons 0 (ones (u + 1) B0))) (ListBlank.cons 0 (ones (2 * p) B0)) }
{ state := 16, tape := mkL (ones v (ListBlank.cons 0 (ones u B0))) (ListBlank.cons 0 (ones (2 * (p + 1)) B0)) }
let Rp := (ones (2 * p) B0).cons 0 u:ℕv:ℕp:ℕLu1:ListBlank (Fin 2) := ListBlank.cons 0 (ones (u + 1) B0)Rp:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * p) B0)⊢ reachPos
{ state := 16, tape := mkL (ones (v + 1) (ListBlank.cons 0 (ones (u + 1) B0))) (ListBlank.cons 0 (ones (2 * p) B0)) }
{ state := 16, tape := mkL (ones v (ListBlank.cons 0 (ones u B0))) (ListBlank.cons 0 (ones (2 * (p + 1)) B0)) }
change reachPos ⟨16, mkL (ones (v + 1) Lu1) Rp⟩ _ u:ℕv:ℕp:ℕLu1:ListBlank (Fin 2) := ListBlank.cons 0 (ones (u + 1) B0)Rp:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * p) B0)⊢ reachPos { state := 16, tape := mkL (ones (v + 1) Lu1) Rp }
{ state := 16, tape := mkL (ones v (ListBlank.cons 0 (ones u B0))) (ListBlank.cons 0 (ones (2 * (p + 1)) B0)) }
rw [ones_succ v Lu1, u:ℕv:ℕp:ℕLu1:ListBlank (Fin 2) := ListBlank.cons 0 (ones (u + 1) B0)Rp:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * p) B0)⊢ reachPos { state := 16, tape := mkL (ListBlank.cons 1 (ones v Lu1)) Rp }
{ state := 16, tape := mkL (ones v (ListBlank.cons 0 (ones u B0))) (ListBlank.cons 0 (ones (2 * (p + 1)) B0)) } ErdosTernary15.Tape.mkL_cons u:ℕv:ℕp:ℕLu1:ListBlank (Fin 2) := ListBlank.cons 0 (ones (u + 1) B0)Rp:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * p) B0)⊢ reachPos { state := 16, tape := { head := 1, left := ones v Lu1, right := Rp } }
{ state := 16, tape := mkL (ones v (ListBlank.cons 0 (ones u B0))) (ListBlank.cons 0 (ones (2 * (p + 1)) B0)) }] u:ℕv:ℕp:ℕLu1:ListBlank (Fin 2) := ListBlank.cons 0 (ones (u + 1) B0)Rp:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * p) B0)⊢ reachPos { state := 16, tape := { head := 1, left := ones v Lu1, right := Rp } }
{ state := 16, tape := mkL (ones v (ListBlank.cons 0 (ones u B0))) (ListBlank.cons 0 (ones (2 * (p + 1)) B0)) }
refine step_then_reachPos (tr16_1 _ _) ?_ u:ℕv:ℕp:ℕLu1:ListBlank (Fin 2) := ListBlank.cons 0 (ones (u + 1) B0)Rp:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * p) B0)⊢ reachPos { state := 17, tape := mkL (ones v Lu1) (ListBlank.cons 1 Rp) }
{ state := 16, tape := mkL (ones v (ListBlank.cons 0 (ones u B0))) (ListBlank.cons 0 (ones (2 * (p + 1)) B0)) }
change reachPos ⟨17, mkL (ones v Lu1) (ones 1 Rp)⟩ _ u:ℕv:ℕp:ℕLu1:ListBlank (Fin 2) := ListBlank.cons 0 (ones (u + 1) B0)Rp:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * p) B0)⊢ reachPos { state := 17, tape := mkL (ones v Lu1) (ones 1 Rp) }
{ state := 16, tape := mkL (ones v (ListBlank.cons 0 (ones u B0))) (ListBlank.cons 0 (ones (2 * (p + 1)) B0)) }
refine nSteps_then_reachPos (sweep1L tr17_1 v Lu1 (ones 1 Rp)) ?_ u:ℕv:ℕp:ℕLu1:ListBlank (Fin 2) := ListBlank.cons 0 (ones (u + 1) B0)Rp:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * p) B0)⊢ reachPos { state := 17, tape := mkL Lu1 (ones v (ones 1 Rp)) }
{ state := 16, tape := mkL (ones v (ListBlank.cons 0 (ones u B0))) (ListBlank.cons 0 (ones (2 * (p + 1)) B0)) }
rw [← ones_add v 1 Rp u:ℕv:ℕp:ℕLu1:ListBlank (Fin 2) := ListBlank.cons 0 (ones (u + 1) B0)Rp:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * p) B0)⊢ reachPos { state := 17, tape := mkL Lu1 (ones (v + 1) Rp) }
{ state := 16, tape := mkL (ones v (ListBlank.cons 0 (ones u B0))) (ListBlank.cons 0 (ones (2 * (p + 1)) B0)) }] u:ℕv:ℕp:ℕLu1:ListBlank (Fin 2) := ListBlank.cons 0 (ones (u + 1) B0)Rp:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * p) B0)⊢ reachPos { state := 17, tape := mkL Lu1 (ones (v + 1) Rp) }
{ state := 16, tape := mkL (ones v (ListBlank.cons 0 (ones u B0))) (ListBlank.cons 0 (ones (2 * (p + 1)) B0)) }
exact cmpFrom17 u v p All goals completed! 🐙private theorem cmp_many (u v p k : ℕ) :
k = 0 ∨ reachPos (cmpCfg (u + k) (v + k) p) (cmpCfg u v (p + k)) := by u:ℕv:ℕp:ℕk:ℕ⊢ k = 0 ∨ reachPos (cmpCfg (u + k) (v + k) p) (cmpCfg u v (p + k))
induction k generalizing u v p with
| zero => zero u:ℕv:ℕp:ℕ⊢ 0 = 0 ∨ reachPos (cmpCfg (u + 0) (v + 0) p) (cmpCfg u v (p + 0)) exact Or.inl rfl All goals completed! 🐙
| succ k ih => succ k:ℕih:∀ (u v p : ℕ), k = 0 ∨ reachPos (cmpCfg (u + k) (v + k) p) (cmpCfg u v (p + k))u:ℕv:ℕp:ℕ⊢ k + 1 = 0 ∨ reachPos (cmpCfg (u + (k + 1)) (v + (k + 1)) p) (cmpCfg u v (p + (k + 1)))
refine Or.inr ?_ succ k:ℕih:∀ (u v p : ℕ), k = 0 ∨ reachPos (cmpCfg (u + k) (v + k) p) (cmpCfg u v (p + k))u:ℕv:ℕp:ℕ⊢ reachPos (cmpCfg (u + (k + 1)) (v + (k + 1)) p) (cmpCfg u v (p + (k + 1)))
rw [show u + (k + 1) = (u + k) + 1 by u:ℕv:ℕp:ℕk:ℕ⊢ k = 0 ∨ reachPos (cmpCfg (u + k) (v + k) p) (cmpCfg u v (p + k)) omega All goals completed! 🐙, show v + (k + 1) = (v + k) + 1 by u:ℕv:ℕp:ℕk:ℕ⊢ k = 0 ∨ reachPos (cmpCfg (u + k) (v + k) p) (cmpCfg u v (p + k)) omega All goals completed! 🐙] succ k:ℕih:∀ (u v p : ℕ), k = 0 ∨ reachPos (cmpCfg (u + k) (v + k) p) (cmpCfg u v (p + k))u:ℕv:ℕp:ℕ⊢ reachPos (cmpCfg (u + k + 1) (v + k + 1) p) (cmpCfg u v (p + (k + 1)))
rcases ih u v (p + 1) with rfl | hrest succ.inl u:ℕv:ℕp:ℕih:∀ (u v p : ℕ), 0 = 0 ∨ reachPos (cmpCfg (u + 0) (v + 0) p) (cmpCfg u v (p + 0))⊢ reachPos (cmpCfg (u + 0 + 1) (v + 0 + 1) p) (cmpCfg u v (p + (0 + 1)))succ.inr k:ℕih:∀ (u v p : ℕ), k = 0 ∨ reachPos (cmpCfg (u + k) (v + k) p) (cmpCfg u v (p + k))u:ℕv:ℕp:ℕhrest:reachPos (cmpCfg (u + k) (v + k) (p + 1)) (cmpCfg u v (p + 1 + k))⊢ reachPos (cmpCfg (u + k + 1) (v + k + 1) p) (cmpCfg u v (p + (k + 1)))
· succ.inl u:ℕv:ℕp:ℕih:∀ (u v p : ℕ), 0 = 0 ∨ reachPos (cmpCfg (u + 0) (v + 0) p) (cmpCfg u v (p + 0))⊢ reachPos (cmpCfg (u + 0 + 1) (v + 0 + 1) p) (cmpCfg u v (p + (0 + 1))) rw [Nat.add_zero succ.inl u:ℕv:ℕp:ℕih:∀ (u v p : ℕ), 0 = 0 ∨ reachPos (cmpCfg (u + 0) (v + 0) p) (cmpCfg u v (p + 0))⊢ reachPos (cmpCfg (u + 1) (v + 0 + 1) p) (cmpCfg u v (p + (0 + 1)))] succ.inl u:ℕv:ℕp:ℕih:∀ (u v p : ℕ), 0 = 0 ∨ reachPos (cmpCfg (u + 0) (v + 0) p) (cmpCfg u v (p + 0))⊢ reachPos (cmpCfg (u + 1) (v + 0 + 1) p) (cmpCfg u v (p + (0 + 1)))
exact cmp_step u v p All goals completed! 🐙
· succ.inr k:ℕih:∀ (u v p : ℕ), k = 0 ∨ reachPos (cmpCfg (u + k) (v + k) p) (cmpCfg u v (p + k))u:ℕv:ℕp:ℕhrest:reachPos (cmpCfg (u + k) (v + k) (p + 1)) (cmpCfg u v (p + 1 + k))⊢ reachPos (cmpCfg (u + k + 1) (v + k + 1) p) (cmpCfg u v (p + (k + 1))) rw [show p + 1 + k = p + (k + 1) by u:ℕv:ℕp:ℕk:ℕ⊢ k = 0 ∨ reachPos (cmpCfg (u + k) (v + k) p) (cmpCfg u v (p + k)) omega All goals completed! 🐙] at hrest succ.inr k:ℕih:∀ (u v p : ℕ), k = 0 ∨ reachPos (cmpCfg (u + k) (v + k) p) (cmpCfg u v (p + k))u:ℕv:ℕp:ℕhrest:reachPos (cmpCfg (u + k) (v + k) (p + 1)) (cmpCfg u v (p + (k + 1)))⊢ reachPos (cmpCfg (u + k + 1) (v + k + 1) p) (cmpCfg u v (p + (k + 1)))
exact reachPos_trans (cmp_step (u + k) (v + k) p) hrest All goals completed! 🐙private theorem cmp_halt_eq (p : ℕ) :
∃ s cfg, nSteps weakCollatz27 s (cmpCfg 0 0 p) = some cfg ∧
step weakCollatz27 cfg = none := by p:ℕ⊢ ∃ s cfg, nSteps weakCollatz27 s (cmpCfg 0 0 p) = some cfg ∧ step weakCollatz27 cfg = none
unfold cmpCfg p:ℕ⊢ ∃ s cfg,
nSteps weakCollatz27 s
{ state := 16, tape := mkL (ones 0 (ListBlank.cons 0 (ones 0 B0))) (ListBlank.cons 0 (ones (2 * p) B0)) } =
some cfg ∧
step weakCollatz27 cfg = none
rw [ones_zero, p:ℕ⊢ ∃ s cfg,
nSteps weakCollatz27 s
{ state := 16, tape := mkL (ListBlank.cons 0 (ones 0 B0)) (ListBlank.cons 0 (ones (2 * p) B0)) } =
some cfg ∧
step weakCollatz27 cfg = none ones_zero, p:ℕ⊢ ∃ s cfg,
nSteps weakCollatz27 s { state := 16, tape := mkL (ListBlank.cons 0 B0) (ListBlank.cons 0 (ones (2 * p) B0)) } =
some cfg ∧
step weakCollatz27 cfg = none B0_cons_zero, p:ℕ⊢ ∃ s cfg,
nSteps weakCollatz27 s { state := 16, tape := mkL B0 (ListBlank.cons 0 (ones (2 * p) B0)) } = some cfg ∧
step weakCollatz27 cfg = none mkL_B0 p:ℕ⊢ ∃ s cfg,
nSteps weakCollatz27 s
{ state := 16, tape := { head := 0, left := B0, right := ListBlank.cons 0 (ones (2 * p) B0) } } =
some cfg ∧
step weakCollatz27 cfg = none] p:ℕ⊢ ∃ s cfg,
nSteps weakCollatz27 s
{ state := 16, tape := { head := 0, left := B0, right := ListBlank.cons 0 (ones (2 * p) B0) } } =
some cfg ∧
step weakCollatz27 cfg = none
have h1 := tr16_0 B0 ((ones (2 * p) B0).cons 0) p:ℕh1:step weakCollatz27 { state := 16, tape := { head := 0, left := B0, right := ListBlank.cons 0 (ones (2 * p) B0) } } =
some { state := 18, tape := mkL B0 (ListBlank.cons 0 (ListBlank.cons 0 (ones (2 * p) B0))) }⊢ ∃ s cfg,
nSteps weakCollatz27 s
{ state := 16, tape := { head := 0, left := B0, right := ListBlank.cons 0 (ones (2 * p) B0) } } =
some cfg ∧
step weakCollatz27 cfg = none
rw [mkL_B0 p:ℕh1:step weakCollatz27 { state := 16, tape := { head := 0, left := B0, right := ListBlank.cons 0 (ones (2 * p) B0) } } =
some
{ state := 18, tape := { head := 0, left := B0, right := ListBlank.cons 0 (ListBlank.cons 0 (ones (2 * p) B0)) } }⊢ ∃ s cfg,
nSteps weakCollatz27 s
{ state := 16, tape := { head := 0, left := B0, right := ListBlank.cons 0 (ones (2 * p) B0) } } =
some cfg ∧
step weakCollatz27 cfg = none] at h1 p:ℕh1:step weakCollatz27 { state := 16, tape := { head := 0, left := B0, right := ListBlank.cons 0 (ones (2 * p) B0) } } =
some
{ state := 18, tape := { head := 0, left := B0, right := ListBlank.cons 0 (ListBlank.cons 0 (ones (2 * p) B0)) } }⊢ ∃ s cfg,
nSteps weakCollatz27 s
{ state := 16, tape := { head := 0, left := B0, right := ListBlank.cons 0 (ones (2 * p) B0) } } =
some cfg ∧
step weakCollatz27 cfg = none
exact ⟨1, _, step_one h1, tr18_0 _ _⟩ All goals completed! 🐙private theorem cmp_lt_to_rest (u p : ℕ) :
reachPos (cmpCfg (u + 1) 0 p) (restCfg (u + 1) 0 p) := by u:ℕp:ℕ⊢ reachPos (cmpCfg (u + 1) 0 p) (restCfg (u + 1) 0 p)
unfold cmpCfg restCfg u:ℕp:ℕ⊢ reachPos { state := 16, tape := mkL (ones 0 (ListBlank.cons 0 (ones (u + 1) B0))) (ListBlank.cons 0 (ones (2 * p) B0)) }
{ state := 5, tape := Tape.mk' (ones 0 (ListBlank.cons 0 (ones (u + 1) B0))) (ListBlank.cons 0 (ones (2 * p) B0)) }
rw [ones_zero, u:ℕp:ℕ⊢ reachPos { state := 16, tape := mkL (ListBlank.cons 0 (ones (u + 1) B0)) (ListBlank.cons 0 (ones (2 * p) B0)) }
{ state := 5, tape := Tape.mk' (ListBlank.cons 0 (ones (u + 1) B0)) (ListBlank.cons 0 (ones (2 * p) B0)) } ErdosTernary15.Tape.mkL_cons u:ℕp:ℕ⊢ reachPos { state := 16, tape := { head := 0, left := ones (u + 1) B0, right := ListBlank.cons 0 (ones (2 * p) B0) } }
{ state := 5, tape := Tape.mk' (ListBlank.cons 0 (ones (u + 1) B0)) (ListBlank.cons 0 (ones (2 * p) B0)) }] u:ℕp:ℕ⊢ reachPos { state := 16, tape := { head := 0, left := ones (u + 1) B0, right := ListBlank.cons 0 (ones (2 * p) B0) } }
{ state := 5, tape := Tape.mk' (ListBlank.cons 0 (ones (u + 1) B0)) (ListBlank.cons 0 (ones (2 * p) B0)) }
refine step_then_reachPos (tr16_0 _ _) ?_ u:ℕp:ℕ⊢ reachPos { state := 18, tape := mkL (ones (u + 1) B0) (ListBlank.cons 0 (ListBlank.cons 0 (ones (2 * p) B0))) }
{ state := 5, tape := Tape.mk' (ListBlank.cons 0 (ones (u + 1) B0)) (ListBlank.cons 0 (ones (2 * p) B0)) }
rw [ones_succ u B0, u:ℕp:ℕ⊢ reachPos
{ state := 18, tape := mkL (ListBlank.cons 1 (ones u B0)) (ListBlank.cons 0 (ListBlank.cons 0 (ones (2 * p) B0))) }
{ state := 5,
tape := Tape.mk' (ListBlank.cons 0 (ListBlank.cons 1 (ones u B0))) (ListBlank.cons 0 (ones (2 * p) B0)) } ErdosTernary15.Tape.mkL_cons u:ℕp:ℕ⊢ reachPos
{ state := 18,
tape := { head := 1, left := ones u B0, right := ListBlank.cons 0 (ListBlank.cons 0 (ones (2 * p) B0)) } }
{ state := 5,
tape := Tape.mk' (ListBlank.cons 0 (ListBlank.cons 1 (ones u B0))) (ListBlank.cons 0 (ones (2 * p) B0)) }] u:ℕp:ℕ⊢ reachPos
{ state := 18,
tape := { head := 1, left := ones u B0, right := ListBlank.cons 0 (ListBlank.cons 0 (ones (2 * p) B0)) } }
{ state := 5,
tape := Tape.mk' (ListBlank.cons 0 (ListBlank.cons 1 (ones u B0))) (ListBlank.cons 0 (ones (2 * p) B0)) }
refine step_then_reachPos (tr18_1 _ _) ?_ u:ℕp:ℕ⊢ reachPos
{ state := 19,
tape := Tape.mk' (ListBlank.cons 1 (ones u B0)) (ListBlank.cons 0 (ListBlank.cons 0 (ones (2 * p) B0))) }
{ state := 5,
tape := Tape.mk' (ListBlank.cons 0 (ListBlank.cons 1 (ones u B0))) (ListBlank.cons 0 (ones (2 * p) B0)) }
rw [← ones_succ u B0, u:ℕp:ℕ⊢ reachPos { state := 19, tape := Tape.mk' (ones (u + 1) B0) (ListBlank.cons 0 (ListBlank.cons 0 (ones (2 * p) B0))) }
{ state := 5, tape := Tape.mk' (ListBlank.cons 0 (ones (u + 1) B0)) (ListBlank.cons 0 (ones (2 * p) B0)) } ErdosTernary15.Tape.mk'_cons u:ℕp:ℕ⊢ reachPos { state := 19, tape := { head := 0, left := ones (u + 1) B0, right := ListBlank.cons 0 (ones (2 * p) B0) } }
{ state := 5, tape := Tape.mk' (ListBlank.cons 0 (ones (u + 1) B0)) (ListBlank.cons 0 (ones (2 * p) B0)) }] u:ℕp:ℕ⊢ reachPos { state := 19, tape := { head := 0, left := ones (u + 1) B0, right := ListBlank.cons 0 (ones (2 * p) B0) } }
{ state := 5, tape := Tape.mk' (ListBlank.cons 0 (ones (u + 1) B0)) (ListBlank.cons 0 (ones (2 * p) B0)) }
exact reachPos_step (tr19_0 _ _) All goals completed! 🐙private theorem cmp_gt_advance (v x : ℕ) (hx : 1 ≤ x) :
reachPos (cmpCfg 0 (v + 1) x) (stageCfg (x + 1) (x + 1)) := by v:ℕx:ℕhx:1 ≤ x⊢ reachPos (cmpCfg 0 (v + 1) x) (stageCfg (x + 1) (x + 1))
unfold cmpCfg v:ℕx:ℕhx:1 ≤ x⊢ reachPos { state := 16, tape := mkL (ones (v + 1) (ListBlank.cons 0 (ones 0 B0))) (ListBlank.cons 0 (ones (2 * x) B0)) }
(stageCfg (x + 1) (x + 1))
let Rx := (ones (2 * x) B0).cons 0 v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 16, tape := mkL (ones (v + 1) (ListBlank.cons 0 (ones 0 B0))) (ListBlank.cons 0 (ones (2 * x) B0)) }
(stageCfg (x + 1) (x + 1))
change reachPos ⟨16, mkL (ones (v + 1) ((ones 0 B0).cons 0)) Rx⟩ _ v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 16, tape := mkL (ones (v + 1) (ListBlank.cons 0 (ones 0 B0))) Rx } (stageCfg (x + 1) (x + 1))
rw [ones_zero, v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 16, tape := mkL (ones (v + 1) (ListBlank.cons 0 B0)) Rx } (stageCfg (x + 1) (x + 1)) B0_cons_zero, v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 16, tape := mkL (ones (v + 1) B0) Rx } (stageCfg (x + 1) (x + 1)) ones_succ v B0, v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 16, tape := mkL (ListBlank.cons 1 (ones v B0)) Rx } (stageCfg (x + 1) (x + 1)) ErdosTernary15.Tape.mkL_cons v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 16, tape := { head := 1, left := ones v B0, right := Rx } } (stageCfg (x + 1) (x + 1))] v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 16, tape := { head := 1, left := ones v B0, right := Rx } } (stageCfg (x + 1) (x + 1))
refine step_then_reachPos (tr16_1 _ _) ?_ v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 17, tape := mkL (ones v B0) (ListBlank.cons 1 Rx) } (stageCfg (x + 1) (x + 1))
change reachPos ⟨17, mkL (ones v B0) (ones 1 Rx)⟩ _ v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 17, tape := mkL (ones v B0) (ones 1 Rx) } (stageCfg (x + 1) (x + 1))
refine nSteps_then_reachPos (sweep1L tr17_1 v B0 (ones 1 Rx)) ?_ v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 17, tape := mkL B0 (ones v (ones 1 Rx)) } (stageCfg (x + 1) (x + 1))
rw [← ones_add v 1 Rx, v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 17, tape := mkL B0 (ones (v + 1) Rx) } (stageCfg (x + 1) (x + 1)) mkL_B0 v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 17, tape := { head := 0, left := B0, right := ones (v + 1) Rx } } (stageCfg (x + 1) (x + 1))] v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 17, tape := { head := 0, left := B0, right := ones (v + 1) Rx } } (stageCfg (x + 1) (x + 1))
refine step_then_reachPos (tr17_0 _ _) ?_ v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 20, tape := mkL B0 (ListBlank.cons 0 (ones (v + 1) Rx)) } (stageCfg (x + 1) (x + 1))
rw [mkL_B0 v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 20, tape := { head := 0, left := B0, right := ListBlank.cons 0 (ones (v + 1) Rx) } }
(stageCfg (x + 1) (x + 1))] v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 20, tape := { head := 0, left := B0, right := ListBlank.cons 0 (ones (v + 1) Rx) } }
(stageCfg (x + 1) (x + 1))
refine step_then_reachPos (tr20_0 _ _) ?_ v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 22, tape := Tape.mk' (ListBlank.cons 0 B0) (ListBlank.cons 0 (ones (v + 1) Rx)) }
(stageCfg (x + 1) (x + 1))
rw [B0_cons_zero, v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 22, tape := Tape.mk' B0 (ListBlank.cons 0 (ones (v + 1) Rx)) } (stageCfg (x + 1) (x + 1)) ErdosTernary15.Tape.mk'_cons v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 22, tape := { head := 0, left := B0, right := ones (v + 1) Rx } } (stageCfg (x + 1) (x + 1))] v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 22, tape := { head := 0, left := B0, right := ones (v + 1) Rx } } (stageCfg (x + 1) (x + 1))
refine step_then_reachPos (tr22_0 _ _) ?_ v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 0, tape := Tape.mk' (ListBlank.cons 0 B0) (ones (v + 1) Rx) } (stageCfg (x + 1) (x + 1))
rw [B0_cons_zero v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 0, tape := Tape.mk' B0 (ones (v + 1) Rx) } (stageCfg (x + 1) (x + 1))] v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 0, tape := Tape.mk' B0 (ones (v + 1) Rx) } (stageCfg (x + 1) (x + 1))
refine nSteps_then_reachPos (erase1R tr0_1 (v + 1) Rx) ?_ v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 0, tape := Tape.mk' B0 Rx } (stageCfg (x + 1) (x + 1))
dsimp only [Rx] v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 0, tape := Tape.mk' B0 (ListBlank.cons 0 (ones (2 * x) B0)) } (stageCfg (x + 1) (x + 1))
rw [ErdosTernary15.Tape.mk'_cons v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 0, tape := { head := 0, left := B0, right := ones (2 * x) B0 } } (stageCfg (x + 1) (x + 1))] v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 0, tape := { head := 0, left := B0, right := ones (2 * x) B0 } } (stageCfg (x + 1) (x + 1))
refine step_then_reachPos (tr0_0 _ _) ?_ v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 2, tape := Tape.mk' (ListBlank.cons 1 B0) (ones (2 * x) B0) } (stageCfg (x + 1) (x + 1))
change reachPos ⟨2, Tape.mk' (ones 1 B0) (ones (2 * x) B0)⟩ _ v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 2, tape := Tape.mk' (ones 1 B0) (ones (2 * x) B0) } (stageCfg (x + 1) (x + 1))
refine nSteps_then_reachPos (sweep1R tr2_1 (2 * x) (ones 1 B0) B0) ?_ v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 2, tape := Tape.mk' (ones (2 * x) (ones 1 B0)) B0 } (stageCfg (x + 1) (x + 1))
rw [← ones_add (2 * x) 1 B0, v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 2, tape := Tape.mk' (ones (2 * x + 1) B0) B0 } (stageCfg (x + 1) (x + 1)) ErdosTernary15.Tape.mk'_B0 v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 2, tape := { head := 0, left := ones (2 * x + 1) B0, right := B0 } } (stageCfg (x + 1) (x + 1))] v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 2, tape := { head := 0, left := ones (2 * x + 1) B0, right := B0 } } (stageCfg (x + 1) (x + 1))
refine step_then_reachPos (tr2_0 _ _) ?_ v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 3, tape := mkL (ones (2 * x + 1) B0) (ListBlank.cons 1 B0) } (stageCfg (x + 1) (x + 1))
change reachPos ⟨3, mkL (ones (2 * x + 1) B0) (ones 1 B0)⟩ _ v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 3, tape := mkL (ones (2 * x + 1) B0) (ones 1 B0) } (stageCfg (x + 1) (x + 1))
refine nSteps_then_reachPos (sweep1L tr3_1 (2 * x + 1) B0 (ones 1 B0)) ?_ v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 3, tape := mkL B0 (ones (2 * x + 1) (ones 1 B0)) } (stageCfg (x + 1) (x + 1))
rw [← ones_add (2 * x + 1) 1 B0, v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 3, tape := mkL B0 (ones (2 * x + 1 + 1) B0) } (stageCfg (x + 1) (x + 1)) show 2 * x + 1 + 1 = 2 * (x + 1) by v:ℕx:ℕhx:1 ≤ x⊢ reachPos (cmpCfg 0 (v + 1) x) (stageCfg (x + 1) (x + 1)) omega All goals completed! 🐙, mkL_B0 v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 3, tape := { head := 0, left := B0, right := ones (2 * (x + 1)) B0 } } (stageCfg (x + 1) (x + 1))] v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 3, tape := { head := 0, left := B0, right := ones (2 * (x + 1)) B0 } } (stageCfg (x + 1) (x + 1))
refine step_then_reachPos (tr3_0 _ _) ?_ v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 1, tape := mkL B0 (ListBlank.cons 0 (ones (2 * (x + 1)) B0)) } (stageCfg (x + 1) (x + 1))
rw [mkL_B0 v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 1, tape := { head := 0, left := B0, right := ListBlank.cons 0 (ones (2 * (x + 1)) B0) } }
(stageCfg (x + 1) (x + 1))] v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 1, tape := { head := 0, left := B0, right := ListBlank.cons 0 (ones (2 * (x + 1)) B0) } }
(stageCfg (x + 1) (x + 1))
refine step_then_reachPos (tr1_0 _ _) ?_ v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)⊢ reachPos { state := 5, tape := Tape.mk' (ListBlank.cons 0 B0) (ListBlank.cons 0 (ones (2 * (x + 1)) B0)) }
(stageCfg (x + 1) (x + 1))
have hrest_eq : (⟨5, Tape.mk' (B0.cons 0) ((ones (2 * (x + 1)) B0).cons 0)⟩ : Cfg 27 2) =
restCfg 0 0 (x + 1) := by v:ℕx:ℕhx:1 ≤ x⊢ reachPos (cmpCfg 0 (v + 1) x) (stageCfg (x + 1) (x + 1))
simp only [restCfg, ones_zero, B0_cons_zero] v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)hrest_eq:{ state := 5, tape := Tape.mk' (ListBlank.cons 0 B0) (ListBlank.cons 0 (ones (2 * (x + 1)) B0)) } = restCfg 0 0 (x + 1)⊢ reachPos { state := 5, tape := Tape.mk' (ListBlank.cons 0 B0) (ListBlank.cons 0 (ones (2 * (x + 1)) B0)) }
(stageCfg (x + 1) (x + 1))
rw [hrest_eq v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)hrest_eq:{ state := 5, tape := Tape.mk' (ListBlank.cons 0 B0) (ListBlank.cons 0 (ones (2 * (x + 1)) B0)) } = restCfg 0 0 (x + 1)⊢ reachPos (restCfg 0 0 (x + 1)) (stageCfg (x + 1) (x + 1))] v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)hrest_eq:{ state := 5, tape := Tape.mk' (ListBlank.cons 0 B0) (ListBlank.cons 0 (ones (2 * (x + 1)) B0)) } = restCfg 0 0 (x + 1)⊢ reachPos (restCfg 0 0 (x + 1)) (stageCfg (x + 1) (x + 1))
exact rest_from_zero (x + 1) (by v:ℕx:ℕhx:1 ≤ xRx:ListBlank (Fin 2) := ListBlank.cons 0 (ones (2 * x) B0)hrest_eq:{ state := 5, tape := Tape.mk' (ListBlank.cons 0 B0) (ListBlank.cons 0 (ones (2 * (x + 1)) B0)) } = restCfg 0 0 (x + 1)⊢ 1 ≤ x + 1 omega All goals completed! 🐙)Blank-Tape Warm-Up & Round Outcomes
private theorem stage_round_halt (x y : ℕ) (hx : 3 ≤ x) (hy : 2 ≤ y) (hhit : terras y = x) :
∃ s cfg, nSteps weakCollatz27 s (stageCfg x y) = some cfg ∧
step weakCollatz27 cfg = none := by x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhhit:terras y = x⊢ ∃ s cfg, nSteps weakCollatz27 s (stageCfg x y) = some cfg ∧ step weakCollatz27 cfg = none
have hcmp1 := terras_to_cmp1 x y (by x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhhit:terras y = x⊢ 2 ≤ x omega All goals completed! 🐙) hy x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhhit:terras y = xhcmp1:reachPos (stageCfg x y) (cmpCfg (x - 1) (terras y - 1) 1)⊢ ∃ s cfg, nSteps weakCollatz27 s (stageCfg x y) = some cfg ∧ step weakCollatz27 cfg = none
rw [hhit x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhhit:terras y = xhcmp1:reachPos (stageCfg x y) (cmpCfg (x - 1) (x - 1) 1)⊢ ∃ s cfg, nSteps weakCollatz27 s (stageCfg x y) = some cfg ∧ step weakCollatz27 cfg = none] at hcmp1 x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhhit:terras y = xhcmp1:reachPos (stageCfg x y) (cmpCfg (x - 1) (x - 1) 1)⊢ ∃ s cfg, nSteps weakCollatz27 s (stageCfg x y) = some cfg ∧ step weakCollatz27 cfg = none
have hmany : reachPos (cmpCfg (x - 1) (x - 1) 1) (cmpCfg 0 0 x) := by
rcases cmp_many 0 0 1 (x - 1) with h0 | hp inl x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhhit:terras y = xhcmp1:reachPos (stageCfg x y) (cmpCfg (x - 1) (x - 1) 1)h0:x - 1 = 0⊢ reachPos (cmpCfg (x - 1) (x - 1) 1) (cmpCfg 0 0 x)inr x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhhit:terras y = xhcmp1:reachPos (stageCfg x y) (cmpCfg (x - 1) (x - 1) 1)hp:reachPos (cmpCfg (0 + (x - 1)) (0 + (x - 1)) 1) (cmpCfg 0 0 (1 + (x - 1)))⊢ reachPos (cmpCfg (x - 1) (x - 1) 1) (cmpCfg 0 0 x)
· inl x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhhit:terras y = xhcmp1:reachPos (stageCfg x y) (cmpCfg (x - 1) (x - 1) 1)h0:x - 1 = 0⊢ reachPos (cmpCfg (x - 1) (x - 1) 1) (cmpCfg 0 0 x) exfalso inl x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhhit:terras y = xhcmp1:reachPos (stageCfg x y) (cmpCfg (x - 1) (x - 1) 1)h0:x - 1 = 0⊢ False; omega All goals completed! 🐙
· inr x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhhit:terras y = xhcmp1:reachPos (stageCfg x y) (cmpCfg (x - 1) (x - 1) 1)hp:reachPos (cmpCfg (0 + (x - 1)) (0 + (x - 1)) 1) (cmpCfg 0 0 (1 + (x - 1)))⊢ reachPos (cmpCfg (x - 1) (x - 1) 1) (cmpCfg 0 0 x) rw [Nat.zero_add, inr x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhhit:terras y = xhcmp1:reachPos (stageCfg x y) (cmpCfg (x - 1) (x - 1) 1)hp:reachPos (cmpCfg (x - 1) (x - 1) 1) (cmpCfg 0 0 (1 + (x - 1)))⊢ reachPos (cmpCfg (x - 1) (x - 1) 1) (cmpCfg 0 0 x) show 1 + (x - 1) = x by x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhhit:terras y = x⊢ ∃ s cfg, nSteps weakCollatz27 s (stageCfg x y) = some cfg ∧ step weakCollatz27 cfg = none omega All goals completed! 🐙] at hp inr x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhhit:terras y = xhcmp1:reachPos (stageCfg x y) (cmpCfg (x - 1) (x - 1) 1)hp:reachPos (cmpCfg (x - 1) (x - 1) 1) (cmpCfg 0 0 x)⊢ reachPos (cmpCfg (x - 1) (x - 1) 1) (cmpCfg 0 0 x)
exact hp x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhhit:terras y = xhcmp1:reachPos (stageCfg x y) (cmpCfg (x - 1) (x - 1) 1)hmany:reachPos (cmpCfg (x - 1) (x - 1) 1) (cmpCfg 0 0 x)⊢ ∃ s cfg, nSteps weakCollatz27 s (stageCfg x y) = some cfg ∧ step weakCollatz27 cfg = none
obtain ⟨s₁, _, hs₁⟩ := reachPos_trans hcmp1 hmany x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhhit:terras y = xhcmp1:reachPos (stageCfg x y) (cmpCfg (x - 1) (x - 1) 1)hmany:reachPos (cmpCfg (x - 1) (x - 1) 1) (cmpCfg 0 0 x)s₁:ℕleft✝:1 ≤ s₁hs₁:nSteps weakCollatz27 s₁ (stageCfg x y) = some (cmpCfg 0 0 x)⊢ ∃ s cfg, nSteps weakCollatz27 s (stageCfg x y) = some cfg ∧ step weakCollatz27 cfg = none
obtain ⟨s₂, cfg, hs₂, hnone⟩ := cmp_halt_eq x x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhhit:terras y = xhcmp1:reachPos (stageCfg x y) (cmpCfg (x - 1) (x - 1) 1)hmany:reachPos (cmpCfg (x - 1) (x - 1) 1) (cmpCfg 0 0 x)s₁:ℕleft✝:1 ≤ s₁hs₁:nSteps weakCollatz27 s₁ (stageCfg x y) = some (cmpCfg 0 0 x)s₂:ℕcfg:Cfg 27 2hs₂:nSteps weakCollatz27 s₂ (cmpCfg 0 0 x) = some cfghnone:step weakCollatz27 cfg = none⊢ ∃ s cfg, nSteps weakCollatz27 s (stageCfg x y) = some cfg ∧ step weakCollatz27 cfg = none
exact ⟨s₁ + s₂, cfg, nSteps_bind_eq hs₁ hs₂, hnone⟩ All goals completed! 🐙private theorem stage_round_lt (x y : ℕ) (hx : 2 ≤ x) (hy : 2 ≤ y) (hlt : terras y < x) :
reachPos (stageCfg x y) (stageCfg x (terras y)) := by x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < x⊢ reachPos (stageCfg x y) (stageCfg x (terras y))
let z := terras y x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras y⊢ reachPos (stageCfg x y) (stageCfg x (terras y))
have hz : 1 ≤ z := terras_pos_of_pos (by x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras y⊢ 1 ≤ y omega All goals completed! 🐙) x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ z⊢ reachPos (stageCfg x y) (stageCfg x (terras y))
refine reachPos_trans (terras_to_cmp1 x y hx hy) ?_ x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ z⊢ reachPos (cmpCfg (x - 1) (terras y - 1) 1) (stageCfg x (terras y))
let q := z - 1 x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1⊢ reachPos (cmpCfg (x - 1) (terras y - 1) 1) (stageCfg x (terras y))
let uRem := x - z - 1 x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1⊢ reachPos (cmpCfg (x - 1) (terras y - 1) 1) (stageCfg x (terras y))
have hsub_x : x - 1 = (uRem + 1) + q := by x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < x⊢ reachPos (stageCfg x y) (stageCfg x (terras y)) dsimp [uRem, q] x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1⊢ x - 1 = x - z - 1 + 1 + (z - 1); omega x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1hsub_x:x - 1 = uRem + 1 + q⊢ reachPos (cmpCfg (x - 1) (terras y - 1) 1) (stageCfg x (terras y))
have hsub_z : z - 1 = 0 + q := by x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < x⊢ reachPos (stageCfg x y) (stageCfg x (terras y)) dsimp [q] x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1hsub_x:x - 1 = uRem + 1 + q⊢ z - 1 = 0 + (z - 1); omega x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1hsub_x:x - 1 = uRem + 1 + qhsub_z:z - 1 = 0 + q⊢ reachPos (cmpCfg (x - 1) (terras y - 1) 1) (stageCfg x (terras y))
rw [hsub_x, x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1hsub_x:x - 1 = uRem + 1 + qhsub_z:z - 1 = 0 + q⊢ reachPos (cmpCfg (uRem + 1 + q) (terras y - 1) 1) (stageCfg x (terras y)) hsub_z x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1hsub_x:x - 1 = uRem + 1 + qhsub_z:z - 1 = 0 + q⊢ reachPos (cmpCfg (uRem + 1 + q) (0 + q) 1) (stageCfg x (terras y))] x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1hsub_x:x - 1 = uRem + 1 + qhsub_z:z - 1 = 0 + q⊢ reachPos (cmpCfg (uRem + 1 + q) (0 + q) 1) (stageCfg x (terras y))
have hmid : reachPos (cmpCfg ((uRem + 1) + q) (0 + q) 1) (restCfg (uRem + 1) 0 (q + 1)) := by x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < x⊢ reachPos (stageCfg x y) (stageCfg x (terras y))
rcases cmp_many (uRem + 1) 0 1 q with hq0 | hp inl x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1hsub_x:x - 1 = uRem + 1 + qhsub_z:z - 1 = 0 + qhq0:q = 0⊢ reachPos (cmpCfg (uRem + 1 + q) (0 + q) 1) (restCfg (uRem + 1) 0 (q + 1))inr x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1hsub_x:x - 1 = uRem + 1 + qhsub_z:z - 1 = 0 + qhp:reachPos (cmpCfg (uRem + 1 + q) (0 + q) 1) (cmpCfg (uRem + 1) 0 (1 + q))⊢ reachPos (cmpCfg (uRem + 1 + q) (0 + q) 1) (restCfg (uRem + 1) 0 (q + 1))
· inl x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1hsub_x:x - 1 = uRem + 1 + qhsub_z:z - 1 = 0 + qhq0:q = 0⊢ reachPos (cmpCfg (uRem + 1 + q) (0 + q) 1) (restCfg (uRem + 1) 0 (q + 1)) rw [hq0, inl x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1hsub_x:x - 1 = uRem + 1 + qhsub_z:z - 1 = 0 + qhq0:q = 0⊢ reachPos (cmpCfg (uRem + 1 + 0) (0 + 0) 1) (restCfg (uRem + 1) 0 (0 + 1)) Nat.add_zero, inl x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1hsub_x:x - 1 = uRem + 1 + qhsub_z:z - 1 = 0 + qhq0:q = 0⊢ reachPos (cmpCfg (uRem + 1) (0 + 0) 1) (restCfg (uRem + 1) 0 (0 + 1)) Nat.add_zero inl x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1hsub_x:x - 1 = uRem + 1 + qhsub_z:z - 1 = 0 + qhq0:q = 0⊢ reachPos (cmpCfg (uRem + 1) (0 + 0) 1) (restCfg (uRem + 1) 0 (0 + 1))] inl x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1hsub_x:x - 1 = uRem + 1 + qhsub_z:z - 1 = 0 + qhq0:q = 0⊢ reachPos (cmpCfg (uRem + 1) (0 + 0) 1) (restCfg (uRem + 1) 0 (0 + 1))
exact cmp_lt_to_rest uRem 1 All goals completed! 🐙
· inr x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1hsub_x:x - 1 = uRem + 1 + qhsub_z:z - 1 = 0 + qhp:reachPos (cmpCfg (uRem + 1 + q) (0 + q) 1) (cmpCfg (uRem + 1) 0 (1 + q))⊢ reachPos (cmpCfg (uRem + 1 + q) (0 + q) 1) (restCfg (uRem + 1) 0 (q + 1)) rw [show 1 + q = q + 1 by x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < x⊢ reachPos (stageCfg x y) (stageCfg x (terras y)) omega All goals completed! 🐙] at hp inr x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1hsub_x:x - 1 = uRem + 1 + qhsub_z:z - 1 = 0 + qhp:reachPos (cmpCfg (uRem + 1 + q) (0 + q) 1) (cmpCfg (uRem + 1) 0 (q + 1))⊢ reachPos (cmpCfg (uRem + 1 + q) (0 + q) 1) (restCfg (uRem + 1) 0 (q + 1))
exact reachPos_trans hp (cmp_lt_to_rest uRem (q + 1)) x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1hsub_x:x - 1 = uRem + 1 + qhsub_z:z - 1 = 0 + qhmid:reachPos (cmpCfg (uRem + 1 + q) (0 + q) 1) (restCfg (uRem + 1) 0 (q + 1))⊢ reachPos (cmpCfg (uRem + 1 + q) (0 + q) 1) (stageCfg x (terras y))
rcases rest_many (uRem + 1) 0 0 (q + 1) with h0 | hrm inl x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1hsub_x:x - 1 = uRem + 1 + qhsub_z:z - 1 = 0 + qhmid:reachPos (cmpCfg (uRem + 1 + q) (0 + q) 1) (restCfg (uRem + 1) 0 (q + 1))h0:q + 1 = 0⊢ reachPos (cmpCfg (uRem + 1 + q) (0 + q) 1) (stageCfg x (terras y))inr x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1hsub_x:x - 1 = uRem + 1 + qhsub_z:z - 1 = 0 + qhmid:reachPos (cmpCfg (uRem + 1 + q) (0 + q) 1) (restCfg (uRem + 1) 0 (q + 1))hrm:reachPos (restCfg (uRem + 1) 0 (0 + (q + 1))) (restCfg (uRem + 1 + (q + 1)) (0 + (q + 1)) 0)⊢ reachPos (cmpCfg (uRem + 1 + q) (0 + q) 1) (stageCfg x (terras y))
· inl x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1hsub_x:x - 1 = uRem + 1 + qhsub_z:z - 1 = 0 + qhmid:reachPos (cmpCfg (uRem + 1 + q) (0 + q) 1) (restCfg (uRem + 1) 0 (q + 1))h0:q + 1 = 0⊢ reachPos (cmpCfg (uRem + 1 + q) (0 + q) 1) (stageCfg x (terras y)) exfalso inl x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1hsub_x:x - 1 = uRem + 1 + qhsub_z:z - 1 = 0 + qhmid:reachPos (cmpCfg (uRem + 1 + q) (0 + q) 1) (restCfg (uRem + 1) 0 (q + 1))h0:q + 1 = 0⊢ False; omega All goals completed! 🐙
· inr x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1hsub_x:x - 1 = uRem + 1 + qhsub_z:z - 1 = 0 + qhmid:reachPos (cmpCfg (uRem + 1 + q) (0 + q) 1) (restCfg (uRem + 1) 0 (q + 1))hrm:reachPos (restCfg (uRem + 1) 0 (0 + (q + 1))) (restCfg (uRem + 1 + (q + 1)) (0 + (q + 1)) 0)⊢ reachPos (cmpCfg (uRem + 1 + q) (0 + q) 1) (stageCfg x (terras y)) have hrm' : reachPos (restCfg (uRem + 1) 0 (q + 1)) (restCfg x z 0) := by x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < x⊢ reachPos (stageCfg x y) (stageCfg x (terras y))
have heq1 : 0 + (q + 1) = q + 1 := Nat.zero_add (q + 1) x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1hsub_x:x - 1 = uRem + 1 + qhsub_z:z - 1 = 0 + qhmid:reachPos (cmpCfg (uRem + 1 + q) (0 + q) 1) (restCfg (uRem + 1) 0 (q + 1))hrm:reachPos (restCfg (uRem + 1) 0 (0 + (q + 1))) (restCfg (uRem + 1 + (q + 1)) (0 + (q + 1)) 0)heq1:0 + (q + 1) = q + 1⊢ reachPos (restCfg (uRem + 1) 0 (q + 1)) (restCfg x z 0)
have heq2 : uRem + 1 + (q + 1) = x := by x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < x⊢ reachPos (stageCfg x y) (stageCfg x (terras y)) dsimp [uRem, q] x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1hsub_x:x - 1 = uRem + 1 + qhsub_z:z - 1 = 0 + qhmid:reachPos (cmpCfg (uRem + 1 + q) (0 + q) 1) (restCfg (uRem + 1) 0 (q + 1))hrm:reachPos (restCfg (uRem + 1) 0 (0 + (q + 1))) (restCfg (uRem + 1 + (q + 1)) (0 + (q + 1)) 0)heq1:0 + (q + 1) = q + 1⊢ x - z - 1 + 1 + (z - 1 + 1) = x; omega x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1hsub_x:x - 1 = uRem + 1 + qhsub_z:z - 1 = 0 + qhmid:reachPos (cmpCfg (uRem + 1 + q) (0 + q) 1) (restCfg (uRem + 1) 0 (q + 1))hrm:reachPos (restCfg (uRem + 1) 0 (0 + (q + 1))) (restCfg (uRem + 1 + (q + 1)) (0 + (q + 1)) 0)heq1:0 + (q + 1) = q + 1heq2:uRem + 1 + (q + 1) = x⊢ reachPos (restCfg (uRem + 1) 0 (q + 1)) (restCfg x z 0)
have heq3 : q + 1 = z := by x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < x⊢ reachPos (stageCfg x y) (stageCfg x (terras y)) dsimp [q] x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1hsub_x:x - 1 = uRem + 1 + qhsub_z:z - 1 = 0 + qhmid:reachPos (cmpCfg (uRem + 1 + q) (0 + q) 1) (restCfg (uRem + 1) 0 (q + 1))hrm:reachPos (restCfg (uRem + 1) 0 (0 + (q + 1))) (restCfg (uRem + 1 + (q + 1)) (0 + (q + 1)) 0)heq1:0 + (q + 1) = q + 1heq2:uRem + 1 + (q + 1) = x⊢ z - 1 + 1 = z; omega x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1hsub_x:x - 1 = uRem + 1 + qhsub_z:z - 1 = 0 + qhmid:reachPos (cmpCfg (uRem + 1 + q) (0 + q) 1) (restCfg (uRem + 1) 0 (q + 1))hrm:reachPos (restCfg (uRem + 1) 0 (0 + (q + 1))) (restCfg (uRem + 1 + (q + 1)) (0 + (q + 1)) 0)heq1:0 + (q + 1) = q + 1heq2:uRem + 1 + (q + 1) = xheq3:q + 1 = z⊢ reachPos (restCfg (uRem + 1) 0 (q + 1)) (restCfg x z 0)
rw [heq1, x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1hsub_x:x - 1 = uRem + 1 + qhsub_z:z - 1 = 0 + qhmid:reachPos (cmpCfg (uRem + 1 + q) (0 + q) 1) (restCfg (uRem + 1) 0 (q + 1))hrm:reachPos (restCfg (uRem + 1) 0 (q + 1)) (restCfg (uRem + 1 + (q + 1)) (q + 1) 0)heq1:0 + (q + 1) = q + 1heq2:uRem + 1 + (q + 1) = xheq3:q + 1 = z⊢ reachPos (restCfg (uRem + 1) 0 (q + 1)) (restCfg x z 0) heq2 x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1hsub_x:x - 1 = uRem + 1 + qhsub_z:z - 1 = 0 + qhmid:reachPos (cmpCfg (uRem + 1 + q) (0 + q) 1) (restCfg (uRem + 1) 0 (q + 1))hrm:reachPos (restCfg (uRem + 1) 0 (q + 1)) (restCfg x (q + 1) 0)heq1:0 + (q + 1) = q + 1heq2:uRem + 1 + (q + 1) = xheq3:q + 1 = z⊢ reachPos (restCfg (uRem + 1) 0 (q + 1)) (restCfg x z 0)] at hrm x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1hsub_x:x - 1 = uRem + 1 + qhsub_z:z - 1 = 0 + qhmid:reachPos (cmpCfg (uRem + 1 + q) (0 + q) 1) (restCfg (uRem + 1) 0 (q + 1))hrm:reachPos (restCfg (uRem + 1) 0 (q + 1)) (restCfg x (q + 1) 0)heq1:0 + (q + 1) = q + 1heq2:uRem + 1 + (q + 1) = xheq3:q + 1 = z⊢ reachPos (restCfg (uRem + 1) 0 (q + 1)) (restCfg x z 0)
have hfin_eq : restCfg x (q + 1) 0 = restCfg x z 0 := by x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < x⊢ reachPos (stageCfg x y) (stageCfg x (terras y)) rw [heq3 x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1hsub_x:x - 1 = uRem + 1 + qhsub_z:z - 1 = 0 + qhmid:reachPos (cmpCfg (uRem + 1 + q) (0 + q) 1) (restCfg (uRem + 1) 0 (q + 1))hrm:reachPos (restCfg (uRem + 1) 0 (q + 1)) (restCfg x (q + 1) 0)heq1:0 + (q + 1) = q + 1heq2:uRem + 1 + (q + 1) = xheq3:q + 1 = z⊢ restCfg x z 0 = restCfg x z 0] x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1hsub_x:x - 1 = uRem + 1 + qhsub_z:z - 1 = 0 + qhmid:reachPos (cmpCfg (uRem + 1 + q) (0 + q) 1) (restCfg (uRem + 1) 0 (q + 1))hrm:reachPos (restCfg (uRem + 1) 0 (q + 1)) (restCfg x (q + 1) 0)heq1:0 + (q + 1) = q + 1heq2:uRem + 1 + (q + 1) = xheq3:q + 1 = zhfin_eq:restCfg x (q + 1) 0 = restCfg x z 0⊢ reachPos (restCfg (uRem + 1) 0 (q + 1)) (restCfg x z 0)
rw [← hfin_eq x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1hsub_x:x - 1 = uRem + 1 + qhsub_z:z - 1 = 0 + qhmid:reachPos (cmpCfg (uRem + 1 + q) (0 + q) 1) (restCfg (uRem + 1) 0 (q + 1))hrm:reachPos (restCfg (uRem + 1) 0 (q + 1)) (restCfg x (q + 1) 0)heq1:0 + (q + 1) = q + 1heq2:uRem + 1 + (q + 1) = xheq3:q + 1 = zhfin_eq:restCfg x (q + 1) 0 = restCfg x z 0⊢ reachPos (restCfg (uRem + 1) 0 (q + 1)) (restCfg x (q + 1) 0)] x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1hsub_x:x - 1 = uRem + 1 + qhsub_z:z - 1 = 0 + qhmid:reachPos (cmpCfg (uRem + 1 + q) (0 + q) 1) (restCfg (uRem + 1) 0 (q + 1))hrm:reachPos (restCfg (uRem + 1) 0 (q + 1)) (restCfg x (q + 1) 0)heq1:0 + (q + 1) = q + 1heq2:uRem + 1 + (q + 1) = xheq3:q + 1 = zhfin_eq:restCfg x (q + 1) 0 = restCfg x z 0⊢ reachPos (restCfg (uRem + 1) 0 (q + 1)) (restCfg x (q + 1) 0)
exact hrm inr x:ℕy:ℕhx:2 ≤ xhy:2 ≤ yhlt:terras y < xz:ℕ := terras yhz:1 ≤ zq:ℕ := z - 1uRem:ℕ := x - z - 1hsub_x:x - 1 = uRem + 1 + qhsub_z:z - 1 = 0 + qhmid:reachPos (cmpCfg (uRem + 1 + q) (0 + q) 1) (restCfg (uRem + 1) 0 (q + 1))hrm:reachPos (restCfg (uRem + 1) 0 (0 + (q + 1))) (restCfg (uRem + 1 + (q + 1)) (0 + (q + 1)) 0)hrm':reachPos (restCfg (uRem + 1) 0 (q + 1)) (restCfg x z 0)⊢ reachPos (cmpCfg (uRem + 1 + q) (0 + q) 1) (stageCfg x (terras y))
exact reachPos_trans hmid (reachPos_trans hrm' (rest_exit x z)) All goals completed! 🐙private theorem stage_round_gt (x y : ℕ) (hx : 3 ≤ x) (hy : 2 ≤ y) (hgt : x < terras y) :
reachPos (stageCfg x y) (stageCfg (x + 1) (x + 1)) := by x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhgt:x < terras y⊢ reachPos (stageCfg x y) (stageCfg (x + 1) (x + 1))
let z := terras y x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhgt:x < terras yz:ℕ := terras y⊢ reachPos (stageCfg x y) (stageCfg (x + 1) (x + 1))
refine reachPos_trans (terras_to_cmp1 x y (by x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhgt:x < terras yz:ℕ := terras y⊢ 2 ≤ x omega All goals completed! 🐙) hy) ?_
let q := x - 1 x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhgt:x < terras yz:ℕ := terras yq:ℕ := x - 1⊢ reachPos (cmpCfg (x - 1) (terras y - 1) 1) (stageCfg (x + 1) (x + 1))
let vRem := z - x - 1 x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhgt:x < terras yz:ℕ := terras yq:ℕ := x - 1vRem:ℕ := z - x - 1⊢ reachPos (cmpCfg (x - 1) (terras y - 1) 1) (stageCfg (x + 1) (x + 1))
have hsub_x : x - 1 = 0 + q := by x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhgt:x < terras y⊢ reachPos (stageCfg x y) (stageCfg (x + 1) (x + 1)) dsimp [q] x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhgt:x < terras yz:ℕ := terras yq:ℕ := x - 1vRem:ℕ := z - x - 1⊢ x - 1 = 0 + (x - 1); omega x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhgt:x < terras yz:ℕ := terras yq:ℕ := x - 1vRem:ℕ := z - x - 1hsub_x:x - 1 = 0 + q⊢ reachPos (cmpCfg (x - 1) (terras y - 1) 1) (stageCfg (x + 1) (x + 1))
have hsub_z : z - 1 = (vRem + 1) + q := by x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhgt:x < terras y⊢ reachPos (stageCfg x y) (stageCfg (x + 1) (x + 1)) dsimp [vRem, q] x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhgt:x < terras yz:ℕ := terras yq:ℕ := x - 1vRem:ℕ := z - x - 1hsub_x:x - 1 = 0 + q⊢ z - 1 = z - x - 1 + 1 + (x - 1); omega x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhgt:x < terras yz:ℕ := terras yq:ℕ := x - 1vRem:ℕ := z - x - 1hsub_x:x - 1 = 0 + qhsub_z:z - 1 = vRem + 1 + q⊢ reachPos (cmpCfg (x - 1) (terras y - 1) 1) (stageCfg (x + 1) (x + 1))
rw [hsub_x, x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhgt:x < terras yz:ℕ := terras yq:ℕ := x - 1vRem:ℕ := z - x - 1hsub_x:x - 1 = 0 + qhsub_z:z - 1 = vRem + 1 + q⊢ reachPos (cmpCfg (0 + q) (terras y - 1) 1) (stageCfg (x + 1) (x + 1)) hsub_z x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhgt:x < terras yz:ℕ := terras yq:ℕ := x - 1vRem:ℕ := z - x - 1hsub_x:x - 1 = 0 + qhsub_z:z - 1 = vRem + 1 + q⊢ reachPos (cmpCfg (0 + q) (vRem + 1 + q) 1) (stageCfg (x + 1) (x + 1))] x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhgt:x < terras yz:ℕ := terras yq:ℕ := x - 1vRem:ℕ := z - x - 1hsub_x:x - 1 = 0 + qhsub_z:z - 1 = vRem + 1 + q⊢ reachPos (cmpCfg (0 + q) (vRem + 1 + q) 1) (stageCfg (x + 1) (x + 1))
rcases cmp_many 0 (vRem + 1) 1 q with hq0 | hp inl x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhgt:x < terras yz:ℕ := terras yq:ℕ := x - 1vRem:ℕ := z - x - 1hsub_x:x - 1 = 0 + qhsub_z:z - 1 = vRem + 1 + qhq0:q = 0⊢ reachPos (cmpCfg (0 + q) (vRem + 1 + q) 1) (stageCfg (x + 1) (x + 1))inr x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhgt:x < terras yz:ℕ := terras yq:ℕ := x - 1vRem:ℕ := z - x - 1hsub_x:x - 1 = 0 + qhsub_z:z - 1 = vRem + 1 + qhp:reachPos (cmpCfg (0 + q) (vRem + 1 + q) 1) (cmpCfg 0 (vRem + 1) (1 + q))⊢ reachPos (cmpCfg (0 + q) (vRem + 1 + q) 1) (stageCfg (x + 1) (x + 1))
· inl x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhgt:x < terras yz:ℕ := terras yq:ℕ := x - 1vRem:ℕ := z - x - 1hsub_x:x - 1 = 0 + qhsub_z:z - 1 = vRem + 1 + qhq0:q = 0⊢ reachPos (cmpCfg (0 + q) (vRem + 1 + q) 1) (stageCfg (x + 1) (x + 1)) exfalso inl x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhgt:x < terras yz:ℕ := terras yq:ℕ := x - 1vRem:ℕ := z - x - 1hsub_x:x - 1 = 0 + qhsub_z:z - 1 = vRem + 1 + qhq0:q = 0⊢ False; dsimp [q] at hq0 inl x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhgt:x < terras yz:ℕ := terras yq:ℕ := x - 1vRem:ℕ := z - x - 1hsub_x:x - 1 = 0 + qhsub_z:z - 1 = vRem + 1 + qhq0:x - 1 = 0⊢ False; omega All goals completed! 🐙
· inr x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhgt:x < terras yz:ℕ := terras yq:ℕ := x - 1vRem:ℕ := z - x - 1hsub_x:x - 1 = 0 + qhsub_z:z - 1 = vRem + 1 + qhp:reachPos (cmpCfg (0 + q) (vRem + 1 + q) 1) (cmpCfg 0 (vRem + 1) (1 + q))⊢ reachPos (cmpCfg (0 + q) (vRem + 1 + q) 1) (stageCfg (x + 1) (x + 1)) rw [show 1 + q = x by x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhgt:x < terras y⊢ reachPos (stageCfg x y) (stageCfg (x + 1) (x + 1)) dsimp [q] x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhgt:x < terras yz:ℕ := terras yq:ℕ := x - 1vRem:ℕ := z - x - 1hsub_x:x - 1 = 0 + qhsub_z:z - 1 = vRem + 1 + qhp:reachPos (cmpCfg (0 + q) (vRem + 1 + q) 1) (cmpCfg 0 (vRem + 1) (1 + q))⊢ 1 + (x - 1) = x; omega All goals completed! 🐙] at hp inr x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhgt:x < terras yz:ℕ := terras yq:ℕ := x - 1vRem:ℕ := z - x - 1hsub_x:x - 1 = 0 + qhsub_z:z - 1 = vRem + 1 + qhp:reachPos (cmpCfg (0 + q) (vRem + 1 + q) 1) (cmpCfg 0 (vRem + 1) x)⊢ reachPos (cmpCfg (0 + q) (vRem + 1 + q) 1) (stageCfg (x + 1) (x + 1))
exact reachPos_trans hp (cmp_gt_advance vRem x (by x:ℕy:ℕhx:3 ≤ xhy:2 ≤ yhgt:x < terras yz:ℕ := terras yq:ℕ := x - 1vRem:ℕ := z - x - 1hsub_x:x - 1 = 0 + qhsub_z:z - 1 = vRem + 1 + qhp:reachPos (cmpCfg (0 + q) (vRem + 1 + q) 1) (cmpCfg 0 (vRem + 1) x)⊢ 1 ≤ x omega All goals completed! 🐙))private theorem boot_to_rest1 : reachPos init (restCfg 0 0 1) := by ⊢ reachPos init (restCfg 0 0 1)
refine ⟨5, by ⊢ 1 ≤ 5 decide All goals completed! 🐙, ?_⟩
change nSteps weakCollatz27 5 ⟨0, ⟨0, B0, B0⟩⟩ = some (restCfg 0 0 1) ⊢ nSteps weakCollatz27 5 { state := 0, tape := { head := 0, left := B0, right := B0 } } = some (restCfg 0 0 1)
simp only [restCfg, Nat.mul_one, ones_succ, ones_zero, nSteps_succ, nSteps_zero,
Option.bind_some, tr0_0, tr2_0, tr3_1, tr3_0, tr1_0,
ErdosTernary15.Tape.mkL_cons, ErdosTernary15.Tape.mk'_B0, B0_cons_zero, mkL_B0] All goals completed! 🐙private theorem init_reaches_stage3 : reachPos init (stageCfg 3 3) := by ⊢ reachPos init (stageCfg 3 3)
have h1 : reachPos init (stageCfg 1 1) :=
reachPos_trans boot_to_rest1 (rest_from_zero 1 le_rfl) h1:reachPos init (stageCfg 1 1)⊢ reachPos init (stageCfg 3 3)
have h2 : reachPos (stageCfg 1 1) (stageCfg 2 2) := stage_y1_advance 1 le_rfl h1:reachPos init (stageCfg 1 1)h2:reachPos (stageCfg 1 1) (stageCfg 2 2)⊢ reachPos init (stageCfg 3 3)
have ht2 : terras 2 = 1 := rfl h1:reachPos init (stageCfg 1 1)h2:reachPos (stageCfg 1 1) (stageCfg 2 2)ht2:terras 2 = 1⊢ reachPos init (stageCfg 3 3)
have h21 : reachPos (stageCfg 2 2) (stageCfg 2 1) := by
have hlt := stage_round_lt 2 2 le_rfl le_rfl (by h1:reachPos init (stageCfg 1 1)h2:reachPos (stageCfg 1 1) (stageCfg 2 2)ht2:terras 2 = 1⊢ terras 2 < 2 rw [ht2 h1:reachPos init (stageCfg 1 1)h2:reachPos (stageCfg 1 1) (stageCfg 2 2)ht2:terras 2 = 1⊢ 1 < 2] h1:reachPos init (stageCfg 1 1)h2:reachPos (stageCfg 1 1) (stageCfg 2 2)ht2:terras 2 = 1⊢ 1 < 2; decide All goals completed! 🐙) h1:reachPos init (stageCfg 1 1)h2:reachPos (stageCfg 1 1) (stageCfg 2 2)ht2:terras 2 = 1hlt:reachPos (stageCfg 2 2) (stageCfg 2 (terras 2))⊢ reachPos (stageCfg 2 2) (stageCfg 2 1)
rw [ht2 h1:reachPos init (stageCfg 1 1)h2:reachPos (stageCfg 1 1) (stageCfg 2 2)ht2:terras 2 = 1hlt:reachPos (stageCfg 2 2) (stageCfg 2 1)⊢ reachPos (stageCfg 2 2) (stageCfg 2 1)] at hlt h1:reachPos init (stageCfg 1 1)h2:reachPos (stageCfg 1 1) (stageCfg 2 2)ht2:terras 2 = 1hlt:reachPos (stageCfg 2 2) (stageCfg 2 1)⊢ reachPos (stageCfg 2 2) (stageCfg 2 1)
exact hlt h1:reachPos init (stageCfg 1 1)h2:reachPos (stageCfg 1 1) (stageCfg 2 2)ht2:terras 2 = 1h21:reachPos (stageCfg 2 2) (stageCfg 2 1)⊢ reachPos init (stageCfg 3 3)
have h3 : reachPos (stageCfg 2 1) (stageCfg 3 3) := stage_y1_advance 2 (by h1:reachPos init (stageCfg 1 1)h2:reachPos (stageCfg 1 1) (stageCfg 2 2)ht2:terras 2 = 1h21:reachPos (stageCfg 2 2) (stageCfg 2 1)⊢ 1 ≤ 2 decide All goals completed! 🐙) h1:reachPos init (stageCfg 1 1)h2:reachPos (stageCfg 1 1) (stageCfg 2 2)ht2:terras 2 = 1h21:reachPos (stageCfg 2 2) (stageCfg 2 1)h3:reachPos (stageCfg 2 1) (stageCfg 3 3)⊢ reachPos init (stageCfg 3 3)
exact reachPos_trans h1 (reachPos_trans h2 (reachPos_trans h21 h3)) All goals completed! 🐙Cycle-Maximum Dovetailing & Halting Equivalence
private theorem terras_iterate_pos {y : ℕ} (hy : 1 ≤ y) (m : ℕ) : 1 ≤ terras^[m] y := by y:ℕhy:1 ≤ ym:ℕ⊢ 1 ≤ terras^[m] y
induction m generalizing y with
| zero => zero y:ℕhy:1 ≤ y⊢ 1 ≤ terras^[0] y exact hy All goals completed! 🐙
| succ m ih => succ m:ℕih:∀ {y : ℕ}, 1 ≤ y → 1 ≤ terras^[m] yy:ℕhy:1 ≤ y⊢ 1 ≤ terras^[m + 1] y
rw [Function.iterate_succ_apply succ m:ℕih:∀ {y : ℕ}, 1 ≤ y → 1 ≤ terras^[m] yy:ℕhy:1 ≤ y⊢ 1 ≤ terras^[m] (terras y)] succ m:ℕih:∀ {y : ℕ}, 1 ≤ y → 1 ≤ terras^[m] yy:ℕhy:1 ≤ y⊢ 1 ≤ terras^[m] (terras y)
exact ih (terras_pos_of_pos hy) All goals completed! 🐙private def StepContinues (x t : ℕ) : Prop :=
2 ≤ terras^[t] x ∧ terras^[t] x < xprivate def StayIn (x m : ℕ) : Prop :=
∀ t : ℕ, 1 ≤ t → t ≤ m → StepContinues x tprivate theorem stayIn_or_first_exit (x m : ℕ) :
StayIn x m ∨ ∃ t : ℕ, 1 ≤ t ∧ t ≤ m ∧ StayIn x (t - 1) ∧ ¬ StepContinues x t := by x:ℕm:ℕ⊢ StayIn x m ∨ ∃ t, 1 ≤ t ∧ t ≤ m ∧ StayIn x (t - 1) ∧ ¬StepContinues x t
induction m with
| zero => zero x:ℕ⊢ StayIn x 0 ∨ ∃ t, 1 ≤ t ∧ t ≤ 0 ∧ StayIn x (t - 1) ∧ ¬StepContinues x t exact Or.inl fun t ht1 ht0 => absurd (le_trans ht1 ht0) (by x:ℕt:ℕht1:1 ≤ tht0:t ≤ 0⊢ ¬1 ≤ 0 decide All goals completed! 🐙)
| succ m ih => succ x:ℕm:ℕih:StayIn x m ∨ ∃ t, 1 ≤ t ∧ t ≤ m ∧ StayIn x (t - 1) ∧ ¬StepContinues x t⊢ StayIn x (m + 1) ∨ ∃ t, 1 ≤ t ∧ t ≤ m + 1 ∧ StayIn x (t - 1) ∧ ¬StepContinues x t
rcases ih with hstay | ⟨t, ht1, htm, hprev, hexit⟩ succ.inl x:ℕm:ℕhstay:StayIn x m⊢ StayIn x (m + 1) ∨ ∃ t, 1 ≤ t ∧ t ≤ m + 1 ∧ StayIn x (t - 1) ∧ ¬StepContinues x tsucc.inr x:ℕm:ℕt:ℕht1:1 ≤ thtm:t ≤ mhprev:StayIn x (t - 1)hexit:¬StepContinues x t⊢ StayIn x (m + 1) ∨ ∃ t, 1 ≤ t ∧ t ≤ m + 1 ∧ StayIn x (t - 1) ∧ ¬StepContinues x t
· succ.inl x:ℕm:ℕhstay:StayIn x m⊢ StayIn x (m + 1) ∨ ∃ t, 1 ≤ t ∧ t ≤ m + 1 ∧ StayIn x (t - 1) ∧ ¬StepContinues x t by_cases hstep : 2 ≤ terras^[m + 1] x ∧ terras^[m + 1] x < x pos x:ℕm:ℕhstay:StayIn x mhstep:2 ≤ terras^[m + 1] x ∧ terras^[m + 1] x < x⊢ StayIn x (m + 1) ∨ ∃ t, 1 ≤ t ∧ t ≤ m + 1 ∧ StayIn x (t - 1) ∧ ¬StepContinues x tneg x:ℕm:ℕhstay:StayIn x mhstep:¬(2 ≤ terras^[m + 1] x ∧ terras^[m + 1] x < x)⊢ StayIn x (m + 1) ∨ ∃ t, 1 ≤ t ∧ t ≤ m + 1 ∧ StayIn x (t - 1) ∧ ¬StepContinues x t
· pos x:ℕm:ℕhstay:StayIn x mhstep:2 ≤ terras^[m + 1] x ∧ terras^[m + 1] x < x⊢ StayIn x (m + 1) ∨ ∃ t, 1 ≤ t ∧ t ≤ m + 1 ∧ StayIn x (t - 1) ∧ ¬StepContinues x t refine Or.inl fun t ht1 htm1 => ?_ pos x:ℕm:ℕhstay:StayIn x mhstep:2 ≤ terras^[m + 1] x ∧ terras^[m + 1] x < xt:ℕht1:1 ≤ thtm1:t ≤ m + 1⊢ StepContinues x t
rcases Nat.lt_or_ge t (m + 1) with hlt | hge pos.inl x:ℕm:ℕhstay:StayIn x mhstep:2 ≤ terras^[m + 1] x ∧ terras^[m + 1] x < xt:ℕht1:1 ≤ thtm1:t ≤ m + 1hlt:t < m + 1⊢ StepContinues x tpos.inr x:ℕm:ℕhstay:StayIn x mhstep:2 ≤ terras^[m + 1] x ∧ terras^[m + 1] x < xt:ℕht1:1 ≤ thtm1:t ≤ m + 1hge:t ≥ m + 1⊢ StepContinues x t
· pos.inl x:ℕm:ℕhstay:StayIn x mhstep:2 ≤ terras^[m + 1] x ∧ terras^[m + 1] x < xt:ℕht1:1 ≤ thtm1:t ≤ m + 1hlt:t < m + 1⊢ StepContinues x t exact hstay t ht1 (by x:ℕm:ℕhstay:StayIn x mhstep:2 ≤ terras^[m + 1] x ∧ terras^[m + 1] x < xt:ℕht1:1 ≤ thtm1:t ≤ m + 1hlt:t < m + 1⊢ t ≤ m omega All goals completed! 🐙)
· pos.inr x:ℕm:ℕhstay:StayIn x mhstep:2 ≤ terras^[m + 1] x ∧ terras^[m + 1] x < xt:ℕht1:1 ≤ thtm1:t ≤ m + 1hge:t ≥ m + 1⊢ StepContinues x t rw [show t = m + 1 by x:ℕm:ℕ⊢ StayIn x m ∨ ∃ t, 1 ≤ t ∧ t ≤ m ∧ StayIn x (t - 1) ∧ ¬StepContinues x t omega All goals completed! 🐙] pos.inr x:ℕm:ℕhstay:StayIn x mhstep:2 ≤ terras^[m + 1] x ∧ terras^[m + 1] x < xt:ℕht1:1 ≤ thtm1:t ≤ m + 1hge:t ≥ m + 1⊢ StepContinues x (m + 1); exact hstep All goals completed! 🐙
· neg x:ℕm:ℕhstay:StayIn x mhstep:¬(2 ≤ terras^[m + 1] x ∧ terras^[m + 1] x < x)⊢ StayIn x (m + 1) ∨ ∃ t, 1 ≤ t ∧ t ≤ m + 1 ∧ StayIn x (t - 1) ∧ ¬StepContinues x t exact Or.inr ⟨m + 1, by x:ℕm:ℕhstay:StayIn x mhstep:¬(2 ≤ terras^[m + 1] x ∧ terras^[m + 1] x < x)⊢ 1 ≤ m + 1 omega All goals completed! 🐙, le_rfl, hstay, hstep⟩
· succ.inr x:ℕm:ℕt:ℕht1:1 ≤ thtm:t ≤ mhprev:StayIn x (t - 1)hexit:¬StepContinues x t⊢ StayIn x (m + 1) ∨ ∃ t, 1 ≤ t ∧ t ≤ m + 1 ∧ StayIn x (t - 1) ∧ ¬StepContinues x t exact Or.inr ⟨t, ht1, by x:ℕm:ℕt:ℕht1:1 ≤ thtm:t ≤ mhprev:StayIn x (t - 1)hexit:¬StepContinues x t⊢ t ≤ m + 1 omega All goals completed! 🐙, hprev, hexit⟩private theorem stage_stay_reach (x : ℕ) (hx : 3 ≤ x) (m : ℕ) (hstay : StayIn x m) :
m = 0 ∨ (1 ≤ m ∧ reachPos (stageCfg x x) (stageCfg x (terras^[m] x))) := by x:ℕhx:3 ≤ xm:ℕhstay:StayIn x m⊢ m = 0 ∨ 1 ≤ m ∧ reachPos (stageCfg x x) (stageCfg x (terras^[m] x))
induction m with
| zero => zero x:ℕhx:3 ≤ xhstay:StayIn x 0⊢ 0 = 0 ∨ 1 ≤ 0 ∧ reachPos (stageCfg x x) (stageCfg x (terras^[0] x)) exact Or.inl rfl All goals completed! 🐙
| succ m ih => succ x:ℕhx:3 ≤ xm:ℕih:StayIn x m → m = 0 ∨ 1 ≤ m ∧ reachPos (stageCfg x x) (stageCfg x (terras^[m] x))hstay:StayIn x (m + 1)⊢ m + 1 = 0 ∨ 1 ≤ m + 1 ∧ reachPos (stageCfg x x) (stageCfg x (terras^[m + 1] x))
refine Or.inr ⟨by x:ℕhx:3 ≤ xm:ℕih:StayIn x m → m = 0 ∨ 1 ≤ m ∧ reachPos (stageCfg x x) (stageCfg x (terras^[m] x))hstay:StayIn x (m + 1)⊢ 1 ≤ m + 1 omega All goals completed! 🐙, ?_⟩
have hstep : StepContinues x (m + 1) := hstay (m + 1) (by x:ℕhx:3 ≤ xm:ℕih:StayIn x m → m = 0 ∨ 1 ≤ m ∧ reachPos (stageCfg x x) (stageCfg x (terras^[m] x))hstay:StayIn x (m + 1)⊢ 1 ≤ m + 1 omega All goals completed! 🐙) le_rfl succ x:ℕhx:3 ≤ xm:ℕih:StayIn x m → m = 0 ∨ 1 ≤ m ∧ reachPos (stageCfg x x) (stageCfg x (terras^[m] x))hstay:StayIn x (m + 1)hstep:StepContinues x (m + 1)⊢ reachPos (stageCfg x x) (stageCfg x (terras^[m + 1] x))
rcases ih (fun t ht1 htm => hstay t ht1 (by x:ℕhx:3 ≤ xm:ℕih:StayIn x m → m = 0 ∨ 1 ≤ m ∧ reachPos (stageCfg x x) (stageCfg x (terras^[m] x))hstay:StayIn x (m + 1)hstep:StepContinues x (m + 1)t:ℕht1:1 ≤ thtm:t ≤ m⊢ t ≤ m + 1 omega All goals completed! 🐙)) with rfl | ⟨hm1, hprev⟩
· succ.inl x:ℕhx:3 ≤ xih:StayIn x 0 → 0 = 0 ∨ 1 ≤ 0 ∧ reachPos (stageCfg x x) (stageCfg x (terras^[0] x))hstay:StayIn x (0 + 1)hstep:StepContinues x (0 + 1)⊢ reachPos (stageCfg x x) (stageCfg x (terras^[0 + 1] x)) have hlt1 : terras x < x := by x:ℕhx:3 ≤ xm:ℕhstay:StayIn x m⊢ m = 0 ∨ 1 ≤ m ∧ reachPos (stageCfg x x) (stageCfg x (terras^[m] x))
have h1 : terras x = terras^[1] x := rfl x:ℕhx:3 ≤ xih:StayIn x 0 → 0 = 0 ∨ 1 ≤ 0 ∧ reachPos (stageCfg x x) (stageCfg x (terras^[0] x))hstay:StayIn x (0 + 1)hstep:StepContinues x (0 + 1)h1:terras x = terras^[1] x⊢ terras x < x
rw [h1 x:ℕhx:3 ≤ xih:StayIn x 0 → 0 = 0 ∨ 1 ≤ 0 ∧ reachPos (stageCfg x x) (stageCfg x (terras^[0] x))hstay:StayIn x (0 + 1)hstep:StepContinues x (0 + 1)h1:terras x = terras^[1] x⊢ terras^[1] x < x] x:ℕhx:3 ≤ xih:StayIn x 0 → 0 = 0 ∨ 1 ≤ 0 ∧ reachPos (stageCfg x x) (stageCfg x (terras^[0] x))hstay:StayIn x (0 + 1)hstep:StepContinues x (0 + 1)h1:terras x = terras^[1] x⊢ terras^[1] x < x
exact hstep.2 succ.inl x:ℕhx:3 ≤ xih:StayIn x 0 → 0 = 0 ∨ 1 ≤ 0 ∧ reachPos (stageCfg x x) (stageCfg x (terras^[0] x))hstay:StayIn x (0 + 1)hstep:StepContinues x (0 + 1)hlt1:terras x < x⊢ reachPos (stageCfg x x) (stageCfg x (terras^[0 + 1] x))
rw [Function.iterate_one succ.inl x:ℕhx:3 ≤ xih:StayIn x 0 → 0 = 0 ∨ 1 ≤ 0 ∧ reachPos (stageCfg x x) (stageCfg x (terras^[0] x))hstay:StayIn x (0 + 1)hstep:StepContinues x (0 + 1)hlt1:terras x < x⊢ reachPos (stageCfg x x) (stageCfg x (terras x))] succ.inl x:ℕhx:3 ≤ xih:StayIn x 0 → 0 = 0 ∨ 1 ≤ 0 ∧ reachPos (stageCfg x x) (stageCfg x (terras^[0] x))hstay:StayIn x (0 + 1)hstep:StepContinues x (0 + 1)hlt1:terras x < x⊢ reachPos (stageCfg x x) (stageCfg x (terras x))
exact stage_round_lt x x (by x:ℕhx:3 ≤ xih:StayIn x 0 → 0 = 0 ∨ 1 ≤ 0 ∧ reachPos (stageCfg x x) (stageCfg x (terras^[0] x))hstay:StayIn x (0 + 1)hstep:StepContinues x (0 + 1)hlt1:terras x < x⊢ 2 ≤ x omega All goals completed! 🐙) (by x:ℕhx:3 ≤ xih:StayIn x 0 → 0 = 0 ∨ 1 ≤ 0 ∧ reachPos (stageCfg x x) (stageCfg x (terras^[0] x))hstay:StayIn x (0 + 1)hstep:StepContinues x (0 + 1)hlt1:terras x < x⊢ 2 ≤ x omega All goals completed! 🐙) hlt1
· succ.inr x:ℕhx:3 ≤ xm:ℕih:StayIn x m → m = 0 ∨ 1 ≤ m ∧ reachPos (stageCfg x x) (stageCfg x (terras^[m] x))hstay:StayIn x (m + 1)hstep:StepContinues x (m + 1)hm1:1 ≤ mhprev:reachPos (stageCfg x x) (stageCfg x (terras^[m] x))⊢ reachPos (stageCfg x x) (stageCfg x (terras^[m + 1] x)) have hym : 2 ≤ terras^[m] x := (hstay m hm1 (by x:ℕhx:3 ≤ xm:ℕih:StayIn x m → m = 0 ∨ 1 ≤ m ∧ reachPos (stageCfg x x) (stageCfg x (terras^[m] x))hstay:StayIn x (m + 1)hstep:StepContinues x (m + 1)hm1:1 ≤ mhprev:reachPos (stageCfg x x) (stageCfg x (terras^[m] x))⊢ m ≤ m + 1 omega All goals completed! 🐙)).1 succ.inr x:ℕhx:3 ≤ xm:ℕih:StayIn x m → m = 0 ∨ 1 ≤ m ∧ reachPos (stageCfg x x) (stageCfg x (terras^[m] x))hstay:StayIn x (m + 1)hstep:StepContinues x (m + 1)hm1:1 ≤ mhprev:reachPos (stageCfg x x) (stageCfg x (terras^[m] x))hym:2 ≤ terras^[m] x⊢ reachPos (stageCfg x x) (stageCfg x (terras^[m + 1] x))
have hlt : terras (terras^[m] x) < x := by x:ℕhx:3 ≤ xm:ℕhstay:StayIn x m⊢ m = 0 ∨ 1 ≤ m ∧ reachPos (stageCfg x x) (stageCfg x (terras^[m] x))
rw [← Function.iterate_succ_apply' terras m x x:ℕhx:3 ≤ xm:ℕih:StayIn x m → m = 0 ∨ 1 ≤ m ∧ reachPos (stageCfg x x) (stageCfg x (terras^[m] x))hstay:StayIn x (m + 1)hstep:StepContinues x (m + 1)hm1:1 ≤ mhprev:reachPos (stageCfg x x) (stageCfg x (terras^[m] x))hym:2 ≤ terras^[m] x⊢ terras^[m.succ] x < x] x:ℕhx:3 ≤ xm:ℕih:StayIn x m → m = 0 ∨ 1 ≤ m ∧ reachPos (stageCfg x x) (stageCfg x (terras^[m] x))hstay:StayIn x (m + 1)hstep:StepContinues x (m + 1)hm1:1 ≤ mhprev:reachPos (stageCfg x x) (stageCfg x (terras^[m] x))hym:2 ≤ terras^[m] x⊢ terras^[m.succ] x < x
exact hstep.2 succ.inr x:ℕhx:3 ≤ xm:ℕih:StayIn x m → m = 0 ∨ 1 ≤ m ∧ reachPos (stageCfg x x) (stageCfg x (terras^[m] x))hstay:StayIn x (m + 1)hstep:StepContinues x (m + 1)hm1:1 ≤ mhprev:reachPos (stageCfg x x) (stageCfg x (terras^[m] x))hym:2 ≤ terras^[m] xhlt:terras (terras^[m] x) < x⊢ reachPos (stageCfg x x) (stageCfg x (terras^[m + 1] x))
rw [Function.iterate_succ_apply' succ.inr x:ℕhx:3 ≤ xm:ℕih:StayIn x m → m = 0 ∨ 1 ≤ m ∧ reachPos (stageCfg x x) (stageCfg x (terras^[m] x))hstay:StayIn x (m + 1)hstep:StepContinues x (m + 1)hm1:1 ≤ mhprev:reachPos (stageCfg x x) (stageCfg x (terras^[m] x))hym:2 ≤ terras^[m] xhlt:terras (terras^[m] x) < x⊢ reachPos (stageCfg x x) (stageCfg x (terras (terras^[m] x)))] succ.inr x:ℕhx:3 ≤ xm:ℕih:StayIn x m → m = 0 ∨ 1 ≤ m ∧ reachPos (stageCfg x x) (stageCfg x (terras^[m] x))hstay:StayIn x (m + 1)hstep:StepContinues x (m + 1)hm1:1 ≤ mhprev:reachPos (stageCfg x x) (stageCfg x (terras^[m] x))hym:2 ≤ terras^[m] xhlt:terras (terras^[m] x) < x⊢ reachPos (stageCfg x x) (stageCfg x (terras (terras^[m] x)))
exact reachPos_trans hprev (stage_round_lt x (terras^[m] x) (by x:ℕhx:3 ≤ xm:ℕih:StayIn x m → m = 0 ∨ 1 ≤ m ∧ reachPos (stageCfg x x) (stageCfg x (terras^[m] x))hstay:StayIn x (m + 1)hstep:StepContinues x (m + 1)hm1:1 ≤ mhprev:reachPos (stageCfg x x) (stageCfg x (terras^[m] x))hym:2 ≤ terras^[m] xhlt:terras (terras^[m] x) < x⊢ 2 ≤ x omega All goals completed! 🐙) hym hlt)private def StageHalts (x : ℕ) : Prop :=
∃ t : ℕ, 1 ≤ t ∧ t ≤ x ∧ StayIn x (t - 1) ∧ terras^[t] x = xprivate theorem stageHalts_decidable (x : ℕ) : StageHalts x ∨ ¬ StageHalts x := by x:ℕ⊢ StageHalts x ∨ ¬StageHalts x
rcases stayIn_or_first_exit x x with hstay | ⟨t, ht1, htx, hprev, hexit⟩ inl x:ℕhstay:StayIn x x⊢ StageHalts x ∨ ¬StageHalts xinr x:ℕt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x t⊢ StageHalts x ∨ ¬StageHalts x
· inl x:ℕhstay:StayIn x x⊢ StageHalts x ∨ ¬StageHalts x refine Or.inr ?_ inl x:ℕhstay:StayIn x x⊢ ¬StageHalts x
rintro ⟨t, ht1, htx, _, hhit⟩ inl x:ℕhstay:StayIn x xt:ℕht1:1 ≤ thtx:t ≤ xleft✝:StayIn x (t - 1)hhit:terras^[t] x = x⊢ False
have hlt := (hstay t ht1 htx).2 inl x:ℕhstay:StayIn x xt:ℕht1:1 ≤ thtx:t ≤ xleft✝:StayIn x (t - 1)hhit:terras^[t] x = xhlt:terras^[t] x < x⊢ False
omega All goals completed! 🐙
· inr x:ℕt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x t⊢ StageHalts x ∨ ¬StageHalts x by_cases hhit : terras^[t] x = x pos x:ℕt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thhit:terras^[t] x = x⊢ StageHalts x ∨ ¬StageHalts xneg x:ℕt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thhit:¬terras^[t] x = x⊢ StageHalts x ∨ ¬StageHalts x
· pos x:ℕt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thhit:terras^[t] x = x⊢ StageHalts x ∨ ¬StageHalts x exact Or.inl ⟨t, ht1, htx, hprev, hhit⟩ All goals completed! 🐙
· neg x:ℕt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thhit:¬terras^[t] x = x⊢ StageHalts x ∨ ¬StageHalts x refine Or.inr ?_ neg x:ℕt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thhit:¬terras^[t] x = x⊢ ¬StageHalts x
rintro ⟨t', ht'1, ht'x, hprev', hhit'⟩ neg x:ℕt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thhit:¬terras^[t] x = xt':ℕht'1:1 ≤ t'ht'x:t' ≤ xhprev':StayIn x (t' - 1)hhit':terras^[t'] x = x⊢ False
rcases Nat.lt_trichotomy t' t with hlt | rfl | hgt neg.inl x:ℕt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thhit:¬terras^[t] x = xt':ℕht'1:1 ≤ t'ht'x:t' ≤ xhprev':StayIn x (t' - 1)hhit':terras^[t'] x = xhlt:t' < t⊢ Falseneg.inr.inl x:ℕt':ℕht'1:1 ≤ t'ht'x:t' ≤ xhprev':StayIn x (t' - 1)hhit':terras^[t'] x = xht1:1 ≤ t'htx:t' ≤ xhprev:StayIn x (t' - 1)hexit:¬StepContinues x t'hhit:¬terras^[t'] x = x⊢ Falseneg.inr.inr x:ℕt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thhit:¬terras^[t] x = xt':ℕht'1:1 ≤ t'ht'x:t' ≤ xhprev':StayIn x (t' - 1)hhit':terras^[t'] x = xhgt:t < t'⊢ False
· neg.inl x:ℕt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thhit:¬terras^[t] x = xt':ℕht'1:1 ≤ t'ht'x:t' ≤ xhprev':StayIn x (t' - 1)hhit':terras^[t'] x = xhlt:t' < t⊢ False have hlt_x := (hprev t' ht'1 (by x:ℕt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thhit:¬terras^[t] x = xt':ℕht'1:1 ≤ t'ht'x:t' ≤ xhprev':StayIn x (t' - 1)hhit':terras^[t'] x = xhlt:t' < t⊢ t' ≤ t - 1 omega All goals completed! 🐙)).2 neg.inl x:ℕt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thhit:¬terras^[t] x = xt':ℕht'1:1 ≤ t'ht'x:t' ≤ xhprev':StayIn x (t' - 1)hhit':terras^[t'] x = xhlt:t' < thlt_x:terras^[t'] x < x⊢ False
omega All goals completed! 🐙
· neg.inr.inl x:ℕt':ℕht'1:1 ≤ t'ht'x:t' ≤ xhprev':StayIn x (t' - 1)hhit':terras^[t'] x = xht1:1 ≤ t'htx:t' ≤ xhprev:StayIn x (t' - 1)hexit:¬StepContinues x t'hhit:¬terras^[t'] x = x⊢ False exact hhit hhit' All goals completed! 🐙
· neg.inr.inr x:ℕt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thhit:¬terras^[t] x = xt':ℕht'1:1 ≤ t'ht'x:t' ≤ xhprev':StayIn x (t' - 1)hhit':terras^[t'] x = xhgt:t < t'⊢ False have hcont : StepContinues x t := hprev' t ht1 (by x:ℕt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thhit:¬terras^[t] x = xt':ℕht'1:1 ≤ t'ht'x:t' ≤ xhprev':StayIn x (t' - 1)hhit':terras^[t'] x = xhgt:t < t'⊢ t ≤ t' - 1 omega All goals completed! 🐙) neg.inr.inr x:ℕt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thhit:¬terras^[t] x = xt':ℕht'1:1 ≤ t'ht'x:t' ≤ xhprev':StayIn x (t' - 1)hhit':terras^[t'] x = xhgt:t < t'hcont:StepContinues x t⊢ False
exact hexit hcont All goals completed! 🐙private theorem stageHalts_of_cycle_max {M j : ℕ} (_hM3 : 3 ≤ M) (hj1 : 1 ≤ j) (hjM : j ≤ M)
(hcyc : terras^[j] M = M) (hbnd : ∀ t : ℕ, 3 ≤ terras^[t] M ∧ terras^[t] M ≤ M) :
StageHalts M := by M:ℕj:ℕ_hM3:3 ≤ Mhj1:1 ≤ jhjM:j ≤ Mhcyc:terras^[j] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ M⊢ StageHalts M
rcases stayIn_or_first_exit M j with hstay | ⟨t, ht1, htj, hprev, hexit⟩ inl M:ℕj:ℕ_hM3:3 ≤ Mhj1:1 ≤ jhjM:j ≤ Mhcyc:terras^[j] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mhstay:StayIn M j⊢ StageHalts Minr M:ℕj:ℕ_hM3:3 ≤ Mhj1:1 ≤ jhjM:j ≤ Mhcyc:terras^[j] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mt:ℕht1:1 ≤ thtj:t ≤ jhprev:StayIn M (t - 1)hexit:¬StepContinues M t⊢ StageHalts M
· inl M:ℕj:ℕ_hM3:3 ≤ Mhj1:1 ≤ jhjM:j ≤ Mhcyc:terras^[j] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mhstay:StayIn M j⊢ StageHalts M exfalso inl M:ℕj:ℕ_hM3:3 ≤ Mhj1:1 ≤ jhjM:j ≤ Mhcyc:terras^[j] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mhstay:StayIn M j⊢ False
have hlt := (hstay j hj1 le_rfl).2 inl M:ℕj:ℕ_hM3:3 ≤ Mhj1:1 ≤ jhjM:j ≤ Mhcyc:terras^[j] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mhstay:StayIn M jhlt:terras^[j] M < M⊢ False
omega All goals completed! 🐙
· inr M:ℕj:ℕ_hM3:3 ≤ Mhj1:1 ≤ jhjM:j ≤ Mhcyc:terras^[j] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mt:ℕht1:1 ≤ thtj:t ≤ jhprev:StayIn M (t - 1)hexit:¬StepContinues M t⊢ StageHalts M refine ⟨t, ht1, by M:ℕj:ℕ_hM3:3 ≤ Mhj1:1 ≤ jhjM:j ≤ Mhcyc:terras^[j] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mt:ℕht1:1 ≤ thtj:t ≤ jhprev:StayIn M (t - 1)hexit:¬StepContinues M t⊢ t ≤ M omega All goals completed! 🐙, hprev, ?_⟩
have ht_bnd := hbnd t inr M:ℕj:ℕ_hM3:3 ≤ Mhj1:1 ≤ jhjM:j ≤ Mhcyc:terras^[j] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mt:ℕht1:1 ≤ thtj:t ≤ jhprev:StayIn M (t - 1)hexit:¬StepContinues M tht_bnd:3 ≤ terras^[t] M ∧ terras^[t] M ≤ M⊢ terras^[t] M = M
by_cases hhit : terras^[t] M = M pos M:ℕj:ℕ_hM3:3 ≤ Mhj1:1 ≤ jhjM:j ≤ Mhcyc:terras^[j] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mt:ℕht1:1 ≤ thtj:t ≤ jhprev:StayIn M (t - 1)hexit:¬StepContinues M tht_bnd:3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mhhit:terras^[t] M = M⊢ terras^[t] M = Mneg M:ℕj:ℕ_hM3:3 ≤ Mhj1:1 ≤ jhjM:j ≤ Mhcyc:terras^[j] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mt:ℕht1:1 ≤ thtj:t ≤ jhprev:StayIn M (t - 1)hexit:¬StepContinues M tht_bnd:3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mhhit:¬terras^[t] M = M⊢ terras^[t] M = M
· pos M:ℕj:ℕ_hM3:3 ≤ Mhj1:1 ≤ jhjM:j ≤ Mhcyc:terras^[j] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mt:ℕht1:1 ≤ thtj:t ≤ jhprev:StayIn M (t - 1)hexit:¬StepContinues M tht_bnd:3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mhhit:terras^[t] M = M⊢ terras^[t] M = M exact hhit All goals completed! 🐙
· neg M:ℕj:ℕ_hM3:3 ≤ Mhj1:1 ≤ jhjM:j ≤ Mhcyc:terras^[j] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mt:ℕht1:1 ≤ thtj:t ≤ jhprev:StayIn M (t - 1)hexit:¬StepContinues M tht_bnd:3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mhhit:¬terras^[t] M = M⊢ terras^[t] M = M exfalso neg M:ℕj:ℕ_hM3:3 ≤ Mhj1:1 ≤ jhjM:j ≤ Mhcyc:terras^[j] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mt:ℕht1:1 ≤ thtj:t ≤ jhprev:StayIn M (t - 1)hexit:¬StepContinues M tht_bnd:3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mhhit:¬terras^[t] M = M⊢ False
exact hexit ⟨by M:ℕj:ℕ_hM3:3 ≤ Mhj1:1 ≤ jhjM:j ≤ Mhcyc:terras^[j] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mt:ℕht1:1 ≤ thtj:t ≤ jhprev:StayIn M (t - 1)hexit:¬StepContinues M tht_bnd:3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mhhit:¬terras^[t] M = M⊢ 2 ≤ terras^[t] M omega All goals completed! 🐙, by M:ℕj:ℕ_hM3:3 ≤ Mhj1:1 ≤ jhjM:j ≤ Mhcyc:terras^[j] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mt:ℕht1:1 ≤ thtj:t ≤ jhprev:StayIn M (t - 1)hexit:¬StepContinues M tht_bnd:3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mhhit:¬terras^[t] M = M⊢ terras^[t] M < M omega All goals completed! 🐙⟩private def NoStageHalts (X : ℕ) : Prop :=
∀ w : ℕ, 3 ≤ w → w ≤ X → ¬ StageHalts wprivate theorem noStageHalts_or_first (X : ℕ) :
NoStageHalts X ∨
∃ w : ℕ, 3 ≤ w ∧ w ≤ X ∧ NoStageHalts (w - 1) ∧ StageHalts w := by X:ℕ⊢ NoStageHalts X ∨ ∃ w, 3 ≤ w ∧ w ≤ X ∧ NoStageHalts (w - 1) ∧ StageHalts w
induction X with
| zero => zero ⊢ NoStageHalts 0 ∨ ∃ w, 3 ≤ w ∧ w ≤ 0 ∧ NoStageHalts (w - 1) ∧ StageHalts w exact Or.inl fun w hw3 hw0 => absurd (le_trans hw3 hw0) (by w:ℕhw3:3 ≤ whw0:w ≤ 0⊢ ¬3 ≤ 0 decide All goals completed! 🐙)
| succ X ih => succ X:ℕih:NoStageHalts X ∨ ∃ w, 3 ≤ w ∧ w ≤ X ∧ NoStageHalts (w - 1) ∧ StageHalts w⊢ NoStageHalts (X + 1) ∨ ∃ w, 3 ≤ w ∧ w ≤ X + 1 ∧ NoStageHalts (w - 1) ∧ StageHalts w
rcases ih with hno | ⟨w, hw3, hwX, hprev, hhalt⟩ succ.inl X:ℕhno:NoStageHalts X⊢ NoStageHalts (X + 1) ∨ ∃ w, 3 ≤ w ∧ w ≤ X + 1 ∧ NoStageHalts (w - 1) ∧ StageHalts wsucc.inr X:ℕw:ℕhw3:3 ≤ whwX:w ≤ Xhprev:NoStageHalts (w - 1)hhalt:StageHalts w⊢ NoStageHalts (X + 1) ∨ ∃ w, 3 ≤ w ∧ w ≤ X + 1 ∧ NoStageHalts (w - 1) ∧ StageHalts w
· succ.inl X:ℕhno:NoStageHalts X⊢ NoStageHalts (X + 1) ∨ ∃ w, 3 ≤ w ∧ w ≤ X + 1 ∧ NoStageHalts (w - 1) ∧ StageHalts w by_cases hw3 : 3 ≤ X + 1 pos X:ℕhno:NoStageHalts Xhw3:3 ≤ X + 1⊢ NoStageHalts (X + 1) ∨ ∃ w, 3 ≤ w ∧ w ≤ X + 1 ∧ NoStageHalts (w - 1) ∧ StageHalts wneg X:ℕhno:NoStageHalts Xhw3:¬3 ≤ X + 1⊢ NoStageHalts (X + 1) ∨ ∃ w, 3 ≤ w ∧ w ≤ X + 1 ∧ NoStageHalts (w - 1) ∧ StageHalts w
· pos X:ℕhno:NoStageHalts Xhw3:3 ≤ X + 1⊢ NoStageHalts (X + 1) ∨ ∃ w, 3 ≤ w ∧ w ≤ X + 1 ∧ NoStageHalts (w - 1) ∧ StageHalts w rcases stageHalts_decidable (X + 1) with hhalt | hnhalt pos.inl X:ℕhno:NoStageHalts Xhw3:3 ≤ X + 1hhalt:StageHalts (X + 1)⊢ NoStageHalts (X + 1) ∨ ∃ w, 3 ≤ w ∧ w ≤ X + 1 ∧ NoStageHalts (w - 1) ∧ StageHalts wpos.inr X:ℕhno:NoStageHalts Xhw3:3 ≤ X + 1hnhalt:¬StageHalts (X + 1)⊢ NoStageHalts (X + 1) ∨ ∃ w, 3 ≤ w ∧ w ≤ X + 1 ∧ NoStageHalts (w - 1) ∧ StageHalts w
· pos.inl X:ℕhno:NoStageHalts Xhw3:3 ≤ X + 1hhalt:StageHalts (X + 1)⊢ NoStageHalts (X + 1) ∨ ∃ w, 3 ≤ w ∧ w ≤ X + 1 ∧ NoStageHalts (w - 1) ∧ StageHalts w exact Or.inr ⟨X + 1, hw3, le_rfl, hno, hhalt⟩ All goals completed! 🐙
· pos.inr X:ℕhno:NoStageHalts Xhw3:3 ≤ X + 1hnhalt:¬StageHalts (X + 1)⊢ NoStageHalts (X + 1) ∨ ∃ w, 3 ≤ w ∧ w ≤ X + 1 ∧ NoStageHalts (w - 1) ∧ StageHalts w refine Or.inl fun w hw_ge3 hw_le => ?_ pos.inr X:ℕhno:NoStageHalts Xhw3:3 ≤ X + 1hnhalt:¬StageHalts (X + 1)w:ℕhw_ge3:3 ≤ whw_le:w ≤ X + 1⊢ ¬StageHalts w
rcases Nat.lt_or_ge w (X + 1) with hlt | hge pos.inr.inl X:ℕhno:NoStageHalts Xhw3:3 ≤ X + 1hnhalt:¬StageHalts (X + 1)w:ℕhw_ge3:3 ≤ whw_le:w ≤ X + 1hlt:w < X + 1⊢ ¬StageHalts wpos.inr.inr X:ℕhno:NoStageHalts Xhw3:3 ≤ X + 1hnhalt:¬StageHalts (X + 1)w:ℕhw_ge3:3 ≤ whw_le:w ≤ X + 1hge:w ≥ X + 1⊢ ¬StageHalts w
· pos.inr.inl X:ℕhno:NoStageHalts Xhw3:3 ≤ X + 1hnhalt:¬StageHalts (X + 1)w:ℕhw_ge3:3 ≤ whw_le:w ≤ X + 1hlt:w < X + 1⊢ ¬StageHalts w exact hno w hw_ge3 (by X:ℕhno:NoStageHalts Xhw3:3 ≤ X + 1hnhalt:¬StageHalts (X + 1)w:ℕhw_ge3:3 ≤ whw_le:w ≤ X + 1hlt:w < X + 1⊢ w ≤ X omega All goals completed! 🐙)
· pos.inr.inr X:ℕhno:NoStageHalts Xhw3:3 ≤ X + 1hnhalt:¬StageHalts (X + 1)w:ℕhw_ge3:3 ≤ whw_le:w ≤ X + 1hge:w ≥ X + 1⊢ ¬StageHalts w rw [show w = X + 1 by X:ℕ⊢ NoStageHalts X ∨ ∃ w, 3 ≤ w ∧ w ≤ X ∧ NoStageHalts (w - 1) ∧ StageHalts w omega All goals completed! 🐙] pos.inr.inr X:ℕhno:NoStageHalts Xhw3:3 ≤ X + 1hnhalt:¬StageHalts (X + 1)w:ℕhw_ge3:3 ≤ whw_le:w ≤ X + 1hge:w ≥ X + 1⊢ ¬StageHalts (X + 1); exact hnhalt All goals completed! 🐙
· neg X:ℕhno:NoStageHalts Xhw3:¬3 ≤ X + 1⊢ NoStageHalts (X + 1) ∨ ∃ w, 3 ≤ w ∧ w ≤ X + 1 ∧ NoStageHalts (w - 1) ∧ StageHalts w exact Or.inl fun w hw_ge3 hw_le => absurd (le_trans hw_ge3 hw_le) hw3 All goals completed! 🐙
· succ.inr X:ℕw:ℕhw3:3 ≤ whwX:w ≤ Xhprev:NoStageHalts (w - 1)hhalt:StageHalts w⊢ NoStageHalts (X + 1) ∨ ∃ w, 3 ≤ w ∧ w ≤ X + 1 ∧ NoStageHalts (w - 1) ∧ StageHalts w exact Or.inr ⟨w, hw3, by X:ℕw:ℕhw3:3 ≤ whwX:w ≤ Xhprev:NoStageHalts (w - 1)hhalt:StageHalts w⊢ w ≤ X + 1 omega All goals completed! 🐙, hprev, hhalt⟩private theorem not_stayIn_self_of_noStageHalts {x : ℕ} (hx : 3 ≤ x)
(hno : NoStageHalts (x - 1)) : ¬ StayIn x x := by x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)⊢ ¬StayIn x x
intro hstay x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x x⊢ False
let N := x - 3 x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3⊢ False
let f : ℕ → ℕ := fun i => terras^[i + 1] x - 2 x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2⊢ False
have hf_lt : ∀ i : ℕ, i ≤ N + 1 → f i < N + 1 := by x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)⊢ ¬StayIn x x
intro i hi x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2i:ℕhi:i ≤ N + 1⊢ f i < N + 1
have hs : StepContinues x (i + 1) := hstay (i + 1) (by x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2i:ℕhi:i ≤ N + 1⊢ 1 ≤ i + 1 omega All goals completed! 🐙) (by x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2i:ℕhi:i ≤ N + 1⊢ i + 1 ≤ x dsimp only [N] at hi x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2i:ℕhi:i ≤ x - 3 + 1⊢ i + 1 ≤ x; omega All goals completed! 🐙) x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2i:ℕhi:i ≤ N + 1hs:StepContinues x (i + 1)⊢ f i < N + 1
have hge2 := hs.1 x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2i:ℕhi:i ≤ N + 1hs:StepContinues x (i + 1)hge2:2 ≤ terras^[i + 1] x⊢ f i < N + 1
have hlt_x := hs.2 x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2i:ℕhi:i ≤ N + 1hs:StepContinues x (i + 1)hge2:2 ≤ terras^[i + 1] xhlt_x:terras^[i + 1] x < x⊢ f i < N + 1
dsimp only [f, N] x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2i:ℕhi:i ≤ N + 1hs:StepContinues x (i + 1)hge2:2 ≤ terras^[i + 1] xhlt_x:terras^[i + 1] x < x⊢ terras^[i + 1] x - 2 < x - 3 + 1
omega x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1⊢ False
rcases WeakCollatz75.nat_pigeonhole_constructive N f hf_lt with ⟨a, b, hab, hb_le, hfab⟩ x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f b⊢ False
have ha_step : StepContinues x (a + 1) :=
hstay (a + 1) (by x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f b⊢ 1 ≤ a + 1 omega All goals completed! 🐙) (by x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f b⊢ a + 1 ≤ x dsimp only [N] at hb_le x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ x - 3 + 1hfab:f a = f b⊢ a + 1 ≤ x; omega All goals completed! 🐙) x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)⊢ False
have hb_step : StepContinues x (b + 1) :=
hstay (b + 1) (by x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)⊢ 1 ≤ b + 1 omega All goals completed! 🐙) (by x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)⊢ b + 1 ≤ x dsimp only [N] at hb_le x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ x - 3 + 1hfab:f a = f bha_step:StepContinues x (a + 1)⊢ b + 1 ≤ x; omega All goals completed! 🐙) x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)⊢ False
have hab_eq : terras^[a + 1] x = terras^[b + 1] x := by x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)⊢ ¬StayIn x x
have ha2 := ha_step.1 x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)ha2:2 ≤ terras^[a + 1] x⊢ terras^[a + 1] x = terras^[b + 1] x
have hb2 := hb_step.1 x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)ha2:2 ≤ terras^[a + 1] xhb2:2 ≤ terras^[b + 1] x⊢ terras^[a + 1] x = terras^[b + 1] x
dsimp only [f] at hfab x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:terras^[a + 1] x - 2 = terras^[b + 1] x - 2ha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)ha2:2 ≤ terras^[a + 1] xhb2:2 ≤ terras^[b + 1] x⊢ terras^[a + 1] x = terras^[b + 1] x
omega x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] x⊢ False
let u := terras^[a + 1] x x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] x⊢ False
have hu3 : 3 ≤ u := by x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)⊢ ¬StayIn x x
have ha2_step : StepContinues x (a + 2) :=
hstay (a + 2) (by x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] x⊢ 1 ≤ a + 2 omega All goals completed! 🐙) (by x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] x⊢ a + 2 ≤ x dsimp only [N] at hb_le x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ x - 3 + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] x⊢ a + 2 ≤ x; omega All goals completed! 🐙) x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xha2_step:StepContinues x (a + 2)⊢ 3 ≤ u
have hnext : terras u = terras^[a + 2] x :=
(Function.iterate_succ_apply' terras (a + 1) x).symm x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xha2_step:StepContinues x (a + 2)hnext:terras u = terras^[a + 2] x⊢ 3 ≤ u
have hge2 : 2 ≤ terras u := by x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)⊢ ¬StayIn x x rw [hnext x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xha2_step:StepContinues x (a + 2)hnext:terras u = terras^[a + 2] x⊢ 2 ≤ terras^[a + 2] x] x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xha2_step:StepContinues x (a + 2)hnext:terras u = terras^[a + 2] x⊢ 2 ≤ terras^[a + 2] x; exact ha2_step.1 x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xha2_step:StepContinues x (a + 2)hnext:terras u = terras^[a + 2] xhge2:2 ≤ terras u⊢ 3 ≤ u
have hu_ge2 : 2 ≤ u := ha_step.1 x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xha2_step:StepContinues x (a + 2)hnext:terras u = terras^[a + 2] xhge2:2 ≤ terras uhu_ge2:2 ≤ u⊢ 3 ≤ u
by_cases hu_eq2 : u = 2 pos x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xha2_step:StepContinues x (a + 2)hnext:terras u = terras^[a + 2] xhge2:2 ≤ terras uhu_ge2:2 ≤ uhu_eq2:u = 2⊢ 3 ≤ uneg x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xha2_step:StepContinues x (a + 2)hnext:terras u = terras^[a + 2] xhge2:2 ≤ terras uhu_ge2:2 ≤ uhu_eq2:¬u = 2⊢ 3 ≤ u
· pos x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xha2_step:StepContinues x (a + 2)hnext:terras u = terras^[a + 2] xhge2:2 ≤ terras uhu_ge2:2 ≤ uhu_eq2:u = 2⊢ 3 ≤ u exfalso pos x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xha2_step:StepContinues x (a + 2)hnext:terras u = terras^[a + 2] xhge2:2 ≤ terras uhu_ge2:2 ≤ uhu_eq2:u = 2⊢ False
rw [hu_eq2, pos x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xha2_step:StepContinues x (a + 2)hnext:terras u = terras^[a + 2] xhge2:2 ≤ terras 2hu_ge2:2 ≤ uhu_eq2:u = 2⊢ False show terras 2 = 1 from rfl pos x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xha2_step:StepContinues x (a + 2)hnext:terras u = terras^[a + 2] xhge2:2 ≤ 1hu_ge2:2 ≤ uhu_eq2:u = 2⊢ False] at hge2 pos x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xha2_step:StepContinues x (a + 2)hnext:terras u = terras^[a + 2] xhge2:2 ≤ 1hu_ge2:2 ≤ uhu_eq2:u = 2⊢ False
omega All goals completed! 🐙
· neg x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xha2_step:StepContinues x (a + 2)hnext:terras u = terras^[a + 2] xhge2:2 ≤ terras uhu_ge2:2 ≤ uhu_eq2:¬u = 2⊢ 3 ≤ u omega x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xhu3:3 ≤ u⊢ False
let k := b - a x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xhu3:3 ≤ uk:ℕ := b - a⊢ False
have hk1 : 1 ≤ k := by x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)⊢ ¬StayIn x x dsimp only [k] x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xhu3:3 ≤ uk:ℕ := b - a⊢ 1 ≤ b - a; omega x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xhu3:3 ≤ uk:ℕ := b - ahk1:1 ≤ k⊢ False
have hu_cyc : terras^[k] u = u := by x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)⊢ ¬StayIn x x
dsimp only [u] x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xhu3:3 ≤ uk:ℕ := b - ahk1:1 ≤ k⊢ terras^[k] (terras^[a + 1] x) = terras^[a + 1] x
rw [← Function.iterate_add_apply, x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xhu3:3 ≤ uk:ℕ := b - ahk1:1 ≤ k⊢ terras^[k + (a + 1)] x = terras^[a + 1] x show k + (a + 1) = b + 1 by x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)⊢ ¬StayIn x x dsimp only [k] x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xhu3:3 ≤ uk:ℕ := b - ahk1:1 ≤ k⊢ b - a + (a + 1) = b + 1; omega All goals completed! 🐙] x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xhu3:3 ≤ uk:ℕ := b - ahk1:1 ≤ k⊢ terras^[b + 1] x = terras^[a + 1] x
exact hab_eq.symm x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xhu3:3 ≤ uk:ℕ := b - ahk1:1 ≤ khu_cyc:terras^[k] u = u⊢ False
rcases WeakCollatz75.exists_bounded_cycle_max hu3 hk1 hu_cyc with
⟨M, j, hM3, hj1, hjM, hj_cyc, hbnd, ⟨i, hik, hi_M⟩⟩ x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xhu3:3 ≤ uk:ℕ := b - ahk1:1 ≤ khu_cyc:terras^[k] u = uM:ℕj:ℕhM3:3 ≤ Mhj1:1 ≤ jhjM:j ≤ M - 2hj_cyc:terras^[j] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mi:ℕhik:i < khi_M:terras^[i] u = M⊢ False
have hM_lt_x : M < x := by x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)⊢ ¬StayIn x x
have hidx_le : i + (a + 1) ≤ x := by x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)⊢ ¬StayIn x x dsimp only [k, N] at hik hb_le x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ x - 3 + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xhu3:3 ≤ uk:ℕ := b - ahk1:1 ≤ khu_cyc:terras^[k] u = uM:ℕj:ℕhM3:3 ≤ Mhj1:1 ≤ jhjM:j ≤ M - 2hj_cyc:terras^[j] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mi:ℕhik:i < b - ahi_M:terras^[i] u = M⊢ i + (a + 1) ≤ x; omega x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xhu3:3 ≤ uk:ℕ := b - ahk1:1 ≤ khu_cyc:terras^[k] u = uM:ℕj:ℕhM3:3 ≤ Mhj1:1 ≤ jhjM:j ≤ M - 2hj_cyc:terras^[j] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mi:ℕhik:i < khi_M:terras^[i] u = Mhidx_le:i + (a + 1) ≤ x⊢ M < x
have hM_eq : M = terras^[i + (a + 1)] x := by x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)⊢ ¬StayIn x x
rw [← hi_M x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xhu3:3 ≤ uk:ℕ := b - ahk1:1 ≤ khu_cyc:terras^[k] u = uM:ℕj:ℕhM3:3 ≤ Mhj1:1 ≤ jhjM:j ≤ M - 2hj_cyc:terras^[j] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mi:ℕhik:i < khi_M:terras^[i] u = Mhidx_le:i + (a + 1) ≤ x⊢ terras^[i] u = terras^[i + (a + 1)] x] x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xhu3:3 ≤ uk:ℕ := b - ahk1:1 ≤ khu_cyc:terras^[k] u = uM:ℕj:ℕhM3:3 ≤ Mhj1:1 ≤ jhjM:j ≤ M - 2hj_cyc:terras^[j] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mi:ℕhik:i < khi_M:terras^[i] u = Mhidx_le:i + (a + 1) ≤ x⊢ terras^[i] u = terras^[i + (a + 1)] x
dsimp only [u] x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xhu3:3 ≤ uk:ℕ := b - ahk1:1 ≤ khu_cyc:terras^[k] u = uM:ℕj:ℕhM3:3 ≤ Mhj1:1 ≤ jhjM:j ≤ M - 2hj_cyc:terras^[j] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mi:ℕhik:i < khi_M:terras^[i] u = Mhidx_le:i + (a + 1) ≤ x⊢ terras^[i] (terras^[a + 1] x) = terras^[i + (a + 1)] x
rw [← Function.iterate_add_apply x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xhu3:3 ≤ uk:ℕ := b - ahk1:1 ≤ khu_cyc:terras^[k] u = uM:ℕj:ℕhM3:3 ≤ Mhj1:1 ≤ jhjM:j ≤ M - 2hj_cyc:terras^[j] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mi:ℕhik:i < khi_M:terras^[i] u = Mhidx_le:i + (a + 1) ≤ x⊢ terras^[i + (a + 1)] x = terras^[i + (a + 1)] x] x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xhu3:3 ≤ uk:ℕ := b - ahk1:1 ≤ khu_cyc:terras^[k] u = uM:ℕj:ℕhM3:3 ≤ Mhj1:1 ≤ jhjM:j ≤ M - 2hj_cyc:terras^[j] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mi:ℕhik:i < khi_M:terras^[i] u = Mhidx_le:i + (a + 1) ≤ xhM_eq:M = terras^[i + (a + 1)] x⊢ M < x
rw [hM_eq x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xhu3:3 ≤ uk:ℕ := b - ahk1:1 ≤ khu_cyc:terras^[k] u = uM:ℕj:ℕhM3:3 ≤ Mhj1:1 ≤ jhjM:j ≤ M - 2hj_cyc:terras^[j] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mi:ℕhik:i < khi_M:terras^[i] u = Mhidx_le:i + (a + 1) ≤ xhM_eq:M = terras^[i + (a + 1)] x⊢ terras^[i + (a + 1)] x < x] x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xhu3:3 ≤ uk:ℕ := b - ahk1:1 ≤ khu_cyc:terras^[k] u = uM:ℕj:ℕhM3:3 ≤ Mhj1:1 ≤ jhjM:j ≤ M - 2hj_cyc:terras^[j] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mi:ℕhik:i < khi_M:terras^[i] u = Mhidx_le:i + (a + 1) ≤ xhM_eq:M = terras^[i + (a + 1)] x⊢ terras^[i + (a + 1)] x < x
exact (hstay (i + (a + 1)) (by x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xhu3:3 ≤ uk:ℕ := b - ahk1:1 ≤ khu_cyc:terras^[k] u = uM:ℕj:ℕhM3:3 ≤ Mhj1:1 ≤ jhjM:j ≤ M - 2hj_cyc:terras^[j] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mi:ℕhik:i < khi_M:terras^[i] u = Mhidx_le:i + (a + 1) ≤ xhM_eq:M = terras^[i + (a + 1)] x⊢ 1 ≤ i + (a + 1) omega All goals completed! 🐙) hidx_le).2 x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xhu3:3 ≤ uk:ℕ := b - ahk1:1 ≤ khu_cyc:terras^[k] u = uM:ℕj:ℕhM3:3 ≤ Mhj1:1 ≤ jhjM:j ≤ M - 2hj_cyc:terras^[j] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mi:ℕhik:i < khi_M:terras^[i] u = MhM_lt_x:M < x⊢ False
have hM_halts : StageHalts M := stageHalts_of_cycle_max hM3 hj1 (by x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xhu3:3 ≤ uk:ℕ := b - ahk1:1 ≤ khu_cyc:terras^[k] u = uM:ℕj:ℕhM3:3 ≤ Mhj1:1 ≤ jhjM:j ≤ M - 2hj_cyc:terras^[j] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mi:ℕhik:i < khi_M:terras^[i] u = MhM_lt_x:M < x⊢ j ≤ M omega All goals completed! 🐙) hj_cyc hbnd x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xhu3:3 ≤ uk:ℕ := b - ahk1:1 ≤ khu_cyc:terras^[k] u = uM:ℕj:ℕhM3:3 ≤ Mhj1:1 ≤ jhjM:j ≤ M - 2hj_cyc:terras^[j] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mi:ℕhik:i < khi_M:terras^[i] u = MhM_lt_x:M < xhM_halts:StageHalts M⊢ False
exact hno M hM3 (by x:ℕhx:3 ≤ xhno:NoStageHalts (x - 1)hstay:StayIn x xN:ℕ := x - 3f:ℕ → ℕ := fun i ↦ terras^[i + 1] x - 2hf_lt:∀ i ≤ N + 1, f i < N + 1a:ℕb:ℕhab:a < bhb_le:b ≤ N + 1hfab:f a = f bha_step:StepContinues x (a + 1)hb_step:StepContinues x (b + 1)hab_eq:terras^[a + 1] x = terras^[b + 1] xu:ℕ := terras^[a + 1] xhu3:3 ≤ uk:ℕ := b - ahk1:1 ≤ khu_cyc:terras^[k] u = uM:ℕj:ℕhM3:3 ≤ Mhj1:1 ≤ jhjM:j ≤ M - 2hj_cyc:terras^[j] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ Mi:ℕhik:i < khi_M:terras^[i] u = MhM_lt_x:M < xhM_halts:StageHalts M⊢ M ≤ x - 1 omega All goals completed! 🐙) hM_haltsprivate theorem stage_advance_of_noStageHalts (x : ℕ) (hx : 3 ≤ x) (hno : NoStageHalts x) :
reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1)) := by x:ℕhx:3 ≤ xhno:NoStageHalts x⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1))
rcases stayIn_or_first_exit x x with hstay | ⟨t, ht1, htx, hprev, hexit⟩ inl x:ℕhx:3 ≤ xhno:NoStageHalts xhstay:StayIn x x⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1))inr x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x t⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1))
· inl x:ℕhx:3 ≤ xhno:NoStageHalts xhstay:StayIn x x⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1)) exfalso inl x:ℕhx:3 ≤ xhno:NoStageHalts xhstay:StayIn x x⊢ False
exact not_stayIn_self_of_noStageHalts hx (fun w hw3 hwx => hno w hw3 (by x:ℕhx:3 ≤ xhno:NoStageHalts xhstay:StayIn x xw:ℕhw3:3 ≤ whwx:w ≤ x - 1⊢ w ≤ x omega All goals completed! 🐙)) hstay
· inr x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x t⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1)) have hnot_halt : ¬ StageHalts x := hno x hx le_rfl inr x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts x⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1))
have hne_x : terras^[t] x ≠ x := fun hhit => hnot_halt ⟨t, ht1, htx, hprev, hhit⟩ inr x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ x⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1))
have ht_pos : 1 ≤ terras^[t] x := terras_iterate_pos (by x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ x⊢ 1 ≤ x omega All goals completed! 🐙) t inr x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] x⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1))
have hor : terras^[t] x = 1 ∨ x < terras^[t] x := by
by_cases h1 : terras^[t] x = 1 pos x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] xh1:terras^[t] x = 1⊢ terras^[t] x = 1 ∨ x < terras^[t] xneg x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] xh1:¬terras^[t] x = 1⊢ terras^[t] x = 1 ∨ x < terras^[t] x
· pos x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] xh1:terras^[t] x = 1⊢ terras^[t] x = 1 ∨ x < terras^[t] x exact Or.inl h1 All goals completed! 🐙
· neg x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] xh1:¬terras^[t] x = 1⊢ terras^[t] x = 1 ∨ x < terras^[t] x refine Or.inr ?_ neg x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] xh1:¬terras^[t] x = 1⊢ x < terras^[t] x
by_cases hlt : terras^[t] x < x pos x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] xh1:¬terras^[t] x = 1hlt:terras^[t] x < x⊢ x < terras^[t] xneg x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] xh1:¬terras^[t] x = 1hlt:¬terras^[t] x < x⊢ x < terras^[t] x
· pos x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] xh1:¬terras^[t] x = 1hlt:terras^[t] x < x⊢ x < terras^[t] x exfalso pos x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] xh1:¬terras^[t] x = 1hlt:terras^[t] x < x⊢ False; exact hexit ⟨by x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] xh1:¬terras^[t] x = 1hlt:terras^[t] x < x⊢ 2 ≤ terras^[t] x omega All goals completed! 🐙, hlt⟩
· neg x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] xh1:¬terras^[t] x = 1hlt:¬terras^[t] x < x⊢ x < terras^[t] x omega inr x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] xhor:terras^[t] x = 1 ∨ x < terras^[t] x⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1))
rcases stage_stay_reach x hx (t - 1) hprev with ht0 | ⟨ht1_pos, hreach_prev⟩ inr.inl x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] xhor:terras^[t] x = 1 ∨ x < terras^[t] xht0:t - 1 = 0⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1))inr.inr x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] xhor:terras^[t] x = 1 ∨ x < terras^[t] xht1_pos:1 ≤ t - 1hreach_prev:reachPos (stageCfg x x) (stageCfg x (terras^[t - 1] x))⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1))
· inr.inl x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] xhor:terras^[t] x = 1 ∨ x < terras^[t] xht0:t - 1 = 0⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1)) have ht_eq1 : t = 1 := by omega inr.inl x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] xhor:terras^[t] x = 1 ∨ x < terras^[t] xht0:t - 1 = 0ht_eq1:t = 1⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1))
subst ht_eq1 inr.inl x:ℕhx:3 ≤ xhno:NoStageHalts xhnot_halt:¬StageHalts xht1:1 ≤ 1htx:1 ≤ xhprev:StayIn x (1 - 1)hexit:¬StepContinues x 1hne_x:terras^[1] x ≠ xht_pos:1 ≤ terras^[1] xhor:terras^[1] x = 1 ∨ x < terras^[1] xht0:1 - 1 = 0⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1))
rw [Function.iterate_one inr.inl x:ℕhx:3 ≤ xhno:NoStageHalts xhnot_halt:¬StageHalts xht1:1 ≤ 1htx:1 ≤ xhprev:StayIn x (1 - 1)hexit:¬StepContinues x 1hne_x:terras^[1] x ≠ xht_pos:1 ≤ terras^[1] xhor:terras x = 1 ∨ x < terras xht0:1 - 1 = 0⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1))] at hor inr.inl x:ℕhx:3 ≤ xhno:NoStageHalts xhnot_halt:¬StageHalts xht1:1 ≤ 1htx:1 ≤ xhprev:StayIn x (1 - 1)hexit:¬StepContinues x 1hne_x:terras^[1] x ≠ xht_pos:1 ≤ terras^[1] xhor:terras x = 1 ∨ x < terras xht0:1 - 1 = 0⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1))
rcases hor with h1 | hgt inr.inl.inl x:ℕhx:3 ≤ xhno:NoStageHalts xhnot_halt:¬StageHalts xht1:1 ≤ 1htx:1 ≤ xhprev:StayIn x (1 - 1)hexit:¬StepContinues x 1hne_x:terras^[1] x ≠ xht_pos:1 ≤ terras^[1] xht0:1 - 1 = 0h1:terras x = 1⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1))inr.inl.inr x:ℕhx:3 ≤ xhno:NoStageHalts xhnot_halt:¬StageHalts xht1:1 ≤ 1htx:1 ≤ xhprev:StayIn x (1 - 1)hexit:¬StepContinues x 1hne_x:terras^[1] x ≠ xht_pos:1 ≤ terras^[1] xht0:1 - 1 = 0hgt:x < terras x⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1))
· inr.inl.inl x:ℕhx:3 ≤ xhno:NoStageHalts xhnot_halt:¬StageHalts xht1:1 ≤ 1htx:1 ≤ xhprev:StayIn x (1 - 1)hexit:¬StepContinues x 1hne_x:terras^[1] x ≠ xht_pos:1 ≤ terras^[1] xht0:1 - 1 = 0h1:terras x = 1⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1)) have hlt := stage_round_lt x x (by x:ℕhx:3 ≤ xhno:NoStageHalts xhnot_halt:¬StageHalts xht1:1 ≤ 1htx:1 ≤ xhprev:StayIn x (1 - 1)hexit:¬StepContinues x 1hne_x:terras^[1] x ≠ xht_pos:1 ≤ terras^[1] xht0:1 - 1 = 0h1:terras x = 1⊢ 2 ≤ x omega All goals completed! 🐙) (by x:ℕhx:3 ≤ xhno:NoStageHalts xhnot_halt:¬StageHalts xht1:1 ≤ 1htx:1 ≤ xhprev:StayIn x (1 - 1)hexit:¬StepContinues x 1hne_x:terras^[1] x ≠ xht_pos:1 ≤ terras^[1] xht0:1 - 1 = 0h1:terras x = 1⊢ 2 ≤ x omega All goals completed! 🐙) (by x:ℕhx:3 ≤ xhno:NoStageHalts xhnot_halt:¬StageHalts xht1:1 ≤ 1htx:1 ≤ xhprev:StayIn x (1 - 1)hexit:¬StepContinues x 1hne_x:terras^[1] x ≠ xht_pos:1 ≤ terras^[1] xht0:1 - 1 = 0h1:terras x = 1⊢ terras x < x omega All goals completed! 🐙) inr.inl.inl x:ℕhx:3 ≤ xhno:NoStageHalts xhnot_halt:¬StageHalts xht1:1 ≤ 1htx:1 ≤ xhprev:StayIn x (1 - 1)hexit:¬StepContinues x 1hne_x:terras^[1] x ≠ xht_pos:1 ≤ terras^[1] xht0:1 - 1 = 0h1:terras x = 1hlt:reachPos (stageCfg x x) (stageCfg x (terras x))⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1))
rw [h1 inr.inl.inl x:ℕhx:3 ≤ xhno:NoStageHalts xhnot_halt:¬StageHalts xht1:1 ≤ 1htx:1 ≤ xhprev:StayIn x (1 - 1)hexit:¬StepContinues x 1hne_x:terras^[1] x ≠ xht_pos:1 ≤ terras^[1] xht0:1 - 1 = 0h1:terras x = 1hlt:reachPos (stageCfg x x) (stageCfg x 1)⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1))] at hlt inr.inl.inl x:ℕhx:3 ≤ xhno:NoStageHalts xhnot_halt:¬StageHalts xht1:1 ≤ 1htx:1 ≤ xhprev:StayIn x (1 - 1)hexit:¬StepContinues x 1hne_x:terras^[1] x ≠ xht_pos:1 ≤ terras^[1] xht0:1 - 1 = 0h1:terras x = 1hlt:reachPos (stageCfg x x) (stageCfg x 1)⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1))
exact reachPos_trans hlt (stage_y1_advance x (by x:ℕhx:3 ≤ xhno:NoStageHalts xhnot_halt:¬StageHalts xht1:1 ≤ 1htx:1 ≤ xhprev:StayIn x (1 - 1)hexit:¬StepContinues x 1hne_x:terras^[1] x ≠ xht_pos:1 ≤ terras^[1] xht0:1 - 1 = 0h1:terras x = 1hlt:reachPos (stageCfg x x) (stageCfg x 1)⊢ 1 ≤ x omega All goals completed! 🐙))
· inr.inl.inr x:ℕhx:3 ≤ xhno:NoStageHalts xhnot_halt:¬StageHalts xht1:1 ≤ 1htx:1 ≤ xhprev:StayIn x (1 - 1)hexit:¬StepContinues x 1hne_x:terras^[1] x ≠ xht_pos:1 ≤ terras^[1] xht0:1 - 1 = 0hgt:x < terras x⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1)) exact stage_round_gt x x hx (by x:ℕhx:3 ≤ xhno:NoStageHalts xhnot_halt:¬StageHalts xht1:1 ≤ 1htx:1 ≤ xhprev:StayIn x (1 - 1)hexit:¬StepContinues x 1hne_x:terras^[1] x ≠ xht_pos:1 ≤ terras^[1] xht0:1 - 1 = 0hgt:x < terras x⊢ 2 ≤ x omega All goals completed! 🐙) hgt
· inr.inr x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] xhor:terras^[t] x = 1 ∨ x < terras^[t] xht1_pos:1 ≤ t - 1hreach_prev:reachPos (stageCfg x x) (stageCfg x (terras^[t - 1] x))⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1)) have hy_prev : 2 ≤ terras^[t - 1] x := (hprev (t - 1) ht1_pos le_rfl).1 inr.inr x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] xhor:terras^[t] x = 1 ∨ x < terras^[t] xht1_pos:1 ≤ t - 1hreach_prev:reachPos (stageCfg x x) (stageCfg x (terras^[t - 1] x))hy_prev:2 ≤ terras^[t - 1] x⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1))
have hnext : terras (terras^[t - 1] x) = terras^[t] x := by
rw [← Function.iterate_succ_apply' terras (t - 1) x, x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] xhor:terras^[t] x = 1 ∨ x < terras^[t] xht1_pos:1 ≤ t - 1hreach_prev:reachPos (stageCfg x x) (stageCfg x (terras^[t - 1] x))hy_prev:2 ≤ terras^[t - 1] x⊢ terras^[(t - 1).succ] x = terras^[t] x show (t - 1).succ = t by x:ℕhx:3 ≤ xhno:NoStageHalts x⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1)) omega All goals completed! 🐙] inr.inr x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] xhor:terras^[t] x = 1 ∨ x < terras^[t] xht1_pos:1 ≤ t - 1hreach_prev:reachPos (stageCfg x x) (stageCfg x (terras^[t - 1] x))hy_prev:2 ≤ terras^[t - 1] xhnext:terras (terras^[t - 1] x) = terras^[t] x⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1))
rcases hor with h1 | hgt inr.inr.inl x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] xht1_pos:1 ≤ t - 1hreach_prev:reachPos (stageCfg x x) (stageCfg x (terras^[t - 1] x))hy_prev:2 ≤ terras^[t - 1] xhnext:terras (terras^[t - 1] x) = terras^[t] xh1:terras^[t] x = 1⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1))inr.inr.inr x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] xht1_pos:1 ≤ t - 1hreach_prev:reachPos (stageCfg x x) (stageCfg x (terras^[t - 1] x))hy_prev:2 ≤ terras^[t - 1] xhnext:terras (terras^[t - 1] x) = terras^[t] xhgt:x < terras^[t] x⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1))
· inr.inr.inl x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] xht1_pos:1 ≤ t - 1hreach_prev:reachPos (stageCfg x x) (stageCfg x (terras^[t - 1] x))hy_prev:2 ≤ terras^[t - 1] xhnext:terras (terras^[t - 1] x) = terras^[t] xh1:terras^[t] x = 1⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1)) have hlt := stage_round_lt x (terras^[t - 1] x) (by x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] xht1_pos:1 ≤ t - 1hreach_prev:reachPos (stageCfg x x) (stageCfg x (terras^[t - 1] x))hy_prev:2 ≤ terras^[t - 1] xhnext:terras (terras^[t - 1] x) = terras^[t] xh1:terras^[t] x = 1⊢ 2 ≤ x omega All goals completed! 🐙) hy_prev (by x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] xht1_pos:1 ≤ t - 1hreach_prev:reachPos (stageCfg x x) (stageCfg x (terras^[t - 1] x))hy_prev:2 ≤ terras^[t - 1] xhnext:terras (terras^[t - 1] x) = terras^[t] xh1:terras^[t] x = 1⊢ terras (terras^[t - 1] x) < x rw [hnext x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] xht1_pos:1 ≤ t - 1hreach_prev:reachPos (stageCfg x x) (stageCfg x (terras^[t - 1] x))hy_prev:2 ≤ terras^[t - 1] xhnext:terras (terras^[t - 1] x) = terras^[t] xh1:terras^[t] x = 1⊢ terras^[t] x < x] x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] xht1_pos:1 ≤ t - 1hreach_prev:reachPos (stageCfg x x) (stageCfg x (terras^[t - 1] x))hy_prev:2 ≤ terras^[t - 1] xhnext:terras (terras^[t - 1] x) = terras^[t] xh1:terras^[t] x = 1⊢ terras^[t] x < x; omega All goals completed! 🐙) inr.inr.inl x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] xht1_pos:1 ≤ t - 1hreach_prev:reachPos (stageCfg x x) (stageCfg x (terras^[t - 1] x))hy_prev:2 ≤ terras^[t - 1] xhnext:terras (terras^[t - 1] x) = terras^[t] xh1:terras^[t] x = 1hlt:reachPos (stageCfg x (terras^[t - 1] x)) (stageCfg x (terras (terras^[t - 1] x)))⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1))
rw [hnext, inr.inr.inl x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] xht1_pos:1 ≤ t - 1hreach_prev:reachPos (stageCfg x x) (stageCfg x (terras^[t - 1] x))hy_prev:2 ≤ terras^[t - 1] xhnext:terras (terras^[t - 1] x) = terras^[t] xh1:terras^[t] x = 1hlt:reachPos (stageCfg x (terras^[t - 1] x)) (stageCfg x (terras^[t] x))⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1)) h1 inr.inr.inl x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] xht1_pos:1 ≤ t - 1hreach_prev:reachPos (stageCfg x x) (stageCfg x (terras^[t - 1] x))hy_prev:2 ≤ terras^[t - 1] xhnext:terras (terras^[t - 1] x) = terras^[t] xh1:terras^[t] x = 1hlt:reachPos (stageCfg x (terras^[t - 1] x)) (stageCfg x 1)⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1))] at hlt inr.inr.inl x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] xht1_pos:1 ≤ t - 1hreach_prev:reachPos (stageCfg x x) (stageCfg x (terras^[t - 1] x))hy_prev:2 ≤ terras^[t - 1] xhnext:terras (terras^[t - 1] x) = terras^[t] xh1:terras^[t] x = 1hlt:reachPos (stageCfg x (terras^[t - 1] x)) (stageCfg x 1)⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1))
exact reachPos_trans hreach_prev (reachPos_trans hlt (stage_y1_advance x (by x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] xht1_pos:1 ≤ t - 1hreach_prev:reachPos (stageCfg x x) (stageCfg x (terras^[t - 1] x))hy_prev:2 ≤ terras^[t - 1] xhnext:terras (terras^[t - 1] x) = terras^[t] xh1:terras^[t] x = 1hlt:reachPos (stageCfg x (terras^[t - 1] x)) (stageCfg x 1)⊢ 1 ≤ x omega All goals completed! 🐙)))
· inr.inr.inr x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] xht1_pos:1 ≤ t - 1hreach_prev:reachPos (stageCfg x x) (stageCfg x (terras^[t - 1] x))hy_prev:2 ≤ terras^[t - 1] xhnext:terras (terras^[t - 1] x) = terras^[t] xhgt:x < terras^[t] x⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1)) rw [← hnext inr.inr.inr x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] xht1_pos:1 ≤ t - 1hreach_prev:reachPos (stageCfg x x) (stageCfg x (terras^[t - 1] x))hy_prev:2 ≤ terras^[t - 1] xhnext:terras (terras^[t - 1] x) = terras^[t] xhgt:x < terras (terras^[t - 1] x)⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1))] at hgt inr.inr.inr x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x thnot_halt:¬StageHalts xhne_x:terras^[t] x ≠ xht_pos:1 ≤ terras^[t] xht1_pos:1 ≤ t - 1hreach_prev:reachPos (stageCfg x x) (stageCfg x (terras^[t - 1] x))hy_prev:2 ≤ terras^[t - 1] xhnext:terras (terras^[t - 1] x) = terras^[t] xhgt:x < terras (terras^[t - 1] x)⊢ reachPos (stageCfg x x) (stageCfg (x + 1) (x + 1))
exact reachPos_trans hreach_prev (stage_round_gt x (terras^[t - 1] x) hx hy_prev hgt) All goals completed! 🐙private theorem reach_stage_from_init (X : ℕ) (hX : 3 ≤ X) (hno : NoStageHalts (X - 1)) :
∃ s : ℕ, X - 2 ≤ s ∧ nSteps weakCollatz27 s init = some (stageCfg X X) := by X:ℕhX:3 ≤ Xhno:NoStageHalts (X - 1)⊢ ∃ s, X - 2 ≤ s ∧ nSteps weakCollatz27 s init = some (stageCfg X X)
induction X, hX using Nat.le_induction with
| base => base X:ℕhno:NoStageHalts (3 - 1)⊢ ∃ s, 3 - 2 ≤ s ∧ nSteps weakCollatz27 s init = some (stageCfg 3 3)
obtain ⟨s, hs1, hs⟩ := init_reaches_stage3 base X:ℕhno:NoStageHalts (3 - 1)s:ℕhs1:1 ≤ shs:nSteps weakCollatz27 s init = some (stageCfg 3 3)⊢ ∃ s, 3 - 2 ≤ s ∧ nSteps weakCollatz27 s init = some (stageCfg 3 3)
exact ⟨s, by X:ℕhno:NoStageHalts (3 - 1)s:ℕhs1:1 ≤ shs:nSteps weakCollatz27 s init = some (stageCfg 3 3)⊢ 3 - 2 ≤ s omega All goals completed! 🐙, hs⟩
| succ X hX ih => succ X✝:ℕX:ℕhX:3 ≤ Xih:NoStageHalts (X - 1) → ∃ s, X - 2 ≤ s ∧ nSteps weakCollatz27 s init = some (stageCfg X X)hno:NoStageHalts (X + 1 - 1)⊢ ∃ s, X + 1 - 2 ≤ s ∧ nSteps weakCollatz27 s init = some (stageCfg (X + 1) (X + 1))
obtain ⟨s₁, hs₁_ge, hs₁⟩ := ih fun w hw3 hw_le => hno w hw3 (by X✝:ℕX:ℕhX:3 ≤ Xih:NoStageHalts (X - 1) → ∃ s, X - 2 ≤ s ∧ nSteps weakCollatz27 s init = some (stageCfg X X)hno:NoStageHalts (X + 1 - 1)w:ℕhw3:3 ≤ whw_le:w ≤ X - 1⊢ w ≤ X + 1 - 1 omega All goals completed! 🐙) succ X✝:ℕX:ℕhX:3 ≤ Xih:NoStageHalts (X - 1) → ∃ s, X - 2 ≤ s ∧ nSteps weakCollatz27 s init = some (stageCfg X X)hno:NoStageHalts (X + 1 - 1)s₁:ℕhs₁_ge:X - 2 ≤ s₁hs₁:nSteps weakCollatz27 s₁ init = some (stageCfg X X)⊢ ∃ s, X + 1 - 2 ≤ s ∧ nSteps weakCollatz27 s init = some (stageCfg (X + 1) (X + 1))
obtain ⟨s₂, hs₂_pos, hs₂⟩ :=
stage_advance_of_noStageHalts X hX fun w hw3 hw_le => hno w hw3 (by X✝:ℕX:ℕhX:3 ≤ Xih:NoStageHalts (X - 1) → ∃ s, X - 2 ≤ s ∧ nSteps weakCollatz27 s init = some (stageCfg X X)hno:NoStageHalts (X + 1 - 1)s₁:ℕhs₁_ge:X - 2 ≤ s₁hs₁:nSteps weakCollatz27 s₁ init = some (stageCfg X X)w:ℕhw3:3 ≤ whw_le:w ≤ X⊢ w ≤ X + 1 - 1 omega All goals completed! 🐙) succ X✝:ℕX:ℕhX:3 ≤ Xih:NoStageHalts (X - 1) → ∃ s, X - 2 ≤ s ∧ nSteps weakCollatz27 s init = some (stageCfg X X)hno:NoStageHalts (X + 1 - 1)s₁:ℕhs₁_ge:X - 2 ≤ s₁hs₁:nSteps weakCollatz27 s₁ init = some (stageCfg X X)s₂:ℕhs₂_pos:1 ≤ s₂hs₂:nSteps weakCollatz27 s₂ (stageCfg X X) = some (stageCfg (X + 1) (X + 1))⊢ ∃ s, X + 1 - 2 ≤ s ∧ nSteps weakCollatz27 s init = some (stageCfg (X + 1) (X + 1))
exact ⟨s₁ + s₂, by X✝:ℕX:ℕhX:3 ≤ Xih:NoStageHalts (X - 1) → ∃ s, X - 2 ≤ s ∧ nSteps weakCollatz27 s init = some (stageCfg X X)hno:NoStageHalts (X + 1 - 1)s₁:ℕhs₁_ge:X - 2 ≤ s₁hs₁:nSteps weakCollatz27 s₁ init = some (stageCfg X X)s₂:ℕhs₂_pos:1 ≤ s₂hs₂:nSteps weakCollatz27 s₂ (stageCfg X X) = some (stageCfg (X + 1) (X + 1))⊢ X + 1 - 2 ≤ s₁ + s₂ omega All goals completed! 🐙, nSteps_bind_eq hs₁ hs₂⟩private theorem stage_halt_of_stageHalts (x : ℕ) (hx : 3 ≤ x) (hhalt : StageHalts x) :
∃ s cfg, nSteps weakCollatz27 s (stageCfg x x) = some cfg ∧
step weakCollatz27 cfg = none := by x:ℕhx:3 ≤ xhhalt:StageHalts x⊢ ∃ s cfg, nSteps weakCollatz27 s (stageCfg x x) = some cfg ∧ step weakCollatz27 cfg = none
obtain ⟨t, ht1, _, hprev, hhit⟩ := hhalt x:ℕhx:3 ≤ xt:ℕht1:1 ≤ tleft✝:t ≤ xhprev:StayIn x (t - 1)hhit:terras^[t] x = x⊢ ∃ s cfg, nSteps weakCollatz27 s (stageCfg x x) = some cfg ∧ step weakCollatz27 cfg = none
rcases stage_stay_reach x hx (t - 1) hprev with ht0 | ⟨ht1_pos, hreach_prev⟩ inl x:ℕhx:3 ≤ xt:ℕht1:1 ≤ tleft✝:t ≤ xhprev:StayIn x (t - 1)hhit:terras^[t] x = xht0:t - 1 = 0⊢ ∃ s cfg, nSteps weakCollatz27 s (stageCfg x x) = some cfg ∧ step weakCollatz27 cfg = noneinr x:ℕhx:3 ≤ xt:ℕht1:1 ≤ tleft✝:t ≤ xhprev:StayIn x (t - 1)hhit:terras^[t] x = xht1_pos:1 ≤ t - 1hreach_prev:reachPos (stageCfg x x) (stageCfg x (terras^[t - 1] x))⊢ ∃ s cfg, nSteps weakCollatz27 s (stageCfg x x) = some cfg ∧ step weakCollatz27 cfg = none
· inl x:ℕhx:3 ≤ xt:ℕht1:1 ≤ tleft✝:t ≤ xhprev:StayIn x (t - 1)hhit:terras^[t] x = xht0:t - 1 = 0⊢ ∃ s cfg, nSteps weakCollatz27 s (stageCfg x x) = some cfg ∧ step weakCollatz27 cfg = none have ht_eq1 : t = 1 := by omega inl x:ℕhx:3 ≤ xt:ℕht1:1 ≤ tleft✝:t ≤ xhprev:StayIn x (t - 1)hhit:terras^[t] x = xht0:t - 1 = 0ht_eq1:t = 1⊢ ∃ s cfg, nSteps weakCollatz27 s (stageCfg x x) = some cfg ∧ step weakCollatz27 cfg = none
subst ht_eq1 inl x:ℕhx:3 ≤ xht1:1 ≤ 1left✝:1 ≤ xhprev:StayIn x (1 - 1)hhit:terras^[1] x = xht0:1 - 1 = 0⊢ ∃ s cfg, nSteps weakCollatz27 s (stageCfg x x) = some cfg ∧ step weakCollatz27 cfg = none
rw [Function.iterate_one inl x:ℕhx:3 ≤ xht1:1 ≤ 1left✝:1 ≤ xhprev:StayIn x (1 - 1)hhit:terras x = xht0:1 - 1 = 0⊢ ∃ s cfg, nSteps weakCollatz27 s (stageCfg x x) = some cfg ∧ step weakCollatz27 cfg = none] at hhit inl x:ℕhx:3 ≤ xht1:1 ≤ 1left✝:1 ≤ xhprev:StayIn x (1 - 1)hhit:terras x = xht0:1 - 1 = 0⊢ ∃ s cfg, nSteps weakCollatz27 s (stageCfg x x) = some cfg ∧ step weakCollatz27 cfg = none
exact stage_round_halt x x hx (by x:ℕhx:3 ≤ xht1:1 ≤ 1left✝:1 ≤ xhprev:StayIn x (1 - 1)hhit:terras x = xht0:1 - 1 = 0⊢ 2 ≤ x omega All goals completed! 🐙) hhit
· inr x:ℕhx:3 ≤ xt:ℕht1:1 ≤ tleft✝:t ≤ xhprev:StayIn x (t - 1)hhit:terras^[t] x = xht1_pos:1 ≤ t - 1hreach_prev:reachPos (stageCfg x x) (stageCfg x (terras^[t - 1] x))⊢ ∃ s cfg, nSteps weakCollatz27 s (stageCfg x x) = some cfg ∧ step weakCollatz27 cfg = none obtain ⟨s₁, _, hs₁⟩ := hreach_prev inr x:ℕhx:3 ≤ xt:ℕht1:1 ≤ tleft✝¹:t ≤ xhprev:StayIn x (t - 1)hhit:terras^[t] x = xht1_pos:1 ≤ t - 1s₁:ℕleft✝:1 ≤ s₁hs₁:nSteps weakCollatz27 s₁ (stageCfg x x) = some (stageCfg x (terras^[t - 1] x))⊢ ∃ s cfg, nSteps weakCollatz27 s (stageCfg x x) = some cfg ∧ step weakCollatz27 cfg = none
have hy_prev : 2 ≤ terras^[t - 1] x := (hprev (t - 1) ht1_pos le_rfl).1 inr x:ℕhx:3 ≤ xt:ℕht1:1 ≤ tleft✝¹:t ≤ xhprev:StayIn x (t - 1)hhit:terras^[t] x = xht1_pos:1 ≤ t - 1s₁:ℕleft✝:1 ≤ s₁hs₁:nSteps weakCollatz27 s₁ (stageCfg x x) = some (stageCfg x (terras^[t - 1] x))hy_prev:2 ≤ terras^[t - 1] x⊢ ∃ s cfg, nSteps weakCollatz27 s (stageCfg x x) = some cfg ∧ step weakCollatz27 cfg = none
have hhit' : terras (terras^[t - 1] x) = x := by
rw [← Function.iterate_succ_apply' terras (t - 1) x, x:ℕhx:3 ≤ xt:ℕht1:1 ≤ tleft✝¹:t ≤ xhprev:StayIn x (t - 1)hhit:terras^[t] x = xht1_pos:1 ≤ t - 1s₁:ℕleft✝:1 ≤ s₁hs₁:nSteps weakCollatz27 s₁ (stageCfg x x) = some (stageCfg x (terras^[t - 1] x))hy_prev:2 ≤ terras^[t - 1] x⊢ terras^[(t - 1).succ] x = x show (t - 1).succ = t by x:ℕhx:3 ≤ xhhalt:StageHalts x⊢ ∃ s cfg, nSteps weakCollatz27 s (stageCfg x x) = some cfg ∧ step weakCollatz27 cfg = none omega All goals completed! 🐙] x:ℕhx:3 ≤ xt:ℕht1:1 ≤ tleft✝¹:t ≤ xhprev:StayIn x (t - 1)hhit:terras^[t] x = xht1_pos:1 ≤ t - 1s₁:ℕleft✝:1 ≤ s₁hs₁:nSteps weakCollatz27 s₁ (stageCfg x x) = some (stageCfg x (terras^[t - 1] x))hy_prev:2 ≤ terras^[t - 1] x⊢ terras^[t] x = x
exact hhit inr x:ℕhx:3 ≤ xt:ℕht1:1 ≤ tleft✝¹:t ≤ xhprev:StayIn x (t - 1)hhit:terras^[t] x = xht1_pos:1 ≤ t - 1s₁:ℕleft✝:1 ≤ s₁hs₁:nSteps weakCollatz27 s₁ (stageCfg x x) = some (stageCfg x (terras^[t - 1] x))hy_prev:2 ≤ terras^[t - 1] xhhit':terras (terras^[t - 1] x) = x⊢ ∃ s cfg, nSteps weakCollatz27 s (stageCfg x x) = some cfg ∧ step weakCollatz27 cfg = none
obtain ⟨s₂, cfg, hs₂, hnone⟩ := stage_round_halt x (terras^[t - 1] x) hx hy_prev hhit' inr x:ℕhx:3 ≤ xt:ℕht1:1 ≤ tleft✝¹:t ≤ xhprev:StayIn x (t - 1)hhit:terras^[t] x = xht1_pos:1 ≤ t - 1s₁:ℕleft✝:1 ≤ s₁hs₁:nSteps weakCollatz27 s₁ (stageCfg x x) = some (stageCfg x (terras^[t - 1] x))hy_prev:2 ≤ terras^[t - 1] xhhit':terras (terras^[t - 1] x) = xs₂:ℕcfg:Cfg 27 2hs₂:nSteps weakCollatz27 s₂ (stageCfg x (terras^[t - 1] x)) = some cfghnone:step weakCollatz27 cfg = none⊢ ∃ s cfg, nSteps weakCollatz27 s (stageCfg x x) = some cfg ∧ step weakCollatz27 cfg = none
exact ⟨s₁ + s₂, cfg, nSteps_bind_eq hs₁ hs₂, hnone⟩ All goals completed! 🐙
The 27-state machine weakCollatz27 (weak_collatz_27) halts on the blank tape if and only if
there exist x ≥ 3 and 1 ≤ j ≤ x with terras^[j] x = x
(constructive, zero Classical.choice).
theorem halts_weakCollatz27_iff_bounded_cycle :
ConjectureMachines.Halts weakCollatz27 ↔
∃ x j : ℕ, 3 ≤ x ∧ 1 ≤ j ∧ j ≤ x ∧ terras^[j] x = x := by ⊢ ConjectureMachines.Halts weakCollatz27 ↔ ∃ x j, 3 ≤ x ∧ 1 ≤ j ∧ j ≤ x ∧ terras^[j] x = x
unfold ConjectureMachines.Halts ⊢ (eval (step weakCollatz27) init).Dom ↔ ∃ x j, 3 ≤ x ∧ 1 ≤ j ∧ j ≤ x ∧ terras^[j] x = x
constructor mp ⊢ (eval (step weakCollatz27) init).Dom → ∃ x j, 3 ≤ x ∧ 1 ≤ j ∧ j ≤ x ∧ terras^[j] x = xmpr ⊢ (∃ x j, 3 ≤ x ∧ 1 ≤ j ∧ j ≤ x ∧ terras^[j] x = x) → (eval (step weakCollatz27) init).Dom
· mp ⊢ (eval (step weakCollatz27) init).Dom → ∃ x j, 3 ≤ x ∧ 1 ≤ j ∧ j ≤ x ∧ terras^[j] x = x intro hdom mp hdom:(eval (step weakCollatz27) init).Dom⊢ ∃ x j, 3 ≤ x ∧ 1 ≤ j ∧ j ≤ x ∧ terras^[j] x = x
rw [Part.dom_iff_mem mp hdom:∃ y, y ∈ eval (step weakCollatz27) init⊢ ∃ x j, 3 ≤ x ∧ 1 ≤ j ∧ j ≤ x ∧ terras^[j] x = x] at hdom mp hdom:∃ y, y ∈ eval (step weakCollatz27) init⊢ ∃ x j, 3 ≤ x ∧ 1 ≤ j ∧ j ≤ x ∧ terras^[j] x = x
obtain ⟨b, hb⟩ := hdom mp b:Cfg 27 2hb:b ∈ eval (step weakCollatz27) init⊢ ∃ x j, 3 ≤ x ∧ 1 ≤ j ∧ j ≤ x ∧ terras^[j] x = x
rw [mem_eval' mp b:Cfg 27 2hb:Reaches (step weakCollatz27) init b ∧ step weakCollatz27 b = none⊢ ∃ x j, 3 ≤ x ∧ 1 ≤ j ∧ j ≤ x ∧ terras^[j] x = x] at hb mp b:Cfg 27 2hb:Reaches (step weakCollatz27) init b ∧ step weakCollatz27 b = none⊢ ∃ x j, 3 ≤ x ∧ 1 ≤ j ∧ j ≤ x ∧ terras^[j] x = x
obtain ⟨hreach, hnone⟩ := hb mp b:Cfg 27 2hreach:Reaches (step weakCollatz27) init bhnone:step weakCollatz27 b = none⊢ ∃ x j, 3 ≤ x ∧ 1 ≤ j ∧ j ≤ x ∧ terras^[j] x = x
obtain ⟨k, hk⟩ := reaches_imp_nSteps hreach mp b:Cfg 27 2hreach:Reaches (step weakCollatz27) init bhnone:step weakCollatz27 b = nonek:ℕhk:nSteps weakCollatz27 k init = some b⊢ ∃ x j, 3 ≤ x ∧ 1 ≤ j ∧ j ≤ x ∧ terras^[j] x = x
rcases noStageHalts_or_first (k + 3) with hno | ⟨w, hw3, -, -, ⟨t, ht1, htw, -, hhit⟩⟩ mp.inl b:Cfg 27 2hreach:Reaches (step weakCollatz27) init bhnone:step weakCollatz27 b = nonek:ℕhk:nSteps weakCollatz27 k init = some bhno:NoStageHalts (k + 3)⊢ ∃ x j, 3 ≤ x ∧ 1 ≤ j ∧ j ≤ x ∧ terras^[j] x = xmp.inr b:Cfg 27 2hreach:Reaches (step weakCollatz27) init bhnone:step weakCollatz27 b = nonek:ℕhk:nSteps weakCollatz27 k init = some bw:ℕhw3:3 ≤ wt:ℕht1:1 ≤ thtw:t ≤ whhit:terras^[t] w = w⊢ ∃ x j, 3 ≤ x ∧ 1 ≤ j ∧ j ≤ x ∧ terras^[j] x = x
· mp.inl b:Cfg 27 2hreach:Reaches (step weakCollatz27) init bhnone:step weakCollatz27 b = nonek:ℕhk:nSteps weakCollatz27 k init = some bhno:NoStageHalts (k + 3)⊢ ∃ x j, 3 ≤ x ∧ 1 ≤ j ∧ j ≤ x ∧ terras^[j] x = x obtain ⟨s, hks, hs⟩ := reach_stage_from_init (k + 3) (by b:Cfg 27 2hreach:Reaches (step weakCollatz27) init bhnone:step weakCollatz27 b = nonek:ℕhk:nSteps weakCollatz27 k init = some bhno:NoStageHalts (k + 3)⊢ 3 ≤ k + 3 omega All goals completed! 🐙)
(fun w hw3 hw_le => hno w hw3 (by b:Cfg 27 2hreach:Reaches (step weakCollatz27) init bhnone:step weakCollatz27 b = nonek:ℕhk:nSteps weakCollatz27 k init = some bhno:NoStageHalts (k + 3)w:ℕhw3:3 ≤ whw_le:w ≤ k + 3 - 1⊢ w ≤ k + 3 omega All goals completed! 🐙)) mp.inl b:Cfg 27 2hreach:Reaches (step weakCollatz27) init bhnone:step weakCollatz27 b = nonek:ℕhk:nSteps weakCollatz27 k init = some bhno:NoStageHalts (k + 3)s:ℕhks:k + 3 - 2 ≤ shs:nSteps weakCollatz27 s init = some (stageCfg (k + 3) (k + 3))⊢ ∃ x j, 3 ≤ x ∧ 1 ≤ j ∧ j ≤ x ∧ terras^[j] x = x
rw [nSteps_eq_none_of_step_none s hk hnone (by b:Cfg 27 2hreach:Reaches (step weakCollatz27) init bhnone:step weakCollatz27 b = nonek:ℕhk:nSteps weakCollatz27 k init = some bhno:NoStageHalts (k + 3)s:ℕhks:k + 3 - 2 ≤ shs:nSteps weakCollatz27 s init = some (stageCfg (k + 3) (k + 3))⊢ k < s omega All goals completed! 🐙)] at hs mp.inl b:Cfg 27 2hreach:Reaches (step weakCollatz27) init bhnone:step weakCollatz27 b = nonek:ℕhk:nSteps weakCollatz27 k init = some bhno:NoStageHalts (k + 3)s:ℕhks:k + 3 - 2 ≤ shs:none = some (stageCfg (k + 3) (k + 3))⊢ ∃ x j, 3 ≤ x ∧ 1 ≤ j ∧ j ≤ x ∧ terras^[j] x = x
cases hs All goals completed! 🐙
· mp.inr b:Cfg 27 2hreach:Reaches (step weakCollatz27) init bhnone:step weakCollatz27 b = nonek:ℕhk:nSteps weakCollatz27 k init = some bw:ℕhw3:3 ≤ wt:ℕht1:1 ≤ thtw:t ≤ whhit:terras^[t] w = w⊢ ∃ x j, 3 ≤ x ∧ 1 ≤ j ∧ j ≤ x ∧ terras^[j] x = x exact ⟨w, t, hw3, ht1, htw, hhit⟩ All goals completed! 🐙
· mpr ⊢ (∃ x j, 3 ≤ x ∧ 1 ≤ j ∧ j ≤ x ∧ terras^[j] x = x) → (eval (step weakCollatz27) init).Dom rintro ⟨x, j, hx3, hj1, _, hhit⟩ mpr x:ℕj:ℕhx3:3 ≤ xhj1:1 ≤ jleft✝:j ≤ xhhit:terras^[j] x = x⊢ (eval (step weakCollatz27) init).Dom
rcases WeakCollatz75.exists_bounded_cycle_max hx3 hj1 hhit with
⟨M, jM, hM3, hjM1, hjMM, hjM_cyc, hbnd, -⟩ mpr x:ℕj:ℕhx3:3 ≤ xhj1:1 ≤ jleft✝:j ≤ xhhit:terras^[j] x = xM:ℕjM:ℕhM3:3 ≤ MhjM1:1 ≤ jMhjMM:jM ≤ M - 2hjM_cyc:terras^[jM] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ M⊢ (eval (step weakCollatz27) init).Dom
have hM_halts : StageHalts M :=
stageHalts_of_cycle_max hM3 hjM1 (by x:ℕj:ℕhx3:3 ≤ xhj1:1 ≤ jleft✝:j ≤ xhhit:terras^[j] x = xM:ℕjM:ℕhM3:3 ≤ MhjM1:1 ≤ jMhjMM:jM ≤ M - 2hjM_cyc:terras^[jM] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ M⊢ jM ≤ M omega All goals completed! 🐙) hjM_cyc hbnd mpr x:ℕj:ℕhx3:3 ≤ xhj1:1 ≤ jleft✝:j ≤ xhhit:terras^[j] x = xM:ℕjM:ℕhM3:3 ≤ MhjM1:1 ≤ jMhjMM:jM ≤ M - 2hjM_cyc:terras^[jM] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ MhM_halts:StageHalts M⊢ (eval (step weakCollatz27) init).Dom
rcases noStageHalts_or_first M with hno | ⟨w₀, hw₀3, -, hprev₀, hhalt₀⟩ mpr.inl x:ℕj:ℕhx3:3 ≤ xhj1:1 ≤ jleft✝:j ≤ xhhit:terras^[j] x = xM:ℕjM:ℕhM3:3 ≤ MhjM1:1 ≤ jMhjMM:jM ≤ M - 2hjM_cyc:terras^[jM] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ MhM_halts:StageHalts Mhno:NoStageHalts M⊢ (eval (step weakCollatz27) init).Dommpr.inr x:ℕj:ℕhx3:3 ≤ xhj1:1 ≤ jleft✝:j ≤ xhhit:terras^[j] x = xM:ℕjM:ℕhM3:3 ≤ MhjM1:1 ≤ jMhjMM:jM ≤ M - 2hjM_cyc:terras^[jM] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ MhM_halts:StageHalts Mw₀:ℕhw₀3:3 ≤ w₀hprev₀:NoStageHalts (w₀ - 1)hhalt₀:StageHalts w₀⊢ (eval (step weakCollatz27) init).Dom
· mpr.inl x:ℕj:ℕhx3:3 ≤ xhj1:1 ≤ jleft✝:j ≤ xhhit:terras^[j] x = xM:ℕjM:ℕhM3:3 ≤ MhjM1:1 ≤ jMhjMM:jM ≤ M - 2hjM_cyc:terras^[jM] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ MhM_halts:StageHalts Mhno:NoStageHalts M⊢ (eval (step weakCollatz27) init).Dom exfalso mpr.inl x:ℕj:ℕhx3:3 ≤ xhj1:1 ≤ jleft✝:j ≤ xhhit:terras^[j] x = xM:ℕjM:ℕhM3:3 ≤ MhjM1:1 ≤ jMhjMM:jM ≤ M - 2hjM_cyc:terras^[jM] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ MhM_halts:StageHalts Mhno:NoStageHalts M⊢ False
exact hno M hM3 le_rfl hM_halts All goals completed! 🐙
· mpr.inr x:ℕj:ℕhx3:3 ≤ xhj1:1 ≤ jleft✝:j ≤ xhhit:terras^[j] x = xM:ℕjM:ℕhM3:3 ≤ MhjM1:1 ≤ jMhjMM:jM ≤ M - 2hjM_cyc:terras^[jM] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ MhM_halts:StageHalts Mw₀:ℕhw₀3:3 ≤ w₀hprev₀:NoStageHalts (w₀ - 1)hhalt₀:StageHalts w₀⊢ (eval (step weakCollatz27) init).Dom obtain ⟨s₁, -, hs₁⟩ := reach_stage_from_init w₀ hw₀3 hprev₀ mpr.inr x:ℕj:ℕhx3:3 ≤ xhj1:1 ≤ jleft✝:j ≤ xhhit:terras^[j] x = xM:ℕjM:ℕhM3:3 ≤ MhjM1:1 ≤ jMhjMM:jM ≤ M - 2hjM_cyc:terras^[jM] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ MhM_halts:StageHalts Mw₀:ℕhw₀3:3 ≤ w₀hprev₀:NoStageHalts (w₀ - 1)hhalt₀:StageHalts w₀s₁:ℕhs₁:nSteps weakCollatz27 s₁ init = some (stageCfg w₀ w₀)⊢ (eval (step weakCollatz27) init).Dom
obtain ⟨s₂, cfg, hs₂, hnone⟩ := stage_halt_of_stageHalts w₀ hw₀3 hhalt₀ mpr.inr x:ℕj:ℕhx3:3 ≤ xhj1:1 ≤ jleft✝:j ≤ xhhit:terras^[j] x = xM:ℕjM:ℕhM3:3 ≤ MhjM1:1 ≤ jMhjMM:jM ≤ M - 2hjM_cyc:terras^[jM] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ MhM_halts:StageHalts Mw₀:ℕhw₀3:3 ≤ w₀hprev₀:NoStageHalts (w₀ - 1)hhalt₀:StageHalts w₀s₁:ℕhs₁:nSteps weakCollatz27 s₁ init = some (stageCfg w₀ w₀)s₂:ℕcfg:Cfg 27 2hs₂:nSteps weakCollatz27 s₂ (stageCfg w₀ w₀) = some cfghnone:step weakCollatz27 cfg = none⊢ (eval (step weakCollatz27) init).Dom
rw [Part.dom_iff_mem mpr.inr x:ℕj:ℕhx3:3 ≤ xhj1:1 ≤ jleft✝:j ≤ xhhit:terras^[j] x = xM:ℕjM:ℕhM3:3 ≤ MhjM1:1 ≤ jMhjMM:jM ≤ M - 2hjM_cyc:terras^[jM] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ MhM_halts:StageHalts Mw₀:ℕhw₀3:3 ≤ w₀hprev₀:NoStageHalts (w₀ - 1)hhalt₀:StageHalts w₀s₁:ℕhs₁:nSteps weakCollatz27 s₁ init = some (stageCfg w₀ w₀)s₂:ℕcfg:Cfg 27 2hs₂:nSteps weakCollatz27 s₂ (stageCfg w₀ w₀) = some cfghnone:step weakCollatz27 cfg = none⊢ ∃ y, y ∈ eval (step weakCollatz27) init] mpr.inr x:ℕj:ℕhx3:3 ≤ xhj1:1 ≤ jleft✝:j ≤ xhhit:terras^[j] x = xM:ℕjM:ℕhM3:3 ≤ MhjM1:1 ≤ jMhjMM:jM ≤ M - 2hjM_cyc:terras^[jM] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ MhM_halts:StageHalts Mw₀:ℕhw₀3:3 ≤ w₀hprev₀:NoStageHalts (w₀ - 1)hhalt₀:StageHalts w₀s₁:ℕhs₁:nSteps weakCollatz27 s₁ init = some (stageCfg w₀ w₀)s₂:ℕcfg:Cfg 27 2hs₂:nSteps weakCollatz27 s₂ (stageCfg w₀ w₀) = some cfghnone:step weakCollatz27 cfg = none⊢ ∃ y, y ∈ eval (step weakCollatz27) init
exact ⟨cfg, mem_eval'.mpr ⟨nSteps_reaches (nSteps_bind_eq hs₁ hs₂), hnone⟩⟩ All goals completed! 🐙
The 27-state candidate machine halts on the blank tape if and only if the 41-state reference
machine does (constructive, zero Classical.choice).
theorem candidate_equivalent : Halts candidate ↔ Halts reference :=
halts_weakCollatz27_iff_bounded_cycle.trans
WeakCollatz41.halts_weakCollatz41_iff_bounded_cycle.symm
The candidate has 14 fewer states than the 41-state reference (27 < 41).
theorem candidate_fewer_states : candidate.states < reference.states := by ⊢ candidate.states < reference.states
decide +kernel All goals completed! 🐙end ConjectureMachines.WeakCollatz27