Download data/lean/OAI/Combinatorics/DiscreteConvexity/LabelCoupling.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 7.06 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/DiscreteConvexity/LabelCoupling.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/DiscreteConvexity/LabelCoupling.lean
-
curl -L -o LabelCoupling.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/DiscreteConvexity/LabelCoupling.lean
7.06 kB
| import OAI.Combinatorics.DiscreteConvexity.Basic | |
| import OAI.Combinatorics.DiscreteConvexity.CoordinateObservations | |
| import OAI.Combinatorics.DiscreteConvexity.UnionBound | |
| import Mathlib.Algebra.BigOperators.Fin | |
| import Mathlib.Algebra.BigOperators.Group.Finset.Piecewise | |
| import Mathlib.Tactic.Ring | |
| namespace OAI | |
| namespace TalagrandDiscreteConvexity | |
| open scoped BigOperators | |
| noncomputable section | |
| /-- One coordinate receives label zero with the residual mass, and each of the | |
| `L` row labels with mass `p`. This does not assert independence of the rows. -/ | |
| def labelLaw (L : β) (p : β) (hp : 0 β€ p) (hLp : (L : β) * p β€ 1) : | |
| FiniteLaw (Fin (L + 1)) := by | |
| classical | |
| exact { | |
| weight := fun j => if j = 0 then 1 - (L : β) * p else p | |
| nonneg := fun j => by | |
| split_ifs | |
| Β· exact sub_nonneg.mpr hLp | |
| Β· exact hp | |
| total := by | |
| rw [Fin.sum_univ_succ] | |
| simp [nsmul_eq_mul] } | |
| @[simp] theorem labelLaw_weight_zero (L : β) (p : β) | |
| (hp : 0 β€ p) (hLp : (L : β) * p β€ 1) : | |
| (labelLaw L p hp hLp).weight 0 = 1 - (L : β) * p := by | |
| simp [labelLaw] | |
| @[simp] theorem labelLaw_weight_succ (L : β) (p : β) | |
| (hp : 0 β€ p) (hLp : (L : β) * p β€ 1) (j : Fin L) : | |
| (labelLaw L p hp hLp).weight j.succ = p := by | |
| simp [labelLaw] | |
| @[simp] theorem labelLaw_prob_zero (L : β) (p : β) | |
| (hp : 0 β€ p) (hLp : (L : β) * p β€ 1) : | |
| (labelLaw L p hp hLp).prob (fun j => j = 0) = 1 - (L : β) * p := by | |
| classical | |
| unfold FiniteLaw.prob | |
| refine (Finset.sum_eq_single (0 : Fin (L + 1)) ?_ ?_).trans ?_ | |
| Β· intro k _ hk | |
| exact ite_eq_right hk | |
| Β· simp | |
| Β· simp only [ite_true, labelLaw_weight_zero] | |
| @[simp] theorem labelLaw_prob_succ (L : β) (p : β) | |
| (hp : 0 β€ p) (hLp : (L : β) * p β€ 1) (j : Fin L) : | |
| (labelLaw L p hp hLp).prob (fun k => k = j.succ) = p := by | |
| classical | |
| unfold FiniteLaw.prob | |
| refine (Finset.sum_eq_single j.succ ?_ ?_).trans ?_ | |
| Β· intro k _ hk | |
| exact ite_eq_right hk | |
| Β· simp | |
| Β· simp only [ite_true, labelLaw_weight_succ] | |
| @[simp] theorem labelLaw_prob_nonzero (L : β) (p : β) | |
| (hp : 0 β€ p) (hLp : (L : β) * p β€ 1) : | |
| (labelLaw L p hp hLp).prob (fun j => j β 0) = (L : β) * p := by | |
| have h := (labelLaw L p hp hLp).prob_compl (fun j => j = 0) | |
| simpa only [labelLaw_prob_zero, sub_sub_cancel] using h | |
| variable {Ξ± : Type*} [Fintype Ξ±] [DecidableEq Ξ±] | |
| /-- Independent coordinate labels; the row membership events may be dependent. -/ | |
| def labelSamples (L : β) (p : β) (hp : 0 β€ p) (hLp : (L : β) * p β€ 1) : | |
| FiniteLaw (Ξ± β Fin (L + 1)) := | |
| FiniteLaw.pi (fun _ : Ξ± => labelLaw L p hp hLp) | |
| /-- Row `j` contains exactly the coordinates labeled by its successor label. -/ | |
| def labelRow {L : β} (Ο : Ξ± β Fin (L + 1)) (j : Fin L) : Finset Ξ± := by | |
| classical | |
| exact cubeSet (fun i => decide (Ο i = j.succ)) | |
| omit [DecidableEq Ξ±] in | |
| @[simp] theorem mem_labelRow {L : β} {Ο : Ξ± β Fin (L + 1)} | |
| {j : Fin L} {i : Ξ±} : i β labelRow Ο j β Ο i = j.succ := by | |
| classical | |
| simp [labelRow] | |
| theorem labelUnion_eq_cubeSet_nonzero {L : β} (Ο : Ξ± β Fin (L + 1)) : | |
| unionTuple (labelRow Ο) = cubeSet (fun i => decide (Ο i β 0)) := by | |
| classical | |
| ext i | |
| simp only [mem_unionTuple, mem_labelRow, mem_cubeSet, decide_eq_true_eq] | |
| constructor | |
| Β· rintro β¨j, hjβ© | |
| rw [hj] | |
| exact Fin.succ_ne_zero j | |
| Β· intro hi | |
| exact Fin.eq_succ_of_ne_zero hi | |
| /-- Every row has the full Bernoulli law, proved from independent coordinates. -/ | |
| theorem labelRow_prob_eq_mass (L : β) (p : β) (hp : 0 β€ p) | |
| (hLp : (L : β) * p β€ 1) (j : Fin L) (s : Finset Ξ±) : | |
| (labelSamples L p hp hLp).prob (fun Ο => labelRow Ο j = s) = | |
| bernoulliMass p s := by | |
| classical | |
| have hobs (i : Ξ±) : | |
| (labelLaw L p hp hLp).prob (fun k => decide (k = j.succ) = true) = p := by | |
| simpa only [decide_eq_true_eq] using labelLaw_prob_succ L p hp hLp j | |
| simpa only [labelSamples, labelRow] using | |
| prob_pi_cubeSet_eq_mass (fun _ : Ξ± => labelLaw L p hp hLp) | |
| (fun _ k => decide (k = j.succ)) p hobs s | |
| theorem labelRow_prob_mem_family (L : β) (p : β) (hp : 0 β€ p) | |
| (hLp : (L : β) * p β€ 1) (j : Fin L) (D : Family Ξ±) : | |
| (labelSamples L p hp hLp).prob (fun Ο => labelRow Ο j β D) = | |
| familyMeasure p D := by | |
| classical | |
| have hobs (i : Ξ±) : | |
| (labelLaw L p hp hLp).prob (fun k => decide (k = j.succ) = true) = p := by | |
| simpa only [decide_eq_true_eq] using labelLaw_prob_succ L p hp hLp j | |
| simpa only [labelSamples, labelRow] using | |
| prob_pi_cubeSet_mem_family (fun _ : Ξ± => labelLaw L p hp hLp) | |
| (fun _ k => decide (k = j.succ)) p hobs D | |
| /-- The row union has the full Bernoulli law at the amplified density `L * p`. -/ | |
| theorem labelUnion_prob_eq_mass (L : β) (p : β) (hp : 0 β€ p) | |
| (hLp : (L : β) * p β€ 1) (s : Finset Ξ±) : | |
| (labelSamples L p hp hLp).prob (fun Ο => unionTuple (labelRow Ο) = s) = | |
| bernoulliMass ((L : β) * p) s := by | |
| classical | |
| have hobs (i : Ξ±) : | |
| (labelLaw L p hp hLp).prob (fun k => decide (k β 0) = true) = (L : β) * p := by | |
| simpa only [decide_eq_true_eq] using labelLaw_prob_nonzero L p hp hLp | |
| simpa only [labelSamples, labelUnion_eq_cubeSet_nonzero] using | |
| prob_pi_cubeSet_eq_mass (fun _ : Ξ± => labelLaw L p hp hLp) | |
| (fun _ k => decide (k β 0)) ((L : β) * p) hobs s | |
| theorem labelUnion_prob_mem_family (L : β) (p : β) (hp : 0 β€ p) | |
| (hLp : (L : β) * p β€ 1) (D : Family Ξ±) : | |
| (labelSamples L p hp hLp).prob (fun Ο => unionTuple (labelRow Ο) β D) = | |
| familyMeasure ((L : β) * p) D := by | |
| classical | |
| have hobs (i : Ξ±) : | |
| (labelLaw L p hp hLp).prob (fun k => decide (k β 0) = true) = (L : β) * p := by | |
| simpa only [decide_eq_true_eq] using labelLaw_prob_nonzero L p hp hLp | |
| simpa only [labelSamples, labelUnion_eq_cubeSet_nonzero] using | |
| prob_pi_cubeSet_mem_family (fun _ : Ξ± => labelLaw L p hp hLp) | |
| (fun _ k => decide (k β 0)) ((L : β) * p) hobs D | |
| /-- Dependent rows give the density bound using only a union bound on failures. | |
| The law of the rows and of their union is supplied by the explicit label coupling. -/ | |
| theorem familyMeasure_unionFamily_label_lower (L : β) (p : β) (hp : 0 β€ p) | |
| (hLp : (L : β) * p β€ 1) (D : Family Ξ±) : | |
| 1 - (L : β) * (1 - familyMeasure p D) β€ | |
| familyMeasure ((L : β) * p) (unionFamily L D) := by | |
| classical | |
| have hgood := FiniteLaw.prob_forall_ge_of_const | |
| (labelSamples (Ξ± := Ξ±) L p hp hLp) | |
| (fun (j : Fin L) Ο => labelRow Ο j β D) (familyMeasure p D) | |
| (fun j => labelRow_prob_mem_family L p hp hLp j D) | |
| have hinclusion := (labelSamples (Ξ± := Ξ±) L p hp hLp).prob_mono | |
| (P := fun Ο => β j : Fin L, labelRow Ο j β D) | |
| (Q := fun Ο => unionTuple (labelRow Ο) β unionFamily L D) | |
| (fun Ο hΟ => mem_unionFamily.mpr β¨labelRow Ο, hΟ, rflβ©) | |
| rw [labelUnion_prob_mem_family] at hinclusion | |
| simpa only [Fintype.card_fin] using hgood.trans hinclusion | |
| end | |
| end TalagrandDiscreteConvexity | |
| end OAI | |