l3lab/ntp-mathlib huggingface dataset:
/-- More general going-up theorem than `exists_ideal_over_prime_of_isIntegral_of_isDomain`.
TODO: Version of going-up theorem with arbitrary length chains (by induction on this)?
  Not sure how best to write an ascending chain in Lean -/
theorem exists_ideal_over_prime_of_isIntegral_of_isPrime
    (H : Algebra.IsIntegral R S) (P : Ideal R) [IsPrime P]
    (I : Ideal S) [IsPrime I] (hIP : I.comap (algebraMap R S) ≤ P) :
    ∃ Q ≥ I, IsPrime Q ∧ Q.comap (algebraMap R S) = P := by
  obtain ⟨Q' : Ideal (S ⧸ I), ⟨Q'_prime, hQ'⟩⟩ :=
    @exists_ideal_over_prime_of_isIntegral_of_isDomain (R ⧸ I.comap (algebraMap R S)) _ (S ⧸ I) _
      Ideal.quotientAlgebra _ H.quotient
      (map (Ideal.Quotient.mk (I.comap (algebraMap R S))) P)
      (map_isPrime_of_surjective Quotient.mk_surjective (by simp [hIP]))
      (le_trans (le_of_eq ((RingHom.injective_iff_ker_eq_bot _).1 algebraMap_quotient_injective))
        bot_le)
  refine' ⟨Q'.comap _, le_trans (le_of_eq mk_ker.symm) (ker_le_comap _), ⟨comap_isPrime _ Q', _⟩⟩
  

Proof state:
case intro.intro
R : Type u_1
inst✝⁴ : CommRing R
S : Type u_2
inst✝³ : CommRing S
f : R →+* S
I✝ J : Ideal S
inst✝² : Algebra R S
H : Algebra.IsIntegral R S
P : Ideal R
inst✝¹ : IsPrime P
I : Ideal S
inst✝ : IsPrime I
hIP : comap (algebraMap R S) I ≤ P
Q' : Ideal (S ⧸ I)
Q'_prime : IsPrime Q'
hQ' : comap (algebraMap (R ⧸ comap (algebraMap R S) I) (S ⧸ I)) Q' = map (Quotient.mk (comap (algebraMap R S) I)) P
⊢ comap (algebraMap R S) (comap (Quotient.mk I) Q') = P

Next tactic:
rw [comap_comap]
/-- More general going-up theorem than `exists_ideal_over_prime_of_isIntegral_of_isDomain`.
TODO: Version of going-up theorem with arbitrary length chains (by induction on this)?
  Not sure how best to write an ascending chain in Lean -/
theorem exists_ideal_over_prime_of_isIntegral_of_isPrime
    (H : Algebra.IsIntegral R S) (P : Ideal R) [IsPrime P]
    (I : Ideal S) [IsPrime I] (hIP : I.comap (algebraMap R S) ≤ P) :
    ∃ Q ≥ I, IsPrime Q ∧ Q.comap (algebraMap R S) = P := by
  obtain ⟨Q' : Ideal (S ⧸ I), ⟨Q'_prime, hQ'⟩⟩ :=
    @exists_ideal_over_prime_of_isIntegral_of_isDomain (R ⧸ I.comap (algebraMap R S)) _ (S ⧸ I) _
      Ideal.quotientAlgebra _ H.quotient
      (map (Ideal.Quotient.mk (I.comap (algebraMap R S))) P)
      (map_isPrime_of_surjective Quotient.mk_surjective (by simp [hIP]))
      (le_trans (le_of_eq ((RingHom.injective_iff_ker_eq_bot _).1 algebraMap_quotient_injective))
        bot_le)
  refine' ⟨Q'.comap _, le_trans (le_of_eq mk_ker.symm) (ker_le_comap _), ⟨comap_isPrime _ Q', _⟩⟩
  rw [comap_comap]
  

Proof state:
case intro.intro
R : Type u_1
inst✝⁴ : CommRing R
S : Type u_2
inst✝³ : CommRing S
f : R →+* S
I✝ J : Ideal S
inst✝² : Algebra R S
H : Algebra.IsIntegral R S
P : Ideal R
inst✝¹ : IsPrime P
I : Ideal S
inst✝ : IsPrime I
hIP : comap (algebraMap R S) I ≤ P
Q' : Ideal (S ⧸ I)
Q'_prime : IsPrime Q'
hQ' : comap (algebraMap (R ⧸ comap (algebraMap R S) I) (S ⧸ I)) Q' = map (Quotient.mk (comap (algebraMap R S) I)) P
⊢ comap (RingHom.comp (Quotient.mk I) (algebraMap R S)) Q' = P

Next tactic:
refine' _root_.trans _ (_root_.trans (congr_arg (comap (Ideal.Quotient.mk
    (comap (algebraMap R S) I))) hQ') _)
/-- More general going-up theorem than `exists_ideal_over_prime_of_isIntegral_of_isDomain`.
TODO: Version of going-up theorem with arbitrary length chains (by induction on this)?
  Not sure how best to write an ascending chain in Lean -/
theorem exists_ideal_over_prime_of_isIntegral_of_isPrime
    (H : Algebra.IsIntegral R S) (P : Ideal R) [IsPrime P]
    (I : Ideal S) [IsPrime I] (hIP : I.comap (algebraMap R S) ≤ P) :
    ∃ Q ≥ I, IsPrime Q ∧ Q.comap (algebraMap R S) = P := by
  obtain ⟨Q' : Ideal (S ⧸ I), ⟨Q'_prime, hQ'⟩⟩ :=
    @exists_ideal_over_prime_of_isIntegral_of_isDomain (R ⧸ I.comap (algebraMap R S)) _ (S ⧸ I) _
      Ideal.quotientAlgebra _ H.quotient
      (map (Ideal.Quotient.mk (I.comap (algebraMap R S))) P)
      (map_isPrime_of_surjective Quotient.mk_surjective (by simp [hIP]))
      (le_trans (le_of_eq ((RingHom.injective_iff_ker_eq_bot _).1 algebraMap_quotient_injective))
        bot_le)
  refine' ⟨Q'.comap _, le_trans (le_of_eq mk_ker.symm) (ker_le_comap _), ⟨comap_isPrime _ Q', _⟩⟩
  rw [comap_comap]
  refine' _root_.trans _ (_root_.trans (congr_arg (comap (Ideal.Quotient.mk
    (comap (algebraMap R S) I))) hQ') _)
  · 

Proof state:
case intro.intro.refine'_1
R : Type u_1
inst✝⁴ : CommRing R
S : Type u_2
inst✝³ : CommRing S
f : R →+* S
I✝ J : Ideal S
inst✝² : Algebra R S
H : Algebra.IsIntegral R S
P : Ideal R
inst✝¹ : IsPrime P
I : Ideal S
inst✝ : IsPrime I
hIP : comap (algebraMap R S) I ≤ P
Q' : Ideal (S ⧸ I)
Q'_prime : IsPrime Q'
hQ' : comap (algebraMap (R ⧸ comap (algebraMap R S) I) (S ⧸ I)) Q' = map (Quotient.mk (comap (algebraMap R S) I)) P
⊢ comap (RingHom.comp (Quotient.mk I) (algebraMap R S)) Q' =
    comap (Quotient.mk (comap (algebraMap R S) I)) (comap (algebraMap (R ⧸ comap (algebraMap R S) I) (S ⧸ I)) Q')

Next tactic:
rw [comap_comap]
/-- More general going-up theorem than `exists_ideal_over_prime_of_isIntegral_of_isDomain`.
TODO: Version of going-up theorem with arbitrary length chains (by induction on this)?
  Not sure how best to write an ascending chain in Lean -/
theorem exists_ideal_over_prime_of_isIntegral_of_isPrime
    (H : Algebra.IsIntegral R S) (P : Ideal R) [IsPrime P]
    (I : Ideal S) [IsPrime I] (hIP : I.comap (algebraMap R S) ≤ P) :
    ∃ Q ≥ I, IsPrime Q ∧ Q.comap (algebraMap R S) = P := by
  obtain ⟨Q' : Ideal (S ⧸ I), ⟨Q'_prime, hQ'⟩⟩ :=
    @exists_ideal_over_prime_of_isIntegral_of_isDomain (R ⧸ I.comap (algebraMap R S)) _ (S ⧸ I) _
      Ideal.quotientAlgebra _ H.quotient
      (map (Ideal.Quotient.mk (I.comap (algebraMap R S))) P)
      (map_isPrime_of_surjective Quotient.mk_surjective (by simp [hIP]))
      (le_trans (le_of_eq ((RingHom.injective_iff_ker_eq_bot _).1 algebraMap_quotient_injective))
        bot_le)
  refine' ⟨Q'.comap _, le_trans (le_of_eq mk_ker.symm) (ker_le_comap _), ⟨comap_isPrime _ Q', _⟩⟩
  rw [comap_comap]
  refine' _root_.trans _ (_root_.trans (congr_arg (comap (Ideal.Quotient.mk
    (comap (algebraMap R S) I))) hQ') _)
  · rw [comap_comap]
    

Proof state:
case intro.intro.refine'_1
R : Type u_1
inst✝⁴ : CommRing R
S : Type u_2
inst✝³ : CommRing S
f : R →+* S
I✝ J : Ideal S
inst✝² : Algebra R S
H : Algebra.IsIntegral R S
P : Ideal R
inst✝¹ : IsPrime P
I : Ideal S
inst✝ : IsPrime I
hIP : comap (algebraMap R S) I ≤ P
Q' : Ideal (S ⧸ I)
Q'_prime : IsPrime Q'
hQ' : comap (algebraMap (R ⧸ comap (algebraMap R S) I) (S ⧸ I)) Q' = map (Quotient.mk (comap (algebraMap R S) I)) P
⊢ comap (RingHom.comp (Quotient.mk I) (algebraMap R S)) Q' =
    comap (RingHom.comp (algebraMap (R ⧸ comap (algebraMap R S) I) (S ⧸ I)) (Quotient.mk (comap (algebraMap R S) I))) Q'

Next tactic:
exact congr_arg (comap . Q') (RingHom.ext fun r => rfl)
/-- More general going-up theorem than `exists_ideal_over_prime_of_isIntegral_of_isDomain`.
TODO: Version of going-up theorem with arbitrary length chains (by induction on this)?
  Not sure how best to write an ascending chain in Lean -/
theorem exists_ideal_over_prime_of_isIntegral_of_isPrime
    (H : Algebra.IsIntegral R S) (P : Ideal R) [IsPrime P]
    (I : Ideal S) [IsPrime I] (hIP : I.comap (algebraMap R S) ≤ P) :
    ∃ Q ≥ I, IsPrime Q ∧ Q.comap (algebraMap R S) = P := by
  obtain ⟨Q' : Ideal (S ⧸ I), ⟨Q'_prime, hQ'⟩⟩ :=
    @exists_ideal_over_prime_of_isIntegral_of_isDomain (R ⧸ I.comap (algebraMap R S)) _ (S ⧸ I) _
      Ideal.quotientAlgebra _ H.quotient
      (map (Ideal.Quotient.mk (I.comap (algebraMap R S))) P)
      (map_isPrime_of_surjective Quotient.mk_surjective (by simp [hIP]))
      (le_trans (le_of_eq ((RingHom.injective_iff_ker_eq_bot _).1 algebraMap_quotient_injective))
        bot_le)
  refine' ⟨Q'.comap _, le_trans (le_of_eq mk_ker.symm) (ker_le_comap _), ⟨comap_isPrime _ Q', _⟩⟩
  rw [comap_comap]
  refine' _root_.trans _ (_root_.trans (congr_arg (comap (Ideal.Quotient.mk
    (comap (algebraMap R S) I))) hQ') _)
  · rw [comap_comap]
    exact congr_arg (comap . Q') (RingHom.ext fun r => rfl)
  · 

Proof state:
case intro.intro.refine'_2
R : Type u_1
inst✝⁴ : CommRing R
S : Type u_2
inst✝³ : CommRing S
f : R →+* S
I✝ J : Ideal S
inst✝² : Algebra R S
H : Algebra.IsIntegral R S
P : Ideal R
inst✝¹ : IsPrime P
I : Ideal S
inst✝ : IsPrime I
hIP : comap (algebraMap R S) I ≤ P
Q' : Ideal (S ⧸ I)
Q'_prime : IsPrime Q'
hQ' : comap (algebraMap (R ⧸ comap (algebraMap R S) I) (S ⧸ I)) Q' = map (Quotient.mk (comap (algebraMap R S) I)) P
⊢ comap (Quotient.mk (comap (algebraMap R S) I)) (map (Quotient.mk (comap (algebraMap R S) I)) P) = P

Next tactic:
refine' _root_.trans (comap_map_of_surjective _ Quotient.mk_surjective _) (sup_eq_left.2 _)
/-- More general going-up theorem than `exists_ideal_over_prime_of_isIntegral_of_isDomain`.
TODO: Version of going-up theorem with arbitrary length chains (by induction on this)?
  Not sure how best to write an ascending chain in Lean -/
theorem exists_ideal_over_prime_of_isIntegral_of_isPrime
    (H : Algebra.IsIntegral R S) (P : Ideal R) [IsPrime P]
    (I : Ideal S) [IsPrime I] (hIP : I.comap (algebraMap R S) ≤ P) :
    ∃ Q ≥ I, IsPrime Q ∧ Q.comap (algebraMap R S) = P := by
  obtain ⟨Q' : Ideal (S ⧸ I), ⟨Q'_prime, hQ'⟩⟩ :=
    @exists_ideal_over_prime_of_isIntegral_of_isDomain (R ⧸ I.comap (algebraMap R S)) _ (S ⧸ I) _
      Ideal.quotientAlgebra _ H.quotient
      (map (Ideal.Quotient.mk (I.comap (algebraMap R S))) P)
      (map_isPrime_of_surjective Quotient.mk_surjective (by simp [hIP]))
      (le_trans (le_of_eq ((RingHom.injective_iff_ker_eq_bot _).1 algebraMap_quotient_injective))
        bot_le)
  refine' ⟨Q'.comap _, le_trans (le_of_eq mk_ker.symm) (ker_le_comap _), ⟨comap_isPrime _ Q', _⟩⟩
  rw [comap_comap]
  refine' _root_.trans _ (_root_.trans (congr_arg (comap (Ideal.Quotient.mk
    (comap (algebraMap R S) I))) hQ') _)
  · rw [comap_comap]
    exact congr_arg (comap . Q') (RingHom.ext fun r => rfl)
  · refine' _root_.trans (comap_map_of_surjective _ Quotient.mk_surjective _) (sup_eq_left.2 _)
    

Proof state:
case intro.intro.refine'_2
R : Type u_1
inst✝⁴ : CommRing R
S : Type u_2
inst✝³ : CommRing S
f : R →+* S
I✝ J : Ideal S
inst✝² : Algebra R S
H : Algebra.IsIntegral R S
P : Ideal R
inst✝¹ : IsPrime P
I : Ideal S
inst✝ : IsPrime I
hIP : comap (algebraMap R S) I ≤ P
Q' : Ideal (S ⧸ I)
Q'_prime : IsPrime Q'
hQ' : comap (algebraMap (R ⧸ comap (algebraMap R S) I) (S ⧸ I)) Q' = map (Quotient.mk (comap (algebraMap R S) I)) P
⊢ comap (Quotient.mk (comap (algebraMap R S) I)) ⊥ ≤ P

Next tactic:
simpa [← RingHom.ker_eq_comap_bot] using hIP
lemma exists_ideal_comap_le_prime (P : Ideal R) [P.IsPrime]
    (I : Ideal S) (hI : I.comap (algebraMap R S) ≤ P) :
    ∃ Q ≥ I, Q.IsPrime ∧ Q.comap (algebraMap R S) ≤ P := by
  

Proof state:
R : Type u_1
inst✝³ : CommRing R
S : Type u_2
inst✝² : CommRing S
f : R →+* S
I✝ J : Ideal S
inst✝¹ : Algebra R S
P : Ideal R
inst✝ : IsPrime P
I : Ideal S
hI : comap (algebraMap R S) I ≤ P
⊢ ∃ Q ≥ I, IsPrime Q ∧ comap (algebraMap R S) Q ≤ P

Next tactic:
let Sₚ := Localization (Algebra.algebraMapSubmonoid S P.primeCompl)
lemma exists_ideal_comap_le_prime (P : Ideal R) [P.IsPrime]
    (I : Ideal S) (hI : I.comap (algebraMap R S) ≤ P) :
    ∃ Q ≥ I, Q.IsPrime ∧ Q.comap (algebraMap R S) ≤ P := by
  let Sₚ := Localization (Algebra.algebraMapSubmonoid S P.primeCompl)
  

Proof state:
R : Type u_1
inst✝³ : CommRing R
S : Type u_2
inst✝² : CommRing S
f : R →+* S
I✝ J : Ideal S
inst✝¹ : Algebra R S
P : Ideal R
inst✝ : IsPrime P
I : Ideal S
hI : comap (algebraMap R S) I ≤ P
Sₚ : Type u_2 := Localization (Algebra.algebraMapSubmonoid S (primeCompl P))
⊢ ∃ Q ≥ I, IsPrime Q ∧ comap (algebraMap R S) Q ≤ P

Next tactic:
let Iₚ := I.map (algebraMap S Sₚ)
lemma exists_ideal_comap_le_prime (P : Ideal R) [P.IsPrime]
    (I : Ideal S) (hI : I.comap (algebraMap R S) ≤ P) :
    ∃ Q ≥ I, Q.IsPrime ∧ Q.comap (algebraMap R S) ≤ P := by
  let Sₚ := Localization (Algebra.algebraMapSubmonoid S P.primeCompl)
  let Iₚ := I.map (algebraMap S Sₚ)
  

Proof state:
R : Type u_1
inst✝³ : CommRing R
S : Type u_2
inst✝² : CommRing S
f : R →+* S
I✝ J : Ideal S
inst✝¹ : Algebra R S
P : Ideal R
inst✝ : IsPrime P
I : Ideal S
hI : comap (algebraMap R S) I ≤ P
Sₚ : Type u_2 := Localization (Algebra.algebraMapSubmonoid S (primeCompl P))
Iₚ : Ideal Sₚ := map (algebraMap S Sₚ) I
⊢ ∃ Q ≥ I, IsPrime Q ∧ comap (algebraMap R S) Q ≤ P

Next tactic:
have hI' : Disjoint (Algebra.algebraMapSubmonoid S P.primeCompl : Set S) I
lemma exists_ideal_comap_le_prime (P : Ideal R) [P.IsPrime]
    (I : Ideal S) (hI : I.comap (algebraMap R S) ≤ P) :
    ∃ Q ≥ I, Q.IsPrime ∧ Q.comap (algebraMap R S) ≤ P := by
  let Sₚ := Localization (Algebra.algebraMapSubmonoid S P.primeCompl)
  let Iₚ := I.map (algebraMap S Sₚ)
  have hI' : Disjoint (Algebra.algebraMapSubmonoid S P.primeCompl : Set S) I
  · 

Proof state:
case hI'
R : Type u_1
inst✝³ : CommRing R
S : Type u_2
inst✝² : CommRing S
f : R →+* S
I✝ J : Ideal S
inst✝¹ : Algebra R S
P : Ideal R
inst✝ : IsPrime P
I : Ideal S
hI : comap (algebraMap R S) I ≤ P
Sₚ : Type u_2 := Localization (Algebra.algebraMapSubmonoid S (primeCompl P))
Iₚ : Ideal Sₚ := map (algebraMap S Sₚ) I
⊢ Disjoint ↑(Algebra.algebraMapSubmonoid S (primeCompl P)) ↑I

Next tactic:
rw [Set.disjoint_iff]
lemma exists_ideal_comap_le_prime (P : Ideal R) [P.IsPrime]
    (I : Ideal S) (hI : I.comap (algebraMap R S) ≤ P) :
    ∃ Q ≥ I, Q.IsPrime ∧ Q.comap (algebraMap R S) ≤ P := by
  let Sₚ := Localization (Algebra.algebraMapSubmonoid S P.primeCompl)
  let Iₚ := I.map (algebraMap S Sₚ)
  have hI' : Disjoint (Algebra.algebraMapSubmonoid S P.primeCompl : Set S) I
  · rw [Set.disjoint_iff]
    

Proof state:
case hI'
R : Type u_1
inst✝³ : CommRing R
S : Type u_2
inst✝² : CommRing S
f : R →+* S
I✝ J : Ideal S
inst✝¹ : Algebra R S
P : Ideal R
inst✝ : IsPrime P
I : Ideal S
hI : comap (algebraMap R S) I ≤ P
Sₚ : Type u_2 := Localization (Algebra.algebraMapSubmonoid S (primeCompl P))
Iₚ : Ideal Sₚ := map (algebraMap S Sₚ) I
⊢ ↑(Algebra.algebraMapSubmonoid S (primeCompl P)) ∩ ↑I ⊆ ∅

Next tactic:
rintro _ ⟨⟨x, hx : x ∉ P, rfl⟩, hx'⟩
lemma exists_ideal_comap_le_prime (P : Ideal R) [P.IsPrime]
    (I : Ideal S) (hI : I.comap (algebraMap R S) ≤ P) :
    ∃ Q ≥ I, Q.IsPrime ∧ Q.comap (algebraMap R S) ≤ P := by
  let Sₚ := Localization (Algebra.algebraMapSubmonoid S P.primeCompl)
  let Iₚ := I.map (algebraMap S Sₚ)
  have hI' : Disjoint (Algebra.algebraMapSubmonoid S P.primeCompl : Set S) I
  · rw [Set.disjoint_iff]
    rintro _ ⟨⟨x, hx : x ∉ P, rfl⟩, hx'⟩
    

Proof state:
case hI'.intro.intro.intro
R : Type u_1
inst✝³ : CommRing R
S : Type u_2
inst✝² : CommRing S
f : R →+* S
I✝ J : Ideal S
inst✝¹ : Algebra R S
P : Ideal R
inst✝ : IsPrime P
I : Ideal S
hI : comap (algebraMap R S) I ≤ P
Sₚ : Type u_2 := Localization (Algebra.algebraMapSubmonoid S (primeCompl P))
Iₚ : Ideal Sₚ := map (algebraMap S Sₚ) I
x : R
hx : x ∉ P
hx' : (algebraMap R S) x ∈ ↑I
⊢ (algebraMap R S) x ∈ ∅

Next tactic:
exact (hx (hI hx')).elim
lemma exists_ideal_comap_le_prime (P : Ideal R) [P.IsPrime]
    (I : Ideal S) (hI : I.comap (algebraMap R S) ≤ P) :
    ∃ Q ≥ I, Q.IsPrime ∧ Q.comap (algebraMap R S) ≤ P := by
  let Sₚ := Localization (Algebra.algebraMapSubmonoid S P.primeCompl)
  let Iₚ := I.map (algebraMap S Sₚ)
  have hI' : Disjoint (Algebra.algebraMapSubmonoid S P.primeCompl : Set S) I
  · rw [Set.disjoint_iff]
    rintro _ ⟨⟨x, hx : x ∉ P, rfl⟩, hx'⟩
    exact (hx (hI hx')).elim
  

Proof state:
R : Type u_1
inst✝³ : CommRing R
S : Type u_2
inst✝² : CommRing S
f : R →+* S
I✝ J : Ideal S
inst✝¹ : Algebra R S
P : Ideal R
inst✝ : IsPrime P
I : Ideal S
hI : comap (algebraMap R S) I ≤ P
Sₚ : Type u_2 := Localization (Algebra.algebraMapSubmonoid S (primeCompl P))
Iₚ : Ideal Sₚ := map (algebraMap S Sₚ) I
hI' : Disjoint ↑(Algebra.algebraMapSubmonoid S (primeCompl P)) ↑I
⊢ ∃ Q ≥ I, IsPrime Q ∧ comap (algebraMap R S) Q ≤ P

Next tactic:
have : Iₚ ≠ ⊤
lemma exists_ideal_comap_le_prime (P : Ideal R) [P.IsPrime]
    (I : Ideal S) (hI : I.comap (algebraMap R S) ≤ P) :
    ∃ Q ≥ I, Q.IsPrime ∧ Q.comap (algebraMap R S) ≤ P := by
  let Sₚ := Localization (Algebra.algebraMapSubmonoid S P.primeCompl)
  let Iₚ := I.map (algebraMap S Sₚ)
  have hI' : Disjoint (Algebra.algebraMapSubmonoid S P.primeCompl : Set S) I
  · rw [Set.disjoint_iff]
    rintro _ ⟨⟨x, hx : x ∉ P, rfl⟩, hx'⟩
    exact (hx (hI hx')).elim
  have : Iₚ ≠ ⊤
  · 

Proof state:
case this
R : Type u_1
inst✝³ : CommRing R
S : Type u_2
inst✝² : CommRing S
f : R →+* S
I✝ J : Ideal S
inst✝¹ : Algebra R S
P : Ideal R
inst✝ : IsPrime P
I : Ideal S
hI : comap (algebraMap R S) I ≤ P
Sₚ : Type u_2 := Localization (Algebra.algebraMapSubmonoid S (primeCompl P))
Iₚ : Ideal Sₚ := map (algebraMap S Sₚ) I
hI' : Disjoint ↑(Algebra.algebraMapSubmonoid S (primeCompl P)) ↑I
⊢ Iₚ ≠ ⊤

Next tactic:
rw [Ne.def, Ideal.eq_top_iff_one, IsLocalization.mem_map_algebraMap_iff
      (Algebra.algebraMapSubmonoid S P.primeCompl) Sₚ, not_exists]
lemma exists_ideal_comap_le_prime (P : Ideal R) [P.IsPrime]
    (I : Ideal S) (hI : I.comap (algebraMap R S) ≤ P) :
    ∃ Q ≥ I, Q.IsPrime ∧ Q.comap (algebraMap R S) ≤ P := by
  let Sₚ := Localization (Algebra.algebraMapSubmonoid S P.primeCompl)
  let Iₚ := I.map (algebraMap S Sₚ)
  have hI' : Disjoint (Algebra.algebraMapSubmonoid S P.primeCompl : Set S) I
  · rw [Set.disjoint_iff]
    rintro _ ⟨⟨x, hx : x ∉ P, rfl⟩, hx'⟩
    exact (hx (hI hx')).elim
  have : Iₚ ≠ ⊤
  · rw [Ne.def, Ideal.eq_top_iff_one, IsLocalization.mem_map_algebraMap_iff
      (Algebra.algebraMapSubmonoid S P.primeCompl) Sₚ, not_exists]
    

Proof state:
case this
R : Type u_1
inst✝³ : CommRing R
S : Type u_2
inst✝² : CommRing S
f : R →+* S
I✝ J : Ideal S
inst✝¹ : Algebra R S
P : Ideal R
inst✝ : IsPrime P
I : Ideal S
hI : comap (algebraMap R S) I ≤ P
Sₚ : Type u_2 := Localization (Algebra.algebraMapSubmonoid S (primeCompl P))
Iₚ : Ideal Sₚ := map (algebraMap S Sₚ) I
hI' : Disjoint ↑(Algebra.algebraMapSubmonoid S (primeCompl P)) ↑I
⊢ ∀ (x : ↥I × ↥(Algebra.algebraMapSubmonoid S (primeCompl P))), ¬1 * (algebraMap S Sₚ) ↑x.2 = (algebraMap S Sₚ) ↑x.1

Next tactic:
simp only [one_mul, IsLocalization.eq_iff_exists (Algebra.algebraMapSubmonoid S P.primeCompl),
      not_exists]
lemma exists_ideal_comap_le_prime (P : Ideal R) [P.IsPrime]
    (I : Ideal S) (hI : I.comap (algebraMap R S) ≤ P) :
    ∃ Q ≥ I, Q.IsPrime ∧ Q.comap (algebraMap R S) ≤ P := by
  let Sₚ := Localization (Algebra.algebraMapSubmonoid S P.primeCompl)
  let Iₚ := I.map (algebraMap S Sₚ)
  have hI' : Disjoint (Algebra.algebraMapSubmonoid S P.primeCompl : Set S) I
  · rw [Set.disjoint_iff]
    rintro _ ⟨⟨x, hx : x ∉ P, rfl⟩, hx'⟩
    exact (hx (hI hx')).elim
  have : Iₚ ≠ ⊤
  · rw [Ne.def, Ideal.eq_top_iff_one, IsLocalization.mem_map_algebraMap_iff
      (Algebra.algebraMapSubmonoid S P.primeCompl) Sₚ, not_exists]
    simp only [one_mul, IsLocalization.eq_iff_exists (Algebra.algebraMapSubmonoid S P.primeCompl),
      not_exists]
    

Proof state:
case this
R : Type u_1
inst✝³ : CommRing R
S : Type u_2
inst✝² : CommRing S
f : R →+* S
I✝ J : Ideal S
inst✝¹ : Algebra R S
P : Ideal R
inst✝ : IsPrime P
I : Ideal S
hI : comap (algebraMap R S) I ≤ P
Sₚ : Type u_2 := Localization (Algebra.algebraMapSubmonoid S (primeCompl P))
Iₚ : Ideal Sₚ := map (algebraMap S Sₚ) I
hI' : Disjoint ↑(Algebra.algebraMapSubmonoid S (primeCompl P)) ↑I
⊢ ∀ (x : ↥I × ↥(Algebra.algebraMapSubmonoid S (primeCompl P))) (x_1 : ↥(Algebra.algebraMapSubmonoid S (primeCompl P))),
    ¬↑x_1 * ↑x.2 = ↑x_1 * ↑x.1

Next tactic:
exact fun x c ↦ hI'.ne_of_mem (mul_mem c.2 x.2.2) (I.mul_mem_left c x.1.2)
lemma exists_ideal_comap_le_prime (P : Ideal R) [P.IsPrime]
    (I : Ideal S) (hI : I.comap (algebraMap R S) ≤ P) :
    ∃ Q ≥ I, Q.IsPrime ∧ Q.comap (algebraMap R S) ≤ P := by
  let Sₚ := Localization (Algebra.algebraMapSubmonoid S P.primeCompl)
  let Iₚ := I.map (algebraMap S Sₚ)
  have hI' : Disjoint (Algebra.algebraMapSubmonoid S P.primeCompl : Set S) I
  · rw [Set.disjoint_iff]
    rintro _ ⟨⟨x, hx : x ∉ P, rfl⟩, hx'⟩
    exact (hx (hI hx')).elim
  have : Iₚ ≠ ⊤
  · rw [Ne.def, Ideal.eq_top_iff_one, IsLocalization.mem_map_algebraMap_iff
      (Algebra.algebraMapSubmonoid S P.primeCompl) Sₚ, not_exists]
    simp only [one_mul, IsLocalization.eq_iff_exists (Algebra.algebraMapSubmonoid S P.primeCompl),
      not_exists]
    exact fun x c ↦ hI'.ne_of_mem (mul_mem c.2 x.2.2) (I.mul_mem_left c x.1.2)
  

Proof state:
R : Type u_1
inst✝³ : CommRing R
S : Type u_2
inst✝² : CommRing S
f : R →+* S
I✝ J : Ideal S
inst✝¹ : Algebra R S
P : Ideal R
inst✝ : IsPrime P
I : Ideal S
hI : comap (algebraMap R S) I ≤ P
Sₚ : Type u_2 := Localization (Algebra.algebraMapSubmonoid S (primeCompl P))
Iₚ : Ideal Sₚ := map (algebraMap S Sₚ) I
hI' : Disjoint ↑(Algebra.algebraMapSubmonoid S (primeCompl P)) ↑I
this : Iₚ ≠ ⊤
⊢ ∃ Q ≥ I, IsPrime Q ∧ comap (algebraMap R S) Q ≤ P

Next tactic:
obtain ⟨M, hM, hM'⟩ := Ideal.exists_le_maximal _ this
lemma exists_ideal_comap_le_prime (P : Ideal R) [P.IsPrime]
    (I : Ideal S) (hI : I.comap (algebraMap R S) ≤ P) :
    ∃ Q ≥ I, Q.IsPrime ∧ Q.comap (algebraMap R S) ≤ P := by
  let Sₚ := Localization (Algebra.algebraMapSubmonoid S P.primeCompl)
  let Iₚ := I.map (algebraMap S Sₚ)
  have hI' : Disjoint (Algebra.algebraMapSubmonoid S P.primeCompl : Set S) I
  · rw [Set.disjoint_iff]
    rintro _ ⟨⟨x, hx : x ∉ P, rfl⟩, hx'⟩
    exact (hx (hI hx')).elim
  have : Iₚ ≠ ⊤
  · rw [Ne.def, Ideal.eq_top_iff_one, IsLocalization.mem_map_algebraMap_iff
      (Algebra.algebraMapSubmonoid S P.primeCompl) Sₚ, not_exists]
    simp only [one_mul, IsLocalization.eq_iff_exists (Algebra.algebraMapSubmonoid S P.primeCompl),
      not_exists]
    exact fun x c ↦ hI'.ne_of_mem (mul_mem c.2 x.2.2) (I.mul_mem_left c x.1.2)
  obtain ⟨M, hM, hM'⟩ := Ideal.exists_le_maximal _ this
  

Proof state:
case intro.intro
R : Type u_1
inst✝³ : CommRing R
S : Type u_2
inst✝² : CommRing S
f : R →+* S
I✝ J : Ideal S
inst✝¹ : Algebra R S
P : Ideal R
inst✝ : IsPrime P
I : Ideal S
hI : comap (algebraMap R S) I ≤ P
Sₚ : Type u_2 := Localization (Algebra.algebraMapSubmonoid S (primeCompl P))
Iₚ : Ideal Sₚ := map (algebraMap S Sₚ) I
hI' : Disjoint ↑(Algebra.algebraMapSubmonoid S (primeCompl P)) ↑I
this : Iₚ ≠ ⊤
M : Ideal Sₚ
hM : IsMaximal M
hM' : Iₚ ≤ M
⊢ ∃ Q ≥ I, IsPrime Q ∧ comap (algebraMap R S) Q ≤ P

Next tactic:
refine ⟨_, Ideal.map_le_iff_le_comap.mp hM', hM.isPrime.comap _, ?_⟩
lemma exists_ideal_comap_le_prime (P : Ideal R) [P.IsPrime]
    (I : Ideal S) (hI : I.comap (algebraMap R S) ≤ P) :
    ∃ Q ≥ I, Q.IsPrime ∧ Q.comap (algebraMap R S) ≤ P := by
  let Sₚ := Localization (Algebra.algebraMapSubmonoid S P.primeCompl)
  let Iₚ := I.map (algebraMap S Sₚ)
  have hI' : Disjoint (Algebra.algebraMapSubmonoid S P.primeCompl : Set S) I
  · rw [Set.disjoint_iff]
    rintro _ ⟨⟨x, hx : x ∉ P, rfl⟩, hx'⟩
    exact (hx (hI hx')).elim
  have : Iₚ ≠ ⊤
  · rw [Ne.def, Ideal.eq_top_iff_one, IsLocalization.mem_map_algebraMap_iff
      (Algebra.algebraMapSubmonoid S P.primeCompl) Sₚ, not_exists]
    simp only [one_mul, IsLocalization.eq_iff_exists (Algebra.algebraMapSubmonoid S P.primeCompl),
      not_exists]
    exact fun x c ↦ hI'.ne_of_mem (mul_mem c.2 x.2.2) (I.mul_mem_left c x.1.2)
  obtain ⟨M, hM, hM'⟩ := Ideal.exists_le_maximal _ this
  refine ⟨_, Ideal.map_le_iff_le_comap.mp hM', hM.isPrime.comap _, ?_⟩
  

Proof state:
case intro.intro
R : Type u_1
inst✝³ : CommRing R
S : Type u_2
inst✝² : CommRing S
f : R →+* S
I✝ J : Ideal S
inst✝¹ : Algebra R S
P : Ideal R
inst✝ : IsPrime P
I : Ideal S
hI : comap (algebraMap R S) I ≤ P
Sₚ : Type u_2 := Localization (Algebra.algebraMapSubmonoid S (primeCompl P))
Iₚ : Ideal Sₚ := map (algebraMap S Sₚ) I
hI' : Disjoint ↑(Algebra.algebraMapSubmonoid S (primeCompl P)) ↑I
this : Iₚ ≠ ⊤
M : Ideal Sₚ
hM : IsMaximal M
hM' : Iₚ ≤ M
⊢ comap (algebraMap R S) (comap (algebraMap S Sₚ) M) ≤ P

Next tactic:
intro x hx