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.Terminal95 public import Cryptids.ReductionSupport.Riemann95.ControlStep95
@[expose] public sectionnamespace ConjectureMachines.Riemann95.Dispatchopen Turing ConjectureMachinesopen Riemann120.Layer2theorem inc_return_guard (c : Schema.ControlWord) (r : Fin 5) (he : Control.effect c = .inc r) : Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 0 (Control.walked c).reverse).reverse).reverse = true := c:Schema.ControlWordr:Fin 5he:Control.effect c = Control.Effect.inc r⊢ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 0 (List.reverse (Control.walked c))).reverse).reverse = true c:Schema.ControlWordr:Fin 5he:Control.effect c = Control.Effect.inc rhc:Control.rawInstr c = Control.toRhInstr (Control.instruction c)⊢ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 0 (List.reverse (Control.walked c))).reverse).reverse = true c:Schema.ControlWordr:Fin 5he:Control.effect c = Control.Effect.inc rhc:RhInstr.inc (↑r) (popBreakRev 0 (List.reverse (Control.walked c))).reverse = Control.toRhInstr (Control.instruction c)⊢ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 0 (List.reverse (Control.walked c))).reverse).reverse = true cases hi : Control.instruction c with c:Schema.ControlWordr:Fin 5he:Control.effect c = Control.Effect.inc rhc:RhInstr.inc (↑r) (popBreakRev 0 (List.reverse (Control.walked c))).reverse = Control.toRhInstr (Control.instruction c)hi:Control.instruction c = Control.Instr.halt⊢ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 0 (List.reverse (Control.walked c))).reverse).reverse = true c:Schema.ControlWordr:Fin 5he:Control.effect c = Control.Effect.inc rhc:RhInstr.inc (↑r) (popBreakRev 0 (List.reverse (Control.walked c))).reverse = RhInstr.halthi:Control.instruction c = Control.Instr.halt⊢ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 0 (List.reverse (Control.walked c))).reverse).reverse = true; All goals completed! 🐙 c:Schema.ControlWordr:Fin 5he:Control.effect c = Control.Effect.inc rhc:RhInstr.inc (↑r) (popBreakRev 0 (List.reverse (Control.walked c))).reverse = Control.toRhInstr (Control.instruction c)n:Schema.ControlWordhi:Control.instruction c = Control.Instr.jump n⊢ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 0 (List.reverse (Control.walked c))).reverse).reverse = true c:Schema.ControlWordr:Fin 5he:Control.effect c = Control.Effect.inc rn:Schema.ControlWordhc:RhInstr.inc (↑r) (popBreakRev 0 (List.reverse (Control.walked c))).reverse = RhInstr.jump (Schema.word n)hi:Control.instruction c = Control.Instr.jump n⊢ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 0 (List.reverse (Control.walked c))).reverse).reverse = true; All goals completed! 🐙 c:Schema.ControlWordr:Fin 5he:Control.effect c = Control.Effect.inc rhc:RhInstr.inc (↑r) (popBreakRev 0 (List.reverse (Control.walked c))).reverse = Control.toRhInstr (Control.instruction c)r':Fin 5n:Schema.ControlWordhi:Control.instruction c = Control.Instr.inc r' n⊢ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 0 (List.reverse (Control.walked c))).reverse).reverse = true c:Schema.ControlWordr:Fin 5he:Control.effect c = Control.Effect.inc rr':Fin 5n:Schema.ControlWordhc:RhInstr.inc (↑r) (popBreakRev 0 (List.reverse (Control.walked c))).reverse = RhInstr.inc (↑r') (Schema.word n)hi:Control.instruction c = Control.Instr.inc r' n⊢ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 0 (List.reverse (Control.walked c))).reverse).reverse = true c:Schema.ControlWordr:Fin 5he:Control.effect c = Control.Effect.inc rr':Fin 5n:Schema.ControlWordhc:RhInstr.inc (↑r) (popBreakRev 0 (List.reverse (Control.walked c))).reverse = RhInstr.inc (↑r') (Schema.word n)hi:Control.instruction c = Control.Instr.inc r' nleft✝:↑r = ↑r'hw:(popBreakRev 0 (List.reverse (Control.walked c))).reverse = Schema.word n⊢ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 0 (List.reverse (Control.walked c))).reverse).reverse = true c:Schema.ControlWordr:Fin 5he:Control.effect c = Control.Effect.inc rr':Fin 5n:Schema.ControlWordhc:RhInstr.inc (↑r) (popBreakRev 0 (List.reverse (Control.walked c))).reverse = RhInstr.inc (↑r') (Schema.word n)hi:Control.instruction c = Control.Instr.inc r' nleft✝:↑r = ↑r'hw:(popBreakRev 0 (List.reverse (Control.walked c))).reverse = Schema.word n⊢ Riemann104.OnePassGuard.NoThreeZeros (1 :: Schema.word n).reverse = true All goals completed! 🐙 c:Schema.ControlWordr:Fin 5he:Control.effect c = Control.Effect.inc rhc:RhInstr.inc (↑r) (popBreakRev 0 (List.reverse (Control.walked c))).reverse = Control.toRhInstr (Control.instruction c)r':Fin 5p:Schema.ControlWordz:Schema.ControlWordhi:Control.instruction c = Control.Instr.decnz r' p z⊢ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 0 (List.reverse (Control.walked c))).reverse).reverse = true c:Schema.ControlWordr:Fin 5he:Control.effect c = Control.Effect.inc rr':Fin 5p:Schema.ControlWordz:Schema.ControlWordhc:RhInstr.inc (↑r) (popBreakRev 0 (List.reverse (Control.walked c))).reverse = RhInstr.decnz (↑r') (Schema.word p) (Schema.word z)hi:Control.instruction c = Control.Instr.decnz r' p z⊢ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 0 (List.reverse (Control.walked c))).reverse).reverse = true; All goals completed! 🐙theorem dec_return_guards (c : Schema.ControlWord) (r : Fin 5) (he : Control.effect c = .decnz r) : Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 0 (Control.walked c).reverse).reverse).reverse = true ∧ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 1 (Control.walked c).reverse).reverse).reverse = true := c:Schema.ControlWordr:Fin 5he:Control.effect c = Control.Effect.decnz r⊢ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 0 (List.reverse (Control.walked c))).reverse).reverse = true ∧ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 1 (List.reverse (Control.walked c))).reverse).reverse = true c:Schema.ControlWordr:Fin 5he:Control.effect c = Control.Effect.decnz rhc:Control.rawInstr c = Control.toRhInstr (Control.instruction c)⊢ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 0 (List.reverse (Control.walked c))).reverse).reverse = true ∧ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 1 (List.reverse (Control.walked c))).reverse).reverse = true c:Schema.ControlWordr:Fin 5he:Control.effect c = Control.Effect.decnz rhc:RhInstr.decnz (↑r) (popBreakRev 0 (List.reverse (Control.walked c))).reverse (popBreakRev 1 (List.reverse (Control.walked c))).reverse = Control.toRhInstr (Control.instruction c)⊢ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 0 (List.reverse (Control.walked c))).reverse).reverse = true ∧ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 1 (List.reverse (Control.walked c))).reverse).reverse = true cases hi : Control.instruction c with c:Schema.ControlWordr:Fin 5he:Control.effect c = Control.Effect.decnz rhc:RhInstr.decnz (↑r) (popBreakRev 0 (List.reverse (Control.walked c))).reverse (popBreakRev 1 (List.reverse (Control.walked c))).reverse = Control.toRhInstr (Control.instruction c)hi:Control.instruction c = Control.Instr.halt⊢ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 0 (List.reverse (Control.walked c))).reverse).reverse = true ∧ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 1 (List.reverse (Control.walked c))).reverse).reverse = true c:Schema.ControlWordr:Fin 5he:Control.effect c = Control.Effect.decnz rhc:RhInstr.decnz (↑r) (popBreakRev 0 (List.reverse (Control.walked c))).reverse (popBreakRev 1 (List.reverse (Control.walked c))).reverse = RhInstr.halthi:Control.instruction c = Control.Instr.halt⊢ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 0 (List.reverse (Control.walked c))).reverse).reverse = true ∧ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 1 (List.reverse (Control.walked c))).reverse).reverse = true; All goals completed! 🐙 c:Schema.ControlWordr:Fin 5he:Control.effect c = Control.Effect.decnz rhc:RhInstr.decnz (↑r) (popBreakRev 0 (List.reverse (Control.walked c))).reverse (popBreakRev 1 (List.reverse (Control.walked c))).reverse = Control.toRhInstr (Control.instruction c)n:Schema.ControlWordhi:Control.instruction c = Control.Instr.jump n⊢ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 0 (List.reverse (Control.walked c))).reverse).reverse = true ∧ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 1 (List.reverse (Control.walked c))).reverse).reverse = true c:Schema.ControlWordr:Fin 5he:Control.effect c = Control.Effect.decnz rn:Schema.ControlWordhc:RhInstr.decnz (↑r) (popBreakRev 0 (List.reverse (Control.walked c))).reverse (popBreakRev 1 (List.reverse (Control.walked c))).reverse = RhInstr.jump (Schema.word n)hi:Control.instruction c = Control.Instr.jump n⊢ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 0 (List.reverse (Control.walked c))).reverse).reverse = true ∧ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 1 (List.reverse (Control.walked c))).reverse).reverse = true; All goals completed! 🐙 c:Schema.ControlWordr:Fin 5he:Control.effect c = Control.Effect.decnz rhc:RhInstr.decnz (↑r) (popBreakRev 0 (List.reverse (Control.walked c))).reverse (popBreakRev 1 (List.reverse (Control.walked c))).reverse = Control.toRhInstr (Control.instruction c)r':Fin 5n:Schema.ControlWordhi:Control.instruction c = Control.Instr.inc r' n⊢ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 0 (List.reverse (Control.walked c))).reverse).reverse = true ∧ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 1 (List.reverse (Control.walked c))).reverse).reverse = true c:Schema.ControlWordr:Fin 5he:Control.effect c = Control.Effect.decnz rr':Fin 5n:Schema.ControlWordhc:RhInstr.decnz (↑r) (popBreakRev 0 (List.reverse (Control.walked c))).reverse (popBreakRev 1 (List.reverse (Control.walked c))).reverse = RhInstr.inc (↑r') (Schema.word n)hi:Control.instruction c = Control.Instr.inc r' n⊢ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 0 (List.reverse (Control.walked c))).reverse).reverse = true ∧ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 1 (List.reverse (Control.walked c))).reverse).reverse = true; All goals completed! 🐙 c:Schema.ControlWordr:Fin 5he:Control.effect c = Control.Effect.decnz rhc:RhInstr.decnz (↑r) (popBreakRev 0 (List.reverse (Control.walked c))).reverse (popBreakRev 1 (List.reverse (Control.walked c))).reverse = Control.toRhInstr (Control.instruction c)r':Fin 5p:Schema.ControlWordz:Schema.ControlWordhi:Control.instruction c = Control.Instr.decnz r' p z⊢ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 0 (List.reverse (Control.walked c))).reverse).reverse = true ∧ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 1 (List.reverse (Control.walked c))).reverse).reverse = true c:Schema.ControlWordr:Fin 5he:Control.effect c = Control.Effect.decnz rr':Fin 5p:Schema.ControlWordz:Schema.ControlWordhc:RhInstr.decnz (↑r) (popBreakRev 0 (List.reverse (Control.walked c))).reverse (popBreakRev 1 (List.reverse (Control.walked c))).reverse = RhInstr.decnz (↑r') (Schema.word p) (Schema.word z)hi:Control.instruction c = Control.Instr.decnz r' p z⊢ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 0 (List.reverse (Control.walked c))).reverse).reverse = true ∧ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 1 (List.reverse (Control.walked c))).reverse).reverse = true c:Schema.ControlWordr:Fin 5he:Control.effect c = Control.Effect.decnz rr':Fin 5p:Schema.ControlWordz:Schema.ControlWordhc:RhInstr.decnz (↑r) (popBreakRev 0 (List.reverse (Control.walked c))).reverse (popBreakRev 1 (List.reverse (Control.walked c))).reverse = RhInstr.decnz (↑r') (Schema.word p) (Schema.word z)hi:Control.instruction c = Control.Instr.decnz r' p zleft✝:↑r = ↑r'hp:(popBreakRev 0 (List.reverse (Control.walked c))).reverse = Schema.word phz:(popBreakRev 1 (List.reverse (Control.walked c))).reverse = Schema.word z⊢ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 0 (List.reverse (Control.walked c))).reverse).reverse = true ∧ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 1 (List.reverse (Control.walked c))).reverse).reverse = true c:Schema.ControlWordr:Fin 5he:Control.effect c = Control.Effect.decnz rr':Fin 5p:Schema.ControlWordz:Schema.ControlWordhc:RhInstr.decnz (↑r) (popBreakRev 0 (List.reverse (Control.walked c))).reverse (popBreakRev 1 (List.reverse (Control.walked c))).reverse = RhInstr.decnz (↑r') (Schema.word p) (Schema.word z)hi:Control.instruction c = Control.Instr.decnz r' p zleft✝:↑r = ↑r'hp:(popBreakRev 0 (List.reverse (Control.walked c))).reverse = Schema.word phz:(popBreakRev 1 (List.reverse (Control.walked c))).reverse = Schema.word z⊢ Riemann104.OnePassGuard.NoThreeZeros (1 :: Schema.word p).reverse = true ∧ Riemann104.OnePassGuard.NoThreeZeros (1 :: Schema.word z).reverse = true All goals completed! 🐙theorem callerPrefix_count_zero (d : Nat) : 1 ≤ (Schema.callerPrefix d).count 0 := d:ℕ⊢ 1 ≤ List.count 0 (Schema.callerPrefix d) induction d with ⊢ 1 ≤ List.count 0 (Schema.callerPrefix 0) All goals completed! 🐙 d:ℕih:1 ≤ List.count 0 (Schema.callerPrefix d)⊢ 1 ≤ List.count 0 (Schema.callerPrefix (d + 1)) d:ℕih:1 ≤ List.count 0 (Schema.callerPrefix d)⊢ 1 ≤ List.count 0 (Schema.callerPrefix d) + List.count 0 [1, 1, 1, 1, 0] All goals completed! 🐙theorem outside_dec_count : ∀ (s : Fin 97) (r : Fin 5), Control.effect (.outside s) = .decnz r → 1 ≤ (Control.walked (.outside s)).count 0 := ⊢ ∀ (s : Fin 97) (r : Fin 5), Control.effect (Schema.ControlWord.outside s) = Control.Effect.decnz r → 1 ≤ List.count 0 (Control.walked (Schema.ControlWord.outside s)) All goals completed! 🐙theorem dec_walk_count (c : Schema.ControlWord) (r : Fin 5) (he : Control.effect c = .decnz r) : 1 ≤ (Control.walked c).count 0 := c:Schema.ControlWordr:Fin 5he:Control.effect c = Control.Effect.decnz r⊢ 1 ≤ List.count 0 (Control.walked c) cases c with r:Fin 5s:Fin 97he:Control.effect (Schema.ControlWord.outside s) = Control.Effect.decnz r⊢ 1 ≤ List.count 0 (Control.walked (Schema.ControlWord.outside s)) All goals completed! 🐙 r:Fin 5d:ℕhe:Control.effect (Schema.ControlWord.entry d) = Control.Effect.decnz r⊢ 1 ≤ List.count 0 (Control.walked (Schema.ControlWord.entry d)) r:Fin 5d:ℕhe:Control.effect (Schema.ControlWord.entry d) = Control.Effect.decnz rhp:1 ≤ List.count 0 (Schema.callerPrefix d)⊢ 1 ≤ List.count 0 (Control.walked (Schema.ControlWord.entry d)) r:Fin 5d:ℕhe:Control.effect (Schema.ControlWord.entry d) = Control.Effect.decnz rhp:1 ≤ List.count 0 (Schema.callerPrefix d)⊢ 1 ≤ List.count 0 (Schema.callerPrefix d) + List.count 0 [0] All goals completed! 🐙 r:Fin 5d:ℕs:Fin 22he:Control.effect (Schema.ControlWord.local d s) = Control.Effect.decnz r⊢ 1 ≤ List.count 0 (Control.walked (Schema.ControlWord.local d s)) r:Fin 5d:ℕs:Fin 22he:Control.effect (Schema.ControlWord.local d s) = Control.Effect.decnz rhp:1 ≤ List.count 0 (Schema.callerPrefix d)⊢ 1 ≤ List.count 0 (Control.walked (Schema.ControlWord.local d s)) r:Fin 5d:ℕs:Fin 22he:Control.effect (Schema.ControlWord.local d s) = Control.Effect.decnz rhp:1 ≤ List.count 0 (Schema.callerPrefix d)⊢ 1 ≤ List.count 0 (Schema.callerPrefix d) + List.count 0 (Schema.localWalkSuffix s) All goals completed! 🐙end ConjectureMachines.Riemann95.Dispatch