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.WeakCollatz17
public import Cryptids.Semantics.WeakCollatz75
WeakCollatz16 (weak_collatz_16)
The 16-state, 2-symbol Turing machine weak_collatz_16 compresses weak_collatz_17 (17 → 16
states, -1 state / -5.88%; 75 → 41 → 27 → 17 → 16 overall, -59 states / -78.67%) while
constructively preserving blank-tape halting equivalence (candidate_equivalent, proved without
Classical.choice).
Compression Ideas (17 → 16 states)
In weak_collatz_17, incrementing the candidate stage by +1 (x ↦ x + 1) required a dedicated
trim/entry state (state 9) to erase the extra 1 written by O_SL before GT_SW filled the
separator 0 on z > x aborts. weak_collatz_16 eliminates that state completely by exploiting
the parity of cycle maxima:
Evenness of Nontrivial Cycle Maxima (even_of_stageHalts): Every nontrivial terras cycle
maximum M = max C ≥ 3 is even (M = 2m, m ≥ 2), because an odd value 2m + 1 ≥ 3 steps to
terras (2m + 1) = 3m + 2 > 2m + 1. Enumerating only even candidate stages x = 2, 4, 6, ...
(x ↦ x + 2 on stage abort) is therefore constructively sound and complete.
Trim-Free +2 Stage Advance: Under the popcount conservation law d + y = x at
roundCfg d y (0^∞ 1^d [0] 1^y 0^∞ in state 1), O_SL (state 9) increases popcount to
x + 1, and jumping directly from P1/P2 (states 10/11) to GT_SW (state 3) fills the
single separator 0 with 1, merging directly into 1^(x + 2) (stageCfg (x + 2)) with zero
trim state. Likewise, y = 1 bounces through 8 → 7 → 5 → 9 → 10 → 3 → 1 to advance
1^x ↦ 1^(x + 2).
Zero-State Blank-Tape Boot: Starting in state 0 (T2, 0R8 1R4) on the all-blank tape
enters stageCfg 2 at t = 9 and stageCfg 4 at t = 39 (31/31 active transitions visited
by step 1,576).
@[expose] public sectionnamespace ConjectureMachines.WeakCollatz16open Turing (Dir)open StateTransitionopen ErdosTernary15 (B0 B0_cons_zero nSteps 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
17-state Weak Collatz reference machine (weak_collatz_17).
abbrev reference : BundledMachine 2 := Machines.weakCollatz17.bundle
16-state Weak Collatz candidate machine (weak_collatz_16).
abbrev candidate : BundledMachine 2 := Machines.weakCollatz16.bundle
The candidate as a Machine 16 2.
abbrev weakCollatz16 : Machine 16 2 := Machines.weakCollatz16private 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 16} {a b : Fin 2}
(h : weakCollatz16.transition q a = some (b, .right, q'))
(L R : ListBlank (Fin 2)) :
step weakCollatz16 ⟨q, ⟨a, L, R⟩⟩ = some ⟨q', Tape.mk' (L.cons b) R⟩ := q:Fin 16q':Fin 16a:Fin 2b:Fin 2h:weakCollatz16.transition q a = some (b, Dir.right, q')L:ListBlank (Fin 2)R:ListBlank (Fin 2)⊢ step weakCollatz16 { state := q, tape := { head := a, left := L, right := R } } =
some { state := q', tape := Tape.mk' (ListBlank.cons b L) R }
q:Fin 16q':Fin 16a:Fin 2b:Fin 2h:weakCollatz16.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 16} {a b : Fin 2}
(h : weakCollatz16.transition q a = some (b, .left, q'))
(L R : ListBlank (Fin 2)) :
step weakCollatz16 ⟨q, ⟨a, L, R⟩⟩ = some ⟨q', mkL L (R.cons b)⟩ := q:Fin 16q':Fin 16a:Fin 2b:Fin 2h:weakCollatz16.transition q a = some (b, Dir.left, q')L:ListBlank (Fin 2)R:ListBlank (Fin 2)⊢ step weakCollatz16 { state := q, tape := { head := a, left := L, right := R } } =
some { state := q', tape := mkL L (ListBlank.cons b R) }
q:Fin 16q':Fin 16a:Fin 2b:Fin 2h:weakCollatz16.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 weakCollatz16 ⟨0, ⟨0, L, R⟩⟩ = some ⟨8, Tape.mk' (L.cons 0) R⟩ := stepR rfl L Rprivate theorem tr0_1 (L R) :
step weakCollatz16 ⟨0, ⟨1, L, R⟩⟩ = some ⟨4, Tape.mk' (L.cons 1) R⟩ := stepR rfl L Rprivate theorem tr1_0 (L R) :
step weakCollatz16 ⟨1, ⟨0, L, R⟩⟩ = some ⟨2, Tape.mk' (L.cons 1) R⟩ := stepR rfl L Rprivate theorem tr1_1 (L R) : step weakCollatz16 ⟨1, ⟨1, L, R⟩⟩ = some ⟨1, mkL L (R.cons 1)⟩ :=
stepL rfl L Rprivate theorem tr2_0 (L R) :
step weakCollatz16 ⟨2, ⟨0, L, R⟩⟩ = some ⟨7, Tape.mk' (L.cons 1) R⟩ := stepR rfl L Rprivate theorem tr2_1 (L R) :
step weakCollatz16 ⟨2, ⟨1, L, R⟩⟩ = some ⟨0, Tape.mk' (L.cons 0) R⟩ := stepR rfl L Rprivate theorem tr3_0 (L R) : step weakCollatz16 ⟨3, ⟨0, L, R⟩⟩ = some ⟨1, mkL L (R.cons 1)⟩ :=
stepL rfl L Rprivate theorem tr3_1 (L R) :
step weakCollatz16 ⟨3, ⟨1, L, R⟩⟩ = some ⟨3, Tape.mk' (L.cons 1) R⟩ := stepR rfl L Rprivate theorem tr4_0 (L R) : step weakCollatz16 ⟨4, ⟨0, L, R⟩⟩ = some ⟨5, mkL L (R.cons 1)⟩ :=
stepL rfl L Rprivate theorem tr4_1 (L R) :
step weakCollatz16 ⟨4, ⟨1, L, R⟩⟩ = some ⟨4, Tape.mk' (L.cons 1) R⟩ := stepR rfl L Rprivate theorem tr5_0 (L R) : step weakCollatz16 ⟨5, ⟨0, L, R⟩⟩ = some ⟨9, mkL L (R.cons 0)⟩ :=
stepL rfl L Rprivate theorem tr5_1 (L R) : step weakCollatz16 ⟨5, ⟨1, L, R⟩⟩ = some ⟨6, mkL L (R.cons 0)⟩ :=
stepL rfl L Rprivate theorem tr6_0 (L R) :
step weakCollatz16 ⟨6, ⟨0, L, R⟩⟩ = some ⟨2, Tape.mk' (L.cons 0) R⟩ := stepR rfl L Rprivate theorem tr6_1 (L R) : step weakCollatz16 ⟨6, ⟨1, L, R⟩⟩ = some ⟨14, mkL L (R.cons 1)⟩ :=
stepL rfl L Rprivate theorem tr7_0 (L R) : step weakCollatz16 ⟨7, ⟨0, L, R⟩⟩ = some ⟨5, mkL L (R.cons 0)⟩ :=
stepL rfl L Rprivate theorem tr7_1 (L R) :
step weakCollatz16 ⟨7, ⟨1, L, R⟩⟩ = some ⟨7, Tape.mk' (L.cons 1) R⟩ := stepR rfl L Rprivate theorem tr8_0 (L R) : step weakCollatz16 ⟨8, ⟨0, L, R⟩⟩ = some ⟨7, mkL L (R.cons 0)⟩ :=
stepL rfl L Rprivate theorem tr8_1 (L R) : step weakCollatz16 ⟨8, ⟨1, L, R⟩⟩ = some ⟨5, mkL L (R.cons 1)⟩ :=
stepL rfl L Rprivate theorem tr9_0 (L R) : step weakCollatz16 ⟨9, ⟨0, L, R⟩⟩ = some ⟨10, mkL L (R.cons 1)⟩ :=
stepL rfl L Rprivate theorem tr9_1 (L R) : step weakCollatz16 ⟨9, ⟨1, L, R⟩⟩ = some ⟨9, mkL L (R.cons 1)⟩ :=
stepL rfl L Rprivate theorem tr10_0 (L R) :
step weakCollatz16 ⟨10, ⟨0, L, R⟩⟩ = some ⟨3, Tape.mk' (L.cons 0) R⟩ := stepR rfl L Rprivate theorem tr10_1 (L R) : step weakCollatz16 ⟨10, ⟨1, L, R⟩⟩ = some ⟨11, mkL L (R.cons 1)⟩ :=
stepL rfl L Rprivate theorem tr11_0 (L R) :
step weakCollatz16 ⟨11, ⟨0, L, R⟩⟩ = some ⟨3, Tape.mk' (L.cons 0) R⟩ := stepR rfl L Rprivate theorem tr11_1 (L R) :
step weakCollatz16 ⟨11, ⟨1, L, R⟩⟩ = some ⟨12, Tape.mk' (L.cons 0) R⟩ := stepR rfl L Rprivate theorem tr12_0 (L R) :
step weakCollatz16 ⟨12, ⟨0, L, R⟩⟩ = some ⟨13, Tape.mk' (L.cons 1) R⟩ := stepR rfl L Rprivate theorem tr12_1 (L R) :
step weakCollatz16 ⟨12, ⟨1, L, R⟩⟩ = some ⟨12, Tape.mk' (L.cons 1) R⟩ := stepR rfl L Rprivate theorem tr13_0 (L R) : step weakCollatz16 ⟨13, ⟨0, L, R⟩⟩ = some ⟨5, mkL L (R.cons 0)⟩ :=
stepL rfl L Rprivate theorem tr13_1 (L R) : step weakCollatz16 ⟨13, ⟨1, L, R⟩⟩ = some ⟨9, mkL L (R.cons 0)⟩ :=
stepL rfl L Rprivate theorem tr14_0 (L R) : step weakCollatz16 ⟨14, ⟨0, L, R⟩⟩ = some ⟨15, mkL L (R.cons 0)⟩ :=
stepL rfl L Rprivate theorem tr14_1 (L R) : step weakCollatz16 ⟨14, ⟨1, L, R⟩⟩ = some ⟨14, mkL L (R.cons 1)⟩ :=
stepL rfl L Rprivate theorem tr15_0 (L R : ListBlank (Fin 2)) : step weakCollatz16 ⟨15, ⟨0, L, R⟩⟩ = none := rflprivate theorem tr15_1 (L R) :
step weakCollatz16 ⟨15, ⟨1, L, R⟩⟩ = some ⟨1, Tape.mk' (L.cons 1) R⟩ := stepR rfl L RSweep & Reachability Combinators
private def reachPos (c₁ c₂ : Cfg 16 2) : Prop :=
∃ s : ℕ, 1 ≤ s ∧ nSteps weakCollatz16 s c₁ = some c₂private theorem reachPos_step {c₁ c₂ : Cfg 16 2}
(h : step weakCollatz16 c₁ = some c₂) : reachPos c₁ c₂ :=
⟨1, le_rfl, step_one h⟩private theorem reachPos_trans {c₁ c₂ c₃ : Cfg 16 2}
(h₁ : reachPos c₁ c₂) (h₂ : reachPos c₂ c₃) : reachPos c₁ c₃ := c₁:Cfg 16 2c₂:Cfg 16 2c₃:Cfg 16 2h₁:reachPos c₁ c₂h₂:reachPos c₂ c₃⊢ reachPos c₁ c₃
c₁:Cfg 16 2c₂:Cfg 16 2c₃:Cfg 16 2h₂:reachPos c₂ c₃s₁:ℕhs₁:1 ≤ s₁heq₁:nSteps weakCollatz16 s₁ c₁ = some c₂⊢ reachPos c₁ c₃
c₁:Cfg 16 2c₂:Cfg 16 2c₃:Cfg 16 2s₁:ℕhs₁:1 ≤ s₁heq₁:nSteps weakCollatz16 s₁ c₁ = some c₂s₂:ℕhs₂:1 ≤ s₂heq₂:nSteps weakCollatz16 s₂ c₂ = some c₃⊢ reachPos c₁ c₃
exact ⟨s₁ + s₂, c₁:Cfg 16 2c₂:Cfg 16 2c₃:Cfg 16 2s₁:ℕhs₁:1 ≤ s₁heq₁:nSteps weakCollatz16 s₁ c₁ = some c₂s₂:ℕhs₂:1 ≤ s₂heq₂:nSteps weakCollatz16 s₂ c₂ = some c₃⊢ 1 ≤ s₁ + s₂ All goals completed! 🐙, nSteps_bind_eq heq₁ heq₂⟩private theorem step_then_reachPos {c₁ c₂ c₃ : Cfg 16 2}
(h₁ : step weakCollatz16 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 16 2}
(h₁ : nSteps weakCollatz16 k c₁ = some c₂) (h₂ : reachPos c₂ c₃) : reachPos c₁ c₃ := k:ℕc₁:Cfg 16 2c₂:Cfg 16 2c₃:Cfg 16 2h₁:nSteps weakCollatz16 k c₁ = some c₂h₂:reachPos c₂ c₃⊢ reachPos c₁ c₃
k:ℕc₁:Cfg 16 2c₂:Cfg 16 2c₃:Cfg 16 2h₁:nSteps weakCollatz16 k c₁ = some c₂s:ℕhs:1 ≤ sheq:nSteps weakCollatz16 s c₂ = some c₃⊢ reachPos c₁ c₃
exact ⟨k + s, k:ℕc₁:Cfg 16 2c₂:Cfg 16 2c₃:Cfg 16 2h₁:nSteps weakCollatz16 k c₁ = some c₂s:ℕhs:1 ≤ sheq:nSteps weakCollatz16 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 16 2}
(h₁ : reachPos c₁ c₂) (h₂ : nSteps weakCollatz16 k c₂ = some c₃) : reachPos c₁ c₃ := k:ℕc₁:Cfg 16 2c₂:Cfg 16 2c₃:Cfg 16 2h₁:reachPos c₁ c₂h₂:nSteps weakCollatz16 k c₂ = some c₃⊢ reachPos c₁ c₃
k:ℕc₁:Cfg 16 2c₂:Cfg 16 2c₃:Cfg 16 2h₂:nSteps weakCollatz16 k c₂ = some c₃s:ℕhs:1 ≤ sheq:nSteps weakCollatz16 s c₁ = some c₂⊢ reachPos c₁ c₃
exact ⟨s + k, k:ℕc₁:Cfg 16 2c₂:Cfg 16 2c₃:Cfg 16 2h₂:nSteps weakCollatz16 k c₂ = some c₃s:ℕhs:1 ≤ sheq:nSteps weakCollatz16 s c₁ = some c₂⊢ 1 ≤ s + k All goals completed! 🐙, nSteps_bind_eq heq h₂⟩private theorem sweep1R {q : Fin 16}
(h : ∀ L R, step weakCollatz16 ⟨q, ⟨1, L, R⟩⟩ = some ⟨q, Tape.mk' (L.cons 1) R⟩)
(k : ℕ) (L R : ListBlank (Fin 2)) :
nSteps weakCollatz16 k ⟨q, Tape.mk' L (ones k R)⟩ = some ⟨q, Tape.mk' (ones k L) R⟩ := q:Fin 16h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz16 { 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 weakCollatz16 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 16h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz16 { 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 weakCollatz16 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 16h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz16 { 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 weakCollatz16 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 weakCollatz16 (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 16}
(h : ∀ L R, step weakCollatz16 ⟨q, ⟨1, L, R⟩⟩ = some ⟨q, mkL L (R.cons 1)⟩)
(k : ℕ) (L R : ListBlank (Fin 2)) :
nSteps weakCollatz16 k ⟨q, mkL (ones k L) R⟩ = some ⟨q, mkL L (ones k R)⟩ := by q:Fin 16h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz16 { 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 weakCollatz16 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 16h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz16 { 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 weakCollatz16 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 16h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz16 { 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 weakCollatz16 k { state := q, tape := mkL (ones k L) R } = some { state := q, tape := mkL L (ones k R) }R:ListBlank (Fin 2)⊢ nSteps weakCollatz16 (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 16h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz16 { 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 weakCollatz16 k { state := q, tape := mkL (ones k L) R } = some { state := q, tape := mkL L (ones k R) }R:ListBlank (Fin 2)⊢ (step weakCollatz16 { state := q, tape := mkL (ones (k + 1) L) R }).bind (nSteps weakCollatz16 k) =
some { state := q, tape := mkL L (ones (k + 1) R) } ones_succ, succ q:Fin 16h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz16 { 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 weakCollatz16 k { state := q, tape := mkL (ones k L) R } = some { state := q, tape := mkL L (ones k R) }R:ListBlank (Fin 2)⊢ (step weakCollatz16 { state := q, tape := mkL (ListBlank.cons 1 (ones k L)) R }).bind (nSteps weakCollatz16 k) =
some { state := q, tape := mkL L (ones (k + 1) R) } ErdosTernary15.Tape.mkL_cons, succ q:Fin 16h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz16 { 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 weakCollatz16 k { state := q, tape := mkL (ones k L) R } = some { state := q, tape := mkL L (ones k R) }R:ListBlank (Fin 2)⊢ (step weakCollatz16 { state := q, tape := { head := 1, left := ones k L, right := R } }).bind (nSteps weakCollatz16 k) =
some { state := q, tape := mkL L (ones (k + 1) R) } h, succ q:Fin 16h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz16 { 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 weakCollatz16 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 weakCollatz16 k) =
some { state := q, tape := mkL L (ones (k + 1) R) } Option.bind_some, succ q:Fin 16h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz16 { 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 weakCollatz16 k { state := q, tape := mkL (ones k L) R } = some { state := q, tape := mkL L (ones k R) }R:ListBlank (Fin 2)⊢ nSteps weakCollatz16 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 16h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz16 { 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 weakCollatz16 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 16h:∀ (L R : ListBlank (Fin 2)),
step weakCollatz16 { 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 weakCollatz16 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! 🐙Conservation-Law Checkpoints & Inward Parity Squeeze
Canonical round checkpoint (d + y = x): 0^∞ 1^d [0] 1^y 0^∞ in state 1.
private def roundCfg (d y : ℕ) : Cfg 16 2 :=
⟨1, ⟨0, ones d B0, ones y B0⟩⟩
Canonical stage start (d = 0, y = x): 0^∞ [0] 1^x 0^∞ in state 1.
private def stageCfg (x : ℕ) : Cfg 16 2 :=
roundCfg 0 x
Inward parity-squeeze configuration (d + b + a = x): 0^∞ 1^d [0] 1^b 0 1^a 0^∞ in state
1 (at a = 0, (ones 0 B0).cons 0 = B0, coinciding with roundCfg d b).
private def sqzCfg (d b a : ℕ) : Cfg 16 2 :=
⟨1, ⟨0, ones d B0, ones b ((ones a B0).cons 0)⟩⟩private theorem roundCfg_eq_sqzCfg (d y : ℕ) : roundCfg d y = sqzCfg d y 0 := by d:ℕy:ℕ⊢ roundCfg d y = sqzCfg d y 0
simp only [roundCfg, sqzCfg, ones_zero, B0_cons_zero] All goals completed! 🐙private theorem sqz_to_eback (d b a : ℕ) :
reachPos (sqzCfg d (b + 2) a)
⟨6, mkL (ones b ((ones (d + 1) B0).cons 0)) ((ones (a + 1) B0).cons 0)⟩ := by d:ℕb:ℕa:ℕ⊢ reachPos (sqzCfg d (b + 2) a)
{ state := 6, tape := mkL (ones b (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (a + 1) B0)) }
unfold sqzCfg d:ℕb:ℕa:ℕ⊢ reachPos { state := 1, tape := { head := 0, left := ones d B0, right := ones (b + 2) (ListBlank.cons 0 (ones a B0)) } }
{ state := 6, tape := mkL (ones b (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (a + 1) B0)) }
let Ra := (ones a B0).cons 0 d:ℕb:ℕa:ℕRa:ListBlank (Fin 2) := ListBlank.cons 0 (ones a B0)⊢ reachPos { state := 1, tape := { head := 0, left := ones d B0, right := ones (b + 2) (ListBlank.cons 0 (ones a B0)) } }
{ state := 6, tape := mkL (ones b (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (a + 1) B0)) }
change reachPos ⟨1, ⟨0, ones d B0, ones (b + 2) Ra⟩⟩ _ d:ℕb:ℕa:ℕRa:ListBlank (Fin 2) := ListBlank.cons 0 (ones a B0)⊢ reachPos { state := 1, tape := { head := 0, left := ones d B0, right := ones (b + 2) Ra } }
{ state := 6, tape := mkL (ones b (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (a + 1) B0)) }
refine step_then_reachPos (tr1_0 _ _) ?_ d:ℕb:ℕa:ℕRa:ListBlank (Fin 2) := ListBlank.cons 0 (ones a B0)⊢ reachPos { state := 2, tape := Tape.mk' (ListBlank.cons 1 (ones d B0)) (ones (b + 2) Ra) }
{ state := 6, tape := mkL (ones b (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (a + 1) B0)) }
rw [← ones_succ d B0, d:ℕb:ℕa:ℕRa:ListBlank (Fin 2) := ListBlank.cons 0 (ones a B0)⊢ reachPos { state := 2, tape := Tape.mk' (ones (d + 1) B0) (ones (b + 2) Ra) }
{ state := 6, tape := mkL (ones b (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (a + 1) B0)) } show b + 2 = (b + 1) + 1 by d:ℕb:ℕa:ℕ⊢ reachPos (sqzCfg d (b + 2) a)
{ state := 6, tape := mkL (ones b (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (a + 1) B0)) } omega All goals completed! 🐙, ones_succ (b + 1) Ra, d:ℕb:ℕa:ℕRa:ListBlank (Fin 2) := ListBlank.cons 0 (ones a B0)⊢ reachPos { state := 2, tape := Tape.mk' (ones (d + 1) B0) (ListBlank.cons 1 (ones (b + 1) Ra)) }
{ state := 6, tape := mkL (ones b (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (a + 1) B0)) }
ErdosTernary15.Tape.mk'_cons d:ℕb:ℕa:ℕRa:ListBlank (Fin 2) := ListBlank.cons 0 (ones a B0)⊢ reachPos { state := 2, tape := { head := 1, left := ones (d + 1) B0, right := ones (b + 1) Ra } }
{ state := 6, tape := mkL (ones b (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (a + 1) B0)) }] d:ℕb:ℕa:ℕRa:ListBlank (Fin 2) := ListBlank.cons 0 (ones a B0)⊢ reachPos { state := 2, tape := { head := 1, left := ones (d + 1) B0, right := ones (b + 1) Ra } }
{ state := 6, tape := mkL (ones b (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (a + 1) B0)) }
refine step_then_reachPos (tr2_1 _ _) ?_ d:ℕb:ℕa:ℕRa:ListBlank (Fin 2) := ListBlank.cons 0 (ones a B0)⊢ reachPos { state := 0, tape := Tape.mk' (ListBlank.cons 0 (ones (d + 1) B0)) (ones (b + 1) Ra) }
{ state := 6, tape := mkL (ones b (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (a + 1) B0)) }
rw [ones_succ b Ra, d:ℕb:ℕa:ℕRa:ListBlank (Fin 2) := ListBlank.cons 0 (ones a B0)⊢ reachPos { state := 0, tape := Tape.mk' (ListBlank.cons 0 (ones (d + 1) B0)) (ListBlank.cons 1 (ones b Ra)) }
{ state := 6, tape := mkL (ones b (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (a + 1) B0)) } ErdosTernary15.Tape.mk'_cons d:ℕb:ℕa:ℕRa:ListBlank (Fin 2) := ListBlank.cons 0 (ones a B0)⊢ reachPos { state := 0, tape := { head := 1, left := ListBlank.cons 0 (ones (d + 1) B0), right := ones b Ra } }
{ state := 6, tape := mkL (ones b (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (a + 1) B0)) }] d:ℕb:ℕa:ℕRa:ListBlank (Fin 2) := ListBlank.cons 0 (ones a B0)⊢ reachPos { state := 0, tape := { head := 1, left := ListBlank.cons 0 (ones (d + 1) B0), right := ones b Ra } }
{ state := 6, tape := mkL (ones b (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (a + 1) B0)) }
refine step_then_reachPos (tr0_1 _ _) ?_ d:ℕb:ℕa:ℕRa:ListBlank (Fin 2) := ListBlank.cons 0 (ones a B0)⊢ reachPos { state := 4, tape := Tape.mk' (ListBlank.cons 1 (ListBlank.cons 0 (ones (d + 1) B0))) (ones b Ra) }
{ state := 6, tape := mkL (ones b (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (a + 1) B0)) }
let Ld := (ones (d + 1) B0).cons 0 d:ℕb:ℕa:ℕRa:ListBlank (Fin 2) := ListBlank.cons 0 (ones a B0)Ld:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)⊢ reachPos { state := 4, tape := Tape.mk' (ListBlank.cons 1 (ListBlank.cons 0 (ones (d + 1) B0))) (ones b Ra) }
{ state := 6, tape := mkL (ones b (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (a + 1) B0)) }
change reachPos ⟨4, Tape.mk' (ones 1 Ld) (ones b Ra)⟩ _ d:ℕb:ℕa:ℕRa:ListBlank (Fin 2) := ListBlank.cons 0 (ones a B0)Ld:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)⊢ reachPos { state := 4, tape := Tape.mk' (ones 1 Ld) (ones b Ra) }
{ state := 6, tape := mkL (ones b (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (a + 1) B0)) }
refine nSteps_then_reachPos (sweep1R tr4_1 b (ones 1 Ld) Ra) ?_ d:ℕb:ℕa:ℕRa:ListBlank (Fin 2) := ListBlank.cons 0 (ones a B0)Ld:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)⊢ reachPos { state := 4, tape := Tape.mk' (ones b (ones 1 Ld)) Ra }
{ state := 6, tape := mkL (ones b (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (a + 1) B0)) }
rw [← ones_add b 1 Ld d:ℕb:ℕa:ℕRa:ListBlank (Fin 2) := ListBlank.cons 0 (ones a B0)Ld:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)⊢ reachPos { state := 4, tape := Tape.mk' (ones (b + 1) Ld) Ra }
{ state := 6, tape := mkL (ones b (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (a + 1) B0)) }] d:ℕb:ℕa:ℕRa:ListBlank (Fin 2) := ListBlank.cons 0 (ones a B0)Ld:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)⊢ reachPos { state := 4, tape := Tape.mk' (ones (b + 1) Ld) Ra }
{ state := 6, tape := mkL (ones b (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (a + 1) B0)) }
dsimp only [Ra] d:ℕb:ℕa:ℕRa:ListBlank (Fin 2) := ListBlank.cons 0 (ones a B0)Ld:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)⊢ reachPos { state := 4, tape := Tape.mk' (ones (b + 1) Ld) (ListBlank.cons 0 (ones a B0)) }
{ state := 6, tape := mkL (ones b (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (a + 1) B0)) }
rw [ErdosTernary15.Tape.mk'_cons d:ℕb:ℕa:ℕRa:ListBlank (Fin 2) := ListBlank.cons 0 (ones a B0)Ld:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)⊢ reachPos { state := 4, tape := { head := 0, left := ones (b + 1) Ld, right := ones a B0 } }
{ state := 6, tape := mkL (ones b (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (a + 1) B0)) }] d:ℕb:ℕa:ℕRa:ListBlank (Fin 2) := ListBlank.cons 0 (ones a B0)Ld:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)⊢ reachPos { state := 4, tape := { head := 0, left := ones (b + 1) Ld, right := ones a B0 } }
{ state := 6, tape := mkL (ones b (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (a + 1) B0)) }
refine step_then_reachPos (tr4_0 _ _) ?_ d:ℕb:ℕa:ℕRa:ListBlank (Fin 2) := ListBlank.cons 0 (ones a B0)Ld:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)⊢ reachPos { state := 5, tape := mkL (ones (b + 1) Ld) (ListBlank.cons 1 (ones a B0)) }
{ state := 6, tape := mkL (ones b (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (a + 1) B0)) }
rw [ones_succ b Ld, d:ℕb:ℕa:ℕRa:ListBlank (Fin 2) := ListBlank.cons 0 (ones a B0)Ld:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)⊢ reachPos { state := 5, tape := mkL (ListBlank.cons 1 (ones b Ld)) (ListBlank.cons 1 (ones a B0)) }
{ state := 6, tape := mkL (ones b (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (a + 1) B0)) } ErdosTernary15.Tape.mkL_cons, d:ℕb:ℕa:ℕRa:ListBlank (Fin 2) := ListBlank.cons 0 (ones a B0)Ld:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)⊢ reachPos { state := 5, tape := { head := 1, left := ones b Ld, right := ListBlank.cons 1 (ones a B0) } }
{ state := 6, tape := mkL (ones b (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (a + 1) B0)) } ← ones_succ a B0 d:ℕb:ℕa:ℕRa:ListBlank (Fin 2) := ListBlank.cons 0 (ones a B0)Ld:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)⊢ reachPos { state := 5, tape := { head := 1, left := ones b Ld, right := ones (a + 1) B0 } }
{ state := 6, tape := mkL (ones b (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (a + 1) B0)) }] d:ℕb:ℕa:ℕRa:ListBlank (Fin 2) := ListBlank.cons 0 (ones a B0)Ld:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)⊢ reachPos { state := 5, tape := { head := 1, left := ones b Ld, right := ones (a + 1) B0 } }
{ state := 6, tape := mkL (ones b (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (a + 1) B0)) }
exact reachPos_step (tr5_1 _ _) All goals completed! 🐙private theorem eback_to_haltchk (L : ListBlank (Fin 2)) (m : ℕ) :
reachPos ⟨6, ⟨1, ones m (L.cons 0), B0⟩⟩ ⟨15, mkL L ((ones (m + 1) B0).cons 0)⟩ := by L:ListBlank (Fin 2)m:ℕ⊢ reachPos { state := 6, tape := { head := 1, left := ones m (ListBlank.cons 0 L), right := B0 } }
{ state := 15, tape := mkL L (ListBlank.cons 0 (ones (m + 1) B0)) }
refine step_then_reachPos (tr6_1 _ _) ?_ L:ListBlank (Fin 2)m:ℕ⊢ reachPos { state := 14, tape := mkL (ones m (ListBlank.cons 0 L)) (ListBlank.cons 1 B0) }
{ state := 15, tape := mkL L (ListBlank.cons 0 (ones (m + 1) B0)) }
change reachPos ⟨14, mkL (ones m (L.cons 0)) (ones 1 B0)⟩ _ L:ListBlank (Fin 2)m:ℕ⊢ reachPos { state := 14, tape := mkL (ones m (ListBlank.cons 0 L)) (ones 1 B0) }
{ state := 15, tape := mkL L (ListBlank.cons 0 (ones (m + 1) B0)) }
refine nSteps_then_reachPos (sweep1L tr14_1 m (L.cons 0) (ones 1 B0)) ?_ L:ListBlank (Fin 2)m:ℕ⊢ reachPos { state := 14, tape := mkL (ListBlank.cons 0 L) (ones m (ones 1 B0)) }
{ state := 15, tape := mkL L (ListBlank.cons 0 (ones (m + 1) B0)) }
rw [← ones_add m 1 B0, L:ListBlank (Fin 2)m:ℕ⊢ reachPos { state := 14, tape := mkL (ListBlank.cons 0 L) (ones (m + 1) B0) }
{ state := 15, tape := mkL L (ListBlank.cons 0 (ones (m + 1) B0)) } ErdosTernary15.Tape.mkL_cons L:ListBlank (Fin 2)m:ℕ⊢ reachPos { state := 14, tape := { head := 0, left := L, right := ones (m + 1) B0 } }
{ state := 15, tape := mkL L (ListBlank.cons 0 (ones (m + 1) B0)) }] L:ListBlank (Fin 2)m:ℕ⊢ reachPos { state := 14, tape := { head := 0, left := L, right := ones (m + 1) B0 } }
{ state := 15, tape := mkL L (ListBlank.cons 0 (ones (m + 1) B0)) }
exact reachPos_step (tr14_0 _ _) All goals completed! 🐙private theorem sqz_step (d b₀ a : ℕ) :
reachPos (sqzCfg d (b₀ + 3) a) (sqzCfg (d + 1) (b₀ + 1) (a + 1)) := by d:ℕb₀:ℕa:ℕ⊢ reachPos (sqzCfg d (b₀ + 3) a) (sqzCfg (d + 1) (b₀ + 1) (a + 1))
rw [show b₀ + 3 = (b₀ + 1) + 2 by d:ℕb₀:ℕa:ℕ⊢ reachPos (sqzCfg d (b₀ + 3) a) (sqzCfg (d + 1) (b₀ + 1) (a + 1)) omega All goals completed! 🐙] d:ℕb₀:ℕa:ℕ⊢ reachPos (sqzCfg d (b₀ + 1 + 2) a) (sqzCfg (d + 1) (b₀ + 1) (a + 1))
refine reachPos_trans (sqz_to_eback d (b₀ + 1) a) ?_ d:ℕb₀:ℕa:ℕ⊢ reachPos
{ state := 6, tape := mkL (ones (b₀ + 1) (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (a + 1) B0)) }
(sqzCfg (d + 1) (b₀ + 1) (a + 1))
let Ld := (ones (d + 1) B0).cons 0 d:ℕb₀:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)⊢ reachPos
{ state := 6, tape := mkL (ones (b₀ + 1) (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (a + 1) B0)) }
(sqzCfg (d + 1) (b₀ + 1) (a + 1))
let Ra1 := (ones (a + 1) B0).cons 0 d:ℕb₀:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)Ra1:ListBlank (Fin 2) := ListBlank.cons 0 (ones (a + 1) B0)⊢ reachPos
{ state := 6, tape := mkL (ones (b₀ + 1) (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (a + 1) B0)) }
(sqzCfg (d + 1) (b₀ + 1) (a + 1))
change reachPos ⟨6, mkL (ones (b₀ + 1) Ld) Ra1⟩ _ d:ℕb₀:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)Ra1:ListBlank (Fin 2) := ListBlank.cons 0 (ones (a + 1) B0)⊢ reachPos { state := 6, tape := mkL (ones (b₀ + 1) Ld) Ra1 } (sqzCfg (d + 1) (b₀ + 1) (a + 1))
rw [ones_succ b₀ Ld, d:ℕb₀:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)Ra1:ListBlank (Fin 2) := ListBlank.cons 0 (ones (a + 1) B0)⊢ reachPos { state := 6, tape := mkL (ListBlank.cons 1 (ones b₀ Ld)) Ra1 } (sqzCfg (d + 1) (b₀ + 1) (a + 1)) ErdosTernary15.Tape.mkL_cons d:ℕb₀:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)Ra1:ListBlank (Fin 2) := ListBlank.cons 0 (ones (a + 1) B0)⊢ reachPos { state := 6, tape := { head := 1, left := ones b₀ Ld, right := Ra1 } } (sqzCfg (d + 1) (b₀ + 1) (a + 1))] d:ℕb₀:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)Ra1:ListBlank (Fin 2) := ListBlank.cons 0 (ones (a + 1) B0)⊢ reachPos { state := 6, tape := { head := 1, left := ones b₀ Ld, right := Ra1 } } (sqzCfg (d + 1) (b₀ + 1) (a + 1))
refine step_then_reachPos (tr6_1 _ _) ?_ d:ℕb₀:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)Ra1:ListBlank (Fin 2) := ListBlank.cons 0 (ones (a + 1) B0)⊢ reachPos { state := 14, tape := mkL (ones b₀ Ld) (ListBlank.cons 1 Ra1) } (sqzCfg (d + 1) (b₀ + 1) (a + 1))
change reachPos ⟨14, mkL (ones b₀ Ld) (ones 1 Ra1)⟩ _ d:ℕb₀:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)Ra1:ListBlank (Fin 2) := ListBlank.cons 0 (ones (a + 1) B0)⊢ reachPos { state := 14, tape := mkL (ones b₀ Ld) (ones 1 Ra1) } (sqzCfg (d + 1) (b₀ + 1) (a + 1))
refine nSteps_then_reachPos (sweep1L tr14_1 b₀ Ld (ones 1 Ra1)) ?_ d:ℕb₀:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)Ra1:ListBlank (Fin 2) := ListBlank.cons 0 (ones (a + 1) B0)⊢ reachPos { state := 14, tape := mkL Ld (ones b₀ (ones 1 Ra1)) } (sqzCfg (d + 1) (b₀ + 1) (a + 1))
rw [← ones_add b₀ 1 Ra1 d:ℕb₀:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)Ra1:ListBlank (Fin 2) := ListBlank.cons 0 (ones (a + 1) B0)⊢ reachPos { state := 14, tape := mkL Ld (ones (b₀ + 1) Ra1) } (sqzCfg (d + 1) (b₀ + 1) (a + 1))] d:ℕb₀:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)Ra1:ListBlank (Fin 2) := ListBlank.cons 0 (ones (a + 1) B0)⊢ reachPos { state := 14, tape := mkL Ld (ones (b₀ + 1) Ra1) } (sqzCfg (d + 1) (b₀ + 1) (a + 1))
dsimp only [Ld] d:ℕb₀:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)Ra1:ListBlank (Fin 2) := ListBlank.cons 0 (ones (a + 1) B0)⊢ reachPos { state := 14, tape := mkL (ListBlank.cons 0 (ones (d + 1) B0)) (ones (b₀ + 1) Ra1) }
(sqzCfg (d + 1) (b₀ + 1) (a + 1))
rw [ErdosTernary15.Tape.mkL_cons d:ℕb₀:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)Ra1:ListBlank (Fin 2) := ListBlank.cons 0 (ones (a + 1) B0)⊢ reachPos { state := 14, tape := { head := 0, left := ones (d + 1) B0, right := ones (b₀ + 1) Ra1 } }
(sqzCfg (d + 1) (b₀ + 1) (a + 1))] d:ℕb₀:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)Ra1:ListBlank (Fin 2) := ListBlank.cons 0 (ones (a + 1) B0)⊢ reachPos { state := 14, tape := { head := 0, left := ones (d + 1) B0, right := ones (b₀ + 1) Ra1 } }
(sqzCfg (d + 1) (b₀ + 1) (a + 1))
refine step_then_reachPos (tr14_0 _ _) ?_ d:ℕb₀:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)Ra1:ListBlank (Fin 2) := ListBlank.cons 0 (ones (a + 1) B0)⊢ reachPos { state := 15, tape := mkL (ones (d + 1) B0) (ListBlank.cons 0 (ones (b₀ + 1) Ra1)) }
(sqzCfg (d + 1) (b₀ + 1) (a + 1))
rw [ones_succ d B0, d:ℕb₀:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)Ra1:ListBlank (Fin 2) := ListBlank.cons 0 (ones (a + 1) B0)⊢ reachPos { state := 15, tape := mkL (ListBlank.cons 1 (ones d B0)) (ListBlank.cons 0 (ones (b₀ + 1) Ra1)) }
(sqzCfg (d + 1) (b₀ + 1) (a + 1)) ErdosTernary15.Tape.mkL_cons d:ℕb₀:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)Ra1:ListBlank (Fin 2) := ListBlank.cons 0 (ones (a + 1) B0)⊢ reachPos { state := 15, tape := { head := 1, left := ones d B0, right := ListBlank.cons 0 (ones (b₀ + 1) Ra1) } }
(sqzCfg (d + 1) (b₀ + 1) (a + 1))] d:ℕb₀:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)Ra1:ListBlank (Fin 2) := ListBlank.cons 0 (ones (a + 1) B0)⊢ reachPos { state := 15, tape := { head := 1, left := ones d B0, right := ListBlank.cons 0 (ones (b₀ + 1) Ra1) } }
(sqzCfg (d + 1) (b₀ + 1) (a + 1))
have h15 := tr15_1 (ones d B0) ((ones (b₀ + 1) Ra1).cons 0) d:ℕb₀:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)Ra1:ListBlank (Fin 2) := ListBlank.cons 0 (ones (a + 1) B0)h15:step weakCollatz16
{ state := 15, tape := { head := 1, left := ones d B0, right := ListBlank.cons 0 (ones (b₀ + 1) Ra1) } } =
some { state := 1, tape := Tape.mk' (ListBlank.cons 1 (ones d B0)) (ListBlank.cons 0 (ones (b₀ + 1) Ra1)) }⊢ reachPos { state := 15, tape := { head := 1, left := ones d B0, right := ListBlank.cons 0 (ones (b₀ + 1) Ra1) } }
(sqzCfg (d + 1) (b₀ + 1) (a + 1))
rw [← ones_succ d B0, d:ℕb₀:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)Ra1:ListBlank (Fin 2) := ListBlank.cons 0 (ones (a + 1) B0)h15:step weakCollatz16
{ state := 15, tape := { head := 1, left := ones d B0, right := ListBlank.cons 0 (ones (b₀ + 1) Ra1) } } =
some { state := 1, tape := Tape.mk' (ones (d + 1) B0) (ListBlank.cons 0 (ones (b₀ + 1) Ra1)) }⊢ reachPos { state := 15, tape := { head := 1, left := ones d B0, right := ListBlank.cons 0 (ones (b₀ + 1) Ra1) } }
(sqzCfg (d + 1) (b₀ + 1) (a + 1)) ErdosTernary15.Tape.mk'_cons d:ℕb₀:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)Ra1:ListBlank (Fin 2) := ListBlank.cons 0 (ones (a + 1) B0)h15:step weakCollatz16
{ state := 15, tape := { head := 1, left := ones d B0, right := ListBlank.cons 0 (ones (b₀ + 1) Ra1) } } =
some { state := 1, tape := { head := 0, left := ones (d + 1) B0, right := ones (b₀ + 1) Ra1 } }⊢ reachPos { state := 15, tape := { head := 1, left := ones d B0, right := ListBlank.cons 0 (ones (b₀ + 1) Ra1) } }
(sqzCfg (d + 1) (b₀ + 1) (a + 1))] at h15 d:ℕb₀:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)Ra1:ListBlank (Fin 2) := ListBlank.cons 0 (ones (a + 1) B0)h15:step weakCollatz16
{ state := 15, tape := { head := 1, left := ones d B0, right := ListBlank.cons 0 (ones (b₀ + 1) Ra1) } } =
some { state := 1, tape := { head := 0, left := ones (d + 1) B0, right := ones (b₀ + 1) Ra1 } }⊢ reachPos { state := 15, tape := { head := 1, left := ones d B0, right := ListBlank.cons 0 (ones (b₀ + 1) Ra1) } }
(sqzCfg (d + 1) (b₀ + 1) (a + 1))
exact reachPos_step h15 All goals completed! 🐙private theorem sqz_many (d b₀ a k : ℕ) :
∃ s : ℕ, nSteps weakCollatz16 s (sqzCfg d ((b₀ + 1) + 2 * k) a) =
some (sqzCfg (d + k) (b₀ + 1) (a + k)) := by d:ℕb₀:ℕa:ℕk:ℕ⊢ ∃ s, nSteps weakCollatz16 s (sqzCfg d (b₀ + 1 + 2 * k) a) = some (sqzCfg (d + k) (b₀ + 1) (a + k))
induction k generalizing d a with
| zero => zero b₀:ℕd:ℕa:ℕ⊢ ∃ s, nSteps weakCollatz16 s (sqzCfg d (b₀ + 1 + 2 * 0) a) = some (sqzCfg (d + 0) (b₀ + 1) (a + 0))
simp only [Nat.mul_zero, Nat.add_zero] zero b₀:ℕd:ℕa:ℕ⊢ ∃ s, nSteps weakCollatz16 s (sqzCfg d (b₀ + 1) a) = some (sqzCfg d (b₀ + 1) a)
exact ⟨0, rfl⟩ All goals completed! 🐙
| succ k ih => succ b₀:ℕk:ℕih:∀ (d a : ℕ), ∃ s, nSteps weakCollatz16 s (sqzCfg d (b₀ + 1 + 2 * k) a) = some (sqzCfg (d + k) (b₀ + 1) (a + k))d:ℕa:ℕ⊢ ∃ s, nSteps weakCollatz16 s (sqzCfg d (b₀ + 1 + 2 * (k + 1)) a) = some (sqzCfg (d + (k + 1)) (b₀ + 1) (a + (k + 1)))
rw [show (b₀ + 1) + 2 * (k + 1) = (b₀ + 2 * k) + 3 by d:ℕb₀:ℕa:ℕk:ℕ⊢ ∃ s, nSteps weakCollatz16 s (sqzCfg d (b₀ + 1 + 2 * k) a) = some (sqzCfg (d + k) (b₀ + 1) (a + k)) omega All goals completed! 🐙] succ b₀:ℕk:ℕih:∀ (d a : ℕ), ∃ s, nSteps weakCollatz16 s (sqzCfg d (b₀ + 1 + 2 * k) a) = some (sqzCfg (d + k) (b₀ + 1) (a + k))d:ℕa:ℕ⊢ ∃ s, nSteps weakCollatz16 s (sqzCfg d (b₀ + 2 * k + 3) a) = some (sqzCfg (d + (k + 1)) (b₀ + 1) (a + (k + 1)))
obtain ⟨s₁, _, hs₁⟩ := sqz_step d (b₀ + 2 * k) a succ b₀:ℕk:ℕih:∀ (d a : ℕ), ∃ s, nSteps weakCollatz16 s (sqzCfg d (b₀ + 1 + 2 * k) a) = some (sqzCfg (d + k) (b₀ + 1) (a + k))d:ℕa:ℕs₁:ℕleft✝:1 ≤ s₁hs₁:nSteps weakCollatz16 s₁ (sqzCfg d (b₀ + 2 * k + 3) a) = some (sqzCfg (d + 1) (b₀ + 2 * k + 1) (a + 1))⊢ ∃ s, nSteps weakCollatz16 s (sqzCfg d (b₀ + 2 * k + 3) a) = some (sqzCfg (d + (k + 1)) (b₀ + 1) (a + (k + 1)))
rw [show (b₀ + 2 * k) + 1 = (b₀ + 1) + 2 * k by d:ℕb₀:ℕa:ℕk:ℕ⊢ ∃ s, nSteps weakCollatz16 s (sqzCfg d (b₀ + 1 + 2 * k) a) = some (sqzCfg (d + k) (b₀ + 1) (a + k)) omega All goals completed! 🐙] at hs₁ succ b₀:ℕk:ℕih:∀ (d a : ℕ), ∃ s, nSteps weakCollatz16 s (sqzCfg d (b₀ + 1 + 2 * k) a) = some (sqzCfg (d + k) (b₀ + 1) (a + k))d:ℕa:ℕs₁:ℕleft✝:1 ≤ s₁hs₁:nSteps weakCollatz16 s₁ (sqzCfg d (b₀ + 2 * k + 3) a) = some (sqzCfg (d + 1) (b₀ + 1 + 2 * k) (a + 1))⊢ ∃ s, nSteps weakCollatz16 s (sqzCfg d (b₀ + 2 * k + 3) a) = some (sqzCfg (d + (k + 1)) (b₀ + 1) (a + (k + 1)))
obtain ⟨s₂, hs₂⟩ := ih (d + 1) (a + 1) succ b₀:ℕk:ℕih:∀ (d a : ℕ), ∃ s, nSteps weakCollatz16 s (sqzCfg d (b₀ + 1 + 2 * k) a) = some (sqzCfg (d + k) (b₀ + 1) (a + k))d:ℕa:ℕs₁:ℕleft✝:1 ≤ s₁hs₁:nSteps weakCollatz16 s₁ (sqzCfg d (b₀ + 2 * k + 3) a) = some (sqzCfg (d + 1) (b₀ + 1 + 2 * k) (a + 1))s₂:ℕhs₂:nSteps weakCollatz16 s₂ (sqzCfg (d + 1) (b₀ + 1 + 2 * k) (a + 1)) = some (sqzCfg (d + 1 + k) (b₀ + 1) (a + 1 + k))⊢ ∃ s, nSteps weakCollatz16 s (sqzCfg d (b₀ + 2 * k + 3) a) = some (sqzCfg (d + (k + 1)) (b₀ + 1) (a + (k + 1)))
rw [show d + 1 + k = d + (k + 1) by d:ℕb₀:ℕa:ℕk:ℕ⊢ ∃ s, nSteps weakCollatz16 s (sqzCfg d (b₀ + 1 + 2 * k) a) = some (sqzCfg (d + k) (b₀ + 1) (a + k)) omega All goals completed! 🐙, show a + 1 + k = a + (k + 1) by d:ℕb₀:ℕa:ℕk:ℕ⊢ ∃ s, nSteps weakCollatz16 s (sqzCfg d (b₀ + 1 + 2 * k) a) = some (sqzCfg (d + k) (b₀ + 1) (a + k)) omega All goals completed! 🐙] at hs₂ succ b₀:ℕk:ℕih:∀ (d a : ℕ), ∃ s, nSteps weakCollatz16 s (sqzCfg d (b₀ + 1 + 2 * k) a) = some (sqzCfg (d + k) (b₀ + 1) (a + k))d:ℕa:ℕs₁:ℕleft✝:1 ≤ s₁hs₁:nSteps weakCollatz16 s₁ (sqzCfg d (b₀ + 2 * k + 3) a) = some (sqzCfg (d + 1) (b₀ + 1 + 2 * k) (a + 1))s₂:ℕhs₂:nSteps weakCollatz16 s₂ (sqzCfg (d + 1) (b₀ + 1 + 2 * k) (a + 1)) = some (sqzCfg (d + (k + 1)) (b₀ + 1) (a + (k + 1)))⊢ ∃ s, nSteps weakCollatz16 s (sqzCfg d (b₀ + 2 * k + 3) a) = some (sqzCfg (d + (k + 1)) (b₀ + 1) (a + (k + 1)))
exact ⟨s₁ + s₂, nSteps_bind_eq hs₁ hs₂⟩ All goals completed! 🐙private theorem sqz_even_exit (d a : ℕ) :
reachPos (sqzCfg d 2 a) (roundCfg (d + 1) (a + 1)) := by d:ℕa:ℕ⊢ reachPos (sqzCfg d 2 a) (roundCfg (d + 1) (a + 1))
refine reachPos_trans (sqz_to_eback d 0 a) ?_ d:ℕa:ℕ⊢ reachPos { state := 6, tape := mkL (ones 0 (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (a + 1) B0)) }
(roundCfg (d + 1) (a + 1))
rw [ones_zero, d:ℕa:ℕ⊢ reachPos { state := 6, tape := mkL (ListBlank.cons 0 (ones (d + 1) B0)) (ListBlank.cons 0 (ones (a + 1) B0)) }
(roundCfg (d + 1) (a + 1)) ErdosTernary15.Tape.mkL_cons d:ℕa:ℕ⊢ reachPos { state := 6, tape := { head := 0, left := ones (d + 1) B0, right := ListBlank.cons 0 (ones (a + 1) B0) } }
(roundCfg (d + 1) (a + 1))] d:ℕa:ℕ⊢ reachPos { state := 6, tape := { head := 0, left := ones (d + 1) B0, right := ListBlank.cons 0 (ones (a + 1) B0) } }
(roundCfg (d + 1) (a + 1))
refine step_then_reachPos (tr6_0 _ _) ?_ d:ℕa:ℕ⊢ reachPos { state := 2, tape := Tape.mk' (ListBlank.cons 0 (ones (d + 1) B0)) (ListBlank.cons 0 (ones (a + 1) B0)) }
(roundCfg (d + 1) (a + 1))
rw [ErdosTernary15.Tape.mk'_cons d:ℕa:ℕ⊢ reachPos { state := 2, tape := { head := 0, left := ListBlank.cons 0 (ones (d + 1) B0), right := ones (a + 1) B0 } }
(roundCfg (d + 1) (a + 1))] d:ℕa:ℕ⊢ reachPos { state := 2, tape := { head := 0, left := ListBlank.cons 0 (ones (d + 1) B0), right := ones (a + 1) B0 } }
(roundCfg (d + 1) (a + 1))
refine step_then_reachPos (tr2_0 _ _) ?_ d:ℕa:ℕ⊢ reachPos { state := 7, tape := Tape.mk' (ListBlank.cons 1 (ListBlank.cons 0 (ones (d + 1) B0))) (ones (a + 1) B0) }
(roundCfg (d + 1) (a + 1))
let Ld := (ones (d + 1) B0).cons 0 d:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)⊢ reachPos { state := 7, tape := Tape.mk' (ListBlank.cons 1 (ListBlank.cons 0 (ones (d + 1) B0))) (ones (a + 1) B0) }
(roundCfg (d + 1) (a + 1))
change reachPos ⟨7, Tape.mk' (ones 1 Ld) (ones (a + 1) B0)⟩ _ d:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)⊢ reachPos { state := 7, tape := Tape.mk' (ones 1 Ld) (ones (a + 1) B0) } (roundCfg (d + 1) (a + 1))
refine nSteps_then_reachPos (sweep1R tr7_1 (a + 1) (ones 1 Ld) B0) ?_ d:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)⊢ reachPos { state := 7, tape := Tape.mk' (ones (a + 1) (ones 1 Ld)) B0 } (roundCfg (d + 1) (a + 1))
rw [← ones_add (a + 1) 1 Ld, d:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)⊢ reachPos { state := 7, tape := Tape.mk' (ones (a + 1 + 1) Ld) B0 } (roundCfg (d + 1) (a + 1)) ErdosTernary15.Tape.mk'_B0 d:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)⊢ reachPos { state := 7, tape := { head := 0, left := ones (a + 1 + 1) Ld, right := B0 } } (roundCfg (d + 1) (a + 1))] d:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)⊢ reachPos { state := 7, tape := { head := 0, left := ones (a + 1 + 1) Ld, right := B0 } } (roundCfg (d + 1) (a + 1))
refine step_then_reachPos (tr7_0 _ _) ?_ d:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)⊢ reachPos { state := 5, tape := mkL (ones (a + 1 + 1) Ld) (ListBlank.cons 0 B0) } (roundCfg (d + 1) (a + 1))
rw [B0_cons_zero, d:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)⊢ reachPos { state := 5, tape := mkL (ones (a + 1 + 1) Ld) B0 } (roundCfg (d + 1) (a + 1)) show a + 1 + 1 = (a + 1) + 1 from rfl, d:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)⊢ reachPos { state := 5, tape := mkL (ones (a + 1 + 1) Ld) B0 } (roundCfg (d + 1) (a + 1)) ones_succ (a + 1) Ld, d:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)⊢ reachPos { state := 5, tape := mkL (ListBlank.cons 1 (ones (a + 1) Ld)) B0 } (roundCfg (d + 1) (a + 1))
ErdosTernary15.Tape.mkL_cons d:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)⊢ reachPos { state := 5, tape := { head := 1, left := ones (a + 1) Ld, right := B0 } } (roundCfg (d + 1) (a + 1))] d:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)⊢ reachPos { state := 5, tape := { head := 1, left := ones (a + 1) Ld, right := B0 } } (roundCfg (d + 1) (a + 1))
refine step_then_reachPos (tr5_1 _ _) ?_ d:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)⊢ reachPos { state := 6, tape := mkL (ones (a + 1) Ld) (ListBlank.cons 0 B0) } (roundCfg (d + 1) (a + 1))
rw [B0_cons_zero, d:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)⊢ reachPos { state := 6, tape := mkL (ones (a + 1) Ld) B0 } (roundCfg (d + 1) (a + 1)) ones_succ a Ld, d:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)⊢ reachPos { state := 6, tape := mkL (ListBlank.cons 1 (ones a Ld)) B0 } (roundCfg (d + 1) (a + 1)) ErdosTernary15.Tape.mkL_cons d:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)⊢ reachPos { state := 6, tape := { head := 1, left := ones a Ld, right := B0 } } (roundCfg (d + 1) (a + 1))] d:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)⊢ reachPos { state := 6, tape := { head := 1, left := ones a Ld, right := B0 } } (roundCfg (d + 1) (a + 1))
refine reachPos_trans (eback_to_haltchk (ones (d + 1) B0) a) ?_ d:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)⊢ reachPos { state := 15, tape := mkL (ones (d + 1) B0) (ListBlank.cons 0 (ones (a + 1) B0)) } (roundCfg (d + 1) (a + 1))
rw [ones_succ d B0, d:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)⊢ reachPos { state := 15, tape := mkL (ListBlank.cons 1 (ones d B0)) (ListBlank.cons 0 (ones (a + 1) B0)) }
(roundCfg (d + 1) (a + 1)) ErdosTernary15.Tape.mkL_cons d:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)⊢ reachPos { state := 15, tape := { head := 1, left := ones d B0, right := ListBlank.cons 0 (ones (a + 1) B0) } }
(roundCfg (d + 1) (a + 1))] d:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)⊢ reachPos { state := 15, tape := { head := 1, left := ones d B0, right := ListBlank.cons 0 (ones (a + 1) B0) } }
(roundCfg (d + 1) (a + 1))
have h15 := tr15_1 (ones d B0) ((ones (a + 1) B0).cons 0) d:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)h15:step weakCollatz16
{ state := 15, tape := { head := 1, left := ones d B0, right := ListBlank.cons 0 (ones (a + 1) B0) } } =
some { state := 1, tape := Tape.mk' (ListBlank.cons 1 (ones d B0)) (ListBlank.cons 0 (ones (a + 1) B0)) }⊢ reachPos { state := 15, tape := { head := 1, left := ones d B0, right := ListBlank.cons 0 (ones (a + 1) B0) } }
(roundCfg (d + 1) (a + 1))
rw [← ones_succ d B0, d:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)h15:step weakCollatz16
{ state := 15, tape := { head := 1, left := ones d B0, right := ListBlank.cons 0 (ones (a + 1) B0) } } =
some { state := 1, tape := Tape.mk' (ones (d + 1) B0) (ListBlank.cons 0 (ones (a + 1) B0)) }⊢ reachPos { state := 15, tape := { head := 1, left := ones d B0, right := ListBlank.cons 0 (ones (a + 1) B0) } }
(roundCfg (d + 1) (a + 1)) ErdosTernary15.Tape.mk'_cons d:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)h15:step weakCollatz16
{ state := 15, tape := { head := 1, left := ones d B0, right := ListBlank.cons 0 (ones (a + 1) B0) } } =
some { state := 1, tape := { head := 0, left := ones (d + 1) B0, right := ones (a + 1) B0 } }⊢ reachPos { state := 15, tape := { head := 1, left := ones d B0, right := ListBlank.cons 0 (ones (a + 1) B0) } }
(roundCfg (d + 1) (a + 1))] at h15 d:ℕa:ℕLd:ListBlank (Fin 2) := ListBlank.cons 0 (ones (d + 1) B0)h15:step weakCollatz16
{ state := 15, tape := { head := 1, left := ones d B0, right := ListBlank.cons 0 (ones (a + 1) B0) } } =
some { state := 1, tape := { head := 0, left := ones (d + 1) B0, right := ones (a + 1) B0 } }⊢ reachPos { state := 15, tape := { head := 1, left := ones d B0, right := ListBlank.cons 0 (ones (a + 1) B0) } }
(roundCfg (d + 1) (a + 1))
exact reachPos_step h15 All goals completed! 🐙private theorem round_even (d k : ℕ) :
reachPos (roundCfg d (2 * k + 2)) (roundCfg (d + k + 1) (k + 1)) := by d:ℕk:ℕ⊢ reachPos (roundCfg d (2 * k + 2)) (roundCfg (d + k + 1) (k + 1))
rw [roundCfg_eq_sqzCfg, d:ℕk:ℕ⊢ reachPos (sqzCfg d (2 * k + 2) 0) (roundCfg (d + k + 1) (k + 1)) show 2 * k + 2 = (1 + 1) + 2 * k by d:ℕk:ℕ⊢ reachPos (roundCfg d (2 * k + 2)) (roundCfg (d + k + 1) (k + 1)) omega All goals completed! 🐙] d:ℕk:ℕ⊢ reachPos (sqzCfg d (1 + 1 + 2 * k) 0) (roundCfg (d + k + 1) (k + 1))
obtain ⟨s, hs⟩ := sqz_many d 1 0 k d:ℕk:ℕs:ℕhs:nSteps weakCollatz16 s (sqzCfg d (1 + 1 + 2 * k) 0) = some (sqzCfg (d + k) (1 + 1) (0 + k))⊢ reachPos (sqzCfg d (1 + 1 + 2 * k) 0) (roundCfg (d + k + 1) (k + 1))
rw [Nat.zero_add d:ℕk:ℕs:ℕhs:nSteps weakCollatz16 s (sqzCfg d (1 + 1 + 2 * k) 0) = some (sqzCfg (d + k) (1 + 1) k)⊢ reachPos (sqzCfg d (1 + 1 + 2 * k) 0) (roundCfg (d + k + 1) (k + 1))] at hs d:ℕk:ℕs:ℕhs:nSteps weakCollatz16 s (sqzCfg d (1 + 1 + 2 * k) 0) = some (sqzCfg (d + k) (1 + 1) k)⊢ reachPos (sqzCfg d (1 + 1 + 2 * k) 0) (roundCfg (d + k + 1) (k + 1))
exact nSteps_then_reachPos hs (sqz_even_exit (d + k) k) All goals completed! 🐙private theorem gt_merge (p m : ℕ) :
reachPos ⟨3, Tape.mk' B0 (ones p ((ones m B0).cons 0))⟩ (stageCfg (p + m + 1)) := by p:ℕm:ℕ⊢ reachPos { state := 3, tape := Tape.mk' B0 (ones p (ListBlank.cons 0 (ones m B0))) } (stageCfg (p + m + 1))
unfold stageCfg roundCfg p:ℕm:ℕ⊢ reachPos { state := 3, tape := Tape.mk' B0 (ones p (ListBlank.cons 0 (ones m B0))) }
{ state := 1, tape := { head := 0, left := ones 0 B0, right := ones (p + m + 1) B0 } }
refine nSteps_then_reachPos (sweep1R tr3_1 p B0 ((ones m B0).cons 0)) ?_ p:ℕm:ℕ⊢ reachPos { state := 3, tape := Tape.mk' (ones p B0) (ListBlank.cons 0 (ones m B0)) }
{ state := 1, tape := { head := 0, left := ones 0 B0, right := ones (p + m + 1) B0 } }
rw [ErdosTernary15.Tape.mk'_cons p:ℕm:ℕ⊢ reachPos { state := 3, tape := { head := 0, left := ones p B0, right := ones m B0 } }
{ state := 1, tape := { head := 0, left := ones 0 B0, right := ones (p + m + 1) B0 } }] p:ℕm:ℕ⊢ reachPos { state := 3, tape := { head := 0, left := ones p B0, right := ones m B0 } }
{ state := 1, tape := { head := 0, left := ones 0 B0, right := ones (p + m + 1) B0 } }
have h3 : reachPos ⟨3, ⟨0, ones p B0, ones m B0⟩⟩
⟨1, mkL (ones p B0) (ones (m + 1) B0)⟩ :=
reachPos_step (tr3_0 (ones p B0) (ones m B0)) p:ℕm:ℕh3:reachPos { state := 3, tape := { head := 0, left := ones p B0, right := ones m B0 } }
{ state := 1, tape := mkL (ones p B0) (ones (m + 1) B0) }⊢ reachPos { state := 3, tape := { head := 0, left := ones p B0, right := ones m B0 } }
{ state := 1, tape := { head := 0, left := ones 0 B0, right := ones (p + m + 1) B0 } }
have hsw := sweep1L tr1_1 p B0 (ones (m + 1) B0) p:ℕm:ℕh3:reachPos { state := 3, tape := { head := 0, left := ones p B0, right := ones m B0 } }
{ state := 1, tape := mkL (ones p B0) (ones (m + 1) B0) }hsw:nSteps weakCollatz16 p { state := 1, tape := mkL (ones p B0) (ones (m + 1) B0) } =
some { state := 1, tape := mkL B0 (ones p (ones (m + 1) B0)) }⊢ reachPos { state := 3, tape := { head := 0, left := ones p B0, right := ones m B0 } }
{ state := 1, tape := { head := 0, left := ones 0 B0, right := ones (p + m + 1) B0 } }
rw [← ones_add p (m + 1) B0, p:ℕm:ℕh3:reachPos { state := 3, tape := { head := 0, left := ones p B0, right := ones m B0 } }
{ state := 1, tape := mkL (ones p B0) (ones (m + 1) B0) }hsw:nSteps weakCollatz16 p { state := 1, tape := mkL (ones p B0) (ones (m + 1) B0) } =
some { state := 1, tape := mkL B0 (ones (p + (m + 1)) B0) }⊢ reachPos { state := 3, tape := { head := 0, left := ones p B0, right := ones m B0 } }
{ state := 1, tape := { head := 0, left := ones 0 B0, right := ones (p + m + 1) B0 } } mkL_B0, p:ℕm:ℕh3:reachPos { state := 3, tape := { head := 0, left := ones p B0, right := ones m B0 } }
{ state := 1, tape := mkL (ones p B0) (ones (m + 1) B0) }hsw:nSteps weakCollatz16 p { state := 1, tape := mkL (ones p B0) (ones (m + 1) B0) } =
some { state := 1, tape := { head := 0, left := B0, right := ones (p + (m + 1)) B0 } }⊢ reachPos { state := 3, tape := { head := 0, left := ones p B0, right := ones m B0 } }
{ state := 1, tape := { head := 0, left := ones 0 B0, right := ones (p + m + 1) B0 } } show p + (m + 1) = p + m + 1 by p:ℕm:ℕ⊢ reachPos { state := 3, tape := Tape.mk' B0 (ones p (ListBlank.cons 0 (ones m B0))) } (stageCfg (p + m + 1)) omega All goals completed! 🐙] at hsw p:ℕm:ℕh3:reachPos { state := 3, tape := { head := 0, left := ones p B0, right := ones m B0 } }
{ state := 1, tape := mkL (ones p B0) (ones (m + 1) B0) }hsw:nSteps weakCollatz16 p { state := 1, tape := mkL (ones p B0) (ones (m + 1) B0) } =
some { state := 1, tape := { head := 0, left := B0, right := ones (p + m + 1) B0 } }⊢ reachPos { state := 3, tape := { head := 0, left := ones p B0, right := ones m B0 } }
{ state := 1, tape := { head := 0, left := ones 0 B0, right := ones (p + m + 1) B0 } }
exact reachPos_then_nSteps h3 hsw All goals completed! 🐙private theorem round_y1 (d : ℕ) : reachPos (roundCfg d 1) (stageCfg (d + 3)) := by d:ℕ⊢ reachPos (roundCfg d 1) (stageCfg (d + 3))
unfold roundCfg d:ℕ⊢ reachPos { state := 1, tape := { head := 0, left := ones d B0, right := ones 1 B0 } } (stageCfg (d + 3))
refine step_then_reachPos (tr1_0 _ _) ?_ d:ℕ⊢ reachPos { state := 2, tape := Tape.mk' (ListBlank.cons 1 (ones d B0)) (ones 1 B0) } (stageCfg (d + 3))
rw [← ones_succ d B0, d:ℕ⊢ reachPos { state := 2, tape := Tape.mk' (ones (d + 1) B0) (ones 1 B0) } (stageCfg (d + 3)) ones_succ 0 B0, d:ℕ⊢ reachPos { state := 2, tape := Tape.mk' (ones (d + 1) B0) (ListBlank.cons 1 (ones 0 B0)) } (stageCfg (d + 3)) ones_zero, d:ℕ⊢ reachPos { state := 2, tape := Tape.mk' (ones (d + 1) B0) (ListBlank.cons 1 B0) } (stageCfg (d + 3)) ErdosTernary15.Tape.mk'_cons d:ℕ⊢ reachPos { state := 2, tape := { head := 1, left := ones (d + 1) B0, right := B0 } } (stageCfg (d + 3))] d:ℕ⊢ reachPos { state := 2, tape := { head := 1, left := ones (d + 1) B0, right := B0 } } (stageCfg (d + 3))
refine step_then_reachPos (tr2_1 _ _) ?_ d:ℕ⊢ reachPos { state := 0, tape := Tape.mk' (ListBlank.cons 0 (ones (d + 1) B0)) B0 } (stageCfg (d + 3))
rw [ErdosTernary15.Tape.mk'_B0 d:ℕ⊢ reachPos { state := 0, tape := { head := 0, left := ListBlank.cons 0 (ones (d + 1) B0), right := B0 } }
(stageCfg (d + 3))] d:ℕ⊢ reachPos { state := 0, tape := { head := 0, left := ListBlank.cons 0 (ones (d + 1) B0), right := B0 } }
(stageCfg (d + 3))
refine step_then_reachPos (tr0_0 _ _) ?_ d:ℕ⊢ reachPos { state := 8, tape := Tape.mk' (ListBlank.cons 0 (ListBlank.cons 0 (ones (d + 1) B0))) B0 } (stageCfg (d + 3))
rw [ErdosTernary15.Tape.mk'_B0 d:ℕ⊢ reachPos
{ state := 8, tape := { head := 0, left := ListBlank.cons 0 (ListBlank.cons 0 (ones (d + 1) B0)), right := B0 } }
(stageCfg (d + 3))] d:ℕ⊢ reachPos
{ state := 8, tape := { head := 0, left := ListBlank.cons 0 (ListBlank.cons 0 (ones (d + 1) B0)), right := B0 } }
(stageCfg (d + 3))
refine step_then_reachPos (tr8_0 _ _) ?_ d:ℕ⊢ reachPos { state := 7, tape := mkL (ListBlank.cons 0 (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 B0) }
(stageCfg (d + 3))
rw [B0_cons_zero, d:ℕ⊢ reachPos { state := 7, tape := mkL (ListBlank.cons 0 (ListBlank.cons 0 (ones (d + 1) B0))) B0 } (stageCfg (d + 3)) ErdosTernary15.Tape.mkL_cons d:ℕ⊢ reachPos { state := 7, tape := { head := 0, left := ListBlank.cons 0 (ones (d + 1) B0), right := B0 } }
(stageCfg (d + 3))] d:ℕ⊢ reachPos { state := 7, tape := { head := 0, left := ListBlank.cons 0 (ones (d + 1) B0), right := B0 } }
(stageCfg (d + 3))
refine step_then_reachPos (tr7_0 _ _) ?_ d:ℕ⊢ reachPos { state := 5, tape := mkL (ListBlank.cons 0 (ones (d + 1) B0)) (ListBlank.cons 0 B0) } (stageCfg (d + 3))
rw [B0_cons_zero, d:ℕ⊢ reachPos { state := 5, tape := mkL (ListBlank.cons 0 (ones (d + 1) B0)) B0 } (stageCfg (d + 3)) ErdosTernary15.Tape.mkL_cons d:ℕ⊢ reachPos { state := 5, tape := { head := 0, left := ones (d + 1) B0, right := B0 } } (stageCfg (d + 3))] d:ℕ⊢ reachPos { state := 5, tape := { head := 0, left := ones (d + 1) B0, right := B0 } } (stageCfg (d + 3))
refine step_then_reachPos (tr5_0 _ _) ?_ d:ℕ⊢ reachPos { state := 9, tape := mkL (ones (d + 1) B0) (ListBlank.cons 0 B0) } (stageCfg (d + 3))
rw [B0_cons_zero d:ℕ⊢ reachPos { state := 9, tape := mkL (ones (d + 1) B0) B0 } (stageCfg (d + 3))] d:ℕ⊢ reachPos { state := 9, tape := mkL (ones (d + 1) B0) B0 } (stageCfg (d + 3))
refine nSteps_then_reachPos (sweep1L tr9_1 (d + 1) B0 B0) ?_ d:ℕ⊢ reachPos { state := 9, tape := mkL B0 (ones (d + 1) B0) } (stageCfg (d + 3))
rw [mkL_B0 d:ℕ⊢ reachPos { state := 9, tape := { head := 0, left := B0, right := ones (d + 1) B0 } } (stageCfg (d + 3))] d:ℕ⊢ reachPos { state := 9, tape := { head := 0, left := B0, right := ones (d + 1) B0 } } (stageCfg (d + 3))
refine step_then_reachPos (tr9_0 _ _) ?_ d:ℕ⊢ reachPos { state := 10, tape := mkL B0 (ListBlank.cons 1 (ones (d + 1) B0)) } (stageCfg (d + 3))
rw [mkL_B0, d:ℕ⊢ reachPos { state := 10, tape := { head := 0, left := B0, right := ListBlank.cons 1 (ones (d + 1) B0) } }
(stageCfg (d + 3)) ← ones_succ (d + 1) B0 d:ℕ⊢ reachPos { state := 10, tape := { head := 0, left := B0, right := ones (d + 1 + 1) B0 } } (stageCfg (d + 3))] d:ℕ⊢ reachPos { state := 10, tape := { head := 0, left := B0, right := ones (d + 1 + 1) B0 } } (stageCfg (d + 3))
refine step_then_reachPos (tr10_0 _ _) ?_ d:ℕ⊢ reachPos { state := 3, tape := Tape.mk' (ListBlank.cons 0 B0) (ones (d + 1 + 1) B0) } (stageCfg (d + 3))
rw [B0_cons_zero d:ℕ⊢ reachPos { state := 3, tape := Tape.mk' B0 (ones (d + 1 + 1) B0) } (stageCfg (d + 3))] d:ℕ⊢ reachPos { state := 3, tape := Tape.mk' B0 (ones (d + 1 + 1) B0) } (stageCfg (d + 3))
have hgt := gt_merge (d + 2) 0 d:ℕhgt:reachPos { state := 3, tape := Tape.mk' B0 (ones (d + 2) (ListBlank.cons 0 (ones 0 B0))) } (stageCfg (d + 2 + 0 + 1))⊢ reachPos { state := 3, tape := Tape.mk' B0 (ones (d + 1 + 1) B0) } (stageCfg (d + 3))
rw [ones_zero, d:ℕhgt:reachPos { state := 3, tape := Tape.mk' B0 (ones (d + 2) (ListBlank.cons 0 B0)) } (stageCfg (d + 2 + 0 + 1))⊢ reachPos { state := 3, tape := Tape.mk' B0 (ones (d + 1 + 1) B0) } (stageCfg (d + 3)) B0_cons_zero, d:ℕhgt:reachPos { state := 3, tape := Tape.mk' B0 (ones (d + 2) B0) } (stageCfg (d + 2 + 0 + 1))⊢ reachPos { state := 3, tape := Tape.mk' B0 (ones (d + 1 + 1) B0) } (stageCfg (d + 3)) show (d + 2) + 0 + 1 = d + 3 by d:ℕ⊢ reachPos (roundCfg d 1) (stageCfg (d + 3)) omega All goals completed! 🐙] at hgt d:ℕhgt:reachPos { state := 3, tape := Tape.mk' B0 (ones (d + 2) B0) } (stageCfg (d + 3))⊢ reachPos { state := 3, tape := Tape.mk' B0 (ones (d + 1 + 1) B0) } (stageCfg (d + 3))
exact hgt All goals completed! 🐙
Odd 3k + 2 Conservation Loop, Trim-Free +2 Merge & z = x Halt
Odd conservation configuration (L + r + m = x): 0^∞ 1^L 0 1^(r - 1) [1] 0 1^m 0^∞ in
state 9 (for r = 0, 0^∞ 1^L [0] 0 1^m 0^∞).
private def oddCfg (L r m : ℕ) : Cfg 16 2 :=
⟨9, mkL (ones r ((ones L B0).cons 0)) ((ones m B0).cons 0)⟩private theorem sqz_odd_enter (d k' : ℕ) :
reachPos (sqzCfg d 1 (k' + 1)) (oddCfg (d + 1) 0 (k' + 1)) := by d:ℕk':ℕ⊢ reachPos (sqzCfg d 1 (k' + 1)) (oddCfg (d + 1) 0 (k' + 1))
unfold sqzCfg oddCfg d:ℕk':ℕ⊢ reachPos { state := 1, tape := { head := 0, left := ones d B0, right := ones 1 (ListBlank.cons 0 (ones (k' + 1) B0)) } }
{ state := 9, tape := mkL (ones 0 (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (k' + 1) B0)) }
let Rk := (ones (k' + 1) B0).cons 0 d:ℕk':ℕRk:ListBlank (Fin 2) := ListBlank.cons 0 (ones (k' + 1) B0)⊢ reachPos { state := 1, tape := { head := 0, left := ones d B0, right := ones 1 (ListBlank.cons 0 (ones (k' + 1) B0)) } }
{ state := 9, tape := mkL (ones 0 (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (k' + 1) B0)) }
change reachPos ⟨1, ⟨0, ones d B0, ones 1 Rk⟩⟩ _ d:ℕk':ℕRk:ListBlank (Fin 2) := ListBlank.cons 0 (ones (k' + 1) B0)⊢ reachPos { state := 1, tape := { head := 0, left := ones d B0, right := ones 1 Rk } }
{ state := 9, tape := mkL (ones 0 (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (k' + 1) B0)) }
refine step_then_reachPos (tr1_0 _ _) ?_ d:ℕk':ℕRk:ListBlank (Fin 2) := ListBlank.cons 0 (ones (k' + 1) B0)⊢ reachPos { state := 2, tape := Tape.mk' (ListBlank.cons 1 (ones d B0)) (ones 1 Rk) }
{ state := 9, tape := mkL (ones 0 (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (k' + 1) B0)) }
rw [← ones_succ d B0, d:ℕk':ℕRk:ListBlank (Fin 2) := ListBlank.cons 0 (ones (k' + 1) B0)⊢ reachPos { state := 2, tape := Tape.mk' (ones (d + 1) B0) (ones 1 Rk) }
{ state := 9, tape := mkL (ones 0 (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (k' + 1) B0)) } ones_succ 0 Rk, d:ℕk':ℕRk:ListBlank (Fin 2) := ListBlank.cons 0 (ones (k' + 1) B0)⊢ reachPos { state := 2, tape := Tape.mk' (ones (d + 1) B0) (ListBlank.cons 1 (ones 0 Rk)) }
{ state := 9, tape := mkL (ones 0 (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (k' + 1) B0)) } ones_zero, d:ℕk':ℕRk:ListBlank (Fin 2) := ListBlank.cons 0 (ones (k' + 1) B0)⊢ reachPos { state := 2, tape := Tape.mk' (ones (d + 1) B0) (ListBlank.cons 1 Rk) }
{ state := 9, tape := mkL (ones 0 (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (k' + 1) B0)) } ErdosTernary15.Tape.mk'_cons d:ℕk':ℕRk:ListBlank (Fin 2) := ListBlank.cons 0 (ones (k' + 1) B0)⊢ reachPos { state := 2, tape := { head := 1, left := ones (d + 1) B0, right := Rk } }
{ state := 9, tape := mkL (ones 0 (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (k' + 1) B0)) }] d:ℕk':ℕRk:ListBlank (Fin 2) := ListBlank.cons 0 (ones (k' + 1) B0)⊢ reachPos { state := 2, tape := { head := 1, left := ones (d + 1) B0, right := Rk } }
{ state := 9, tape := mkL (ones 0 (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (k' + 1) B0)) }
refine step_then_reachPos (tr2_1 _ _) ?_ d:ℕk':ℕRk:ListBlank (Fin 2) := ListBlank.cons 0 (ones (k' + 1) B0)⊢ reachPos { state := 0, tape := Tape.mk' (ListBlank.cons 0 (ones (d + 1) B0)) Rk }
{ state := 9, tape := mkL (ones 0 (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (k' + 1) B0)) }
dsimp only [Rk] d:ℕk':ℕRk:ListBlank (Fin 2) := ListBlank.cons 0 (ones (k' + 1) B0)⊢ reachPos { state := 0, tape := Tape.mk' (ListBlank.cons 0 (ones (d + 1) B0)) (ListBlank.cons 0 (ones (k' + 1) B0)) }
{ state := 9, tape := mkL (ones 0 (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (k' + 1) B0)) }
rw [ErdosTernary15.Tape.mk'_cons d:ℕk':ℕRk:ListBlank (Fin 2) := ListBlank.cons 0 (ones (k' + 1) B0)⊢ reachPos { state := 0, tape := { head := 0, left := ListBlank.cons 0 (ones (d + 1) B0), right := ones (k' + 1) B0 } }
{ state := 9, tape := mkL (ones 0 (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (k' + 1) B0)) }] d:ℕk':ℕRk:ListBlank (Fin 2) := ListBlank.cons 0 (ones (k' + 1) B0)⊢ reachPos { state := 0, tape := { head := 0, left := ListBlank.cons 0 (ones (d + 1) B0), right := ones (k' + 1) B0 } }
{ state := 9, tape := mkL (ones 0 (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (k' + 1) B0)) }
refine step_then_reachPos (tr0_0 _ _) ?_ d:ℕk':ℕRk:ListBlank (Fin 2) := ListBlank.cons 0 (ones (k' + 1) B0)⊢ reachPos { state := 8, tape := Tape.mk' (ListBlank.cons 0 (ListBlank.cons 0 (ones (d + 1) B0))) (ones (k' + 1) B0) }
{ state := 9, tape := mkL (ones 0 (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (k' + 1) B0)) }
rw [ones_succ k' B0, d:ℕk':ℕRk:ListBlank (Fin 2) := ListBlank.cons 0 (ones (k' + 1) B0)⊢ reachPos
{ state := 8,
tape := Tape.mk' (ListBlank.cons 0 (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 1 (ones k' B0)) }
{ state := 9,
tape := mkL (ones 0 (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ListBlank.cons 1 (ones k' B0))) } ErdosTernary15.Tape.mk'_cons d:ℕk':ℕRk:ListBlank (Fin 2) := ListBlank.cons 0 (ones (k' + 1) B0)⊢ reachPos
{ state := 8,
tape := { head := 1, left := ListBlank.cons 0 (ListBlank.cons 0 (ones (d + 1) B0)), right := ones k' B0 } }
{ state := 9,
tape := mkL (ones 0 (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ListBlank.cons 1 (ones k' B0))) }] d:ℕk':ℕRk:ListBlank (Fin 2) := ListBlank.cons 0 (ones (k' + 1) B0)⊢ reachPos
{ state := 8,
tape := { head := 1, left := ListBlank.cons 0 (ListBlank.cons 0 (ones (d + 1) B0)), right := ones k' B0 } }
{ state := 9,
tape := mkL (ones 0 (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ListBlank.cons 1 (ones k' B0))) }
refine step_then_reachPos (tr8_1 _ _) ?_ d:ℕk':ℕRk:ListBlank (Fin 2) := ListBlank.cons 0 (ones (k' + 1) B0)⊢ reachPos
{ state := 5, tape := mkL (ListBlank.cons 0 (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 1 (ones k' B0)) }
{ state := 9,
tape := mkL (ones 0 (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ListBlank.cons 1 (ones k' B0))) }
rw [← ones_succ k' B0, d:ℕk':ℕRk:ListBlank (Fin 2) := ListBlank.cons 0 (ones (k' + 1) B0)⊢ reachPos { state := 5, tape := mkL (ListBlank.cons 0 (ListBlank.cons 0 (ones (d + 1) B0))) (ones (k' + 1) B0) }
{ state := 9, tape := mkL (ones 0 (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (k' + 1) B0)) } ErdosTernary15.Tape.mkL_cons d:ℕk':ℕRk:ListBlank (Fin 2) := ListBlank.cons 0 (ones (k' + 1) B0)⊢ reachPos { state := 5, tape := { head := 0, left := ListBlank.cons 0 (ones (d + 1) B0), right := ones (k' + 1) B0 } }
{ state := 9, tape := mkL (ones 0 (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (k' + 1) B0)) }] d:ℕk':ℕRk:ListBlank (Fin 2) := ListBlank.cons 0 (ones (k' + 1) B0)⊢ reachPos { state := 5, tape := { head := 0, left := ListBlank.cons 0 (ones (d + 1) B0), right := ones (k' + 1) B0 } }
{ state := 9, tape := mkL (ones 0 (ListBlank.cons 0 (ones (d + 1) B0))) (ListBlank.cons 0 (ones (k' + 1) B0)) }
exact reachPos_step (tr5_0 _ _) All goals completed! 🐙private theorem odd_peel_to_13 (L r m : ℕ) :
reachPos (oddCfg (L + 2) r m)
⟨13, Tape.mk' (ones (r + 3) ((ones L B0).cons 0)) (ones m B0)⟩ := by L:ℕr:ℕm:ℕ⊢ reachPos (oddCfg (L + 2) r m)
{ state := 13, tape := Tape.mk' (ones (r + 3) (ListBlank.cons 0 (ones L B0))) (ones m B0) }
unfold oddCfg L:ℕr:ℕm:ℕ⊢ reachPos { state := 9, tape := mkL (ones r (ListBlank.cons 0 (ones (L + 2) B0))) (ListBlank.cons 0 (ones m B0)) }
{ state := 13, tape := Tape.mk' (ones (r + 3) (ListBlank.cons 0 (ones L B0))) (ones m B0) }
let LL2 := (ones (L + 2) B0).cons 0 L:ℕr:ℕm:ℕLL2:ListBlank (Fin 2) := ListBlank.cons 0 (ones (L + 2) B0)⊢ reachPos { state := 9, tape := mkL (ones r (ListBlank.cons 0 (ones (L + 2) B0))) (ListBlank.cons 0 (ones m B0)) }
{ state := 13, tape := Tape.mk' (ones (r + 3) (ListBlank.cons 0 (ones L B0))) (ones m B0) }
let Rm := (ones m B0).cons 0 L:ℕr:ℕm:ℕLL2:ListBlank (Fin 2) := ListBlank.cons 0 (ones (L + 2) B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 9, tape := mkL (ones r (ListBlank.cons 0 (ones (L + 2) B0))) (ListBlank.cons 0 (ones m B0)) }
{ state := 13, tape := Tape.mk' (ones (r + 3) (ListBlank.cons 0 (ones L B0))) (ones m B0) }
change reachPos ⟨9, mkL (ones r LL2) Rm⟩ _ L:ℕr:ℕm:ℕLL2:ListBlank (Fin 2) := ListBlank.cons 0 (ones (L + 2) B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 9, tape := mkL (ones r LL2) Rm }
{ state := 13, tape := Tape.mk' (ones (r + 3) (ListBlank.cons 0 (ones L B0))) (ones m B0) }
refine nSteps_then_reachPos (sweep1L tr9_1 r LL2 Rm) ?_ L:ℕr:ℕm:ℕLL2:ListBlank (Fin 2) := ListBlank.cons 0 (ones (L + 2) B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 9, tape := mkL LL2 (ones r Rm) }
{ state := 13, tape := Tape.mk' (ones (r + 3) (ListBlank.cons 0 (ones L B0))) (ones m B0) }
dsimp only [LL2] L:ℕr:ℕm:ℕLL2:ListBlank (Fin 2) := ListBlank.cons 0 (ones (L + 2) B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 9, tape := mkL (ListBlank.cons 0 (ones (L + 2) B0)) (ones r Rm) }
{ state := 13, tape := Tape.mk' (ones (r + 3) (ListBlank.cons 0 (ones L B0))) (ones m B0) }
rw [ErdosTernary15.Tape.mkL_cons L:ℕr:ℕm:ℕLL2:ListBlank (Fin 2) := ListBlank.cons 0 (ones (L + 2) B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 9, tape := { head := 0, left := ones (L + 2) B0, right := ones r Rm } }
{ state := 13, tape := Tape.mk' (ones (r + 3) (ListBlank.cons 0 (ones L B0))) (ones m B0) }] L:ℕr:ℕm:ℕLL2:ListBlank (Fin 2) := ListBlank.cons 0 (ones (L + 2) B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 9, tape := { head := 0, left := ones (L + 2) B0, right := ones r Rm } }
{ state := 13, tape := Tape.mk' (ones (r + 3) (ListBlank.cons 0 (ones L B0))) (ones m B0) }
refine step_then_reachPos (tr9_0 _ _) ?_ L:ℕr:ℕm:ℕLL2:ListBlank (Fin 2) := ListBlank.cons 0 (ones (L + 2) B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 10, tape := mkL (ones (L + 2) B0) (ListBlank.cons 1 (ones r Rm)) }
{ state := 13, tape := Tape.mk' (ones (r + 3) (ListBlank.cons 0 (ones L B0))) (ones m B0) }
rw [show L + 2 = (L + 1) + 1 by L:ℕr:ℕm:ℕ⊢ reachPos (oddCfg (L + 2) r m)
{ state := 13, tape := Tape.mk' (ones (r + 3) (ListBlank.cons 0 (ones L B0))) (ones m B0) } omega All goals completed! 🐙, ones_succ (L + 1) B0, L:ℕr:ℕm:ℕLL2:ListBlank (Fin 2) := ListBlank.cons 0 (ones (L + 2) B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 10, tape := mkL (ListBlank.cons 1 (ones (L + 1) B0)) (ListBlank.cons 1 (ones r Rm)) }
{ state := 13, tape := Tape.mk' (ones (r + 3) (ListBlank.cons 0 (ones L B0))) (ones m B0) } ErdosTernary15.Tape.mkL_cons, L:ℕr:ℕm:ℕLL2:ListBlank (Fin 2) := ListBlank.cons 0 (ones (L + 2) B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 10, tape := { head := 1, left := ones (L + 1) B0, right := ListBlank.cons 1 (ones r Rm) } }
{ state := 13, tape := Tape.mk' (ones (r + 3) (ListBlank.cons 0 (ones L B0))) (ones m B0) }
← ones_succ r Rm L:ℕr:ℕm:ℕLL2:ListBlank (Fin 2) := ListBlank.cons 0 (ones (L + 2) B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 10, tape := { head := 1, left := ones (L + 1) B0, right := ones (r + 1) Rm } }
{ state := 13, tape := Tape.mk' (ones (r + 3) (ListBlank.cons 0 (ones L B0))) (ones m B0) }] L:ℕr:ℕm:ℕLL2:ListBlank (Fin 2) := ListBlank.cons 0 (ones (L + 2) B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 10, tape := { head := 1, left := ones (L + 1) B0, right := ones (r + 1) Rm } }
{ state := 13, tape := Tape.mk' (ones (r + 3) (ListBlank.cons 0 (ones L B0))) (ones m B0) }
refine step_then_reachPos (tr10_1 _ _) ?_ L:ℕr:ℕm:ℕLL2:ListBlank (Fin 2) := ListBlank.cons 0 (ones (L + 2) B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 11, tape := mkL (ones (L + 1) B0) (ListBlank.cons 1 (ones (r + 1) Rm)) }
{ state := 13, tape := Tape.mk' (ones (r + 3) (ListBlank.cons 0 (ones L B0))) (ones m B0) }
rw [ones_succ L B0, L:ℕr:ℕm:ℕLL2:ListBlank (Fin 2) := ListBlank.cons 0 (ones (L + 2) B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 11, tape := mkL (ListBlank.cons 1 (ones L B0)) (ListBlank.cons 1 (ones (r + 1) Rm)) }
{ state := 13, tape := Tape.mk' (ones (r + 3) (ListBlank.cons 0 (ones L B0))) (ones m B0) } ErdosTernary15.Tape.mkL_cons, L:ℕr:ℕm:ℕLL2:ListBlank (Fin 2) := ListBlank.cons 0 (ones (L + 2) B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 11, tape := { head := 1, left := ones L B0, right := ListBlank.cons 1 (ones (r + 1) Rm) } }
{ state := 13, tape := Tape.mk' (ones (r + 3) (ListBlank.cons 0 (ones L B0))) (ones m B0) } ← ones_succ (r + 1) Rm L:ℕr:ℕm:ℕLL2:ListBlank (Fin 2) := ListBlank.cons 0 (ones (L + 2) B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 11, tape := { head := 1, left := ones L B0, right := ones (r + 1 + 1) Rm } }
{ state := 13, tape := Tape.mk' (ones (r + 3) (ListBlank.cons 0 (ones L B0))) (ones m B0) }] L:ℕr:ℕm:ℕLL2:ListBlank (Fin 2) := ListBlank.cons 0 (ones (L + 2) B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 11, tape := { head := 1, left := ones L B0, right := ones (r + 1 + 1) Rm } }
{ state := 13, tape := Tape.mk' (ones (r + 3) (ListBlank.cons 0 (ones L B0))) (ones m B0) }
refine step_then_reachPos (tr11_1 _ _) ?_ L:ℕr:ℕm:ℕLL2:ListBlank (Fin 2) := ListBlank.cons 0 (ones (L + 2) B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 12, tape := Tape.mk' (ListBlank.cons 0 (ones L B0)) (ones (r + 1 + 1) Rm) }
{ state := 13, tape := Tape.mk' (ones (r + 3) (ListBlank.cons 0 (ones L B0))) (ones m B0) }
let LL := (ones L B0).cons 0 L:ℕr:ℕm:ℕLL2:ListBlank (Fin 2) := ListBlank.cons 0 (ones (L + 2) B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)LL:ListBlank (Fin 2) := ListBlank.cons 0 (ones L B0)⊢ reachPos { state := 12, tape := Tape.mk' (ListBlank.cons 0 (ones L B0)) (ones (r + 1 + 1) Rm) }
{ state := 13, tape := Tape.mk' (ones (r + 3) (ListBlank.cons 0 (ones L B0))) (ones m B0) }
change reachPos ⟨12, Tape.mk' LL (ones (r + 2) Rm)⟩ _ L:ℕr:ℕm:ℕLL2:ListBlank (Fin 2) := ListBlank.cons 0 (ones (L + 2) B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)LL:ListBlank (Fin 2) := ListBlank.cons 0 (ones L B0)⊢ reachPos { state := 12, tape := Tape.mk' LL (ones (r + 2) Rm) }
{ state := 13, tape := Tape.mk' (ones (r + 3) (ListBlank.cons 0 (ones L B0))) (ones m B0) }
refine nSteps_then_reachPos (sweep1R tr12_1 (r + 2) LL Rm) ?_ L:ℕr:ℕm:ℕLL2:ListBlank (Fin 2) := ListBlank.cons 0 (ones (L + 2) B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)LL:ListBlank (Fin 2) := ListBlank.cons 0 (ones L B0)⊢ reachPos { state := 12, tape := Tape.mk' (ones (r + 2) LL) Rm }
{ state := 13, tape := Tape.mk' (ones (r + 3) (ListBlank.cons 0 (ones L B0))) (ones m B0) }
dsimp only [Rm] L:ℕr:ℕm:ℕLL2:ListBlank (Fin 2) := ListBlank.cons 0 (ones (L + 2) B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)LL:ListBlank (Fin 2) := ListBlank.cons 0 (ones L B0)⊢ reachPos { state := 12, tape := Tape.mk' (ones (r + 2) LL) (ListBlank.cons 0 (ones m B0)) }
{ state := 13, tape := Tape.mk' (ones (r + 3) (ListBlank.cons 0 (ones L B0))) (ones m B0) }
rw [ErdosTernary15.Tape.mk'_cons L:ℕr:ℕm:ℕLL2:ListBlank (Fin 2) := ListBlank.cons 0 (ones (L + 2) B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)LL:ListBlank (Fin 2) := ListBlank.cons 0 (ones L B0)⊢ reachPos { state := 12, tape := { head := 0, left := ones (r + 2) LL, right := ones m B0 } }
{ state := 13, tape := Tape.mk' (ones (r + 3) (ListBlank.cons 0 (ones L B0))) (ones m B0) }] L:ℕr:ℕm:ℕLL2:ListBlank (Fin 2) := ListBlank.cons 0 (ones (L + 2) B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)LL:ListBlank (Fin 2) := ListBlank.cons 0 (ones L B0)⊢ reachPos { state := 12, tape := { head := 0, left := ones (r + 2) LL, right := ones m B0 } }
{ state := 13, tape := Tape.mk' (ones (r + 3) (ListBlank.cons 0 (ones L B0))) (ones m B0) }
have h12 := tr12_0 (ones (r + 2) LL) (ones m B0) L:ℕr:ℕm:ℕLL2:ListBlank (Fin 2) := ListBlank.cons 0 (ones (L + 2) B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)LL:ListBlank (Fin 2) := ListBlank.cons 0 (ones L B0)h12:step weakCollatz16 { state := 12, tape := { head := 0, left := ones (r + 2) LL, right := ones m B0 } } =
some { state := 13, tape := Tape.mk' (ListBlank.cons 1 (ones (r + 2) LL)) (ones m B0) }⊢ reachPos { state := 12, tape := { head := 0, left := ones (r + 2) LL, right := ones m B0 } }
{ state := 13, tape := Tape.mk' (ones (r + 3) (ListBlank.cons 0 (ones L B0))) (ones m B0) }
rw [← ones_succ (r + 2) LL L:ℕr:ℕm:ℕLL2:ListBlank (Fin 2) := ListBlank.cons 0 (ones (L + 2) B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)LL:ListBlank (Fin 2) := ListBlank.cons 0 (ones L B0)h12:step weakCollatz16 { state := 12, tape := { head := 0, left := ones (r + 2) LL, right := ones m B0 } } =
some { state := 13, tape := Tape.mk' (ones (r + 2 + 1) LL) (ones m B0) }⊢ reachPos { state := 12, tape := { head := 0, left := ones (r + 2) LL, right := ones m B0 } }
{ state := 13, tape := Tape.mk' (ones (r + 3) (ListBlank.cons 0 (ones L B0))) (ones m B0) }] at h12 L:ℕr:ℕm:ℕLL2:ListBlank (Fin 2) := ListBlank.cons 0 (ones (L + 2) B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)LL:ListBlank (Fin 2) := ListBlank.cons 0 (ones L B0)h12:step weakCollatz16 { state := 12, tape := { head := 0, left := ones (r + 2) LL, right := ones m B0 } } =
some { state := 13, tape := Tape.mk' (ones (r + 2 + 1) LL) (ones m B0) }⊢ reachPos { state := 12, tape := { head := 0, left := ones (r + 2) LL, right := ones m B0 } }
{ state := 13, tape := Tape.mk' (ones (r + 3) (ListBlank.cons 0 (ones L B0))) (ones m B0) }
exact reachPos_step h12 All goals completed! 🐙private theorem odd_pass (L r m : ℕ) :
reachPos (oddCfg (L + 2) r (m + 1)) (oddCfg L (r + 3) m) := by L:ℕr:ℕm:ℕ⊢ reachPos (oddCfg (L + 2) r (m + 1)) (oddCfg L (r + 3) m)
refine reachPos_trans (odd_peel_to_13 L r (m + 1)) ?_ L:ℕr:ℕm:ℕ⊢ reachPos { state := 13, tape := Tape.mk' (ones (r + 3) (ListBlank.cons 0 (ones L B0))) (ones (m + 1) B0) }
(oddCfg L (r + 3) m)
rw [ones_succ m B0, L:ℕr:ℕm:ℕ⊢ reachPos { state := 13, tape := Tape.mk' (ones (r + 3) (ListBlank.cons 0 (ones L B0))) (ListBlank.cons 1 (ones m B0)) }
(oddCfg L (r + 3) m) ErdosTernary15.Tape.mk'_cons L:ℕr:ℕm:ℕ⊢ reachPos { state := 13, tape := { head := 1, left := ones (r + 3) (ListBlank.cons 0 (ones L B0)), right := ones m B0 } }
(oddCfg L (r + 3) m)] L:ℕr:ℕm:ℕ⊢ reachPos { state := 13, tape := { head := 1, left := ones (r + 3) (ListBlank.cons 0 (ones L B0)), right := ones m B0 } }
(oddCfg L (r + 3) m)
exact reachPos_step (tr13_1 _ _) All goals completed! 🐙private theorem odd_many (L r m j : ℕ) :
∃ s : ℕ, nSteps weakCollatz16 s (oddCfg (L + 2 * j) r (m + j)) =
some (oddCfg L (r + 3 * j) m) := by L:ℕr:ℕm:ℕj:ℕ⊢ ∃ s, nSteps weakCollatz16 s (oddCfg (L + 2 * j) r (m + j)) = some (oddCfg L (r + 3 * j) m)
induction j generalizing L r with
| zero => zero m:ℕL:ℕr:ℕ⊢ ∃ s, nSteps weakCollatz16 s (oddCfg (L + 2 * 0) r (m + 0)) = some (oddCfg L (r + 3 * 0) m)
simp only [Nat.mul_zero, Nat.add_zero] zero m:ℕL:ℕr:ℕ⊢ ∃ s, nSteps weakCollatz16 s (oddCfg L r m) = some (oddCfg L r m)
exact ⟨0, rfl⟩ All goals completed! 🐙
| succ j ih => succ m:ℕj:ℕih:∀ (L r : ℕ), ∃ s, nSteps weakCollatz16 s (oddCfg (L + 2 * j) r (m + j)) = some (oddCfg L (r + 3 * j) m)L:ℕr:ℕ⊢ ∃ s, nSteps weakCollatz16 s (oddCfg (L + 2 * (j + 1)) r (m + (j + 1))) = some (oddCfg L (r + 3 * (j + 1)) m)
rw [show L + 2 * (j + 1) = (L + 2 * j) + 2 by L:ℕr:ℕm:ℕj:ℕ⊢ ∃ s, nSteps weakCollatz16 s (oddCfg (L + 2 * j) r (m + j)) = some (oddCfg L (r + 3 * j) m) omega All goals completed! 🐙,
show m + (j + 1) = (m + j) + 1 by L:ℕr:ℕm:ℕj:ℕ⊢ ∃ s, nSteps weakCollatz16 s (oddCfg (L + 2 * j) r (m + j)) = some (oddCfg L (r + 3 * j) m) omega All goals completed! 🐙] succ m:ℕj:ℕih:∀ (L r : ℕ), ∃ s, nSteps weakCollatz16 s (oddCfg (L + 2 * j) r (m + j)) = some (oddCfg L (r + 3 * j) m)L:ℕr:ℕ⊢ ∃ s, nSteps weakCollatz16 s (oddCfg (L + 2 * j + 2) r (m + j + 1)) = some (oddCfg L (r + 3 * (j + 1)) m)
obtain ⟨s₁, _, hs₁⟩ := odd_pass (L + 2 * j) r (m + j) succ m:ℕj:ℕih:∀ (L r : ℕ), ∃ s, nSteps weakCollatz16 s (oddCfg (L + 2 * j) r (m + j)) = some (oddCfg L (r + 3 * j) m)L:ℕr:ℕs₁:ℕleft✝:1 ≤ s₁hs₁:nSteps weakCollatz16 s₁ (oddCfg (L + 2 * j + 2) r (m + j + 1)) = some (oddCfg (L + 2 * j) (r + 3) (m + j))⊢ ∃ s, nSteps weakCollatz16 s (oddCfg (L + 2 * j + 2) r (m + j + 1)) = some (oddCfg L (r + 3 * (j + 1)) m)
obtain ⟨s₂, hs₂⟩ := ih L (r + 3) succ m:ℕj:ℕih:∀ (L r : ℕ), ∃ s, nSteps weakCollatz16 s (oddCfg (L + 2 * j) r (m + j)) = some (oddCfg L (r + 3 * j) m)L:ℕr:ℕs₁:ℕleft✝:1 ≤ s₁hs₁:nSteps weakCollatz16 s₁ (oddCfg (L + 2 * j + 2) r (m + j + 1)) = some (oddCfg (L + 2 * j) (r + 3) (m + j))s₂:ℕhs₂:nSteps weakCollatz16 s₂ (oddCfg (L + 2 * j) (r + 3) (m + j)) = some (oddCfg L (r + 3 + 3 * j) m)⊢ ∃ s, nSteps weakCollatz16 s (oddCfg (L + 2 * j + 2) r (m + j + 1)) = some (oddCfg L (r + 3 * (j + 1)) m)
rw [show r + 3 + 3 * j = r + 3 * (j + 1) by L:ℕr:ℕm:ℕj:ℕ⊢ ∃ s, nSteps weakCollatz16 s (oddCfg (L + 2 * j) r (m + j)) = some (oddCfg L (r + 3 * j) m) omega All goals completed! 🐙] at hs₂ succ m:ℕj:ℕih:∀ (L r : ℕ), ∃ s, nSteps weakCollatz16 s (oddCfg (L + 2 * j) r (m + j)) = some (oddCfg L (r + 3 * j) m)L:ℕr:ℕs₁:ℕleft✝:1 ≤ s₁hs₁:nSteps weakCollatz16 s₁ (oddCfg (L + 2 * j + 2) r (m + j + 1)) = some (oddCfg (L + 2 * j) (r + 3) (m + j))s₂:ℕhs₂:nSteps weakCollatz16 s₂ (oddCfg (L + 2 * j) (r + 3) (m + j)) = some (oddCfg L (r + 3 * (j + 1)) m)⊢ ∃ s, nSteps weakCollatz16 s (oddCfg (L + 2 * j + 2) r (m + j + 1)) = some (oddCfg L (r + 3 * (j + 1)) m)
exact ⟨s₁ + s₂, nSteps_bind_eq hs₁ hs₂⟩ All goals completed! 🐙private theorem odd_done_to_15 (L r : ℕ) :
reachPos (oddCfg (L + 2) r 0) ⟨15, mkL (ones L B0) ((ones (r + 2) B0).cons 0)⟩ := by L:ℕr:ℕ⊢ reachPos (oddCfg (L + 2) r 0) { state := 15, tape := mkL (ones L B0) (ListBlank.cons 0 (ones (r + 2) B0)) }
refine reachPos_trans (odd_peel_to_13 L r 0) ?_ L:ℕr:ℕ⊢ reachPos { state := 13, tape := Tape.mk' (ones (r + 3) (ListBlank.cons 0 (ones L B0))) (ones 0 B0) }
{ state := 15, tape := mkL (ones L B0) (ListBlank.cons 0 (ones (r + 2) B0)) }
rw [ones_zero, L:ℕr:ℕ⊢ reachPos { state := 13, tape := Tape.mk' (ones (r + 3) (ListBlank.cons 0 (ones L B0))) B0 }
{ state := 15, tape := mkL (ones L B0) (ListBlank.cons 0 (ones (r + 2) B0)) } ErdosTernary15.Tape.mk'_B0 L:ℕr:ℕ⊢ reachPos { state := 13, tape := { head := 0, left := ones (r + 3) (ListBlank.cons 0 (ones L B0)), right := B0 } }
{ state := 15, tape := mkL (ones L B0) (ListBlank.cons 0 (ones (r + 2) B0)) }] L:ℕr:ℕ⊢ reachPos { state := 13, tape := { head := 0, left := ones (r + 3) (ListBlank.cons 0 (ones L B0)), right := B0 } }
{ state := 15, tape := mkL (ones L B0) (ListBlank.cons 0 (ones (r + 2) B0)) }
refine step_then_reachPos (tr13_0 _ _) ?_ L:ℕr:ℕ⊢ reachPos { state := 5, tape := mkL (ones (r + 3) (ListBlank.cons 0 (ones L B0))) (ListBlank.cons 0 B0) }
{ state := 15, tape := mkL (ones L B0) (ListBlank.cons 0 (ones (r + 2) B0)) }
let LL := (ones L B0).cons 0 L:ℕr:ℕLL:ListBlank (Fin 2) := ListBlank.cons 0 (ones L B0)⊢ reachPos { state := 5, tape := mkL (ones (r + 3) (ListBlank.cons 0 (ones L B0))) (ListBlank.cons 0 B0) }
{ state := 15, tape := mkL (ones L B0) (ListBlank.cons 0 (ones (r + 2) B0)) }
rw [B0_cons_zero, L:ℕr:ℕLL:ListBlank (Fin 2) := ListBlank.cons 0 (ones L B0)⊢ reachPos { state := 5, tape := mkL (ones (r + 3) (ListBlank.cons 0 (ones L B0))) B0 }
{ state := 15, tape := mkL (ones L B0) (ListBlank.cons 0 (ones (r + 2) B0)) } show r + 3 = (r + 2) + 1 by L:ℕr:ℕ⊢ reachPos (oddCfg (L + 2) r 0) { state := 15, tape := mkL (ones L B0) (ListBlank.cons 0 (ones (r + 2) B0)) } omega All goals completed! 🐙, ones_succ (r + 2) LL, L:ℕr:ℕLL:ListBlank (Fin 2) := ListBlank.cons 0 (ones L B0)⊢ reachPos { state := 5, tape := mkL (ListBlank.cons 1 (ones (r + 2) LL)) B0 }
{ state := 15, tape := mkL (ones L B0) (ListBlank.cons 0 (ones (r + 2) B0)) }
ErdosTernary15.Tape.mkL_cons L:ℕr:ℕLL:ListBlank (Fin 2) := ListBlank.cons 0 (ones L B0)⊢ reachPos { state := 5, tape := { head := 1, left := ones (r + 2) LL, right := B0 } }
{ state := 15, tape := mkL (ones L B0) (ListBlank.cons 0 (ones (r + 2) B0)) }] L:ℕr:ℕLL:ListBlank (Fin 2) := ListBlank.cons 0 (ones L B0)⊢ reachPos { state := 5, tape := { head := 1, left := ones (r + 2) LL, right := B0 } }
{ state := 15, tape := mkL (ones L B0) (ListBlank.cons 0 (ones (r + 2) B0)) }
refine step_then_reachPos (tr5_1 _ _) ?_ L:ℕr:ℕLL:ListBlank (Fin 2) := ListBlank.cons 0 (ones L B0)⊢ reachPos { state := 6, tape := mkL (ones (r + 2) LL) (ListBlank.cons 0 B0) }
{ state := 15, tape := mkL (ones L B0) (ListBlank.cons 0 (ones (r + 2) B0)) }
rw [B0_cons_zero, L:ℕr:ℕLL:ListBlank (Fin 2) := ListBlank.cons 0 (ones L B0)⊢ reachPos { state := 6, tape := mkL (ones (r + 2) LL) B0 }
{ state := 15, tape := mkL (ones L B0) (ListBlank.cons 0 (ones (r + 2) B0)) } show r + 2 = (r + 1) + 1 by L:ℕr:ℕ⊢ reachPos (oddCfg (L + 2) r 0) { state := 15, tape := mkL (ones L B0) (ListBlank.cons 0 (ones (r + 2) B0)) } omega All goals completed! 🐙, ones_succ (r + 1) LL, L:ℕr:ℕLL:ListBlank (Fin 2) := ListBlank.cons 0 (ones L B0)⊢ reachPos { state := 6, tape := mkL (ListBlank.cons 1 (ones (r + 1) LL)) B0 }
{ state := 15, tape := mkL (ones L B0) (ListBlank.cons 0 (ones (r + 1 + 1) B0)) }
ErdosTernary15.Tape.mkL_cons L:ℕr:ℕLL:ListBlank (Fin 2) := ListBlank.cons 0 (ones L B0)⊢ reachPos { state := 6, tape := { head := 1, left := ones (r + 1) LL, right := B0 } }
{ state := 15, tape := mkL (ones L B0) (ListBlank.cons 0 (ones (r + 1 + 1) B0)) }] L:ℕr:ℕLL:ListBlank (Fin 2) := ListBlank.cons 0 (ones L B0)⊢ reachPos { state := 6, tape := { head := 1, left := ones (r + 1) LL, right := B0 } }
{ state := 15, tape := mkL (ones L B0) (ListBlank.cons 0 (ones (r + 1 + 1) B0)) }
exact eback_to_haltchk (ones L B0) (r + 1) All goals completed! 🐙private theorem odd_done_lt (d' r : ℕ) :
reachPos (oddCfg (d' + 3) r 0) (roundCfg (d' + 1) (r + 2)) := by d':ℕr:ℕ⊢ reachPos (oddCfg (d' + 3) r 0) (roundCfg (d' + 1) (r + 2))
rw [show d' + 3 = (d' + 1) + 2 by d':ℕr:ℕ⊢ reachPos (oddCfg (d' + 3) r 0) (roundCfg (d' + 1) (r + 2)) omega All goals completed! 🐙] d':ℕr:ℕ⊢ reachPos (oddCfg (d' + 1 + 2) r 0) (roundCfg (d' + 1) (r + 2))
refine reachPos_trans (odd_done_to_15 (d' + 1) r) ?_ d':ℕr:ℕ⊢ reachPos { state := 15, tape := mkL (ones (d' + 1) B0) (ListBlank.cons 0 (ones (r + 2) B0)) }
(roundCfg (d' + 1) (r + 2))
rw [ones_succ d' B0, d':ℕr:ℕ⊢ reachPos { state := 15, tape := mkL (ListBlank.cons 1 (ones d' B0)) (ListBlank.cons 0 (ones (r + 2) B0)) }
(roundCfg (d' + 1) (r + 2)) ErdosTernary15.Tape.mkL_cons d':ℕr:ℕ⊢ reachPos { state := 15, tape := { head := 1, left := ones d' B0, right := ListBlank.cons 0 (ones (r + 2) B0) } }
(roundCfg (d' + 1) (r + 2))] d':ℕr:ℕ⊢ reachPos { state := 15, tape := { head := 1, left := ones d' B0, right := ListBlank.cons 0 (ones (r + 2) B0) } }
(roundCfg (d' + 1) (r + 2))
have h15 := tr15_1 (ones d' B0) ((ones (r + 2) B0).cons 0) d':ℕr:ℕh15:step weakCollatz16
{ state := 15, tape := { head := 1, left := ones d' B0, right := ListBlank.cons 0 (ones (r + 2) B0) } } =
some { state := 1, tape := Tape.mk' (ListBlank.cons 1 (ones d' B0)) (ListBlank.cons 0 (ones (r + 2) B0)) }⊢ reachPos { state := 15, tape := { head := 1, left := ones d' B0, right := ListBlank.cons 0 (ones (r + 2) B0) } }
(roundCfg (d' + 1) (r + 2))
rw [← ones_succ d' B0, d':ℕr:ℕh15:step weakCollatz16
{ state := 15, tape := { head := 1, left := ones d' B0, right := ListBlank.cons 0 (ones (r + 2) B0) } } =
some { state := 1, tape := Tape.mk' (ones (d' + 1) B0) (ListBlank.cons 0 (ones (r + 2) B0)) }⊢ reachPos { state := 15, tape := { head := 1, left := ones d' B0, right := ListBlank.cons 0 (ones (r + 2) B0) } }
(roundCfg (d' + 1) (r + 2)) ErdosTernary15.Tape.mk'_cons d':ℕr:ℕh15:step weakCollatz16
{ state := 15, tape := { head := 1, left := ones d' B0, right := ListBlank.cons 0 (ones (r + 2) B0) } } =
some { state := 1, tape := { head := 0, left := ones (d' + 1) B0, right := ones (r + 2) B0 } }⊢ reachPos { state := 15, tape := { head := 1, left := ones d' B0, right := ListBlank.cons 0 (ones (r + 2) B0) } }
(roundCfg (d' + 1) (r + 2))] at h15 d':ℕr:ℕh15:step weakCollatz16
{ state := 15, tape := { head := 1, left := ones d' B0, right := ListBlank.cons 0 (ones (r + 2) B0) } } =
some { state := 1, tape := { head := 0, left := ones (d' + 1) B0, right := ones (r + 2) B0 } }⊢ reachPos { state := 15, tape := { head := 1, left := ones d' B0, right := ListBlank.cons 0 (ones (r + 2) B0) } }
(roundCfg (d' + 1) (r + 2))
exact reachPos_step h15 All goals completed! 🐙private theorem odd_done_halt (r : ℕ) :
∃ s cfg, nSteps weakCollatz16 s (oddCfg 2 r 0) = some cfg ∧
step weakCollatz16 cfg = none := by r:ℕ⊢ ∃ s cfg, nSteps weakCollatz16 s (oddCfg 2 r 0) = some cfg ∧ step weakCollatz16 cfg = none
obtain ⟨s, _, hs⟩ := odd_done_to_15 0 r r:ℕs:ℕleft✝:1 ≤ shs:nSteps weakCollatz16 s (oddCfg (0 + 2) r 0) =
some { state := 15, tape := mkL (ones 0 B0) (ListBlank.cons 0 (ones (r + 2) B0)) }⊢ ∃ s cfg, nSteps weakCollatz16 s (oddCfg 2 r 0) = some cfg ∧ step weakCollatz16 cfg = none
rw [ones_zero, r:ℕs:ℕleft✝:1 ≤ shs:nSteps weakCollatz16 s (oddCfg (0 + 2) r 0) = some { state := 15, tape := mkL B0 (ListBlank.cons 0 (ones (r + 2) B0)) }⊢ ∃ s cfg, nSteps weakCollatz16 s (oddCfg 2 r 0) = some cfg ∧ step weakCollatz16 cfg = none mkL_B0 r:ℕs:ℕleft✝:1 ≤ shs:nSteps weakCollatz16 s (oddCfg (0 + 2) r 0) =
some { state := 15, tape := { head := 0, left := B0, right := ListBlank.cons 0 (ones (r + 2) B0) } }⊢ ∃ s cfg, nSteps weakCollatz16 s (oddCfg 2 r 0) = some cfg ∧ step weakCollatz16 cfg = none] at hs r:ℕs:ℕleft✝:1 ≤ shs:nSteps weakCollatz16 s (oddCfg (0 + 2) r 0) =
some { state := 15, tape := { head := 0, left := B0, right := ListBlank.cons 0 (ones (r + 2) B0) } }⊢ ∃ s cfg, nSteps weakCollatz16 s (oddCfg 2 r 0) = some cfg ∧ step weakCollatz16 cfg = none
exact ⟨s, _, hs, tr15_0 B0 ((ones (r + 2) B0).cons 0)⟩ All goals completed! 🐙private theorem odd_abort_L0 (r m : ℕ) :
reachPos (oddCfg 0 r m) (stageCfg (r + m + 2)) := by r:ℕm:ℕ⊢ reachPos (oddCfg 0 r m) (stageCfg (r + m + 2))
unfold oddCfg r:ℕm:ℕ⊢ reachPos { state := 9, tape := mkL (ones r (ListBlank.cons 0 (ones 0 B0))) (ListBlank.cons 0 (ones m B0)) }
(stageCfg (r + m + 2))
rw [ones_zero, r:ℕm:ℕ⊢ reachPos { state := 9, tape := mkL (ones r (ListBlank.cons 0 B0)) (ListBlank.cons 0 (ones m B0)) }
(stageCfg (r + m + 2)) B0_cons_zero r:ℕm:ℕ⊢ reachPos { state := 9, tape := mkL (ones r B0) (ListBlank.cons 0 (ones m B0)) } (stageCfg (r + m + 2))] r:ℕm:ℕ⊢ reachPos { state := 9, tape := mkL (ones r B0) (ListBlank.cons 0 (ones m B0)) } (stageCfg (r + m + 2))
let Rm := (ones m B0).cons 0 r:ℕm:ℕRm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 9, tape := mkL (ones r B0) (ListBlank.cons 0 (ones m B0)) } (stageCfg (r + m + 2))
change reachPos ⟨9, mkL (ones r B0) Rm⟩ _ r:ℕm:ℕRm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 9, tape := mkL (ones r B0) Rm } (stageCfg (r + m + 2))
refine nSteps_then_reachPos (sweep1L tr9_1 r B0 Rm) ?_ r:ℕm:ℕRm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 9, tape := mkL B0 (ones r Rm) } (stageCfg (r + m + 2))
rw [mkL_B0 r:ℕm:ℕRm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 9, tape := { head := 0, left := B0, right := ones r Rm } } (stageCfg (r + m + 2))] r:ℕm:ℕRm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 9, tape := { head := 0, left := B0, right := ones r Rm } } (stageCfg (r + m + 2))
refine step_then_reachPos (tr9_0 _ _) ?_ r:ℕm:ℕRm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 10, tape := mkL B0 (ListBlank.cons 1 (ones r Rm)) } (stageCfg (r + m + 2))
rw [mkL_B0, r:ℕm:ℕRm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 10, tape := { head := 0, left := B0, right := ListBlank.cons 1 (ones r Rm) } }
(stageCfg (r + m + 2)) ← ones_succ r Rm r:ℕm:ℕRm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 10, tape := { head := 0, left := B0, right := ones (r + 1) Rm } } (stageCfg (r + m + 2))] r:ℕm:ℕRm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 10, tape := { head := 0, left := B0, right := ones (r + 1) Rm } } (stageCfg (r + m + 2))
refine step_then_reachPos (tr10_0 _ _) ?_ r:ℕm:ℕRm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 3, tape := Tape.mk' (ListBlank.cons 0 B0) (ones (r + 1) Rm) } (stageCfg (r + m + 2))
rw [B0_cons_zero, r:ℕm:ℕRm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 3, tape := Tape.mk' B0 (ones (r + 1) Rm) } (stageCfg (r + m + 2)) show r + m + 2 = (r + 1) + m + 1 by r:ℕm:ℕ⊢ reachPos (oddCfg 0 r m) (stageCfg (r + m + 2)) omega All goals completed! 🐙] r:ℕm:ℕRm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 3, tape := Tape.mk' B0 (ones (r + 1) Rm) } (stageCfg (r + 1 + m + 1))
exact gt_merge (r + 1) m All goals completed! 🐙private theorem odd_abort_L1 (r m : ℕ) :
reachPos (oddCfg 1 r m) (stageCfg (1 + r + m + 2)) := by r:ℕm:ℕ⊢ reachPos (oddCfg 1 r m) (stageCfg (1 + r + m + 2))
unfold oddCfg r:ℕm:ℕ⊢ reachPos { state := 9, tape := mkL (ones r (ListBlank.cons 0 (ones 1 B0))) (ListBlank.cons 0 (ones m B0)) }
(stageCfg (1 + r + m + 2))
let L1 := (ones 1 B0).cons 0 r:ℕm:ℕL1:ListBlank (Fin 2) := ListBlank.cons 0 (ones 1 B0)⊢ reachPos { state := 9, tape := mkL (ones r (ListBlank.cons 0 (ones 1 B0))) (ListBlank.cons 0 (ones m B0)) }
(stageCfg (1 + r + m + 2))
let Rm := (ones m B0).cons 0 r:ℕm:ℕL1:ListBlank (Fin 2) := ListBlank.cons 0 (ones 1 B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 9, tape := mkL (ones r (ListBlank.cons 0 (ones 1 B0))) (ListBlank.cons 0 (ones m B0)) }
(stageCfg (1 + r + m + 2))
change reachPos ⟨9, mkL (ones r L1) Rm⟩ _ r:ℕm:ℕL1:ListBlank (Fin 2) := ListBlank.cons 0 (ones 1 B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 9, tape := mkL (ones r L1) Rm } (stageCfg (1 + r + m + 2))
refine nSteps_then_reachPos (sweep1L tr9_1 r L1 Rm) ?_ r:ℕm:ℕL1:ListBlank (Fin 2) := ListBlank.cons 0 (ones 1 B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 9, tape := mkL L1 (ones r Rm) } (stageCfg (1 + r + m + 2))
dsimp only [L1] r:ℕm:ℕL1:ListBlank (Fin 2) := ListBlank.cons 0 (ones 1 B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 9, tape := mkL (ListBlank.cons 0 (ones 1 B0)) (ones r Rm) } (stageCfg (1 + r + m + 2))
rw [ErdosTernary15.Tape.mkL_cons r:ℕm:ℕL1:ListBlank (Fin 2) := ListBlank.cons 0 (ones 1 B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 9, tape := { head := 0, left := ones 1 B0, right := ones r Rm } } (stageCfg (1 + r + m + 2))] r:ℕm:ℕL1:ListBlank (Fin 2) := ListBlank.cons 0 (ones 1 B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 9, tape := { head := 0, left := ones 1 B0, right := ones r Rm } } (stageCfg (1 + r + m + 2))
refine step_then_reachPos (tr9_0 _ _) ?_ r:ℕm:ℕL1:ListBlank (Fin 2) := ListBlank.cons 0 (ones 1 B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 10, tape := mkL (ones 1 B0) (ListBlank.cons 1 (ones r Rm)) } (stageCfg (1 + r + m + 2))
rw [ones_succ 0 B0, r:ℕm:ℕL1:ListBlank (Fin 2) := ListBlank.cons 0 (ones 1 B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 10, tape := mkL (ListBlank.cons 1 (ones 0 B0)) (ListBlank.cons 1 (ones r Rm)) }
(stageCfg (1 + r + m + 2)) ones_zero, r:ℕm:ℕL1:ListBlank (Fin 2) := ListBlank.cons 0 (ones 1 B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 10, tape := mkL (ListBlank.cons 1 B0) (ListBlank.cons 1 (ones r Rm)) } (stageCfg (1 + r + m + 2)) ErdosTernary15.Tape.mkL_cons, r:ℕm:ℕL1:ListBlank (Fin 2) := ListBlank.cons 0 (ones 1 B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 10, tape := { head := 1, left := B0, right := ListBlank.cons 1 (ones r Rm) } }
(stageCfg (1 + r + m + 2)) ← ones_succ r Rm r:ℕm:ℕL1:ListBlank (Fin 2) := ListBlank.cons 0 (ones 1 B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 10, tape := { head := 1, left := B0, right := ones (r + 1) Rm } } (stageCfg (1 + r + m + 2))] r:ℕm:ℕL1:ListBlank (Fin 2) := ListBlank.cons 0 (ones 1 B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 10, tape := { head := 1, left := B0, right := ones (r + 1) Rm } } (stageCfg (1 + r + m + 2))
refine step_then_reachPos (tr10_1 _ _) ?_ r:ℕm:ℕL1:ListBlank (Fin 2) := ListBlank.cons 0 (ones 1 B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 11, tape := mkL B0 (ListBlank.cons 1 (ones (r + 1) Rm)) } (stageCfg (1 + r + m + 2))
rw [mkL_B0, r:ℕm:ℕL1:ListBlank (Fin 2) := ListBlank.cons 0 (ones 1 B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 11, tape := { head := 0, left := B0, right := ListBlank.cons 1 (ones (r + 1) Rm) } }
(stageCfg (1 + r + m + 2)) ← ones_succ (r + 1) Rm r:ℕm:ℕL1:ListBlank (Fin 2) := ListBlank.cons 0 (ones 1 B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 11, tape := { head := 0, left := B0, right := ones (r + 1 + 1) Rm } } (stageCfg (1 + r + m + 2))] r:ℕm:ℕL1:ListBlank (Fin 2) := ListBlank.cons 0 (ones 1 B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 11, tape := { head := 0, left := B0, right := ones (r + 1 + 1) Rm } } (stageCfg (1 + r + m + 2))
refine step_then_reachPos (tr11_0 _ _) ?_ r:ℕm:ℕL1:ListBlank (Fin 2) := ListBlank.cons 0 (ones 1 B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 3, tape := Tape.mk' (ListBlank.cons 0 B0) (ones (r + 1 + 1) Rm) } (stageCfg (1 + r + m + 2))
rw [B0_cons_zero, r:ℕm:ℕL1:ListBlank (Fin 2) := ListBlank.cons 0 (ones 1 B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 3, tape := Tape.mk' B0 (ones (r + 1 + 1) Rm) } (stageCfg (1 + r + m + 2)) show 1 + r + m + 2 = (r + 2) + m + 1 by r:ℕm:ℕ⊢ reachPos (oddCfg 1 r m) (stageCfg (1 + r + m + 2)) omega All goals completed! 🐙] r:ℕm:ℕL1:ListBlank (Fin 2) := ListBlank.cons 0 (ones 1 B0)Rm:ListBlank (Fin 2) := ListBlank.cons 0 (ones m B0)⊢ reachPos { state := 3, tape := Tape.mk' B0 (ones (r + 1 + 1) Rm) } (stageCfg (r + 2 + m + 1))
exact gt_merge (r + 2) m All goals completed! 🐙
Round Dispatch (z < x, z > x, z = x, y = 1) & Blank-Tape Boot
private theorem round_to_odd (d k : ℕ) (hk : 1 ≤ k) :
reachPos (roundCfg d (2 * k + 1)) (oddCfg (d + k + 1) 0 k) := by d:ℕk:ℕhk:1 ≤ k⊢ reachPos (roundCfg d (2 * k + 1)) (oddCfg (d + k + 1) 0 k)
rw [roundCfg_eq_sqzCfg, d:ℕk:ℕhk:1 ≤ k⊢ reachPos (sqzCfg d (2 * k + 1) 0) (oddCfg (d + k + 1) 0 k) show 2 * k + 1 = (0 + 1) + 2 * k by d:ℕk:ℕhk:1 ≤ k⊢ reachPos (roundCfg d (2 * k + 1)) (oddCfg (d + k + 1) 0 k) omega All goals completed! 🐙] d:ℕk:ℕhk:1 ≤ k⊢ reachPos (sqzCfg d (0 + 1 + 2 * k) 0) (oddCfg (d + k + 1) 0 k)
obtain ⟨s, hs⟩ := sqz_many d 0 0 k d:ℕk:ℕhk:1 ≤ ks:ℕhs:nSteps weakCollatz16 s (sqzCfg d (0 + 1 + 2 * k) 0) = some (sqzCfg (d + k) (0 + 1) (0 + k))⊢ reachPos (sqzCfg d (0 + 1 + 2 * k) 0) (oddCfg (d + k + 1) 0 k)
have hsqz : sqzCfg (d + k) (0 + 1) (0 + k) = sqzCfg (d + k) 1 ((k - 1) + 1) := by d:ℕk:ℕhk:1 ≤ k⊢ reachPos (roundCfg d (2 * k + 1)) (oddCfg (d + k + 1) 0 k)
congr 1 e_a d:ℕk:ℕhk:1 ≤ ks:ℕhs:nSteps weakCollatz16 s (sqzCfg d (0 + 1 + 2 * k) 0) = some (sqzCfg (d + k) (0 + 1) (0 + k))⊢ 0 + k = k - 1 + 1; omega d:ℕk:ℕhk:1 ≤ ks:ℕhs:nSteps weakCollatz16 s (sqzCfg d (0 + 1 + 2 * k) 0) = some (sqzCfg (d + k) (0 + 1) (0 + k))hsqz:sqzCfg (d + k) (0 + 1) (0 + k) = sqzCfg (d + k) 1 (k - 1 + 1)⊢ reachPos (sqzCfg d (0 + 1 + 2 * k) 0) (oddCfg (d + k + 1) 0 k)
rw [hsqz d:ℕk:ℕhk:1 ≤ ks:ℕhs:nSteps weakCollatz16 s (sqzCfg d (0 + 1 + 2 * k) 0) = some (sqzCfg (d + k) 1 (k - 1 + 1))hsqz:sqzCfg (d + k) (0 + 1) (0 + k) = sqzCfg (d + k) 1 (k - 1 + 1)⊢ reachPos (sqzCfg d (0 + 1 + 2 * k) 0) (oddCfg (d + k + 1) 0 k)] at hs d:ℕk:ℕhk:1 ≤ ks:ℕhs:nSteps weakCollatz16 s (sqzCfg d (0 + 1 + 2 * k) 0) = some (sqzCfg (d + k) 1 (k - 1 + 1))hsqz:sqzCfg (d + k) (0 + 1) (0 + k) = sqzCfg (d + k) 1 (k - 1 + 1)⊢ reachPos (sqzCfg d (0 + 1 + 2 * k) 0) (oddCfg (d + k + 1) 0 k)
have hent := sqz_odd_enter (d + k) (k - 1) d:ℕk:ℕhk:1 ≤ ks:ℕhs:nSteps weakCollatz16 s (sqzCfg d (0 + 1 + 2 * k) 0) = some (sqzCfg (d + k) 1 (k - 1 + 1))hsqz:sqzCfg (d + k) (0 + 1) (0 + k) = sqzCfg (d + k) 1 (k - 1 + 1)hent:reachPos (sqzCfg (d + k) 1 (k - 1 + 1)) (oddCfg (d + k + 1) 0 (k - 1 + 1))⊢ reachPos (sqzCfg d (0 + 1 + 2 * k) 0) (oddCfg (d + k + 1) 0 k)
have hodd : oddCfg (d + k + 1) 0 ((k - 1) + 1) = oddCfg (d + k + 1) 0 k := by d:ℕk:ℕhk:1 ≤ k⊢ reachPos (roundCfg d (2 * k + 1)) (oddCfg (d + k + 1) 0 k)
congr 1 e_m d:ℕk:ℕhk:1 ≤ ks:ℕhs:nSteps weakCollatz16 s (sqzCfg d (0 + 1 + 2 * k) 0) = some (sqzCfg (d + k) 1 (k - 1 + 1))hsqz:sqzCfg (d + k) (0 + 1) (0 + k) = sqzCfg (d + k) 1 (k - 1 + 1)hent:reachPos (sqzCfg (d + k) 1 (k - 1 + 1)) (oddCfg (d + k + 1) 0 (k - 1 + 1))⊢ k - 1 + 1 = k; omega d:ℕk:ℕhk:1 ≤ ks:ℕhs:nSteps weakCollatz16 s (sqzCfg d (0 + 1 + 2 * k) 0) = some (sqzCfg (d + k) 1 (k - 1 + 1))hsqz:sqzCfg (d + k) (0 + 1) (0 + k) = sqzCfg (d + k) 1 (k - 1 + 1)hent:reachPos (sqzCfg (d + k) 1 (k - 1 + 1)) (oddCfg (d + k + 1) 0 (k - 1 + 1))hodd:oddCfg (d + k + 1) 0 (k - 1 + 1) = oddCfg (d + k + 1) 0 k⊢ reachPos (sqzCfg d (0 + 1 + 2 * k) 0) (oddCfg (d + k + 1) 0 k)
rw [hodd d:ℕk:ℕhk:1 ≤ ks:ℕhs:nSteps weakCollatz16 s (sqzCfg d (0 + 1 + 2 * k) 0) = some (sqzCfg (d + k) 1 (k - 1 + 1))hsqz:sqzCfg (d + k) (0 + 1) (0 + k) = sqzCfg (d + k) 1 (k - 1 + 1)hent:reachPos (sqzCfg (d + k) 1 (k - 1 + 1)) (oddCfg (d + k + 1) 0 k)hodd:oddCfg (d + k + 1) 0 (k - 1 + 1) = oddCfg (d + k + 1) 0 k⊢ reachPos (sqzCfg d (0 + 1 + 2 * k) 0) (oddCfg (d + k + 1) 0 k)] at hent d:ℕk:ℕhk:1 ≤ ks:ℕhs:nSteps weakCollatz16 s (sqzCfg d (0 + 1 + 2 * k) 0) = some (sqzCfg (d + k) 1 (k - 1 + 1))hsqz:sqzCfg (d + k) (0 + 1) (0 + k) = sqzCfg (d + k) 1 (k - 1 + 1)hent:reachPos (sqzCfg (d + k) 1 (k - 1 + 1)) (oddCfg (d + k + 1) 0 k)hodd:oddCfg (d + k + 1) 0 (k - 1 + 1) = oddCfg (d + k + 1) 0 k⊢ reachPos (sqzCfg d (0 + 1 + 2 * k) 0) (oddCfg (d + k + 1) 0 k)
exact nSteps_then_reachPos hs hent All goals completed! 🐙private theorem even_or_odd_constructive (y : ℕ) : ∃ m : ℕ, y = 2 * m ∨ y = 2 * m + 1 :=
⟨y / 2, by y:ℕ⊢ y = 2 * (y / 2) ∨ y = 2 * (y / 2) + 1 omega All goals completed! 🐙⟩private theorem stage_round_lt (x y : ℕ) (hy2 : 2 ≤ y) (hyle : y ≤ x) (hlt : terras y < x) :
reachPos (roundCfg (x - y) y) (roundCfg (x - terras y) (terras y)) := by x:ℕy:ℕhy2:2 ≤ yhyle:y ≤ xhlt:terras y < x⊢ reachPos (roundCfg (x - y) y) (roundCfg (x - terras y) (terras y))
rcases even_or_odd_constructive y with ⟨m, rfl | rfl⟩ inl x:ℕm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xhlt:terras (2 * m) < x⊢ reachPos (roundCfg (x - 2 * m) (2 * m)) (roundCfg (x - terras (2 * m)) (terras (2 * m)))inr x:ℕm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhlt:terras (2 * m + 1) < x⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (roundCfg (x - terras (2 * m + 1)) (terras (2 * m + 1)))
· inl x:ℕm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xhlt:terras (2 * m) < x⊢ reachPos (roundCfg (x - 2 * m) (2 * m)) (roundCfg (x - terras (2 * m)) (terras (2 * m))) have hm1 : 1 ≤ m := by x:ℕy:ℕhy2:2 ≤ yhyle:y ≤ xhlt:terras y < x⊢ reachPos (roundCfg (x - y) y) (roundCfg (x - terras y) (terras y)) omega inl x:ℕm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xhlt:terras (2 * m) < xhm1:1 ≤ m⊢ reachPos (roundCfg (x - 2 * m) (2 * m)) (roundCfg (x - terras (2 * m)) (terras (2 * m)))
have hte : terras (2 * m) = m := by x:ℕy:ℕhy2:2 ≤ yhyle:y ≤ xhlt:terras y < x⊢ reachPos (roundCfg (x - y) y) (roundCfg (x - terras y) (terras y)) unfold terras x:ℕm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xhlt:terras (2 * m) < xhm1:1 ≤ m⊢ (if 2 * m % 2 = 0 then 2 * m / 2 else (3 * (2 * m) + 1) / 2) = m; split isTrue x:ℕm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xhlt:terras (2 * m) < xhm1:1 ≤ mh✝:2 * m % 2 = 0⊢ 2 * m / 2 = misFalse x:ℕm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xhlt:terras (2 * m) < xhm1:1 ≤ mh✝:¬2 * m % 2 = 0⊢ (3 * (2 * m) + 1) / 2 = m <;> isTrue x:ℕm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xhlt:terras (2 * m) < xhm1:1 ≤ mh✝:2 * m % 2 = 0⊢ 2 * m / 2 = misFalse x:ℕm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xhlt:terras (2 * m) < xhm1:1 ≤ mh✝:¬2 * m % 2 = 0⊢ (3 * (2 * m) + 1) / 2 = m omega inl x:ℕm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xhlt:terras (2 * m) < xhm1:1 ≤ mhte:terras (2 * m) = m⊢ reachPos (roundCfg (x - 2 * m) (2 * m)) (roundCfg (x - terras (2 * m)) (terras (2 * m)))
rw [hte inl x:ℕm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xhlt:terras (2 * m) < xhm1:1 ≤ mhte:terras (2 * m) = m⊢ reachPos (roundCfg (x - 2 * m) (2 * m)) (roundCfg (x - m) m)] inl x:ℕm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xhlt:terras (2 * m) < xhm1:1 ≤ mhte:terras (2 * m) = m⊢ reachPos (roundCfg (x - 2 * m) (2 * m)) (roundCfg (x - m) m)
let k := m - 1 inl x:ℕm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xhlt:terras (2 * m) < xhm1:1 ≤ mhte:terras (2 * m) = mk:ℕ := m - 1⊢ reachPos (roundCfg (x - 2 * m) (2 * m)) (roundCfg (x - m) m)
have hy_eq : 2 * m = 2 * k + 2 := by x:ℕy:ℕhy2:2 ≤ yhyle:y ≤ xhlt:terras y < x⊢ reachPos (roundCfg (x - y) y) (roundCfg (x - terras y) (terras y)) dsimp only [k] x:ℕm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xhlt:terras (2 * m) < xhm1:1 ≤ mhte:terras (2 * m) = mk:ℕ := m - 1⊢ 2 * m = 2 * (m - 1) + 2; omega inl x:ℕm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xhlt:terras (2 * m) < xhm1:1 ≤ mhte:terras (2 * m) = mk:ℕ := m - 1hy_eq:2 * m = 2 * k + 2⊢ reachPos (roundCfg (x - 2 * m) (2 * m)) (roundCfg (x - m) m)
rw [hy_eq inl x:ℕm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xhlt:terras (2 * m) < xhm1:1 ≤ mhte:terras (2 * m) = mk:ℕ := m - 1hy_eq:2 * m = 2 * k + 2⊢ reachPos (roundCfg (x - (2 * k + 2)) (2 * k + 2)) (roundCfg (x - m) m)] inl x:ℕm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xhlt:terras (2 * m) < xhm1:1 ≤ mhte:terras (2 * m) = mk:ℕ := m - 1hy_eq:2 * m = 2 * k + 2⊢ reachPos (roundCfg (x - (2 * k + 2)) (2 * k + 2)) (roundCfg (x - m) m)
have hrev := round_even (x - (2 * k + 2)) k inl x:ℕm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xhlt:terras (2 * m) < xhm1:1 ≤ mhte:terras (2 * m) = mk:ℕ := m - 1hy_eq:2 * m = 2 * k + 2hrev:reachPos (roundCfg (x - (2 * k + 2)) (2 * k + 2)) (roundCfg (x - (2 * k + 2) + k + 1) (k + 1))⊢ reachPos (roundCfg (x - (2 * k + 2)) (2 * k + 2)) (roundCfg (x - m) m)
have hd_eq : x - (2 * k + 2) + k + 1 = x - m := by x:ℕy:ℕhy2:2 ≤ yhyle:y ≤ xhlt:terras y < x⊢ reachPos (roundCfg (x - y) y) (roundCfg (x - terras y) (terras y)) dsimp only [k] x:ℕm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xhlt:terras (2 * m) < xhm1:1 ≤ mhte:terras (2 * m) = mk:ℕ := m - 1hy_eq:2 * m = 2 * k + 2hrev:reachPos (roundCfg (x - (2 * k + 2)) (2 * k + 2)) (roundCfg (x - (2 * k + 2) + k + 1) (k + 1))⊢ x - (2 * (m - 1) + 2) + (m - 1) + 1 = x - m; omega inl x:ℕm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xhlt:terras (2 * m) < xhm1:1 ≤ mhte:terras (2 * m) = mk:ℕ := m - 1hy_eq:2 * m = 2 * k + 2hrev:reachPos (roundCfg (x - (2 * k + 2)) (2 * k + 2)) (roundCfg (x - (2 * k + 2) + k + 1) (k + 1))hd_eq:x - (2 * k + 2) + k + 1 = x - m⊢ reachPos (roundCfg (x - (2 * k + 2)) (2 * k + 2)) (roundCfg (x - m) m)
have hk_eq : k + 1 = m := by x:ℕy:ℕhy2:2 ≤ yhyle:y ≤ xhlt:terras y < x⊢ reachPos (roundCfg (x - y) y) (roundCfg (x - terras y) (terras y)) dsimp only [k] x:ℕm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xhlt:terras (2 * m) < xhm1:1 ≤ mhte:terras (2 * m) = mk:ℕ := m - 1hy_eq:2 * m = 2 * k + 2hrev:reachPos (roundCfg (x - (2 * k + 2)) (2 * k + 2)) (roundCfg (x - (2 * k + 2) + k + 1) (k + 1))hd_eq:x - (2 * k + 2) + k + 1 = x - m⊢ m - 1 + 1 = m; omega inl x:ℕm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xhlt:terras (2 * m) < xhm1:1 ≤ mhte:terras (2 * m) = mk:ℕ := m - 1hy_eq:2 * m = 2 * k + 2hrev:reachPos (roundCfg (x - (2 * k + 2)) (2 * k + 2)) (roundCfg (x - (2 * k + 2) + k + 1) (k + 1))hd_eq:x - (2 * k + 2) + k + 1 = x - mhk_eq:k + 1 = m⊢ reachPos (roundCfg (x - (2 * k + 2)) (2 * k + 2)) (roundCfg (x - m) m)
rw [hd_eq, inl x:ℕm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xhlt:terras (2 * m) < xhm1:1 ≤ mhte:terras (2 * m) = mk:ℕ := m - 1hy_eq:2 * m = 2 * k + 2hrev:reachPos (roundCfg (x - (2 * k + 2)) (2 * k + 2)) (roundCfg (x - m) (k + 1))hd_eq:x - (2 * k + 2) + k + 1 = x - mhk_eq:k + 1 = m⊢ reachPos (roundCfg (x - (2 * k + 2)) (2 * k + 2)) (roundCfg (x - m) m) hk_eq inl x:ℕm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xhlt:terras (2 * m) < xhm1:1 ≤ mhte:terras (2 * m) = mk:ℕ := m - 1hy_eq:2 * m = 2 * k + 2hrev:reachPos (roundCfg (x - (2 * k + 2)) (2 * k + 2)) (roundCfg (x - m) m)hd_eq:x - (2 * k + 2) + k + 1 = x - mhk_eq:k + 1 = m⊢ reachPos (roundCfg (x - (2 * k + 2)) (2 * k + 2)) (roundCfg (x - m) m)] at hrev inl x:ℕm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xhlt:terras (2 * m) < xhm1:1 ≤ mhte:terras (2 * m) = mk:ℕ := m - 1hy_eq:2 * m = 2 * k + 2hrev:reachPos (roundCfg (x - (2 * k + 2)) (2 * k + 2)) (roundCfg (x - m) m)hd_eq:x - (2 * k + 2) + k + 1 = x - mhk_eq:k + 1 = m⊢ reachPos (roundCfg (x - (2 * k + 2)) (2 * k + 2)) (roundCfg (x - m) m)
exact hrev All goals completed! 🐙
· inr x:ℕm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhlt:terras (2 * m + 1) < x⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (roundCfg (x - terras (2 * m + 1)) (terras (2 * m + 1))) have hm1 : 1 ≤ m := by x:ℕy:ℕhy2:2 ≤ yhyle:y ≤ xhlt:terras y < x⊢ reachPos (roundCfg (x - y) y) (roundCfg (x - terras y) (terras y)) omega inr x:ℕm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhlt:terras (2 * m + 1) < xhm1:1 ≤ m⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (roundCfg (x - terras (2 * m + 1)) (terras (2 * m + 1)))
have hto : terras (2 * m + 1) = 3 * m + 2 := by x:ℕy:ℕhy2:2 ≤ yhyle:y ≤ xhlt:terras y < x⊢ reachPos (roundCfg (x - y) y) (roundCfg (x - terras y) (terras y)) unfold terras x:ℕm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhlt:terras (2 * m + 1) < xhm1:1 ≤ m⊢ (if (2 * m + 1) % 2 = 0 then (2 * m + 1) / 2 else (3 * (2 * m + 1) + 1) / 2) = 3 * m + 2; split isTrue x:ℕm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhlt:terras (2 * m + 1) < xhm1:1 ≤ mh✝:(2 * m + 1) % 2 = 0⊢ (2 * m + 1) / 2 = 3 * m + 2isFalse x:ℕm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhlt:terras (2 * m + 1) < xhm1:1 ≤ mh✝:¬(2 * m + 1) % 2 = 0⊢ (3 * (2 * m + 1) + 1) / 2 = 3 * m + 2 <;> isTrue x:ℕm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhlt:terras (2 * m + 1) < xhm1:1 ≤ mh✝:(2 * m + 1) % 2 = 0⊢ (2 * m + 1) / 2 = 3 * m + 2isFalse x:ℕm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhlt:terras (2 * m + 1) < xhm1:1 ≤ mh✝:¬(2 * m + 1) % 2 = 0⊢ (3 * (2 * m + 1) + 1) / 2 = 3 * m + 2 omega inr x:ℕm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhlt:terras (2 * m + 1) < xhm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (roundCfg (x - terras (2 * m + 1)) (terras (2 * m + 1)))
rw [hto inr x:ℕm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhlt:3 * m + 2 < xhm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (roundCfg (x - (3 * m + 2)) (3 * m + 2))] at hlt ⊢ inr x:ℕm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhlt:3 * m + 2 < xhm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (roundCfg (x - (3 * m + 2)) (3 * m + 2))
have h1 := round_to_odd (x - (2 * m + 1)) m hm1 inr x:ℕm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhlt:3 * m + 2 < xhm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2h1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg (x - (2 * m + 1) + m + 1) 0 m)⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (roundCfg (x - (3 * m + 2)) (3 * m + 2))
let d' := x - (3 * m + 2) - 1 inr x:ℕm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhlt:3 * m + 2 < xhm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2h1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg (x - (2 * m + 1) + m + 1) 0 m)d':ℕ := x - (3 * m + 2) - 1⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (roundCfg (x - (3 * m + 2)) (3 * m + 2))
have hL : x - (2 * m + 1) + m + 1 = (d' + 3) + 2 * m := by x:ℕy:ℕhy2:2 ≤ yhyle:y ≤ xhlt:terras y < x⊢ reachPos (roundCfg (x - y) y) (roundCfg (x - terras y) (terras y)) dsimp only [d'] x:ℕm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhlt:3 * m + 2 < xhm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2h1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg (x - (2 * m + 1) + m + 1) 0 m)d':ℕ := x - (3 * m + 2) - 1⊢ x - (2 * m + 1) + m + 1 = x - (3 * m + 2) - 1 + 3 + 2 * m; omega inr x:ℕm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhlt:3 * m + 2 < xhm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2h1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg (x - (2 * m + 1) + m + 1) 0 m)d':ℕ := x - (3 * m + 2) - 1hL:x - (2 * m + 1) + m + 1 = d' + 3 + 2 * m⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (roundCfg (x - (3 * m + 2)) (3 * m + 2))
rw [hL inr x:ℕm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhlt:3 * m + 2 < xhm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2d':ℕ := x - (3 * m + 2) - 1h1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg (d' + 3 + 2 * m) 0 m)hL:x - (2 * m + 1) + m + 1 = d' + 3 + 2 * m⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (roundCfg (x - (3 * m + 2)) (3 * m + 2))] at h1 inr x:ℕm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhlt:3 * m + 2 < xhm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2d':ℕ := x - (3 * m + 2) - 1h1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg (d' + 3 + 2 * m) 0 m)hL:x - (2 * m + 1) + m + 1 = d' + 3 + 2 * m⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (roundCfg (x - (3 * m + 2)) (3 * m + 2))
obtain ⟨s, hs⟩ := odd_many (d' + 3) 0 0 m inr x:ℕm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhlt:3 * m + 2 < xhm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2d':ℕ := x - (3 * m + 2) - 1h1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg (d' + 3 + 2 * m) 0 m)hL:x - (2 * m + 1) + m + 1 = d' + 3 + 2 * ms:ℕhs:nSteps weakCollatz16 s (oddCfg (d' + 3 + 2 * m) 0 (0 + m)) = some (oddCfg (d' + 3) (0 + 3 * m) 0)⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (roundCfg (x - (3 * m + 2)) (3 * m + 2))
simp only [Nat.zero_add] at hs inr x:ℕm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhlt:3 * m + 2 < xhm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2d':ℕ := x - (3 * m + 2) - 1h1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg (d' + 3 + 2 * m) 0 m)hL:x - (2 * m + 1) + m + 1 = d' + 3 + 2 * ms:ℕhs:nSteps weakCollatz16 s (oddCfg (d' + 3 + 2 * m) 0 m) = some (oddCfg (d' + 3) (3 * m) 0)⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (roundCfg (x - (3 * m + 2)) (3 * m + 2))
have hfin := odd_done_lt d' (3 * m) inr x:ℕm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhlt:3 * m + 2 < xhm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2d':ℕ := x - (3 * m + 2) - 1h1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg (d' + 3 + 2 * m) 0 m)hL:x - (2 * m + 1) + m + 1 = d' + 3 + 2 * ms:ℕhs:nSteps weakCollatz16 s (oddCfg (d' + 3 + 2 * m) 0 m) = some (oddCfg (d' + 3) (3 * m) 0)hfin:reachPos (oddCfg (d' + 3) (3 * m) 0) (roundCfg (d' + 1) (3 * m + 2))⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (roundCfg (x - (3 * m + 2)) (3 * m + 2))
rw [show d' + 1 = x - (3 * m + 2) by x:ℕy:ℕhy2:2 ≤ yhyle:y ≤ xhlt:terras y < x⊢ reachPos (roundCfg (x - y) y) (roundCfg (x - terras y) (terras y)) dsimp only [d'] x:ℕm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhlt:3 * m + 2 < xhm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2d':ℕ := x - (3 * m + 2) - 1h1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg (d' + 3 + 2 * m) 0 m)hL:x - (2 * m + 1) + m + 1 = d' + 3 + 2 * ms:ℕhs:nSteps weakCollatz16 s (oddCfg (d' + 3 + 2 * m) 0 m) = some (oddCfg (d' + 3) (3 * m) 0)hfin:reachPos (oddCfg (d' + 3) (3 * m) 0) (roundCfg (d' + 1) (3 * m + 2))⊢ x - (3 * m + 2) - 1 + 1 = x - (3 * m + 2); omega All goals completed! 🐙] at hfin inr x:ℕm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhlt:3 * m + 2 < xhm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2d':ℕ := x - (3 * m + 2) - 1h1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg (d' + 3 + 2 * m) 0 m)hL:x - (2 * m + 1) + m + 1 = d' + 3 + 2 * ms:ℕhs:nSteps weakCollatz16 s (oddCfg (d' + 3 + 2 * m) 0 m) = some (oddCfg (d' + 3) (3 * m) 0)hfin:reachPos (oddCfg (d' + 3) (3 * m) 0) (roundCfg (x - (3 * m + 2)) (3 * m + 2))⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (roundCfg (x - (3 * m + 2)) (3 * m + 2))
exact reachPos_trans h1 (nSteps_then_reachPos hs hfin) All goals completed! 🐙private theorem stage_round_gt (x y : ℕ) (hx : 3 ≤ x) (hy2 : 2 ≤ y) (hyle : y ≤ x)
(hgt : x < terras y) :
reachPos (roundCfg (x - y) y) (stageCfg (x + 2)) := by x:ℕy:ℕhx:3 ≤ xhy2:2 ≤ yhyle:y ≤ xhgt:x < terras y⊢ reachPos (roundCfg (x - y) y) (stageCfg (x + 2))
rcases even_or_odd_constructive y with ⟨m, rfl | rfl⟩ inl x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xhgt:x < terras (2 * m)⊢ reachPos (roundCfg (x - 2 * m) (2 * m)) (stageCfg (x + 2))inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < terras (2 * m + 1)⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2))
· inl x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xhgt:x < terras (2 * m)⊢ reachPos (roundCfg (x - 2 * m) (2 * m)) (stageCfg (x + 2)) exfalso inl x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xhgt:x < terras (2 * m)⊢ False
have hte : terras (2 * m) = m := by x:ℕy:ℕhx:3 ≤ xhy2:2 ≤ yhyle:y ≤ xhgt:x < terras y⊢ reachPos (roundCfg (x - y) y) (stageCfg (x + 2)) unfold terras x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xhgt:x < terras (2 * m)⊢ (if 2 * m % 2 = 0 then 2 * m / 2 else (3 * (2 * m) + 1) / 2) = m; split isTrue x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xhgt:x < terras (2 * m)h✝:2 * m % 2 = 0⊢ 2 * m / 2 = misFalse x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xhgt:x < terras (2 * m)h✝:¬2 * m % 2 = 0⊢ (3 * (2 * m) + 1) / 2 = m <;> isTrue x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xhgt:x < terras (2 * m)h✝:2 * m % 2 = 0⊢ 2 * m / 2 = misFalse x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xhgt:x < terras (2 * m)h✝:¬2 * m % 2 = 0⊢ (3 * (2 * m) + 1) / 2 = m omega inl x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xhgt:x < terras (2 * m)hte:terras (2 * m) = m⊢ False
omega All goals completed! 🐙
· inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < terras (2 * m + 1)⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2)) have hm1 : 1 ≤ m := by x:ℕy:ℕhx:3 ≤ xhy2:2 ≤ yhyle:y ≤ xhgt:x < terras y⊢ reachPos (roundCfg (x - y) y) (stageCfg (x + 2)) omega inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < terras (2 * m + 1)hm1:1 ≤ m⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2))
have hto : terras (2 * m + 1) = 3 * m + 2 := by x:ℕy:ℕhx:3 ≤ xhy2:2 ≤ yhyle:y ≤ xhgt:x < terras y⊢ reachPos (roundCfg (x - y) y) (stageCfg (x + 2)) unfold terras x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < terras (2 * m + 1)hm1:1 ≤ m⊢ (if (2 * m + 1) % 2 = 0 then (2 * m + 1) / 2 else (3 * (2 * m + 1) + 1) / 2) = 3 * m + 2; split isTrue x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < terras (2 * m + 1)hm1:1 ≤ mh✝:(2 * m + 1) % 2 = 0⊢ (2 * m + 1) / 2 = 3 * m + 2isFalse x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < terras (2 * m + 1)hm1:1 ≤ mh✝:¬(2 * m + 1) % 2 = 0⊢ (3 * (2 * m + 1) + 1) / 2 = 3 * m + 2 <;> isTrue x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < terras (2 * m + 1)hm1:1 ≤ mh✝:(2 * m + 1) % 2 = 0⊢ (2 * m + 1) / 2 = 3 * m + 2isFalse x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < terras (2 * m + 1)hm1:1 ≤ mh✝:¬(2 * m + 1) % 2 = 0⊢ (3 * (2 * m + 1) + 1) / 2 = 3 * m + 2 omega inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < terras (2 * m + 1)hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2))
rw [hto inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2))] at hgt inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2))
have h1 := round_to_odd (x - (2 * m + 1)) m hm1 inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2h1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg (x - (2 * m + 1) + m + 1) 0 m)⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2))
let L₀ := x - m inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2h1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg (x - (2 * m + 1) + m + 1) 0 m)L₀:ℕ := x - m⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2))
have hL₀_eq : x - (2 * m + 1) + m + 1 = L₀ := by x:ℕy:ℕhx:3 ≤ xhy2:2 ≤ yhyle:y ≤ xhgt:x < terras y⊢ reachPos (roundCfg (x - y) y) (stageCfg (x + 2)) dsimp only [L₀] x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2h1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg (x - (2 * m + 1) + m + 1) 0 m)L₀:ℕ := x - m⊢ x - (2 * m + 1) + m + 1 = x - m; omega inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2h1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg (x - (2 * m + 1) + m + 1) 0 m)L₀:ℕ := x - mhL₀_eq:x - (2 * m + 1) + m + 1 = L₀⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2))
rw [hL₀_eq inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2))] at h1 inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2))
let j := L₀ / 2 inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2))
let rem := L₀ % 2 inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2rem:ℕ := L₀ % 2⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2))
have hj_le : j ≤ m := by x:ℕy:ℕhx:3 ≤ xhy2:2 ≤ yhyle:y ≤ xhgt:x < terras y⊢ reachPos (roundCfg (x - y) y) (stageCfg (x + 2)) dsimp only [j, L₀] x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2rem:ℕ := L₀ % 2⊢ (x - m) / 2 ≤ m; omega inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2rem:ℕ := L₀ % 2hj_le:j ≤ m⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2))
have hL_split : L₀ = rem + 2 * j := by x:ℕy:ℕhx:3 ≤ xhy2:2 ≤ yhyle:y ≤ xhgt:x < terras y⊢ reachPos (roundCfg (x - y) y) (stageCfg (x + 2)) dsimp only [j, rem] x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2rem:ℕ := L₀ % 2hj_le:j ≤ m⊢ L₀ = L₀ % 2 + 2 * (L₀ / 2); omega inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2rem:ℕ := L₀ % 2hj_le:j ≤ mhL_split:L₀ = rem + 2 * j⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2))
have hm_split : m = (m - j) + j := by x:ℕy:ℕhx:3 ≤ xhy2:2 ≤ yhyle:y ≤ xhgt:x < terras y⊢ reachPos (roundCfg (x - y) y) (stageCfg (x + 2)) omega inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2rem:ℕ := L₀ % 2hj_le:j ≤ mhL_split:L₀ = rem + 2 * jhm_split:m = m - j + j⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2))
obtain ⟨s, hs⟩ := odd_many rem 0 (m - j) j inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2rem:ℕ := L₀ % 2hj_le:j ≤ mhL_split:L₀ = rem + 2 * jhm_split:m = m - j + js:ℕhs:nSteps weakCollatz16 s (oddCfg (rem + 2 * j) 0 (m - j + j)) = some (oddCfg rem (0 + 3 * j) (m - j))⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2))
have hin : oddCfg (rem + 2 * j) 0 ((m - j) + j) = oddCfg L₀ 0 m := by x:ℕy:ℕhx:3 ≤ xhy2:2 ≤ yhyle:y ≤ xhgt:x < terras y⊢ reachPos (roundCfg (x - y) y) (stageCfg (x + 2))
rw [← hL_split, x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2rem:ℕ := L₀ % 2hj_le:j ≤ mhL_split:L₀ = rem + 2 * jhm_split:m = m - j + js:ℕhs:nSteps weakCollatz16 s (oddCfg (rem + 2 * j) 0 (m - j + j)) = some (oddCfg rem (0 + 3 * j) (m - j))⊢ oddCfg L₀ 0 (m - j + j) = oddCfg L₀ 0 m ← hm_split x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2rem:ℕ := L₀ % 2hj_le:j ≤ mhL_split:L₀ = rem + 2 * jhm_split:m = m - j + js:ℕhs:nSteps weakCollatz16 s (oddCfg (rem + 2 * j) 0 (m - j + j)) = some (oddCfg rem (0 + 3 * j) (m - j))⊢ oddCfg L₀ 0 m = oddCfg L₀ 0 m] inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2rem:ℕ := L₀ % 2hj_le:j ≤ mhL_split:L₀ = rem + 2 * jhm_split:m = m - j + js:ℕhs:nSteps weakCollatz16 s (oddCfg (rem + 2 * j) 0 (m - j + j)) = some (oddCfg rem (0 + 3 * j) (m - j))hin:oddCfg (rem + 2 * j) 0 (m - j + j) = oddCfg L₀ 0 m⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2))
rw [hin, inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2rem:ℕ := L₀ % 2hj_le:j ≤ mhL_split:L₀ = rem + 2 * jhm_split:m = m - j + js:ℕhs:nSteps weakCollatz16 s (oddCfg L₀ 0 m) = some (oddCfg rem (0 + 3 * j) (m - j))hin:oddCfg (rem + 2 * j) 0 (m - j + j) = oddCfg L₀ 0 m⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2)) Nat.zero_add inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2rem:ℕ := L₀ % 2hj_le:j ≤ mhL_split:L₀ = rem + 2 * jhm_split:m = m - j + js:ℕhs:nSteps weakCollatz16 s (oddCfg L₀ 0 m) = some (oddCfg rem (3 * j) (m - j))hin:oddCfg (rem + 2 * j) 0 (m - j + j) = oddCfg L₀ 0 m⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2))] at hs inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2rem:ℕ := L₀ % 2hj_le:j ≤ mhL_split:L₀ = rem + 2 * jhm_split:m = m - j + js:ℕhs:nSteps weakCollatz16 s (oddCfg L₀ 0 m) = some (oddCfg rem (3 * j) (m - j))hin:oddCfg (rem + 2 * j) 0 (m - j + j) = oddCfg L₀ 0 m⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2))
have hrem01 : rem = 0 ∨ rem = 1 := by x:ℕy:ℕhx:3 ≤ xhy2:2 ≤ yhyle:y ≤ xhgt:x < terras y⊢ reachPos (roundCfg (x - y) y) (stageCfg (x + 2)) dsimp only [rem] x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2rem:ℕ := L₀ % 2hj_le:j ≤ mhL_split:L₀ = rem + 2 * jhm_split:m = m - j + js:ℕhs:nSteps weakCollatz16 s (oddCfg L₀ 0 m) = some (oddCfg rem (3 * j) (m - j))hin:oddCfg (rem + 2 * j) 0 (m - j + j) = oddCfg L₀ 0 m⊢ L₀ % 2 = 0 ∨ L₀ % 2 = 1; omega inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2rem:ℕ := L₀ % 2hj_le:j ≤ mhL_split:L₀ = rem + 2 * jhm_split:m = m - j + js:ℕhs:nSteps weakCollatz16 s (oddCfg L₀ 0 m) = some (oddCfg rem (3 * j) (m - j))hin:oddCfg (rem + 2 * j) 0 (m - j + j) = oddCfg L₀ 0 mhrem01:rem = 0 ∨ rem = 1⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2))
rcases hrem01 with hrem0 | hrem1 inr.inl x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2rem:ℕ := L₀ % 2hj_le:j ≤ mhL_split:L₀ = rem + 2 * jhm_split:m = m - j + js:ℕhs:nSteps weakCollatz16 s (oddCfg L₀ 0 m) = some (oddCfg rem (3 * j) (m - j))hin:oddCfg (rem + 2 * j) 0 (m - j + j) = oddCfg L₀ 0 mhrem0:rem = 0⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2))inr.inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2rem:ℕ := L₀ % 2hj_le:j ≤ mhL_split:L₀ = rem + 2 * jhm_split:m = m - j + js:ℕhs:nSteps weakCollatz16 s (oddCfg L₀ 0 m) = some (oddCfg rem (3 * j) (m - j))hin:oddCfg (rem + 2 * j) 0 (m - j + j) = oddCfg L₀ 0 mhrem1:rem = 1⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2))
· inr.inl x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2rem:ℕ := L₀ % 2hj_le:j ≤ mhL_split:L₀ = rem + 2 * jhm_split:m = m - j + js:ℕhs:nSteps weakCollatz16 s (oddCfg L₀ 0 m) = some (oddCfg rem (3 * j) (m - j))hin:oddCfg (rem + 2 * j) 0 (m - j + j) = oddCfg L₀ 0 mhrem0:rem = 0⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2)) rw [hrem0 inr.inl x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2rem:ℕ := L₀ % 2hj_le:j ≤ mhL_split:L₀ = rem + 2 * jhm_split:m = m - j + js:ℕhs:nSteps weakCollatz16 s (oddCfg L₀ 0 m) = some (oddCfg 0 (3 * j) (m - j))hin:oddCfg (rem + 2 * j) 0 (m - j + j) = oddCfg L₀ 0 mhrem0:rem = 0⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2))] at hs inr.inl x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2rem:ℕ := L₀ % 2hj_le:j ≤ mhL_split:L₀ = rem + 2 * jhm_split:m = m - j + js:ℕhs:nSteps weakCollatz16 s (oddCfg L₀ 0 m) = some (oddCfg 0 (3 * j) (m - j))hin:oddCfg (rem + 2 * j) 0 (m - j + j) = oddCfg L₀ 0 mhrem0:rem = 0⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2))
have hab := odd_abort_L0 (3 * j) (m - j) inr.inl x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2rem:ℕ := L₀ % 2hj_le:j ≤ mhL_split:L₀ = rem + 2 * jhm_split:m = m - j + js:ℕhs:nSteps weakCollatz16 s (oddCfg L₀ 0 m) = some (oddCfg 0 (3 * j) (m - j))hin:oddCfg (rem + 2 * j) 0 (m - j + j) = oddCfg L₀ 0 mhrem0:rem = 0hab:reachPos (oddCfg 0 (3 * j) (m - j)) (stageCfg (3 * j + (m - j) + 2))⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2))
have hsum : 3 * j + (m - j) + 2 = x + 2 := by x:ℕy:ℕhx:3 ≤ xhy2:2 ≤ yhyle:y ≤ xhgt:x < terras y⊢ reachPos (roundCfg (x - y) y) (stageCfg (x + 2))
have : rem = 0 := hrem0 x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2rem:ℕ := L₀ % 2hj_le:j ≤ mhL_split:L₀ = rem + 2 * jhm_split:m = m - j + js:ℕhs:nSteps weakCollatz16 s (oddCfg L₀ 0 m) = some (oddCfg 0 (3 * j) (m - j))hin:oddCfg (rem + 2 * j) 0 (m - j + j) = oddCfg L₀ 0 mhrem0:rem = 0hab:reachPos (oddCfg 0 (3 * j) (m - j)) (stageCfg (3 * j + (m - j) + 2))this:rem = 0⊢ 3 * j + (m - j) + 2 = x + 2
dsimp only [j, rem, L₀] at this hj_le ⊢ x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2rem:ℕ := L₀ % 2hj_le:(x - m) / 2 ≤ mhL_split:L₀ = rem + 2 * jhm_split:m = m - j + js:ℕhs:nSteps weakCollatz16 s (oddCfg L₀ 0 m) = some (oddCfg 0 (3 * j) (m - j))hin:oddCfg (rem + 2 * j) 0 (m - j + j) = oddCfg L₀ 0 mhrem0:rem = 0hab:reachPos (oddCfg 0 (3 * j) (m - j)) (stageCfg (3 * j + (m - j) + 2))this:(x - m) % 2 = 0⊢ 3 * ((x - m) / 2) + (m - (x - m) / 2) + 2 = x + 2
omega inr.inl x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2rem:ℕ := L₀ % 2hj_le:j ≤ mhL_split:L₀ = rem + 2 * jhm_split:m = m - j + js:ℕhs:nSteps weakCollatz16 s (oddCfg L₀ 0 m) = some (oddCfg 0 (3 * j) (m - j))hin:oddCfg (rem + 2 * j) 0 (m - j + j) = oddCfg L₀ 0 mhrem0:rem = 0hab:reachPos (oddCfg 0 (3 * j) (m - j)) (stageCfg (3 * j + (m - j) + 2))hsum:3 * j + (m - j) + 2 = x + 2⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2))
rw [hsum inr.inl x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2rem:ℕ := L₀ % 2hj_le:j ≤ mhL_split:L₀ = rem + 2 * jhm_split:m = m - j + js:ℕhs:nSteps weakCollatz16 s (oddCfg L₀ 0 m) = some (oddCfg 0 (3 * j) (m - j))hin:oddCfg (rem + 2 * j) 0 (m - j + j) = oddCfg L₀ 0 mhrem0:rem = 0hab:reachPos (oddCfg 0 (3 * j) (m - j)) (stageCfg (x + 2))hsum:3 * j + (m - j) + 2 = x + 2⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2))] at hab inr.inl x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2rem:ℕ := L₀ % 2hj_le:j ≤ mhL_split:L₀ = rem + 2 * jhm_split:m = m - j + js:ℕhs:nSteps weakCollatz16 s (oddCfg L₀ 0 m) = some (oddCfg 0 (3 * j) (m - j))hin:oddCfg (rem + 2 * j) 0 (m - j + j) = oddCfg L₀ 0 mhrem0:rem = 0hab:reachPos (oddCfg 0 (3 * j) (m - j)) (stageCfg (x + 2))hsum:3 * j + (m - j) + 2 = x + 2⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2))
exact reachPos_trans h1 (nSteps_then_reachPos hs hab) All goals completed! 🐙
· inr.inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2rem:ℕ := L₀ % 2hj_le:j ≤ mhL_split:L₀ = rem + 2 * jhm_split:m = m - j + js:ℕhs:nSteps weakCollatz16 s (oddCfg L₀ 0 m) = some (oddCfg rem (3 * j) (m - j))hin:oddCfg (rem + 2 * j) 0 (m - j + j) = oddCfg L₀ 0 mhrem1:rem = 1⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2)) rw [hrem1 inr.inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2rem:ℕ := L₀ % 2hj_le:j ≤ mhL_split:L₀ = rem + 2 * jhm_split:m = m - j + js:ℕhs:nSteps weakCollatz16 s (oddCfg L₀ 0 m) = some (oddCfg 1 (3 * j) (m - j))hin:oddCfg (rem + 2 * j) 0 (m - j + j) = oddCfg L₀ 0 mhrem1:rem = 1⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2))] at hs inr.inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2rem:ℕ := L₀ % 2hj_le:j ≤ mhL_split:L₀ = rem + 2 * jhm_split:m = m - j + js:ℕhs:nSteps weakCollatz16 s (oddCfg L₀ 0 m) = some (oddCfg 1 (3 * j) (m - j))hin:oddCfg (rem + 2 * j) 0 (m - j + j) = oddCfg L₀ 0 mhrem1:rem = 1⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2))
have hab := odd_abort_L1 (3 * j) (m - j) inr.inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2rem:ℕ := L₀ % 2hj_le:j ≤ mhL_split:L₀ = rem + 2 * jhm_split:m = m - j + js:ℕhs:nSteps weakCollatz16 s (oddCfg L₀ 0 m) = some (oddCfg 1 (3 * j) (m - j))hin:oddCfg (rem + 2 * j) 0 (m - j + j) = oddCfg L₀ 0 mhrem1:rem = 1hab:reachPos (oddCfg 1 (3 * j) (m - j)) (stageCfg (1 + 3 * j + (m - j) + 2))⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2))
have hsum : 1 + 3 * j + (m - j) + 2 = x + 2 := by x:ℕy:ℕhx:3 ≤ xhy2:2 ≤ yhyle:y ≤ xhgt:x < terras y⊢ reachPos (roundCfg (x - y) y) (stageCfg (x + 2))
have : rem = 1 := hrem1 x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2rem:ℕ := L₀ % 2hj_le:j ≤ mhL_split:L₀ = rem + 2 * jhm_split:m = m - j + js:ℕhs:nSteps weakCollatz16 s (oddCfg L₀ 0 m) = some (oddCfg 1 (3 * j) (m - j))hin:oddCfg (rem + 2 * j) 0 (m - j + j) = oddCfg L₀ 0 mhrem1:rem = 1hab:reachPos (oddCfg 1 (3 * j) (m - j)) (stageCfg (1 + 3 * j + (m - j) + 2))this:rem = 1⊢ 1 + 3 * j + (m - j) + 2 = x + 2
dsimp only [j, rem, L₀] at this hj_le ⊢ x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2rem:ℕ := L₀ % 2hj_le:(x - m) / 2 ≤ mhL_split:L₀ = rem + 2 * jhm_split:m = m - j + js:ℕhs:nSteps weakCollatz16 s (oddCfg L₀ 0 m) = some (oddCfg 1 (3 * j) (m - j))hin:oddCfg (rem + 2 * j) 0 (m - j + j) = oddCfg L₀ 0 mhrem1:rem = 1hab:reachPos (oddCfg 1 (3 * j) (m - j)) (stageCfg (1 + 3 * j + (m - j) + 2))this:(x - m) % 2 = 1⊢ 1 + 3 * ((x - m) / 2) + (m - (x - m) / 2) + 2 = x + 2
omega inr.inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2rem:ℕ := L₀ % 2hj_le:j ≤ mhL_split:L₀ = rem + 2 * jhm_split:m = m - j + js:ℕhs:nSteps weakCollatz16 s (oddCfg L₀ 0 m) = some (oddCfg 1 (3 * j) (m - j))hin:oddCfg (rem + 2 * j) 0 (m - j + j) = oddCfg L₀ 0 mhrem1:rem = 1hab:reachPos (oddCfg 1 (3 * j) (m - j)) (stageCfg (1 + 3 * j + (m - j) + 2))hsum:1 + 3 * j + (m - j) + 2 = x + 2⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2))
rw [hsum inr.inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2rem:ℕ := L₀ % 2hj_le:j ≤ mhL_split:L₀ = rem + 2 * jhm_split:m = m - j + js:ℕhs:nSteps weakCollatz16 s (oddCfg L₀ 0 m) = some (oddCfg 1 (3 * j) (m - j))hin:oddCfg (rem + 2 * j) 0 (m - j + j) = oddCfg L₀ 0 mhrem1:rem = 1hab:reachPos (oddCfg 1 (3 * j) (m - j)) (stageCfg (x + 2))hsum:1 + 3 * j + (m - j) + 2 = x + 2⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2))] at hab inr.inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xhgt:x < 3 * m + 2hm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2L₀:ℕ := x - mh1:reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (oddCfg L₀ 0 m)hL₀_eq:x - (2 * m + 1) + m + 1 = L₀j:ℕ := L₀ / 2rem:ℕ := L₀ % 2hj_le:j ≤ mhL_split:L₀ = rem + 2 * jhm_split:m = m - j + js:ℕhs:nSteps weakCollatz16 s (oddCfg L₀ 0 m) = some (oddCfg 1 (3 * j) (m - j))hin:oddCfg (rem + 2 * j) 0 (m - j + j) = oddCfg L₀ 0 mhrem1:rem = 1hab:reachPos (oddCfg 1 (3 * j) (m - j)) (stageCfg (x + 2))hsum:1 + 3 * j + (m - j) + 2 = x + 2⊢ reachPos (roundCfg (x - (2 * m + 1)) (2 * m + 1)) (stageCfg (x + 2))
exact reachPos_trans h1 (nSteps_then_reachPos hs hab) All goals completed! 🐙private theorem stage_round_halt (x y : ℕ) (hx : 3 ≤ x) (hy2 : 2 ≤ y) (hyle : y ≤ x)
(heq : terras y = x) :
∃ s cfg, nSteps weakCollatz16 s (roundCfg (x - y) y) = some cfg ∧
step weakCollatz16 cfg = none := by x:ℕy:ℕhx:3 ≤ xhy2:2 ≤ yhyle:y ≤ xheq:terras y = x⊢ ∃ s cfg, nSteps weakCollatz16 s (roundCfg (x - y) y) = some cfg ∧ step weakCollatz16 cfg = none
rcases even_or_odd_constructive y with ⟨m, rfl | rfl⟩ inl x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xheq:terras (2 * m) = x⊢ ∃ s cfg, nSteps weakCollatz16 s (roundCfg (x - 2 * m) (2 * m)) = some cfg ∧ step weakCollatz16 cfg = noneinr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xheq:terras (2 * m + 1) = x⊢ ∃ s cfg, nSteps weakCollatz16 s (roundCfg (x - (2 * m + 1)) (2 * m + 1)) = some cfg ∧ step weakCollatz16 cfg = none
· inl x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xheq:terras (2 * m) = x⊢ ∃ s cfg, nSteps weakCollatz16 s (roundCfg (x - 2 * m) (2 * m)) = some cfg ∧ step weakCollatz16 cfg = none exfalso inl x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xheq:terras (2 * m) = x⊢ False
have hte : terras (2 * m) = m := by x:ℕy:ℕhx:3 ≤ xhy2:2 ≤ yhyle:y ≤ xheq:terras y = x⊢ ∃ s cfg, nSteps weakCollatz16 s (roundCfg (x - y) y) = some cfg ∧ step weakCollatz16 cfg = none unfold terras x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xheq:terras (2 * m) = x⊢ (if 2 * m % 2 = 0 then 2 * m / 2 else (3 * (2 * m) + 1) / 2) = m; split isTrue x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xheq:terras (2 * m) = xh✝:2 * m % 2 = 0⊢ 2 * m / 2 = misFalse x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xheq:terras (2 * m) = xh✝:¬2 * m % 2 = 0⊢ (3 * (2 * m) + 1) / 2 = m <;> isTrue x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xheq:terras (2 * m) = xh✝:2 * m % 2 = 0⊢ 2 * m / 2 = misFalse x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xheq:terras (2 * m) = xh✝:¬2 * m % 2 = 0⊢ (3 * (2 * m) + 1) / 2 = m omega inl x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * mhyle:2 * m ≤ xheq:terras (2 * m) = xhte:terras (2 * m) = m⊢ False
omega All goals completed! 🐙
· inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xheq:terras (2 * m + 1) = x⊢ ∃ s cfg, nSteps weakCollatz16 s (roundCfg (x - (2 * m + 1)) (2 * m + 1)) = some cfg ∧ step weakCollatz16 cfg = none have hm1 : 1 ≤ m := by x:ℕy:ℕhx:3 ≤ xhy2:2 ≤ yhyle:y ≤ xheq:terras y = x⊢ ∃ s cfg, nSteps weakCollatz16 s (roundCfg (x - y) y) = some cfg ∧ step weakCollatz16 cfg = none omega inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xheq:terras (2 * m + 1) = xhm1:1 ≤ m⊢ ∃ s cfg, nSteps weakCollatz16 s (roundCfg (x - (2 * m + 1)) (2 * m + 1)) = some cfg ∧ step weakCollatz16 cfg = none
have hto : terras (2 * m + 1) = 3 * m + 2 := by x:ℕy:ℕhx:3 ≤ xhy2:2 ≤ yhyle:y ≤ xheq:terras y = x⊢ ∃ s cfg, nSteps weakCollatz16 s (roundCfg (x - y) y) = some cfg ∧ step weakCollatz16 cfg = none unfold terras x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xheq:terras (2 * m + 1) = xhm1:1 ≤ m⊢ (if (2 * m + 1) % 2 = 0 then (2 * m + 1) / 2 else (3 * (2 * m + 1) + 1) / 2) = 3 * m + 2; split isTrue x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xheq:terras (2 * m + 1) = xhm1:1 ≤ mh✝:(2 * m + 1) % 2 = 0⊢ (2 * m + 1) / 2 = 3 * m + 2isFalse x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xheq:terras (2 * m + 1) = xhm1:1 ≤ mh✝:¬(2 * m + 1) % 2 = 0⊢ (3 * (2 * m + 1) + 1) / 2 = 3 * m + 2 <;> isTrue x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xheq:terras (2 * m + 1) = xhm1:1 ≤ mh✝:(2 * m + 1) % 2 = 0⊢ (2 * m + 1) / 2 = 3 * m + 2isFalse x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xheq:terras (2 * m + 1) = xhm1:1 ≤ mh✝:¬(2 * m + 1) % 2 = 0⊢ (3 * (2 * m + 1) + 1) / 2 = 3 * m + 2 omega inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xheq:terras (2 * m + 1) = xhm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2⊢ ∃ s cfg, nSteps weakCollatz16 s (roundCfg (x - (2 * m + 1)) (2 * m + 1)) = some cfg ∧ step weakCollatz16 cfg = none
rw [hto inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xheq:3 * m + 2 = xhm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2⊢ ∃ s cfg, nSteps weakCollatz16 s (roundCfg (x - (2 * m + 1)) (2 * m + 1)) = some cfg ∧ step weakCollatz16 cfg = none] at heq inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xheq:3 * m + 2 = xhm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2⊢ ∃ s cfg, nSteps weakCollatz16 s (roundCfg (x - (2 * m + 1)) (2 * m + 1)) = some cfg ∧ step weakCollatz16 cfg = none
obtain ⟨s₁, _, hs₁⟩ := round_to_odd (x - (2 * m + 1)) m hm1 inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xheq:3 * m + 2 = xhm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2s₁:ℕleft✝:1 ≤ s₁hs₁:nSteps weakCollatz16 s₁ (roundCfg (x - (2 * m + 1)) (2 * m + 1)) = some (oddCfg (x - (2 * m + 1) + m + 1) 0 m)⊢ ∃ s cfg, nSteps weakCollatz16 s (roundCfg (x - (2 * m + 1)) (2 * m + 1)) = some cfg ∧ step weakCollatz16 cfg = none
have hL : x - (2 * m + 1) + m + 1 = 2 + 2 * m := by x:ℕy:ℕhx:3 ≤ xhy2:2 ≤ yhyle:y ≤ xheq:terras y = x⊢ ∃ s cfg, nSteps weakCollatz16 s (roundCfg (x - y) y) = some cfg ∧ step weakCollatz16 cfg = none omega inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xheq:3 * m + 2 = xhm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2s₁:ℕleft✝:1 ≤ s₁hs₁:nSteps weakCollatz16 s₁ (roundCfg (x - (2 * m + 1)) (2 * m + 1)) = some (oddCfg (x - (2 * m + 1) + m + 1) 0 m)hL:x - (2 * m + 1) + m + 1 = 2 + 2 * m⊢ ∃ s cfg, nSteps weakCollatz16 s (roundCfg (x - (2 * m + 1)) (2 * m + 1)) = some cfg ∧ step weakCollatz16 cfg = none
rw [hL inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xheq:3 * m + 2 = xhm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2s₁:ℕleft✝:1 ≤ s₁hs₁:nSteps weakCollatz16 s₁ (roundCfg (x - (2 * m + 1)) (2 * m + 1)) = some (oddCfg (2 + 2 * m) 0 m)hL:x - (2 * m + 1) + m + 1 = 2 + 2 * m⊢ ∃ s cfg, nSteps weakCollatz16 s (roundCfg (x - (2 * m + 1)) (2 * m + 1)) = some cfg ∧ step weakCollatz16 cfg = none] at hs₁ inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xheq:3 * m + 2 = xhm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2s₁:ℕleft✝:1 ≤ s₁hs₁:nSteps weakCollatz16 s₁ (roundCfg (x - (2 * m + 1)) (2 * m + 1)) = some (oddCfg (2 + 2 * m) 0 m)hL:x - (2 * m + 1) + m + 1 = 2 + 2 * m⊢ ∃ s cfg, nSteps weakCollatz16 s (roundCfg (x - (2 * m + 1)) (2 * m + 1)) = some cfg ∧ step weakCollatz16 cfg = none
obtain ⟨s₂, hs₂⟩ := odd_many 2 0 0 m inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xheq:3 * m + 2 = xhm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2s₁:ℕleft✝:1 ≤ s₁hs₁:nSteps weakCollatz16 s₁ (roundCfg (x - (2 * m + 1)) (2 * m + 1)) = some (oddCfg (2 + 2 * m) 0 m)hL:x - (2 * m + 1) + m + 1 = 2 + 2 * ms₂:ℕhs₂:nSteps weakCollatz16 s₂ (oddCfg (2 + 2 * m) 0 (0 + m)) = some (oddCfg 2 (0 + 3 * m) 0)⊢ ∃ s cfg, nSteps weakCollatz16 s (roundCfg (x - (2 * m + 1)) (2 * m + 1)) = some cfg ∧ step weakCollatz16 cfg = none
simp only [Nat.zero_add] at hs₂ inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xheq:3 * m + 2 = xhm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2s₁:ℕleft✝:1 ≤ s₁hs₁:nSteps weakCollatz16 s₁ (roundCfg (x - (2 * m + 1)) (2 * m + 1)) = some (oddCfg (2 + 2 * m) 0 m)hL:x - (2 * m + 1) + m + 1 = 2 + 2 * ms₂:ℕhs₂:nSteps weakCollatz16 s₂ (oddCfg (2 + 2 * m) 0 m) = some (oddCfg 2 (3 * m) 0)⊢ ∃ s cfg, nSteps weakCollatz16 s (roundCfg (x - (2 * m + 1)) (2 * m + 1)) = some cfg ∧ step weakCollatz16 cfg = none
obtain ⟨s₃, cfg, hs₃, hnone⟩ := odd_done_halt (3 * m) inr x:ℕhx:3 ≤ xm:ℕhy2:2 ≤ 2 * m + 1hyle:2 * m + 1 ≤ xheq:3 * m + 2 = xhm1:1 ≤ mhto:terras (2 * m + 1) = 3 * m + 2s₁:ℕleft✝:1 ≤ s₁hs₁:nSteps weakCollatz16 s₁ (roundCfg (x - (2 * m + 1)) (2 * m + 1)) = some (oddCfg (2 + 2 * m) 0 m)hL:x - (2 * m + 1) + m + 1 = 2 + 2 * ms₂:ℕhs₂:nSteps weakCollatz16 s₂ (oddCfg (2 + 2 * m) 0 m) = some (oddCfg 2 (3 * m) 0)s₃:ℕcfg:Cfg 16 2hs₃:nSteps weakCollatz16 s₃ (oddCfg 2 (3 * m) 0) = some cfghnone:step weakCollatz16 cfg = none⊢ ∃ s cfg, nSteps weakCollatz16 s (roundCfg (x - (2 * m + 1)) (2 * m + 1)) = some cfg ∧ step weakCollatz16 cfg = none
exact ⟨s₁ + s₂ + s₃, cfg, nSteps_bind_eq (nSteps_bind_eq hs₁ hs₂) hs₃, hnone⟩ All goals completed! 🐙private theorem stage_y1_advance (x : ℕ) (hx : 1 ≤ x) :
reachPos (roundCfg (x - 1) 1) (stageCfg (x + 2)) := by x:ℕhx:1 ≤ x⊢ reachPos (roundCfg (x - 1) 1) (stageCfg (x + 2))
have h := round_y1 (x - 1) x:ℕhx:1 ≤ xh:reachPos (roundCfg (x - 1) 1) (stageCfg (x - 1 + 3))⊢ reachPos (roundCfg (x - 1) 1) (stageCfg (x + 2))
rw [show x - 1 + 3 = x + 2 by omega All goals completed! 🐙] at h x:ℕhx:1 ≤ xh:reachPos (roundCfg (x - 1) 1) (stageCfg (x + 2))⊢ reachPos (roundCfg (x - 1) 1) (stageCfg (x + 2))
exact h All goals completed! 🐙private theorem init_reaches_stage2 : reachPos init (stageCfg 2) := by ⊢ reachPos init (stageCfg 2)
change reachPos ⟨0, ⟨0, B0, B0⟩⟩ _ ⊢ reachPos { state := 0, tape := { head := 0, left := B0, right := B0 } } (stageCfg 2)
refine step_then_reachPos (tr0_0 B0 B0) ?_ ⊢ reachPos { state := 8, tape := Tape.mk' (ListBlank.cons 0 B0) B0 } (stageCfg 2)
rw [B0_cons_zero, ⊢ reachPos { state := 8, tape := Tape.mk' B0 B0 } (stageCfg 2) ErdosTernary15.Tape.mk'_B0 ⊢ reachPos { state := 8, tape := { head := 0, left := B0, right := B0 } } (stageCfg 2)] ⊢ reachPos { state := 8, tape := { head := 0, left := B0, right := B0 } } (stageCfg 2)
refine step_then_reachPos (tr8_0 B0 B0) ?_ ⊢ reachPos { state := 7, tape := mkL B0 (ListBlank.cons 0 B0) } (stageCfg 2)
rw [B0_cons_zero, ⊢ reachPos { state := 7, tape := mkL B0 B0 } (stageCfg 2) mkL_B0 ⊢ reachPos { state := 7, tape := { head := 0, left := B0, right := B0 } } (stageCfg 2)] ⊢ reachPos { state := 7, tape := { head := 0, left := B0, right := B0 } } (stageCfg 2)
refine step_then_reachPos (tr7_0 B0 B0) ?_ ⊢ reachPos { state := 5, tape := mkL B0 (ListBlank.cons 0 B0) } (stageCfg 2)
rw [B0_cons_zero, ⊢ reachPos { state := 5, tape := mkL B0 B0 } (stageCfg 2) mkL_B0 ⊢ reachPos { state := 5, tape := { head := 0, left := B0, right := B0 } } (stageCfg 2)] ⊢ reachPos { state := 5, tape := { head := 0, left := B0, right := B0 } } (stageCfg 2)
refine step_then_reachPos (tr5_0 B0 B0) ?_ ⊢ reachPos { state := 9, tape := mkL B0 (ListBlank.cons 0 B0) } (stageCfg 2)
rw [B0_cons_zero, ⊢ reachPos { state := 9, tape := mkL B0 B0 } (stageCfg 2) mkL_B0 ⊢ reachPos { state := 9, tape := { head := 0, left := B0, right := B0 } } (stageCfg 2)] ⊢ reachPos { state := 9, tape := { head := 0, left := B0, right := B0 } } (stageCfg 2)
refine step_then_reachPos (tr9_0 B0 B0) ?_ ⊢ reachPos { state := 10, tape := mkL B0 (ListBlank.cons 1 B0) } (stageCfg 2)
have h1 : B0.cons 1 = ones 1 B0 := rfl h1:ListBlank.cons 1 B0 = ones 1 B0⊢ reachPos { state := 10, tape := mkL B0 (ListBlank.cons 1 B0) } (stageCfg 2)
rw [mkL_B0, h1:ListBlank.cons 1 B0 = ones 1 B0⊢ reachPos { state := 10, tape := { head := 0, left := B0, right := ListBlank.cons 1 B0 } } (stageCfg 2) h1 h1:ListBlank.cons 1 B0 = ones 1 B0⊢ reachPos { state := 10, tape := { head := 0, left := B0, right := ones 1 B0 } } (stageCfg 2)] h1:ListBlank.cons 1 B0 = ones 1 B0⊢ reachPos { state := 10, tape := { head := 0, left := B0, right := ones 1 B0 } } (stageCfg 2)
refine step_then_reachPos (tr10_0 B0 (ones 1 B0)) ?_ h1:ListBlank.cons 1 B0 = ones 1 B0⊢ reachPos { state := 3, tape := Tape.mk' (ListBlank.cons 0 B0) (ones 1 B0) } (stageCfg 2)
rw [B0_cons_zero h1:ListBlank.cons 1 B0 = ones 1 B0⊢ reachPos { state := 3, tape := Tape.mk' B0 (ones 1 B0) } (stageCfg 2)] h1:ListBlank.cons 1 B0 = ones 1 B0⊢ reachPos { state := 3, tape := Tape.mk' B0 (ones 1 B0) } (stageCfg 2)
have hgt := gt_merge 1 0 h1:ListBlank.cons 1 B0 = ones 1 B0hgt:reachPos { state := 3, tape := Tape.mk' B0 (ones 1 (ListBlank.cons 0 (ones 0 B0))) } (stageCfg (1 + 0 + 1))⊢ reachPos { state := 3, tape := Tape.mk' B0 (ones 1 B0) } (stageCfg 2)
rw [ones_zero, h1:ListBlank.cons 1 B0 = ones 1 B0hgt:reachPos { state := 3, tape := Tape.mk' B0 (ones 1 (ListBlank.cons 0 B0)) } (stageCfg (1 + 0 + 1))⊢ reachPos { state := 3, tape := Tape.mk' B0 (ones 1 B0) } (stageCfg 2) B0_cons_zero h1:ListBlank.cons 1 B0 = ones 1 B0hgt:reachPos { state := 3, tape := Tape.mk' B0 (ones 1 B0) } (stageCfg (1 + 0 + 1))⊢ reachPos { state := 3, tape := Tape.mk' B0 (ones 1 B0) } (stageCfg 2)] at hgt h1:ListBlank.cons 1 B0 = ones 1 B0hgt:reachPos { state := 3, tape := Tape.mk' B0 (ones 1 B0) } (stageCfg (1 + 0 + 1))⊢ reachPos { state := 3, tape := Tape.mk' B0 (ones 1 B0) } (stageCfg 2)
exact hgt All goals completed! 🐙private theorem init_reaches_stage4 : reachPos init (stageCfg 4) :=
reachPos_trans init_reaches_stage2 (reachPos_trans (round_even 0 0) (round_y1 1))Even-Stage Cycle-Maximum Dovetailing & Halting Equivalence
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 isTrue y:ℕhy:1 ≤ yh✝:y % 2 = 0⊢ 1 ≤ y / 2isFalse y:ℕhy:1 ≤ yh✝:¬y % 2 = 0⊢ 1 ≤ (3 * y + 1) / 2 <;> isTrue y:ℕhy:1 ≤ yh✝:y % 2 = 0⊢ 1 ≤ y / 2isFalse y:ℕhy:1 ≤ yh✝:¬y % 2 = 0⊢ 1 ≤ (3 * y + 1) / 2 omega All goals completed! 🐙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) (roundCfg (x - terras^[m] x) (terras^[m] x))) := by x:ℕhx:3 ≤ xm:ℕhstay:StayIn x m⊢ m = 0 ∨ 1 ≤ m ∧ reachPos (stageCfg x) (roundCfg (x - terras^[m] x) (terras^[m] x))
induction m with
| zero => zero x:ℕhx:3 ≤ xhstay:StayIn x 0⊢ 0 = 0 ∨ 1 ≤ 0 ∧ reachPos (stageCfg x) (roundCfg (x - terras^[0] 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) (roundCfg (x - terras^[m] x) (terras^[m] x))hstay:StayIn x (m + 1)⊢ m + 1 = 0 ∨ 1 ≤ m + 1 ∧ reachPos (stageCfg x) (roundCfg (x - terras^[m + 1] x) (terras^[m + 1] x))
refine Or.inr ⟨by x:ℕhx:3 ≤ xm:ℕih:StayIn x m → m = 0 ∨ 1 ≤ m ∧ reachPos (stageCfg x) (roundCfg (x - terras^[m] 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) (roundCfg (x - terras^[m] 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) (roundCfg (x - terras^[m] x) (terras^[m] x))hstay:StayIn x (m + 1)hstep:StepContinues x (m + 1)⊢ reachPos (stageCfg x) (roundCfg (x - terras^[m + 1] 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) (roundCfg (x - terras^[m] 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) (roundCfg (x - terras^[0] x) (terras^[0] x))hstay:StayIn x (0 + 1)hstep:StepContinues x (0 + 1)⊢ reachPos (stageCfg x) (roundCfg (x - terras^[0 + 1] 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) (roundCfg (x - terras^[m] 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) (roundCfg (x - terras^[0] 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) (roundCfg (x - terras^[0] 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) (roundCfg (x - terras^[0] 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) (roundCfg (x - terras^[0] x) (terras^[0] x))hstay:StayIn x (0 + 1)hstep:StepContinues x (0 + 1)hlt1:terras x < x⊢ reachPos (stageCfg x) (roundCfg (x - terras^[0 + 1] 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) (roundCfg (x - terras^[0] x) (terras^[0] x))hstay:StayIn x (0 + 1)hstep:StepContinues x (0 + 1)hlt1:terras x < x⊢ reachPos (stageCfg x) (roundCfg (x - terras x) (terras x))] succ.inl x:ℕhx:3 ≤ xih:StayIn x 0 → 0 = 0 ∨ 1 ≤ 0 ∧ reachPos (stageCfg x) (roundCfg (x - terras^[0] x) (terras^[0] x))hstay:StayIn x (0 + 1)hstep:StepContinues x (0 + 1)hlt1:terras x < x⊢ reachPos (stageCfg x) (roundCfg (x - terras x) (terras x))
have h0 : stageCfg x = roundCfg (x - x) x := by x:ℕhx:3 ≤ xm:ℕhstay:StayIn x m⊢ m = 0 ∨ 1 ≤ m ∧ reachPos (stageCfg x) (roundCfg (x - terras^[m] x) (terras^[m] x)) unfold stageCfg x:ℕhx:3 ≤ xih:StayIn x 0 → 0 = 0 ∨ 1 ≤ 0 ∧ reachPos (stageCfg x) (roundCfg (x - terras^[0] x) (terras^[0] x))hstay:StayIn x (0 + 1)hstep:StepContinues x (0 + 1)hlt1:terras x < x⊢ roundCfg 0 x = roundCfg (x - x) x; rw [Nat.sub_self x:ℕhx:3 ≤ xih:StayIn x 0 → 0 = 0 ∨ 1 ≤ 0 ∧ reachPos (stageCfg x) (roundCfg (x - terras^[0] x) (terras^[0] x))hstay:StayIn x (0 + 1)hstep:StepContinues x (0 + 1)hlt1:terras x < x⊢ roundCfg 0 x = roundCfg 0 x] succ.inl x:ℕhx:3 ≤ xih:StayIn x 0 → 0 = 0 ∨ 1 ≤ 0 ∧ reachPos (stageCfg x) (roundCfg (x - terras^[0] x) (terras^[0] x))hstay:StayIn x (0 + 1)hstep:StepContinues x (0 + 1)hlt1:terras x < xh0:stageCfg x = roundCfg (x - x) x⊢ reachPos (stageCfg x) (roundCfg (x - terras x) (terras x))
rw [h0 succ.inl x:ℕhx:3 ≤ xih:StayIn x 0 → 0 = 0 ∨ 1 ≤ 0 ∧ reachPos (stageCfg x) (roundCfg (x - terras^[0] x) (terras^[0] x))hstay:StayIn x (0 + 1)hstep:StepContinues x (0 + 1)hlt1:terras x < xh0:stageCfg x = roundCfg (x - x) x⊢ reachPos (roundCfg (x - x) x) (roundCfg (x - terras x) (terras x))] succ.inl x:ℕhx:3 ≤ xih:StayIn x 0 → 0 = 0 ∨ 1 ≤ 0 ∧ reachPos (stageCfg x) (roundCfg (x - terras^[0] x) (terras^[0] x))hstay:StayIn x (0 + 1)hstep:StepContinues x (0 + 1)hlt1:terras x < xh0:stageCfg x = roundCfg (x - x) x⊢ reachPos (roundCfg (x - x) x) (roundCfg (x - terras x) (terras x))
exact stage_round_lt x x (by x:ℕhx:3 ≤ xih:StayIn x 0 → 0 = 0 ∨ 1 ≤ 0 ∧ reachPos (stageCfg x) (roundCfg (x - terras^[0] x) (terras^[0] x))hstay:StayIn x (0 + 1)hstep:StepContinues x (0 + 1)hlt1:terras x < xh0:stageCfg x = roundCfg (x - x) x⊢ 2 ≤ x omega All goals completed! 🐙) le_rfl hlt1
· succ.inr x:ℕhx:3 ≤ xm:ℕih:StayIn x m → m = 0 ∨ 1 ≤ m ∧ reachPos (stageCfg x) (roundCfg (x - terras^[m] x) (terras^[m] x))hstay:StayIn x (m + 1)hstep:StepContinues x (m + 1)hm1:1 ≤ mhprev:reachPos (stageCfg x) (roundCfg (x - terras^[m] x) (terras^[m] x))⊢ reachPos (stageCfg x) (roundCfg (x - terras^[m + 1] x) (terras^[m + 1] x)) have hym := hstay m hm1 (by x:ℕhx:3 ≤ xm:ℕih:StayIn x m → m = 0 ∨ 1 ≤ m ∧ reachPos (stageCfg x) (roundCfg (x - terras^[m] x) (terras^[m] x))hstay:StayIn x (m + 1)hstep:StepContinues x (m + 1)hm1:1 ≤ mhprev:reachPos (stageCfg x) (roundCfg (x - terras^[m] x) (terras^[m] x))⊢ m ≤ m + 1 omega All goals completed! 🐙) succ.inr x:ℕhx:3 ≤ xm:ℕih:StayIn x m → m = 0 ∨ 1 ≤ m ∧ reachPos (stageCfg x) (roundCfg (x - terras^[m] x) (terras^[m] x))hstay:StayIn x (m + 1)hstep:StepContinues x (m + 1)hm1:1 ≤ mhprev:reachPos (stageCfg x) (roundCfg (x - terras^[m] x) (terras^[m] x))hym:StepContinues x m⊢ reachPos (stageCfg x) (roundCfg (x - terras^[m + 1] 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) (roundCfg (x - terras^[m] 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) (roundCfg (x - terras^[m] x) (terras^[m] x))hstay:StayIn x (m + 1)hstep:StepContinues x (m + 1)hm1:1 ≤ mhprev:reachPos (stageCfg x) (roundCfg (x - terras^[m] x) (terras^[m] x))hym:StepContinues x m⊢ terras^[m.succ] x < x] x:ℕhx:3 ≤ xm:ℕih:StayIn x m → m = 0 ∨ 1 ≤ m ∧ reachPos (stageCfg x) (roundCfg (x - terras^[m] x) (terras^[m] x))hstay:StayIn x (m + 1)hstep:StepContinues x (m + 1)hm1:1 ≤ mhprev:reachPos (stageCfg x) (roundCfg (x - terras^[m] x) (terras^[m] x))hym:StepContinues x m⊢ 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) (roundCfg (x - terras^[m] x) (terras^[m] x))hstay:StayIn x (m + 1)hstep:StepContinues x (m + 1)hm1:1 ≤ mhprev:reachPos (stageCfg x) (roundCfg (x - terras^[m] x) (terras^[m] x))hym:StepContinues x mhlt:terras (terras^[m] x) < x⊢ reachPos (stageCfg x) (roundCfg (x - terras^[m + 1] 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) (roundCfg (x - terras^[m] x) (terras^[m] x))hstay:StayIn x (m + 1)hstep:StepContinues x (m + 1)hm1:1 ≤ mhprev:reachPos (stageCfg x) (roundCfg (x - terras^[m] x) (terras^[m] x))hym:StepContinues x mhlt:terras (terras^[m] x) < x⊢ reachPos (stageCfg x) (roundCfg (x - terras (terras^[m] x)) (terras (terras^[m] x)))] succ.inr x:ℕhx:3 ≤ xm:ℕih:StayIn x m → m = 0 ∨ 1 ≤ m ∧ reachPos (stageCfg x) (roundCfg (x - terras^[m] x) (terras^[m] x))hstay:StayIn x (m + 1)hstep:StepContinues x (m + 1)hm1:1 ≤ mhprev:reachPos (stageCfg x) (roundCfg (x - terras^[m] x) (terras^[m] x))hym:StepContinues x mhlt:terras (terras^[m] x) < x⊢ reachPos (stageCfg x) (roundCfg (x - terras (terras^[m] x)) (terras (terras^[m] x)))
exact reachPos_trans hprev
(stage_round_lt x (terras^[m] x) hym.1 (le_of_lt hym.2) hlt) All goals completed! 🐙private def StageHalts (x : ℕ) : Prop :=
∃ t : ℕ, 1 ≤ t ∧ t ≤ x ∧ StayIn x (t - 1) ∧ terras^[t] x = xprivate theorem even_of_stageHalts {w : ℕ} (hw3 : 3 ≤ w) (hh : StageHalts w) :
∃ m : ℕ, 2 ≤ m ∧ w = 2 * m := by w:ℕhw3:3 ≤ whh:StageHalts w⊢ ∃ m, 2 ≤ m ∧ w = 2 * m
obtain ⟨t, ht1, _, hprev, hhit⟩ := hh w:ℕhw3:3 ≤ wt:ℕht1:1 ≤ tleft✝:t ≤ whprev:StayIn w (t - 1)hhit:terras^[t] w = w⊢ ∃ m, 2 ≤ m ∧ w = 2 * m
rcases even_or_odd_constructive w with ⟨m, rfl | rfl⟩ inl t:ℕht1:1 ≤ tm:ℕhw3:3 ≤ 2 * mleft✝:t ≤ 2 * mhprev:StayIn (2 * m) (t - 1)hhit:terras^[t] (2 * m) = 2 * m⊢ ∃ m_1, 2 ≤ m_1 ∧ 2 * m = 2 * m_1inr t:ℕht1:1 ≤ tm:ℕhw3:3 ≤ 2 * m + 1left✝:t ≤ 2 * m + 1hprev:StayIn (2 * m + 1) (t - 1)hhit:terras^[t] (2 * m + 1) = 2 * m + 1⊢ ∃ m_1, 2 ≤ m_1 ∧ 2 * m + 1 = 2 * m_1
· inl t:ℕht1:1 ≤ tm:ℕhw3:3 ≤ 2 * mleft✝:t ≤ 2 * mhprev:StayIn (2 * m) (t - 1)hhit:terras^[t] (2 * m) = 2 * m⊢ ∃ m_1, 2 ≤ m_1 ∧ 2 * m = 2 * m_1 exact ⟨m, by t:ℕht1:1 ≤ tm:ℕhw3:3 ≤ 2 * mleft✝:t ≤ 2 * mhprev:StayIn (2 * m) (t - 1)hhit:terras^[t] (2 * m) = 2 * m⊢ 2 ≤ m omega All goals completed! 🐙, rfl⟩
· inr t:ℕht1:1 ≤ tm:ℕhw3:3 ≤ 2 * m + 1left✝:t ≤ 2 * m + 1hprev:StayIn (2 * m + 1) (t - 1)hhit:terras^[t] (2 * m + 1) = 2 * m + 1⊢ ∃ m_1, 2 ≤ m_1 ∧ 2 * m + 1 = 2 * m_1 exfalso inr t:ℕht1:1 ≤ tm:ℕhw3:3 ≤ 2 * m + 1left✝:t ≤ 2 * m + 1hprev:StayIn (2 * m + 1) (t - 1)hhit:terras^[t] (2 * m + 1) = 2 * m + 1⊢ False
have hto : terras (2 * m + 1) = 3 * m + 2 := by w:ℕhw3:3 ≤ whh:StageHalts w⊢ ∃ m, 2 ≤ m ∧ w = 2 * m unfold terras t:ℕht1:1 ≤ tm:ℕhw3:3 ≤ 2 * m + 1left✝:t ≤ 2 * m + 1hprev:StayIn (2 * m + 1) (t - 1)hhit:terras^[t] (2 * m + 1) = 2 * m + 1⊢ (if (2 * m + 1) % 2 = 0 then (2 * m + 1) / 2 else (3 * (2 * m + 1) + 1) / 2) = 3 * m + 2; split isTrue t:ℕht1:1 ≤ tm:ℕhw3:3 ≤ 2 * m + 1left✝:t ≤ 2 * m + 1hprev:StayIn (2 * m + 1) (t - 1)hhit:terras^[t] (2 * m + 1) = 2 * m + 1h✝:(2 * m + 1) % 2 = 0⊢ (2 * m + 1) / 2 = 3 * m + 2isFalse t:ℕht1:1 ≤ tm:ℕhw3:3 ≤ 2 * m + 1left✝:t ≤ 2 * m + 1hprev:StayIn (2 * m + 1) (t - 1)hhit:terras^[t] (2 * m + 1) = 2 * m + 1h✝:¬(2 * m + 1) % 2 = 0⊢ (3 * (2 * m + 1) + 1) / 2 = 3 * m + 2 <;> isTrue t:ℕht1:1 ≤ tm:ℕhw3:3 ≤ 2 * m + 1left✝:t ≤ 2 * m + 1hprev:StayIn (2 * m + 1) (t - 1)hhit:terras^[t] (2 * m + 1) = 2 * m + 1h✝:(2 * m + 1) % 2 = 0⊢ (2 * m + 1) / 2 = 3 * m + 2isFalse t:ℕht1:1 ≤ tm:ℕhw3:3 ≤ 2 * m + 1left✝:t ≤ 2 * m + 1hprev:StayIn (2 * m + 1) (t - 1)hhit:terras^[t] (2 * m + 1) = 2 * m + 1h✝:¬(2 * m + 1) % 2 = 0⊢ (3 * (2 * m + 1) + 1) / 2 = 3 * m + 2 omega inr t:ℕht1:1 ≤ tm:ℕhw3:3 ≤ 2 * m + 1left✝:t ≤ 2 * m + 1hprev:StayIn (2 * m + 1) (t - 1)hhit:terras^[t] (2 * m + 1) = 2 * m + 1hto:terras (2 * m + 1) = 3 * m + 2⊢ False
by_cases ht_eq1 : t = 1 pos t:ℕht1:1 ≤ tm:ℕhw3:3 ≤ 2 * m + 1left✝:t ≤ 2 * m + 1hprev:StayIn (2 * m + 1) (t - 1)hhit:terras^[t] (2 * m + 1) = 2 * m + 1hto:terras (2 * m + 1) = 3 * m + 2ht_eq1:t = 1⊢ Falseneg t:ℕht1:1 ≤ tm:ℕhw3:3 ≤ 2 * m + 1left✝:t ≤ 2 * m + 1hprev:StayIn (2 * m + 1) (t - 1)hhit:terras^[t] (2 * m + 1) = 2 * m + 1hto:terras (2 * m + 1) = 3 * m + 2ht_eq1:¬t = 1⊢ False
· pos t:ℕht1:1 ≤ tm:ℕhw3:3 ≤ 2 * m + 1left✝:t ≤ 2 * m + 1hprev:StayIn (2 * m + 1) (t - 1)hhit:terras^[t] (2 * m + 1) = 2 * m + 1hto:terras (2 * m + 1) = 3 * m + 2ht_eq1:t = 1⊢ False subst ht_eq1 pos m:ℕhw3:3 ≤ 2 * m + 1hto:terras (2 * m + 1) = 3 * m + 2ht1:1 ≤ 1left✝:1 ≤ 2 * m + 1hprev:StayIn (2 * m + 1) (1 - 1)hhit:terras^[1] (2 * m + 1) = 2 * m + 1⊢ False
rw [Function.iterate_one, pos m:ℕhw3:3 ≤ 2 * m + 1hto:terras (2 * m + 1) = 3 * m + 2ht1:1 ≤ 1left✝:1 ≤ 2 * m + 1hprev:StayIn (2 * m + 1) (1 - 1)hhit:terras (2 * m + 1) = 2 * m + 1⊢ False hto pos m:ℕhw3:3 ≤ 2 * m + 1hto:terras (2 * m + 1) = 3 * m + 2ht1:1 ≤ 1left✝:1 ≤ 2 * m + 1hprev:StayIn (2 * m + 1) (1 - 1)hhit:3 * m + 2 = 2 * m + 1⊢ False] at hhit pos m:ℕhw3:3 ≤ 2 * m + 1hto:terras (2 * m + 1) = 3 * m + 2ht1:1 ≤ 1left✝:1 ≤ 2 * m + 1hprev:StayIn (2 * m + 1) (1 - 1)hhit:3 * m + 2 = 2 * m + 1⊢ False
omega All goals completed! 🐙
· neg t:ℕht1:1 ≤ tm:ℕhw3:3 ≤ 2 * m + 1left✝:t ≤ 2 * m + 1hprev:StayIn (2 * m + 1) (t - 1)hhit:terras^[t] (2 * m + 1) = 2 * m + 1hto:terras (2 * m + 1) = 3 * m + 2ht_eq1:¬t = 1⊢ False have hs1 : StepContinues (2 * m + 1) 1 := hprev 1 le_rfl (by t:ℕht1:1 ≤ tm:ℕhw3:3 ≤ 2 * m + 1left✝:t ≤ 2 * m + 1hprev:StayIn (2 * m + 1) (t - 1)hhit:terras^[t] (2 * m + 1) = 2 * m + 1hto:terras (2 * m + 1) = 3 * m + 2ht_eq1:¬t = 1⊢ 1 ≤ t - 1 omega All goals completed! 🐙) neg t:ℕht1:1 ≤ tm:ℕhw3:3 ≤ 2 * m + 1left✝:t ≤ 2 * m + 1hprev:StayIn (2 * m + 1) (t - 1)hhit:terras^[t] (2 * m + 1) = 2 * m + 1hto:terras (2 * m + 1) = 3 * m + 2ht_eq1:¬t = 1hs1:StepContinues (2 * m + 1) 1⊢ False
have hlt1 : terras (2 * m + 1) < 2 * m + 1 := by w:ℕhw3:3 ≤ whh:StageHalts w⊢ ∃ m, 2 ≤ m ∧ w = 2 * m
have h1 : terras (2 * m + 1) = terras^[1] (2 * m + 1) := rfl t:ℕht1:1 ≤ tm:ℕhw3:3 ≤ 2 * m + 1left✝:t ≤ 2 * m + 1hprev:StayIn (2 * m + 1) (t - 1)hhit:terras^[t] (2 * m + 1) = 2 * m + 1hto:terras (2 * m + 1) = 3 * m + 2ht_eq1:¬t = 1hs1:StepContinues (2 * m + 1) 1h1:terras (2 * m + 1) = terras^[1] (2 * m + 1)⊢ terras (2 * m + 1) < 2 * m + 1
rw [h1 t:ℕht1:1 ≤ tm:ℕhw3:3 ≤ 2 * m + 1left✝:t ≤ 2 * m + 1hprev:StayIn (2 * m + 1) (t - 1)hhit:terras^[t] (2 * m + 1) = 2 * m + 1hto:terras (2 * m + 1) = 3 * m + 2ht_eq1:¬t = 1hs1:StepContinues (2 * m + 1) 1h1:terras (2 * m + 1) = terras^[1] (2 * m + 1)⊢ terras^[1] (2 * m + 1) < 2 * m + 1] t:ℕht1:1 ≤ tm:ℕhw3:3 ≤ 2 * m + 1left✝:t ≤ 2 * m + 1hprev:StayIn (2 * m + 1) (t - 1)hhit:terras^[t] (2 * m + 1) = 2 * m + 1hto:terras (2 * m + 1) = 3 * m + 2ht_eq1:¬t = 1hs1:StepContinues (2 * m + 1) 1h1:terras (2 * m + 1) = terras^[1] (2 * m + 1)⊢ terras^[1] (2 * m + 1) < 2 * m + 1
exact hs1.2 neg t:ℕht1:1 ≤ tm:ℕhw3:3 ≤ 2 * m + 1left✝:t ≤ 2 * m + 1hprev:StayIn (2 * m + 1) (t - 1)hhit:terras^[t] (2 * m + 1) = 2 * m + 1hto:terras (2 * m + 1) = 3 * m + 2ht_eq1:¬t = 1hs1:StepContinues (2 * m + 1) 1hlt1:terras (2 * m + 1) < 2 * m + 1⊢ False
omega All goals completed! 🐙private 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) (stageCfg (x + 2)) := by x:ℕhx:3 ≤ xhno:NoStageHalts x⊢ reachPos (stageCfg x) (stageCfg (x + 2))
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) (stageCfg (x + 2))inr x:ℕhx:3 ≤ xhno:NoStageHalts xt:ℕht1:1 ≤ thtx:t ≤ xhprev:StayIn x (t - 1)hexit:¬StepContinues x t⊢ reachPos (stageCfg x) (stageCfg (x + 2))
· inl x:ℕhx:3 ≤ xhno:NoStageHalts xhstay:StayIn x x⊢ reachPos (stageCfg x) (stageCfg (x + 2)) 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) (stageCfg (x + 2)) 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) (stageCfg (x + 2))
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) (stageCfg (x + 2))
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) (stageCfg (x + 2))
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) (stageCfg (x + 2))
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) (stageCfg (x + 2))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) (roundCfg (x - terras^[t - 1] x) (terras^[t - 1] x))⊢ reachPos (stageCfg x) (stageCfg (x + 2))
· 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) (stageCfg (x + 2)) 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) (stageCfg (x + 2))
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) (stageCfg (x + 2))
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) (stageCfg (x + 2))] 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) (stageCfg (x + 2))
have h0 : stageCfg x = roundCfg (x - x) x := by unfold stageCfg 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⊢ roundCfg 0 x = roundCfg (x - x) x; rw [Nat.sub_self 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⊢ roundCfg 0 x = roundCfg 0 x] 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 = 0h0:stageCfg x = roundCfg (x - x) x⊢ reachPos (stageCfg x) (stageCfg (x + 2))
rw [h0 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 = 0h0:stageCfg x = roundCfg (x - x) x⊢ reachPos (roundCfg (x - x) x) (stageCfg (x + 2))] 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 = 0h0:stageCfg x = roundCfg (x - x) x⊢ reachPos (roundCfg (x - x) x) (stageCfg (x + 2))
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 = 0h0:stageCfg x = roundCfg (x - x) xh1:terras x = 1⊢ reachPos (roundCfg (x - x) x) (stageCfg (x + 2))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 = 0h0:stageCfg x = roundCfg (x - x) xhgt:x < terras x⊢ reachPos (roundCfg (x - x) x) (stageCfg (x + 2))
· 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 = 0h0:stageCfg x = roundCfg (x - x) xh1:terras x = 1⊢ reachPos (roundCfg (x - x) x) (stageCfg (x + 2)) 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 = 0h0:stageCfg x = roundCfg (x - x) xh1:terras x = 1⊢ 2 ≤ x omega All goals completed! 🐙) le_rfl (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 = 0h0:stageCfg x = roundCfg (x - x) xh1: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 = 0h0:stageCfg x = roundCfg (x - x) xh1:terras x = 1hlt:reachPos (roundCfg (x - x) x) (roundCfg (x - terras x) (terras x))⊢ reachPos (roundCfg (x - x) x) (stageCfg (x + 2))
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 = 0h0:stageCfg x = roundCfg (x - x) xh1:terras x = 1hlt:reachPos (roundCfg (x - x) x) (roundCfg (x - 1) 1)⊢ reachPos (roundCfg (x - x) x) (stageCfg (x + 2))] 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 = 0h0:stageCfg x = roundCfg (x - x) xh1:terras x = 1hlt:reachPos (roundCfg (x - x) x) (roundCfg (x - 1) 1)⊢ reachPos (roundCfg (x - x) x) (stageCfg (x + 2))
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 = 0h0:stageCfg x = roundCfg (x - x) xh1:terras x = 1hlt:reachPos (roundCfg (x - x) x) (roundCfg (x - 1) 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 = 0h0:stageCfg x = roundCfg (x - x) xhgt:x < terras x⊢ reachPos (roundCfg (x - x) x) (stageCfg (x + 2)) 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 = 0h0:stageCfg x = roundCfg (x - x) xhgt:x < terras x⊢ 2 ≤ x omega All goals completed! 🐙) le_rfl 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) (roundCfg (x - terras^[t - 1] x) (terras^[t - 1] x))⊢ reachPos (stageCfg x) (stageCfg (x + 2)) have hy_prev := hprev (t - 1) ht1_pos le_rfl 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) (roundCfg (x - terras^[t - 1] x) (terras^[t - 1] x))hy_prev:StepContinues x (t - 1)⊢ reachPos (stageCfg x) (stageCfg (x + 2))
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) (roundCfg (x - terras^[t - 1] x) (terras^[t - 1] x))hy_prev:StepContinues x (t - 1)⊢ terras^[(t - 1).succ] x = terras^[t] x show (t - 1).succ = t by x:ℕhx:3 ≤ xhno:NoStageHalts x⊢ reachPos (stageCfg x) (stageCfg (x + 2)) 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) (roundCfg (x - terras^[t - 1] x) (terras^[t - 1] x))hy_prev:StepContinues x (t - 1)hnext:terras (terras^[t - 1] x) = terras^[t] x⊢ reachPos (stageCfg x) (stageCfg (x + 2))
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) (roundCfg (x - terras^[t - 1] x) (terras^[t - 1] x))hy_prev:StepContinues x (t - 1)hnext:terras (terras^[t - 1] x) = terras^[t] xh1:terras^[t] x = 1⊢ reachPos (stageCfg x) (stageCfg (x + 2))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) (roundCfg (x - terras^[t - 1] x) (terras^[t - 1] x))hy_prev:StepContinues x (t - 1)hnext:terras (terras^[t - 1] x) = terras^[t] xhgt:x < terras^[t] x⊢ reachPos (stageCfg x) (stageCfg (x + 2))
· 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) (roundCfg (x - terras^[t - 1] x) (terras^[t - 1] x))hy_prev:StepContinues x (t - 1)hnext:terras (terras^[t - 1] x) = terras^[t] xh1:terras^[t] x = 1⊢ reachPos (stageCfg x) (stageCfg (x + 2)) have hlt :=
stage_round_lt x (terras^[t - 1] x) hy_prev.1 (le_of_lt hy_prev.2)
(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) (roundCfg (x - terras^[t - 1] x) (terras^[t - 1] x))hy_prev:StepContinues x (t - 1)hnext: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) (roundCfg (x - terras^[t - 1] x) (terras^[t - 1] x))hy_prev:StepContinues x (t - 1)hnext: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) (roundCfg (x - terras^[t - 1] x) (terras^[t - 1] x))hy_prev:StepContinues x (t - 1)hnext: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) (roundCfg (x - terras^[t - 1] x) (terras^[t - 1] x))hy_prev:StepContinues x (t - 1)hnext:terras (terras^[t - 1] x) = terras^[t] xh1:terras^[t] x = 1hlt:reachPos (roundCfg (x - terras^[t - 1] x) (terras^[t - 1] x))
(roundCfg (x - terras (terras^[t - 1] x)) (terras (terras^[t - 1] x)))⊢ reachPos (stageCfg x) (stageCfg (x + 2))
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) (roundCfg (x - terras^[t - 1] x) (terras^[t - 1] x))hy_prev:StepContinues x (t - 1)hnext:terras (terras^[t - 1] x) = terras^[t] xh1:terras^[t] x = 1hlt:reachPos (roundCfg (x - terras^[t - 1] x) (terras^[t - 1] x)) (roundCfg (x - terras^[t] x) (terras^[t] x))⊢ reachPos (stageCfg x) (stageCfg (x + 2)) 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) (roundCfg (x - terras^[t - 1] x) (terras^[t - 1] x))hy_prev:StepContinues x (t - 1)hnext:terras (terras^[t - 1] x) = terras^[t] xh1:terras^[t] x = 1hlt:reachPos (roundCfg (x - terras^[t - 1] x) (terras^[t - 1] x)) (roundCfg (x - 1) 1)⊢ reachPos (stageCfg x) (stageCfg (x + 2))] 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) (roundCfg (x - terras^[t - 1] x) (terras^[t - 1] x))hy_prev:StepContinues x (t - 1)hnext:terras (terras^[t - 1] x) = terras^[t] xh1:terras^[t] x = 1hlt:reachPos (roundCfg (x - terras^[t - 1] x) (terras^[t - 1] x)) (roundCfg (x - 1) 1)⊢ reachPos (stageCfg x) (stageCfg (x + 2))
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) (roundCfg (x - terras^[t - 1] x) (terras^[t - 1] x))hy_prev:StepContinues x (t - 1)hnext:terras (terras^[t - 1] x) = terras^[t] xh1:terras^[t] x = 1hlt:reachPos (roundCfg (x - terras^[t - 1] x) (terras^[t - 1] x)) (roundCfg (x - 1) 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) (roundCfg (x - terras^[t - 1] x) (terras^[t - 1] x))hy_prev:StepContinues x (t - 1)hnext:terras (terras^[t - 1] x) = terras^[t] xhgt:x < terras^[t] x⊢ reachPos (stageCfg x) (stageCfg (x + 2)) 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) (roundCfg (x - terras^[t - 1] x) (terras^[t - 1] x))hy_prev:StepContinues x (t - 1)hnext:terras (terras^[t - 1] x) = terras^[t] xhgt:x < terras (terras^[t - 1] x)⊢ reachPos (stageCfg x) (stageCfg (x + 2))] 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) (roundCfg (x - terras^[t - 1] x) (terras^[t - 1] x))hy_prev:StepContinues x (t - 1)hnext:terras (terras^[t - 1] x) = terras^[t] xhgt:x < terras (terras^[t - 1] x)⊢ reachPos (stageCfg x) (stageCfg (x + 2))
exact reachPos_trans hreach_prev
(stage_round_gt x (terras^[t - 1] x) hx hy_prev.1 (le_of_lt hy_prev.2) hgt) All goals completed! 🐙private theorem reach_even_stage_from_init (m : ℕ) (hm : 2 ≤ m)
(hno : NoStageHalts (2 * m - 1)) :
∃ s : ℕ, m - 1 ≤ s ∧ nSteps weakCollatz16 s init = some (stageCfg (2 * m)) := by m:ℕhm:2 ≤ mhno:NoStageHalts (2 * m - 1)⊢ ∃ s, m - 1 ≤ s ∧ nSteps weakCollatz16 s init = some (stageCfg (2 * m))
induction m, hm using Nat.le_induction with
| base => base m:ℕhno:NoStageHalts (2 * 2 - 1)⊢ ∃ s, 2 - 1 ≤ s ∧ nSteps weakCollatz16 s init = some (stageCfg (2 * 2))
obtain ⟨s, hs1, hs⟩ := init_reaches_stage4 base m:ℕhno:NoStageHalts (2 * 2 - 1)s:ℕhs1:1 ≤ shs:nSteps weakCollatz16 s init = some (stageCfg 4)⊢ ∃ s, 2 - 1 ≤ s ∧ nSteps weakCollatz16 s init = some (stageCfg (2 * 2))
exact ⟨s, by m:ℕhno:NoStageHalts (2 * 2 - 1)s:ℕhs1:1 ≤ shs:nSteps weakCollatz16 s init = some (stageCfg 4)⊢ 2 - 1 ≤ s omega All goals completed! 🐙, hs⟩
| succ m hm ih => succ m✝:ℕm:ℕhm:2 ≤ mih:NoStageHalts (2 * m - 1) → ∃ s, m - 1 ≤ s ∧ nSteps weakCollatz16 s init = some (stageCfg (2 * m))hno:NoStageHalts (2 * (m + 1) - 1)⊢ ∃ s, m + 1 - 1 ≤ s ∧ nSteps weakCollatz16 s init = some (stageCfg (2 * (m + 1)))
obtain ⟨s₁, hs₁_ge, hs₁⟩ := ih fun w hw3 hw_le => hno w hw3 (by m✝:ℕm:ℕhm:2 ≤ mih:NoStageHalts (2 * m - 1) → ∃ s, m - 1 ≤ s ∧ nSteps weakCollatz16 s init = some (stageCfg (2 * m))hno:NoStageHalts (2 * (m + 1) - 1)w:ℕhw3:3 ≤ whw_le:w ≤ 2 * m - 1⊢ w ≤ 2 * (m + 1) - 1 omega All goals completed! 🐙) succ m✝:ℕm:ℕhm:2 ≤ mih:NoStageHalts (2 * m - 1) → ∃ s, m - 1 ≤ s ∧ nSteps weakCollatz16 s init = some (stageCfg (2 * m))hno:NoStageHalts (2 * (m + 1) - 1)s₁:ℕhs₁_ge:m - 1 ≤ s₁hs₁:nSteps weakCollatz16 s₁ init = some (stageCfg (2 * m))⊢ ∃ s, m + 1 - 1 ≤ s ∧ nSteps weakCollatz16 s init = some (stageCfg (2 * (m + 1)))
obtain ⟨s₂, hs₂_pos, hs₂⟩ :=
stage_advance_of_noStageHalts (2 * m) (by m✝:ℕm:ℕhm:2 ≤ mih:NoStageHalts (2 * m - 1) → ∃ s, m - 1 ≤ s ∧ nSteps weakCollatz16 s init = some (stageCfg (2 * m))hno:NoStageHalts (2 * (m + 1) - 1)s₁:ℕhs₁_ge:m - 1 ≤ s₁hs₁:nSteps weakCollatz16 s₁ init = some (stageCfg (2 * m))⊢ 3 ≤ 2 * m omega All goals completed! 🐙) fun w hw3 hw_le => hno w hw3 (by m✝:ℕm:ℕhm:2 ≤ mih:NoStageHalts (2 * m - 1) → ∃ s, m - 1 ≤ s ∧ nSteps weakCollatz16 s init = some (stageCfg (2 * m))hno:NoStageHalts (2 * (m + 1) - 1)s₁:ℕhs₁_ge:m - 1 ≤ s₁hs₁:nSteps weakCollatz16 s₁ init = some (stageCfg (2 * m))w:ℕhw3:3 ≤ whw_le:w ≤ 2 * m⊢ w ≤ 2 * (m + 1) - 1 omega All goals completed! 🐙) succ m✝:ℕm:ℕhm:2 ≤ mih:NoStageHalts (2 * m - 1) → ∃ s, m - 1 ≤ s ∧ nSteps weakCollatz16 s init = some (stageCfg (2 * m))hno:NoStageHalts (2 * (m + 1) - 1)s₁:ℕhs₁_ge:m - 1 ≤ s₁hs₁:nSteps weakCollatz16 s₁ init = some (stageCfg (2 * m))s₂:ℕhs₂_pos:1 ≤ s₂hs₂:nSteps weakCollatz16 s₂ (stageCfg (2 * m)) = some (stageCfg (2 * m + 2))⊢ ∃ s, m + 1 - 1 ≤ s ∧ nSteps weakCollatz16 s init = some (stageCfg (2 * (m + 1)))
rw [show 2 * m + 2 = 2 * (m + 1) by m:ℕhm:2 ≤ mhno:NoStageHalts (2 * m - 1)⊢ ∃ s, m - 1 ≤ s ∧ nSteps weakCollatz16 s init = some (stageCfg (2 * m)) omega All goals completed! 🐙] at hs₂ succ m✝:ℕm:ℕhm:2 ≤ mih:NoStageHalts (2 * m - 1) → ∃ s, m - 1 ≤ s ∧ nSteps weakCollatz16 s init = some (stageCfg (2 * m))hno:NoStageHalts (2 * (m + 1) - 1)s₁:ℕhs₁_ge:m - 1 ≤ s₁hs₁:nSteps weakCollatz16 s₁ init = some (stageCfg (2 * m))s₂:ℕhs₂_pos:1 ≤ s₂hs₂:nSteps weakCollatz16 s₂ (stageCfg (2 * m)) = some (stageCfg (2 * (m + 1)))⊢ ∃ s, m + 1 - 1 ≤ s ∧ nSteps weakCollatz16 s init = some (stageCfg (2 * (m + 1)))
exact ⟨s₁ + s₂, by m✝:ℕm:ℕhm:2 ≤ mih:NoStageHalts (2 * m - 1) → ∃ s, m - 1 ≤ s ∧ nSteps weakCollatz16 s init = some (stageCfg (2 * m))hno:NoStageHalts (2 * (m + 1) - 1)s₁:ℕhs₁_ge:m - 1 ≤ s₁hs₁:nSteps weakCollatz16 s₁ init = some (stageCfg (2 * m))s₂:ℕhs₂_pos:1 ≤ s₂hs₂:nSteps weakCollatz16 s₂ (stageCfg (2 * m)) = some (stageCfg (2 * (m + 1)))⊢ m + 1 - 1 ≤ 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 weakCollatz16 s (stageCfg x) = some cfg ∧
step weakCollatz16 cfg = none := by x:ℕhx:3 ≤ xhhalt:StageHalts x⊢ ∃ s cfg, nSteps weakCollatz16 s (stageCfg x) = some cfg ∧ step weakCollatz16 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 weakCollatz16 s (stageCfg x) = some cfg ∧ step weakCollatz16 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 weakCollatz16 s (stageCfg x) = some cfg ∧ step weakCollatz16 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) (roundCfg (x - terras^[t - 1] x) (terras^[t - 1] x))⊢ ∃ s cfg, nSteps weakCollatz16 s (stageCfg x) = some cfg ∧ step weakCollatz16 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 weakCollatz16 s (stageCfg x) = some cfg ∧ step weakCollatz16 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 weakCollatz16 s (stageCfg x) = some cfg ∧ step weakCollatz16 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 weakCollatz16 s (stageCfg x) = some cfg ∧ step weakCollatz16 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 weakCollatz16 s (stageCfg x) = some cfg ∧ step weakCollatz16 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 weakCollatz16 s (stageCfg x) = some cfg ∧ step weakCollatz16 cfg = none
have h0 : stageCfg x = roundCfg (x - x) x := by unfold stageCfg x:ℕhx:3 ≤ xht1:1 ≤ 1left✝:1 ≤ xhprev:StayIn x (1 - 1)hhit:terras x = xht0:1 - 1 = 0⊢ roundCfg 0 x = roundCfg (x - x) x; rw [Nat.sub_self x:ℕhx:3 ≤ xht1:1 ≤ 1left✝:1 ≤ xhprev:StayIn x (1 - 1)hhit:terras x = xht0:1 - 1 = 0⊢ roundCfg 0 x = roundCfg 0 x] inl x:ℕhx:3 ≤ xht1:1 ≤ 1left✝:1 ≤ xhprev:StayIn x (1 - 1)hhit:terras x = xht0:1 - 1 = 0h0:stageCfg x = roundCfg (x - x) x⊢ ∃ s cfg, nSteps weakCollatz16 s (stageCfg x) = some cfg ∧ step weakCollatz16 cfg = none
rw [h0 inl x:ℕhx:3 ≤ xht1:1 ≤ 1left✝:1 ≤ xhprev:StayIn x (1 - 1)hhit:terras x = xht0:1 - 1 = 0h0:stageCfg x = roundCfg (x - x) x⊢ ∃ s cfg, nSteps weakCollatz16 s (roundCfg (x - x) x) = some cfg ∧ step weakCollatz16 cfg = none] inl x:ℕhx:3 ≤ xht1:1 ≤ 1left✝:1 ≤ xhprev:StayIn x (1 - 1)hhit:terras x = xht0:1 - 1 = 0h0:stageCfg x = roundCfg (x - x) x⊢ ∃ s cfg, nSteps weakCollatz16 s (roundCfg (x - x) x) = some cfg ∧ step weakCollatz16 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 = 0h0:stageCfg x = roundCfg (x - x) x⊢ 2 ≤ x omega All goals completed! 🐙) le_rfl 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) (roundCfg (x - terras^[t - 1] x) (terras^[t - 1] x))⊢ ∃ s cfg, nSteps weakCollatz16 s (stageCfg x) = some cfg ∧ step weakCollatz16 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 weakCollatz16 s₁ (stageCfg x) = some (roundCfg (x - terras^[t - 1] x) (terras^[t - 1] x))⊢ ∃ s cfg, nSteps weakCollatz16 s (stageCfg x) = some cfg ∧ step weakCollatz16 cfg = none
have hy_prev := hprev (t - 1) ht1_pos le_rfl 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 weakCollatz16 s₁ (stageCfg x) = some (roundCfg (x - terras^[t - 1] x) (terras^[t - 1] x))hy_prev:StepContinues x (t - 1)⊢ ∃ s cfg, nSteps weakCollatz16 s (stageCfg x) = some cfg ∧ step weakCollatz16 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 weakCollatz16 s₁ (stageCfg x) = some (roundCfg (x - terras^[t - 1] x) (terras^[t - 1] x))hy_prev:StepContinues x (t - 1)⊢ terras^[(t - 1).succ] x = x show (t - 1).succ = t by x:ℕhx:3 ≤ xhhalt:StageHalts x⊢ ∃ s cfg, nSteps weakCollatz16 s (stageCfg x) = some cfg ∧ step weakCollatz16 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 weakCollatz16 s₁ (stageCfg x) = some (roundCfg (x - terras^[t - 1] x) (terras^[t - 1] x))hy_prev:StepContinues x (t - 1)⊢ 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 weakCollatz16 s₁ (stageCfg x) = some (roundCfg (x - terras^[t - 1] x) (terras^[t - 1] x))hy_prev:StepContinues x (t - 1)hhit':terras (terras^[t - 1] x) = x⊢ ∃ s cfg, nSteps weakCollatz16 s (stageCfg x) = some cfg ∧ step weakCollatz16 cfg = none
obtain ⟨s₂, cfg, hs₂, hnone⟩ :=
stage_round_halt x (terras^[t - 1] x) hx hy_prev.1 (le_of_lt hy_prev.2) 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 weakCollatz16 s₁ (stageCfg x) = some (roundCfg (x - terras^[t - 1] x) (terras^[t - 1] x))hy_prev:StepContinues x (t - 1)hhit':terras (terras^[t - 1] x) = xs₂:ℕcfg:Cfg 16 2hs₂:nSteps weakCollatz16 s₂ (roundCfg (x - terras^[t - 1] x) (terras^[t - 1] x)) = some cfghnone:step weakCollatz16 cfg = none⊢ ∃ s cfg, nSteps weakCollatz16 s (stageCfg x) = some cfg ∧ step weakCollatz16 cfg = none
exact ⟨s₁ + s₂, cfg, nSteps_bind_eq hs₁ hs₂, hnone⟩ All goals completed! 🐙
The 16-state machine weakCollatz16 (weak_collatz_16) 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_weakCollatz16_iff_bounded_cycle :
ConjectureMachines.Halts weakCollatz16 ↔
∃ x j : ℕ, 3 ≤ x ∧ 1 ≤ j ∧ j ≤ x ∧ terras^[j] x = x := by ⊢ ConjectureMachines.Halts weakCollatz16 ↔ ∃ x j, 3 ≤ x ∧ 1 ≤ j ∧ j ≤ x ∧ terras^[j] x = x
unfold ConjectureMachines.Halts ⊢ (eval (step weakCollatz16) init).Dom ↔ ∃ x j, 3 ≤ x ∧ 1 ≤ j ∧ j ≤ x ∧ terras^[j] x = x
constructor mp ⊢ (eval (step weakCollatz16) 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 weakCollatz16) init).Dom
· mp ⊢ (eval (step weakCollatz16) init).Dom → ∃ x j, 3 ≤ x ∧ 1 ≤ j ∧ j ≤ x ∧ terras^[j] x = x intro hdom mp hdom:(eval (step weakCollatz16) 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 weakCollatz16) init⊢ ∃ x j, 3 ≤ x ∧ 1 ≤ j ∧ j ≤ x ∧ terras^[j] x = x] at hdom mp hdom:∃ y, y ∈ eval (step weakCollatz16) init⊢ ∃ x j, 3 ≤ x ∧ 1 ≤ j ∧ j ≤ x ∧ terras^[j] x = x
obtain ⟨b, hb⟩ := hdom mp b:Cfg 16 2hb:b ∈ eval (step weakCollatz16) init⊢ ∃ x j, 3 ≤ x ∧ 1 ≤ j ∧ j ≤ x ∧ terras^[j] x = x
rw [mem_eval' mp b:Cfg 16 2hb:Reaches (step weakCollatz16) init b ∧ step weakCollatz16 b = none⊢ ∃ x j, 3 ≤ x ∧ 1 ≤ j ∧ j ≤ x ∧ terras^[j] x = x] at hb mp b:Cfg 16 2hb:Reaches (step weakCollatz16) init b ∧ step weakCollatz16 b = none⊢ ∃ x j, 3 ≤ x ∧ 1 ≤ j ∧ j ≤ x ∧ terras^[j] x = x
obtain ⟨hreach, hnone⟩ := hb mp b:Cfg 16 2hreach:Reaches (step weakCollatz16) init bhnone:step weakCollatz16 b = none⊢ ∃ x j, 3 ≤ x ∧ 1 ≤ j ∧ j ≤ x ∧ terras^[j] x = x
obtain ⟨k, hk⟩ := reaches_imp_nSteps hreach mp b:Cfg 16 2hreach:Reaches (step weakCollatz16) init bhnone:step weakCollatz16 b = nonek:ℕhk:nSteps weakCollatz16 k init = some b⊢ ∃ x j, 3 ≤ x ∧ 1 ≤ j ∧ j ≤ x ∧ terras^[j] x = x
rcases noStageHalts_or_first (2 * (k + 2) - 1) with
hno | ⟨w, hw3, -, -, ⟨t, ht1, htw, -, hhit⟩⟩ mp.inl b:Cfg 16 2hreach:Reaches (step weakCollatz16) init bhnone:step weakCollatz16 b = nonek:ℕhk:nSteps weakCollatz16 k init = some bhno:NoStageHalts (2 * (k + 2) - 1)⊢ ∃ x j, 3 ≤ x ∧ 1 ≤ j ∧ j ≤ x ∧ terras^[j] x = xmp.inr b:Cfg 16 2hreach:Reaches (step weakCollatz16) init bhnone:step weakCollatz16 b = nonek:ℕhk:nSteps weakCollatz16 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 16 2hreach:Reaches (step weakCollatz16) init bhnone:step weakCollatz16 b = nonek:ℕhk:nSteps weakCollatz16 k init = some bhno:NoStageHalts (2 * (k + 2) - 1)⊢ ∃ x j, 3 ≤ x ∧ 1 ≤ j ∧ j ≤ x ∧ terras^[j] x = x obtain ⟨s, hks, hs⟩ := reach_even_stage_from_init (k + 2) (by b:Cfg 16 2hreach:Reaches (step weakCollatz16) init bhnone:step weakCollatz16 b = nonek:ℕhk:nSteps weakCollatz16 k init = some bhno:NoStageHalts (2 * (k + 2) - 1)⊢ 2 ≤ k + 2 omega All goals completed! 🐙) hno mp.inl b:Cfg 16 2hreach:Reaches (step weakCollatz16) init bhnone:step weakCollatz16 b = nonek:ℕhk:nSteps weakCollatz16 k init = some bhno:NoStageHalts (2 * (k + 2) - 1)s:ℕhks:k + 2 - 1 ≤ shs:nSteps weakCollatz16 s init = some (stageCfg (2 * (k + 2)))⊢ ∃ 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 16 2hreach:Reaches (step weakCollatz16) init bhnone:step weakCollatz16 b = nonek:ℕhk:nSteps weakCollatz16 k init = some bhno:NoStageHalts (2 * (k + 2) - 1)s:ℕhks:k + 2 - 1 ≤ shs:nSteps weakCollatz16 s init = some (stageCfg (2 * (k + 2)))⊢ k < s omega All goals completed! 🐙)] at hs mp.inl b:Cfg 16 2hreach:Reaches (step weakCollatz16) init bhnone:step weakCollatz16 b = nonek:ℕhk:nSteps weakCollatz16 k init = some bhno:NoStageHalts (2 * (k + 2) - 1)s:ℕhks:k + 2 - 1 ≤ shs:none = some (stageCfg (2 * (k + 2)))⊢ ∃ x j, 3 ≤ x ∧ 1 ≤ j ∧ j ≤ x ∧ terras^[j] x = x
cases hs All goals completed! 🐙
· mp.inr b:Cfg 16 2hreach:Reaches (step weakCollatz16) init bhnone:step weakCollatz16 b = nonek:ℕhk:nSteps weakCollatz16 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 weakCollatz16) init).Dom rintro ⟨x, j, hx3, hj1, _, hhit⟩ mpr x:ℕj:ℕhx3:3 ≤ xhj1:1 ≤ jleft✝:j ≤ xhhit:terras^[j] x = x⊢ (eval (step weakCollatz16) 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 ≤ jM_hjMM:jM ≤ M - 2hjM_cyc:terras^[jM] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ M⊢ (eval (step weakCollatz16) 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 ≤ jM_hjMM: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 ≤ jM_hjMM:jM ≤ M - 2hjM_cyc:terras^[jM] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ MhM_halts:StageHalts M⊢ (eval (step weakCollatz16) 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 ≤ jM_hjMM:jM ≤ M - 2hjM_cyc:terras^[jM] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ MhM_halts:StageHalts Mhno:NoStageHalts M⊢ (eval (step weakCollatz16) init).Dommpr.inr x:ℕj:ℕhx3:3 ≤ xhj1:1 ≤ jleft✝:j ≤ xhhit:terras^[j] x = xM:ℕjM:ℕhM3:3 ≤ MhjM1:1 ≤ jM_hjMM: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 weakCollatz16) init).Dom
· mpr.inl x:ℕj:ℕhx3:3 ≤ xhj1:1 ≤ jleft✝:j ≤ xhhit:terras^[j] x = xM:ℕjM:ℕhM3:3 ≤ MhjM1:1 ≤ jM_hjMM:jM ≤ M - 2hjM_cyc:terras^[jM] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ MhM_halts:StageHalts Mhno:NoStageHalts M⊢ (eval (step weakCollatz16) init).Dom exfalso mpr.inl x:ℕj:ℕhx3:3 ≤ xhj1:1 ≤ jleft✝:j ≤ xhhit:terras^[j] x = xM:ℕjM:ℕhM3:3 ≤ MhjM1:1 ≤ jM_hjMM: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 ≤ jM_hjMM: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 weakCollatz16) init).Dom obtain ⟨m₀, hm₀2, rfl⟩ := even_of_stageHalts hw₀3 hhalt₀ mpr.inr x:ℕj:ℕhx3:3 ≤ xhj1:1 ≤ jleft✝:j ≤ xhhit:terras^[j] x = xM:ℕjM:ℕhM3:3 ≤ MhjM1:1 ≤ jM_hjMM:jM ≤ M - 2hjM_cyc:terras^[jM] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ MhM_halts:StageHalts Mm₀:ℕhm₀2:2 ≤ m₀hw₀3:3 ≤ 2 * m₀hprev₀:NoStageHalts (2 * m₀ - 1)hhalt₀:StageHalts (2 * m₀)⊢ (eval (step weakCollatz16) init).Dom
obtain ⟨s₁, -, hs₁⟩ := reach_even_stage_from_init m₀ hm₀2 hprev₀ mpr.inr x:ℕj:ℕhx3:3 ≤ xhj1:1 ≤ jleft✝:j ≤ xhhit:terras^[j] x = xM:ℕjM:ℕhM3:3 ≤ MhjM1:1 ≤ jM_hjMM:jM ≤ M - 2hjM_cyc:terras^[jM] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ MhM_halts:StageHalts Mm₀:ℕhm₀2:2 ≤ m₀hw₀3:3 ≤ 2 * m₀hprev₀:NoStageHalts (2 * m₀ - 1)hhalt₀:StageHalts (2 * m₀)s₁:ℕhs₁:nSteps weakCollatz16 s₁ init = some (stageCfg (2 * m₀))⊢ (eval (step weakCollatz16) init).Dom
obtain ⟨s₂, cfg, hs₂, hnone⟩ := stage_halt_of_stageHalts (2 * m₀) hw₀3 hhalt₀ mpr.inr x:ℕj:ℕhx3:3 ≤ xhj1:1 ≤ jleft✝:j ≤ xhhit:terras^[j] x = xM:ℕjM:ℕhM3:3 ≤ MhjM1:1 ≤ jM_hjMM:jM ≤ M - 2hjM_cyc:terras^[jM] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ MhM_halts:StageHalts Mm₀:ℕhm₀2:2 ≤ m₀hw₀3:3 ≤ 2 * m₀hprev₀:NoStageHalts (2 * m₀ - 1)hhalt₀:StageHalts (2 * m₀)s₁:ℕhs₁:nSteps weakCollatz16 s₁ init = some (stageCfg (2 * m₀))s₂:ℕcfg:Cfg 16 2hs₂:nSteps weakCollatz16 s₂ (stageCfg (2 * m₀)) = some cfghnone:step weakCollatz16 cfg = none⊢ (eval (step weakCollatz16) 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 ≤ jM_hjMM:jM ≤ M - 2hjM_cyc:terras^[jM] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ MhM_halts:StageHalts Mm₀:ℕhm₀2:2 ≤ m₀hw₀3:3 ≤ 2 * m₀hprev₀:NoStageHalts (2 * m₀ - 1)hhalt₀:StageHalts (2 * m₀)s₁:ℕhs₁:nSteps weakCollatz16 s₁ init = some (stageCfg (2 * m₀))s₂:ℕcfg:Cfg 16 2hs₂:nSteps weakCollatz16 s₂ (stageCfg (2 * m₀)) = some cfghnone:step weakCollatz16 cfg = none⊢ ∃ y, y ∈ eval (step weakCollatz16) init] mpr.inr x:ℕj:ℕhx3:3 ≤ xhj1:1 ≤ jleft✝:j ≤ xhhit:terras^[j] x = xM:ℕjM:ℕhM3:3 ≤ MhjM1:1 ≤ jM_hjMM:jM ≤ M - 2hjM_cyc:terras^[jM] M = Mhbnd:∀ (t : ℕ), 3 ≤ terras^[t] M ∧ terras^[t] M ≤ MhM_halts:StageHalts Mm₀:ℕhm₀2:2 ≤ m₀hw₀3:3 ≤ 2 * m₀hprev₀:NoStageHalts (2 * m₀ - 1)hhalt₀:StageHalts (2 * m₀)s₁:ℕhs₁:nSteps weakCollatz16 s₁ init = some (stageCfg (2 * m₀))s₂:ℕcfg:Cfg 16 2hs₂:nSteps weakCollatz16 s₂ (stageCfg (2 * m₀)) = some cfghnone:step weakCollatz16 cfg = none⊢ ∃ y, y ∈ eval (step weakCollatz16) init
exact ⟨cfg, mem_eval'.mpr ⟨nSteps_reaches (nSteps_bind_eq hs₁ hs₂), hnone⟩⟩ All goals completed! 🐙
The 16-state candidate machine halts on the blank tape if and only if the 17-state reference
machine does (constructive, zero Classical.choice).
theorem candidate_equivalent : Halts candidate ↔ Halts reference :=
halts_weakCollatz16_iff_bounded_cycle.trans
WeakCollatz17.halts_weakCollatz17_iff_bounded_cycle.symm
The candidate has 1 fewer state than the 17-state reference (16 < 17).
theorem candidate_fewer_states : candidate.states < reference.states := by ⊢ candidate.states < reference.states
decide +kernel All goals completed! 🐙end ConjectureMachines.WeakCollatz16