@@ -132,4 +132,97 @@ theorem choose_pow_mul_pow_mul_modEq_choose_nat :
132132 rw [← Int.natCast_modEq_iff]
133133 exact_mod_cast choose_pow_mul_pow_mul_modEq_choose
134134
135+ /-- For primes `p` and positive integer `n`, assume that for all `i ∈ Icc 1 (n - 1)`,
136+ `choose n i` congruent to `0` module `p`, then `n = p ^ multiplicity p n`.
137+ Also see `eq_pow_multiplicity_of_choose_modEq_zero_nat` for the version with `MOD`. -/
138+ theorem eq_pow_multiplicity_of_choose_modEq_zero (hn : 0 < n)
139+ (h : ∀ i ∈ Icc 1 (n - 1 ), n.choose i ≡ 0 [ZMOD p]) : n = p ^ multiplicity p n := by
140+ rename_i hp
141+ by_contra! hn₀
142+ obtain ⟨m, hm⟩ := pow_multiplicity_dvd p n
143+ specialize h (p ^ multiplicity p n) (by grind [le_of_dvd hn (pow_multiplicity_dvd p n)])
144+ nth_grw 1 [← mul_one (p ^ _), hm, choose_pow_mul_pow_mul_modEq_choose, choose_one_right] at h
145+ suffices multiplicity p n + 1 ≤ multiplicity p n by lia
146+ rw [← FiniteMultiplicity.pow_dvd_iff_le_multiplicity]
147+ · nth_rw 2 [hm]
148+ simpa [pow_add] using Nat.mul_dvd_mul_left _ (dvd_iff_mod_eq_zero.mpr (by exact_mod_cast h))
149+ · exact finiteMultiplicity_iff.mpr ⟨hp.out.ne_one, hn⟩
150+
151+ /-- For primes `p` and positive integer `n`, assume that for all `i ∈ Icc 1 (n - 1)`,
152+ `choose n i` congruent to `0` module `p`, then `n = p ^ multiplicity p n`.
153+ Also see `eq_pow_multiplicity_of_choose_modEq_zero` for the version with `ZMOD`. -/
154+ theorem eq_pow_multiplicity_of_choose_modEq_zero_nat (hn : 0 < n)
155+ (h : ∀ i ∈ Icc 1 (n - 1 ), n.choose i ≡ 0 [MOD p]) : n = p ^ multiplicity p n :=
156+ eq_pow_multiplicity_of_choose_modEq_zero hn (by exact_mod_cast h)
157+
158+ /-- For a prime power `n`, the minimal prime factor divides the greatest common divisor of
159+ `choose n 1, ⋯, choose n (n - 1)`. -/
160+ theorem minFac_dvd_gcd_choose_of_isPrimePow (h : IsPrimePow n) :
161+ n.minFac ∣ (Icc 1 (n - 1 )).gcd n.choose := by
162+ obtain ⟨k, _, _, hn₁⟩ := (isPrimePow_nat_iff_bounded_log_minFac _).mp h
163+ exact dvd_gcd_iff.mpr fun i hi => by
164+ nth_rw 2 [hn₁]
165+ exact Prime.dvd_choose_pow (minFac_prime_iff.mpr h.ne_one) (by grind) (by grind)
166+
167+ lemma minFac_sq_ndvd_gcd_choose_of_isPrimePow (h : IsPrimePow n) :
168+ ¬ n.minFac ^ 2 ∣ (Icc 1 (n - 1 )).gcd n.choose := by
169+ obtain ⟨k, _, k_pos, hn₁⟩ := (isPrimePow_nat_iff_bounded_log_minFac _).mp h
170+ have isPrime := minFac_prime_iff.mpr (IsPrimePow.ne_one h)
171+ refine mt Finset.dvd_gcd_iff.mp ?_
172+ simp only [mem_Icc, not_forall]
173+ have : n.minFac ^ (k - 1 ) ≤ n.minFac ^ k := Nat.pow_le_pow_right (minFac_pos n) (sub_le k 1 )
174+ refine ⟨n.minFac ^ (k - 1 ), ⟨one_le_pow _ _ (minFac_pos n), ?_⟩, ?_⟩
175+ · refine le_sub_one_of_lt ?_
176+ nth_rw 2 [hn₁]
177+ exact Nat.pow_lt_pow_of_lt (Prime.one_lt isPrime) (sub_one_lt_of_lt k_pos)
178+ · refine emultiplicity_lt_iff_not_dvd.mp ?_
179+ nth_rw 2 [hn₁]
180+ rw [Nat.Prime.emultiplicity_choose_prime_pow isPrime this (pow_ne_zero _
181+ (Nat.Prime.ne_zero isPrime)), multiplicity_pow_self_of_prime (prime_iff.mp isPrime)]
182+ norm_cast
183+ grind
184+
185+ lemma primeFactors_gcd_choose_of_isPrimePow (h : IsPrimePow n) :
186+ ((Icc 1 (n - 1 )).gcd n.choose).primeFactors = {n.minFac} := by
187+ have ne_zero : (Icc 1 (n - 1 )).gcd n.choose ≠ 0 :=
188+ gcd_ne_zero_iff.mpr ⟨1 , by simp; grind [IsPrimePow.two_le h]⟩
189+ have isPrime := minFac_prime_iff.mpr (IsPrimePow.ne_one h)
190+ refine eq_singleton_iff_unique_mem.mpr ⟨isPrime.mem_primeFactors
191+ (minFac_dvd_gcd_choose_of_isPrimePow h) ne_zero, ?_⟩
192+ intro p hp
193+ simp only [mem_primeFactors, ne_eq] at hp
194+ obtain ⟨hp₁, hp₂, hp₃⟩ := hp
195+ haveI : Fact (Nat.Prime p) := ⟨hp₁⟩
196+ simp_rw [Finset.dvd_gcd_iff, ← modEq_zero_iff_dvd] at hp₂
197+ have := eq_pow_multiplicity_of_choose_modEq_zero_nat h.pos hp₂
198+ have dvd_pow : n.minFac ∣ p ^ multiplicity p n := this ▸ minFac_dvd _
199+ exact (Nat.prime_dvd_prime_iff_eq isPrime hp₁).mp (isPrime.dvd_of_dvd_pow dvd_pow)|>.symm
200+
201+ /-- For a prime power `n`, the greatest common divisor of `choose n 1, ⋯, choose n (n - 1)`
202+ is actually the minimal prime factor of `n`. -/
203+ theorem gcd_choose_eq_minFac_of_isPrimePow (h : IsPrimePow n) :
204+ (Icc 1 (n - 1 )).gcd n.choose = n.minFac := by
205+ have ne_zero : (Icc 1 (n - 1 )).gcd n.choose ≠ 0 :=
206+ gcd_ne_zero_iff.mpr ⟨1 , by simp; grind [IsPrimePow.two_le h]⟩
207+ have isPrime := minFac_prime_iff.mpr (IsPrimePow.ne_one h)
208+ have : multiplicity n.minFac ((Icc 1 (n - 1 )).gcd n.choose) = 1 := by
209+ refine multiplicity_eq_of_dvd_of_not_dvd ?_ (minFac_sq_ndvd_gcd_choose_of_isPrimePow h)
210+ simpa using minFac_dvd_gcd_choose_of_isPrimePow h
211+ rw [Nat.prod_pow_primeFactors_factorization ne_zero, primeFactors_gcd_choose_of_isPrimePow h]
212+ simp [← Nat.multiplicity_eq_factorization isPrime ne_zero, this]
213+
214+ /-- For a natural number `n` greater than `1`, assume that `n` is not a prime power, then
215+ the greatest common divisor of `choose n 1, ⋯, choose n (n - 1)` is `1`. -/
216+ theorem gcd_choose_eq_one_of_not_isPrimePow (hn : 1 < n) (hpn : ¬ IsPrimePow n) :
217+ (Icc 1 (n - 1 )).gcd n.choose = 1 := by
218+ contrapose! hpn
219+ obtain ⟨q, hq, h⟩ := Nat.exists_prime_and_dvd hpn
220+ simp_rw [Finset.dvd_gcd_iff, ← modEq_zero_iff_dvd] at h
221+ haveI : Fact (Nat.Prime q) := ⟨hq⟩
222+ have := eq_pow_multiplicity_of_choose_modEq_zero_nat (zero_lt_of_lt hn) h
223+ refine (isPrimePow_nat_iff n).mpr ⟨q, _, hq, Dvd.multiplicity_pos ?_, this.symm⟩
224+ specialize h 1 (by grind)
225+ rw [choose_one_right, modEq_zero_iff_dvd] at h
226+ exact h
227+
135228end Choose
0 commit comments