Documentation

Mathlib.Data.PNat.Factors

Prime factors of nonzero naturals #

This file defines the factorization of a nonzero natural number n as a multiset of primes, the multiplicity of p in this factors multiset being the p-adic valuation of n.

Main declarations #

The type of multisets of prime numbers. Unique factorization gives an equivalence between this set and ℕ+, as we will formalize below.

Instances For
    @[implicit_reducible]
    @[implicit_reducible]
    @[implicit_reducible]

    The multiset consisting of a single prime

    Instances For

      We can forget the primality property and regard a multiset of primes as just a multiset of positive integers, or a multiset of natural numbers. In the opposite direction, if we have a multiset of positive integers or natural numbers, together with a proof that all the elements are prime, then we can regard it as a multiset of primes. The next block of results records obvious properties of these coercions.

      Instances For
        @[implicit_reducible]

        PrimeMultiset.coe, the coercion from a multiset of primes to a multiset of naturals, promoted to an AddMonoidHom.

        Instances For

          coePNat, the coercion from a multiset of primes to a multiset of positive naturals, regarded as an AddMonoidHom.

          Instances For
            @[implicit_reducible]

            The product of a PrimeMultiset, as a ℕ+.

            Instances For
              def PrimeMultiset.ofNatMultiset (v : Multiset ) (h : pv, Nat.Prime p) :

              If a Multiset consists only of primes, it can be recast as a PrimeMultiset.

              Instances For
                @[simp]
                theorem PrimeMultiset.mem_ofNatMultiset {p : ℕ+} {s : Multiset } (hs : ps, Nat.Prime p) :
                p (ofNatMultiset s hs).toPNatMultiset p s
                @[simp]
                theorem PrimeMultiset.to_ofNatMultiset (v : Multiset ) (h : pv, Nat.Prime p) :
                @[simp]
                theorem PrimeMultiset.prod_ofNatMultiset (v : Multiset ) (h : pv, Nat.Prime p) :
                (ofNatMultiset v h).prod = v.prod

                If a Multiset ℕ+ consists only of primes, it can be recast as a PrimeMultiset.

                Instances For
                  @[simp]
                  theorem PrimeMultiset.prod_ofPNatMultiset (v : Multiset ℕ+) (h : pv, p.Prime) :
                  def PrimeMultiset.ofNatList (l : List ) (h : pl, Nat.Prime p) :

                  Lists can be coerced to multisets; here we have some results about how this interacts with our constructions on multisets.

                  Instances For
                    @[simp]
                    theorem PrimeMultiset.mem_ofNatList {p : ℕ+} {l : List } (hl : pl, Nat.Prime p) :
                    p (ofNatList l hl).toPNatMultiset p l
                    @[simp]
                    theorem PrimeMultiset.prod_ofNatList (l : List ) (h : pl, Nat.Prime p) :
                    (ofNatList l h).prod = l.prod
                    def PrimeMultiset.ofPNatList (l : List ℕ+) (h : pl, p.Prime) :

                    If a List ℕ+ consists only of primes, it can be recast as a PrimeMultiset with the coercion from lists to multisets.

                    Instances For
                      @[simp]
                      theorem PrimeMultiset.toPNatMultiset_ofPNatList {l : List ℕ+} (hl : pl, p.Prime) :
                      @[simp]
                      theorem PrimeMultiset.prod_ofPNatList (l : List ℕ+) (h : pl, p.Prime) :
                      (ofPNatList l h).prod = l.prod
                      @[simp]

                      The product map gives a homomorphism from the additive monoid of multisets to the multiplicative monoid ℕ+.

                      @[simp]
                      theorem PrimeMultiset.prod_add (u v : PrimeMultiset) :
                      (u + v).prod = u.prod * v.prod
                      @[simp]
                      theorem PrimeMultiset.prod_smul (d : ) (u : PrimeMultiset) :
                      (d u).prod = u.prod ^ d

                      The prime factors of n, regarded as a multiset

                      Instances For
                        @[simp]

                        The product of the factors is the original number

                        @[simp]
                        theorem PNat.mem_factorMultiset {p n : ℕ+} :
                        p n.factorMultiset.toPNatMultiset p.Prime p n
                        @[simp]

                        If we start with a multiset of primes, take the product and then factor it, we get back the original multiset.

                        Positive integers biject with multisets of primes.

                        Instances For
                          @[simp]

                          Factoring gives a homomorphism from the multiplicative monoid ℕ+ to the additive monoid of multisets.

                          @[simp]
                          theorem PNat.factorMultiset_pow (n : ℕ+) (m : ) :
                          (n ^ m).factorMultiset = m n.factorMultiset

                          Factoring a prime gives the corresponding one-element multiset.

                          @[simp]

                          We now have four different results that all encode the idea that inequality of multisets corresponds to divisibility of positive integers.

                          Alias of the reverse direction of PNat.factorMultiset_le_iff.


                          We now have four different results that all encode the idea that inequality of multisets corresponds to divisibility of positive integers.

                          @[simp]
                          theorem PrimeMultiset.prod_dvd_iff {u v : PrimeMultiset} :
                          u.prod v.prod u v
                          theorem PrimeMultiset.prod_dvd_prod {u v : PrimeMultiset} :
                          u vu.prod v.prod

                          Alias of the reverse direction of PrimeMultiset.prod_dvd_iff.

                          The gcd and lcm operations on positive integers correspond to the inf and sup operations on multisets.

                          theorem PNat.count_factorMultiset (m : ℕ+) (p : Nat.Primes) (k : ) :
                          p ^ k m k Multiset.count p m.factorMultiset

                          The number of occurrences of p in the factor multiset of m is the same as the p-adic valuation of m.