cfahlgren1's picture
download
raw
4.85 kB
import OAI.LinearAlgebra.MatrixMultiplication.FieldConstruction.Source
import Mathlib.Analysis.SpecialFunctions.Log.Basic
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Positivity
import Mathlib.Tactic.Ring
namespace OAI
/-! Tensor extraction over arbitrary fields and its asymptotic rate. -/
noncomputable section
namespace MatrixMultiplication.AllFieldSourceRates
open AllFieldSource Filter
open scoped Topology
private theorem tendsto_log_linear_div_nat (a : โ„) (ha : 0 < a) :
Tendsto (fun N : โ„• => Real.log (a * N + 1) / (N : โ„)) atTop (๐“ 0) := by
have hnat : Tendsto (fun N : โ„• => (N : โ„)) atTop atTop :=
tendsto_natCast_atTop_atTop
have harg : Tendsto (fun N : โ„• => a * N + 1) atTop atTop :=
(hnat.const_mul_atTop ha).atTop_add_nonneg (fun _ => zero_le_one)
have hlog : Tendsto (fun N : โ„• => Real.log (a * N + 1) / (a * N + 1))
atTop (๐“ 0) := by
simpa only [Function.comp_def, id_eq] using
Real.isLittleO_log_id_atTop.tendsto_div_nhds_zero.comp harg
have hinv : Tendsto (fun N : โ„• => (1 : โ„) / N) atTop (๐“ 0) :=
tendsto_const_nhds.div_atTop hnat
have hratio : Tendsto (fun N : โ„• => (a * N + 1) / (N : โ„)) atTop (๐“ a) := by
have hsum : Tendsto (fun N : โ„• => a + 1 / (N : โ„)) atTop (๐“ a) := by
simpa only [add_zero] using hinv.const_add a
apply hsum.congr'
filter_upwards [eventually_ne_atTop (0 : โ„•)] with N hN
have hN' : (N : โ„) โ‰  0 := Nat.cast_ne_zero.mpr hN
field_simp [hN']
have hprod : Tendsto (fun N : โ„• =>
(Real.log (a * N + 1) / (a * N + 1)) * ((a * N + 1) / (N : โ„)))
atTop (๐“ 0) := by
simpa only [zero_mul] using hlog.mul hratio
apply hprod.congr
intro N
have harg' : a * (N : โ„) + 1 โ‰  0 := by positivity
exact div_mul_div_cancelโ‚€ harg'
theorem tendsto_log_polynomial_overhead (K : โ„•) (hK : 0 < K) :
Tendsto (fun N : โ„• =>
Real.log (((3 * (8 * K * N) + 1) ^ 2 : โ„•) : โ„) / ((K : โ„) * N))
atTop (๐“ 0) := by
have hK' : (0 : โ„) < K := Nat.cast_pos.mpr hK
have hbase := tendsto_log_linear_div_nat (3 * (8 * (K : โ„))) (by positivity)
have hscaled : Tendsto (fun N : โ„• =>
(2 * (Real.log (3 * (8 * (K : โ„)) * N + 1) / (N : โ„))) / (K : โ„))
atTop (๐“ 0) := by
simpa only [mul_zero, zero_div] using (hbase.const_mul 2).div_const (K : โ„)
apply hscaled.congr
intro N
have harg : ((3 * (8 * K * N) + 1 : โ„•) : โ„) =
3 * (8 * (K : โ„)) * N + 1 := by push_cast; ring
rw [Nat.cast_pow, Real.log_pow, harg]
norm_num only [Nat.cast_ofNat]
ring
theorem tendsto_log_exponential_source (K : โ„•) (hK : 0 < K) :
Tendsto (fun N : โ„• =>
Real.log ((7 ^ (8 * K * N) : โ„•) : โ„) / ((K : โ„) * N))
atTop (๐“ (8 * Real.log 7)) := by
have hK' : (K : โ„) โ‰  0 := Nat.cast_ne_zero.mpr (Nat.ne_of_gt hK)
apply tendsto_const_nhds.congr'
filter_upwards [eventually_ne_atTop (0 : โ„•)] with N hN
have hN' : (N : โ„) โ‰  0 := Nat.cast_ne_zero.mpr hN
rw [Nat.cast_pow, Real.log_pow]
push_cast
field_simp [hK', hN']
theorem log_rankBudget (Copies : Type*) [Fintype Copies] (K N : โ„•)
(hcopies : 0 < Fintype.card Copies) :
Real.log (rankBudget Copies K N : โ„) =
Real.log (Fintype.card Copies : โ„) +
Real.log (((3 * (8 * K * N) + 1) ^ 2 : โ„•) : โ„) +
Real.log ((7 ^ (8 * K * N) : โ„•) : โ„) := by
have hc : (Fintype.card Copies : โ„) โ‰  0 :=
Nat.cast_ne_zero.mpr (Nat.ne_of_gt hcopies)
have hp : (((3 * (8 * K * N) + 1) ^ 2 : โ„•) : โ„) โ‰  0 := by positivity
have he : ((7 ^ (8 * K * N) : โ„•) : โ„) โ‰  0 := by positivity
simp only [rankBudget, Nat.cast_mul]
rw [Real.log_mul hc (mul_ne_zero hp he), Real.log_mul hp he, โ† add_assoc]
theorem tendsto_log_rankBudget (Copies : โ„• โ†’ Type*) [โˆ€ N, Fintype (Copies N)]
(K : โ„•) (hK : 0 < K)
(hcopies : โˆ€ N, 0 < Fintype.card (Copies N))
(hcopyRate : Tendsto (fun N : โ„• =>
Real.log (Fintype.card (Copies N) : โ„) / (N : โ„)) atTop (๐“ 0)) :
Tendsto (fun N : โ„• =>
Real.log (rankBudget (Copies N) K N : โ„) / ((K : โ„) * N))
atTop (๐“ (8 * Real.log 7)) := by
have hc : Tendsto (fun N : โ„• =>
Real.log (Fintype.card (Copies N) : โ„) / ((K : โ„) * N)) atTop (๐“ 0) := by
have h : Tendsto (fun N : โ„• =>
(Real.log (Fintype.card (Copies N) : โ„) / (N : โ„)) / (K : โ„))
atTop (๐“ 0) := by
simpa only [zero_div] using hcopyRate.div_const (K : โ„)
apply h.congr
intro N
ring
have hsum := (hc.add (tendsto_log_polynomial_overhead K hK)).add
(tendsto_log_exponential_source K hK)
simp only [zero_add] at hsum
apply hsum.congr
intro N
rw [log_rankBudget (Copies N) K N (hcopies N), add_div, add_div]
end MatrixMultiplication.AllFieldSourceRates
end
end OAI

Xet Storage Details

Size:
4.85 kB
ยท
Xet hash:
5732df2ad9f60caabc8b8414bd8565377e2729222d05eb1774e831be6fff76ea

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.