Download data/lean/OAI/NumberTheory/Jacobsthal/Probability/FullPatternVariance.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 10.3 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/NumberTheory/Jacobsthal/Probability/FullPatternVariance.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/NumberTheory/Jacobsthal/Probability/FullPatternVariance.lean
-
curl -L -o FullPatternVariance.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/NumberTheory/Jacobsthal/Probability/FullPatternVariance.lean
10.3 kB
| import OAI.NumberTheory.Jacobsthal.Estimates.ConditionalPatternCounts | |
| import OAI.NumberTheory.Jacobsthal.Primes.StableSourceChebyshev | |
| namespace OAI | |
| namespace Erdos970 | |
| open scoped _root_.Erdos970 | |
| namespace ErdosLargePatternLaw | |
| open NumberTheoryLean ErdosVarianceSmallModel ErdosVarianceMoments | |
| attribute [local instance] Classical.propDecidable | |
| attribute [local instance] Classical.decEq | |
| theorem four_coordinate_count {A B C D : Type*} [Fintype A] [Fintype B] [Fintype C] [Fintype D] | |
| (P : A β B β Prop) (Q : C β D β Prop) (n m : β) | |
| (hP : β a,(Finset.univ.filter (P a)).card=n) | |
| (hQ : β c,(Finset.univ.filter (Q c)).card=m) : | |
| (Finset.univ.filter (fun v : A Γ B Γ C Γ D => P v.1 v.2.1 β§ Q v.2.2.1 v.2.2.2)).card = | |
| Fintype.card A*n*Fintype.card C*m := by | |
| have hi (a : A) (b : B) (c : C) (d : D) : | |
| (if P a b β§ Q c d then 1 else 0 : β)=(if P a b then 1 else 0)*(if Q c d then 1 else 0) := by | |
| by_cases hp : P a b <;> by_cases hq : Q c d <;> simp [hp,hq] | |
| have hp (a : A) : (β b : B,if P a b then 1 else 0)=n := by | |
| simpa only [Finset.card_filter] using hP a | |
| have hq (c : C) : (β d : D,if Q c d then 1 else 0)=m := by | |
| simpa only [Finset.card_filter] using hQ c | |
| have hd (a : A) (b : B) (c : C) : | |
| (β d : D,(if P a b then 1 else 0)*(if Q c d then 1 else 0)) = | |
| (if P a b then 1 else 0)*m := by | |
| calc | |
| _ = (if P a b then 1 else 0)*(β d : D,if Q c d then 1 else 0) := | |
| (Finset.mul_sum _ _ _).symm | |
| _ = _ := by rw [hq] | |
| simp only [Finset.card_filter,Fintype.sum_prod_type,hi] | |
| simp_rw [hd] | |
| simp only [Finset.sum_const,Finset.card_univ,smul_eq_mul] | |
| have hb (a : A) : (β b : B,Fintype.card C*((if P a b then 1 else 0)*m)) = | |
| Fintype.card C*(n*m) := by | |
| calc | |
| _ = Fintype.card C*(β b : B,(if P a b then 1 else 0)*m) := (Finset.mul_sum _ _ _).symm | |
| _ = Fintype.card C*((β b : B,if P a b then 1 else 0)*m) := | |
| congrArg (fun x => Fintype.card C*x) (Finset.sum_mul _ _ _).symm | |
| _ = _ := by rw [hp] | |
| simp_rw [hb] | |
| simp only [Finset.sum_const,Finset.card_univ,smul_eq_mul] | |
| ring | |
| theorem joint_condition_card (w : β) (H qA : β) (beta delta : β t : β,ZMod t) (S : Finset β) | |
| (hqA : β t β coprimePrimes w H,qA.Coprime t) : | |
| (Finset.univ.filter (jointCondition w H qA beta delta S)).card = | |
| (divisorModulus w H).totient*(β t β divisorPrimes w H,(t-(positionResidues S t).card))* | |
| (coprimeModulus w H).totient*(β t β coprimePrimes w H,(t-(positionResidues S t).card)) := by | |
| have he : Finset.univ.filter (jointCondition w H qA beta delta S) = | |
| Finset.univ.filter (fun v : FullPattern w H => | |
| divisorCondition w H beta S v.1 v.2.1 β§ coprimeCondition w H qA delta S v.2.2.1 v.2.2.2) := by | |
| apply Finset.filter_congr | |
| rintro β¨p0,k0,p1,m1β© _ | |
| exact joint_condition_split w H qA beta delta S p0 k0 p1 m1 | |
| rw [he,four_coordinate_count _ _ _ _ | |
| (divisor_condition_card w H beta S) (fun p1 => coprime_condition_card w H qA delta S p1 hqA)] | |
| simp only [ZMod.card_units_eq_totient] | |
| theorem joint_density_split (w : β) (H : β) (S : Finset β) : | |
| jointDensity (divisorPrimes w H) S*jointDensity (coprimePrimes w H) S = | |
| jointDensity (LargePrimeDeletion.cutoffPrimes βwββ) S := by | |
| unfold jointDensity divisorPrimes coprimePrimes | |
| exact Finset.prod_filter_mul_prod_filter_not _ _ _ | |
| theorem joint_expectation (w : β) (H qA : β) (beta delta : β t : β,ZMod t) (S : Finset β) | |
| (hqA : β t β coprimePrimes w H,qA.Coprime t) : | |
| expectation w H (fun v => if jointCondition w H qA beta delta S v then 1 else 0) = | |
| jointDensity (LargePrimeDeletion.cutoffPrimes βwββ) S := by | |
| have h0 : β t β divisorPrimes w H,t.Prime := fun t ht => | |
| (LargePrimeDeletion.mem_cutoffPrimes.mp (Finset.mem_filter.mp ht).1).1 | |
| have h1 : β t β coprimePrimes w H,t.Prime := fun t ht => | |
| (LargePrimeDeletion.mem_cutoffPrimes.mp (Finset.mem_filter.mp ht).1).1 | |
| have hc : (β v : FullPattern w H,if jointCondition w H qA beta delta S v then (1 : β) else 0) = | |
| ((Finset.univ.filter (jointCondition w H qA beta delta S)).card : β) := by | |
| simp only [Finset.card_filter,Nat.cast_sum,Nat.cast_ite,Nat.cast_one,Nat.cast_zero] | |
| have hT0 : (divisorModulus w H : β) β 0 := by exact_mod_cast (divisorModulus_pos w H).ne' | |
| have hT1 : (coprimeModulus w H : β) β 0 := by exact_mod_cast (coprimeModulus_pos w H).ne' | |
| have hP0 : ((divisorModulus w H).totient : β) β 0 := by | |
| exact_mod_cast (Nat.totient_pos.mpr (divisorModulus_pos w H)).ne' | |
| have hP1 : ((coprimeModulus w H).totient : β) β 0 := by | |
| exact_mod_cast (Nat.totient_pos.mpr (coprimeModulus_pos w H)).ne' | |
| rw [expectation,β Finset.mul_sum,hc,joint_condition_card w H qA beta delta S hqA] | |
| simp only [Nat.cast_mul] | |
| rw [product_allowed_eq_density _ S h0,product_allowed_eq_density _ S h1] | |
| change weight w H*(((divisorModulus w H).totient : β)* | |
| ((divisorModulus w H : β)*jointDensity (divisorPrimes w H) S)* | |
| ((coprimeModulus w H).totient : β)* | |
| ((coprimeModulus w H : β)*jointDensity (coprimePrimes w H) S)) = _ | |
| rw [β joint_density_split w H S] | |
| unfold weight | |
| field_simp | |
| end ErdosLargePatternLaw | |
| open _root_.Filter | |
| namespace ErdosLargePatternLaw | |
| open NumberTheoryLean ErdosVarianceSmallModel ErdosVarianceMoments ErdosRandomVariance | |
| attribute [local instance] Classical.propDecidable | |
| attribute [local instance] Classical.decEq | |
| theorem single_expectation (w : β) (H qA : β) (beta delta : β t : β,ZMod t) (j : β) | |
| (hqA : β t β coprimePrimes w H,qA.Coprime t) : | |
| expectation w H (indicator w H qA beta delta j) = | |
| sieveProduct (LargePrimeDeletion.cutoffPrimes βwββ) := by | |
| have h := joint_expectation w H qA beta delta {j} hqA | |
| have he : (fun v => if jointCondition w H qA beta delta {j} v then (1 : β) else 0) = | |
| indicator w H qA beta delta j := by | |
| funext v | |
| simp only [jointCondition,Finset.mem_singleton,forall_eq,indicator] | |
| rw [he,jointDensity_singleton] at h | |
| exact h | |
| theorem pair_expectation (w : β) (H qA : β) (beta delta : β t : β,ZMod t) (i j : β) | |
| (hqA : β t β coprimePrimes w H,qA.Coprime t) : | |
| expectation w H (fun v => indicator w H qA beta delta i v*indicator w H qA beta delta j v) = | |
| pairKernel (LargePrimeDeletion.cutoffPrimes βwββ) i j := by | |
| have h := joint_expectation w H qA beta delta {i,j} hqA | |
| have he : (fun v => indicator w H qA beta delta i v*indicator w H qA beta delta j v) = | |
| (fun v => if jointCondition w H qA beta delta {i,j} v then 1 else 0) := by | |
| funext v | |
| simp only [jointCondition,Finset.forall_mem_insert,Finset.mem_singleton,forall_eq,indicator] | |
| by_cases hi : survives w H qA beta delta i v <;> | |
| by_cases hj : survives w H qA beta delta j v <;> simp [hi,hj] | |
| rw [he,h,jointDensity_pair] | |
| theorem count_variance (w : β) (H qA J : β) (beta delta : β t : β,ZMod t) | |
| (hqA : β t β coprimePrimes w H,qA.Coprime t) : | |
| expectation w H (fun v => ((survivorCount w H qA J beta delta v : β)- | |
| (J : β)*sieveProduct (LargePrimeDeletion.cutoffPrimes βwββ))^2) β€ | |
| (J : β)*sieveProduct (LargePrimeDeletion.cutoffPrimes βwββ) := by | |
| have hs (j : β) := single_expectation w H qA beta delta j hqA | |
| have hp (i j : β) := pair_expectation w H qA beta delta i j hqA | |
| have hh := stable_prime_variance (Finset.univ : Finset (FullPattern w H)) (fun _ => weight w H) | |
| J (indicator w H qA beta delta) (LargePrimeDeletion.cutoffPrimes βwββ) | |
| (fun p hp => (LargePrimeDeletion.mem_cutoffPrimes.mp hp).1) 0 (le_refl _) | |
| (fun j _ v _ => indicator_binary w H qA beta delta j v) | |
| (by simpa only [add_zero] using (weight_sum w H).le) | |
| (fun j _ => by simpa only [sub_zero,one_mul,expectation,weightedMoment] using (hs j).ge) | |
| (fun j _ => by simpa only [add_zero,one_mul,expectation,weightedMoment] using (hs j).le) | |
| (fun i _ j _ _ => by simpa only [add_zero,one_mul,expectation,weightedMoment] using (hp i j).le) | |
| simpa only [mul_zero,zero_mul,one_mul,add_zero,indicatorSum,β count_eq_indicator_sum,expectation,weightedMoment] using hh | |
| theorem uniform_pattern_chebyshev (a eta tau : β) (ha : 0 < a) (heta : 0 < eta) (htau : 0 < tau) : | |
| βαΆ w : β in atTop,1 < w β§ β (H qA : β) (beta delta : β t : β,ZMod t), | |
| (β t β coprimePrimes w H,qA.Coprime t) β β J : β,w^a β€ (J : β) β | |
| (β v : FullPattern w H with eta*((J : β)*SmallSieveFinite.smallEuler βwββ) β€ | |
| |(survivorCount w H qA J beta delta v : β)-(J : β)*SmallSieveFinite.smallEuler βwββ|, | |
| weight w H) β€ tau := by | |
| have heps : 0 < tau*eta^2 := mul_pos htau (sq_pos_of_pos heta) | |
| filter_upwards [stable_source_chebyshev a (tau*eta^2) ha heps] with w hw | |
| refine β¨hw.1,?_β© | |
| intro H qA beta delta hqA J hJ | |
| have hcut : variancePrimes w=LargePrimeDeletion.cutoffPrimes βwββ := by | |
| ext p | |
| simp only [variancePrimes,LargePrimeDeletion.mem_cutoffPrimes,Finset.mem_filter,Finset.mem_Ioc] | |
| exact β¨fun h => β¨h.2,h.1.2β©,fun h => β¨β¨h.1.pos,h.2β©,h.1β©β© | |
| have hs (j : β) := single_expectation w H qA beta delta j hqA | |
| have hp (i j : β) := pair_expectation w H qA beta delta i j hqA | |
| have hh := hw.2 J hJ (FullPattern w H) Finset.univ (fun _ => weight w H) | |
| (indicator w H qA beta delta) 0 eta (fun _ _ => (weight_positive w H).le) | |
| (le_refl _) zero_le_one heta (fun j _ v _ => indicator_binary w H qA beta delta j v) | |
| (by simpa only [add_zero] using (weight_sum w H).le) | |
| (fun j _ => by simpa only [sub_zero,one_mul,hcut,expectation,weightedMoment] using (hs j).ge) | |
| (fun j _ => by simpa only [add_zero,one_mul,hcut,expectation,weightedMoment] using (hs j).le) | |
| (fun i _ j _ _ => by simpa only [add_zero,one_mul,hcut,expectation,weightedMoment] using (hp i j).le) | |
| have hV : sieveProduct (variancePrimes w)=SmallSieveFinite.smallEuler βwββ := by | |
| rw [hcut] | |
| simp only [sieveProduct,SmallSieveFinite.smallEuler,one_div] | |
| have hb : (tau*eta^2+4*0)/eta^2=tau := by | |
| field_simp [heta.ne'] | |
| ring | |
| simpa only [hV,hb,indicatorSum,β count_eq_indicator_sum] using hh | |
| end ErdosLargePatternLaw | |
| end Erdos970 | |
| end OAI | |