l3lab/ntp-mathlib huggingface dataset:
/-- The unit as a natural transformation. -/
def identityToΓSpec : 𝟭 LocallyRingedSpace.{u} ⟶ Γ.rightOp ⋙ Spec.toLocallyRingedSpace where
  app := LocallyRingedSpace.toΓSpec
  naturality X Y f := by
    symm
    apply LocallyRingedSpace.comp_ring_hom_ext
    · ext1 x
      dsimp [Spec.topMap, LocallyRingedSpace.toΓSpecFun]
      --Porting Note: Had to add the next four lines
      rw [comp_apply, comp_apply]
      dsimp [toΓSpecBase]
      -- The next six lines were `rw [ContinuousMap.coe_mk, ContinuousMap.coe_mk]` before
      -- leanprover/lean4#2644
      have : (ContinuousMap.mk (toΓSpecFun Y) (toΓSpec_continuous _)) (f.val.base x)
        = toΓSpecFun Y (f.val.base x) := by rw [ContinuousMap.coe_mk]
      erw [this]
      

Proof state:
case w.w
X Y : LocallyRingedSpace
f : X ⟶ Y
x : (forget TopCat).obj ↑((𝟭 LocallyRingedSpace).obj X).toPresheafedSpace
this : (ContinuousMap.mk (toΓSpecFun Y)) (f.val.base x) = toΓSpecFun Y (f.val.base x)
⊢ (PrimeSpectrum.comap (f.val.c.app (op ⊤))) ((ContinuousMap.mk (toΓSpecFun X)) x) = toΓSpecFun Y (f.val.base x)

Next tactic:
have : (ContinuousMap.mk (toΓSpecFun X) (toΓSpec_continuous _)) x
        = toΓSpecFun X x := by rw [ContinuousMap.coe_mk]
/-- The unit as a natural transformation. -/
def identityToΓSpec : 𝟭 LocallyRingedSpace.{u} ⟶ Γ.rightOp ⋙ Spec.toLocallyRingedSpace where
  app := LocallyRingedSpace.toΓSpec
  naturality X Y f := by
    symm
    apply LocallyRingedSpace.comp_ring_hom_ext
    · ext1 x
      dsimp [Spec.topMap, LocallyRingedSpace.toΓSpecFun]
      --Porting Note: Had to add the next four lines
      rw [comp_apply, comp_apply]
      dsimp [toΓSpecBase]
      -- The next six lines were `rw [ContinuousMap.coe_mk, ContinuousMap.coe_mk]` before
      -- leanprover/lean4#2644
      have : (ContinuousMap.mk (toΓSpecFun Y) (toΓSpec_continuous _)) (f.val.base x)
        = toΓSpecFun Y (f.val.base x) := by rw [ContinuousMap.coe_mk]
      erw [this]
      have : (ContinuousMap.mk (toΓSpecFun X) (toΓSpec_continuous _)) x
        = toΓSpecFun X x := by 

Proof state:
X Y : LocallyRingedSpace
f : X ⟶ Y
x : (forget TopCat).obj ↑((𝟭 LocallyRingedSpace).obj X).toPresheafedSpace
this : (ContinuousMap.mk (toΓSpecFun Y)) (f.val.base x) = toΓSpecFun Y (f.val.base x)
⊢ (ContinuousMap.mk (toΓSpecFun X)) x = toΓSpecFun X x

Next tactic:
rw [ContinuousMap.coe_mk]
/-- The unit as a natural transformation. -/
def identityToΓSpec : 𝟭 LocallyRingedSpace.{u} ⟶ Γ.rightOp ⋙ Spec.toLocallyRingedSpace where
  app := LocallyRingedSpace.toΓSpec
  naturality X Y f := by
    symm
    apply LocallyRingedSpace.comp_ring_hom_ext
    · ext1 x
      dsimp [Spec.topMap, LocallyRingedSpace.toΓSpecFun]
      --Porting Note: Had to add the next four lines
      rw [comp_apply, comp_apply]
      dsimp [toΓSpecBase]
      -- The next six lines were `rw [ContinuousMap.coe_mk, ContinuousMap.coe_mk]` before
      -- leanprover/lean4#2644
      have : (ContinuousMap.mk (toΓSpecFun Y) (toΓSpec_continuous _)) (f.val.base x)
        = toΓSpecFun Y (f.val.base x) := by rw [ContinuousMap.coe_mk]
      erw [this]
      have : (ContinuousMap.mk (toΓSpecFun X) (toΓSpec_continuous _)) x
        = toΓSpecFun X x := by rw [ContinuousMap.coe_mk]
      

Proof state:
case w.w
X Y : LocallyRingedSpace
f : X ⟶ Y
x : (forget TopCat).obj ↑((𝟭 LocallyRingedSpace).obj X).toPresheafedSpace
this✝ : (ContinuousMap.mk (toΓSpecFun Y)) (f.val.base x) = toΓSpecFun Y (f.val.base x)
this : (ContinuousMap.mk (toΓSpecFun X)) x = toΓSpecFun X x
⊢ (PrimeSpectrum.comap (f.val.c.app (op ⊤))) ((ContinuousMap.mk (toΓSpecFun X)) x) = toΓSpecFun Y (f.val.base x)

Next tactic:
erw [this]
/-- The unit as a natural transformation. -/
def identityToΓSpec : 𝟭 LocallyRingedSpace.{u} ⟶ Γ.rightOp ⋙ Spec.toLocallyRingedSpace where
  app := LocallyRingedSpace.toΓSpec
  naturality X Y f := by
    symm
    apply LocallyRingedSpace.comp_ring_hom_ext
    · ext1 x
      dsimp [Spec.topMap, LocallyRingedSpace.toΓSpecFun]
      --Porting Note: Had to add the next four lines
      rw [comp_apply, comp_apply]
      dsimp [toΓSpecBase]
      -- The next six lines were `rw [ContinuousMap.coe_mk, ContinuousMap.coe_mk]` before
      -- leanprover/lean4#2644
      have : (ContinuousMap.mk (toΓSpecFun Y) (toΓSpec_continuous _)) (f.val.base x)
        = toΓSpecFun Y (f.val.base x) := by rw [ContinuousMap.coe_mk]
      erw [this]
      have : (ContinuousMap.mk (toΓSpecFun X) (toΓSpec_continuous _)) x
        = toΓSpecFun X x := by rw [ContinuousMap.coe_mk]
      erw [this]
      

Proof state:
case w.w
X Y : LocallyRingedSpace
f : X ⟶ Y
x : (forget TopCat).obj ↑((𝟭 LocallyRingedSpace).obj X).toPresheafedSpace
this✝ : (ContinuousMap.mk (toΓSpecFun Y)) (f.val.base x) = toΓSpecFun Y (f.val.base x)
this : (ContinuousMap.mk (toΓSpecFun X)) x = toΓSpecFun X x
⊢ (PrimeSpectrum.comap (f.val.c.app (op ⊤))) (toΓSpecFun X x) = toΓSpecFun Y (f.val.base x)

Next tactic:
dsimp [toΓSpecFun]
/-- The unit as a natural transformation. -/
def identityToΓSpec : 𝟭 LocallyRingedSpace.{u} ⟶ Γ.rightOp ⋙ Spec.toLocallyRingedSpace where
  app := LocallyRingedSpace.toΓSpec
  naturality X Y f := by
    symm
    apply LocallyRingedSpace.comp_ring_hom_ext
    · ext1 x
      dsimp [Spec.topMap, LocallyRingedSpace.toΓSpecFun]
      --Porting Note: Had to add the next four lines
      rw [comp_apply, comp_apply]
      dsimp [toΓSpecBase]
      -- The next six lines were `rw [ContinuousMap.coe_mk, ContinuousMap.coe_mk]` before
      -- leanprover/lean4#2644
      have : (ContinuousMap.mk (toΓSpecFun Y) (toΓSpec_continuous _)) (f.val.base x)
        = toΓSpecFun Y (f.val.base x) := by rw [ContinuousMap.coe_mk]
      erw [this]
      have : (ContinuousMap.mk (toΓSpecFun X) (toΓSpec_continuous _)) x
        = toΓSpecFun X x := by rw [ContinuousMap.coe_mk]
      erw [this]
      dsimp [toΓSpecFun]
      -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
      

Proof state:
case w.w
X Y : LocallyRingedSpace
f : X ⟶ Y
x : (forget TopCat).obj ↑((𝟭 LocallyRingedSpace).obj X).toPresheafedSpace
this✝ : (ContinuousMap.mk (toΓSpecFun Y)) (f.val.base x) = toΓSpecFun Y (f.val.base x)
this : (ContinuousMap.mk (toΓSpecFun X)) x = toΓSpecFun X x
⊢ (PrimeSpectrum.comap (f.val.c.app (op ⊤)))
      ((PrimeSpectrum.comap (ΓToStalk X x)) (LocalRing.closedPoint ↑(TopCat.Presheaf.stalk X.presheaf x))) =
    (PrimeSpectrum.comap (ΓToStalk Y (f.val.base x)))
      (LocalRing.closedPoint ↑(TopCat.Presheaf.stalk Y.presheaf (f.val.base x)))

Next tactic:
erw [← LocalRing.comap_closedPoint (PresheafedSpace.stalkMap f.val x), ←
        PrimeSpectrum.comap_comp_apply, ← PrimeSpectrum.comap_comp_apply]
/-- The unit as a natural transformation. -/
def identityToΓSpec : 𝟭 LocallyRingedSpace.{u} ⟶ Γ.rightOp ⋙ Spec.toLocallyRingedSpace where
  app := LocallyRingedSpace.toΓSpec
  naturality X Y f := by
    symm
    apply LocallyRingedSpace.comp_ring_hom_ext
    · ext1 x
      dsimp [Spec.topMap, LocallyRingedSpace.toΓSpecFun]
      --Porting Note: Had to add the next four lines
      rw [comp_apply, comp_apply]
      dsimp [toΓSpecBase]
      -- The next six lines were `rw [ContinuousMap.coe_mk, ContinuousMap.coe_mk]` before
      -- leanprover/lean4#2644
      have : (ContinuousMap.mk (toΓSpecFun Y) (toΓSpec_continuous _)) (f.val.base x)
        = toΓSpecFun Y (f.val.base x) := by rw [ContinuousMap.coe_mk]
      erw [this]
      have : (ContinuousMap.mk (toΓSpecFun X) (toΓSpec_continuous _)) x
        = toΓSpecFun X x := by rw [ContinuousMap.coe_mk]
      erw [this]
      dsimp [toΓSpecFun]
      -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
      erw [← LocalRing.comap_closedPoint (PresheafedSpace.stalkMap f.val x), ←
        PrimeSpectrum.comap_comp_apply, ← PrimeSpectrum.comap_comp_apply]
      

Proof state:
case w.w
X Y : LocallyRingedSpace
f : X ⟶ Y
x : (forget TopCat).obj ↑((𝟭 LocallyRingedSpace).obj X).toPresheafedSpace
this✝ : (ContinuousMap.mk (toΓSpecFun Y)) (f.val.base x) = toΓSpecFun Y (f.val.base x)
this : (ContinuousMap.mk (toΓSpecFun X)) x = toΓSpecFun X x
⊢ (PrimeSpectrum.comap (RingHom.comp (ΓToStalk X x) (f.val.c.app (op ⊤))))
      (LocalRing.closedPoint ↑(TopCat.Presheaf.stalk X.presheaf x)) =
    (PrimeSpectrum.comap (RingHom.comp (PresheafedSpace.stalkMap f.val x) (ΓToStalk Y (f.val.base x))))
      (LocalRing.closedPoint ↑(PresheafedSpace.stalk X.toPresheafedSpace x))

Next tactic:
congr 2
/-- The unit as a natural transformation. -/
def identityToΓSpec : 𝟭 LocallyRingedSpace.{u} ⟶ Γ.rightOp ⋙ Spec.toLocallyRingedSpace where
  app := LocallyRingedSpace.toΓSpec
  naturality X Y f := by
    symm
    apply LocallyRingedSpace.comp_ring_hom_ext
    · ext1 x
      dsimp [Spec.topMap, LocallyRingedSpace.toΓSpecFun]
      --Porting Note: Had to add the next four lines
      rw [comp_apply, comp_apply]
      dsimp [toΓSpecBase]
      -- The next six lines were `rw [ContinuousMap.coe_mk, ContinuousMap.coe_mk]` before
      -- leanprover/lean4#2644
      have : (ContinuousMap.mk (toΓSpecFun Y) (toΓSpec_continuous _)) (f.val.base x)
        = toΓSpecFun Y (f.val.base x) := by rw [ContinuousMap.coe_mk]
      erw [this]
      have : (ContinuousMap.mk (toΓSpecFun X) (toΓSpec_continuous _)) x
        = toΓSpecFun X x := by rw [ContinuousMap.coe_mk]
      erw [this]
      dsimp [toΓSpecFun]
      -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
      erw [← LocalRing.comap_closedPoint (PresheafedSpace.stalkMap f.val x), ←
        PrimeSpectrum.comap_comp_apply, ← PrimeSpectrum.comap_comp_apply]
      congr 2
      

Proof state:
case w.w.e_a.e_f
X Y : LocallyRingedSpace
f : X ⟶ Y
x : (forget TopCat).obj ↑((𝟭 LocallyRingedSpace).obj X).toPresheafedSpace
this✝ : (ContinuousMap.mk (toΓSpecFun Y)) (f.val.base x) = toΓSpecFun Y (f.val.base x)
this : (ContinuousMap.mk (toΓSpecFun X)) x = toΓSpecFun X x
⊢ RingHom.comp (ΓToStalk X x) (f.val.c.app (op ⊤)) =
    RingHom.comp (PresheafedSpace.stalkMap f.val x) (ΓToStalk Y (f.val.base x))

Next tactic:
exact (PresheafedSpace.stalkMap_germ f.1 ⊤ ⟨x, trivial⟩).symm
/-- The unit as a natural transformation. -/
def identityToΓSpec : 𝟭 LocallyRingedSpace.{u} ⟶ Γ.rightOp ⋙ Spec.toLocallyRingedSpace where
  app := LocallyRingedSpace.toΓSpec
  naturality X Y f := by
    symm
    apply LocallyRingedSpace.comp_ring_hom_ext
    · ext1 x
      dsimp [Spec.topMap, LocallyRingedSpace.toΓSpecFun]
      --Porting Note: Had to add the next four lines
      rw [comp_apply, comp_apply]
      dsimp [toΓSpecBase]
      -- The next six lines were `rw [ContinuousMap.coe_mk, ContinuousMap.coe_mk]` before
      -- leanprover/lean4#2644
      have : (ContinuousMap.mk (toΓSpecFun Y) (toΓSpec_continuous _)) (f.val.base x)
        = toΓSpecFun Y (f.val.base x) := by rw [ContinuousMap.coe_mk]
      erw [this]
      have : (ContinuousMap.mk (toΓSpecFun X) (toΓSpec_continuous _)) x
        = toΓSpecFun X x := by rw [ContinuousMap.coe_mk]
      erw [this]
      dsimp [toΓSpecFun]
      -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
      erw [← LocalRing.comap_closedPoint (PresheafedSpace.stalkMap f.val x), ←
        PrimeSpectrum.comap_comp_apply, ← PrimeSpectrum.comap_comp_apply]
      congr 2
      exact (PresheafedSpace.stalkMap_germ f.1 ⊤ ⟨x, trivial⟩).symm
    · 

Proof state:
case h
X Y : LocallyRingedSpace
f : X ⟶ Y
⊢ ∀ (r : ↑(Γ.rightOp.obj Y).unop),
    (Γ.rightOp.map f).unop ≫
        ((𝟭 LocallyRingedSpace).obj X).presheaf.map
          (homOfLE (_ : ((𝟭 LocallyRingedSpace).map f ≫ toΓSpec Y)⁻¹ᵁ basicOpen r ≤ ⊤)).op =
      toOpen (↑(Γ.rightOp.obj Y).unop) (basicOpen r) ≫
        ((𝟭 LocallyRingedSpace).map f ≫ toΓSpec Y).val.c.app (op (basicOpen r))

Next tactic:
intro r
/-- The unit as a natural transformation. -/
def identityToΓSpec : 𝟭 LocallyRingedSpace.{u} ⟶ Γ.rightOp ⋙ Spec.toLocallyRingedSpace where
  app := LocallyRingedSpace.toΓSpec
  naturality X Y f := by
    symm
    apply LocallyRingedSpace.comp_ring_hom_ext
    · ext1 x
      dsimp [Spec.topMap, LocallyRingedSpace.toΓSpecFun]
      --Porting Note: Had to add the next four lines
      rw [comp_apply, comp_apply]
      dsimp [toΓSpecBase]
      -- The next six lines were `rw [ContinuousMap.coe_mk, ContinuousMap.coe_mk]` before
      -- leanprover/lean4#2644
      have : (ContinuousMap.mk (toΓSpecFun Y) (toΓSpec_continuous _)) (f.val.base x)
        = toΓSpecFun Y (f.val.base x) := by rw [ContinuousMap.coe_mk]
      erw [this]
      have : (ContinuousMap.mk (toΓSpecFun X) (toΓSpec_continuous _)) x
        = toΓSpecFun X x := by rw [ContinuousMap.coe_mk]
      erw [this]
      dsimp [toΓSpecFun]
      -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
      erw [← LocalRing.comap_closedPoint (PresheafedSpace.stalkMap f.val x), ←
        PrimeSpectrum.comap_comp_apply, ← PrimeSpectrum.comap_comp_apply]
      congr 2
      exact (PresheafedSpace.stalkMap_germ f.1 ⊤ ⟨x, trivial⟩).symm
    · intro r
      

Proof state:
case h
X Y : LocallyRingedSpace
f : X ⟶ Y
r : ↑(Γ.rightOp.obj Y).unop
⊢ (Γ.rightOp.map f).unop ≫
      ((𝟭 LocallyRingedSpace).obj X).presheaf.map
        (homOfLE (_ : ((𝟭 LocallyRingedSpace).map f ≫ toΓSpec Y)⁻¹ᵁ basicOpen r ≤ ⊤)).op =
    toOpen (↑(Γ.rightOp.obj Y).unop) (basicOpen r) ≫
      ((𝟭 LocallyRingedSpace).map f ≫ toΓSpec Y).val.c.app (op (basicOpen r))

Next tactic:
rw [LocallyRingedSpace.comp_val_c_app, ← Category.assoc]
/-- The unit as a natural transformation. -/
def identityToΓSpec : 𝟭 LocallyRingedSpace.{u} ⟶ Γ.rightOp ⋙ Spec.toLocallyRingedSpace where
  app := LocallyRingedSpace.toΓSpec
  naturality X Y f := by
    symm
    apply LocallyRingedSpace.comp_ring_hom_ext
    · ext1 x
      dsimp [Spec.topMap, LocallyRingedSpace.toΓSpecFun]
      --Porting Note: Had to add the next four lines
      rw [comp_apply, comp_apply]
      dsimp [toΓSpecBase]
      -- The next six lines were `rw [ContinuousMap.coe_mk, ContinuousMap.coe_mk]` before
      -- leanprover/lean4#2644
      have : (ContinuousMap.mk (toΓSpecFun Y) (toΓSpec_continuous _)) (f.val.base x)
        = toΓSpecFun Y (f.val.base x) := by rw [ContinuousMap.coe_mk]
      erw [this]
      have : (ContinuousMap.mk (toΓSpecFun X) (toΓSpec_continuous _)) x
        = toΓSpecFun X x := by rw [ContinuousMap.coe_mk]
      erw [this]
      dsimp [toΓSpecFun]
      -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
      erw [← LocalRing.comap_closedPoint (PresheafedSpace.stalkMap f.val x), ←
        PrimeSpectrum.comap_comp_apply, ← PrimeSpectrum.comap_comp_apply]
      congr 2
      exact (PresheafedSpace.stalkMap_germ f.1 ⊤ ⟨x, trivial⟩).symm
    · intro r
      rw [LocallyRingedSpace.comp_val_c_app, ← Category.assoc]
      

Proof state:
case h
X Y : LocallyRingedSpace
f : X ⟶ Y
r : ↑(Γ.rightOp.obj Y).unop
⊢ (Γ.rightOp.map f).unop ≫
      ((𝟭 LocallyRingedSpace).obj X).presheaf.map
        (homOfLE (_ : ((𝟭 LocallyRingedSpace).map f ≫ toΓSpec Y)⁻¹ᵁ basicOpen r ≤ ⊤)).op =
    (toOpen (↑(Γ.rightOp.obj Y).unop) (basicOpen r) ≫ (toΓSpec Y).val.c.app (op (basicOpen r))) ≫
      ((𝟭 LocallyRingedSpace).map f).val.c.app (op (toΓSpec Y⁻¹ᵁ (op (basicOpen r)).unop))

Next tactic:
erw [Y.toΓSpecSheafedSpace_app_spec, f.1.c.naturality]
/-- The unit as a natural transformation. -/
def identityToΓSpec : 𝟭 LocallyRingedSpace.{u} ⟶ Γ.rightOp ⋙ Spec.toLocallyRingedSpace where
  app := LocallyRingedSpace.toΓSpec
  naturality X Y f := by
    symm
    apply LocallyRingedSpace.comp_ring_hom_ext
    · ext1 x
      dsimp [Spec.topMap, LocallyRingedSpace.toΓSpecFun]
      --Porting Note: Had to add the next four lines
      rw [comp_apply, comp_apply]
      dsimp [toΓSpecBase]
      -- The next six lines were `rw [ContinuousMap.coe_mk, ContinuousMap.coe_mk]` before
      -- leanprover/lean4#2644
      have : (ContinuousMap.mk (toΓSpecFun Y) (toΓSpec_continuous _)) (f.val.base x)
        = toΓSpecFun Y (f.val.base x) := by rw [ContinuousMap.coe_mk]
      erw [this]
      have : (ContinuousMap.mk (toΓSpecFun X) (toΓSpec_continuous _)) x
        = toΓSpecFun X x := by rw [ContinuousMap.coe_mk]
      erw [this]
      dsimp [toΓSpecFun]
      -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
      erw [← LocalRing.comap_closedPoint (PresheafedSpace.stalkMap f.val x), ←
        PrimeSpectrum.comap_comp_apply, ← PrimeSpectrum.comap_comp_apply]
      congr 2
      exact (PresheafedSpace.stalkMap_germ f.1 ⊤ ⟨x, trivial⟩).symm
    · intro r
      rw [LocallyRingedSpace.comp_val_c_app, ← Category.assoc]
      erw [Y.toΓSpecSheafedSpace_app_spec, f.1.c.naturality]
      

Proof state:
case h
X Y : LocallyRingedSpace
f : X ⟶ Y
r : ↑(Γ.rightOp.obj Y).unop
⊢ (Γ.rightOp.map f).unop ≫
      ((𝟭 LocallyRingedSpace).obj X).presheaf.map
        (homOfLE (_ : ((𝟭 LocallyRingedSpace).map f ≫ toΓSpec Y)⁻¹ᵁ basicOpen r ≤ ⊤)).op =
    f.val.c.app (op ⊤) ≫ (f.val.base _* X.presheaf).map (Opens.leTop (toΓSpecMapBasicOpen Y r)).op

Next tactic:
rfl
/-- `SpecΓIdentity` is iso so these are mutually two-sided inverses. -/
theorem right_triangle (R : CommRingCat) :
    identityToΓSpec.app (Spec.toLocallyRingedSpace.obj <| op R) ≫
        Spec.toLocallyRingedSpace.map (SpecΓIdentity.inv.app R).op =
      𝟙 _ := by
  

Proof state:
R : CommRingCat
⊢ identityToΓSpec.app (Spec.toLocallyRingedSpace.obj (op R)) ≫
      Spec.toLocallyRingedSpace.map (SpecΓIdentity.inv.app R).op =
    𝟙 ((𝟭 LocallyRingedSpace).obj (Spec.toLocallyRingedSpace.obj (op R)))

Next tactic:
apply LocallyRingedSpace.comp_ring_hom_ext
/-- `SpecΓIdentity` is iso so these are mutually two-sided inverses. -/
theorem right_triangle (R : CommRingCat) :
    identityToΓSpec.app (Spec.toLocallyRingedSpace.obj <| op R) ≫
        Spec.toLocallyRingedSpace.map (SpecΓIdentity.inv.app R).op =
      𝟙 _ := by
  apply LocallyRingedSpace.comp_ring_hom_ext
  · 

Proof state:
case w
R : CommRingCat
⊢ (toΓSpec ((𝟭 LocallyRingedSpace).obj (Spec.toLocallyRingedSpace.obj (op R)))).val.base ≫
      (Spec.locallyRingedSpaceMap (SpecΓIdentity.inv.app R).op.unop).val.base =
    (𝟙 ((𝟭 LocallyRingedSpace).obj (Spec.toLocallyRingedSpace.obj (op R)))).val.base

Next tactic:
ext (p : PrimeSpectrum R)
/-- `SpecΓIdentity` is iso so these are mutually two-sided inverses. -/
theorem right_triangle (R : CommRingCat) :
    identityToΓSpec.app (Spec.toLocallyRingedSpace.obj <| op R) ≫
        Spec.toLocallyRingedSpace.map (SpecΓIdentity.inv.app R).op =
      𝟙 _ := by
  apply LocallyRingedSpace.comp_ring_hom_ext
  · ext (p : PrimeSpectrum R)
    

Proof state:
case w.w
R : CommRingCat
p : PrimeSpectrum ↑R
⊢ ((toΓSpec ((𝟭 LocallyRingedSpace).obj (Spec.toLocallyRingedSpace.obj (op R)))).val.base ≫
        (Spec.locallyRingedSpaceMap (SpecΓIdentity.inv.app R).op.unop).val.base)
      p =
    (𝟙 ((𝟭 LocallyRingedSpace).obj (Spec.toLocallyRingedSpace.obj (op R)))).val.base p

Next tactic:
change _ = p
/-- `SpecΓIdentity` is iso so these are mutually two-sided inverses. -/
theorem right_triangle (R : CommRingCat) :
    identityToΓSpec.app (Spec.toLocallyRingedSpace.obj <| op R) ≫
        Spec.toLocallyRingedSpace.map (SpecΓIdentity.inv.app R).op =
      𝟙 _ := by
  apply LocallyRingedSpace.comp_ring_hom_ext
  · ext (p : PrimeSpectrum R)
    change _ = p -- Porting note: Had to add this line to make `ext x` work.
    

Proof state:
case w.w
R : CommRingCat
p : PrimeSpectrum ↑R
⊢ ((toΓSpec ((𝟭 LocallyRingedSpace).obj (Spec.toLocallyRingedSpace.obj (op R)))).val.base ≫
        (Spec.locallyRingedSpaceMap (SpecΓIdentity.inv.app R).op.unop).val.base)
      p =
    p

Next tactic:
ext x
/-- `SpecΓIdentity` is iso so these are mutually two-sided inverses. -/
theorem right_triangle (R : CommRingCat) :
    identityToΓSpec.app (Spec.toLocallyRingedSpace.obj <| op R) ≫
        Spec.toLocallyRingedSpace.map (SpecΓIdentity.inv.app R).op =
      𝟙 _ := by
  apply LocallyRingedSpace.comp_ring_hom_ext
  · ext (p : PrimeSpectrum R)
    change _ = p -- Porting note: Had to add this line to make `ext x` work.
    ext x
    

Proof state:
case w.w.asIdeal.h
R : CommRingCat
p : PrimeSpectrum ↑R
x : ↑(op ((𝟭 CommRingCat).obj R)).unop
⊢ x ∈
      (((toΓSpec ((𝟭 LocallyRingedSpace).obj (Spec.toLocallyRingedSpace.obj (op R)))).val.base ≫
            (Spec.locallyRingedSpaceMap (SpecΓIdentity.inv.app R).op.unop).val.base)
          p).asIdeal ↔
    x ∈ p.asIdeal

Next tactic:
erw [← IsLocalization.AtPrime.to_map_mem_maximal_iff ((structureSheaf R).presheaf.stalk p)
        p.asIdeal x]
/-- `SpecΓIdentity` is iso so these are mutually two-sided inverses. -/
theorem right_triangle (R : CommRingCat) :
    identityToΓSpec.app (Spec.toLocallyRingedSpace.obj <| op R) ≫
        Spec.toLocallyRingedSpace.map (SpecΓIdentity.inv.app R).op =
      𝟙 _ := by
  apply LocallyRingedSpace.comp_ring_hom_ext
  · ext (p : PrimeSpectrum R)
    change _ = p -- Porting note: Had to add this line to make `ext x` work.
    ext x
    erw [← IsLocalization.AtPrime.to_map_mem_maximal_iff ((structureSheaf R).presheaf.stalk p)
        p.asIdeal x]
    

Proof state:
case w.w.asIdeal.h
R : CommRingCat
p : PrimeSpectrum ↑R
x : ↑(op ((𝟭 CommRingCat).obj R)).unop
⊢ x ∈
      (((toΓSpec ((𝟭 LocallyRingedSpace).obj (Spec.toLocallyRingedSpace.obj (op R)))).val.base ≫
            (Spec.locallyRingedSpaceMap (SpecΓIdentity.inv.app R).op.unop).val.base)
          p).asIdeal ↔
    (algebraMap ↑R ↑(TopCat.Presheaf.stalk (TopCat.Sheaf.presheaf (structureSheaf ↑R)) p)) x ∈
      LocalRing.maximalIdeal ↑(TopCat.Presheaf.stalk (TopCat.Sheaf.presheaf (structureSheaf ↑R)) p)

Next tactic:
rfl
/-- `SpecΓIdentity` is iso so these are mutually two-sided inverses. -/
theorem right_triangle (R : CommRingCat) :
    identityToΓSpec.app (Spec.toLocallyRingedSpace.obj <| op R) ≫
        Spec.toLocallyRingedSpace.map (SpecΓIdentity.inv.app R).op =
      𝟙 _ := by
  apply LocallyRingedSpace.comp_ring_hom_ext
  · ext (p : PrimeSpectrum R)
    change _ = p -- Porting note: Had to add this line to make `ext x` work.
    ext x
    erw [← IsLocalization.AtPrime.to_map_mem_maximal_iff ((structureSheaf R).presheaf.stalk p)
        p.asIdeal x]
    rfl
  · 

Proof state:
case h
R : CommRingCat
⊢ ∀ (r : ↑(op ((𝟭 CommRingCat).obj R)).unop),
    (SpecΓIdentity.inv.app R).op.unop ≫
        ((𝟭 LocallyRingedSpace).obj (Spec.toLocallyRingedSpace.obj (op R))).presheaf.map
          (homOfLE (_ : 𝟙 ((𝟭 LocallyRingedSpace).obj (Spec.toLocallyRingedSpace.obj (op R)))⁻¹ᵁ basicOpen r ≤ ⊤)).op =
      toOpen (↑(op ((𝟭 CommRingCat).obj R)).unop) (basicOpen r) ≫
        (𝟙 ((𝟭 LocallyRingedSpace).obj (Spec.toLocallyRingedSpace.obj (op R)))).val.c.app (op (basicOpen r))

Next tactic:
intro r
/-- `SpecΓIdentity` is iso so these are mutually two-sided inverses. -/
theorem right_triangle (R : CommRingCat) :
    identityToΓSpec.app (Spec.toLocallyRingedSpace.obj <| op R) ≫
        Spec.toLocallyRingedSpace.map (SpecΓIdentity.inv.app R).op =
      𝟙 _ := by
  apply LocallyRingedSpace.comp_ring_hom_ext
  · ext (p : PrimeSpectrum R)
    change _ = p -- Porting note: Had to add this line to make `ext x` work.
    ext x
    erw [← IsLocalization.AtPrime.to_map_mem_maximal_iff ((structureSheaf R).presheaf.stalk p)
        p.asIdeal x]
    rfl
  · intro r; 

Proof state:
case h
R : CommRingCat
r : ↑(op ((𝟭 CommRingCat).obj R)).unop
⊢ (SpecΓIdentity.inv.app R).op.unop ≫
      ((𝟭 LocallyRingedSpace).obj (Spec.toLocallyRingedSpace.obj (op R))).presheaf.map
        (homOfLE (_ : 𝟙 ((𝟭 LocallyRingedSpace).obj (Spec.toLocallyRingedSpace.obj (op R)))⁻¹ᵁ basicOpen r ≤ ⊤)).op =
    toOpen (↑(op ((𝟭 CommRingCat).obj R)).unop) (basicOpen r) ≫
      (𝟙 ((𝟭 LocallyRingedSpace).obj (Spec.toLocallyRingedSpace.obj (op R)))).val.c.app (op (basicOpen r))

Next tactic:
apply toOpen_res
/-- The adjunction `Γ ⊣ Spec` from `CommRingᵒᵖ` to `LocallyRingedSpace`. -/
--Porting Note: `simps` cause a time out, so `Unit` and `counit` will be added manually
def locallyRingedSpaceAdjunction : Γ.rightOp ⊣ Spec.toLocallyRingedSpace.{u} :=
  Adjunction.mkOfUnitCounit
    { unit := identityToΓSpec
      counit := (NatIso.op SpecΓIdentity).inv
      left_triangle := by
        

Proof state:
⊢ whiskerRight identityToΓSpec Γ.rightOp ≫
      (Functor.associator Γ.rightOp Spec.toLocallyRingedSpace Γ.rightOp).hom ≫
        whiskerLeft Γ.rightOp (NatIso.op SpecΓIdentity).inv =
    NatTrans.id (𝟭 LocallyRingedSpace ⋙ Γ.rightOp)

Next tactic:
ext X