A small I/O application verified by weakest-precondition rewriting #
This fixed program reads one word, increments it, and writes the result. Its functional proof uses budget-free verification conditions. A separate time proof checks the compiler-derived instruction count without repeating the functional postcondition. Their combination supplies the checked compiler with a contract for a real halted execution of the same generated code.
The result is modular word addition. No natural-number no-overflow claim is made, and any unconsumed input is retained.
The mathematical increment is also an ordinary StateM program verified
with Lean's native mvcgen. Its triple is transferred through the existing
RAM refinement and used by the final compiled execution theorem.
Equations
Instances For
Equations
Instances For
The machine implements the ordinary word function fun x => x + 1.
The untouched input tail and prior output are retained as ghost parameters,
not reconstructed by unfolding the execution in each client proof.
Native verification concerns the abstract state, without machine registers or an instruction budget. Addition keeps its modular word semantics.
The existing implementation refinement also describes the standard returned-value/final-state pair of the stateful mathematical model.
The functional result is proved before choosing any instruction budget.
Instruction accounting can ignore the functional postcondition. The seven steps still come from the existing measured compiler semantics.
Independent functional and time proofs describe the same execution.