Straight-line instruction blocks #
execBlock is a convenient state transformer, not a second cost model.
execBlock_exec connects it to exactly one real machine transition per
instruction whenever a linear block is present at the current program counter.
Instructions that always advance to the next address without changing running status. Input reads are excluded because exhausted input faults.
Equations
- (Ram.Instr.const dst value).Linear = True
- (Ram.Instr.move dst src).Linear = True
- (Ram.Instr.binop op dst lhs rhs).Linear = True
- (Ram.Instr.load dst addrReg).Linear = True
- (Ram.Instr.store addrReg src).Linear = True
- (Ram.Instr.write src).Linear = True
- x✝.Linear = False
Instances For
Fold instruction bodies in their program order. This transformer is used only through the machine-execution theorem when assigning a transition count.
Equations
- Ram.execBlock block s = List.foldl (fun (s : Ram.State w) (i : Ram.Instr) => Ram.execInstr i s) s block
Instances For
theorem
Ram.CodeAt.prefix_append
(pre block suffix : Code)
:
CodeAt (pre ++ block ++ suffix) (List.length pre) block
theorem
Ram.CodeAt.append_right
{code a b : Code}
{pc : Nat}
(h : CodeAt code pc (a ++ b))
:
CodeAt code (pc + List.length a) b
theorem
Ram.CodeAt.append
{code a b : Code}
{pc : Nat}
(ha : CodeAt code pc a)
(hb : CodeAt code (pc + List.length a) b)
:
theorem
Ram.execBlock_exec
{w : Nat}
{code block : Code}
{s : State w}
(hAt : CodeAt code s.pc block)
(hlinear : ∀ (i : Instr), i ∈ block → i.Linear)
(hrun : s.status = Status.running)
:
Exec code (List.length block) s (execBlock block s)
A linear block executes in exactly its length many transitions of the
machine's real step, starting from any running state at its first instruction.