Documentation

PolyFun.Control.Monad.WPInstance

Core's judgments at an explicit interpretation #

Core's Triple, WPConjunctive, and LawfulWPMonadAttach take their interpretation as an instance-implicit argument, and so do their constructors and projections. Some interpretations are constructions rather than instances, such as MAlgOrdered.toWP α or MonadAttach.toWPMonadDemonic. A proof about one of them cannot build or project these structures directly: ⟨h⟩ and h.le_wp search for the interpretation again, and instance search does not find a construction. The lemmas here take the interpretation as an explicit argument, which a goal or a hypothesis determines by unification. Each states its judgment through inst.wp:

They are upstream candidates for core's Std.WP, and they live in its namespaces.

theorem Std.WP.WP.triple_iff {Prog : Type u} {Value : Type v} {Pred : Type w} {EPred : Type w'} [Assertion Pred] [Assertion EPred] (inst : WP Prog Value Pred EPred) {x : Prog} {pre : Pred} {post : Value → Pred} {epost : EPred} :
⦃ pre ⦄ x ⦃ post; epost ⦄ ↔ Lean.Order.PartialOrder.rel pre (wp x post epost)

Triple.iff at an explicit interpretation: a triple is an entailment of the weakest precondition. Upstream candidate.

theorem Std.WP.WP.triple_of_le_wp {Prog : Type u} {Value : Type v} {Pred : Type w} {EPred : Type w'} [Assertion Pred] [Assertion EPred] (inst : WP Prog Value Pred EPred) {x : Prog} {pre : Pred} {post : Value → Pred} {epost : EPred} (h : Lean.Order.PartialOrder.rel pre (wp x post epost)) :
⦃ pre ⦄ x ⦃ post; epost ⦄

Triple.intro at an explicit interpretation. Upstream candidate.

theorem Std.WP.WP.wpConjunctive_iff {Prog : Type u} {Value : Type v} {Pred : Type w} {EPred : Type w'} [Assertion Pred] [Assertion EPred] (inst : WP Prog Value Pred EPred) (x : Prog) :
WPConjunctive x ↔ ∀ (Q₁ Q₂ : Value → Pred) (E₁ E₂ : EPred), Lean.Order.PartialOrder.rel (Lean.Order.meet (wp x Q₁ E₁) (wp x Q₂ E₂)) (wp x (Lean.Order.meet Q₁ Q₂) (Lean.Order.meet E₁ E₂))

Conjunctivity at a program, at an explicit interpretation: the meet of two weakest preconditions lies below the weakest precondition of the meets. Upstream candidate.

theorem Std.WP.WPMonad.lawfulWPMonadAttach_iff {m : Type u → Type v} {Pred : Type w} {EPred : Type z} [Monad m] [MonadAttach m] [LawfulMonadAttach m] [Assertion Pred] [Assertion EPred] (inst : WPMonad m Pred EPred) :
LawfulWPMonadAttach m Pred EPred ↔ ∀ {α : Type u} {x : m α} {P : α → Prop} {a : α}, MonadAttach.CanReturn x a → Lean.Order.PartialOrder.rel Lean.Order.top (wp x (fun (a : α) => Lean.Order.CompleteLattice.ofProp (P a)) Lean.Order.top) → P a

Soundness with respect to lawful attachment, at an explicit interpretation: a postcondition that the weakest precondition proves holds at every value the program can return. Upstream candidate.