l3lab/ntp-mathlib huggingface dataset:
/-- The glued scheme (`(gluing 𝒰 f g).glued`) is indeed the pullback of `f` and `g`. -/
def gluedIsLimit : IsLimit (PullbackCone.mk _ _ (p_comm 𝒰 f g)) := by
  apply PullbackCone.isLimitAux'
  intro s
  refine' ⟨gluedLift 𝒰 f g s, gluedLift_p1 𝒰 f g s, gluedLift_p2 𝒰 f g s, _⟩
  intro m h₁ h₂
  change m ≫ p1 𝒰 f g = _ at h₁
  change m ≫ p2 𝒰 f g = _ at h₂
  apply (𝒰.pullbackCover s.fst).hom_ext
  intro i
  rw [OpenCover.pullbackCover_map]
  have := pullbackRightPullbackFstIso (p1 𝒰 f g) (𝒰.map i) m ≪≫ pullback.congrHom h₁ rfl
  erw [(𝒰.pullbackCover s.fst).ι_glueMorphisms]
  rw [←
    cancel_epi
      (pullbackRightPullbackFstIso (p1 𝒰 f g) (𝒰.map i) m ≪≫ pullback.congrHom h₁ rfl).hom,
    Iso.trans_hom, Category.assoc, pullback.congrHom_hom, pullback.lift_fst_assoc,
    Category.comp_id, pullbackRightPullbackFstIso_hom_fst_assoc, pullback.condition]
  trans pullback.snd ≫ (pullbackP1Iso 𝒰 f g _).hom ≫ (gluing 𝒰 f g).ι _
  · congr 1; rw [← pullbackP1Iso_hom_ι]
  simp_rw [← Category.assoc]
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X Y Z : Scheme
𝒰 : OpenCover X
f : X ⟶ Z
g : Y ⟶ Z
inst✝ : ∀ (i : 𝒰.J), HasPullback (OpenCover.map 𝒰 i ≫ f) g
s✝ s : PullbackCone f g
m : s.pt ⟶ (PullbackCone.mk (p1 𝒰 f g) (p2 𝒰 f g) (_ : p1 𝒰 f g ≫ f = p2 𝒰 f g ≫ g)).pt
h₁ : m ≫ p1 𝒰 f g = PullbackCone.fst s
h₂ : m ≫ p2 𝒰 f g = PullbackCone.snd s
i : (OpenCover.pullbackCover 𝒰 (PullbackCone.fst s)).J
this : pullback m pullback.fst ≅ pullback (PullbackCone.fst s) (OpenCover.map 𝒰 i)
⊢ (pullback.snd ≫ (pullbackP1Iso 𝒰 f g i).hom) ≫ GlueData.ι (gluing 𝒰 f g) i =
    ((((pullbackRightPullbackFstIso (p1 𝒰 f g) (OpenCover.map 𝒰 i) m).hom ≫
            pullback.map (m ≫ p1 𝒰 f g) (OpenCover.map 𝒰 i) (PullbackCone.fst s) (OpenCover.map 𝒰 i) (𝟙 s.pt)
              (𝟙 (OpenCover.obj 𝒰 i)) (𝟙 X) (_ : (m ≫ p1 𝒰 f g) ≫ 𝟙 X = 𝟙 s.pt ≫ PullbackCone.fst s)
              (_ : OpenCover.map 𝒰 i ≫ 𝟙 X = 𝟙 (OpenCover.obj 𝒰 i) ≫ OpenCover.map 𝒰 i)) ≫
          (pullbackSymmetry (PullbackCone.fst s) (OpenCover.map 𝒰 i)).hom) ≫
        pullback.map (OpenCover.map 𝒰 i) (PullbackCone.fst s) (OpenCover.map 𝒰 i ≫ f) g (𝟙 (OpenCover.obj 𝒰 i))
          (PullbackCone.snd s) f (_ : OpenCover.map 𝒰 i ≫ f = 𝟙 (OpenCover.obj 𝒰 i) ≫ OpenCover.map 𝒰 i ≫ f)
          (_ : PullbackCone.fst s ≫ f = PullbackCone.snd s ≫ g)) ≫
      GlueData.ι (gluing 𝒰 f g) i

Next tactic:
congr 1
/-- The glued scheme (`(gluing 𝒰 f g).glued`) is indeed the pullback of `f` and `g`. -/
def gluedIsLimit : IsLimit (PullbackCone.mk _ _ (p_comm 𝒰 f g)) := by
  apply PullbackCone.isLimitAux'
  intro s
  refine' ⟨gluedLift 𝒰 f g s, gluedLift_p1 𝒰 f g s, gluedLift_p2 𝒰 f g s, _⟩
  intro m h₁ h₂
  change m ≫ p1 𝒰 f g = _ at h₁
  change m ≫ p2 𝒰 f g = _ at h₂
  apply (𝒰.pullbackCover s.fst).hom_ext
  intro i
  rw [OpenCover.pullbackCover_map]
  have := pullbackRightPullbackFstIso (p1 𝒰 f g) (𝒰.map i) m ≪≫ pullback.congrHom h₁ rfl
  erw [(𝒰.pullbackCover s.fst).ι_glueMorphisms]
  rw [←
    cancel_epi
      (pullbackRightPullbackFstIso (p1 𝒰 f g) (𝒰.map i) m ≪≫ pullback.congrHom h₁ rfl).hom,
    Iso.trans_hom, Category.assoc, pullback.congrHom_hom, pullback.lift_fst_assoc,
    Category.comp_id, pullbackRightPullbackFstIso_hom_fst_assoc, pullback.condition]
  trans pullback.snd ≫ (pullbackP1Iso 𝒰 f g _).hom ≫ (gluing 𝒰 f g).ι _
  · congr 1; rw [← pullbackP1Iso_hom_ι]
  simp_rw [← Category.assoc]
  congr 1
  

Proof state:
case e_a
C : Type u
inst✝¹ : Category.{v, u} C
X Y Z : Scheme
𝒰 : OpenCover X
f : X ⟶ Z
g : Y ⟶ Z
inst✝ : ∀ (i : 𝒰.J), HasPullback (OpenCover.map 𝒰 i ≫ f) g
s✝ s : PullbackCone f g
m : s.pt ⟶ (PullbackCone.mk (p1 𝒰 f g) (p2 𝒰 f g) (_ : p1 𝒰 f g ≫ f = p2 𝒰 f g ≫ g)).pt
h₁ : m ≫ p1 𝒰 f g = PullbackCone.fst s
h₂ : m ≫ p2 𝒰 f g = PullbackCone.snd s
i : (OpenCover.pullbackCover 𝒰 (PullbackCone.fst s)).J
this : pullback m pullback.fst ≅ pullback (PullbackCone.fst s) (OpenCover.map 𝒰 i)
⊢ pullback.snd ≫ (pullbackP1Iso 𝒰 f g i).hom =
    (((pullbackRightPullbackFstIso (p1 𝒰 f g) (OpenCover.map 𝒰 i) m).hom ≫
          pullback.map (m ≫ p1 𝒰 f g) (OpenCover.map 𝒰 i) (PullbackCone.fst s) (OpenCover.map 𝒰 i) (𝟙 s.pt)
            (𝟙 (OpenCover.obj 𝒰 i)) (𝟙 X) (_ : (m ≫ p1 𝒰 f g) ≫ 𝟙 X = 𝟙 s.pt ≫ PullbackCone.fst s)
            (_ : OpenCover.map 𝒰 i ≫ 𝟙 X = 𝟙 (OpenCover.obj 𝒰 i) ≫ OpenCover.map 𝒰 i)) ≫
        (pullbackSymmetry (PullbackCone.fst s) (OpenCover.map 𝒰 i)).hom) ≫
      pullback.map (OpenCover.map 𝒰 i) (PullbackCone.fst s) (OpenCover.map 𝒰 i ≫ f) g (𝟙 (OpenCover.obj 𝒰 i))
        (PullbackCone.snd s) f (_ : OpenCover.map 𝒰 i ≫ f = 𝟙 (OpenCover.obj 𝒰 i) ≫ OpenCover.map 𝒰 i ≫ f)
        (_ : PullbackCone.fst s ≫ f = PullbackCone.snd s ≫ g)

Next tactic:
apply pullback.hom_ext
/-- The glued scheme (`(gluing 𝒰 f g).glued`) is indeed the pullback of `f` and `g`. -/
def gluedIsLimit : IsLimit (PullbackCone.mk _ _ (p_comm 𝒰 f g)) := by
  apply PullbackCone.isLimitAux'
  intro s
  refine' ⟨gluedLift 𝒰 f g s, gluedLift_p1 𝒰 f g s, gluedLift_p2 𝒰 f g s, _⟩
  intro m h₁ h₂
  change m ≫ p1 𝒰 f g = _ at h₁
  change m ≫ p2 𝒰 f g = _ at h₂
  apply (𝒰.pullbackCover s.fst).hom_ext
  intro i
  rw [OpenCover.pullbackCover_map]
  have := pullbackRightPullbackFstIso (p1 𝒰 f g) (𝒰.map i) m ≪≫ pullback.congrHom h₁ rfl
  erw [(𝒰.pullbackCover s.fst).ι_glueMorphisms]
  rw [←
    cancel_epi
      (pullbackRightPullbackFstIso (p1 𝒰 f g) (𝒰.map i) m ≪≫ pullback.congrHom h₁ rfl).hom,
    Iso.trans_hom, Category.assoc, pullback.congrHom_hom, pullback.lift_fst_assoc,
    Category.comp_id, pullbackRightPullbackFstIso_hom_fst_assoc, pullback.condition]
  trans pullback.snd ≫ (pullbackP1Iso 𝒰 f g _).hom ≫ (gluing 𝒰 f g).ι _
  · congr 1; rw [← pullbackP1Iso_hom_ι]
  simp_rw [← Category.assoc]
  congr 1
  apply pullback.hom_ext
  · 

Proof state:
case e_a.h₀
C : Type u
inst✝¹ : Category.{v, u} C
X Y Z : Scheme
𝒰 : OpenCover X
f : X ⟶ Z
g : Y ⟶ Z
inst✝ : ∀ (i : 𝒰.J), HasPullback (OpenCover.map 𝒰 i ≫ f) g
s✝ s : PullbackCone f g
m : s.pt ⟶ (PullbackCone.mk (p1 𝒰 f g) (p2 𝒰 f g) (_ : p1 𝒰 f g ≫ f = p2 𝒰 f g ≫ g)).pt
h₁ : m ≫ p1 𝒰 f g = PullbackCone.fst s
h₂ : m ≫ p2 𝒰 f g = PullbackCone.snd s
i : (OpenCover.pullbackCover 𝒰 (PullbackCone.fst s)).J
this : pullback m pullback.fst ≅ pullback (PullbackCone.fst s) (OpenCover.map 𝒰 i)
⊢ (pullback.snd ≫ (pullbackP1Iso 𝒰 f g i).hom) ≫ pullback.fst =
    ((((pullbackRightPullbackFstIso (p1 𝒰 f g) (OpenCover.map 𝒰 i) m).hom ≫
            pullback.map (m ≫ p1 𝒰 f g) (OpenCover.map 𝒰 i) (PullbackCone.fst s) (OpenCover.map 𝒰 i) (𝟙 s.pt)
              (𝟙 (OpenCover.obj 𝒰 i)) (𝟙 X) (_ : (m ≫ p1 𝒰 f g) ≫ 𝟙 X = 𝟙 s.pt ≫ PullbackCone.fst s)
              (_ : OpenCover.map 𝒰 i ≫ 𝟙 X = 𝟙 (OpenCover.obj 𝒰 i) ≫ OpenCover.map 𝒰 i)) ≫
          (pullbackSymmetry (PullbackCone.fst s) (OpenCover.map 𝒰 i)).hom) ≫
        pullback.map (OpenCover.map 𝒰 i) (PullbackCone.fst s) (OpenCover.map 𝒰 i ≫ f) g (𝟙 (OpenCover.obj 𝒰 i))
          (PullbackCone.snd s) f (_ : OpenCover.map 𝒰 i ≫ f = 𝟙 (OpenCover.obj 𝒰 i) ≫ OpenCover.map 𝒰 i ≫ f)
          (_ : PullbackCone.fst s ≫ f = PullbackCone.snd s ≫ g)) ≫
      pullback.fst

Next tactic:
simp only [Category.comp_id, pullbackRightPullbackFstIso_hom_snd, Category.assoc,
      pullbackP1Iso_hom_fst, pullback.lift_snd, pullback.lift_fst, pullbackSymmetry_hom_comp_fst]
/-- The glued scheme (`(gluing 𝒰 f g).glued`) is indeed the pullback of `f` and `g`. -/
def gluedIsLimit : IsLimit (PullbackCone.mk _ _ (p_comm 𝒰 f g)) := by
  apply PullbackCone.isLimitAux'
  intro s
  refine' ⟨gluedLift 𝒰 f g s, gluedLift_p1 𝒰 f g s, gluedLift_p2 𝒰 f g s, _⟩
  intro m h₁ h₂
  change m ≫ p1 𝒰 f g = _ at h₁
  change m ≫ p2 𝒰 f g = _ at h₂
  apply (𝒰.pullbackCover s.fst).hom_ext
  intro i
  rw [OpenCover.pullbackCover_map]
  have := pullbackRightPullbackFstIso (p1 𝒰 f g) (𝒰.map i) m ≪≫ pullback.congrHom h₁ rfl
  erw [(𝒰.pullbackCover s.fst).ι_glueMorphisms]
  rw [←
    cancel_epi
      (pullbackRightPullbackFstIso (p1 𝒰 f g) (𝒰.map i) m ≪≫ pullback.congrHom h₁ rfl).hom,
    Iso.trans_hom, Category.assoc, pullback.congrHom_hom, pullback.lift_fst_assoc,
    Category.comp_id, pullbackRightPullbackFstIso_hom_fst_assoc, pullback.condition]
  trans pullback.snd ≫ (pullbackP1Iso 𝒰 f g _).hom ≫ (gluing 𝒰 f g).ι _
  · congr 1; rw [← pullbackP1Iso_hom_ι]
  simp_rw [← Category.assoc]
  congr 1
  apply pullback.hom_ext
  · simp only [Category.comp_id, pullbackRightPullbackFstIso_hom_snd, Category.assoc,
      pullbackP1Iso_hom_fst, pullback.lift_snd, pullback.lift_fst, pullbackSymmetry_hom_comp_fst]
  · 

Proof state:
case e_a.h₁
C : Type u
inst✝¹ : Category.{v, u} C
X Y Z : Scheme
𝒰 : OpenCover X
f : X ⟶ Z
g : Y ⟶ Z
inst✝ : ∀ (i : 𝒰.J), HasPullback (OpenCover.map 𝒰 i ≫ f) g
s✝ s : PullbackCone f g
m : s.pt ⟶ (PullbackCone.mk (p1 𝒰 f g) (p2 𝒰 f g) (_ : p1 𝒰 f g ≫ f = p2 𝒰 f g ≫ g)).pt
h₁ : m ≫ p1 𝒰 f g = PullbackCone.fst s
h₂ : m ≫ p2 𝒰 f g = PullbackCone.snd s
i : (OpenCover.pullbackCover 𝒰 (PullbackCone.fst s)).J
this : pullback m pullback.fst ≅ pullback (PullbackCone.fst s) (OpenCover.map 𝒰 i)
⊢ (pullback.snd ≫ (pullbackP1Iso 𝒰 f g i).hom) ≫ pullback.snd =
    ((((pullbackRightPullbackFstIso (p1 𝒰 f g) (OpenCover.map 𝒰 i) m).hom ≫
            pullback.map (m ≫ p1 𝒰 f g) (OpenCover.map 𝒰 i) (PullbackCone.fst s) (OpenCover.map 𝒰 i) (𝟙 s.pt)
              (𝟙 (OpenCover.obj 𝒰 i)) (𝟙 X) (_ : (m ≫ p1 𝒰 f g) ≫ 𝟙 X = 𝟙 s.pt ≫ PullbackCone.fst s)
              (_ : OpenCover.map 𝒰 i ≫ 𝟙 X = 𝟙 (OpenCover.obj 𝒰 i) ≫ OpenCover.map 𝒰 i)) ≫
          (pullbackSymmetry (PullbackCone.fst s) (OpenCover.map 𝒰 i)).hom) ≫
        pullback.map (OpenCover.map 𝒰 i) (PullbackCone.fst s) (OpenCover.map 𝒰 i ≫ f) g (𝟙 (OpenCover.obj 𝒰 i))
          (PullbackCone.snd s) f (_ : OpenCover.map 𝒰 i ≫ f = 𝟙 (OpenCover.obj 𝒰 i) ≫ OpenCover.map 𝒰 i ≫ f)
          (_ : PullbackCone.fst s ≫ f = PullbackCone.snd s ≫ g)) ≫
      pullback.snd

Next tactic:
simp only [Category.comp_id, pullbackRightPullbackFstIso_hom_fst_assoc,
      pullbackP1Iso_hom_snd, Category.assoc, pullback.lift_fst_assoc,
      pullbackSymmetry_hom_comp_snd_assoc, pullback.lift_snd]
/-- The glued scheme (`(gluing 𝒰 f g).glued`) is indeed the pullback of `f` and `g`. -/
def gluedIsLimit : IsLimit (PullbackCone.mk _ _ (p_comm 𝒰 f g)) := by
  apply PullbackCone.isLimitAux'
  intro s
  refine' ⟨gluedLift 𝒰 f g s, gluedLift_p1 𝒰 f g s, gluedLift_p2 𝒰 f g s, _⟩
  intro m h₁ h₂
  change m ≫ p1 𝒰 f g = _ at h₁
  change m ≫ p2 𝒰 f g = _ at h₂
  apply (𝒰.pullbackCover s.fst).hom_ext
  intro i
  rw [OpenCover.pullbackCover_map]
  have := pullbackRightPullbackFstIso (p1 𝒰 f g) (𝒰.map i) m ≪≫ pullback.congrHom h₁ rfl
  erw [(𝒰.pullbackCover s.fst).ι_glueMorphisms]
  rw [←
    cancel_epi
      (pullbackRightPullbackFstIso (p1 𝒰 f g) (𝒰.map i) m ≪≫ pullback.congrHom h₁ rfl).hom,
    Iso.trans_hom, Category.assoc, pullback.congrHom_hom, pullback.lift_fst_assoc,
    Category.comp_id, pullbackRightPullbackFstIso_hom_fst_assoc, pullback.condition]
  trans pullback.snd ≫ (pullbackP1Iso 𝒰 f g _).hom ≫ (gluing 𝒰 f g).ι _
  · congr 1; rw [← pullbackP1Iso_hom_ι]
  simp_rw [← Category.assoc]
  congr 1
  apply pullback.hom_ext
  · simp only [Category.comp_id, pullbackRightPullbackFstIso_hom_snd, Category.assoc,
      pullbackP1Iso_hom_fst, pullback.lift_snd, pullback.lift_fst, pullbackSymmetry_hom_comp_fst]
  · simp only [Category.comp_id, pullbackRightPullbackFstIso_hom_fst_assoc,
      pullbackP1Iso_hom_snd, Category.assoc, pullback.lift_fst_assoc,
      pullbackSymmetry_hom_comp_snd_assoc, pullback.lift_snd]
    

Proof state:
case e_a.h₁
C : Type u
inst✝¹ : Category.{v, u} C
X Y Z : Scheme
𝒰 : OpenCover X
f : X ⟶ Z
g : Y ⟶ Z
inst✝ : ∀ (i : 𝒰.J), HasPullback (OpenCover.map 𝒰 i ≫ f) g
s✝ s : PullbackCone f g
m : s.pt ⟶ (PullbackCone.mk (p1 𝒰 f g) (p2 𝒰 f g) (_ : p1 𝒰 f g ≫ f = p2 𝒰 f g ≫ g)).pt
h₁ : m ≫ p1 𝒰 f g = PullbackCone.fst s
h₂ : m ≫ p2 𝒰 f g = PullbackCone.snd s
i : (OpenCover.pullbackCover 𝒰 (PullbackCone.fst s)).J
this : pullback m pullback.fst ≅ pullback (PullbackCone.fst s) (OpenCover.map 𝒰 i)
⊢ pullback.snd ≫ pullback.fst ≫ p2 𝒰 f g = pullback.fst ≫ PullbackCone.snd s

Next tactic:
rw [← pullback.condition_assoc, h₂]
instance affine_hasPullback {A B C : CommRingCat}
    (f : Spec.obj (Opposite.op A) ⟶ Spec.obj (Opposite.op C))
    (g : Spec.obj (Opposite.op B) ⟶ Spec.obj (Opposite.op C)) : HasPullback f g := by
  

Proof state:
C✝ : Type u
inst✝¹ : Category.{v, u} C✝
X Y Z : Scheme
𝒰 : OpenCover X
f✝ : X ⟶ Z
g✝ : Y ⟶ Z
inst✝ : ∀ (i : 𝒰.J), HasPullback (OpenCover.map 𝒰 i ≫ f✝) g✝
s : PullbackCone f✝ g✝
A B C : CommRingCat
f : Spec.obj (Opposite.op A) ⟶ Spec.obj (Opposite.op C)
g : Spec.obj (Opposite.op B) ⟶ Spec.obj (Opposite.op C)
⊢ HasPullback f g

Next tactic:
rw [← Spec.image_preimage f, ← Spec.image_preimage g]
instance affine_hasPullback {A B C : CommRingCat}
    (f : Spec.obj (Opposite.op A) ⟶ Spec.obj (Opposite.op C))
    (g : Spec.obj (Opposite.op B) ⟶ Spec.obj (Opposite.op C)) : HasPullback f g := by
  rw [← Spec.image_preimage f, ← Spec.image_preimage g]
  

Proof state:
C✝ : Type u
inst✝¹ : Category.{v, u} C✝
X Y Z : Scheme
𝒰 : OpenCover X
f✝ : X ⟶ Z
g✝ : Y ⟶ Z
inst✝ : ∀ (i : 𝒰.J), HasPullback (OpenCover.map 𝒰 i ≫ f✝) g✝
s : PullbackCone f✝ g✝
A B C : CommRingCat
f : Spec.obj (Opposite.op A) ⟶ Spec.obj (Opposite.op C)
g : Spec.obj (Opposite.op B) ⟶ Spec.obj (Opposite.op C)
⊢ HasPullback (Spec.map (Spec.preimage f)) (Spec.map (Spec.preimage g))

Next tactic:
exact
    ⟨⟨⟨_, isLimitOfHasPullbackOfPreservesLimit Spec (Spec.preimage f) (Spec.preimage g)⟩⟩⟩
instance left_affine_comp_pullback_hasPullback {X Y Z : Scheme} (f : X ⟶ Z) (g : Y ⟶ Z)
    (i : Z.affineCover.J) : HasPullback ((Z.affineCover.pullbackCover f).map i ≫ f) g := by
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X✝ Y✝ Z✝ : Scheme
𝒰 : OpenCover X✝
f✝ : X✝ ⟶ Z✝
g✝ : Y✝ ⟶ Z✝
inst✝ : ∀ (i : 𝒰.J), HasPullback (OpenCover.map 𝒰 i ≫ f✝) g✝
s : PullbackCone f✝ g✝
X Y Z : Scheme
f : X ⟶ Z
g : Y ⟶ Z
i : (affineCover Z).J
⊢ HasPullback (OpenCover.map (OpenCover.pullbackCover (affineCover Z) f) i ≫ f) g

Next tactic:
let Xᵢ := pullback f (Z.affineCover.map i)
instance left_affine_comp_pullback_hasPullback {X Y Z : Scheme} (f : X ⟶ Z) (g : Y ⟶ Z)
    (i : Z.affineCover.J) : HasPullback ((Z.affineCover.pullbackCover f).map i ≫ f) g := by
  let Xᵢ := pullback f (Z.affineCover.map i)
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X✝ Y✝ Z✝ : Scheme
𝒰 : OpenCover X✝
f✝ : X✝ ⟶ Z✝
g✝ : Y✝ ⟶ Z✝
inst✝ : ∀ (i : 𝒰.J), HasPullback (OpenCover.map 𝒰 i ≫ f✝) g✝
s : PullbackCone f✝ g✝
X Y Z : Scheme
f : X ⟶ Z
g : Y ⟶ Z
i : (affineCover Z).J
Xᵢ : Scheme := pullback f (OpenCover.map (affineCover Z) i)
⊢ HasPullback (OpenCover.map (OpenCover.pullbackCover (affineCover Z) f) i ≫ f) g

Next tactic:
let Yᵢ := pullback g (Z.affineCover.map i)
instance left_affine_comp_pullback_hasPullback {X Y Z : Scheme} (f : X ⟶ Z) (g : Y ⟶ Z)
    (i : Z.affineCover.J) : HasPullback ((Z.affineCover.pullbackCover f).map i ≫ f) g := by
  let Xᵢ := pullback f (Z.affineCover.map i)
  let Yᵢ := pullback g (Z.affineCover.map i)
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X✝ Y✝ Z✝ : Scheme
𝒰 : OpenCover X✝
f✝ : X✝ ⟶ Z✝
g✝ : Y✝ ⟶ Z✝
inst✝ : ∀ (i : 𝒰.J), HasPullback (OpenCover.map 𝒰 i ≫ f✝) g✝
s : PullbackCone f✝ g✝
X Y Z : Scheme
f : X ⟶ Z
g : Y ⟶ Z
i : (affineCover Z).J
Xᵢ : Scheme := pullback f (OpenCover.map (affineCover Z) i)
Yᵢ : Scheme := pullback g (OpenCover.map (affineCover Z) i)
⊢ HasPullback (OpenCover.map (OpenCover.pullbackCover (affineCover Z) f) i ≫ f) g

Next tactic:
let W := pullback (pullback.snd : Yᵢ ⟶ _) (pullback.snd : Xᵢ ⟶ _)
instance left_affine_comp_pullback_hasPullback {X Y Z : Scheme} (f : X ⟶ Z) (g : Y ⟶ Z)
    (i : Z.affineCover.J) : HasPullback ((Z.affineCover.pullbackCover f).map i ≫ f) g := by
  let Xᵢ := pullback f (Z.affineCover.map i)
  let Yᵢ := pullback g (Z.affineCover.map i)
  let W := pullback (pullback.snd : Yᵢ ⟶ _) (pullback.snd : Xᵢ ⟶ _)
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X✝ Y✝ Z✝ : Scheme
𝒰 : OpenCover X✝
f✝ : X✝ ⟶ Z✝
g✝ : Y✝ ⟶ Z✝
inst✝ : ∀ (i : 𝒰.J), HasPullback (OpenCover.map 𝒰 i ≫ f✝) g✝
s : PullbackCone f✝ g✝
X Y Z : Scheme
f : X ⟶ Z
g : Y ⟶ Z
i : (affineCover Z).J
Xᵢ : Scheme := pullback f (OpenCover.map (affineCover Z) i)
Yᵢ : Scheme := pullback g (OpenCover.map (affineCover Z) i)
W : Scheme := pullback pullback.snd pullback.snd
⊢ HasPullback (OpenCover.map (OpenCover.pullbackCover (affineCover Z) f) i ≫ f) g

Next tactic:
have :=
    bigSquareIsPullback (pullback.fst : W ⟶ _) (pullback.fst : Yᵢ ⟶ _) (pullback.snd : Xᵢ ⟶ _)
      (Z.affineCover.map i) pullback.snd pullback.snd g pullback.condition.symm
      pullback.condition.symm (PullbackCone.flipIsLimit <| pullbackIsPullback _ _)
      (PullbackCone.flipIsLimit <| pullbackIsPullback _ _)
instance left_affine_comp_pullback_hasPullback {X Y Z : Scheme} (f : X ⟶ Z) (g : Y ⟶ Z)
    (i : Z.affineCover.J) : HasPullback ((Z.affineCover.pullbackCover f).map i ≫ f) g := by
  let Xᵢ := pullback f (Z.affineCover.map i)
  let Yᵢ := pullback g (Z.affineCover.map i)
  let W := pullback (pullback.snd : Yᵢ ⟶ _) (pullback.snd : Xᵢ ⟶ _)
  have :=
    bigSquareIsPullback (pullback.fst : W ⟶ _) (pullback.fst : Yᵢ ⟶ _) (pullback.snd : Xᵢ ⟶ _)
      (Z.affineCover.map i) pullback.snd pullback.snd g pullback.condition.symm
      pullback.condition.symm (PullbackCone.flipIsLimit <| pullbackIsPullback _ _)
      (PullbackCone.flipIsLimit <| pullbackIsPullback _ _)
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X✝ Y✝ Z✝ : Scheme
𝒰 : OpenCover X✝
f✝ : X✝ ⟶ Z✝
g✝ : Y✝ ⟶ Z✝
inst✝ : ∀ (i : 𝒰.J), HasPullback (OpenCover.map 𝒰 i ≫ f✝) g✝
s : PullbackCone f✝ g✝
X Y Z : Scheme
f : X ⟶ Z
g : Y ⟶ Z
i : (affineCover Z).J
Xᵢ : Scheme := pullback f (OpenCover.map (affineCover Z) i)
Yᵢ : Scheme := pullback g (OpenCover.map (affineCover Z) i)
W : Scheme := pullback pullback.snd pullback.snd
this :
  IsLimit
    (PullbackCone.mk pullback.snd (pullback.fst ≫ pullback.fst)
      (_ : pullback.snd ≫ pullback.snd ≫ OpenCover.map (affineCover Z) i = (pullback.fst ≫ pullback.fst) ≫ g))
⊢ HasPullback (OpenCover.map (OpenCover.pullbackCover (affineCover Z) f) i ≫ f) g

Next tactic:
have : HasPullback (pullback.snd ≫ Z.affineCover.map i : Xᵢ ⟶ _) g := ⟨⟨⟨_, this⟩⟩⟩
instance left_affine_comp_pullback_hasPullback {X Y Z : Scheme} (f : X ⟶ Z) (g : Y ⟶ Z)
    (i : Z.affineCover.J) : HasPullback ((Z.affineCover.pullbackCover f).map i ≫ f) g := by
  let Xᵢ := pullback f (Z.affineCover.map i)
  let Yᵢ := pullback g (Z.affineCover.map i)
  let W := pullback (pullback.snd : Yᵢ ⟶ _) (pullback.snd : Xᵢ ⟶ _)
  have :=
    bigSquareIsPullback (pullback.fst : W ⟶ _) (pullback.fst : Yᵢ ⟶ _) (pullback.snd : Xᵢ ⟶ _)
      (Z.affineCover.map i) pullback.snd pullback.snd g pullback.condition.symm
      pullback.condition.symm (PullbackCone.flipIsLimit <| pullbackIsPullback _ _)
      (PullbackCone.flipIsLimit <| pullbackIsPullback _ _)
  have : HasPullback (pullback.snd ≫ Z.affineCover.map i : Xᵢ ⟶ _) g := ⟨⟨⟨_, this⟩⟩⟩
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X✝ Y✝ Z✝ : Scheme
𝒰 : OpenCover X✝
f✝ : X✝ ⟶ Z✝
g✝ : Y✝ ⟶ Z✝
inst✝ : ∀ (i : 𝒰.J), HasPullback (OpenCover.map 𝒰 i ≫ f✝) g✝
s : PullbackCone f✝ g✝
X Y Z : Scheme
f : X ⟶ Z
g : Y ⟶ Z
i : (affineCover Z).J
Xᵢ : Scheme := pullback f (OpenCover.map (affineCover Z) i)
Yᵢ : Scheme := pullback g (OpenCover.map (affineCover Z) i)
W : Scheme := pullback pullback.snd pullback.snd
this✝ :
  IsLimit
    (PullbackCone.mk pullback.snd (pullback.fst ≫ pullback.fst)
      (_ : pullback.snd ≫ pullback.snd ≫ OpenCover.map (affineCover Z) i = (pullback.fst ≫ pullback.fst) ≫ g))
this : HasPullback (pullback.snd ≫ OpenCover.map (affineCover Z) i) g
⊢ HasPullback (OpenCover.map (OpenCover.pullbackCover (affineCover Z) f) i ≫ f) g

Next tactic:
rw [← pullback.condition] at this
instance left_affine_comp_pullback_hasPullback {X Y Z : Scheme} (f : X ⟶ Z) (g : Y ⟶ Z)
    (i : Z.affineCover.J) : HasPullback ((Z.affineCover.pullbackCover f).map i ≫ f) g := by
  let Xᵢ := pullback f (Z.affineCover.map i)
  let Yᵢ := pullback g (Z.affineCover.map i)
  let W := pullback (pullback.snd : Yᵢ ⟶ _) (pullback.snd : Xᵢ ⟶ _)
  have :=
    bigSquareIsPullback (pullback.fst : W ⟶ _) (pullback.fst : Yᵢ ⟶ _) (pullback.snd : Xᵢ ⟶ _)
      (Z.affineCover.map i) pullback.snd pullback.snd g pullback.condition.symm
      pullback.condition.symm (PullbackCone.flipIsLimit <| pullbackIsPullback _ _)
      (PullbackCone.flipIsLimit <| pullbackIsPullback _ _)
  have : HasPullback (pullback.snd ≫ Z.affineCover.map i : Xᵢ ⟶ _) g := ⟨⟨⟨_, this⟩⟩⟩
  rw [← pullback.condition] at this
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X✝ Y✝ Z✝ : Scheme
𝒰 : OpenCover X✝
f✝ : X✝ ⟶ Z✝
g✝ : Y✝ ⟶ Z✝
inst✝ : ∀ (i : 𝒰.J), HasPullback (OpenCover.map 𝒰 i ≫ f✝) g✝
s : PullbackCone f✝ g✝
X Y Z : Scheme
f : X ⟶ Z
g : Y ⟶ Z
i : (affineCover Z).J
Xᵢ : Scheme := pullback f (OpenCover.map (affineCover Z) i)
Yᵢ : Scheme := pullback g (OpenCover.map (affineCover Z) i)
W : Scheme := pullback pullback.snd pullback.snd
this✝ :
  IsLimit
    (PullbackCone.mk pullback.snd (pullback.fst ≫ pullback.fst)
      (_ : pullback.snd ≫ pullback.snd ≫ OpenCover.map (affineCover Z) i = (pullback.fst ≫ pullback.fst) ≫ g))
this : HasPullback (pullback.fst ≫ f) g
⊢ HasPullback (OpenCover.map (OpenCover.pullbackCover (affineCover Z) f) i ≫ f) g

Next tactic:
exact this
/-- Given an open cover `{ Xᵢ }` of `X`, then `X ×[Z] Y` is covered by `Xᵢ ×[Z] Y`. -/
@[simps! J obj map]
def openCoverOfLeft (𝒰 : OpenCover X) (f : X ⟶ Z) (g : Y ⟶ Z) : OpenCover (pullback f g) := by
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X Y Z : Scheme
𝒰✝ : OpenCover X
f✝ : X ⟶ Z
g✝ : Y ⟶ Z
inst✝ : ∀ (i : 𝒰✝.J), HasPullback (OpenCover.map 𝒰✝ i ≫ f✝) g✝
s : PullbackCone f✝ g✝
𝒰 : OpenCover X
f : X ⟶ Z
g : Y ⟶ Z
⊢ OpenCover (pullback f g)

Next tactic:
fapply
    ((gluing 𝒰 f g).openCover.pushforwardIso
          (limit.isoLimitCone ⟨_, gluedIsLimit 𝒰 f g⟩).inv).copy
      𝒰.J (fun i => pullback (𝒰.map i ≫ f) g)
      (fun i => pullback.map _ _ _ _ (𝒰.map i) (𝟙 _) (𝟙 _) (Category.comp_id _) (by simp))
      (Equiv.refl 𝒰.J) fun _ => Iso.refl _
/-- Given an open cover `{ Xᵢ }` of `X`, then `X ×[Z] Y` is covered by `Xᵢ ×[Z] Y`. -/
@[simps! J obj map]
def openCoverOfLeft (𝒰 : OpenCover X) (f : X ⟶ Z) (g : Y ⟶ Z) : OpenCover (pullback f g) := by
  fapply
    ((gluing 𝒰 f g).openCover.pushforwardIso
          (limit.isoLimitCone ⟨_, gluedIsLimit 𝒰 f g⟩).inv).copy
      𝒰.J (fun i => pullback (𝒰.map i ≫ f) g)
      (fun i => pullback.map _ _ _ _ (𝒰.map i) (𝟙 _) (𝟙 _) (Category.comp_id _) (by 

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X Y Z : Scheme
𝒰✝ : OpenCover X
f✝ : X ⟶ Z
g✝ : Y ⟶ Z
inst✝ : ∀ (i : 𝒰✝.J), HasPullback (OpenCover.map 𝒰✝ i ≫ f✝) g✝
s : PullbackCone f✝ g✝
𝒰 : OpenCover X
f : X ⟶ Z
g : Y ⟶ Z
i : 𝒰.J
⊢ g ≫ 𝟙 Z = 𝟙 Y ≫ g

Next tactic:
simp
/-- Given an open cover `{ Xᵢ }` of `X`, then `X ×[Z] Y` is covered by `Xᵢ ×[Z] Y`. -/
@[simps! J obj map]
def openCoverOfLeft (𝒰 : OpenCover X) (f : X ⟶ Z) (g : Y ⟶ Z) : OpenCover (pullback f g) := by
  fapply
    ((gluing 𝒰 f g).openCover.pushforwardIso
          (limit.isoLimitCone ⟨_, gluedIsLimit 𝒰 f g⟩).inv).copy
      𝒰.J (fun i => pullback (𝒰.map i ≫ f) g)
      (fun i => pullback.map _ _ _ _ (𝒰.map i) (𝟙 _) (𝟙 _) (Category.comp_id _) (by simp))
      (Equiv.refl 𝒰.J) fun _ => Iso.refl _
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X Y Z : Scheme
𝒰✝ : OpenCover X
f✝ : X ⟶ Z
g✝ : Y ⟶ Z
inst✝ : ∀ (i : 𝒰✝.J), HasPullback (OpenCover.map 𝒰✝ i ≫ f✝) g✝
s : PullbackCone f✝ g✝
𝒰 : OpenCover X
f : X ⟶ Z
g : Y ⟶ Z
⊢ ∀ (i : 𝒰.J),
    pullback.map (OpenCover.map 𝒰 i ≫ f) g f g (OpenCover.map 𝒰 i) (𝟙 Y) (𝟙 Z)
        (_ : (OpenCover.map 𝒰 i ≫ f) ≫ 𝟙 Z = OpenCover.map 𝒰 i ≫ f) (_ : g ≫ 𝟙 Z = 𝟙 Y ≫ g) =
      (Iso.refl ((fun i => pullback (OpenCover.map 𝒰 i ≫ f) g) i)).hom ≫
        OpenCover.map
          (OpenCover.pushforwardIso (GlueData.openCover (gluing 𝒰 f g))
            (limit.isoLimitCone
                { cone := PullbackCone.mk (p1 𝒰 f g) (p2 𝒰 f g) (_ : p1 𝒰 f g ≫ f = p2 𝒰 f g ≫ g),
                  isLimit := gluedIsLimit 𝒰 f g }).inv)
          ((Equiv.refl 𝒰.J) i)

Next tactic:
rintro (i : 𝒰.J)