File: Mathlib/Data/Nat/Factorization/Basic.lean

full_name: Nat.factorization_eq_zero_of_lt
code: theorem factorization_eq_zero_of_lt {n p : ℕ} (h : n < p) : n.factorization p = 0 
goal: n.factorization p = 0

full_name: Nat.factorization_one_right
code: @[simp]
theorem factorization_one_right (n : ℕ) : n.factorization 1 = 0 
goal: n.factorization 1 = 0

full_name: Nat.dvd_of_factorization_pos
code: theorem dvd_of_factorization_pos {n p : ℕ} (hn : n.factorization p ≠ 0) : p ∣ n 
goal: p ∣ n

full_name: Nat.factorization_eq_zero_iff_remainder
code: theorem factorization_eq_zero_iff_remainder {p r : ℕ} (i : ℕ) (pp : p.Prime) (hr0 : r ≠ 0) :
    ¬p ∣ r ↔ (p * i + r).factorization p = 0 
goal: ¬p ∣ r ↔ (p * i + r).factorization p = 0

full_name: Nat.factorization_eq_zero_iff'
code: /-- The only numbers with empty prime factorization are `0` and `1` -/
theorem factorization_eq_zero_iff' (n : ℕ) : n.factorization = 0 ↔ n = 0 ∨ n = 1 
goal: n.factorization = 0 ↔ n = 0 ∨ n = 1

full_name: Nat.prod_factorization_eq_prod_primeFactors
code: /-- A product over `n.factorization` can be written as a product over `n.primeFactors`; -/
lemma prod_factorization_eq_prod_primeFactors {β : Type*} [CommMonoid β] (f : ℕ → ℕ → β) :
    n.factorization.prod f = ∏ p ∈ n.primeFactors, f p (n.factorization p) 
goal: n.factorization.prod f = ∏ p ∈ n.primeFactors, f p (n.factorization p)

full_name: Nat.prod_primeFactors_prod_factorization
code: /-- A product over `n.primeFactors` can be written as a product over `n.factorization`; -/
lemma prod_primeFactors_prod_factorization {β : Type*} [CommMonoid β] (f : ℕ → β) :
    ∏ p ∈ n.primeFactors, f p = n.factorization.prod (fun p _ ↦ f p) 
goal: ∏ p ∈ n.primeFactors, f p = n.factorization.prod fun p x => f p

full_name: Nat.Prime.factorization_self
code: /-- The multiplicity of prime `p` in `p` is `1` -/
@[simp]
theorem Prime.factorization_self {p : ℕ} (hp : Prime p) : p.factorization p = 1 
goal: p.factorization p = 1

full_name: Nat.eq_pow_of_factorization_eq_single
code: /-- If the factorization of `n` contains just one number `p` then `n` is a power of `p` -/
theorem eq_pow_of_factorization_eq_single {n p k : ℕ} (hn : n ≠ 0)
    (h : n.factorization = Finsupp.single p k) : n = p ^ k 
goal: n = p ^ k

full_name: Nat.Prime.eq_of_factorization_pos
code: /-- The only prime factor of prime `p` is `p` itself. -/
theorem Prime.eq_of_factorization_pos {p q : ℕ} (hp : Prime p) (h : p.factorization q ≠ 0) :
    p = q 
goal: p = q

full_name: Nat.eq_factorization_iff
code: theorem eq_factorization_iff {n : ℕ} {f : ℕ →₀ ℕ} (hn : n ≠ 0) (hf : ∀ p ∈ f.support, Prime p) :
    f = n.factorization ↔ f.prod (· ^ ·) = n 
goal: f = n.factorization ↔ (f.prod fun x x_1 => x ^ x_1) = n

full_name: Nat.factorizationEquiv_inv_apply
code: theorem factorizationEquiv_inv_apply {f : ℕ →₀ ℕ} (hf : ∀ p ∈ f.support, Prime p) :
    (factorizationEquiv.symm ⟨f, hf⟩).1 = f.prod (· ^ ·) 
goal: ↑(Nat.factorizationEquiv.symm ⟨f, hf⟩) = f.prod fun x x_1 => x ^ x_1

full_name: Nat.ord_proj_of_not_prime
code: @[simp]
theorem ord_proj_of_not_prime (n p : ℕ) (hp : ¬p.Prime) : ord_proj[p] n = 1 
goal: p ^ n.factorization p = 1

full_name: Nat.ord_compl_of_not_prime
code: @[simp]
theorem ord_compl_of_not_prime (n p : ℕ) (hp : ¬p.Prime) : ord_compl[p] n = n 
goal: n / p ^ n.factorization p = n

full_name: Nat.ord_compl_dvd
code: theorem ord_compl_dvd (n p : ℕ) : ord_compl[p] n ∣ n 
goal: n / p ^ n.factorization p ∣ n

full_name: Nat.ord_proj_pos
code: theorem ord_proj_pos (n p : ℕ) : 0 < ord_proj[p] n 
goal: 0 < p ^ n.factorization p

full_name: Nat.ord_proj_le
code: theorem ord_proj_le {n : ℕ} (p : ℕ) (hn : n ≠ 0) : ord_proj[p] n ≤ n 
goal: p ^ n.factorization p ≤ n

full_name: Nat.ord_compl_pos
code: theorem ord_compl_pos {n : ℕ} (p : ℕ) (hn : n ≠ 0) : 0 < ord_compl[p] n 
goal: 0 < n / p ^ n.factorization p

full_name: Nat.ord_compl_le
code: theorem ord_compl_le (n p : ℕ) : ord_compl[p] n ≤ n 
goal: n / p ^ n.factorization p ≤ n

full_name: Nat.ord_proj_mul_ord_compl_eq_self
code: theorem ord_proj_mul_ord_compl_eq_self (n p : ℕ) : ord_proj[p] n * ord_compl[p] n = n 
goal: p ^ n.factorization p * (n / p ^ n.factorization p) = n

full_name: Nat.ord_proj_mul
code: theorem ord_proj_mul {a b : ℕ} (p : ℕ) (ha : a ≠ 0) (hb : b ≠ 0) :
    ord_proj[p] (a * b) = ord_proj[p] a * ord_proj[p] b 
goal: p ^ (a * b).factorization p = p ^ a.factorization p * p ^ b.factorization p

full_name: Nat.ord_compl_mul
code: theorem ord_compl_mul (a b p : ℕ) : ord_compl[p] (a * b) = ord_compl[p] a * ord_compl[p] b 
goal: a * b / p ^ (a * b).factorization p = a / p ^ a.factorization p * (b / p ^ b.factorization p)

full_name: Nat.factorization_lt
code: /-- A crude upper bound on `n.factorization p` -/
theorem factorization_lt {n : ℕ} (p : ℕ) (hn : n ≠ 0) : n.factorization p < n 
goal: n.factorization p < n

full_name: Nat.factorization_le_of_le_pow
code: /-- An upper bound on `n.factorization p` -/
theorem factorization_le_of_le_pow {n p b : ℕ} (hb : n ≤ p ^ b) : n.factorization p ≤ b 
goal: n.factorization p ≤ b

full_name: Nat.factorization_prime_le_iff_dvd
code: theorem factorization_prime_le_iff_dvd {d n : ℕ} (hd : d ≠ 0) (hn : n ≠ 0) :
    (∀ p : ℕ, p.Prime → d.factorization p ≤ n.factorization p) ↔ d ∣ n 
goal: (∀ (p : ℕ), Nat.Prime p → d.factorization p ≤ n.factorization p) ↔ d ∣ n

full_name: Nat.factorization_le_factorization_mul_left
code: theorem factorization_le_factorization_mul_left {a b : ℕ} (hb : b ≠ 0) :
    a.factorization ≤ (a * b).factorization 
goal: a.factorization ≤ (a * b).factorization

full_name: Nat.factorization_le_factorization_mul_right
code: theorem factorization_le_factorization_mul_right {a b : ℕ} (ha : a ≠ 0) :
    b.factorization ≤ (a * b).factorization 
goal: b.factorization ≤ (a * b).factorization

full_name: Nat.Prime.pow_dvd_iff_le_factorization
code: theorem Prime.pow_dvd_iff_le_factorization {p k n : ℕ} (pp : Prime p) (hn : n ≠ 0) :
    p ^ k ∣ n ↔ k ≤ n.factorization p 
goal: p ^ k ∣ n ↔ k ≤ n.factorization p

full_name: Nat.Prime.pow_dvd_iff_dvd_ord_proj
code: theorem Prime.pow_dvd_iff_dvd_ord_proj {p k n : ℕ} (pp : Prime p) (hn : n ≠ 0) :
    p ^ k ∣ n ↔ p ^ k ∣ ord_proj[p] n 
goal: p ^ k ∣ n ↔ p ^ k ∣ p ^ n.factorization p

full_name: Nat.Prime.dvd_iff_one_le_factorization
code: theorem Prime.dvd_iff_one_le_factorization {p n : ℕ} (pp : Prime p) (hn : n ≠ 0) :
    p ∣ n ↔ 1 ≤ n.factorization p 
goal: p ∣ n ↔ 1 ≤ n.factorization p

full_name: Nat.exists_factorization_lt_of_lt
code: theorem exists_factorization_lt_of_lt {a b : ℕ} (ha : a ≠ 0) (hab : a < b) :
    ∃ p : ℕ, a.factorization p < b.factorization p 
goal: ∃ p, a.factorization p < b.factorization p

full_name: Nat.factorization_div
code: @[simp]
theorem factorization_div {d n : ℕ} (h : d ∣ n) :
    (n / d).factorization = n.factorization - d.factorization 
goal: (n / d).factorization = n.factorization - d.factorization

full_name: Nat.dvd_ord_proj_of_dvd
code: theorem dvd_ord_proj_of_dvd {n p : ℕ} (hn : n ≠ 0) (pp : p.Prime) (h : p ∣ n) : p ∣ ord_proj[p] n 
goal: p ∣ p ^ n.factorization p

full_name: Nat.not_dvd_ord_compl
code: theorem not_dvd_ord_compl {n p : ℕ} (hp : Prime p) (hn : n ≠ 0) : ¬p ∣ ord_compl[p] n 
goal: ¬p ∣ n / p ^ n.factorization p

full_name: Nat.coprime_ord_compl
code: theorem coprime_ord_compl {n p : ℕ} (hp : Prime p) (hn : n ≠ 0) : Coprime p (ord_compl[p] n) 
goal: p.Coprime (n / p ^ n.factorization p)

full_name: Nat.factorization_ord_compl
code: theorem factorization_ord_compl (n p : ℕ) :
    (ord_compl[p] n).factorization = n.factorization.erase p 
goal: (n / p ^ n.factorization p).factorization = Finsupp.erase p n.factorization

full_name: Nat.dvd_ord_compl_of_dvd_not_dvd
code: theorem dvd_ord_compl_of_dvd_not_dvd {p d n : ℕ} (hdn : d ∣ n) (hpd : ¬p ∣ d) :
    d ∣ ord_compl[p] n 
goal: d ∣ n / p ^ n.factorization p

full_name: Nat.exists_eq_pow_mul_and_not_dvd
code: /-- If `n` is a nonzero natural number and `p ≠ 1`, then there are natural numbers `e`
and `n'` such that `n'` is not divisible by `p` and `n = p^e * n'`. -/
theorem exists_eq_pow_mul_and_not_dvd {n : ℕ} (hn : n ≠ 0) (p : ℕ) (hp : p ≠ 1) :
    ∃ e n' : ℕ, ¬p ∣ n' ∧ n = p ^ e * n' 
goal: ∃ e n', ¬p ∣ n' ∧ n = p ^ e * n'

full_name: Nat.exists_eq_two_pow_mul_odd
code: /-- Any nonzero natural number is the product of an odd part `m` and a power of
two `2 ^ k`. -/
theorem exists_eq_two_pow_mul_odd {n : ℕ} (hn : n ≠ 0) :
    ∃ k m : ℕ, Odd m ∧ n = 2 ^ k * m 
goal: ∃ k m, Odd m ∧ n = 2 ^ k * m

full_name: Nat.dvd_iff_div_factorization_eq_tsub
code: theorem dvd_iff_div_factorization_eq_tsub {d n : ℕ} (hd : d ≠ 0) (hdn : d ≤ n) :
    d ∣ n ↔ (n / d).factorization = n.factorization - d.factorization 
goal: d ∣ n ↔ (n / d).factorization = n.factorization - d.factorization

full_name: Nat.ord_proj_dvd_ord_proj_of_dvd
code: theorem ord_proj_dvd_ord_proj_of_dvd {a b : ℕ} (hb0 : b ≠ 0) (hab : a ∣ b) (p : ℕ) :
    ord_proj[p] a ∣ ord_proj[p] b 
goal: p ^ a.factorization p ∣ p ^ b.factorization p

full_name: Nat.ord_proj_dvd_ord_proj_iff_dvd
code: theorem ord_proj_dvd_ord_proj_iff_dvd {a b : ℕ} (ha0 : a ≠ 0) (hb0 : b ≠ 0) :
    (∀ p : ℕ, ord_proj[p] a ∣ ord_proj[p] b) ↔ a ∣ b 
goal: (∀ (p : ℕ), p ^ a.factorization p ∣ p ^ b.factorization p) ↔ a ∣ b

full_name: Nat.ord_compl_dvd_ord_compl_of_dvd
code: theorem ord_compl_dvd_ord_compl_of_dvd {a b : ℕ} (hab : a ∣ b) (p : ℕ) :
    ord_compl[p] a ∣ ord_compl[p] b 
goal: a / p ^ a.factorization p ∣ b / p ^ b.factorization p

full_name: Nat.ord_compl_dvd_ord_compl_iff_dvd
code: theorem ord_compl_dvd_ord_compl_iff_dvd (a b : ℕ) :
    (∀ p : ℕ, ord_compl[p] a ∣ ord_compl[p] b) ↔ a ∣ b 
goal: (∀ (p : ℕ), a / p ^ a.factorization p ∣ b / p ^ b.factorization p) ↔ a ∣ b

full_name: Nat.dvd_iff_prime_pow_dvd_dvd
code: theorem dvd_iff_prime_pow_dvd_dvd (n d : ℕ) :
    d ∣ n ↔ ∀ p k : ℕ, Prime p → p ^ k ∣ d → p ^ k ∣ n 
goal: d ∣ n ↔ ∀ (p k : ℕ), Nat.Prime p → p ^ k ∣ d → p ^ k ∣ n

full_name: Nat.prod_primeFactors_dvd
code: theorem prod_primeFactors_dvd (n : ℕ) : ∏ p ∈ n.primeFactors, p ∣ n 
goal: ∏ p ∈ n.primeFactors, p ∣ n

full_name: Nat.factorization_gcd
code: theorem factorization_gcd {a b : ℕ} (ha_pos : a ≠ 0) (hb_pos : b ≠ 0) :
    (gcd a b).factorization = a.factorization ⊓ b.factorization 
goal: (a.gcd b).factorization = a.factorization ⊓ b.factorization

full_name: Nat.factorization_lcm
code: theorem factorization_lcm {a b : ℕ} (ha : a ≠ 0) (hb : b ≠ 0) :
    (a.lcm b).factorization = a.factorization ⊔ b.factorization 
goal: (a.lcm b).factorization = a.factorization ⊔ b.factorization

full_name: Nat.factorizationLCMLeft_zero_left
code: @[simp]
lemma factorizationLCMLeft_zero_left : factorizationLCMLeft 0 b = 1 
goal: Nat.factorizationLCMLeft 0 b = 1

full_name: Nat.factorizationLCMLeft_zero_right
code: @[simp]
lemma factorizationLCMLeft_zero_right : factorizationLCMLeft a 0 = 1 
goal: a.factorizationLCMLeft 0 = 1

full_name: Nat.factorizationLCRight_zero_left
code: @[simp]
lemma factorizationLCRight_zero_left : factorizationLCMRight 0 b = 1 
goal: Nat.factorizationLCMRight 0 b = 1

full_name: Nat.factorizationLCMRight_zero_right
code: @[simp]
lemma factorizationLCMRight_zero_right : factorizationLCMRight a 0 = 1 
goal: a.factorizationLCMRight 0 = 1

full_name: Nat.factorizationLCMLeft_pos
code: lemma factorizationLCMLeft_pos :
    0 < factorizationLCMLeft a b 
goal: 0 < a.factorizationLCMLeft b

full_name: Nat.factorizationLCMRight_pos
code: lemma factorizationLCMRight_pos :
    0 < factorizationLCMRight a b 
goal: 0 < a.factorizationLCMRight b

full_name: Nat.coprime_factorizationLCMLeft_factorizationLCMRight
code: lemma coprime_factorizationLCMLeft_factorizationLCMRight :
    (factorizationLCMLeft a b).Coprime (factorizationLCMRight a b) 
goal: (a.factorizationLCMLeft b).Coprime (a.factorizationLCMRight b)

full_name: Nat.factorizationLCMLeft_mul_factorizationLCMRight
code: lemma factorizationLCMLeft_mul_factorizationLCMRight (ha : a ≠ 0) (hb : b ≠ 0) :
    (factorizationLCMLeft a b) * (factorizationLCMRight a b) = lcm a b 
goal: a.factorizationLCMLeft b * a.factorizationLCMRight b = a.lcm b

full_name: Nat.factorizationLCMLeft_dvd_left
code: lemma factorizationLCMLeft_dvd_left : factorizationLCMLeft a b ∣ a 
goal: a.factorizationLCMLeft b ∣ a

full_name: Nat.factorizationLCMRight_dvd_right
code: lemma factorizationLCMRight_dvd_right : factorizationLCMRight a b ∣ b 
goal: a.factorizationLCMRight b ∣ b

full_name: Nat.prod_primeFactors_gcd_mul_prod_primeFactors_mul
code: @[to_additive sum_primeFactors_gcd_add_sum_primeFactors_mul]
theorem prod_primeFactors_gcd_mul_prod_primeFactors_mul {β : Type*} [CommMonoid β] (m n : ℕ)
    (f : ℕ → β) :
    (m.gcd n).primeFactors.prod f * (m * n).primeFactors.prod f =
      m.primeFactors.prod f * n.primeFactors.prod f 
goal: (m.gcd n).primeFactors.prod f * (m * n).primeFactors.prod f = m.primeFactors.prod f * n.primeFactors.prod f

full_name: Nat.sum_primeFactors_gcd_add_sum_primeFactors_mul
code: @[to_additive sum_primeFactors_gcd_add_sum_primeFactors_mul]
theorem prod_primeFactors_gcd_mul_prod_primeFactors_mul {β : Type*} [CommMonoid β] (m n : ℕ)
    (f : ℕ → β) :
    (m.gcd n).primeFactors.prod f * (m * n).primeFactors.prod f =
      m.primeFactors.prod f * n.primeFactors.prod f 
goal: (m.gcd n).primeFactors.sum f + (m * n).primeFactors.sum f = m.primeFactors.sum f + n.primeFactors.sum f

full_name: Nat.setOf_pow_dvd_eq_Icc_factorization
code: theorem setOf_pow_dvd_eq_Icc_factorization {n p : ℕ} (pp : p.Prime) (hn : n ≠ 0) :
    { i : ℕ | i ≠ 0 ∧ p ^ i ∣ n } = Set.Icc 1 (n.factorization p) 
goal: {i | i ≠ 0 ∧ p ^ i ∣ n} = Set.Icc 1 (n.factorization p)

full_name: Nat.Icc_factorization_eq_pow_dvd
code: /-- The set of positive powers of prime `p` that divide `n` is exactly the set of
positive natural numbers up to `n.factorization p`. -/
theorem Icc_factorization_eq_pow_dvd (n : ℕ) {p : ℕ} (pp : Prime p) :
    Icc 1 (n.factorization p) = (Ico 1 n).filter fun i : ℕ => p ^ i ∣ n 
goal: Finset.Icc 1 (n.factorization p) = Finset.filter (fun i => p ^ i ∣ n) (Finset.Ico 1 n)

full_name: Nat.factorization_eq_card_pow_dvd
code: theorem factorization_eq_card_pow_dvd (n : ℕ) {p : ℕ} (pp : p.Prime) :
    n.factorization p = ((Ico 1 n).filter fun i => p ^ i ∣ n).card 
goal: n.factorization p = (Finset.filter (fun i => p ^ i ∣ n) (Finset.Ico 1 n)).card

full_name: Nat.Ico_filter_pow_dvd_eq
code: theorem Ico_filter_pow_dvd_eq {n p b : ℕ} (pp : p.Prime) (hn : n ≠ 0) (hb : n ≤ p ^ b) :
    ((Ico 1 n).filter fun i => p ^ i ∣ n) = (Icc 1 b).filter fun i => p ^ i ∣ n 
goal: Finset.filter (fun i => p ^ i ∣ n) (Finset.Ico 1 n) = Finset.filter (fun i => p ^ i ∣ n) (Finset.Icc 1 b)

full_name: Nat.factorization_eq_of_coprime_left
code: /-- If `p` is a prime factor of `a` then the power of `p` in `a` is the same that in `a * b`,
for any `b` coprime to `a`. -/
theorem factorization_eq_of_coprime_left {p a b : ℕ} (hab : Coprime a b)
    (hpa : p ∈ a.primeFactorsList) : (a * b).factorization p = a.factorization p 
goal: (a * b).factorization p = a.factorization p

full_name: Nat.factorization_eq_of_coprime_right
code: /-- If `p` is a prime factor of `b` then the power of `p` in `b` is the same that in `a * b`,
for any `a` coprime to `b`. -/
theorem factorization_eq_of_coprime_right {p a b : ℕ} (hab : Coprime a b)
    (hpb : p ∈ b.primeFactorsList) : (a * b).factorization p = b.factorization p 
goal: (a * b).factorization p = b.factorization p

full_name: Nat.eq_iff_prime_padicValNat_eq
code: /-- Two positive naturals are equal if their prime padic valuations are equal -/
theorem eq_iff_prime_padicValNat_eq (a b : ℕ) (ha : a ≠ 0) (hb : b ≠ 0) :
    a = b ↔ ∀ p : ℕ, p.Prime → padicValNat p a = padicValNat p b 
goal: a = b ↔ ∀ (p : ℕ), Nat.Prime p → padicValNat p a = padicValNat p b

full_name: Nat.prod_pow_prime_padicValNat
code: theorem prod_pow_prime_padicValNat (n : Nat) (hn : n ≠ 0) (m : Nat) (pr : n < m) :
    (∏ p ∈ Finset.filter Nat.Prime (Finset.range m), p ^ padicValNat p n) = n 
goal: ∏ p ∈ Finset.filter Nat.Prime (Finset.range m), p ^ padicValNat p n = n

full_name: Nat.card_multiples
code: /-- Exactly `n / p` naturals in `[1, n]` are multiples of `p`.
See `Nat.card_multiples'` for an alternative spelling of the statement.  -/
theorem card_multiples (n p : ℕ) : card ((Finset.range n).filter fun e => p ∣ e + 1) = n / p 
goal: (Finset.filter (fun e => p ∣ e + 1) (Finset.range n)).card = n / p

full_name: Nat.Ioc_filter_dvd_card_eq_div
code: /-- Exactly `n / p` naturals in `(0, n]` are multiples of `p`. -/
theorem Ioc_filter_dvd_card_eq_div (n p : ℕ) : ((Ioc 0 n).filter fun x => p ∣ x).card = n / p 
goal: (Finset.filter (fun x => p ∣ x) (Finset.Ioc 0 n)).card = n / p

full_name: Nat.card_multiples'
code: /-- There are exactly `⌊N/n⌋` positive multiples of `n` that are `≤ N`.
See `Nat.card_multiples` for a "shifted-by-one" version. -/
lemma card_multiples' (N n : ℕ) :
    ((Finset.range N.succ).filter (fun k ↦ k ≠ 0 ∧ n ∣ k)).card = N / n 
goal: (Finset.filter (fun k => k ≠ 0 ∧ n ∣ k) (Finset.range N.succ)).card = N / n