Skip to content
Imports
@[expose] public sectionnamespace ConjectureMachines.Riemann95.ReferenceProgramopen Turing StateTransition ConjectureMachines.Riemann120open ConjectureMachines.Riemann120.Layer2attribute [local irreducible] word oldWord rowInstr decoded instructionattribute [local irreducible] ReferenceLogical.rows ReferenceLogical.row ReferenceLogical.word
ReferenceLogical.oldWord ReferenceLogical.rowInstr ReferenceLogical.role
ReferenceLogical.decoded ReferenceLogical.instructiondef encodeBank (regs : List Nat) : List Nat :=
[regs.getD 2 0,regs.getD 4 0,regs.getD 3 0,regs.getD 0 0,regs.getD 1 0]def decodeBank (regs : List Nat) : List Nat :=
[regs.getD 3 0,regs.getD 4 0,regs.getD 0 0,regs.getD 2 0,regs.getD 1 0]theorem bank_five (regs : List Nat) (hlen : regs.length = 5) :
∃ a b c d e, regs = [a,b,c,d,e] :=
ConjectureMachines.list_length_five regs hlentheorem encodeBank_length (regs : List Nat) : (encodeBank regs).length = 5 := rfltheorem decodeBank_length (regs : List Nat) : (decodeBank regs).length = 5 := rfltheorem decode_encode (regs : List Nat) (hlen : regs.length = 5) :
decodeBank (encodeBank regs) = regs := regs:List ℕhlen:regs.length = 5⊢ decodeBank (encodeBank regs) = regs
a:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5⊢ decodeBank (encodeBank [a, b, c, d, e]) = [a, b, c, d, e]
All goals completed! 🐙theorem encode_decode (regs : List Nat) (hlen : regs.length = 5) :
encodeBank (decodeBank regs) = regs := regs:List ℕhlen:regs.length = 5⊢ encodeBank (decodeBank regs) = regs
a:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5⊢ encodeBank (decodeBank [a, b, c, d, e]) = [a, b, c, d, e]
All goals completed! 🐙theorem encodeBank_getD (regs : List Nat) (hlen : regs.length = 5) (r : Nat) :
(encodeBank regs).getD (perm r) 0 = regs.getD r 0 := regs:List ℕhlen:regs.length = 5r:ℕ⊢ (encodeBank regs).getD (perm r) 0 = regs.getD r 0
r:ℕa:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5⊢ (encodeBank [a, b, c, d, e]).getD (perm r) 0 = [a, b, c, d, e].getD r 0
a:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5⊢ (encodeBank [a, b, c, d, e]).getD (perm 0) 0 = [a, b, c, d, e].getD 0 0a:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5r:ℕ⊢ (encodeBank [a, b, c, d, e]).getD (perm (r + 1)) 0 = [a, b, c, d, e].getD (r + 1) 0 a:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5⊢ (encodeBank [a, b, c, d, e]).getD (perm 0) 0 = [a, b, c, d, e].getD 0 0a:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5r:ℕ⊢ (encodeBank [a, b, c, d, e]).getD (perm (r + 1)) 0 = [a, b, c, d, e].getD (r + 1) 0 try a:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5r:ℕ⊢ (encodeBank [a, b, c, d, e]).getD (perm (r + 1)) 0 = [a, b, c, d, e].getD (r + 1) 0
a:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5⊢ (encodeBank [a, b, c, d, e]).getD (perm (0 + 1)) 0 = [a, b, c, d, e].getD (0 + 1) 0a:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5r:ℕ⊢ (encodeBank [a, b, c, d, e]).getD (perm (r + 1 + 1)) 0 = [a, b, c, d, e].getD (r + 1 + 1) 0 a:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5⊢ (encodeBank [a, b, c, d, e]).getD (perm (0 + 1)) 0 = [a, b, c, d, e].getD (0 + 1) 0a:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5r:ℕ⊢ (encodeBank [a, b, c, d, e]).getD (perm (r + 1 + 1)) 0 = [a, b, c, d, e].getD (r + 1 + 1) 0 try a:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5r:ℕ⊢ (encodeBank [a, b, c, d, e]).getD (perm (r + 1 + 1)) 0 = [a, b, c, d, e].getD (r + 1 + 1) 0
a:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5⊢ (encodeBank [a, b, c, d, e]).getD (perm (0 + 1 + 1)) 0 = [a, b, c, d, e].getD (0 + 1 + 1) 0a:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5r:ℕ⊢ (encodeBank [a, b, c, d, e]).getD (perm (r + 1 + 1 + 1)) 0 = [a, b, c, d, e].getD (r + 1 + 1 + 1) 0 a:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5⊢ (encodeBank [a, b, c, d, e]).getD (perm (0 + 1 + 1)) 0 = [a, b, c, d, e].getD (0 + 1 + 1) 0a:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5r:ℕ⊢ (encodeBank [a, b, c, d, e]).getD (perm (r + 1 + 1 + 1)) 0 = [a, b, c, d, e].getD (r + 1 + 1 + 1) 0 try a:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5r:ℕ⊢ (encodeBank [a, b, c, d, e]).getD (perm (r + 1 + 1 + 1)) 0 = [a, b, c, d, e].getD (r + 1 + 1 + 1) 0
a:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5⊢ (encodeBank [a, b, c, d, e]).getD (perm (0 + 1 + 1 + 1)) 0 = [a, b, c, d, e].getD (0 + 1 + 1 + 1) 0a:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5r:ℕ⊢ (encodeBank [a, b, c, d, e]).getD (perm (r + 1 + 1 + 1 + 1)) 0 = [a, b, c, d, e].getD (r + 1 + 1 + 1 + 1) 0 a:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5⊢ (encodeBank [a, b, c, d, e]).getD (perm (0 + 1 + 1 + 1)) 0 = [a, b, c, d, e].getD (0 + 1 + 1 + 1) 0a:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5r:ℕ⊢ (encodeBank [a, b, c, d, e]).getD (perm (r + 1 + 1 + 1 + 1)) 0 = [a, b, c, d, e].getD (r + 1 + 1 + 1 + 1) 0 try a:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5r:ℕ⊢ (encodeBank [a, b, c, d, e]).getD (perm (r + 1 + 1 + 1 + 1)) 0 = [a, b, c, d, e].getD (r + 1 + 1 + 1 + 1) 0
a:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5⊢ (encodeBank [a, b, c, d, e]).getD (perm (0 + 1 + 1 + 1 + 1)) 0 = [a, b, c, d, e].getD (0 + 1 + 1 + 1 + 1) 0a:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5r:ℕ⊢ (encodeBank [a, b, c, d, e]).getD (perm (r + 1 + 1 + 1 + 1 + 1)) 0 = [a, b, c, d, e].getD (r + 1 + 1 + 1 + 1 + 1) 0 a:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5⊢ (encodeBank [a, b, c, d, e]).getD (perm (0 + 1 + 1 + 1 + 1)) 0 = [a, b, c, d, e].getD (0 + 1 + 1 + 1 + 1) 0a:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5r:ℕ⊢ (encodeBank [a, b, c, d, e]).getD (perm (r + 1 + 1 + 1 + 1 + 1)) 0 = [a, b, c, d, e].getD (r + 1 + 1 + 1 + 1 + 1) 0 All goals completed! 🐙theorem encodeBank_set (regs : List Nat) (hlen : regs.length = 5) (r value : Nat) :
encodeBank (regs.set r value) = (encodeBank regs).set (perm r) value := regs:List ℕhlen:regs.length = 5r:ℕvalue:ℕ⊢ encodeBank (regs.set r value) = (encodeBank regs).set (perm r) value
r:ℕvalue:ℕa:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5⊢ encodeBank ([a, b, c, d, e].set r value) = (encodeBank [a, b, c, d, e]).set (perm r) value
value:ℕa:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5⊢ encodeBank ([a, b, c, d, e].set 0 value) = (encodeBank [a, b, c, d, e]).set (perm 0) valuevalue:ℕa:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5r:ℕ⊢ encodeBank ([a, b, c, d, e].set (r + 1) value) = (encodeBank [a, b, c, d, e]).set (perm (r + 1)) value value:ℕa:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5⊢ encodeBank ([a, b, c, d, e].set 0 value) = (encodeBank [a, b, c, d, e]).set (perm 0) valuevalue:ℕa:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5r:ℕ⊢ encodeBank ([a, b, c, d, e].set (r + 1) value) = (encodeBank [a, b, c, d, e]).set (perm (r + 1)) value try value:ℕa:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5r:ℕ⊢ encodeBank ([a, b, c, d, e].set (r + 1) value) = (encodeBank [a, b, c, d, e]).set (perm (r + 1)) value
value:ℕa:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5⊢ encodeBank ([a, b, c, d, e].set (0 + 1) value) = (encodeBank [a, b, c, d, e]).set (perm (0 + 1)) valuevalue:ℕa:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5r:ℕ⊢ encodeBank ([a, b, c, d, e].set (r + 1 + 1) value) = (encodeBank [a, b, c, d, e]).set (perm (r + 1 + 1)) value value:ℕa:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5⊢ encodeBank ([a, b, c, d, e].set (0 + 1) value) = (encodeBank [a, b, c, d, e]).set (perm (0 + 1)) valuevalue:ℕa:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5r:ℕ⊢ encodeBank ([a, b, c, d, e].set (r + 1 + 1) value) = (encodeBank [a, b, c, d, e]).set (perm (r + 1 + 1)) value try value:ℕa:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5r:ℕ⊢ encodeBank ([a, b, c, d, e].set (r + 1 + 1) value) = (encodeBank [a, b, c, d, e]).set (perm (r + 1 + 1)) value
value:ℕa:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5⊢ encodeBank ([a, b, c, d, e].set (0 + 1 + 1) value) = (encodeBank [a, b, c, d, e]).set (perm (0 + 1 + 1)) valuevalue:ℕa:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5r:ℕ⊢ encodeBank ([a, b, c, d, e].set (r + 1 + 1 + 1) value) = (encodeBank [a, b, c, d, e]).set (perm (r + 1 + 1 + 1)) value value:ℕa:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5⊢ encodeBank ([a, b, c, d, e].set (0 + 1 + 1) value) = (encodeBank [a, b, c, d, e]).set (perm (0 + 1 + 1)) valuevalue:ℕa:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5r:ℕ⊢ encodeBank ([a, b, c, d, e].set (r + 1 + 1 + 1) value) = (encodeBank [a, b, c, d, e]).set (perm (r + 1 + 1 + 1)) value try value:ℕa:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5r:ℕ⊢ encodeBank ([a, b, c, d, e].set (r + 1 + 1 + 1) value) = (encodeBank [a, b, c, d, e]).set (perm (r + 1 + 1 + 1)) value
value:ℕa:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5⊢ encodeBank ([a, b, c, d, e].set (0 + 1 + 1 + 1) value) = (encodeBank [a, b, c, d, e]).set (perm (0 + 1 + 1 + 1)) valuevalue:ℕa:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5r:ℕ⊢ encodeBank ([a, b, c, d, e].set (r + 1 + 1 + 1 + 1) value) =
(encodeBank [a, b, c, d, e]).set (perm (r + 1 + 1 + 1 + 1)) value value:ℕa:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5⊢ encodeBank ([a, b, c, d, e].set (0 + 1 + 1 + 1) value) = (encodeBank [a, b, c, d, e]).set (perm (0 + 1 + 1 + 1)) valuevalue:ℕa:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5r:ℕ⊢ encodeBank ([a, b, c, d, e].set (r + 1 + 1 + 1 + 1) value) =
(encodeBank [a, b, c, d, e]).set (perm (r + 1 + 1 + 1 + 1)) value try value:ℕa:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5r:ℕ⊢ encodeBank ([a, b, c, d, e].set (r + 1 + 1 + 1 + 1) value) =
(encodeBank [a, b, c, d, e]).set (perm (r + 1 + 1 + 1 + 1)) value
value:ℕa:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5⊢ encodeBank ([a, b, c, d, e].set (0 + 1 + 1 + 1 + 1) value) =
(encodeBank [a, b, c, d, e]).set (perm (0 + 1 + 1 + 1 + 1)) valuevalue:ℕa:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5r:ℕ⊢ encodeBank ([a, b, c, d, e].set (r + 1 + 1 + 1 + 1 + 1) value) =
(encodeBank [a, b, c, d, e]).set (perm (r + 1 + 1 + 1 + 1 + 1)) value value:ℕa:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5⊢ encodeBank ([a, b, c, d, e].set (0 + 1 + 1 + 1 + 1) value) =
(encodeBank [a, b, c, d, e]).set (perm (0 + 1 + 1 + 1 + 1)) valuevalue:ℕa:ℕb:ℕc:ℕd:ℕe:ℕhlen:[a, b, c, d, e].length = 5r:ℕ⊢ encodeBank ([a, b, c, d, e].set (r + 1 + 1 + 1 + 1 + 1) value) =
(encodeBank [a, b, c, d, e]).set (perm (r + 1 + 1 + 1 + 1 + 1)) value All goals completed! 🐙def encodeCfg (c : RhRegCfg) : RhRegCfg := ⟨c.stack,encodeBank c.regs⟩theorem step_encode (c : RhRegCfg) (hlen : c.regs.length = 5) :
step (encodeCfg c) = (ReferenceLogical.step c).map encodeCfg := c:RhRegCfghlen:c.regs.length = 5⊢ step (encodeCfg c) = Option.map encodeCfg (ReferenceLogical.step c)
c:RhRegCfghlen:c.regs.length = 5⊢ (match mapInstr (ReferenceLogical.instruction (encodeCfg c).stack) with
| RhInstr.halt => none
| RhInstr.jump target => some { stack := target, regs := (encodeCfg c).regs }
| RhInstr.inc r target => some { stack := target, regs := (encodeCfg c).regs.set r ((encodeCfg c).regs.getD r 0 + 1) }
| RhInstr.decnz r positive zero =>
if ((encodeCfg c).regs.getD r 0 == 0) = true then some { stack := zero, regs := (encodeCfg c).regs }
else some { stack := positive, regs := (encodeCfg c).regs.set r ((encodeCfg c).regs.getD r 0 - 1) }) =
Option.map encodeCfg
(match ReferenceLogical.instruction c.stack with
| RhInstr.halt => none
| RhInstr.jump target => some { stack := target, regs := c.regs }
| RhInstr.inc r target => some { stack := target, regs := c.regs.set r (c.regs.getD r 0 + 1) }
| RhInstr.decnz r positive zero =>
if (c.regs.getD r 0 == 0) = true then some { stack := zero, regs := c.regs }
else some { stack := positive, regs := c.regs.set r (c.regs.getD r 0 - 1) })
c:RhRegCfghlen:c.regs.length = 5⊢ (match mapInstr (ReferenceLogical.instruction c.stack) with
| RhInstr.halt => none
| RhInstr.jump target => some { stack := target, regs := encodeBank c.regs }
| RhInstr.inc r target =>
some { stack := target, regs := (encodeBank c.regs).set r ((encodeBank c.regs).getD r 0 + 1) }
| RhInstr.decnz r positive zero =>
if ((encodeBank c.regs).getD r 0 == 0) = true then some { stack := zero, regs := encodeBank c.regs }
else some { stack := positive, regs := (encodeBank c.regs).set r ((encodeBank c.regs).getD r 0 - 1) }) =
Option.map encodeCfg
(match ReferenceLogical.instruction c.stack with
| RhInstr.halt => none
| RhInstr.jump target => some { stack := target, regs := c.regs }
| RhInstr.inc r target => some { stack := target, regs := c.regs.set r (c.regs.getD r 0 + 1) }
| RhInstr.decnz r positive zero =>
if (c.regs.getD r 0 == 0) = true then some { stack := zero, regs := c.regs }
else some { stack := positive, regs := c.regs.set r (c.regs.getD r 0 - 1) })
cases h : ReferenceLogical.instruction c.stack with
c:RhRegCfghlen:c.regs.length = 5h:ReferenceLogical.instruction c.stack = RhInstr.halt⊢ (match mapInstr RhInstr.halt with
| RhInstr.halt => none
| RhInstr.jump target => some { stack := target, regs := encodeBank c.regs }
| RhInstr.inc r target =>
some { stack := target, regs := (encodeBank c.regs).set r ((encodeBank c.regs).getD r 0 + 1) }
| RhInstr.decnz r positive zero =>
if ((encodeBank c.regs).getD r 0 == 0) = true then some { stack := zero, regs := encodeBank c.regs }
else some { stack := positive, regs := (encodeBank c.regs).set r ((encodeBank c.regs).getD r 0 - 1) }) =
Option.map encodeCfg
(match RhInstr.halt with
| RhInstr.halt => none
| RhInstr.jump target => some { stack := target, regs := c.regs }
| RhInstr.inc r target => some { stack := target, regs := c.regs.set r (c.regs.getD r 0 + 1) }
| RhInstr.decnz r positive zero =>
if (c.regs.getD r 0 == 0) = true then some { stack := zero, regs := c.regs }
else some { stack := positive, regs := c.regs.set r (c.regs.getD r 0 - 1) }) All goals completed! 🐙
c:RhRegCfghlen:c.regs.length = 5target:List (Fin 2)h:ReferenceLogical.instruction c.stack = RhInstr.jump target⊢ (match mapInstr (RhInstr.jump target) with
| RhInstr.halt => none
| RhInstr.jump target => some { stack := target, regs := encodeBank c.regs }
| RhInstr.inc r target =>
some { stack := target, regs := (encodeBank c.regs).set r ((encodeBank c.regs).getD r 0 + 1) }
| RhInstr.decnz r positive zero =>
if ((encodeBank c.regs).getD r 0 == 0) = true then some { stack := zero, regs := encodeBank c.regs }
else some { stack := positive, regs := (encodeBank c.regs).set r ((encodeBank c.regs).getD r 0 - 1) }) =
Option.map encodeCfg
(match RhInstr.jump target with
| RhInstr.halt => none
| RhInstr.jump target => some { stack := target, regs := c.regs }
| RhInstr.inc r target => some { stack := target, regs := c.regs.set r (c.regs.getD r 0 + 1) }
| RhInstr.decnz r positive zero =>
if (c.regs.getD r 0 == 0) = true then some { stack := zero, regs := c.regs }
else some { stack := positive, regs := c.regs.set r (c.regs.getD r 0 - 1) }) All goals completed! 🐙
c:RhRegCfghlen:c.regs.length = 5r:ℕtarget:List (Fin 2)h:ReferenceLogical.instruction c.stack = RhInstr.inc r target⊢ (match mapInstr (RhInstr.inc r target) with
| RhInstr.halt => none
| RhInstr.jump target => some { stack := target, regs := encodeBank c.regs }
| RhInstr.inc r target =>
some { stack := target, regs := (encodeBank c.regs).set r ((encodeBank c.regs).getD r 0 + 1) }
| RhInstr.decnz r positive zero =>
if ((encodeBank c.regs).getD r 0 == 0) = true then some { stack := zero, regs := encodeBank c.regs }
else some { stack := positive, regs := (encodeBank c.regs).set r ((encodeBank c.regs).getD r 0 - 1) }) =
Option.map encodeCfg
(match RhInstr.inc r target with
| RhInstr.halt => none
| RhInstr.jump target => some { stack := target, regs := c.regs }
| RhInstr.inc r target => some { stack := target, regs := c.regs.set r (c.regs.getD r 0 + 1) }
| RhInstr.decnz r positive zero =>
if (c.regs.getD r 0 == 0) = true then some { stack := zero, regs := c.regs }
else some { stack := positive, regs := c.regs.set r (c.regs.getD r 0 - 1) })
c:RhRegCfghlen:c.regs.length = 5r:ℕtarget:List (Fin 2)h:ReferenceLogical.instruction c.stack = RhInstr.inc r target⊢ some { stack := target, regs := (encodeBank c.regs).set (perm r) (c.regs.getD r 0 + 1) } =
some { stack := target, regs := encodeBank (c.regs.set r (c.regs.getD r 0 + 1)) }
All goals completed! 🐙
| decnz r positive zero =>decnzc:RhRegCfghlen:c.regs.length = 5r:ℕpositive:List (Fin 2)zero:List (Fin 2)h:ReferenceLogical.instruction c.stack = RhInstr.decnz r positive zero⊢ (match mapInstr (RhInstr.decnz r positive zero) with
| RhInstr.halt => none
| RhInstr.jump target => some { stack := target, regs := encodeBank c.regs }
| RhInstr.inc r target =>
some { stack := target, regs := (encodeBank c.regs).set r ((encodeBank c.regs).getD r 0 + 1) }
| RhInstr.decnz r positive zero =>
if ((encodeBank c.regs).getD r 0 == 0) = true then some { stack := zero, regs := encodeBank c.regs }
else some { stack := positive, regs := (encodeBank c.regs).set r ((encodeBank c.regs).getD r 0 - 1) }) =
Option.map encodeCfg
(match RhInstr.decnz r positive zero with
| RhInstr.halt => none
| RhInstr.jump target => some { stack := target, regs := c.regs }
| RhInstr.inc r target => some { stack := target, regs := c.regs.set r (c.regs.getD r 0 + 1) }
| RhInstr.decnz r positive zero =>
if (c.regs.getD r 0 == 0) = true then some { stack := zero, regs := c.regs }
else some { stack := positive, regs := c.regs.set r (c.regs.getD r 0 - 1) })
simp only [mapInstr,encodeBank_getD _ hlen]decnzc:RhRegCfghlen:c.regs.length = 5r:ℕpositive:List (Fin 2)zero:List (Fin 2)h:ReferenceLogical.instruction c.stack = RhInstr.decnz r positive zero⊢ (if (c.regs.getD r 0 == 0) = true then some { stack := zero, regs := encodeBank c.regs }
else some { stack := positive, regs := (encodeBank c.regs).set (perm r) (c.regs.getD r 0 - 1) }) =
Option.map encodeCfg
(if (c.regs.getD r 0 == 0) = true then some { stack := zero, regs := c.regs }
else some { stack := positive, regs := c.regs.set r (c.regs.getD r 0 - 1) })
splitdecnz.isTruec:RhRegCfghlen:c.regs.length = 5r:ℕpositive:List (Fin 2)zero:List (Fin 2)h:ReferenceLogical.instruction c.stack = RhInstr.decnz r positive zeroh✝:(c.regs.getD r 0 == 0) = true⊢ some { stack := zero, regs := encodeBank c.regs } = Option.map encodeCfg (some { stack := zero, regs := c.regs })decnz.isFalsec:RhRegCfghlen:c.regs.length = 5r:ℕpositive:List (Fin 2)zero:List (Fin 2)h:ReferenceLogical.instruction c.stack = RhInstr.decnz r positive zeroh✝:¬(c.regs.getD r 0 == 0) = true⊢ some { stack := positive, regs := (encodeBank c.regs).set (perm r) (c.regs.getD r 0 - 1) } =
Option.map encodeCfg (some { stack := positive, regs := c.regs.set r (c.regs.getD r 0 - 1) }) <;>decnz.isTruec:RhRegCfghlen:c.regs.length = 5r:ℕpositive:List (Fin 2)zero:List (Fin 2)h:ReferenceLogical.instruction c.stack = RhInstr.decnz r positive zeroh✝:(c.regs.getD r 0 == 0) = true⊢ some { stack := zero, regs := encodeBank c.regs } = Option.map encodeCfg (some { stack := zero, regs := c.regs })decnz.isFalsec:RhRegCfghlen:c.regs.length = 5r:ℕpositive:List (Fin 2)zero:List (Fin 2)h:ReferenceLogical.instruction c.stack = RhInstr.decnz r positive zeroh✝:¬(c.regs.getD r 0 == 0) = true⊢ some { stack := positive, regs := (encodeBank c.regs).set (perm r) (c.regs.getD r 0 - 1) } =
Option.map encodeCfg (some { stack := positive, regs := c.regs.set r (c.regs.getD r 0 - 1) }) simp only [Option.map_some,encodeCfg]decnz.isFalsec:RhRegCfghlen:c.regs.length = 5r:ℕpositive:List (Fin 2)zero:List (Fin 2)h:ReferenceLogical.instruction c.stack = RhInstr.decnz r positive zeroh✝:¬(c.regs.getD r 0 == 0) = true⊢ some { stack := positive, regs := (encodeBank c.regs).set (perm r) (c.regs.getD r 0 - 1) } =
some { stack := positive, regs := encodeBank (c.regs.set r (c.regs.getD r 0 - 1)) }
rw [encodeBank_set _ hlendecnz.isFalsec:RhRegCfghlen:c.regs.length = 5r:ℕpositive:List (Fin 2)zero:List (Fin 2)h:ReferenceLogical.instruction c.stack = RhInstr.decnz r positive zeroh✝:¬(c.regs.getD r 0 == 0) = true⊢ some { stack := positive, regs := (encodeBank c.regs).set (perm r) (c.regs.getD r 0 - 1) } =
some { stack := positive, regs := (encodeBank c.regs).set (perm r) (c.regs.getD r 0 - 1) }]All goals completed! 🐙end ConjectureMachines.Riemann95.ReferenceProgram