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.Nat.Squarefree

43 declarations and 1 deprecated aliases. Mathlib docs · Source

Lemmas about squarefreeness of natural numbers

A number is squarefree when it is not divisible by any squares except the squares of units.

Main Results

  • Nat.squarefree_iff_nodup_primeFactorsList: A positive natural number x is squarefree iff the list factors x has no duplicate factors.

Tags

squarefree, multiplicity

theorem Nat.MinSqFacProp.match_1.congr_eq_2 E1 #

∀ (motive : Option ℕ → Sort u_1) (x : Option ℕ) (h_1 : Unit → motive none) (h_2 : (d : ℕ) → motive (some d)) (d : ℕ),
  x = some d →
    (match x with
      | none => h_1 ()
      | some d => h_2 d) ≍
      h_2 d

theorem Nat.MinSqFacProp.match_1.congr_eq_1 E1 #

∀ (motive : Option ℕ → Sort u_1) (x : Option ℕ) (h_1 : Unit → motive none) (h_2 : (d : ℕ) → motive (some d)),
  x = none →
    (match x with
      | none => h_1 ()
      | some d => h_2 d) ≍
      h_1 ()

theorem Nat.squarefree_iff_nodup_primeFactorsList E3 #

∀ {n : ℕ}, n ≠ 0 → (Squarefree n ↔ n.primeFactorsList.Nodup)

theorem Squarefree.nodup_primeFactorsList E1 #

∀ {n : ℕ}, Squarefree n → n.primeFactorsList.Nodup

theorem Nat.squarefree_iff_prime_squarefree E1 #

∀ {n : ℕ}, Squarefree n ↔ ∀ (x : ℕ), Nat.Prime x → ¬x * x ∣ n

theorem Squarefree.natFactorization_le_one E1 #

∀ {n : ℕ} (p : ℕ), Squarefree n → n.factorization p ≤ 1

theorem Nat.factorization_eq_one_of_squarefree E1 #

∀ {n p : ℕ}, Squarefree n → Nat.Prime p → p ∣ n → n.factorization p = 1

theorem Nat.squarefree_of_factorization_le_one E1 #

∀ {n : ℕ}, n ≠ 0 → (∀ (p : ℕ), n.factorization p ≤ 1) → Squarefree n

theorem Nat.squarefree_iff_factorization_le_one E1 #

∀ {n : ℕ}, n ≠ 0 → (Squarefree n ↔ ∀ (p : ℕ), n.factorization p ≤ 1)

theorem Nat.Squarefree.ext_iff E0 #

∀ {n m : ℕ}, Squarefree n → Squarefree m → (n = m ↔ ∀ (p : ℕ), Nat.Prime p → (p ∣ n ↔ p ∣ m))

theorem Nat.squarefree_pow_iff E0 #

∀ {n k : ℕ}, n ≠ 1 → k ≠ 0 → (Squarefree (n ^ k) ↔ Squarefree n ∧ k = 1)

theorem Nat.squarefree_and_prime_pow_iff_prime E1 #

∀ {n : ℕ}, Squarefree n ∧ IsPrimePow n ↔ Nat.Prime n

def Nat.minSqFacAux E0 #

ℕ → ℕ → Option ℕ

Assuming that n has no factors less than k, returns the smallest prime p such that p^2 ∣ n.

def Nat.minSqFac E1 #

ℕ → Option ℕ

Returns the smallest prime factor p of n such that p^2 ∣ n, or none if there is no such p (that is, n is squarefree). See also Nat.squarefree_iff_minSqFac.

def Nat.MinSqFacProp E1 #

ℕ → Option ℕ → Prop

The correctness property of the return value of minSqFac.

  • If none, then n is squarefree;
  • If some d, then d is a minimal square factor of n

theorem Nat.minSqFacProp_div E1 #

∀ (n : ℕ) {k : ℕ}, Nat.Prime k → k ∣ n → ¬k * k ∣ n → ∀ {o : Option ℕ}, (n / k).MinSqFacProp o → n.MinSqFacProp o

theorem Nat.minSqFacAux_has_prop E1 #

∀ {n : ℕ} (k : ℕ),
  0 < n → ∀ (i : ℕ), k = 2 * i + 3 → (∀ (m : ℕ), Nat.Prime m → m ∣ n → k ≤ m) → n.MinSqFacProp (n.minSqFacAux k)

theorem Nat.minSqFac_has_prop E1 #

∀ (n : ℕ), n.MinSqFacProp n.minSqFac

theorem Nat.minSqFac_prime E1 #

∀ {n d : ℕ}, n.minSqFac = some d → Nat.Prime d

theorem Nat.minSqFac_dvd E1 #

∀ {n d : ℕ}, n.minSqFac = some d → d * d ∣ n

theorem Nat.minSqFac_le_of_dvd E1 #

∀ {n d : ℕ}, n.minSqFac = some d → ∀ {m : ℕ}, 2 ≤ m → m * m ∣ n → d ≤ m

theorem Nat.squarefree_iff_minSqFac E1 #

∀ {n : ℕ}, Squarefree n ↔ n.minSqFac = none

instance Nat.instDecidablePredSquarefree E0 #

DecidablePred Squarefree

theorem Nat.squarefree_two E1 #

Squarefree 2

theorem Nat.divisors_filter_squarefree_of_squarefree E1 #

∀ {n : ℕ}, Squarefree n → {d ∈ n.divisors | Squarefree d} = n.divisors

theorem Nat.divisors_filter_squarefree E1 #

∀ {n : ℕ},
  n ≠ 0 →
    {d ∈ n.divisors | Squarefree d}.val =
      Multiset.map (fun x ↦ x.val.prod) (UniqueFactorizationMonoid.normalizedFactors n).toFinset.powerset.val

theorem Nat.sum_divisors_filter_squarefree E1 #

∀ {n : ℕ},
  n ≠ 0 →
    ∀ {α : Type u_1} [inst : AddCommMonoid α] {f : ℕ → α},
      ∑ d ∈ n.divisors with Squarefree d, f d =
        ∑ i ∈ (UniqueFactorizationMonoid.normalizedFactors n).toFinset.powerset, f i.val.prod

theorem Nat.sq_mul_squarefree_of_pos E1 #

∀ {n : ℕ}, 0 < n → ∃ a b, 0 < a ∧ 0 < b ∧ b ^ 2 * a = n ∧ Squarefree a

theorem Nat.sq_mul_squarefree_of_pos' E1 #

∀ {n : ℕ}, 0 < n → ∃ a b, (b + 1) ^ 2 * (a + 1) = n ∧ Squarefree (a + 1)

theorem Nat.squarefree_mul E1 #

∀ {m n : ℕ}, m.Coprime n → (Squarefree (m * n) ↔ Squarefree m ∧ Squarefree n)

Squarefree is multiplicative. Note that the → direction does not require hmn and generalizes to arbitrary commutative monoids. See Squarefree.of_mul_left and Squarefree.of_mul_right above for auxiliary lemmas.

theorem Nat.coprime_of_squarefree_mul E1 #

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

theorem Nat.squarefree_mul_iff E0 #

∀ {m n : ℕ}, Squarefree (m * n) ↔ m.Coprime n ∧ Squarefree m ∧ Squarefree n

theorem Nat.coprime_div_gcd_of_squarefree E1 #

∀ {m n : ℕ}, Squarefree m → (m / m.gcd n).Coprime n

theorem Nat.prod_primeFactors_of_squarefree E1 #

∀ {n : ℕ}, Squarefree n → ∏ p ∈ n.primeFactors, p = n

theorem Nat.squarefree_and_primeFactors_card_eq_two_iff E0 #

∀ (n : ℕ), Squarefree n ∧ n.primeFactors.card = 2 ↔ ∃ p q, p < q ∧ Nat.Prime p ∧ Nat.Prime q ∧ p * q = n

theorem Nat.primeFactors_prod E1 #

∀ {s : Finset ℕ}, (∀ p ∈ s, Nat.Prime p) → (∏ p ∈ s, p).primeFactors = s

theorem Nat.primeFactors_prod_primeFactors E1 #

∀ (n : ℕ), (∏ p ∈ n.primeFactors, p).primeFactors = n.primeFactors

theorem Nat.squarefree_prod_primeFactors E1 #

∀ (n : ℕ), Squarefree (∏ p ∈ n.primeFactors, p)

theorem Nat.prod_primeFactors_dvd_iff E0 #

∀ {n k : ℕ}, k ≠ 0 → (∏ p ∈ n.primeFactors, p ∣ k ↔ n.primeFactors ⊆ k.primeFactors)

theorem Nat.primeFactors_div_gcd E1 #

∀ {m n : ℕ}, Squarefree m → n ≠ 0 → (m / m.gcd n).primeFactors = m.primeFactors \ n.primeFactors

theorem Nat.prod_primeFactors_invOn_squarefree E1 #

Set.InvOn (fun n ↦ n.factorization.support) (fun s ↦ ∏ p ∈ s, p) {s | ∀ p ∈ s, Nat.Prime p} {n | Squarefree n}

theorem Nat.prod_primeFactors_sdiff_of_squarefree E1 #

∀ {n : ℕ}, Squarefree n → ∀ {t : Finset ℕ}, t ⊆ n.primeFactors → ∏ a ∈ n.primeFactors \ t, a = n / ∏ a ∈ t, a

theorem Int.squarefree_iff_prime_sq_not_dvd E1 #

∀ {n : ℤ}, Squarefree n ↔ ∀ (p : ℕ), Nat.Prime p → ¬↑p ^ 2 ∣ n

An integer is squarefree iff no prime square divides it.

Deprecated aliases

NameNew nameSince
Nat.sq_mul_squarefree2026-08-17