| halt
| goto (next : Fin l)
| set (dst : Fin r) (value : Bool) (next : Fin l)
| copy (dst src : Fin r) (next : Fin l)
| bnot (dst src : Fin r) (next : Fin l)
| band (dst left right : Fin r) (next : Fin l)
| bor (dst left right : Fin r) (next : Fin l)
| bxor (dst left right : Fin r) (next : Fin l)
| branch (test : Fin r) (yes no : Fin l)
| push (stack : Fin s) (src : Fin r) (next : Fin l)
| peek (stack : Fin s) (value present : Fin r) (next : Fin l)
| pop (stack : Fin s) (value present : Fin r) (next : Fin l)
derivingDecidableEq, Fintype
defexecInstr {r s l : ℕ} (instr : Instr r s l) (c : Cfg r s l) : Cfg r s l :=
body · 22
lines
match instr with
| .halt => { c with pc := none }
| .goto next => { c with pc := some next }
| .set dst value next =>
{ c with pc := some next, regs :=Function.update c.regs dst value }
| .copy dst src next =>
{ c with pc := some next, regs :=Function.update c.regs dst (c.regs src) }
| .bnot dst src next =>
{ c with pc := some next, regs :=Function.update c.regs dst (!(c.regs src)) }
| .band dst a b next =>
{ c with pc := some next, regs :=Function.update c.regs dst (c.regs a && c.regs b) }
| .bor dst a b next =>
{ c with pc := some next, regs :=Function.update c.regs dst (c.regs a || c.regs b) }
| .bxor dst a b next =>
{ c with pc := some next, regs :=Function.update c.regs dst (c.regs a ^^ c.regs b) }
| .branch test yes no => { c with pc := some (if c.regs test then yes else no) }
| .push stack src next =>
{ c with pc := some next, «stacks»:=Function.update c.stacks stack (c.regs src :: c.stacks stack) }
| .peek stack value present next =>
{ c with pc := some next, regs := readRegs c.regs value present (c.stacks stack).head? }
| .pop stack value present next =>
{ pc := some next, regs := readRegs c.regs value present (c.stacks stack).head?, «stacks»:=Function.update c.stacks stack (c.stacks stack).tail }
theoremstep_code {r s l : ℕ} (p : Program r s l) (c : Cfg r s l)
(label : Fin l) (instr : Instr r s l) (hp : c.pc = some label)
(hc : p.code label = instr) : step p c = some (execInstr instr c) :=by
theoremreadRegs_value {r : ℕ} (regs : Fin r →Bool)
(value present : Fin r) (top : OptionBool) (h : value ≠ present) :
readRegs regs value present top value = top.getD false:=by