import OAI.NumberTheory.GaussianMoat.SieveSmoothing namespace OAI namespace GaussianMoat open scoped BigOperators Classical open Filter theorem exists_sieveCertificate (D : ℝ) (hD : 1≤D) : Nonempty (SieveCertificate D) := by obtain ⟨a,δ,t,K,ha,ha1,haδ,ht,hK,hgap,hcost,hdensity⟩ := exists_separated_parameters let c := topCoefficient a/4 have hc : 0 Real.exp (m:ℝ)) atTop atTop := Real.tendsto_exp_atTop.comp tendsto_natCast_atTop_atTop obtain ⟨m,hbatch,hsmooth,hm⟩ := (hbatch.and ((eventually_allBins_smoothing D W).and (hexp.eventually (eventually_ge_atTop (max X0 (K*Real.log 2)))))).exists have hmX : X0≤Real.exp (m:ℝ) := (le_max_left _ _).trans hm have hmK : K*Real.log 2≤Real.exp (m:ℝ) := (le_max_right _ _).trans hm have hbexists : ∀ w : ℕ, ∃ J : Finset ℕ, t*((100:ℝ)^w*Real.exp m)≤J.card ∧ (∀ i∈J, ∀ j∈J, i hsep w) obtain ⟨hsmooth,htotal⟩ := hsmooth J (fun w hw j hj => (hJ w hw j hj).2) refine ⟨{ schedule := commonBlocks a m W J smoothing := windowSmoothing W m batches := binEnum U last := U.card-1 lengths := fun n => batchWordLength (binEnum U n) rates := fun n => c/(10000000*Real.log ((2:ℝ)^(binEnum U n))) error := Real.exp (-Real.exp m) batch := ?_ divides := ?_ nonneg := (Real.exp_pos _).le smooth := ?_ excess := ?_ }⟩ · intro n hn apply Classical.choice have hn' : n hbounds w) (hsep w) _ hjw _) have hh := precedingFactors_enum_cost U hK hn' hUsep have hm := mul_le_mul_of_nonneg_right hcost (show (0:ℝ)≤2^(binEnum U n) by positivity) exact hh.trans (by convert hm using 1; ring) · intro n hn exact batchWordLength_dvd (binEnum_strictMono U (Nat.lt_succ_self n) (by omega)).le · intro n hn a ha' rw [hUlast,precedingFactors_enum_all] exact hsmooth _ (binEnum_mem U (by omega)) _ (binEnum_mem U (by omega)) a ha' · rw [hUlast,binEnum_sum U (fun j => c/(10000000*Real.log ((2:ℝ)^j)))] have hsum := allBins_rate J (Real.exp_pos (m:ℝ)) hc hJ (fun w _ => hdense w) have hcost' : ((U.card-1:ℕ):ℝ)*Real.exp (-Real.exp m)≤1 := (mul_le_mul_of_nonneg_right (by exact_mod_cast Nat.sub_le U.card 1 : ((U.card-1:ℕ):ℝ)≤U.card) (Real.exp_nonneg _)).trans htotal have hh := hWrate.trans_le hsum linarith only [hcost',hh] theorem finiteSieveEndpoint_proved : FiniteSieveEndpoint := finiteSieve_of_certificates exists_sieveCertificate theorem fullMain : MainEndpoint ∧ UniformEndpoint := endpoints_of_finiteSieve finiteSieveEndpoint_proved end GaussianMoat end OAI