File size: 4,005 Bytes
4a56cd6 | 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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | import OAI.LinearAlgebra.MatrixMultiplication.FieldParameters.Compatibility
import OAI.LinearAlgebra.MatrixMultiplication.Entropy.ComplexFiniteEntropy
namespace OAI
/-! Fixed rational distributions and their entropy and capacity formulas. -/
namespace MatrixMultiplication.AllFieldParameters
open MatrixMultiplication.Foundation
open scoped BigOperators
noncomputable section
theorem entropy_two_points {A : Type*} [Fintype A] [DecidableEq A]
(a b : A) (hab : a β b) (p q : β) :
finiteEntropy (fun i => if i = a then p else if i = b then q else 0) =
entropyTerm p + entropyTerm q := by
unfold finiteEntropy
calc
_ = β i : A, ((if i = a then entropyTerm p else 0) +
(if i = b then entropyTerm q else 0)) := by
apply Finset.sum_congr rfl
intro i _
by_cases hi : i = a
Β· subst i
simp [hab]
Β· by_cases hj : i = b
Β· subst i
simp [hab.symm]
Β· simp [hi, hj]
_ = _ := by simp [Finset.sum_add_distrib]
theorem weighted_two_points {A : Type*} [Fintype A] [DecidableEq A]
(a b : A) (hab : a β b) (p q : β) (f : A β β) :
(β i : A, (if i = a then p else if i = b then q else 0) * f i) =
p * f a + q * f b := by
calc
_ = β i : A, ((if i = a then p * f a else 0) +
(if i = b then q * f b else 0)) := by
apply Finset.sum_congr rfl
intro i _
by_cases hi : i = a
Β· subst i
simp [hab]
Β· by_cases hj : i = b
Β· subst i
simp [hi]
Β· simp [hi, hj]
_ = _ := by simp [Finset.sum_add_distrib]
def statisticRate (d : β) (k : Fin 5) : β :=
finiteEntropy (fun i : Fin 6 => (statisticLaw d k i : β)) +
β i : Fin 6, (statisticLaw d k i : β) * Real.log (multiplicity i : β)
def binaryEntropyRate (d : β) : β :=
entropyTerm (1 - (d : β)) + entropyTerm (d : β) + (d : β) * Real.log 2
theorem statisticLaw_two_real (d : β) (i : Fin 6) :
(statisticLaw d 2 i : β) =
if i = 2 then 1 - (d : β) else if i = 3 then (d : β) else 0 := by
by_cases hi : i = 2
Β· simp [statisticLaw, hi]
Β· by_cases hj : i = 3 <;> simp [statisticLaw, hi, hj]
theorem statisticRate_two (d : β) :
statisticRate d 2 = binaryEntropyRate d + 2 * (1 - (d : β)) * Real.log 5 := by
unfold statisticRate
simp_rw [statisticLaw_two_real]
rw [entropy_two_points (2 : Fin 6) 3 (by decide),
weighted_two_points (2 : Fin 6) 3 (by decide)]
have h25 : Real.log (25 : β) = 2 * Real.log 5 := by
have hp : (5 : β) ^ 2 = 25 := by norm_num
rw [β hp, Real.log_pow]
norm_num
change entropyTerm (1 - (d : β)) + entropyTerm (d : β) +
((1 - (d : β)) * Real.log 25 + (d : β) * Real.log 2) = _
rw [h25]
unfold binaryEntropyRate
ring
theorem statisticRate_deterministic (d : β) (k : Fin 5) (hk : k.val β 2) :
statisticRate d k = Real.log (multiplicity (singletonSlot k.val) : β) := by
have hmass (i : Fin 6) : (statisticLaw d k i : β) =
if i = singletonSlot k.val then 1 else 0 := by
by_cases hi : i = singletonSlot k.val <;> simp [statisticLaw, hk, hi]
unfold statisticRate finiteEntropy
simp_rw [hmass]
simp [entropyTerm, apply_ite]
theorem statisticRate_zero (d : β) : statisticRate d 0 = 0 := by
rw [statisticRate_deterministic d 0 (by decide)]
norm_num [singletonSlot, multiplicity]
theorem statisticRate_one (d : β) : statisticRate d 1 = Real.log 10 := by
rw [statisticRate_deterministic d 1 (by decide)]
norm_num [singletonSlot, multiplicity]
theorem statisticRate_three (d : β) : statisticRate d 3 = Real.log 10 := by
rw [statisticRate_deterministic d 3 (by decide)]
change Real.log (10 : β) = Real.log 10
rfl
theorem statisticRate_four (d : β) : statisticRate d 4 = 0 := by
rw [statisticRate_deterministic d 4 (by decide)]
have hv : multiplicity (singletonSlot (4 : Fin 5).val) = 1 := by decide +kernel
rw [hv]
norm_num
end
end MatrixMultiplication.AllFieldParameters
end OAI
|