-- Mathlib/RingTheory/UniqueFactorizationDomain/Basic.lean
theorem prime_factors_irreducible [CancelCommMonoidWithZero α] {a : α} {f : Multiset α}
    (ha : Irreducible a) (pfa : (∀ b ∈ f, Prime b) ∧ f.prod ~ᵤ a) : ∃ p, a ~ᵤ p ∧ f = {p}

Proof state:
α : Type u_1
inst✝ : CancelCommMonoidWithZero α
a : α
f : Multiset α
ha : Irreducible a
pfa : (∀ b ∈ f, Prime b) ∧ f.prod ~ᵤ a
this : DecidableEq α
p : α
s : Multiset α
a✝ : s.prod ~ᵤ a → (∀ b ∈ s, Prime b) → ∃ p, a ~ᵤ p ∧ s = {p}
u : αˣ
hu : (p ::ₘ s).prod * ↑u = a
hs : ∀ b ∈ p ::ₘ s, Prime b
hs0 : ¬s = 0
q : α
hq : q ∈ s
⊢ ¬IsUnit p

Tactic:
apply (hs p (Multiset.mem_cons_self _ _)).2.1

Result:
no goals

Proof state:
α : Type u_1
inst✝ : CancelCommMonoidWithZero α
a : α
f : Multiset α
ha : Irreducible a
pfa : (∀ b ∈ f, Prime b) ∧ f.prod ~ᵤ a
this : DecidableEq α
⊢ ∃ p, a ~ᵤ p ∧ f = {p}

Tactic:
refine @Multiset.induction_on _
  (fun g => (g.prod ~ᵤ a) → (∀ b ∈ g, Prime b) → ∃ p, a ~ᵤ p ∧ g = {p}) f ?_ ?_ pfa.2 pfa.1

Result:
case refine_1
α : Type u_1
inst✝ : CancelCommMonoidWithZero α
a : α
f : Multiset α
ha : Irreducible a
pfa : (∀ b ∈ f, Prime b) ∧ f.prod ~ᵤ a
this : DecidableEq α
⊢ (fun g => g.prod ~ᵤ a → (∀ b ∈ g, Prime b) → ∃ p, a ~ᵤ p ∧ g = {p}) 0

case refine_2
α : Type u_1
inst✝ : CancelCommMonoidWithZero α
a : α
f : Multiset α
ha : Irreducible a
pfa : (∀ b ∈ f, Prime b) ∧ f.prod ~ᵤ a
this : DecidableEq α
⊢ ∀ (a_1 : α) (s : Multiset α),
    (fun g => g.prod ~ᵤ a → (∀ b ∈ g, Prime b) → ∃ p, a ~ᵤ p ∧ g = {p}) s →
      (fun g => g.prod ~ᵤ a → (∀ b ∈ g, Prime b) → ∃ p, a ~ᵤ p ∧ g = {p}) (a_1 ::ₘ s)

Proof state:
case refine_2
α : Type u_1
inst✝ : CancelCommMonoidWithZero α
a : α
f : Multiset α
ha : Irreducible a
pfa : (∀ b ∈ f, Prime b) ∧ f.prod ~ᵤ a
this : DecidableEq α
⊢ ∀ (a_1 : α) (s : Multiset α),
    (fun g => g.prod ~ᵤ a → (∀ b ∈ g, Prime b) → ∃ p, a ~ᵤ p ∧ g = {p}) s →
      (fun g => g.prod ~ᵤ a → (∀ b ∈ g, Prime b) → ∃ p, a ~ᵤ p ∧ g = {p}) (a_1 ::ₘ s)

Tactic:
rintro p s _ ⟨u, hu⟩ hs

Result:
case refine_2.intro
α : Type u_1
inst✝ : CancelCommMonoidWithZero α
a : α
f : Multiset α
ha : Irreducible a
pfa : (∀ b ∈ f, Prime b) ∧ f.prod ~ᵤ a
this : DecidableEq α
p : α
s : Multiset α
a✝ : s.prod ~ᵤ a → (∀ b ∈ s, Prime b) → ∃ p, a ~ᵤ p ∧ s = {p}
u : αˣ
hu : (p ::ₘ s).prod * ↑u = a
hs : ∀ b ∈ p ::ₘ s, Prime b
⊢ ∃ p_1, a ~ᵤ p_1 ∧ p ::ₘ s = {p_1}

Proof state:
α : Type u_1
inst✝ : CancelCommMonoidWithZero α
a : α
f : Multiset α
ha : Irreducible a
pfa : (∀ b ∈ f, Prime b) ∧ f.prod ~ᵤ a
this : DecidableEq α
p : α
s : Multiset α
a✝ : s.prod ~ᵤ a → (∀ b ∈ s, Prime b) → ∃ p, a ~ᵤ p ∧ s = {p}
u : αˣ
hu : (p ::ₘ s).prod * ↑u = a
hs : ∀ b ∈ p ::ₘ s, Prime b
hs0 : ¬s = 0
⊢ False

Tactic:
obtain ⟨q, hq⟩ := Multiset.exists_mem_of_ne_zero hs0

Result:
case intro
α : Type u_1
inst✝ : CancelCommMonoidWithZero α
a : α
f : Multiset α
ha : Irreducible a
pfa : (∀ b ∈ f, Prime b) ∧ f.prod ~ᵤ a
this : DecidableEq α
p : α
s : Multiset α
a✝ : s.prod ~ᵤ a → (∀ b ∈ s, Prime b) → ∃ p, a ~ᵤ p ∧ s = {p}
u : αˣ
hu : (p ::ₘ s).prod * ↑u = a
hs : ∀ b ∈ p ::ₘ s, Prime b
hs0 : ¬s = 0
q : α
hq : q ∈ s
⊢ False

Proof state:
case refine_1
α : Type u_1
inst✝ : CancelCommMonoidWithZero α
a : α
f : Multiset α
ha : Irreducible a
pfa : (∀ b ∈ f, Prime b) ∧ f.prod ~ᵤ a
this : DecidableEq α
h : Multiset.prod 0 ~ᵤ a
⊢ (∀ b ∈ 0, Prime b) → ∃ p, a ~ᵤ p ∧ 0 = {p}

Tactic:
exact (ha.not_unit (associated_one_iff_isUnit.1 (Associated.symm h))).elim

Result:
no goals

Proof state:
case refine_1
α : Type u_1
inst✝ : CancelCommMonoidWithZero α
a : α
f : Multiset α
ha : Irreducible a
pfa : (∀ b ∈ f, Prime b) ∧ f.prod ~ᵤ a
this : DecidableEq α
⊢ (fun g => g.prod ~ᵤ a → (∀ b ∈ g, Prime b) → ∃ p, a ~ᵤ p ∧ g = {p}) 0

Tactic:
intro h

Result:
case refine_1
α : Type u_1
inst✝ : CancelCommMonoidWithZero α
a : α
f : Multiset α
ha : Irreducible a
pfa : (∀ b ∈ f, Prime b) ∧ f.prod ~ᵤ a
this : DecidableEq α
h : Multiset.prod 0 ~ᵤ a
⊢ (∀ b ∈ 0, Prime b) → ∃ p, a ~ᵤ p ∧ 0 = {p}