Download data/lean/OAI/Computability/UniqueGames/Soundness/SubsetIntersectionLemmas.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 39.6 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/UniqueGames/Soundness/SubsetIntersectionLemmas.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/UniqueGames/Soundness/SubsetIntersectionLemmas.lean
-
curl -L -o SubsetIntersectionLemmas.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/UniqueGames/Soundness/SubsetIntersectionLemmas.lean
39.6 kB
| import Mathlib.Algebra.BigOperators.Field | |
| import Mathlib.Algebra.BigOperators.Group.Finset.Sigma | |
| import Mathlib.Algebra.BigOperators.Ring.Finset | |
| import Mathlib.Algebra.Order.BigOperators.Expect | |
| import Mathlib.Algebra.Order.BigOperators.Group.Finset | |
| import Mathlib.Data.Finset.Powerset | |
| import Mathlib.Data.Rat.Cast.Order | |
| import Mathlib.Basic.Real.Basic | |
| import Mathlib.Tactic.FieldSimp | |
| import Mathlib.Tactic.Linarith | |
| import Mathlib.Tactic.NormNum | |
| import Mathlib.Tactic.Positivity | |
| import Mathlib.Tactic.Ring | |
| import OAI.Computability.UniqueGames.Foundations.SamplingLemmas | |
| import OAI.Computability.UniqueGames.Reduction.FinalParametersLemmas | |
| import OAI.Computability.UniqueGames.Soundness.ExpectationComparisonLemmas | |
| import OAI.Computability.UniqueGames.Soundness.LinearMapDensityLemmas | |
| import OAI.Computability.UniqueGames.Soundness.PartnerLinearLemmas | |
| namespace OAI | |
| section | |
| /-! | |
| All expectations below are explicit rational sums over `Finset.powersetCard`. | |
| The marginal inclusion probability is derived from the exact binomial count | |
| of subsets containing a prescribed singleton. No probabilistic estimate is an | |
| assumption. This is the active-set overlap bound used in Lemma 6.3. | |
| -/ | |
| namespace UniqueGamesTheorem.Soundness.SubsetIntersection | |
| open scoped BigOperators | |
| /-- The actual finite sample space of all `t`-subsets of `Fin k`. -/ | |
| def subsets (k t : β) : Finset (Finset (Fin k)) := | |
| (Finset.univ : Finset (Fin k)).powersetCard t | |
| /-- Uniform expectation, implemented by its normalized finite sum. -/ | |
| def uniformMean (k t : β) (f : Finset (Fin k) β β) : β := | |
| (β a β subsets k t, f a) / (subsets k t).card | |
| /-- Independent draws use the product of the two uniform laws. -/ | |
| def independentMean (k t : β) (f : Finset (Fin k) β Finset (Fin k) β β) : β := | |
| uniformMean k t fun a => uniformMean k t fun b => f a b | |
| def memberIndicator {k : β} (i : Fin k) (a : Finset (Fin k)) : β := | |
| if i β a then 1 else 0 | |
| def overlapProbability (k t : β) : β := | |
| independentMean k t fun a b => if (a β© b).Nonempty then 1 else 0 | |
| /-- The nested expectations are exactly the normalized sum on the product | |
| sample space, whose cardinality is the square of the single-draw cardinality. -/ | |
| theorem independentMean_eq_double_sum (k t : β) | |
| (f : Finset (Fin k) β Finset (Fin k) β β) : | |
| independentMean k t f = | |
| (β a β subsets k t, β b β subsets k t, f a b) / ((subsets k t).card : β)^2 := by | |
| unfold independentMean uniformMean | |
| simp only [div_eq_mul_inv, β Finset.sum_mul, pow_two, mul_inv_rev] | |
| ring | |
| theorem uniformMean_mul_left (k t : β) (c : β) (f : Finset (Fin k) β β) : | |
| uniformMean k t (fun a => c * f a) = c * uniformMean k t f := by | |
| unfold uniformMean | |
| rw [β Finset.mul_sum] | |
| ring | |
| theorem uniformMean_mul_right (k t : β) (c : β) (f : Finset (Fin k) β β) : | |
| uniformMean k t (fun a => f a * c) = uniformMean k t f * c := by | |
| unfold uniformMean | |
| rw [β Finset.sum_mul] | |
| ring | |
| /-- Independence is proved from the actual two normalized finite sums. -/ | |
| theorem independentMean_product (k t : β) (f g : Finset (Fin k) β β) : | |
| independentMean k t (fun a b => f a * g b) = uniformMean k t f * uniformMean k t g := by | |
| simp only [independentMean, uniformMean_mul_left, uniformMean_mul_right] | |
| theorem subsets_card (k t : β) : (subsets k t).card = k.choose t := by | |
| simp [subsets] | |
| theorem subsets_nonempty {k t : β} (htk : t β€ k) : (subsets k t).Nonempty := by | |
| apply Finset.powersetCard_nonempty.mpr | |
| simpa using htk | |
| theorem subsets_card_ne_zero {k t : β} (htk : t β€ k) : | |
| ((subsets k t).card : β) β 0 := by | |
| exact_mod_cast (Finset.card_ne_zero.mpr (subsets_nonempty htk)) | |
| /-- Count the sampled subsets containing one specified coordinate. -/ | |
| theorem count_containing {k t : β} (ht : 0 < t) (i : Fin k) : | |
| ((subsets k t).filter (fun a => i β a)).card = | |
| (k - 1).choose (t - 1) := by | |
| simpa [subsets] using | |
| (Finset.card_filter_powersetCard_subset ({i} : Finset (Fin k)) Finset.univ t | |
| (by simp) (by simpa using Nat.succ_le_of_lt ht)) | |
| theorem choose_predecessor_ratio {k t : β} (hk : 0 < k) (ht : 0 < t) (htk : t β€ k) : | |
| ((k - 1).choose (t - 1) : β) / k.choose t = (t : β) / k := by | |
| have hk0 : (k : β) β 0 := by exact_mod_cast (Nat.ne_of_gt hk) | |
| have hc0 : (k.choose t : β) β 0 := by exact_mod_cast (Nat.ne_of_gt (Nat.choose_pos htk)) | |
| have hrel : k * (k - 1).choose (t - 1) = k.choose t * t := by | |
| simpa [Nat.sub_add_cancel hk, Nat.sub_add_cancel ht] using | |
| (Nat.add_one_mul_choose_eq (k - 1) (t - 1)) | |
| apply (div_eq_div_iff hc0 hk0).2 | |
| exact_mod_cast (by simpa [Nat.mul_comm] using hrel) | |
| /-- Exact marginal probability: a coordinate belongs to a uniform `t`-subset | |
| with probability `t / k`. This also includes `t = 0`. -/ | |
| theorem inclusion_probability {k t : β} (hk : 0 < k) (htk : t β€ k) (i : Fin k) : | |
| uniformMean k t (memberIndicator i) = (t : β) / k := by | |
| by_cases ht : t = 0 | |
| Β· subst t | |
| simp [uniformMean, subsets, memberIndicator] | |
| Β· have htpos : 0 < t := Nat.pos_of_ne_zero ht | |
| unfold uniformMean memberIndicator | |
| rw [Finset.sum_boole, count_containing htpos i, subsets_card] | |
| exact choose_predecessor_ratio hk htpos htk | |
| /-- A coordinate belongs to both independent draws with the product probability. -/ | |
| theorem independent_inclusion_probability {k t : β} (hk : 0 < k) (htk : t β€ k) (i : Fin k) : | |
| independentMean k t (fun a b => memberIndicator i a * memberIndicator i b) = | |
| ((t : β) / k)^2 := by | |
| rw [independentMean_product, inclusion_probability hk htk] | |
| ring | |
| theorem uniformMean_congr {k t : β} {f g : Finset (Fin k) β β} | |
| (h : β a β subsets k t, f a = g a) : uniformMean k t f = uniformMean k t g := by | |
| unfold uniformMean | |
| rw [Finset.sum_congr rfl h] | |
| theorem uniformMean_const {k t : β} (htk : t β€ k) (c : β) : | |
| uniformMean k t (fun _ => c) = c := by | |
| have hn := subsets_card_ne_zero htk | |
| simp only [uniformMean, Finset.sum_const, nsmul_eq_mul] | |
| field_simp | |
| theorem uniformMean_finset_sum {k t : β} {Ξ± : Type*} (s : Finset Ξ±) | |
| (f : Ξ± β Finset (Fin k) β β) : | |
| uniformMean k t (fun a => β i β s, f i a) = | |
| β i β s, uniformMean k t (f i) := by | |
| unfold uniformMean | |
| rw [Finset.sum_comm] | |
| simp only [div_eq_mul_inv, Finset.sum_mul] | |
| theorem uniformMean_mono {k t : β} {f g : Finset (Fin k) β β} | |
| (h : β a β subsets k t, f a β€ g a) : uniformMean k t f β€ uniformMean k t g := by | |
| apply div_le_div_of_nonneg_right (Finset.sum_le_sum h) | |
| exact Nat.cast_nonneg _ | |
| theorem independentMean_mono {k t : β} {f g : Finset (Fin k) β Finset (Fin k) β β} | |
| (h : β a β subsets k t, β b β subsets k t, f a b β€ g a b) : | |
| independentMean k t f β€ independentMean k t g := by | |
| apply uniformMean_mono | |
| intro a ha | |
| apply uniformMean_mono | |
| exact h a ha | |
| theorem intersection_card_indicator {k : β} (a b : Finset (Fin k)) : | |
| ((a β© b).card : β) = β i β a, memberIndicator i b := by | |
| simp [memberIndicator] | |
| /-- Conditional expectation against any fixed first set, directly from the | |
| proved marginal inclusion probability of the independent second draw. -/ | |
| theorem expected_intersection_fixed {k t : β} (hk : 0 < k) (htk : t β€ k) | |
| (a : Finset (Fin k)) : | |
| uniformMean k t (fun b => ((a β© b).card : β)) = a.card * ((t : β) / k) := by | |
| simp_rw [intersection_card_indicator] | |
| rw [uniformMean_finset_sum] | |
| simp [inclusion_probability hk htk, nsmul_eq_mul] | |
| /-- Exact expected intersection size for independent uniform `t`-subsets. -/ | |
| theorem expected_intersection {k t : β} (hk : 0 < k) (htk : t β€ k) : | |
| independentMean k t (fun a b => ((a β© b).card : β)) = (t : β)^2 / k := by | |
| unfold independentMean | |
| simp_rw [expected_intersection_fixed hk htk] | |
| calc | |
| uniformMean k t (fun a => a.card * ((t : β) / k)) = | |
| uniformMean k t (fun _ => (t : β) * ((t : β) / k)) := by | |
| apply uniformMean_congr | |
| intro a ha | |
| have hcard : a.card = t := (Finset.mem_powersetCard.mp ha).2 | |
| rw [hcard] | |
| _ = (t : β) * ((t : β) / k) := uniformMean_const htk _ | |
| _ = (t : β)^2 / k := by ring | |
| /-- The pointwise first-moment bound for a nonempty intersection. -/ | |
| theorem nonempty_indicator_le_card {k : β} (a b : Finset (Fin k)) : | |
| (if (a β© b).Nonempty then (1 : β) else 0) β€ (a β© b).card := by | |
| split_ifs with h | |
| Β· exact_mod_cast (Finset.card_pos.mpr h) | |
| Β· exact Nat.cast_nonneg _ | |
| /-- The uniform-subset overlap bound used in the map-law comparison. -/ | |
| theorem overlap_probability_le {k t : β} (hk : 0 < k) (htk : t β€ k) : | |
| overlapProbability k t β€ (t : β)^2 / k := by | |
| calc | |
| overlapProbability k t β€ independentMean k t (fun a b => ((a β© b).card : β)) := | |
| independentMean_mono (fun a _ b _ => nonempty_indicator_le_card a b) | |
| _ = (t : β)^2 / k := expected_intersection hk htk | |
| end UniqueGamesTheorem.Soundness.SubsetIntersection | |
| end | |
| section | |
| namespace UniqueGamesTheorem.Soundness.PartnerSampling | |
| open scoped BigOperators | |
| open SubsetIntersection (subsets) | |
| /-- The literal support of the uniform active-set sample. -/ | |
| abbrev ActiveSet (k t : β) := β₯(subsets k t) | |
| /-- Each retained coordinate receives an independent slot in `Fin 3`. -/ | |
| abbrev Partner (k t : β) := Ξ£ a : ActiveSet k t, (β₯a.val β Fin 3) | |
| theorem activeSet_card {k t : β} (a : ActiveSet k t) : a.val.card = t := | |
| (Finset.mem_powersetCard.mp a.property).2 | |
| theorem slotTuples_card {k t : β} (a : ActiveSet k t) : | |
| Fintype.card (β₯a.val β Fin 3) = 3 ^ t := by | |
| simp [activeSet_card a] | |
| /-- Equal-size fibers prove that slot sampling does not change subset weights. -/ | |
| theorem partner_card (k t : β) : | |
| Fintype.card (Partner k t) = (subsets k t).card * 3 ^ t := by | |
| rw [Fintype.card_sigma] | |
| simp only [slotTuples_card, Finset.sum_const, Finset.card_univ, nsmul_eq_mul, | |
| Fintype.card_coe, Nat.cast_id] | |
| theorem partner_nonempty {k t : β} (htk : t β€ k) : Nonempty (Partner k t) := by | |
| obtain β¨a, haβ© := SubsetIntersection.subsets_nonempty htk | |
| exact β¨β¨β¨a, haβ©, fun _ => 0β©β© | |
| theorem uniformMean_real_cast (k t : β) (f : Finset (Fin k) β β) : | |
| (SubsetIntersection.uniformMean k t f : β) = | |
| (πΌ a β subsets k t, (f a : β)) := by | |
| rw [Finset.expect_eq_sum_div_card] | |
| simp [SubsetIntersection.uniformMean] | |
| theorem independentMean_real_cast (k t : β) | |
| (f : Finset (Fin k) β Finset (Fin k) β β) : | |
| (SubsetIntersection.independentMean k t f : β) = | |
| (πΌ a β subsets k t, πΌ b β subsets k t, (f a b : β)) := by | |
| simp only [SubsetIntersection.independentMean, uniformMean_real_cast] | |
| /-- Real `Finset.expect` form of the already-proved rational subset bound. -/ | |
| theorem subset_overlap_probability_le {k t : β} (hk : 0 < k) (htk : t β€ k) : | |
| (πΌ a β subsets k t, πΌ b β subsets k t, | |
| if (a β© b).Nonempty then (1 : β) else 0) β€ (t : β)^2 / k := by | |
| have h : (SubsetIntersection.overlapProbability k t : β) β€ (t : β)^2 / k := by | |
| have h := SubsetIntersection.overlap_probability_le hk htk | |
| have hh := (Rat.cast_le (K := β)).mpr h | |
| simpa using hh | |
| simpa only [SubsetIntersection.overlapProbability, independentMean_real_cast, | |
| apply_ite, Rat.cast_one, Rat.cast_zero] using h | |
| theorem activeSet_expect (k t : β) (f : Finset (Fin k) β β) : | |
| (πΌ a : ActiveSet k t, f a.val) = (πΌ a β subsets k t, f a) := by | |
| simp only [Finset.expect_eq_sum_div_card, Finset.card_univ, Fintype.card_coe, | |
| Finset.sum_coe_sort] | |
| /-- The uniform full-partner law projects to the uniform active-subset law. -/ | |
| theorem partner_expect_activeSet (k t : β) (f : ActiveSet k t β β) : | |
| (πΌ p : Partner k t, f p.1) = (πΌ a : ActiveSet k t, f a) := by | |
| have hsum : (β p : Partner k t, f p.1) = (3 : β)^t * β a : ActiveSet k t, f a := by | |
| rw [Fintype.sum_sigma] | |
| simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, slotTuples_card, | |
| Nat.cast_pow, Nat.cast_ofNat] | |
| rw [Finset.mul_sum] | |
| rw [Fintype.expect_eq_sum_div_card, Fintype.expect_eq_sum_div_card, hsum, partner_card] | |
| simp only [Nat.cast_mul, Nat.cast_pow, Nat.cast_ofNat, Fintype.card_coe] | |
| have hc : (3 : β)^t β 0 := pow_ne_zero _ (by norm_num) | |
| simpa only [mul_comm] using | |
| (mul_div_mul_left (β a : ActiveSet k t, f a) ((subsets k t).card : β) hc) | |
| theorem partner_expect_active (k t : β) (f : Finset (Fin k) β β) : | |
| (πΌ p : Partner k t, f p.1.val) = (πΌ a β subsets k t, f a) := by | |
| rw [partner_expect_activeSet k t (fun a => f a.val), activeSet_expect] | |
| theorem partner_pair_expect_active (k t : β) | |
| (f : Finset (Fin k) β Finset (Fin k) β β) : | |
| (πΌ p : Partner k t, πΌ q : Partner k t, f p.1.val q.1.val) = | |
| (πΌ a β subsets k t, πΌ b β subsets k t, f a b) := by | |
| calc | |
| _ = πΌ p : Partner k t, πΌ b β subsets k t, f p.1.val b := by | |
| apply Finset.expect_congr rfl | |
| intro p _ | |
| exact partner_expect_active k t (fun b => f p.1.val b) | |
| _ = _ := partner_expect_active k t (fun a => πΌ b β subsets k t, f a b) | |
| /-- The independently drawn full partners obey the same active-overlap bound. -/ | |
| theorem partner_active_overlap_probability_le {k t : β} (hk : 0 < k) (htk : t β€ k) : | |
| (πΌ p : Partner k t, πΌ q : Partner k t, | |
| if (p.1.val β© q.1.val).Nonempty then (1 : β) else 0) β€ (t : β)^2 / k := by | |
| rw [partner_pair_expect_active k t (fun a b => if (a β© b).Nonempty then (1 : β) else 0)] | |
| exact subset_overlap_probability_le hk htk | |
| def active {k t : β} (p : Partner k t) (j : Fin k) : Bool := | |
| decide (j β p.1.val) | |
| def decodeSlot (i : Fin 3) : PartnerProjection.Slot := | |
| if i.val = 0 then .first else if i.val = 1 then .second else .third | |
| def slots {k t : β} (p : Partner k t) (j : Fin k) : PartnerProjection.Slot := | |
| if hj : j β p.1.val then decodeSlot (p.2 β¨j, hjβ©) else .first | |
| noncomputable def kernel {k t : β} (rhs : Fin k β Bool) (p : Partner k t) : | |
| Submodule (ZMod 2) (PartnerProjection.SourcePoint rhs) := | |
| (PartnerLinear.projection rhs (active p) (slots p)).ker | |
| def activeSubtypeEquiv {k t : β} (p : Partner k t) : | |
| PartnerLinear.Active (active p) β β₯p.1.val := | |
| Equiv.subtypeEquivRight (fun j => by simp [active]) | |
| theorem kernel_finrank {k t : β} (rhs : Fin k β Bool) (p : Partner k t) : | |
| Module.finrank (ZMod 2) (kernel rhs p) = t := by | |
| rw [kernel, PartnerLinear.projection_ker_finrank] | |
| calc | |
| Fintype.card (PartnerLinear.Active (active p)) = Fintype.card β₯p.1.val := | |
| Fintype.card_congr (activeSubtypeEquiv p) | |
| _ = t := by simpa using activeSet_card p.1 | |
| theorem kernel_inf_finrank_le {k t : β} (rhs : Fin k β Bool) (p q : Partner k t) : | |
| Module.finrank (ZMod 2) β₯(kernel rhs p β kernel rhs q : Submodule (ZMod 2) (PartnerProjection.SourcePoint rhs)) β€ t := by | |
| calc | |
| Module.finrank (ZMod 2) β₯(kernel rhs p β kernel rhs q : Submodule (ZMod 2) (PartnerProjection.SourcePoint rhs)) β€ | |
| Module.finrank (ZMod 2) (kernel rhs p) := Submodule.finrank_mono inf_le_left | |
| _ = t := kernel_finrank rhs p | |
| theorem kernel_inf_eq_bot_of_no_overlap {k t : β} | |
| (rhs : Fin k β Bool) (p q : Partner k t) | |
| (h : Β¬ (p.1.val β© q.1.val).Nonempty) : | |
| kernel rhs p β kernel rhs q = β₯ := by | |
| apply PartnerLinear.disjoint_projection_kernels | |
| rhs (active p) (slots p) (active q) (slots q) | |
| intro j hj | |
| have hp : j β p.1.val := by simpa [active] using hj | |
| have hq : j β q.1.val := by | |
| intro hq | |
| exact h β¨j, Finset.mem_inter.mpr β¨hp, hqβ©β© | |
| simp [active, hq] | |
| def activeOverlap {k t : β} (p q : Partner k t) : β := | |
| if (p.1.val β© q.1.val).Nonempty then 1 else 0 | |
| noncomputable def kernelCollision {k t : β} | |
| (rhs : Fin k β Bool) (p q : Partner k t) : β := by | |
| classical | |
| exact if kernel rhs p β kernel rhs q β β₯ then 1 else 0 | |
| theorem kernelCollision_le_activeOverlap {k t : β} | |
| (rhs : Fin k β Bool) (p q : Partner k t) : | |
| kernelCollision rhs p q β€ activeOverlap p q := by | |
| classical | |
| by_cases h : (p.1.val β© q.1.val).Nonempty | |
| Β· simp only [activeOverlap, ite_eq_left h, kernelCollision] | |
| split_ifs <;> norm_num | |
| Β· have hb := kernel_inf_eq_bot_of_no_overlap rhs p q h | |
| simp [kernelCollision, activeOverlap, h, hb] | |
| theorem kernel_collision_probability_le {k t : β} | |
| (hk : 0 < k) (htk : t β€ k) (rhs : Fin k β Bool) : | |
| (πΌ p : Partner k t, πΌ q : Partner k t, | |
| kernelCollision rhs p q) β€ (t : β)^2 / k := by | |
| calc | |
| (πΌ p : Partner k t, πΌ q : Partner k t, kernelCollision rhs p q) β€ | |
| (πΌ p : Partner k t, πΌ q : Partner k t, activeOverlap p q) := by | |
| apply Finset.expect_le_expect | |
| intro p _ | |
| apply Finset.expect_le_expect | |
| intro q _ | |
| exact kernelCollision_le_activeOverlap rhs p q | |
| _ β€ (t : β)^2 / k := partner_active_overlap_probability_le hk htk | |
| theorem kernel_overlap_weight_pointwise {k t : β} | |
| (rhs : Fin k β Bool) (m : β) (p q : Partner k t) : | |
| (2 : β) ^ (m * Module.finrank (ZMod 2) β₯(kernel rhs p β kernel rhs q : Submodule (ZMod 2) (PartnerProjection.SourcePoint rhs))) β€ | |
| 1 + activeOverlap p q * (2 : β) ^ (m * t) := by | |
| have hcap : | |
| (2 : β) ^ (m * Module.finrank (ZMod 2) β₯(kernel rhs p β kernel rhs q : Submodule (ZMod 2) (PartnerProjection.SourcePoint rhs))) β€ | |
| (2 : β) ^ (m * t) := by | |
| apply pow_le_pow_rightβ (by norm_num : (1 : β) β€ 2) | |
| exact Nat.mul_le_mul_left m (kernel_inf_finrank_le rhs p q) | |
| by_cases h : (p.1.val β© q.1.val).Nonempty | |
| Β· simp only [activeOverlap, ite_eq_left h, one_mul] | |
| linarith | |
| Β· have hb := kernel_inf_eq_bot_of_no_overlap rhs p q h | |
| rw [hb] | |
| simp [activeOverlap, h] | |
| theorem kernel_overlap_weight_le {k t : β} | |
| (hk : 0 < k) (htk : t β€ k) (rhs : Fin k β Bool) (m : β) : | |
| (πΌ p : Partner k t, πΌ q : Partner k t, | |
| (2 : β) ^ (m * Module.finrank (ZMod 2) β₯(kernel rhs p β kernel rhs q : Submodule (ZMod 2) (PartnerProjection.SourcePoint rhs)))) β€ | |
| 1 + ((t : β)^2 / k) * (2 : β) ^ (m * t) := by | |
| let : Nonempty (Partner k t) := partner_nonempty htk | |
| have hmean : | |
| (πΌ p : Partner k t, πΌ q : Partner k t, | |
| (1 + activeOverlap p q * (2 : β) ^ (m * t))) = | |
| 1 + (πΌ p : Partner k t, πΌ q : Partner k t, activeOverlap p q) * | |
| (2 : β) ^ (m * t) := by | |
| simp_rw [Finset.expect_add_distrib, β Finset.expect_mul, Fintype.expect_const] | |
| calc | |
| (πΌ p : Partner k t, πΌ q : Partner k t, | |
| (2 : β) ^ (m * Module.finrank (ZMod 2) β₯(kernel rhs p β kernel rhs q : Submodule (ZMod 2) (PartnerProjection.SourcePoint rhs)))) β€ | |
| (πΌ p : Partner k t, πΌ q : Partner k t, | |
| (1 + activeOverlap p q * (2 : β) ^ (m * t))) := by | |
| apply Finset.expect_le_expect | |
| intro p _ | |
| apply Finset.expect_le_expect | |
| intro q _ | |
| exact kernel_overlap_weight_pointwise rhs m p q | |
| _ = 1 + (πΌ p : Partner k t, πΌ q : Partner k t, activeOverlap p q) * | |
| (2 : β) ^ (m * t) := hmean | |
| _ β€ 1 + ((t : β)^2 / k) * (2 : β) ^ (m * t) := by | |
| apply add_le_add le_rfl | |
| apply mul_le_mul_of_nonneg_right | |
| Β· exact partner_active_overlap_probability_le hk htk | |
| Β· exact pow_nonneg (by norm_num) _ | |
| end UniqueGamesTheorem.Soundness.PartnerSampling | |
| end | |
| section | |
| /-! Lemma 6.3 for the actual independently sampled partner maps. -/ | |
| namespace UniqueGamesTheorem.Soundness.ActualMapComparison | |
| open LinearMapDensity PartnerProjection PartnerSampling | |
| theorem actual_partner_expectation_comparison {k t : β} | |
| (hk : 0 < k) (htk : t β€ k) (rhs : Fin k β Bool) | |
| {R : Type} [AddCommGroup R] [Module (ZMod 2) R] [FiniteDimensional (ZMod 2) R] | |
| [Fintype (SourcePoint rhs ββ[ZMod 2] R)] | |
| [β p : Partner k t, Fintype (PartnerPoint rhs (active p) ββ[ZMod 2] R)] | |
| (H : (SourcePoint rhs ββ[ZMod 2] R) β β) (hH : β M, |H M| β€ 1) : | |
| |uniformMean (fun p : Partner k t => | |
| uniformMean (fun B : PartnerPoint rhs (active p) ββ[ZMod 2] R => | |
| H (B.comp (PartnerLinear.projection rhs (active p) (slots p))))) - uniformMean H| β€ | |
| Real.sqrt (((t : β)^2 / k) * (2 : β)^(Module.finrank (ZMod 2) R * t)) := by | |
| let : Nonempty (Partner k t) := partner_nonempty htk | |
| have hsecond : | |
| uniformMean (fun M : SourcePoint rhs ββ[ZMod 2] R => | |
| (mixtureDensity (kernel (t := t) rhs) M)^2) β€ | |
| 1 + ((t : β)^2 / k) * (2 : β)^(Module.finrank (ZMod 2) R * t) := by | |
| rw [mixtureDensity_second_moment] | |
| exact kernel_overlap_weight_le hk htk rhs (Module.finrank (ZMod 2) R) | |
| have hc := ExpectationComparison.bounded_test_expectation_comparison | |
| Finset.univ Finset.univ_nonempty (mixtureDensity (R := R) (kernel (t := t) rhs)) H | |
| (((t : β)^2 / k) * (2 : β)^(Module.finrank (ZMod 2) R * t)) | |
| (mixtureDensity_mean (R := R) (kernel (t := t) rhs)) hsecond (fun M _ => hH M) | |
| rw [mixture_pullback_uniformMean | |
| (fun p : Partner k t => PartnerLinear.projection rhs (active p) (slots p)) | |
| (fun p => PartnerLinear.projection_surjective rhs (active p) (slots p)) H] | |
| have hkernel : kernel (t := t) rhs = | |
| (fun p : Partner k t => (PartnerLinear.projection rhs (active p) (slots p)).ker) := rfl | |
| rw [hkernel] at hc | |
| simpa only [uniformMean, mul_comm] using hc | |
| theorem actual_partner_expectation_comparison_dimension {k t L : β} | |
| (hk : 0 < k) (htk : t β€ k) (rhs : Fin k β Bool) | |
| {R : Type} [AddCommGroup R] [Module (ZMod 2) R] [FiniteDimensional (ZMod 2) R] | |
| [Fintype (SourcePoint rhs ββ[ZMod 2] R)] | |
| [β p : Partner k t, Fintype (PartnerPoint rhs (active p) ββ[ZMod 2] R)] | |
| (H : (SourcePoint rhs ββ[ZMod 2] R) β β) (hH : β M, |H M| β€ 1) | |
| (hm : Module.finrank (ZMod 2) R β€ L) : | |
| |uniformMean (fun p : Partner k t => | |
| uniformMean (fun B : PartnerPoint rhs (active p) ββ[ZMod 2] R => | |
| H (B.comp (PartnerLinear.projection rhs (active p) (slots p))))) - uniformMean H| β€ | |
| Real.sqrt (((t : β)^2 / k) * (2 : β)^(t * L)) := by | |
| have he : Module.finrank (ZMod 2) R * t β€ t * L := by | |
| simpa only [Nat.mul_comm] using Nat.mul_le_mul_right t hm | |
| have hp : (2 : β)^(Module.finrank (ZMod 2) R * t) β€ (2 : β)^(t*L) := | |
| pow_le_pow_rightβ (by norm_num) he | |
| exact (actual_partner_expectation_comparison hk htk rhs H hH).trans | |
| (Real.sqrt_le_sqrt (mul_le_mul_of_nonneg_left hp | |
| (div_nonneg (sq_nonneg (t : β)) (Nat.cast_nonneg k)))) | |
| theorem actual_partner_expectation_quarter {k t L : β} {ΞΈ : β} | |
| (hk : 0 < k) (htk : t β€ k) (rhs : Fin k β Bool) | |
| {R : Type} [AddCommGroup R] [Module (ZMod 2) R] [FiniteDimensional (ZMod 2) R] | |
| [Fintype (SourcePoint rhs ββ[ZMod 2] R)] | |
| [β p : Partner k t, Fintype (PartnerPoint rhs (active p) ββ[ZMod 2] R)] | |
| (H : (SourcePoint rhs ββ[ZMod 2] R) β β) (hH : β M, |H M| β€ 1) | |
| (hm : Module.finrank (ZMod 2) R β€ L) (hΞΈ : 0 β€ ΞΈ) | |
| (budget : 16 * (t : β)^2 * 2^(t*L) β€ (k : β)*ΞΈ^2) : | |
| |uniformMean (fun p : Partner k t => | |
| uniformMean (fun B : PartnerPoint rhs (active p) ββ[ZMod 2] R => | |
| H (B.comp (PartnerLinear.projection rhs (active p) (slots p))))) - uniformMean H| β€ | |
| (ΞΈ : β) / 4 := | |
| (actual_partner_expectation_comparison_dimension hk htk rhs H hH hm).trans | |
| (ExpectationComparison.comparison_error_le_quarter _ _ (by exact_mod_cast hΞΈ) | |
| (Integration.RealBounds.comparison_square_budget hk budget)) | |
| end UniqueGamesTheorem.Soundness.ActualMapComparison | |
| end | |
| section | |
| /-! | |
| Uniform indices at all positions restrict to uniform indices on an active set. | |
| The explicit restriction/complement equivalence proves this sampling fact. The | |
| dependent partner average then equals sampling the active set followed by all | |
| slot indices, including unused indices outside the active set. Finally, the | |
| coordinatewise occurrence/slot draw is related to that same law. | |
| -/ | |
| namespace UniqueGamesTheorem.Soundness.PartnerFullSampling | |
| open scoped BigOperators | |
| open PartnerSampling | |
| noncomputable section | |
| def restrictIndices {P X : Type*} (J : Finset P) (indices : P β X) : β₯J β X := | |
| fun j => indices j.val | |
| /-- The values inside and outside a finite set reconstruct the full tuple. -/ | |
| def restrictionProductEquiv {P X : Type*} [DecidableEq P] (J : Finset P) : | |
| (P β X) β ((β₯J β X) Γ ({j : P // j β J} β X)) where | |
| toFun indices := (restrictIndices J indices, fun j => indices j.val) | |
| invFun parts := fun j => | |
| if hj : j β J then parts.1 β¨j, hjβ© else parts.2 β¨j, hjβ© | |
| left_inv indices := by | |
| funext j | |
| by_cases hj : j β J <;> simp [restrictIndices, hj] | |
| right_inv parts := by | |
| apply Prod.ext | |
| Β· funext j | |
| simp [restrictIndices, j.property] | |
| Β· funext j | |
| simp [j.property] | |
| /-- Marginalizing the nonempty complement tuple gives the exact uniform law | |
| on the active coordinates. This includes an empty active set or complement. -/ | |
| theorem expect_restrictIndices {P X : Type*} [Fintype P] [DecidableEq P] | |
| [Fintype X] [Nonempty X] (J : Finset P) (h : (β₯J β X) β β) : | |
| (πΌ indices : P β X, h (restrictIndices J indices)) = | |
| πΌ activeIndices : β₯J β X, h activeIndices := by | |
| calc | |
| (πΌ indices : P β X, h (restrictIndices J indices)) = | |
| πΌ parts : (β₯J β X) Γ ({j : P // j β J} β X), h parts.1 := | |
| Fintype.expect_equiv (restrictionProductEquiv J) _ _ (fun _ => rfl) | |
| _ = πΌ activeIndices : β₯J β X, h activeIndices := by | |
| simpa only [Finset.univ_product_univ, Fintype.expect_const] using | |
| (Finset.expect_product (Finset.univ : Finset (β₯J β X)) | |
| (Finset.univ : Finset ({j : P // j β J} β X)) | |
| (fun parts => h parts.1)) | |
| def fromFullIndices {k t : β} (a : ActiveSet k t) (indices : Fin k β Fin 3) : | |
| Partner k t := β¨a, restrictIndices a.val indicesβ© | |
| /-- Fixed-active-set form of the actual three-way slot sampling identity. -/ | |
| theorem fixed_active_expect_fullIndices {k t : β} (a : ActiveSet k t) | |
| (h : (β₯a.val β Fin 3) β β) : | |
| (πΌ indices : Fin k β Fin 3, h (restrictIndices a.val indices)) = | |
| πΌ activeIndices : β₯a.val β Fin 3, h activeIndices := | |
| expect_restrictIndices a.val h | |
| /-- All active-set fibers have `3^t` elements, so the uniform dependent-pair | |
| average is the active-set average of the uniform slot average. -/ | |
| theorem partner_expect_active_slots (k t : β) (f : Partner k t β β) : | |
| (πΌ p : Partner k t, f p) = | |
| πΌ a : ActiveSet k t, πΌ indices : β₯a.val β Fin 3, f β¨a, indicesβ© := by | |
| simp only [Fintype.expect_eq_sum_div_card, Fintype.sum_sigma, | |
| slotTuples_card, partner_card, Fintype.card_coe, | |
| Nat.cast_mul, Nat.cast_pow, Nat.cast_ofNat] | |
| rw [β Finset.sum_div, div_div] | |
| congr 1 | |
| exact mul_comm _ _ | |
| /-- The full-index experiment has exactly the existing `Partner` law. | |
| No independence or equality of probability laws is assumed. -/ | |
| theorem partner_expect_fullIndices (k t : β) (f : Partner k t β β) : | |
| (πΌ p : Partner k t, f p) = | |
| πΌ a : ActiveSet k t, πΌ indices : Fin k β Fin 3, | |
| f (fromFullIndices a indices) := by | |
| rw [partner_expect_active_slots] | |
| apply Finset.expect_congr rfl | |
| intro a _ | |
| exact (fixed_active_expect_fullIndices a (fun indices => f β¨a, indicesβ©)).symm | |
| /-- Slots outside active positions have no effect on the genuine projection. -/ | |
| theorem projection_eq_of_slots_eq_on_active {P : Type} | |
| (rhs active : P β Bool) (slot slot' : P β PartnerProjection.Slot) | |
| (hslot : β j, active j = true β slot j = slot' j) : | |
| PartnerLinear.projection rhs active slot = | |
| PartnerLinear.projection rhs active slot' := by | |
| apply LinearMap.ext | |
| intro x | |
| change PartnerProjection.project rhs active slot x = | |
| PartnerProjection.project rhs active slot' x | |
| apply PartnerProjection.partner_ext rhs active | |
| Β· rfl | |
| Β· rfl | |
| Β· funext j | |
| by_cases hj : active j = true | |
| Β· simp [PartnerProjection.project, hj, hslot j hj] | |
| Β· simp [PartnerProjection.project, hj] | |
| /-- Defaulting inactive slots to `.first` gives the same map as retaining all | |
| the independently sampled full indices. -/ | |
| theorem projection_fromFullIndices {k t : β} (rhs : Fin k β Bool) | |
| (a : ActiveSet k t) (indices : Fin k β Fin 3) : | |
| PartnerLinear.projection rhs (active (fromFullIndices a indices)) | |
| (slots (fromFullIndices a indices)) = | |
| PartnerLinear.projection rhs (active (fromFullIndices a indices)) | |
| (fun j => decodeSlot (indices j)) := by | |
| apply projection_eq_of_slots_eq_on_active | |
| intro j hj | |
| have hmem : j β a.val := by | |
| change decide (j β a.val) = true at hj | |
| exact of_decide_eq_true hj | |
| simp [slots, fromFullIndices, restrictIndices, hmem] | |
| /-- Drawing an occurrence and a slot at each position is the same finite | |
| sample space as drawing the occurrence tuple and the slot tuple separately. -/ | |
| def drawProductEquiv {P Id : Type*} : | |
| (P β Id Γ Fin 3) β ((P β Id) Γ (P β Fin 3)) where | |
| toFun draw := (fun j => (draw j).1, fun j => (draw j).2) | |
| invFun parts := fun j => (parts.1 j, parts.2 j) | |
| left_inv draw := by funext j; rfl | |
| right_inv parts := by | |
| apply Prod.ext <;> funext j <;> rfl | |
| /-- The raw occurrence/slot draw induces independent uniform occurrences and | |
| uniform active slots, with all unused slot choices marginalized exactly. -/ | |
| theorem fixed_active_rawDraw_expect {k t : β} {Id : Type*} [Fintype Id] | |
| (a : ActiveSet k t) | |
| (f : (Fin k β Id) β (β₯a.val β Fin 3) β β) : | |
| (πΌ draw : Fin k β Id Γ Fin 3, | |
| f (fun j => (draw j).1) | |
| (restrictIndices a.val (fun j => (draw j).2))) = | |
| πΌ occurrence : Fin k β Id, πΌ indices : β₯a.val β Fin 3, | |
| f occurrence indices := by | |
| calc | |
| (πΌ draw : Fin k β Id Γ Fin 3, | |
| f (fun j => (draw j).1) | |
| (restrictIndices a.val (fun j => (draw j).2))) = | |
| πΌ parts : (Fin k β Id) Γ (Fin k β Fin 3), | |
| f parts.1 (restrictIndices a.val parts.2) := | |
| Fintype.expect_equiv drawProductEquiv _ _ (fun _ => rfl) | |
| _ = πΌ occurrence : Fin k β Id, πΌ indices : Fin k β Fin 3, | |
| f occurrence (restrictIndices a.val indices) := by | |
| simpa only [Finset.univ_product_univ] using | |
| (Finset.expect_product (Finset.univ : Finset (Fin k β Id)) | |
| (Finset.univ : Finset (Fin k β Fin 3)) | |
| (fun parts => f parts.1 (restrictIndices a.val parts.2))) | |
| _ = πΌ occurrence : Fin k β Id, πΌ indices : β₯a.val β Fin 3, | |
| f occurrence indices := by | |
| apply Finset.expect_congr rfl | |
| intro occurrence _ | |
| exact fixed_active_expect_fullIndices a (f occurrence) | |
| /-- The actual raw draw, including indices outside the active set, agrees | |
| with the occurrence-then-partner experiment for every real test function. -/ | |
| theorem occurrence_partner_expect_eq_rawDraw (k t : β) | |
| {Id : Type*} [Fintype Id] (f : (Fin k β Id) β Partner k t β β) : | |
| (πΌ occurrence : Fin k β Id, πΌ p : Partner k t, f occurrence p) = | |
| πΌ a : ActiveSet k t, πΌ draw : Fin k β Id Γ Fin 3, | |
| f (fun j => (draw j).1) (fromFullIndices a (fun j => (draw j).2)) := by | |
| symm | |
| calc | |
| (πΌ a : ActiveSet k t, πΌ draw : Fin k β Id Γ Fin 3, | |
| f (fun j => (draw j).1) (fromFullIndices a (fun j => (draw j).2))) = | |
| πΌ a : ActiveSet k t, πΌ occurrence : Fin k β Id, | |
| πΌ indices : β₯a.val β Fin 3, f occurrence β¨a, indicesβ© := by | |
| apply Finset.expect_congr rfl | |
| intro a _ | |
| exact fixed_active_rawDraw_expect a (fun occurrence indices => f occurrence β¨a, indicesβ©) | |
| _ = πΌ occurrence : Fin k β Id, πΌ a : ActiveSet k t, | |
| πΌ indices : β₯a.val β Fin 3, f occurrence β¨a, indicesβ© := | |
| Finset.expect_comm _ _ _ | |
| _ = πΌ occurrence : Fin k β Id, πΌ p : Partner k t, f occurrence p := by | |
| apply Finset.expect_congr rfl | |
| intro occurrence _ | |
| exact (partner_expect_active_slots k t (f occurrence)).symm | |
| end | |
| end UniqueGamesTheorem.Soundness.PartnerFullSampling | |
| end | |
| section | |
| namespace UniqueGamesTheorem.Soundness.ActualMapComparison | |
| def sourcePrecomposeEquiv {A E R : Type} | |
| [AddCommGroup A] [Module (ZMod 2) A] [AddCommGroup E] [Module (ZMod 2) E] | |
| [AddCommGroup R] [Module (ZMod 2) R] (e : A ββ[ZMod 2] E) : | |
| (E ββ[ZMod 2] R) β (A ββ[ZMod 2] R) where | |
| toFun M := M.comp e.toLinearMap | |
| invFun M := M.comp e.symm.toLinearMap | |
| left_inv M := by | |
| apply LinearMap.ext | |
| intro x | |
| change M (e (e.symm x)) = M x | |
| rw [e.apply_symm_apply] | |
| right_inv M := by | |
| apply LinearMap.ext | |
| intro x | |
| change M (e.symm (e x)) = M x | |
| rw [e.symm_apply_apply] | |
| theorem uniformMean_sourcePrecompose {A E R : Type} | |
| [AddCommGroup A] [Module (ZMod 2) A] [AddCommGroup E] [Module (ZMod 2) E] | |
| [AddCommGroup R] [Module (ZMod 2) R] | |
| [Fintype (A ββ[ZMod 2] R)] [Fintype (E ββ[ZMod 2] R)] | |
| (e : A ββ[ZMod 2] E) (H : (E ββ[ZMod 2] R) β β) : | |
| LinearMapDensity.uniformMean (fun M : A ββ[ZMod 2] R => | |
| H (M.comp e.symm.toLinearMap)) = LinearMapDensity.uniformMean H := by | |
| simpa only [LinearMapDensity.uniformMean] using | |
| (Fintype.expect_equiv (sourcePrecomposeEquiv e).symm | |
| (fun M : A ββ[ZMod 2] R => H (M.comp e.symm.toLinearMap)) H (fun _ => rfl)) | |
| theorem actual_partner_expectation_quarter_equiv {k t L : β} {ΞΈ : β} | |
| (hk : 0 < k) (htk : t β€ k) (rhs : Fin k β Bool) | |
| {R E : Type} [AddCommGroup R] [Module (ZMod 2) R] [FiniteDimensional (ZMod 2) R] | |
| [AddCommGroup E] [Module (ZMod 2) E] | |
| [Fintype (PartnerProjection.SourcePoint rhs ββ[ZMod 2] R)] | |
| [Fintype (E ββ[ZMod 2] R)] | |
| [β p : PartnerSampling.Partner k t, | |
| Fintype (PartnerProjection.PartnerPoint rhs (PartnerSampling.active p) ββ[ZMod 2] R)] | |
| (e : PartnerProjection.SourcePoint rhs ββ[ZMod 2] E) | |
| (H : (E ββ[ZMod 2] R) β β) (hH : β M, |H M| β€ 1) | |
| (hm : Module.finrank (ZMod 2) R β€ L) (hΞΈ : 0 β€ ΞΈ) | |
| (budget : 16 * (t : β)^2 * 2^(t*L) β€ (k : β) * ΞΈ^2) : | |
| |LinearMapDensity.uniformMean (fun p : PartnerSampling.Partner k t => | |
| LinearMapDensity.uniformMean (fun B : | |
| PartnerProjection.PartnerPoint rhs (PartnerSampling.active p) ββ[ZMod 2] R => | |
| H (B.comp ((PartnerLinear.projection rhs (PartnerSampling.active p) | |
| (PartnerSampling.slots p)).comp e.symm.toLinearMap)))) - | |
| LinearMapDensity.uniformMean H| β€ (ΞΈ : β) / 4 := by | |
| let Hcanon : (PartnerProjection.SourcePoint rhs ββ[ZMod 2] R) β β := | |
| fun M => H (M.comp e.symm.toLinearMap) | |
| have hcanon := actual_partner_expectation_quarter hk htk rhs Hcanon | |
| (fun M => hH (M.comp e.symm.toLinearMap)) hm hΞΈ budget | |
| have hmean : LinearMapDensity.uniformMean Hcanon = LinearMapDensity.uniformMean H := | |
| uniformMean_sourcePrecompose e H | |
| rw [hmean] at hcanon | |
| simpa only [Hcanon, LinearMap.comp_assoc] using hcanon | |
| end UniqueGamesTheorem.Soundness.ActualMapComparison | |
| end | |
| section | |
| /-! Exact finite uniform conditioning and total expectation, including empty fibres. -/ | |
| namespace UniqueGamesTheorem.Soundness.UniformPartition | |
| open scoped BigOperators | |
| noncomputable section | |
| def mean {Ξ© : Type} [Fintype Ξ©] (g : Ξ© β β) : β := | |
| (β Ο, g Ο) / Fintype.card Ξ© | |
| theorem mean_equiv {Ξ© Ξ : Type} [Fintype Ξ©] [Fintype Ξ] | |
| (e : Ξ© β Ξ) (g : Ξ β β) : mean (fun Ο => g (e Ο)) = mean g := by | |
| unfold mean | |
| rw [e.sum_comp, Fintype.card_congr e] | |
| def fiberSum {Ξ© H : Type} [Fintype Ξ©] [DecidableEq H] | |
| (f : Ξ© β H) (h : H) (g : Ξ© β β) : β := | |
| β Ο, if f Ο = h then g Ο else 0 | |
| def fiberSize {Ξ© H : Type} [Fintype Ξ©] [DecidableEq H] | |
| (f : Ξ© β H) (h : H) : β := fiberSum f h (fun _ => 1) | |
| theorem fiberSize_eq_card {Ξ© H : Type} [Fintype Ξ©] [DecidableEq H] | |
| (f : Ξ© β H) (h : H) : | |
| fiberSize f h = ((Finset.univ.filter (fun Ο => f Ο = h)).card : β) := by | |
| classical | |
| unfold fiberSize fiberSum | |
| rw [β Finset.sum_filter] | |
| simp | |
| theorem sum_fiberSum {Ξ© H : Type} [Fintype Ξ©] [Fintype H] [DecidableEq H] | |
| (f : Ξ© β H) (g : Ξ© β β) : | |
| (β h, fiberSum f h g) = β Ο, g Ο := by | |
| unfold fiberSum | |
| rw [Finset.sum_comm] | |
| apply Finset.sum_congr rfl | |
| intro Ο _ | |
| simp | |
| theorem fiberSize_mul {Ξ© H : Type} [Fintype Ξ©] [DecidableEq H] | |
| (f : Ξ© β H) (b : H β β) (h : H) : | |
| fiberSize f h * b h = fiberSum f h (fun Ο => b (f Ο)) := by | |
| unfold fiberSize fiberSum | |
| rw [Finset.sum_mul] | |
| apply Finset.sum_congr rfl | |
| intro Ο _ | |
| by_cases hΟ : f Ο = h <;> simp [hΟ] | |
| theorem fiberSize_pos {Ξ© H : Type} [Fintype Ξ©] [DecidableEq H] | |
| (f : Ξ© β H) (h : H) (hh : β Ο, f Ο = h) : 0 < fiberSize f h := by | |
| classical | |
| obtain β¨Ο, hΟβ© := hh | |
| rw [fiberSize_eq_card] | |
| have hc : 0 < (Finset.univ.filter (fun Ο => f Ο = h)).card := | |
| Finset.card_pos.mpr β¨Ο, by simp [hΟ]β© | |
| exact_mod_cast hc | |
| theorem fiberSize_mul_conditional {Ξ© H : Type} [Fintype Ξ©] [DecidableEq H] | |
| (f : Ξ© β H) (g : Ξ© β β) (h : H) : | |
| fiberSize f h * (fiberSum f h g / fiberSize f h) = fiberSum f h g := by | |
| classical | |
| by_cases hh : β Ο, f Ο = h | |
| Β· have hn : fiberSize f h β 0 := ne_of_gt (fiberSize_pos f h hh) | |
| field_simp [hn] | |
| Β· have hz : β Ο, f Ο β h := fun Ο hΟ => hh β¨Ο, hΟβ© | |
| simp [fiberSize, fiberSum, hz] | |
| theorem total_mean {Ξ© H : Type} [Fintype Ξ©] [Fintype H] [DecidableEq H] | |
| (f : Ξ© β H) (g : Ξ© β β) : | |
| mean g = mean (fun Ο => fiberSum f (f Ο) g / fiberSize f (f Ο)) := by | |
| let b : H β β := fun h => fiberSum f h g / fiberSize f h | |
| change mean g = mean (fun Ο => b (f Ο)) | |
| unfold mean | |
| apply congrArg (fun x : β => x / (Fintype.card Ξ© : β)) | |
| calc | |
| (β Ο, g Ο) = β h, fiberSum f h g := (sum_fiberSum f g).symm | |
| _ = β h, fiberSize f h * b h := by | |
| apply Finset.sum_congr rfl | |
| intro h _ | |
| exact (fiberSize_mul_conditional f g h).symm | |
| _ = β h, fiberSum f h (fun Ο => b (f Ο)) := by | |
| apply Finset.sum_congr rfl | |
| intro h _ | |
| exact fiberSize_mul f b h | |
| _ = β Ο, b (f Ο) := sum_fiberSum f (fun Ο => b (f Ο)) | |
| theorem mean_mono {Ξ© : Type} [Fintype Ξ©] {g g' : Ξ© β β} | |
| (h : β Ο, g Ο β€ g' Ο) : mean g β€ mean g' := by | |
| exact div_le_div_of_nonneg_right (Finset.sum_le_sum (fun Ο _ => h Ο)) (Nat.cast_nonneg _) | |
| theorem mean_le_partition_bound {Ξ© H : Type} | |
| [Fintype Ξ©] [Fintype H] [DecidableEq H] | |
| (f : Ξ© β H) (g : Ξ© β β) (bound : H β β) | |
| (hlocal : β h, (β Ο, f Ο = h) β | |
| fiberSum f h g / fiberSize f h β€ bound h) : | |
| mean g β€ mean (fun Ο => bound (f Ο)) := by | |
| calc | |
| mean g = mean (fun Ο => fiberSum f (f Ο) g / fiberSize f (f Ο)) := total_mean f g | |
| _ β€ mean (fun Ο => bound (f Ο)) := mean_mono (fun Ο => hlocal (f Ο) β¨Ο,rflβ©) | |
| theorem fiber_conditional_eq_subtype_mean {Ξ© H : Type} | |
| [Fintype Ξ©] [DecidableEq H] (f : Ξ© β H) (h : H) (g : Ξ© β β) : | |
| fiberSum f h g / fiberSize f h = | |
| mean (fun Ο : {Ο // f Ο = h} => g Ο.val) := by | |
| classical | |
| simp only [fiberSum, fiberSize, mean] | |
| congr 1 | |
| Β· rw [β Finset.sum_filter] | |
| exact Finset.sum_subtype _ (fun Ο => by simp) g | |
| Β· rw [β Finset.sum_filter] | |
| simp [Fintype.card_subtype] | |
| end | |
| end UniqueGamesTheorem.Soundness.UniformPartition | |
| end | |
| end OAI | |