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.Layer2Every 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')
have hparse := actual_parse c 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')
rw [hterminal 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')] at hparse 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')
have hext : Control.walked c = Schema.word c ++
List.replicate ((Control.walked c).length - (Schema.word c).length) 0 := by
have hp := arithmeticPrefix_all c 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)hp:arithmeticPrefix c⊢ Control.walked c = Schema.word c ++ List.replicate (List.length (Control.walked c) - List.length (Schema.word c)) 0
cases inc false c:Schema.ControlWordr:Fin 5pad:ℕbank:List ℕhr:↑r < bank.lengthhfill:3 ≤ pad - List.length (Control.walked c)hp:arithmeticPrefix che:Control.effect c = if false = true then Control.Effect.inc r else Control.Effect.decnz rhterminal:terminal c = if false = true then Physical.incLeaf r else Physical.decLeaf rhparse:Parser.walkInternal 15 (Control.walked c) = some (if false = true then Physical.incLeaf r else Physical.decLeaf r)⊢ Control.walked c = Schema.word c ++ List.replicate (List.length (Control.walked c) - List.length (Schema.word c)) 0true c:Schema.ControlWordr:Fin 5pad:ℕbank:List ℕhr:↑r < bank.lengthhfill:3 ≤ pad - List.length (Control.walked c)hp:arithmeticPrefix che:Control.effect c = if true = true then Control.Effect.inc r else Control.Effect.decnz rhterminal:terminal c = if true = true then Physical.incLeaf r else Physical.decLeaf rhparse:Parser.walkInternal 15 (Control.walked c) = some (if true = true then Physical.incLeaf r else Physical.decLeaf r)⊢ Control.walked c = Schema.word c ++ List.replicate (List.length (Control.walked c) - List.length (Schema.word c)) 0 <;> false c:Schema.ControlWordr:Fin 5pad:ℕbank:List ℕhr:↑r < bank.lengthhfill:3 ≤ pad - List.length (Control.walked c)hp:arithmeticPrefix che:Control.effect c = if false = true then Control.Effect.inc r else Control.Effect.decnz rhterminal:terminal c = if false = true then Physical.incLeaf r else Physical.decLeaf rhparse:Parser.walkInternal 15 (Control.walked c) = some (if false = true then Physical.incLeaf r else Physical.decLeaf r)⊢ Control.walked c = Schema.word c ++ List.replicate (List.length (Control.walked c) - List.length (Schema.word c)) 0true c:Schema.ControlWordr:Fin 5pad:ℕbank:List ℕhr:↑r < bank.lengthhfill:3 ≤ pad - List.length (Control.walked c)hp:arithmeticPrefix che:Control.effect c = if true = true then Control.Effect.inc r else Control.Effect.decnz rhterminal:terminal c = if true = true then Physical.incLeaf r else Physical.decLeaf rhparse:Parser.walkInternal 15 (Control.walked c) = some (if true = true then Physical.incLeaf r else Physical.decLeaf r)⊢ Control.walked c = Schema.word c ++ List.replicate (List.length (Control.walked c) - List.length (Schema.word c)) 0 simpa only [arithmeticPrefix, he, Bool.false_eq_true, ↓reduceIte] using hp 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')
have hlen : (Schema.word c).length ≤ (Control.walked c).length := by
rw [hext 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⊢ List.length (Schema.word c) ≤
List.length (Schema.word c ++ List.replicate (List.length (Control.walked c) - List.length (Schema.word c)) 0)] 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⊢ List.length (Schema.word c) ≤
List.length (Schema.word c ++ List.replicate (List.length (Control.walked c) - List.length (Schema.word c)) 0)
simp 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')
have htape : Schema.word c ++ List.replicate (pad - (Schema.word c).length) 0 =
Control.walked c ++ List.replicate (pad - (Control.walked c).length) 0 := by
calc
_ = Schema.word c ++ List.replicate
(((Control.walked c).length - (Schema.word c).length) +
(pad - (Control.walked c).length)) 0 := by 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)⊢ Schema.word c ++ List.replicate (pad - List.length (Schema.word c)) 0 =
Schema.word c ++
List.replicate
(List.length (Control.walked c) - List.length (Schema.word c) + (pad - List.length (Control.walked c))) 0
have hz : pad - (Schema.word c).length =
((Control.walked c).length - (Schema.word c).length) +
(pad - (Control.walked c).length) := by omega 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)hz:pad - List.length (Schema.word c) =
List.length (Control.walked c) - List.length (Schema.word c) + (pad - List.length (Control.walked c))⊢ Schema.word c ++ List.replicate (pad - List.length (Schema.word c)) 0 =
Schema.word c ++
List.replicate
(List.length (Control.walked c) - List.length (Schema.word c) + (pad - List.length (Control.walked c))) 0
rw [hz 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)hz:pad - List.length (Schema.word c) =
List.length (Control.walked c) - List.length (Schema.word c) + (pad - List.length (Control.walked c))⊢ Schema.word c ++
List.replicate
(List.length (Control.walked c) - List.length (Schema.word c) + (pad - List.length (Control.walked c))) 0 =
Schema.word c ++
List.replicate
(List.length (Control.walked c) - List.length (Schema.word c) + (pad - List.length (Control.walked c))) 0] All goals completed! 🐙
_ = _ := by 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)⊢ Schema.word c ++
List.replicate
(List.length (Control.walked c) - List.length (Schema.word c) + (pad - List.length (Control.walked c))) 0 =
Control.walked c ++ List.replicate (pad - List.length (Control.walked c)) 0 rw [List.replicate_add, 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)⊢ Schema.word c ++
(List.replicate (List.length (Control.walked c) - List.length (Schema.word c)) 0 ++
List.replicate (pad - List.length (Control.walked c)) 0) =
Control.walked c ++ List.replicate (pad - List.length (Control.walked c)) 0 ← List.append_assoc, 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)⊢ Schema.word c ++ List.replicate (List.length (Control.walked c) - List.length (Schema.word c)) 0 ++
List.replicate (pad - List.length (Control.walked c)) 0 =
Control.walked c ++ List.replicate (pad - List.length (Control.walked c)) 0 ← hext 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)⊢ Control.walked c ++ List.replicate (pad - List.length (Control.walked c)) 0 =
Control.walked c ++ List.replicate (pad - List.length (Control.walked c)) 0] 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')
have hg0 : Riemann104.OnePassGuard.NoThreeZeros
(1 :: (popBreakRev 0 (Control.walked c).reverse).reverse).reverse = true := by
cases inc with
| false => false c:Schema.ControlWordr:Fin 5pad:ℕbank:List ℕhr:↑r < bank.lengthhfill:3 ≤ pad - List.length (Control.walked c)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)) 0he:Control.effect c = if false = true then Control.Effect.inc r else Control.Effect.decnz rhterminal:terminal c = if false = true then Physical.incLeaf r else Physical.decLeaf rhparse:Parser.walkInternal 15 (Control.walked c) = some (if false = true then Physical.incLeaf r else Physical.decLeaf r)⊢ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 0 (List.reverse (Control.walked c))).reverse).reverse = true exact (dec_return_guards c r he).1 All goals completed! 🐙
| true => true c:Schema.ControlWordr:Fin 5pad:ℕbank:List ℕhr:↑r < bank.lengthhfill:3 ≤ pad - List.length (Control.walked c)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)) 0he:Control.effect c = if true = true then Control.Effect.inc r else Control.Effect.decnz rhterminal:terminal c = if true = true then Physical.incLeaf r else Physical.decLeaf rhparse:Parser.walkInternal 15 (Control.walked c) = some (if true = true then Physical.incLeaf r else Physical.decLeaf r)⊢ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 0 (List.reverse (Control.walked c))).reverse).reverse = true exact inc_return_guard c r he 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')
have hk : inc = false → 1 ≤ (Control.walked c).count 0 := by
intro hi 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 = truehi:inc = false⊢ 1 ≤ List.count 0 (Control.walked c)
subst inc c:Schema.ControlWordr:Fin 5pad:ℕbank:List ℕhr:↑r < bank.lengthhfill:3 ≤ pad - List.length (Control.walked c)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 = truehe:Control.effect c = if false = true then Control.Effect.inc r else Control.Effect.decnz rhterminal:terminal c = if false = true then Physical.incLeaf r else Physical.decLeaf rhparse:Parser.walkInternal 15 (Control.walked c) = some (if false = true then Physical.incLeaf r else Physical.decLeaf r)⊢ 1 ≤ List.count 0 (Control.walked c)
exact dec_walk_count c r he 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')
have hg1 : inc = false → Riemann104.OnePassGuard.NoThreeZeros
(1 :: (popBreakRev 1 (Control.walked c).reverse).reverse).reverse = true := by
intro hi 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)hi:inc = false⊢ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 1 (List.reverse (Control.walked c))).reverse).reverse = true
subst inc c:Schema.ControlWordr:Fin 5pad:ℕbank:List ℕhr:↑r < bank.lengthhfill:3 ≤ pad - List.length (Control.walked c)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 = truehe:Control.effect c = if false = true then Control.Effect.inc r else Control.Effect.decnz rhterminal:terminal c = if false = true then Physical.incLeaf r else Physical.decLeaf rhparse:Parser.walkInternal 15 (Control.walked c) = some (if false = true then Physical.incLeaf r else Physical.decLeaf r)hk:false = false → 1 ≤ List.count 0 (Control.walked c)⊢ Riemann104.OnePassGuard.NoThreeZeros (1 :: (popBreakRev 1 (List.reverse (Control.walked c))).reverse).reverse = true
exact (dec_return_guards c r he).2 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')
exact arithmetic_dispatch_exact pad (Schema.word c) (Control.walked c) bank r inc
hfill htape hparse hr hk hg0 hg1 All goals completed! 🐙end ConjectureMachines.Riemann95.Dispatch