File size: 3,990 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 | import Mathlib
namespace OAI
namespace MatrixAllFields
open scoped BigOperators Topology Polynomial
noncomputable section
namespace MatrixMultiplication.FloorExponentialRates
open Filter
open scoped BigOperators Topology Classical
def count (rate : β) (m : β) : β := βReal.exp ((m : β) * rate)ββ
theorem count_pos {rate : β} (hr : 0 β€ rate) (m : β) : 0 < count rate m := by
have he : (1 : β) β€ Real.exp ((m : β) * rate) :=
Real.one_le_exp (mul_nonneg (Nat.cast_nonneg _) hr)
exact lt_of_lt_of_le Nat.zero_lt_one (Nat.le_floor (by simpa only [Nat.cast_one] using he))
theorem log_count_bounds {rate : β} (hr : 0 β€ rate) (m : β) :
(m : β) * rate - Real.log 2 β€ Real.log (count rate m : β) β§
Real.log (count rate m : β) β€ (m : β) * rate := by
have hp : (0 : β) < count rate m := Nat.cast_pos.mpr (count_pos hr m)
have hone : (1 : β) β€ count rate m := by exact_mod_cast count_pos hr m
have hround := Nat.lt_floor_add_one (Real.exp ((m : β) * rate))
have hhalf : Real.exp ((m : β) * rate) / 2 β€ (count rate m : β) := by
change Real.exp ((m : β) * rate) < (count rate m : β) + 1 at hround
linarith
constructor
Β· have h := Real.log_le_log (by positivity : 0 < Real.exp ((m : β) * rate) / 2) hhalf
simpa only [Real.log_div (Real.exp_ne_zero _) (by norm_num : (2 : β) β 0),
Real.log_exp] using h
Β· have h := Real.log_le_log hp (Nat.floor_le (Real.exp_pos _).le)
simpa only [Real.log_exp] using h
theorem tendsto_log_count_div_nat {rate : β} (hr : 0 β€ rate) :
Tendsto (fun m : β => Real.log (count rate m : β) / (m : β))
atTop (π rate) := by
have hinv : Tendsto (fun m : β => Real.log 2 / (m : β)) atTop (π 0) :=
tendsto_const_nhds.div_atTop tendsto_natCast_atTop_atTop
have hlo : Tendsto (fun m : β => rate - Real.log 2 / (m : β)) atTop (π rate) := by
simpa only [sub_zero] using tendsto_const_nhds.sub hinv
apply tendsto_of_tendsto_of_tendsto_of_le_of_le' hlo tendsto_const_nhds
Β· filter_upwards [eventually_gt_atTop (0 : β)] with m hm
have hm' : (0 : β) < m := Nat.cast_pos.mpr hm
have h := div_le_div_of_nonneg_right (log_count_bounds hr m).1 hm'.le
simpa only [sub_div, mul_div_cancel_leftβ rate hm'.ne'] using h
Β· filter_upwards [eventually_gt_atTop (0 : β)] with m hm
have hm' : (0 : β) < m := Nat.cast_pos.mpr hm
have h := div_le_div_of_nonneg_right (log_count_bounds hr m).2 hm'.le
simpa only [mul_div_cancel_leftβ rate hm'.ne'] using h
theorem tendsto_log_prod_count_div_nat {I : Type*} [Fintype I] (rate : I β β)
(hr : β i, 0 β€ rate i) :
Tendsto (fun m : β => Real.log ((β i, count (rate i) m : β) : β) / (m : β))
atTop (π (β i, rate i)) := by
have h := tendsto_finsetSum Finset.univ (fun i _ => tendsto_log_count_div_nat (hr i))
apply h.congr
intro m
rw [Nat.cast_prod, Real.log_prod
(fun i _ => Nat.cast_ne_zero.mpr (Nat.ne_of_gt (count_pos (hr i) m)))]
simp only [div_eq_mul_inv, Finset.sum_mul]
abbrev Labels {I : Type*} (rate : I β β) (m : β) := β i, Fin (count (rate i) m)
theorem card_labels {I : Type*} [Fintype I] (rate : I β β) (m : β) :
Fintype.card (Labels rate m) = β i, count (rate i) m := by
simp only [Labels, Fintype.card_pi, Fintype.card_fin]
theorem card_labels_pos {I : Type*} [Fintype I] (rate : I β β)
(hr : β i, 0 β€ rate i) (m : β) : 0 < Fintype.card (Labels rate m) := by
rw [card_labels]
exact Finset.prod_pos fun i _ => count_pos (hr i) m
theorem tendsto_log_card_labels_div_nat {I : Type*} [Fintype I] (rate : I β β)
(hr : β i, 0 β€ rate i) :
Tendsto (fun m : β => Real.log (Fintype.card (Labels rate m) : β) / (m : β))
atTop (π (β i, rate i)) := by
simpa only [card_labels] using tendsto_log_prod_count_div_nat rate hr
end MatrixMultiplication.FloorExponentialRates
end
end MatrixAllFields
end OAI
|