Documentation

Complexity.Computability.Ram.Verification.Time.StraightLine

Exact costs of straight-line source statements #

Every completed execution of a straight-line block takes exactly the length of its compiled code. This derives the costs of sequences of assignments, memory operations and I/O from the existing compiler, without repeating their functional proofs.

Ram.Source.TimeBound.of_isStraightLine gives the corresponding conditional bound. It does not establish safety or termination; use Ram.Source.TotalContract.with_timeBound to combine it with a separate total-correctness proof.

theorem Ram.Source.LocalMeasuredExec.steps_eq_stmtSize {w control heapLimit depth steps : Nat} {program : Program} {stmt : Stmt} {s t : State w} (execution : LocalMeasuredExec control program heapLimit depth stmt steps s t) (straight : stmt.IsStraightLine) :

A completed straight-line execution takes exactly the number of instructions emitted by the local-frame compiler.

theorem Ram.Source.TimeBound.of_isStraightLine {w control heapLimit depth : Nat} {program : Program} {stmt : Stmt} {P : State w → Prop} (straight : stmt.IsStraightLine) :
TimeBound control program heapLimit depth stmt P fun (x : State w) => LocalCompiler.stmtSize control (LocalCompiler.calleeLocals program) stmt

Bound every completed straight-line execution by its compiled code length. No safety or termination assertion is needed for this conditional cost bound.