Divisor Finsets #
This file defines sets of divisors of a natural number. This is particularly useful as background for defining Dirichlet convolution.
Main Definitions #
Let n : ℕ
. All of the following definitions are in the Nat
namespace:
divisors n
is theFinset
of natural numbers that dividen
.properDivisors n
is theFinset
of natural numbers that dividen
, other thann
.divisorsAntidiagonal n
is theFinset
of pairs(x,y)
such thatx * y = n
.Perfect n
is true whenn
is positive and the sum ofproperDivisors n
isn
.
Implementation details #
divisors 0
,properDivisors 0
, anddivisorsAntidiagonal 0
are defined to be∅
.
Tags #
divisors, perfect numbers
divisors n
is the Finset
of divisors of n
. As a special case, divisors 0 = ∅
.
Equations
- Nat.divisors n = Finset.filter (fun x => x ∣ n) (Finset.Ico 1 (n + 1))
Instances For
properDivisors n
is the Finset
of divisors of n
, other than n
.
As a special case, properDivisors 0 = ∅
.
Equations
- Nat.properDivisors n = Finset.filter (fun x => x ∣ n) (Finset.Ico 1 n)
Instances For
divisorsAntidiagonal n
is the Finset
of pairs (x,y)
such that x * y = n
.
As a special case, divisorsAntidiagonal 0 = ∅
.
Equations
- Nat.divisorsAntidiagonal n = Finset.filter (fun x => x.fst * x.snd = n) (Finset.Ico 1 (n + 1) ×ˢ Finset.Ico 1 (n + 1))
Instances For
@[simp]
theorem
Nat.filter_dvd_eq_divisors
{n : ℕ}
(h : n ≠ 0)
:
Finset.filter (fun x => x ∣ n) (Finset.range (Nat.succ n)) = Nat.divisors n
@[simp]
theorem
Nat.filter_dvd_eq_properDivisors
{n : ℕ}
(h : n ≠ 0)
:
Finset.filter (fun x => x ∣ n) (Finset.range n) = Nat.properDivisors n
@[simp]
theorem
Nat.insert_self_properDivisors
{n : ℕ}
(h : n ≠ 0)
:
insert n (Nat.properDivisors n) = Nat.divisors n
theorem
Nat.cons_self_properDivisors
{n : ℕ}
(h : n ≠ 0)
:
Finset.cons n (Nat.properDivisors n) (_ : ¬n ∈ Nat.properDivisors n) = Nat.divisors n
theorem
Nat.divisors_filter_dvd_of_dvd
{n : ℕ}
{m : ℕ}
(hn : n ≠ 0)
(hm : m ∣ n)
:
Finset.filter (fun x => x ∣ m) (Nat.divisors n) = Nat.divisors m
theorem
Nat.fst_mem_divisors_of_mem_antidiagonal
{n : ℕ}
{x : ℕ × ℕ}
(h : x ∈ Nat.divisorsAntidiagonal n)
:
x.fst ∈ Nat.divisors n
theorem
Nat.snd_mem_divisors_of_mem_antidiagonal
{n : ℕ}
{x : ℕ × ℕ}
(h : x ∈ Nat.divisorsAntidiagonal n)
:
x.snd ∈ Nat.divisors n
@[simp]
@[simp]
theorem
Nat.image_fst_divisorsAntidiagonal
{n : ℕ}
:
Finset.image Prod.fst (Nat.divisorsAntidiagonal n) = Nat.divisors n
@[simp]
theorem
Nat.image_snd_divisorsAntidiagonal
{n : ℕ}
:
Finset.image Prod.snd (Nat.divisorsAntidiagonal n) = Nat.divisors n
theorem
Nat.map_div_right_divisors
{n : ℕ}
:
Finset.map
{ toFun := fun d => (d, n / d),
inj' :=
(_ :
∀ (p₁ p₂ : ℕ),
(fun d => (d, n / d)) p₁ = (fun d => (d, n / d)) p₂ →
((fun d => (d, n / d)) p₁).fst = ((fun d => (d, n / d)) p₂).fst) }
(Nat.divisors n) = Nat.divisorsAntidiagonal n
theorem
Nat.map_div_left_divisors
{n : ℕ}
:
Finset.map
{ toFun := fun d => (n / d, d),
inj' :=
(_ :
∀ (p₁ p₂ : ℕ),
(fun d => (n / d, d)) p₁ = (fun d => (n / d, d)) p₂ →
((fun d => (n / d, d)) p₁).snd = ((fun d => (n / d, d)) p₂).snd) }
(Nat.divisors n) = Nat.divisorsAntidiagonal n
theorem
Nat.sum_divisors_eq_sum_properDivisors_add_self
{n : ℕ}
:
(Finset.sum (Nat.divisors n) fun i => i) = (Finset.sum (Nat.properDivisors n) fun i => i) + n
n : ℕ
is perfect if and only the sum of the proper divisors of n
is n
and n
is positive.
Equations
- Nat.Perfect n = ((Finset.sum (Nat.properDivisors n) fun i => i) = n ∧ 0 < n)
Instances For
theorem
Nat.perfect_iff_sum_properDivisors
{n : ℕ}
(h : 0 < n)
:
Nat.Perfect n ↔ (Finset.sum (Nat.properDivisors n) fun i => i) = n
theorem
Nat.perfect_iff_sum_divisors_eq_two_mul
{n : ℕ}
(h : 0 < n)
:
Nat.Perfect n ↔ (Finset.sum (Nat.divisors n) fun i => i) = 2 * n
theorem
Nat.divisors_prime_pow
{p : ℕ}
(pp : Nat.Prime p)
(k : ℕ)
:
Nat.divisors (p ^ k) = Finset.map { toFun := Nat.pow p, inj' := (_ : Function.Injective fun n => p ^ n) } (Finset.range (k + 1))
theorem
Nat.eq_properDivisors_of_subset_of_sum_eq_sum
{n : ℕ}
{s : Finset ℕ}
(hsub : s ⊆ Nat.properDivisors n)
:
((Finset.sum s fun x => x) = Finset.sum (Nat.properDivisors n) fun x => x) → s = Nat.properDivisors n
theorem
Nat.sum_properDivisors_dvd
{n : ℕ}
(h : (Finset.sum (Nat.properDivisors n) fun x => x) ∣ n)
:
(Finset.sum (Nat.properDivisors n) fun x => x) = 1 ∨ (Finset.sum (Nat.properDivisors n) fun x => x) = n
@[simp]
theorem
Nat.Prime.sum_properDivisors
{α : Type u_1}
[AddCommMonoid α]
{p : ℕ}
{f : ℕ → α}
(h : Nat.Prime p)
:
(Finset.sum (Nat.properDivisors p) fun x => f x) = f 1
@[simp]
theorem
Nat.Prime.prod_properDivisors
{α : Type u_1}
[CommMonoid α]
{p : ℕ}
{f : ℕ → α}
(h : Nat.Prime p)
:
(Finset.prod (Nat.properDivisors p) fun x => f x) = f 1
@[simp]
theorem
Nat.Prime.sum_divisors
{α : Type u_1}
[AddCommMonoid α]
{p : ℕ}
{f : ℕ → α}
(h : Nat.Prime p)
:
(Finset.sum (Nat.divisors p) fun x => f x) = f p + f 1
@[simp]
theorem
Nat.Prime.prod_divisors
{α : Type u_1}
[CommMonoid α]
{p : ℕ}
{f : ℕ → α}
(h : Nat.Prime p)
:
(Finset.prod (Nat.divisors p) fun x => f x) = f p * f 1
theorem
Nat.properDivisors_eq_singleton_one_iff_prime
{n : ℕ}
:
Nat.properDivisors n = {1} ↔ Nat.Prime n
theorem
Nat.sum_properDivisors_eq_one_iff_prime
{n : ℕ}
:
(Finset.sum (Nat.properDivisors n) fun x => x) = 1 ↔ Nat.Prime n
theorem
Nat.properDivisors_prime_pow
{p : ℕ}
(pp : Nat.Prime p)
(k : ℕ)
:
Nat.properDivisors (p ^ k) = Finset.map { toFun := Nat.pow p, inj' := (_ : Function.Injective fun n => p ^ n) } (Finset.range k)
@[simp]
theorem
Nat.sum_properDivisors_prime_nsmul
{α : Type u_1}
[AddCommMonoid α]
{k : ℕ}
{p : ℕ}
{f : ℕ → α}
(h : Nat.Prime p)
:
(Finset.sum (Nat.properDivisors (p ^ k)) fun x => f x) = Finset.sum (Finset.range k) fun x => f (p ^ x)
@[simp]
theorem
Nat.prod_properDivisors_prime_pow
{α : Type u_1}
[CommMonoid α]
{k : ℕ}
{p : ℕ}
{f : ℕ → α}
(h : Nat.Prime p)
:
(Finset.prod (Nat.properDivisors (p ^ k)) fun x => f x) = Finset.prod (Finset.range k) fun x => f (p ^ x)
@[simp]
theorem
Nat.sum_divisors_prime_pow
{α : Type u_1}
[AddCommMonoid α]
{k : ℕ}
{p : ℕ}
{f : ℕ → α}
(h : Nat.Prime p)
:
(Finset.sum (Nat.divisors (p ^ k)) fun x => f x) = Finset.sum (Finset.range (k + 1)) fun x => f (p ^ x)
@[simp]
theorem
Nat.prod_divisors_prime_pow
{α : Type u_1}
[CommMonoid α]
{k : ℕ}
{p : ℕ}
{f : ℕ → α}
(h : Nat.Prime p)
:
(Finset.prod (Nat.divisors (p ^ k)) fun x => f x) = Finset.prod (Finset.range (k + 1)) fun x => f (p ^ x)
theorem
Nat.sum_divisorsAntidiagonal
{M : Type u_1}
[AddCommMonoid M]
(f : ℕ → ℕ → M)
{n : ℕ}
:
(Finset.sum (Nat.divisorsAntidiagonal n) fun i => f i.fst i.snd) = Finset.sum (Nat.divisors n) fun i => f i (n / i)
theorem
Nat.prod_divisorsAntidiagonal
{M : Type u_1}
[CommMonoid M]
(f : ℕ → ℕ → M)
{n : ℕ}
:
(Finset.prod (Nat.divisorsAntidiagonal n) fun i => f i.fst i.snd) = Finset.prod (Nat.divisors n) fun i => f i (n / i)
theorem
Nat.sum_divisorsAntidiagonal'
{M : Type u_1}
[AddCommMonoid M]
(f : ℕ → ℕ → M)
{n : ℕ}
:
(Finset.sum (Nat.divisorsAntidiagonal n) fun i => f i.fst i.snd) = Finset.sum (Nat.divisors n) fun i => f (n / i) i
theorem
Nat.prod_divisorsAntidiagonal'
{M : Type u_1}
[CommMonoid M]
(f : ℕ → ℕ → M)
{n : ℕ}
:
(Finset.prod (Nat.divisorsAntidiagonal n) fun i => f i.fst i.snd) = Finset.prod (Nat.divisors n) fun i => f (n / i) i
The factors of n
are the prime divisors
theorem
Nat.prime_divisors_filter_dvd_of_dvd
{m : ℕ}
{n : ℕ}
(hn : n ≠ 0)
(hmn : m ∣ n)
:
Finset.filter (fun x => x ∣ m) (List.toFinset (Nat.factors n)) = List.toFinset (Nat.factors m)
@[simp]
theorem
Nat.image_div_divisors_eq_divisors
(n : ℕ)
:
Finset.image (fun x => n / x) (Nat.divisors n) = Nat.divisors n
theorem
Nat.sum_div_divisors
{α : Type u_1}
[AddCommMonoid α]
(n : ℕ)
(f : ℕ → α)
:
(Finset.sum (Nat.divisors n) fun d => f (n / d)) = Finset.sum (Nat.divisors n) f
theorem
Nat.prod_div_divisors
{α : Type u_1}
[CommMonoid α]
(n : ℕ)
(f : ℕ → α)
:
(Finset.prod (Nat.divisors n) fun d => f (n / d)) = Finset.prod (Nat.divisors n) f