l3lab/ntp-mathlib huggingface dataset:
/--
An invertible fractional ideal of a commutative ring with finitely many maximal ideals is principal.

https://math.stackexchange.com/a/95857 -/
theorem FractionalIdeal.isPrincipal.of_finite_maximals_of_inv {A : Type*} [CommRing A]
    [Algebra R A] {S : Submonoid R} [IsLocalization S A] (hS : S ≤ R⁰)
    (hf : {I : Ideal R | I.IsMaximal}.Finite) (I I' : FractionalIdeal S A) (hinv : I * I' = 1) :
    Submodule.IsPrincipal (I : Submodule R A) := by
  have hinv' := hinv
  rw [Subtype.ext_iff, val_eq_coe, coe_mul] at hinv
  let s := hf.toFinset
  haveI := Classical.decEq (Ideal R)
  have coprime : ∀ M ∈ s, ∀ M' ∈ s.erase M, M ⊔ M' = ⊤ := by
    simp_rw [Finset.mem_erase, hf.mem_toFinset]
    rintro M hM M' ⟨hne, hM'⟩
    exact Ideal.IsMaximal.coprime_of_ne hM hM' hne.symm
  have nle : ∀ M ∈ s, ¬⨅ M' ∈ s.erase M, M' ≤ M := fun M hM =>
    left_lt_sup.1
      ((hf.mem_toFinset.1 hM).ne_top.lt_top.trans_eq (Ideal.sup_iInf_eq_top <| coprime M hM).symm)
  have : ∀ M ∈ s, ∃ a ∈ I, ∃ b ∈ I', a * b ∉ IsLocalization.coeSubmodule A M := by
    intro M hM; by_contra! h
    obtain ⟨x, hx, hxM⟩ :=
      SetLike.exists_of_lt
        ((IsLocalization.coeSubmodule_strictMono hS (hf.mem_toFinset.1 hM).ne_top.lt_top).trans_eq
          hinv.symm)
    refine' hxM (Submodule.map₂_le.2 _ hx); exact h
  choose! a ha b hb hm using this
  choose! u hu hum using fun M hM => SetLike.not_le_iff_exists.1 (nle M hM)
  let v := ∑ M in s, u M • b M
  have hv : v ∈ I' := Submodule.sum_mem _ fun M hM => Submodule.smul_mem _ _ <| hb M hM
  refine'
    FractionalIdeal.isPrincipal_of_unit_of_comap_mul_span_singleton_eq_top
      (Units.mkOfMulEqOne I I' hinv') hv (of_not_not fun h => _)
  obtain ⟨M, hM, hJM⟩ := Ideal.exists_le_maximal _ h
  replace hM := hf.mem_toFinset.2 hM
  have : ∀ a ∈ I, ∀ b ∈ I', ∃ c, algebraMap R _ c = a * b := by
    intro a ha b hb; have hi := hinv.le
    obtain ⟨c, -, hc⟩ := hi (Submodule.mul_mem_mul ha hb)
    exact ⟨c, hc⟩
  have hmem : a M * v ∈ IsLocalization.coeSubmodule A M := by
    

Proof state:
R : Type u_1
inst✝³ : CommRing R
A : Type u_2
inst✝² : CommRing A
inst✝¹ : Algebra R A
S : Submonoid R
inst✝ : IsLocalization S A
hS : S ≤ R⁰
hf : Set.Finite {I | IsMaximal I}
I I' : FractionalIdeal S A
hinv : ↑I * ↑I' = ↑1
hinv' : I * I' = 1
s : Finset (Ideal R) := Set.Finite.toFinset hf
this✝ : DecidableEq (Ideal R)
coprime : ∀ M ∈ s, ∀ M' ∈ Finset.erase s M, M ⊔ M' = ⊤
nle : ∀ M ∈ s, ¬⨅ M' ∈ Finset.erase s M, M' ≤ M
a : Ideal R → A
ha : ∀ M ∈ s, a M ∈ I
b : Ideal R → A
hb : ∀ M ∈ s, b M ∈ I'
hm : ∀ M ∈ s, a M * b M ∉ IsLocalization.coeSubmodule A M
u : Ideal R → R
hu : ∀ M ∈ s, u M ∈ ⨅ M' ∈ Finset.erase s M, M'
hum : ∀ M ∈ s, u M ∉ M
v : A := ∑ M in s, u M • b M
hv : v ∈ I'
h : ¬Submodule.comap (Algebra.linearMap R A) (↑↑(Units.mkOfMulEqOne I I' hinv') * Submodule.span R {v}) = ⊤
M : Ideal R
hJM : Submodule.comap (Algebra.linearMap R A) (↑↑(Units.mkOfMulEqOne I I' hinv') * Submodule.span R {v}) ≤ M
hM : M ∈ Set.Finite.toFinset hf
this : ∀ a ∈ I, ∀ b ∈ I', ∃ c, (algebraMap R A) c = a * b
⊢ a M * v ∈ IsLocalization.coeSubmodule A M

Next tactic:
obtain ⟨c, hc⟩ := this _ (ha M hM) v hv
/-- A Dedekind domain is a PID if its set of primes is finite. -/
theorem IsPrincipalIdealRing.of_finite_primes [IsDomain R] [IsDedekindDomain R]
    (h : {I : Ideal R | I.IsPrime}.Finite) : IsPrincipalIdealRing R :=
  ⟨fun I => by
    

Proof state:
R : Type u_1
inst✝² : CommRing R
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
h : Set.Finite {I | IsPrime I}
I : Ideal R
⊢ Submodule.IsPrincipal I

Next tactic:
obtain rfl | hI := eq_or_ne I ⊥
/-- A Dedekind domain is a PID if its set of primes is finite. -/
theorem IsPrincipalIdealRing.of_finite_primes [IsDomain R] [IsDedekindDomain R]
    (h : {I : Ideal R | I.IsPrime}.Finite) : IsPrincipalIdealRing R :=
  ⟨fun I => by
    obtain rfl | hI := eq_or_ne I ⊥
    · 

Proof state:
case inl
R : Type u_1
inst✝² : CommRing R
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
h : Set.Finite {I | IsPrime I}
⊢ Submodule.IsPrincipal ⊥

Next tactic:
exact bot_isPrincipal
/-- A Dedekind domain is a PID if its set of primes is finite. -/
theorem IsPrincipalIdealRing.of_finite_primes [IsDomain R] [IsDedekindDomain R]
    (h : {I : Ideal R | I.IsPrime}.Finite) : IsPrincipalIdealRing R :=
  ⟨fun I => by
    obtain rfl | hI := eq_or_ne I ⊥
    · exact bot_isPrincipal
    

Proof state:
case inr
R : Type u_1
inst✝² : CommRing R
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
h : Set.Finite {I | IsPrime I}
I : Ideal R
hI : I ≠ ⊥
⊢ Submodule.IsPrincipal I

Next tactic:
apply Ideal.IsPrincipal.of_finite_maximals_of_isUnit
/-- A Dedekind domain is a PID if its set of primes is finite. -/
theorem IsPrincipalIdealRing.of_finite_primes [IsDomain R] [IsDedekindDomain R]
    (h : {I : Ideal R | I.IsPrime}.Finite) : IsPrincipalIdealRing R :=
  ⟨fun I => by
    obtain rfl | hI := eq_or_ne I ⊥
    · exact bot_isPrincipal
    apply Ideal.IsPrincipal.of_finite_maximals_of_isUnit
    · 

Proof state:
case inr.hf
R : Type u_1
inst✝² : CommRing R
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
h : Set.Finite {I | IsPrime I}
I : Ideal R
hI : I ≠ ⊥
⊢ Set.Finite {I | IsMaximal I}

Next tactic:
apply h.subset
/-- A Dedekind domain is a PID if its set of primes is finite. -/
theorem IsPrincipalIdealRing.of_finite_primes [IsDomain R] [IsDedekindDomain R]
    (h : {I : Ideal R | I.IsPrime}.Finite) : IsPrincipalIdealRing R :=
  ⟨fun I => by
    obtain rfl | hI := eq_or_ne I ⊥
    · exact bot_isPrincipal
    apply Ideal.IsPrincipal.of_finite_maximals_of_isUnit
    · apply h.subset; 

Proof state:
case inr.hf
R : Type u_1
inst✝² : CommRing R
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
h : Set.Finite {I | IsPrime I}
I : Ideal R
hI : I ≠ ⊥
⊢ {I | IsMaximal I} ⊆ {I | IsPrime I}

Next tactic:
exact @Ideal.IsMaximal.isPrime _ _
/-- A Dedekind domain is a PID if its set of primes is finite. -/
theorem IsPrincipalIdealRing.of_finite_primes [IsDomain R] [IsDedekindDomain R]
    (h : {I : Ideal R | I.IsPrime}.Finite) : IsPrincipalIdealRing R :=
  ⟨fun I => by
    obtain rfl | hI := eq_or_ne I ⊥
    · exact bot_isPrincipal
    apply Ideal.IsPrincipal.of_finite_maximals_of_isUnit
    · apply h.subset; exact @Ideal.IsMaximal.isPrime _ _
    · 

Proof state:
case inr.hI
R : Type u_1
inst✝² : CommRing R
inst✝¹ : IsDomain R
inst✝ : IsDedekindDomain R
h : Set.Finite {I | IsPrime I}
I : Ideal R
hI : I ≠ ⊥
⊢ IsUnit ↑I

Next tactic:
exact isUnit_of_mul_eq_one _ _ (FractionalIdeal.coe_ideal_mul_inv I hI)
/-- If `p` is a prime in the Dedekind domain `R`, `S` an extension of `R` and `Sₚ` the localization
of `S` at `p`, then all primes in `Sₚ` are factors of the image of `p` in `Sₚ`. -/
theorem IsLocalization.OverPrime.mem_normalizedFactors_of_isPrime [DecidableEq (Ideal Sₚ)]
    {P : Ideal Sₚ} (hP : IsPrime P) (hP0 : P ≠ ⊥) :
    P ∈ normalizedFactors (Ideal.map (algebraMap R Sₚ) p) := by
  

Proof state:
R : Type u_1
inst✝¹⁶ : CommRing R
inst✝¹⁵ : IsDomain R
inst✝¹⁴ : IsDedekindDomain R
S : Type u_2
inst✝¹³ : CommRing S
inst✝¹² : IsDomain S
inst✝¹¹ : Algebra R S
inst✝¹⁰ : Module.Free R S
inst✝⁹ : Module.Finite R S
p : Ideal R
hp0 : p ≠ ⊥
inst✝⁸ : IsPrime p
Sₚ : Type u_3
inst✝⁷ : CommRing Sₚ
inst✝⁶ : Algebra S Sₚ
inst✝⁵ : IsLocalization (Algebra.algebraMapSubmonoid S (primeCompl p)) Sₚ
inst✝⁴ : Algebra R Sₚ
inst✝³ : IsScalarTower R S Sₚ
inst✝² : IsDomain Sₚ
inst✝¹ : IsDedekindDomain Sₚ
inst✝ : DecidableEq (Ideal Sₚ)
P : Ideal Sₚ
hP : IsPrime P
hP0 : P ≠ ⊥
⊢ P ∈ normalizedFactors (Ideal.map (algebraMap R Sₚ) p)

Next tactic:
have non_zero_div : Algebra.algebraMapSubmonoid S p.primeCompl ≤ S⁰ :=
    map_le_nonZeroDivisors_of_injective _ (NoZeroSMulDivisors.algebraMap_injective _ _)
      p.primeCompl_le_nonZeroDivisors
/-- If `p` is a prime in the Dedekind domain `R`, `S` an extension of `R` and `Sₚ` the localization
of `S` at `p`, then all primes in `Sₚ` are factors of the image of `p` in `Sₚ`. -/
theorem IsLocalization.OverPrime.mem_normalizedFactors_of_isPrime [DecidableEq (Ideal Sₚ)]
    {P : Ideal Sₚ} (hP : IsPrime P) (hP0 : P ≠ ⊥) :
    P ∈ normalizedFactors (Ideal.map (algebraMap R Sₚ) p) := by
  have non_zero_div : Algebra.algebraMapSubmonoid S p.primeCompl ≤ S⁰ :=
    map_le_nonZeroDivisors_of_injective _ (NoZeroSMulDivisors.algebraMap_injective _ _)
      p.primeCompl_le_nonZeroDivisors
  

Proof state:
R : Type u_1
inst✝¹⁶ : CommRing R
inst✝¹⁵ : IsDomain R
inst✝¹⁴ : IsDedekindDomain R
S : Type u_2
inst✝¹³ : CommRing S
inst✝¹² : IsDomain S
inst✝¹¹ : Algebra R S
inst✝¹⁰ : Module.Free R S
inst✝⁹ : Module.Finite R S
p : Ideal R
hp0 : p ≠ ⊥
inst✝⁸ : IsPrime p
Sₚ : Type u_3
inst✝⁷ : CommRing Sₚ
inst✝⁶ : Algebra S Sₚ
inst✝⁵ : IsLocalization (Algebra.algebraMapSubmonoid S (primeCompl p)) Sₚ
inst✝⁴ : Algebra R Sₚ
inst✝³ : IsScalarTower R S Sₚ
inst✝² : IsDomain Sₚ
inst✝¹ : IsDedekindDomain Sₚ
inst✝ : DecidableEq (Ideal Sₚ)
P : Ideal Sₚ
hP : IsPrime P
hP0 : P ≠ ⊥
non_zero_div : Algebra.algebraMapSubmonoid S (primeCompl p) ≤ S⁰
⊢ P ∈ normalizedFactors (Ideal.map (algebraMap R Sₚ) p)

Next tactic:
letI : Algebra (Localization.AtPrime p) Sₚ := localizationAlgebra p.primeCompl S
/-- If `p` is a prime in the Dedekind domain `R`, `S` an extension of `R` and `Sₚ` the localization
of `S` at `p`, then all primes in `Sₚ` are factors of the image of `p` in `Sₚ`. -/
theorem IsLocalization.OverPrime.mem_normalizedFactors_of_isPrime [DecidableEq (Ideal Sₚ)]
    {P : Ideal Sₚ} (hP : IsPrime P) (hP0 : P ≠ ⊥) :
    P ∈ normalizedFactors (Ideal.map (algebraMap R Sₚ) p) := by
  have non_zero_div : Algebra.algebraMapSubmonoid S p.primeCompl ≤ S⁰ :=
    map_le_nonZeroDivisors_of_injective _ (NoZeroSMulDivisors.algebraMap_injective _ _)
      p.primeCompl_le_nonZeroDivisors
  letI : Algebra (Localization.AtPrime p) Sₚ := localizationAlgebra p.primeCompl S
  

Proof state:
R : Type u_1
inst✝¹⁶ : CommRing R
inst✝¹⁵ : IsDomain R
inst✝¹⁴ : IsDedekindDomain R
S : Type u_2
inst✝¹³ : CommRing S
inst✝¹² : IsDomain S
inst✝¹¹ : Algebra R S
inst✝¹⁰ : Module.Free R S
inst✝⁹ : Module.Finite R S
p : Ideal R
hp0 : p ≠ ⊥
inst✝⁸ : IsPrime p
Sₚ : Type u_3
inst✝⁷ : CommRing Sₚ
inst✝⁶ : Algebra S Sₚ
inst✝⁵ : IsLocalization (Algebra.algebraMapSubmonoid S (primeCompl p)) Sₚ
inst✝⁴ : Algebra R Sₚ
inst✝³ : IsScalarTower R S Sₚ
inst✝² : IsDomain Sₚ
inst✝¹ : IsDedekindDomain Sₚ
inst✝ : DecidableEq (Ideal Sₚ)
P : Ideal Sₚ
hP : IsPrime P
hP0 : P ≠ ⊥
non_zero_div : Algebra.algebraMapSubmonoid S (primeCompl p) ≤ S⁰
this : Algebra (Localization.AtPrime p) Sₚ := localizationAlgebra (primeCompl p) S
⊢ P ∈ normalizedFactors (Ideal.map (algebraMap R Sₚ) p)

Next tactic:
haveI : IsScalarTower R (Localization.AtPrime p) Sₚ :=
    IsScalarTower.of_algebraMap_eq fun x => by
      -- Porting note: replaced `erw` with a `rw` followed by `exact` to help infer implicits
      rw [IsScalarTower.algebraMap_apply R S]
      exact (IsLocalization.map_eq (T := Algebra.algebraMapSubmonoid S (primeCompl p))
        (Submonoid.le_comap_map _) x).symm
/-- If `p` is a prime in the Dedekind domain `R`, `S` an extension of `R` and `Sₚ` the localization
of `S` at `p`, then all primes in `Sₚ` are factors of the image of `p` in `Sₚ`. -/
theorem IsLocalization.OverPrime.mem_normalizedFactors_of_isPrime [DecidableEq (Ideal Sₚ)]
    {P : Ideal Sₚ} (hP : IsPrime P) (hP0 : P ≠ ⊥) :
    P ∈ normalizedFactors (Ideal.map (algebraMap R Sₚ) p) := by
  have non_zero_div : Algebra.algebraMapSubmonoid S p.primeCompl ≤ S⁰ :=
    map_le_nonZeroDivisors_of_injective _ (NoZeroSMulDivisors.algebraMap_injective _ _)
      p.primeCompl_le_nonZeroDivisors
  letI : Algebra (Localization.AtPrime p) Sₚ := localizationAlgebra p.primeCompl S
  haveI : IsScalarTower R (Localization.AtPrime p) Sₚ :=
    IsScalarTower.of_algebraMap_eq fun x => by
      -- Porting note: replaced `erw` with a `rw` followed by `exact` to help infer implicits
      

Proof state:
R : Type u_1
inst✝¹⁶ : CommRing R
inst✝¹⁵ : IsDomain R
inst✝¹⁴ : IsDedekindDomain R
S : Type u_2
inst✝¹³ : CommRing S
inst✝¹² : IsDomain S
inst✝¹¹ : Algebra R S
inst✝¹⁰ : Module.Free R S
inst✝⁹ : Module.Finite R S
p : Ideal R
hp0 : p ≠ ⊥
inst✝⁸ : IsPrime p
Sₚ : Type u_3
inst✝⁷ : CommRing Sₚ
inst✝⁶ : Algebra S Sₚ
inst✝⁵ : IsLocalization (Algebra.algebraMapSubmonoid S (primeCompl p)) Sₚ
inst✝⁴ : Algebra R Sₚ
inst✝³ : IsScalarTower R S Sₚ
inst✝² : IsDomain Sₚ
inst✝¹ : IsDedekindDomain Sₚ
inst✝ : DecidableEq (Ideal Sₚ)
P : Ideal Sₚ
hP : IsPrime P
hP0 : P ≠ ⊥
non_zero_div : Algebra.algebraMapSubmonoid S (primeCompl p) ≤ S⁰
this : Algebra (Localization.AtPrime p) Sₚ := localizationAlgebra (primeCompl p) S
x : R
⊢ (algebraMap R Sₚ) x = (algebraMap (Localization.AtPrime p) Sₚ) ((algebraMap R (Localization.AtPrime p)) x)

Next tactic:
rw [IsScalarTower.algebraMap_apply R S]
/-- If `p` is a prime in the Dedekind domain `R`, `S` an extension of `R` and `Sₚ` the localization
of `S` at `p`, then all primes in `Sₚ` are factors of the image of `p` in `Sₚ`. -/
theorem IsLocalization.OverPrime.mem_normalizedFactors_of_isPrime [DecidableEq (Ideal Sₚ)]
    {P : Ideal Sₚ} (hP : IsPrime P) (hP0 : P ≠ ⊥) :
    P ∈ normalizedFactors (Ideal.map (algebraMap R Sₚ) p) := by
  have non_zero_div : Algebra.algebraMapSubmonoid S p.primeCompl ≤ S⁰ :=
    map_le_nonZeroDivisors_of_injective _ (NoZeroSMulDivisors.algebraMap_injective _ _)
      p.primeCompl_le_nonZeroDivisors
  letI : Algebra (Localization.AtPrime p) Sₚ := localizationAlgebra p.primeCompl S
  haveI : IsScalarTower R (Localization.AtPrime p) Sₚ :=
    IsScalarTower.of_algebraMap_eq fun x => by
      -- Porting note: replaced `erw` with a `rw` followed by `exact` to help infer implicits
      rw [IsScalarTower.algebraMap_apply R S]
      

Proof state:
R : Type u_1
inst✝¹⁶ : CommRing R
inst✝¹⁵ : IsDomain R
inst✝¹⁴ : IsDedekindDomain R
S : Type u_2
inst✝¹³ : CommRing S
inst✝¹² : IsDomain S
inst✝¹¹ : Algebra R S
inst✝¹⁰ : Module.Free R S
inst✝⁹ : Module.Finite R S
p : Ideal R
hp0 : p ≠ ⊥
inst✝⁸ : IsPrime p
Sₚ : Type u_3
inst✝⁷ : CommRing Sₚ
inst✝⁶ : Algebra S Sₚ
inst✝⁵ : IsLocalization (Algebra.algebraMapSubmonoid S (primeCompl p)) Sₚ
inst✝⁴ : Algebra R Sₚ
inst✝³ : IsScalarTower R S Sₚ
inst✝² : IsDomain Sₚ
inst✝¹ : IsDedekindDomain Sₚ
inst✝ : DecidableEq (Ideal Sₚ)
P : Ideal Sₚ
hP : IsPrime P
hP0 : P ≠ ⊥
non_zero_div : Algebra.algebraMapSubmonoid S (primeCompl p) ≤ S⁰
this : Algebra (Localization.AtPrime p) Sₚ := localizationAlgebra (primeCompl p) S
x : R
⊢ (algebraMap S Sₚ) ((algebraMap R S) x) =
    (algebraMap (Localization.AtPrime p) Sₚ) ((algebraMap R (Localization.AtPrime p)) x)

Next tactic:
exact (IsLocalization.map_eq (T := Algebra.algebraMapSubmonoid S (primeCompl p))
        (Submonoid.le_comap_map _) x).symm
/-- If `p` is a prime in the Dedekind domain `R`, `S` an extension of `R` and `Sₚ` the localization
of `S` at `p`, then all primes in `Sₚ` are factors of the image of `p` in `Sₚ`. -/
theorem IsLocalization.OverPrime.mem_normalizedFactors_of_isPrime [DecidableEq (Ideal Sₚ)]
    {P : Ideal Sₚ} (hP : IsPrime P) (hP0 : P ≠ ⊥) :
    P ∈ normalizedFactors (Ideal.map (algebraMap R Sₚ) p) := by
  have non_zero_div : Algebra.algebraMapSubmonoid S p.primeCompl ≤ S⁰ :=
    map_le_nonZeroDivisors_of_injective _ (NoZeroSMulDivisors.algebraMap_injective _ _)
      p.primeCompl_le_nonZeroDivisors
  letI : Algebra (Localization.AtPrime p) Sₚ := localizationAlgebra p.primeCompl S
  haveI : IsScalarTower R (Localization.AtPrime p) Sₚ :=
    IsScalarTower.of_algebraMap_eq fun x => by
      -- Porting note: replaced `erw` with a `rw` followed by `exact` to help infer implicits
      rw [IsScalarTower.algebraMap_apply R S]
      exact (IsLocalization.map_eq (T := Algebra.algebraMapSubmonoid S (primeCompl p))
        (Submonoid.le_comap_map _) x).symm
  

Proof state:
R : Type u_1
inst✝¹⁶ : CommRing R
inst✝¹⁵ : IsDomain R
inst✝¹⁴ : IsDedekindDomain R
S : Type u_2
inst✝¹³ : CommRing S
inst✝¹² : IsDomain S
inst✝¹¹ : Algebra R S
inst✝¹⁰ : Module.Free R S
inst✝⁹ : Module.Finite R S
p : Ideal R
hp0 : p ≠ ⊥
inst✝⁸ : IsPrime p
Sₚ : Type u_3
inst✝⁷ : CommRing Sₚ
inst✝⁶ : Algebra S Sₚ
inst✝⁵ : IsLocalization (Algebra.algebraMapSubmonoid S (primeCompl p)) Sₚ
inst✝⁴ : Algebra R Sₚ
inst✝³ : IsScalarTower R S Sₚ
inst✝² : IsDomain Sₚ
inst✝¹ : IsDedekindDomain Sₚ
inst✝ : DecidableEq (Ideal Sₚ)
P : Ideal Sₚ
hP : IsPrime P
hP0 : P ≠ ⊥
non_zero_div : Algebra.algebraMapSubmonoid S (primeCompl p) ≤ S⁰
this✝ : Algebra (Localization.AtPrime p) Sₚ := localizationAlgebra (primeCompl p) S
this : IsScalarTower R (Localization.AtPrime p) Sₚ
⊢ P ∈ normalizedFactors (Ideal.map (algebraMap R Sₚ) p)

Next tactic:
obtain ⟨pid, p', ⟨hp'0, hp'p⟩, hpu⟩ :=
    (DiscreteValuationRing.iff_pid_with_one_nonzero_prime (Localization.AtPrime p)).mp
      (IsLocalization.AtPrime.discreteValuationRing_of_dedekind_domain R hp0 _)
/-- If `p` is a prime in the Dedekind domain `R`, `S` an extension of `R` and `Sₚ` the localization
of `S` at `p`, then all primes in `Sₚ` are factors of the image of `p` in `Sₚ`. -/
theorem IsLocalization.OverPrime.mem_normalizedFactors_of_isPrime [DecidableEq (Ideal Sₚ)]
    {P : Ideal Sₚ} (hP : IsPrime P) (hP0 : P ≠ ⊥) :
    P ∈ normalizedFactors (Ideal.map (algebraMap R Sₚ) p) := by
  have non_zero_div : Algebra.algebraMapSubmonoid S p.primeCompl ≤ S⁰ :=
    map_le_nonZeroDivisors_of_injective _ (NoZeroSMulDivisors.algebraMap_injective _ _)
      p.primeCompl_le_nonZeroDivisors
  letI : Algebra (Localization.AtPrime p) Sₚ := localizationAlgebra p.primeCompl S
  haveI : IsScalarTower R (Localization.AtPrime p) Sₚ :=
    IsScalarTower.of_algebraMap_eq fun x => by
      -- Porting note: replaced `erw` with a `rw` followed by `exact` to help infer implicits
      rw [IsScalarTower.algebraMap_apply R S]
      exact (IsLocalization.map_eq (T := Algebra.algebraMapSubmonoid S (primeCompl p))
        (Submonoid.le_comap_map _) x).symm
  obtain ⟨pid, p', ⟨hp'0, hp'p⟩, hpu⟩ :=
    (DiscreteValuationRing.iff_pid_with_one_nonzero_prime (Localization.AtPrime p)).mp
      (IsLocalization.AtPrime.discreteValuationRing_of_dedekind_domain R hp0 _)
  

Proof state:
case intro.intro.intro.intro
R : Type u_1
inst✝¹⁶ : CommRing R
inst✝¹⁵ : IsDomain R
inst✝¹⁴ : IsDedekindDomain R
S : Type u_2
inst✝¹³ : CommRing S
inst✝¹² : IsDomain S
inst✝¹¹ : Algebra R S
inst✝¹⁰ : Module.Free R S
inst✝⁹ : Module.Finite R S
p : Ideal R
hp0 : p ≠ ⊥
inst✝⁸ : IsPrime p
Sₚ : Type u_3
inst✝⁷ : CommRing Sₚ
inst✝⁶ : Algebra S Sₚ
inst✝⁵ : IsLocalization (Algebra.algebraMapSubmonoid S (primeCompl p)) Sₚ
inst✝⁴ : Algebra R Sₚ
inst✝³ : IsScalarTower R S Sₚ
inst✝² : IsDomain Sₚ
inst✝¹ : IsDedekindDomain Sₚ
inst✝ : DecidableEq (Ideal Sₚ)
P : Ideal Sₚ
hP : IsPrime P
hP0 : P ≠ ⊥
non_zero_div : Algebra.algebraMapSubmonoid S (primeCompl p) ≤ S⁰
this✝ : Algebra (Localization.AtPrime p) Sₚ := localizationAlgebra (primeCompl p) S
this : IsScalarTower R (Localization.AtPrime p) Sₚ
pid : IsPrincipalIdealRing (Localization.AtPrime p)
p' : Ideal (Localization.AtPrime p)
hpu : ∀ (y : Ideal (Localization.AtPrime p)), (fun P => P ≠ ⊥ ∧ IsPrime P) y → y = p'
hp'0 : p' ≠ ⊥
hp'p : IsPrime p'
⊢ P ∈ normalizedFactors (Ideal.map (algebraMap R Sₚ) p)

Next tactic:
have : LocalRing.maximalIdeal (Localization.AtPrime p) ≠ ⊥ := by
    rw [Submodule.ne_bot_iff] at hp0 ⊢
    obtain ⟨x, x_mem, x_ne⟩ := hp0
    exact
      ⟨algebraMap _ _ x, (IsLocalization.AtPrime.to_map_mem_maximal_iff _ _ _).mpr x_mem,
        IsLocalization.to_map_ne_zero_of_mem_nonZeroDivisors _ p.primeCompl_le_nonZeroDivisors
          (mem_nonZeroDivisors_of_ne_zero x_ne)⟩
/-- If `p` is a prime in the Dedekind domain `R`, `S` an extension of `R` and `Sₚ` the localization
of `S` at `p`, then all primes in `Sₚ` are factors of the image of `p` in `Sₚ`. -/
theorem IsLocalization.OverPrime.mem_normalizedFactors_of_isPrime [DecidableEq (Ideal Sₚ)]
    {P : Ideal Sₚ} (hP : IsPrime P) (hP0 : P ≠ ⊥) :
    P ∈ normalizedFactors (Ideal.map (algebraMap R Sₚ) p) := by
  have non_zero_div : Algebra.algebraMapSubmonoid S p.primeCompl ≤ S⁰ :=
    map_le_nonZeroDivisors_of_injective _ (NoZeroSMulDivisors.algebraMap_injective _ _)
      p.primeCompl_le_nonZeroDivisors
  letI : Algebra (Localization.AtPrime p) Sₚ := localizationAlgebra p.primeCompl S
  haveI : IsScalarTower R (Localization.AtPrime p) Sₚ :=
    IsScalarTower.of_algebraMap_eq fun x => by
      -- Porting note: replaced `erw` with a `rw` followed by `exact` to help infer implicits
      rw [IsScalarTower.algebraMap_apply R S]
      exact (IsLocalization.map_eq (T := Algebra.algebraMapSubmonoid S (primeCompl p))
        (Submonoid.le_comap_map _) x).symm
  obtain ⟨pid, p', ⟨hp'0, hp'p⟩, hpu⟩ :=
    (DiscreteValuationRing.iff_pid_with_one_nonzero_prime (Localization.AtPrime p)).mp
      (IsLocalization.AtPrime.discreteValuationRing_of_dedekind_domain R hp0 _)
  have : LocalRing.maximalIdeal (Localization.AtPrime p) ≠ ⊥ := by
    

Proof state:
R : Type u_1
inst✝¹⁶ : CommRing R
inst✝¹⁵ : IsDomain R
inst✝¹⁴ : IsDedekindDomain R
S : Type u_2
inst✝¹³ : CommRing S
inst✝¹² : IsDomain S
inst✝¹¹ : Algebra R S
inst✝¹⁰ : Module.Free R S
inst✝⁹ : Module.Finite R S
p : Ideal R
hp0 : p ≠ ⊥
inst✝⁸ : IsPrime p
Sₚ : Type u_3
inst✝⁷ : CommRing Sₚ
inst✝⁶ : Algebra S Sₚ
inst✝⁵ : IsLocalization (Algebra.algebraMapSubmonoid S (primeCompl p)) Sₚ
inst✝⁴ : Algebra R Sₚ
inst✝³ : IsScalarTower R S Sₚ
inst✝² : IsDomain Sₚ
inst✝¹ : IsDedekindDomain Sₚ
inst✝ : DecidableEq (Ideal Sₚ)
P : Ideal Sₚ
hP : IsPrime P
hP0 : P ≠ ⊥
non_zero_div : Algebra.algebraMapSubmonoid S (primeCompl p) ≤ S⁰
this✝ : Algebra (Localization.AtPrime p) Sₚ := localizationAlgebra (primeCompl p) S
this : IsScalarTower R (Localization.AtPrime p) Sₚ
pid : IsPrincipalIdealRing (Localization.AtPrime p)
p' : Ideal (Localization.AtPrime p)
hpu : ∀ (y : Ideal (Localization.AtPrime p)), (fun P => P ≠ ⊥ ∧ IsPrime P) y → y = p'
hp'0 : p' ≠ ⊥
hp'p : IsPrime p'
⊢ LocalRing.maximalIdeal (Localization.AtPrime p) ≠ ⊥

Next tactic:
rw [Submodule.ne_bot_iff] at hp0 ⊢
/-- If `p` is a prime in the Dedekind domain `R`, `S` an extension of `R` and `Sₚ` the localization
of `S` at `p`, then all primes in `Sₚ` are factors of the image of `p` in `Sₚ`. -/
theorem IsLocalization.OverPrime.mem_normalizedFactors_of_isPrime [DecidableEq (Ideal Sₚ)]
    {P : Ideal Sₚ} (hP : IsPrime P) (hP0 : P ≠ ⊥) :
    P ∈ normalizedFactors (Ideal.map (algebraMap R Sₚ) p) := by
  have non_zero_div : Algebra.algebraMapSubmonoid S p.primeCompl ≤ S⁰ :=
    map_le_nonZeroDivisors_of_injective _ (NoZeroSMulDivisors.algebraMap_injective _ _)
      p.primeCompl_le_nonZeroDivisors
  letI : Algebra (Localization.AtPrime p) Sₚ := localizationAlgebra p.primeCompl S
  haveI : IsScalarTower R (Localization.AtPrime p) Sₚ :=
    IsScalarTower.of_algebraMap_eq fun x => by
      -- Porting note: replaced `erw` with a `rw` followed by `exact` to help infer implicits
      rw [IsScalarTower.algebraMap_apply R S]
      exact (IsLocalization.map_eq (T := Algebra.algebraMapSubmonoid S (primeCompl p))
        (Submonoid.le_comap_map _) x).symm
  obtain ⟨pid, p', ⟨hp'0, hp'p⟩, hpu⟩ :=
    (DiscreteValuationRing.iff_pid_with_one_nonzero_prime (Localization.AtPrime p)).mp
      (IsLocalization.AtPrime.discreteValuationRing_of_dedekind_domain R hp0 _)
  have : LocalRing.maximalIdeal (Localization.AtPrime p) ≠ ⊥ := by
    rw [Submodule.ne_bot_iff] at hp0 ⊢
    

Proof state:
R : Type u_1
inst✝¹⁶ : CommRing R
inst✝¹⁵ : IsDomain R
inst✝¹⁴ : IsDedekindDomain R
S : Type u_2
inst✝¹³ : CommRing S
inst✝¹² : IsDomain S
inst✝¹¹ : Algebra R S
inst✝¹⁰ : Module.Free R S
inst✝⁹ : Module.Finite R S
p : Ideal R
hp0 : ∃ x ∈ p, x ≠ 0
inst✝⁸ : IsPrime p
Sₚ : Type u_3
inst✝⁷ : CommRing Sₚ
inst✝⁶ : Algebra S Sₚ
inst✝⁵ : IsLocalization (Algebra.algebraMapSubmonoid S (primeCompl p)) Sₚ
inst✝⁴ : Algebra R Sₚ
inst✝³ : IsScalarTower R S Sₚ
inst✝² : IsDomain Sₚ
inst✝¹ : IsDedekindDomain Sₚ
inst✝ : DecidableEq (Ideal Sₚ)
P : Ideal Sₚ
hP : IsPrime P
hP0 : P ≠ ⊥
non_zero_div : Algebra.algebraMapSubmonoid S (primeCompl p) ≤ S⁰
this✝ : Algebra (Localization.AtPrime p) Sₚ := localizationAlgebra (primeCompl p) S
this : IsScalarTower R (Localization.AtPrime p) Sₚ
pid : IsPrincipalIdealRing (Localization.AtPrime p)
p' : Ideal (Localization.AtPrime p)
hpu : ∀ (y : Ideal (Localization.AtPrime p)), (fun P => P ≠ ⊥ ∧ IsPrime P) y → y = p'
hp'0 : p' ≠ ⊥
hp'p : IsPrime p'
⊢ ∃ x ∈ LocalRing.maximalIdeal (Localization.AtPrime p), x ≠ 0

Next tactic:
obtain ⟨x, x_mem, x_ne⟩ := hp0