-- Lean 4 proof step from Mathlib.RingTheory.DedekindDomain.Ideal.Basic (goal)
Goal:
A : Type u_2
inst : CommRing A
inst_1 : IsDedekindDomain A
hNF : ¬IsField A
I M : Ideal A
hI0 : I ≠ ⊥
hIM : I ≤ M
hM : M.IsMaximal
Z₀ : Multiset (PrimeSpectrum A)
hZ₀ : (Multiset.map asIdeal Z₀).prod ≤ I ∧ (Multiset.map asIdeal Z₀).prod ≠ ⊥
Z : Multiset (PrimeSpectrum A)
h_eraseZ :
  ∀ (x : Multiset (PrimeSpectrum A)),
    Membership.mem (γ := Set (Multiset (PrimeSpectrum A)))
        {Z : Multiset (PrimeSpectrum A) | (Multiset.map asIdeal Z).prod ≤ I ∧ (Multiset.map asIdeal Z).prod ≠ ⊥} x →
      ¬x < Z
hZI : (Multiset.map asIdeal Z).prod ≤ I
hprodZ : (Multiset.map asIdeal Z).prod ≠ ⊥
P : PrimeSpectrum A
hPZ : P ∈ Z
hPZ' : P.asIdeal ∈ Multiset.map asIdeal Z
hPM : P.asIdeal ≤ M
have have₁ have₂ :
  ∀ (this : Multiset.map asIdeal (Z.erase P) = (Multiset.map asIdeal Z).erase P.asIdeal),
    ∃ (Z : Multiset (PrimeSpectrum A)), (M ::ₘ Multiset.map asIdeal Z).prod ≤ I ∧ ¬(Multiset.map asIdeal Z).prod ≤ I
have₃ :
  ∀ (this : Multiset.map asIdeal (Z.erase P) = (Multiset.map asIdeal Z).erase P.asIdeal) (hP0 : P.asIdeal ≠ ⊥)
    (hZP0 : (Multiset.map asIdeal (Z.erase P)).prod ≠ ⊥),
    ∃ (Z : Multiset (PrimeSpectrum A)), (M ::ₘ Multiset.map asIdeal Z).prod ≤ I ∧ ¬(Multiset.map asIdeal Z).prod ≤ I
have₄ :
  ∀ (this : Multiset.map asIdeal (Z.erase P) = (Multiset.map asIdeal Z).erase P.asIdeal) (hP0 : P.asIdeal ≠ ⊥)
    (hZP0 : (Multiset.map asIdeal (Z.erase P)).prod ≠ ⊥) (hPM' : P.asIdeal = M),
    ∃ (Z : Multiset (PrimeSpectrum A)), (M ::ₘ Multiset.map asIdeal Z).prod ≤ I ∧ ¬(Multiset.map asIdeal Z).prod ≤ I
have₅ :
  ∀ (this : Multiset.map asIdeal (Z.erase P) = (Multiset.map asIdeal Z).erase P.asIdeal) (hP0 : P.asIdeal ≠ ⊥)
    (hZP0 : (Multiset.map asIdeal (Z.erase P)).prod ≠ ⊥) (hIM : I ≤ P.asIdeal) [hM : P.asIdeal.IsMaximal]
    (hPM : P.asIdeal ≤ P.asIdeal),
    ∃ (Z : Multiset (PrimeSpectrum A)),
      (P.asIdeal ::ₘ Multiset.map asIdeal Z).prod ≤ I ∧ ¬(Multiset.map asIdeal Z).prod ≤ I
refine_1 :
  ∀ (this : Multiset.map asIdeal (Z.erase P) = (Multiset.map asIdeal Z).erase P.asIdeal) (hP0 : P.asIdeal ≠ ⊥)
    (hZP0 : (Multiset.map asIdeal (Z.erase P)).prod ≠ ⊥) (hIM : I ≤ P.asIdeal) [hM : P.asIdeal.IsMaximal]
    (hPM : P.asIdeal ≤ P.asIdeal), (P.asIdeal ::ₘ Multiset.map asIdeal (Z.erase P)).prod ≤ I
⊢ ∃ (Z : Multiset (PrimeSpectrum A)), (M ::ₘ Multiset.map asIdeal Z).prod ≤ I ∧ ¬(Multiset.map asIdeal Z).prod ≤ I
have refine_2 : ∀ (this : Multiset.map asIdeal (Z.erase P) = (Multiset.map asIdeal Z).erase P.asIdeal) (hP0 : P.asIdeal ≠ ⊥)
  (hZP0 : (Multiset.map asIdeal (Z.erase P)).prod ≠ ⊥) (hIM : I ≤ P.asIdeal) [hM : P.asIdeal.IsMaximal]
  (hPM : P.asIdeal ≤ P.asIdeal), ¬(Multiset.map asIdeal (Z.erase P)).prod ≤ I
Tactic: classical
    have := Multiset.map_erase asIdeal (fun _ _ => PrimeSpectrum.ext) P Z
    obtain ⟨hP0, hZP0⟩ : P.asIdeal ≠ ⊥ ∧ ((Z.erase P).map asIdeal).prod ≠ ⊥ := by
      rwa [Ne, ← Multiset.cons_erase hPZ', Multiset.prod_cons, Ideal.mul_eq_bot, not_or, ←
        this] at hprodZ
    -- By maximality of `P` and `M`, we have that `P ≤ M` implies `P = M`.
    have hPM' := (P.isPrime.isMaximal hP0).eq_of_le hM.ne_top hPM
    subst hPM'
    -- By minimality of `Z`, erasing `P` from `Z` is exactly what we need.
    refine ⟨Z.erase P, ?_, ?_⟩
    · convert! hZI
      rw [this, Multiset.cons_erase hPZ']
    · refine fun h => h_eraseZ (Z.erase P) ⟨h, ?_⟩ (Multiset.erase_lt.mpr hPZ)
      exact hZP0
Cleared hypotheses: M, hIM, hM, hPM