-- Lean 4 proof step from Mathlib.RingTheory.DedekindDomain.Factorization (goal)
Goal:
R : Type u_1
inst : CommRing R
K : Type u_2
inst_1 : Field K
inst_2 : Algebra R K
inst_3 : IsFractionRing R K
inst_4 : IsDedekindDomain R
v w : HeightOneSpectrum R
hw : w ≠ v
hw_fact :
  (↑w.asIdeal : FractionalIdeal R⁰ K) =
    HMul.hMul (α := FractionalIdeal.{u_1, u_2} (R := R) R⁰ K) (β := FractionalIdeal.{u_1, u_2} (R := R) R⁰ K)
      (spanSingleton R⁰ ((algebraMap R K : (a : R) → K) 1)⁻¹ : FractionalIdeal.{u_1, u_2} (R := R) R⁰ K)
      ((↑w.asIdeal : FractionalIdeal.{u_1, u_2} (R := R) R⁰ K) : FractionalIdeal.{u_1, u_2} (R := R) R⁰ K)
hw_ne_zero : Ne.{u_2 + 1} (α := FractionalIdeal.{u_1, u_2} (R := R) R⁰ K) (↑w.asIdeal : FractionalIdeal R⁰ K) 0
hv : Irreducible (M := Associates (Ideal R)) (Associates.mk v.asIdeal)
hw' : Irreducible (M := Associates (Ideal R)) (Associates.mk w.asIdeal)
rw :
  HSub.hSub (α := ℤ) (↑(Associates.count (Associates.mk v.asIdeal) (Associates.factors (Associates.mk w.asIdeal))) : ℤ)
      (↑(Associates.count (Associates.mk v.asIdeal) (Associates.factors (Associates.mk (Ideal.span {1})))) : ℤ) =
    0
rw₁ :
  HSub.hSub (α := ℤ) (↑(Associates.count (Associates.mk v.asIdeal) (Associates.factors (Associates.mk w.asIdeal))) : ℤ)
      (↑(Associates.count (Associates.mk v.asIdeal) (Associates.factors (Associates.mk ⊤))) : ℤ) =
    0
rw₂ :
  HSub.hSub (α := ℤ) (↑(Associates.count (Associates.mk v.asIdeal) (Associates.factors (Associates.mk w.asIdeal))) : ℤ)
      (↑(Associates.count (Associates.mk v.asIdeal) (Associates.factors (Associates.mk 1))) : ℤ) =
    0
rw₃ :
  HSub.hSub (α := ℤ) (↑(Associates.count (Associates.mk v.asIdeal) (Associates.factors (Associates.mk w.asIdeal))) : ℤ)
      (↑(Associates.count (Associates.mk v.asIdeal) (Associates.factors 1)) : ℤ) =
    0
rw₄ :
  HSub.hSub (α := ℤ) (↑(Associates.count (Associates.mk v.asIdeal) (Associates.factors (Associates.mk w.asIdeal))) : ℤ)
      (↑(Associates.count (Associates.mk v.asIdeal) 0) : ℤ) =
    0
rw₅ :
  HSub.hSub (α := ℤ) (↑(Associates.count (Associates.mk v.asIdeal) (Associates.factors (Associates.mk w.asIdeal))) : ℤ)
      (↑0 : ℤ) =
    0
rw₆ :
  HSub.hSub (α := ℤ) (↑(Associates.count (Associates.mk v.asIdeal) (Associates.factors (Associates.mk w.asIdeal))) : ℤ)
      0 =
    0
rw₇ : Eq (α := ℤ) (↑(Associates.count (Associates.mk v.asIdeal) (Associates.factors (Associates.mk w.asIdeal))) : ℤ) 0
rw₈ : Associates.count (Associates.mk v.asIdeal) (Associates.factors (Associates.mk w.asIdeal)) = 0
rw₉ :
  Associates.count (Associates.mk v.asIdeal)
      (HPow.hPow (α := Associates (Ideal R)) (β := ℕ) (Associates.mk w.asIdeal) 1).factors =
    0
rw₁₀ :
  Associates.count (Associates.mk v.asIdeal)
      (↑(Multiset.replicate 1
            (Subtype.mk (p := fun (a : Associates (Ideal R)) ↦ Irreducible a) (Associates.mk w.asIdeal) hw')) :
        WithTop (Multiset { a : Associates (Ideal R) // Irreducible a })) =
    0
rw₁₁ :
  Multiset.count (Subtype.mk (p := fun (a : Associates (Ideal R)) ↦ Irreducible a) (Associates.mk v.asIdeal) hv)
      (Multiset.replicate 1
        (Subtype.mk (p := fun (a : Associates (Ideal R)) ↦ Irreducible a) (Associates.mk w.asIdeal) hw')) =
    0
rw₁₂ :
  Multiset.count (Subtype.mk (p := fun (a : Associates (Ideal R)) ↦ Irreducible a) (Associates.mk v.asIdeal) hv)
      {Subtype.mk (p := fun (a : Associates (Ideal R)) ↦ Irreducible a) (Associates.mk w.asIdeal) hw'} =
    0
⊢ count K v (↑w.asIdeal : FractionalIdeal R⁰ K) = 0
have rw₁₃ : Subtype.mk (p := fun (a : Associates (Ideal R)) ↦ Irreducible a) (Associates.mk v.asIdeal) hv ∉
  {Subtype.mk (p := fun (a : Associates (Ideal R)) ↦ Irreducible a) (Associates.mk w.asIdeal) hw'}
Tactic: classical
  rw [count_well_defined K v hw_ne_zero hw_fact, Ideal.span_singleton_one, ← Ideal.one_eq_top,
    Associates.mk_one, Associates.factors_one, Associates.count_zero hv, ofNat_zero, sub_zero,
    natCast_eq_zero, ← pow_one (Associates.mk w.asIdeal), Associates.factors_prime_pow hw',
    Associates.count_some hv, Multiset.replicate_one, Multiset.count_eq_zero,
    Multiset.mem_singleton]
  simp only [Subtype.mk.injEq]
  rw [Associates.mk_eq_mk_iff_associated, associated_iff_eq, ← HeightOneSpectrum.ext_iff]
  exact Ne.symm hw