Prime factorizations #
n.factorization is the finitely supported function ℕ →₀ ℕ
mapping each prime factor of n to its multiplicity in n. For example, since 2000 = 2^4 * 5^3,
factorization 2000 2is 4factorization 2000 5is 3factorization 2000 kis 0 for all otherk : ℕ.
TODO #
-
As discussed in this Zulip thread: https://leanprover.zulipchat.com/#narrow/stream/217875/topic/Multiplicity.20in.20the.20naturals We have lots of disparate ways of talking about the multiplicity of a prime in a natural number, including
factors.count,padicValNat,multiplicity, and the material inData/PNat/Factors. Move some of this material to this file, prove results about the relationships between these definitions, and (where appropriate) choose a uniform canonical way of expressing these ideas. -
Moreover, the results here should be generalised to an arbitrary unique factorization monoid with a normalization function, and then deduplicated. The basics of this have been started in
RingTheory/UniqueFactorizationDomain. -
Extend the inductions to any
NormalizationMonoidwith unique factorization.
n.factorization is the finitely supported function ℕ →₀ ℕ
mapping each prime factor of n to its multiplicity in n.
Equations
- One or more equations did not get rendered due to their size.
Instances For
We can write both n.factorization p and n.factors.count p to represent the power
of p in the factorization of n: we declare the former to be the simp-normal form.
Basic facts about factorization #
Every nonzero natural number has a unique prime factorization
The support of n.factorization is exactly n.factors.toFinset
Lemmas characterising when n.factorization p = 0 #
The only numbers with empty prime factorization are 0 and 1
Lemmas about factorizations of products and powers #
For nonzero a and b, the power of p in a * b is the sum of the powers in a and b
If a product over n.factorization doesn't use the multiplicities of the prime factors
then it's equal to the corresponding product over n.factors.toFinset
For any p : ℕ and any function g : α → ℕ that's non-zero on S : Finset α,
the power of p in S.prod g equals the sum over x ∈ S of the powers of p in g x.
Generalises factorization_mul, which is the special case where S.card = 2 and g = id.
For any p, the power of p in n^k is k times the power in n
Lemmas about factorizations of primes and prime powers #
The only prime factor of prime p is p itself, with multiplicity 1
The multiplicity of prime p in p is 1
For prime p the only prime factor of p^k is p with multiplicity k
If the factorization of n contains just one number p then n is a power of p
The only prime factor of prime p is p itself.
Equivalence between ℕ+ and ℕ →₀ ℕ with support in the primes. #
Any Finsupp f : ℕ →₀ ℕ whose support is in the primes is equal to the factorization of
the product ∏ (a : ℕ) in f.support, a ^ f a.
Generalisation of the "even part" and "odd part" of a natural number #
We introduce the notations ord_proj[p] n for the largest power of the prime p that
divides n and ord_compl[p] n for the complementary part. The ord naming comes from
the $p$-adic order/valuation of a number, and proj and compl are for the projection and
complementary projection. The term n.factorization p is the $p$-adic order itself.
For example, ord_proj[2] n is the even part of n and ord_compl[2] n is the odd part.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Factorization and divisibility #
A crude upper bound on n.factorization p
An upper bound on n.factorization p
The set of positive powers of prime p that divide n is exactly the set of
positive natural numbers up to n.factorization p.
Factorization and coprimes #
For coprime a and b, the power of p in a * b is the sum of the powers in a and b
For coprime a and b, the power of p in a * b is the sum of the powers in a and b
If p is a prime factor of a then the power of p in a is the same that in a * b,
for any b coprime to a.
If p is a prime factor of b then the power of p in b is the same that in a * b,
for any a coprime to b.
The prime factorizations of coprime a and b are disjoint
For coprime a and b the prime factorization a * b is the union of those of a and b
Induction principles involving factorizations #
Given P 0, P 1 and a way to extend P a to P (p ^ n * a) for prime p not dividing a,
we can define P for all natural numbers.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Given P 0, P 1, and P (p ^ n) for positive prime powers, and a way to extend P a and
P b to P (a * b) when a, b are positive coprime, we can define P for all natural numbers.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Given P 0, P (p ^ n) for all prime powers, and a way to extend P a and P b to
P (a * b) when a, b are positive coprime, we can define P for all natural numbers.
Equations
- Nat.recOnPrimeCoprime h0 hp h a = Nat.recOnPosPrimePosCoprime (fun p n h x => hp p n h) h0 (hp 2 0 Nat.prime_two) h a
Instances For
Given P 0, P 1, P p for all primes, and a way to extend P a and P b to
P (a * b), we can define P for all natural numbers.
Equations
- One or more equations did not get rendered due to their size.
Instances For
For any multiplicative function f with f 1 = 1 and any n ≠ 0,
we can evaluate f n by evaluating f at p ^ k over the factorization of n
For any multiplicative function f with f 1 = 1 and f 0 = 1,
we can evaluate f n by evaluating f at p ^ k over the factorization of n
Two positive naturals are equal if their prime padic valuations are equal
Lemmas about factorizations of particular functions #
Exactly n / p naturals in [1, n] are multiples of p.
Exactly n / p naturals in (0, n] are multiples of p.