File size: 4,048 Bytes
cdec422 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | import Mathlib.Algebra.BigOperators.Field
import Mathlib.Analysis.SpecialFunctions.BinaryEntropy
import Mathlib.Analysis.SpecialFunctions.Pow.Real
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring
namespace OAI
/-!
# Entropy optimization for finitely many sectors
The normalized weights `q = A / (A + B)` and `1 - q = B / (A + B)`
make the entropy-weighted geometric mean equal to `A + B`. This is the
scalar identity used in Section 5.1 of the auxiliary-separation argument.
The same calculation also applies to an arbitrary nonempty finite family.
-/
open scoped BigOperators
namespace MatrixMultiplication.AuxiliarySeparation
/-- The logarithmic form of the entropy identity at the normalized weights. -/
theorem binary_entropy_log_partition {A B : ℝ} (hA : 0 < A) (hB : 0 < B) :
Real.binEntropy (A / (A + B)) +
Real.log A * (A / (A + B)) +
Real.log B * (1 - A / (A + B)) = Real.log (A + B) := by
have hsum : A + B ≠ 0 := ne_of_gt (add_pos hA hB)
have hcomplement : 1 - A / (A + B) = B / (A + B) := by
field_simp
ring
rw [Real.binEntropy, hcomplement, Real.log_inv, Real.log_inv,
Real.log_div hA.ne' hsum, Real.log_div hB.ne' hsum]
field_simp
ring
/-- Entropy compensates the weighted geometric mean at the normalized weights. -/
theorem binary_entropy_variational_identity {A B : ℝ} (hA : 0 < A) (hB : 0 < B) :
Real.exp (Real.binEntropy (A / (A + B))) *
A ^ (A / (A + B)) * B ^ (1 - A / (A + B)) = A + B := by
rw [Real.rpow_def_of_pos hA, Real.rpow_def_of_pos hB,
← Real.exp_add, ← Real.exp_add, binary_entropy_log_partition hA hB,
Real.exp_log (add_pos hA hB)]
/-- The identity with an explicitly named optimizing proportion. -/
theorem binary_entropy_variational_identity_of_ratio {A B q : ℝ}
(hA : 0 < A) (hB : 0 < B) (hq : q = A / (A + B)) :
Real.exp (-q * Real.log q - (1 - q) * Real.log (1 - q)) *
A ^ q * B ^ (1 - q) = A + B := by
subst q
have hentropy :
-(A / (A + B)) * Real.log (A / (A + B)) -
(1 - A / (A + B)) * Real.log (1 - A / (A + B)) =
Real.binEntropy (A / (A + B)) := by
simp only [Real.binEntropy, Real.log_inv]
ring
rw [hentropy]
exact binary_entropy_variational_identity hA hB
/-- The logarithmic entropy identity for positive weights on a finite set. -/
theorem finite_entropy_log_partition {ι : Type*} (s : Finset ι) (A : ι → ℝ)
(hs : s.Nonempty) (hA : ∀ i ∈ s, 0 < A i) :
-(∑ i ∈ s, (A i / (∑ j ∈ s, A j)) * Real.log (A i / (∑ j ∈ s, A j))) +
(∑ i ∈ s, Real.log (A i) * (A i / (∑ j ∈ s, A j))) =
Real.log (∑ j ∈ s, A j) := by
have hsum : 0 < ∑ j ∈ s, A j := Finset.sum_pos hA hs
calc
_ = ∑ i ∈ s, (A i / (∑ j ∈ s, A j)) * Real.log (∑ j ∈ s, A j) := by
rw [← Finset.sum_neg_distrib, ← Finset.sum_add_distrib]
apply Finset.sum_congr rfl
intro i hi
rw [Real.log_div (hA i hi).ne' hsum.ne']
ring
_ = (∑ i ∈ s, A i / (∑ j ∈ s, A j)) * Real.log (∑ j ∈ s, A j) := by
rw [Finset.sum_mul]
_ = _ := by rw [← Finset.sum_div, div_self hsum.ne', one_mul]
/-- Normalizing any positive finite family attains its sum in the entropy formula. -/
theorem finite_entropy_variational_identity {ι : Type*} (s : Finset ι) (A : ι → ℝ)
(hs : s.Nonempty) (hA : ∀ i ∈ s, 0 < A i) :
Real.exp (-(∑ i ∈ s, (A i / (∑ j ∈ s, A j)) *
Real.log (A i / (∑ j ∈ s, A j)))) *
(∏ i ∈ s, (A i) ^ (A i / (∑ j ∈ s, A j))) = ∑ j ∈ s, A j := by
have hsum : 0 < ∑ j ∈ s, A j := Finset.sum_pos hA hs
have hprod : (∏ i ∈ s, (A i) ^ (A i / (∑ j ∈ s, A j))) =
Real.exp (∑ i ∈ s, Real.log (A i) * (A i / (∑ j ∈ s, A j))) := by
rw [Real.exp_sum]
apply Finset.prod_congr rfl
intro i hi
exact Real.rpow_def_of_pos (hA i hi) _
rw [hprod, ← Real.exp_add, finite_entropy_log_partition s A hs hA,
Real.exp_log hsum]
end MatrixMultiplication.AuxiliarySeparation
end OAI
|