Buckets:
| import Mathlib | |
| import OAI.Computability.DirectedFeedback.Games.ChainRule | |
| namespace OAI | |
| namespace DFVSGames.Foundations.Repetition.ProfileCorrection | |
| open scoped BigOperators | |
| open DFVSGames.Foundations.Information | |
| noncomputable section | |
| variable {S X Y : Type*} [Fintype S] [Fintype X] [Fintype Y] | |
| def seedQuestionMarginal (p : X × (S × Y) → ℝ) : X × S → ℝ := | |
| firstMarginal (fun z : (X × S) × Y => p (z.1.1, (z.1.2, z.2))) | |
| theorem seedQuestionMarginal_isProbability (p : X × (S × Y) → ℝ) | |
| (hp : IsProbability p) : IsProbability (seedQuestionMarginal p) := by | |
| apply firstMarginal_isProbability | |
| constructor | |
| · intro z | |
| exact hp.1 _ | |
| · have h := hp.2 | |
| simp only [Fintype.sum_prod_type] at h ⊢ | |
| exact h | |
| omit [Fintype X] in | |
| theorem seedQuestionMarginal_first (p : X × (S × Y) → ℝ) : | |
| firstMarginal (seedQuestionMarginal p) = firstMarginal p := by | |
| funext x | |
| simp only [seedQuestionMarginal, firstMarginal, Fintype.sum_prod_type] | |
| theorem totalVariation_triangle {Ω : Type*} [Fintype Ω] | |
| (p c d : Ω → ℝ) : | |
| totalVariation p d ≤ totalVariation p c + totalVariation c d := by | |
| unfold totalVariation | |
| have h := Finset.sum_le_sum (s := Finset.univ) | |
| (fun x _ => abs_sub_le (p x) (c x) (d x)) | |
| rw [Finset.sum_add_distrib] at h | |
| linarith | |
| theorem left_profile_correction | |
| (p : X × (S × Y) → ℝ) (μ : X × Y → ℝ) | |
| (fallbackS : S → ℝ) (fallbackY : Y → ℝ) | |
| (hp : IsProbability p) (hμ : IsProbability μ) | |
| (hS : IsProbability fallbackS) (hY : IsProbability fallbackY) : | |
| totalVariation p (fun z => μ (z.1, z.2.2) * | |
| conditionalKernel (seedQuestionMarginal p) fallbackS z.1 z.2.1) ≤ | |
| totalVariation p (fun z => seedQuestionMarginal p (z.1, z.2.1) * | |
| conditionalKernel μ fallbackY z.1 z.2.2) + | |
| totalVariation (firstMarginal p) (firstMarginal μ) := by | |
| let σ := seedQuestionMarginal p | |
| let L := conditionalKernel σ fallbackS | |
| let M := conditionalKernel μ fallbackY | |
| let k : X → S × Y → ℝ := fun x sy => L x sy.1 * M x sy.2 | |
| let c : X × (S × Y) → ℝ := fun z => σ (z.1,z.2.1) * M z.1 z.2.2 | |
| let d : X × (S × Y) → ℝ := fun z => μ (z.1,z.2.2) * L z.1 z.2.1 | |
| have hσ : IsProbability σ := seedQuestionMarginal_isProbability p hp | |
| have hk : ∀ x, IsProbability (k x) := by | |
| intro x | |
| exact kernelProduct_isProbability (L x) (fun _ : S => M x) | |
| (conditionalKernel_isProbability σ fallbackS hσ hS x) | |
| (fun _ => conditionalKernel_isProbability μ fallbackY hμ hY x) | |
| have hc : c = fun z => firstMarginal σ z.1 * k z.1 z.2 := by | |
| funext z | |
| change σ (z.1,z.2.1) * M z.1 z.2.2 = | |
| firstMarginal σ z.1 * (L z.1 z.2.1 * M z.1 z.2.2) | |
| rw [← mul_assoc, marginal_mul_conditionalKernel σ fallbackS hσ] | |
| have hd : d = fun z => firstMarginal μ z.1 * k z.1 z.2 := by | |
| funext z | |
| change μ (z.1,z.2.2) * L z.1 z.2.1 = | |
| firstMarginal μ z.1 * (L z.1 z.2.1 * M z.1 z.2.2) | |
| calc | |
| _ = (firstMarginal μ z.1 * M z.1 z.2.2) * L z.1 z.2.1 := by | |
| rw [marginal_mul_conditionalKernel μ fallbackY hμ] | |
| _ = _ := by ring | |
| have hmiddle : totalVariation c d = | |
| totalVariation (firstMarginal σ) (firstMarginal μ) := by | |
| rw [hc, hd] | |
| exact totalVariation_joint_common_kernel _ _ k hk | |
| have result := totalVariation_triangle p c d | |
| rw [hmiddle] at result | |
| have hmarg : firstMarginal σ = firstMarginal p := seedQuestionMarginal_first p | |
| rw [hmarg] at result | |
| exact result | |
| end | |
| end DFVSGames.Foundations.Repetition.ProfileCorrection | |
| namespace DFVSGames.Foundations.Repetition | |
| open scoped BigOperators | |
| open Games Information | |
| noncomputable section | |
| variable {X Y : Type*} [Fintype X] [Fintype Y] [DecidableEq X] [DecidableEq Y] | |
| def revealEndpoint (q : X × Y) (side : Bool) : X ⊕ Y := | |
| if side then Sum.inr q.2 else Sum.inl q.1 | |
| def revealLaw (μ : FiniteDistribution (X × Y)) : | |
| FiniteDistribution ((X × Y) × (X ⊕ Y)) := | |
| (μ.product (FiniteDistribution.uniform Bool)).pushforward | |
| (fun z => (z.1, revealEndpoint z.1 z.2)) | |
| theorem revealLaw_weight (μ : FiniteDistribution (X × Y)) (q : X × Y) (r : X ⊕ Y) : | |
| (revealLaw μ).weight (q,r) = | |
| (if r = Sum.inl q.1 then μ.weight q / 2 else 0) + | |
| (if r = Sum.inr q.2 then μ.weight q / 2 else 0) := by | |
| classical | |
| rcases q with ⟨x,y⟩ | |
| simp only [revealLaw, FiniteDistribution.pushforward, FiniteDistribution.product, | |
| Fintype.sum_prod_type, Prod.mk.injEq, ite_and] | |
| simp [revealEndpoint, FiniteDistribution.uniform, div_eq_mul_inv, add_comm, eq_comm] | |
| def revealFirstLaw (μ : FiniteDistribution (X × Y)) : | |
| FiniteDistribution ((X ⊕ Y) × (X × Y)) := | |
| (revealLaw μ).transport (Equiv.prodComm _ _) | |
| omit [DecidableEq X] [DecidableEq Y] in | |
| @[simp] theorem revealFirstLaw_weight (μ : FiniteDistribution (X × Y)) | |
| (r : X ⊕ Y) (q : X × Y) : | |
| (revealFirstLaw μ).weight (r,q) = (revealLaw μ).weight (q,r) := rfl | |
| def revealFallback (μ : FiniteDistribution (X × Y)) (r : X ⊕ Y) : | |
| FiniteDistribution (X × Y) := | |
| match r with | |
| | Sum.inl x => μ.pushforward (fun q => (x,q.2)) | |
| | Sum.inr y => μ.pushforward (fun q => (q.1,y)) | |
| def revealProfile (μ : FiniteDistribution (X × Y)) (r : X ⊕ Y) : | |
| FiniteDistribution (X × Y) := | |
| gameConditionalKernel (revealFirstLaw μ) (revealFallback μ r) r | |
| theorem revealProfile_inl_support (μ : FiniteDistribution (X × Y)) | |
| (x : X) (q : X × Y) (h : q.1 ≠ x) : | |
| (revealProfile μ (Sum.inl x)).weight q = 0 := by | |
| classical | |
| rcases q with ⟨x',y⟩ | |
| dsimp at h | |
| simp only [revealProfile, gameConditionalKernel, toGameLaw, conditionalKernel] | |
| split | |
| · simp [revealFallback, FiniteDistribution.pushforward, Fintype.sum_prod_type, | |
| Prod.mk.injEq, Ne.symm h] | |
| · simp [revealLaw_weight, Ne.symm h] | |
| theorem revealProfile_inr_support (μ : FiniteDistribution (X × Y)) | |
| (y : Y) (q : X × Y) (h : q.2 ≠ y) : | |
| (revealProfile μ (Sum.inr y)).weight q = 0 := by | |
| classical | |
| rcases q with ⟨x,y'⟩ | |
| dsimp at h | |
| simp only [revealProfile, gameConditionalKernel, toGameLaw, conditionalKernel] | |
| split | |
| · simp [revealFallback, FiniteDistribution.pushforward, Fintype.sum_prod_type, | |
| Prod.mk.injEq, Ne.symm h] | |
| · simp [revealLaw_weight, Ne.symm h] | |
| def revealInputLaw (μ : FiniteDistribution (X × Y)) : FiniteDistribution (X ⊕ Y) := | |
| (revealLaw μ).pushforward Prod.snd | |
| theorem revealInputLaw_weight (μ : FiniteDistribution (X × Y)) (r : X ⊕ Y) : | |
| (revealInputLaw μ).weight r = firstMarginal (revealFirstLaw μ).weight r := by | |
| classical | |
| cases r <;> | |
| simp [revealInputLaw, FiniteDistribution.pushforward, firstMarginal, Fintype.sum_prod_type] | |
| theorem reveal_profile_recombination (μ : FiniteDistribution (X × Y)) | |
| (r : X ⊕ Y) (q : X × Y) : | |
| (revealInputLaw μ).weight r * (revealProfile μ r).weight q = | |
| (revealLaw μ).weight (q,r) := by | |
| rw [revealInputLaw_weight] | |
| exact gameConditionalKernel_recombine (revealFirstLaw μ) (revealFallback μ r) r q | |
| theorem reveal_profile_inl_recombination (μ : FiniteDistribution (X × Y)) | |
| (x : X) (q : X × Y) : | |
| (revealInputLaw μ).weight (Sum.inl x) * (revealProfile μ (Sum.inl x)).weight q = | |
| if x = q.1 then μ.weight q / 2 else 0 := by | |
| rw [reveal_profile_recombination, revealLaw_weight] | |
| simp | |
| theorem reveal_profile_inr_recombination (μ : FiniteDistribution (X × Y)) | |
| (y : Y) (q : X × Y) : | |
| (revealInputLaw μ).weight (Sum.inr y) * (revealProfile μ (Sum.inr y)).weight q = | |
| if y = q.2 then μ.weight q / 2 else 0 := by | |
| rw [reveal_profile_recombination, revealLaw_weight] | |
| simp | |
| theorem revealInputLaw_inl (μ : FiniteDistribution (X × Y)) (x : X) : | |
| (revealInputLaw μ).weight (Sum.inl x) = (∑ y, μ.weight (x,y)) / 2 := by | |
| classical | |
| rw [revealInputLaw_weight] | |
| simp [firstMarginal, Fintype.sum_prod_type, revealLaw_weight, | |
| div_eq_mul_inv] | |
| rw [Finset.sum_comm] | |
| simp [← Finset.sum_mul] | |
| theorem revealInputLaw_inr (μ : FiniteDistribution (X × Y)) (y : Y) : | |
| (revealInputLaw μ).weight (Sum.inr y) = (∑ x, μ.weight (x,y)) / 2 := by | |
| classical | |
| rw [revealInputLaw_weight] | |
| simp [firstMarginal, Fintype.sum_prod_type, revealLaw_weight, | |
| div_eq_mul_inv, ← Finset.sum_mul] | |
| theorem revealProfile_inl_diagonal (μ : FiniteDistribution (X × Y)) (x : X) (y : Y) : | |
| (revealProfile μ (Sum.inl x)).weight (x,y) = | |
| conditionalKernel μ.weight (μ.pushforward Prod.snd).weight x y := by | |
| classical | |
| have hm : firstMarginal (revealFirstLaw μ).weight (Sum.inl x) = | |
| firstMarginal μ.weight x / 2 := by | |
| rw [← revealInputLaw_weight, revealInputLaw_inl] | |
| rfl | |
| have hf : (revealFallback μ (Sum.inl x)).weight (x,y) = | |
| (μ.pushforward Prod.snd).weight y := by | |
| simp [revealFallback, FiniteDistribution.pushforward, Prod.mk.injEq] | |
| apply Finset.sum_congr rfl | |
| intro q _ | |
| by_cases hq : q.2 = y <;> simp [hq] | |
| simp only [revealProfile, gameConditionalKernel, toGameLaw, conditionalKernel, hm] | |
| by_cases h : firstMarginal μ.weight x = 0 | |
| · simpa [h] using hf | |
| · have hh : firstMarginal μ.weight x / 2 ≠ 0 := div_ne_zero h (by norm_num) | |
| simp only [ite_eq_right h, ite_eq_right hh, revealFirstLaw_weight, revealLaw_weight, | |
| ite_true, Sum.inl_ne_inr, ite_false, add_zero] | |
| field_simp | |
| theorem revealProfile_inr_diagonal (μ : FiniteDistribution (X × Y)) (x : X) (y : Y) : | |
| (revealProfile μ (Sum.inr y)).weight (x,y) = | |
| conditionalKernel (μ.transport (Equiv.prodComm X Y)).weight | |
| (μ.pushforward Prod.fst).weight y x := by | |
| classical | |
| have hm : firstMarginal (revealFirstLaw μ).weight (Sum.inr y) = | |
| firstMarginal (μ.transport (Equiv.prodComm X Y)).weight y / 2 := by | |
| rw [← revealInputLaw_weight, revealInputLaw_inr] | |
| rfl | |
| have hf : (revealFallback μ (Sum.inr y)).weight (x,y) = | |
| (μ.pushforward Prod.fst).weight x := by | |
| simp [revealFallback, FiniteDistribution.pushforward, Prod.mk.injEq] | |
| apply Finset.sum_congr rfl | |
| intro q _ | |
| by_cases hq : q.1 = x <;> simp [hq] | |
| simp only [revealProfile, gameConditionalKernel, toGameLaw, conditionalKernel, hm] | |
| by_cases h : firstMarginal (μ.transport (Equiv.prodComm X Y)).weight y = 0 | |
| · simpa [h] using hf | |
| · have hh : firstMarginal (μ.transport (Equiv.prodComm X Y)).weight y / 2 ≠ 0 := | |
| div_ne_zero h (by norm_num) | |
| simp only [ite_eq_right h, ite_eq_right hh, revealFirstLaw_weight, revealLaw_weight, | |
| ite_true, Sum.inr_ne_inl, ite_false, zero_add] | |
| change (μ.weight (x,y) / 2) / (firstMarginal (μ.transport (Equiv.prodComm X Y)).weight y / 2) = | |
| μ.weight (x,y) / firstMarginal (μ.transport (Equiv.prodComm X Y)).weight y | |
| field_simp | |
| theorem revealLaw_sum_left (μ : FiniteDistribution (X × Y)) (q : X × Y) : | |
| (∑ x, (revealLaw μ).weight (q, Sum.inl x)) = μ.weight q / 2 := by | |
| classical | |
| simp [revealLaw_weight] | |
| theorem revealLaw_sum_right (μ : FiniteDistribution (X × Y)) (q : X × Y) : | |
| (∑ y, (revealLaw μ).weight (q, Sum.inr y)) = μ.weight q / 2 := by | |
| classical | |
| simp [revealLaw_weight] | |
| theorem revealLaw_forget (μ : FiniteDistribution (X × Y)) : | |
| (revealLaw μ).pushforward Prod.fst = μ := by | |
| classical | |
| apply FiniteDistribution.eq_of_weight_eq | |
| intro q | |
| rcases q with ⟨x,y⟩ | |
| simp [FiniteDistribution.pushforward, Fintype.sum_prod_type, | |
| Finset.sum_ite_irrel, revealLaw_weight] | |
| theorem reveal_product_factorization {ι : Type*} [Fintype ι] | |
| (μ : FiniteDistribution (X × Y)) (r : ι → X ⊕ Y) (q : ι → X × Y) : | |
| (∏ i, (revealInputLaw μ).weight (r i)) * | |
| (∏ i, (revealProfile μ (r i)).weight (q i)) = | |
| ∏ i, (revealLaw μ).weight (q i,r i) := by | |
| rw [← Finset.prod_mul_distrib] | |
| apply Finset.prod_congr rfl | |
| intro i _ | |
| exact reveal_profile_recombination μ (r i) (q i) | |
| theorem reveal_product_forget {ι : Type*} [Fintype ι] [DecidableEq ι] | |
| (μ : FiniteDistribution (X × Y)) (q : ι → X × Y) : | |
| (∑ r : ι → X ⊕ Y, | |
| (∏ i, (revealInputLaw μ).weight (r i)) * | |
| (∏ i, (revealProfile μ (r i)).weight (q i))) = | |
| ∏ i, μ.weight (q i) := by | |
| classical | |
| simp_rw [reveal_product_factorization] | |
| calc | |
| _ = ∏ i, ∑ r : X ⊕ Y, (revealLaw μ).weight (q i,r) := | |
| (Fintype.prod_sum (fun (i : ι) (r : X ⊕ Y) => (revealLaw μ).weight (q i,r))).symm | |
| _ = _ := by | |
| apply Finset.prod_congr rfl | |
| intro i _ | |
| rw [Fintype.sum_sum_type, revealLaw_sum_left, revealLaw_sum_right] | |
| ring | |
| theorem reveal_product_expectation {ι : Type*} [Fintype ι] [DecidableEq ι] | |
| (μ : FiniteDistribution (X × Y)) (f : (ι → X × Y) → ℝ) : | |
| (∑ r : ι → X ⊕ Y, | |
| (∏ i, (revealInputLaw μ).weight (r i)) * | |
| ∑ q : ι → X × Y, (∏ i, (revealProfile μ (r i)).weight (q i)) * f q) = | |
| ∑ q : ι → X × Y, (∏ i, μ.weight (q i)) * f q := by | |
| classical | |
| simp_rw [Finset.mul_sum] | |
| rw [Finset.sum_comm] | |
| apply Finset.sum_congr rfl | |
| intro q _ | |
| simp_rw [← mul_assoc, ← Finset.sum_mul] | |
| rw [reveal_product_forget] | |
| end | |
| end DFVSGames.Foundations.Repetition | |
| namespace DFVSGames.Foundations.Information | |
| open scoped BigOperators | |
| variable {α : Type*} [Fintype α] | |
| noncomputable def hellingerSquared (p q : α → ℝ) : ℝ := | |
| ∑ a, (Real.sqrt (p a) - Real.sqrt (q a)) ^ 2 | |
| theorem sqrt_distance_le_relativeEntropy_term {x y : ℝ} (hx : 0 ≤ x) (hy : 0 ≤ y) | |
| (hs : x ≠ 0 → y ≠ 0) : | |
| (Real.sqrt x - Real.sqrt y)^2 ≤ x * Real.log (x / y) - x + y := by | |
| by_cases hxzero : x = 0 | |
| · subst x | |
| simp [Real.sq_sqrt hy] | |
| have hxpos : 0 < x := lt_of_le_of_ne hx (Ne.symm hxzero) | |
| have hypos : 0 < y := lt_of_le_of_ne hy (Ne.symm (hs hxzero)) | |
| have hsx : 0 < Real.sqrt x := Real.sqrt_pos.2 hxpos | |
| have hsy : 0 < Real.sqrt y := Real.sqrt_pos.2 hypos | |
| have hlog := Real.log_le_sub_one_of_pos (div_pos hsy hsx) | |
| have hlogid : Real.log (Real.sqrt y / Real.sqrt x) = | |
| -(Real.log (x / y)) / 2 := by | |
| rw [Real.log_div hsy.ne' hsx.ne', Real.log_sqrt hy, Real.log_sqrt hx, | |
| Real.log_div hxzero (hs hxzero)] | |
| ring | |
| have hprod : x * (Real.sqrt y / Real.sqrt x) = Real.sqrt x * Real.sqrt y := by | |
| calc | |
| x * (Real.sqrt y / Real.sqrt x) = (Real.sqrt x)^2 * (Real.sqrt y / Real.sqrt x) := by | |
| rw [Real.sq_sqrt hx] | |
| _ = Real.sqrt x * Real.sqrt y := by field_simp [hsx.ne'] | |
| have hm := mul_le_mul_of_nonneg_left hlog hx | |
| rw [hlogid, mul_sub, mul_one, hprod] at hm | |
| nlinarith [Real.sq_sqrt hx, Real.sq_sqrt hy] | |
| theorem hellingerSquared_le_relativeEntropy (p q : α → ℝ) (hp : IsProbability p) | |
| (hq : IsProbability q) (hs : SupportedBy p q) : | |
| hellingerSquared p q ≤ relativeEntropy p q := by | |
| have hsum := Finset.sum_le_sum (fun a (_ : a ∈ (Finset.univ : Finset α)) => | |
| sqrt_distance_le_relativeEntropy_term (hp.1 a) (hq.1 a) (hs a)) | |
| simpa only [hellingerSquared, relativeEntropy, Finset.sum_add_distrib, | |
| Finset.sum_sub_distrib, hp.2, hq.2, sub_add_cancel] using hsum | |
| theorem totalVariation_sq_le_hellingerSquared (p q : α → ℝ) (hp : IsProbability p) | |
| (hq : IsProbability q) : totalVariation p q ^ 2 ≤ hellingerSquared p q := by | |
| have hfactor : ∀ a, |Real.sqrt (p a) - Real.sqrt (q a)| * | |
| (Real.sqrt (p a) + Real.sqrt (q a)) = |p a - q a| := by | |
| intro a | |
| rw [← abs_of_nonneg (add_nonneg (Real.sqrt_nonneg _) (Real.sqrt_nonneg _)), | |
| ← abs_mul] | |
| congr 1 | |
| nlinarith [Real.sq_sqrt (hp.1 a), Real.sq_sqrt (hq.1 a)] | |
| have hcs := Finset.sum_mul_sq_le_sq_mul_sq (Finset.univ : Finset α) | |
| (fun a => |Real.sqrt (p a) - Real.sqrt (q a)|) | |
| (fun a => Real.sqrt (p a) + Real.sqrt (q a)) | |
| simp only [hfactor, sq_abs] at hcs | |
| have hpoint : ∀ a, (Real.sqrt (p a) + Real.sqrt (q a)) ^ 2 ≤ 2 * (p a + q a) := by | |
| intro a | |
| nlinarith [sq_nonneg (Real.sqrt (p a) - Real.sqrt (q a)), | |
| Real.sq_sqrt (hp.1 a), Real.sq_sqrt (hq.1 a)] | |
| have hsum := Finset.sum_le_sum (fun a (_ : a ∈ (Finset.univ : Finset α)) => hpoint a) | |
| simp only [← Finset.mul_sum, Finset.sum_add_distrib, hp.2, hq.2] at hsum | |
| have hnonneg : 0 ≤ ∑ a, (Real.sqrt (p a) - Real.sqrt (q a)) ^ 2 := | |
| Finset.sum_nonneg (fun a _ => sq_nonneg _) | |
| have hmul := mul_le_mul_of_nonneg_left hsum hnonneg | |
| dsimp [totalVariation, hellingerSquared] | |
| nlinarith | |
| theorem totalVariation_sq_le_relativeEntropy (p q : α → ℝ) (hp : IsProbability p) | |
| (hq : IsProbability q) (hs : SupportedBy p q) : | |
| totalVariation p q ^ 2 ≤ relativeEntropy p q := | |
| (totalVariation_sq_le_hellingerSquared p q hp hq).trans | |
| (hellingerSquared_le_relativeEntropy p q hp hq hs) | |
| theorem posterior_totalVariation_sq_le_log (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) : | |
| totalVariation (posterior p w z) p ^ 2 ≤ Real.log (1 / z) := by | |
| exact (totalVariation_sq_le_relativeEntropy _ _ (posterior_isProbability p w hp hw hz hmass) | |
| hp (posterior_supportedBy p w z)).trans | |
| (posterior_relativeEntropy_le p w hp hw hw_one hz hmass) | |
| end DFVSGames.Foundations.Information | |
| namespace DFVSGames.Foundations.Information | |
| open scoped BigOperators | |
| variable {ι α : Type*} [Fintype ι] [Fintype α] [DecidableEq ι] | |
| noncomputable def coordinateMarginal (p : (ι → α) → ℝ) (i : ι) (a : α) : ℝ := by | |
| classical | |
| exact ∑ x, if x i = a then p x else 0 | |
| noncomputable def independentProduct (q : ι → α → ℝ) (x : ι → α) : ℝ := ∏ i, q i (x i) | |
| theorem coordinateMarginal_isProbability (p : (ι → α) → ℝ) (hp : IsProbability p) (i : ι) : | |
| IsProbability (coordinateMarginal p i) := by | |
| classical | |
| constructor | |
| · intro a | |
| apply Finset.sum_nonneg | |
| intro x _ | |
| split_ifs | |
| · exact hp.1 x | |
| · exact le_rfl | |
| · simp only [coordinateMarginal] | |
| rw [Finset.sum_comm] | |
| simpa using hp.2 | |
| theorem point_le_coordinateMarginal (p : (ι → α) → ℝ) (hp : IsProbability p) | |
| (i : ι) (x : ι → α) : p x ≤ coordinateMarginal p i (x i) := by | |
| classical | |
| have h := Finset.single_le_sum | |
| (f := fun y : ι → α => if y i = x i then p y else 0) | |
| (fun y _ => by split_ifs; exact hp.1 y; exact le_rfl) (Finset.mem_univ x) | |
| simpa [coordinateMarginal] using h | |
| theorem marginal_expectation (p : (ι → α) → ℝ) (i : ι) (f : α → ℝ) : | |
| (∑ x, p x * f (x i)) = ∑ a, coordinateMarginal p i a * f a := by | |
| classical | |
| simp only [coordinateMarginal, Finset.sum_mul] | |
| rw [Finset.sum_comm] | |
| apply Finset.sum_congr rfl | |
| intro x _ | |
| simp [ite_mul] | |
| theorem independentProduct_isProbability (q : ι → α → ℝ) (hq : ∀ i, IsProbability (q i)) : | |
| IsProbability (independentProduct q) := by | |
| classical | |
| constructor | |
| · intro x | |
| exact Finset.prod_nonneg (fun i _ => (hq i).1 (x i)) | |
| · simp only [independentProduct, ← Fintype.prod_sum, (hq _).2, Finset.prod_const_one] | |
| theorem joint_supportedBy_product_coordinateMarginals (p : (ι → α) → ℝ) | |
| (hp : IsProbability p) : SupportedBy p (independentProduct (coordinateMarginal p)) := by | |
| intro x hx | |
| apply Finset.prod_ne_zero_iff.mpr | |
| intro i _ | |
| exact ne_of_gt ((lt_of_le_of_ne (hp.1 x) (Ne.symm hx)).trans_le | |
| (point_le_coordinateMarginal p hp i x)) | |
| theorem relativeEntropy_independent_reference (p : (ι → α) → ℝ) (q : ι → α → ℝ) | |
| (hp : IsProbability p) (_hq : ∀ i, IsProbability (q i)) | |
| (hs : ∀ i, SupportedBy (coordinateMarginal p i) (q i)) : | |
| relativeEntropy p (independentProduct q) = | |
| relativeEntropy p (independentProduct (coordinateMarginal p)) + | |
| ∑ i, relativeEntropy (coordinateMarginal p i) (q i) := by | |
| classical | |
| have hpoint : ∀ x : ι → α, p x * Real.log (p x / independentProduct q x) = | |
| p x * Real.log (p x / independentProduct (coordinateMarginal p) x) + | |
| ∑ i, p x * Real.log (coordinateMarginal p i (x i) / q i (x i)) := by | |
| intro x | |
| by_cases hx : p x = 0 | |
| · simp [hx] | |
| have hm : ∀ i, coordinateMarginal p i (x i) ≠ 0 := by | |
| intro i | |
| exact ne_of_gt ((lt_of_le_of_ne (hp.1 x) (Ne.symm hx)).trans_le | |
| (point_le_coordinateMarginal p hp i x)) | |
| have hqne : ∀ i, q i (x i) ≠ 0 := fun i => hs i (x i) (hm i) | |
| have hmp : (∏ i, coordinateMarginal p i (x i)) ≠ 0 := | |
| Finset.prod_ne_zero_iff.mpr (fun i _ => hm i) | |
| have hqp : (∏ i, q i (x i)) ≠ 0 := | |
| Finset.prod_ne_zero_iff.mpr (fun i _ => hqne i) | |
| simp only [independentProduct, Real.log_div hx hmp, Real.log_div hx hqp, | |
| Real.log_prod (fun i _ => hm i), Real.log_prod (fun i _ => hqne i)] | |
| simp_rw [Real.log_div (hm _) (hqne _)] | |
| rw [← Finset.mul_sum, Finset.sum_sub_distrib] | |
| ring | |
| calc | |
| relativeEntropy p (independentProduct q) = | |
| ∑ x, (p x * Real.log (p x / independentProduct (coordinateMarginal p) x) + | |
| ∑ i, p x * Real.log (coordinateMarginal p i (x i) / q i (x i))) := by | |
| exact Finset.sum_congr rfl (fun x _ => hpoint x) | |
| _ = relativeEntropy p (independentProduct (coordinateMarginal p)) + | |
| ∑ i, ∑ x, p x * Real.log (coordinateMarginal p i (x i) / q i (x i)) := by | |
| rw [Finset.sum_add_distrib, Finset.sum_comm] | |
| rfl | |
| _ = relativeEntropy p (independentProduct (coordinateMarginal p)) + | |
| ∑ i, relativeEntropy (coordinateMarginal p i) (q i) := by | |
| congr 1 | |
| apply Finset.sum_congr rfl | |
| intro i _ | |
| exact marginal_expectation p i (fun a => Real.log (coordinateMarginal p i a / q i a)) | |
| theorem coordinate_relativeEntropy_sum_le (p : (ι → α) → ℝ) (q : ι → α → ℝ) | |
| (hp : IsProbability p) (hq : ∀ i, IsProbability (q i)) | |
| (hs : ∀ i, SupportedBy (coordinateMarginal p i) (q i)) : | |
| (∑ i, relativeEntropy (coordinateMarginal p i) (q i)) ≤ | |
| relativeEntropy p (independentProduct q) := by | |
| rw [relativeEntropy_independent_reference p q hp hq hs] | |
| exact le_add_of_nonneg_left (relativeEntropy_nonneg _ _ hp | |
| (independentProduct_isProbability _ (coordinateMarginal_isProbability p hp)) | |
| (joint_supportedBy_product_coordinateMarginals p hp)) | |
| theorem coordinate_totalVariation_sq_sum_le (p : (ι → α) → ℝ) (q : ι → α → ℝ) | |
| (hp : IsProbability p) (hq : ∀ i, IsProbability (q i)) | |
| (hs : ∀ i, SupportedBy (coordinateMarginal p i) (q i)) : | |
| (∑ i, totalVariation (coordinateMarginal p i) (q i) ^ 2) ≤ | |
| relativeEntropy p (independentProduct q) := by | |
| exact (Finset.sum_le_sum (fun i _ => totalVariation_sq_le_relativeEntropy _ _ | |
| (coordinateMarginal_isProbability p hp i) (hq i) (hs i))).trans | |
| (coordinate_relativeEntropy_sum_le p q hp hq hs) | |
| theorem posterior_coordinate_supportedBy (q : ι → α → ℝ) (w : (ι → α) → ℝ) | |
| (z : ℝ) (i : ι) : | |
| SupportedBy (coordinateMarginal (posterior (independentProduct q) w z) i) (q i) := by | |
| classical | |
| intro a ha hqa | |
| apply ha | |
| unfold coordinateMarginal | |
| apply Finset.sum_eq_zero | |
| intro x _ | |
| by_cases hxa : x i = a | |
| · have hzprod : independentProduct q x = 0 := by | |
| exact Finset.prod_eq_zero (Finset.mem_univ i) (by simpa only [hxa] using hqa) | |
| simp [hxa, posterior, hzprod] | |
| · simp [hxa] | |
| theorem posterior_coordinate_totalVariation_sq_sum_le_log | |
| (q : ι → α → ℝ) (hq : ∀ i, IsProbability (q i)) (w : (ι → α) → ℝ) | |
| (hw : ∀ x, 0 ≤ w x) (hw_one : ∀ x, w x ≤ 1) {z : ℝ} (hz : 0 < z) | |
| (hmass : ∑ x, independentProduct q x * w x = z) : | |
| (∑ i, totalVariation | |
| (coordinateMarginal (posterior (independentProduct q) w z) i) (q i) ^ 2) ≤ | |
| Real.log (1 / z) := by | |
| have hp := independentProduct_isProbability q hq | |
| exact (coordinate_totalVariation_sq_sum_le _ q | |
| (posterior_isProbability _ w hp hw hz hmass) hq | |
| (posterior_coordinate_supportedBy q w z)).trans | |
| (posterior_relativeEntropy_le _ w hp hw hw_one hz hmass) | |
| theorem posterior_coordinate_totalVariation_sum_le_sqrt | |
| (q : ι → α → ℝ) (hq : ∀ i, IsProbability (q i)) (w : (ι → α) → ℝ) | |
| (hw : ∀ x, 0 ≤ w x) (hw_one : ∀ x, w x ≤ 1) {z : ℝ} (hz : 0 < z) | |
| (hmass : ∑ x, independentProduct q x * w x = z) : | |
| (∑ i, totalVariation | |
| (coordinateMarginal (posterior (independentProduct q) w z) i) (q i)) ≤ | |
| Real.sqrt ((Fintype.card ι : ℝ) * Real.log (1 / z)) := by | |
| let d : ι → ℝ := fun i => totalVariation | |
| (coordinateMarginal (posterior (independentProduct q) w z) i) (q i) | |
| have hsq := posterior_coordinate_totalVariation_sq_sum_le_log q hq w hw hw_one hz hmass | |
| have hcs := Finset.sum_mul_sq_le_sq_mul_sq (Finset.univ : Finset ι) d (fun _ => (1 : ℝ)) | |
| simp only [mul_one, one_pow, Finset.sum_const, Finset.card_univ, nsmul_eq_mul, mul_one] at hcs | |
| have hln : 0 ≤ Real.log (1 / z) := by | |
| have hp := independentProduct_isProbability q hq | |
| exact (relativeEntropy_nonneg _ _ (posterior_isProbability _ w hp hw hz hmass) hp | |
| (posterior_supportedBy _ w z)).trans | |
| (posterior_relativeEntropy_le _ w hp hw hw_one hz hmass) | |
| have hcard : 0 ≤ (Fintype.card ι : ℝ) := Nat.cast_nonneg _ | |
| have hmul := mul_le_mul_of_nonneg_left hsq hcard | |
| have hsqrt := Real.sq_sqrt (mul_nonneg hcard hln) | |
| have hsqrtpos := Real.sqrt_nonneg ((Fintype.card ι : ℝ) * Real.log (1 / z)) | |
| change (∑ i, d i) ≤ _ | |
| change (∑ i, d i ^ 2) ≤ _ at hsq | |
| change (Fintype.card ι : ℝ) * (∑ i, d i ^ 2) ≤ _ at hmul | |
| nlinarith | |
| theorem posterior_coordinate_totalVariation_sq_sum_le_binaryLog | |
| (q : ι → α → ℝ) (hq : ∀ i, IsProbability (q i)) (w : (ι → α) → ℝ) | |
| (hw : ∀ x, 0 ≤ w x) (hw_one : ∀ x, w x ≤ 1) {z : ℝ} (hz : 0 < z) | |
| (hmass : ∑ x, independentProduct q x * w x = z) : | |
| (∑ i, totalVariation | |
| (coordinateMarginal (posterior (independentProduct q) w z) i) (q i) ^ 2) ≤ | |
| Real.log (1 / z) / Real.log 2 := by | |
| exact le_binaryLog_of_le_log (Finset.sum_nonneg (fun _ _ => sq_nonneg _)) | |
| (posterior_coordinate_totalVariation_sq_sum_le_log q hq w hw hw_one hz hmass) | |
| end DFVSGames.Foundations.Information | |
| namespace DFVSGames.Foundations.Information | |
| open scoped BigOperators | |
| variable {α : Type*} [Fintype α] | |
| theorem normalize_isProbability (b : α → ℝ) (hb : ∀ a, 0 ≤ b a) | |
| {B : ℝ} (hB : 0 < B) (hmass : ∑ a, b a = B) : | |
| IsProbability (fun a => b a / B) := by | |
| constructor | |
| · intro a | |
| exact div_nonneg (hb a) hB.le | |
| · simp only [div_eq_mul_inv, ← Finset.sum_mul, hmass, mul_inv_cancel₀ hB.ne'] | |
| theorem relativeEntropy_normalize_right (p b : α → ℝ) (hp : IsProbability p) | |
| (hs : SupportedBy p b) {B : ℝ} (hB : 0 < B) : | |
| relativeEntropy p (fun a => b a / B) = relativeEntropy p b + Real.log B := by | |
| have hpoint : ∀ a, p a * Real.log (p a / (b a / B)) = | |
| p a * Real.log (p a / b a) + p a * Real.log B := by | |
| intro a | |
| by_cases hpa : p a = 0 | |
| · simp [hpa] | |
| have hbne := hs a hpa | |
| rw [Real.log_div hpa (div_ne_zero hbne hB.ne'), Real.log_div hbne hB.ne', | |
| Real.log_div hpa hbne] | |
| ring | |
| simp only [relativeEntropy, hpoint, Finset.sum_add_distrib, ← Finset.sum_mul, hp.2, one_mul] | |
| theorem neg_relativeEntropy_le_log_mass (p b : α → ℝ) (hp : IsProbability p) | |
| (hb : ∀ a, 0 ≤ b a) (hs : SupportedBy p b) {B : ℝ} (hB : 0 < B) | |
| (hmass : ∑ a, b a = B) : -relativeEntropy p b ≤ Real.log B := by | |
| have hs' : SupportedBy p (fun a => b a / B) := | |
| fun a ha => div_ne_zero (hs a ha) hB.ne' | |
| have hnonneg := relativeEntropy_nonneg p (fun a => b a / B) hp | |
| (normalize_isProbability b hb hB hmass) hs' | |
| rw [relativeEntropy_normalize_right p b hp hs hB] at hnonneg | |
| linarith | |
| theorem posterior_weighted_log_inverse_le (p b c : α → ℝ) (hp : IsProbability p) | |
| (hb : ∀ a, 0 ≤ b a) {z B : ℝ} (hz : 0 < z) (hB : 0 < B) | |
| (hmass : ∑ a, b a = B) (hpost : ∀ a, p a = b a * c a / z) : | |
| (∑ a, p a * Real.log (1 / c a)) ≤ Real.log (B / z) := by | |
| have hs : SupportedBy p b := by | |
| intro a ha hba | |
| apply ha | |
| rw [hpost, hba, zero_mul, zero_div] | |
| have hpoint : ∀ a, p a * Real.log (1 / c a) = | |
| p a * Real.log (1 / z) - p a * Real.log (p a / b a) := by | |
| intro a | |
| by_cases hpa : p a = 0 | |
| · simp [hpa] | |
| have hbne := hs a hpa | |
| have hcne : c a ≠ 0 := by | |
| intro hca | |
| apply hpa | |
| rw [hpost, hca, mul_zero, zero_div] | |
| have hratio : p a / b a = c a / z := by | |
| rw [hpost] | |
| field_simp [hbne, hz.ne'] | |
| rw [hratio, Real.log_div hcne hz.ne', Real.log_div one_ne_zero hcne, | |
| Real.log_div one_ne_zero hz.ne', Real.log_one] | |
| ring | |
| have hid : (∑ a, p a * Real.log (1 / c a)) = | |
| Real.log (1 / z) - relativeEntropy p b := by | |
| simp only [hpoint, Finset.sum_sub_distrib, ← Finset.sum_mul, hp.2, one_mul, | |
| relativeEntropy] | |
| have hkl := neg_relativeEntropy_le_log_mass p b hp hb hs hB hmass | |
| rw [hid, Real.log_div hB.ne' hz.ne', Real.log_div one_ne_zero hz.ne', Real.log_one] | |
| linarith | |
| end DFVSGames.Foundations.Information | |
| namespace DFVSGames.Foundations.Information | |
| open scoped BigOperators | |
| noncomputable def posteriorOrOriginal | |
| {A : Type*} [Fintype A] (p e : A → ℝ) (z : ℝ) : A → ℝ := by | |
| classical | |
| exact if 0 < z then posterior p e z else p | |
| theorem posteriorOrOriginal_isProbability | |
| {A : Type*} [Fintype A] (p e : A → ℝ) | |
| (hp : IsProbability p) (he : ∀ a, 0 ≤ e a) | |
| {z : ℝ} (hmass : ∑ a, p a * e a = z) : | |
| IsProbability (posteriorOrOriginal p e z) := by | |
| classical | |
| by_cases hz : 0 < z | |
| · simpa only [posteriorOrOriginal, ite_eq_left hz] using | |
| posterior_isProbability p e hp he hz hmass | |
| · simpa only [posteriorOrOriginal, ite_eq_right hz] using hp | |
| theorem mass_mul_posteriorOrOriginal | |
| {A : Type*} [Fintype A] (p e : A → ℝ) | |
| (hp : IsProbability p) (he : ∀ a, 0 ≤ e a) | |
| {c : ℝ} (hmass : ∑ a, p a * e a = c) (x : A) : | |
| c * posteriorOrOriginal p e c x = p x * e x := by | |
| classical | |
| by_cases hc : 0 < c | |
| · simp only [posteriorOrOriginal, ite_eq_left hc, posterior] | |
| field_simp [hc.ne'] | |
| · have hcnonneg : 0 ≤ c := by | |
| rw [← hmass] | |
| exact Finset.sum_nonneg (fun a _ => mul_nonneg (hp.1 a) (he a)) | |
| have hc0 : c = 0 := le_antisymm (le_of_not_gt hc) hcnonneg | |
| have hpoint := Finset.single_le_sum | |
| (fun a (_ : a ∈ (Finset.univ : Finset A)) => mul_nonneg (hp.1 a) (he a)) | |
| (Finset.mem_univ x) | |
| rw [hmass, hc0] at hpoint | |
| have hzero : p x * e x = 0 := le_antisymm hpoint (mul_nonneg (hp.1 x) (he x)) | |
| simp [posteriorOrOriginal, hc0, hzero] | |
| theorem weighted_coordinate_posterior_recombine | |
| {I A : Type*} [Fintype I] [Fintype A] [DecidableEq I] [DecidableEq A] | |
| (p e : (I → A) → ℝ) (hp : IsProbability p) (he : ∀ x, 0 ≤ e x) | |
| {c : ℝ} (hmass : ∑ x, p x * e x = c) (b z : ℝ) (i : I) (a : A) : | |
| (b * c / z) * coordinateMarginal (posteriorOrOriginal p e c) i a = | |
| (b / z) * ∑ x, if x i = a then p x * e x else 0 := by | |
| classical | |
| simp only [coordinateMarginal, Finset.mul_sum] | |
| apply Finset.sum_congr rfl | |
| intro x _ | |
| by_cases hxa : x i = a | |
| · simp only [ite_eq_left hxa] | |
| calc | |
| (b * c / z) * posteriorOrOriginal p e c x = | |
| (b / z) * (c * posteriorOrOriginal p e c x) := by ring | |
| _ = (b / z) * (p x * e x) := by | |
| rw [mass_mul_posteriorOrOriginal p e hp he hmass x] | |
| · simp [hxa] | |
| variable {J I A : Type*} | |
| variable [Fintype J] [Fintype I] [Fintype A] [DecidableEq I] | |
| theorem side_information_bound | |
| (w b c : J → ℝ) | |
| (q : J → I → A → ℝ) | |
| (e : J → (I → A) → ℝ) | |
| (hw : IsProbability w) | |
| (hb : ∀ j, 0 ≤ b j) | |
| (hq : ∀ j i, IsProbability (q j i)) | |
| (he : ∀ j x, 0 ≤ e j x) | |
| (he_one : ∀ j x, e j x ≤ 1) | |
| (hmass : ∀ j, ∑ x, independentProduct (q j) x * e j x = c j) | |
| {z B : ℝ} (hz : 0 < z) (hB : 0 < B) | |
| (hbase : ∑ j, b j = B) | |
| (hweight : ∀ j, w j = b j * c j / z) : | |
| (∑ i, totalVariation | |
| (fun ja : J × A => w ja.1 * coordinateMarginal | |
| (posteriorOrOriginal (independentProduct (q ja.1)) | |
| (e ja.1) (c ja.1)) i ja.2) | |
| (fun ja : J × A => w ja.1 * q ja.1 i ja.2)) ≤ | |
| Real.sqrt ((Fintype.card I : ℝ) * Real.log (B / z)) := by | |
| classical | |
| let d : J → I → ℝ := fun j i => totalVariation | |
| (coordinateMarginal | |
| (posteriorOrOriginal (independentProduct (q j)) (e j) (c j)) i) | |
| (q j i) | |
| have hbudget : ∀ j, | |
| w j * (∑ i, d j i ^ 2) ≤ w j * Real.log (1 / c j) := by | |
| intro j | |
| by_cases hwzero : w j = 0 | |
| · simp [hwzero] | |
| have hcne : c j ≠ 0 := by | |
| intro hczero | |
| apply hwzero | |
| rw [hweight j, hczero, mul_zero, zero_div] | |
| have hcnonneg : 0 ≤ c j := by | |
| rw [← hmass j] | |
| exact Finset.sum_nonneg (fun x _ => mul_nonneg | |
| ((independentProduct_isProbability (q j) (hq j)).1 x) (he j x)) | |
| have hcpos : 0 < c j := lt_of_le_of_ne hcnonneg (Ne.symm hcne) | |
| have hlocal := posterior_coordinate_totalVariation_sq_sum_le_log | |
| (q j) (hq j) (e j) (he j) (he_one j) hcpos (hmass j) | |
| have hweighted := mul_le_mul_of_nonneg_left hlocal (hw.1 j) | |
| simpa only [d, posteriorOrOriginal, ite_eq_left hcpos] using hweighted | |
| have hcs := weighted_coordinate_sum_sq_le | |
| w d (fun j => Real.log (1 / c j)) hw hbudget | |
| have hlog := posterior_weighted_log_inverse_le w b c hw hb hz hB hbase hweight | |
| have hsq : (∑ i, ∑ j, w j * d j i)^2 ≤ | |
| (Fintype.card I : ℝ) * Real.log (B / z) := | |
| hcs.trans (mul_le_mul_of_nonneg_left hlog (Nat.cast_nonneg _)) | |
| have htv : ∀ i, totalVariation | |
| (fun ja : J × A => w ja.1 * coordinateMarginal | |
| (posteriorOrOriginal (independentProduct (q ja.1)) | |
| (e ja.1) (c ja.1)) i ja.2) | |
| (fun ja : J × A => w ja.1 * q ja.1 i ja.2) = | |
| ∑ j, w j * d j i := by | |
| intro i | |
| exact totalVariation_joint_common_weights w | |
| (fun j => coordinateMarginal | |
| (posteriorOrOriginal (independentProduct (q j)) (e j) (c j)) i) | |
| (fun j => q j i) hw.1 | |
| simp_rw [htv] | |
| have hradicand : 0 ≤ (Fintype.card I : ℝ) * Real.log (B / z) := | |
| (sq_nonneg _).trans hsq | |
| have hsqrt := Real.sq_sqrt hradicand | |
| have hsqrt_nonneg := Real.sqrt_nonneg ((Fintype.card I : ℝ) * Real.log (B / z)) | |
| nlinarith | |
| variable {T V : Type*} [Fintype T] [Fintype V] [Nonempty V] | |
| theorem finite_side_information_bound | |
| (pT : T → ℝ) (q : T → I → A → ℝ) | |
| (e : T × V → (I → A) → ℝ) (c w : T × V → ℝ) | |
| (hpT : IsProbability pT) | |
| (hq : ∀ t i, IsProbability (q t i)) | |
| (he : ∀ tv x, 0 ≤ e tv x) | |
| (he_sum : ∀ t x, (∑ v, e (t, v) x) ≤ 1) | |
| (hc : ∀ tv, ∑ x, independentProduct (q tv.1) x * e tv x = c tv) | |
| {z : ℝ} (hz : 0 < z) | |
| (hZ : ∑ tv, pT tv.1 * c tv = z) | |
| (hweight : ∀ tv, w tv = pT tv.1 * c tv / z) : | |
| (∑ i, totalVariation | |
| (fun tva : (T × V) × A => w tva.1 * coordinateMarginal | |
| (posteriorOrOriginal (independentProduct (q tva.1.1)) | |
| (e tva.1) (c tva.1)) i tva.2) | |
| (fun tva : (T × V) × A => w tva.1 * q tva.1.1 i tva.2)) ≤ | |
| Real.sqrt ((Fintype.card I : ℝ) * | |
| (Real.log (Fintype.card V : ℝ) + Real.log (1 / z))) := by | |
| classical | |
| have hcnonneg : ∀ tv, 0 ≤ c tv := by | |
| intro tv | |
| rw [← hc tv] | |
| exact Finset.sum_nonneg (fun x _ => mul_nonneg | |
| ((independentProduct_isProbability (q tv.1) (hq tv.1)).1 x) (he tv x)) | |
| have hw : IsProbability w := by | |
| constructor | |
| · intro tv | |
| rw [hweight tv] | |
| exact div_nonneg (mul_nonneg (hpT.1 tv.1) (hcnonneg tv)) hz.le | |
| · simp_rw [hweight, div_eq_mul_inv] | |
| rw [← Finset.sum_mul, hZ, mul_inv_cancel₀ hz.ne'] | |
| have he_one : ∀ tv x, e tv x ≤ 1 := by | |
| intro tv x | |
| have hsingle : e tv x ≤ ∑ v, e (tv.1, v) x := | |
| Finset.single_le_sum (fun v _ => he (tv.1, v) x) (Finset.mem_univ tv.2) | |
| exact hsingle.trans (he_sum tv.1 x) | |
| have hB : 0 < (Fintype.card V : ℝ) := Nat.cast_pos.mpr Fintype.card_pos | |
| have hbase : (∑ tv : T × V, pT tv.1) = (Fintype.card V : ℝ) := by | |
| simp only [Fintype.sum_prod_type, Finset.sum_const, Finset.card_univ, | |
| nsmul_eq_mul, ← Finset.mul_sum, hpT.2, mul_one] | |
| have h := side_information_bound w (fun tv : T × V => pT tv.1) c | |
| (fun tv => q tv.1) e hw (fun tv => hpT.1 tv.1) (fun tv => hq tv.1) | |
| he he_one hc hz hB hbase hweight | |
| have hlog : Real.log ((Fintype.card V : ℝ) / z) = | |
| Real.log (Fintype.card V : ℝ) + Real.log (1 / z) := by | |
| rw [Real.log_div hB.ne' hz.ne', Real.log_div one_ne_zero hz.ne', Real.log_one] | |
| ring | |
| simpa only [hlog] using h | |
| end DFVSGames.Foundations.Information | |
| end OAI | |
Xet Storage Details
- Size:
- 36.4 kB
- Xet hash:
- 363e645baa6742d00a912f06e5b9766ca57e729f1616c5360d1fb708a3e600b6
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.