Program logic #
A weakest-precondition calculus for exec, with cost. Nothing here is trusted: every rule is
a theorem about the interpreter.
wp c Q s says: from s, c terminates normally (no fail, no machine error), and Q holds
of the final state and the number of steps taken. The rules below push wp through the
syntax. For a concrete program, simp only [wp_simps] turns the goal into a pure
verification condition; each loop needs an invariant (wp_loop).
Normal-termination weakest precondition for a state-and-cost postcondition.
Equations
- OrderMaintenance.Machine.wp c Q s = (OrderMaintenance.Machine.exec c s).Ok Q
Instances For
Hoare triple with a cost bound: from every state satisfying P, c terminates normally
in at most k steps, in a state satisfying Q.
Equations
- (⦃P⦄ c ⦃Q⦄≤ k) = ∀ (s : OrderMaintenance.Machine.State), P s → OrderMaintenance.Machine.wp c (fun (s' : OrderMaintenance.Machine.State) (n : Nat) => Q s' ∧ n ≤ k) s
Instances For
Hoare triple with a cost bound: from every state satisfying P, c terminates normally
in at most k steps, in a state satisfying Q.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Outcomes #
One rule per construct #
A catch whose body fails runs the handler from the state the body reached.
Loops #
The loop rule. N is the value of the bound, I k the invariant before iteration k,
and kb a bound on the cost of one execution of the body.