Download data/lean/OAI/Combinatorics/GraphThreshold/BernoulliCoupling.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 5.55 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/GraphThreshold/BernoulliCoupling.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/GraphThreshold/BernoulliCoupling.lean
-
curl -L -o BernoulliCoupling.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/GraphThreshold/BernoulliCoupling.lean
5.55 kB
| import OAI.Combinatorics.GraphThreshold.FiniteProbability | |
| import Mathlib.Algebra.BigOperators.Group.Finset.Powerset | |
| import Mathlib.Tactic.FieldSimp | |
| namespace OAI | |
| open scoped BigOperators | |
| noncomputable section | |
| attribute [local instance] Classical.propDecidable | |
| namespace LeanBlast.SecondKahnKalai | |
| variable {X : Type*} [Fintype X] [DecidableEq X] | |
| theorem bernoulliExpectation_congr (p : β) {f g : Finset X β β} | |
| (h : β W, f W = g W) : bernoulliExpectation p f = bernoulliExpectation p g := by | |
| exact Finset.sum_congr rfl fun W _ => congrArg (fun z => bernoulliWeight p W * z) (h W) | |
| @[simp] theorem bernoulliExpectation_const (p c : β) : | |
| bernoulliExpectation p (fun _ : Finset X => c) = c := by | |
| rw [bernoulliExpectation, β Finset.sum_mul, bernoulliWeight_sum, one_mul] | |
| theorem bernoulliExpectation_add (p : β) (f g : Finset X β β) : | |
| bernoulliExpectation p (fun W => f W + g W) = | |
| bernoulliExpectation p f + bernoulliExpectation p g := by | |
| simp [bernoulliExpectation, mul_add, Finset.sum_add_distrib] | |
| theorem bernoulliExpectation_smul (p c : β) (f : Finset X β β) : | |
| bernoulliExpectation p (fun W => c * f W) = c * bernoulliExpectation p f := by | |
| simp [bernoulliExpectation, Finset.mul_sum, mul_left_comm] | |
| theorem bernoulliExpectation_sum {ΞΉ : Type*} [Fintype ΞΉ] (p : β) | |
| (f : ΞΉ β Finset X β β) : | |
| bernoulliExpectation p (fun W => β i, f i W) = β i, bernoulliExpectation p (f i) := by | |
| simp only [bernoulliExpectation, Finset.mul_sum] | |
| exact Finset.sum_comm | |
| theorem bernoulliExpectation_nonneg {p : β} (hp0 : 0 β€ p) (hp1 : p β€ 1) | |
| {f : Finset X β β} (hf : β W, 0 β€ f W) : 0 β€ bernoulliExpectation p f := | |
| (bernoulliLaw p hp0 hp1).expectation_nonneg hf | |
| theorem bernoulliExpectation_mono {p : β} (hp0 : 0 β€ p) (hp1 : p β€ 1) | |
| {f g : Finset X β β} (hfg : β W, f W β€ g W) : | |
| bernoulliExpectation p f β€ bernoulliExpectation p g := | |
| (bernoulliLaw p hp0 hp1).expectation_mono hfg | |
| theorem finset_eq_indicator_product (U V : Finset X) : | |
| (if U = V then (1 : β) else 0) = | |
| β x, if (x β U β x β V) then (1 : β) else 0 := by | |
| rw [Fintype.prod_boole] | |
| have h : (β x : X, x β U β x β V) β U = V := | |
| β¨Finset.ext, fun h => by subst V; simpβ© | |
| simp only [h] | |
| theorem bernoulliExpectation_pushforward (p : β) (T : Finset X β Finset X) | |
| (F : Finset X β β) : | |
| bernoulliExpectation p (fun W => F (T W)) = | |
| β Y : Finset X, bernoulliExpectation p (fun W => if T W = Y then 1 else 0) * F Y := by | |
| unfold bernoulliExpectation | |
| calc | |
| (β W : Finset X, bernoulliWeight p W * F (T W)) = | |
| β W : Finset X, β Y : Finset X, | |
| (bernoulliWeight p W * (if T W = Y then 1 else 0)) * F Y := by | |
| apply Finset.sum_congr rfl | |
| intro W _ | |
| simp [mul_ite, ite_mul] | |
| _ = β Y : Finset X, β W : Finset X, | |
| (bernoulliWeight p W * (if T W = Y then 1 else 0)) * F Y := Finset.sum_comm | |
| _ = _ := by simp only [Finset.sum_mul] | |
| theorem bernoulli_union_fixed_mass (p : β) (A Y : Finset X) : | |
| bernoulliExpectation p (fun W => if W βͺ A = Y then 1 else 0) = | |
| β x, if x β A then (if x β Y then (1 : β) else 0) | |
| else (if x β Y then p else 1 - p) := by | |
| let f : X β Bool β β := fun x b => | |
| if (b = true β¨ x β A) β x β Y then 1 else 0 | |
| have hf : (fun W : Finset X => if W βͺ A = Y then (1 : β) else 0) = | |
| (fun W => β x, f x (decide (x β W))) := by | |
| funext W | |
| simpa [f] using finset_eq_indicator_product (W βͺ A) Y | |
| rw [hf, bernoulliExpectation_product] | |
| apply Finset.prod_congr rfl | |
| intro x _ | |
| by_cases ha : x β A <;> by_cases hy : x β Y <;> simp [f, ha, hy] | |
| theorem bernoulli_union_fixed_mass_mul (p : β) (A Y : Finset X) : | |
| p ^ A.card * bernoulliExpectation p (fun W => if W βͺ A = Y then 1 else 0) = | |
| if A β Y then bernoulliWeight p Y else 0 := by | |
| rw [bernoulli_union_fixed_mass] | |
| by_cases hAY : A β Y | |
| Β· rw [ite_eq_left hAY] | |
| have hp : p ^ A.card = β x : X, if x β A then p else 1 := by | |
| rw [Fintype.prod_ite_mem] | |
| simp | |
| rw [hp, β Finset.prod_mul_distrib] | |
| apply Finset.prod_congr rfl | |
| intro x _ | |
| by_cases ha : x β A | |
| Β· simp [ha, hAY ha] | |
| Β· simp [ha] | |
| Β· rw [ite_eq_right hAY] | |
| obtain β¨x, hxa, hxyβ© := Finset.not_subset.mp hAY | |
| have hz : (β x, if x β A then (if x β Y then (1 : β) else 0) | |
| else (if x β Y then p else 1 - p)) = 0 := by | |
| apply Finset.prod_eq_zero (Finset.mem_univ x) | |
| simp [hxa, hxy] | |
| rw [hz, mul_zero] | |
| theorem bernoulli_union_fixed_mass_div (p : β) (hp : p β 0) (A Y : Finset X) : | |
| bernoulliExpectation p (fun W => if W βͺ A = Y then 1 else 0) = | |
| (if A β Y then bernoulliWeight p Y else 0) / p ^ A.card := by | |
| apply (eq_div_iff (pow_ne_zero _ hp)).2 | |
| simpa only [mul_comm] using bernoulli_union_fixed_mass_mul p A Y | |
| /-- Forcing all coordinates of `A` to be present gives the literal Bernoulli | |
| law conditioned on containing `A`. -/ | |
| theorem bernoulliExpectation_union_fixed (p : β) (hp : p β 0) | |
| (A : Finset X) (F : Finset X β β) : | |
| bernoulliExpectation p (fun W => F (W βͺ A)) = | |
| bernoulliExpectation p (fun Y => if A β Y then F Y / p ^ A.card else 0) := by | |
| rw [bernoulliExpectation_pushforward] | |
| unfold bernoulliExpectation | |
| apply Finset.sum_congr rfl | |
| intro Y _ | |
| rw [β bernoulliExpectation, bernoulli_union_fixed_mass_div p hp A Y] | |
| by_cases hAY : A β Y <;> simp [hAY] | |
| ring | |
| end LeanBlast.SecondKahnKalai | |
| end | |
| end OAI | |