l3lab/ntp-mathlib huggingface dataset:
instance mono_left [Mono sq] : Mono sq.left where
  right_cancellation {Z} φ ψ h := by
    let aux : (Z ⟶ f.left) → (Arrow.mk (𝟙 Z) ⟶ f) := fun φ =>
      { left := φ
        right := φ ≫ f.hom }
    have : ∀ g, (aux g).right = g ≫ f.hom := fun g => by dsimp
    show (aux φ).left = (aux ψ).left
    congr 1
    rw [← cancel_mono sq]
    apply CommaMorphism.ext
    · exact h
    · 

Proof state:
case e_self.right
T : Type u
inst✝¹ : Category.{v, u} T
f g : Arrow T
sq : f ⟶ g
inst✝ : Mono sq
Z : T
φ ψ : Z ⟶ f.left
h : φ ≫ sq.left = ψ ≫ sq.left
aux : (Z ⟶ f.left) → (mk (𝟙 Z) ⟶ f) := fun φ => CommaMorphism.mk φ (φ ≫ f.hom)
this : ∀ (g : Z ⟶ f.left), (aux g).right = g ≫ f.hom
⊢ (aux φ ≫ sq).right = (aux ψ ≫ sq).right

Next tactic:
rw [Comma.comp_right, Comma.comp_right, this, this, Category.assoc, Category.assoc]
instance mono_left [Mono sq] : Mono sq.left where
  right_cancellation {Z} φ ψ h := by
    let aux : (Z ⟶ f.left) → (Arrow.mk (𝟙 Z) ⟶ f) := fun φ =>
      { left := φ
        right := φ ≫ f.hom }
    have : ∀ g, (aux g).right = g ≫ f.hom := fun g => by dsimp
    show (aux φ).left = (aux ψ).left
    congr 1
    rw [← cancel_mono sq]
    apply CommaMorphism.ext
    · exact h
    · rw [Comma.comp_right, Comma.comp_right, this, this, Category.assoc, Category.assoc]
      

Proof state:
case e_self.right
T : Type u
inst✝¹ : Category.{v, u} T
f g : Arrow T
sq : f ⟶ g
inst✝ : Mono sq
Z : T
φ ψ : Z ⟶ f.left
h : φ ≫ sq.left = ψ ≫ sq.left
aux : (Z ⟶ f.left) → (mk (𝟙 Z) ⟶ f) := fun φ => CommaMorphism.mk φ (φ ≫ f.hom)
this : ∀ (g : Z ⟶ f.left), (aux g).right = g ≫ f.hom
⊢ φ ≫ f.hom ≫ sq.right = ψ ≫ f.hom ≫ sq.right

Next tactic:
rw [← Arrow.w]
instance mono_left [Mono sq] : Mono sq.left where
  right_cancellation {Z} φ ψ h := by
    let aux : (Z ⟶ f.left) → (Arrow.mk (𝟙 Z) ⟶ f) := fun φ =>
      { left := φ
        right := φ ≫ f.hom }
    have : ∀ g, (aux g).right = g ≫ f.hom := fun g => by dsimp
    show (aux φ).left = (aux ψ).left
    congr 1
    rw [← cancel_mono sq]
    apply CommaMorphism.ext
    · exact h
    · rw [Comma.comp_right, Comma.comp_right, this, this, Category.assoc, Category.assoc]
      rw [← Arrow.w]
      

Proof state:
case e_self.right
T : Type u
inst✝¹ : Category.{v, u} T
f g : Arrow T
sq : f ⟶ g
inst✝ : Mono sq
Z : T
φ ψ : Z ⟶ f.left
h : φ ≫ sq.left = ψ ≫ sq.left
aux : (Z ⟶ f.left) → (mk (𝟙 Z) ⟶ f) := fun φ => CommaMorphism.mk φ (φ ≫ f.hom)
this : ∀ (g : Z ⟶ f.left), (aux g).right = g ≫ f.hom
⊢ φ ≫ sq.left ≫ g.hom = ψ ≫ sq.left ≫ g.hom

Next tactic:
simp only [← Category.assoc, h]
instance epi_right [Epi sq] : Epi sq.right where
  left_cancellation {Z} φ ψ h := by
    

Proof state:
T : Type u
inst✝¹ : Category.{v, u} T
f g : Arrow T
sq : f ⟶ g
inst✝ : Epi sq
Z : T
φ ψ : g.right ⟶ Z
h : sq.right ≫ φ = sq.right ≫ ψ
⊢ φ = ψ

Next tactic:
let aux : (g.right ⟶ Z) → (g ⟶ Arrow.mk (𝟙 Z)) := fun φ =>
      { right := φ
        left := g.hom ≫ φ }
instance epi_right [Epi sq] : Epi sq.right where
  left_cancellation {Z} φ ψ h := by
    let aux : (g.right ⟶ Z) → (g ⟶ Arrow.mk (𝟙 Z)) := fun φ =>
      { right := φ
        left := g.hom ≫ φ }
    

Proof state:
T : Type u
inst✝¹ : Category.{v, u} T
f g : Arrow T
sq : f ⟶ g
inst✝ : Epi sq
Z : T
φ ψ : g.right ⟶ Z
h : sq.right ≫ φ = sq.right ≫ ψ
aux : (g.right ⟶ Z) → (g ⟶ mk (𝟙 Z)) := fun φ => CommaMorphism.mk (g.hom ≫ φ) φ
⊢ φ = ψ

Next tactic:
show (aux φ).right = (aux ψ).right
instance epi_right [Epi sq] : Epi sq.right where
  left_cancellation {Z} φ ψ h := by
    let aux : (g.right ⟶ Z) → (g ⟶ Arrow.mk (𝟙 Z)) := fun φ =>
      { right := φ
        left := g.hom ≫ φ }
    show (aux φ).right = (aux ψ).right
    

Proof state:
T : Type u
inst✝¹ : Category.{v, u} T
f g : Arrow T
sq : f ⟶ g
inst✝ : Epi sq
Z : T
φ ψ : g.right ⟶ Z
h : sq.right ≫ φ = sq.right ≫ ψ
aux : (g.right ⟶ Z) → (g ⟶ mk (𝟙 Z)) := fun φ => CommaMorphism.mk (g.hom ≫ φ) φ
⊢ (aux φ).right = (aux ψ).right

Next tactic:
congr 1
instance epi_right [Epi sq] : Epi sq.right where
  left_cancellation {Z} φ ψ h := by
    let aux : (g.right ⟶ Z) → (g ⟶ Arrow.mk (𝟙 Z)) := fun φ =>
      { right := φ
        left := g.hom ≫ φ }
    show (aux φ).right = (aux ψ).right
    congr 1
    

Proof state:
case e_self
T : Type u
inst✝¹ : Category.{v, u} T
f g : Arrow T
sq : f ⟶ g
inst✝ : Epi sq
Z : T
φ ψ : g.right ⟶ Z
h : sq.right ≫ φ = sq.right ≫ ψ
aux : (g.right ⟶ Z) → (g ⟶ mk (𝟙 Z)) := fun φ => CommaMorphism.mk (g.hom ≫ φ) φ
⊢ aux φ = aux ψ

Next tactic:
rw [← cancel_epi sq]
instance epi_right [Epi sq] : Epi sq.right where
  left_cancellation {Z} φ ψ h := by
    let aux : (g.right ⟶ Z) → (g ⟶ Arrow.mk (𝟙 Z)) := fun φ =>
      { right := φ
        left := g.hom ≫ φ }
    show (aux φ).right = (aux ψ).right
    congr 1
    rw [← cancel_epi sq]
    

Proof state:
case e_self
T : Type u
inst✝¹ : Category.{v, u} T
f g : Arrow T
sq : f ⟶ g
inst✝ : Epi sq
Z : T
φ ψ : g.right ⟶ Z
h : sq.right ≫ φ = sq.right ≫ ψ
aux : (g.right ⟶ Z) → (g ⟶ mk (𝟙 Z)) := fun φ => CommaMorphism.mk (g.hom ≫ φ) φ
⊢ sq ≫ aux φ = sq ≫ aux ψ

Next tactic:
apply CommaMorphism.ext
instance epi_right [Epi sq] : Epi sq.right where
  left_cancellation {Z} φ ψ h := by
    let aux : (g.right ⟶ Z) → (g ⟶ Arrow.mk (𝟙 Z)) := fun φ =>
      { right := φ
        left := g.hom ≫ φ }
    show (aux φ).right = (aux ψ).right
    congr 1
    rw [← cancel_epi sq]
    apply CommaMorphism.ext
    · 

Proof state:
case e_self.left
T : Type u
inst✝¹ : Category.{v, u} T
f g : Arrow T
sq : f ⟶ g
inst✝ : Epi sq
Z : T
φ ψ : g.right ⟶ Z
h : sq.right ≫ φ = sq.right ≫ ψ
aux : (g.right ⟶ Z) → (g ⟶ mk (𝟙 Z)) := fun φ => CommaMorphism.mk (g.hom ≫ φ) φ
⊢ (sq ≫ aux φ).left = (sq ≫ aux ψ).left

Next tactic:
rw [Comma.comp_left, Comma.comp_left, Arrow.w_assoc, Arrow.w_assoc, h]
instance epi_right [Epi sq] : Epi sq.right where
  left_cancellation {Z} φ ψ h := by
    let aux : (g.right ⟶ Z) → (g ⟶ Arrow.mk (𝟙 Z)) := fun φ =>
      { right := φ
        left := g.hom ≫ φ }
    show (aux φ).right = (aux ψ).right
    congr 1
    rw [← cancel_epi sq]
    apply CommaMorphism.ext
    · rw [Comma.comp_left, Comma.comp_left, Arrow.w_assoc, Arrow.w_assoc, h]
    · 

Proof state:
case e_self.right
T : Type u
inst✝¹ : Category.{v, u} T
f g : Arrow T
sq : f ⟶ g
inst✝ : Epi sq
Z : T
φ ψ : g.right ⟶ Z
h : sq.right ≫ φ = sq.right ≫ ψ
aux : (g.right ⟶ Z) → (g ⟶ mk (𝟙 Z)) := fun φ => CommaMorphism.mk (g.hom ≫ φ) φ
⊢ (sq ≫ aux φ).right = (sq ≫ aux ψ).right

Next tactic:
exact h
@[reassoc (attr := simp)]
lemma hom_inv_id_left (e : f ≅ g) : e.hom.left ≫ e.inv.left = 𝟙 _ := by
  

Proof state:
T : Type u
inst✝ : Category.{v, u} T
f g : Arrow T
sq : f ⟶ g
e : f ≅ g
⊢ e.hom.left ≫ e.inv.left = 𝟙 f.left

Next tactic:
rw [← comp_left, e.hom_inv_id, id_left]
@[reassoc (attr := simp)]
lemma inv_hom_id_left (e : f ≅ g) : e.inv.left ≫ e.hom.left = 𝟙 _ := by
  

Proof state:
T : Type u
inst✝ : Category.{v, u} T
f g : Arrow T
sq : f ⟶ g
e : f ≅ g
⊢ e.inv.left ≫ e.hom.left = 𝟙 g.left

Next tactic:
rw [← comp_left, e.inv_hom_id, id_left]
@[reassoc (attr := simp)]
lemma hom_inv_id_right (e : f ≅ g) : e.hom.right ≫ e.inv.right = 𝟙 _ := by
  

Proof state:
T : Type u
inst✝ : Category.{v, u} T
f g : Arrow T
sq : f ⟶ g
e : f ≅ g
⊢ e.hom.right ≫ e.inv.right = 𝟙 f.right

Next tactic:
rw [← comp_right, e.hom_inv_id, id_right]
@[reassoc (attr := simp)]
lemma inv_hom_id_right (e : f ≅ g) : e.inv.right ≫ e.hom.right = 𝟙 _ := by
  

Proof state:
T : Type u
inst✝ : Category.{v, u} T
f g : Arrow T
sq : f ⟶ g
e : f ≅ g
⊢ e.inv.right ≫ e.hom.right = 𝟙 g.right

Next tactic:
rw [← comp_right, e.inv_hom_id, id_right]
/-- Given a square from an arrow `i` to an isomorphism `p`, express the source part of `sq`
in terms of the inverse of `p`. -/
@[simp]
theorem square_to_iso_invert (i : Arrow T) {X Y : T} (p : X ≅ Y) (sq : i ⟶ Arrow.mk p.hom) :
    i.hom ≫ sq.right ≫ p.inv = sq.left := by
  

Proof state:
T : Type u
inst✝ : Category.{v, u} T
i : Arrow T
X Y : T
p : X ≅ Y
sq : i ⟶ mk p.hom
⊢ i.hom ≫ sq.right ≫ p.inv = sq.left

Next tactic:
simpa only [Category.assoc] using (Iso.comp_inv_eq p).mpr (Arrow.w_mk_right sq).symm
/-- Given a square from an isomorphism `i` to an arrow `p`, express the target part of `sq`
in terms of the inverse of `i`. -/
theorem square_from_iso_invert {X Y : T} (i : X ≅ Y) (p : Arrow T) (sq : Arrow.mk i.hom ⟶ p) :
    i.inv ≫ sq.left ≫ p.hom = sq.right := by 

Proof state:
T : Type u
inst✝ : Category.{v, u} T
X Y : T
i : X ≅ Y
p : Arrow T
sq : mk i.hom ⟶ p
⊢ i.inv ≫ sq.left ≫ p.hom = sq.right

Next tactic:
simp only [Iso.inv_hom_id_assoc, Arrow.w, Arrow.mk_hom]
/-- A functor `C ⥤ D` induces a functor between the corresponding arrow categories. -/
@[simps]
def mapArrow (F : C ⥤ D) : Arrow C ⥤ Arrow D where
  obj a :=
    { left := F.obj a.left
      right := F.obj a.right
      hom := F.map a.hom }
  map f :=
    { left := F.map f.left
      right := F.map f.right
      w := by
        

Proof state:
T : Type u
inst✝² : Category.{v, u} T
C : Type u₁
inst✝¹ : Category.{v₁, u₁} C
D : Type u₂
inst✝ : Category.{v₂, u₂} D
F : C ⥤ D
X✝ Y✝ : Arrow C
f : X✝ ⟶ Y✝
⊢ (𝟭 D).map (F.map f.left) ≫ ((fun a => { left := F.obj a.left, right := F.obj a.right, hom := F.map a.hom }) Y✝).hom =
    ((fun a => { left := F.obj a.left, right := F.obj a.right, hom := F.map a.hom }) X✝).hom ≫ (𝟭 D).map (F.map f.right)

Next tactic:
let w := f.w
/-- A functor `C ⥤ D` induces a functor between the corresponding arrow categories. -/
@[simps]
def mapArrow (F : C ⥤ D) : Arrow C ⥤ Arrow D where
  obj a :=
    { left := F.obj a.left
      right := F.obj a.right
      hom := F.map a.hom }
  map f :=
    { left := F.map f.left
      right := F.map f.right
      w := by
        let w := f.w
        

Proof state:
T : Type u
inst✝² : Category.{v, u} T
C : Type u₁
inst✝¹ : Category.{v₁, u₁} C
D : Type u₂
inst✝ : Category.{v₂, u₂} D
F : C ⥤ D
X✝ Y✝ : Arrow C
f : X✝ ⟶ Y✝
w : (𝟭 C).map f.left ≫ Y✝.hom = X✝.hom ≫ (𝟭 C).map f.right := f.w
⊢ (𝟭 D).map (F.map f.left) ≫ ((fun a => { left := F.obj a.left, right := F.obj a.right, hom := F.map a.hom }) Y✝).hom =
    ((fun a => { left := F.obj a.left, right := F.obj a.right, hom := F.map a.hom }) X✝).hom ≫ (𝟭 D).map (F.map f.right)

Next tactic:
simp only [id_map] at w
/-- A functor `C ⥤ D` induces a functor between the corresponding arrow categories. -/
@[simps]
def mapArrow (F : C ⥤ D) : Arrow C ⥤ Arrow D where
  obj a :=
    { left := F.obj a.left
      right := F.obj a.right
      hom := F.map a.hom }
  map f :=
    { left := F.map f.left
      right := F.map f.right
      w := by
        let w := f.w
        simp only [id_map] at w
        

Proof state:
T : Type u
inst✝² : Category.{v, u} T
C : Type u₁
inst✝¹ : Category.{v₁, u₁} C
D : Type u₂
inst✝ : Category.{v₂, u₂} D
F : C ⥤ D
X✝ Y✝ : Arrow C
f : X✝ ⟶ Y✝
w : f.left ≫ Y✝.hom = X✝.hom ≫ f.right := f.w
⊢ (𝟭 D).map (F.map f.left) ≫ ((fun a => { left := F.obj a.left, right := F.obj a.right, hom := F.map a.hom }) Y✝).hom =
    ((fun a => { left := F.obj a.left, right := F.obj a.right, hom := F.map a.hom }) X✝).hom ≫ (𝟭 D).map (F.map f.right)

Next tactic:
dsimp
/-- A functor `C ⥤ D` induces a functor between the corresponding arrow categories. -/
@[simps]
def mapArrow (F : C ⥤ D) : Arrow C ⥤ Arrow D where
  obj a :=
    { left := F.obj a.left
      right := F.obj a.right
      hom := F.map a.hom }
  map f :=
    { left := F.map f.left
      right := F.map f.right
      w := by
        let w := f.w
        simp only [id_map] at w
        dsimp
        

Proof state:
T : Type u
inst✝² : Category.{v, u} T
C : Type u₁
inst✝¹ : Category.{v₁, u₁} C
D : Type u₂
inst✝ : Category.{v₂, u₂} D
F : C ⥤ D
X✝ Y✝ : Arrow C
f : X✝ ⟶ Y✝
w : f.left ≫ Y✝.hom = X✝.hom ≫ f.right := f.w
⊢ F.map f.left ≫ F.map Y✝.hom = F.map X✝.hom ≫ F.map f.right

Next tactic:
simp only [← F.map_comp, w]
/-- Localizing a domain of Krull dimension `≤ 1` gives another ring of Krull dimension `≤ 1`.

Note that the same proof can/should be generalized to preserving any Krull dimension,
once we have a suitable definition.
-/
theorem Ring.DimensionLEOne.localization {R : Type*} (Rₘ : Type*) [CommRing R] [IsDomain R]
    [CommRing Rₘ] [Algebra R Rₘ] {M : Submonoid R} [IsLocalization M Rₘ] (hM : M ≤ R⁰)
    [h : Ring.DimensionLEOne R] : Ring.DimensionLEOne Rₘ := ⟨by
  

Proof state:
R✝ : Type u_1
A : Type u_2
K : Type u_3
inst✝⁸ : CommRing R✝
inst✝⁷ : CommRing A
inst✝⁶ : IsDomain A
inst✝⁵ : Field K
R : Type u_4
Rₘ : Type u_5
inst✝⁴ : CommRing R
inst✝³ : IsDomain R
inst✝² : CommRing Rₘ
inst✝¹ : Algebra R Rₘ
M : Submonoid R
inst✝ : IsLocalization M Rₘ
hM : M ≤ R⁰
h : DimensionLEOne R
⊢ ∀ {p : Ideal Rₘ}, p ≠ ⊥ → Ideal.IsPrime p → Ideal.IsMaximal p

Next tactic:
intro p hp0 hpp
/-- Localizing a domain of Krull dimension `≤ 1` gives another ring of Krull dimension `≤ 1`.

Note that the same proof can/should be generalized to preserving any Krull dimension,
once we have a suitable definition.
-/
theorem Ring.DimensionLEOne.localization {R : Type*} (Rₘ : Type*) [CommRing R] [IsDomain R]
    [CommRing Rₘ] [Algebra R Rₘ] {M : Submonoid R} [IsLocalization M Rₘ] (hM : M ≤ R⁰)
    [h : Ring.DimensionLEOne R] : Ring.DimensionLEOne Rₘ := ⟨by
  intro p hp0 hpp
  

Proof state:
R✝ : Type u_1
A : Type u_2
K : Type u_3
inst✝⁸ : CommRing R✝
inst✝⁷ : CommRing A
inst✝⁶ : IsDomain A
inst✝⁵ : Field K
R : Type u_4
Rₘ : Type u_5
inst✝⁴ : CommRing R
inst✝³ : IsDomain R
inst✝² : CommRing Rₘ
inst✝¹ : Algebra R Rₘ
M : Submonoid R
inst✝ : IsLocalization M Rₘ
hM : M ≤ R⁰
h : DimensionLEOne R
p : Ideal Rₘ
hp0 : p ≠ ⊥
hpp : Ideal.IsPrime p
⊢ Ideal.IsMaximal p

Next tactic:
refine' Ideal.isMaximal_def.mpr ⟨hpp.ne_top, Ideal.maximal_of_no_maximal fun P hpP hPm => _⟩
/-- Localizing a domain of Krull dimension `≤ 1` gives another ring of Krull dimension `≤ 1`.

Note that the same proof can/should be generalized to preserving any Krull dimension,
once we have a suitable definition.
-/
theorem Ring.DimensionLEOne.localization {R : Type*} (Rₘ : Type*) [CommRing R] [IsDomain R]
    [CommRing Rₘ] [Algebra R Rₘ] {M : Submonoid R} [IsLocalization M Rₘ] (hM : M ≤ R⁰)
    [h : Ring.DimensionLEOne R] : Ring.DimensionLEOne Rₘ := ⟨by
  intro p hp0 hpp
  refine' Ideal.isMaximal_def.mpr ⟨hpp.ne_top, Ideal.maximal_of_no_maximal fun P hpP hPm => _⟩
  

Proof state:
R✝ : Type u_1
A : Type u_2
K : Type u_3
inst✝⁸ : CommRing R✝
inst✝⁷ : CommRing A
inst✝⁶ : IsDomain A
inst✝⁵ : Field K
R : Type u_4
Rₘ : Type u_5
inst✝⁴ : CommRing R
inst✝³ : IsDomain R
inst✝² : CommRing Rₘ
inst✝¹ : Algebra R Rₘ
M : Submonoid R
inst✝ : IsLocalization M Rₘ
hM : M ≤ R⁰
h : DimensionLEOne R
p : Ideal Rₘ
hp0 : p ≠ ⊥
hpp : Ideal.IsPrime p
P : Ideal Rₘ
hpP : p < P
hPm : Ideal.IsMaximal P
⊢ False

Next tactic:
have hpP' : (⟨p, hpp⟩ : { p : Ideal Rₘ // p.IsPrime }) < ⟨P, hPm.isPrime⟩ := hpP
/-- Localizing a domain of Krull dimension `≤ 1` gives another ring of Krull dimension `≤ 1`.

Note that the same proof can/should be generalized to preserving any Krull dimension,
once we have a suitable definition.
-/
theorem Ring.DimensionLEOne.localization {R : Type*} (Rₘ : Type*) [CommRing R] [IsDomain R]
    [CommRing Rₘ] [Algebra R Rₘ] {M : Submonoid R} [IsLocalization M Rₘ] (hM : M ≤ R⁰)
    [h : Ring.DimensionLEOne R] : Ring.DimensionLEOne Rₘ := ⟨by
  intro p hp0 hpp
  refine' Ideal.isMaximal_def.mpr ⟨hpp.ne_top, Ideal.maximal_of_no_maximal fun P hpP hPm => _⟩
  have hpP' : (⟨p, hpp⟩ : { p : Ideal Rₘ // p.IsPrime }) < ⟨P, hPm.isPrime⟩ := hpP
  

Proof state:
R✝ : Type u_1
A : Type u_2
K : Type u_3
inst✝⁸ : CommRing R✝
inst✝⁷ : CommRing A
inst✝⁶ : IsDomain A
inst✝⁵ : Field K
R : Type u_4
Rₘ : Type u_5
inst✝⁴ : CommRing R
inst✝³ : IsDomain R
inst✝² : CommRing Rₘ
inst✝¹ : Algebra R Rₘ
M : Submonoid R
inst✝ : IsLocalization M Rₘ
hM : M ≤ R⁰
h : DimensionLEOne R
p : Ideal Rₘ
hp0 : p ≠ ⊥
hpp : Ideal.IsPrime p
P : Ideal Rₘ
hpP : p < P
hPm : Ideal.IsMaximal P
hpP' : { val := p, property := hpp } < { val := P, property := (_ : Ideal.IsPrime P) }
⊢ False

Next tactic:
rw [← (IsLocalization.orderIsoOfPrime M Rₘ).lt_iff_lt] at hpP'
/-- Localizing a domain of Krull dimension `≤ 1` gives another ring of Krull dimension `≤ 1`.

Note that the same proof can/should be generalized to preserving any Krull dimension,
once we have a suitable definition.
-/
theorem Ring.DimensionLEOne.localization {R : Type*} (Rₘ : Type*) [CommRing R] [IsDomain R]
    [CommRing Rₘ] [Algebra R Rₘ] {M : Submonoid R} [IsLocalization M Rₘ] (hM : M ≤ R⁰)
    [h : Ring.DimensionLEOne R] : Ring.DimensionLEOne Rₘ := ⟨by
  intro p hp0 hpp
  refine' Ideal.isMaximal_def.mpr ⟨hpp.ne_top, Ideal.maximal_of_no_maximal fun P hpP hPm => _⟩
  have hpP' : (⟨p, hpp⟩ : { p : Ideal Rₘ // p.IsPrime }) < ⟨P, hPm.isPrime⟩ := hpP
  rw [← (IsLocalization.orderIsoOfPrime M Rₘ).lt_iff_lt] at hpP'
  

Proof state:
R✝ : Type u_1
A : Type u_2
K : Type u_3
inst✝⁸ : CommRing R✝
inst✝⁷ : CommRing A
inst✝⁶ : IsDomain A
inst✝⁵ : Field K
R : Type u_4
Rₘ : Type u_5
inst✝⁴ : CommRing R
inst✝³ : IsDomain R
inst✝² : CommRing Rₘ
inst✝¹ : Algebra R Rₘ
M : Submonoid R
inst✝ : IsLocalization M Rₘ
hM : M ≤ R⁰
h : DimensionLEOne R
p : Ideal Rₘ
hp0 : p ≠ ⊥
hpp : Ideal.IsPrime p
P : Ideal Rₘ
hpP : p < P
hPm : Ideal.IsMaximal P
hpP' :
  (IsLocalization.orderIsoOfPrime M Rₘ) { val := p, property := hpp } <
    (IsLocalization.orderIsoOfPrime M Rₘ) { val := P, property := (_ : Ideal.IsPrime P) }
⊢ False

Next tactic:
haveI : Ideal.IsPrime (Ideal.comap (algebraMap R Rₘ) p) :=
    ((IsLocalization.orderIsoOfPrime M Rₘ) ⟨p, hpp⟩).2.1
/-- Localizing a domain of Krull dimension `≤ 1` gives another ring of Krull dimension `≤ 1`.

Note that the same proof can/should be generalized to preserving any Krull dimension,
once we have a suitable definition.
-/
theorem Ring.DimensionLEOne.localization {R : Type*} (Rₘ : Type*) [CommRing R] [IsDomain R]
    [CommRing Rₘ] [Algebra R Rₘ] {M : Submonoid R} [IsLocalization M Rₘ] (hM : M ≤ R⁰)
    [h : Ring.DimensionLEOne R] : Ring.DimensionLEOne Rₘ := ⟨by
  intro p hp0 hpp
  refine' Ideal.isMaximal_def.mpr ⟨hpp.ne_top, Ideal.maximal_of_no_maximal fun P hpP hPm => _⟩
  have hpP' : (⟨p, hpp⟩ : { p : Ideal Rₘ // p.IsPrime }) < ⟨P, hPm.isPrime⟩ := hpP
  rw [← (IsLocalization.orderIsoOfPrime M Rₘ).lt_iff_lt] at hpP'
  haveI : Ideal.IsPrime (Ideal.comap (algebraMap R Rₘ) p) :=
    ((IsLocalization.orderIsoOfPrime M Rₘ) ⟨p, hpp⟩).2.1
  

Proof state:
R✝ : Type u_1
A : Type u_2
K : Type u_3
inst✝⁸ : CommRing R✝
inst✝⁷ : CommRing A
inst✝⁶ : IsDomain A
inst✝⁵ : Field K
R : Type u_4
Rₘ : Type u_5
inst✝⁴ : CommRing R
inst✝³ : IsDomain R
inst✝² : CommRing Rₘ
inst✝¹ : Algebra R Rₘ
M : Submonoid R
inst✝ : IsLocalization M Rₘ
hM : M ≤ R⁰
h : DimensionLEOne R
p : Ideal Rₘ
hp0 : p ≠ ⊥
hpp : Ideal.IsPrime p
P : Ideal Rₘ
hpP : p < P
hPm : Ideal.IsMaximal P
hpP' :
  (IsLocalization.orderIsoOfPrime M Rₘ) { val := p, property := hpp } <
    (IsLocalization.orderIsoOfPrime M Rₘ) { val := P, property := (_ : Ideal.IsPrime P) }
this : Ideal.IsPrime (Ideal.comap (algebraMap R Rₘ) p)
⊢ False

Next tactic:
haveI : Ideal.IsPrime (Ideal.comap (algebraMap R Rₘ) P) :=
    ((IsLocalization.orderIsoOfPrime M Rₘ) ⟨P, hPm.isPrime⟩).2.1
/-- Localizing a domain of Krull dimension `≤ 1` gives another ring of Krull dimension `≤ 1`.

Note that the same proof can/should be generalized to preserving any Krull dimension,
once we have a suitable definition.
-/
theorem Ring.DimensionLEOne.localization {R : Type*} (Rₘ : Type*) [CommRing R] [IsDomain R]
    [CommRing Rₘ] [Algebra R Rₘ] {M : Submonoid R} [IsLocalization M Rₘ] (hM : M ≤ R⁰)
    [h : Ring.DimensionLEOne R] : Ring.DimensionLEOne Rₘ := ⟨by
  intro p hp0 hpp
  refine' Ideal.isMaximal_def.mpr ⟨hpp.ne_top, Ideal.maximal_of_no_maximal fun P hpP hPm => _⟩
  have hpP' : (⟨p, hpp⟩ : { p : Ideal Rₘ // p.IsPrime }) < ⟨P, hPm.isPrime⟩ := hpP
  rw [← (IsLocalization.orderIsoOfPrime M Rₘ).lt_iff_lt] at hpP'
  haveI : Ideal.IsPrime (Ideal.comap (algebraMap R Rₘ) p) :=
    ((IsLocalization.orderIsoOfPrime M Rₘ) ⟨p, hpp⟩).2.1
  haveI : Ideal.IsPrime (Ideal.comap (algebraMap R Rₘ) P) :=
    ((IsLocalization.orderIsoOfPrime M Rₘ) ⟨P, hPm.isPrime⟩).2.1
  

Proof state:
R✝ : Type u_1
A : Type u_2
K : Type u_3
inst✝⁸ : CommRing R✝
inst✝⁷ : CommRing A
inst✝⁶ : IsDomain A
inst✝⁵ : Field K
R : Type u_4
Rₘ : Type u_5
inst✝⁴ : CommRing R
inst✝³ : IsDomain R
inst✝² : CommRing Rₘ
inst✝¹ : Algebra R Rₘ
M : Submonoid R
inst✝ : IsLocalization M Rₘ
hM : M ≤ R⁰
h : DimensionLEOne R
p : Ideal Rₘ
hp0 : p ≠ ⊥
hpp : Ideal.IsPrime p
P : Ideal Rₘ
hpP : p < P
hPm : Ideal.IsMaximal P
hpP' :
  (IsLocalization.orderIsoOfPrime M Rₘ) { val := p, property := hpp } <
    (IsLocalization.orderIsoOfPrime M Rₘ) { val := P, property := (_ : Ideal.IsPrime P) }
this✝ : Ideal.IsPrime (Ideal.comap (algebraMap R Rₘ) p)
this : Ideal.IsPrime (Ideal.comap (algebraMap R Rₘ) P)
⊢ False

Next tactic:
have _ : Ideal.comap (algebraMap R Rₘ) p < Ideal.comap (algebraMap R Rₘ) P := hpP'
/-- Localizing a domain of Krull dimension `≤ 1` gives another ring of Krull dimension `≤ 1`.

Note that the same proof can/should be generalized to preserving any Krull dimension,
once we have a suitable definition.
-/
theorem Ring.DimensionLEOne.localization {R : Type*} (Rₘ : Type*) [CommRing R] [IsDomain R]
    [CommRing Rₘ] [Algebra R Rₘ] {M : Submonoid R} [IsLocalization M Rₘ] (hM : M ≤ R⁰)
    [h : Ring.DimensionLEOne R] : Ring.DimensionLEOne Rₘ := ⟨by
  intro p hp0 hpp
  refine' Ideal.isMaximal_def.mpr ⟨hpp.ne_top, Ideal.maximal_of_no_maximal fun P hpP hPm => _⟩
  have hpP' : (⟨p, hpp⟩ : { p : Ideal Rₘ // p.IsPrime }) < ⟨P, hPm.isPrime⟩ := hpP
  rw [← (IsLocalization.orderIsoOfPrime M Rₘ).lt_iff_lt] at hpP'
  haveI : Ideal.IsPrime (Ideal.comap (algebraMap R Rₘ) p) :=
    ((IsLocalization.orderIsoOfPrime M Rₘ) ⟨p, hpp⟩).2.1
  haveI : Ideal.IsPrime (Ideal.comap (algebraMap R Rₘ) P) :=
    ((IsLocalization.orderIsoOfPrime M Rₘ) ⟨P, hPm.isPrime⟩).2.1
  have _ : Ideal.comap (algebraMap R Rₘ) p < Ideal.comap (algebraMap R Rₘ) P := hpP'
  

Proof state:
R✝ : Type u_1
A : Type u_2
K : Type u_3
inst✝⁸ : CommRing R✝
inst✝⁷ : CommRing A
inst✝⁶ : IsDomain A
inst✝⁵ : Field K
R : Type u_4
Rₘ : Type u_5
inst✝⁴ : CommRing R
inst✝³ : IsDomain R
inst✝² : CommRing Rₘ
inst✝¹ : Algebra R Rₘ
M : Submonoid R
inst✝ : IsLocalization M Rₘ
hM : M ≤ R⁰
h : DimensionLEOne R
p : Ideal Rₘ
hp0 : p ≠ ⊥
hpp : Ideal.IsPrime p
P : Ideal Rₘ
hpP : p < P
hPm : Ideal.IsMaximal P
hpP' :
  (IsLocalization.orderIsoOfPrime M Rₘ) { val := p, property := hpp } <
    (IsLocalization.orderIsoOfPrime M Rₘ) { val := P, property := (_ : Ideal.IsPrime P) }
this✝ : Ideal.IsPrime (Ideal.comap (algebraMap R Rₘ) p)
this : Ideal.IsPrime (Ideal.comap (algebraMap R Rₘ) P)
x✝ : Ideal.comap (algebraMap R Rₘ) p < Ideal.comap (algebraMap R Rₘ) P
⊢ False

Next tactic:
refine' h.not_lt_lt ⊥ (Ideal.comap _ _) (Ideal.comap _ _) ⟨_, hpP'⟩