Machine certificates for stateful controllers #
Refines relates a mathematical free-monad client to a fixed structured RAM program. Unlike
an operation-count contract, its budget bounds an actual execution, including controller
instructions and argument preparation. The final halt is added by Refines.executes.
The intermediate assertions record how answers are represented in registers or memory. The
bind rule uses one continuation code fragment for every intermediate answer: Lean's semantic
continuation is not an uncharged machine computation. Likewise returning a pure answer requires
an execution certificate. Initialization is supplied as code using Refines.prepend.
Main definitions #
Refines: admissible client semantics and bounded RAM execution with a relational postcondition.
Main results #
Refines.bind,Refines.branch: sequential and conditional controller certificates.Refines.call: inlining a dynamic operation after charged register preparation.Refines.executes: a complete flat-program run, including its final halt.
References #
The clients reuse Quang Dao's upstream PFunctor.FreeM. Machine execution and assembly reuse
the word-RAM calculus based on the lean-trominoes formalization; see WordRAM.Defs.
A fixed machine fragment implements the selected admissible client and its result/state
representation, within a bound depending on the initial abstract and concrete states.
As for ExecWithin, word boundedness is an entry assertion obligation: include Data.Bounded
in pre when reasoning about arbitrary machine data. Standard Data.init inputs are bounded
whenever InputFits holds.
Instances For
Strengthen an entry assertion, weaken the exit assertion, or increase the instruction bound.
Even a pure semantic computation needs actual code realizing its output assertion.
Compose with one fixed continuation fragment valid for every represented intermediate answer. The continuation budget is evaluated at the state actually reached by the first fragment.
A machine branch must test the same proposition as the semantic client. Both paths include all their control instructions; the common bound allows the larger two-instruction overhead.
Charge initialization or argument computation preceding a certified client. The prefix preserves the abstract initial state, while establishing its concrete entry representation.
Discharge a client's abstract postcondition using an independently proved semantic contract.
A certificate produces a real halting machine execution. The output relation specifies which word represents the abstract answer; observing this word does not evaluate a host decoder.
Inline a dynamic operation after a machine-certified preparation fragment. The body bound excludes a halt because execution continues in the caller; only the complete program halts.