File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -442,6 +442,20 @@ theorem prod_pow_prime_padicValNat (n : Nat) (hn : n ≠ 0) (m : Nat) (pr : n <
442442 · intro p hp
443443 simp [factorization_def n (prime_of_mem_primeFactors hp)]
444444
445+ lemma prod_pow_primeFactors_factorization (hn : n ≠ 0 ) :
446+ n = ∏ (p : n.primeFactors), (p : ℕ) ^ (n.factorization p) := by
447+ nth_rw 1 [← factorization_prod_pow_eq_self hn]
448+ rw [prod_factorization_eq_prod_primeFactors _]
449+ exact prod_subtype n.primeFactors (fun _ ↦ Iff.rfl) fun a ↦ a ^ n.factorization a
450+
451+ lemma pairwise_coprime_pow_primeFactors_factorization :
452+ Pairwise (Function.onFun Nat.Coprime fun (p : n.primeFactors) ↦ p ^ n.factorization p) := by
453+ intro p1 p2 hp
454+ refine Nat.Coprime.pow (n.factorization p1) (n.factorization p2) ?_
455+ refine (Nat.coprime_primes ?_ ?_).mpr <| Subtype.coe_ne_coe.mpr hp
456+ · exact Nat.prime_of_mem_primeFactors p1.2
457+ · exact Nat.prime_of_mem_primeFactors p2.2
458+
445459/-! ### Lemmas about factorizations of particular functions -/
446460
447461/-- Exactly `n / p` naturals in `[1, n]` are multiples of `p`.
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ Authors: Anne Baanen
66import Mathlib.RingTheory.Ideal.Quotient.Operations
77import Mathlib.RingTheory.Int.Basic
88import Mathlib.RingTheory.ZMod
9+ import Mathlib.Data.Nat.Factorization.Basic
910
1011/-!
1112# `ZMod n` and quotient groups / rings
@@ -76,4 +77,11 @@ def ZMod.prodEquivPi {ι : Type*} [Fintype ι] (a : ι → ℕ)
7677 quotientInfRingEquivPiQuotient _ this |>.trans <|
7778 RingEquiv.piCongrRight fun i ↦ Int.quotientSpanNatEquivZMod (a i)
7879
80+ /-- The **Chinese remainder theorem** , version for `ZMod n`. -/
81+ def ZMod.equivPi (hn : n ≠ 0 ) :
82+ ZMod n ≃+* Π (p : n.primeFactors), ZMod (p ^ (n.factorization p)) :=
83+ (ringEquivCongr <| Nat.prod_pow_primeFactors_factorization hn).trans
84+ <| prodEquivPi (fun (p : n.primeFactors) ↦ (p : ℕ) ^ (n.factorization p))
85+ n.pairwise_coprime_pow_primeFactors_factorization
86+
7987end ChineseRemainder
You can’t perform that action at this time.
0 commit comments