cfahlgren1/math / lean /OAI /NumberTheory /Ostmann /QuadraticSieveComplementError.lean
cfahlgren1's picture
download
raw
3.97 kB
import OAI.NumberTheory.Ostmann.QuadraticSieveComplement
import OAI.NumberTheory.Ostmann.QuadraticSieveCoprimePoisson
namespace OAI
namespace Ostmann.QuadraticSieve
open scoped SchwartzMap
noncomputable def complementarySchwartzSum (W : 𝓒(ℝ, β„‚)) (M : ℝ) (K d q : β„•) : β„‚ :=
βˆ‘' n : {n : β„• // 0 < n}, if squarefreeKernel n.val ≀ K then
(if Odd n.val then (jacobiSym (n.val : β„€) (d ^ 2 * q) : β„‚) *
W ((n.val : ℝ) / M) else 0) else 0
noncomputable def complementaryPoissonMain (W : 𝓒(ℝ, β„‚)) (M : ℝ) (K d q : β„•)
(X₁ Xβ‚‚ L : β„• β†’ ℝ) : β„‚ :=
(1 / 2 : β„‚) * βˆ‘ v ∈ oddSquarefreeUpTo K, if Nat.Coprime v d then
(jacobiSym (v : β„€) q : β„‚) * coprimePoissonMain (squarePullback W 1 (by norm_num))
(2 * q * d) (Real.sqrt (M / v)) (X₁ v) (Xβ‚‚ v) (L v) else 0
theorem complementaryPoisson_error (W : 𝓒(ℝ, β„‚)) (A : β„•) :
βˆƒ C : ℝ, 0 < C ∧ βˆ€ (M : ℝ), 0 < M β†’ βˆ€ (K d q : β„•), d β‰  0 β†’ q β‰  0 β†’
βˆ€ (X₁ Xβ‚‚ J L : β„• β†’ ℝ),
(βˆ€ v ∈ oddSquarefreeUpTo K,
0 < X₁ v ∧ X₁ v ≀ Real.sqrt (M / v) ∧ Real.sqrt (M / v) ≀ Xβ‚‚ v ∧
0 < J v ∧ J v ≀ min (Real.sqrt (M / v) / X₁ v) (Xβ‚‚ v / Real.sqrt (M / v)) ∧
(Xβ‚‚ v / Real.sqrt (M / v)) ^ 2 ≀ L v) β†’
β€–complementarySchwartzSum W M K d q - complementaryPoissonMain W M K d q X₁ Xβ‚‚ Lβ€– ≀
C * βˆ‘ v ∈ oddSquarefreeUpTo K, Real.sqrt (M / v) / J v ^ A := by
let ψ := squarePullback W 1 (by norm_num)
obtain ⟨C, hC, hbound⟩ := coprime_poisson_truncated ψ A
refine ⟨C / 2, by positivity, ?_⟩
intro M hM K d q hd hq X₁ Xβ‚‚ J L hp
let : NeZero d := ⟨hd⟩
let : NeZero q := ⟨hq⟩
have hk : 2 ≀ 2 * q * d := by
have hdp := Nat.pos_of_ne_zero hd
have hqp := Nat.pos_of_ne_zero hq
nlinarith
let E : β„• β†’ β„‚ := fun v =>
(βˆ‘' m : β„€, if Nat.Coprime m.natAbs (2 * q * d) then
ψ ((m : ℝ) / Real.sqrt (M / v)) else 0) -
coprimePoissonMain ψ (2 * q * d) (Real.sqrt (M / v)) (X₁ v) (Xβ‚‚ v) (L v)
have hdiff : complementarySchwartzSum W M K d q -
complementaryPoissonMain W M K d q X₁ Xβ‚‚ L =
(1 / 2 : β„‚) * βˆ‘ v ∈ oddSquarefreeUpTo K,
if Nat.Coprime v d then (jacobiSym (v : β„€) q : β„‚) * E v else 0 := by
rw [complementarySchwartzSum, schwartz_complement_eq_coprime_lattices W M hM,
complementaryPoissonMain, ← mul_sub, ← Finset.sum_sub_distrib]
congr 1
apply Finset.sum_congr rfl
intro v hv
by_cases hc : Nat.Coprime v d
Β· simp only [ite_eq_left hc]
dsimp only [E, ψ]
ring
Β· simp only [ite_eq_right hc, sub_self]
have hn : β€–(1 / 2 : β„‚)β€– = (1 / 2 : ℝ) := by norm_num
rw [hdiff, norm_mul, hn]
calc
(1 / 2 : ℝ) * β€–βˆ‘ v ∈ oddSquarefreeUpTo K,
if Nat.Coprime v d then (jacobiSym (v : β„€) q : β„‚) * E v else 0β€– ≀
(1 / 2 : ℝ) * βˆ‘ v ∈ oddSquarefreeUpTo K,
β€–if Nat.Coprime v d then (jacobiSym (v : β„€) q : β„‚) * E v else 0β€– :=
mul_le_mul_of_nonneg_left (norm_sum_le _ _) (by norm_num)
_ ≀ (1 / 2 : ℝ) * βˆ‘ v ∈ oddSquarefreeUpTo K,
C * Real.sqrt (M / v) / J v ^ A := by
apply mul_le_mul_of_nonneg_left _ (by norm_num)
apply Finset.sum_le_sum
intro v hv
obtain ⟨h1, h2, h3, hJ, hmin, hL⟩ := hp v hv
have he := hbound (2 * q * d) (Real.sqrt (M / v)) (X₁ v) (Xβ‚‚ v) (J v) (L v)
hk h1 h2 h3 hJ hmin hL
change β€–E vβ€– ≀ C * Real.sqrt (M / v) / J v ^ A at he
by_cases hc : Nat.Coprime v d
Β· rw [ite_eq_left hc]
apply le_trans _ he
rcases jacobiSym.trichotomy (v : β„€) q with h | h | h <;> simp [h]
Β· rw [ite_eq_right hc, norm_zero]
positivity
_ = _ := by
rw [Finset.mul_sum, Finset.mul_sum]
apply Finset.sum_congr rfl
intro v hv
ring
end Ostmann.QuadraticSieve
end OAI

Xet Storage Details

Size:
3.97 kB
Β·
Xet hash:
79765270a86abe929fcf399b183d3f4f0abd48d3a76f9a2f2bcdeb1ef42d4bc0

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