Exact source counts for callee-sized frames #
LocalMeasuredExec retains the computations and safety premises of SafeExec.
Its counts come from the instruction blocks generated by LocalCompiler and
the concrete callee-sized ABI. A function's declared local bound determines its
call overhead; the reserved-register boundary does not price the call.
The closed simulation below proves that these counts are actual machine transitions. Recursive bodies use the induction hypothesis at their own local bound; no unproved call-simulation assumption remains.
Safe execution with exact counts from the local-frame compiler. control
locates reserved registers; depth separately bounds nested source calls.
- skip {control : Nat} {program : Program} {heapLimit w d : Nat} {s : State w} : LocalMeasuredExec control program heapLimit d Stmt.skip 0 s s
- assign {control : Nat} {program : Program} {heapLimit w d : Nat} {dst : Reg} {value : Expr} {s : State w} (reads : Expr.ReadsBelow heapLimit s.regs s.mem value) : LocalMeasuredExec control program heapLimit d (Stmt.assign dst value) (LocalCompiler.stmtSize control (LocalCompiler.calleeLocals program) (Stmt.assign dst value)) s (s.setReg dst (s.eval value))
- store {control : Nat} {program : Program} {heapLimit w d : Nat} {address value : Expr} {s : State w} (addressReads : Expr.ReadsBelow heapLimit s.regs s.mem address) (valueReads : Expr.ReadsBelow heapLimit s.regs s.mem value) (destination : BitVec.toNat (s.eval address) < heapLimit) : LocalMeasuredExec control program heapLimit d (Stmt.store address value) (LocalCompiler.stmtSize control (LocalCompiler.calleeLocals program) (Stmt.store address value)) s (s.setMem (s.eval address) (s.eval value))
- seq {control : Nat} {program : Program} {heapLimit w d : Nat} {a : Stmt} {na : Nat} {s middle : State w} {b : Stmt} {nb : Nat} {t : State w} (first : LocalMeasuredExec control program heapLimit d a na s middle) (second : LocalMeasuredExec control program heapLimit d b nb middle t) : LocalMeasuredExec control program heapLimit d (a.seq b) (na + nb) s t
- iteTrue {control : Nat} {program : Program} {heapLimit w d : Nat} {yes : Stmt} {nb : Nat} {s t : State w} {c : Expr} {no : Stmt} (reads : Expr.ReadsBelow heapLimit s.regs s.mem c) (condition : s.eval c ≠ 0) (body : LocalMeasuredExec control program heapLimit d yes nb s t) : LocalMeasuredExec control program heapLimit d (Stmt.ite c yes no) (List.length (c.compile (ABI.scratch control)) + 1 + nb + 1) s t
- iteFalse {control : Nat} {program : Program} {heapLimit w d : Nat} {no : Stmt} {nb : Nat} {s t : State w} {c : Expr} {yes : Stmt} (reads : Expr.ReadsBelow heapLimit s.regs s.mem c) (condition : s.eval c = 0) (body : LocalMeasuredExec control program heapLimit d no nb s t) : LocalMeasuredExec control program heapLimit d (Stmt.ite c yes no) (List.length (c.compile (ABI.scratch control)) + 1 + nb) s t
- whileFalse {control : Nat} {program : Program} {heapLimit w d : Nat} {c : Expr} {body : Stmt} {s : State w} (reads : Expr.ReadsBelow heapLimit s.regs s.mem c) (condition : s.eval c = 0) : LocalMeasuredExec control program heapLimit d (Stmt.while c body) (List.length (c.compile (ABI.scratch control)) + 1) s s
- whileTrue {control : Nat} {program : Program} {heapLimit w d : Nat} {b : Stmt} {nb : Nat} {s middle : State w} {c : Expr} {nr : Nat} {t : State w} (reads : Expr.ReadsBelow heapLimit s.regs s.mem c) (condition : s.eval c ≠ 0) (body : LocalMeasuredExec control program heapLimit d b nb s middle) (rest : LocalMeasuredExec control program heapLimit d (Stmt.while c b) nr middle t) : LocalMeasuredExec control program heapLimit d (Stmt.while c b) (List.length (c.compile (ABI.scratch control)) + 1 + nb + 1 + nr) s t
- read {control : Nat} {program : Program} {heapLimit w : Nat} {value : Word w} {rest : List (Word w)} {d : Nat} {dst : Reg} {s : State w} (available : s.input = value :: rest) : LocalMeasuredExec control program heapLimit d (Stmt.read dst) (LocalCompiler.stmtSize control (LocalCompiler.calleeLocals program) (Stmt.read dst)) s (let __src := s.setReg dst value; { regs := __src.regs, mem := __src.mem, input := rest, outputRev := __src.outputRev })
- write {control : Nat} {program : Program} {heapLimit w d : Nat} {value : Expr} {s : State w} (reads : Expr.ReadsBelow heapLimit s.regs s.mem value) : LocalMeasuredExec control program heapLimit d (Stmt.write value) (LocalCompiler.stmtSize control (LocalCompiler.calleeLocals program) (Stmt.write value)) s { regs := s.regs, mem := s.mem, input := s.input, outputRev := s.eval value :: s.outputRev }
- call {control : Nat} {program : Program} {heapLimit w fn : Nat} {f : Func} {args : List Expr} {d bodySteps : Nat} {callee : State w} {dsts : List Reg} {s : State w} (lookup : program[fn]? = some f) (arity : args.length = f.params) (hresultCount : dsts.length = f.results.length) (frame : f.params ≤ f.locals) (arguments : ∀ (arg : Expr), arg ∈ args → Expr.ReadsBelow heapLimit s.regs s.mem arg) (body : LocalMeasuredExec control program heapLimit d f.body bodySteps (s.enter (List.map s.eval args)) callee) (results : ∀ (result : Expr), result ∈ f.results → Expr.ReadsBelow heapLimit callee.regs callee.mem result) : LocalMeasuredExec control program heapLimit (d + 1) (Stmt.call dsts fn args) (List.length (ABI.callPrefixLocals control f.locals args 0) + 1 + bodySteps + List.length (ABI.returnCodeResultsLocals control f.locals f.results) + dsts.length) s (s.leave callee dsts f.results)
Instances For
Dropping the count preserves every source operation and safety premise.
Additional allowed call nesting does not alter the executed count.
Moving the reserved registers does not change a computation's instruction count. In particular, a larger global register boundary does not enlarge the frames of functions whose declared local bounds have stayed the same.
An existing safe assignment has exactly its emitted instruction length. The endpoint is retained, so clients can reuse a proved value correspondence without rebuilding the assignment or eliminating a fixed concrete state.
Every safe computation has a local-compiler-derived count, independently of whether the supplied register boundary is sufficient for its compilation. Compiler simulation separately requires well-formedness at that boundary.
Every measured source constructor executes for exactly its declared number
of actual RAM transitions. In the recursive case the body runs at f.locals,
which need not equal either the caller's local bound or control.
A safe source execution determines a single exact count uniformly for all matching target states, rather than a target-dependent count chosen afterward.