Skip to content

Commit 05eae2d

Browse files
committed
feat(NumberTheory/Padics/PadicVal): padicValNat_factorial (#5802)
Co-authored-by: Moritz Firsching <firsching@google.com>
1 parent 91db558 commit 05eae2d

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

Mathlib/Data/Nat/Multiplicity.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ coefficients.
2323
## Multiplicity calculations
2424
2525
* `Nat.Prime.multiplicity_factorial`: Legendre's Theorem. The multiplicity of `p` in `n!` is
26-
`n/p + ... + n/p^b` for any `b` such that `n/p^(b + 1) = 0`.
26+
`n/p + ... + n/p^b` for any `b` such that `n/p^(b + 1) = 0`. See `padicValNat_factorial` for the
27+
for this result stated in the language of `p`-adic valuations.
2728
* `Nat.Prime.multiplicity_factorial_mul`: The multiplicity of `p` in `(p * n)!` is `n` more than
2829
that of `n!`.
2930
* `Nat.Prime.multiplicity_choose`: Kummer's Theorem. The multiplicity of `p` in `n.choose k` is the

Mathlib/NumberTheory/Padics/PadicVal.lean

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,16 @@ by taking `[Fact p.Prime]` as a type class argument.
3333
3434
## Calculations with `p`-adic valuations
3535
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+
3641
* `padicValNat_choose`: Kummer's Theorem. The `p`-adic valuation of `n.choose k` is the number
3742
of carries when `k` and `n - k` are added in base `p`. This sum is expressed over the finset
3843
`Ico 1 b` where `b` is any bound greater than `log p n`. See `Nat.Prime.multiplicity_choose` for the
3944
same result but stated in the language of prime multiplicity.
4045
41-
4246
## References
4347
4448
* [F. Q. Gouvêa, *p-adic numbers*][gouvea1997]
@@ -554,6 +558,20 @@ theorem padicValNat_factorial_mul {p : ℕ} (n : ℕ) (hp : p.Prime):
554558
padicValNat_def' (Nat.Prime.ne_one hp) <| factorial_pos n]
555559
exact Prime.multiplicity_factorial_mul hp
556560

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`. -/
557575
theorem padicValNat_choose {p n k b : ℕ} [hp : Fact p.Prime] (hkn : k ≤ n) (hnb : log p n < b) :
558576
padicValNat p (choose n k) =
559577
((Finset.Ico 1 b).filter fun i => p ^ i ≤ k % p ^ i + (n - k) % p ^ i).card :=

0 commit comments

Comments
 (0)