Download data/lean/OAI/NumberTheory/Jacobsthal/Estimates/ConditionalPatternCounts.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 9.41 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/NumberTheory/Jacobsthal/Estimates/ConditionalPatternCounts.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/NumberTheory/Jacobsthal/Estimates/ConditionalPatternCounts.lean
-
curl -L -o ConditionalPatternCounts.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/NumberTheory/Jacobsthal/Estimates/ConditionalPatternCounts.lean
9.41 kB
| import OAI.NumberTheory.Jacobsthal.Estimates.SmallModelSourceScales | |
| namespace OAI | |
| namespace Erdos970 | |
| open scoped _root_.Erdos970 | |
| namespace ErdosLargePatternLaw | |
| open ErdosVarianceSmallModel | |
| attribute [local instance] Classical.propDecidable | |
| abbrev FullPattern (w : β) (H : β) := | |
| (ZMod (divisorModulus w H))Λ£ Γ ZMod (divisorModulus w H) Γ | |
| (ZMod (coprimeModulus w H))Λ£ Γ ZMod (coprimeModulus w H) | |
| noncomputable def weight (w : β) (H : β) : β := | |
| 1/(((divisorModulus w H).totient : β)*(divisorModulus w H : β)* | |
| ((coprimeModulus w H).totient : β)*(coprimeModulus w H : β)) | |
| noncomputable def expectation (w : β) (H : β) (F : FullPattern w H β β) : β := | |
| β v,weight w H*F v | |
| def survives (w : β) (H qA : β) (beta delta : β t : β,ZMod t) | |
| (j : β) (v : FullPattern w H) : Prop := | |
| (β t β divisorPrimes w H,(v.2.1.val : ZMod t)+(v.1.val.val : ZMod t)*(j : ZMod t) β beta t) β§ | |
| (β t β coprimePrimes w H,(v.2.2.1.val.val : ZMod t)*(qA : ZMod t)* | |
| ((v.2.2.2.val : ZMod t)+(H : ZMod t)*(j : ZMod t)) β delta t) | |
| def jointCondition (w : β) (H qA : β) (beta delta : β t : β,ZMod t) | |
| (S : Finset β) (v : FullPattern w H) : Prop := β j β S,survives w H qA beta delta j v | |
| noncomputable def indicator (w : β) (H qA : β) (beta delta : β t : β,ZMod t) | |
| (j : β) (v : FullPattern w H) : β := if survives w H qA beta delta j v then 1 else 0 | |
| noncomputable def survivorCount (w : β) (H qA J : β) (beta delta : β t : β,ZMod t) | |
| (v : FullPattern w H) : β := ((Finset.range J).filter (fun j => survives w H qA beta delta j v)).card | |
| theorem pattern_card (w : β) (H : β) : Fintype.card (FullPattern w H) = | |
| (divisorModulus w H).totient*divisorModulus w H*(coprimeModulus w H).totient*coprimeModulus w H := by | |
| simp only [FullPattern,Fintype.card_prod,ZMod.card_units_eq_totient,ZMod.card] | |
| ring | |
| theorem weight_positive (w : β) (H : β) : 0 < weight w H := by | |
| have hT0 := divisorModulus_pos w H | |
| have hT1 := coprimeModulus_pos w H | |
| have hP0 := Nat.totient_pos.mpr hT0 | |
| have hP1 := Nat.totient_pos.mpr hT1 | |
| unfold weight | |
| positivity | |
| theorem weight_sum (w : β) (H : β) : (β _v : FullPattern w H,weight w H)=1 := by | |
| 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' | |
| simp only [Finset.sum_const,Finset.card_univ,pattern_card,nsmul_eq_mul,Nat.cast_mul,weight] | |
| field_simp | |
| theorem indicator_binary (w : β) (H qA : β) (beta delta : β t : β,ZMod t) | |
| (j : β) (v : FullPattern w H) : indicator w H qA beta delta j v=0 β¨ indicator w H qA beta delta j v=1 := by | |
| unfold indicator | |
| split_ifs <;> simp | |
| theorem count_eq_indicator_sum (w : β) (H qA J : β) (beta delta : β t : β,ZMod t) | |
| (v : FullPattern w H) : (survivorCount w H qA J beta delta v : β)= | |
| β j β Finset.range J,indicator w H qA beta delta j v := by | |
| simp only [survivorCount,Finset.card_filter,Nat.cast_sum,Nat.cast_ite,Nat.cast_one,Nat.cast_zero,indicator] | |
| end ErdosLargePatternLaw | |
| namespace ErdosLargePatternLaw | |
| open NumberTheoryLean ErdosVarianceSmallModel ErdosVarianceMoments | |
| attribute [local instance] Classical.propDecidable | |
| attribute [local instance] Classical.decEq | |
| noncomputable def projectedUnit (M t : β) [NeZero M] (ht : t β£ M) (p : (ZMod M)Λ£) : (ZMod t)Λ£ := | |
| Units.map (ZMod.castHom ht (ZMod t)).toMonoidHom p | |
| theorem projectedUnit_coe (M t : β) [NeZero M] (ht : t β£ M) (p : (ZMod M)Λ£) : | |
| (projectedUnit M t ht p : ZMod t) = (p.val.val : ZMod t) := by | |
| change ZMod.castHom ht (ZMod t) p.val = _ | |
| calc | |
| ZMod.castHom ht (ZMod t) p.val = | |
| ZMod.castHom ht (ZMod t) (p.val.val : ZMod M) := | |
| congrArg (ZMod.castHom ht (ZMod t)) (ZMod.natCast_zmod_val p.val).symm | |
| _ = _ := map_natCast (ZMod.castHom ht (ZMod t)) p.val.val | |
| def divisorCondition (w : β) (H : β) (beta : β t : β,ZMod t) (S : Finset β) | |
| (p0 : (ZMod (divisorModulus w H))Λ£) (k0 : ZMod (divisorModulus w H)) : Prop := | |
| β t β divisorPrimes w H,β j β S,(k0.val : ZMod t)+(p0.val.val : ZMod t)*(j : ZMod t) β beta t | |
| def coprimeCondition (w : β) (H qA : β) (delta : β t : β,ZMod t) (S : Finset β) | |
| (p1 : (ZMod (coprimeModulus w H))Λ£) (m1 : ZMod (coprimeModulus w H)) : Prop := | |
| β t β coprimePrimes w H,β j β S,(p1.val.val : ZMod t)*(qA : ZMod t)* | |
| ((m1.val : ZMod t)+(H : ZMod t)*(j : ZMod t)) β delta t | |
| theorem joint_condition_split (w : β) (H qA : β) (beta delta : β t : β,ZMod t) | |
| (S : Finset β) (p0 : (ZMod (divisorModulus w H))Λ£) (k0 : ZMod (divisorModulus w H)) | |
| (p1 : (ZMod (coprimeModulus w H))Λ£) (m1 : ZMod (coprimeModulus w H)) : | |
| jointCondition w H qA beta delta S (p0,k0,p1,m1) β | |
| divisorCondition w H beta S p0 k0 β§ coprimeCondition w H qA delta S p1 m1 := by | |
| constructor | |
| Β· intro h | |
| exact β¨fun t ht j hj => (h j hj).1 t ht,fun t ht j hj => (h j hj).2 t htβ© | |
| Β· rintro β¨h0,h1β© j hj | |
| exact β¨fun t ht => h0 t ht j hj,fun t ht => h1 t ht j hjβ© | |
| theorem divisor_condition_card (w : β) (H : β) (beta : β t : β,ZMod t) (S : Finset β) | |
| (p0 : (ZMod (divisorModulus w H))Λ£) : | |
| (Finset.univ.filter (divisorCondition w H beta S p0)).card = | |
| β t β divisorPrimes w H,(t-(positionResidues S t).card) := by | |
| let u (t : β) : (ZMod t)Λ£ := | |
| if ht : t β divisorPrimes w H then projectedUnit (divisorModulus w H) t (Finset.dvd_prod_of_mem _ ht) p0 else 1 | |
| have hu (t : β) (ht : t β divisorPrimes w H) : (u t : ZMod t)=(p0.val.val : ZMod t) := by | |
| dsimp only [u] | |
| rw [dite_eq_left ht] | |
| exact projectedUnit_coe (divisorModulus w H) t (Finset.dvd_prod_of_mem _ ht) p0 | |
| have hP (t : β) (ht : t β divisorPrimes w H) : t.Prime := | |
| (LargePrimeDeletion.mem_cutoffPrimes.mp (Finset.mem_filter.mp ht).1).1 | |
| let : NeZero (β t β divisorPrimes w H,t) := β¨(divisorModulus_pos w H).ne'β© | |
| have hh := prime_unit_avoidance_card (divisorPrimes w H) S hP u beta | |
| have he : Finset.univ.filter (divisorCondition w H beta S p0) = | |
| Finset.univ.filter (fun k0 : ZMod (divisorModulus w H) => | |
| β t β divisorPrimes w H,β j β S,(k0.val : ZMod t)+(u t : ZMod t)*(j : ZMod t) β beta t) := by | |
| apply Finset.filter_congr | |
| intro k0 _ | |
| unfold divisorCondition | |
| exact forall_congr' (fun t => forall_congr' (fun ht => by rw [hu t ht])) | |
| rw [he] | |
| exact hh | |
| theorem multiply_unit_iff (t : β) (u : (ZMod t)Λ£) (x c : ZMod t) : | |
| (u : ZMod t)*x=c β x=(β(uβ»ΒΉ) : ZMod t)*c := by | |
| constructor | |
| Β· intro h | |
| have hh := congrArg (fun y : ZMod t => (β(uβ»ΒΉ) : ZMod t)*y) h | |
| simpa only [β mul_assoc,Units.inv_mul,one_mul] using hh | |
| Β· intro h | |
| rw [h,β mul_assoc,Units.mul_inv,one_mul] | |
| theorem coprime_condition_card (w : β) (H qA : β) (delta : β t : β,ZMod t) (S : Finset β) | |
| (p1 : (ZMod (coprimeModulus w H))Λ£) (hqA : β t β coprimePrimes w H,qA.Coprime t) : | |
| (Finset.univ.filter (coprimeCondition w H qA delta S p1)).card = | |
| β t β coprimePrimes w H,(t-(positionResidues S t).card) := by | |
| let u (t : β) : (ZMod t)Λ£ := if ht : t β coprimePrimes w H then | |
| ZMod.unitOfCoprime H | |
| (((LargePrimeDeletion.mem_cutoffPrimes.mp (Finset.mem_filter.mp ht).1).1.coprime_iff_not_dvd.mpr | |
| (Finset.mem_filter.mp ht).2).symm) else 1 | |
| let coeff (t : β) (ht : t β coprimePrimes w H) : (ZMod t)Λ£ := | |
| projectedUnit (coprimeModulus w H) t (Finset.dvd_prod_of_mem _ ht) p1*ZMod.unitOfCoprime qA (hqA t ht) | |
| let c (t : β) : ZMod t := if ht : t β coprimePrimes w H then (β((coeff t ht)β»ΒΉ) : ZMod t)*delta t else 0 | |
| have hu (t : β) (ht : t β coprimePrimes w H) : (u t : ZMod t)=(H : ZMod t) := by | |
| simp only [u,dite_eq_left ht,ZMod.coe_unitOfCoprime] | |
| have hc (t : β) (ht : t β coprimePrimes w H) : | |
| (coeff t ht : ZMod t)=(p1.val.val : ZMod t)*(qA : ZMod t) := by | |
| simp only [coeff,Units.val_mul,ZMod.coe_unitOfCoprime] | |
| exact congrArg (fun v : ZMod t => v*(qA : ZMod t)) | |
| (projectedUnit_coe (coprimeModulus w H) t (Finset.dvd_prod_of_mem _ ht) p1) | |
| have hP (t : β) (ht : t β coprimePrimes w H) : t.Prime := | |
| (LargePrimeDeletion.mem_cutoffPrimes.mp (Finset.mem_filter.mp ht).1).1 | |
| let : NeZero (β t β coprimePrimes w H,t) := β¨(coprimeModulus_pos w H).ne'β© | |
| have hh := prime_unit_avoidance_card (coprimePrimes w H) S hP u c | |
| have he : Finset.univ.filter (coprimeCondition w H qA delta S p1) = | |
| Finset.univ.filter (fun m1 : ZMod (coprimeModulus w H) => | |
| β t β coprimePrimes w H,β j β S,(m1.val : ZMod t)+(u t : ZMod t)*(j : ZMod t) β c t) := by | |
| apply Finset.filter_congr | |
| intro m1 _ | |
| unfold coprimeCondition | |
| apply forall_congr' | |
| intro t | |
| apply forall_congr' | |
| intro ht | |
| rw [hu t ht] | |
| apply forall_congr' | |
| intro j | |
| apply forall_congr' | |
| intro _hj | |
| simp only [c,dite_eq_left ht] | |
| rw [β hc t ht] | |
| exact not_congr (multiply_unit_iff t (coeff t ht) _ _) | |
| rw [he] | |
| exact hh | |
| end ErdosLargePatternLaw | |
| end Erdos970 | |
| end OAI | |