-- 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 : HeightOneSpectrum R
I I' : FractionalIdeal.{u_1, u_2} (R := R) R⁰ K
hI : I ≠ 0
hI' : I' ≠ 0
have : Irreducible (M := Associates (Ideal R)) (Associates.mk v.asIdeal)
have₁ :
  ∀ (hv : Irreducible (M := Associates (Ideal R)) (Associates.mk v.asIdeal)),
    count K v (I * I') = count K v I + count K v I'
have₂ : Irreducible (M := Associates (Ideal R)) (Associates.mk v.asIdeal)
have₃ have₄ :
  ∀ (hv : Irreducible (M := Associates (Ideal R)) (Associates.mk v.asIdeal)),
    count K v (I * I') = count K v I + count K v I'
have₅ :
  ∀ (hv : Irreducible (M := Associates (Ideal R)) (Associates.mk v.asIdeal)) (a : R) (J : Ideal R) (ha : a ≠ 0)
    (haJ :
      I =
        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) a)⁻¹ : FractionalIdeal.{u_1, u_2} (R := R) R⁰ K)
          ((↑J : FractionalIdeal.{u_1, u_2} (R := R) R⁰ K) : FractionalIdeal.{u_1, u_2} (R := R) R⁰ K)),
    count K v (I * I') = count K v I + count K v I'
have₆ :
  ∀ (hv : Irreducible (M := Associates (Ideal R)) (Associates.mk v.asIdeal)) (a : R) (J : Ideal R) (ha : a ≠ 0)
    (haJ :
      I =
        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) a)⁻¹ : FractionalIdeal.{u_1, u_2} (R := R) R⁰ K)
          ((↑J : FractionalIdeal.{u_1, u_2} (R := R) R⁰ K) : FractionalIdeal.{u_1, u_2} (R := R) R⁰ K))
    (ha_ne_zero : Ne (α := Associates (Ideal R)) (Associates.mk (Ideal.span {a})) 0),
    count K v (I * I') = count K v I + count K v I'
have₇ :
  ∀ (hv : Irreducible (M := Associates (Ideal R)) (Associates.mk v.asIdeal)) (a : R) (J : Ideal R) (ha : a ≠ 0)
    (haJ :
      I =
        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) a)⁻¹ : FractionalIdeal.{u_1, u_2} (R := R) R⁰ K)
          ((↑J : FractionalIdeal.{u_1, u_2} (R := R) R⁰ K) : FractionalIdeal.{u_1, u_2} (R := R) R⁰ K))
    (ha_ne_zero : Ne (α := Associates (Ideal R)) (Associates.mk (Ideal.span {a})) 0)
    (hJ_ne_zero : Ne (α := Associates (Ideal R)) (Associates.mk J) 0), count K v (I * I') = count K v I + count K v I'
have₈ :
  ∀ (hv : Irreducible (M := Associates (Ideal R)) (Associates.mk v.asIdeal)) (a : R) (J : Ideal R) (ha : a ≠ 0)
    (haJ :
      I =
        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) a)⁻¹ : FractionalIdeal.{u_1, u_2} (R := R) R⁰ K)
          ((↑J : FractionalIdeal.{u_1, u_2} (R := R) R⁰ K) : FractionalIdeal.{u_1, u_2} (R := R) R⁰ K))
    (ha_ne_zero : Ne (α := Associates (Ideal R)) (Associates.mk (Ideal.span {a})) 0)
    (hJ_ne_zero : Ne (α := Associates (Ideal R)) (Associates.mk J) 0) (a' : R) (J' : Ideal R) (ha' : a' ≠ 0)
    (haJ' :
      I' =
        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) a')⁻¹ : FractionalIdeal.{u_1, u_2} (R := R) R⁰ K)
          ((↑J' : FractionalIdeal.{u_1, u_2} (R := R) R⁰ K) : FractionalIdeal.{u_1, u_2} (R := R) R⁰ K)),
    count K v (I * I') = count K v I + count K v I'
have₉ :
  ∀ (hv : Irreducible (M := Associates (Ideal R)) (Associates.mk v.asIdeal)) (a : R) (J : Ideal R) (ha : a ≠ 0)
    (haJ :
      I =
        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) a)⁻¹ : FractionalIdeal.{u_1, u_2} (R := R) R⁰ K)
          ((↑J : FractionalIdeal.{u_1, u_2} (R := R) R⁰ K) : FractionalIdeal.{u_1, u_2} (R := R) R⁰ K))
    (ha_ne_zero : Ne (α := Associates (Ideal R)) (Associates.mk (Ideal.span {a})) 0)
    (hJ_ne_zero : Ne (α := Associates (Ideal R)) (Associates.mk J) 0) (a' : R) (J' : Ideal R) (ha' : a' ≠ 0)
    (haJ' :
      I' =
        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) a')⁻¹ : FractionalIdeal.{u_1, u_2} (R := R) R⁰ K)
          ((↑J' : FractionalIdeal.{u_1, u_2} (R := R) R⁰ K) : FractionalIdeal.{u_1, u_2} (R := R) R⁰ K))
    (ha'_ne_zero : Ne (α := Associates (Ideal R)) (Associates.mk (Ideal.span {a'})) 0),
    count K v (I * I') = count K v I + count K v I'
⊢ count K v (I * I') = count K v I + count K v I'
have have₁₀ : ∀ (hv : Irreducible (M := Associates (Ideal R)) (Associates.mk v.asIdeal)) (a : R) (J : Ideal R) (ha : a ≠ 0)
  (haJ :
    I =
      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) a)⁻¹ : FractionalIdeal.{u_1, u_2} (R := R) R⁰ K)
        ((↑J : FractionalIdeal.{u_1, u_2} (R := R) R⁰ K) : FractionalIdeal.{u_1, u_2} (R := R) R⁰ K))
  (ha_ne_zero : Ne (α := Associates (Ideal R)) (Associates.mk (Ideal.span {a})) 0)
  (hJ_ne_zero : Ne (α := Associates (Ideal R)) (Associates.mk J) 0) (a' : R) (J' : Ideal R) (ha' : a' ≠ 0)
  (haJ' :
    I' =
      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) a')⁻¹ : FractionalIdeal.{u_1, u_2} (R := R) R⁰ K)
        ((↑J' : FractionalIdeal.{u_1, u_2} (R := R) R⁰ K) : FractionalIdeal.{u_1, u_2} (R := R) R⁰ K))
  (ha'_ne_zero : Ne (α := Associates (Ideal R)) (Associates.mk (Ideal.span {a'})) 0)
  (hJ'_ne_zero : Ne (α := Associates (Ideal R)) (Associates.mk J') 0), count K v (I * I') = count K v I + count K v I'
Tactic: classical
  have hv : Irreducible (Associates.mk v.asIdeal) := by apply v.associates_irreducible
  obtain ⟨a, J, ha, haJ⟩ := exists_eq_spanSingleton_mul I
  have ha_ne_zero : Associates.mk (Ideal.span {a} : Ideal R) ≠ 0 := by
    rw [ne_eq, Associates.mk_eq_zero, Ideal.zero_eq_bot, Ideal.span_singleton_eq_bot]; exact ha
  have hJ_ne_zero : Associates.mk J ≠ 0 := Associates.mk_ne_zero.mpr (ideal_factor_ne_zero hI haJ)
  obtain ⟨a', J', ha', haJ'⟩ := exists_eq_spanSingleton_mul I'
  have ha'_ne_zero : Associates.mk (Ideal.span {a'} : Ideal R) ≠ 0 := by
    rw [ne_eq, Associates.mk_eq_zero, Ideal.zero_eq_bot, Ideal.span_singleton_eq_bot]; exact ha'
  have hJ'_ne_zero : Associates.mk J' ≠ 0 :=
    Associates.mk_ne_zero.mpr (ideal_factor_ne_zero hI' haJ')
  have h_prod : I * I' = spanSingleton R⁰ ((algebraMap R K) (a * a'))⁻¹ * ↑(J * J') := by
    rw [haJ, haJ', mul_assoc, mul_comm (J : FractionalIdeal R⁰ K), mul_assoc, ← mul_assoc,
      spanSingleton_mul_spanSingleton, coeIdeal_mul, map_mul, mul_inv,
      mul_comm (J : FractionalIdeal R⁰ K)]
  rw [count_well_defined K v hI haJ, count_well_defined K v hI' haJ',
    count_well_defined K v (mul_ne_zero hI hI') h_prod, ← Associates.mk_mul_mk,
    Associates.count_mul hJ_ne_zero hJ'_ne_zero hv, ← Ideal.span_singleton_mul_span_singleton,
    ← Associates.mk_mul_mk, Associates.count_mul ha_ne_zero ha'_ne_zero hv]
  push_cast
  ring