Download data/lean/OAI/NumberTheory/PiExponent/Analysis/LogTailAnalytic.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 10.5 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/NumberTheory/PiExponent/Analysis/LogTailAnalytic.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/NumberTheory/PiExponent/Analysis/LogTailAnalytic.lean
-
curl -L -o LogTailAnalytic.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/NumberTheory/PiExponent/Analysis/LogTailAnalytic.lean
10.5 kB
| import Mathlib | |
| import OAI.NumberTheory.PiExponent.Analysis.AnalyticCollision | |
| import OAI.NumberTheory.PiExponent.Approximation.RowTranslation | |
| namespace OAI | |
| open scoped BigOperators | |
| namespace PiExponent.LogTailAnalytic | |
| noncomputable def logTail (T : β) (z : β) : β := | |
| Complex.logTaylor T z - Complex.log (1 + z) | |
| theorem eval_trunc_log (T : β) (z : β) : | |
| (PowerSeries.trunc T (PowerSeries.log β)).eval z = Complex.logTaylor T z := by | |
| change (PowerSeries.trunc T (PowerSeries.log β)).evalβ (RingHom.id β) z = _ | |
| rw [PowerSeries.evalβ_trunc_eq_sum_range] | |
| unfold Complex.logTaylor | |
| apply Finset.sum_congr rfl | |
| intro n hn | |
| simp only [RingHom.id_apply, PowerSeries.coeff_log] | |
| by_cases h : n = 0 | |
| Β· simp [h] | |
| Β· simp [h, map_divβ, map_pow] | |
| ring | |
| theorem analyticAt_logTail (T : β) {z : β} (hz : βzβ < 1) : | |
| AnalyticAt β (logTail T) z := by | |
| unfold logTail Complex.logTaylor | |
| apply AnalyticAt.sub | |
| Β· apply Finset.analyticAt_fun_sum | |
| intro n hn | |
| fun_prop | |
| Β· exact (analyticAt_const.add analyticAt_id).clog (Complex.mem_slitPlane_of_norm_lt_one hz) | |
| theorem norm_logTail_le (T : β) (hT : 1 β€ T) {z : β} (hz : βzβ < 1) : | |
| βlogTail T zβ β€ βzβ ^ T * (1 - βzβ)β»ΒΉ / T := by | |
| obtain β¨n, rflβ© := Nat.exists_eq_succ_of_ne_zero (by omega : T β 0) | |
| unfold logTail | |
| rw [norm_sub_rev] | |
| simpa only [Nat.succ_eq_add_one, Nat.cast_add, Nat.cast_one] using | |
| Complex.norm_log_sub_logTaylor_le n hz | |
| theorem norm_logTail_le_one (T : β) (hT : 1 β€ T) {z : β} (hz : βzβ β€ 1 / 2) : | |
| βlogTail T zβ β€ 1 := by | |
| have hz1 : βzβ < 1 := by linarith | |
| have hpow : βzβ ^ T β€ 1 / 2 := by | |
| obtain β¨n, rflβ© := Nat.exists_eq_succ_of_ne_zero (by omega : T β 0) | |
| rw [pow_succ] | |
| have hh : βzβ ^ n β€ 1 := pow_le_oneβ (norm_nonneg z) hz1.le | |
| nlinarith [norm_nonneg z] | |
| have hinv : (1 - βzβ)β»ΒΉ β€ 2 := by | |
| rw [inv_le_commβ (by linarith : 0 < 1 - βzβ) (by norm_num : (0 : β) < 2)] | |
| linarith | |
| have hTreal : (1 : β) β€ T := by exact_mod_cast hT | |
| calc | |
| βlogTail T zβ β€ βzβ ^ T * (1 - βzβ)β»ΒΉ / T := norm_logTail_le T hT hz1 | |
| _ β€ (1 / 2 : β) * 2 / T := by gcongr | |
| _ β€ 1 := by rw [div_le_iffβ (by positivity : (0 : β) < T)]; nlinarith | |
| theorem norm_prod_logTail_le_one {ΞΉ : Type*} (s : Finset ΞΉ) (T d : ΞΉ β β) | |
| (hT : β i β s, 1 β€ T i) {z : β} (hz : βzβ β€ 1 / 2) : | |
| ββ i β s, logTail (T i) z ^ d iβ β€ 1 := by | |
| rw [norm_prod] | |
| apply Finset.prod_le_oneβ | |
| Β· intro i hi | |
| positivity | |
| Β· intro i hi | |
| rw [norm_pow] | |
| exact pow_le_oneβ (norm_nonneg _) (norm_logTail_le_one (T i) (hT i hi) hz) | |
| theorem analyticAt_prod_logTail {ΞΉ : Type*} (s : Finset ΞΉ) (T d : ΞΉ β β) | |
| {z : β} (hz : βzβ < 1) : | |
| AnalyticAt β (fun t => β i β s, logTail (T i) t ^ d i) z := by | |
| apply Finset.analyticAt_fun_prod | |
| intro i hi | |
| exact (analyticAt_logTail (T i) hz).pow (d i) | |
| theorem norm_rowTest_prod_logTail_le {ΞΉ : Type*} (s : Finset ΞΉ) (T d : ΞΉ β β) | |
| (hT : β i β s, 1 β€ T i) (k : β) : | |
| βAnalyticCollision.rowTest k (fun z => β i β s, logTail (T i) z ^ d i)β β€ | |
| (2 : β) ^ k := by | |
| have h := AnalyticCollision.norm_rowTest_le | |
| (f := fun z => β i β s, logTail (T i) z ^ d i) (D := 1) ?_ k | |
| Β· simpa only [mul_one] using h | |
| intro z hz | |
| apply norm_prod_logTail_le_one s T d hT | |
| exact (by simpa only [Metric.mem_sphere, dist_zero_right] using hz : βzβ = 1 / 2).le | |
| theorem logTail_isBigO (T : β) (hT : 1 β€ T) : | |
| (fun z => logTail T z) =O[nhds (0 : β)] (fun z => z ^ T) := by | |
| obtain β¨n, rflβ© := Nat.exists_eq_succ_of_ne_zero (by omega : T β 0) | |
| have h := (Complex.log_sub_logTaylor_isBigO n).neg_left | |
| simpa only [logTail, neg_sub, Nat.succ_eq_add_one] using h | |
| theorem order_formal_logTail (T : β) : | |
| (T : ββ) β€ (RowTranslation.tail T (PowerSeries.log β)).order := | |
| RowTranslation.order_tail T (PowerSeries.log β) | |
| theorem hasSum_formal_log {z : β} (hz : βzβ < 1) : | |
| HasSum (fun n => PowerSeries.coeff n (PowerSeries.log β) * z ^ n) | |
| (Complex.log (1 + z)) := by | |
| convert Complex.hasSum_taylorSeries_log hz using 1 | |
| funext n | |
| by_cases hn : n = 0 | |
| Β· simp [hn] | |
| Β· simp [PowerSeries.coeff_log, hn, map_divβ, map_pow] | |
| ring | |
| theorem hasSum_trunc_log (T : β) (z : β) : | |
| HasSum (fun n => PowerSeries.coeff n | |
| (PowerSeries.trunc T (PowerSeries.log β) : PowerSeries β) * z ^ n) | |
| (Complex.logTaylor T z) := by | |
| have h := hasSum_sum_of_ne_finset_zero (L := SummationFilter.unconditional β) | |
| (s := Finset.range T) | |
| (f := fun n => PowerSeries.coeff n | |
| (PowerSeries.trunc T (PowerSeries.log β) : PowerSeries β) * z ^ n) ?_ | |
| Β· convert h using 1 | |
| rw [β eval_trunc_log] | |
| change (PowerSeries.trunc T (PowerSeries.log β)).evalβ (RingHom.id β) z = _ | |
| rw [PowerSeries.evalβ_trunc_eq_sum_range] | |
| apply Finset.sum_congr rfl | |
| intro n hn | |
| simp [PowerSeries.coeff_trunc, Finset.mem_range.mp hn] | |
| Β· intro n hn | |
| have hn' : Β¬ n < T := by simpa only [Finset.mem_range] using hn | |
| simp [PowerSeries.coeff_trunc, hn'] | |
| theorem hasSum_formal_logTail (T : β) {z : β} (hz : βzβ < 1) : | |
| HasSum (fun n => PowerSeries.coeff n | |
| (RowTranslation.tail T (PowerSeries.log β)) * z ^ n) (logTail T z) := by | |
| convert (hasSum_trunc_log T z).sub (hasSum_formal_log hz) using 1 | |
| Β· funext n | |
| simp only [RowTranslation.tail, map_sub, sub_mul] | |
| Β· rfl | |
| theorem hasFPowerSeriesAt_logTail (T : β) : | |
| HasFPowerSeriesAt (logTail T) | |
| (FormalMultilinearSeries.ofScalars β | |
| (fun n => PowerSeries.coeff n (RowTranslation.tail T (PowerSeries.log β)))) 0 := by | |
| rw [hasFPowerSeriesAt_iff] | |
| filter_upwards [Metric.ball_mem_nhds (0 : β) (by norm_num : (0 : β) < 1)] with z hz | |
| have hn : βzβ < 1 := by simpa only [Metric.mem_ball, dist_zero_right] using hz | |
| simpa only [FormalMultilinearSeries.coeff_ofScalars, zero_add, smul_eq_mul, mul_comm] using | |
| hasSum_formal_logTail T hn | |
| theorem hasSum_coeff_mul {f g : PowerSeries β} {x y z : β} | |
| (hf : HasSum (fun n => PowerSeries.coeff n f * z ^ n) x) | |
| (hg : HasSum (fun n => PowerSeries.coeff n g * z ^ n) y) : | |
| HasSum (fun n => PowerSeries.coeff n (f * g) * z ^ n) (x * y) := by | |
| have hfn := hf.summable.norm | |
| have hgn := hg.summable.norm | |
| have hs := (summable_norm_sum_mul_antidiagonal_of_summable_norm hfn hgn).of_norm.hasSum | |
| have heq := tsum_mul_tsum_eq_tsum_sum_antidiagonal_of_summable_norm hfn hgn | |
| rw [hf.tsum_eq, hg.tsum_eq] at heq | |
| rw [β heq] at hs | |
| convert hs using 1 | |
| funext n | |
| rw [PowerSeries.coeff_mul, Finset.sum_mul] | |
| apply Finset.sum_congr rfl | |
| intro a ha | |
| have he : a.1 + a.2 = n := Finset.HasAntidiagonal.mem_antidiagonal.mp ha | |
| rw [β he, pow_add] | |
| ring | |
| theorem hasSum_coeff_one (z : β) : | |
| HasSum (fun n => PowerSeries.coeff n (1 : PowerSeries β) * z ^ n) 1 := by | |
| convert hasSum_ite_eq 0 (1 : β) using 1 | |
| funext n | |
| by_cases hn : n = 0 <;> simp [PowerSeries.coeff_one, hn] | |
| theorem hasSum_coeff_pow {f : PowerSeries β} {x z : β} | |
| (hf : HasSum (fun n => PowerSeries.coeff n f * z ^ n) x) (d : β) : | |
| HasSum (fun n => PowerSeries.coeff n (f ^ d) * z ^ n) (x ^ d) := by | |
| induction d with | |
| | zero => simpa only [pow_zero] using hasSum_coeff_one z | |
| | succ d hd => simpa only [pow_succ] using hasSum_coeff_mul hd hf | |
| theorem hasSum_formal_prod_logTail {ΞΉ : Type*} (s : Finset ΞΉ) (T d : ΞΉ β β) | |
| {z : β} (hz : βzβ < 1) : | |
| HasSum (fun n => PowerSeries.coeff n | |
| (β i β s, RowTranslation.tail (T i) (PowerSeries.log β) ^ d i) * z ^ n) | |
| (β i β s, logTail (T i) z ^ d i) := by | |
| classical | |
| induction s using Finset.induction_on with | |
| | empty => simpa only [Finset.prod_empty] using hasSum_coeff_one z | |
| | @insert i s hi hs => | |
| simpa only [Finset.prod_insert hi] using | |
| hasSum_coeff_mul (hasSum_coeff_pow (hasSum_formal_logTail (T i) hz) (d i)) hs | |
| theorem hasFPowerSeriesAt_prod_logTail {ΞΉ : Type*} (s : Finset ΞΉ) (T d : ΞΉ β β) : | |
| HasFPowerSeriesAt (fun z => β i β s, logTail (T i) z ^ d i) | |
| (FormalMultilinearSeries.ofScalars β | |
| (fun n => PowerSeries.coeff n | |
| (β i β s, RowTranslation.tail (T i) (PowerSeries.log β) ^ d i))) 0 := by | |
| rw [hasFPowerSeriesAt_iff] | |
| filter_upwards [Metric.ball_mem_nhds (0 : β) (by norm_num : (0 : β) < 1)] with z hz | |
| have hn : βzβ < 1 := by simpa only [Metric.mem_ball, dist_zero_right] using hz | |
| simpa only [FormalMultilinearSeries.coeff_ofScalars, zero_add, smul_eq_mul, mul_comm] using | |
| hasSum_formal_prod_logTail s T d hn | |
| theorem rowTest_prod_logTail_eq_coeff {ΞΉ : Type*} (s : Finset ΞΉ) (T d : ΞΉ β β) (k : β) : | |
| AnalyticCollision.rowTest k (fun z => β i β s, logTail (T i) z ^ d i) = | |
| PowerSeries.coeff k (β i β s, RowTranslation.tail (T i) (PowerSeries.log β) ^ d i) := by | |
| have hd : DifferentiableOn β (fun z => β i β s, logTail (T i) z ^ d i) | |
| (Metric.closedBall 0 (1 / 2)) := by | |
| intro z hz | |
| apply (analyticAt_prod_logTail s T d ?_).differentiableAt.differentiableWithinAt | |
| have hz' : βzβ β€ 1 / 2 := by simpa only [Metric.mem_closedBall, dist_zero_right] using hz | |
| linarith | |
| have hp := hd.hasFPowerSeriesOnBall (R := (1 / 2 : NNReal)) (by norm_num) | |
| have he := hp.hasFPowerSeriesAt.eq_formalMultilinearSeries | |
| (hasFPowerSeriesAt_prod_logTail s T d) | |
| have hh := congrArg (fun p : FormalMultilinearSeries β β β => p k (fun _ => 1)) he | |
| simpa only [AnalyticCollision.rowTest, FormalMultilinearSeries.apply_eq_prod_smul_coeff, | |
| Finset.prod_const_one, one_smul, FormalMultilinearSeries.coeff_ofScalars, | |
| NNReal.coe_div, NNReal.coe_one, NNReal.coe_ofNat] using hh | |
| theorem norm_coeff_prod_formal_logTail_le {ΞΉ : Type*} (s : Finset ΞΉ) (T d : ΞΉ β β) | |
| (hT : β i β s, 1 β€ T i) (k : β) : | |
| βPowerSeries.coeff k (β i β s, RowTranslation.tail (T i) (PowerSeries.log β) ^ d i)β β€ | |
| (2 : β) ^ k := by | |
| rw [β rowTest_prod_logTail_eq_coeff] | |
| exact norm_rowTest_prod_logTail_le s T d hT k | |
| theorem rowTest_tail_budget {ΞΉ : Type*} (s : Finset ΞΉ) (T d : ΞΉ β β) (k : β) | |
| (hk : AnalyticCollision.rowTest k (fun z => β i β s, logTail (T i) z ^ d i) β 0) : | |
| β i β s, d i * T i β€ k := by | |
| rw [rowTest_prod_logTail_eq_coeff] at hk | |
| exact RowTranslation.tail_budget_nat s T d (fun _ => PowerSeries.log β) k hk | |
| end PiExponent.LogTailAnalytic | |
| end OAI | |