The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V02. Numbers

Mathlib.Data.PNat.Factors

72 declarations. Mathlib docs · Source

theorem PrimeMultiset.ofNatList.congr_simp E1 #

∀ (l l_1 : List ℕ) (e_l : l = l_1) (h : ∀ p ∈ l, Nat.Prime p),
  PrimeMultiset.ofNatList l h = PrimeMultiset.ofNatList l_1 ⋯

theorem PrimeMultiset.ofNatMultiset.congr_simp E1 #

∀ (v v_1 : Multiset ℕ) (e_v : v = v_1) (h : ∀ p ∈ v, Nat.Prime p),
  PrimeMultiset.ofNatMultiset v h = PrimeMultiset.ofNatMultiset v_1 ⋯

theorem PrimeMultiset.ofPNatMultiset.congr_simp E1 #

∀ (v v_1 : Multiset ℕ+) (e_v : v = v_1) (h : ∀ p ∈ v, p.Prime),
  PrimeMultiset.ofPNatMultiset v h = PrimeMultiset.ofPNatMultiset v_1 ⋯

def PrimeMultiset E1 #

Type

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

instance instDistribLatticePrimeMultiset E0 #

DistribLattice PrimeMultiset

instance instSemilatticeSupPrimeMultiset E0 #

SemilatticeSup PrimeMultiset

instance instAddCommMonoidPrimeMultiset E0 #

AddCommMonoid PrimeMultiset

instance instInhabitedPrimeMultiset E0 #

Inhabited PrimeMultiset

instance instCanonicallyOrderedAddPrimeMultiset E0 #

CanonicallyOrderedAdd PrimeMultiset

instance instIsOrderedCancelAddMonoidPrimeMultiset E0 #

IsOrderedCancelAddMonoid PrimeMultiset

instance instOrderBotPrimeMultiset E0 #

OrderBot PrimeMultiset

instance instSubPrimeMultiset E0 #

Sub PrimeMultiset

instance instOrderedSubPrimeMultiset E0 #

OrderedSub PrimeMultiset

instance PrimeMultiset.instRepr E0 #

Repr PrimeMultiset

def PrimeMultiset.ofPrime E1 #

Nat.Primes → PrimeMultiset

The multiset consisting of a single prime

theorem PrimeMultiset.card_ofPrime E0 #

∀ (p : Nat.Primes), Multiset.card (PrimeMultiset.ofPrime p) = 1

def PrimeMultiset.toNatMultiset E1 #

PrimeMultiset → Multiset ℕ

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.

instance PrimeMultiset.coeNat E0 #

Coe PrimeMultiset (Multiset ℕ)

def PrimeMultiset.coeNatMonoidHom E1 #

PrimeMultiset →+ Multiset ℕ

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

theorem PrimeMultiset.coe_coeNatMonoidHom E0 #

⇑PrimeMultiset.coeNatMonoidHom = PrimeMultiset.toNatMultiset

theorem PrimeMultiset.coeNat_injective E1 #

Function.Injective PrimeMultiset.toNatMultiset

theorem PrimeMultiset.coeNat_ofPrime E1 #

∀ (p : Nat.Primes), (PrimeMultiset.ofPrime p).toNatMultiset = {↑p}

theorem PrimeMultiset.coeNat_prime E1 #

∀ (v : PrimeMultiset), ∀ p ∈ v.toNatMultiset, Nat.Prime p

def PrimeMultiset.toPNatMultiset E1 #

PrimeMultiset → Multiset ℕ+

Converts a PrimeMultiset to a Multiset ℕ+.

instance PrimeMultiset.coePNat E0 #

Coe PrimeMultiset (Multiset ℕ+)

def PrimeMultiset.coePNatMonoidHom E1 #

PrimeMultiset →+ Multiset ℕ+

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

theorem PrimeMultiset.coe_coePNatMonoidHom E0 #

⇑PrimeMultiset.coePNatMonoidHom = PrimeMultiset.toPNatMultiset

theorem PrimeMultiset.coePNat_injective E1 #

Function.Injective PrimeMultiset.toPNatMultiset

theorem PrimeMultiset.coePNat_ofPrime E1 #

∀ (p : Nat.Primes), (PrimeMultiset.ofPrime p).toPNatMultiset = {↑p}

theorem PrimeMultiset.coePNat_prime E1 #

∀ (v : PrimeMultiset), ∀ p ∈ v.toPNatMultiset, p.Prime

instance PrimeMultiset.coeMultisetPNatNat E0 #

Coe (Multiset ℕ+) (Multiset ℕ)

theorem PrimeMultiset.coePNat_nat E1 #

∀ (v : PrimeMultiset), Multiset.map PNat.val v.toPNatMultiset = v.toNatMultiset

def PrimeMultiset.prod E1 #

PrimeMultiset → ℕ+

The product of a PrimeMultiset, as a ℕ+.

theorem PrimeMultiset.coe_prod E0 #

∀ (v : PrimeMultiset), ↑v.prod = v.toNatMultiset.prod

theorem PrimeMultiset.prod_ofPrime E1 #

∀ (p : Nat.Primes), (PrimeMultiset.ofPrime p).prod = ↑p

def PrimeMultiset.ofNatMultiset E1 #

(v : Multiset ℕ) → (∀ p ∈ v, Nat.Prime p) → PrimeMultiset

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

theorem PrimeMultiset.mem_ofNatMultiset E0 #

∀ {p : ℕ+} {s : Multiset ℕ} (hs : ∀ p ∈ s, Nat.Prime p), p ∈ (PrimeMultiset.ofNatMultiset s hs).toPNatMultiset ↔ ↑p ∈ s

theorem PrimeMultiset.to_ofNatMultiset E0 #

∀ (v : Multiset ℕ) (h : ∀ p ∈ v, Nat.Prime p), (PrimeMultiset.ofNatMultiset v h).toNatMultiset = v

theorem PrimeMultiset.prod_ofNatMultiset E0 #

∀ (v : Multiset ℕ) (h : ∀ p ∈ v, Nat.Prime p), ↑(PrimeMultiset.ofNatMultiset v h).prod = v.prod

def PrimeMultiset.ofPNatMultiset E1 #

(v : Multiset ℕ+) → (∀ p ∈ v, p.Prime) → PrimeMultiset

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

theorem PrimeMultiset.to_ofPNatMultiset E0 #

∀ (v : Multiset ℕ+) (h : ∀ p ∈ v, p.Prime), (PrimeMultiset.ofPNatMultiset v h).toPNatMultiset = v

theorem PrimeMultiset.prod_ofPNatMultiset E0 #

∀ (v : Multiset ℕ+) (h : ∀ p ∈ v, p.Prime), (PrimeMultiset.ofPNatMultiset v h).prod = v.prod

def PrimeMultiset.ofNatList E1 #

(l : List ℕ) → (∀ p ∈ l, Nat.Prime p) → PrimeMultiset

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

theorem PrimeMultiset.mem_ofNatList E0 #

∀ {p : ℕ+} {l : List ℕ} (hl : ∀ p ∈ l, Nat.Prime p), p ∈ (PrimeMultiset.ofNatList l hl).toPNatMultiset ↔ ↑p ∈ l

theorem PrimeMultiset.prod_ofNatList E0 #

∀ (l : List ℕ) (h : ∀ p ∈ l, Nat.Prime p), ↑(PrimeMultiset.ofNatList l h).prod = l.prod

def PrimeMultiset.ofPNatList E1 #

(l : List ℕ+) → (∀ p ∈ l, p.Prime) → PrimeMultiset

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

theorem PrimeMultiset.toPNatMultiset_ofPNatList E0 #

∀ {l : List ℕ+} (hl : ∀ p ∈ l, p.Prime), (PrimeMultiset.ofPNatList l hl).toPNatMultiset = ↑l

theorem PrimeMultiset.prod_ofPNatList E0 #

∀ (l : List ℕ+) (h : ∀ p ∈ l, p.Prime), (PrimeMultiset.ofPNatList l h).prod = l.prod

theorem PrimeMultiset.prod_zero E0 #

PrimeMultiset.prod 0 = 1

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

theorem PrimeMultiset.prod_add E0 #

∀ (u v : PrimeMultiset), (u + v).prod = u.prod * v.prod

theorem PrimeMultiset.prod_smul E0 #

∀ (d : ℕ) (u : PrimeMultiset), (d • u).prod = u.prod ^ d

def PNat.factorMultiset E1 #

ℕ+ → PrimeMultiset

The prime factors of n, regarded as a multiset

theorem PNat.prod_factorMultiset E0 #

∀ (n : ℕ+), n.factorMultiset.prod = n

The product of the factors is the original number

theorem PNat.coeNat_factorMultiset E1 #

∀ (n : ℕ+), n.factorMultiset.toNatMultiset = ↑(↑n).primeFactorsList

theorem PNat.mem_factorMultiset E0 #

∀ {p n : ℕ+}, p ∈ n.factorMultiset.toPNatMultiset ↔ p.Prime ∧ p ∣ n

theorem PrimeMultiset.factorMultiset_prod E0 #

∀ (v : PrimeMultiset), v.prod.factorMultiset = v

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

def PNat.factorMultisetEquiv E1 #

ℕ+ ≃ PrimeMultiset

Positive integers biject with multisets of primes.

theorem PNat.factorMultiset_one E0 #

PNat.factorMultiset 1 = 0

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

theorem PNat.factorMultiset_mul E0 #

∀ (n m : ℕ+), (n * m).factorMultiset = n.factorMultiset + m.factorMultiset

theorem PNat.factorMultiset_pow E0 #

∀ (n : ℕ+) (m : ℕ), (n ^ m).factorMultiset = m • n.factorMultiset

theorem PNat.factorMultiset_ofPrime E1 #

∀ (p : Nat.Primes), (↑p).factorMultiset = PrimeMultiset.ofPrime p

Factoring a prime gives the corresponding one-element multiset.

theorem PNat.factorMultiset_le_iff E0 #

∀ {m n : ℕ+}, m.factorMultiset ≤ n.factorMultiset ↔ m ∣ n

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

theorem PNat.factorMultiset_mono E1 #

∀ {m n : ℕ+}, m ∣ n → m.factorMultiset ≤ n.factorMultiset

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.

theorem PNat.factorMultiset_le_iff' E1 #

∀ {m : ℕ+} {v : PrimeMultiset}, m.factorMultiset ≤ v ↔ m ∣ v.prod

theorem PrimeMultiset.prod_dvd_iff E0 #

∀ {u v : PrimeMultiset}, u.prod ∣ v.prod ↔ u ≤ v

theorem PrimeMultiset.prod_dvd_prod E1 #

∀ {u v : PrimeMultiset}, u ≤ v → u.prod ∣ v.prod

Alias of the reverse direction of PrimeMultiset.prod_dvd_iff.

theorem PrimeMultiset.prod_dvd_iff' E1 #

∀ {u : PrimeMultiset} {n : ℕ+}, u.prod ∣ n ↔ u ≤ n.factorMultiset

theorem PNat.factorMultiset_gcd E1 #

∀ (m n : ℕ+), (m.gcd n).factorMultiset = m.factorMultiset ⊓ n.factorMultiset

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

theorem PNat.factorMultiset_lcm E1 #

∀ (m n : ℕ+), (m.lcm n).factorMultiset = m.factorMultiset ⊔ n.factorMultiset

theorem PNat.count_factorMultiset E1 #

∀ (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.

theorem PrimeMultiset.prod_inf E1 #

∀ (u v : PrimeMultiset), (u ⊓ v).prod = u.prod.gcd v.prod

theorem PrimeMultiset.prod_sup E1 #

∀ (u v : PrimeMultiset), (u ⊔ v).prod = u.prod.lcm v.prod