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

full_name: Nat.factorization
code: /-- `n.factorization` is the finitely supported function `ℕ →₀ ℕ`
 mapping each prime factor of `n` to its multiplicity in `n`. -/
def factorization (n : ℕ) : ℕ →₀ ℕ 
goal: ℕ →₀ ℕ

full_name: Nat.support_factorization
code: /-- The support of `n.factorization` is exactly `n.primeFactors`. -/
@[simp] lemma support_factorization (n : ℕ) : (factorization n).support = n.primeFactors 
goal: n.factorization.support = n.primeFactors

full_name: Nat.factorization_def
code: theorem factorization_def (n : ℕ) {p : ℕ} (pp : p.Prime) : n.factorization p = padicValNat p n 
goal: n.factorization p = padicValNat p n

full_name: Nat.primeFactorsList_count_eq
code: /-- We can write both `n.factorization p` and `n.factors.count p` to represent the power
of `p` in the factorization of `n`: we declare the former to be the simp-normal form. -/
@[simp]
theorem primeFactorsList_count_eq {n p : ℕ} : n.primeFactorsList.count p = n.factorization p 
goal: List.count p n.primeFactorsList = n.factorization p

full_name: Nat.factorization_eq_primeFactorsList_multiset
code: theorem factorization_eq_primeFactorsList_multiset (n : ℕ) :
    n.factorization = Multiset.toFinsupp (n.primeFactorsList : Multiset ℕ) 
goal: n.factorization = Multiset.toFinsupp ↑n.primeFactorsList

full_name: Nat.Prime.factorization_pos_of_dvd
code: theorem Prime.factorization_pos_of_dvd {n p : ℕ} (hp : p.Prime) (hn : n ≠ 0) (h : p ∣ n) :
    0 < n.factorization p 
goal: 0 < n.factorization p

full_name: Nat.multiplicity_eq_factorization
code: theorem multiplicity_eq_factorization {n p : ℕ} (pp : p.Prime) (hn : n ≠ 0) :
    multiplicity p n = n.factorization p 
goal: multiplicity p n = ↑(n.factorization p)

full_name: Nat.factorization_prod_pow_eq_self
code: @[simp]
theorem factorization_prod_pow_eq_self {n : ℕ} (hn : n ≠ 0) : n.factorization.prod (· ^ ·) = n 
goal: (n.factorization.prod fun x x_1 => x ^ x_1) = n

full_name: Nat.eq_of_factorization_eq
code: theorem eq_of_factorization_eq {a b : ℕ} (ha : a ≠ 0) (hb : b ≠ 0)
    (h : ∀ p : ℕ, a.factorization p = b.factorization p) : a = b 
goal: a = b

full_name: Nat.factorization_inj
code: /-- Every nonzero natural number has a unique prime factorization -/
theorem factorization_inj : Set.InjOn factorization { x : ℕ | x ≠ 0 } 
goal: Set.InjOn Nat.factorization {x | x ≠ 0}

full_name: Nat.factorization_zero
code: @[simp]
theorem factorization_zero : factorization 0 = 0 
goal: Nat.factorization 0 = 0

full_name: Nat.factorization_one
code: @[simp]
theorem factorization_one : factorization 1 = 0 
goal: Nat.factorization 1 = 0

full_name: Nat.factorization_eq_zero_iff
code: theorem factorization_eq_zero_iff (n p : ℕ) :
    n.factorization p = 0 ↔ ¬p.Prime ∨ ¬p ∣ n ∨ n = 0 
goal: n.factorization p = 0 ↔ ¬Nat.Prime p ∨ ¬p ∣ n ∨ n = 0

full_name: Nat.factorization_eq_zero_of_non_prime
code: @[simp]
theorem factorization_eq_zero_of_non_prime (n : ℕ) {p : ℕ} (hp : ¬p.Prime) :
    n.factorization p = 0 
goal: n.factorization p = 0

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

full_name: Nat.factorization_eq_zero_of_not_dvd
code: theorem factorization_eq_zero_of_not_dvd {n p : ℕ} (h : ¬p ∣ n) : n.factorization p = 0 
goal: n.factorization p = 0

full_name: Nat.factorization_eq_zero_of_remainder
code: theorem factorization_eq_zero_of_remainder {p r : ℕ} (i : ℕ) (hr : ¬p ∣ r) :
    (p * i + r).factorization p = 0 
goal: (p * i + r).factorization p = 0

full_name: Nat.factorization_mul
code: /-- For nonzero `a` and `b`, the power of `p` in `a * b` is the sum of the powers in `a` and `b` -/
@[simp]
theorem factorization_mul {a b : ℕ} (ha : a ≠ 0) (hb : b ≠ 0) :
    (a * b).factorization = a.factorization + b.factorization 
goal: (a * b).factorization = a.factorization + b.factorization

full_name: Nat.factorization_le_iff_dvd
code: theorem factorization_le_iff_dvd {d n : ℕ} (hd : d ≠ 0) (hn : n ≠ 0) :
    d.factorization ≤ n.factorization ↔ d ∣ n 
goal: d.factorization ≤ n.factorization ↔ d ∣ n

full_name: Nat.factorization_prod
code: /-- For any `p : ℕ` and any function `g : α → ℕ` that's non-zero on `S : Finset α`,
the power of `p` in `S.prod g` equals the sum over `x ∈ S` of the powers of `p` in `g x`.
Generalises `factorization_mul`, which is the special case where `S.card = 2` and `g = id`. -/
theorem factorization_prod {α : Type*} {S : Finset α} {g : α → ℕ} (hS : ∀ x ∈ S, g x ≠ 0) :
    (S.prod g).factorization = S.sum fun x => (g x).factorization 
goal: (S.prod g).factorization = ∑ x ∈ S, (g x).factorization

full_name: Nat.factorization_pow
code: /-- For any `p`, the power of `p` in `n^k` is `k` times the power in `n` -/
@[simp]
theorem factorization_pow (n k : ℕ) : factorization (n ^ k) = k • n.factorization 
goal: (n ^ k).factorization = k • n.factorization

full_name: Nat.Prime.factorization
code: /-- The only prime factor of prime `p` is `p` itself, with multiplicity `1` -/
@[simp]
protected theorem Prime.factorization {p : ℕ} (hp : Prime p) : p.factorization = single p 1 
goal: p.factorization = Finsupp.single p 1

full_name: Nat.Prime.factorization_pow
code: /-- For prime `p` the only prime factor of `p^k` is `p` with multiplicity `k` -/
theorem Prime.factorization_pow {p k : ℕ} (hp : Prime p) : (p ^ k).factorization = single p k 
goal: (p ^ k).factorization = Finsupp.single p k

full_name: Nat.pow_succ_factorization_not_dvd
code: theorem pow_succ_factorization_not_dvd {n p : ℕ} (hn : n ≠ 0) (hp : p.Prime) :
    ¬p ^ (n.factorization p + 1) ∣ n 
goal: ¬p ^ (n.factorization p + 1) ∣ n

full_name: Nat.prod_pow_factorization_eq_self
code: /-- Any Finsupp `f : ℕ →₀ ℕ` whose support is in the primes is equal to the factorization of
the product `∏ (a : ℕ) ∈ f.support, a ^ f a`. -/
theorem prod_pow_factorization_eq_self {f : ℕ →₀ ℕ} (hf : ∀ p : ℕ, p ∈ f.support → Prime p) :
    (f.prod (· ^ ·)).factorization = f 
goal: (f.prod fun x x_1 => x ^ x_1).factorization = f

full_name: Nat.factorizationEquiv
code: /-- The equiv between `ℕ+` and `ℕ →₀ ℕ` with support in the primes. -/
def factorizationEquiv : ℕ+ ≃ { f : ℕ →₀ ℕ | ∀ p ∈ f.support, Prime p } 
goal: ℕ+ ≃ ↑{f | ∀ p ∈ f.support, Nat.Prime p}

full_name: Nat.factorization_mul_apply_of_coprime
code: /-- For coprime `a` and `b`, the power of `p` in `a * b` is the sum of the powers in `a` and `b` -/
theorem factorization_mul_apply_of_coprime {p a b : ℕ} (hab : Coprime a b) :
    (a * b).factorization p = a.factorization p + b.factorization p 
goal: (a * b).factorization p = a.factorization p + b.factorization p

full_name: Nat.factorization_mul_of_coprime
code: /-- For coprime `a` and `b`, the power of `p` in `a * b` is the sum of the powers in `a` and `b` -/
theorem factorization_mul_of_coprime {a b : ℕ} (hab : Coprime a b) :
    (a * b).factorization = a.factorization + b.factorization 
goal: (a * b).factorization = a.factorization + b.factorization

full_name: Nat.«_aux_Mathlib_Data_Nat_Factorization_Defs___macroRules_Nat_termOrd_proj[_]__1»
code: notation "ord_proj[" p "] " n:arg => p ^ Nat.factorization n p
goal: Lean.Macro

full_name: Nat.«_aux_Mathlib_Data_Nat_Factorization_Defs___macroRules_Nat_termOrd_compl[_]__1»
code: notation "ord_compl[" p "] " n:arg => n / ord_proj[p] n
goal: Lean.Macro

full_name: Nat.ord_proj_dvd
code: theorem ord_proj_dvd (n p : ℕ) : ord_proj[p] n ∣ n 
goal: p ^ n.factorization p ∣ n

full_name: Nat.factorizationLCMLeft
code: /-- If `a = ∏ pᵢ ^ nᵢ` and `b = ∏ pᵢ ^ mᵢ`, then `factorizationLCMLeft = ∏ pᵢ ^ kᵢ`, where
`kᵢ = nᵢ` if `mᵢ ≤ nᵢ` and `0` otherwise. Note that the product is over the divisors of `lcm a b`,
so if one of `a` or `b` is `0` then the result is `1`. -/
def factorizationLCMLeft (a b : ℕ) : ℕ 
goal: ℕ

full_name: Nat.factorizationLCMRight
code: /-- If `a = ∏ pᵢ ^ nᵢ` and `b = ∏ pᵢ ^ mᵢ`, then `factorizationLCMRight = ∏ pᵢ ^ kᵢ`, where
`kᵢ = mᵢ` if `nᵢ < mᵢ` and `0` otherwise. Note that the product is over the divisors of `lcm a b`,
so if one of `a` or `b` is `0` then the result is `1`.

Note that `factorizationLCMRight a b` is *not* `factorizationLCMLeft b a`: the difference is
that in `factorizationLCMLeft a b` there are the primes whose exponent in `a` is bigger or equal
than the exponent in `b`, while in `factorizationLCMRight a b` there are the primes whose
exponent in `b` is strictly bigger than in `a`. For example `factorizationLCMLeft 2 2 = 2`, but
`factorizationLCMRight 2 2 = 1`. -/
def factorizationLCMRight (a b : ℕ) 
goal: ℕ