Buckets:
| import Mathlib | |
| import OAI.Computability.MaxCut.Games.Basic2 | |
| namespace OAI | |
| noncomputable section | |
| /-! Per-label diagonal lower bounds for the actual finite shared sampler. | |
| These bounds retain the output label, which is necessary for comparing the | |
| sampler's output distribution with a prescribed diagonal distribution. -/ | |
| namespace MaxCutGames.Foundations.CorrelatedSampling | |
| section | |
| variable {σ α : Type*} [Fintype σ] [DecidableEq σ] [DecidableEq α] | |
| def localSample (accept : σ → Bool) (decode : σ → α) (fallback : α) | |
| (proposals : List σ) : α := | |
| ((firstAccepted accept proposals).map decode).getD fallback | |
| def localDiagonal (left right : σ → Bool) (decode : σ → α) (fallback a : α) | |
| (proposals : List σ) : ℝ := | |
| if localSample left decode fallback proposals = a ∧ | |
| localSample right decode fallback proposals = a then 1 else 0 | |
| def goodLabel (left right : σ → Bool) (decode : σ → α) (a : α) (s : σ) : Bool := | |
| (left s && right s) && decide (decode s = a) | |
| omit [Fintype σ] [DecidableEq σ] in | |
| theorem common_first_label_lower (left right : σ → Bool) (decode : σ → α) | |
| (fallback a : α) (proposals : List σ) : | |
| goodFirstIndicator (fun s => left s || right s) (goodLabel left right decode a) proposals ≤ | |
| localDiagonal left right decode fallback a proposals := by | |
| cases hfirst : firstAccepted (fun s => left s || right s) proposals with | |
| | none => | |
| simp only [goodFirstIndicator, hfirst] | |
| unfold localDiagonal | |
| split_ifs <;> norm_num | |
| | some s => | |
| by_cases hc : goodLabel left right decode a s = true | |
| · have hparts : (left s = true ∧ right s = true) ∧ decode s = a := by | |
| simpa [goodLabel] using hc | |
| have h := first_union_common left right proposals s hfirst hparts.1.1 hparts.1.2 | |
| simp [goodFirstIndicator, hfirst, hc, localDiagonal, localSample, h.1, h.2, hparts.2] | |
| · have hn : 0 ≤ localDiagonal left right decode fallback a proposals := by | |
| unfold localDiagonal | |
| split_ifs <;> norm_num | |
| simpa [goodFirstIndicator, hfirst, hc] using hn | |
| omit [DecidableEq σ] in theorem union_goodLabel_mass | |
| (w : σ → ℝ) (left right : σ → Bool) (decode : σ → α) (a : α) : | |
| eventMass w (fun s => (left s || right s) && goodLabel left right decode a s) = | |
| eventMass w (goodLabel left right decode a) := by | |
| unfold eventMass | |
| apply Finset.sum_congr rfl | |
| intro s _ | |
| cases hl : left s <;> cases hr : right s <;> simp [goodLabel, hl, hr] | |
| /-- The finite shared-list sampler's mass on the particular diagonal output | |
| (a,a) is at least the common-first-label mass. Exhaustion uses a fixed local | |
| fallback; its contribution is nonnegative and is not counted in this bound. -/ | |
| theorem finite_label_diagonal_bound (w : σ → ℝ) (left right : σ → Bool) | |
| (decode : σ → α) (fallback a : α) (hw : ∀ s, 0 ≤ w s) | |
| (hw_sum : ∑ s, w s = 1) (hu : 0 < eventMass w (fun s => left s || right s)) (n : Nat) : | |
| eventMass w (goodLabel left right decode a) / eventMass w (fun s => left s || right s) * | |
| (1 - eventMass w (fun s => !(left s || right s)) ^ n) ≤ | |
| traceAverage w n (localDiagonal left right decode fallback a) := by | |
| have h := traceAverage_mono w hw n _ _ (common_first_label_lower left right decode fallback a) | |
| rw [goodFirstIndicator_law w _ _ hw_sum n, | |
| goodFirstMass_exact w _ _ hw_sum (ne_of_gt hu) n, | |
| union_goodLabel_mass] at h | |
| exact h | |
| variable [Fintype α] [Nonempty α] | |
| /-- Concrete normalized-density instance of the per-label bound. All random | |
| proposals come from the finite rectangle constructed from `thresholds`. -/ | |
| theorem rectangle_label_diagonal_bound (thresholds : List ℝ) (p q : α → ℝ) | |
| (fallback a : α) | |
| (hpm : ∀ x, p x ∈ thresholds) (hqm : ∀ x, q x ∈ thresholds) | |
| (hp0 : ∀ x, 0 ≤ p x) (hq0 : ∀ x, 0 ≤ q x) | |
| (hp1 : ∀ x, p x ≤ 1) (hq1 : ∀ x, q x ≤ 1) | |
| (hpsum : ∑ x, p x = 1) (hqsum : ∑ x, q x = 1) (n : Nat) : | |
| min (p a) (q a) / (1 + totalVariation p q) * | |
| (1 - eventMass (rectangleWeight thresholds) | |
| (fun s => !(rectangleAccept thresholds p s || rectangleAccept thresholds q s)) ^ n) ≤ | |
| traceAverage (rectangleWeight thresholds) n | |
| (localDiagonal (rectangleAccept thresholds p) (rectangleAccept thresholds q) | |
| Prod.fst fallback a) := by | |
| have hc : 0 < (Fintype.card α : ℝ) := by exact_mod_cast Fintype.card_pos | |
| have hU : 0 < unionMass p q := by | |
| rw [unionMass_eq p q hpsum hqsum] | |
| linarith [totalVariation_nonneg p q] | |
| have hmass := rectangle_union_mass thresholds p q hpm hqm hp0 hq0 hp1 hq1 | |
| have hu : 0 < eventMass (rectangleWeight thresholds) | |
| (fun s => rectangleAccept thresholds p s || rectangleAccept thresholds q s) := by | |
| rw [hmass] | |
| exact div_pos hU hc | |
| have h := finite_label_diagonal_bound (rectangleWeight thresholds) | |
| (rectangleAccept thresholds p) (rectangleAccept thresholds q) Prod.fst fallback a | |
| (rectangleWeight_nonnegative thresholds) (rectangleWeight_normalized thresholds) hu n | |
| unfold goodLabel at h | |
| rw [rectangle_common_label_mass thresholds p q a hpm hqm hp0 hq0 hp1 hq1, hmass] at h | |
| have hratio : (min (p a) (q a) / (Fintype.card α : ℝ)) / | |
| (unionMass p q / (Fintype.card α : ℝ)) = min (p a) (q a) / unionMass p q := by | |
| field_simp | |
| rw [hratio, unionMass_eq p q hpsum hqsum] at h | |
| exact h | |
| end | |
| /-! | |
| A single finite rectangle proposal law for two finite families of distributions. | |
| The subdivision includes every density appearing in either family. Consequently | |
| the local samplers share a seed space independently of their particular inputs. | |
| -/ | |
| open scoped BigOperators | |
| def profileThresholds {κ S : Type*} [Fintype κ] [Fintype S] | |
| (P : κ → S → ℝ) : List ℝ := by | |
| classical | |
| exact (Finset.univ.toList : List (κ × S)).map (fun ks => P ks.1 ks.2) | |
| theorem mem_profileThresholds {κ S : Type*} [Fintype κ] [Fintype S] | |
| (P : κ → S → ℝ) (k : κ) (s : S) : P k s ∈ profileThresholds P := by | |
| classical | |
| exact List.mem_map.mpr ⟨(k, s), by simp, rfl⟩ | |
| theorem distribution_weight_le_one {S : Type*} [Fintype S] | |
| (μ : Games.FiniteDistribution S) (s : S) : μ.weight s ≤ 1 := by | |
| calc | |
| μ.weight s ≤ ∑ t, μ.weight t := | |
| Finset.single_le_sum (fun t _ => μ.nonnegative t) (Finset.mem_univ s) | |
| _ = 1 := μ.normalized | |
| variable {Q₁ Q₂ S : Type*} [Fintype Q₁] [Fintype Q₂] [Fintype S] | |
| def sharedProfileThresholds (L : Q₁ → Games.FiniteDistribution S) | |
| (R : Q₂ → Games.FiniteDistribution S) : List ℝ := | |
| profileThresholds (fun (k : Q₁ ⊕ Q₂) s => (Sum.elim L R k).weight s) | |
| theorem left_mem_sharedProfileThresholds (L : Q₁ → Games.FiniteDistribution S) | |
| (R : Q₂ → Games.FiniteDistribution S) (x : Q₁) (s : S) : | |
| (L x).weight s ∈ sharedProfileThresholds L R := by | |
| exact mem_profileThresholds _ (Sum.inl x) s | |
| theorem right_mem_sharedProfileThresholds (L : Q₁ → Games.FiniteDistribution S) | |
| (R : Q₂ → Games.FiniteDistribution S) (y : Q₂) (s : S) : | |
| (R y).weight s ∈ sharedProfileThresholds L R := by | |
| exact mem_profileThresholds _ (Sum.inr y) s | |
| abbrev SharedProfileSeed (L : Q₁ → Games.FiniteDistribution S) | |
| (R : Q₂ → Games.FiniteDistribution S) := | |
| RectangleSeed (sharedProfileThresholds L R) S | |
| def sharedProfileLeft (L : Q₁ → Games.FiniteDistribution S) | |
| (R : Q₂ → Games.FiniteDistribution S) (x : Q₁) : SharedProfileSeed L R → Bool := | |
| rectangleAccept (sharedProfileThresholds L R) (L x).weight | |
| def sharedProfileRight (L : Q₁ → Games.FiniteDistribution S) | |
| (R : Q₂ → Games.FiniteDistribution S) (y : Q₂) : SharedProfileSeed L R → Bool := | |
| rectangleAccept (sharedProfileThresholds L R) (R y).weight | |
| def sharedProfileReject (L : Q₁ → Games.FiniteDistribution S) | |
| (R : Q₂ → Games.FiniteDistribution S) (x : Q₁) (y : Q₂) : ℝ := | |
| eventMass (rectangleWeight (sharedProfileThresholds L R)) | |
| (fun s => !(sharedProfileLeft L R x s || sharedProfileRight L R y s)) | |
| def uniformRejectionRate (S : Type*) [Fintype S] : ℝ := | |
| 1 - 1 / (Fintype.card S : ℝ) | |
| theorem uniformRejectionRate_nonnegative (S : Type*) [Fintype S] [Nonempty S] : | |
| 0 ≤ uniformRejectionRate S := by | |
| have hc : (0 : ℝ) < Fintype.card S := by | |
| exact_mod_cast (Fintype.card_pos : 0 < Fintype.card S) | |
| have hc₁ : (1 : ℝ) ≤ Fintype.card S := by | |
| exact_mod_cast (Nat.succ_le_of_lt (Fintype.card_pos : 0 < Fintype.card S)) | |
| apply sub_nonneg.mpr | |
| exact (div_le_iff₀ hc).2 (by simpa using hc₁) | |
| theorem uniformRejectionRate_lt_one (S : Type*) [Fintype S] [Nonempty S] : | |
| uniformRejectionRate S < 1 := by | |
| have hc : (0 : ℝ) < Fintype.card S := by | |
| exact_mod_cast (Fintype.card_pos : 0 < Fintype.card S) | |
| have hp : (0 : ℝ) < 1 / (Fintype.card S : ℝ) := div_pos (by norm_num) hc | |
| dsimp [uniformRejectionRate] | |
| linarith | |
| theorem sharedProfileReject_nonnegative [Nonempty S] | |
| (L : Q₁ → Games.FiniteDistribution S) (R : Q₂ → Games.FiniteDistribution S) | |
| (x : Q₁) (y : Q₂) : 0 ≤ sharedProfileReject L R x y := by | |
| exact eventMass_nonneg _ _ | |
| (rectangleDistribution (α := S) (sharedProfileThresholds L R)).nonnegative | |
| theorem sharedProfile_reject_le_rate [Nonempty S] | |
| (L : Q₁ → Games.FiniteDistribution S) (R : Q₂ → Games.FiniteDistribution S) | |
| (x : Q₁) (y : Q₂) : sharedProfileReject L R x y ≤ uniformRejectionRate S := by | |
| let thresholds := sharedProfileThresholds L R | |
| have hsum : (∑ s : RectangleSeed thresholds S, rectangleWeight thresholds s) = 1 := | |
| (rectangleDistribution (α := S) thresholds).normalized | |
| have hcomp := eventMass_complement (rectangleWeight thresholds) | |
| (fun s => sharedProfileLeft L R x s || sharedProfileRight L R y s) hsum | |
| have hu : eventMass (rectangleWeight thresholds) | |
| (fun s => sharedProfileLeft L R x s || sharedProfileRight L R y s) = | |
| (1 + totalVariation (L x).weight (R y).weight) / (Fintype.card S : ℝ) := by | |
| change eventMass (rectangleWeight thresholds) | |
| (fun s => rectangleAccept thresholds (L x).weight s || | |
| rectangleAccept thresholds (R y).weight s) = _ | |
| rw [rectangle_union_mass thresholds (L x).weight (R y).weight | |
| (left_mem_sharedProfileThresholds L R x) | |
| (right_mem_sharedProfileThresholds L R y) | |
| (L x).nonnegative (R y).nonnegative | |
| (distribution_weight_le_one (L x)) (distribution_weight_le_one (R y))] | |
| rw [unionMass_eq (L x).weight (R y).weight (L x).normalized (R y).normalized] | |
| have hc : (0 : ℝ) < Fintype.card S := by | |
| exact_mod_cast (Fintype.card_pos : 0 < Fintype.card S) | |
| have htv := totalVariation_nonneg (L x).weight (R y).weight | |
| have hquot : 1 / (Fintype.card S : ℝ) ≤ | |
| (1 + totalVariation (L x).weight (R y).weight) / (Fintype.card S : ℝ) := | |
| (div_le_div_iff_of_pos_right hc).2 (by linarith) | |
| rw [hu] at hcomp | |
| change eventMass (rectangleWeight thresholds) | |
| (fun s => !(sharedProfileLeft L R x s || sharedProfileRight L R y s)) ≤ | |
| 1 - 1 / (Fintype.card S : ℝ) | |
| linarith | |
| private theorem nonnegative_powers_mono_inline_SharedProfiles (a b : ℝ) (ha : 0 ≤ a) (hab : a ≤ b) | |
| (n : ℕ) : a ^ n ≤ b ^ n := by | |
| have hb : 0 ≤ b := le_trans ha hab | |
| induction n with | |
| | zero => simp | |
| | succ n ih => | |
| rw [pow_succ, pow_succ] | |
| exact mul_le_mul ih hab ha (pow_nonneg hb n) | |
| theorem sharedProfile_label_diagonal_bound [Nonempty S] [DecidableEq S] | |
| (L : Q₁ → Games.FiniteDistribution S) (R : Q₂ → Games.FiniteDistribution S) | |
| (x : Q₁) (y : Q₂) (fallback a : S) (n : ℕ) : | |
| min ((L x).weight a) ((R y).weight a) / | |
| (1 + totalVariation (L x).weight (R y).weight) * | |
| (1 - uniformRejectionRate S ^ n) ≤ | |
| traceAverage (rectangleWeight (sharedProfileThresholds L R)) n | |
| (localDiagonal (sharedProfileLeft L R x) (sharedProfileRight L R y) | |
| Prod.fst fallback a) := by | |
| have hp := nonnegative_powers_mono_inline_SharedProfiles (sharedProfileReject L R x y) | |
| (uniformRejectionRate S) (sharedProfileReject_nonnegative L R x y) | |
| (sharedProfile_reject_le_rate L R x y) n | |
| have htv := totalVariation_nonneg (L x).weight (R y).weight | |
| have hm : 0 ≤ min ((L x).weight a) ((R y).weight a) / | |
| (1 + totalVariation (L x).weight (R y).weight) := | |
| div_nonneg (le_min ((L x).nonnegative a) ((R y).nonnegative a)) (by linarith) | |
| have hsurv : | |
| min ((L x).weight a) ((R y).weight a) / | |
| (1 + totalVariation (L x).weight (R y).weight) * | |
| (1 - uniformRejectionRate S ^ n) ≤ | |
| min ((L x).weight a) ((R y).weight a) / | |
| (1 + totalVariation (L x).weight (R y).weight) * | |
| (1 - sharedProfileReject L R x y ^ n) := | |
| mul_le_mul_of_nonneg_left (by linarith) hm | |
| refine hsurv.trans ?_ | |
| simpa only [sharedProfileReject, sharedProfileLeft, sharedProfileRight] using | |
| rectangle_label_diagonal_bound (sharedProfileThresholds L R) | |
| (L x).weight (R y).weight fallback a | |
| (left_mem_sharedProfileThresholds L R x) | |
| (right_mem_sharedProfileThresholds L R y) | |
| (L x).nonnegative (R y).nonnegative | |
| (distribution_weight_le_one (L x)) (distribution_weight_le_one (R y)) | |
| (L x).normalized (R y).normalized n | |
| theorem exists_uniformRejectionRate_pow_lt (S : Type*) [Fintype S] [Nonempty S] | |
| (η : ℝ) (hη : 0 < η) : ∃ n : ℕ, uniformRejectionRate S ^ n < η := by | |
| have ht := tendsto_pow_atTop_nhds_zero_of_lt_one | |
| (uniformRejectionRate_nonnegative S) (uniformRejectionRate_lt_one S) | |
| exact (ht.eventually (gt_mem_nhds hη)).exists | |
| end MaxCutGames.Foundations.CorrelatedSampling | |
| /-! | |
| Finite real probability vectors and information inequalities. | |
| `relativeEntropy` uses the natural logarithm and a real-valued finite sum. | |
| Its theorems require support containment, so a positive numerator is never | |
| silently assigned finite divergence against a zero denominator. | |
| -/ | |
| namespace MaxCutGames.Foundations.Information | |
| section | |
| open scoped BigOperators | |
| variable {α : Type*} [Fintype α] | |
| def IsProbability (p : α → ℝ) : Prop := | |
| (∀ a, 0 ≤ p a) ∧ ∑ a, p a = 1 | |
| def SupportedBy (p q : α → ℝ) : Prop := ∀ a, p a ≠ 0 → q a ≠ 0 | |
| noncomputable def relativeEntropy (p q : α → ℝ) : ℝ := | |
| ∑ a, p a * Real.log (p a / q a) | |
| noncomputable def totalVariation (p q : α → ℝ) : ℝ := | |
| (∑ a, |p a - q a|) / 2 | |
| noncomputable def posterior (p w : α → ℝ) (z : ℝ) : α → ℝ := | |
| fun a => p a * w a / z | |
| theorem posterior_isProbability (p w : α → ℝ) (hp : IsProbability p) | |
| (hw : ∀ a, 0 ≤ w a) {z : ℝ} (hz : 0 < z) | |
| (hmass : ∑ a, p a * w a = z) : IsProbability (posterior p w z) := by | |
| constructor | |
| · intro a | |
| exact div_nonneg (mul_nonneg (hp.1 a) (hw a)) hz.le | |
| · simp only [posterior, div_eq_mul_inv, ← Finset.sum_mul, hmass, | |
| mul_inv_cancel₀ hz.ne'] | |
| omit [Fintype α] in | |
| theorem posterior_supportedBy (p w : α → ℝ) (z : ℝ) : | |
| SupportedBy (posterior p w z) p := by | |
| intro a ha hp | |
| exact ha (by simp [posterior, hp]) | |
| theorem mul_log_div_ge_sub {x y : ℝ} (hx : 0 < x) (hy : 0 < y) : | |
| x - y ≤ x * Real.log (x / y) := by | |
| have h := Real.one_sub_inv_le_log_of_pos (div_pos hx hy) | |
| have hm := mul_le_mul_of_nonneg_left h hx.le | |
| have he : x * (1 - (x / y)⁻¹) = x - y := by | |
| field_simp [hx.ne', hy.ne'] | |
| rwa [he] at hm | |
| theorem relativeEntropy_nonneg (p q : α → ℝ) (hp : IsProbability p) | |
| (hq : IsProbability q) (hs : SupportedBy p q) : 0 ≤ relativeEntropy p q := by | |
| have hpoint : ∀ a, p a - q a ≤ p a * Real.log (p a / q a) := by | |
| intro a | |
| by_cases hpa : p a = 0 | |
| · simp only [hpa, zero_sub, zero_div, zero_mul] | |
| exact neg_nonpos.mpr (hq.1 a) | |
| · exact mul_log_div_ge_sub (lt_of_le_of_ne (hp.1 a) (Ne.symm hpa)) | |
| (lt_of_le_of_ne (hq.1 a) (Ne.symm (hs a hpa))) | |
| have hsum := Finset.sum_le_sum (fun a (_ : a ∈ (Finset.univ : Finset α)) => hpoint a) | |
| simpa [relativeEntropy, Finset.sum_sub_distrib, hp.2, hq.2] using hsum | |
| theorem posterior_relativeEntropy_le (p w : α → ℝ) (hp : IsProbability p) | |
| (hw : ∀ a, 0 ≤ w a) (hw_one : ∀ a, w a ≤ 1) {z : ℝ} (hz : 0 < z) | |
| (hmass : ∑ a, p a * w a = z) : | |
| relativeEntropy (posterior p w z) p ≤ Real.log (1 / z) := by | |
| have hpost := posterior_isProbability p w hp hw hz hmass | |
| have hpoint : ∀ a, posterior p w z a * Real.log (posterior p w z a / p a) ≤ | |
| posterior p w z a * Real.log (1 / z) := by | |
| intro a | |
| by_cases hpa : posterior p w z a = 0 | |
| · simp [hpa] | |
| have hpne := posterior_supportedBy p w z a hpa | |
| have hppos : 0 < p a := lt_of_le_of_ne (hp.1 a) (Ne.symm hpne) | |
| have hpostpos : 0 < posterior p w z a := | |
| lt_of_le_of_ne (hpost.1 a) (Ne.symm hpa) | |
| have hr : posterior p w z a / p a = w a / z := by | |
| dsimp [posterior] | |
| field_simp [hpne, hz.ne'] | |
| apply mul_le_mul_of_nonneg_left _ (hpost.1 a) | |
| apply Real.log_le_log (div_pos hpostpos hppos) | |
| rw [hr] | |
| exact div_le_div_of_nonneg_right (hw_one a) hz.le | |
| have hsum := Finset.sum_le_sum (fun a (_ : a ∈ (Finset.univ : Finset α)) => hpoint a) | |
| simpa only [relativeEntropy, ← Finset.sum_mul, hpost.2, one_mul] using hsum | |
| theorem totalVariation_nonneg (p q : α → ℝ) : 0 ≤ totalVariation p q := by | |
| exact div_nonneg (Finset.sum_nonneg (fun a _ => abs_nonneg (p a - q a))) (by norm_num) | |
| theorem totalVariation_symm (p q : α → ℝ) : totalVariation p q = totalVariation q p := by | |
| simp only [totalVariation, abs_sub_comm] | |
| theorem totalVariation_le_one (p q : α → ℝ) (hp : IsProbability p) | |
| (hq : IsProbability q) : totalVariation p q ≤ 1 := by | |
| have hpoint : ∀ a, |p a - q a| ≤ p a + q a := by | |
| intro a | |
| rw [abs_le] | |
| constructor <;> linarith [hp.1 a, hq.1 a] | |
| have hsum := Finset.sum_le_sum (fun a (_ : a ∈ (Finset.univ : Finset α)) => hpoint a) | |
| simp only [Finset.sum_add_distrib, hp.2, hq.2] at hsum | |
| dsimp [totalVariation] | |
| linarith | |
| theorem le_binaryLog_of_le_log {r x : ℝ} (hr : 0 ≤ r) (h : r ≤ Real.log x) : | |
| r ≤ Real.log x / Real.log 2 := by | |
| have htwo : 0 < Real.log 2 := Real.log_pos (by norm_num) | |
| have htwo_one : Real.log 2 ≤ 1 := by | |
| have ht := Real.log_le_sub_one_of_pos (show (0 : ℝ) < 2 by norm_num) | |
| norm_num at ht ⊢ | |
| exact ht | |
| apply (le_div_iff₀ htwo).2 | |
| exact (mul_le_mul_of_nonneg_left htwo_one hr).trans (by simpa using h) | |
| /-- Finite weighted Cauchy–Schwarz for probability weights. The summands | |
| need not be nonnegative. -/ | |
| theorem weighted_sum_sq_le (w x : α → ℝ) (hw : IsProbability w) : | |
| (∑ a, w a * x a)^2 ≤ ∑ a, w a * (x a)^2 := by | |
| have hcs := Finset.sum_mul_sq_le_sq_mul_sq (Finset.univ : Finset α) | |
| (fun a => Real.sqrt (w a)) (fun a => Real.sqrt (w a) * x a) | |
| have hfirst : ∀ a, Real.sqrt (w a) * (Real.sqrt (w a) * x a) = w a * x a := by | |
| intro a | |
| rw [← mul_assoc, Real.mul_self_sqrt (hw.1 a)] | |
| have hsecond : ∀ a, (Real.sqrt (w a) * x a)^2 = w a * (x a)^2 := by | |
| intro a | |
| rw [mul_pow, Real.sq_sqrt (hw.1 a)] | |
| simpa only [hfirst, hsecond, Real.sq_sqrt (hw.1 _), hw.2, one_mul] using hcs | |
| end | |
| /-! Finite product-reference entropy decomposition, including zero-probability fibers. -/ | |
| open scoped BigOperators | |
| variable {α β : Type*} [Fintype α] [Fintype β] | |
| noncomputable def firstMarginal (p : α × β → ℝ) (a : α) : ℝ := ∑ b, p (a, b) | |
| noncomputable def secondMarginal (p : α × β → ℝ) (b : β) : ℝ := ∑ a, p (a, b) | |
| def product (p : α → ℝ) (q : β → ℝ) : α × β → ℝ := fun ab => p ab.1 * q ab.2 | |
| theorem firstMarginal_isProbability (p : α × β → ℝ) (hp : IsProbability p) : | |
| IsProbability (firstMarginal p) := by | |
| constructor | |
| · intro a | |
| exact Finset.sum_nonneg (fun b _ => hp.1 (a, b)) | |
| · simpa only [firstMarginal, Fintype.sum_prod_type] using hp.2 | |
| theorem secondMarginal_isProbability (p : α × β → ℝ) (hp : IsProbability p) : | |
| IsProbability (secondMarginal p) := by | |
| constructor | |
| · intro b | |
| exact Finset.sum_nonneg (fun a _ => hp.1 (a, b)) | |
| · change (∑ b, ∑ a, p (a, b)) = 1 | |
| rw [Finset.sum_comm] | |
| exact (firstMarginal_isProbability p hp).2 | |
| theorem product_isProbability (p : α → ℝ) (q : β → ℝ) | |
| (hp : IsProbability p) (hq : IsProbability q) : IsProbability (product p q) := by | |
| constructor | |
| · intro ab | |
| exact mul_nonneg (hp.1 ab.1) (hq.1 ab.2) | |
| · simp only [product, Fintype.sum_prod_type, ← Finset.mul_sum, hq.2, mul_one, hp.2] | |
| theorem point_le_firstMarginal (p : α × β → ℝ) (hp : IsProbability p) (a : α) (b : β) : | |
| p (a, b) ≤ firstMarginal p a := by | |
| classical | |
| exact Finset.single_le_sum (fun b _ => hp.1 (a, b)) (Finset.mem_univ b) | |
| theorem point_le_secondMarginal (p : α × β → ℝ) (hp : IsProbability p) (a : α) (b : β) : | |
| p (a, b) ≤ secondMarginal p b := by | |
| classical | |
| exact Finset.single_le_sum (fun a _ => hp.1 (a, b)) (Finset.mem_univ a) | |
| theorem joint_supportedBy_product_marginals (p : α × β → ℝ) (hp : IsProbability p) : | |
| SupportedBy p (product (firstMarginal p) (secondMarginal p)) := by | |
| intro ab hpne | |
| have hpos : 0 < p ab := lt_of_le_of_ne (hp.1 ab) (Ne.symm hpne) | |
| exact mul_ne_zero | |
| (ne_of_gt (hpos.trans_le (point_le_firstMarginal p hp ab.1 ab.2))) | |
| (ne_of_gt (hpos.trans_le (point_le_secondMarginal p hp ab.1 ab.2))) | |
| theorem relativeEntropy_product_reference (p : α × β → ℝ) (u : α → ℝ) (v : β → ℝ) | |
| (hp : IsProbability p) (_hu : IsProbability u) (_hv : IsProbability v) | |
| (hsu : SupportedBy (firstMarginal p) u) (hsv : SupportedBy (secondMarginal p) v) : | |
| relativeEntropy p (product u v) = | |
| relativeEntropy p (product (firstMarginal p) (secondMarginal p)) + | |
| relativeEntropy (firstMarginal p) u + relativeEntropy (secondMarginal p) v := by | |
| have hpoint : ∀ ab : α × β, p ab * Real.log (p ab / product u v ab) = | |
| p ab * Real.log (p ab / product (firstMarginal p) (secondMarginal p) ab) + | |
| p ab * Real.log (firstMarginal p ab.1 / u ab.1) + | |
| p ab * Real.log (secondMarginal p ab.2 / v ab.2) := by | |
| intro ab | |
| by_cases hzero : p ab = 0 | |
| · simp [hzero] | |
| have hpos : 0 < p ab := lt_of_le_of_ne (hp.1 ab) (Ne.symm hzero) | |
| have hleft := ne_of_gt (hpos.trans_le (point_le_firstMarginal p hp ab.1 ab.2)) | |
| have hright := ne_of_gt (hpos.trans_le (point_le_secondMarginal p hp ab.1 ab.2)) | |
| have hune := hsu ab.1 hleft | |
| have hvne := hsv ab.2 hright | |
| simp only [product, Real.log_div hzero (mul_ne_zero hune hvne), | |
| Real.log_div hzero (mul_ne_zero hleft hright), Real.log_mul hune hvne, | |
| Real.log_mul hleft hright, Real.log_div hleft hune, Real.log_div hright hvne] | |
| ring | |
| have hleftSum : (∑ ab : α × β, p ab * Real.log (firstMarginal p ab.1 / u ab.1)) = | |
| relativeEntropy (firstMarginal p) u := by | |
| simp only [Fintype.sum_prod_type, ← Finset.sum_mul, relativeEntropy, firstMarginal] | |
| have hrightSum : (∑ ab : α × β, p ab * Real.log (secondMarginal p ab.2 / v ab.2)) = | |
| relativeEntropy (secondMarginal p) v := by | |
| rw [Fintype.sum_prod_type, Finset.sum_comm] | |
| simp only [← Finset.sum_mul, relativeEntropy, secondMarginal] | |
| unfold relativeEntropy | |
| simp_rw [hpoint] | |
| rw [Finset.sum_add_distrib, Finset.sum_add_distrib, hleftSum, hrightSum] | |
| rfl | |
| theorem marginal_relativeEntropy_sum_le (p : α × β → ℝ) (u : α → ℝ) (v : β → ℝ) | |
| (hp : IsProbability p) (hu : IsProbability u) (hv : IsProbability v) | |
| (hsu : SupportedBy (firstMarginal p) u) (hsv : SupportedBy (secondMarginal p) v) : | |
| relativeEntropy (firstMarginal p) u + relativeEntropy (secondMarginal p) v ≤ | |
| relativeEntropy p (product u v) := by | |
| rw [relativeEntropy_product_reference p u v hp hu hv hsu hsv] | |
| have hn := relativeEntropy_nonneg p (product (firstMarginal p) (secondMarginal p)) hp | |
| (product_isProbability _ _ (firstMarginal_isProbability p hp) | |
| (secondMarginal_isProbability p hp)) (joint_supportedBy_product_marginals p hp) | |
| linarith | |
| /-! | |
| Conditional laws on finite spaces, with a normalized default on null rows. | |
| The default remains a probability law when a new input law charges a row | |
| that had zero probability in the original joint distribution. | |
| -/ | |
| noncomputable def conditionalKernel | |
| (p : α × β → ℝ) (fallback : β → ℝ) (a : α) (b : β) : ℝ := by | |
| classical | |
| exact if firstMarginal p a = 0 then fallback b | |
| else p (a, b) / firstMarginal p a | |
| theorem conditionalKernel_isProbability | |
| (p : α × β → ℝ) (fallback : β → ℝ) | |
| (hp : IsProbability p) (hf : IsProbability fallback) (a : α) : | |
| IsProbability (conditionalKernel p fallback a) := by | |
| classical | |
| by_cases hm : firstMarginal p a = 0 | |
| · simpa only [IsProbability, conditionalKernel, ite_eq_left hm] using hf | |
| · constructor | |
| · intro b | |
| simp only [conditionalKernel, ite_eq_right hm] | |
| exact div_nonneg (hp.1 (a, b)) | |
| ((firstMarginal_isProbability p hp).1 a) | |
| · simp only [conditionalKernel, ite_eq_right hm, div_eq_mul_inv, ← Finset.sum_mul] | |
| change firstMarginal p a * (firstMarginal p a)⁻¹ = 1 | |
| exact mul_inv_cancel₀ hm | |
| theorem marginal_mul_conditionalKernel | |
| (p : α × β → ℝ) (fallback : β → ℝ) | |
| (hp : IsProbability p) (a : α) (b : β) : | |
| firstMarginal p a * conditionalKernel p fallback a b = p (a, b) := by | |
| classical | |
| by_cases hm : firstMarginal p a = 0 | |
| · have hpoint := point_le_firstMarginal p hp a b | |
| rw [hm] at hpoint | |
| have hz : p (a, b) = 0 := le_antisymm hpoint (hp.1 (a, b)) | |
| simp [conditionalKernel, hm, hz] | |
| · simp only [conditionalKernel, ite_eq_right hm] | |
| calc | |
| firstMarginal p a * (p (a, b) / firstMarginal p a) | |
| = p (a, b) * | |
| (firstMarginal p a / firstMarginal p a) := by ring | |
| _ = p (a, b) := by rw [div_self hm, mul_one] | |
| theorem law_of_total_probability | |
| (p : α × β → ℝ) (fallback : β → ℝ) | |
| (hp : IsProbability p) (b : β) : | |
| (∑ a, firstMarginal p a * conditionalKernel p fallback a b) = | |
| secondMarginal p b := by | |
| simp only [marginal_mul_conditionalKernel p fallback hp, secondMarginal] | |
| theorem kernelProduct_isProbability | |
| (r : α → ℝ) (k : α → β → ℝ) | |
| (hr : IsProbability r) (hk : ∀ a, IsProbability (k a)) : | |
| IsProbability (fun ab : α × β => r ab.1 * k ab.1 ab.2) := by | |
| constructor | |
| · intro ab | |
| exact mul_nonneg (hr.1 ab.1) ((hk ab.1).1 ab.2) | |
| · simp only [Fintype.sum_prod_type, ← Finset.mul_sum, | |
| (hk _).2, mul_one, hr.2] | |
| theorem alternativeInput_conditionalProduct_isProbability | |
| (p : α × β → ℝ) (fallback : β → ℝ) (r : α → ℝ) | |
| (hp : IsProbability p) (hf : IsProbability fallback) | |
| (hr : IsProbability r) : | |
| IsProbability | |
| (fun ab : α × β => r ab.1 * conditionalKernel p fallback ab.1 ab.2) := | |
| kernelProduct_isProbability r (conditionalKernel p fallback) hr | |
| (conditionalKernel_isProbability p fallback hp hf) | |
| end MaxCutGames.Foundations.Information | |
| /-! Exact finite total variation and its event-probability bound. -/ | |
| namespace MaxCutGames.Foundations.Games.FiniteDistribution | |
| open scoped BigOperators | |
| variable {Ω : Type*} [Fintype Ω] | |
| def totalVariation (μ ν : FiniteDistribution Ω) : ℝ := | |
| (∑ x, |μ.weight x - ν.weight x|) / 2 | |
| theorem totalVariation_nonnegative (μ ν : FiniteDistribution Ω) : | |
| 0 ≤ μ.totalVariation ν := | |
| div_nonneg (Finset.sum_nonneg fun _ _ => abs_nonneg _) (by norm_num) | |
| theorem totalVariation_comm (μ ν : FiniteDistribution Ω) : | |
| μ.totalVariation ν = ν.totalVariation μ := by | |
| unfold totalVariation | |
| congr 1 | |
| apply Finset.sum_congr rfl | |
| intro x _ | |
| exact abs_sub_comm _ _ | |
| /-- A one-sided event difference is bounded by half the total absolute mass | |
| difference. Normalization is used; the full absolute-mass sum would lose a | |
| factor of two needed in the repetition argument. -/ | |
| theorem probability_sub_le_totalVariation (μ ν : FiniteDistribution Ω) | |
| (event : Ω → Bool) : | |
| μ.probability event - ν.probability event ≤ μ.totalVariation ν := by | |
| have pointwise (x : Ω) : | |
| 2 * ((if event x then μ.weight x else 0) - | |
| (if event x then ν.weight x else 0)) ≤ | |
| |μ.weight x - ν.weight x| + (μ.weight x - ν.weight x) := by | |
| have h₁ := le_abs_self (μ.weight x - ν.weight x) | |
| have h₂ := neg_le_abs (μ.weight x - ν.weight x) | |
| cases event x <;> simp only [Bool.false_eq_true, ↓reduceIte] <;> linarith | |
| have summed := Finset.sum_le_sum (s := Finset.univ) fun x _ => pointwise x | |
| simp only [← Finset.mul_sum, Finset.sum_add_distrib, Finset.sum_sub_distrib, | |
| μ.normalized, ν.normalized, sub_self, add_zero] at summed | |
| unfold probability totalVariation | |
| linarith | |
| theorem probability_abs_sub_le_totalVariation (μ ν : FiniteDistribution Ω) | |
| (event : Ω → Bool) : | |
| |μ.probability event - ν.probability event| ≤ μ.totalVariation ν := by | |
| apply abs_le.mpr | |
| constructor | |
| · have h := ν.probability_sub_le_totalVariation μ event | |
| rw [totalVariation_comm] at h | |
| linarith | |
| · exact μ.probability_sub_le_totalVariation ν event | |
| theorem probability_le_add_totalVariation (μ ν : FiniteDistribution Ω) | |
| (event : Ω → Bool) : | |
| μ.probability event ≤ ν.probability event + μ.totalVariation ν := by | |
| have h := μ.probability_sub_le_totalVariation ν event | |
| linarith | |
| end MaxCutGames.Foundations.Games.FiniteDistribution | |
| /-! | |
| Conditioning of actual finite distributions and the selected-coordinate chain | |
| rule used in parallel repetition. A normalized conditional distribution is only | |
| constructed when the conditioning event has strictly positive probability. | |
| -/ | |
| namespace MaxCutGames.Foundations.Games | |
| open scoped BigOperators | |
| namespace FiniteDistribution | |
| variable {Ω : Type*} [Fintype Ω] | |
| def condition (μ : FiniteDistribution Ω) (given : Ω → Bool) | |
| (positive : 0 < μ.probability given) : FiniteDistribution Ω where | |
| weight x := if given x then μ.weight x / μ.probability given else 0 | |
| nonnegative x := by | |
| split | |
| · exact div_nonneg (μ.nonnegative x) positive.le | |
| · exact le_rfl | |
| normalized := by | |
| calc | |
| _ = (∑ x, if given x then μ.weight x else 0) / μ.probability given := by | |
| simp only [div_eq_mul_inv, Finset.sum_mul] | |
| apply Finset.sum_congr rfl | |
| intro x _ | |
| by_cases hx : given x = true <;> simp [hx] | |
| _ = 1 := div_self (ne_of_gt positive) | |
| theorem probability_condition (μ : FiniteDistribution Ω) (given event : Ω → Bool) | |
| (positive : 0 < μ.probability given) : | |
| (μ.condition given positive).probability event = | |
| μ.probability (fun x => given x && event x) / μ.probability given := by | |
| simp only [probability, condition, div_eq_mul_inv, Finset.sum_mul] | |
| apply Finset.sum_congr rfl | |
| intro x _ | |
| by_cases hg : given x = true <;> by_cases he : event x = true <;> simp [hg, he] | |
| theorem probability_inter_eq_mul_conditional (μ : FiniteDistribution Ω) | |
| (given event : Ω → Bool) (positive : 0 < μ.probability given) : | |
| μ.probability (fun x => given x && event x) = | |
| μ.probability given * (μ.condition given positive).probability event := by | |
| have h := (eq_div_iff (ne_of_gt positive)).mp | |
| (μ.probability_condition given event positive) | |
| simpa only [mul_comm] using h.symm | |
| theorem probability_and_le_left (μ : FiniteDistribution Ω) (event event' : Ω → Bool) : | |
| μ.probability (fun x => event x && event' x) ≤ μ.probability event := by | |
| apply μ.probability_mono | |
| intro x hx | |
| have h : event x = true ∧ event' x = true := by simpa using hx | |
| exact h.1 | |
| theorem probability_and_le_right (μ : FiniteDistribution Ω) (event event' : Ω → Bool) : | |
| μ.probability (fun x => event x && event' x) ≤ μ.probability event' := by | |
| apply μ.probability_mono | |
| intro x hx | |
| have h : event x = true ∧ event' x = true := by simpa using hx | |
| exact h.2 | |
| theorem probability_and_eq_zero_of_probability_eq_zero (μ : FiniteDistribution Ω) | |
| (given event : Ω → Bool) (zero : μ.probability given = 0) : | |
| μ.probability (fun x => given x && event x) = 0 := by | |
| apply le_antisymm | |
| · exact (μ.probability_and_le_left given event).trans_eq zero | |
| · exact μ.probability_nonnegative _ | |
| @[simp] theorem probability_condition_given (μ : FiniteDistribution Ω) | |
| (given : Ω → Bool) (positive : 0 < μ.probability given) : | |
| (μ.condition given positive).probability given = 1 := by | |
| rw [μ.probability_condition] | |
| simpa only [Bool.and_self] using div_self (ne_of_gt positive) | |
| end FiniteDistribution | |
| namespace Game | |
| variable {Q₁ Q₂ A₁ A₂ : Type*} | |
| [Fintype Q₁] [Fintype Q₂] [Fintype A₁] [Fintype A₂] | |
| {n : Nat} | |
| theorem selectedWins_insert (G : Game Q₁ Q₂ A₁ A₂) | |
| (strategy : Strategy (Fin n → Q₁) (Fin n → Q₂) (Fin n → A₁) (Fin n → A₂)) | |
| (selected : Finset (Fin n)) (coordinate : Fin n) : | |
| G.selectedWins strategy (insert coordinate selected) = | |
| fun questions => | |
| G.selectedWins strategy selected questions && G.coordinateWin strategy coordinate questions := by | |
| classical | |
| funext questions | |
| apply Bool.eq_iff_iff.mpr | |
| simp [selectedWins, and_comm] | |
| def selectedSuccess (G : Game Q₁ Q₂ A₁ A₂) | |
| (strategy : Strategy (Fin n → Q₁) (Fin n → Q₂) (Fin n → A₁) (Fin n → A₂)) | |
| (selected : Finset (Fin n)) : ℝ := | |
| (G.repetition n).questions.probability (G.selectedWins strategy selected) | |
| theorem selectedSuccess_nonnegative (G : Game Q₁ Q₂ A₁ A₂) | |
| (strategy : Strategy (Fin n → Q₁) (Fin n → Q₂) (Fin n → A₁) (Fin n → A₂)) | |
| (selected : Finset (Fin n)) : 0 ≤ G.selectedSuccess strategy selected := | |
| (G.repetition n).questions.probability_nonnegative _ | |
| theorem selectedSuccess_le_one (G : Game Q₁ Q₂ A₁ A₂) | |
| (strategy : Strategy (Fin n → Q₁) (Fin n → Q₂) (Fin n → A₁) (Fin n → A₂)) | |
| (selected : Finset (Fin n)) : G.selectedSuccess strategy selected ≤ 1 := | |
| (G.repetition n).questions.probability_le_one _ | |
| @[simp] theorem selectedSuccess_empty (G : Game Q₁ Q₂ A₁ A₂) | |
| (strategy : Strategy (Fin n → Q₁) (Fin n → Q₂) (Fin n → A₁) (Fin n → A₂)) : | |
| G.selectedSuccess strategy ∅ = 1 := by | |
| have h : G.selectedWins strategy ∅ = fun _ => true := | |
| funext (G.selectedWins_empty strategy) | |
| rw [selectedSuccess, h, FiniteDistribution.probability_true] | |
| theorem selectedSuccess_univ (G : Game Q₁ Q₂ A₁ A₂) | |
| (strategy : Strategy (Fin n → Q₁) (Fin n → Q₂) (Fin n → A₁) (Fin n → A₂)) : | |
| G.selectedSuccess strategy Finset.univ = (G.repetition n).success strategy := by | |
| rw [selectedSuccess, G.selectedWins_univ] | |
| rfl | |
| theorem selectedSuccess_antitone (G : Game Q₁ Q₂ A₁ A₂) | |
| (strategy : Strategy (Fin n → Q₁) (Fin n → Q₂) (Fin n → A₁) (Fin n → A₂)) : | |
| Antitone (G.selectedSuccess strategy) := by | |
| intro selected selected' h | |
| exact G.selectedWins_mono strategy h | |
| theorem selectedSuccess_insert (G : Game Q₁ Q₂ A₁ A₂) | |
| (strategy : Strategy (Fin n → Q₁) (Fin n → Q₂) (Fin n → A₁) (Fin n → A₂)) | |
| (selected : Finset (Fin n)) (coordinate : Fin n) | |
| (positive : 0 < G.selectedSuccess strategy selected) : | |
| G.selectedSuccess strategy (insert coordinate selected) = | |
| G.selectedSuccess strategy selected * | |
| ((G.repetition n).questions.condition (G.selectedWins strategy selected) positive).probability | |
| (G.coordinateWin strategy coordinate) := by | |
| unfold selectedSuccess | |
| rw [G.selectedWins_insert] | |
| exact (G.repetition n).questions.probability_inter_eq_mul_conditional _ _ positive | |
| theorem selectedSuccess_insert_eq_zero (G : Game Q₁ Q₂ A₁ A₂) | |
| (strategy : Strategy (Fin n → Q₁) (Fin n → Q₂) (Fin n → A₁) (Fin n → A₂)) | |
| (selected : Finset (Fin n)) (coordinate : Fin n) | |
| (zero : G.selectedSuccess strategy selected = 0) : | |
| G.selectedSuccess strategy (insert coordinate selected) = 0 := by | |
| apply le_antisymm | |
| · exact (G.selectedSuccess_antitone strategy (Finset.subset_insert coordinate selected)).trans_eq zero | |
| · exact G.selectedSuccess_nonnegative _ _ | |
| end Game | |
| end MaxCutGames.Foundations.Games | |
| end | |
| end OAI | |
Xet Storage Details
- Size:
- 36.1 kB
- Xet hash:
- 9b8571146e270a1c408d3038e5bcc2e016f441bb86b26e6e5f01978d8d542cda
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.