-
Notifications
You must be signed in to change notification settings - Fork 3
Description
A proof in src/Bluebell/Logic/WeakestPre.lean contains a sorry.
🤖 AI Analysis:
Statement Explanation
This theorem, wp_conj, states the rule for conjunction for the weakest precondition (wp). It asserts that satisfying the weakest preconditions for two separate programs, t₁ with postcondition Q₁ and t₂ with postcondition Q₂, is equivalent to satisfying the weakest precondition for a single combined program with a combined postcondition Q₁ ∧ Q₂.
- LHS:
(wp t₁ Q₁) ∧ (wp t₂ Q₂)describes a resourceathat is a valid precondition for botht₁to establishQ₁and fort₂to establishQ₂. - RHS:
wp (sorry) (and Q₁ Q₂)describes a resourceathat is a valid precondition for a combined program (represented bysorry) to establish the conjoined postconditionQ₁ ∧ Q₂.
The sorry in the program position on the right-hand side is a placeholder. It should be replaced with a program composition operator that runs t₁ and t₂ in parallel. Crucially, this equivalence is only expected to hold if t₁ and t₂ are non-interfering, meaning they operate on disjoint parts of the state. This is typically expressed as a side-condition that their "relevant indices" are disjoint.
Context
This theorem is one of the fundamental laws of the weakest precondition calculus being formalized, analogous to the rule of conjunction in Hoare logic. It is part of a collection of laws for wp including:
wp_conseq: The rule of consequence.wp_frame: The frame rule for separating conjunction (∗).wp_comp: The rule for sequential composition (∘).
The TODO comment just above this theorem (relevantIndices of a program and program composition placeholder) indicates that the necessary concepts to state and prove this theorem fully (like a parallel composition operator for program transformers and the notion of relevant indices for a program) are not yet defined. Proving this theorem will likely require defining these concepts first and adding a hypothesis about the disjointness of relevantIndices t₁ and relevantIndices t₂. The proof will rely heavily on the definition of wp and the properties of the underlying IndexedPSpPm model, which represents a state indexed by a set I.
Proof Suggestion
Before attempting the proof, you must fill in the sorry with a suitable program composition operator (let's call it t_comp) and add a hypothesis h_disjoint stating that the relevant indices of t₁ and t₂ are disjoint. The proof is an equivalence (⊣⊢), so it requires proving two implications.
-
Forward Direction (
⊢):(wp t₁ Q₁) ∧ (wp t₂ Q₂) → wp t_comp (Q₁ ∧ Q₂)- Start by unfolding the definitions of
wp,and, andentails(⊢). Userintro a ⟨ha₁, ha₂⟩ μ₀ c h_incto set up the context. ha₁gives you∃ b₁, (b₁ • c) ≤ t₁ (liftProb μ₀) ∧ Q₁ b₁. Similarly,ha₂gives∃ b₂, .... Usercasesto extract these witnessesb₁andb₂.- The core task is to construct a new resource
bfromb₁andb₂that will satisfy the goal. Thisbshould agree withb₁on the relevant indices oft₁and withb₂on the relevant indices oft₂. - Show that
Q₁ bandQ₂ bboth hold. This step is non-trivial and will likely require using theisIrrelevantproperty of hyper-assertions. Specifically, sinceQ₁ b₁holds andbagrees withb₁on the indices whereQ₁is "relevant",Q₁ bshould follow. - Finally, prove
(b • c) ≤ t_comp (liftProb μ₀). This will depend on the precise definition oft_comp, which should combine the outputs oft₁andt₂based on their disjoint relevant indices.
- Start by unfolding the definitions of
-
Backward Direction (
⊢):wp t_comp (Q₁ ∧ Q₂) → (wp t₁ Q₁) ∧ (wp t₂ Q₂)- Unfold definitions and assume
asatisfies the LHS. The goal is to prove two separate subgoals:a ∈ wp t₁ Q₁anda ∈ wp t₂ Q₂. Thesplittactic is useful here. - Let's focus on proving
a ∈ wp t₁ Q₁. Introduceμ₀,c, and the inclusion hypothesish_inc. - From the main assumption
a ∈ wp t_comp (Q₁ ∧ Q₂)applied toμ₀andc, you obtain a resourcebsuch that(b • c) ≤ t_comp (liftProb μ₀)andQ₁ b ∧ Q₂ b. - You can use this
bas the witness for the goal. You already haveQ₁ bfrom the conjunction. - The remaining task is to show
(b • c) ≤ t₁ (liftProb μ₀). You have(b • c) ≤ t_comp (liftProb μ₀). This requires showing that the output of the composed programt_compis greater than or equal to the output oft₁when restricted to the relevant indices oft₁. This property should follow from your definition oft_compand the disjointness hypothesis.
- Unfold definitions and assume
Goal: Replace the sorry with a complete proof.
Code Snippet:
theorem wp_conj : (wp t₁ Q₁) ∧ (wp t₂ Q₂) ⊣⊢ (wp (sorry) (and Q₁ Q₂)) := by sorry