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.Auxiliary95Raw

The 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'' 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'' 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⟩ := 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 } 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 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 } All goals completed! 🐙 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 } 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 } 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 } 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)⟩ := 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) } 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) } 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)⟩ := 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) } 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) } All goals completed! 🐙end ConjectureMachines.Riemann95Auxiliary.Return