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
Mathlib/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
- n.factorization = { support := n.primeFactors, toFun := fun (p : ℕ) => if Nat.Prime p then padicValNat p n else 0, mem_support_toFun := ⋯ }
Instances For
The support of n.factorization is exactly n.primeFactors.
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
Lemmas characterising when n.factorization p = 0 #
Alias of Nat.factorization_eq_zero_of_non_prime.
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
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 = 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
For prime p the only prime factor of p^k is p with multiplicity k
Equivalence between ℕ+ and ℕ →₀ ℕ with support in the primes. #
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
Generalisation of the "even part" and "odd part" of a natural number #
We introduce the notations ordProj[p] n for the largest power of the prime p that
divides n and ordCompl[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, ordProj[2] n is the even part of n and ordCompl[2] n is the odd part.
Equations
- One or more equations did not get rendered due to their size.
Instances For
We introduce the notations ordProj[p] n for the largest power of the prime p that
divides n and ordCompl[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, ordProj[2] n is the even part of n and ordCompl[2] n is the odd part.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Factorization LCM definitions #
If a = ∏ pᵢ ^ nᵢ and b = ∏ pᵢ ^ mᵢ, then factorizationLCMLeft = ∏ pᵢ ^ kᵢ, where
kᵢ = nᵢ if mᵢ ≤ nᵢ and 0 otherwise. Note that the product is over the divisors of lcm a b,
so if one of a or b is 0 then the result is 1.
Equations
- a.factorizationLCMLeft b = (a.lcm b).factorization.prod fun (p n : ℕ) => if b.factorization p ≤ a.factorization p then p ^ n else 1
Instances For
If a = ∏ pᵢ ^ nᵢ and b = ∏ pᵢ ^ mᵢ, then factorizationLCMRight = ∏ pᵢ ^ kᵢ, where
kᵢ = mᵢ if nᵢ < mᵢ and 0 otherwise. Note that the product is over the divisors of lcm a b,
so if one of a or b is 0 then the result is 1.
Note that factorizationLCMRight a b is not factorizationLCMLeft b a: the difference is
that in factorizationLCMLeft a b there are the primes whose exponent in a is bigger or equal
than the exponent in b, while in factorizationLCMRight a b there are the primes whose
exponent in b is strictly bigger than in a. For example factorizationLCMLeft 2 2 = 2, but
factorizationLCMRight 2 2 = 1.
Equations
- a.factorizationLCMRight b = (a.lcm b).factorization.prod fun (p n : ℕ) => if b.factorization p ≤ a.factorization p then 1 else p ^ n