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.ArithmeticDispatch95 public import Cryptids.ReductionSupport.Riemann95.NativeGuard95
@[expose] public sectionnamespace ConjectureMachines.Riemann95.Dispatchopen Turing ConjectureMachinesopen Riemann120.Layer2

Every typed native arithmetic call executes on the complete 95-state tape frame.

theorem root_native (c : Schema.ControlWord) (r : Fin 5) (inc : Bool) (he : Control.effect c = if inc then .inc r else .decnz r) (pad : Nat) (bank : List Nat) (hr : r.val < bank.length) (hfill : 3 ≤ pad - (Control.walked c).length) : let walked := Control.walked c let k : Fin 2 := if inc then 0 else if bank.getD r.val 0 = 0 then 1 else 0 let bank' := if inc then bank.set r.val (bank.getD r.val 0 + 1) else if bank.getD r.val 0 = 0 then bank else bank.set r.val (bank.getD r.val 0 - 1) ++ [0] ∃ s ≥ 1, nSteps s (Physical.rootCfg pad (Schema.word c) bank) = some (Physical.rootCfg (Physical.exactPad k walked (pad - walked.length)) (popBreakRev k.val walked.reverse).reverse bank') := c:Schema.ControlWordr:Fin 5inc:Boolhe:Control.effect c = if inc = true then Control.Effect.inc r else Control.Effect.decnz rpad:ℕbank:List ℕhr:↑r < bank.lengthhfill:3 ≤ pad - List.length (Control.walked c)⊢ let walked := Control.walked c; let k := if inc = true then 0 else if bank.getD (↑r) 0 = 0 then 1 else 0; let bank' := if inc = true then bank.set (↑r) (bank.getD (↑r) 0 + 1) else if bank.getD (↑r) 0 = 0 then bank else bank.set (↑r) (bank.getD (↑r) 0 - 1) ++ [0]; ∃ s ≥ 1, nSteps s (Physical.rootCfg pad (Schema.word c) bank) = some (Physical.rootCfg (Physical.exactPad k walked (pad - List.length walked)) (popBreakRev (↑k) (List.reverse walked)).reverse bank') c:Schema.ControlWordr:Fin 5inc:Boolhe:Control.effect c = if inc = true then Control.Effect.inc r else Control.Effect.decnz rpad:ℕbank:List ℕhr:↑r < bank.lengthhfill:3 ≤ pad - List.length (Control.walked c)hterminal:terminal c = if inc = true then Physical.incLeaf r else Physical.decLeaf r⊢ let walked := Control.walked c; let k := if inc = true then 0 else if bank.getD (↑r) 0 = 0 then 1 else 0; let bank' := if inc = true then bank.set (↑r) (bank.getD (↑r) 0 + 1) else if bank.getD (↑r) 0 = 0 then bank else bank.set (↑r) (bank.getD (↑r) 0 - 1) ++ [0]; ∃ s ≥ 1, nSteps s (Physical.rootCfg pad (Schema.word c) bank) = some (Physical.rootCfg (Physical.exactPad k walked (pad - List.length walked)) (popBreakRev (↑k) (List.reverse walked)).reverse bank') c:Schema.ControlWordr:Fin 5inc:Boolhe:Control.effect c = if inc = true then Control.Effect.inc r else Control.Effect.decnz rpad:ℕbank:List ℕhr:↑r < bank.lengthhfill:3 ≤ pad - List.length (Control.walked c)hterminal:terminal c = if inc = true then Physical.incLeaf r else Physical.decLeaf rhparse:Parser.walkInternal 15 (Control.walked c) = some (terminal c)⊢ let walked := Control.walked c; let k := if inc = true then 0 else if bank.getD (↑r) 0 = 0 then 1 else 0; let bank' := if inc = true then bank.set (↑r) (bank.getD (↑r) 0 + 1) else if bank.getD (↑r) 0 = 0 then bank else bank.set (↑r) (bank.getD (↑r) 0 - 1) ++ [0]; ∃ s ≥ 1, nSteps s (Physical.rootCfg pad (Schema.word c) bank) = some (Physical.rootCfg (Physical.exactPad k walked (pad - List.length walked)) (popBreakRev (↑k) (List.reverse walked)).reverse bank') c:Schema.ControlWordr:Fin 5inc:Boolhe:Control.effect c = if inc = true then Control.Effect.inc r else Control.Effect.decnz rpad:ℕbank:List ℕhr:↑r < bank.lengthhfill:3 ≤ pad - List.length (Control.walked c)hterminal:terminal c = if inc = true then Physical.incLeaf r else Physical.decLeaf rhparse:Parser.walkInternal 15 (Control.walked c) = some (if inc = true then Physical.incLeaf r else Physical.decLeaf r)⊢ let walked := Control.walked c; let k := if inc = true then 0 else if bank.getD (↑r) 0 = 0 then 1 else 0; let bank' := if inc = true then bank.set (↑r) (bank.getD (↑r) 0 + 1) else if bank.getD (↑r) 0 = 0 then bank else bank.set (↑r) (bank.getD (↑r) 0 - 1) ++ [0]; ∃ s ≥ 1, nSteps s (Physical.rootCfg pad (Schema.word c) bank) = some (Physical.rootCfg (Physical.exactPad k walked (pad - List.length walked)) (popBreakRev (↑k) (List.reverse walked)).reverse bank') c:Schema.ControlWordr:Fin 5inc:Boolhe:Control.effect c = if inc = true then Control.Effect.inc r else Control.Effect.decnz rpad:ℕbank:List ℕhr:↑r < bank.lengthhfill:3 ≤ pad - List.length (Control.walked c)hterminal:terminal c = if inc = true then Physical.incLeaf r else Physical.decLeaf rhparse:Parser.walkInternal 15 (Control.walked c) = some (if inc = true then Physical.incLeaf r else Physical.decLeaf r)hext:Control.walked c = Schema.word c ++ List.replicate (List.length (Control.walked c) - List.length (Schema.word c)) 0⊢ let walked := Control.walked c; let k := if inc = true then 0 else if bank.getD (↑r) 0 = 0 then 1 else 0; let bank' := if inc = true then bank.set (↑r) (bank.getD (↑r) 0 + 1) else if bank.getD (↑r) 0 = 0 then bank else bank.set (↑r) (bank.getD (↑r) 0 - 1) ++ [0]; ∃ s ≥ 1, nSteps s (Physical.rootCfg pad (Schema.word c) bank) = some (Physical.rootCfg (Physical.exactPad k walked (pad - List.length walked)) (popBreakRev (↑k) (List.reverse walked)).reverse bank') c:Schema.ControlWordr:Fin 5inc:Boolhe:Control.effect c = if inc = true then Control.Effect.inc r else Control.Effect.decnz rpad:ℕbank:List ℕhr:↑r < bank.lengthhfill:3 ≤ pad - List.length (Control.walked c)hterminal:terminal c = if inc = true then Physical.incLeaf r else Physical.decLeaf rhparse:Parser.walkInternal 15 (Control.walked c) = some (if inc = true then Physical.incLeaf r else Physical.decLeaf r)hext:Control.walked c = Schema.word c ++ List.replicate (List.length (Control.walked c) - List.length (Schema.word c)) 0hlen:List.length (Schema.word c) ≤ List.length (Control.walked c)⊢ let walked := Control.walked c; let k := if inc = true then 0 else if bank.getD (↑r) 0 = 0 then 1 else 0; let bank' := if inc = true then bank.set (↑r) (bank.getD (↑r) 0 + 1) else if bank.getD (↑r) 0 = 0 then bank else bank.set (↑r) (bank.getD (↑r) 0 - 1) ++ [0]; ∃ s ≥ 1, nSteps s (Physical.rootCfg pad (Schema.word c) bank) = some (Physical.rootCfg (Physical.exactPad k walked (pad - List.length walked)) (popBreakRev (↑k) (List.reverse walked)).reverse bank') c:Schema.ControlWordr:Fin 5inc:Boolhe:Control.effect c = if inc = true then Control.Effect.inc r else Control.Effect.decnz rpad:ℕbank:List ℕhr:↑r < bank.lengthhfill:3 ≤ pad - List.length (Control.walked c)hterminal:terminal c = if inc = true then Physical.incLeaf r else Physical.decLeaf rhparse:Parser.walkInternal 15 (Control.walked c) = some (if inc = true then Physical.incLeaf r else Physical.decLeaf r)hext:Control.walked c = Schema.word c ++ List.replicate (List.length (Control.walked c) - List.length (Schema.word c)) 0hlen:List.length (Schema.word c) ≤ List.length (Control.walked c)htape:Schema.word c ++ List.replicate (pad - List.length (Schema.word c)) 0 = Control.walked c ++ List.replicate (pad - List.length (Control.walked c)) 0⊢ let walked := Control.walked c; let k := if inc = true then 0 else if bank.getD (↑r) 0 = 0 then 1 else 0; let bank' := if inc = true then bank.set (↑r) (bank.getD (↑r) 0 + 1) else if bank.getD (↑r) 0 = 0 then bank else bank.set (↑r) (bank.getD (↑r) 0 - 1) ++ [0]; ∃ s ≥ 1, nSteps s (Physical.rootCfg pad (Schema.word c) bank) = some (Physical.rootCfg (Physical.exactPad k walked (pad - List.length walked)) (popBreakRev (↑k) (List.reverse walked)).reverse bank') c:Schema.ControlWordr:Fin 5inc:Boolhe:Control.effect c = if inc = true then Control.Effect.inc r else Control.Effect.decnz rpad:ℕbank:List ℕhr:↑r < bank.lengthhfill:3 ≤ pad - List.length (Control.walked c)hterminal:terminal c = if inc = true then Physical.incLeaf r else Physical.decLeaf rhparse:Parser.walkInternal 15 (Control.walked c) = some (if inc = true then Physical.incLeaf r else Physical.decLeaf r)hext:Control.walked c = Schema.word c ++ List.replicate (List.length (Control.walked c) - List.length (Schema.word c)) 0hlen:List.length (Schema.word c) ≤ List.length (Control.walked c)htape:Schema.word c ++ List.replicate (pad - List.length (Schema.word c)) 0 = Control.walked c ++ List.replicate (pad - List.length (Control.walked c)) 0hg0:Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 0 (List.reverse (Control.walked c))).reverse).reverse = true⊢ let walked := Control.walked c; let k := if inc = true then 0 else if bank.getD (↑r) 0 = 0 then 1 else 0; let bank' := if inc = true then bank.set (↑r) (bank.getD (↑r) 0 + 1) else if bank.getD (↑r) 0 = 0 then bank else bank.set (↑r) (bank.getD (↑r) 0 - 1) ++ [0]; ∃ s ≥ 1, nSteps s (Physical.rootCfg pad (Schema.word c) bank) = some (Physical.rootCfg (Physical.exactPad k walked (pad - List.length walked)) (popBreakRev (↑k) (List.reverse walked)).reverse bank') c:Schema.ControlWordr:Fin 5inc:Boolhe:Control.effect c = if inc = true then Control.Effect.inc r else Control.Effect.decnz rpad:ℕbank:List ℕhr:↑r < bank.lengthhfill:3 ≤ pad - List.length (Control.walked c)hterminal:terminal c = if inc = true then Physical.incLeaf r else Physical.decLeaf rhparse:Parser.walkInternal 15 (Control.walked c) = some (if inc = true then Physical.incLeaf r else Physical.decLeaf r)hext:Control.walked c = Schema.word c ++ List.replicate (List.length (Control.walked c) - List.length (Schema.word c)) 0hlen:List.length (Schema.word c) ≤ List.length (Control.walked c)htape:Schema.word c ++ List.replicate (pad - List.length (Schema.word c)) 0 = Control.walked c ++ List.replicate (pad - List.length (Control.walked c)) 0hg0:Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 0 (List.reverse (Control.walked c))).reverse).reverse = truehk:inc = false → 1 ≤ List.count 0 (Control.walked c)⊢ let walked := Control.walked c; let k := if inc = true then 0 else if bank.getD (↑r) 0 = 0 then 1 else 0; let bank' := if inc = true then bank.set (↑r) (bank.getD (↑r) 0 + 1) else if bank.getD (↑r) 0 = 0 then bank else bank.set (↑r) (bank.getD (↑r) 0 - 1) ++ [0]; ∃ s ≥ 1, nSteps s (Physical.rootCfg pad (Schema.word c) bank) = some (Physical.rootCfg (Physical.exactPad k walked (pad - List.length walked)) (popBreakRev (↑k) (List.reverse walked)).reverse bank') c:Schema.ControlWordr:Fin 5inc:Boolhe:Control.effect c = if inc = true then Control.Effect.inc r else Control.Effect.decnz rpad:ℕbank:List ℕhr:↑r < bank.lengthhfill:3 ≤ pad - List.length (Control.walked c)hterminal:terminal c = if inc = true then Physical.incLeaf r else Physical.decLeaf rhparse:Parser.walkInternal 15 (Control.walked c) = some (if inc = true then Physical.incLeaf r else Physical.decLeaf r)hext:Control.walked c = Schema.word c ++ List.replicate (List.length (Control.walked c) - List.length (Schema.word c)) 0hlen:List.length (Schema.word c) ≤ List.length (Control.walked c)htape:Schema.word c ++ List.replicate (pad - List.length (Schema.word c)) 0 = Control.walked c ++ List.replicate (pad - List.length (Control.walked c)) 0hg0:Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 0 (List.reverse (Control.walked c))).reverse).reverse = truehk:inc = false → 1 ≤ List.count 0 (Control.walked c)hg1:inc = false → Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 1 (List.reverse (Control.walked c))).reverse).reverse = true⊢ let walked := Control.walked c; let k := if inc = true then 0 else if bank.getD (↑r) 0 = 0 then 1 else 0; let bank' := if inc = true then bank.set (↑r) (bank.getD (↑r) 0 + 1) else if bank.getD (↑r) 0 = 0 then bank else bank.set (↑r) (bank.getD (↑r) 0 - 1) ++ [0]; ∃ s ≥ 1, nSteps s (Physical.rootCfg pad (Schema.word c) bank) = some (Physical.rootCfg (Physical.exactPad k walked (pad - List.length walked)) (popBreakRev (↑k) (List.reverse walked)).reverse bank') All goals completed! 🐙end ConjectureMachines.Riemann95.Dispatch