Stat.Coupling

This module collects coupling-based statistical primitives.

Atomic­Spectral­Law 3 core · 0 supporting · 2 submodules This roll-up module provides model-independent bounds that transfer a collision-safe diagonalizable functional calculus estimate to finite atomic one-Wasserstein laws represented by anchored operator evaluations. Monotone 22 core · 26 supporting · 1 submodule Monotone couplings of random variables and stochastic-order comparisons.
Atomic­Transport 8 core · 3 supporting This module defines finite atomic probability laws with arbitrary finite slot types, their represented measures and finite expectations, transport plans between two such laws, and the finite transport-polytope primal cos ★ exists_optimalTransportPlan

Finite atomic laws and their transport polytope

This module defines finite atomic probability laws with arbitrary finite slot types, their represented measures and finite expectations, transport plans between two such laws, and the finite transport-polytope primal cost for |x-y|. It defines the finite-atomic one-Wasserstein distance as the infimum of that cost and proves that an optimal transport plan exists.

structure AtomicLaw reviewed
Causalean.Stat.Coupling

A labelled finite atomic real law: a real weight and a real atom location for every slot of an index type, prior to imposing nonnegativity and unit total mass.

Definition (Lean source)
ι :
Type*
weight :
ι → ℝ
atom :
ι → ℝ
Causalean.Stat.Coupling.AtomicLaw · Causalean/Stat/Coupling/AtomicTransport.lean:22
def Valid reviewed
Causalean.Stat.Coupling.AtomicLaw

A finite atomic representation is valid when all its weights are nonnegative and they sum to one, so that it represents a probability law.

Definition (Lean source)
ι :
Type*
μ :
Valid μ :
Prop
clause 1
i :
0 ≤ μ.weight i
clause 2
∑ i, μ.weight i = 1
Causalean.Stat.Coupling.AtomicLaw.Valid · Causalean/Stat/Coupling/AtomicTransport.lean:30 · uses AtomicLaw
def toMeasure reviewed
Causalean.Stat.Coupling.AtomicLaw

The measure on the real line represented by a finite list of weighted atoms: the sum over slots of the point mass at the slot's atom scaled by the slot's weight, a negative weight being counted as zero. It is a probability measure when the representation is valid.

Definition (Lean source)
ι :
Type*
μ :
toMeasure μ :
∑ i, ofReal (μ.weight i) • Measure.dirac (μ.atom i)
Causalean.Stat.Coupling.AtomicLaw.toMeasure · Causalean/Stat/Coupling/AtomicTransport.lean:35 · uses AtomicLaw
def integral reviewed
Causalean.Stat.Coupling.AtomicLaw

The finite weighted expectation of a scalar test function: the sum over slots of the weight times the function value at the atom.

Definition (Lean source)
ι :
Type*
μ :
f :
ℝ → ℝ
integral μ f :
ℝ
∑ i, μ.weight i * f (μ.atom i)
Causalean.Stat.Coupling.AtomicLaw.integral · Causalean/Stat/Coupling/AtomicTransport.lean:41 · uses AtomicLaw
structure TransportPlan reviewed
Causalean.Stat.Coupling.AtomicLaw

A finite transport plan between two finite atomic representations is a table of masses, one per pair of slots, with nonnegative entries, row sums equal to the first representation's weights, and column sums equal to the second representation's weights.

Definition (Lean source)
ι κ :
Type*
μ :
ν :
mass :
ι → κ → ℝ
nonneg :
∀ i j, 0 ≤ mass i j
fst_marginal :
∀ i, ∑ j, mass i j = μ.weight i
snd_marginal :
∀ j, ∑ i, mass i j = ν.weight j
Causalean.Stat.Coupling.AtomicLaw.TransportPlan · Causalean/Stat/Coupling/AtomicTransport.lean:66 · uses AtomicLaw
def transportCost reviewed
Causalean.Stat.Coupling.AtomicLaw

The absolute-distance cost of a finite transport plan: the sum over slot pairs of the transported mass times the absolute distance between the two atoms.

Definition (Lean source)
ι κ :
π :
transportCost π :
ℝ
∑ i, ∑ j, π.mass i j * |μ.atom i - ν.atom j|
Causalean.Stat.Coupling.AtomicLaw.transportCost · Causalean/Stat/Coupling/AtomicTransport.lean:76 · uses AtomicLaw , TransportPlan
def w1 reviewed
Causalean.Stat.Coupling.AtomicLaw

Finite-atomic one-Wasserstein distance: the infimum of the absolute-distance transport cost over all transport plans between the two representations.

Definition (Lean source)
ι κ :
Type*
μ :
ν :
w1 μ ν :
ℝ
sInf {c : ℝ | ∃ π : TransportPlan μ ν, transportCost π = c}
Causalean.Stat.Coupling.AtomicLaw.w1 · Causalean/Stat/Coupling/AtomicTransport.lean:82 · uses AtomicLaw
theorem exists_optimalTransportPlan reviewed
Causalean.Stat.Coupling.AtomicLaw

Two finite atomic laws with finite slot types and nonnegative unit-mass weights have a transport plan attaining their one-Wasserstein cost.

Formal statement
ι κ :
Type*
μ :
ν :
hμ :
μ.Valid
hν :
ν.Valid
∃ π : TransportPlan μ ν, transportCost π = w1 μ ν
Proof (Lean source)
theorem exists_optimalTransportPlan {ι κ : Type*} [Fintype ι] [Fintype κ] (μ : AtomicLaw ι) (ν : AtomicLaw κ) (hμ : μ.Valid) (hν : ν.Valid) : ∃ π : TransportPlan μ ν, transportCost π = w1 μ ν := by classical let S : Set (ι → κ → ℝ) := {m | (∀ i j, 0 ≤ m i j) ∧ (∀ i, ∑ j, m i j = μ.weight i) ∧ ∀ j, ∑ i, m i j = ν.weight j} have hSne : S.Nonempty := by refine ⟨fun i j => μ.weight i * ν.weight j, ?_⟩ refine ⟨fun i j => mul_nonneg (hμ.1 i) (hν.1 j), ?_, ?_⟩ · intro i rw [← Finset.mul_sum, hν.2, mul_one] · intro j rw [← Finset.sum_mul, hμ.2, one_mul] have hweight_le_one (i : ι) : μ.weight i ≤ 1 := by rw [← hμ.2] exact Finset.single_le_sum (fun j _ => hμ.1 j) (Finset.mem_univ i) have hSsub : S ⊆ Icc (fun _ _ => 0) (fun _ _ => 1) := by intro m hm refine ⟨fun i j => hm.1 i j, fun i j => ?_⟩ calc m i j ≤ ∑ r, m i r := Finset.single_le_sum (fun r _ => hm.1 i r) (Finset.mem_univ j) _ = μ.weight i := hm.2.1 i _ ≤ 1 := hweight_le_one i have hSclosed : IsClosed S := by dsimp [S] simp only [Set.setOf_and] apply IsClosed.inter · simpa only [Set.iInter_ofPred] using (isClosed_iInter fun i => isClosed_iInter fun j => isClosed_le (continuous_const : Continuous (fun _ : ι → κ → ℝ => (0 : ℝ))) (by fun_prop : Continuous (fun m : ι → κ → ℝ => m i j))) apply IsClosed.inter · simpa only [Set.iInter_ofPred] using (isClosed_iInter fun i => isClosed_eq (by fun_prop : Continuous (fun m : ι → κ → ℝ => ∑ j, m i j)) (by fun_prop : Continuous (fun _ : ι → κ → ℝ => μ.weight i))) · simpa only [Set.iInter_ofPred] using (isClosed_iInter fun j => isClosed_eq (by fun_prop : Continuous (fun m : ι → κ → ℝ => ∑ i, m i j)) (by fun_prop : Continuous (fun _ : ι → κ → ℝ => ν.weight j))) have hScompact : IsCompact S := IsCompact.of_isClosed_subset isCompact_Icc hSclosed hSsub let cost : (ι → κ → ℝ) → ℝ := fun m => ∑ i, ∑ j, m i j * |μ.atom i - ν.atom j| have hcost_cont : Continuous cost := by unfold cost fun_prop obtain ⟨m, hmS, hmmin⟩ := hScompact.exists_isMinOn hSne hcost_cont.continuousOn let π : TransportPlan μ ν := { mass := m nonneg := hmS.1 fst_marginal := hmS.2.1 snd_marginal := hmS.2.2 } refine ⟨π, ?_⟩ have hvalues_ne : ({c : ℝ | ∃ q : TransportPlan μ ν, transportCost q = c}).Nonempty := ⟨transportCost π, π, rfl⟩ have hvalues_bdd : BddBelow {c : ℝ | ∃ q : TransportPlan μ ν, transportCost q = c} := by refine ⟨0, ?_⟩ rintro c ⟨q, rfl⟩ exact Finset.sum_nonneg fun i _ => Finset.sum_nonneg fun j _ => mul_nonneg (q.nonneg i j) (abs_nonneg _) apply le_antisymm · unfold w1 apply le_csInf hvalues_ne rintro c ⟨q, rfl⟩ simpa [cost, transportCost, π] using hmmin ⟨q.nonneg, q.fst_marginal, q.snd_marginal⟩ · unfold w1 exact csInf_le hvalues_bdd ⟨π, rfl⟩
Causalean.Stat.Coupling.AtomicLaw.exists_optimalTransportPlan · Causalean/Stat/Coupling/AtomicTransport.lean:104 · uses AtomicLaw , TransportPlan , Valid , transportCost , w1
3 supporting declarations (lemmas, instances)
Atomic­Cdf 8 core · 8 supporting This module defines the cumulative distribution function of a finite atomic law, the CDF gap of two laws, the cut-crossing quantities of a transport plan, and the CDF-sign potential. ★ integral_abs_cdfGap_le_transportCost

CDF gaps and the Kantorovich--Rubinstein potential of finite atomic laws

This module defines the cumulative distribution function of a finite atomic law, the CDF gap of two laws, the cut-crossing quantities of a transport plan, and the CDF-sign potential. It proves that the integrated absolute CDF gap is dominated by every transport cost, and the finite-atomic integration-by-parts identity expressing the expectation contrast of the CDF-sign potential through the CDF gap.

def cdf reviewed
Causalean.Stat.Coupling.AtomicLaw

The cumulative distribution function of a finite atomic representation: at a real point x, the total weight of the atoms located at or below x.

Definition (Lean source)
ι :
Type*
μ :
x :
ℝ
cdf μ x :
ℝ
∑ i, if μ.atom i ≤ x then μ.weight i else 0
Causalean.Stat.Coupling.AtomicLaw.cdf · Causalean/Stat/Coupling/AtomicCdf.lean:23 · uses AtomicLaw
def cdfGap reviewed
Causalean.Stat.Coupling.AtomicLaw

The pointwise difference of the two finite atomic cumulative distribution functions, the first minus the second.

Definition (Lean source)
ι κ :
Type*
μ :
ν :
x :
ℝ
cdfGap μ ν x :
ℝ
μ.cdf x - ν.cdf x
Causalean.Stat.Coupling.AtomicLaw.cdfGap · Causalean/Stat/Coupling/AtomicCdf.lean:28 · uses AtomicLaw
def signedCrossing reviewed
Causalean.Stat.Coupling.AtomicLaw

The signed amount of a transport plan crossing the cut at x: mass moved from a source atom at or below x to a target atom strictly above x counts positively, mass moved from a source atom strictly above x to a target atom at or below x counts negatively, and all other mass counts zero.

Definition (Lean source)
ι κ :
π :
x :
ℝ
signedCrossing π x :
ℝ
∑ i, ∑ j, π.mass i j * (if μ.atom i ≤ x ∧ x < ν.atom j then 1 else if ν.atom j ≤ x ∧ x < μ.atom i then -1 else 0)
Causalean.Stat.Coupling.AtomicLaw.signedCrossing · Causalean/Stat/Coupling/AtomicCdf.lean:34 · uses AtomicLaw , TransportPlan
def crossingEnvelope reviewed
Causalean.Stat.Coupling.AtomicLaw

The unsigned amount of a transport plan crossing the cut at x: the total mass moved between an atom at or below x and an atom strictly above x, in either direction.

Definition (Lean source)
ι κ :
π :
x :
ℝ
crossingEnvelope π x :
ℝ
∑ i, ∑ j, π.mass i j * (if μ.atom i ≤ x ∧ x < ν.atom j ∨ ν.atom j ≤ x ∧ x < μ.atom i then 1 else 0)
Causalean.Stat.Coupling.AtomicLaw.crossingEnvelope · Causalean/Stat/Coupling/AtomicCdf.lean:44 · uses AtomicLaw , TransportPlan
def CutMonotone reviewed
Causalean.Stat.Coupling.AtomicLaw

A transport plan has no counterflow when, at every real cut x, mass crosses in at most one of the two possible directions: either no mass moves from a source atom at or below x to a target atom strictly above x, or no mass moves from a source atom strictly above x to a target atom at or below x.

Definition (Lean source)
ι κ :
π :
x :
CutMonotone π :
Prop
(∑ i, ∑ j, if μ.atom i ≤ x ∧ x < ν.atom j then π.mass i j else 0)
= 0 ∨ (∑ i, ∑ j, if ν.atom j ≤ x ∧ x < μ.atom i then π.mass i j else 0) = 0
Causalean.Stat.Coupling.AtomicLaw.CutMonotone · Causalean/Stat/Coupling/AtomicCdf.lean:51 · uses AtomicLaw , TransportPlan
def cdfSign reviewed
Causalean.Stat.Coupling.AtomicLaw

The sign of the CDF gap of two finite atomic representations at a real point: one where the gap is positive, minus one where it is negative, and zero where it vanishes. It is the derivative of the attaining Kantorovich--Rubinstein potential.

Definition (Lean source)
ι κ :
Type*
μ :
ν :
x :
ℝ
cdfSign μ ν x :
ℝ
if 0 < cdfGap μ ν x then 1 else if cdfGap μ ν x < 0 then -1 else 0
Causalean.Stat.Coupling.AtomicLaw.cdfSign · Causalean/Stat/Coupling/AtomicCdf.lean:61 · uses AtomicLaw
def krPotential reviewed
Causalean.Stat.Coupling.AtomicLaw

The piecewise-linear primitive of the sign of the finite atomic CDF difference: the integral of that sign from zero to x, so that it vanishes at zero.

Definition (Lean source)
ι κ :
Type*
μ :
ν :
x :
ℝ
krPotential μ ν x :
ℝ
∫ t in (0 : ℝ)..x, cdfSign μ ν t
Causalean.Stat.Coupling.AtomicLaw.krPotential · Causalean/Stat/Coupling/AtomicCdf.lean:103 · uses AtomicLaw
theorem integral_abs_cdfGap_le_transportCost reviewed
Causalean.Stat.Coupling.AtomicLaw

Two finite atomic laws with finite slot types and any transport plan between them satisfy the lower bound of transport cost by integrated absolute CDF gap: the Lebesgue integral over the real line of the absolute difference of the two cumulative distribution functions is at most the absolute-distance cost of the plan.

Formal statement
ι κ :
π :
(∫ x, |cdfGap μ ν x|) ≤ transportCost π
Proof (Lean source)
theorem integral_abs_cdfGap_le_transportCost {ι κ : Type*} [Fintype ι] [Fintype κ] {μ : AtomicLaw ι} {ν : AtomicLaw κ} (π : TransportPlan μ ν) : (∫ x, |cdfGap μ ν x|) ≤ transportCost π := by rw [← integral_crossingEnvelope_eq_transportCost π] exact integral_abs_cdfGap_le_integral_crossingEnvelope π
Causalean.Stat.Coupling.AtomicLaw.integral_abs_cdfGap_le_transportCost · Causalean/Stat/Coupling/AtomicCdf.lean:335 · uses AtomicLaw , TransportPlan , cdfGap , transportCost
8 supporting declarations (lemmas, instances)
  • krPotential_lipschitz theorem — The CDF-sign potential is one-Lipschitz.
    ι κ :
    Type*
    μ :
    ν :
    Proof (Lean source)
    theorem krPotential_lipschitz {ι κ : Type*} [Fintype ι] [Fintype κ] (μ : AtomicLaw ι) (ν : AtomicLaw κ) : LipschitzWith 1 (krPotential μ ν) := by rw [lipschitzWith_iff_dist_le_mul] intro x y rw [Real.dist_eq, Real.dist_eq] change |(∫ t in (0 : ℝ)..x, cdfSign μ ν t) - ∫ t in (0 : ℝ)..y, cdfSign μ ν t| ≤ (1 : ℝ) * |x - y| rw [ intervalIntegral.integral_interval_sub_left (cdfSign_intervalIntegrable μ ν 0 x) (cdfSign_intervalIntegrable μ ν 0 y)] simpa [Real.norm_eq_abs, abs_sub_comm] using (intervalIntegral.norm_integral_le_of_norm_le_const (fun t ht => by simpa [Real.norm_eq_abs] using abs_cdfSign_le_one μ ν t) : ‖∫ t in y..x, cdfSign μ ν t‖ ≤ (1 : ℝ) * |x - y|)
    Causalean.Stat.Coupling.AtomicLaw.krPotential_lipschitz · Causalean/Stat/Coupling/AtomicCdf.lean:109
  • krPotential_zero theorem — The canonical CDF-sign potential is normalized to vanish at zero.
    ι κ :
    Type*
    μ :
    ν :
    krPotential μ ν 0 = 0
    Proof (Lean source)
    @[simp] theorem krPotential_zero {ι κ : Type*} [Fintype ι] [Fintype κ] (μ : AtomicLaw ι) (ν : AtomicLaw κ) : krPotential μ ν 0 = 0 := by simp [krPotential]
    Causalean.Stat.Coupling.AtomicLaw.krPotential_zero · Causalean/Stat/Coupling/AtomicCdf.lean:125
  • cdf_eq_toMeasure_Iic theorem — The finite-sum CDF of a valid atomic representation is the real mass of the corresponding closed lower ray under its represented measure.
    ι :
    Type*
    μ :
    hμ :
    μ.Valid
    x :
    ℝ
    μ.cdf x = (μ.toMeasure (Iic x)).toReal
    Proof (Lean source)
    theorem cdf_eq_toMeasure_Iic {ι : Type*} [Fintype ι] (μ : AtomicLaw ι) (hμ : μ.Valid) (x : ℝ) : μ.cdf x = (μ.toMeasure (Iic x)).toReal := by /- Expand the finite sum measure, evaluate each Dirac mass on `Iic x`, and use `ENNReal.toReal_ofReal` with `hμ.1`. -/ classical simp only [cdf, toMeasure, Measure.coe_finsetSum, Finset.sum_apply, Measure.smul_apply, smul_eq_mul, Measure.dirac_apply' _ measurableSet_Iic, Set.indicator_apply, Pi.one_apply] rw [ENNReal.toReal_sum (by intro i hi split_ifs <;> simp [ENNReal.ofReal_ne_top])] apply Finset.sum_congr rfl intro i hi by_cases hix : μ.atom i ≤ x · simp [hix, ENNReal.toReal_ofReal (hμ.1 i)] · simp [hix]
    Causalean.Stat.Coupling.AtomicLaw.cdf_eq_toMeasure_Iic · Causalean/Stat/Coupling/AtomicCdf.lean:130
  • cdf_eq_of_toMeasure_eq theorem — Valid finite atomic representations of the same measure have identical CDFs, even when their slot types and labellings are unrelated.
    ι κ :
    Type*
    μ :
    ν :
    hμ :
    μ.Valid
    hν :
    ν.Valid
    h :
    μ.toMeasure = ν.toMeasure
    μ.cdf = ν.cdf
    Proof (Lean source)
    theorem cdf_eq_of_toMeasure_eq {ι κ : Type*} [Fintype ι] [Fintype κ] (μ : AtomicLaw ι) (ν : AtomicLaw κ) (hμ : μ.Valid) (hν : ν.Valid) (h : μ.toMeasure = ν.toMeasure) : μ.cdf = ν.cdf := by funext x rw [cdf_eq_toMeasure_Iic μ hμ x, cdf_eq_toMeasure_Iic ν hν x, h]
    Causalean.Stat.Coupling.AtomicLaw.cdf_eq_of_toMeasure_eq · Causalean/Stat/Coupling/AtomicCdf.lean:150
  • cdfGap_eq_signedCrossing theorem — For every transport plan, the CDF difference at a cut is exactly its signed crossing mass at that cut.
    ι κ :
    π :
    x :
    ℝ
    cdfGap μ ν x = signedCrossing π x
    Proof (Lean source)
    theorem cdfGap_eq_signedCrossing {ι κ : Type*} [Fintype ι] [Fintype κ] {μ : AtomicLaw ι} {ν : AtomicLaw κ} (π : TransportPlan μ ν) (x : ℝ) : cdfGap μ ν x = signedCrossing π x := by /- Expand both marginals, distribute their finite sums, and partition each pair of atoms by its position relative to `x`. This is purely finite algebra and uses no validity premise. -/ classical unfold cdfGap cdf signedCrossing calc (∑ i, if μ.atom i ≤ x then μ.weight i else 0) - (∑ j, if ν.atom j ≤ x then ν.weight j else 0) = (∑ i, ∑ j, if μ.atom i ≤ x then π.mass i j else 0) - (∑ j, ∑ i, if ν.atom j ≤ x then π.mass i j else 0) := by congr 1 · apply Finset.sum_congr rfl intro i hi rw [← π.fst_marginal i] by_cases hix : μ.atom i ≤ x <;> simp [hix] · apply Finset.sum_congr rfl intro j hj rw [← π.snd_marginal j] by_cases hjx : ν.atom j ≤ x <;> simp [hjx] _ = ∑ i, ∑ j, π.mass i j * (if μ.atom i ≤ x ∧ x < ν.atom j then 1 else if ν.atom j ≤ x ∧ x < μ.atom i then -1 else 0) := by rw [Finset.sum_comm (f := fun j i => if ν.atom j ≤ x then π.mass i j else 0), ← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro i hi rw [← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro j hj by_cases hix : μ.atom i ≤ x · by_cases hjx : ν.atom j ≤ x · simp [hix, hjx, not_lt_of_ge hix, not_lt_of_ge hjx] · have hxj : x < ν.atom j := lt_of_not_ge hjx simp [hix, hjx, hxj] · have hxi : x < μ.atom i := lt_of_not_ge hix by_cases hjx : ν.atom j ≤ x · simp [hix, hjx, hxi] · simp [hix, hjx]
    Causalean.Stat.Coupling.AtomicLaw.cdfGap_eq_signedCrossing · Causalean/Stat/Coupling/AtomicCdf.lean:203
  • integral_abs_cdfGap_le_integral_crossingEnvelope theorem — Pointwise triangle inequality for cut flow integrates to domination by the unsigned crossing envelope.
    ι κ :
    π :
    (∫ x, |cdfGap μ ν x|) ≤ ∫ x, crossingEnvelope π x
    Proof (Lean source)
    theorem integral_abs_cdfGap_le_integral_crossingEnvelope {ι κ : Type*} [Fintype ι] [Fintype κ] {μ : AtomicLaw ι} {ν : AtomicLaw κ} (π : TransportPlan μ ν) : (∫ x, |cdfGap μ ν x|) ≤ ∫ x, crossingEnvelope π x := by /- Use `cdfGap_eq_signedCrossing`, the nonnegativity of plan masses, and finite-sum integrability of half-open interval indicators. -/ classical have hsigned : Integrable (signedCrossing π) volume := by unfold signedCrossing apply integrable_finsetSum univ intro i hi apply integrable_finsetSum univ intro j hj exact signedPair_integrable (π.mass i j) (μ.atom i) (ν.atom j) have hgap : Integrable (cdfGap μ ν) volume := by rw [show cdfGap μ ν = signedCrossing π from funext fun x => cdfGap_eq_signedCrossing π x] exact hsigned have henvelope : Integrable (crossingEnvelope π) volume := by unfold crossingEnvelope apply integrable_finsetSum univ intro i hi apply integrable_finsetSum univ intro j hj exact unsignedPair_integrable (π.mass i j) (μ.atom i) (ν.atom j) apply integral_mono hgap.abs henvelope intro x change |cdfGap μ ν x| ≤ crossingEnvelope π x rw [cdfGap_eq_signedCrossing π x] unfold signedCrossing crossingEnvelope calc |∑ i, ∑ j, π.mass i j * (if μ.atom i ≤ x ∧ x < ν.atom j then 1 else if ν.atom j ≤ x ∧ x < μ.atom i then -1 else 0)| ≤ ∑ i, |∑ j, π.mass i j * (if μ.atom i ≤ x ∧ x < ν.atom j then 1 else if ν.atom j ≤ x ∧ x < μ.atom i then -1 else 0)| := Finset.abs_sum_le_sum_abs _ _ _ ≤ ∑ i, ∑ j, |π.mass i j * (if μ.atom i ≤ x ∧ x < ν.atom j then 1 else if ν.atom j ≤ x ∧ x < μ.atom i then -1 else 0)| := by exact Finset.sum_le_sum fun i hi => Finset.abs_sum_le_sum_abs _ _ _ ≤ ∑ i, ∑ j, π.mass i j * (if μ.atom i ≤ x ∧ x < ν.atom j ∨ ν.atom j ≤ x ∧ x < μ.atom i then 1 else 0) := by apply Finset.sum_le_sum intro i hi apply Finset.sum_le_sum intro j hj rw [abs_mul, abs_of_nonneg (π.nonneg i j)] split_ifs with h₁ h₂ h₃ <;> simp_all [π.nonneg i j]
    Causalean.Stat.Coupling.AtomicLaw.integral_abs_cdfGap_le_integral_crossingEnvelope · Causalean/Stat/Coupling/AtomicCdf.lean:247
  • integral_crossingEnvelope_eq_transportCost theorem — The integral of the unsigned crossing envelope is exactly the absolute-distance cost of the transport plan.
    ι κ :
    π :
    (∫ x, crossingEnvelope π x) = transportCost π
    Proof (Lean source)
    theorem integral_crossingEnvelope_eq_transportCost {ι κ : Type*} [Fintype ι] [Fintype κ] {μ : AtomicLaw ι} {ν : AtomicLaw κ} (π : TransportPlan μ ν) : (∫ x, crossingEnvelope π x) = transportCost π := by /- Swap the finite sums with the integral. Each half-open interval indicator has Lebesgue integral equal to the distance between its two endpoints. -/ classical unfold crossingEnvelope transportCost rw [integral_finsetSum univ] · apply Finset.sum_congr rfl intro i hi rw [integral_finsetSum univ] · apply Finset.sum_congr rfl intro j hj simp_rw [unsignedCut_eq] rw [integral_const_mul, integral_add (cutIndicator_integrable (μ.atom i) (ν.atom j)) (cutIndicator_integrable (ν.atom j) (μ.atom i)), integral_cutIndicator, integral_cutIndicator] by_cases hij : μ.atom i ≤ ν.atom j · rw [abs_of_nonpos (sub_nonpos.mpr hij)] simp [hij] · have hji : ν.atom j ≤ μ.atom i := le_of_not_ge hij rw [abs_of_nonneg (sub_nonneg.mpr hji)] simp [hij, hji] · intro j hj exact unsignedPair_integrable (π.mass i j) (μ.atom i) (ν.atom j) · intro i hi apply integrable_finsetSum univ intro j hj exact unsignedPair_integrable (π.mass i j) (μ.atom i) (ν.atom j)
    Causalean.Stat.Coupling.AtomicLaw.integral_crossingEnvelope_eq_transportCost · Causalean/Stat/Coupling/AtomicCdf.lean:301
  • integral_krPotential_sub_eq_neg_integral_cdfSign_mul_cdfGap theorem — Finite-atomic integration by parts expresses the expectation contrast of the CDF-sign potential as the negative integral of the sign times the CDF gap.
    ι κ :
    Type*
    μ :
    ν :
    hμ :
    μ.Valid
    hν :
    ν.Valid
    μ.integral (krPotential μ ν) - ν.integral (krPotential μ ν)
    = -(∫ x, cdfSign μ ν x * cdfGap μ ν x)
    Proof (Lean source)
    theorem integral_krPotential_sub_eq_neg_integral_cdfSign_mul_cdfGap {ι κ : Type*} [Fintype ι] [Fintype κ] (μ : AtomicLaw ι) (ν : AtomicLaw κ) (hμ : μ.Valid) (hν : ν.Valid) : μ.integral (krPotential μ ν) - ν.integral (krPotential μ ν) = -(∫ x, cdfSign μ ν x * cdfGap μ ν x) := by /- Expand the finite expectations and oriented interval integrals, interchange finite sums with integration. A useful local bridge is (∫ t in 0..a, g t) = ∫ t, g t * (if 0 ≤ t ∧ t < a then 1 else if a ≤ t ∧ t < 0 then -1 else 0), proved by splitting on `0 ≤ a`, rewriting the interval integral as a restricted integral, and changing `Ioc` to `Ico` modulo the endpoint null sets. After distributing the finite sums, split pointwise on `0 ≤ t`: `hμ.2` and `hν.2` identify each weighted signed-cut sum with `1 - cdf` on the nonnegative half-line and with `-cdf` on the negative half-line. Thus their difference is `-cdfGap` everywhere, while finite sums of compact interval indicators provide all integrability side conditions needed by `integral_finsetSum`. -/ classical let signedCutAt : ℝ → ℝ → ℝ := fun a x => if 0 ≤ x ∧ x < a then 1 else if a ≤ x ∧ x < 0 then -1 else 0 have hμIntegral : μ.integral (krPotential μ ν) = ∫ x, cdfSign μ ν x * ∑ i, μ.weight i * signedCutAt (μ.atom i) x := by unfold AtomicLaw.integral krPotential calc (∑ i, μ.weight i * ∫ t in (0 : ℝ)..μ.atom i, cdfSign μ ν t) = ∑ i, ∫ x, μ.weight i * (cdfSign μ ν x * signedCutAt (μ.atom i) x) := by apply Finset.sum_congr rfl intro i hi rw [intervalIntegral_cdfSign_eq_integral_mul_signedCut] rw [integral_const_mul] _ = ∫ x, ∑ i, μ.weight i * (cdfSign μ ν x * signedCutAt (μ.atom i) x) := by rw [integral_finsetSum univ] intro i hi exact (cdfSign_mul_signedCut_integrable μ ν 0 (μ.atom i)).const_mul (μ.weight i) _ = ∫ x, cdfSign μ ν x * ∑ i, μ.weight i * signedCutAt (μ.atom i) x := by apply integral_congr_ae filter_upwards with x rw [Finset.mul_sum] apply Finset.sum_congr rfl intro i hi ring have hνIntegral : ν.integral (krPotential μ ν) = ∫ x, cdfSign μ ν x * ∑ j, ν.weight j * signedCutAt (ν.atom j) x := by unfold AtomicLaw.integral krPotential calc (∑ j, ν.weight j * ∫ t in (0 : ℝ)..ν.atom j, cdfSign μ ν t) = ∑ j, ∫ x, ν.weight j * (cdfSign μ ν x * signedCutAt (ν.atom j) x) := by apply Finset.sum_congr rfl intro j hj rw [intervalIntegral_cdfSign_eq_integral_mul_signedCut] rw [integral_const_mul] _ = ∫ x, ∑ j, ν.weight j * (cdfSign μ ν x * signedCutAt (ν.atom j) x) := by rw [integral_finsetSum univ] intro j hj exact (cdfSign_mul_signedCut_integrable μ ν 0 (ν.atom j)).const_mul (ν.weight j) _ = ∫ x, cdfSign μ ν x * ∑ j, ν.weight j * signedCutAt (ν.atom j) x := by apply integral_congr_ae filter_upwards with x rw [Finset.mul_sum] apply Finset.sum_congr rfl intro j hj ring have hμInt : Integrable (fun x => cdfSign μ ν x * ∑ i, μ.weight i * signedCutAt (μ.atom i) x) volume := by have hsum := integrable_finset_sum_of_integrable volume univ (fun i x => μ.weight i * (cdfSign μ ν x * signedCutAt (μ.atom i) x)) (fun i hi => (cdfSign_mul_signedCut_integrable μ ν 0 (μ.atom i)).const_mul (μ.weight i)) convert hsum using 1 funext x rw [Finset.mul_sum] apply Finset.sum_congr rfl intro i hi ring have hνInt : Integrable (fun x => cdfSign μ ν x * ∑ j, ν.weight j * signedCutAt (ν.atom j) x) volume := by have hsum := integrable_finset_sum_of_integrable volume univ (fun j x => ν.weight j * (cdfSign μ ν x * signedCutAt (ν.atom j) x)) (fun j hj => (cdfSign_mul_signedCut_integrable μ ν 0 (ν.atom j)).const_mul (ν.weight j)) convert hsum using 1 funext x rw [Finset.mul_sum] apply Finset.sum_congr rfl intro j hj ring rw [hμIntegral, hνIntegral, ← integral_sub hμInt hνInt] rw [← integral_neg] apply integral_congr_ae filter_upwards with x have hμsum := weighted_signedCut_sum_eq μ hμ x have hνsum := weighted_signedCut_sum_eq ν hν x change ( cdfSign μ ν x * ∑ i, μ.weight i * signedCutAt (μ.atom i) x) - cdfSign μ ν x * ∑ j, ν.weight j * signedCutAt (ν.atom j) x = -(cdfSign μ ν x * cdfGap μ ν x) change (∑ i, μ.weight i * signedCutAt (μ.atom i) x) = _ at hμsum change (∑ j, ν.weight j * signedCutAt (ν.atom j) x) = _ at hνsum rw [hμsum, hνsum] unfold cdfGap by_cases hx : 0 ≤ x <;> simp [hx] <;> ring
    Causalean.Stat.Coupling.AtomicLaw.integral_krPotential_sub_eq_neg_integral_cdfSign_mul_cdfGap · Causalean/Stat/Coupling/AtomicCdf.lean:470
Basic 1 core · 0 supporting This module defines the shared predicate for a probability measure whose two marginals are prescribed.

Coupling predicate

This module defines the shared predicate for a probability measure whose two marginals are prescribed. It is polymorphic in both measurable spaces so that coupling constructions throughout the statistical library can use one common interface.

structure IsCoupling reviewed
Causalean.Stat

For measurable spaces α and β, a measure π on their product and proposed marginal measures μ and ν, π is a coupling of μ and ν when it is a probability measure and its first and second marginals are respectively μ and ν.

Definition (Lean source)
α :
Type u
β :
Type v
π :
Measure (α × β)
μ :
ν :
isProbabilityMeasure :

A coupling is a probability measure.

map_fst :
π.map fst = μ

The first marginal of π is μ.

map_snd :
π.map snd = ν

The second marginal of π is ν.

Causalean.Stat.IsCoupling · Causalean/Stat/Coupling/Basic.lean:28
Atomic­Cut­Monotone 2 core · 4 supporting This module selects a no-counterflow transport plan between two finite atomic laws by minimizing a quadratic displacement objective over the finite transport polytope. ★ exists_transportPlan_cost_eq_integral_abs_cdfGap

Cut-monotone transport plans of finite atomic laws

This module selects a no-counterflow transport plan between two finite atomic laws by minimizing a quadratic displacement objective over the finite transport polytope. It proves that such a cut-monotone plan exists and that its transport cost equals the integrated absolute CDF gap.

def transportSqCost reviewed
Causalean.Stat.Coupling.AtomicLaw

The quadratic displacement objective of a finite transport plan: the sum over slot pairs of the transported mass times the squared distance between the two atoms. It is used only to select a no-counterflow plan from the finite transport polytope.

Definition (Lean source)
ι κ :
π :
transportSqCost π :
ℝ
∑ i, ∑ j, π.mass i j * (μ.atom i - ν.atom j) ^ 2
Causalean.Stat.Coupling.AtomicLaw.transportSqCost · Causalean/Stat/Coupling/AtomicCutMonotone.lean:21 · uses AtomicLaw , TransportPlan
theorem exists_transportPlan_cost_eq_integral_abs_cdfGap reviewed
Causalean.Stat.Coupling.AtomicLaw

Two finite atomic laws with finite slot types and nonnegative unit-mass weights have a transport plan whose absolute-distance cost equals their integrated absolute CDF gap, the Lebesgue integral over the real line of the absolute difference of the two cumulative distribution functions.

Formal statement
ι κ :
Type*
μ :
ν :
hμ :
μ.Valid
hν :
ν.Valid
∃ π : TransportPlan μ ν, transportCost π = ∫ x, |cdfGap μ ν x|
Proof (Lean source)
theorem exists_transportPlan_cost_eq_integral_abs_cdfGap {ι κ : Type*} [Fintype ι] [Fintype κ] (μ : AtomicLaw ι) (ν : AtomicLaw κ) (hμ : μ.Valid) (hν : ν.Valid) : ∃ π : TransportPlan μ ν, transportCost π = ∫ x, |cdfGap μ ν x| := by obtain ⟨π, hπ⟩ := exists_cutMonotone_transportPlan μ ν hμ hν exact ⟨π, transportCost_eq_integral_abs_cdfGap_of_cutMonotone π hπ⟩
Causalean.Stat.Coupling.AtomicLaw.exists_transportPlan_cost_eq_integral_abs_cdfGap · Causalean/Stat/Coupling/AtomicCutMonotone.lean:314 · uses AtomicLaw , TransportPlan , Valid , cdfGap , transportCost
4 supporting declarations (lemmas, instances)
  • exists_transportPlan_minimizing_sqCost theorem — Among all transport plans between two valid finite atomic laws, one minimizes the quadratic displacement objective.
    ι κ :
    Type*
    μ :
    ν :
    hμ :
    μ.Valid
    hν :
    ν.Valid
    ∃ π : TransportPlan μ ν, ∀ q : TransportPlan μ ν, transportSqCost π ≤ transportSqCost q
    Proof (Lean source)
    theorem exists_transportPlan_minimizing_sqCost {ι κ : Type*} [Fintype ι] [Fintype κ] (μ : AtomicLaw ι) (ν : AtomicLaw κ) (hμ : μ.Valid) (hν : ν.Valid) : ∃ π : TransportPlan μ ν, ∀ q : TransportPlan μ ν, transportSqCost π ≤ transportSqCost q := by /- Reuse the compact finite transport polytope argument from `exists_optimalTransportPlan`, replacing absolute displacement by the continuous quadratic objective. -/ classical let S : Set (ι → κ → ℝ) := {m | (∀ i j, 0 ≤ m i j) ∧ (∀ i, ∑ j, m i j = μ.weight i) ∧ ∀ j, ∑ i, m i j = ν.weight j} have hSne : S.Nonempty := by refine ⟨fun i j => μ.weight i * ν.weight j, ?_⟩ refine ⟨fun i j => mul_nonneg (hμ.1 i) (hν.1 j), ?_, ?_⟩ · intro i rw [← Finset.mul_sum, hν.2, mul_one] · intro j rw [← Finset.sum_mul, hμ.2, one_mul] have hweight_le_one (i : ι) : μ.weight i ≤ 1 := by rw [← hμ.2] exact Finset.single_le_sum (fun j _ => hμ.1 j) (Finset.mem_univ i) have hSsub : S ⊆ Icc (fun _ _ => 0) (fun _ _ => 1) := by intro m hm refine ⟨fun i j => hm.1 i j, fun i j => ?_⟩ calc m i j ≤ ∑ r, m i r := Finset.single_le_sum (fun r _ => hm.1 i r) (Finset.mem_univ j) _ = μ.weight i := hm.2.1 i _ ≤ 1 := hweight_le_one i have hSclosed : IsClosed S := by dsimp [S] simp only [Set.setOf_and] apply IsClosed.inter · simpa only [Set.iInter_ofPred] using (isClosed_iInter fun i => isClosed_iInter fun j => isClosed_le (continuous_const : Continuous (fun _ : ι → κ → ℝ => (0 : ℝ))) (by fun_prop : Continuous (fun m : ι → κ → ℝ => m i j))) apply IsClosed.inter · simpa only [Set.iInter_ofPred] using (isClosed_iInter fun i => isClosed_eq (by fun_prop : Continuous (fun m : ι → κ → ℝ => ∑ j, m i j)) (by fun_prop : Continuous (fun _ : ι → κ → ℝ => μ.weight i))) · simpa only [Set.iInter_ofPred] using (isClosed_iInter fun j => isClosed_eq (by fun_prop : Continuous (fun m : ι → κ → ℝ => ∑ i, m i j)) (by fun_prop : Continuous (fun _ : ι → κ → ℝ => ν.weight j))) have hScompact : IsCompact S := IsCompact.of_isClosed_subset isCompact_Icc hSclosed hSsub let cost : (ι → κ → ℝ) → ℝ := fun m => ∑ i, ∑ j, m i j * (μ.atom i - ν.atom j) ^ 2 have hcost_cont : Continuous cost := by unfold cost fun_prop obtain ⟨m, hmS, hmmin⟩ := hScompact.exists_isMinOn hSne hcost_cont.continuousOn let π : TransportPlan μ ν := { mass := m nonneg := hmS.1 fst_marginal := hmS.2.1 snd_marginal := hmS.2.2 } refine ⟨π, fun q => ?_⟩ simpa [cost, transportSqCost, π] using hmmin ⟨q.nonneg, q.fst_marginal, q.snd_marginal⟩
    Causalean.Stat.Coupling.AtomicLaw.exists_transportPlan_minimizing_sqCost · Causalean/Stat/Coupling/AtomicCutMonotone.lean:28
  • cutMonotone_of_sqCost_minimal theorem — A quadratic-cost-minimizing finite transport plan cannot send positive mass in opposite directions across the same real cut.
    ι κ :
    π :
    hmin :
    Proof (Lean source)
    theorem cutMonotone_of_sqCost_minimal {ι κ : Type*} [Fintype ι] [Fintype κ] {μ : AtomicLaw ι} {ν : AtomicLaw κ} (π : TransportPlan μ ν) (hmin : ∀ q : TransportPlan μ ν, transportSqCost π ≤ transportSqCost q) : CutMonotone π := by /- If positive entries `(i,j)` and `(k,l)` cross a cut in opposite directions, move their common minimum mass from `(i,j),(k,l)` to `(i,l),(k,j)`. Marginals and nonnegativity are preserved, while the quadratic objective falls by `2 * ε * (μ.atom k - μ.atom i) * (ν.atom j - ν.atom l) > 0`. -/ classical intro x by_contra hcounter rw [not_or] at hcounter let right : ℝ := ∑ i, ∑ j, if μ.atom i ≤ x ∧ x < ν.atom j then π.mass i j else 0 let left : ℝ := ∑ i, ∑ j, if ν.atom j ≤ x ∧ x < μ.atom i then π.mass i j else 0 have hright_nonneg : 0 ≤ right := by dsimp [right] exact Finset.sum_nonneg fun i _ => Finset.sum_nonneg fun j _ => by split_ifs · exact π.nonneg i j · exact le_rfl have hleft_nonneg : 0 ≤ left := by dsimp [left] exact Finset.sum_nonneg fun i _ => Finset.sum_nonneg fun j _ => by split_ifs · exact π.nonneg i j · exact le_rfl have hright_ne : right ≠ 0 := by simpa [right] using hcounter.1 have hleft_ne : left ≠ 0 := by simpa [left] using hcounter.2 have hright_pos : 0 < right := lt_of_le_of_ne hright_nonneg (Ne.symm hright_ne) have hleft_pos : 0 < left := lt_of_le_of_ne hleft_nonneg (Ne.symm hleft_ne) obtain ⟨i, hi, hi_pos⟩ := (Finset.sum_pos_iff_of_nonneg (fun i _ => Finset.sum_nonneg fun j _ => by split_ifs · exact π.nonneg i j · exact le_rfl)).mp hright_pos obtain ⟨j, hj, hij_pos⟩ := (Finset.sum_pos_iff_of_nonneg (fun j _ => by split_ifs · exact π.nonneg i j · exact le_rfl)).mp hi_pos have hij_cut : μ.atom i ≤ x ∧ x < ν.atom j := by by_contra hij simp [hij] at hij_pos have hij_mass : 0 < π.mass i j := by simpa [hij_cut] using hij_pos obtain ⟨k, hk, hk_pos⟩ := (Finset.sum_pos_iff_of_nonneg (fun k _ => Finset.sum_nonneg fun l _ => by split_ifs · exact π.nonneg k l · exact le_rfl)).mp hleft_pos obtain ⟨l, hl, hkl_pos⟩ := (Finset.sum_pos_iff_of_nonneg (fun l _ => by split_ifs · exact π.nonneg k l · exact le_rfl)).mp hk_pos have hkl_cut : ν.atom l ≤ x ∧ x < μ.atom k := by by_contra hkl simp [hkl] at hkl_pos have hkl_mass : 0 < π.mass k l := by simpa [hkl_cut] using hkl_pos have hsource : μ.atom i < μ.atom k := lt_of_le_of_lt hij_cut.1 hkl_cut.2 have htarget : ν.atom l < ν.atom j := lt_of_le_of_lt hkl_cut.1 hij_cut.2 have hik : i ≠ k := by intro hik subst k exact (lt_irrefl _ hsource) have hjl : j ≠ l := by intro hjl subst l exact (lt_irrefl _ htarget) let ε : ℝ := min (π.mass i j) (π.mass k l) have hε_pos : 0 < ε := by exact lt_min hij_mass hkl_mass have hε_ij : ε ≤ π.mass i j := min_le_left _ _ have hε_kl : ε ≤ π.mass k l := min_le_right _ _ let q : TransportPlan μ ν := { mass := fun a b => π.mass a b - (if a = i ∧ b = j then ε else 0) - (if a = k ∧ b = l then ε else 0) + (if a = i ∧ b = l then ε else 0) + (if a = k ∧ b = j then ε else 0) nonneg := by intro a b by_cases hai : a = i <;> by_cases hak : a = k <;> by_cases hbj : b = j <;> by_cases hbl : b = l <;> simp_all [sub_nonneg.mpr hε_ij, sub_nonneg.mpr hε_kl, π.nonneg] <;> exact add_nonneg (π.nonneg _ _) (le_of_lt hε_pos) fst_marginal := by intro a simp only [Finset.sum_add_distrib, Finset.sum_sub_distrib] by_cases hai : a = i · subst a simp [π.fst_marginal, hik] · by_cases hak : a = k · subst a simp [π.fst_marginal, hai, Ne.symm hik] · simp [π.fst_marginal, hai, hak] snd_marginal := by intro b simp only [Finset.sum_add_distrib, Finset.sum_sub_distrib] by_cases hbj : b = j · subst b simp [π.snd_marginal, hjl] · by_cases hbl : b = l · subst b simp [π.snd_marginal, hbj, Ne.symm hjl] · simp [π.snd_marginal, hbj, hbl] } have hsum_single (a : ι) (b : κ) (f : ι → κ → ℝ) : (∑ u, ∑ v, if u = a ∧ v = b then f u v else 0) = f a b := by calc _ = ∑ v, if a = a ∧ v = b then f a v else 0 := by apply Finset.sum_eq_single a · intro u hu hua simp [hua] · simp _ = f a b := by simp have hcost : transportSqCost q = transportSqCost π - 2 * ε * (μ.atom k - μ.atom i) * (ν.atom j - ν.atom l) := by unfold transportSqCost dsimp [q] simp only [sub_mul, add_mul, Finset.sum_add_distrib, Finset.sum_sub_distrib] simp [hik, hjl, hsum_single] ring have hdecrease : 0 < 2 * ε * (μ.atom k - μ.atom i) * (ν.atom j - ν.atom l) := by positivity have hstrict : transportSqCost q < transportSqCost π := by rw [hcost] linarith exact (not_lt_of_ge (hmin q)) hstrict
    Causalean.Stat.Coupling.AtomicLaw.cutMonotone_of_sqCost_minimal · Causalean/Stat/Coupling/AtomicCutMonotone.lean:95
  • exists_cutMonotone_transportPlan theorem — Any two valid finite atomic laws have a transport plan with no simultaneous flow in opposite directions across any cut.
    ι κ :
    Type*
    μ :
    ν :
    hμ :
    μ.Valid
    hν :
    ν.Valid
    ∃ π : TransportPlan μ ν, CutMonotone π
    Proof (Lean source)
    theorem exists_cutMonotone_transportPlan {ι κ : Type*} [Fintype ι] [Fintype κ] (μ : AtomicLaw ι) (ν : AtomicLaw κ) (hμ : μ.Valid) (hν : ν.Valid) : ∃ π : TransportPlan μ ν, CutMonotone π := by obtain ⟨π, hπ⟩ := exists_transportPlan_minimizing_sqCost μ ν hμ hν exact ⟨π, cutMonotone_of_sqCost_minimal π hπ⟩
    Causalean.Stat.Coupling.AtomicLaw.exists_cutMonotone_transportPlan · Causalean/Stat/Coupling/AtomicCutMonotone.lean:236
  • transportCost_eq_integral_abs_cdfGap_of_cutMonotone theorem — A no-counterflow transport plan attains the integrated absolute CDF gap.
    ι κ :
    π :
    hπ :
    transportCost π = ∫ x, |cdfGap μ ν x|
    Proof (Lean source)
    theorem transportCost_eq_integral_abs_cdfGap_of_cutMonotone {ι κ : Type*} [Fintype ι] [Fintype κ] {μ : AtomicLaw ι} {ν : AtomicLaw κ} (π : TransportPlan μ ν) (hπ : CutMonotone π) : transportCost π = ∫ x, |cdfGap μ ν x| := by /- At each cut, `CutMonotone` turns the absolute signed crossing mass into the unsigned crossing envelope. Integrate and use `integral_crossingEnvelope_eq_transportCost`. -/ classical rw [← integral_crossingEnvelope_eq_transportCost π] apply integral_congr_ae filter_upwards with x let right : ℝ := ∑ i, ∑ j, if μ.atom i ≤ x ∧ x < ν.atom j then π.mass i j else 0 let left : ℝ := ∑ i, ∑ j, if ν.atom j ≤ x ∧ x < μ.atom i then π.mass i j else 0 have hright : 0 ≤ right := by dsimp [right] exact Finset.sum_nonneg fun i _ => Finset.sum_nonneg fun j _ => by split_ifs · exact π.nonneg i j · exact le_rfl have hleft : 0 ≤ left := by dsimp [left] exact Finset.sum_nonneg fun i _ => Finset.sum_nonneg fun j _ => by split_ifs · exact π.nonneg i j · exact le_rfl have hsigned : signedCrossing π x = right - left := by unfold signedCrossing dsimp [right, left] rw [← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro i hi rw [← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro j hj by_cases hr : μ.atom i ≤ x ∧ x < ν.atom j · have hl : ¬(ν.atom j ≤ x ∧ x < μ.atom i) := by rintro ⟨hjx, hxi⟩ exact (not_lt_of_ge hjx) hr.2 simp [hr, hl] · by_cases hl : ν.atom j ≤ x ∧ x < μ.atom i · simp [hr, hl] · simp [hr, hl] have henvelope : crossingEnvelope π x = right + left := by unfold crossingEnvelope dsimp [right, left] rw [← Finset.sum_add_distrib] apply Finset.sum_congr rfl intro i hi rw [← Finset.sum_add_distrib] apply Finset.sum_congr rfl intro j hj by_cases hr : μ.atom i ≤ x ∧ x < ν.atom j · have hl : ¬(ν.atom j ≤ x ∧ x < μ.atom i) := by rintro ⟨hjx, hxi⟩ exact (not_lt_of_ge hjx) hr.2 simp [hr, hl] · by_cases hl : ν.atom j ≤ x ∧ x < μ.atom i · simp [hr, hl] · simp [hr, hl] rw [cdfGap_eq_signedCrossing π x, hsigned, henvelope] rcases hπ x with hright_zero | hleft_zero · change right = 0 at hright_zero rw [hright_zero, zero_sub, abs_neg, abs_of_nonneg hleft, zero_add] · change left = 0 at hleft_zero rw [hleft_zero, sub_zero, abs_of_nonneg hright, add_zero]
    Causalean.Stat.Coupling.AtomicLaw.transportCost_eq_integral_abs_cdfGap_of_cutMonotone · Causalean/Stat/Coupling/AtomicCutMonotone.lean:245
Atomic­Wasserstein 1 core · 8 supporting For two finitely supported probability laws on the real line, the one-Wasserstein distance (the least absolute-distance cost over transport plans) equals the integral of the absolute difference of the two distribution fu ★ w1_eq_sSup_lipschitz

Finite atomic one-dimensional Wasserstein duality

For two finitely supported probability laws on the real line, the one-Wasserstein distance (the least absolute-distance cost over transport plans) equals the integral of the absolute difference of the two distribution functions, and equals the supremum of |E_μ f − E_ν f| over 1-Lipschitz f (Kantorovich–Rubinstein duality). The supremum is attained by an explicit potential: the primitive of the sign of the CDF difference. The distance depends only on the represented measures, so permuting slots, adding zero-weight slots, and splitting or merging coincident atoms do not change it.

Main results

* AtomicLaw.w1_eq_integral_abs_cdfGap — W₁(μ, ν) = ∫ |F_μ − F_ν|. * AtomicLaw.lipschitz_integral_sub_le_w1 — weak duality: every 1-Lipschitz contrast is at most W₁. * AtomicLaw.krPotential_attains — the CDF-sign potential is 1-Lipschitz and attains W₁. * AtomicLaw.w1_eq_sSup_lipschitz — exact Kantorovich–Rubinstein duality. * AtomicLaw.w1_le_of_lipschitz_integral_sub_le — a uniform bound on 1-Lipschitz contrasts bounds W₁. * AtomicLaw.w1_congr_toMeasure — W₁ depends only on the two represented measures.

The atomic laws and transport plans, the CDF and potential calculus, and the cut-monotone plan these proofs use are defined in AtomicTransport, AtomicCdf and AtomicCutMonotone, which this file imports.

theorem w1_eq_sSup_lipschitz reviewed
Causalean.Stat.Coupling.AtomicLaw

Two finite atomic laws with finite slot types and valid probability weights have one-Wasserstein distance equal to the supremum of absolute expectation contrasts over one-Lipschitz functions.

Formal statement
ι κ :
Type*
μ :
ν :
hμ :
μ.Valid
hν :
ν.Valid
w1 μ ν = sSup {r : ℝ | ∃ f : ℝ → ℝ, LipschitzWith 1 f ∧ r = |μ.integral f - ν.integral f|}
Proof (Lean source)
theorem w1_eq_sSup_lipschitz {ι κ : Type*} [Fintype ι] [Fintype κ] (μ : AtomicLaw ι) (ν : AtomicLaw κ) (hμ : μ.Valid) (hν : ν.Valid) : w1 μ ν = sSup {r : ℝ | ∃ f : ℝ → ℝ, LipschitzWith 1 f ∧ r = |μ.integral f - ν.integral f|} := by let S : Set ℝ := {r : ℝ | ∃ f : ℝ → ℝ, LipschitzWith 1 f ∧ r = |μ.integral f - ν.integral f|} obtain ⟨hpotLip, hpotEq⟩ := krPotential_attains μ ν hμ hν have hpotMem : |μ.integral (krPotential μ ν) - ν.integral (krPotential μ ν)| ∈ S := ⟨krPotential μ ν, hpotLip, rfl⟩ have hSne : S.Nonempty := ⟨_, hpotMem⟩ have hSbdd : BddAbove S := by refine ⟨w1 μ ν, ?_⟩ rintro r ⟨f, hf, rfl⟩ exact lipschitz_integral_sub_le_w1 μ ν hμ hν f hf change w1 μ ν = sSup S apply le_antisymm · rw [hpotEq] exact le_csSup hSbdd hpotMem · exact csSup_le hSne fun r hr => by obtain ⟨f, hf, rfl⟩ := hr exact lipschitz_integral_sub_le_w1 μ ν hμ hν f hf
Causalean.Stat.Coupling.AtomicLaw.w1_eq_sSup_lipschitz · Causalean/Stat/Coupling/AtomicWasserstein.lean:144 · uses AtomicLaw , Valid , integral , w1
8 supporting declarations (lemmas, instances)