Framing at the wp layer #
WP.Frames op x F states that the program x commutes op F · into the postcondition of wp x.
A WP built as the Lean.Order.PredTrans.frameClosure of a base wp frames every resource by
construction.
The monadic counterpart, which builds a WPMonad from the frame closure of a base interpretation,
is in Std.WP.Monad.Frame.
x frames the resource F with respect to the operator op : R → Pred → Pred: op F · commutes
into the postcondition of wp x for every postcondition.
For the meet op = (· ⊓ ·) with R = Pred and stateful Pred, this means running x preserves the
state identified by F. Other operators take a simpler resource, e.g. a cost counter R = Nat.
- op_wp_le_wp_op (Q : Value → Pred) (E : EPred) : Lean.Order.PartialOrder.rel (op F (wp x Q E)) (wp x (fun (a : Value) => op F (Q a)) E)
When
xframes(op F ·),(op F ·)commutes into the postcondition ofwp x.
Instances For
The framed spec vcgen applies for x, when each op r preserves suprema: framing x by F
makes op F (wp x (fun a => PreservesSup.upperAdjoint (op F) (Q a))) a precondition for wp x Q.
le_frameClosure at the wp layer: when x frames every resource r, landing
below wp x Q E suffices to land below the frame closure of wp x · E.
If wp is built as the frameClosure op of a base predicate transformer f x (the frame
rule internalized into wp), then every program frames every resource F with respect to op.
If wp x is conjunctive, then x frames (F ⊓ ·) when F holds before and after running x.
Reinterpret a WP so its weakest precondition is the frameClosure of the base
wp over a family of supremum-preserving resource operators op r.
Equations
- Std.WP.WP.of_frameClosure op base = { wpTrans := fun (x : Prog) => Lean.Order.PredTrans.frameClosure op (Std.WP.WP.wpTrans x), wp_trans_monotone := ⋯ }
Instances For
Characterization of the WP.of_frameClosure weakest precondition: landing below it is landing
below the base wp with every resource op r framed onto the pre- and postcondition.
Introduction rule for the weakest precondition of a WP.of_frameClosure interpretation,
selected by the witness equation heq: land below the base wp with every resource framed on.