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.Prime

53 declarations. Mathlib docs · Source

Primality and GCD on pnat

This file extends the theory of ℕ+ with gcd, lcm and Prime functions, analogous to those on Nat.

Prime numbers

Coprime numbers and gcd

def Nat.Primes.toPNat E1 #

Nat.Primes → ℕ+

The canonical map from Nat.Primes to ℕ+

instance Nat.Primes.coePNat E0 #

Coe Nat.Primes ℕ+

theorem Nat.Primes.coe_pnat_nat E0 #

∀ (p : Nat.Primes), ↑↑p = ↑p

theorem Nat.Primes.coe_pnat_injective E0 #

Function.Injective Nat.Primes.toPNat

theorem Nat.Primes.coe_pnat_inj E0 #

∀ (p q : Nat.Primes), ↑p = ↑q ↔ p = q

def PNat.gcd E1 #

ℕ+ → ℕ+ → ℕ+

The greatest common divisor (gcd) of two positive natural numbers, viewed as positive natural number.

def PNat.lcm E1 #

ℕ+ → ℕ+ → ℕ+

The least common multiple (lcm) of two positive natural numbers, viewed as positive natural number.

theorem PNat.gcd_coe E0 #

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

theorem PNat.lcm_coe E0 #

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

theorem PNat.gcd_dvd_left E1 #

∀ (n m : ℕ+), n.gcd m ∣ n

theorem PNat.gcd_dvd_right E1 #

∀ (n m : ℕ+), n.gcd m ∣ m

theorem PNat.dvd_gcd E1 #

∀ {m n k : ℕ+}, k ∣ m → k ∣ n → k ∣ m.gcd n

theorem PNat.dvd_lcm_left E1 #

∀ (n m : ℕ+), n ∣ n.lcm m

theorem PNat.dvd_lcm_right E1 #

∀ (n m : ℕ+), m ∣ n.lcm m

theorem PNat.lcm_dvd E1 #

∀ {m n k : ℕ+}, m ∣ k → n ∣ k → m.lcm n ∣ k

theorem PNat.gcd_mul_lcm E1 #

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

def PNat.Prime E1 #

ℕ+ → Prop

Primality predicate for ℕ+, defined in terms of Nat.Prime.

theorem PNat.Prime.one_lt E1 #

∀ {p : ℕ+}, p.Prime → 1 < p

theorem PNat.prime_two E1 #

PNat.Prime 2

instance PNat.instFactPrimeValOfPrime E0 #

∀ {p : ℕ+} [h : Fact p.Prime], Fact (Nat.Prime ↑p)

instance PNat.fact_prime_two E0 #

Fact (PNat.Prime 2)

theorem PNat.prime_three E1 #

PNat.Prime 3

instance PNat.fact_prime_three E0 #

Fact (PNat.Prime 3)

theorem PNat.prime_five E1 #

PNat.Prime 5

instance PNat.fact_prime_five E0 #

Fact (PNat.Prime 5)

theorem PNat.dvd_prime E1 #

∀ {p m : ℕ+}, p.Prime → (m ∣ p ↔ m = 1 ∨ m = p)

theorem PNat.Prime.ne_one E1 #

∀ {p : ℕ+}, p.Prime → p ≠ 1

theorem PNat.not_prime_one E0 #

¬PNat.Prime 1

theorem PNat.Prime.not_dvd_one E1 #

∀ {p : ℕ+}, p.Prime → ¬p ∣ 1

theorem PNat.exists_prime_and_dvd E1 #

∀ {n : ℕ+}, n ≠ 1 → ∃ p, p.Prime ∧ p ∣ n

def PNat.Coprime E1 #

ℕ+ → ℕ+ → Prop

Two pnats are coprime if their gcd is 1.

theorem PNat.coprime_coe E0 #

∀ {m n : ℕ+}, (↑m).Coprime ↑n ↔ m.Coprime n

theorem PNat.Coprime.mul E1 #

∀ {k m n : ℕ+}, m.Coprime k → n.Coprime k → (m * n).Coprime k

theorem PNat.Coprime.mul_right E1 #

∀ {k m n : ℕ+}, k.Coprime m → k.Coprime n → k.Coprime (m * n)

theorem PNat.gcd_comm E1 #

∀ {m n : ℕ+}, m.gcd n = n.gcd m

theorem PNat.gcd_eq_left_iff_dvd E1 #

∀ {m n : ℕ+}, m.gcd n = m ↔ m ∣ n

theorem PNat.gcd_eq_right_iff_dvd E1 #

∀ {m n : ℕ+}, n.gcd m = m ↔ m ∣ n

theorem PNat.Coprime.gcd_mul_left_cancel E1 #

∀ (m : ℕ+) {n k : ℕ+}, k.Coprime n → (k * m).gcd n = m.gcd n

theorem PNat.Coprime.gcd_mul_right_cancel E1 #

∀ (m : ℕ+) {n k : ℕ+}, k.Coprime n → (m * k).gcd n = m.gcd n

theorem PNat.Coprime.gcd_mul_left_cancel_right E1 #

∀ (m : ℕ+) {n k : ℕ+}, k.Coprime m → m.gcd (k * n) = m.gcd n

theorem PNat.Coprime.gcd_mul_right_cancel_right E1 #

∀ (m : ℕ+) {n k : ℕ+}, k.Coprime m → m.gcd (n * k) = m.gcd n

theorem PNat.one_gcd E0 #

∀ {n : ℕ+}, PNat.gcd 1 n = 1

theorem PNat.gcd_one E0 #

∀ {n : ℕ+}, n.gcd 1 = 1

theorem PNat.Coprime.symm E1 #

∀ {m n : ℕ+}, m.Coprime n → n.Coprime m

theorem PNat.one_coprime E0 #

∀ {n : ℕ+}, PNat.Coprime 1 n

theorem PNat.coprime_one E0 #

∀ {n : ℕ+}, n.Coprime 1

theorem PNat.Coprime.coprime_dvd_left E1 #

∀ {m k n : ℕ+}, m ∣ k → k.Coprime n → m.Coprime n

theorem PNat.Coprime.factor_eq_gcd_left E1 #

∀ {a b m n : ℕ+}, m.Coprime n → a ∣ m → b ∣ n → a = (a * b).gcd m

theorem PNat.Coprime.factor_eq_gcd_right E1 #

∀ {a b m n : ℕ+}, m.Coprime n → a ∣ m → b ∣ n → a = (b * a).gcd m

theorem PNat.Coprime.factor_eq_gcd_left_right E1 #

∀ {a b m n : ℕ+}, m.Coprime n → a ∣ m → b ∣ n → a = m.gcd (a * b)

theorem PNat.Coprime.factor_eq_gcd_right_right E1 #

∀ {a b m n : ℕ+}, m.Coprime n → a ∣ m → b ∣ n → a = m.gcd (b * a)

theorem PNat.Coprime.gcd_mul E1 #

∀ (k : ℕ+) {m n : ℕ+}, m.Coprime n → k.gcd (m * n) = k.gcd m * k.gcd n

theorem PNat.Coprime.pow E1 #

∀ {m n : ℕ+} (k l : ℕ), m.Coprime n → (↑m ^ k).Coprime (↑n ^ l)