File: Mathlib/NumberTheory/Divisors.lean

full_name: Nat.divisors
code: /-- `divisors n` is the `Finset` of divisors of `n`. As a special case, `divisors 0 = ∅`. -/
def divisors : Finset ℕ 
goal: Finset ℕ

full_name: Nat.properDivisors
code: /-- `properDivisors n` is the `Finset` of divisors of `n`, other than `n`.
  As a special case, `properDivisors 0 = ∅`. -/
def properDivisors : Finset ℕ 
goal: Finset ℕ

full_name: Nat.divisorsAntidiagonal
code: /-- `divisorsAntidiagonal n` is the `Finset` of pairs `(x,y)` such that `x * y = n`.
  As a special case, `divisorsAntidiagonal 0 = ∅`. -/
def divisorsAntidiagonal : Finset (ℕ × ℕ) 
goal: Finset (ℕ × ℕ)

full_name: Nat.filter_dvd_eq_divisors
code: @[simp]
theorem filter_dvd_eq_divisors (h : n ≠ 0) : (Finset.range n.succ).filter (· ∣ n) = n.divisors 
goal: Finset.filter (fun x => x ∣ n) (Finset.range n.succ) = n.divisors

full_name: Nat.filter_dvd_eq_properDivisors
code: @[simp]
theorem filter_dvd_eq_properDivisors (h : n ≠ 0) :
    (Finset.range n).filter (· ∣ n) = n.properDivisors 
goal: Finset.filter (fun x => x ∣ n) (Finset.range n) = n.properDivisors

full_name: Nat.properDivisors.not_self_mem
code: theorem properDivisors.not_self_mem : ¬n ∈ properDivisors n 
goal: n ∉ n.properDivisors

full_name: Nat.mem_properDivisors
code: @[simp]
theorem mem_properDivisors {m : ℕ} : n ∈ properDivisors m ↔ n ∣ m ∧ n < m 
goal: n ∈ m.properDivisors ↔ n ∣ m ∧ n < m

full_name: Nat.insert_self_properDivisors
code: theorem insert_self_properDivisors (h : n ≠ 0) : insert n (properDivisors n) = divisors n 
goal: insert n n.properDivisors = n.divisors

full_name: Nat.cons_self_properDivisors
code: theorem cons_self_properDivisors (h : n ≠ 0) :
    cons n (properDivisors n) properDivisors.not_self_mem = divisors n 
goal: Finset.cons n n.properDivisors ⋯ = n.divisors

full_name: Nat.mem_divisors
code: @[simp]
theorem mem_divisors {m : ℕ} : n ∈ divisors m ↔ n ∣ m ∧ m ≠ 0 
goal: n ∈ m.divisors ↔ n ∣ m ∧ m ≠ 0

full_name: Nat.one_mem_divisors
code: theorem one_mem_divisors : 1 ∈ divisors n ↔ n ≠ 0 
goal: 1 ∈ n.divisors ↔ n ≠ 0

full_name: Nat.mem_divisors_self
code: theorem mem_divisors_self (n : ℕ) (h : n ≠ 0) : n ∈ n.divisors 
goal: n ∈ n.divisors

full_name: Nat.dvd_of_mem_divisors
code: theorem dvd_of_mem_divisors {m : ℕ} (h : n ∈ divisors m) : n ∣ m 
goal: n ∣ m

full_name: Nat.mem_divisorsAntidiagonal
code: @[simp]
theorem mem_divisorsAntidiagonal {x : ℕ × ℕ} :
    x ∈ divisorsAntidiagonal n ↔ x.fst * x.snd = n ∧ n ≠ 0 
goal: x ∈ n.divisorsAntidiagonal ↔ x.1 * x.2 = n ∧ n ≠ 0

full_name: Nat.ne_zero_of_mem_divisorsAntidiagonal
code: lemma ne_zero_of_mem_divisorsAntidiagonal {p : ℕ × ℕ} (hp : p ∈ n.divisorsAntidiagonal) :
    p.1 ≠ 0 ∧ p.2 ≠ 0 
goal: p.1 ≠ 0 ∧ p.2 ≠ 0

full_name: Nat.left_ne_zero_of_mem_divisorsAntidiagonal
code: lemma left_ne_zero_of_mem_divisorsAntidiagonal {p : ℕ × ℕ} (hp : p ∈ n.divisorsAntidiagonal) :
    p.1 ≠ 0 
goal: p.1 ≠ 0

full_name: Nat.right_ne_zero_of_mem_divisorsAntidiagonal
code: lemma right_ne_zero_of_mem_divisorsAntidiagonal {p : ℕ × ℕ} (hp : p ∈ n.divisorsAntidiagonal) :
    p.2 ≠ 0 
goal: p.2 ≠ 0

full_name: Nat.divisor_le
code: theorem divisor_le {m : ℕ} : n ∈ divisors m → n ≤ m 
goal: n ∈ m.divisors → n ≤ m

full_name: Nat.divisors_subset_of_dvd
code: theorem divisors_subset_of_dvd {m : ℕ} (hzero : n ≠ 0) (h : m ∣ n) : divisors m ⊆ divisors n 
goal: m.divisors ⊆ n.divisors

full_name: Nat.divisors_subset_properDivisors
code: theorem divisors_subset_properDivisors {m : ℕ} (hzero : n ≠ 0) (h : m ∣ n) (hdiff : m ≠ n) :
    divisors m ⊆ properDivisors n 
goal: m.divisors ⊆ n.properDivisors

full_name: Nat.divisors_filter_dvd_of_dvd
code: lemma divisors_filter_dvd_of_dvd {n m : ℕ} (hn : n ≠ 0) (hm : m ∣ n) :
    (n.divisors.filter (· ∣ m)) = m.divisors 
goal: Finset.filter (fun x => x ∣ m) n.divisors = m.divisors

full_name: Nat.divisors_zero
code: @[simp]
theorem divisors_zero : divisors 0 = ∅ 
goal: Nat.divisors 0 = ∅

full_name: Nat.properDivisors_zero
code: @[simp]
theorem properDivisors_zero : properDivisors 0 = ∅ 
goal: Nat.properDivisors 0 = ∅

full_name: Nat.nonempty_divisors
code: @[simp]
lemma nonempty_divisors : (divisors n).Nonempty ↔ n ≠ 0 
goal: n.divisors.Nonempty ↔ n ≠ 0

full_name: Nat.divisors_eq_empty
code: @[simp]
lemma divisors_eq_empty : divisors n = ∅ ↔ n = 0 
goal: n.divisors = ∅ ↔ n = 0

full_name: Nat.properDivisors_subset_divisors
code: theorem properDivisors_subset_divisors : properDivisors n ⊆ divisors n 
goal: n.properDivisors ⊆ n.divisors

full_name: Nat.divisors_one
code: @[simp]
theorem divisors_one : divisors 1 = {1} 
goal: Nat.divisors 1 = {1}

full_name: Nat.properDivisors_one
code: @[simp]
theorem properDivisors_one : properDivisors 1 = ∅ 
goal: Nat.properDivisors 1 = ∅

full_name: Nat.pos_of_mem_divisors
code: theorem pos_of_mem_divisors {m : ℕ} (h : m ∈ n.divisors) : 0 < m 
goal: 0 < m

full_name: Nat.pos_of_mem_properDivisors
code: theorem pos_of_mem_properDivisors {m : ℕ} (h : m ∈ n.properDivisors) : 0 < m 
goal: 0 < m

full_name: Nat.one_mem_properDivisors_iff_one_lt
code: theorem one_mem_properDivisors_iff_one_lt : 1 ∈ n.properDivisors ↔ 1 < n 
goal: 1 ∈ n.properDivisors ↔ 1 < n

full_name: Nat.sup_divisors_id
code: @[simp]
lemma sup_divisors_id (n : ℕ) : n.divisors.sup id = n 
goal: n.divisors.sup id = n

full_name: Nat.one_lt_of_mem_properDivisors
code: lemma one_lt_of_mem_properDivisors {m n : ℕ} (h : m ∈ n.properDivisors) : 1 < n 
goal: 1 < n

full_name: Nat.one_lt_div_of_mem_properDivisors
code: lemma one_lt_div_of_mem_properDivisors {m n : ℕ} (h : m ∈ n.properDivisors) :
    1 < n / m 
goal: 1 < n / m

full_name: Nat.mem_properDivisors_iff_exists
code: /-- See also `Nat.mem_properDivisors`. -/
lemma mem_properDivisors_iff_exists {m n : ℕ} (hn : n ≠ 0) :
    m ∈ n.properDivisors ↔ ∃ k > 1, n = m * k 
goal: m ∈ n.properDivisors ↔ ∃ k > 1, n = m * k

full_name: Nat.nonempty_properDivisors
code: @[simp]
lemma nonempty_properDivisors : n.properDivisors.Nonempty ↔ 1 < n 
goal: n.properDivisors.Nonempty ↔ 1 < n

full_name: Nat.properDivisors_eq_empty
code: @[simp]
lemma properDivisors_eq_empty : n.properDivisors = ∅ ↔ n ≤ 1 
goal: n.properDivisors = ∅ ↔ n ≤ 1

full_name: Nat.divisorsAntidiagonal_zero
code: @[simp]
theorem divisorsAntidiagonal_zero : divisorsAntidiagonal 0 = ∅ 
goal: Nat.divisorsAntidiagonal 0 = ∅

full_name: Nat.divisorsAntidiagonal_one
code: @[simp]
theorem divisorsAntidiagonal_one : divisorsAntidiagonal 1 = {(1, 1)} 
goal: Nat.divisorsAntidiagonal 1 = {(1, 1)}

full_name: Nat.swap_mem_divisorsAntidiagonal
code: theorem swap_mem_divisorsAntidiagonal {x : ℕ × ℕ} :
    x.swap ∈ divisorsAntidiagonal n ↔ x ∈ divisorsAntidiagonal n 
goal: x.swap ∈ n.divisorsAntidiagonal ↔ x ∈ n.divisorsAntidiagonal

full_name: Nat.swap_mem_divisorsAntidiagonal_aux
code: @[simp]
theorem swap_mem_divisorsAntidiagonal_aux {x : ℕ × ℕ} :
    x.snd * x.fst = n ∧ ¬n = 0 ↔ x ∈ divisorsAntidiagonal n 
goal: x.2 * x.1 = n ∧ ¬n = 0 ↔ x ∈ n.divisorsAntidiagonal

full_name: Nat.fst_mem_divisors_of_mem_antidiagonal
code: theorem fst_mem_divisors_of_mem_antidiagonal {x : ℕ × ℕ} (h : x ∈ divisorsAntidiagonal n) :
    x.fst ∈ divisors n 
goal: x.1 ∈ n.divisors

full_name: Nat.snd_mem_divisors_of_mem_antidiagonal
code: theorem snd_mem_divisors_of_mem_antidiagonal {x : ℕ × ℕ} (h : x ∈ divisorsAntidiagonal n) :
    x.snd ∈ divisors n 
goal: x.2 ∈ n.divisors

full_name: Nat.map_swap_divisorsAntidiagonal
code: @[simp]
theorem map_swap_divisorsAntidiagonal :
    (divisorsAntidiagonal n).map (Equiv.prodComm _ _).toEmbedding = divisorsAntidiagonal n 
goal: Finset.map (Equiv.prodComm ℕ ℕ).toEmbedding n.divisorsAntidiagonal = n.divisorsAntidiagonal

full_name: Nat.image_fst_divisorsAntidiagonal
code: @[simp]
theorem image_fst_divisorsAntidiagonal : (divisorsAntidiagonal n).image Prod.fst = divisors n 
goal: Finset.image Prod.fst n.divisorsAntidiagonal = n.divisors

full_name: Nat.image_snd_divisorsAntidiagonal
code: @[simp]
theorem image_snd_divisorsAntidiagonal : (divisorsAntidiagonal n).image Prod.snd = divisors n 
goal: Finset.image Prod.snd n.divisorsAntidiagonal = n.divisors

full_name: Nat.map_div_right_divisors
code: theorem map_div_right_divisors :
    n.divisors.map ⟨fun d => (d, n / d), fun p₁ p₂ => congr_arg Prod.fst⟩ =
      n.divisorsAntidiagonal 
goal: Finset.map { toFun := fun d => (d, n / d), inj' := ⋯ } n.divisors = n.divisorsAntidiagonal

full_name: Nat.map_div_left_divisors
code: theorem map_div_left_divisors :
    n.divisors.map ⟨fun d => (n / d, d), fun p₁ p₂ => congr_arg Prod.snd⟩ =
      n.divisorsAntidiagonal 
goal: Finset.map { toFun := fun d => (n / d, d), inj' := ⋯ } n.divisors = n.divisorsAntidiagonal

full_name: Nat.sum_divisors_eq_sum_properDivisors_add_self
code: theorem sum_divisors_eq_sum_properDivisors_add_self :
    ∑ i ∈ divisors n, i = (∑ i ∈ properDivisors n, i) + n 
goal: ∑ i ∈ n.divisors, i = ∑ i ∈ n.properDivisors, i + n

full_name: Nat.Perfect
code: /-- `n : ℕ` is perfect if and only the sum of the proper divisors of `n` is `n` and `n`
  is positive. -/
def Perfect (n : ℕ) : Prop 
goal: Prop

full_name: Nat.perfect_iff_sum_properDivisors
code: theorem perfect_iff_sum_properDivisors (h : 0 < n) : Perfect n ↔ ∑ i ∈ properDivisors n, i = n 
goal: n.Perfect ↔ ∑ i ∈ n.properDivisors, i = n

full_name: Nat.perfect_iff_sum_divisors_eq_two_mul
code: theorem perfect_iff_sum_divisors_eq_two_mul (h : 0 < n) :
    Perfect n ↔ ∑ i ∈ divisors n, i = 2 * n 
goal: n.Perfect ↔ ∑ i ∈ n.divisors, i = 2 * n

full_name: Nat.mem_divisors_prime_pow
code: theorem mem_divisors_prime_pow {p : ℕ} (pp : p.Prime) (k : ℕ) {x : ℕ} :
    x ∈ divisors (p ^ k) ↔ ∃ j ≤ k, x = p ^ j 
goal: x ∈ (p ^ k).divisors ↔ ∃ j ≤ k, x = p ^ j

full_name: Nat.Prime.divisors
code: theorem Prime.divisors {p : ℕ} (pp : p.Prime) : divisors p = {1, p} 
goal: p.divisors = {1, p}

full_name: Nat.Prime.properDivisors
code: theorem Prime.properDivisors {p : ℕ} (pp : p.Prime) : properDivisors p = {1} 
goal: p.properDivisors = {1}

full_name: Nat.divisors_prime_pow
code: theorem divisors_prime_pow {p : ℕ} (pp : p.Prime) (k : ℕ) :
    divisors (p ^ k) = (Finset.range (k + 1)).map ⟨(p ^ ·), Nat.pow_right_injective pp.two_le⟩ 
goal: (p ^ k).divisors = Finset.map { toFun := fun x => p ^ x, inj' := ⋯ } (Finset.range (k + 1))

full_name: Nat.divisors_injective
code: theorem divisors_injective : Function.Injective divisors 
goal: Function.Injective Nat.divisors

full_name: Nat.divisors_inj
code: @[simp]
theorem divisors_inj {a b : ℕ} : a.divisors = b.divisors ↔ a = b 
goal: a.divisors = b.divisors ↔ a = b

full_name: Nat.eq_properDivisors_of_subset_of_sum_eq_sum
code: theorem eq_properDivisors_of_subset_of_sum_eq_sum {s : Finset ℕ} (hsub : s ⊆ n.properDivisors) :
    ((∑ x ∈ s, x) = ∑ x ∈ n.properDivisors, x) → s = n.properDivisors 
goal: ∑ x ∈ s, x = ∑ x ∈ n.properDivisors, x → s = n.properDivisors

full_name: Nat.sum_properDivisors_dvd
code: theorem sum_properDivisors_dvd (h : (∑ x ∈ n.properDivisors, x) ∣ n) :
    ∑ x ∈ n.properDivisors, x = 1 ∨ ∑ x ∈ n.properDivisors, x = n 
goal: ∑ x ∈ n.properDivisors, x = 1 ∨ ∑ x ∈ n.properDivisors, x = n

full_name: Nat.Prime.sum_properDivisors
code: @[to_additive (attr := simp)]
theorem Prime.prod_properDivisors {α : Type*} [CommMonoid α] {p : ℕ} {f : ℕ → α} (h : p.Prime) :
    ∏ x ∈ p.properDivisors, f x = f 1 
goal: ∑ x ∈ p.properDivisors, f x = f 1

full_name: Nat.Prime.prod_properDivisors
code: @[to_additive (attr := simp)]
theorem Prime.prod_properDivisors {α : Type*} [CommMonoid α] {p : ℕ} {f : ℕ → α} (h : p.Prime) :
    ∏ x ∈ p.properDivisors, f x = f 1 
goal: ∏ x ∈ p.properDivisors, f x = f 1

full_name: Nat.Prime.sum_divisors
code: @[to_additive (attr := simp)]
theorem Prime.prod_divisors {α : Type*} [CommMonoid α] {p : ℕ} {f : ℕ → α} (h : p.Prime) :
    ∏ x ∈ p.divisors, f x = f p * f 1 
goal: ∑ x ∈ p.divisors, f x = f p + f 1

full_name: Nat.Prime.prod_divisors
code: @[to_additive (attr := simp)]
theorem Prime.prod_divisors {α : Type*} [CommMonoid α] {p : ℕ} {f : ℕ → α} (h : p.Prime) :
    ∏ x ∈ p.divisors, f x = f p * f 1 
goal: ∏ x ∈ p.divisors, f x = f p * f 1

full_name: Nat.properDivisors_eq_singleton_one_iff_prime
code: theorem properDivisors_eq_singleton_one_iff_prime : n.properDivisors = {1} ↔ n.Prime 
goal: n.properDivisors = {1} ↔ Nat.Prime n

full_name: Nat.sum_properDivisors_eq_one_iff_prime
code: theorem sum_properDivisors_eq_one_iff_prime : ∑ x ∈ n.properDivisors, x = 1 ↔ n.Prime 
goal: ∑ x ∈ n.properDivisors, x = 1 ↔ Nat.Prime n

full_name: Nat.mem_properDivisors_prime_pow
code: theorem mem_properDivisors_prime_pow {p : ℕ} (pp : p.Prime) (k : ℕ) {x : ℕ} :
    x ∈ properDivisors (p ^ k) ↔ ∃ (j : ℕ) (_ : j < k), x = p ^ j 
goal: x ∈ (p ^ k).properDivisors ↔ ∃ j, ∃ (_ : j < k), x = p ^ j

full_name: Nat.properDivisors_prime_pow
code: theorem properDivisors_prime_pow {p : ℕ} (pp : p.Prime) (k : ℕ) :
    properDivisors (p ^ k) = (Finset.range k).map ⟨(p ^ ·), Nat.pow_right_injective pp.two_le⟩ 
goal: (p ^ k).properDivisors = Finset.map { toFun := fun x => p ^ x, inj' := ⋯ } (Finset.range k)

full_name: Nat.prod_properDivisors_prime_pow
code: @[to_additive (attr := simp)]
theorem prod_properDivisors_prime_pow {α : Type*} [CommMonoid α] {k p : ℕ} {f : ℕ → α}
    (h : p.Prime) : (∏ x ∈ (p ^ k).properDivisors, f x) = ∏ x ∈ range k, f (p ^ x) 
goal: ∏ x ∈ (p ^ k).properDivisors, f x = ∏ x ∈ Finset.range k, f (p ^ x)

full_name: Nat.sum_properDivisors_prime_nsmul
code: @[to_additive (attr := simp)]
theorem prod_properDivisors_prime_pow {α : Type*} [CommMonoid α] {k p : ℕ} {f : ℕ → α}
    (h : p.Prime) : (∏ x ∈ (p ^ k).properDivisors, f x) = ∏ x ∈ range k, f (p ^ x) 
goal: ∑ x ∈ (p ^ k).properDivisors, f x = ∑ x ∈ Finset.range k, f (p ^ x)

full_name: Nat.prod_divisors_prime_pow
code: @[to_additive (attr := simp) sum_divisors_prime_pow]
theorem prod_divisors_prime_pow {α : Type*} [CommMonoid α] {k p : ℕ} {f : ℕ → α} (h : p.Prime) :
    (∏ x ∈ (p ^ k).divisors, f x) = ∏ x ∈ range (k + 1), f (p ^ x) 
goal: ∏ x ∈ (p ^ k).divisors, f x = ∏ x ∈ Finset.range (k + 1), f (p ^ x)

full_name: Nat.sum_divisors_prime_pow
code: @[to_additive (attr := simp) sum_divisors_prime_pow]
theorem prod_divisors_prime_pow {α : Type*} [CommMonoid α] {k p : ℕ} {f : ℕ → α} (h : p.Prime) :
    (∏ x ∈ (p ^ k).divisors, f x) = ∏ x ∈ range (k + 1), f (p ^ x) 
goal: ∑ x ∈ (p ^ k).divisors, f x = ∑ x ∈ Finset.range (k + 1), f (p ^ x)

full_name: Nat.sum_divisorsAntidiagonal
code: @[to_additive]
theorem prod_divisorsAntidiagonal {M : Type*} [CommMonoid M] (f : ℕ → ℕ → M) {n : ℕ} :
    ∏ i ∈ n.divisorsAntidiagonal, f i.1 i.2 = ∏ i ∈ n.divisors, f i (n / i) 
goal: ∑ i ∈ n.divisorsAntidiagonal, f i.1 i.2 = ∑ i ∈ n.divisors, f i (n / i)

full_name: Nat.prod_divisorsAntidiagonal
code: @[to_additive]
theorem prod_divisorsAntidiagonal {M : Type*} [CommMonoid M] (f : ℕ → ℕ → M) {n : ℕ} :
    ∏ i ∈ n.divisorsAntidiagonal, f i.1 i.2 = ∏ i ∈ n.divisors, f i (n / i) 
goal: ∏ i ∈ n.divisorsAntidiagonal, f i.1 i.2 = ∏ i ∈ n.divisors, f i (n / i)

full_name: Nat.prod_divisorsAntidiagonal'
code: @[to_additive]
theorem prod_divisorsAntidiagonal' {M : Type*} [CommMonoid M] (f : ℕ → ℕ → M) {n : ℕ} :
    ∏ i ∈ n.divisorsAntidiagonal, f i.1 i.2 = ∏ i ∈ n.divisors, f (n / i) i 
goal: ∏ i ∈ n.divisorsAntidiagonal, f i.1 i.2 = ∏ i ∈ n.divisors, f (n / i) i

full_name: Nat.sum_divisorsAntidiagonal'
code: @[to_additive]
theorem prod_divisorsAntidiagonal' {M : Type*} [CommMonoid M] (f : ℕ → ℕ → M) {n : ℕ} :
    ∏ i ∈ n.divisorsAntidiagonal, f i.1 i.2 = ∏ i ∈ n.divisors, f (n / i) i 
goal: ∑ i ∈ n.divisorsAntidiagonal, f i.1 i.2 = ∑ i ∈ n.divisors, f (n / i) i

full_name: Nat.primeFactors_eq_to_filter_divisors_prime
code: /-- The factors of `n` are the prime divisors -/
theorem primeFactors_eq_to_filter_divisors_prime (n : ℕ) :
    n.primeFactors = (divisors n).filter Prime 
goal: n.primeFactors = Finset.filter Nat.Prime n.divisors

full_name: Nat.primeFactors_filter_dvd_of_dvd
code: lemma primeFactors_filter_dvd_of_dvd {m n : ℕ} (hn : n ≠ 0) (hmn : m ∣ n) :
    n.primeFactors.filter (· ∣ m) = m.primeFactors 
goal: Finset.filter (fun x => x ∣ m) n.primeFactors = m.primeFactors

full_name: Nat.image_div_divisors_eq_divisors
code: @[simp]
theorem image_div_divisors_eq_divisors (n : ℕ) :
    image (fun x : ℕ => n / x) n.divisors = n.divisors 
goal: Finset.image (fun x => n / x) n.divisors = n.divisors

full_name: Nat.prod_div_divisors
code: @[to_additive sum_div_divisors]
theorem prod_div_divisors {α : Type*} [CommMonoid α] (n : ℕ) (f : ℕ → α) :
    (∏ d ∈ n.divisors, f (n / d)) = n.divisors.prod f 
goal: ∏ d ∈ n.divisors, f (n / d) = n.divisors.prod f

full_name: Nat.sum_div_divisors
code: @[to_additive sum_div_divisors]
theorem prod_div_divisors {α : Type*} [CommMonoid α] (n : ℕ) (f : ℕ → α) :
    (∏ d ∈ n.divisors, f (n / d)) = n.divisors.prod f 
goal: ∑ d ∈ n.divisors, f (n / d) = n.divisors.sum f