roseking's picture
Add lean source and binary files (part 64)
92416a2 verified
Raw History Blame Contribute Delete
9.45 kB
import Mathlib
import OAI.Computability.VertexCover.Information.Pinsker
namespace OAI
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
namespace UniqueGames.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 UniqueGames.Foundations.Information
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end OAI