l3lab/ntp-mathlib huggingface dataset:
theorem AtPrime.localRing [IsLocalization.AtPrime S P] : LocalRing S :=
  -- Porting Note : since I couldn't get local instance running, I just specify it manually
  letI := AtPrime.Nontrivial S P
  LocalRing.of_nonunits_add
    (by
      intro x y hx hy hu
      cases' isUnit_iff_exists_inv.1 hu with z hxyz
      have : ∀ {r : R} {s : P.primeCompl}, mk' S r s ∈ nonunits S → r ∈ P := fun {r s} =>
        not_imp_comm.1 fun nr => isUnit_iff_exists_inv.2 ⟨mk' S ↑s (⟨r, nr⟩ : P.primeCompl),
          mk'_mul_mk'_eq_one' _ _ <| show r ∈ P.primeCompl from nr⟩
      rcases mk'_surjective P.primeCompl x with ⟨rx, sx, hrx⟩
      rcases mk'_surjective P.primeCompl y with ⟨ry, sy, hry⟩
      rcases mk'_surjective P.primeCompl z with ⟨rz, sz, hrz⟩
      rw [← hrx, ← hry, ← hrz, ← mk'_add, ← mk'_mul, ← mk'_self S P.primeCompl.one_mem] at hxyz
      rw [← hrx] at hx
      rw [← hry] at hy
      obtain ⟨t, ht⟩ := IsLocalization.eq.1 hxyz
      

Proof state:
case intro.intro.intro.intro.intro.intro.intro.intro
R : Type u_1
inst✝⁴ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝³ : CommSemiring S
inst✝² : Algebra R S
P✝ : Type u_3
inst✝¹ : CommSemiring P✝
P : Ideal R
hp : Ideal.IsPrime P
inst✝ : IsLocalization.AtPrime S P
this✝ : _root_.Nontrivial S := Nontrivial S P
x y : S
hu : IsUnit (x + y)
z : S
this : ∀ {r : R} {s : ↥(Ideal.primeCompl P)}, mk' S r s ∈ nonunits S → r ∈ P
rx : R
sx : ↥(Ideal.primeCompl P)
hx : mk' S rx sx ∈ nonunits S
hrx : mk' S rx sx = x
ry : R
sy : ↥(Ideal.primeCompl P)
hy : mk' S ry sy ∈ nonunits S
hry : mk' S ry sy = y
rz : R
sz : ↥(Ideal.primeCompl P)
hxyz :
  mk' S ((rx * ↑sy + ry * ↑sx) * rz) (sx * sy * sz) = mk' S 1 { val := 1, property := (_ : 1 ∈ Ideal.primeCompl P) }
hrz : mk' S rz sz = z
t : ↥(Ideal.primeCompl P)
ht :
  ↑t * (↑{ val := 1, property := (_ : 1 ∈ Ideal.primeCompl P) } * ((rx * ↑sy + ry * ↑sx) * rz)) =
    ↑t * (↑(sx * sy * sz) * 1)
⊢ False

Next tactic:
simp only [mul_one, one_mul, Submonoid.coe_mul, Subtype.coe_mk] at ht
theorem AtPrime.localRing [IsLocalization.AtPrime S P] : LocalRing S :=
  -- Porting Note : since I couldn't get local instance running, I just specify it manually
  letI := AtPrime.Nontrivial S P
  LocalRing.of_nonunits_add
    (by
      intro x y hx hy hu
      cases' isUnit_iff_exists_inv.1 hu with z hxyz
      have : ∀ {r : R} {s : P.primeCompl}, mk' S r s ∈ nonunits S → r ∈ P := fun {r s} =>
        not_imp_comm.1 fun nr => isUnit_iff_exists_inv.2 ⟨mk' S ↑s (⟨r, nr⟩ : P.primeCompl),
          mk'_mul_mk'_eq_one' _ _ <| show r ∈ P.primeCompl from nr⟩
      rcases mk'_surjective P.primeCompl x with ⟨rx, sx, hrx⟩
      rcases mk'_surjective P.primeCompl y with ⟨ry, sy, hry⟩
      rcases mk'_surjective P.primeCompl z with ⟨rz, sz, hrz⟩
      rw [← hrx, ← hry, ← hrz, ← mk'_add, ← mk'_mul, ← mk'_self S P.primeCompl.one_mem] at hxyz
      rw [← hrx] at hx
      rw [← hry] at hy
      obtain ⟨t, ht⟩ := IsLocalization.eq.1 hxyz
      simp only [mul_one, one_mul, Submonoid.coe_mul, Subtype.coe_mk] at ht
      

Proof state:
case intro.intro.intro.intro.intro.intro.intro.intro
R : Type u_1
inst✝⁴ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝³ : CommSemiring S
inst✝² : Algebra R S
P✝ : Type u_3
inst✝¹ : CommSemiring P✝
P : Ideal R
hp : Ideal.IsPrime P
inst✝ : IsLocalization.AtPrime S P
this✝ : _root_.Nontrivial S := Nontrivial S P
x y : S
hu : IsUnit (x + y)
z : S
this : ∀ {r : R} {s : ↥(Ideal.primeCompl P)}, mk' S r s ∈ nonunits S → r ∈ P
rx : R
sx : ↥(Ideal.primeCompl P)
hx : mk' S rx sx ∈ nonunits S
hrx : mk' S rx sx = x
ry : R
sy : ↥(Ideal.primeCompl P)
hy : mk' S ry sy ∈ nonunits S
hry : mk' S ry sy = y
rz : R
sz : ↥(Ideal.primeCompl P)
hxyz :
  mk' S ((rx * ↑sy + ry * ↑sx) * rz) (sx * sy * sz) = mk' S 1 { val := 1, property := (_ : 1 ∈ Ideal.primeCompl P) }
hrz : mk' S rz sz = z
t : ↥(Ideal.primeCompl P)
ht : ↑t * ((rx * ↑sy + ry * ↑sx) * rz) = ↑t * (↑sx * ↑sy * ↑sz)
⊢ False

Next tactic:
suffices : (t : R) * (sx * sy * sz) ∈ P
theorem AtPrime.localRing [IsLocalization.AtPrime S P] : LocalRing S :=
  -- Porting Note : since I couldn't get local instance running, I just specify it manually
  letI := AtPrime.Nontrivial S P
  LocalRing.of_nonunits_add
    (by
      intro x y hx hy hu
      cases' isUnit_iff_exists_inv.1 hu with z hxyz
      have : ∀ {r : R} {s : P.primeCompl}, mk' S r s ∈ nonunits S → r ∈ P := fun {r s} =>
        not_imp_comm.1 fun nr => isUnit_iff_exists_inv.2 ⟨mk' S ↑s (⟨r, nr⟩ : P.primeCompl),
          mk'_mul_mk'_eq_one' _ _ <| show r ∈ P.primeCompl from nr⟩
      rcases mk'_surjective P.primeCompl x with ⟨rx, sx, hrx⟩
      rcases mk'_surjective P.primeCompl y with ⟨ry, sy, hry⟩
      rcases mk'_surjective P.primeCompl z with ⟨rz, sz, hrz⟩
      rw [← hrx, ← hry, ← hrz, ← mk'_add, ← mk'_mul, ← mk'_self S P.primeCompl.one_mem] at hxyz
      rw [← hrx] at hx
      rw [← hry] at hy
      obtain ⟨t, ht⟩ := IsLocalization.eq.1 hxyz
      simp only [mul_one, one_mul, Submonoid.coe_mul, Subtype.coe_mk] at ht
      suffices : (t : R) * (sx * sy * sz) ∈ P
      

Proof state:
case intro.intro.intro.intro.intro.intro.intro.intro
R : Type u_1
inst✝⁴ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝³ : CommSemiring S
inst✝² : Algebra R S
P✝ : Type u_3
inst✝¹ : CommSemiring P✝
P : Ideal R
hp : Ideal.IsPrime P
inst✝ : IsLocalization.AtPrime S P
this✝¹ : _root_.Nontrivial S := Nontrivial S P
x y : S
hu : IsUnit (x + y)
z : S
this✝ : ∀ {r : R} {s : ↥(Ideal.primeCompl P)}, mk' S r s ∈ nonunits S → r ∈ P
rx : R
sx : ↥(Ideal.primeCompl P)
hx : mk' S rx sx ∈ nonunits S
hrx : mk' S rx sx = x
ry : R
sy : ↥(Ideal.primeCompl P)
hy : mk' S ry sy ∈ nonunits S
hry : mk' S ry sy = y
rz : R
sz : ↥(Ideal.primeCompl P)
hxyz :
  mk' S ((rx * ↑sy + ry * ↑sx) * rz) (sx * sy * sz) = mk' S 1 { val := 1, property := (_ : 1 ∈ Ideal.primeCompl P) }
hrz : mk' S rz sz = z
t : ↥(Ideal.primeCompl P)
ht : ↑t * ((rx * ↑sy + ry * ↑sx) * rz) = ↑t * (↑sx * ↑sy * ↑sz)
this : ↑t * (↑sx * ↑sy * ↑sz) ∈ P
⊢ False
case this
R : Type u_1
inst✝⁴ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝³ : CommSemiring S
inst✝² : Algebra R S
P✝ : Type u_3
inst✝¹ : CommSemiring P✝
P : Ideal R
hp : Ideal.IsPrime P
inst✝ : IsLocalization.AtPrime S P
this✝ : _root_.Nontrivial S := Nontrivial S P
x y : S
hu : IsUnit (x + y)
z : S
this : ∀ {r : R} {s : ↥(Ideal.primeCompl P)}, mk' S r s ∈ nonunits S → r ∈ P
rx : R
sx : ↥(Ideal.primeCompl P)
hx : mk' S rx sx ∈ nonunits S
hrx : mk' S rx sx = x
ry : R
sy : ↥(Ideal.primeCompl P)
hy : mk' S ry sy ∈ nonunits S
hry : mk' S ry sy = y
rz : R
sz : ↥(Ideal.primeCompl P)
hxyz :
  mk' S ((rx * ↑sy + ry * ↑sx) * rz) (sx * sy * sz) = mk' S 1 { val := 1, property := (_ : 1 ∈ Ideal.primeCompl P) }
hrz : mk' S rz sz = z
t : ↥(Ideal.primeCompl P)
ht : ↑t * ((rx * ↑sy + ry * ↑sx) * rz) = ↑t * (↑sx * ↑sy * ↑sz)
⊢ ↑t * (↑sx * ↑sy * ↑sz) ∈ P

Next tactic:
exact
        not_or_of_not (mt hp.mem_or_mem <| not_or_of_not sx.2 sy.2) sz.2
          (hp.mem_or_mem <| (hp.mem_or_mem this).resolve_left t.2)
theorem AtPrime.localRing [IsLocalization.AtPrime S P] : LocalRing S :=
  -- Porting Note : since I couldn't get local instance running, I just specify it manually
  letI := AtPrime.Nontrivial S P
  LocalRing.of_nonunits_add
    (by
      intro x y hx hy hu
      cases' isUnit_iff_exists_inv.1 hu with z hxyz
      have : ∀ {r : R} {s : P.primeCompl}, mk' S r s ∈ nonunits S → r ∈ P := fun {r s} =>
        not_imp_comm.1 fun nr => isUnit_iff_exists_inv.2 ⟨mk' S ↑s (⟨r, nr⟩ : P.primeCompl),
          mk'_mul_mk'_eq_one' _ _ <| show r ∈ P.primeCompl from nr⟩
      rcases mk'_surjective P.primeCompl x with ⟨rx, sx, hrx⟩
      rcases mk'_surjective P.primeCompl y with ⟨ry, sy, hry⟩
      rcases mk'_surjective P.primeCompl z with ⟨rz, sz, hrz⟩
      rw [← hrx, ← hry, ← hrz, ← mk'_add, ← mk'_mul, ← mk'_self S P.primeCompl.one_mem] at hxyz
      rw [← hrx] at hx
      rw [← hry] at hy
      obtain ⟨t, ht⟩ := IsLocalization.eq.1 hxyz
      simp only [mul_one, one_mul, Submonoid.coe_mul, Subtype.coe_mk] at ht
      suffices : (t : R) * (sx * sy * sz) ∈ P
      exact
        not_or_of_not (mt hp.mem_or_mem <| not_or_of_not sx.2 sy.2) sz.2
          (hp.mem_or_mem <| (hp.mem_or_mem this).resolve_left t.2)
      

Proof state:
case this
R : Type u_1
inst✝⁴ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝³ : CommSemiring S
inst✝² : Algebra R S
P✝ : Type u_3
inst✝¹ : CommSemiring P✝
P : Ideal R
hp : Ideal.IsPrime P
inst✝ : IsLocalization.AtPrime S P
this✝ : _root_.Nontrivial S := Nontrivial S P
x y : S
hu : IsUnit (x + y)
z : S
this : ∀ {r : R} {s : ↥(Ideal.primeCompl P)}, mk' S r s ∈ nonunits S → r ∈ P
rx : R
sx : ↥(Ideal.primeCompl P)
hx : mk' S rx sx ∈ nonunits S
hrx : mk' S rx sx = x
ry : R
sy : ↥(Ideal.primeCompl P)
hy : mk' S ry sy ∈ nonunits S
hry : mk' S ry sy = y
rz : R
sz : ↥(Ideal.primeCompl P)
hxyz :
  mk' S ((rx * ↑sy + ry * ↑sx) * rz) (sx * sy * sz) = mk' S 1 { val := 1, property := (_ : 1 ∈ Ideal.primeCompl P) }
hrz : mk' S rz sz = z
t : ↥(Ideal.primeCompl P)
ht : ↑t * ((rx * ↑sy + ry * ↑sx) * rz) = ↑t * (↑sx * ↑sy * ↑sz)
⊢ ↑t * (↑sx * ↑sy * ↑sz) ∈ P

Next tactic:
rw [← ht]
theorem AtPrime.localRing [IsLocalization.AtPrime S P] : LocalRing S :=
  -- Porting Note : since I couldn't get local instance running, I just specify it manually
  letI := AtPrime.Nontrivial S P
  LocalRing.of_nonunits_add
    (by
      intro x y hx hy hu
      cases' isUnit_iff_exists_inv.1 hu with z hxyz
      have : ∀ {r : R} {s : P.primeCompl}, mk' S r s ∈ nonunits S → r ∈ P := fun {r s} =>
        not_imp_comm.1 fun nr => isUnit_iff_exists_inv.2 ⟨mk' S ↑s (⟨r, nr⟩ : P.primeCompl),
          mk'_mul_mk'_eq_one' _ _ <| show r ∈ P.primeCompl from nr⟩
      rcases mk'_surjective P.primeCompl x with ⟨rx, sx, hrx⟩
      rcases mk'_surjective P.primeCompl y with ⟨ry, sy, hry⟩
      rcases mk'_surjective P.primeCompl z with ⟨rz, sz, hrz⟩
      rw [← hrx, ← hry, ← hrz, ← mk'_add, ← mk'_mul, ← mk'_self S P.primeCompl.one_mem] at hxyz
      rw [← hrx] at hx
      rw [← hry] at hy
      obtain ⟨t, ht⟩ := IsLocalization.eq.1 hxyz
      simp only [mul_one, one_mul, Submonoid.coe_mul, Subtype.coe_mk] at ht
      suffices : (t : R) * (sx * sy * sz) ∈ P
      exact
        not_or_of_not (mt hp.mem_or_mem <| not_or_of_not sx.2 sy.2) sz.2
          (hp.mem_or_mem <| (hp.mem_or_mem this).resolve_left t.2)
      rw [← ht]
      

Proof state:
case this
R : Type u_1
inst✝⁴ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝³ : CommSemiring S
inst✝² : Algebra R S
P✝ : Type u_3
inst✝¹ : CommSemiring P✝
P : Ideal R
hp : Ideal.IsPrime P
inst✝ : IsLocalization.AtPrime S P
this✝ : _root_.Nontrivial S := Nontrivial S P
x y : S
hu : IsUnit (x + y)
z : S
this : ∀ {r : R} {s : ↥(Ideal.primeCompl P)}, mk' S r s ∈ nonunits S → r ∈ P
rx : R
sx : ↥(Ideal.primeCompl P)
hx : mk' S rx sx ∈ nonunits S
hrx : mk' S rx sx = x
ry : R
sy : ↥(Ideal.primeCompl P)
hy : mk' S ry sy ∈ nonunits S
hry : mk' S ry sy = y
rz : R
sz : ↥(Ideal.primeCompl P)
hxyz :
  mk' S ((rx * ↑sy + ry * ↑sx) * rz) (sx * sy * sz) = mk' S 1 { val := 1, property := (_ : 1 ∈ Ideal.primeCompl P) }
hrz : mk' S rz sz = z
t : ↥(Ideal.primeCompl P)
ht : ↑t * ((rx * ↑sy + ry * ↑sx) * rz) = ↑t * (↑sx * ↑sy * ↑sz)
⊢ ↑t * ((rx * ↑sy + ry * ↑sx) * rz) ∈ P

Next tactic:
exact
        P.mul_mem_left _ <| P.mul_mem_right _ <|
            P.add_mem (P.mul_mem_right _ <| this hx) <| P.mul_mem_right _ <| this hy
theorem to_map_mem_maximal_iff (x : R) (h : LocalRing S := localRing S I) :
    algebraMap R S x ∈ LocalRing.maximalIdeal S ↔ x ∈ I :=
  not_iff_not.mp <| by
    

Proof state:
R : Type u_1
inst✝⁶ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝⁵ : CommSemiring S
inst✝⁴ : Algebra R S
P : Type u_3
inst✝³ : CommSemiring P
A : Type u_4
inst✝² : CommRing A
inst✝¹ : IsDomain A
I : Ideal R
hI : Ideal.IsPrime I
inst✝ : IsLocalization.AtPrime S I
x : R
h : optParam (LocalRing S) (_ : LocalRing S)
⊢ (algebraMap R S) x ∉ LocalRing.maximalIdeal S ↔ x ∉ I

Next tactic:
simpa only [LocalRing.mem_maximalIdeal, mem_nonunits_iff, Classical.not_not] using
      isUnit_to_map_iff S I x
theorem comap_maximalIdeal (h : LocalRing S := localRing S I) :
    (LocalRing.maximalIdeal S).comap (algebraMap R S) = I :=
  Ideal.ext fun x => by 

Proof state:
R : Type u_1
inst✝⁶ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝⁵ : CommSemiring S
inst✝⁴ : Algebra R S
P : Type u_3
inst✝³ : CommSemiring P
A : Type u_4
inst✝² : CommRing A
inst✝¹ : IsDomain A
I : Ideal R
hI : Ideal.IsPrime I
inst✝ : IsLocalization.AtPrime S I
h : optParam (LocalRing S) (_ : LocalRing S)
x : R
⊢ x ∈ Ideal.comap (algebraMap R S) (LocalRing.maximalIdeal S) ↔ x ∈ I

Next tactic:
simpa only [Ideal.mem_comap] using to_map_mem_maximal_iff _ I x
theorem mk'_mem_maximal_iff (x : R) (y : I.primeCompl) (h : LocalRing S := localRing S I) :
    mk' S x y ∈ LocalRing.maximalIdeal S ↔ x ∈ I :=
  not_iff_not.mp <| by
    

Proof state:
R : Type u_1
inst✝⁶ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝⁵ : CommSemiring S
inst✝⁴ : Algebra R S
P : Type u_3
inst✝³ : CommSemiring P
A : Type u_4
inst✝² : CommRing A
inst✝¹ : IsDomain A
I : Ideal R
hI : Ideal.IsPrime I
inst✝ : IsLocalization.AtPrime S I
x : R
y : ↥(Ideal.primeCompl I)
h : optParam (LocalRing S) (_ : LocalRing S)
⊢ mk' S x y ∉ LocalRing.maximalIdeal S ↔ x ∉ I

Next tactic:
simpa only [LocalRing.mem_maximalIdeal, mem_nonunits_iff, Classical.not_not] using
      isUnit_mk'_iff S I x y
/-- The image of `I` in the localization at `I.primeCompl` is a maximal ideal, and in particular
it is the unique maximal ideal given by the local ring structure `AtPrime.localRing` -/
theorem AtPrime.map_eq_maximalIdeal :
    Ideal.map (algebraMap R (Localization.AtPrime I)) I =
      LocalRing.maximalIdeal (Localization I.primeCompl) := by
  

Proof state:
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
P : Type u_3
inst✝ : CommSemiring P
I : Ideal R
hI : Ideal.IsPrime I
⊢ Ideal.map (algebraMap R (Localization.AtPrime I)) I = LocalRing.maximalIdeal (Localization (Ideal.primeCompl I))

Next tactic:
convert congr_arg (Ideal.map (algebraMap R (Localization.AtPrime I)))
  -- Porting Note : `algebraMap R ...` can not be solve by unification
    (AtPrime.comap_maximalIdeal (hI := hI)).symm
/-- The image of `I` in the localization at `I.primeCompl` is a maximal ideal, and in particular
it is the unique maximal ideal given by the local ring structure `AtPrime.localRing` -/
theorem AtPrime.map_eq_maximalIdeal :
    Ideal.map (algebraMap R (Localization.AtPrime I)) I =
      LocalRing.maximalIdeal (Localization I.primeCompl) := by
  convert congr_arg (Ideal.map (algebraMap R (Localization.AtPrime I)))
  -- Porting Note : `algebraMap R ...` can not be solve by unification
    (AtPrime.comap_maximalIdeal (hI := hI)).symm
  -- Porting Note : can not find `hI`
  

Proof state:
case h.e'_3
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
P : Type u_3
inst✝ : CommSemiring P
I : Ideal R
hI : Ideal.IsPrime I
⊢ LocalRing.maximalIdeal (Localization (Ideal.primeCompl I)) =
    Ideal.map (algebraMap R (Localization.AtPrime I))
      (Ideal.comap (algebraMap R (Localization.AtPrime I)) (LocalRing.maximalIdeal (Localization (Ideal.primeCompl I))))

Next tactic:
rw [map_comap I.primeCompl]
theorem le_comap_primeCompl_iff {J : Ideal P} [hJ : J.IsPrime] {f : R →+* P} :
    I.primeCompl ≤ J.primeCompl.comap f ↔ J.comap f ≤ I :=
  ⟨fun h x hx => by
    

Proof state:
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
P : Type u_3
inst✝ : CommSemiring P
I : Ideal R
hI : Ideal.IsPrime I
J : Ideal P
hJ : Ideal.IsPrime J
f : R →+* P
h : Ideal.primeCompl I ≤ Submonoid.comap f (Ideal.primeCompl J)
x : R
hx : x ∈ Ideal.comap f J
⊢ x ∈ I

Next tactic:
contrapose! hx
theorem le_comap_primeCompl_iff {J : Ideal P} [hJ : J.IsPrime] {f : R →+* P} :
    I.primeCompl ≤ J.primeCompl.comap f ↔ J.comap f ≤ I :=
  ⟨fun h x hx => by
    contrapose! hx
    

Proof state:
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
P : Type u_3
inst✝ : CommSemiring P
I : Ideal R
hI : Ideal.IsPrime I
J : Ideal P
hJ : Ideal.IsPrime J
f : R →+* P
h : Ideal.primeCompl I ≤ Submonoid.comap f (Ideal.primeCompl J)
x : R
hx : x ∉ I
⊢ x ∉ Ideal.comap f J

Next tactic:
exact h hx
instance isLocalRingHom_localRingHom (J : Ideal P) [hJ : J.IsPrime] (f : R →+* P)
    (hIJ : I = J.comap f) : IsLocalRingHom (localRingHom I J f hIJ) :=
  IsLocalRingHom.mk fun x hx => by
    

Proof state:
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
P : Type u_3
inst✝ : CommSemiring P
I : Ideal R
hI : Ideal.IsPrime I
J : Ideal P
hJ : Ideal.IsPrime J
f : R →+* P
hIJ : I = Ideal.comap f J
x : Localization.AtPrime I
hx : IsUnit ((localRingHom I J f hIJ) x)
⊢ IsUnit x

Next tactic:
rcases IsLocalization.mk'_surjective I.primeCompl x with ⟨r, s, rfl⟩
instance isLocalRingHom_localRingHom (J : Ideal P) [hJ : J.IsPrime] (f : R →+* P)
    (hIJ : I = J.comap f) : IsLocalRingHom (localRingHom I J f hIJ) :=
  IsLocalRingHom.mk fun x hx => by
    rcases IsLocalization.mk'_surjective I.primeCompl x with ⟨r, s, rfl⟩
    

Proof state:
case intro.intro
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
P : Type u_3
inst✝ : CommSemiring P
I : Ideal R
hI : Ideal.IsPrime I
J : Ideal P
hJ : Ideal.IsPrime J
f : R →+* P
hIJ : I = Ideal.comap f J
r : R
s : ↥(Ideal.primeCompl I)
hx : IsUnit ((localRingHom I J f hIJ) (mk' (Localization.AtPrime I) r s))
⊢ IsUnit (mk' (Localization.AtPrime I) r s)

Next tactic:
rw [localRingHom_mk'] at hx
instance isLocalRingHom_localRingHom (J : Ideal P) [hJ : J.IsPrime] (f : R →+* P)
    (hIJ : I = J.comap f) : IsLocalRingHom (localRingHom I J f hIJ) :=
  IsLocalRingHom.mk fun x hx => by
    rcases IsLocalization.mk'_surjective I.primeCompl x with ⟨r, s, rfl⟩
    rw [localRingHom_mk'] at hx
    

Proof state:
case intro.intro
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
P : Type u_3
inst✝ : CommSemiring P
I : Ideal R
hI : Ideal.IsPrime I
J : Ideal P
hJ : Ideal.IsPrime J
f : R →+* P
hIJ : I = Ideal.comap f J
r : R
s : ↥(Ideal.primeCompl I)
hx :
  IsUnit
    (mk' (Localization.AtPrime J) (f r) { val := f ↑s, property := (_ : ↑s ∈ Submonoid.comap f (Ideal.primeCompl J)) })
⊢ IsUnit (mk' (Localization.AtPrime I) r s)

Next tactic:
rw [AtPrime.isUnit_mk'_iff] at hx ⊢
instance isLocalRingHom_localRingHom (J : Ideal P) [hJ : J.IsPrime] (f : R →+* P)
    (hIJ : I = J.comap f) : IsLocalRingHom (localRingHom I J f hIJ) :=
  IsLocalRingHom.mk fun x hx => by
    rcases IsLocalization.mk'_surjective I.primeCompl x with ⟨r, s, rfl⟩
    rw [localRingHom_mk'] at hx
    rw [AtPrime.isUnit_mk'_iff] at hx ⊢
    

Proof state:
case intro.intro
R : Type u_1
inst✝³ : CommSemiring R
M : Submonoid R
S : Type u_2
inst✝² : CommSemiring S
inst✝¹ : Algebra R S
P : Type u_3
inst✝ : CommSemiring P
I : Ideal R
hI : Ideal.IsPrime I
J : Ideal P
hJ : Ideal.IsPrime J
f : R →+* P
hIJ : I = Ideal.comap f J
r : R
s : ↥(Ideal.primeCompl I)
hx : f r ∈ Ideal.primeCompl J
⊢ r ∈ Ideal.primeCompl I

Next tactic:
exact fun hr => hx ((SetLike.ext_iff.mp hIJ r).mp hr)
theorem localRingHom_comp {S : Type*} [CommSemiring S] (J : Ideal S) [hJ : J.IsPrime] (K : Ideal P)
    [hK : K.IsPrime] (f : R →+* S) (hIJ : I = J.comap f) (g : S →+* P) (hJK : J = K.comap g) :
    localRingHom I K (g.comp f) (by 

Proof state:
R : Type u_1
inst✝⁴ : CommSemiring R
M : Submonoid R
S✝ : Type u_2
inst✝³ : CommSemiring S✝
inst✝² : Algebra R S✝
P : Type u_3
inst✝¹ : CommSemiring P
I : Ideal R
hI : Ideal.IsPrime I
S : Type u_4
inst✝ : CommSemiring S
J : Ideal S
hJ : Ideal.IsPrime J
K : Ideal P
hK : Ideal.IsPrime K
f : R →+* S
hIJ : I = Ideal.comap f J
g : S →+* P
hJK : J = Ideal.comap g K
⊢ I = Ideal.comap (RingHom.comp g f) K

Next tactic:
rw [hIJ, hJK, Ideal.comap_comap f g]
theorem localRingHom_comp {S : Type*} [CommSemiring S] (J : Ideal S) [hJ : J.IsPrime] (K : Ideal P)
    [hK : K.IsPrime] (f : R →+* S) (hIJ : I = J.comap f) (g : S →+* P) (hJK : J = K.comap g) :
    localRingHom I K (g.comp f) (by rw [hIJ, hJK, Ideal.comap_comap f g]) =
      (localRingHom J K g hJK).comp (localRingHom I J f hIJ) :=
  localRingHom_unique _ _ _ _ fun r => by
    

Proof state:
R : Type u_1
inst✝⁴ : CommSemiring R
M : Submonoid R
S✝ : Type u_2
inst✝³ : CommSemiring S✝
inst✝² : Algebra R S✝
P : Type u_3
inst✝¹ : CommSemiring P
I : Ideal R
hI : Ideal.IsPrime I
S : Type u_4
inst✝ : CommSemiring S
J : Ideal S
hJ : Ideal.IsPrime J
K : Ideal P
hK : Ideal.IsPrime K
f : R →+* S
hIJ : I = Ideal.comap f J
g : S →+* P
hJK : J = Ideal.comap g K
r : R
⊢ (RingHom.comp (localRingHom J K g hJK) (localRingHom I J f hIJ)) ((algebraMap R (Localization.AtPrime I)) r) =
    (algebraMap P (Localization.AtPrime K)) ((RingHom.comp g f) r)

Next tactic:
simp only [Function.comp_apply, RingHom.coe_comp, localRingHom_to_map]
/-- A complex of functors gives a functor to complexes. -/
@[simps obj map]
def asFunctor {T : Type*} [Category T] (C : HomologicalComplex (T ⥤ V) c) :
    T ⥤ HomologicalComplex V c where
  obj t :=
    { X := fun i => (C.X i).obj t
      d := fun i j => (C.d i j).app t
      d_comp_d' := fun i j k _ _ => by
        have := C.d_comp_d i j k
        rw [NatTrans.ext_iff, Function.funext_iff] at this
        exact this t
      shape := fun i j h => by
        

Proof state:
V : Type u
inst✝² : Category.{v, u} V
inst✝¹ : HasZeroMorphisms V
ι : Type u_1
c : ComplexShape ι
T : Type u_2
inst✝ : Category.{?u.78, u_2} T
C : HomologicalComplex (T ⥤ V) c
t : T
i j : ι
h : ¬ComplexShape.Rel c i j
⊢ (fun i j => (d C i j).app t) i j = 0

Next tactic:
have := C.shape _ _ h
/-- A complex of functors gives a functor to complexes. -/
@[simps obj map]
def asFunctor {T : Type*} [Category T] (C : HomologicalComplex (T ⥤ V) c) :
    T ⥤ HomologicalComplex V c where
  obj t :=
    { X := fun i => (C.X i).obj t
      d := fun i j => (C.d i j).app t
      d_comp_d' := fun i j k _ _ => by
        have := C.d_comp_d i j k
        rw [NatTrans.ext_iff, Function.funext_iff] at this
        exact this t
      shape := fun i j h => by
        have := C.shape _ _ h
        

Proof state:
V : Type u
inst✝² : Category.{v, u} V
inst✝¹ : HasZeroMorphisms V
ι : Type u_1
c : ComplexShape ι
T : Type u_2
inst✝ : Category.{?u.78, u_2} T
C : HomologicalComplex (T ⥤ V) c
t : T
i j : ι
h : ¬ComplexShape.Rel c i j
this : d C i j = 0
⊢ (fun i j => (d C i j).app t) i j = 0

Next tactic:
rw [NatTrans.ext_iff, Function.funext_iff] at this
/-- A complex of functors gives a functor to complexes. -/
@[simps obj map]
def asFunctor {T : Type*} [Category T] (C : HomologicalComplex (T ⥤ V) c) :
    T ⥤ HomologicalComplex V c where
  obj t :=
    { X := fun i => (C.X i).obj t
      d := fun i j => (C.d i j).app t
      d_comp_d' := fun i j k _ _ => by
        have := C.d_comp_d i j k
        rw [NatTrans.ext_iff, Function.funext_iff] at this
        exact this t
      shape := fun i j h => by
        have := C.shape _ _ h
        rw [NatTrans.ext_iff, Function.funext_iff] at this
        

Proof state:
V : Type u
inst✝² : Category.{v, u} V
inst✝¹ : HasZeroMorphisms V
ι : Type u_1
c : ComplexShape ι
T : Type u_2
inst✝ : Category.{?u.78, u_2} T
C : HomologicalComplex (T ⥤ V) c
t : T
i j : ι
h : ¬ComplexShape.Rel c i j
this : ∀ (a : T), (d C i j).app a = 0.app a
⊢ (fun i j => (d C i j).app t) i j = 0

Next tactic:
exact this t
/-- A complex of functors gives a functor to complexes. -/
@[simps obj map]
def asFunctor {T : Type*} [Category T] (C : HomologicalComplex (T ⥤ V) c) :
    T ⥤ HomologicalComplex V c where
  obj t :=
    { X := fun i => (C.X i).obj t
      d := fun i j => (C.d i j).app t
      d_comp_d' := fun i j k _ _ => by
        

Proof state:
V : Type u
inst✝² : Category.{v, u} V
inst✝¹ : HasZeroMorphisms V
ι : Type u_1
c : ComplexShape ι
T : Type u_2
inst✝ : Category.{?u.78, u_2} T
C : HomologicalComplex (T ⥤ V) c
t : T
i j k : ι
x✝¹ : ComplexShape.Rel c i j
x✝ : ComplexShape.Rel c j k
⊢ (fun i j => (d C i j).app t) i j ≫ (fun i j => (d C i j).app t) j k = 0

Next tactic:
have := C.d_comp_d i j k