WP Soundness #
WPSound m ps is the soundness bridge from wp-style reasoning to the operational
Internal.Ensures predicate: if wp x proves a postcondition P, then x is
Internal.Ensures-witnessed at P. Combined with Internal.MayReturn x a, this
yields P a for any value a that x may classically return.
Soundness of wp: a wp-provable postcondition is Internal.Ensures-witnessed.
- ensures_of_wp {α : Type u} {x : m α} {P : α → Prop} : (⊢ₛ wp⟦x⟧ (PostCond.mayThrow fun (a : α) => ⌜P a⌝)) → Internal.Ensures P x
A
wp-provable postcondition refinesxviaInternal.Ensures.
Instances
From a wp-provable postcondition and an Internal.MayReturn witness, conclude P
at that value.
From a wp-provable postcondition and a MonadAttach.CanReturn witness, conclude P
at that value. Convenient when the monad has a LawfulMonadAttach instance, since
CanReturn is typically definitional.
Soundness lemma for Id.run. Derived from WPSound.of_wp_canReturn: Id.run prog = x
is the MonadAttach.CanReturn prog x witness.
Per-transformer soundness lemmas #
For each transformer T, T.ensures_of_wp_run produces an Internal.Ensures over the post-run
computation prog.run «args» : m _. T.of_wp_run further collapses this to a pure proposition
P a when the base monad m has LawfulMonadAttach and the caller can supply a
MonadAttach.CanReturn witness — the natural generalization of the Id-specialized
*.of_wp_run_eq family below.
A wp-provable postcondition refines the post-run computation prog.run r : m α
via Internal.Ensures.
Pure-proposition soundness: from a MonadAttach.CanReturn witness for prog.run r and a
wp-provable postcondition, conclude P a.
Soundness lemma for ReaderM.run: Id-specialization of ReaderT.of_wp_run.
A wp-provable postcondition refines the post-run computation prog.run s : m (α × σ)
via Internal.Ensures.
Pure-proposition soundness for StateT.run, generalizing StateM.of_wp_run_eq.
Soundness lemma for StateM.run: Id-specialization of StateT.of_wp_run.
Soundness lemma for StateM.run': Id-specialization of StateT.of_wp_run.
A wp-provable postcondition with split .ok/.error cases refines the post-run computation
prog.run : m (Except ε α) via Internal.Ensures.
Pure-proposition soundness for ExceptT.run, generalizing Except.of_wp_eq.
A wp-provable postcondition with split some/none cases refines the post-run computation
prog.run : m (Option α) via Internal.Ensures.
Pure-proposition soundness for OptionT.run, generalizing Option.of_wp_eq.