@@ -33,12 +33,16 @@ by taking `[Fact p.Prime]` as a type class argument.
33
33
34
34
## Calculations with `p`-adic valuations
35
35
36
+ * `padicValNat_factorial`: Legendre's Theorem. The `p`-adic valuation of `n!` is the sum of the
37
+ quotients `n / p ^ i`. This sum is expressed over the finset `Ico 1 b` where `b` is any bound
38
+ greater than `log p n`. See `Nat.Prime.multiplicity_factorial` for the same result but stated in the
39
+ language of prime multiplicity.
40
+
36
41
* `padicValNat_choose`: Kummer's Theorem. The `p`-adic valuation of `n.choose k` is the number
37
42
of carries when `k` and `n - k` are added in base `p`. This sum is expressed over the finset
38
43
`Ico 1 b` where `b` is any bound greater than `log p n`. See `Nat.Prime.multiplicity_choose` for the
39
44
same result but stated in the language of prime multiplicity.
40
45
41
-
42
46
## References
43
47
44
48
* [ F. Q. Gouvêa, *p-adic numbers* ] [gouvea1997 ]
@@ -554,6 +558,20 @@ theorem padicValNat_factorial_mul {p : ℕ} (n : ℕ) (hp : p.Prime):
554
558
padicValNat_def' (Nat.Prime.ne_one hp) <| factorial_pos n]
555
559
exact Prime.multiplicity_factorial_mul hp
556
560
561
+ /-- **Legendre's Theorem**
562
+
563
+ The `p`-adic valuation of `n!` is the sum of the quotients `n / p ^ i`. This sum is expressed
564
+ over the finset `Ico 1 b` where `b` is any bound greater than `log p n`. -/
565
+ theorem padicValNat_factorial {p n b : ℕ} [hp : Fact p.Prime] (hnb : log p n < b) :
566
+ padicValNat p (n !) = ∑ i in Finset.Ico 1 b, n / p ^ i :=
567
+ PartENat.natCast_inj.mp ((padicValNat_def' (Nat.Prime.ne_one hp.out) <| factorial_pos _) ▸
568
+ Prime.multiplicity_factorial hp.out hnb)
569
+
570
+ /-- **Kummer's Theorem**
571
+
572
+ The `p`-adic valuation of `n.choose k` is the number of carries when `k` and `n - k` are added
573
+ in base `p`. This sum is expressed over the finset `Ico 1 b` where `b` is any bound greater than
574
+ `log p n`. -/
557
575
theorem padicValNat_choose {p n k b : ℕ} [hp : Fact p.Prime] (hkn : k ≤ n) (hnb : log p n < b) :
558
576
padicValNat p (choose n k) =
559
577
((Finset.Ico 1 b).filter fun i => p ^ i ≤ k % p ^ i + (n - k) % p ^ i).card :=
0 commit comments