l3lab/ntp-mathlib huggingface dataset:
instance forgetPreservesLimitsOfLeft : PreservesLimit (cospan f g) (forget C) :=
  preservesLimitOfPreservesLimitCone (pullbackConeOfLeftIsLimit f g)
    (by
      apply (IsLimit.postcomposeHomEquiv (diagramIsoCospan _) _).toFun
      refine' (IsLimit.equivIsoLimit _).toFun (limit.isLimit (cospan f.base g.base))
      fapply Cones.ext
      · exact Iso.refl _
      change ∀ j, _ = 𝟙 _ ≫ _ ≫ _
      simp_rw [Category.id_comp]
      rintro (_ | _ | _) <;> 

Proof state:
case w.some.right
C : Type u_1
inst✝ : Category.{?u.239998, u_1} C
X Y Z : PresheafedSpace C
f : X ⟶ Z
hf : IsOpenImmersion f
g : Y ⟶ Z
s : PullbackCone f g
⊢ (limit.cone (cospan f.base g.base)).π.app (some WalkingPair.right) =
    ((forget C).mapCone (pullbackConeOfLeft f g)).π.app (some WalkingPair.right) ≫
      (diagramIsoCospan (cospan f g ⋙ forget C)).hom.app (some WalkingPair.right)

Next tactic:
symm
instance forgetPreservesLimitsOfLeft : PreservesLimit (cospan f g) (forget C) :=
  preservesLimitOfPreservesLimitCone (pullbackConeOfLeftIsLimit f g)
    (by
      apply (IsLimit.postcomposeHomEquiv (diagramIsoCospan _) _).toFun
      refine' (IsLimit.equivIsoLimit _).toFun (limit.isLimit (cospan f.base g.base))
      fapply Cones.ext
      · exact Iso.refl _
      change ∀ j, _ = 𝟙 _ ≫ _ ≫ _
      simp_rw [Category.id_comp]
      rintro (_ | _ | _) <;> symm
      · 

Proof state:
case w.none
C : Type u_1
inst✝ : Category.{?u.239998, u_1} C
X Y Z : PresheafedSpace C
f : X ⟶ Z
hf : IsOpenImmersion f
g : Y ⟶ Z
s : PullbackCone f g
⊢ ((forget C).mapCone (pullbackConeOfLeft f g)).π.app none ≫ (diagramIsoCospan (cospan f g ⋙ forget C)).hom.app none =
    (limit.cone (cospan f.base g.base)).π.app none

Next tactic:
erw [Category.comp_id]
instance forgetPreservesLimitsOfLeft : PreservesLimit (cospan f g) (forget C) :=
  preservesLimitOfPreservesLimitCone (pullbackConeOfLeftIsLimit f g)
    (by
      apply (IsLimit.postcomposeHomEquiv (diagramIsoCospan _) _).toFun
      refine' (IsLimit.equivIsoLimit _).toFun (limit.isLimit (cospan f.base g.base))
      fapply Cones.ext
      · exact Iso.refl _
      change ∀ j, _ = 𝟙 _ ≫ _ ≫ _
      simp_rw [Category.id_comp]
      rintro (_ | _ | _) <;> symm
      · erw [Category.comp_id]
        

Proof state:
case w.none
C : Type u_1
inst✝ : Category.{?u.239998, u_1} C
X Y Z : PresheafedSpace C
f : X ⟶ Z
hf : IsOpenImmersion f
g : Y ⟶ Z
s : PullbackCone f g
⊢ ((forget C).mapCone (pullbackConeOfLeft f g)).π.app none = (limit.cone (cospan f.base g.base)).π.app none

Next tactic:
exact limit.w (cospan f.base g.base) WalkingCospan.Hom.inl
instance forgetPreservesLimitsOfLeft : PreservesLimit (cospan f g) (forget C) :=
  preservesLimitOfPreservesLimitCone (pullbackConeOfLeftIsLimit f g)
    (by
      apply (IsLimit.postcomposeHomEquiv (diagramIsoCospan _) _).toFun
      refine' (IsLimit.equivIsoLimit _).toFun (limit.isLimit (cospan f.base g.base))
      fapply Cones.ext
      · exact Iso.refl _
      change ∀ j, _ = 𝟙 _ ≫ _ ≫ _
      simp_rw [Category.id_comp]
      rintro (_ | _ | _) <;> symm
      · erw [Category.comp_id]
        exact limit.w (cospan f.base g.base) WalkingCospan.Hom.inl
      · 

Proof state:
case w.some.left
C : Type u_1
inst✝ : Category.{?u.239998, u_1} C
X Y Z : PresheafedSpace C
f : X ⟶ Z
hf : IsOpenImmersion f
g : Y ⟶ Z
s : PullbackCone f g
⊢ ((forget C).mapCone (pullbackConeOfLeft f g)).π.app (some WalkingPair.left) ≫
      (diagramIsoCospan (cospan f g ⋙ forget C)).hom.app (some WalkingPair.left) =
    (limit.cone (cospan f.base g.base)).π.app (some WalkingPair.left)

Next tactic:
exact Category.comp_id _
instance forgetPreservesLimitsOfLeft : PreservesLimit (cospan f g) (forget C) :=
  preservesLimitOfPreservesLimitCone (pullbackConeOfLeftIsLimit f g)
    (by
      apply (IsLimit.postcomposeHomEquiv (diagramIsoCospan _) _).toFun
      refine' (IsLimit.equivIsoLimit _).toFun (limit.isLimit (cospan f.base g.base))
      fapply Cones.ext
      · exact Iso.refl _
      change ∀ j, _ = 𝟙 _ ≫ _ ≫ _
      simp_rw [Category.id_comp]
      rintro (_ | _ | _) <;> symm
      · erw [Category.comp_id]
        exact limit.w (cospan f.base g.base) WalkingCospan.Hom.inl
      · exact Category.comp_id _
      · 

Proof state:
case w.some.right
C : Type u_1
inst✝ : Category.{?u.239998, u_1} C
X Y Z : PresheafedSpace C
f : X ⟶ Z
hf : IsOpenImmersion f
g : Y ⟶ Z
s : PullbackCone f g
⊢ ((forget C).mapCone (pullbackConeOfLeft f g)).π.app (some WalkingPair.right) ≫
      (diagramIsoCospan (cospan f g ⋙ forget C)).hom.app (some WalkingPair.right) =
    (limit.cone (cospan f.base g.base)).π.app (some WalkingPair.right)

Next tactic:
exact Category.comp_id _
theorem pullback_snd_isIso_of_range_subset (H : Set.range g.base ⊆ Set.range f.base) :
    IsIso (pullback.snd : pullback f g ⟶ _) := by
  

Proof state:
C : Type u_1
inst✝ : Category.{u_3, u_1} C
X Y Z : PresheafedSpace C
f : X ⟶ Z
hf : IsOpenImmersion f
g : Y ⟶ Z
s : PullbackCone f g
H : Set.range ⇑g.base ⊆ Set.range ⇑f.base
⊢ IsIso pullback.snd

Next tactic:
haveI := TopCat.snd_iso_of_left_embedding_range_subset hf.base_open.toEmbedding g.base H
theorem pullback_snd_isIso_of_range_subset (H : Set.range g.base ⊆ Set.range f.base) :
    IsIso (pullback.snd : pullback f g ⟶ _) := by
  haveI := TopCat.snd_iso_of_left_embedding_range_subset hf.base_open.toEmbedding g.base H
  

Proof state:
C : Type u_1
inst✝ : Category.{u_3, u_1} C
X Y Z : PresheafedSpace C
f : X ⟶ Z
hf : IsOpenImmersion f
g : Y ⟶ Z
s : PullbackCone f g
H : Set.range ⇑g.base ⊆ Set.range ⇑f.base
this : IsIso pullback.snd
⊢ IsIso pullback.snd

Next tactic:
have : IsIso (pullback.snd : pullback f g ⟶ _).base := by
    delta pullback.snd
    rw [← limit.isoLimitCone_hom_π ⟨_, pullbackConeOfLeftIsLimit f g⟩ WalkingCospan.right]
    change IsIso (_ ≫ pullback.snd)
    infer_instance
theorem pullback_snd_isIso_of_range_subset (H : Set.range g.base ⊆ Set.range f.base) :
    IsIso (pullback.snd : pullback f g ⟶ _) := by
  haveI := TopCat.snd_iso_of_left_embedding_range_subset hf.base_open.toEmbedding g.base H
  have : IsIso (pullback.snd : pullback f g ⟶ _).base := by
    

Proof state:
C : Type u_1
inst✝ : Category.{u_3, u_1} C
X Y Z : PresheafedSpace C
f : X ⟶ Z
hf : IsOpenImmersion f
g : Y ⟶ Z
s : PullbackCone f g
H : Set.range ⇑g.base ⊆ Set.range ⇑f.base
this : IsIso pullback.snd
⊢ IsIso pullback.snd.base

Next tactic:
delta pullback.snd
theorem pullback_snd_isIso_of_range_subset (H : Set.range g.base ⊆ Set.range f.base) :
    IsIso (pullback.snd : pullback f g ⟶ _) := by
  haveI := TopCat.snd_iso_of_left_embedding_range_subset hf.base_open.toEmbedding g.base H
  have : IsIso (pullback.snd : pullback f g ⟶ _).base := by
    delta pullback.snd
    

Proof state:
C : Type u_1
inst✝ : Category.{u_3, u_1} C
X Y Z : PresheafedSpace C
f : X ⟶ Z
hf : IsOpenImmersion f
g : Y ⟶ Z
s : PullbackCone f g
H : Set.range ⇑g.base ⊆ Set.range ⇑f.base
this : IsIso pullback.snd
⊢ IsIso (limit.π (cospan f g) WalkingCospan.right).base

Next tactic:
rw [← limit.isoLimitCone_hom_π ⟨_, pullbackConeOfLeftIsLimit f g⟩ WalkingCospan.right]
theorem pullback_snd_isIso_of_range_subset (H : Set.range g.base ⊆ Set.range f.base) :
    IsIso (pullback.snd : pullback f g ⟶ _) := by
  haveI := TopCat.snd_iso_of_left_embedding_range_subset hf.base_open.toEmbedding g.base H
  have : IsIso (pullback.snd : pullback f g ⟶ _).base := by
    delta pullback.snd
    rw [← limit.isoLimitCone_hom_π ⟨_, pullbackConeOfLeftIsLimit f g⟩ WalkingCospan.right]
    

Proof state:
C : Type u_1
inst✝ : Category.{u_3, u_1} C
X Y Z : PresheafedSpace C
f : X ⟶ Z
hf : IsOpenImmersion f
g : Y ⟶ Z
s : PullbackCone f g
H : Set.range ⇑g.base ⊆ Set.range ⇑f.base
this : IsIso pullback.snd
⊢ IsIso
    ((limit.isoLimitCone { cone := pullbackConeOfLeft f g, isLimit := pullbackConeOfLeftIsLimit f g }).hom ≫
        { cone := pullbackConeOfLeft f g, isLimit := pullbackConeOfLeftIsLimit f g }.cone.π.app
          WalkingCospan.right).base

Next tactic:
change IsIso (_ ≫ pullback.snd)
theorem pullback_snd_isIso_of_range_subset (H : Set.range g.base ⊆ Set.range f.base) :
    IsIso (pullback.snd : pullback f g ⟶ _) := by
  haveI := TopCat.snd_iso_of_left_embedding_range_subset hf.base_open.toEmbedding g.base H
  have : IsIso (pullback.snd : pullback f g ⟶ _).base := by
    delta pullback.snd
    rw [← limit.isoLimitCone_hom_π ⟨_, pullbackConeOfLeftIsLimit f g⟩ WalkingCospan.right]
    change IsIso (_ ≫ pullback.snd)
    

Proof state:
C : Type u_1
inst✝ : Category.{u_3, u_1} C
X Y Z : PresheafedSpace C
f : X ⟶ Z
hf : IsOpenImmersion f
g : Y ⟶ Z
s : PullbackCone f g
H : Set.range ⇑g.base ⊆ Set.range ⇑f.base
this : IsIso pullback.snd
⊢ IsIso
    ((limit.isoLimitCone { cone := pullbackConeOfLeft f g, isLimit := pullbackConeOfLeftIsLimit f g }).hom.base ≫
      pullback.snd)

Next tactic:
infer_instance
theorem pullback_snd_isIso_of_range_subset (H : Set.range g.base ⊆ Set.range f.base) :
    IsIso (pullback.snd : pullback f g ⟶ _) := by
  haveI := TopCat.snd_iso_of_left_embedding_range_subset hf.base_open.toEmbedding g.base H
  have : IsIso (pullback.snd : pullback f g ⟶ _).base := by
    delta pullback.snd
    rw [← limit.isoLimitCone_hom_π ⟨_, pullbackConeOfLeftIsLimit f g⟩ WalkingCospan.right]
    change IsIso (_ ≫ pullback.snd)
    infer_instance
  

Proof state:
C : Type u_1
inst✝ : Category.{u_3, u_1} C
X Y Z : PresheafedSpace C
f : X ⟶ Z
hf : IsOpenImmersion f
g : Y ⟶ Z
s : PullbackCone f g
H : Set.range ⇑g.base ⊆ Set.range ⇑f.base
this✝ : IsIso pullback.snd
this : IsIso pullback.snd.base
⊢ IsIso pullback.snd

Next tactic:
apply to_iso
@[simp, reassoc]
theorem lift_fac (H : Set.range g.base ⊆ Set.range f.base) : lift f g H ≫ f = g := by
  -- Porting note : this instance was automatic
  

Proof state:
C : Type u_1
inst✝ : Category.{u_3, u_1} C
X Y Z : PresheafedSpace C
f : X ⟶ Z
hf : IsOpenImmersion f
g : Y ⟶ Z
s : PullbackCone f g
H : Set.range ⇑g.base ⊆ Set.range ⇑f.base
⊢ lift f g H ≫ f = g

Next tactic:
letI := pullback_snd_isIso_of_range_subset _ _ H
@[simp, reassoc]
theorem lift_fac (H : Set.range g.base ⊆ Set.range f.base) : lift f g H ≫ f = g := by
  -- Porting note : this instance was automatic
  letI := pullback_snd_isIso_of_range_subset _ _ H
  

Proof state:
C : Type u_1
inst✝ : Category.{u_3, u_1} C
X Y Z : PresheafedSpace C
f : X ⟶ Z
hf : IsOpenImmersion f
g : Y ⟶ Z
s : PullbackCone f g
H : Set.range ⇑g.base ⊆ Set.range ⇑f.base
this : IsIso pullback.snd := pullback_snd_isIso_of_range_subset f g H
⊢ lift f g H ≫ f = g

Next tactic:
erw [Category.assoc]
@[simp, reassoc]
theorem lift_fac (H : Set.range g.base ⊆ Set.range f.base) : lift f g H ≫ f = g := by
  -- Porting note : this instance was automatic
  letI := pullback_snd_isIso_of_range_subset _ _ H
  erw [Category.assoc]; 

Proof state:
C : Type u_1
inst✝ : Category.{u_3, u_1} C
X Y Z : PresheafedSpace C
f : X ⟶ Z
hf : IsOpenImmersion f
g : Y ⟶ Z
s : PullbackCone f g
H : Set.range ⇑g.base ⊆ Set.range ⇑f.base
this : IsIso pullback.snd := pullback_snd_isIso_of_range_subset f g H
⊢ inv pullback.snd ≫ pullback.fst ≫ f = g

Next tactic:
rw [IsIso.inv_comp_eq]
@[simp, reassoc]
theorem lift_fac (H : Set.range g.base ⊆ Set.range f.base) : lift f g H ≫ f = g := by
  -- Porting note : this instance was automatic
  letI := pullback_snd_isIso_of_range_subset _ _ H
  erw [Category.assoc]; rw [IsIso.inv_comp_eq]; 

Proof state:
C : Type u_1
inst✝ : Category.{u_3, u_1} C
X Y Z : PresheafedSpace C
f : X ⟶ Z
hf : IsOpenImmersion f
g : Y ⟶ Z
s : PullbackCone f g
H : Set.range ⇑g.base ⊆ Set.range ⇑f.base
this : IsIso pullback.snd := pullback_snd_isIso_of_range_subset f g H
⊢ pullback.fst ≫ f = pullback.snd ≫ g

Next tactic:
exact pullback.condition
theorem lift_uniq (H : Set.range g.base ⊆ Set.range f.base) (l : Y ⟶ X) (hl : l ≫ f = g) :
    l = lift f g H := by 

Proof state:
C : Type u_1
inst✝ : Category.{u_3, u_1} C
X Y Z : PresheafedSpace C
f : X ⟶ Z
hf : IsOpenImmersion f
g : Y ⟶ Z
s : PullbackCone f g
H : Set.range ⇑g.base ⊆ Set.range ⇑f.base
l : Y ⟶ X
hl : l ≫ f = g
⊢ l = lift f g H

Next tactic:
rw [← cancel_mono f, hl, lift_fac]
/-- Two open immersions with equal range is isomorphic. -/
@[simps]
def isoOfRangeEq [IsOpenImmersion g] (e : Set.range f.base = Set.range g.base) : X ≅ Y where
  hom := lift g f (le_of_eq e)
  inv := lift f g (le_of_eq e.symm)
  hom_inv_id := by 

Proof state:
C : Type u_1
inst✝¹ : Category.{?u.277167, u_1} C
X Y Z : PresheafedSpace C
f : X ⟶ Z
hf : IsOpenImmersion f
g : Y ⟶ Z
s : PullbackCone f g
inst✝ : IsOpenImmersion g
e : Set.range ⇑f.base = Set.range ⇑g.base
⊢ lift g f (_ : Set.range ⇑f.base ≤ Set.range ⇑g.base) ≫ lift f g (_ : Set.range ⇑g.base ≤ Set.range ⇑f.base) = 𝟙 X

Next tactic:
rw [← cancel_mono f]
/-- Two open immersions with equal range is isomorphic. -/
@[simps]
def isoOfRangeEq [IsOpenImmersion g] (e : Set.range f.base = Set.range g.base) : X ≅ Y where
  hom := lift g f (le_of_eq e)
  inv := lift f g (le_of_eq e.symm)
  hom_inv_id := by rw [← cancel_mono f]; 

Proof state:
C : Type u_1
inst✝¹ : Category.{?u.277167, u_1} C
X Y Z : PresheafedSpace C
f : X ⟶ Z
hf : IsOpenImmersion f
g : Y ⟶ Z
s : PullbackCone f g
inst✝ : IsOpenImmersion g
e : Set.range ⇑f.base = Set.range ⇑g.base
⊢ (lift g f (_ : Set.range ⇑f.base ≤ Set.range ⇑g.base) ≫ lift f g (_ : Set.range ⇑g.base ≤ Set.range ⇑f.base)) ≫ f =
    𝟙 X ≫ f

Next tactic:
simp
/-- Two open immersions with equal range is isomorphic. -/
@[simps]
def isoOfRangeEq [IsOpenImmersion g] (e : Set.range f.base = Set.range g.base) : X ≅ Y where
  hom := lift g f (le_of_eq e)
  inv := lift f g (le_of_eq e.symm)
  hom_inv_id := by rw [← cancel_mono f]; simp
  inv_hom_id := by 

Proof state:
C : Type u_1
inst✝¹ : Category.{?u.277167, u_1} C
X Y Z : PresheafedSpace C
f : X ⟶ Z
hf : IsOpenImmersion f
g : Y ⟶ Z
s : PullbackCone f g
inst✝ : IsOpenImmersion g
e : Set.range ⇑f.base = Set.range ⇑g.base
⊢ lift f g (_ : Set.range ⇑g.base ≤ Set.range ⇑f.base) ≫ lift g f (_ : Set.range ⇑f.base ≤ Set.range ⇑g.base) = 𝟙 Y

Next tactic:
rw [← cancel_mono g]
/-- Two open immersions with equal range is isomorphic. -/
@[simps]
def isoOfRangeEq [IsOpenImmersion g] (e : Set.range f.base = Set.range g.base) : X ≅ Y where
  hom := lift g f (le_of_eq e)
  inv := lift f g (le_of_eq e.symm)
  hom_inv_id := by rw [← cancel_mono f]; simp
  inv_hom_id := by rw [← cancel_mono g]; 

Proof state:
C : Type u_1
inst✝¹ : Category.{?u.277167, u_1} C
X Y Z : PresheafedSpace C
f : X ⟶ Z
hf : IsOpenImmersion f
g : Y ⟶ Z
s : PullbackCone f g
inst✝ : IsOpenImmersion g
e : Set.range ⇑f.base = Set.range ⇑g.base
⊢ (lift f g (_ : Set.range ⇑g.base ≤ Set.range ⇑f.base) ≫ lift g f (_ : Set.range ⇑f.base ≤ Set.range ⇑g.base)) ≫ g =
    𝟙 Y ≫ g

Next tactic:
simp
/-- If `X ⟶ Y` is an open immersion, and `Y` is a SheafedSpace, then so is `X`. -/
def toSheafedSpace : SheafedSpace C where
  IsSheaf := by
    

Proof state:
C : Type u_1
inst✝ : Category.{?u.279937, u_1} C
X : PresheafedSpace C
Y : SheafedSpace C
f : X ⟶ Y.toPresheafedSpace
H : IsOpenImmersion f
⊢ TopCat.Presheaf.IsSheaf X.presheaf

Next tactic:
apply TopCat.Presheaf.isSheaf_of_iso (sheafIsoOfIso H.isoRestrict.symm).symm
/-- If `X ⟶ Y` is an open immersion, and `Y` is a SheafedSpace, then so is `X`. -/
def toSheafedSpace : SheafedSpace C where
  IsSheaf := by
    apply TopCat.Presheaf.isSheaf_of_iso (sheafIsoOfIso H.isoRestrict.symm).symm
    

Proof state:
C : Type u_1
inst✝ : Category.{?u.279937, u_1} C
X : PresheafedSpace C
Y : SheafedSpace C
f : X ⟶ Y.toPresheafedSpace
H : IsOpenImmersion f
⊢ TopCat.Presheaf.IsSheaf
    ((isoRestrict H).symm.hom.base _* (restrict Y.toPresheafedSpace (_ : OpenEmbedding ⇑f.base)).presheaf)

Next tactic:
apply TopCat.Sheaf.pushforward_sheaf_of_sheaf
/-- If `X ⟶ Y` is an open immersion, and `Y` is a SheafedSpace, then so is `X`. -/
def toSheafedSpace : SheafedSpace C where
  IsSheaf := by
    apply TopCat.Presheaf.isSheaf_of_iso (sheafIsoOfIso H.isoRestrict.symm).symm
    apply TopCat.Sheaf.pushforward_sheaf_of_sheaf
    

Proof state:
case h
C : Type u_1
inst✝ : Category.{?u.279937, u_1} C
X : PresheafedSpace C
Y : SheafedSpace C
f : X ⟶ Y.toPresheafedSpace
H : IsOpenImmersion f
⊢ TopCat.Presheaf.IsSheaf (restrict Y.toPresheafedSpace (_ : OpenEmbedding ⇑f.base)).presheaf

Next tactic:
exact (Y.restrict H.base_open).IsSheaf
@[simp]
theorem sheafedSpace_toSheafedSpace {X Y : SheafedSpace C} (f : X ⟶ Y) [IsOpenImmersion f] :
    toSheafedSpace Y f = X := by 

Proof state:
C : Type u_1
inst✝¹ : Category.{u_2, u_1} C
X✝ : PresheafedSpace C
Y✝ : SheafedSpace C
f✝ : X✝ ⟶ Y✝.toPresheafedSpace
H : IsOpenImmersion f✝
X Y : SheafedSpace C
f : X ⟶ Y
inst✝ : IsOpenImmersion f
⊢ toSheafedSpace Y f = X

Next tactic:
cases X
@[simp]
theorem sheafedSpace_toSheafedSpace {X Y : SheafedSpace C} (f : X ⟶ Y) [IsOpenImmersion f] :
    toSheafedSpace Y f = X := by cases X; 

Proof state:
case mk
C : Type u_1
inst✝¹ : Category.{u_2, u_1} C
X : PresheafedSpace C
Y✝ : SheafedSpace C
f✝ : X ⟶ Y✝.toPresheafedSpace
H : IsOpenImmersion f✝
Y : SheafedSpace C
toPresheafedSpace✝ : PresheafedSpace C
IsSheaf✝ : TopCat.Presheaf.IsSheaf toPresheafedSpace✝.presheaf
f : { toPresheafedSpace := toPresheafedSpace✝, IsSheaf := IsSheaf✝ } ⟶ Y
inst✝ : IsOpenImmersion f
⊢ toSheafedSpace Y f = { toPresheafedSpace := toPresheafedSpace✝, IsSheaf := IsSheaf✝ }

Next tactic:
rfl
@[simp]
theorem locallyRingedSpace_toLocallyRingedSpace {X Y : LocallyRingedSpace} (f : X ⟶ Y)
    [LocallyRingedSpace.IsOpenImmersion f] : toLocallyRingedSpace Y f.1 = X := by
    

Proof state:
C : Type u_1
inst✝¹ : Category.{?u.286855, u_1} C
X✝ : PresheafedSpace CommRingCat
Y✝ : LocallyRingedSpace
f✝ : X✝ ⟶ Y✝.toPresheafedSpace
H : IsOpenImmersion f✝
X Y : LocallyRingedSpace
f : X ⟶ Y
inst✝ : LocallyRingedSpace.IsOpenImmersion f
⊢ toLocallyRingedSpace Y f.val = X

Next tactic:
cases X
@[simp]
theorem locallyRingedSpace_toLocallyRingedSpace {X Y : LocallyRingedSpace} (f : X ⟶ Y)
    [LocallyRingedSpace.IsOpenImmersion f] : toLocallyRingedSpace Y f.1 = X := by
    cases X; 

Proof state:
case mk
C : Type u_1
inst✝¹ : Category.{?u.286855, u_1} C
X : PresheafedSpace CommRingCat
Y✝ : LocallyRingedSpace
f✝ : X ⟶ Y✝.toPresheafedSpace
H : IsOpenImmersion f✝
Y : LocallyRingedSpace
toSheafedSpace✝ : SheafedSpace CommRingCat
localRing✝ : ∀ (x : ↑↑toSheafedSpace✝.toPresheafedSpace), LocalRing ↑(TopCat.Presheaf.stalk toSheafedSpace✝.presheaf x)
f : { toSheafedSpace := toSheafedSpace✝, localRing := localRing✝ } ⟶ Y
inst✝ : LocallyRingedSpace.IsOpenImmersion f
⊢ toLocallyRingedSpace Y f.val = { toSheafedSpace := toSheafedSpace✝, localRing := localRing✝ }

Next tactic:
delta toLocallyRingedSpace
@[simp]
theorem locallyRingedSpace_toLocallyRingedSpace {X Y : LocallyRingedSpace} (f : X ⟶ Y)
    [LocallyRingedSpace.IsOpenImmersion f] : toLocallyRingedSpace Y f.1 = X := by
    cases X; delta toLocallyRingedSpace; 

Proof state:
case mk
C : Type u_1
inst✝¹ : Category.{?u.286855, u_1} C
X : PresheafedSpace CommRingCat
Y✝ : LocallyRingedSpace
f✝ : X ⟶ Y✝.toPresheafedSpace
H : IsOpenImmersion f✝
Y : LocallyRingedSpace
toSheafedSpace✝ : SheafedSpace CommRingCat
localRing✝ : ∀ (x : ↑↑toSheafedSpace✝.toPresheafedSpace), LocalRing ↑(TopCat.Presheaf.stalk toSheafedSpace✝.presheaf x)
f : { toSheafedSpace := toSheafedSpace✝, localRing := localRing✝ } ⟶ Y
inst✝ : LocallyRingedSpace.IsOpenImmersion f
⊢ { toSheafedSpace := toSheafedSpace Y.toSheafedSpace f.val,
      localRing :=
        (_ :
          ∀ (x : ↑↑(toSheafedSpace Y.toSheafedSpace f.val).toPresheafedSpace),
            LocalRing
              ↑(stalk { toSheafedSpace := toSheafedSpace✝, localRing := localRing✝ }.toSheafedSpace.toPresheafedSpace
                  x)) } =
    { toSheafedSpace := toSheafedSpace✝, localRing := localRing✝ }

Next tactic:
simp
theorem isIso_of_subset {X Y : PresheafedSpace C} (f : X ⟶ Y)
    [H : PresheafedSpace.IsOpenImmersion f] (U : Opens Y.carrier)
    (hU : (U : Set Y.carrier) ⊆ Set.range f.base) : IsIso (f.c.app <| op U) := by
  

Proof state:
C : Type u_1
inst✝ : Category.{u_2, u_1} C
X Y : PresheafedSpace C
f : X ⟶ Y
H : IsOpenImmersion f
U : Opens ↑↑Y
hU : ↑U ⊆ Set.range ⇑f.base
⊢ IsIso (f.c.app (op U))

Next tactic:
have : U = H.base_open.isOpenMap.functor.obj ((Opens.map f.base).obj U) := by
    ext1
    exact (Set.inter_eq_left.mpr hU).symm.trans Set.image_preimage_eq_inter_range.symm
theorem isIso_of_subset {X Y : PresheafedSpace C} (f : X ⟶ Y)
    [H : PresheafedSpace.IsOpenImmersion f] (U : Opens Y.carrier)
    (hU : (U : Set Y.carrier) ⊆ Set.range f.base) : IsIso (f.c.app <| op U) := by
  have : U = H.base_open.isOpenMap.functor.obj ((Opens.map f.base).obj U) := by
    

Proof state:
C : Type u_1
inst✝ : Category.{u_2, u_1} C
X Y : PresheafedSpace C
f : X ⟶ Y
H : IsOpenImmersion f
U : Opens ↑↑Y
hU : ↑U ⊆ Set.range ⇑f.base
⊢ U = (IsOpenMap.functor (_ : IsOpenMap ⇑f.base)).obj ((Opens.map f.base).obj U)

Next tactic:
ext1
theorem isIso_of_subset {X Y : PresheafedSpace C} (f : X ⟶ Y)
    [H : PresheafedSpace.IsOpenImmersion f] (U : Opens Y.carrier)
    (hU : (U : Set Y.carrier) ⊆ Set.range f.base) : IsIso (f.c.app <| op U) := by
  have : U = H.base_open.isOpenMap.functor.obj ((Opens.map f.base).obj U) := by
    ext1
    

Proof state:
case h
C : Type u_1
inst✝ : Category.{u_2, u_1} C
X Y : PresheafedSpace C
f : X ⟶ Y
H : IsOpenImmersion f
U : Opens ↑↑Y
hU : ↑U ⊆ Set.range ⇑f.base
⊢ ↑U = ↑((IsOpenMap.functor (_ : IsOpenMap ⇑f.base)).obj ((Opens.map f.base).obj U))

Next tactic:
exact (Set.inter_eq_left.mpr hU).symm.trans Set.image_preimage_eq_inter_range.symm
theorem isIso_of_subset {X Y : PresheafedSpace C} (f : X ⟶ Y)
    [H : PresheafedSpace.IsOpenImmersion f] (U : Opens Y.carrier)
    (hU : (U : Set Y.carrier) ⊆ Set.range f.base) : IsIso (f.c.app <| op U) := by
  have : U = H.base_open.isOpenMap.functor.obj ((Opens.map f.base).obj U) := by
    ext1
    exact (Set.inter_eq_left.mpr hU).symm.trans Set.image_preimage_eq_inter_range.symm
  

Proof state:
C : Type u_1
inst✝ : Category.{u_2, u_1} C
X Y : PresheafedSpace C
f : X ⟶ Y
H : IsOpenImmersion f
U : Opens ↑↑Y
hU : ↑U ⊆ Set.range ⇑f.base
this : U = (IsOpenMap.functor (_ : IsOpenMap ⇑f.base)).obj ((Opens.map f.base).obj U)
⊢ IsIso (f.c.app (op U))

Next tactic:
convert H.c_iso ((Opens.map f.base).obj U)
instance : Mono f :=
  (forget).mono_of_mono_map (show @Mono (PresheafedSpace C) _ _ _ f by 

Proof state:
C : Type u_1
inst✝ : Category.{?u.304428, u_1} C
X Y Z : SheafedSpace C
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
⊢ Mono f

Next tactic:
infer_instance
instance hasLimit_cospan_forget_of_left : HasLimit (cospan f g ⋙ forget) := by
  

Proof state:
C : Type u_1
inst✝ : Category.{?u.309175, u_1} C
X Y Z : SheafedSpace C
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
⊢ HasLimit (cospan f g ⋙ forget)

Next tactic:
have : HasLimit (cospan ((cospan f g ⋙ forget).map Hom.inl) ((cospan f g ⋙ forget).map Hom.inr))
instance hasLimit_cospan_forget_of_left : HasLimit (cospan f g ⋙ forget) := by
  have : HasLimit (cospan ((cospan f g ⋙ forget).map Hom.inl) ((cospan f g ⋙ forget).map Hom.inr))
  · 

Proof state:
case this
C : Type u_1
inst✝ : Category.{?u.309175, u_1} C
X Y Z : SheafedSpace C
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
⊢ HasLimit (cospan ((cospan f g ⋙ forget).map Hom.inl) ((cospan f g ⋙ forget).map Hom.inr))

Next tactic:
change HasLimit (cospan ((forget).map f) ((forget).map g))
instance hasLimit_cospan_forget_of_left : HasLimit (cospan f g ⋙ forget) := by
  have : HasLimit (cospan ((cospan f g ⋙ forget).map Hom.inl) ((cospan f g ⋙ forget).map Hom.inr))
  · change HasLimit (cospan ((forget).map f) ((forget).map g))
    

Proof state:
case this
C : Type u_1
inst✝ : Category.{?u.309175, u_1} C
X Y Z : SheafedSpace C
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
⊢ HasLimit (cospan (forget.map f) (forget.map g))

Next tactic:
infer_instance
instance hasLimit_cospan_forget_of_left : HasLimit (cospan f g ⋙ forget) := by
  have : HasLimit (cospan ((cospan f g ⋙ forget).map Hom.inl) ((cospan f g ⋙ forget).map Hom.inr))
  · change HasLimit (cospan ((forget).map f) ((forget).map g))
    infer_instance
  

Proof state:
C : Type u_1
inst✝ : Category.{?u.309175, u_1} C
X Y Z : SheafedSpace C
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
this : HasLimit (cospan ((cospan f g ⋙ forget).map Hom.inl) ((cospan f g ⋙ forget).map Hom.inr))
⊢ HasLimit (cospan f g ⋙ forget)

Next tactic:
apply hasLimitOfIso (diagramIsoCospan _).symm