l3lab/ntp-mathlib huggingface dataset:
@[simp]
theorem factorization_one : factorization 1 = 0 := by 

Proof state:
a b m n p : ℕ
⊢ factorization 1 = 0

Next tactic:
decide
theorem factorization_eq_zero_iff (n p : ℕ) :
    n.factorization p = 0 ↔ ¬p.Prime ∨ ¬p ∣ n ∨ n = 0 := by
  

Proof state:
a b m n✝ p✝ n p : ℕ
⊢ (factorization n) p = 0 ↔ ¬Prime p ∨ ¬p ∣ n ∨ n = 0

Next tactic:
simp_rw [← not_mem_support_iff, support_factorization, mem_primeFactors, not_and_or, not_ne_iff]
@[simp]
theorem factorization_eq_zero_of_non_prime (n : ℕ) {p : ℕ} (hp : ¬p.Prime) :
    n.factorization p = 0 := by 

Proof state:
a b m n✝ p✝ n p : ℕ
hp : ¬Prime p
⊢ (factorization n) p = 0

Next tactic:
simp [factorization_eq_zero_iff, hp]
theorem factorization_eq_zero_of_not_dvd {n p : ℕ} (h : ¬p ∣ n) : n.factorization p = 0 := by
  

Proof state:
a b m n✝ p✝ n p : ℕ
h : ¬p ∣ n
⊢ (factorization n) p = 0

Next tactic:
simp [factorization_eq_zero_iff, h]
theorem Prime.factorization_pos_of_dvd {n p : ℕ} (hp : p.Prime) (hn : n ≠ 0) (h : p ∣ n) :
    0 < n.factorization p := by
    

Proof state:
a b m n✝ p✝ n p : ℕ
hp : Prime p
hn : n ≠ 0
h : p ∣ n
⊢ 0 < (factorization n) p

Next tactic:
rwa [← factors_count_eq, count_pos_iff_mem, mem_factors_iff_dvd hn hp]
theorem factorization_eq_zero_of_remainder {p r : ℕ} (i : ℕ) (hr : ¬p ∣ r) :
    (p * i + r).factorization p = 0 := by
  

Proof state:
a b m n p✝ p r i : ℕ
hr : ¬p ∣ r
⊢ (factorization (p * i + r)) p = 0

Next tactic:
apply factorization_eq_zero_of_not_dvd
theorem factorization_eq_zero_of_remainder {p r : ℕ} (i : ℕ) (hr : ¬p ∣ r) :
    (p * i + r).factorization p = 0 := by
  apply factorization_eq_zero_of_not_dvd
  

Proof state:
case h
a b m n p✝ p r i : ℕ
hr : ¬p ∣ r
⊢ ¬p ∣ p * i + r

Next tactic:
rwa [← Nat.dvd_add_iff_right (Dvd.intro i rfl)]
theorem factorization_eq_zero_iff_remainder {p r : ℕ} (i : ℕ) (pp : p.Prime) (hr0 : r ≠ 0) :
    ¬p ∣ r ↔ (p * i + r).factorization p = 0 := by
  

Proof state:
a b m n p✝ p r i : ℕ
pp : Prime p
hr0 : r ≠ 0
⊢ ¬p ∣ r ↔ (factorization (p * i + r)) p = 0

Next tactic:
refine' ⟨factorization_eq_zero_of_remainder i, fun h => _⟩
theorem factorization_eq_zero_iff_remainder {p r : ℕ} (i : ℕ) (pp : p.Prime) (hr0 : r ≠ 0) :
    ¬p ∣ r ↔ (p * i + r).factorization p = 0 := by
  refine' ⟨factorization_eq_zero_of_remainder i, fun h => _⟩
  

Proof state:
a b m n p✝ p r i : ℕ
pp : Prime p
hr0 : r ≠ 0
h : (factorization (p * i + r)) p = 0
⊢ ¬p ∣ r

Next tactic:
rw [factorization_eq_zero_iff] at h
theorem factorization_eq_zero_iff_remainder {p r : ℕ} (i : ℕ) (pp : p.Prime) (hr0 : r ≠ 0) :
    ¬p ∣ r ↔ (p * i + r).factorization p = 0 := by
  refine' ⟨factorization_eq_zero_of_remainder i, fun h => _⟩
  rw [factorization_eq_zero_iff] at h
  

Proof state:
a b m n p✝ p r i : ℕ
pp : Prime p
hr0 : r ≠ 0
h : ¬Prime p ∨ ¬p ∣ p * i + r ∨ p * i + r = 0
⊢ ¬p ∣ r

Next tactic:
contrapose! h
theorem factorization_eq_zero_iff_remainder {p r : ℕ} (i : ℕ) (pp : p.Prime) (hr0 : r ≠ 0) :
    ¬p ∣ r ↔ (p * i + r).factorization p = 0 := by
  refine' ⟨factorization_eq_zero_of_remainder i, fun h => _⟩
  rw [factorization_eq_zero_iff] at h
  contrapose! h
  

Proof state:
a b m n p✝ p r i : ℕ
pp : Prime p
hr0 : r ≠ 0
h : p ∣ r
⊢ Prime p ∧ p ∣ p * i + r ∧ p * i + r ≠ 0

Next tactic:
refine' ⟨pp, _, _⟩
theorem factorization_eq_zero_iff_remainder {p r : ℕ} (i : ℕ) (pp : p.Prime) (hr0 : r ≠ 0) :
    ¬p ∣ r ↔ (p * i + r).factorization p = 0 := by
  refine' ⟨factorization_eq_zero_of_remainder i, fun h => _⟩
  rw [factorization_eq_zero_iff] at h
  contrapose! h
  refine' ⟨pp, _, _⟩
  · 

Proof state:
case refine'_1
a b m n p✝ p r i : ℕ
pp : Prime p
hr0 : r ≠ 0
h : p ∣ r
⊢ p ∣ p * i + r

Next tactic:
rwa [← Nat.dvd_add_iff_right (dvd_mul_right p i)]
theorem factorization_eq_zero_iff_remainder {p r : ℕ} (i : ℕ) (pp : p.Prime) (hr0 : r ≠ 0) :
    ¬p ∣ r ↔ (p * i + r).factorization p = 0 := by
  refine' ⟨factorization_eq_zero_of_remainder i, fun h => _⟩
  rw [factorization_eq_zero_iff] at h
  contrapose! h
  refine' ⟨pp, _, _⟩
  · rwa [← Nat.dvd_add_iff_right (dvd_mul_right p i)]
  · 

Proof state:
case refine'_2
a b m n p✝ p r i : ℕ
pp : Prime p
hr0 : r ≠ 0
h : p ∣ r
⊢ p * i + r ≠ 0

Next tactic:
contrapose! hr0
theorem factorization_eq_zero_iff_remainder {p r : ℕ} (i : ℕ) (pp : p.Prime) (hr0 : r ≠ 0) :
    ¬p ∣ r ↔ (p * i + r).factorization p = 0 := by
  refine' ⟨factorization_eq_zero_of_remainder i, fun h => _⟩
  rw [factorization_eq_zero_iff] at h
  contrapose! h
  refine' ⟨pp, _, _⟩
  · rwa [← Nat.dvd_add_iff_right (dvd_mul_right p i)]
  · contrapose! hr0
    

Proof state:
case refine'_2
a b m n p✝ p r i : ℕ
pp : Prime p
h : p ∣ r
hr0 : p * i + r = 0
⊢ r = 0

Next tactic:
exact (add_eq_zero_iff.mp hr0).2
/-- The only numbers with empty prime factorization are `0` and `1` -/
theorem factorization_eq_zero_iff' (n : ℕ) : n.factorization = 0 ↔ n = 0 ∨ n = 1 := by
  

Proof state:
a b m n✝ p n : ℕ
⊢ factorization n = 0 ↔ n = 0 ∨ n = 1

Next tactic:
rw [factorization_eq_factors_multiset n]
/-- The only numbers with empty prime factorization are `0` and `1` -/
theorem factorization_eq_zero_iff' (n : ℕ) : n.factorization = 0 ↔ n = 0 ∨ n = 1 := by
  rw [factorization_eq_factors_multiset n]
  

Proof state:
a b m n✝ p n : ℕ
⊢ Multiset.toFinsupp ↑(factors n) = 0 ↔ n = 0 ∨ n = 1

Next tactic:
simp [factorization, AddEquiv.map_eq_zero_iff, Multiset.coe_eq_zero]
/-- 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 := by
  

Proof state:
a✝ b✝ m n p a b : ℕ
ha : a ≠ 0
hb : b ≠ 0
⊢ factorization (a * b) = factorization a + factorization b

Next tactic:
ext p
/-- 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 := by
  ext p
  

Proof state:
case h
a✝ b✝ m n p✝ a b : ℕ
ha : a ≠ 0
hb : b ≠ 0
p : ℕ
⊢ (factorization (a * b)) p = (factorization a + factorization b) p

Next tactic:
simp only [add_apply, ← factors_count_eq, perm_iff_count.mp (perm_factors_mul ha hb) p,
    count_append]
/-- 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 := by
  

Proof state:
a b m n p : ℕ
α : Type u_1
S : Finset α
g : α → ℕ
hS : ∀ x ∈ S, g x ≠ 0
⊢ factorization (Finset.prod S g) = ∑ x in S, factorization (g x)

Next tactic:
classical
    ext p
    refine' Finset.induction_on' S ?_ ?_
    · simp
    · intro x T hxS hTS hxT IH
      have hT : T.prod g ≠ 0 := prod_ne_zero_iff.mpr fun x hx => hS x (hTS hx)
      simp [prod_insert hxT, sum_insert hxT, ← IH, factorization_mul (hS x hxS) hT]
/-- 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 := by
  classical
    

Proof state:
a b m n p : ℕ
α : Type u_1
S : Finset α
g : α → ℕ
hS : ∀ x ∈ S, g x ≠ 0
⊢ factorization (Finset.prod S g) = ∑ x in S, factorization (g x)

Next tactic:
ext p
/-- 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 := by
  classical
    ext p
    

Proof state:
case h
a b m n p✝ : ℕ
α : Type u_1
S : Finset α
g : α → ℕ
hS : ∀ x ∈ S, g x ≠ 0
p : ℕ
⊢ (factorization (Finset.prod S g)) p = (∑ x in S, factorization (g x)) p

Next tactic:
refine' Finset.induction_on' S ?_ ?_
/-- 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 := by
  classical
    ext p
    refine' Finset.induction_on' S ?_ ?_
    · 

Proof state:
case h.refine'_1
a b m n p✝ : ℕ
α : Type u_1
S : Finset α
g : α → ℕ
hS : ∀ x ∈ S, g x ≠ 0
p : ℕ
⊢ (factorization (Finset.prod ∅ g)) p = (∑ x in ∅, factorization (g x)) p

Next tactic:
simp
/-- 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 := by
  classical
    ext p
    refine' Finset.induction_on' S ?_ ?_
    · simp
    · 

Proof state:
case h.refine'_2
a b m n p✝ : ℕ
α : Type u_1
S : Finset α
g : α → ℕ
hS : ∀ x ∈ S, g x ≠ 0
p : ℕ
⊢ ∀ {a : α} {s : Finset α},
    a ∈ S →
      s ⊆ S →
        a ∉ s →
          (factorization (Finset.prod s g)) p = (∑ x in s, factorization (g x)) p →
            (factorization (Finset.prod (insert a s) g)) p = (∑ x in insert a s, factorization (g x)) p

Next tactic:
intro x T hxS hTS hxT IH
/-- 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 := by
  classical
    ext p
    refine' Finset.induction_on' S ?_ ?_
    · simp
    · intro x T hxS hTS hxT IH
      

Proof state:
case h.refine'_2
a b m n p✝ : ℕ
α : Type u_1
S : Finset α
g : α → ℕ
hS : ∀ x ∈ S, g x ≠ 0
p : ℕ
x : α
T : Finset α
hxS : x ∈ S
hTS : T ⊆ S
hxT : x ∉ T
IH : (factorization (Finset.prod T g)) p = (∑ x in T, factorization (g x)) p
⊢ (factorization (Finset.prod (insert x T) g)) p = (∑ x in insert x T, factorization (g x)) p

Next tactic:
have hT : T.prod g ≠ 0 := prod_ne_zero_iff.mpr fun x hx => hS x (hTS hx)
/-- 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 := by
  classical
    ext p
    refine' Finset.induction_on' S ?_ ?_
    · simp
    · intro x T hxS hTS hxT IH
      have hT : T.prod g ≠ 0 := prod_ne_zero_iff.mpr fun x hx => hS x (hTS hx)
      

Proof state:
case h.refine'_2
a b m n p✝ : ℕ
α : Type u_1
S : Finset α
g : α → ℕ
hS : ∀ x ∈ S, g x ≠ 0
p : ℕ
x : α
T : Finset α
hxS : x ∈ S
hTS : T ⊆ S
hxT : x ∉ T
IH : (factorization (Finset.prod T g)) p = (∑ x in T, factorization (g x)) p
hT : Finset.prod T g ≠ 0
⊢ (factorization (Finset.prod (insert x T) g)) p = (∑ x in insert x T, factorization (g x)) p

Next tactic:
simp [prod_insert hxT, sum_insert hxT, ← IH, factorization_mul (hS x hxS) hT]
/-- 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 := by
  

Proof state:
a b m n✝ p n k : ℕ
⊢ factorization (n ^ k) = k • factorization n

Next tactic:
induction' k with k ih
/-- 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 := by
  induction' k with k ih; · 

Proof state:
case zero
a b m n✝ p n : ℕ
⊢ factorization (n ^ zero) = zero • factorization n

Next tactic:
simp
/-- 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 := by
  induction' k with k ih; · simp
  

Proof state:
case succ
a b m n✝ p n k : ℕ
ih : factorization (n ^ k) = k • factorization n
⊢ factorization (n ^ succ k) = succ k • factorization n

Next tactic:
rcases eq_or_ne n 0 with (rfl | hn)
/-- 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 := by
  induction' k with k ih; · simp
  rcases eq_or_ne n 0 with (rfl | hn)
  · 

Proof state:
case succ.inl
a b m n p k : ℕ
ih : factorization (0 ^ k) = k • factorization 0
⊢ factorization (0 ^ succ k) = succ k • factorization 0

Next tactic:
simp
/-- 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 := by
  induction' k with k ih; · simp
  rcases eq_or_ne n 0 with (rfl | hn)
  · simp
  

Proof state:
case succ.inr
a b m n✝ p n k : ℕ
ih : factorization (n ^ k) = k • factorization n
hn : n ≠ 0
⊢ factorization (n ^ succ k) = succ k • factorization n

Next tactic:
rw [pow_succ, mul_comm, factorization_mul hn (pow_ne_zero _ hn), ih, succ_eq_one_add, add_smul,
   one_smul]
/-- The only prime factor of prime `p` is `p` itself, with multiplicity `1` -/
@[simp]
theorem Prime.factorization {p : ℕ} (hp : Prime p) : p.factorization = single p 1 := by
  

Proof state:
a b m n p✝ p : ℕ
hp : Prime p
⊢ Nat.factorization p = fun₀ | p => 1

Next tactic:
ext q
/-- The only prime factor of prime `p` is `p` itself, with multiplicity `1` -/
@[simp]
theorem Prime.factorization {p : ℕ} (hp : Prime p) : p.factorization = single p 1 := by
  ext q
  

Proof state:
case h
a b m n p✝ p : ℕ
hp : Prime p
q : ℕ
⊢ (Nat.factorization p) q = (fun₀ | p => 1) q

Next tactic:
rw [← factors_count_eq, factors_prime hp, single_apply, count_singleton', if_congr eq_comm]
/-- The only prime factor of prime `p` is `p` itself, with multiplicity `1` -/
@[simp]
theorem Prime.factorization {p : ℕ} (hp : Prime p) : p.factorization = single p 1 := by
  ext q
  rw [← factors_count_eq, factors_prime hp, single_apply, count_singleton', if_congr eq_comm] <;>
    

Proof state:
case h.h_t
a b m n p✝ p : ℕ
hp : Prime p
q : ℕ
⊢ 1 = 1

Next tactic:
rfl
/-- The only prime factor of prime `p` is `p` itself, with multiplicity `1` -/
@[simp]
theorem Prime.factorization {p : ℕ} (hp : Prime p) : p.factorization = single p 1 := by
  ext q
  rw [← factors_count_eq, factors_prime hp, single_apply, count_singleton', if_congr eq_comm] <;>
    

Proof state:
case h.h_e
a b m n p✝ p : ℕ
hp : Prime p
q : ℕ
⊢ 0 = 0

Next tactic:
rfl
/-- The multiplicity of prime `p` in `p` is `1` -/
@[simp]
theorem Prime.factorization_self {p : ℕ} (hp : Prime p) : p.factorization p = 1 := by 

Proof state:
a b m n p✝ p : ℕ
hp : Prime p
⊢ (Nat.factorization p) p = 1

Next tactic:
simp [hp]
/-- 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 := by
  

Proof state:
a b m n p✝ p k : ℕ
hp : Prime p
⊢ Nat.factorization (p ^ k) = fun₀ | p => k

Next tactic:
simp [hp]
/-- 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 := by
  -- Porting note: explicitly added `Finsupp.prod_single_index`
  

Proof state:
a b m n✝ p✝ n p k : ℕ
hn : n ≠ 0
h : factorization n = fun₀ | p => k
⊢ n = p ^ k

Next tactic:
rw [← Nat.factorization_prod_pow_eq_self hn, h, Finsupp.prod_single_index]
/-- 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 := by
  -- Porting note: explicitly added `Finsupp.prod_single_index`
  rw [← Nat.factorization_prod_pow_eq_self hn, h, Finsupp.prod_single_index]
  

Proof state:
a b m n✝ p✝ n p k : ℕ
hn : n ≠ 0
h : factorization n = fun₀ | p => k
⊢ p ^ 0 = 1

Next tactic:
simp
/-- 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 := by 

Proof state:
a b m n p✝ p q : ℕ
hp : Prime p
h : (Nat.factorization p) q ≠ 0
⊢ p = q

Next tactic:
simpa [hp.factorization, single_apply] using h
/-- Any Finsupp `f : ℕ →₀ ℕ` whose support is in the primes is equal to the factorization of
the product `∏ (a : ℕ) in f.support, a ^ f a`. -/
theorem prod_pow_factorization_eq_self {f : ℕ →₀ ℕ} (hf : ∀ p : ℕ, p ∈ f.support → Prime p) :
    (f.prod (· ^ ·)).factorization = f := by
  

Proof state:
a b m n p : ℕ
f : ℕ →₀ ℕ
hf : ∀ p ∈ f.support, Prime p
⊢ factorization (Finsupp.prod f fun x x_1 => x ^ x_1) = f

Next tactic:
have h : ∀ x : ℕ, x ∈ f.support → x ^ f x ≠ 0 := fun p hp =>
    pow_ne_zero _ (Prime.ne_zero (hf p hp))
/-- Any Finsupp `f : ℕ →₀ ℕ` whose support is in the primes is equal to the factorization of
the product `∏ (a : ℕ) in f.support, a ^ f a`. -/
theorem prod_pow_factorization_eq_self {f : ℕ →₀ ℕ} (hf : ∀ p : ℕ, p ∈ f.support → Prime p) :
    (f.prod (· ^ ·)).factorization = f := by
  have h : ∀ x : ℕ, x ∈ f.support → x ^ f x ≠ 0 := fun p hp =>
    pow_ne_zero _ (Prime.ne_zero (hf p hp))
  

Proof state:
a b m n p : ℕ
f : ℕ →₀ ℕ
hf : ∀ p ∈ f.support, Prime p
h : ∀ x ∈ f.support, x ^ f x ≠ 0
⊢ factorization (Finsupp.prod f fun x x_1 => x ^ x_1) = f

Next tactic:
simp only [Finsupp.prod, factorization_prod h]
/-- Any Finsupp `f : ℕ →₀ ℕ` whose support is in the primes is equal to the factorization of
the product `∏ (a : ℕ) in f.support, a ^ f a`. -/
theorem prod_pow_factorization_eq_self {f : ℕ →₀ ℕ} (hf : ∀ p : ℕ, p ∈ f.support → Prime p) :
    (f.prod (· ^ ·)).factorization = f := by
  have h : ∀ x : ℕ, x ∈ f.support → x ^ f x ≠ 0 := fun p hp =>
    pow_ne_zero _ (Prime.ne_zero (hf p hp))
  simp only [Finsupp.prod, factorization_prod h]
  

Proof state:
a b m n p : ℕ
f : ℕ →₀ ℕ
hf : ∀ p ∈ f.support, Prime p
h : ∀ x ∈ f.support, x ^ f x ≠ 0
⊢ ∑ x in f.support, factorization (x ^ f x) = f

Next tactic:
conv =>
    rhs
    rw [(sum_single f).symm]
/-- Any Finsupp `f : ℕ →₀ ℕ` whose support is in the primes is equal to the factorization of
the product `∏ (a : ℕ) in f.support, a ^ f a`. -/
theorem prod_pow_factorization_eq_self {f : ℕ →₀ ℕ} (hf : ∀ p : ℕ, p ∈ f.support → Prime p) :
    (f.prod (· ^ ·)).factorization = f := by
  have h : ∀ x : ℕ, x ∈ f.support → x ^ f x ≠ 0 := fun p hp =>
    pow_ne_zero _ (Prime.ne_zero (hf p hp))
  simp only [Finsupp.prod, factorization_prod h]
  conv =>
    

Proof state:
a b m n p : ℕ
f : ℕ →₀ ℕ
hf : ∀ p ∈ f.support, Prime p
h : ∀ x ∈ f.support, x ^ f x ≠ 0
| ∑ x in f.support, factorization (x ^ f x) = f

Next tactic:
rhs
    rw [(sum_single f).symm]
/-- Any Finsupp `f : ℕ →₀ ℕ` whose support is in the primes is equal to the factorization of
the product `∏ (a : ℕ) in f.support, a ^ f a`. -/
theorem prod_pow_factorization_eq_self {f : ℕ →₀ ℕ} (hf : ∀ p : ℕ, p ∈ f.support → Prime p) :
    (f.prod (· ^ ·)).factorization = f := by
  have h : ∀ x : ℕ, x ∈ f.support → x ^ f x ≠ 0 := fun p hp =>
    pow_ne_zero _ (Prime.ne_zero (hf p hp))
  simp only [Finsupp.prod, factorization_prod h]
  conv =>
    

Proof state:
a b m n p : ℕ
f : ℕ →₀ ℕ
hf : ∀ p ∈ f.support, Prime p
h : ∀ x ∈ f.support, x ^ f x ≠ 0
| ∑ x in f.support, factorization (x ^ f x) = f

Next tactic:
rhs
/-- Any Finsupp `f : ℕ →₀ ℕ` whose support is in the primes is equal to the factorization of
the product `∏ (a : ℕ) in f.support, a ^ f a`. -/
theorem prod_pow_factorization_eq_self {f : ℕ →₀ ℕ} (hf : ∀ p : ℕ, p ∈ f.support → Prime p) :
    (f.prod (· ^ ·)).factorization = f := by
  have h : ∀ x : ℕ, x ∈ f.support → x ^ f x ≠ 0 := fun p hp =>
    pow_ne_zero _ (Prime.ne_zero (hf p hp))
  simp only [Finsupp.prod, factorization_prod h]
  conv =>
    rhs
    

Proof state:
a b m n p : ℕ
f : ℕ →₀ ℕ
hf : ∀ p ∈ f.support, Prime p
h : ∀ x ∈ f.support, x ^ f x ≠ 0
| f

Next tactic:
rw [(sum_single f).symm]
/-- Any Finsupp `f : ℕ →₀ ℕ` whose support is in the primes is equal to the factorization of
the product `∏ (a : ℕ) in f.support, a ^ f a`. -/
theorem prod_pow_factorization_eq_self {f : ℕ →₀ ℕ} (hf : ∀ p : ℕ, p ∈ f.support → Prime p) :
    (f.prod (· ^ ·)).factorization = f := by
  have h : ∀ x : ℕ, x ∈ f.support → x ^ f x ≠ 0 := fun p hp =>
    pow_ne_zero _ (Prime.ne_zero (hf p hp))
  simp only [Finsupp.prod, factorization_prod h]
  conv =>
    rhs
    rw [(sum_single f).symm]
  

Proof state:
a b m n p : ℕ
f : ℕ →₀ ℕ
hf : ∀ p ∈ f.support, Prime p
h : ∀ x ∈ f.support, x ^ f x ≠ 0
⊢ ∑ x in f.support, factorization (x ^ f x) = Finsupp.sum f single

Next tactic:
exact sum_congr rfl fun p hp => Prime.factorization_pow (hf p hp)
theorem eq_factorization_iff {n : ℕ} {f : ℕ →₀ ℕ} (hn : n ≠ 0) (hf : ∀ p ∈ f.support, Prime p) :
    f = n.factorization ↔ f.prod (· ^ ·) = n :=
  ⟨fun h => by 

Proof state:
a b m n✝ p n : ℕ
f : ℕ →₀ ℕ
hn : n ≠ 0
hf : ∀ p ∈ f.support, Prime p
h : f = factorization n
⊢ (Finsupp.prod f fun x x_1 => x ^ x_1) = n

Next tactic:
rw [h, factorization_prod_pow_eq_self hn]
theorem eq_factorization_iff {n : ℕ} {f : ℕ →₀ ℕ} (hn : n ≠ 0) (hf : ∀ p ∈ f.support, Prime p) :
    f = n.factorization ↔ f.prod (· ^ ·) = n :=
  ⟨fun h => by rw [h, factorization_prod_pow_eq_self hn], fun h => by
    

Proof state:
a b m n✝ p n : ℕ
f : ℕ →₀ ℕ
hn : n ≠ 0
hf : ∀ p ∈ f.support, Prime p
h : (Finsupp.prod f fun x x_1 => x ^ x_1) = n
⊢ f = factorization n

Next tactic:
rw [← h, prod_pow_factorization_eq_self hf]
theorem factorizationEquiv_apply (n : ℕ+) : (factorizationEquiv n).1 = n.1.factorization := by
  

Proof state:
a b m n✝ p : ℕ
n : ℕ+
⊢ ↑(factorizationEquiv n) = factorization ↑n

Next tactic:
cases n
theorem factorizationEquiv_apply (n : ℕ+) : (factorizationEquiv n).1 = n.1.factorization := by
  cases n
  

Proof state:
case mk
a b m n p val✝ : ℕ
property✝ : 0 < val✝
⊢ ↑(factorizationEquiv { val := val✝, property := property✝ }) = factorization ↑{ val := val✝, property := property✝ }

Next tactic:
rfl
@[simp]
theorem ord_proj_of_not_prime (n p : ℕ) (hp : ¬p.Prime) : ord_proj[p] n = 1 := by
  

Proof state:
a b m n✝ p✝ n p : ℕ
hp : ¬Prime p
⊢ p ^ (factorization n) p = 1

Next tactic:
simp [factorization_eq_zero_of_non_prime n hp]
@[simp]
theorem ord_compl_of_not_prime (n p : ℕ) (hp : ¬p.Prime) : ord_compl[p] n = n := by
  

Proof state:
a b m n✝ p✝ n p : ℕ
hp : ¬Prime p
⊢ n / p ^ (factorization n) p = n

Next tactic:
simp [factorization_eq_zero_of_non_prime n hp]
theorem ord_proj_dvd (n p : ℕ) : ord_proj[p] n ∣ n := by
  

Proof state:
a b m n✝ p✝ n p : ℕ
⊢ p ^ (factorization n) p ∣ n

Next tactic:
by_cases hp : p.Prime
theorem ord_proj_dvd (n p : ℕ) : ord_proj[p] n ∣ n := by
  by_cases hp : p.Prime
  

Proof state:
case pos
a b m n✝ p✝ n p : ℕ
hp : Prime p
⊢ p ^ (factorization n) p ∣ n
case neg a b m n✝ p✝ n p : ℕ hp : ¬Prime p ⊢ p ^ (factorization n) p ∣ n

Next tactic:
case neg => simp [hp]
theorem ord_proj_dvd (n p : ℕ) : ord_proj[p] n ∣ n := by
  by_cases hp : p.Prime
  

Proof state:
a b m n✝ p✝ n p : ℕ
hp : ¬Prime p
⊢ p ^ (factorization n) p ∣ n

Next tactic:
case neg => simp [hp]
theorem ord_proj_dvd (n p : ℕ) : ord_proj[p] n ∣ n := by
  by_cases hp : p.Prime
  case neg => 

Proof state:
a b m n✝ p✝ n p : ℕ
hp : ¬Prime p
⊢ p ^ (factorization n) p ∣ n

Next tactic:
simp [hp]