introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
19 kB
import OAI.LinearAlgebra.MatrixMultiplication.Entropy.ComplexSeparationAsymptotics
import OAI.LinearAlgebra.MatrixMultiplication.JointExtraction.APFree
import Mathlib.Algebra.Order.Floor.Semiring
import Mathlib.Analysis.SpecialFunctions.Exp
namespace OAI
/-! Joint tensor extraction, compatibility and entropy estimates. -/
noncomputable section
namespace MatrixMultiplication.JointExtractionRates
open Filter
open scoped BigOperators Topology
def goodCount {Ξ© E : Type*} [Fintype E] (good : Ξ© β†’ E β†’ Prop) (Ο‰ : Ξ©) : β„• := by
classical
exact (Finset.univ.filter (good Ο‰)).card
def goodIncidence {Ξ© E : Type*} [Fintype Ξ©] (good : Ξ© β†’ E β†’ Prop) (e : E) : β„• := by
classical
exact (Finset.univ.filter (fun Ο‰ => good Ο‰ e)).card
theorem sum_goodCount_eq_sum_goodIncidence {Ξ© E : Type*} [Fintype Ξ©] [Fintype E]
(good : Ξ© β†’ E β†’ Prop) :
(βˆ‘ Ο‰, goodCount good Ο‰) = βˆ‘ e, goodIncidence good e := by
classical
simp only [goodCount, goodIncidence, Finset.card_filter]
exact Finset.sum_comm
theorem exists_goodCount_ge {Ξ© E : Type*} [Fintype Ξ©] [Nonempty Ξ©] [Fintype E]
(good : Ξ© β†’ E β†’ Prop) (q : ℝ)
(hinc : βˆ€ e, q * (Fintype.card Ξ© : ℝ) ≀ (goodIncidence good e : ℝ)) :
βˆƒ Ο‰, (Fintype.card E : ℝ) * q ≀ (goodCount good Ο‰ : ℝ) := by
have hsum := Finset.sum_le_sum (fun e (_ : e ∈ Finset.univ) => hinc e)
have hdouble : (βˆ‘ Ο‰, (goodCount good Ο‰ : ℝ)) =
βˆ‘ e, (goodIncidence good e : ℝ) := by
exact_mod_cast sum_goodCount_eq_sum_goodIncidence good
have havg : (βˆ‘ _Ο‰ : Ξ©, (Fintype.card E : ℝ) * q) ≀
βˆ‘ Ο‰, (goodCount good Ο‰ : ℝ) := by
rw [hdouble]
simpa only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, mul_assoc,
mul_comm, mul_left_comm] using hsum
obtain βŸ¨Ο‰, _, hΟ‰βŸ© := Finset.exists_le_of_sum_le Finset.univ_nonempty havg
exact βŸ¨Ο‰, hΟ‰βŸ©
theorem exists_good_subfamily {Ξ© E : Type*} [Fintype E]
(good : Ξ© β†’ E β†’ Prop) (Ο‰ : Ξ©) (K : β„•) (hK : K ≀ goodCount good Ο‰) :
βˆƒ G : Finset E, G.card = K ∧ βˆ€ e ∈ G, good Ο‰ e := by
classical
obtain ⟨G, hG, hcard⟩ := Finset.exists_subset_card_eq
(s := Finset.univ.filter (good Ο‰)) (by simpa only [goodCount] using hK)
exact ⟨G, hcard, fun e he => (Finset.mem_filter.mp (hG he)).2⟩
theorem eventually_exists_good_subfamily {Ξ© E : β„• β†’ Type*}
[βˆ€ N, Fintype (E N)]
(good : βˆ€ N, Ξ© N β†’ E N β†’ Prop) (K : β„• β†’ β„•)
(hK : βˆ€αΆ  N in atTop, βˆƒ Ο‰ : Ξ© N, K N ≀ goodCount (good N) Ο‰) :
βˆ€αΆ  N in atTop, βˆƒ (Ο‰ : Ξ© N) (G : Finset (E N)),
G.card = K N ∧ βˆ€ e ∈ G, good N Ο‰ e := by
filter_upwards [hK] with N hN
obtain βŸ¨Ο‰, hΟ‰βŸ© := hN
obtain ⟨G, hcard, hgood⟩ := exists_good_subfamily (good N) Ο‰ (K N) hΟ‰
exact βŸ¨Ο‰, G, hcard, hgood⟩
theorem incidence_lower_of_survival_and_loss {Ξ© E : Type*} [Fintype Ξ©]
(survives bad : Ξ© β†’ E β†’ Prop) (e : E) (s Ξ΅ : ℝ)
(hs : s * (Fintype.card Ξ© : ℝ) ≀ (goodIncidence survives e : ℝ))
(hb : (goodIncidence (fun Ο‰ e => survives Ο‰ e ∧ bad Ο‰ e) e : ℝ) ≀
s * Ξ΅ * (Fintype.card Ξ© : ℝ)) :
s * (1 - Ξ΅) * (Fintype.card Ξ© : ℝ) ≀
(goodIncidence (fun Ο‰ e => survives Ο‰ e ∧ Β¬ bad Ο‰ e) e : ℝ) := by
classical
have hsplit : goodIncidence (fun Ο‰ e => survives Ο‰ e ∧ bad Ο‰ e) e +
goodIncidence (fun Ο‰ e => survives Ο‰ e ∧ Β¬ bad Ο‰ e) e =
goodIncidence survives e := by
simp only [goodIncidence, Finset.card_filter, ← Finset.sum_add_distrib]
apply Finset.sum_congr rfl
intro Ο‰ _
by_cases hs : survives Ο‰ e <;> by_cases hb : bad Ο‰ e <;> simp [hs, hb]
have hsplitR :
(goodIncidence (fun Ο‰ e => survives Ο‰ e ∧ bad Ο‰ e) e : ℝ) +
(goodIncidence (fun Ο‰ e => survives Ο‰ e ∧ Β¬ bad Ο‰ e) e : ℝ) =
(goodIncidence survives e : ℝ) := by
exact_mod_cast hsplit
nlinarith
theorem exists_goodCount_ge_half_survival {Ξ© E : Type*}
[Fintype Ξ©] [Nonempty Ξ©] [Fintype E]
(survives bad : Ξ© β†’ E β†’ Prop) (s Ξ΅ : ℝ) (hsβ‚€ : 0 ≀ s) (hΞ΅ : Ξ΅ ≀ 1 / 2)
(hs : βˆ€ e, s * (Fintype.card Ξ© : ℝ) ≀ (goodIncidence survives e : ℝ))
(hb : βˆ€ e, (goodIncidence (fun Ο‰ e => survives Ο‰ e ∧ bad Ο‰ e) e : ℝ) ≀
s * Ξ΅ * (Fintype.card Ξ© : ℝ)) :
βˆƒ Ο‰, (Fintype.card E : ℝ) * (s / 2) ≀
(goodCount (fun Ο‰ e => survives Ο‰ e ∧ Β¬ bad Ο‰ e) Ο‰ : ℝ) := by
apply exists_goodCount_ge
intro e
have h := incidence_lower_of_survival_and_loss survives bad e s Ξ΅ (hs e) (hb e)
have hc : (0 : ℝ) ≀ Fintype.card Ξ© := Nat.cast_nonneg _
have hm := mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hΞ΅ hsβ‚€) hc
nlinarith
theorem tendsto_polynomial_mul_exp_neg (d : β„•) {c : ℝ} (hc : 0 < c) :
Tendsto (fun N : β„• => ((N : ℝ) + 1) ^ d * Real.exp (-c * (N : ℝ)))
atTop (𝓝 0) := by
have hbase := (Real.summable_pow_mul_exp_neg_nat_mul d hc).tendsto_atTop_zero
have hshift := (hbase.comp (tendsto_add_atTop_nat 1)).mul_const (Real.exp c)
simp only [zero_mul, Function.comp_apply, Nat.cast_add, Nat.cast_one] at hshift
convert hshift using 1
ext N
rw [mul_assoc, ← Real.exp_add]
congr 2
ring
theorem eventually_error_le_half {error : β„• β†’ ℝ} (B : ℝ) (d : β„•)
{c : ℝ} (hc : 0 < c)
(hbound : βˆ€αΆ  N in atTop,
error N ≀ B * (((N : ℝ) + 1) ^ d * Real.exp (-c * (N : ℝ)))) :
βˆ€αΆ  N in atTop, error N ≀ 1 / 2 := by
have hlim := (tendsto_polynomial_mul_exp_neg d hc).const_mul B
have hsmall : βˆ€αΆ  N : β„• in atTop,
B * (((N : ℝ) + 1) ^ d * Real.exp (-c * (N : ℝ))) < 1 / 2 := by
simpa only [mul_zero] using (tendsto_order.1 hlim).2 (1 / 2) (by simp)
filter_upwards [hbound, hsmall] with N hb hs
exact hb.trans hs.le
theorem tendsto_log_one_sub_error_div_nat {error : β„• β†’ ℝ}
(herror : Tendsto error atTop (𝓝 0)) :
Tendsto (fun N => Real.log (1 - error N) / (N : ℝ)) atTop (𝓝 0) := by
have hone : Tendsto (fun N => 1 - error N) atTop (𝓝 (1 : ℝ)) := by
simpa using (tendsto_const_nhds :
Tendsto (fun _ : β„• => (1 : ℝ)) atTop (𝓝 1)).sub herror
exact (hone.log one_ne_zero).div_atTop tendsto_natCast_atTop_atTop
def hashModulus (H : ℝ) (N : β„•) : β„• :=
37 ^ (⌊(N : ℝ) * H / Real.log 37βŒ‹β‚Š + 1)
theorem hashModulus_ge (H : ℝ) (N : β„•) : 37 ≀ hashModulus H N := by
simpa only [hashModulus, pow_one] using
(Nat.pow_le_pow_right (by norm_num : 0 < 37)
(show 1 ≀ ⌊(N : ℝ) * H / Real.log 37βŒ‹β‚Š + 1 by omega))
theorem hashModulus_log_bounds {H : ℝ} (hH : 0 ≀ H) (N : β„•) :
(N : ℝ) * H ≀ Real.log (hashModulus H N : ℝ) ∧
Real.log (hashModulus H N : ℝ) ≀ (N : ℝ) * H + Real.log 37 := by
have hl : 0 < Real.log (37 : ℝ) := Real.log_pos (by norm_num)
have harg : 0 ≀ (N : ℝ) * H / Real.log 37 :=
div_nonneg (mul_nonneg (Nat.cast_nonneg N) hH) hl.le
have hfloor := mul_le_mul_of_nonneg_right (Nat.floor_le harg) hl.le
have hceil := mul_lt_mul_of_pos_right
(Nat.lt_floor_add_one ((N : ℝ) * H / Real.log 37)) hl
have hcancel : (N : ℝ) * H / Real.log 37 * Real.log 37 = (N : ℝ) * H :=
div_mul_cancelβ‚€ _ hl.ne'
simp only [hashModulus, Nat.cast_pow, Real.log_pow, Nat.cast_add, Nat.cast_one]
constructor <;> nlinarith
theorem tendsto_log_hashModulus_div_nat {H : ℝ} (hH : 0 ≀ H) :
Tendsto (fun N => Real.log (hashModulus H N : ℝ) / (N : ℝ))
atTop (𝓝 H) := by
have hc : Tendsto (fun N : β„• => Real.log 37 / (N : ℝ)) atTop (𝓝 0) :=
tendsto_const_nhds.div_atTop tendsto_natCast_atTop_atTop
have hu : Tendsto (fun N : β„• => H + Real.log 37 / (N : ℝ)) atTop (𝓝 H) := by
simpa only [add_zero] using hc.const_add H
apply tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_const_nhds hu
Β· filter_upwards [eventually_ge_atTop (1 : β„•)] with N hN
have hNr : (0 : ℝ) < N := by exact_mod_cast hN
apply (le_div_iffβ‚€ hNr).2
nlinarith [(hashModulus_log_bounds hH N).1]
Β· filter_upwards [eventually_ge_atTop (1 : β„•)] with N hN
have hNr : (0 : ℝ) < N := by exact_mod_cast hN
have hb := div_le_div_of_nonneg_right (hashModulus_log_bounds hH N).2 hNr.le
simpa only [add_div, mul_div_cancel_leftβ‚€ H hNr.ne'] using hb
theorem eventual_log_upper_of_error {degree : β„• β†’ β„•} {error : β„• β†’ ℝ} {D : ℝ}
(herror : Tendsto (fun N => error N / (N : ℝ)) atTop (𝓝 0))
(hbound : βˆ€αΆ  N in atTop,
Real.log (degree N : ℝ) ≀ (N : ℝ) * D + error N)
{Ξ· : ℝ} (hΞ· : 0 < Ξ·) :
βˆ€αΆ  N in atTop, Real.log (degree N : ℝ) / (N : ℝ) ≀ D + Ξ· := by
filter_upwards [hbound, (tendsto_order.1 herror).2 Ξ· hΞ·,
eventually_ge_atTop (1 : β„•)] with N hb he hN
have hNr : (0 : ℝ) < N := by exact_mod_cast hN
have hd := div_le_div_of_nonneg_right hb hNr.le
rw [add_div, mul_div_cancel_leftβ‚€ D hNr.ne'] at hd
linarith
theorem eventually_ratio_le_exp_neg_of_log_bounds {degree M : β„• β†’ β„•} {D H c : ℝ}
(hdegree : βˆ€ Ξ· : ℝ, 0 < Ξ· β†’
βˆ€αΆ  N in atTop, Real.log (degree N : ℝ) / (N : ℝ) ≀ D + Ξ·)
(hpos : βˆ€αΆ  N in atTop, 0 < M N)
(hM : Tendsto (fun N => Real.log (M N : ℝ) / (N : ℝ)) atTop (𝓝 H))
(hc : c < H - D) :
βˆ€αΆ  N in atTop, (degree N : ℝ) / (M N : ℝ) ≀ Real.exp (-c * (N : ℝ)) := by
let Ξ· : ℝ := (H - D - c) / 3
have hΞ· : 0 < Ξ· := by dsimp [Ξ·]; linarith
filter_upwards [hdegree Ξ· hΞ·, hpos,
(tendsto_order.1 hM).1 (H - Ξ·) (by linarith),
eventually_ge_atTop (1 : β„•)] with N hd hp hm hN
by_cases hz : degree N = 0
Β· simp only [hz, Nat.cast_zero, zero_div]
exact (Real.exp_pos _).le
have hdpos : (0 : ℝ) < degree N := by
exact_mod_cast Nat.pos_of_ne_zero hz
have hmpos : (0 : ℝ) < M N := by exact_mod_cast hp
have hNr : (0 : ℝ) < N := by exact_mod_cast hN
have hdu := (div_le_iffβ‚€ hNr).mp hd
have hml := (lt_div_iffβ‚€ hNr).mp hm
have hcoefficient : D - H + 2 * Ξ· ≀ -c := by dsimp [Ξ·]; linarith
have hscaled := mul_le_mul_of_nonneg_right hcoefficient hNr.le
have hdiff : Real.log (degree N : ℝ) - Real.log (M N : ℝ) ≀
-c * (N : ℝ) := by nlinarith
calc
_ = Real.exp (Real.log (degree N : ℝ) - Real.log (M N : ℝ)) := by
rw [Real.exp_sub, Real.exp_log hdpos, Real.exp_log hmpos]
_ ≀ _ := Real.exp_le_exp.mpr hdiff
theorem eventually_degree_div_hashModulus_le_exp {degree : β„• β†’ β„•} {D H c : ℝ}
(hH : 0 ≀ H)
(hdegree : βˆ€ Ξ· : ℝ, 0 < Ξ· β†’
βˆ€αΆ  N in atTop, Real.log (degree N : ℝ) / (N : ℝ) ≀ D + Ξ·)
(hc : c < H - D) :
βˆ€αΆ  N in atTop, (degree N : ℝ) / (hashModulus H N : ℝ) ≀
Real.exp (-c * (N : ℝ)) := by
apply eventually_ratio_le_exp_neg_of_log_bounds hdegree _
(tendsto_log_hashModulus_div_nat hH) hc
exact Eventually.of_forall fun N =>
lt_of_lt_of_le (by decide : 0 < 37) (hashModulus_ge H N)
theorem tendsto_sqrt_div_nat_of_div_nat {a : β„• β†’ ℝ} {A : ℝ}
(ha : βˆ€ N, 0 ≀ a N)
(h : Tendsto (fun N => a N / (N : ℝ)) atTop (𝓝 A)) :
Tendsto (fun N => Real.sqrt (a N) / (N : ℝ)) atTop (𝓝 0) := by
have hinv : Tendsto (fun N : β„• => 1 / (N : ℝ)) atTop (𝓝 0) :=
tendsto_const_nhds.div_atTop tendsto_natCast_atTop_atTop
have hp := h.sqrt.mul hinv.sqrt
simp only [Real.sqrt_zero, mul_zero] at hp
convert hp using 1
ext N
symm
rw [Real.sqrt_div (ha N), Real.sqrt_div (by norm_num : (0 : ℝ) ≀ 1),
Real.sqrt_one, div_mul_div_comm, mul_one, Real.mul_self_sqrt (Nat.cast_nonneg N)]
theorem tendsto_log_modularSet_card_div_nat {M : β„• β†’ β„•} {H : ℝ}
(hM : βˆ€αΆ  N in atTop, 2 ≀ M N)
(hlog : Tendsto (fun N => Real.log (M N : ℝ) / (N : ℝ)) atTop (𝓝 H)) :
Tendsto (fun N => Real.log ((JointAPFree.modularSet (M N)).card : ℝ) / (N : ℝ))
atTop (𝓝 H) := by
have hsqrt := tendsto_sqrt_div_nat_of_div_nat
(fun N => Real.log_natCast_nonneg (M N)) hlog
have hconst : Tendsto (fun N : β„• => Real.log 3 / (N : ℝ)) atTop (𝓝 0) :=
tendsto_const_nhds.div_atTop tendsto_natCast_atTop_atTop
have hlower : Tendsto (fun N =>
(Real.log (M N : ℝ) - Real.log 3 -
4 * Real.sqrt (Real.log (M N : ℝ))) / (N : ℝ))
atTop (𝓝 H) := by
have h := (hlog.sub hconst).sub (hsqrt.const_mul 4)
simp only [mul_zero, sub_zero] at h
apply h.congr
intro N
ring
apply tendsto_of_tendsto_of_tendsto_of_le_of_le' hlower hlog
Β· filter_upwards [hM] with N hN
exact div_le_div_of_nonneg_right
(JointAPFree.modularSet_log_card_lower_modulus hN) (Nat.cast_nonneg N)
Β· filter_upwards [hM] with N hN
exact div_le_div_of_nonneg_right
(JointAPFree.modularSet_log_card_le_modulus hN) (Nat.cast_nonneg N)
theorem tendsto_log_yield_lower {T U M : β„• β†’ β„•} {A B C : ℝ}
(hT : Tendsto (fun N => Real.log (T N : ℝ) / (N : ℝ)) atTop (𝓝 A))
(hU : Tendsto (fun N => Real.log (U N : ℝ) / (N : ℝ)) atTop (𝓝 B))
(hM : Tendsto (fun N => Real.log (M N : ℝ) / (N : ℝ)) atTop (𝓝 C)) :
Tendsto (fun N =>
(Real.log (T N : ℝ) + Real.log (U N : ℝ) -
2 * Real.log (M N : ℝ) - Real.log 2) / (N : ℝ))
atTop (𝓝 (A + B - 2 * C)) := by
have hconst : Tendsto (fun N : β„• => Real.log 2 / (N : ℝ)) atTop (𝓝 0) :=
tendsto_const_nhds.div_atTop tendsto_natCast_atTop_atTop
have h := ((hT.add hU).sub (hM.const_mul 2)).sub hconst
simp only [sub_zero] at h
apply h.congr
intro N
ring
theorem exp_log_yield_lower {T U M : β„•} (hT : 0 < T) (hU : 0 < U) (hM : 0 < M) :
Real.exp (Real.log (T : ℝ) + Real.log (U : ℝ) -
2 * Real.log (M : ℝ) - Real.log 2) =
(T : ℝ) * ((U : ℝ) / (M : ℝ) ^ 2 / 2) := by
have hTr : (0 : ℝ) < T := by exact_mod_cast hT
have hUr : (0 : ℝ) < U := by exact_mod_cast hU
have hMr : (0 : ℝ) < M := by exact_mod_cast hM
rw [Real.exp_sub, Real.exp_sub, Real.exp_add, Real.exp_log hTr,
Real.exp_log hUr, Real.exp_log (by norm_num : (0 : ℝ) < 2)]
rw [show 2 * Real.log (M : ℝ) = Real.log ((M : ℝ) ^ 2) by
rw [Real.log_pow]; norm_num, Real.exp_log (pow_pos hMr 2)]
ring
theorem eventually_floor_exp_le_of_log_lower {Y : β„• β†’ β„•} {L : β„• β†’ ℝ} {R : ℝ}
(hL : Tendsto (fun N => L N / (N : ℝ)) atTop (𝓝 R))
(hY : βˆ€αΆ  N in atTop, Real.exp (L N) ≀ (Y N : ℝ))
{Ξ΅ : ℝ} (hΞ΅ : 0 < Ξ΅) :
βˆ€αΆ  N : β„• in atTop, ⌊Real.exp ((N : ℝ) * (R - Ξ΅))βŒ‹β‚Š ≀ Y N := by
filter_upwards [(tendsto_order.1 hL).1 (R - Ξ΅) (by linarith), hY,
(eventually_atTop.2 ⟨1, fun N (hN : 1 ≀ N) => hN⟩)] with N hrate hy hN
have hNr : (0 : ℝ) < N := by exact_mod_cast hN
have hexp : Real.exp ((N : ℝ) * (R - Ξ΅)) ≀ (Y N : ℝ) := by
apply le_trans (Real.exp_le_exp.mpr ?_) hy
have hm := (lt_div_iffβ‚€ hNr).mp hrate
nlinarith
simpa only [Nat.floor_natCast] using Nat.floor_le_floor hexp
theorem eventually_exists_many_good
{Ξ© E : β„• β†’ Type*} [βˆ€ N, Fintype (Ξ© N)] [βˆ€ N, Nonempty (Ξ© N)]
[βˆ€ N, Fintype (E N)]
(good : βˆ€ N, Ξ© N β†’ E N β†’ Prop) (U M : β„• β†’ β„•) {A H : ℝ}
(hpos : βˆ€αΆ  N in atTop, 0 < Fintype.card (E N) ∧ 0 < U N ∧ 0 < M N)
(hinc : βˆ€αΆ  N in atTop, βˆ€ e,
((U N : ℝ) / (M N : ℝ) ^ 2 / 2) * (Fintype.card (Ξ© N) : ℝ) ≀
(goodIncidence (good N) e : ℝ))
(hE : Tendsto (fun N => Real.log (Fintype.card (E N) : ℝ) / (N : ℝ))
atTop (𝓝 A))
(hU : Tendsto (fun N => Real.log (U N : ℝ) / (N : ℝ)) atTop (𝓝 H))
(hM : Tendsto (fun N => Real.log (M N : ℝ) / (N : ℝ)) atTop (𝓝 H))
{Ξ΅ : ℝ} (hΞ΅ : 0 < Ξ΅) :
βˆ€αΆ  N in atTop, βˆƒ Ο‰ : Ξ© N,
⌊Real.exp ((N : ℝ) * (A - H - Ξ΅))βŒ‹β‚Š ≀ goodCount (good N) Ο‰ := by
let L : β„• β†’ ℝ := fun N => Real.log (Fintype.card (E N) : ℝ) +
Real.log (U N : ℝ) - 2 * Real.log (M N : ℝ) - Real.log 2
have hL : Tendsto (fun N => L N / (N : ℝ)) atTop (𝓝 (A - H)) := by
simpa only [L, show A + H - 2 * H = A - H by ring] using
tendsto_log_yield_lower hE hU hM
filter_upwards [hpos, hinc, (tendsto_order.1 hL).1 (A - H - Ξ΅) (by linarith),
(eventually_atTop.2 ⟨1, fun N (hN : 1 ≀ N) => hN⟩)] with N hp hi hr hN
obtain βŸ¨Ο‰, hΟ‰βŸ© := exists_goodCount_ge (good N) _ hi
refine βŸ¨Ο‰, ?_⟩
have heq := exp_log_yield_lower hp.1 hp.2.1 hp.2.2
have hNr : (0 : ℝ) < N := by exact_mod_cast hN
have he : Real.exp ((N : ℝ) * (A - H - Ξ΅)) ≀
(goodCount (good N) Ο‰ : ℝ) := by
calc
_ ≀ Real.exp (L N) := Real.exp_le_exp.mpr (by
have hm := (lt_div_iffβ‚€ hNr).mp hr
nlinarith)
_ = _ := heq
_ ≀ _ := hΟ‰
simpa only [Nat.floor_natCast] using Nat.floor_le_floor he
theorem eventually_exists_many_good_explicit
{Ξ© E : β„• β†’ Type*} [βˆ€ N, Fintype (Ξ© N)] [βˆ€ N, Nonempty (Ξ© N)]
[βˆ€ N, Fintype (E N)]
(good : βˆ€ N, Ξ© N β†’ E N β†’ Prop) {A H : ℝ} (hH : 0 ≀ H)
(hpos : βˆ€αΆ  N in atTop, 0 < Fintype.card (E N))
(hinc : βˆ€αΆ  N in atTop, βˆ€ e,
(((JointAPFree.modularSet (hashModulus H N)).card : ℝ) /
(hashModulus H N : ℝ) ^ 2 / 2) * (Fintype.card (Ξ© N) : ℝ) ≀
(goodIncidence (good N) e : ℝ))
(hE : Tendsto (fun N => Real.log (Fintype.card (E N) : ℝ) / (N : ℝ))
atTop (𝓝 A))
{Ξ΅ : ℝ} (hΞ΅ : 0 < Ξ΅) :
βˆ€αΆ  N in atTop, βˆƒ Ο‰ : Ξ© N,
⌊Real.exp ((N : ℝ) * (A - H - Ξ΅))βŒ‹β‚Š ≀ goodCount (good N) Ο‰ := by
have hM : βˆ€ N, 2 ≀ hashModulus H N := fun N =>
(by norm_num : 2 ≀ 37).trans (hashModulus_ge H N)
have hr := tendsto_log_hashModulus_div_nat hH
apply eventually_exists_many_good good
(fun N => (JointAPFree.modularSet (hashModulus H N)).card) (hashModulus H)
_ hinc hE (tendsto_log_modularSet_card_div_nat (Eventually.of_forall hM) hr) hr hΞ΅
filter_upwards [hpos] with N hN
exact ⟨hN, JointAPFree.modularSet_card_pos (hM N),
lt_of_lt_of_le (by decide : 0 < 2) (hM N)⟩
theorem fixed_product_subexponential {I : Type*} (s : Finset I) (R : I β†’ β„• β†’ β„•)
(hpos : βˆ€ i ∈ s, βˆ€ N, 0 < R i N)
(hR : βˆ€ i ∈ s,
Tendsto (fun N => Real.log (R i N : ℝ) / (N : ℝ)) atTop (𝓝 0)) :
Tendsto (fun N => Real.log ((∏ i ∈ s, R i N : β„•) : ℝ) / (N : ℝ))
atTop (𝓝 0) := by
simpa only [Finset.sum_const_zero] using
MatrixMultiplication.Foundation.Separation.tendsto_log_nat_prod_div_nat s hpos hR
theorem presence_replications_subexponential (L : β„• β†’ β„•)
(hL : Tendsto (fun N => (L N : ℝ) / (N : ℝ)) atTop (𝓝 0)) :
Tendsto (fun N => Real.log ((2 ^ (3 * L N) : β„•) : ℝ) / (N : ℝ))
atTop (𝓝 0) := by
have h := hL.const_mul (3 * Real.log 2)
simp only [mul_zero] at h
apply h.congr
intro N
rw [Nat.cast_pow, Real.log_pow]
push_cast
ring
end MatrixMultiplication.JointExtractionRates
end
end OAI