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.ReductionSupport.Riemann95.Auxiliary95RawReturn
public import Cryptids.ReductionSupport.Riemann95.Auxiliary95RawThe return scanner is proved once for the raw labels, then transported by renaming.
@[expose] public sectionnamespace ConjectureMachines.Riemann95Auxiliary.Returnopen Turing ConjectureMachinesopen ConjectureMachines.Semantics.Riemann.Layer1 (append_replicate_cons Tape.mkL)open ConjectureMachines.Riemann120 (rootLeftOf stackLeftOf)open ConjectureMachines.Riemann104.OnePassGuard (NoThreeZeros)theorem nSteps_bind_eq {m n : Nat} {c c' c'' : Cfg 98 2}
(h : nSteps m c = some c') (h' : nSteps n c' = some c'') :
nSteps (m + n) c = some c'' := m:ℕn:ℕc:Cfg 98 2c':Cfg 98 2c'':Cfg 98 2h:nSteps m c = some c'h':nSteps n c' = some c''⊢ nSteps (m + n) c = some c''
m:ℕn:ℕc:Cfg 98 2c':Cfg 98 2c'':Cfg 98 2h:nSteps m c = some c'h':nSteps n c' = some c''hadd:∀ (m n : ℕ) (c : Cfg 98 2), nSteps (m + n) c = (nSteps m c).bind (nSteps n)⊢ nSteps (m + n) c = some c''
rw [hadd, m:ℕn:ℕc:Cfg 98 2c':Cfg 98 2c'':Cfg 98 2h:nSteps m c = some c'h':nSteps n c' = some c''hadd:∀ (m n : ℕ) (c : Cfg 98 2), nSteps (m + n) c = (nSteps m c).bind (nSteps n)⊢ (nSteps m c).bind (nSteps n) = some c'' h m:ℕn:ℕc:Cfg 98 2c':Cfg 98 2c'':Cfg 98 2h:nSteps m c = some c'h':nSteps n c' = some c''hadd:∀ (m n : ℕ) (c : Cfg 98 2), nSteps (m + n) c = (nSteps m c).bind (nSteps n)⊢ (some c').bind (nSteps n) = some c''] m:ℕn:ℕc:Cfg 98 2c':Cfg 98 2c'':Cfg 98 2h:nSteps m c = some c'h':nSteps n c' = some c''hadd:∀ (m n : ℕ) (c : Cfg 98 2), nSteps (m + n) c = (nSteps m c).bind (nSteps n)⊢ (some c').bind (nSteps n) = some c''
exact h' All goals completed! 🐙theorem right_scan {q : Fin 98} {a b : Fin 2}
(h : machine.transition q a = some (b, .right, q)) (k : Nat)
(L R : ListBlank (Fin 2)) :
nSteps k ⟨q, Tape.mk' L (ListBlank.append (List.replicate k a) R)⟩ =
some ⟨q, Tape.mk' (ListBlank.append (List.replicate k b) L) R⟩ := by q:Fin 98a:Fin 2b:Fin 2h:machine.transition q a = some (b, Dir.right, q)k:ℕL:ListBlank (Fin 2)R:ListBlank (Fin 2)⊢ nSteps k { state := q, tape := Tape.mk' L (ListBlank.append (List.replicate k a) R) } =
some { state := q, tape := Tape.mk' (ListBlank.append (List.replicate k b) L) R }
have hs (L R : ListBlank (Fin 2)) :
step machine ⟨q, Tape.mk' L (R.cons a)⟩ = some ⟨q, Tape.mk' (L.cons b) R⟩ := by
simp [step, h, Tape.mk', Tape.write, Tape.move] q:Fin 98a:Fin 2b:Fin 2h:machine.transition q a = some (b, Dir.right, q)k:ℕL:ListBlank (Fin 2)R:ListBlank (Fin 2)hs:∀ (L R : ListBlank (Fin 2)),
step machine { state := q, tape := Tape.mk' L (ListBlank.cons a R) } =
some { state := q, tape := Tape.mk' (ListBlank.cons b L) R }⊢ nSteps k { state := q, tape := Tape.mk' L (ListBlank.append (List.replicate k a) R) } =
some { state := q, tape := Tape.mk' (ListBlank.append (List.replicate k b) L) R }
induction k generalizing L with
| zero => zero q:Fin 98a:Fin 2b:Fin 2h:machine.transition q a = some (b, Dir.right, q)R:ListBlank (Fin 2)hs:∀ (L R : ListBlank (Fin 2)),
step machine { state := q, tape := Tape.mk' L (ListBlank.cons a R) } =
some { state := q, tape := Tape.mk' (ListBlank.cons b L) R }L:ListBlank (Fin 2)⊢ nSteps 0 { state := q, tape := Tape.mk' L (ListBlank.append (List.replicate 0 a) R) } =
some { state := q, tape := Tape.mk' (ListBlank.append (List.replicate 0 b) L) R } rfl All goals completed! 🐙
| succ k ih => succ q:Fin 98a:Fin 2b:Fin 2h:machine.transition q a = some (b, Dir.right, q)R:ListBlank (Fin 2)hs:∀ (L R : ListBlank (Fin 2)),
step machine { state := q, tape := Tape.mk' L (ListBlank.cons a R) } =
some { state := q, tape := Tape.mk' (ListBlank.cons b L) R }k:ℕih:∀ (L : ListBlank (Fin 2)),
nSteps k { state := q, tape := Tape.mk' L (ListBlank.append (List.replicate k a) R) } =
some { state := q, tape := Tape.mk' (ListBlank.append (List.replicate k b) L) R }L:ListBlank (Fin 2)⊢ nSteps (k + 1) { state := q, tape := Tape.mk' L (ListBlank.append (List.replicate (k + 1) a) R) } =
some { state := q, tape := Tape.mk' (ListBlank.append (List.replicate (k + 1) b) L) R }
rw [List.replicate_succ, succ q:Fin 98a:Fin 2b:Fin 2h:machine.transition q a = some (b, Dir.right, q)R:ListBlank (Fin 2)hs:∀ (L R : ListBlank (Fin 2)),
step machine { state := q, tape := Tape.mk' L (ListBlank.cons a R) } =
some { state := q, tape := Tape.mk' (ListBlank.cons b L) R }k:ℕih:∀ (L : ListBlank (Fin 2)),
nSteps k { state := q, tape := Tape.mk' L (ListBlank.append (List.replicate k a) R) } =
some { state := q, tape := Tape.mk' (ListBlank.append (List.replicate k b) L) R }L:ListBlank (Fin 2)⊢ nSteps (k + 1) { state := q, tape := Tape.mk' L (ListBlank.append (a :: List.replicate k a) R) } =
some { state := q, tape := Tape.mk' (ListBlank.append (List.replicate (k + 1) b) L) R } ListBlank.append, succ q:Fin 98a:Fin 2b:Fin 2h:machine.transition q a = some (b, Dir.right, q)R:ListBlank (Fin 2)hs:∀ (L R : ListBlank (Fin 2)),
step machine { state := q, tape := Tape.mk' L (ListBlank.cons a R) } =
some { state := q, tape := Tape.mk' (ListBlank.cons b L) R }k:ℕih:∀ (L : ListBlank (Fin 2)),
nSteps k { state := q, tape := Tape.mk' L (ListBlank.append (List.replicate k a) R) } =
some { state := q, tape := Tape.mk' (ListBlank.append (List.replicate k b) L) R }L:ListBlank (Fin 2)⊢ nSteps (k + 1) { state := q, tape := Tape.mk' L (ListBlank.cons a (ListBlank.append (List.replicate k a) R)) } =
some { state := q, tape := Tape.mk' (ListBlank.append (List.replicate (k + 1) b) L) R } nSteps, succ q:Fin 98a:Fin 2b:Fin 2h:machine.transition q a = some (b, Dir.right, q)R:ListBlank (Fin 2)hs:∀ (L R : ListBlank (Fin 2)),
step machine { state := q, tape := Tape.mk' L (ListBlank.cons a R) } =
some { state := q, tape := Tape.mk' (ListBlank.cons b L) R }k:ℕih:∀ (L : ListBlank (Fin 2)),
nSteps k { state := q, tape := Tape.mk' L (ListBlank.append (List.replicate k a) R) } =
some { state := q, tape := Tape.mk' (ListBlank.append (List.replicate k b) L) R }L:ListBlank (Fin 2)⊢ (step machine { state := q, tape := Tape.mk' L (ListBlank.cons a (ListBlank.append (List.replicate k a) R)) }).bind
(nSteps k) =
some { state := q, tape := Tape.mk' (ListBlank.append (List.replicate (k + 1) b) L) R } hs succ q:Fin 98a:Fin 2b:Fin 2h:machine.transition q a = some (b, Dir.right, q)R:ListBlank (Fin 2)hs:∀ (L R : ListBlank (Fin 2)),
step machine { state := q, tape := Tape.mk' L (ListBlank.cons a R) } =
some { state := q, tape := Tape.mk' (ListBlank.cons b L) R }k:ℕih:∀ (L : ListBlank (Fin 2)),
nSteps k { state := q, tape := Tape.mk' L (ListBlank.append (List.replicate k a) R) } =
some { state := q, tape := Tape.mk' (ListBlank.append (List.replicate k b) L) R }L:ListBlank (Fin 2)⊢ (some { state := q, tape := Tape.mk' (ListBlank.cons b L) (ListBlank.append (List.replicate k a) R) }).bind (nSteps k) =
some { state := q, tape := Tape.mk' (ListBlank.append (List.replicate (k + 1) b) L) R }] succ q:Fin 98a:Fin 2b:Fin 2h:machine.transition q a = some (b, Dir.right, q)R:ListBlank (Fin 2)hs:∀ (L R : ListBlank (Fin 2)),
step machine { state := q, tape := Tape.mk' L (ListBlank.cons a R) } =
some { state := q, tape := Tape.mk' (ListBlank.cons b L) R }k:ℕih:∀ (L : ListBlank (Fin 2)),
nSteps k { state := q, tape := Tape.mk' L (ListBlank.append (List.replicate k a) R) } =
some { state := q, tape := Tape.mk' (ListBlank.append (List.replicate k b) L) R }L:ListBlank (Fin 2)⊢ (some { state := q, tape := Tape.mk' (ListBlank.cons b L) (ListBlank.append (List.replicate k a) R) }).bind (nSteps k) =
some { state := q, tape := Tape.mk' (ListBlank.append (List.replicate (k + 1) b) L) R }
simp only [Option.bind_some] succ q:Fin 98a:Fin 2b:Fin 2h:machine.transition q a = some (b, Dir.right, q)R:ListBlank (Fin 2)hs:∀ (L R : ListBlank (Fin 2)),
step machine { state := q, tape := Tape.mk' L (ListBlank.cons a R) } =
some { state := q, tape := Tape.mk' (ListBlank.cons b L) R }k:ℕih:∀ (L : ListBlank (Fin 2)),
nSteps k { state := q, tape := Tape.mk' L (ListBlank.append (List.replicate k a) R) } =
some { state := q, tape := Tape.mk' (ListBlank.append (List.replicate k b) L) R }L:ListBlank (Fin 2)⊢ nSteps k { state := q, tape := Tape.mk' (ListBlank.cons b L) (ListBlank.append (List.replicate k a) R) } =
some { state := q, tape := Tape.mk' (ListBlank.append (List.replicate (k + 1) b) L) R }
rw [ih (L.cons b), succ q:Fin 98a:Fin 2b:Fin 2h:machine.transition q a = some (b, Dir.right, q)R:ListBlank (Fin 2)hs:∀ (L R : ListBlank (Fin 2)),
step machine { state := q, tape := Tape.mk' L (ListBlank.cons a R) } =
some { state := q, tape := Tape.mk' (ListBlank.cons b L) R }k:ℕih:∀ (L : ListBlank (Fin 2)),
nSteps k { state := q, tape := Tape.mk' L (ListBlank.append (List.replicate k a) R) } =
some { state := q, tape := Tape.mk' (ListBlank.append (List.replicate k b) L) R }L:ListBlank (Fin 2)⊢ some { state := q, tape := Tape.mk' (ListBlank.append (List.replicate k b) (ListBlank.cons b L)) R } =
some { state := q, tape := Tape.mk' (ListBlank.append (List.replicate (k + 1) b) L) R } append_replicate_cons succ q:Fin 98a:Fin 2b:Fin 2h:machine.transition q a = some (b, Dir.right, q)R:ListBlank (Fin 2)hs:∀ (L R : ListBlank (Fin 2)),
step machine { state := q, tape := Tape.mk' L (ListBlank.cons a R) } =
some { state := q, tape := Tape.mk' (ListBlank.cons b L) R }k:ℕih:∀ (L : ListBlank (Fin 2)),
nSteps k { state := q, tape := Tape.mk' L (ListBlank.append (List.replicate k a) R) } =
some { state := q, tape := Tape.mk' (ListBlank.append (List.replicate k b) L) R }L:ListBlank (Fin 2)⊢ some { state := q, tape := Tape.mk' (ListBlank.append (List.replicate (k + 1) b) L) R } =
some { state := q, tape := Tape.mk' (ListBlank.append (List.replicate (k + 1) b) L) R }] All goals completed! 🐙The relabelled table has the same complete NoThree return scanner.
theorem run_return98 (word : List (Fin 2))
(hok : NoThreeZeros (1 :: word).reverse = true) (R : ListBlank (Fin 2)) :
∃ s, 1 ≤ s ∧ nSteps s
⟨5, Tape.mkL (stackLeftOf true word) R⟩ =
some ⟨15, Tape.mk' (rootLeftOf true) (ListBlank.append word R)⟩ := by word:List (Fin 2)hok:NoThreeZeros (1 :: word).reverse = trueR:ListBlank (Fin 2)⊢ ∃ s,
1 ≤ s ∧
nSteps s { state := 5, tape := Tape.mkL (stackLeftOf true word) R } =
some { state := 15, tape := Tape.mk' (rootLeftOf true) (ListBlank.append word R) }
obtain ⟨s, hs, h⟩ := ReturnRaw.run_return98 word hok R word:List (Fin 2)hok:NoThreeZeros (1 :: word).reverse = trueR:ListBlank (Fin 2)s:ℕhs:1 ≤ sh:Raw.nSteps s { state := 5, tape := Tape.mkL (stackLeftOf true word) R } =
some { state := 15, tape := Tape.mk' (rootLeftOf true) (ListBlank.append word R) }⊢ ∃ s,
1 ≤ s ∧
nSteps s { state := 5, tape := Tape.mkL (stackLeftOf true word) R } =
some { state := 15, tape := Tape.mk' (rootLeftOf true) (ListBlank.append word R) }
exact ⟨s, hs, Renaming.of_raw h⟩ All goals completed! 🐙Renaming also preserves the positive run after its first ONE step.
theorem run_return98_after_one (word : List (Fin 2))
(hok : NoThreeZeros (1 :: word).reverse = true)
(hhead : (stackLeftOf true word).head = 1) (R : ListBlank (Fin 2)) :
∃ s, 1 ≤ s ∧ nSteps s
⟨5, Tape.mkL (stackLeftOf true word).tail (R.cons 1)⟩ =
some ⟨15, Tape.mk' (rootLeftOf true) (ListBlank.append word R)⟩ := by word:List (Fin 2)hok:NoThreeZeros (1 :: word).reverse = truehhead:(stackLeftOf true word).head = 1R:ListBlank (Fin 2)⊢ ∃ s,
1 ≤ s ∧
nSteps s { state := 5, tape := Tape.mkL (stackLeftOf true word).tail (ListBlank.cons 1 R) } =
some { state := 15, tape := Tape.mk' (rootLeftOf true) (ListBlank.append word R) }
obtain ⟨s, hs, h⟩ := ReturnRaw.run_return98_after_one word hok hhead R word:List (Fin 2)hok:NoThreeZeros (1 :: word).reverse = truehhead:(stackLeftOf true word).head = 1R:ListBlank (Fin 2)s:ℕhs:1 ≤ sh:Raw.nSteps s { state := 5, tape := Tape.mkL (stackLeftOf true word).tail (ListBlank.cons 1 R) } =
some { state := 15, tape := Tape.mk' (rootLeftOf true) (ListBlank.append word R) }⊢ ∃ s,
1 ≤ s ∧
nSteps s { state := 5, tape := Tape.mkL (stackLeftOf true word).tail (ListBlank.cons 1 R) } =
some { state := 15, tape := Tape.mk' (rootLeftOf true) (ListBlank.append word R) }
exact ⟨s, hs, Renaming.of_raw h⟩ All goals completed! 🐙end ConjectureMachines.Riemann95Auxiliary.Return