Documentation

Mathlib.NumberTheory.Divisors

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:

Conventions #

Since 0 has infinitely many divisors, none of the definitions in this file make sense for it. Therefore we adopt the convention that Nat.divisors 0, Nat.properDivisors 0, Nat.divisorsAntidiagonal 0 and Int.divisorsAntidiag 0 are all ∅.

Tags #

divisors, perfect numbers

divisors n is the Finset of divisors of n. By convention, we set divisors 0 = ∅.

Equations
Instances For

    properDivisors n is the Finset of divisors of n, other than n. By convention, we set properDivisors 0 = ∅.

    Equations
    Instances For

      Pairs of divisors of a natural number as a finset.

      n.divisorsAntidiagonal is the finset of pairs (a, b) : ℕ × ℕ such that a * b = n. By convention, we set Nat.divisorsAntidiagonal 0 = ∅.

      O(n).

      Equations
      Instances For

        Pairs of divisors of a natural number, as a list.

        n.divisorsAntidiagonalList is the list of pairs (a, b) : ℕ × ℕ such that a * b = n, ordered by increasing a. By convention, we set Nat.divisorsAntidiagonalList 0 = [].

        Equations
        Instances For
          @[simp]
          theorem Nat.filter_dvd_eq_divisors {n : ℕ} (h : n ≠ 0) :
          {d ∈ Finset.range n.succ | d ∣ n} = n.divisors
          @[simp]
          theorem Nat.filter_dvd_eq_properDivisors {n : ℕ} (h : n ≠ 0) :
          {d ∈ Finset.range n | d ∣ n} = n.properDivisors
          @[simp]
          theorem Nat.mem_properDivisors {n m : ℕ} :
          @[simp]
          theorem Nat.mem_divisors {n m : ℕ} :
          n ∈ m.divisors ↔ n ∣ m ∧ m ≠ 0
          theorem Nat.dvd_of_mem_divisors {n m : ℕ} (h : n ∈ m.divisors) :
          n ∣ m
          theorem Nat.ne_zero_of_mem_divisors {n m : ℕ} (h : n ∈ m.divisors) :
          m ≠ 0
          theorem Nat.mem_divisors_self (n : ℕ) (h : n ≠ 0) :
          @[simp]
          theorem Nat.mem_divisorsAntidiagonal {n : ℕ} {x : ℕ × ℕ} :
          x ∈ n.divisorsAntidiagonal ↔ x.1 * x.2 = n ∧ n ≠ 0
          @[simp]

          The Finset and List versions agree by definition.

          @[simp]
          theorem Nat.divisor_le {n m : ℕ} :
          n ∈ m.divisors → n ≤ m
          theorem Nat.divisors_subset_of_dvd {n m : ℕ} (hzero : n ≠ 0) (h : m ∣ n) :
          theorem Nat.divisors_subset_properDivisors {n m : ℕ} (hzero : n ≠ 0) (h : m ∣ n) (hdiff : m ≠ n) :
          theorem Nat.divisors_filter_dvd_of_dvd {n m : ℕ} (hn : n ≠ 0) (hm : m ∣ n) :
          {d ∈ n.divisors | d ∣ m} = m.divisors
          @[simp]
          theorem Nat.divisors_eq_empty {n : ℕ} :
          @[simp]
          theorem Nat.pos_of_mem_divisors {n m : ℕ} (h : m ∈ n.divisors) :
          0 < m
          @[simp]
          theorem Nat.sup_divisors_id (n : ℕ) :
          theorem Nat.mem_properDivisors_iff_exists {m n : ℕ} (hn : n ≠ 0) :
          m ∈ n.properDivisors ↔ ∃ k > 1, n = m * k

          See also Nat.mem_properDivisors.

          theorem Nat.map_div_right_divisors {n : ℕ} :
          Finset.map { toFun := fun (d : ℕ) => (d, n / d), inj' := ⋯ } n.divisors = n.divisorsAntidiagonal
          theorem Nat.map_div_left_divisors {n : ℕ} :
          Finset.map { toFun := fun (d : ℕ) => (n / d, d), inj' := ⋯ } n.divisors = n.divisorsAntidiagonal
          def Nat.Perfect (n : ℕ) :

          n : ℕ is perfect if and only the sum of the proper divisors of n is n and n is positive.

          Equations
          Instances For
            theorem Nat.perfect_iff_sum_properDivisors {n : ℕ} (h : 0 < n) :
            n.Perfect ↔ ∑ i ∈ n.properDivisors, i = n
            theorem Nat.perfect_iff_sum_divisors_eq_two_mul {n : ℕ} (h : 0 < n) :
            n.Perfect ↔ ∑ i ∈ n.divisors, i = 2 * n
            theorem Nat.mem_divisors_prime_pow {p : ℕ} (pp : Prime p) (k : ℕ) {x : ℕ} :
            x ∈ (p ^ k).divisors ↔ ∃ j ≤ k, x = p ^ j
            theorem Nat.Prime.divisors {p : ℕ} (pp : Prime p) :
            theorem Nat.divisors_prime_pow {p : ℕ} (pp : Prime p) (k : ℕ) :
            (p ^ k).divisors = Finset.map { toFun := fun (x : ℕ) => p ^ x, inj' := ⋯ } (Finset.range (k + 1))
            @[simp]
            theorem Nat.divisors_inj {a b : ℕ} :
            theorem Nat.eq_properDivisors_of_subset_of_sum_eq_sum {n : ℕ} {s : Finset ℕ} (hsub : s ⊆ n.properDivisors) :
            ∑ x ∈ s, x = ∑ x ∈ n.properDivisors, x → s = n.properDivisors
            theorem Nat.sum_properDivisors_dvd {n : ℕ} (h : ∑ x ∈ n.properDivisors, x ∣ n) :
            ∑ x ∈ n.properDivisors, x = 1 ∨ ∑ x ∈ n.properDivisors, x = n
            @[simp]
            theorem Nat.Prime.prod_properDivisors {α : Type u_1} [CommMonoid α] {p : ℕ} {f : ℕ → α} (h : Prime p) :
            ∏ x ∈ p.properDivisors, f x = f 1
            @[simp]
            theorem Nat.Prime.sum_properDivisors {α : Type u_1} [AddCommMonoid α] {p : ℕ} {f : ℕ → α} (h : Prime p) :
            ∑ x ∈ p.properDivisors, f x = f 1
            @[simp]
            theorem Nat.Prime.prod_divisors {α : Type u_1} [CommMonoid α] {p : ℕ} {f : ℕ → α} (h : Prime p) :
            ∏ x ∈ p.divisors, f x = f p * f 1
            @[simp]
            theorem Nat.Prime.sum_divisors {α : Type u_1} [AddCommMonoid α] {p : ℕ} {f : ℕ → α} (h : Prime p) :
            ∑ x ∈ p.divisors, f x = f p + f 1
            theorem Nat.mem_properDivisors_prime_pow {p : ℕ} (pp : Prime p) (k : ℕ) {x : ℕ} :
            x ∈ (p ^ k).properDivisors ↔ ∃ (j : ℕ) (_ : j < k), x = p ^ j
            theorem Nat.properDivisors_prime_pow {p : ℕ} (pp : Prime p) (k : ℕ) :
            (p ^ k).properDivisors = Finset.map { toFun := fun (x : ℕ) => p ^ x, inj' := ⋯ } (Finset.range k)
            @[simp]
            theorem Nat.prod_properDivisors_prime_pow {α : Type u_1} [CommMonoid α] {k p : ℕ} {f : ℕ → α} (h : Prime p) :
            ∏ x ∈ (p ^ k).properDivisors, f x = ∏ x ∈ Finset.range k, f (p ^ x)
            @[simp]
            theorem Nat.sum_properDivisors_prime_nsmul {α : Type u_1} [AddCommMonoid α] {k p : ℕ} {f : ℕ → α} (h : Prime p) :
            ∑ x ∈ (p ^ k).properDivisors, f x = ∑ x ∈ Finset.range k, f (p ^ x)
            @[simp]
            theorem Nat.prod_divisors_prime_pow {α : Type u_1} [CommMonoid α] {k p : ℕ} {f : ℕ → α} (h : Prime p) :
            ∏ x ∈ (p ^ k).divisors, f x = ∏ x ∈ Finset.range (k + 1), f (p ^ x)
            @[simp]
            theorem Nat.sum_divisors_prime_pow {α : Type u_1} [AddCommMonoid α] {k p : ℕ} {f : ℕ → α} (h : Prime p) :
            ∑ x ∈ (p ^ k).divisors, f x = ∑ x ∈ Finset.range (k + 1), f (p ^ x)
            theorem Nat.prod_divisorsAntidiagonal {M : Type u_1} [CommMonoid M] (f : ℕ → ℕ → M) {n : ℕ} :
            ∏ i ∈ n.divisorsAntidiagonal, f i.1 i.2 = ∏ i ∈ n.divisors, f i (n / i)
            theorem Nat.sum_divisorsAntidiagonal {M : Type u_1} [AddCommMonoid M] (f : ℕ → ℕ → M) {n : ℕ} :
            ∑ i ∈ n.divisorsAntidiagonal, f i.1 i.2 = ∑ i ∈ n.divisors, f i (n / i)
            theorem Nat.prod_divisorsAntidiagonal' {M : Type u_1} [CommMonoid M] (f : ℕ → ℕ → M) {n : ℕ} :
            ∏ i ∈ n.divisorsAntidiagonal, f i.1 i.2 = ∏ i ∈ n.divisors, f (n / i) i
            theorem Nat.sum_divisorsAntidiagonal' {M : Type u_1} [AddCommMonoid M] (f : ℕ → ℕ → M) {n : ℕ} :
            ∑ i ∈ n.divisorsAntidiagonal, f i.1 i.2 = ∑ i ∈ n.divisors, f (n / i) i

            The factors of n are the prime divisors

            theorem Nat.primeFactors_filter_dvd_of_dvd {m n : ℕ} (hn : n ≠ 0) (hmn : m ∣ n) :
            {p ∈ n.primeFactors | p ∣ m} = m.primeFactors
            @[simp]
            @[simp]
            theorem Nat.prod_div_divisors {α : Type u_1} [CommMonoid α] (n : ℕ) (f : ℕ → α) :
            ∏ d ∈ n.divisors, f (n / d) = n.divisors.prod f
            @[simp]
            theorem Nat.sum_div_divisors {α : Type u_1} [AddCommMonoid α] (n : ℕ) (f : ℕ → α) :
            ∑ d ∈ n.divisors, f (n / d) = n.divisors.sum f
            theorem Nat.divisorsAntidiagonal_eq_prod_filter_of_le {n N : ℕ} (n_ne_zero : n ≠ 0) (hn : n ≤ N) :
            n.divisorsAntidiagonal = {x ∈ Finset.Ioc 0 N ×ˢ Finset.Ioc 0 N | x.1 * x.2 = n}

            Useful lemma for reordering sums.

            theorem Nat.antidiagonal_map_subset_divisorsAntidiagonal_pow {q : ℕ} (hq : 1 < q) (k : ℕ) :
            Finset.map ({ toFun := fun (k : ℕ) => q ^ k, inj' := ⋯ }.prodMap { toFun := fun (k : ℕ) => q ^ k, inj' := ⋯ }) (Finset.antidiagonal k) ⊆ (q ^ k).divisorsAntidiagonal

            Finset.antidiagonal k embeds as a subset of Nat.divisorsAntidiagonal (q ^ k).

            divisors z is the Finset of divisors of z. By convention, we set divisors 0 = ∅.

            Equations
            Instances For

              Pairs of divisors of an integer as a finset.

              z.divisorsAntidiag is the finset of pairs (a, b) : ℤ × ℤ such that a * b = z. By convention, we set Int.divisorsAntidiag 0 = ∅.

              O(|z|). Computed from Nat.divisorsAntidiagonal.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                @[simp]
                theorem Int.mem_divisors {x z : ℤ} :
                x ∈ z.divisors ↔ x ∣ z ∧ z ≠ 0
                theorem Int.dvd_of_mem_divisors {x z : ℤ} (h : x ∈ z.divisors) :
                x ∣ z
                theorem Int.ne_zero_of_mem_divisors {x z : ℤ} (h : x ∈ z.divisors) :
                z ≠ 0
                @[simp]
                theorem Int.divisors_eq_empty {z : ℤ} :
                @[simp]
                theorem Int.mem_divisors_self {z : ℤ} (hz : z ≠ 0) :
                @[simp]
                theorem Int.divisors_neg {z : ℤ} :
                @[simp]
                theorem Int.mem_divisorsAntidiag {xy : ℤ × ℤ} {z : ℤ} :
                xy ∈ z.divisorsAntidiag ↔ xy.1 * xy.2 = z ∧ z ≠ 0
                theorem Int.prodMk_mem_divisorsAntidiag {x y z : ℤ} (hz : z ≠ 0) :
                theorem Int.mul_mem_one_two_three_iff {a b : ℤ} :
                a * b ∈ {1, 2, 3} ↔ (a, b) ∈ {(1, 1), (-1, -1), (1, 2), (2, 1), (-1, -2), (-2, -1), (1, 3), (3, 1), (-1, -3), (-3, -1)}

                This lemma justifies its existence from its utility in crystallographic root system theory.

                theorem Int.mul_mem_zero_one_two_three_four_iff {a b : ℤ} (h₀ : a = 0 ↔ b = 0) :
                a * b ∈ {0, 1, 2, 3, 4} ↔ (a, b) ∈ {(0, 0), (1, 1), (-1, -1), (1, 2), (2, 1), (-1, -2), (-2, -1), (1, 3), (3, 1), (-1, -3), (-3, -1), (4, 1), (1, 4), (-4, -1), (-1, -4), (2, 2), (-2, -2)}

                This lemma justifies its existence from its utility in crystallographic root system theory.