l3lab/ntp-mathlib huggingface dataset:
/-- The canonical morphism from the gluing of an open cover of `X` into `X`.
This is an isomorphism, as witnessed by an `IsIso` instance. -/
def fromGlued : 𝒰.gluedCover.glued ⟶ X := by
  fapply Multicoequalizer.desc
  exact fun x => 𝒰.map x
  rintro ⟨x, y⟩
  change pullback.fst ≫ _ = ((pullbackSymmetry _ _).hom ≫ pullback.fst) ≫ _
  

Proof state:
case h.mk
X : Scheme
𝒰 : OpenCover X
x y : (gluedCover 𝒰).toGlueData.J
⊢ pullback.fst ≫ map 𝒰 (MultispanIndex.fstFrom (diagram (gluedCover 𝒰).toGlueData) (x, y)) =
    ((pullbackSymmetry (map 𝒰 x) (map 𝒰 y)).hom ≫ pullback.fst) ≫
      map 𝒰 (MultispanIndex.sndFrom (diagram (gluedCover 𝒰).toGlueData) (x, y))

Next tactic:
simpa using pullback.condition
theorem fromGlued_injective : Function.Injective 𝒰.fromGlued.1.base := by
  

Proof state:
X : Scheme
𝒰 : OpenCover X
⊢ Function.Injective ⇑(fromGlued 𝒰).val.base

Next tactic:
intro x y h
theorem fromGlued_injective : Function.Injective 𝒰.fromGlued.1.base := by
  intro x y h
  

Proof state:
X : Scheme
𝒰 : OpenCover X
x y :
  (CategoryTheory.forget TopCat).obj
    ↑(GlueData.glued (gluedCover 𝒰)).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace
h : (fromGlued 𝒰).val.base x = (fromGlued 𝒰).val.base y
⊢ x = y

Next tactic:
obtain ⟨i, x, rfl⟩ := 𝒰.gluedCover.ι_jointly_surjective x
theorem fromGlued_injective : Function.Injective 𝒰.fromGlued.1.base := by
  intro x y h
  obtain ⟨i, x, rfl⟩ := 𝒰.gluedCover.ι_jointly_surjective x
  

Proof state:
case intro.intro
X : Scheme
𝒰 : OpenCover X
y :
  (CategoryTheory.forget TopCat).obj
    ↑(GlueData.glued (gluedCover 𝒰)).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace
i : (gluedCover 𝒰).toGlueData.J
x : ↑↑(U (gluedCover 𝒰).toGlueData i).toPresheafedSpace
h : (fromGlued 𝒰).val.base ((GlueData.ι (gluedCover 𝒰) i).val.base x) = (fromGlued 𝒰).val.base y
⊢ (GlueData.ι (gluedCover 𝒰) i).val.base x = y

Next tactic:
obtain ⟨j, y, rfl⟩ := 𝒰.gluedCover.ι_jointly_surjective y
theorem fromGlued_injective : Function.Injective 𝒰.fromGlued.1.base := by
  intro x y h
  obtain ⟨i, x, rfl⟩ := 𝒰.gluedCover.ι_jointly_surjective x
  obtain ⟨j, y, rfl⟩ := 𝒰.gluedCover.ι_jointly_surjective y
  

Proof state:
case intro.intro.intro.intro
X : Scheme
𝒰 : OpenCover X
i : (gluedCover 𝒰).toGlueData.J
x : ↑↑(U (gluedCover 𝒰).toGlueData i).toPresheafedSpace
j : (gluedCover 𝒰).toGlueData.J
y : ↑↑(U (gluedCover 𝒰).toGlueData j).toPresheafedSpace
h :
  (fromGlued 𝒰).val.base ((GlueData.ι (gluedCover 𝒰) i).val.base x) =
    (fromGlued 𝒰).val.base ((GlueData.ι (gluedCover 𝒰) j).val.base y)
⊢ (GlueData.ι (gluedCover 𝒰) i).val.base x = (GlueData.ι (gluedCover 𝒰) j).val.base y

Next tactic:
simp_rw [← comp_apply, ← SheafedSpace.comp_base, ← LocallyRingedSpace.comp_val] at h
theorem fromGlued_injective : Function.Injective 𝒰.fromGlued.1.base := by
  intro x y h
  obtain ⟨i, x, rfl⟩ := 𝒰.gluedCover.ι_jointly_surjective x
  obtain ⟨j, y, rfl⟩ := 𝒰.gluedCover.ι_jointly_surjective y
  simp_rw [← comp_apply, ← SheafedSpace.comp_base, ← LocallyRingedSpace.comp_val] at h
  

Proof state:
case intro.intro.intro.intro
X : Scheme
𝒰 : OpenCover X
i : (gluedCover 𝒰).toGlueData.J
x : ↑↑(U (gluedCover 𝒰).toGlueData i).toPresheafedSpace
j : (gluedCover 𝒰).toGlueData.J
y : ↑↑(U (gluedCover 𝒰).toGlueData j).toPresheafedSpace
h : (GlueData.ι (gluedCover 𝒰) i ≫ fromGlued 𝒰).val.base x = (GlueData.ι (gluedCover 𝒰) j ≫ fromGlued 𝒰).val.base y
⊢ (GlueData.ι (gluedCover 𝒰) i).val.base x = (GlueData.ι (gluedCover 𝒰) j).val.base y

Next tactic:
erw [ι_fromGlued, ι_fromGlued] at h
theorem fromGlued_injective : Function.Injective 𝒰.fromGlued.1.base := by
  intro x y h
  obtain ⟨i, x, rfl⟩ := 𝒰.gluedCover.ι_jointly_surjective x
  obtain ⟨j, y, rfl⟩ := 𝒰.gluedCover.ι_jointly_surjective y
  simp_rw [← comp_apply, ← SheafedSpace.comp_base, ← LocallyRingedSpace.comp_val] at h
  erw [ι_fromGlued, ι_fromGlued] at h
  

Proof state:
case intro.intro.intro.intro
X : Scheme
𝒰 : OpenCover X
i : (gluedCover 𝒰).toGlueData.J
x : ↑↑(U (gluedCover 𝒰).toGlueData i).toPresheafedSpace
j : (gluedCover 𝒰).toGlueData.J
y : ↑↑(U (gluedCover 𝒰).toGlueData j).toPresheafedSpace
h : (map 𝒰 i).val.base x = (map 𝒰 j).val.base y
⊢ (GlueData.ι (gluedCover 𝒰) i).val.base x = (GlueData.ι (gluedCover 𝒰) j).val.base y

Next tactic:
let e :=
    (TopCat.pullbackConeIsLimit _ _).conePointUniqueUpToIso
      (isLimitOfHasPullbackOfPreservesLimit Scheme.forgetToTop (𝒰.map i) (𝒰.map j))
theorem fromGlued_injective : Function.Injective 𝒰.fromGlued.1.base := by
  intro x y h
  obtain ⟨i, x, rfl⟩ := 𝒰.gluedCover.ι_jointly_surjective x
  obtain ⟨j, y, rfl⟩ := 𝒰.gluedCover.ι_jointly_surjective y
  simp_rw [← comp_apply, ← SheafedSpace.comp_base, ← LocallyRingedSpace.comp_val] at h
  erw [ι_fromGlued, ι_fromGlued] at h
  let e :=
    (TopCat.pullbackConeIsLimit _ _).conePointUniqueUpToIso
      (isLimitOfHasPullbackOfPreservesLimit Scheme.forgetToTop (𝒰.map i) (𝒰.map j))
  

Proof state:
case intro.intro.intro.intro
X : Scheme
𝒰 : OpenCover X
i : (gluedCover 𝒰).toGlueData.J
x : ↑↑(U (gluedCover 𝒰).toGlueData i).toPresheafedSpace
j : (gluedCover 𝒰).toGlueData.J
y : ↑↑(U (gluedCover 𝒰).toGlueData j).toPresheafedSpace
h : (map 𝒰 i).val.base x = (map 𝒰 j).val.base y
e : (TopCat.pullbackCone (forgetToTop.map (map 𝒰 i)) (forgetToTop.map (map 𝒰 j))).pt ≅
  (PullbackCone.mk (forgetToTop.map pullback.fst) (forgetToTop.map pullback.snd)
      (_ :
        forgetToTop.map pullback.fst ≫ forgetToTop.map (map 𝒰 i) =
          forgetToTop.map pullback.snd ≫ forgetToTop.map (map 𝒰 j))).pt :=
  IsLimit.conePointUniqueUpToIso (TopCat.pullbackConeIsLimit (forgetToTop.map (map 𝒰 i)) (forgetToTop.map (map 𝒰 j)))
    (isLimitOfHasPullbackOfPreservesLimit forgetToTop (map 𝒰 i) (map 𝒰 j))
⊢ (GlueData.ι (gluedCover 𝒰) i).val.base x = (GlueData.ι (gluedCover 𝒰) j).val.base y

Next tactic:
rw [𝒰.gluedCover.ι_eq_iff]
theorem fromGlued_injective : Function.Injective 𝒰.fromGlued.1.base := by
  intro x y h
  obtain ⟨i, x, rfl⟩ := 𝒰.gluedCover.ι_jointly_surjective x
  obtain ⟨j, y, rfl⟩ := 𝒰.gluedCover.ι_jointly_surjective y
  simp_rw [← comp_apply, ← SheafedSpace.comp_base, ← LocallyRingedSpace.comp_val] at h
  erw [ι_fromGlued, ι_fromGlued] at h
  let e :=
    (TopCat.pullbackConeIsLimit _ _).conePointUniqueUpToIso
      (isLimitOfHasPullbackOfPreservesLimit Scheme.forgetToTop (𝒰.map i) (𝒰.map j))
  rw [𝒰.gluedCover.ι_eq_iff]
  

Proof state:
case intro.intro.intro.intro
X : Scheme
𝒰 : OpenCover X
i : (gluedCover 𝒰).toGlueData.J
x : ↑↑(U (gluedCover 𝒰).toGlueData i).toPresheafedSpace
j : (gluedCover 𝒰).toGlueData.J
y : ↑↑(U (gluedCover 𝒰).toGlueData j).toPresheafedSpace
h : (map 𝒰 i).val.base x = (map 𝒰 j).val.base y
e : (TopCat.pullbackCone (forgetToTop.map (map 𝒰 i)) (forgetToTop.map (map 𝒰 j))).pt ≅
  (PullbackCone.mk (forgetToTop.map pullback.fst) (forgetToTop.map pullback.snd)
      (_ :
        forgetToTop.map pullback.fst ≫ forgetToTop.map (map 𝒰 i) =
          forgetToTop.map pullback.snd ≫ forgetToTop.map (map 𝒰 j))).pt :=
  IsLimit.conePointUniqueUpToIso (TopCat.pullbackConeIsLimit (forgetToTop.map (map 𝒰 i)) (forgetToTop.map (map 𝒰 j)))
    (isLimitOfHasPullbackOfPreservesLimit forgetToTop (map 𝒰 i) (map 𝒰 j))
⊢ GlueData.Rel (gluedCover 𝒰) { fst := i, snd := x } { fst := j, snd := y }

Next tactic:
right
theorem fromGlued_injective : Function.Injective 𝒰.fromGlued.1.base := by
  intro x y h
  obtain ⟨i, x, rfl⟩ := 𝒰.gluedCover.ι_jointly_surjective x
  obtain ⟨j, y, rfl⟩ := 𝒰.gluedCover.ι_jointly_surjective y
  simp_rw [← comp_apply, ← SheafedSpace.comp_base, ← LocallyRingedSpace.comp_val] at h
  erw [ι_fromGlued, ι_fromGlued] at h
  let e :=
    (TopCat.pullbackConeIsLimit _ _).conePointUniqueUpToIso
      (isLimitOfHasPullbackOfPreservesLimit Scheme.forgetToTop (𝒰.map i) (𝒰.map j))
  rw [𝒰.gluedCover.ι_eq_iff]
  right
  

Proof state:
case intro.intro.intro.intro.h
X : Scheme
𝒰 : OpenCover X
i : (gluedCover 𝒰).toGlueData.J
x : ↑↑(U (gluedCover 𝒰).toGlueData i).toPresheafedSpace
j : (gluedCover 𝒰).toGlueData.J
y : ↑↑(U (gluedCover 𝒰).toGlueData j).toPresheafedSpace
h : (map 𝒰 i).val.base x = (map 𝒰 j).val.base y
e : (TopCat.pullbackCone (forgetToTop.map (map 𝒰 i)) (forgetToTop.map (map 𝒰 j))).pt ≅
  (PullbackCone.mk (forgetToTop.map pullback.fst) (forgetToTop.map pullback.snd)
      (_ :
        forgetToTop.map pullback.fst ≫ forgetToTop.map (map 𝒰 i) =
          forgetToTop.map pullback.snd ≫ forgetToTop.map (map 𝒰 j))).pt :=
  IsLimit.conePointUniqueUpToIso (TopCat.pullbackConeIsLimit (forgetToTop.map (map 𝒰 i)) (forgetToTop.map (map 𝒰 j)))
    (isLimitOfHasPullbackOfPreservesLimit forgetToTop (map 𝒰 i) (map 𝒰 j))
⊢ ∃ x_1,
    (GlueData.f (gluedCover 𝒰).toGlueData { fst := i, snd := x }.fst { fst := j, snd := y }.fst).val.base x_1 =
        { fst := i, snd := x }.snd ∧
      (t (gluedCover 𝒰).toGlueData { fst := i, snd := x }.fst { fst := j, snd := y }.fst ≫
                GlueData.f (gluedCover 𝒰).toGlueData { fst := j, snd := y }.fst { fst := i, snd := x }.fst).val.base
          x_1 =
        { fst := j, snd := y }.snd

Next tactic:
use e.hom ⟨⟨x, y⟩, h⟩
theorem fromGlued_injective : Function.Injective 𝒰.fromGlued.1.base := by
  intro x y h
  obtain ⟨i, x, rfl⟩ := 𝒰.gluedCover.ι_jointly_surjective x
  obtain ⟨j, y, rfl⟩ := 𝒰.gluedCover.ι_jointly_surjective y
  simp_rw [← comp_apply, ← SheafedSpace.comp_base, ← LocallyRingedSpace.comp_val] at h
  erw [ι_fromGlued, ι_fromGlued] at h
  let e :=
    (TopCat.pullbackConeIsLimit _ _).conePointUniqueUpToIso
      (isLimitOfHasPullbackOfPreservesLimit Scheme.forgetToTop (𝒰.map i) (𝒰.map j))
  rw [𝒰.gluedCover.ι_eq_iff]
  right
  use e.hom ⟨⟨x, y⟩, h⟩
  

Proof state:
case h
X : Scheme
𝒰 : OpenCover X
i : (gluedCover 𝒰).toGlueData.J
x : ↑↑(U (gluedCover 𝒰).toGlueData i).toPresheafedSpace
j : (gluedCover 𝒰).toGlueData.J
y : ↑↑(U (gluedCover 𝒰).toGlueData j).toPresheafedSpace
h : (map 𝒰 i).val.base x = (map 𝒰 j).val.base y
e : (TopCat.pullbackCone (forgetToTop.map (map 𝒰 i)) (forgetToTop.map (map 𝒰 j))).pt ≅
  (PullbackCone.mk (forgetToTop.map pullback.fst) (forgetToTop.map pullback.snd)
      (_ :
        forgetToTop.map pullback.fst ≫ forgetToTop.map (map 𝒰 i) =
          forgetToTop.map pullback.snd ≫ forgetToTop.map (map 𝒰 j))).pt :=
  IsLimit.conePointUniqueUpToIso (TopCat.pullbackConeIsLimit (forgetToTop.map (map 𝒰 i)) (forgetToTop.map (map 𝒰 j)))
    (isLimitOfHasPullbackOfPreservesLimit forgetToTop (map 𝒰 i) (map 𝒰 j))
⊢ (GlueData.f (gluedCover 𝒰).toGlueData { fst := i, snd := x }.fst { fst := j, snd := y }.fst).val.base
        (e.hom { val := (x, y), property := h }) =
      { fst := i, snd := x }.snd ∧
    (t (gluedCover 𝒰).toGlueData { fst := i, snd := x }.fst { fst := j, snd := y }.fst ≫
              GlueData.f (gluedCover 𝒰).toGlueData { fst := j, snd := y }.fst { fst := i, snd := x }.fst).val.base
        (e.hom { val := (x, y), property := h }) =
      { fst := j, snd := y }.snd

Next tactic:
constructor
theorem fromGlued_injective : Function.Injective 𝒰.fromGlued.1.base := by
  intro x y h
  obtain ⟨i, x, rfl⟩ := 𝒰.gluedCover.ι_jointly_surjective x
  obtain ⟨j, y, rfl⟩ := 𝒰.gluedCover.ι_jointly_surjective y
  simp_rw [← comp_apply, ← SheafedSpace.comp_base, ← LocallyRingedSpace.comp_val] at h
  erw [ι_fromGlued, ι_fromGlued] at h
  let e :=
    (TopCat.pullbackConeIsLimit _ _).conePointUniqueUpToIso
      (isLimitOfHasPullbackOfPreservesLimit Scheme.forgetToTop (𝒰.map i) (𝒰.map j))
  rw [𝒰.gluedCover.ι_eq_iff]
  right
  use e.hom ⟨⟨x, y⟩, h⟩
  constructor
  -- Porting note: in the two subproofs below, added the `change` lines
  · 

Proof state:
case h.left
X : Scheme
𝒰 : OpenCover X
i : (gluedCover 𝒰).toGlueData.J
x : ↑↑(U (gluedCover 𝒰).toGlueData i).toPresheafedSpace
j : (gluedCover 𝒰).toGlueData.J
y : ↑↑(U (gluedCover 𝒰).toGlueData j).toPresheafedSpace
h : (map 𝒰 i).val.base x = (map 𝒰 j).val.base y
e : (TopCat.pullbackCone (forgetToTop.map (map 𝒰 i)) (forgetToTop.map (map 𝒰 j))).pt ≅
  (PullbackCone.mk (forgetToTop.map pullback.fst) (forgetToTop.map pullback.snd)
      (_ :
        forgetToTop.map pullback.fst ≫ forgetToTop.map (map 𝒰 i) =
          forgetToTop.map pullback.snd ≫ forgetToTop.map (map 𝒰 j))).pt :=
  IsLimit.conePointUniqueUpToIso (TopCat.pullbackConeIsLimit (forgetToTop.map (map 𝒰 i)) (forgetToTop.map (map 𝒰 j)))
    (isLimitOfHasPullbackOfPreservesLimit forgetToTop (map 𝒰 i) (map 𝒰 j))
⊢ (GlueData.f (gluedCover 𝒰).toGlueData { fst := i, snd := x }.fst { fst := j, snd := y }.fst).val.base
      (e.hom { val := (x, y), property := h }) =
    { fst := i, snd := x }.snd

Next tactic:
change (e.hom ≫ _) ⟨(x, y), h⟩ = x
theorem fromGlued_injective : Function.Injective 𝒰.fromGlued.1.base := by
  intro x y h
  obtain ⟨i, x, rfl⟩ := 𝒰.gluedCover.ι_jointly_surjective x
  obtain ⟨j, y, rfl⟩ := 𝒰.gluedCover.ι_jointly_surjective y
  simp_rw [← comp_apply, ← SheafedSpace.comp_base, ← LocallyRingedSpace.comp_val] at h
  erw [ι_fromGlued, ι_fromGlued] at h
  let e :=
    (TopCat.pullbackConeIsLimit _ _).conePointUniqueUpToIso
      (isLimitOfHasPullbackOfPreservesLimit Scheme.forgetToTop (𝒰.map i) (𝒰.map j))
  rw [𝒰.gluedCover.ι_eq_iff]
  right
  use e.hom ⟨⟨x, y⟩, h⟩
  constructor
  -- Porting note: in the two subproofs below, added the `change` lines
  · change (e.hom ≫ _) ⟨(x, y), h⟩ = x
    

Proof state:
case h.left
X : Scheme
𝒰 : OpenCover X
i : (gluedCover 𝒰).toGlueData.J
x : ↑↑(U (gluedCover 𝒰).toGlueData i).toPresheafedSpace
j : (gluedCover 𝒰).toGlueData.J
y : ↑↑(U (gluedCover 𝒰).toGlueData j).toPresheafedSpace
h : (map 𝒰 i).val.base x = (map 𝒰 j).val.base y
e : (TopCat.pullbackCone (forgetToTop.map (map 𝒰 i)) (forgetToTop.map (map 𝒰 j))).pt ≅
  (PullbackCone.mk (forgetToTop.map pullback.fst) (forgetToTop.map pullback.snd)
      (_ :
        forgetToTop.map pullback.fst ≫ forgetToTop.map (map 𝒰 i) =
          forgetToTop.map pullback.snd ≫ forgetToTop.map (map 𝒰 j))).pt :=
  IsLimit.conePointUniqueUpToIso (TopCat.pullbackConeIsLimit (forgetToTop.map (map 𝒰 i)) (forgetToTop.map (map 𝒰 j)))
    (isLimitOfHasPullbackOfPreservesLimit forgetToTop (map 𝒰 i) (map 𝒰 j))
⊢ (e.hom ≫ (GlueData.f (gluedCover 𝒰).toGlueData { fst := i, snd := x }.fst { fst := j, snd := y }.fst).val.base)
      { val := (x, y), property := h } =
    x

Next tactic:
erw [IsLimit.conePointUniqueUpToIso_hom_comp _ _ WalkingCospan.left]
theorem fromGlued_injective : Function.Injective 𝒰.fromGlued.1.base := by
  intro x y h
  obtain ⟨i, x, rfl⟩ := 𝒰.gluedCover.ι_jointly_surjective x
  obtain ⟨j, y, rfl⟩ := 𝒰.gluedCover.ι_jointly_surjective y
  simp_rw [← comp_apply, ← SheafedSpace.comp_base, ← LocallyRingedSpace.comp_val] at h
  erw [ι_fromGlued, ι_fromGlued] at h
  let e :=
    (TopCat.pullbackConeIsLimit _ _).conePointUniqueUpToIso
      (isLimitOfHasPullbackOfPreservesLimit Scheme.forgetToTop (𝒰.map i) (𝒰.map j))
  rw [𝒰.gluedCover.ι_eq_iff]
  right
  use e.hom ⟨⟨x, y⟩, h⟩
  constructor
  -- Porting note: in the two subproofs below, added the `change` lines
  · change (e.hom ≫ _) ⟨(x, y), h⟩ = x
    erw [IsLimit.conePointUniqueUpToIso_hom_comp _ _ WalkingCospan.left]; 

Proof state:
case h.left
X : Scheme
𝒰 : OpenCover X
i : (gluedCover 𝒰).toGlueData.J
x : ↑↑(U (gluedCover 𝒰).toGlueData i).toPresheafedSpace
j : (gluedCover 𝒰).toGlueData.J
y : ↑↑(U (gluedCover 𝒰).toGlueData j).toPresheafedSpace
h : (map 𝒰 i).val.base x = (map 𝒰 j).val.base y
e : (TopCat.pullbackCone (forgetToTop.map (map 𝒰 i)) (forgetToTop.map (map 𝒰 j))).pt ≅
  (PullbackCone.mk (forgetToTop.map pullback.fst) (forgetToTop.map pullback.snd)
      (_ :
        forgetToTop.map pullback.fst ≫ forgetToTop.map (map 𝒰 i) =
          forgetToTop.map pullback.snd ≫ forgetToTop.map (map 𝒰 j))).pt :=
  IsLimit.conePointUniqueUpToIso (TopCat.pullbackConeIsLimit (forgetToTop.map (map 𝒰 i)) (forgetToTop.map (map 𝒰 j)))
    (isLimitOfHasPullbackOfPreservesLimit forgetToTop (map 𝒰 i) (map 𝒰 j))
⊢ ((TopCat.pullbackCone (forgetToTop.map (map 𝒰 i)) (forgetToTop.map (map 𝒰 j))).π.app WalkingCospan.left)
      { val := (x, y), property := h } =
    x

Next tactic:
rfl
theorem fromGlued_injective : Function.Injective 𝒰.fromGlued.1.base := by
  intro x y h
  obtain ⟨i, x, rfl⟩ := 𝒰.gluedCover.ι_jointly_surjective x
  obtain ⟨j, y, rfl⟩ := 𝒰.gluedCover.ι_jointly_surjective y
  simp_rw [← comp_apply, ← SheafedSpace.comp_base, ← LocallyRingedSpace.comp_val] at h
  erw [ι_fromGlued, ι_fromGlued] at h
  let e :=
    (TopCat.pullbackConeIsLimit _ _).conePointUniqueUpToIso
      (isLimitOfHasPullbackOfPreservesLimit Scheme.forgetToTop (𝒰.map i) (𝒰.map j))
  rw [𝒰.gluedCover.ι_eq_iff]
  right
  use e.hom ⟨⟨x, y⟩, h⟩
  constructor
  -- Porting note: in the two subproofs below, added the `change` lines
  · change (e.hom ≫ _) ⟨(x, y), h⟩ = x
    erw [IsLimit.conePointUniqueUpToIso_hom_comp _ _ WalkingCospan.left]; rfl
  · 

Proof state:
case h.right
X : Scheme
𝒰 : OpenCover X
i : (gluedCover 𝒰).toGlueData.J
x : ↑↑(U (gluedCover 𝒰).toGlueData i).toPresheafedSpace
j : (gluedCover 𝒰).toGlueData.J
y : ↑↑(U (gluedCover 𝒰).toGlueData j).toPresheafedSpace
h : (map 𝒰 i).val.base x = (map 𝒰 j).val.base y
e : (TopCat.pullbackCone (forgetToTop.map (map 𝒰 i)) (forgetToTop.map (map 𝒰 j))).pt ≅
  (PullbackCone.mk (forgetToTop.map pullback.fst) (forgetToTop.map pullback.snd)
      (_ :
        forgetToTop.map pullback.fst ≫ forgetToTop.map (map 𝒰 i) =
          forgetToTop.map pullback.snd ≫ forgetToTop.map (map 𝒰 j))).pt :=
  IsLimit.conePointUniqueUpToIso (TopCat.pullbackConeIsLimit (forgetToTop.map (map 𝒰 i)) (forgetToTop.map (map 𝒰 j)))
    (isLimitOfHasPullbackOfPreservesLimit forgetToTop (map 𝒰 i) (map 𝒰 j))
⊢ (t (gluedCover 𝒰).toGlueData { fst := i, snd := x }.fst { fst := j, snd := y }.fst ≫
            GlueData.f (gluedCover 𝒰).toGlueData { fst := j, snd := y }.fst { fst := i, snd := x }.fst).val.base
      (e.hom { val := (x, y), property := h }) =
    { fst := j, snd := y }.snd

Next tactic:
change (e.hom ≫ ((gluedCover 𝒰).toGlueData.t i j ≫
      (gluedCover 𝒰).toGlueData.f j i).val.base) ⟨(x, y), h⟩ = y
theorem fromGlued_injective : Function.Injective 𝒰.fromGlued.1.base := by
  intro x y h
  obtain ⟨i, x, rfl⟩ := 𝒰.gluedCover.ι_jointly_surjective x
  obtain ⟨j, y, rfl⟩ := 𝒰.gluedCover.ι_jointly_surjective y
  simp_rw [← comp_apply, ← SheafedSpace.comp_base, ← LocallyRingedSpace.comp_val] at h
  erw [ι_fromGlued, ι_fromGlued] at h
  let e :=
    (TopCat.pullbackConeIsLimit _ _).conePointUniqueUpToIso
      (isLimitOfHasPullbackOfPreservesLimit Scheme.forgetToTop (𝒰.map i) (𝒰.map j))
  rw [𝒰.gluedCover.ι_eq_iff]
  right
  use e.hom ⟨⟨x, y⟩, h⟩
  constructor
  -- Porting note: in the two subproofs below, added the `change` lines
  · change (e.hom ≫ _) ⟨(x, y), h⟩ = x
    erw [IsLimit.conePointUniqueUpToIso_hom_comp _ _ WalkingCospan.left]; rfl
  · change (e.hom ≫ ((gluedCover 𝒰).toGlueData.t i j ≫
      (gluedCover 𝒰).toGlueData.f j i).val.base) ⟨(x, y), h⟩ = y
    

Proof state:
case h.right
X : Scheme
𝒰 : OpenCover X
i : (gluedCover 𝒰).toGlueData.J
x : ↑↑(U (gluedCover 𝒰).toGlueData i).toPresheafedSpace
j : (gluedCover 𝒰).toGlueData.J
y : ↑↑(U (gluedCover 𝒰).toGlueData j).toPresheafedSpace
h : (map 𝒰 i).val.base x = (map 𝒰 j).val.base y
e : (TopCat.pullbackCone (forgetToTop.map (map 𝒰 i)) (forgetToTop.map (map 𝒰 j))).pt ≅
  (PullbackCone.mk (forgetToTop.map pullback.fst) (forgetToTop.map pullback.snd)
      (_ :
        forgetToTop.map pullback.fst ≫ forgetToTop.map (map 𝒰 i) =
          forgetToTop.map pullback.snd ≫ forgetToTop.map (map 𝒰 j))).pt :=
  IsLimit.conePointUniqueUpToIso (TopCat.pullbackConeIsLimit (forgetToTop.map (map 𝒰 i)) (forgetToTop.map (map 𝒰 j)))
    (isLimitOfHasPullbackOfPreservesLimit forgetToTop (map 𝒰 i) (map 𝒰 j))
⊢ (e.hom ≫ (t (gluedCover 𝒰).toGlueData i j ≫ GlueData.f (gluedCover 𝒰).toGlueData j i).val.base)
      { val := (x, y), property := h } =
    y

Next tactic:
erw [pullbackSymmetry_hom_comp_fst,
      IsLimit.conePointUniqueUpToIso_hom_comp _ _ WalkingCospan.right]
theorem fromGlued_injective : Function.Injective 𝒰.fromGlued.1.base := by
  intro x y h
  obtain ⟨i, x, rfl⟩ := 𝒰.gluedCover.ι_jointly_surjective x
  obtain ⟨j, y, rfl⟩ := 𝒰.gluedCover.ι_jointly_surjective y
  simp_rw [← comp_apply, ← SheafedSpace.comp_base, ← LocallyRingedSpace.comp_val] at h
  erw [ι_fromGlued, ι_fromGlued] at h
  let e :=
    (TopCat.pullbackConeIsLimit _ _).conePointUniqueUpToIso
      (isLimitOfHasPullbackOfPreservesLimit Scheme.forgetToTop (𝒰.map i) (𝒰.map j))
  rw [𝒰.gluedCover.ι_eq_iff]
  right
  use e.hom ⟨⟨x, y⟩, h⟩
  constructor
  -- Porting note: in the two subproofs below, added the `change` lines
  · change (e.hom ≫ _) ⟨(x, y), h⟩ = x
    erw [IsLimit.conePointUniqueUpToIso_hom_comp _ _ WalkingCospan.left]; rfl
  · change (e.hom ≫ ((gluedCover 𝒰).toGlueData.t i j ≫
      (gluedCover 𝒰).toGlueData.f j i).val.base) ⟨(x, y), h⟩ = y
    erw [pullbackSymmetry_hom_comp_fst,
      IsLimit.conePointUniqueUpToIso_hom_comp _ _ WalkingCospan.right]
    

Proof state:
case h.right
X : Scheme
𝒰 : OpenCover X
i : (gluedCover 𝒰).toGlueData.J
x : ↑↑(U (gluedCover 𝒰).toGlueData i).toPresheafedSpace
j : (gluedCover 𝒰).toGlueData.J
y : ↑↑(U (gluedCover 𝒰).toGlueData j).toPresheafedSpace
h : (map 𝒰 i).val.base x = (map 𝒰 j).val.base y
e : (TopCat.pullbackCone (forgetToTop.map (map 𝒰 i)) (forgetToTop.map (map 𝒰 j))).pt ≅
  (PullbackCone.mk (forgetToTop.map pullback.fst) (forgetToTop.map pullback.snd)
      (_ :
        forgetToTop.map pullback.fst ≫ forgetToTop.map (map 𝒰 i) =
          forgetToTop.map pullback.snd ≫ forgetToTop.map (map 𝒰 j))).pt :=
  IsLimit.conePointUniqueUpToIso (TopCat.pullbackConeIsLimit (forgetToTop.map (map 𝒰 i)) (forgetToTop.map (map 𝒰 j)))
    (isLimitOfHasPullbackOfPreservesLimit forgetToTop (map 𝒰 i) (map 𝒰 j))
⊢ ((TopCat.pullbackCone (forgetToTop.map (map 𝒰 i)) (forgetToTop.map (map 𝒰 j))).π.app WalkingCospan.right)
      { val := (x, y), property := h } =
    y

Next tactic:
rfl
instance fromGlued_stalk_iso (x : 𝒰.gluedCover.glued.carrier) :
    IsIso (PresheafedSpace.stalkMap 𝒰.fromGlued.val x) := by
  

Proof state:
X : Scheme
𝒰 : OpenCover X
x : ↑↑(GlueData.glued (gluedCover 𝒰)).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace
⊢ IsIso (stalkMap (fromGlued 𝒰).val x)

Next tactic:
obtain ⟨i, x, rfl⟩ := 𝒰.gluedCover.ι_jointly_surjective x
instance fromGlued_stalk_iso (x : 𝒰.gluedCover.glued.carrier) :
    IsIso (PresheafedSpace.stalkMap 𝒰.fromGlued.val x) := by
  obtain ⟨i, x, rfl⟩ := 𝒰.gluedCover.ι_jointly_surjective x
  

Proof state:
case intro.intro
X : Scheme
𝒰 : OpenCover X
i : (gluedCover 𝒰).toGlueData.J
x : ↑↑(U (gluedCover 𝒰).toGlueData i).toPresheafedSpace
⊢ IsIso (stalkMap (fromGlued 𝒰).val ((GlueData.ι (gluedCover 𝒰) i).val.base x))

Next tactic:
have :=
    PresheafedSpace.stalkMap.congr_hom _ _
      (congr_arg LocallyRingedSpace.Hom.val <| 𝒰.ι_fromGlued i) x
instance fromGlued_stalk_iso (x : 𝒰.gluedCover.glued.carrier) :
    IsIso (PresheafedSpace.stalkMap 𝒰.fromGlued.val x) := by
  obtain ⟨i, x, rfl⟩ := 𝒰.gluedCover.ι_jointly_surjective x
  have :=
    PresheafedSpace.stalkMap.congr_hom _ _
      (congr_arg LocallyRingedSpace.Hom.val <| 𝒰.ι_fromGlued i) x
  

Proof state:
case intro.intro
X : Scheme
𝒰 : OpenCover X
i : (gluedCover 𝒰).toGlueData.J
x : ↑↑(U (gluedCover 𝒰).toGlueData i).toPresheafedSpace
this :
  stalkMap (GlueData.ι (gluedCover 𝒰) i ≫ fromGlued 𝒰).val x =
    eqToHom
        (_ :
          stalk X.toPresheafedSpace ((GlueData.ι (gluedCover 𝒰) i ≫ fromGlued 𝒰).val.base x) =
            stalk X.toPresheafedSpace ((map 𝒰 i).val.base x)) ≫
      stalkMap (map 𝒰 i).val x
⊢ IsIso (stalkMap (fromGlued 𝒰).val ((GlueData.ι (gluedCover 𝒰) i).val.base x))

Next tactic:
erw [PresheafedSpace.stalkMap.comp] at this