-
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, C_wp_swap, states a relationship between the weakest precondition wp and the joint conditioning modality 𝑪_. It asserts that if a resource satisfies the joint condition for a family of weakest preconditions, then it also satisfies the weakest precondition for the joint condition of the postconditions.
- Hypotheses: The main hypothesis is
𝑪_ μ (fun v => wp t (K v)). This means the current resource can be decomposed according to the probability distributionμ. For each outcomevfrom the support ofμ, the corresponding component of the resource satisfieswp t (K v), which is the weakest precondition for the programtto achieve the postconditionK v. Thesorryon the left-hand side likely represents a missing side-condition, possibly related to the behavior of the programt(e.g., that it doesn't interfere with the probabilistic structure). - Goal: The goal is to prove
wp t (𝑪_ μ K). This means the original resource satisfies the weakest precondition for the programtto achieve the joint postcondition𝑪_ μ K. The postcondition𝑪_ μ Kitself asserts that the final resource can be decomposed according toμ, with each component satisfyingK v.
In essence, this theorem allows "swapping" the wp and 𝑪_ operators, moving the wp from inside the modality to the outside. This is a powerful property for compositional verification of probabilistic programs.
Context
This theorem is a key component of the Bluebell program logic, specifically for reasoning about programs that involve probabilistic sampling. It connects the weakest precondition calculus (a standard tool for program verification) with the jointCondition modality (𝑪_), which is the logic's way of specifying properties of probability distributions.
This rule is analogous to other rules that describe how wp interacts with logical connectives. For instance, wp distributes over ∧, but its interaction with separating conjunction ∗ is more complex, as shown by the wp_frame theorem. C_wp_swap clarifies this interaction for the 𝑪_ modality, which is central to expressing hyperproperties about probabilistic behavior.
Proving this theorem is essential for verifying programs that first sample a value v from a distribution μ and then execute code that depends on v. This rule allows reasoning about the whole program by analyzing the weakest precondition for each possible outcome v separately. The sorry placeholder is critical; such "swap" rules in program logic often require side-conditions about non-interference or linearity of the program transformer t.
Proof Suggestion
The proof will involve carefully unfolding the definitions of wp and 𝑪_ and constructing a suitable witness for the final existential quantifier.
-
Unfold Definitions: Start by applying
intro a hato assume you have a resourceathat satisfies the left-hand side. Unfold the definition of entailment (⊢). Then, unfold the definition ofwpin the goal. This will require you to prove a statement of the form∀ μ₀ c, (a • c) ≤ ... → ∃ b, .... So, introduceμ₀,c, and the inclusion hypothesish_inc. -
Deconstruct the Hypothesis: The main hypothesis is
a ∈ 𝑪_ μ (fun v => wp t (K v)). UnfoldjointCondition(𝑪_) on this hypothesis. This will give you existential witnesses:P: An indexed family of probability spaces.p: An indexed family of permissions.h_compat: A compatibility proof.κ: An indexed family of Markov kernels.
And several properties, including:- An inclusion
a_k ≤ a, wherea_kis the resource(fun i => ⟨⟨WithTop.some (P i), p i⟩, h_compat i⟩). - A factorization of measures:
∀ i, (P i).μ = μ.toMeasure.bind (κ i). - The core property:
∀ v ∈ μ.support, b_v ∈ wp t (K v), whereb_vis the resource corresponding to the outcomev.
-
Use the Inner
wp: For eachv ∈ μ.support, you have a hypothesisb_v ∈ wp t (K v). The definition ofwpis universally quantified over initial distributions and frames. The main challenge is to connect the single global execution starting fromIndexedPSpPm.liftProb μ₀(from the goal) with these individualwphypotheses. This step will likely rely on a key property of the program transformert, for example, that it is "linear" or preserves the kernel decomposition in some way. This might be what thesorryhypothesis is intended to capture. -
Construct the Witness
b: Your goal is to provide a resourcebthat satisfiesb ∈ 𝑪_ μ Kand(b • c) ≤ t (IndexedPSpPm.liftProb μ₀). You will need to constructbby defining its own decomposition (P',p',κ'). This construction will likely use the results of applying thewpproperty for eachv.- For each
v ∈ μ.support, the hypothesisb_v ∈ wp t (K v)gives you the existence of a final resourceb'_vsatisfyingK v. - You need a way to "stitch together" these individual
b'_vresources to form the final global resourceb. The structure ofbshould mirror the structure ofa, using a new set of kernels that represent the state after the programthas run.
- For each
-
Show Inclusion and Postcondition: Once you have constructed
b, you must prove the two required properties:b ∈ 𝑪_ μ K: This should follow from your construction ofb, as its componentsb'_vwere chosen to satisfyK v.(b • c) ≤ t (IndexedPSpPm.liftProb μ₀): This is the most difficult part. It requires relating the global final statet (IndexedPSpPm.liftProb μ₀)to the componentsb'_vyou obtained. Again, this relies on the properties oft.
A useful tactic throughout this proof will be unfold to manage the complex definitions. You may need to use rcases or cases to deconstruct the existential hypotheses from 𝑪_. The key insight will likely involve identifying and applying a linearity or decomposition property of t. Consider investigating what properties are assumed for a program transformer of type IndexedPSpPm I α V F → IndexedPSpPm I α V F, as this might be where the justification for the swap lies.
Goal: Replace the sorry with a complete proof.
Code Snippet:
theorem C_wp_swap {β : Type*} [MeasurableSpace β] {μ : PMF β}
{K : β → HyperAssertion (IndexedPSpPm I α V F)} :
𝑪_ μ (fun v => wp t (K v)) ∧ sorry ⊢ wp t (𝑪_ μ K) := by sorry