Stat.Coupling.Product­Loss­Monotone­Coupling

This module collects the coupling construction and optimality theorem showing that, among all couplings of two real probability measures with finite second moments, the product expectation is largest at the comonotone qu

Tail­Integral 3 core · 10 supporting The elementary identity behind Hoeffding's covariance formula is that every real number is the Lebesgue integral of a *signed tail indicator*: a = ∫ s, (𝟙{s < a} - 𝟙{s < 0}) ds. ★ integral_signedTail_prod

The signed tail representation of a real number

The elementary identity behind Hoeffding's covariance formula is that every real number is the Lebesgue integral of a signed tail indicator:

a = ∫ s, (𝟙{s < a} - 𝟙{s < 0}) ds.

Indeed the integrand vanishes outside the interval between 0 and a, where it equals +1 (if a ≥ 0) or -1 (if a < 0), so the integral is the signed length a.

This file packages that identity, its integrability, and the corresponding statements for the product signedTail x s * signedTail y t on ℝ × ℝ, which represents the product x * y as a two-dimensional Lebesgue integral:

x * y = ∫∫ (𝟙{s < x} - 𝟙{s < 0})(𝟙{t < y} - 𝟙{t < 0}) ds dt.

Together with the bound ∫∫ |·| = |x| * |y| (which is what makes the downstream Fubini swap legitimate for marginals, via Cauchy–Schwarz), this is the entire analytic input to hoeffding_cov_identity.

def tailInd reviewed
Causalean.Stat

tailInd a s is the indicator 𝟙{s < a}, i.e. 1 when s < a and 0 otherwise, written as the indicator function of the ray Iio a.

Definition (Lean source)
noncomputable def tailInd (a s : ℝ) : ℝ := (Iio a).indicator (fun _ => (1 : ℝ)) s
def signedTail reviewed
Causalean.Stat

signedTail a s = 𝟙{s < a} - 𝟙{s < 0}, the signed tail indicator of a. As a function of s it is +1 on [0, a) when a ≥ 0, -1 on [a, 0) when a < 0, and 0 elsewhere; its Lebesgue integral is exactly a.

Definition (Lean source)
noncomputable def signedTail (a s : ℝ) : ℝ := tailInd a s - tailInd 0 s
lemma integral_signedTail_prod reviewed
Causalean.Stat

Product tail representation. For any two reals x and y, their product x * y equals the two-dimensional Lebesgue integral of the product of their signed tail indicators, ∫∫ (𝟙{s<x} - 𝟙{s<0})(𝟙{t<y} - 𝟙{t<0}) ds dt.

Formal statement
x y :
(∫ q : ℝ × ℝ, signedTail x q.1 * signedTail y q.2 ∂(volume.prod volume)) = x * y
Proof (Lean source)
lemma integral_signedTail_prod (x y : ℝ) : (∫ q : ℝ × ℝ, signedTail x q.1 * signedTail y q.2 ∂(volume.prod volume)) = x * y := by rw [integral_prod_mul (fun s => signedTail x s) (fun t => signedTail y t), integral_signedTail, integral_signedTail]
10 supporting declarations (lemmas, instances)
PIT 2 core · 3 supporting This file proves the probability-integral-transform: if μ is a Borel probability measure on ℝ, then pushing the uniform measure on (0,1) through the (lower) quantile function Causalean.Stat.quantile μ recovers μ: (volume ★ quantile_map_uniform

Probability integral transform (PIT) for the quantile function

This file proves the probability-integral-transform: if μ is a Borel probability measure on , then pushing the uniform measure on (0,1) through the (lower) quantile function Causalean.Stat.quantile μ recovers μ:

(volume.restrict (Ioo 0 1)).map (quantile μ) = μ.

The proof rests on the Galois characterisation quantile_le_iff from Causalean.Stat.Quantile:

quantile μ τ ≤ x ↔ τ ≤ cdf μ x (for interior 0 < τ < 1),

so that, writing U for a Unif(0,1) variable, P(quantile μ U ≤ x) = P(U ≤ cdf μ x) = cdf μ x, i.e. the pushforward and μ have the same values on every left-ray Iic x, hence are equal by Measure.ext_of_Iic.

These are the reusable primitives feeding the comonotone / countermonotone optimal couplings in Coupling.lean.

def unifOI reviewed
Causalean.Stat

The uniform probability measure on the open unit interval (0,1), realised as Lebesgue measure restricted to Ioo 0 1.

Definition (Lean source)
noncomputable def unifOI : Measure ℝ := volume.restrict (Ioo (0 : ℝ) 1)
theorem quantile_map_uniform reviewed
Causalean.Stat

Probability integral transform. For a Borel probability measure μ on , the pushforward of the uniform distribution on (0,1) under μ's quantile function equals μ itself.

Formal statement
unifOI.map (quantile μ) = μ
Proof (Lean source)
theorem quantile_map_uniform (μ : Measure ℝ) [IsProbabilityMeasure μ] : unifOI.map (quantile μ) = μ := by refine Measure.ext_of_Iic (unifOI.map (quantile μ)) μ (fun x => ?_) rw [Measure.map_apply₀ (aemeasurable_quantile_unifOI μ) measurableSet_Iic.nullMeasurableSet] rw [unifOI, Measure.restrict_apply' measurableSet_Ioo] have hset : quantile μ ⁻¹' Iic x ∩ Ioo (0 : ℝ) 1 = Ioo (0 : ℝ) 1 ∩ Iic (cdf μ x) := by ext u constructor · intro h exact ⟨h.2, (quantile_le_iff h.2.1 h.2.2).mp h.1⟩ · intro h exact ⟨(quantile_le_iff h.1.1 h.1.2).mpr h.2, h.1⟩ rw [hset, ← ProbabilityTheory.ofReal_cdf μ x] exact volume_Ioo_zero_one_inter_Iic (ProbabilityTheory.cdf_nonneg μ x) (ProbabilityTheory.cdf_le_one μ x)
3 supporting declarations (lemmas, instances)
Coupling 5 core · 1 supporting A coupling of two real probability measures μ, ν is a probability measure π on ℝ × ℝ whose two marginals are μ and ν. ★ isCoupling_comonotoneCoupling★ isCoupling_countermonotoneCoupling

Couplings and the explicit monotone couplings

A coupling of two real probability measures μ, ν is a probability measure π on ℝ × ℝ whose two marginals are μ and ν. This file:

* defines IsCoupling π μ ν (probability measure with π.map Prod.fst = μ, π.map Prod.snd = ν), the Fréchet class Π(μ,ν); * defines the two extremal couplings built from the quantile transform: * comonotoneCoupling μ ν — pushforward of Unif(0,1) under u ↦ (quantile μ u, quantile ν u) (the comonotone / quantile coupling); * countermonotoneCoupling μ ν — pushforward under u ↦ (quantile μ u, quantile ν (1 - u)) (the countermonotone coupling); * proves each is genuinely a coupling of (μ, ν) (marginals via the PIT quantile_map_uniform, plus that u ↦ 1 - u preserves Unif(0,1)).

These are the optimizers whose optimality is established downstream.

structure IsCoupling reviewed
Causalean.Stat

π is a coupling of μ and ν, i.e. a member of the Fréchet class Π(μ, ν), when it is a probability measure on ℝ × ℝ whose first marginal is μ and whose second marginal is ν.

Definition (Lean source)
π :
Measure (ℝ × ℝ)
μ ν :
A coupling is a probability measure.
isProbabilityMeasure :
The first marginal of `π` is `μ`.
map_fst :
π.map fst = μ
The second marginal of `π` is `ν`.
map_snd :
π.map snd = ν
def comonotoneCoupling reviewed
Causalean.Stat

The comonotone (quantile) coupling of μ and ν: the pushforward of the uniform measure on (0,1) under u ↦ (quantile μ u, quantile ν u). Both coordinates are driven by the same uniform draw, giving the maximal positive dependence within Π(μ, ν).

Definition (Lean source)
noncomputable def comonotoneCoupling (μ ν : Measure ℝ) : Measure (ℝ × ℝ) := unifOI.map (fun u => (quantile μ u, quantile ν u))
def countermonotoneCoupling reviewed
Causalean.Stat

The countermonotone coupling of μ and ν: the pushforward of the uniform measure on (0,1) under u ↦ (quantile μ u, quantile ν (1 - u)). The reflection u ↦ 1 - u on the second coordinate produces the maximal negative dependence within Π(μ, ν).

Definition (Lean source)
noncomputable def countermonotoneCoupling (μ ν : Measure ℝ) : Measure (ℝ × ℝ) := unifOI.map (fun u => (quantile μ u, quantile ν (1 - u)))
theorem isCoupling_comonotoneCoupling reviewed
Causalean.Stat

For probability measures μ and ν on the reals, the comonotone coupling of μ and ν is indeed a coupling of the pair, i.e. its two marginals recover μ and ν.

Formal statement
Proof (Lean source)
theorem isCoupling_comonotoneCoupling (μ ν : Measure ℝ) [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] : IsCoupling (comonotoneCoupling μ ν) μ ν := by let hμ : AEMeasurable (quantile μ) unifOI := aemeasurable_quantile_unifOI μ let hν : AEMeasurable (quantile ν) unifOI := aemeasurable_quantile_unifOI ν refine ⟨?_, ?_, ?_⟩ · unfold comonotoneCoupling exact Measure.isProbabilityMeasure_map (hμ.prodMk hν) · unfold comonotoneCoupling calc (unifOI.map (fun u => (quantile μ u, quantile ν u))).map fst = unifOI.map (fst ∘ fun u => (quantile μ u, quantile ν u)) := by rw [AEMeasurable.map_map_of_aemeasurable measurable_fst.aemeasurable (hμ.prodMk hν)] _ = μ := by simpa [Function.comp_def] using (quantile_map_uniform μ) · unfold comonotoneCoupling calc (unifOI.map (fun u => (quantile μ u, quantile ν u))).map snd = unifOI.map (snd ∘ fun u => (quantile μ u, quantile ν u)) := by rw [AEMeasurable.map_map_of_aemeasurable measurable_snd.aemeasurable (hμ.prodMk hν)] _ = ν := by simpa [Function.comp_def] using (quantile_map_uniform ν)
theorem isCoupling_countermonotoneCoupling reviewed
Causalean.Stat

For probability measures μ and ν on the reals, the countermonotone coupling of μ and ν is indeed a coupling of the pair, i.e. its two marginals recover μ and ν.

Formal statement
Proof (Lean source)
theorem isCoupling_countermonotoneCoupling (μ ν : Measure ℝ) [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] : IsCoupling (countermonotoneCoupling μ ν) μ ν := by let r : ℝ → ℝ := fun u => 1 - u have hr : Measurable r := measurable_const.sub measurable_id let hμ : AEMeasurable (quantile μ) unifOI := aemeasurable_quantile_unifOI μ have hνmap : AEMeasurable (quantile ν) (unifOI.map r) := by simpa [r, map_one_sub_unifOI] using (aemeasurable_quantile_unifOI ν) let hνr : AEMeasurable (fun u : ℝ => quantile ν (1 - u)) unifOI := by simpa [r, Function.comp_def] using hνmap.comp_measurable hr refine ⟨?_, ?_, ?_⟩ · unfold countermonotoneCoupling exact Measure.isProbabilityMeasure_map (hμ.prodMk hνr) · unfold countermonotoneCoupling calc (unifOI.map (fun u => (quantile μ u, quantile ν (1 - u)))).map fst = unifOI.map (fst ∘ fun u => (quantile μ u, quantile ν (1 - u))) := by rw [AEMeasurable.map_map_of_aemeasurable measurable_fst.aemeasurable (hμ.prodMk hνr)] _ = μ := by simpa [Function.comp_def] using (quantile_map_uniform μ) · unfold countermonotoneCoupling calc (unifOI.map (fun u => (quantile μ u, quantile ν (1 - u)))).map snd = unifOI.map (snd ∘ fun u => (quantile μ u, quantile ν (1 - u))) := by rw [AEMeasurable.map_map_of_aemeasurable measurable_snd.aemeasurable (hμ.prodMk hνr)] _ = (unifOI.map r).map (quantile ν) := by rw [AEMeasurable.map_map_of_aemeasurable hνmap hr.aemeasurable] rfl _ = ν := by rw [map_one_sub_unifOI] exact quantile_map_uniform ν
1 supporting declaration (lemmas, instances)
  • map_one_sub_unifOI lemma — The reflection u ↦ 1 - u preserves the uniform measure on (0,1): unifOI.map (fun u => 1 - u) = unifOI.
    unifOI.map (fun u : ℝ => 1 - u) = unifOI
    Proof (Lean source)
    lemma map_one_sub_unifOI : unifOI.map (fun u : ℝ => 1 - u) = unifOI := by let f : ℝ → ℝ := fun u => 1 - u have hf : Measurable f := measurable_const.sub measurable_id have hvol : Measure.map f (volume : Measure ℝ) = volume := by have hneg : Measure.map (fun u : ℝ => (-1 : ℝ) * u) (volume : Measure ℝ) = volume := by simpa using (Real.map_volume_mul_left (a := (-1 : ℝ)) (by norm_num)) have hadd : Measure.map (fun u : ℝ => (1 : ℝ) + u) (volume : Measure ℝ) = volume := (measurePreserving_add_left (volume : Measure ℝ) (1 : ℝ)).map_eq calc Measure.map f (volume : Measure ℝ) = Measure.map (fun u : ℝ => (1 : ℝ) + u) (Measure.map (fun u : ℝ => (-1 : ℝ) * u) volume) := by rw [Measure.map_map] · congr 1 funext u dsimp [f] ring · exact (measurable_const.add measurable_id) · exact (measurable_const.mul measurable_id) _ = volume := by rw [hneg, hadd] have hpre : f ⁻¹' Ioo (0 : ℝ) 1 = Ioo (0 : ℝ) 1 := by ext u simp [f] have hrestrict := Measure.restrict_map (μ := (volume : Measure ℝ)) (f := f) hf (s := Ioo (0 : ℝ) 1) measurableSet_Ioo simpa [unifOI, hvol, hpre] using hrestrict.symm
Frechet­Hoeffding 3 core · 0 supporting For a coupling π ∈ Π(μ, ν) with marginal cdfs F = cdf μ, G = cdf ν, the joint cdf H_π x y = π (Iic x ×ˢ Iic y) obeys the pointwise Fréchet–Hoeffding bounds max (F x + G y - 1) 0 ≤ H_π x y ≤ min (F x) (G y). ★ frechet_hoeffding_upper★ frechet_hoeffding_lower

Fréchet–Hoeffding bounds on the joint cdf

For a coupling π ∈ Π(μ, ν) with marginal cdfs F = cdf μ, G = cdf ν, the joint cdf H_π x y = π (Iic x ×ˢ Iic y) obeys the pointwise Fréchet–Hoeffding bounds

max (F x + G y - 1) 0 ≤ H_π x y ≤ min (F x) (G y).

The upper bound is H ≤ F and H ≤ G (monotonicity of measure under the two projections onto the marginals); the lower bound is inclusion–exclusion on the complement. Both bounds are attained:

  • the comonotone coupling attains the upper bound H = min (F, G);
  • the countermonotone coupling attains the lower bound H = max (F+G-1, 0).

This is the pointwise ordering that, integrated against the Hoeffding covariance identity, yields the optimality of the monotone couplings.

def jointCdf reviewed
Causalean.Stat

The joint cdf of a measure π on ℝ × ℝ: the mass of the lower-left quadrant Iic x ×ˢ Iic y, as a real number.

Definition (Lean source)
noncomputable def jointCdf (π : Measure (ℝ × ℝ)) (x y : ℝ) : ℝ := (π (Iic x ×ˢ Iic y)).toReal
theorem frechet_hoeffding_upper reviewed
Causalean.Stat

Fréchet–Hoeffding upper bound. For a coupling π of the probability measures μ and ν and reals x and y, the joint cdf of π at (x, y) is bounded above by the smaller of the marginal cdfs of μ at x and ν at y.

Formal statement
h :
IsCoupling π μ ν
x y :
jointCdf π x y ≤ min (cdf μ x) (cdf ν y)
Proof (Lean source)
theorem frechet_hoeffding_upper (h : IsCoupling π μ ν) (x y : ℝ) : jointCdf π x y ≤ min (cdf μ x) (cdf ν y) := by letI : IsProbabilityMeasure π := h.isProbabilityMeasure haveI : IsProbabilityMeasure μ := by rw [← h.map_fst] exact Measure.isProbabilityMeasure_map measurable_fst.aemeasurable haveI : IsProbabilityMeasure ν := by rw [← h.map_snd] exact Measure.isProbabilityMeasure_map measurable_snd.aemeasurable apply le_min · unfold jointCdf change (π (Iic x ×ˢ Iic y)).toReal ≤ cdf μ x rw [cdf_eq_real] rw [measureReal_def] apply ENNReal.toReal_mono · exact measure_ne_top μ _ · calc π (Iic x ×ˢ Iic y) ≤ π (Iic x ×ˢ (univ : Set ℝ)) := by exact measure_mono (by intro p hp exact ⟨hp.1, trivial⟩) _ = π (fst ⁻¹' Iic x) := by congr 1 ext p simp _ = (π.map fst) (Iic x) := by rw [Measure.map_apply] · exact measurable_fst · exact measurableSet_Iic _ = μ (Iic x) := by rw [h.map_fst] · unfold jointCdf change (π (Iic x ×ˢ Iic y)).toReal ≤ cdf ν y rw [cdf_eq_real] rw [measureReal_def] apply ENNReal.toReal_mono · exact measure_ne_top ν _ · calc π (Iic x ×ˢ Iic y) ≤ π ((univ : Set ℝ) ×ˢ Iic y) := by exact measure_mono (by intro p hp exact ⟨trivial, hp.2⟩) _ = π (snd ⁻¹' Iic y) := by congr 1 ext p simp _ = (π.map snd) (Iic y) := by rw [Measure.map_apply] · exact measurable_snd · exact measurableSet_Iic _ = ν (Iic y) := by rw [h.map_snd]
theorem frechet_hoeffding_lower reviewed
Causalean.Stat

Fréchet–Hoeffding lower bound. For a coupling π of the probability measures μ and ν and reals x and y, the joint cdf of π at (x, y) is bounded below by the maximum of 0 and the sum of the marginal cdfs of μ at x and ν at y, minus 1.

Formal statement
h :
IsCoupling π μ ν
x y :
max (cdf μ x + cdf ν y - 1) 0 ≤ jointCdf π x y
Proof (Lean source)
theorem frechet_hoeffding_lower (h : IsCoupling π μ ν) (x y : ℝ) : max (cdf μ x + cdf ν y - 1) 0 ≤ jointCdf π x y := by letI : IsProbabilityMeasure π := h.isProbabilityMeasure haveI : IsProbabilityMeasure μ := by rw [← h.map_fst] exact Measure.isProbabilityMeasure_map measurable_fst.aemeasurable haveI : IsProbabilityMeasure ν := by rw [← h.map_snd] exact Measure.isProbabilityMeasure_map measurable_snd.aemeasurable let A : Set (ℝ × ℝ) := Prod.fst ⁻¹' Iic x let B : Set (ℝ × ℝ) := Prod.snd ⁻¹' Iic y have hB_meas : MeasurableSet B := measurableSet_Iic.preimage measurable_snd have hquad : (Iic (x, y) : Set (ℝ × ℝ)) = A ∩ B := by ext p constructor · intro hp exact ⟨hp.1, hp.2⟩ · intro hp exact ⟨hp.1, hp.2⟩ have hA : π.real A = cdf μ x := by rw [cdf_eq_real] rw [measureReal_def] congr 1 calc π A = (π.map Prod.fst) (Iic x) := by rw [Measure.map_apply] · exact measurable_fst · exact measurableSet_Iic _ = μ (Iic x) := by rw [h.map_fst] have hB : π.real B = cdf ν y := by rw [cdf_eq_real] rw [measureReal_def] congr 1 calc π B = (π.map Prod.snd) (Iic y) := by rw [Measure.map_apply] · exact measurable_snd · exact measurableSet_Iic _ = ν (Iic y) := by rw [h.map_snd] have hinc := measureReal_union_add_inter (μ := π) (s := A) (t := B) hB_meas have hUle : π.real (A ∪ B) ≤ 1 := by calc π.real (A ∪ B) ≤ π.real (univ : Set (ℝ × ℝ)) := by exact measureReal_mono (subset_univ _) (measure_ne_top π _) _ = 1 := by simp [Measure.real] apply max_le · unfold jointCdf change cdf μ x + cdf ν y - 1 ≤ π.real (A ∩ B) linarith · unfold jointCdf exact ENNReal.toReal_nonneg
Survival 4 core · 3 supporting For a coupling π ∈ Π(μ, ν) we record the two marginal *survival* functions and the joint survival function SX s = π{p | s < p.1}, SY t = π{p | t < p.2}, S s t = π{p | s < p.1 ∧ t < p.2}. ★ surv_gap_eq

Survival functions of a coupling, and the survival-to-cdf bridge

For a coupling π ∈ Π(μ, ν) we record the two marginal survival functions and the joint survival function

SX s = π{p | s < p.1}, SY t = π{p | t < p.2}, S s t = π{p | s < p.1 ∧ t < p.2}.

Since π is a probability measure, complementation gives SX = 1 - F and SY = 1 - G, and inclusion–exclusion on the two half-planes gives S = 1 - F - G + H_π. The point of this file is the resulting survival gap = cdf gap identity

S s t - SX s * SY t = H_π s t - F s * G t,

which is what converts the Fubini computation of Cov_π (which naturally produces survival functions, because the tail indicator 𝟙{s < x} is a survival indicator) into the Fréchet-gap form used by the optimality theorem.

def survFst reviewed
Causalean.Stat

The first marginal survival function of π: SX s = π{p | s < p.1}.

Definition (Lean source)
noncomputable def survFst (π : Measure (ℝ × ℝ)) (s : ℝ) : ℝ := (π (fst ⁻¹' Ioi s)).toReal
def survSnd reviewed
Causalean.Stat

The second marginal survival function of π: SY t = π{p | t < p.2}.

Definition (Lean source)
noncomputable def survSnd (π : Measure (ℝ × ℝ)) (t : ℝ) : ℝ := (π (snd ⁻¹' Ioi t)).toReal
def jointSurv reviewed
Causalean.Stat

The joint survival function of π: S s t = π (Ioi s ×ˢ Ioi t), the mass of the open upper-right quadrant.

Definition (Lean source)
noncomputable def jointSurv (π : Measure (ℝ × ℝ)) (s t : ℝ) : ℝ := (π (Ioi s ×ˢ Ioi t)).toReal
lemma surv_gap_eq reviewed
Causalean.Stat

Survival gap = cdf gap. For a coupling π of two probability measures μ and ν, the gap between the joint and product-of-marginals survival functions of π at (s, t) equals the corresponding gap between the joint and product-of-marginals cumulative distribution functions.

Formal statement
h :
IsCoupling π μ ν
s t :
jointSurv π s t - survFst π s * survSnd π t = jointCdf π s t - cdf μ s * cdf ν t
Proof (Lean source)
lemma surv_gap_eq (h : IsCoupling π μ ν) (s t : ℝ) : jointSurv π s t - survFst π s * survSnd π t = jointCdf π s t - cdf μ s * cdf ν t := by rw [survFst_eq h, survSnd_eq h, jointSurv_eq h] ring
3 supporting declarations (lemmas, instances)
  • survFst_eq lemma — The first marginal survival function of a coupling is 1 - F, where F = cdf μ. Proof: Prod.fst ⁻¹' Ioi s is the complement of Prod.fst ⁻¹' Iic s, whose π-mass is μ (Iic s) = F s by h.map_fst.
    h :
    IsCoupling π μ ν
    s :
    survFst π s = 1 - cdf μ s
    Proof (Lean source)
    lemma survFst_eq (h : IsCoupling π μ ν) (s : ℝ) : survFst π s = 1 - cdf μ s := by letI : IsProbabilityMeasure π := h.isProbabilityMeasure haveI : IsProbabilityMeasure μ := by rw [← h.map_fst] exact Measure.isProbabilityMeasure_map measurable_fst.aemeasurable haveI : IsProbabilityMeasure ν := by rw [← h.map_snd] exact Measure.isProbabilityMeasure_map measurable_snd.aemeasurable let A : Set (ℝ × ℝ) := Prod.fst ⁻¹' Iic s have hA_meas : MeasurableSet A := measurableSet_Iic.preimage measurable_fst have hsurv : Prod.fst ⁻¹' Ioi s = Aᶜ := by ext p simp [A] have hA : π.real A = cdf μ s := by rw [cdf_eq_real] rw [measureReal_def] congr 1 calc π A = (π.map Prod.fst) (Iic s) := by rw [Measure.map_apply] · exact measurable_fst · exact measurableSet_Iic _ = μ (Iic s) := by rw [h.map_fst] have hcompl := measureReal_add_measureReal_compl (μ := π) hA_meas have huniv : π.real (univ : Set (ℝ × ℝ)) = 1 := by simp [Measure.real] unfold survFst change π.real (Prod.fst ⁻¹' Ioi s) = 1 - cdf μ s rw [hsurv] linarith
  • survSnd_eq lemma — The second marginal survival function of a coupling is 1 - G, where G = cdf ν.
    h :
    IsCoupling π μ ν
    t :
    survSnd π t = 1 - cdf ν t
    Proof (Lean source)
    lemma survSnd_eq (h : IsCoupling π μ ν) (t : ℝ) : survSnd π t = 1 - cdf ν t := by letI : IsProbabilityMeasure π := h.isProbabilityMeasure haveI : IsProbabilityMeasure μ := by rw [← h.map_fst] exact Measure.isProbabilityMeasure_map measurable_fst.aemeasurable haveI : IsProbabilityMeasure ν := by rw [← h.map_snd] exact Measure.isProbabilityMeasure_map measurable_snd.aemeasurable let B : Set (ℝ × ℝ) := Prod.snd ⁻¹' Iic t have hB_meas : MeasurableSet B := measurableSet_Iic.preimage measurable_snd have hsurv : Prod.snd ⁻¹' Ioi t = Bᶜ := by ext p simp [B] have hB : π.real B = cdf ν t := by rw [cdf_eq_real] rw [measureReal_def] congr 1 calc π B = (π.map Prod.snd) (Iic t) := by rw [Measure.map_apply] · exact measurable_snd · exact measurableSet_Iic _ = ν (Iic t) := by rw [h.map_snd] have hcompl := measureReal_add_measureReal_compl (μ := π) hB_meas have huniv : π.real (univ : Set (ℝ × ℝ)) = 1 := by simp [Measure.real] unfold survSnd change π.real (Prod.snd ⁻¹' Ioi t) = 1 - cdf ν t rw [hsurv] linarith
  • jointSurv_eq lemma — Inclusion–exclusion. The joint survival function of a coupling is S s t = 1 - F s - G t + H_π s t. Proof: Ioi s ×ˢ Ioi t is the complement of (Prod.fst ⁻¹' Iic s) ∪ (Prod.snd ⁻¹' Iic t), and the mass of that union is F s + G t - H_π s t by measureReal_union_add_inter, the intersection being the lower-left quadrant Iic s ×ˢ Iic t.
    h :
    IsCoupling π μ ν
    s t :
    jointSurv π s t = 1 - cdf μ s - cdf ν t + jointCdf π s t
    Proof (Lean source)
    lemma jointSurv_eq (h : IsCoupling π μ ν) (s t : ℝ) : jointSurv π s t = 1 - cdf μ s - cdf ν t + jointCdf π s t := by letI : IsProbabilityMeasure π := h.isProbabilityMeasure haveI : IsProbabilityMeasure μ := by rw [← h.map_fst] exact Measure.isProbabilityMeasure_map measurable_fst.aemeasurable haveI : IsProbabilityMeasure ν := by rw [← h.map_snd] exact Measure.isProbabilityMeasure_map measurable_snd.aemeasurable let A : Set (ℝ × ℝ) := Prod.fst ⁻¹' Iic s let B : Set (ℝ × ℝ) := Prod.snd ⁻¹' Iic t have hA_meas : MeasurableSet A := measurableSet_Iic.preimage measurable_fst have hB_meas : MeasurableSet B := measurableSet_Iic.preimage measurable_snd have hsurv : Ioi s ×ˢ Ioi t = (A ∪ B)ᶜ := by ext p simp [A, B, Set.mem_prod] have hquad : Iic s ×ˢ Iic t = A ∩ B := by ext p constructor · intro hp exact ⟨hp.1, hp.2⟩ · intro hp exact ⟨hp.1, hp.2⟩ have hA : π.real A = cdf μ s := by rw [cdf_eq_real] rw [measureReal_def] congr 1 calc π A = (π.map Prod.fst) (Iic s) := by rw [Measure.map_apply] · exact measurable_fst · exact measurableSet_Iic _ = μ (Iic s) := by rw [h.map_fst] have hB : π.real B = cdf ν t := by rw [cdf_eq_real] rw [measureReal_def] congr 1 calc π B = (π.map Prod.snd) (Iic t) := by rw [Measure.map_apply] · exact measurable_snd · exact measurableSet_Iic _ = ν (Iic t) := by rw [h.map_snd] have hAB : π.real (A ∩ B) = jointCdf π s t := by unfold jointCdf change π.real (A ∩ B) = π.real (Iic s ×ˢ Iic t) rw [hquad] have hinc := measureReal_union_add_inter (μ := π) (s := A) (t := B) hB_meas have hcompl := measureReal_add_measureReal_compl (μ := π) (hA_meas.union hB_meas) have huniv : π.real (univ : Set (ℝ × ℝ)) = 1 := by simp [Measure.real] unfold jointSurv change π.real (Ioi s ×ˢ Ioi t) = 1 - cdf μ s - cdf ν t + jointCdf π s t rw [hsurv] linarith
Frechet­Hoeffding­Attainment 2 core · 2 supporting This file proves that the quantile couplings attain the Fréchet-Hoeffding bounds on the joint distribution function. ★ jointCdf_comonotoneCoupling★ jointCdf_countermonotoneCoupling

Sharp Fréchet-Hoeffding attainability for monotone quantile couplings

This file proves that the quantile couplings attain the Fréchet-Hoeffding bounds on the joint distribution function. The comonotone coupling realizes the upper envelope, and the countermonotone coupling realizes the lower envelope.

The resulting pointwise comparisons are the cdf-order inputs used by the product-expectation optimality theorem.

theorem jointCdf_comonotoneCoupling reviewed
Causalean.Stat

Comonotone attainment. The joint cdf of the comonotone coupling of two probability measures μ and ν, evaluated at a point (x, y), equals the Fréchet–Hoeffding upper bound min (cdf μ x) (cdf ν y).

Formal statement
jointCdf (comonotoneCoupling μ ν) x y = min (cdf μ x) (cdf ν y)
Proof (Lean source)
theorem jointCdf_comonotoneCoupling (μ ν : Measure ℝ) [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] (x y : ℝ) : jointCdf (comonotoneCoupling μ ν) x y = min (cdf μ x) (cdf ν y) := by let m : ℝ := min (cdf μ x) (cdf ν y) have hm0 : 0 ≤ m := le_min (cdf_nonneg μ x) (cdf_nonneg ν y) have hm1 : m ≤ 1 := by exact (min_le_left (cdf μ x) (cdf ν y)).trans (cdf_le_one μ x) have hpair_ae : AEMeasurable (fun u : ℝ => (quantile μ u, quantile ν u)) unifOI := (aemeasurable_quantile_unifOI μ).prodMk (aemeasurable_quantile_unifOI ν) have hquad_meas : MeasurableSet (Iic x ×ˢ Iic y : Set (ℝ × ℝ)) := measurableSet_Iic.prod measurableSet_Iic have hpre_null : NullMeasurableSet ((fun u : ℝ => (quantile μ u, quantile ν u)) ⁻¹' (Iic x ×ˢ Iic y : Set (ℝ × ℝ))) unifOI := hpair_ae.nullMeasurableSet_preimage hquad_meas unfold jointCdf comonotoneCoupling rw [Measure.map_apply_of_aemeasurable hpair_ae hquad_meas] rw [unifOI, Measure.restrict_apply₀] · have hset : ((fun u : ℝ => (quantile μ u, quantile ν u)) ⁻¹' (Iic x ×ˢ Iic y : Set (ℝ × ℝ))) ∩ Ioo (0 : ℝ) 1 = Ioc (0 : ℝ) m ∩ Ioo (0 : ℝ) 1 := by ext u constructor · intro hu rcases hu with ⟨huq, hu01⟩ have hu0 : 0 < u := hu01.1 have hu1 : u < 1 := hu01.2 have hux : quantile μ u ≤ x := by simpa using huq.1 have huy : quantile ν u ≤ y := by simpa using huq.2 have hucdfx : u ≤ cdf μ x := (quantile_le_iff (μ := μ) hu0 hu1).1 hux have hucdfy : u ≤ cdf ν y := (quantile_le_iff (μ := ν) hu0 hu1).1 huy exact ⟨⟨hu0, le_min hucdfx hucdfy⟩, hu01⟩ · intro hu rcases hu with ⟨hu0m, hu01⟩ have hu0 : 0 < u := hu0m.1 have hum : u ≤ m := hu0m.2 have hu1 : u < 1 := hu01.2 have hux : quantile μ u ≤ x := (quantile_le_iff (μ := μ) hu0 hu1).2 (hum.trans (min_le_left _ _)) have huy : quantile ν u ≤ y := (quantile_le_iff (μ := ν) hu0 hu1).2 (hum.trans (min_le_right _ _)) exact ⟨⟨hux, huy⟩, ⟨hu0, hu1⟩⟩ rw [hset] have hvol : volume (Ioc (0 : ℝ) m ∩ Ioo (0 : ℝ) 1) = volume (Ioc (0 : ℝ) m) := by apply le_antisymm · exact measure_mono inter_subset_left · calc volume (Ioc (0 : ℝ) m) ≤ volume ((Ioc (0 : ℝ) m ∩ Ioo (0 : ℝ) 1) ∪ ({1} : Set ℝ)) := by apply measure_mono intro u hu by_cases hu1eq : u = 1 · right simp [hu1eq] · left have hu1lt : u < 1 := lt_of_le_of_ne (hu.2.trans hm1) hu1eq exact ⟨hu, ⟨hu.1, hu1lt⟩⟩ _ ≤ volume (Ioc (0 : ℝ) m ∩ Ioo (0 : ℝ) 1) + volume ({1} : Set ℝ) := measure_union_le _ _ _ = volume (Ioc (0 : ℝ) m ∩ Ioo (0 : ℝ) 1) := by simp rw [hvol, Real.volume_Ioc] simp only [sub_zero] rw [ENNReal.toReal_ofReal hm0] · simpa [unifOI] using hpre_null
theorem jointCdf_countermonotoneCoupling reviewed
Causalean.Stat

Countermonotone attainment. The joint cdf of the countermonotone coupling of two probability measures μ and ν, evaluated at a point (x, y), equals the Fréchet–Hoeffding lower bound max (cdf μ x + cdf ν y - 1) 0.

Formal statement
jointCdf (countermonotoneCoupling μ ν) x y = max (cdf μ x + cdf ν y - 1) 0
Proof (Lean source)
theorem jointCdf_countermonotoneCoupling (μ ν : Measure ℝ) [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] (x y : ℝ) : jointCdf (countermonotoneCoupling μ ν) x y = max (cdf μ x + cdf ν y - 1) 0 := by let a : ℝ := cdf μ x let b : ℝ := cdf ν y let l : ℝ := 1 - b have ha1 : a ≤ 1 := cdf_le_one μ x have hb0 : 0 ≤ b := cdf_nonneg ν y have hb1 : b ≤ 1 := cdf_le_one ν y have hl0 : 0 ≤ l := sub_nonneg.mpr hb1 have hone_sub_meas : Measurable (fun u : ℝ => 1 - u) := by fun_prop have hquant_reflect_ae : AEMeasurable (fun u : ℝ => quantile ν (1 - u)) unifOI := by have hq : AEMeasurable (quantile ν) (unifOI.map (fun u : ℝ => 1 - u)) := by rw [map_one_sub_unifOI] exact aemeasurable_quantile_unifOI ν exact hq.comp_measurable hone_sub_meas have hpair_ae : AEMeasurable (fun u : ℝ => (quantile μ u, quantile ν (1 - u))) unifOI := (aemeasurable_quantile_unifOI μ).prodMk hquant_reflect_ae have hquad_meas : MeasurableSet (Iic x ×ˢ Iic y : Set (ℝ × ℝ)) := measurableSet_Iic.prod measurableSet_Iic have hpre_null : NullMeasurableSet ((fun u : ℝ => (quantile μ u, quantile ν (1 - u))) ⁻¹' (Iic x ×ˢ Iic y : Set (ℝ × ℝ))) unifOI := hpair_ae.nullMeasurableSet_preimage hquad_meas unfold jointCdf countermonotoneCoupling rw [Measure.map_apply_of_aemeasurable hpair_ae hquad_meas] rw [unifOI, Measure.restrict_apply₀] · have hset : ((fun u : ℝ => (quantile μ u, quantile ν (1 - u))) ⁻¹' (Iic x ×ˢ Iic y : Set (ℝ × ℝ))) ∩ Ioo (0 : ℝ) 1 = Icc l a ∩ Ioo (0 : ℝ) 1 := by ext u constructor · intro hu rcases hu with ⟨huq, hu01⟩ have hu0 : 0 < u := hu01.1 have hu1 : u < 1 := hu01.2 have h1u0 : 0 < 1 - u := sub_pos.mpr hu1 have h1u1 : 1 - u < 1 := by linarith have hux : quantile μ u ≤ x := by simpa using huq.1 have huy : quantile ν (1 - u) ≤ y := by simpa using huq.2 have hua : u ≤ a := by dsimp [a] exact (quantile_le_iff (μ := μ) hu0 hu1).1 hux have h1ub : 1 - u ≤ b := by dsimp [b] exact (quantile_le_iff (μ := ν) h1u0 h1u1).1 huy have hlu : l ≤ u := by dsimp [l] linarith exact ⟨⟨hlu, hua⟩, hu01⟩ · intro hu rcases hu with ⟨hulua, hu01⟩ have hu0 : 0 < u := hu01.1 have hu1 : u < 1 := hu01.2 have h1u0 : 0 < 1 - u := sub_pos.mpr hu1 have h1u1 : 1 - u < 1 := by linarith have hua : u ≤ cdf μ x := by simpa [a] using hulua.2 have h1ub : 1 - u ≤ cdf ν y := by have hle : 1 - cdf ν y ≤ u := by simpa [l, b] using hulua.1 linarith have hux : quantile μ u ≤ x := (quantile_le_iff (μ := μ) hu0 hu1).2 hua have huy : quantile ν (1 - u) ≤ y := (quantile_le_iff (μ := ν) h1u0 h1u1).2 h1ub exact ⟨⟨hux, huy⟩, hu01⟩ rw [hset] have hvol : volume (Icc l a ∩ Ioo (0 : ℝ) 1) = volume (Icc l a) := by have hpoints : volume ({0} ∪ {1} : Set ℝ) = 0 := by apply le_antisymm · calc volume ({0} ∪ {1} : Set ℝ) ≤ volume ({0} : Set ℝ) + volume ({1} : Set ℝ) := measure_union_le _ _ _ = 0 := by simp · exact zero_le apply le_antisymm · exact measure_mono inter_subset_left · calc volume (Icc l a) ≤ volume ((Icc l a ∩ Ioo (0 : ℝ) 1) ∪ ({0} ∪ {1} : Set ℝ)) := by apply measure_mono intro u hu by_cases hu0eq : u = 0 · right left simp [hu0eq] · by_cases hu1eq : u = 1 · right right simp [hu1eq] · left have hu0lt : 0 < u := lt_of_le_of_ne (hl0.trans hu.1) (Ne.symm hu0eq) have hu1lt : u < 1 := lt_of_le_of_ne (hu.2.trans ha1) hu1eq exact ⟨hu, ⟨hu0lt, hu1lt⟩⟩ _ ≤ volume (Icc l a ∩ Ioo (0 : ℝ) 1) + volume ({0} ∪ {1} : Set ℝ) := measure_union_le _ _ _ = volume (Icc l a ∩ Ioo (0 : ℝ) 1) := by rw [hpoints, add_zero] rw [hvol, Real.volume_Icc] have hcalc : a - l = cdf μ x + cdf ν y - 1 := by dsimp [a, b, l] ring rw [hcalc] simp [ENNReal.toReal_ofReal'] · simpa [unifOI] using hpre_null
2 supporting declarations (lemmas, instances)
Hoeffding 1 core · 3 supporting For a coupling π ∈ Π(μ, ν) of two L² real measures, with marginal cdfs F = cdf μ, G = cdf ν and joint cdf H_π, Hoeffding's identity expresses the covariance as a double integral of the gap between the joint cdf and the p ★ hoeffding_cov_identity

Hoeffding's covariance identity

For a coupling π ∈ Π(μ, ν) of two real measures, with marginal cdfs F = cdf μ, G = cdf ν and joint cdf H_π, Hoeffding's identity expresses the covariance as a double integral of the gap between the joint cdf and the product of the marginals:

Cov_π(X, Y) = ∫∫ (H_π x y - F x · G y) dx dy,

where Cov_π(X,Y) = E_π[XY] - E[X] E[Y].

Proof structure

Everything is assembled from HoeffdingFubini.lean and Survival.lean:

1. integral_prod_eq_integral_fiber : E_π[XY] = ∫ q, (∫ Φ q p ∂π) dq, where Φ q p = signedTail p.1 q.1 * signedTail p.2 q.2 is the product tail representation of p.1 * p.2. 2. fiber_integral_pi : the inner integral is S - 𝟙{t<0}·SX - 𝟙{s<0}·SY + 𝟙{s<0}·𝟙{t<0} in terms of survival functions. 3. mean_fst_tail, mean_snd_tail and integral_prod_mul : the product of the means is ∫ q, (SX q.1 - 𝟙{q.1<0})·(SY q.2 - 𝟙{q.2<0}) dq. 4. Subtracting (2) and (3) pointwise, the three inhomogeneous terms cancel and what remains is the survival gap S - SX·SY. 5. surv_gap_eq : the survival gap equals the Fréchet gap H_π - F·G.

The MemLp 2 hypotheses on the marginals enter exactly once, through Cauchy–Schwarz, to give E|XY| < ∞ and hence the Fubini domination.

theorem hoeffding_cov_identity reviewed
Causalean.Stat

Hoeffding's covariance identity. For a coupling π of μ and ν, where both μ and ν have finite second moment (are ), the covariance of the coordinates under π equals the double integral, over the plane, of the Fréchet gap between the joint and product cumulative distribution functions, H_π - F·G:

Formal statement
h :
IsCoupling π μ ν
:
MemLp (fun x : ℝ => x) 2 μ
:
MemLp (fun y : ℝ => y) 2 ν
(∫ p, p.1 * p.2 ∂π) - (∫ x, x ∂μ) * (∫ y, y ∂ν)
= ∫ x, ∫ y, (jointCdf π x y - cdf μ x * cdf ν y) ∂volume ∂volume
Proof (Lean source)
theorem hoeffding_cov_identity (h : IsCoupling π μ ν) (hμ : MemLp (fun x : ℝ => x) 2 μ) (hν : MemLp (fun y : ℝ => y) 2 ν) : (∫ p, p.1 * p.2 ∂π) - (∫ x, x ∂μ) * (∫ y, y ∂ν) = ∫ x, ∫ y, (jointCdf π x y - cdf μ x * cdf ν y) ∂volume ∂volume := by rw [hoeffding_cov_identity_prod h hμ hν] exact integral_prod _ (integrable_frechet_gap h hμ hν)
3 supporting declarations (lemmas, instances)
Hoeffding­Fubini 1 core · 7 supporting Fix a coupling π ∈ Π(μ, ν) with L² marginals. ★ fiber_integral_pi

The Fubini step in Hoeffding's covariance identity

Fix a coupling π ∈ Π(μ, ν) with marginals. Writing Φ q p = signedTail p.1 q.1 * signedTail p.2 q.2 for the product tail representation of p.1 * p.2 (see TailIntegral.lean), this file performs the two Fubini swaps that turn the moments of π into Lebesgue integrals of survival functions:

* integral_prod_eq_integral_fiber : E_π[XY] = ∫∫ (∫ Φ q p ∂π) dq; * mean_fst_tail / mean_snd_tail : E[X] = ∫ (SX s - 𝟙{s<0}) ds, likewise E[Y]; * fiber_integral_pi : the inner π-integral evaluates, by linearity of the expectation of a product of tail indicators, to S s t - 𝟙{t<0}·SX s - 𝟙{s<0}·SY t + 𝟙{s<0}·𝟙{t<0}.

The domination that legitimises both swaps is ∫∫ |Φ q p| dq = |p.1| * |p.2| (integral_norm_signedTail_prod), whose π-integral is finite by Cauchy–Schwarz on the marginals. Subtracting E[X]·E[Y] (rewritten as a double integral via integral_prod_mul) cancels the three inhomogeneous terms and leaves the survival gap S - SX·SY, which is the Fréchet gap by surv_gap_eq.

Orientation convention: all product measures are taken as (volume.prod volume).prod π, i.e. tail variables first, so that MeasureTheory.Integrable.integral_prod_left directly yields integrability of the fibre q ↦ ∫ Φ q p ∂π against Lebesgue×Lebesgue.

lemma fiber_integral_pi reviewed
Causalean.Stat

Fibre integral. For a coupling π of two probability measures, the π-integral of the product of the two signed tail indicators at thresholds s and t equals the joint survival function of π at (s, t), adjusted by cross terms built from the two marginal survival functions and the sign indicators of s and t.

Formal statement
h :
IsCoupling π μ ν
s t :
(∫ p : ℝ × ℝ, signedTail p.1 s * signedTail p.2 t ∂π)
= jointSurv π s t
- tailInd 0 t * survFst π s
- tailInd 0 s * survSnd π t
+ tailInd 0 s * tailInd 0 t
Proof (Lean source)
lemma fiber_integral_pi (h : IsCoupling π μ ν) (s t : ℝ) : (∫ p : ℝ × ℝ, signedTail p.1 s * signedTail p.2 t ∂π) = jointSurv π s t - tailInd 0 t * survFst π s - tailInd 0 s * survSnd π t + tailInd 0 s * tailInd 0 t := by letI : IsProbabilityMeasure π := h.isProbabilityMeasure let A : Set (ℝ × ℝ) := Prod.fst ⁻¹' Ioi s let B : Set (ℝ × ℝ) := Prod.snd ⁻¹' Ioi t let C : Set (ℝ × ℝ) := Ioi s ×ˢ Ioi t let a : ℝ := tailInd 0 s let b : ℝ := tailInd 0 t have hA : MeasurableSet A := measurableSet_Ioi.preimage measurable_fst have hB : MeasurableSet B := measurableSet_Ioi.preimage measurable_snd have hC : MeasurableSet C := measurableSet_Ioi.prod measurableSet_Ioi have hfun : (fun p : ℝ × ℝ => signedTail p.1 s * signedTail p.2 t) = fun p : ℝ × ℝ => C.indicator (fun _ => (1 : ℝ)) p - b * A.indicator (fun _ => (1 : ℝ)) p - a * B.indicator (fun _ => (1 : ℝ)) p + a * b := by funext p by_cases hsp : s < p.1 · by_cases htp : t < p.2 · by_cases hs0 : s < 0 <;> by_cases ht0 : t < 0 <;> simp [A, B, C, a, b, signedTail, tailInd_apply, hsp, htp, hs0, ht0] · by_cases hs0 : s < 0 <;> by_cases ht0 : t < 0 <;> simp [A, B, C, a, b, signedTail, tailInd_apply, hsp, htp, hs0, ht0] · by_cases htp : t < p.2 · by_cases hs0 : s < 0 <;> by_cases ht0 : t < 0 <;> simp [A, B, C, a, b, signedTail, tailInd_apply, hsp, htp, hs0, ht0] · by_cases hs0 : s < 0 <;> by_cases ht0 : t < 0 <;> simp [A, B, C, a, b, signedTail, tailInd_apply, hsp, htp, hs0, ht0] have hIA : Integrable (fun p : ℝ × ℝ => A.indicator (fun _ => (1 : ℝ)) p) π := (integrable_const (1 : ℝ)).indicator hA have hIB : Integrable (fun p : ℝ × ℝ => B.indicator (fun _ => (1 : ℝ)) p) π := (integrable_const (1 : ℝ)).indicator hB have hIC : Integrable (fun p : ℝ × ℝ => C.indicator (fun _ => (1 : ℝ)) p) π := (integrable_const (1 : ℝ)).indicator hC have hBA : Integrable (fun p : ℝ × ℝ => b * A.indicator (fun _ => (1 : ℝ)) p) π := hIA.const_mul b have hAB : Integrable (fun p : ℝ × ℝ => a * B.indicator (fun _ => (1 : ℝ)) p) π := hIB.const_mul a have hK : Integrable (fun _ : ℝ × ℝ => a * b) π := integrable_const _ have hIntA : (∫ p : ℝ × ℝ, A.indicator (fun _ => (1 : ℝ)) p ∂π) = π.real A := by exact (integral_indicator_one (μ := π) (s := A) hA) have hIntB : (∫ p : ℝ × ℝ, B.indicator (fun _ => (1 : ℝ)) p ∂π) = π.real B := by exact (integral_indicator_one (μ := π) (s := B) hB) have hIntC : (∫ p : ℝ × ℝ, C.indicator (fun _ => (1 : ℝ)) p ∂π) = π.real C := by exact (integral_indicator_one (μ := π) (s := C) hC) rw [hfun] change (∫ p : ℝ × ℝ, (((fun p : ℝ × ℝ => C.indicator (fun _ => (1 : ℝ)) p) - (fun p : ℝ × ℝ => b * A.indicator (fun _ => (1 : ℝ)) p) - (fun p : ℝ × ℝ => a * B.indicator (fun _ => (1 : ℝ)) p)) + (fun _ : ℝ × ℝ => a * b)) p ∂π) = jointSurv π s t - tailInd 0 t * survFst π s - tailInd 0 s * survSnd π t + tailInd 0 s * tailInd 0 t rw [integral_add' ((hIC.sub hBA).sub hAB) hK] rw [integral_sub' (hIC.sub hBA) hAB] rw [integral_sub' hIC hBA] rw [integral_const_mul, integral_const_mul] rw [hIntA, hIntB, hIntC, integral_const] simp [jointSurv, survFst, survSnd, A, B, C, a, b, Measure.real, smul_eq_mul]
7 supporting declarations (lemmas, instances)
Hoeffding­Fubini­Integrability 2 core · 7 supporting This file proves the integrability bounds and Fubini swaps that turn the signed tail representation of the product into Lebesgue integrals of fibre expectations and marginal tail means. ★ integrable_bigPhi★ integral_prod_eq_integral_fiber

Integrability and Fubini swaps for Hoeffding's identity

This file proves the integrability bounds and Fubini swaps that turn the signed tail representation of the product into Lebesgue integrals of fibre expectations and marginal tail means.

The output supplies the integrable fibre and mean-tail formulas consumed by the final Hoeffding covariance identity.

lemma integrable_bigPhi reviewed
Causalean.Stat

The key integrability. Let π be a coupling of μ and ν, where both marginals have finite second moment. Then the product tail kernel Φ q p = signedTail p.1 q.1 * signedTail p.2 q.2 is integrable for the product of Lebesgue measure on the plane with π, i.e. on (volume ⊗ volume) ⊗ π.

Formal statement
h :
IsCoupling π μ ν
:
MemLp (fun x : ℝ => x) 2 μ
:
MemLp (fun y : ℝ => y) 2 ν
Integrable (fun z : (ℝ × ℝ) × (ℝ × ℝ) => signedTail z.2.1 z.1.1 * signedTail z.2.2 z.1.2) ((volume.prod volume).prod π)
Proof (Lean source)
lemma integrable_bigPhi (h : IsCoupling π μ ν) (hμ : MemLp (fun x : ℝ => x) 2 μ) (hν : MemLp (fun y : ℝ => y) 2 ν) : Integrable (fun z : (ℝ × ℝ) × (ℝ × ℝ) => signedTail z.2.1 z.1.1 * signedTail z.2.2 z.1.2) ((volume.prod volume).prod π) := by letI : IsProbabilityMeasure π := h.isProbabilityMeasure have hmeas₁ : Measurable (fun z : (ℝ × ℝ) × (ℝ × ℝ) => signedTail z.2.1 z.1.1) := by exact measurable_signedTail_uncurry.comp ((measurable_fst.comp measurable_snd).prodMk (measurable_fst.comp measurable_fst)) have hmeas₂ : Measurable (fun z : (ℝ × ℝ) × (ℝ × ℝ) => signedTail z.2.2 z.1.2) := by exact measurable_signedTail_uncurry.comp ((measurable_snd.comp measurable_snd).prodMk (measurable_snd.comp measurable_fst)) refine (integrable_prod_iff' (hmeas₁.mul hmeas₂).aestronglyMeasurable).2 ?_ constructor · exact Filter.Eventually.of_forall fun p => integrable_signedTail_prod p.1 p.2 · have hbase : Integrable (fun y : ℝ × ℝ => |y.1| * |y.2|) π := by simpa [Real.norm_eq_abs, abs_mul] using (coupling_integrable_mul h hμ hν).norm exact hbase.congr (Filter.Eventually.of_forall fun y => by symm simpa [Real.norm_eq_abs, abs_mul] using integral_norm_signedTail_prod y.1 y.2)
lemma integral_prod_eq_integral_fiber reviewed
Causalean.Stat

First swap. For a coupling π of μ and ν, where both marginals have finite second moment, the expectation E_π[XY] equals the Lebesgue double integral, over the plane, of the fibre integrals ∫ p, Φ q p ∂π, i.e. ∫ p, p.1 * p.2 ∂π = ∫ q, (∫ p, Φ q p ∂π) dq.

Formal statement
h :
IsCoupling π μ ν
:
MemLp (fun x : ℝ => x) 2 μ
:
MemLp (fun y : ℝ => y) 2 ν
(∫ p : ℝ × ℝ, p.1 * p.2 ∂π)
= ∫ q : ℝ × ℝ, (∫ p : ℝ × ℝ, signedTail p.1 q.1 * signedTail p.2 q.2 ∂π) ∂(volume.prod volume)
Proof (Lean source)
lemma integral_prod_eq_integral_fiber (h : IsCoupling π μ ν) (hμ : MemLp (fun x : ℝ => x) 2 μ) (hν : MemLp (fun y : ℝ => y) 2 ν) : (∫ p : ℝ × ℝ, p.1 * p.2 ∂π) = ∫ q : ℝ × ℝ, (∫ p : ℝ × ℝ, signedTail p.1 q.1 * signedTail p.2 q.2 ∂π) ∂(volume.prod volume) := by letI : IsProbabilityMeasure π := h.isProbabilityMeasure calc (∫ p : ℝ × ℝ, p.1 * p.2 ∂π) = ∫ p : ℝ × ℝ, (∫ q : ℝ × ℝ, signedTail p.1 q.1 * signedTail p.2 q.2 ∂(volume.prod volume)) ∂π := by apply integral_congr_ae exact Filter.Eventually.of_forall fun p => (integral_signedTail_prod p.1 p.2).symm _ = ∫ q : ℝ × ℝ, (∫ p : ℝ × ℝ, signedTail p.1 q.1 * signedTail p.2 q.2 ∂π) ∂(volume.prod volume) := by exact (integral_integral_swap (μ := volume.prod volume) (ν := π) (f := fun q : ℝ × ℝ => fun p : ℝ × ℝ => signedTail p.1 q.1 * signedTail p.2 q.2) (integrable_bigPhi h hμ hν)).symm
7 supporting declarations (lemmas, instances)
Optimality 3 core · 0 supporting Over the Fréchet class Π(μ, ν) of couplings of two L² real probability measures, the product expectation E_π[XY] = ∫ p, p.1 * p.2 ∂π is: * maximised by the comonotone (quantile) coupling, and * minimised by the countermo ★ product_expectation_le_comonotone★ countermonotone_le_product_expectation★ product_expectation_comonotoneCoupling

Optimality of the monotone couplings (capstone)

Over the Fréchet class Π(μ, ν) of couplings of two real probability measures, the product expectation E_π[XY] = ∫ p, p.1 * p.2 ∂π is:

  • maximised by the comonotone (quantile) coupling, and
  • minimised by the countermonotone coupling.

The argument: by Hoeffding's identity E_π[XY] = E[X]E[Y] + ∫∫ (H_π - F·G). The term E[X]E[Y] depends only on the marginals μ, ν, hence is constant across Π(μ, ν); so extremising E_π[XY] is the same as extremising ∫∫ H_π. The Fréchet–Hoeffding bounds give this pointwise: H_π ≤ H_comonotone and H_countermonotone ≤ H_π, and monotonicity of the double integral lifts the pointwise ordering to the integrals.

A closed form for the optimum is also recorded: E[XY] under the comonotone coupling equals ∫_(0,1) quantile μ · quantile ν.

theorem product_expectation_le_comonotone reviewed
Causalean.Stat

Upper optimality. For any coupling π of μ and ν, where both marginals have finite second moment, the expectation of the coordinate product under π is at most its expectation under the comonotone (quantile) coupling of μ and ν:

Formal statement
h :
IsCoupling π μ ν
:
MemLp (fun x : ℝ => x) 2 μ
:
MemLp (fun y : ℝ => y) 2 ν
(∫ p, p.1 * p.2 ∂π) ≤ ∫ p, p.1 * p.2 ∂(comonotoneCoupling μ ν)
Proof (Lean source)
theorem product_expectation_le_comonotone (h : IsCoupling π μ ν) [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] (hμ : MemLp (fun x : ℝ => x) 2 μ) (hν : MemLp (fun y : ℝ => y) 2 ν) : (∫ p, p.1 * p.2 ∂π) ≤ ∫ p, p.1 * p.2 ∂(comonotoneCoupling μ ν) := by let hc : IsCoupling (comonotoneCoupling μ ν) μ ν := isCoupling_comonotoneCoupling μ ν have hπid := hoeffding_cov_identity h hμ hν have hcid := hoeffding_cov_identity hc hμ hν have hπint := integrable_frechet_gap h hμ hν have hcint := integrable_frechet_gap hc hμ hν have hgap : (∫ x, ∫ y, (jointCdf π x y - cdf μ x * cdf ν y) ∂volume ∂volume) ≤ ∫ x, ∫ y, (jointCdf (comonotoneCoupling μ ν) x y - cdf μ x * cdf ν y) ∂volume ∂volume := by rw [← MeasureTheory.integral_prod (fun p : ℝ × ℝ => jointCdf π p.1 p.2 - cdf μ p.1 * cdf ν p.2) hπint, ← MeasureTheory.integral_prod (fun p : ℝ × ℝ => jointCdf (comonotoneCoupling μ ν) p.1 p.2 - cdf μ p.1 * cdf ν p.2) hcint] refine MeasureTheory.integral_mono hπint hcint ?_ intro p exact sub_le_sub_right (jointCdf_le_comonotone h p.1 p.2) _ nlinarith [hπid, hcid, hgap]
theorem countermonotone_le_product_expectation reviewed
Causalean.Stat

Lower optimality. For any coupling π of μ and ν, where both marginals have finite second moment, the expectation of the coordinate product under π is at least its expectation under the countermonotone coupling of μ and ν:

Formal statement
h :
IsCoupling π μ ν
:
MemLp (fun x : ℝ => x) 2 μ
:
MemLp (fun y : ℝ => y) 2 ν
(∫ p, p.1 * p.2 ∂(countermonotoneCoupling μ ν)) ≤ ∫ p, p.1 * p.2 ∂π
Proof (Lean source)
theorem countermonotone_le_product_expectation (h : IsCoupling π μ ν) [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] (hμ : MemLp (fun x : ℝ => x) 2 μ) (hν : MemLp (fun y : ℝ => y) 2 ν) : (∫ p, p.1 * p.2 ∂(countermonotoneCoupling μ ν)) ≤ ∫ p, p.1 * p.2 ∂π := by let hc : IsCoupling (countermonotoneCoupling μ ν) μ ν := isCoupling_countermonotoneCoupling μ ν have hcid := hoeffding_cov_identity hc hμ hν have hπid := hoeffding_cov_identity h hμ hν have hcint := integrable_frechet_gap hc hμ hν have hπint := integrable_frechet_gap h hμ hν have hgap : (∫ x, ∫ y, (jointCdf (countermonotoneCoupling μ ν) x y - cdf μ x * cdf ν y) ∂volume ∂volume) ≤ ∫ x, ∫ y, (jointCdf π x y - cdf μ x * cdf ν y) ∂volume ∂volume := by rw [← MeasureTheory.integral_prod (fun p : ℝ × ℝ => jointCdf (countermonotoneCoupling μ ν) p.1 p.2 - cdf μ p.1 * cdf ν p.2) hcint, ← MeasureTheory.integral_prod (fun p : ℝ × ℝ => jointCdf π p.1 p.2 - cdf μ p.1 * cdf ν p.2) hπint] refine MeasureTheory.integral_mono hcint hπint ?_ intro p exact sub_le_sub_right (countermonotone_le_jointCdf h p.1 p.2) _ nlinarith [hcid, hπid, hgap]
theorem product_expectation_comonotoneCoupling reviewed
Causalean.Stat

Closed form of the optimum. For two probability measures μ and ν, each with finite second moment, the expectation of the coordinate product under the comonotone (quantile) coupling of μ and ν equals the integral, over (0,1), of the product of their quantile functions:

Formal statement
_hμ :
MemLp (fun x : ℝ => x) 2 μ
_hν :
MemLp (fun y : ℝ => y) 2 ν
(∫ p, p.1 * p.2 ∂(comonotoneCoupling μ ν))
= ∫ u in Ioo (0 : ℝ) 1, quantile μ u * quantile ν u
Proof (Lean source)
theorem product_expectation_comonotoneCoupling (μ ν : Measure ℝ) [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] (_hμ : MemLp (fun x : ℝ => x) 2 μ) (_hν : MemLp (fun y : ℝ => y) 2 ν) : (∫ p, p.1 * p.2 ∂(comonotoneCoupling μ ν)) = ∫ u in Ioo (0 : ℝ) 1, quantile μ u * quantile ν u := by unfold comonotoneCoupling rw [MeasureTheory.integral_map] · rfl · exact (aemeasurable_quantile_unifOI μ).prodMk (aemeasurable_quantile_unifOI ν) · fun_prop