Download data/lean/OAI/LinearAlgebra/MatrixFields/Entropy/JointAmbientRateLimit.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 7.07 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/MatrixFields/Entropy/JointAmbientRateLimit.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/LinearAlgebra/MatrixFields/Entropy/JointAmbientRateLimit.lean
-
curl -L -o JointAmbientRateLimit.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/MatrixFields/Entropy/JointAmbientRateLimit.lean
7.07 kB
| import Mathlib | |
| import OAI.LinearAlgebra.MatrixFields.Construction.JointMarginalSupport | |
| namespace OAI | |
| namespace MatrixAllFields | |
| open scoped BigOperators Topology Polynomial | |
| section | |
| noncomputable section | |
| namespace MatrixMultiplication.JointAmbientRateLimit | |
| open MatrixMultiplication.Foundation JointPopulation JointAmbientDegree Filter | |
| open scoped BigOperators Topology | |
| attribute [local instance] Classical.propDecidable | |
| theorem tendsto_log_succ_div_nat_of_ratio {n : β β β} {mass : β} | |
| (hsize : Tendsto (fun N => (n N : β) / (N : β)) atTop (π mass)) : | |
| Tendsto (fun N => Real.log (n N + 1 : β) / (N : β)) atTop (π 0) := by | |
| let C : β := |mass| + 2 | |
| have hC : 0 < C := by dsimp [C]; positivity | |
| have hmC : mass < C := by dsimp [C]; linarith [le_abs_self mass] | |
| have hlog : Tendsto (fun N : β => Real.log (N : β) / (N : β)) atTop (π 0) := by | |
| simpa only [Function.comp_def, id_eq] using | |
| Real.isLittleO_log_id_atTop.tendsto_div_nhds_zero.comp tendsto_natCast_atTop_atTop | |
| have hc : Tendsto (fun N : β => Real.log (C + 1) / (N : β)) atTop (π 0) := | |
| tendsto_const_nhds.div_atTop tendsto_natCast_atTop_atTop | |
| have hu : Tendsto (fun N : β => | |
| (Real.log (C + 1) + Real.log (N : β)) / (N : β)) atTop (π 0) := by | |
| simpa only [add_div, add_zero] using hc.add hlog | |
| apply tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_const_nhds hu | |
| Β· exact Eventually.of_forall fun N => | |
| div_nonneg (Real.log_nonneg (by exact_mod_cast Nat.succ_le_succ (Nat.zero_le (n N)))) | |
| (Nat.cast_nonneg _) | |
| Β· filter_upwards [(tendsto_order.1 hsize).2 C hmC, | |
| eventually_ge_atTop (1 : β)] with N hn hN | |
| have hNr : (1 : β) β€ N := by exact_mod_cast hN | |
| have hNp : (0 : β) < N := lt_of_lt_of_le zero_lt_one hNr | |
| have hsizeN := (div_lt_iffβ hNp).mp hn | |
| have hbound : (n N + 1 : β) β€ (C + 1) * (N : β) := by | |
| push_cast | |
| nlinarith | |
| have hl := Real.log_le_log (by positivity : (0 : β) < (n N + 1 : β)) hbound | |
| rw [Real.log_mul (by positivity : C + 1 β 0) hNp.ne'] at hl | |
| exact div_le_div_of_nonneg_right hl hNp.le | |
| variable {H : Type*} [Fintype H] [DecidableEq H] | |
| omit [Fintype H] [DecidableEq H] in | |
| theorem tendsto_classExponent_div_nat | |
| (counts : β β H β Shape β β) (s : Fin 3) (h : H) | |
| (cap : β β β) (mass capRate marginalRate : β) | |
| (hsize : Tendsto (fun N => (β a, counts N h a : β) / (N : β)) | |
| atTop (π mass)) | |
| (hcap : Tendsto (fun N => ((β a, counts N h a : β) / (N : β)) * cap N) | |
| atTop (π capRate)) | |
| (hmarginal : Tendsto (fun N => | |
| ((β a, counts N h a : β) / (N : β)) * | |
| finiteEntropy (fun a => (wordPopulation | |
| (sideWord (counts N) s (triple (counts N) (canonicalTarget (counts N))) h) a : β) / | |
| Fintype.card (Positions (counts N) h))) atTop (π marginalRate)) : | |
| Tendsto (fun N => | |
| classExponent (counts N) s (triple (counts N) (canonicalTarget (counts N))) h (cap N) / | |
| (N : β)) atTop (π (capRate - marginalRate)) := by | |
| let A : β := (Fintype.card Shape : β) + (Fintype.card (Fin 17) : β) + 2 | |
| have hlog := tendsto_log_succ_div_nat_of_ratio hsize | |
| have hinv : Tendsto (fun N : β => (1 : β) / N) atTop (π 0) := | |
| tendsto_const_nhds.div_atTop tendsto_natCast_atTop_atTop | |
| have htotal := (hcap.sub hmarginal).add | |
| (((hinv.add hlog).const_mul A).add (hlog.const_mul (Fintype.card Shape : β))) | |
| simp only [add_zero, mul_zero] at htotal | |
| convert htotal using 1 | |
| ext N | |
| dsimp only [classExponent, A, Positions] | |
| simp only [Fintype.card_fin, div_eq_mul_inv] | |
| ring | |
| omit [DecidableEq H] in | |
| theorem tendsto_sum_classExponent_div_nat | |
| (counts : β β H β Shape β β) (s : Fin 3) | |
| (cap : β β H β β) (mass capRate marginalRate : H β β) | |
| (hsize : β h, Tendsto (fun N => (β a, counts N h a : β) / (N : β)) | |
| atTop (π (mass h))) | |
| (hcap : β h, Tendsto (fun N => ((β a, counts N h a : β) / (N : β)) * cap N h) | |
| atTop (π (capRate h))) | |
| (hmarginal : β h, Tendsto (fun N => | |
| ((β a, counts N h a : β) / (N : β)) * | |
| finiteEntropy (fun a => (wordPopulation | |
| (sideWord (counts N) s (triple (counts N) (canonicalTarget (counts N))) h) a : β) / | |
| Fintype.card (Positions (counts N) h))) atTop (π (marginalRate h))) : | |
| Tendsto (fun N => (β h, | |
| classExponent (counts N) s (triple (counts N) (canonicalTarget (counts N))) h (cap N h)) / | |
| (N : β)) atTop (π (β h, (capRate h - marginalRate h))) := by | |
| have hs := tendsto_finsetSum Finset.univ (fun h _ => | |
| tendsto_classExponent_div_nat counts s h (fun N => cap N h) | |
| (mass h) (capRate h) (marginalRate h) (hsize h) (hcap h) (hmarginal h)) | |
| simpa only [Finset.sum_div] using hs | |
| theorem eventually_all_target_degree_upper | |
| (counts : β β H β Shape β β) (sum : H β β) | |
| (cap : β β H β β) (sideRate : Fin 3 β β) (D : β) (hD : 0 β€ D) | |
| (hentropy : βαΆ N in atTop, β h w, localAllowed (counts N) sum h w β | |
| finiteEntropy (fun a => (wordPopulation w a : β) / | |
| Fintype.card (Positions (counts N) h)) β€ cap N h) | |
| (hrate : β s, Tendsto (fun N => (β h, | |
| classExponent (counts N) s (triple (counts N) (canonicalTarget (counts N))) h (cap N h)) / | |
| (N : β)) atTop (π (sideRate s))) | |
| (hside : β s, sideRate s β€ D) (Ξ· : β) (hΞ· : 0 < Ξ·) : | |
| βαΆ N in atTop, β e : Target (counts N), | |
| Real.log ((neighbors (counts N) sum (triple (counts N) e)).card : β) / (N : β) β€ | |
| D + Ξ· := by | |
| have hs : βαΆ N in atTop, β s : Fin 3, | |
| (β h, classExponent (counts N) s | |
| (triple (counts N) (canonicalTarget (counts N))) h (cap N h)) / (N : β) β€ | |
| D + Ξ· / 2 := by | |
| rw [Filter.eventually_all] | |
| intro s | |
| filter_upwards [(tendsto_order.1 (hrate s)).2 (sideRate s + Ξ· / 2) (by linarith)] | |
| with N hN | |
| linarith [hside s] | |
| have hc : Tendsto (fun N : β => Real.log 3 / (N : β)) atTop (π 0) := | |
| tendsto_const_nhds.div_atTop tendsto_natCast_atTop_atTop | |
| filter_upwards [hentropy, hs, (tendsto_order.1 hc).2 (Ξ· / 2) (by linarith), | |
| eventually_ge_atTop (1 : β)] with N he hs hc hN | |
| intro e | |
| by_cases hz : (neighbors (counts N) sum (triple (counts N) e)).card = 0 | |
| Β· simp only [hz, Nat.cast_zero, Real.log_zero, zero_div] | |
| linarith | |
| have hNp : (0 : β) < N := by exact_mod_cast hN | |
| have hupper (s : Fin 3) : | |
| (β h, classExponent (counts N) s (triple (counts N) e) h (cap N h)) β€ | |
| (N : β) * (D + Ξ· / 2) := by | |
| simp_rw [classExponent_target_eq] | |
| simpa only [mul_comm] using (div_le_iffβ hNp).mp (hs s) | |
| have hb := div_le_div_of_nonneg_right | |
| (log_neighbors_card_le (counts N) sum (triple (counts N) e) (cap N) he | |
| ((N : β) * (D + Ξ· / 2)) hupper (Nat.pos_of_ne_zero hz)) hNp.le | |
| rw [add_div, mul_div_cancel_leftβ _ hNp.ne'] at hb | |
| linarith | |
| end MatrixMultiplication.JointAmbientRateLimit | |
| end | |
| end | |
| end MatrixAllFields | |
| end OAI | |