Documentation

Mathlib.Data.Nat.Factorization.Defs

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,

TODO #

n.factorization is the finitely supported function ℕ →₀ ℕ mapping each prime factor of n to its multiplicity in n.

Equations
    Instances For
      @[simp]

      The support of n.factorization is exactly n.primeFactors.

      theorem Nat.factorization_def (n : ) {p : } (pp : Prime p) :
      @[simp]

      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.

      theorem Nat.Prime.factorization_pos_of_dvd {n p : } (hp : Prime p) (hn : n 0) (h : p n) :
      theorem Nat.multiplicity_eq_factorization {n p : } (pp : Prime p) (hn : n 0) :

      Basic facts about factorization #

      @[simp]
      theorem Nat.factorization_prod_pow_eq_self {n : } (hn : n 0) :
      (n.factorization.prod fun (x1 x2 : ) => x1 ^ x2) = n
      theorem Nat.eq_of_factorization_eq {a b : } (ha : a 0) (hb : b 0) (h : ∀ (p : ), a.factorization p = b.factorization p) :
      a = b

      Every nonzero natural number has a unique prime factorization

      Lemmas characterising when n.factorization p = 0 #

      @[simp]
      theorem Nat.factorization_eq_zero_of_remainder {p r : } (i : ) (hr : ¬p r) :
      (p * i + r).factorization p = 0

      Lemmas about factorizations of products and powers #

      @[simp]
      theorem Nat.factorization_mul {a b : } (ha : a 0) (hb : b 0) :

      For nonzero a and b, the power of p in a * b is the sum of the powers in a and b

      theorem Nat.factorization_le_iff_dvd {d n : } (hd : d 0) (hn : n 0) :
      theorem Nat.factorization_prod {α : Type u_1} {S : Finset α} {g : α} (hS : xS, g x 0) :
      (S.prod g).factorization = xS, (g x).factorization

      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.

      @[simp]

      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 #

      @[simp]

      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

      theorem Nat.pow_succ_factorization_not_dvd {n p : } (hn : n 0) (hp : Prime p) :
      ¬p ^ (n.factorization p + 1) n

      Equivalence between ℕ+ and ℕ →₀ ℕ with support in the primes. #

      theorem Nat.prod_pow_factorization_eq_self {f : →₀ } (hf : pf.support, Prime p) :
      (f.prod fun (x1 x2 : ) => x1 ^ x2).factorization = f

      Any Finsupp f : ℕ →₀ ℕ whose support is in the primes is equal to the factorization of the product ∏ (a : ℕ) ∈ f.support, a ^ f a.

      The equiv between ℕ+ and ℕ →₀ ℕ with support in the primes.

      Equations
        Instances For

          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
            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
                Instances For
                  theorem Nat.ordProj_dvd (n p : ) :
                  @[deprecated Nat.ordProj_dvd (since := "2024-10-24")]
                  theorem Nat.ord_proj_dvd (n p : ) :

                  Alias of Nat.ordProj_dvd.

                  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
                    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
                        Instances For