Download data/lean/OAI/LinearAlgebra/MatrixMultiplication/FieldConstruction/SourceRates.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 4.85 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/MatrixMultiplication/FieldConstruction/SourceRates.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/LinearAlgebra/MatrixMultiplication/FieldConstruction/SourceRates.lean
-
curl -L -o SourceRates.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/MatrixMultiplication/FieldConstruction/SourceRates.lean
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 | |