l3lab/ntp-mathlib huggingface dataset:
/-- An explicit pullback cone over `cospan f g` if `f` is an open immersion. -/
def pullbackConeOfLeft : PullbackCone f g := by
  refine' PullbackCone.mk _
      (Y.ofRestrict (TopCat.snd_openEmbedding_of_left_openEmbedding H.base_open g.1.base)) _
  · use PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftFst f.1 g.1
    intro x
    have := PresheafedSpace.stalkMap.congr_hom _ _
        (PresheafedSpace.IsOpenImmersion.pullback_cone_of_left_condition f.1 g.1) x
    rw [PresheafedSpace.stalkMap.comp, PresheafedSpace.stalkMap.comp] at this
    rw [← IsIso.eq_inv_comp] at this
    rw [this]
    

Proof state:
case prop
C : Type u_1
inst✝ : Category.{?u.488555, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
x : ↑↑(restrict Y (_ : OpenEmbedding ⇑pullback.snd)).toSheafedSpace.toPresheafedSpace
this :
  PresheafedSpace.stalkMap (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftFst f.val g.val) x =
    inv (PresheafedSpace.stalkMap f.val ((PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftFst f.val g.val).base x)) ≫
      eqToHom
          (_ :
            PresheafedSpace.stalk Z.toPresheafedSpace
                ((PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftFst f.val g.val ≫ f.val).base x) =
              PresheafedSpace.stalk Z.toPresheafedSpace
                ((PresheafedSpace.ofRestrict Y.toPresheafedSpace (_ : OpenEmbedding ⇑pullback.snd) ≫ g.val).base x)) ≫
        PresheafedSpace.stalkMap g.val
            ((PresheafedSpace.ofRestrict Y.toPresheafedSpace (_ : OpenEmbedding ⇑pullback.snd)).base x) ≫
          PresheafedSpace.stalkMap (PresheafedSpace.ofRestrict Y.toPresheafedSpace (_ : OpenEmbedding ⇑pullback.snd)) x
⊢ IsLocalRingHom
    (inv (PresheafedSpace.stalkMap f.val ((PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftFst f.val g.val).base x)) ≫
      eqToHom
          (_ :
            PresheafedSpace.stalk Z.toPresheafedSpace
                ((PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftFst f.val g.val ≫ f.val).base x) =
              PresheafedSpace.stalk Z.toPresheafedSpace
                ((PresheafedSpace.ofRestrict Y.toPresheafedSpace (_ : OpenEmbedding ⇑pullback.snd) ≫ g.val).base x)) ≫
        PresheafedSpace.stalkMap g.val
            ((PresheafedSpace.ofRestrict Y.toPresheafedSpace (_ : OpenEmbedding ⇑pullback.snd)).base x) ≫
          PresheafedSpace.stalkMap (PresheafedSpace.ofRestrict Y.toPresheafedSpace (_ : OpenEmbedding ⇑pullback.snd)) x)

Next tactic:
infer_instance
/-- An explicit pullback cone over `cospan f g` if `f` is an open immersion. -/
def pullbackConeOfLeft : PullbackCone f g := by
  refine' PullbackCone.mk _
      (Y.ofRestrict (TopCat.snd_openEmbedding_of_left_openEmbedding H.base_open g.1.base)) _
  · use PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftFst f.1 g.1
    intro x
    have := PresheafedSpace.stalkMap.congr_hom _ _
        (PresheafedSpace.IsOpenImmersion.pullback_cone_of_left_condition f.1 g.1) x
    rw [PresheafedSpace.stalkMap.comp, PresheafedSpace.stalkMap.comp] at this
    rw [← IsIso.eq_inv_comp] at this
    rw [this]
    infer_instance
  · 

Proof state:
case refine'_2
C : Type u_1
inst✝ : Category.{?u.488555, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
⊢ { val := PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftFst f.val g.val,
        prop :=
          (_ :
            ∀ (x : ↑↑(restrict Y (_ : OpenEmbedding ⇑pullback.snd)).toSheafedSpace.toPresheafedSpace),
              IsLocalRingHom
                (PresheafedSpace.stalkMap (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftFst f.val g.val) x)) } ≫
      f =
    ofRestrict Y (_ : OpenEmbedding ⇑pullback.snd) ≫ g

Next tactic:
exact LocallyRingedSpace.Hom.ext _ _
        (PresheafedSpace.IsOpenImmersion.pullback_cone_of_left_condition _ _)
instance : LocallyRingedSpace.IsOpenImmersion (pullbackConeOfLeft f g).snd :=
  show PresheafedSpace.IsOpenImmersion (Y.toPresheafedSpace.ofRestrict _) by 

Proof state:
C : Type u_1
inst✝ : Category.{?u.491361, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
⊢ PresheafedSpace.IsOpenImmersion (PresheafedSpace.ofRestrict Y.toPresheafedSpace (_ : OpenEmbedding ⇑pullback.snd))

Next tactic:
infer_instance
/-- The constructed `pullbackConeOfLeft` is indeed limiting. -/
def pullbackConeOfLeftIsLimit : IsLimit (pullbackConeOfLeft f g) :=
  PullbackCone.isLimitAux' _ fun s => by
    

Proof state:
C : Type u_1
inst✝ : Category.{?u.491994, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
s : PullbackCone f g
⊢ { l //
    l ≫ PullbackCone.fst (pullbackConeOfLeft f g) = PullbackCone.fst s ∧
      l ≫ PullbackCone.snd (pullbackConeOfLeft f g) = PullbackCone.snd s ∧
        ∀ {m : s.pt ⟶ (pullbackConeOfLeft f g).pt},
          m ≫ PullbackCone.fst (pullbackConeOfLeft f g) = PullbackCone.fst s →
            m ≫ PullbackCone.snd (pullbackConeOfLeft f g) = PullbackCone.snd s → m = l }

Next tactic:
refine' ⟨LocallyRingedSpace.Hom.mk (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift
        f.1 g.1 (PullbackCone.mk _ _ (congr_arg LocallyRingedSpace.Hom.val s.condition))) _,
      LocallyRingedSpace.Hom.ext _ _
        (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift_fst f.1 g.1 _),
      LocallyRingedSpace.Hom.ext _ _
          (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift_snd f.1 g.1 _), _⟩
/-- The constructed `pullbackConeOfLeft` is indeed limiting. -/
def pullbackConeOfLeftIsLimit : IsLimit (pullbackConeOfLeft f g) :=
  PullbackCone.isLimitAux' _ fun s => by
    refine' ⟨LocallyRingedSpace.Hom.mk (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift
        f.1 g.1 (PullbackCone.mk _ _ (congr_arg LocallyRingedSpace.Hom.val s.condition))) _,
      LocallyRingedSpace.Hom.ext _ _
        (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift_fst f.1 g.1 _),
      LocallyRingedSpace.Hom.ext _ _
          (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift_snd f.1 g.1 _), _⟩
    · 

Proof state:
case refine'_1
C : Type u_1
inst✝ : Category.{?u.491994, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
s : PullbackCone f g
⊢ ∀ (x : ↑↑s.pt.toPresheafedSpace),
    IsLocalRingHom
      (PresheafedSpace.stalkMap
        (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift f.val g.val
          (PullbackCone.mk (PullbackCone.fst s).val (PullbackCone.snd s).val
            (_ : (PullbackCone.fst s ≫ f).val = (PullbackCone.snd s ≫ g).val)))
        x)

Next tactic:
intro x
/-- The constructed `pullbackConeOfLeft` is indeed limiting. -/
def pullbackConeOfLeftIsLimit : IsLimit (pullbackConeOfLeft f g) :=
  PullbackCone.isLimitAux' _ fun s => by
    refine' ⟨LocallyRingedSpace.Hom.mk (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift
        f.1 g.1 (PullbackCone.mk _ _ (congr_arg LocallyRingedSpace.Hom.val s.condition))) _,
      LocallyRingedSpace.Hom.ext _ _
        (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift_fst f.1 g.1 _),
      LocallyRingedSpace.Hom.ext _ _
          (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift_snd f.1 g.1 _), _⟩
    · intro x
      

Proof state:
case refine'_1
C : Type u_1
inst✝ : Category.{?u.491994, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
s : PullbackCone f g
x : ↑↑s.pt.toPresheafedSpace
⊢ IsLocalRingHom
    (PresheafedSpace.stalkMap
      (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift f.val g.val
        (PullbackCone.mk (PullbackCone.fst s).val (PullbackCone.snd s).val
          (_ : (PullbackCone.fst s ≫ f).val = (PullbackCone.snd s ≫ g).val)))
      x)

Next tactic:
have :=
        PresheafedSpace.stalkMap.congr_hom _ _
          (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift_snd f.1 g.1
            (PullbackCone.mk s.fst.1 s.snd.1 (congr_arg LocallyRingedSpace.Hom.val s.condition)))
          x
/-- The constructed `pullbackConeOfLeft` is indeed limiting. -/
def pullbackConeOfLeftIsLimit : IsLimit (pullbackConeOfLeft f g) :=
  PullbackCone.isLimitAux' _ fun s => by
    refine' ⟨LocallyRingedSpace.Hom.mk (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift
        f.1 g.1 (PullbackCone.mk _ _ (congr_arg LocallyRingedSpace.Hom.val s.condition))) _,
      LocallyRingedSpace.Hom.ext _ _
        (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift_fst f.1 g.1 _),
      LocallyRingedSpace.Hom.ext _ _
          (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift_snd f.1 g.1 _), _⟩
    · intro x
      have :=
        PresheafedSpace.stalkMap.congr_hom _ _
          (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift_snd f.1 g.1
            (PullbackCone.mk s.fst.1 s.snd.1 (congr_arg LocallyRingedSpace.Hom.val s.condition)))
          x
      

Proof state:
case refine'_1
C : Type u_1
inst✝ : Category.{?u.491994, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
s : PullbackCone f g
x : ↑↑s.pt.toPresheafedSpace
this :
  PresheafedSpace.stalkMap
      (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift f.val g.val
          (PullbackCone.mk (PullbackCone.fst s).val (PullbackCone.snd s).val
            (_ : (PullbackCone.fst s ≫ f).val = (PullbackCone.snd s ≫ g).val)) ≫
        PullbackCone.snd (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeft f.val g.val))
      x =
    eqToHom
        (_ :
          PresheafedSpace.stalk Y.toPresheafedSpace
              ((PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift f.val g.val
                      (PullbackCone.mk (PullbackCone.fst s).val (PullbackCone.snd s).val
                        (_ : (PullbackCone.fst s ≫ f).val = (PullbackCone.snd s ≫ g).val)) ≫
                    PullbackCone.snd (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeft f.val g.val)).base
                x) =
            PresheafedSpace.stalk Y.toPresheafedSpace
              ((PullbackCone.snd
                    (PullbackCone.mk (PullbackCone.fst s).val (PullbackCone.snd s).val
                      (_ : (PullbackCone.fst s ≫ f).val = (PullbackCone.snd s ≫ g).val))).base
                x)) ≫
      PresheafedSpace.stalkMap
        (PullbackCone.snd
          (PullbackCone.mk (PullbackCone.fst s).val (PullbackCone.snd s).val
            (_ : (PullbackCone.fst s ≫ f).val = (PullbackCone.snd s ≫ g).val)))
        x
⊢ IsLocalRingHom
    (PresheafedSpace.stalkMap
      (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift f.val g.val
        (PullbackCone.mk (PullbackCone.fst s).val (PullbackCone.snd s).val
          (_ : (PullbackCone.fst s ≫ f).val = (PullbackCone.snd s ≫ g).val)))
      x)

Next tactic:
change _ = _ ≫ PresheafedSpace.stalkMap s.snd.1 x at this
/-- The constructed `pullbackConeOfLeft` is indeed limiting. -/
def pullbackConeOfLeftIsLimit : IsLimit (pullbackConeOfLeft f g) :=
  PullbackCone.isLimitAux' _ fun s => by
    refine' ⟨LocallyRingedSpace.Hom.mk (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift
        f.1 g.1 (PullbackCone.mk _ _ (congr_arg LocallyRingedSpace.Hom.val s.condition))) _,
      LocallyRingedSpace.Hom.ext _ _
        (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift_fst f.1 g.1 _),
      LocallyRingedSpace.Hom.ext _ _
          (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift_snd f.1 g.1 _), _⟩
    · intro x
      have :=
        PresheafedSpace.stalkMap.congr_hom _ _
          (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift_snd f.1 g.1
            (PullbackCone.mk s.fst.1 s.snd.1 (congr_arg LocallyRingedSpace.Hom.val s.condition)))
          x
      change _ = _ ≫ PresheafedSpace.stalkMap s.snd.1 x at this
      

Proof state:
case refine'_1
C : Type u_1
inst✝ : Category.{?u.491994, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
s : PullbackCone f g
x : ↑↑s.pt.toPresheafedSpace
this :
  PresheafedSpace.stalkMap
      (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift f.val g.val
          (PullbackCone.mk (PullbackCone.fst s).val (PullbackCone.snd s).val
            (_ : (PullbackCone.fst s ≫ f).val = (PullbackCone.snd s ≫ g).val)) ≫
        PullbackCone.snd (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeft f.val g.val))
      x =
    eqToHom
        (_ :
          PresheafedSpace.stalk Y.toPresheafedSpace
              ((PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift f.val g.val
                      (PullbackCone.mk (PullbackCone.fst s).val (PullbackCone.snd s).val
                        (_ : (PullbackCone.fst s ≫ f).val = (PullbackCone.snd s ≫ g).val)) ≫
                    PullbackCone.snd (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeft f.val g.val)).base
                x) =
            PresheafedSpace.stalk Y.toPresheafedSpace
              ((PullbackCone.snd
                    (PullbackCone.mk (PullbackCone.fst s).val (PullbackCone.snd s).val
                      (_ : (PullbackCone.fst s ≫ f).val = (PullbackCone.snd s ≫ g).val))).base
                x)) ≫
      PresheafedSpace.stalkMap (PullbackCone.snd s).val x
⊢ IsLocalRingHom
    (PresheafedSpace.stalkMap
      (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift f.val g.val
        (PullbackCone.mk (PullbackCone.fst s).val (PullbackCone.snd s).val
          (_ : (PullbackCone.fst s ≫ f).val = (PullbackCone.snd s ≫ g).val)))
      x)

Next tactic:
rw [PresheafedSpace.stalkMap.comp, ← IsIso.eq_inv_comp] at this
/-- The constructed `pullbackConeOfLeft` is indeed limiting. -/
def pullbackConeOfLeftIsLimit : IsLimit (pullbackConeOfLeft f g) :=
  PullbackCone.isLimitAux' _ fun s => by
    refine' ⟨LocallyRingedSpace.Hom.mk (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift
        f.1 g.1 (PullbackCone.mk _ _ (congr_arg LocallyRingedSpace.Hom.val s.condition))) _,
      LocallyRingedSpace.Hom.ext _ _
        (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift_fst f.1 g.1 _),
      LocallyRingedSpace.Hom.ext _ _
          (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift_snd f.1 g.1 _), _⟩
    · intro x
      have :=
        PresheafedSpace.stalkMap.congr_hom _ _
          (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift_snd f.1 g.1
            (PullbackCone.mk s.fst.1 s.snd.1 (congr_arg LocallyRingedSpace.Hom.val s.condition)))
          x
      change _ = _ ≫ PresheafedSpace.stalkMap s.snd.1 x at this
      rw [PresheafedSpace.stalkMap.comp, ← IsIso.eq_inv_comp] at this
      

Proof state:
case refine'_1
C : Type u_1
inst✝ : Category.{?u.491994, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
s : PullbackCone f g
x : ↑↑s.pt.toPresheafedSpace
this :
  PresheafedSpace.stalkMap
      (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift f.val g.val
        (PullbackCone.mk (PullbackCone.fst s).val (PullbackCone.snd s).val
          (_ : (PullbackCone.fst s ≫ f).val = (PullbackCone.snd s ≫ g).val)))
      x =
    inv
        (PresheafedSpace.stalkMap (PullbackCone.snd (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeft f.val g.val))
          ((PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift f.val g.val
                (PullbackCone.mk (PullbackCone.fst s).val (PullbackCone.snd s).val
                  (_ : (PullbackCone.fst s ≫ f).val = (PullbackCone.snd s ≫ g).val))).base
            x)) ≫
      eqToHom
          (_ :
            PresheafedSpace.stalk Y.toPresheafedSpace
                ((PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift f.val g.val
                        (PullbackCone.mk (PullbackCone.fst s).val (PullbackCone.snd s).val
                          (_ : (PullbackCone.fst s ≫ f).val = (PullbackCone.snd s ≫ g).val)) ≫
                      PullbackCone.snd (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeft f.val g.val)).base
                  x) =
              PresheafedSpace.stalk Y.toPresheafedSpace
                ((PullbackCone.snd
                      (PullbackCone.mk (PullbackCone.fst s).val (PullbackCone.snd s).val
                        (_ : (PullbackCone.fst s ≫ f).val = (PullbackCone.snd s ≫ g).val))).base
                  x)) ≫
        PresheafedSpace.stalkMap (PullbackCone.snd s).val x
⊢ IsLocalRingHom
    (PresheafedSpace.stalkMap
      (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift f.val g.val
        (PullbackCone.mk (PullbackCone.fst s).val (PullbackCone.snd s).val
          (_ : (PullbackCone.fst s ≫ f).val = (PullbackCone.snd s ≫ g).val)))
      x)

Next tactic:
rw [this]
/-- The constructed `pullbackConeOfLeft` is indeed limiting. -/
def pullbackConeOfLeftIsLimit : IsLimit (pullbackConeOfLeft f g) :=
  PullbackCone.isLimitAux' _ fun s => by
    refine' ⟨LocallyRingedSpace.Hom.mk (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift
        f.1 g.1 (PullbackCone.mk _ _ (congr_arg LocallyRingedSpace.Hom.val s.condition))) _,
      LocallyRingedSpace.Hom.ext _ _
        (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift_fst f.1 g.1 _),
      LocallyRingedSpace.Hom.ext _ _
          (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift_snd f.1 g.1 _), _⟩
    · intro x
      have :=
        PresheafedSpace.stalkMap.congr_hom _ _
          (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift_snd f.1 g.1
            (PullbackCone.mk s.fst.1 s.snd.1 (congr_arg LocallyRingedSpace.Hom.val s.condition)))
          x
      change _ = _ ≫ PresheafedSpace.stalkMap s.snd.1 x at this
      rw [PresheafedSpace.stalkMap.comp, ← IsIso.eq_inv_comp] at this
      rw [this]
      infer_instance
    · 

Proof state:
case refine'_2
C : Type u_1
inst✝ : Category.{?u.491994, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
s : PullbackCone f g
⊢ ∀ {m : s.pt ⟶ (pullbackConeOfLeft f g).pt},
    m ≫ PullbackCone.fst (pullbackConeOfLeft f g) = PullbackCone.fst s →
      m ≫ PullbackCone.snd (pullbackConeOfLeft f g) = PullbackCone.snd s →
        m =
          {
            val :=
              PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift f.val g.val
                (PullbackCone.mk (PullbackCone.fst s).val (PullbackCone.snd s).val
                  (_ : (PullbackCone.fst s ≫ f).val = (PullbackCone.snd s ≫ g).val)),
            prop :=
              (_ :
                ∀ (x : ↑↑s.pt.toPresheafedSpace),
                  IsLocalRingHom
                    (PresheafedSpace.stalkMap
                      (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift f.val g.val
                        (PullbackCone.mk (PullbackCone.fst s).val (PullbackCone.snd s).val
                          (_ : (PullbackCone.fst s ≫ f).val = (PullbackCone.snd s ≫ g).val)))
                      x)) }

Next tactic:
intro m _ h₂
/-- The constructed `pullbackConeOfLeft` is indeed limiting. -/
def pullbackConeOfLeftIsLimit : IsLimit (pullbackConeOfLeft f g) :=
  PullbackCone.isLimitAux' _ fun s => by
    refine' ⟨LocallyRingedSpace.Hom.mk (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift
        f.1 g.1 (PullbackCone.mk _ _ (congr_arg LocallyRingedSpace.Hom.val s.condition))) _,
      LocallyRingedSpace.Hom.ext _ _
        (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift_fst f.1 g.1 _),
      LocallyRingedSpace.Hom.ext _ _
          (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift_snd f.1 g.1 _), _⟩
    · intro x
      have :=
        PresheafedSpace.stalkMap.congr_hom _ _
          (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift_snd f.1 g.1
            (PullbackCone.mk s.fst.1 s.snd.1 (congr_arg LocallyRingedSpace.Hom.val s.condition)))
          x
      change _ = _ ≫ PresheafedSpace.stalkMap s.snd.1 x at this
      rw [PresheafedSpace.stalkMap.comp, ← IsIso.eq_inv_comp] at this
      rw [this]
      infer_instance
    · intro m _ h₂
      

Proof state:
case refine'_2
C : Type u_1
inst✝ : Category.{?u.491994, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
s : PullbackCone f g
m : s.pt ⟶ (pullbackConeOfLeft f g).pt
a✝ : m ≫ PullbackCone.fst (pullbackConeOfLeft f g) = PullbackCone.fst s
h₂ : m ≫ PullbackCone.snd (pullbackConeOfLeft f g) = PullbackCone.snd s
⊢ m =
    {
      val :=
        PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift f.val g.val
          (PullbackCone.mk (PullbackCone.fst s).val (PullbackCone.snd s).val
            (_ : (PullbackCone.fst s ≫ f).val = (PullbackCone.snd s ≫ g).val)),
      prop :=
        (_ :
          ∀ (x : ↑↑s.pt.toPresheafedSpace),
            IsLocalRingHom
              (PresheafedSpace.stalkMap
                (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift f.val g.val
                  (PullbackCone.mk (PullbackCone.fst s).val (PullbackCone.snd s).val
                    (_ : (PullbackCone.fst s ≫ f).val = (PullbackCone.snd s ≫ g).val)))
                x)) }

Next tactic:
rw [← cancel_mono (pullbackConeOfLeft f g).snd]
/-- The constructed `pullbackConeOfLeft` is indeed limiting. -/
def pullbackConeOfLeftIsLimit : IsLimit (pullbackConeOfLeft f g) :=
  PullbackCone.isLimitAux' _ fun s => by
    refine' ⟨LocallyRingedSpace.Hom.mk (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift
        f.1 g.1 (PullbackCone.mk _ _ (congr_arg LocallyRingedSpace.Hom.val s.condition))) _,
      LocallyRingedSpace.Hom.ext _ _
        (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift_fst f.1 g.1 _),
      LocallyRingedSpace.Hom.ext _ _
          (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift_snd f.1 g.1 _), _⟩
    · intro x
      have :=
        PresheafedSpace.stalkMap.congr_hom _ _
          (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift_snd f.1 g.1
            (PullbackCone.mk s.fst.1 s.snd.1 (congr_arg LocallyRingedSpace.Hom.val s.condition)))
          x
      change _ = _ ≫ PresheafedSpace.stalkMap s.snd.1 x at this
      rw [PresheafedSpace.stalkMap.comp, ← IsIso.eq_inv_comp] at this
      rw [this]
      infer_instance
    · intro m _ h₂
      rw [← cancel_mono (pullbackConeOfLeft f g).snd]
      

Proof state:
case refine'_2
C : Type u_1
inst✝ : Category.{?u.491994, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
s : PullbackCone f g
m : s.pt ⟶ (pullbackConeOfLeft f g).pt
a✝ : m ≫ PullbackCone.fst (pullbackConeOfLeft f g) = PullbackCone.fst s
h₂ : m ≫ PullbackCone.snd (pullbackConeOfLeft f g) = PullbackCone.snd s
⊢ m ≫ PullbackCone.snd (pullbackConeOfLeft f g) =
    {
        val :=
          PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift f.val g.val
            (PullbackCone.mk (PullbackCone.fst s).val (PullbackCone.snd s).val
              (_ : (PullbackCone.fst s ≫ f).val = (PullbackCone.snd s ≫ g).val)),
        prop :=
          (_ :
            ∀ (x : ↑↑s.pt.toPresheafedSpace),
              IsLocalRingHom
                (PresheafedSpace.stalkMap
                  (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift f.val g.val
                    (PullbackCone.mk (PullbackCone.fst s).val (PullbackCone.snd s).val
                      (_ : (PullbackCone.fst s ≫ f).val = (PullbackCone.snd s ≫ g).val)))
                  x)) } ≫
      PullbackCone.snd (pullbackConeOfLeft f g)

Next tactic:
exact h₂.trans <| LocallyRingedSpace.Hom.ext _ _
        (PresheafedSpace.IsOpenImmersion.pullbackConeOfLeftLift_snd f.1 g.1 <|
          PullbackCone.mk s.fst.1 s.snd.1 <| congr_arg LocallyRingedSpace.Hom.val s.condition).symm
/-- Open immersions are stable under base-change. -/
instance pullback_snd_of_left :
    LocallyRingedSpace.IsOpenImmersion (pullback.snd : pullback f g ⟶ _) := by
  

Proof state:
C : Type u_1
inst✝ : Category.{?u.497958, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
⊢ IsOpenImmersion pullback.snd

Next tactic:
delta pullback.snd
/-- Open immersions are stable under base-change. -/
instance pullback_snd_of_left :
    LocallyRingedSpace.IsOpenImmersion (pullback.snd : pullback f g ⟶ _) := by
  delta pullback.snd
  

Proof state:
C : Type u_1
inst✝ : Category.{?u.497958, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
⊢ IsOpenImmersion (limit.π (cospan f g) WalkingCospan.right)

Next tactic:
rw [← limit.isoLimitCone_hom_π ⟨_, pullbackConeOfLeftIsLimit f g⟩ WalkingCospan.right]