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.ReferenceLogical95
@[expose] public sectionnamespace ConjectureMachines.Riemann95.ReferenceProgramopen Turing StateTransition ConjectureMachines.Riemann120open ConjectureMachines.Riemann120.Layer2abbrev Word := ReferenceLogical.Wordabbrev ControlInstr := ReferenceLogical.ControlInstrdef perm : Nat → Nat | 0 => 3 | 1 => 4 | 2 => 0 | 3 => 2 | 4 => 1 | n + 5 => n + 5def mapControl : ControlInstr → ControlInstr | .halt => .halt | .jump n => .jump n | .inc r n => .inc (perm r) n | .decnz r p z => .decnz (perm r) p zdef mapInstr : RhInstr → RhInstr | .halt => .halt | .jump n => .jump n | .inc r n => .inc (perm r) n | .decnz r p z => .decnz (perm r) p zdef word (s : Fin 121) : Word := ReferenceLogical.word sdef oldWord (s : Fin 121) : Word := ReferenceLogical.oldWord sdef rowInstr (s : Fin 121) : ControlInstr := mapControl (ReferenceLogical.rowInstr s)abbrev toInstr := ReferenceLogical.toInstrdef decoded (s : Fin 121) : RhInstr := toInstr word (rowInstr s)def instruction (bits : Word) : RhInstr := mapInstr (ReferenceLogical.instruction bits)def step (c : RhRegCfg) : Option RhRegCfg := match instruction c.stack with | .halt => none | .jump target => some ⟨target,c.regs⟩ | .inc r target => some ⟨target,c.regs.set r (c.regs.getD r 0 + 1)⟩ | .decnz r positive zero => if c.regs.getD r 0 == 0 then some ⟨zero,c.regs⟩ else some ⟨positive,c.regs.set r (c.regs.getD r 0 - 1)⟩theorem map_toInstr (target : Fin 121 → Word) (i : ControlInstr) : mapInstr (toInstr target i) = toInstr target (mapControl i) := target:Fin 121 → Wordi:ControlInstr⊢ mapInstr (toInstr target i) = toInstr target (mapControl i) target:Fin 121 → Word⊢ mapInstr (toInstr target ReferenceLogical.ControlInstr.halt) = toInstr target (mapControl ReferenceLogical.ControlInstr.halt)target:Fin 121 → Wordnext✝:Fin 121⊢ mapInstr (toInstr target (ReferenceLogical.ControlInstr.jump next✝)) = toInstr target (mapControl (ReferenceLogical.ControlInstr.jump next✝))target:Fin 121 → Wordreg✝:ℕnext✝:Fin 121⊢ mapInstr (toInstr target (ReferenceLogical.ControlInstr.inc reg✝ next✝)) = toInstr target (mapControl (ReferenceLogical.ControlInstr.inc reg✝ next✝))target:Fin 121 → Wordreg✝:ℕpositive✝:Fin 121zero✝:Fin 121⊢ mapInstr (toInstr target (ReferenceLogical.ControlInstr.decnz reg✝ positive✝ zero✝)) = toInstr target (mapControl (ReferenceLogical.ControlInstr.decnz reg✝ positive✝ zero✝)) target:Fin 121 → Word⊢ mapInstr (toInstr target ReferenceLogical.ControlInstr.halt) = toInstr target (mapControl ReferenceLogical.ControlInstr.halt)target:Fin 121 → Wordnext✝:Fin 121⊢ mapInstr (toInstr target (ReferenceLogical.ControlInstr.jump next✝)) = toInstr target (mapControl (ReferenceLogical.ControlInstr.jump next✝))target:Fin 121 → Wordreg✝:ℕnext✝:Fin 121⊢ mapInstr (toInstr target (ReferenceLogical.ControlInstr.inc reg✝ next✝)) = toInstr target (mapControl (ReferenceLogical.ControlInstr.inc reg✝ next✝))target:Fin 121 → Wordreg✝:ℕpositive✝:Fin 121zero✝:Fin 121⊢ mapInstr (toInstr target (ReferenceLogical.ControlInstr.decnz reg✝ positive✝ zero✝)) = toInstr target (mapControl (ReferenceLogical.ControlInstr.decnz reg✝ positive✝ zero✝)) All goals completed! 🐙theorem instruction_word (s : Fin 121) : instruction (word s) = decoded s := s:Fin 121⊢ instruction (word s) = decoded s s:Fin 121⊢ mapInstr (ReferenceLogical.instruction (ReferenceLogical.word s)) = decoded s s:Fin 121⊢ mapInstr (ReferenceLogical.decoded s) = decoded s All goals completed! 🐙def stageCfg (M : Nat) : RhRegCfg := ⟨[],[0,0,0,M,0]⟩end ConjectureMachines.Riemann95.ReferenceProgram