/-- The **Kummer-Dedekind Theorem**. -/
theorem normalizedFactors_ideal_map_eq_normalizedFactors_min_poly_mk_map (hI : IsMaximal I)
    (hI' : I ≠ ⊥) (hx : (conductor R x).comap (algebraMap R S) ⊔ I = ⊤) (hx' : IsIntegral R x) :
    normalizedFactors (I.map (algebraMap R S)) =
      Multiset.map
        (fun f =>
          ((normalizedFactorsMapEquivNormalizedFactorsMinPolyMk hI hI' hx hx').symm f : Ideal S))
        (normalizedFactors (Polynomial.map (Ideal.Quotient.mk I) (minpoly R x))).attach := by
  ext J
  -- WLOG, assume J is a normalized factor
  by_cases hJ : J ∈ normalizedFactors (I.map (algebraMap R S));
  swap
  · rw [Multiset.count_eq_zero.mpr hJ, eq_comm, Multiset.count_eq_zero, Multiset.mem_map]
    simp only [Multiset.mem_attach, true_and_iff, not_exists]
    rintro J' rfl
    exact
      hJ ((normalizedFactorsMapEquivNormalizedFactorsMinPolyMk hI hI' hx hx').symm J').prop
  -- Then we just have to compare the multiplicities, which we already proved are equal.
  have := multiplicity_factors_map_eq_multiplicity hI hI' hx hx' hJ
  rw [multiplicity_eq_count_normalizedFactors, multiplicity_eq_count_normalizedFactors,
    UniqueFactorizationMonoid.normalize_normalized_factor _ hJ,
    UniqueFactorizationMonoid.normalize_normalized_factor, PartENat.natCast_inj] at this
  refine' this.trans _
  -- Get rid of the `map` by applying the equiv to both sides.
  generalize hJ' :
    (normalizedFactorsMapEquivNormalizedFactorsMinPolyMk hI hI' hx hx') ⟨J, hJ⟩ = J'
  have : ((normalizedFactorsMapEquivNormalizedFactorsMinPolyMk hI hI' hx hx').symm J' : Ideal S) =
      J :=
    by rw [← hJ', Equiv.symm_apply_apply _ _, Subtype.coe_mk]
  

Proof state:
case pos
R : Type u_1
S : Type u_2
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
inst✝⁵ : Algebra R S
x : S
I : Ideal R
inst✝⁴ : IsDomain R
inst✝³ : IsIntegrallyClosed R
inst✝² : IsDomain S
inst✝¹ : IsDedekindDomain S
inst✝ : NoZeroSMulDivisors R S
hI : IsMaximal I
hI' : I ≠ ⊥
hx : comap (algebraMap R S) (conductor R x) ⊔ I = ⊤
hx' : _root_.IsIntegral R x
J : Ideal S
hJ : J ∈ normalizedFactors (Ideal.map (algebraMap R S) I)
this✝ :
  Multiset.count J (normalizedFactors (Ideal.map (algebraMap R S) I)) =
    Multiset.count (↑((normalizedFactorsMapEquivNormalizedFactorsMinPolyMk hI hI' hx hx') { val := J, property := hJ }))
      (normalizedFactors (Polynomial.map (Ideal.Quotient.mk I) (minpoly R x)))
J' : ↑{d | d ∈ normalizedFactors (Polynomial.map (Ideal.Quotient.mk I) (minpoly R x))}
hJ' : (normalizedFactorsMapEquivNormalizedFactorsMinPolyMk hI hI' hx hx') { val := J, property := hJ } = J'
this : ↑((normalizedFactorsMapEquivNormalizedFactorsMinPolyMk hI hI' hx hx').symm J') = J
⊢ Multiset.count (↑J') (normalizedFactors (Polynomial.map (Ideal.Quotient.mk I) (minpoly R x))) =
    Multiset.count J
      (Multiset.map (fun f => ↑((normalizedFactorsMapEquivNormalizedFactorsMinPolyMk hI hI' hx hx').symm f))
        (Multiset.attach (normalizedFactors (Polynomial.map (Ideal.Quotient.mk I) (minpoly R x)))))
case pos.a
R : Type u_1
S : Type u_2
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
inst✝⁵ : Algebra R S
x : S
I : Ideal R
inst✝⁴ : IsDomain R
inst✝³ : IsIntegrallyClosed R
inst✝² : IsDomain S
inst✝¹ : IsDedekindDomain S
inst✝ : NoZeroSMulDivisors R S
hI : IsMaximal I
hI' : I ≠ ⊥
hx : comap (algebraMap R S) (conductor R x) ⊔ I = ⊤
hx' : _root_.IsIntegral R x
J : Ideal S
hJ : J ∈ normalizedFactors (Ideal.map (algebraMap R S) I)
this :
  ↑(Multiset.count J (normalizedFactors (Ideal.map (algebraMap R S) I))) =
    ↑(Multiset.count
        (normalize ↑((normalizedFactorsMapEquivNormalizedFactorsMinPolyMk hI hI' hx hx') { val := J, property := hJ }))
        (normalizedFactors (Polynomial.map (Ideal.Quotient.mk I) (minpoly R x))))
⊢ ↑((normalizedFactorsMapEquivNormalizedFactorsMinPolyMk hI hI' hx hx') { val := J, property := hJ }) ∈
    normalizedFactors ?m.1009095
R : Type u_1
S : Type u_2
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
inst✝⁵ : Algebra R S
x : S
I : Ideal R
inst✝⁴ : IsDomain R
inst✝³ : IsIntegrallyClosed R
inst✝² : IsDomain S
inst✝¹ : IsDedekindDomain S
inst✝ : NoZeroSMulDivisors R S
hI : IsMaximal I
hI' : I ≠ ⊥
hx : comap (algebraMap R S) (conductor R x) ⊔ I = ⊤
hx' : _root_.IsIntegral R x
J : Ideal S
hJ : J ∈ normalizedFactors (Ideal.map (algebraMap R S) I)
this :
  ↑(Multiset.count J (normalizedFactors (Ideal.map (algebraMap R S) I))) =
    ↑(Multiset.count
        (normalize ↑((normalizedFactorsMapEquivNormalizedFactorsMinPolyMk hI hI' hx hx') { val := J, property := hJ }))
        (normalizedFactors (Polynomial.map (Ideal.Quotient.mk I) (minpoly R x))))
⊢ (R ⧸ I)[X]
case pos.ha
R : Type u_1
S : Type u_2
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
inst✝⁵ : Algebra R S
x : S
I : Ideal R
inst✝⁴ : IsDomain R
inst✝³ : IsIntegrallyClosed R
inst✝² : IsDomain S
inst✝¹ : IsDedekindDomain S
inst✝ : NoZeroSMulDivisors R S
hI : IsMaximal I
hI' : I ≠ ⊥
hx : comap (algebraMap R S) (conductor R x) ⊔ I = ⊤
hx' : _root_.IsIntegral R x
J : Ideal S
hJ : J ∈ normalizedFactors (Ideal.map (algebraMap R S) I)
this :
  ↑(Multiset.count (normalize J) (normalizedFactors (Ideal.map (algebraMap R S) I))) =
    multiplicity (↑((normalizedFactorsMapEquivNormalizedFactorsMinPolyMk hI hI' hx hx') { val := J, property := hJ }))
      (Polynomial.map (Ideal.Quotient.mk I) (minpoly R x))
⊢ Irreducible ↑((normalizedFactorsMapEquivNormalizedFactorsMinPolyMk hI hI' hx hx') { val := J, property := hJ })
case pos.hb
R : Type u_1
S : Type u_2
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
inst✝⁵ : Algebra R S
x : S
I : Ideal R
inst✝⁴ : IsDomain R
inst✝³ : IsIntegrallyClosed R
inst✝² : IsDomain S
inst✝¹ : IsDedekindDomain S
inst✝ : NoZeroSMulDivisors R S
hI : IsMaximal I
hI' : I ≠ ⊥
hx : comap (algebraMap R S) (conductor R x) ⊔ I = ⊤
hx' : _root_.IsIntegral R x
J : Ideal S
hJ : J ∈ normalizedFactors (Ideal.map (algebraMap R S) I)
this :
  ↑(Multiset.count (normalize J) (normalizedFactors (Ideal.map (algebraMap R S) I))) =
    multiplicity (↑((normalizedFactorsMapEquivNormalizedFactorsMinPolyMk hI hI' hx hx') { val := J, property := hJ }))
      (Polynomial.map (Ideal.Quotient.mk I) (minpoly R x))
⊢ Polynomial.map (Ideal.Quotient.mk I) (minpoly R x) ≠ 0
case pos.ha
R : Type u_1
S : Type u_2
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
inst✝⁵ : Algebra R S
x : S
I : Ideal R
inst✝⁴ : IsDomain R
inst✝³ : IsIntegrallyClosed R
inst✝² : IsDomain S
inst✝¹ : IsDedekindDomain S
inst✝ : NoZeroSMulDivisors R S
hI : IsMaximal I
hI' : I ≠ ⊥
hx : comap (algebraMap R S) (conductor R x) ⊔ I = ⊤
hx' : _root_.IsIntegral R x
J : Ideal S
hJ : J ∈ normalizedFactors (Ideal.map (algebraMap R S) I)
this :
  multiplicity J (Ideal.map (algebraMap R S) I) =
    multiplicity (↑((normalizedFactorsMapEquivNormalizedFactorsMinPolyMk hI hI' hx hx') { val := J, property := hJ }))
      (Polynomial.map (Ideal.Quotient.mk I) (minpoly R x))
⊢ Irreducible J
case pos.hb
R : Type u_1
S : Type u_2
inst✝⁷ : CommRing R
inst✝⁶ : CommRing S
inst✝⁵ : Algebra R S
x : S
I : Ideal R
inst✝⁴ : IsDomain R
inst✝³ : IsIntegrallyClosed R
inst✝² : IsDomain S
inst✝¹ : IsDedekindDomain S
inst✝ : NoZeroSMulDivisors R S
hI : IsMaximal I
hI' : I ≠ ⊥
hx : comap (algebraMap R S) (conductor R x) ⊔ I = ⊤
hx' : _root_.IsIntegral R x
J : Ideal S
hJ : J ∈ normalizedFactors (Ideal.map (algebraMap R S) I)
this :
  multiplicity J (Ideal.map (algebraMap R S) I) =
    multiplicity (↑((normalizedFactorsMapEquivNormalizedFactorsMinPolyMk hI hI' hx hx') { val := J, property := hJ }))
      (Polynomial.map (Ideal.Quotient.mk I) (minpoly R x))
⊢ Ideal.map (algebraMap R S) I ≠ 0

Next tactic:
subst this