l3lab/ntp-mathlib huggingface dataset:
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
  erw [PresheafedSpace.stalkMap.comp] at this
  

Proof state:
case intro.intro
X : Scheme
𝒰 : OpenCover X
i : (gluedCover 𝒰).toGlueData.J
x : ↑↑(U (gluedCover 𝒰).toGlueData i).toPresheafedSpace
this :
  stalkMap (fromGlued 𝒰).val ((GlueData.ι (gluedCover 𝒰) i).val.base x) ≫ stalkMap (GlueData.ι (gluedCover 𝒰) i).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:
rw [← IsIso.eq_comp_inv] at this
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
  erw [PresheafedSpace.stalkMap.comp] at this
  rw [← IsIso.eq_comp_inv] at this
  

Proof state:
case intro.intro
X : Scheme
𝒰 : OpenCover X
i : (gluedCover 𝒰).toGlueData.J
x : ↑↑(U (gluedCover 𝒰).toGlueData i).toPresheafedSpace
this :
  stalkMap (fromGlued 𝒰).val ((GlueData.ι (gluedCover 𝒰) i).val.base 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) ≫
      inv (stalkMap (GlueData.ι (gluedCover 𝒰) i).val x)
⊢ IsIso (stalkMap (fromGlued 𝒰).val ((GlueData.ι (gluedCover 𝒰) i).val.base x))

Next tactic:
rw [this]
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
  erw [PresheafedSpace.stalkMap.comp] at this
  rw [← IsIso.eq_comp_inv] at this
  rw [this]
  

Proof state:
case intro.intro
X : Scheme
𝒰 : OpenCover X
i : (gluedCover 𝒰).toGlueData.J
x : ↑↑(U (gluedCover 𝒰).toGlueData i).toPresheafedSpace
this :
  stalkMap (fromGlued 𝒰).val ((GlueData.ι (gluedCover 𝒰) i).val.base 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) ≫
      inv (stalkMap (GlueData.ι (gluedCover 𝒰) i).val x)
⊢ IsIso
    ((eqToHom
          (_ :
            stalk X.toPresheafedSpace ((GlueData.ι (gluedCover 𝒰) i ≫ fromGlued 𝒰).val.base x) =
              stalk X.toPresheafedSpace ((map 𝒰 i).val.base x)) ≫
        stalkMap (map 𝒰 i).val x) ≫
      inv (stalkMap (GlueData.ι (gluedCover 𝒰) i).val x))

Next tactic:
infer_instance
theorem fromGlued_open_map : IsOpenMap 𝒰.fromGlued.1.base := by
  

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

Next tactic:
intro U hU
theorem fromGlued_open_map : IsOpenMap 𝒰.fromGlued.1.base := by
  intro U hU
  

Proof state:
X : Scheme
𝒰 : OpenCover X
U :
  Set
    ((CategoryTheory.forget TopCat).obj
      ↑(GlueData.glued (gluedCover 𝒰)).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace)
hU : _root_.IsOpen U
⊢ _root_.IsOpen (⇑(fromGlued 𝒰).val.base '' U)

Next tactic:
rw [isOpen_iff_forall_mem_open]
theorem fromGlued_open_map : IsOpenMap 𝒰.fromGlued.1.base := by
  intro U hU
  rw [isOpen_iff_forall_mem_open]
  

Proof state:
X : Scheme
𝒰 : OpenCover X
U :
  Set
    ((CategoryTheory.forget TopCat).obj
      ↑(GlueData.glued (gluedCover 𝒰)).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace)
hU : _root_.IsOpen U
⊢ ∀ x ∈ ⇑(fromGlued 𝒰).val.base '' U, ∃ t ⊆ ⇑(fromGlued 𝒰).val.base '' U, _root_.IsOpen t ∧ x ∈ t

Next tactic:
intro x hx
theorem fromGlued_open_map : IsOpenMap 𝒰.fromGlued.1.base := by
  intro U hU
  rw [isOpen_iff_forall_mem_open]
  intro x hx
  

Proof state:
X : Scheme
𝒰 : OpenCover X
U :
  Set
    ((CategoryTheory.forget TopCat).obj
      ↑(GlueData.glued (gluedCover 𝒰)).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace)
hU : _root_.IsOpen U
x : (CategoryTheory.forget TopCat).obj ↑X.toPresheafedSpace
hx : x ∈ ⇑(fromGlued 𝒰).val.base '' U
⊢ ∃ t ⊆ ⇑(fromGlued 𝒰).val.base '' U, _root_.IsOpen t ∧ x ∈ t

Next tactic:
rw [𝒰.gluedCover.isOpen_iff] at hU
theorem fromGlued_open_map : IsOpenMap 𝒰.fromGlued.1.base := by
  intro U hU
  rw [isOpen_iff_forall_mem_open]
  intro x hx
  rw [𝒰.gluedCover.isOpen_iff] at hU
  

Proof state:
X : Scheme
𝒰 : OpenCover X
U :
  Set
    ((CategoryTheory.forget TopCat).obj
      ↑(GlueData.glued (gluedCover 𝒰)).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace)
hU : ∀ (i : (gluedCover 𝒰).toGlueData.J), _root_.IsOpen (⇑(GlueData.ι (gluedCover 𝒰) i).val.base ⁻¹' U)
x : (CategoryTheory.forget TopCat).obj ↑X.toPresheafedSpace
hx : x ∈ ⇑(fromGlued 𝒰).val.base '' U
⊢ ∃ t ⊆ ⇑(fromGlued 𝒰).val.base '' U, _root_.IsOpen t ∧ x ∈ t

Next tactic:
use 𝒰.fromGlued.val.base '' U ∩ Set.range (𝒰.map (𝒰.f x)).1.base
theorem fromGlued_open_map : IsOpenMap 𝒰.fromGlued.1.base := by
  intro U hU
  rw [isOpen_iff_forall_mem_open]
  intro x hx
  rw [𝒰.gluedCover.isOpen_iff] at hU
  use 𝒰.fromGlued.val.base '' U ∩ Set.range (𝒰.map (𝒰.f x)).1.base
  

Proof state:
case h
X : Scheme
𝒰 : OpenCover X
U :
  Set
    ((CategoryTheory.forget TopCat).obj
      ↑(GlueData.glued (gluedCover 𝒰)).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace)
hU : ∀ (i : (gluedCover 𝒰).toGlueData.J), _root_.IsOpen (⇑(GlueData.ι (gluedCover 𝒰) i).val.base ⁻¹' U)
x : (CategoryTheory.forget TopCat).obj ↑X.toPresheafedSpace
hx : x ∈ ⇑(fromGlued 𝒰).val.base '' U
⊢ ⇑(fromGlued 𝒰).val.base '' U ∩ Set.range ⇑(map 𝒰 (f 𝒰 x)).val.base ⊆ ⇑(fromGlued 𝒰).val.base '' U ∧
    _root_.IsOpen (⇑(fromGlued 𝒰).val.base '' U ∩ Set.range ⇑(map 𝒰 (f 𝒰 x)).val.base) ∧
      x ∈ ⇑(fromGlued 𝒰).val.base '' U ∩ Set.range ⇑(map 𝒰 (f 𝒰 x)).val.base

Next tactic:
use Set.inter_subset_left _ _
theorem fromGlued_open_map : IsOpenMap 𝒰.fromGlued.1.base := by
  intro U hU
  rw [isOpen_iff_forall_mem_open]
  intro x hx
  rw [𝒰.gluedCover.isOpen_iff] at hU
  use 𝒰.fromGlued.val.base '' U ∩ Set.range (𝒰.map (𝒰.f x)).1.base
  use Set.inter_subset_left _ _
  

Proof state:
case right
X : Scheme
𝒰 : OpenCover X
U :
  Set
    ((CategoryTheory.forget TopCat).obj
      ↑(GlueData.glued (gluedCover 𝒰)).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace)
hU : ∀ (i : (gluedCover 𝒰).toGlueData.J), _root_.IsOpen (⇑(GlueData.ι (gluedCover 𝒰) i).val.base ⁻¹' U)
x : (CategoryTheory.forget TopCat).obj ↑X.toPresheafedSpace
hx : x ∈ ⇑(fromGlued 𝒰).val.base '' U
⊢ _root_.IsOpen (⇑(fromGlued 𝒰).val.base '' U ∩ Set.range ⇑(map 𝒰 (f 𝒰 x)).val.base) ∧
    x ∈ ⇑(fromGlued 𝒰).val.base '' U ∩ Set.range ⇑(map 𝒰 (f 𝒰 x)).val.base

Next tactic:
constructor
theorem fromGlued_open_map : IsOpenMap 𝒰.fromGlued.1.base := by
  intro U hU
  rw [isOpen_iff_forall_mem_open]
  intro x hx
  rw [𝒰.gluedCover.isOpen_iff] at hU
  use 𝒰.fromGlued.val.base '' U ∩ Set.range (𝒰.map (𝒰.f x)).1.base
  use Set.inter_subset_left _ _
  constructor
  · 

Proof state:
case right.left
X : Scheme
𝒰 : OpenCover X
U :
  Set
    ((CategoryTheory.forget TopCat).obj
      ↑(GlueData.glued (gluedCover 𝒰)).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace)
hU : ∀ (i : (gluedCover 𝒰).toGlueData.J), _root_.IsOpen (⇑(GlueData.ι (gluedCover 𝒰) i).val.base ⁻¹' U)
x : (CategoryTheory.forget TopCat).obj ↑X.toPresheafedSpace
hx : x ∈ ⇑(fromGlued 𝒰).val.base '' U
⊢ _root_.IsOpen (⇑(fromGlued 𝒰).val.base '' U ∩ Set.range ⇑(map 𝒰 (f 𝒰 x)).val.base)

Next tactic:
rw [← Set.image_preimage_eq_inter_range]
theorem fromGlued_open_map : IsOpenMap 𝒰.fromGlued.1.base := by
  intro U hU
  rw [isOpen_iff_forall_mem_open]
  intro x hx
  rw [𝒰.gluedCover.isOpen_iff] at hU
  use 𝒰.fromGlued.val.base '' U ∩ Set.range (𝒰.map (𝒰.f x)).1.base
  use Set.inter_subset_left _ _
  constructor
  · rw [← Set.image_preimage_eq_inter_range]
    

Proof state:
case right.left
X : Scheme
𝒰 : OpenCover X
U :
  Set
    ((CategoryTheory.forget TopCat).obj
      ↑(GlueData.glued (gluedCover 𝒰)).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace)
hU : ∀ (i : (gluedCover 𝒰).toGlueData.J), _root_.IsOpen (⇑(GlueData.ι (gluedCover 𝒰) i).val.base ⁻¹' U)
x : (CategoryTheory.forget TopCat).obj ↑X.toPresheafedSpace
hx : x ∈ ⇑(fromGlued 𝒰).val.base '' U
⊢ _root_.IsOpen (⇑(map 𝒰 (f 𝒰 x)).val.base '' (⇑(map 𝒰 (f 𝒰 x)).val.base ⁻¹' (⇑(fromGlued 𝒰).val.base '' U)))

Next tactic:
apply (show IsOpenImmersion (𝒰.map (𝒰.f x)) from inferInstance).base_open.isOpenMap
theorem fromGlued_open_map : IsOpenMap 𝒰.fromGlued.1.base := by
  intro U hU
  rw [isOpen_iff_forall_mem_open]
  intro x hx
  rw [𝒰.gluedCover.isOpen_iff] at hU
  use 𝒰.fromGlued.val.base '' U ∩ Set.range (𝒰.map (𝒰.f x)).1.base
  use Set.inter_subset_left _ _
  constructor
  · rw [← Set.image_preimage_eq_inter_range]
    apply (show IsOpenImmersion (𝒰.map (𝒰.f x)) from inferInstance).base_open.isOpenMap
    

Proof state:
case right.left.a
X : Scheme
𝒰 : OpenCover X
U :
  Set
    ((CategoryTheory.forget TopCat).obj
      ↑(GlueData.glued (gluedCover 𝒰)).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace)
hU : ∀ (i : (gluedCover 𝒰).toGlueData.J), _root_.IsOpen (⇑(GlueData.ι (gluedCover 𝒰) i).val.base ⁻¹' U)
x : (CategoryTheory.forget TopCat).obj ↑X.toPresheafedSpace
hx : x ∈ ⇑(fromGlued 𝒰).val.base '' U
⊢ _root_.IsOpen (⇑(map 𝒰 (f 𝒰 x)).val.base ⁻¹' (⇑(fromGlued 𝒰).val.base '' U))

Next tactic:
convert hU (𝒰.f x) using 1
theorem fromGlued_open_map : IsOpenMap 𝒰.fromGlued.1.base := by
  intro U hU
  rw [isOpen_iff_forall_mem_open]
  intro x hx
  rw [𝒰.gluedCover.isOpen_iff] at hU
  use 𝒰.fromGlued.val.base '' U ∩ Set.range (𝒰.map (𝒰.f x)).1.base
  use Set.inter_subset_left _ _
  constructor
  · rw [← Set.image_preimage_eq_inter_range]
    apply (show IsOpenImmersion (𝒰.map (𝒰.f x)) from inferInstance).base_open.isOpenMap
    convert hU (𝒰.f x) using 1
    

Proof state:
case h.e'_3.h
X : Scheme
𝒰 : OpenCover X
U :
  Set
    ((CategoryTheory.forget TopCat).obj
      ↑(GlueData.glued (gluedCover 𝒰)).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace)
hU : ∀ (i : (gluedCover 𝒰).toGlueData.J), _root_.IsOpen (⇑(GlueData.ι (gluedCover 𝒰) i).val.base ⁻¹' U)
x : (CategoryTheory.forget TopCat).obj ↑X.toPresheafedSpace
hx : x ∈ ⇑(fromGlued 𝒰).val.base '' U
e_1✝ :
  (CategoryTheory.forget TopCat).obj ↑(obj 𝒰 (f 𝒰 x)).toPresheafedSpace =
    (CategoryTheory.forget TopCat).obj ↑(CategoryTheory.GlueData.U (gluedCover 𝒰).toGlueData (f 𝒰 x)).toPresheafedSpace
⊢ ⇑(map 𝒰 (f 𝒰 x)).val.base ⁻¹' (⇑(fromGlued 𝒰).val.base '' U) = ⇑(GlueData.ι (gluedCover 𝒰) (f 𝒰 x)).val.base ⁻¹' U

Next tactic:
rw [← ι_fromGlued]
theorem fromGlued_open_map : IsOpenMap 𝒰.fromGlued.1.base := by
  intro U hU
  rw [isOpen_iff_forall_mem_open]
  intro x hx
  rw [𝒰.gluedCover.isOpen_iff] at hU
  use 𝒰.fromGlued.val.base '' U ∩ Set.range (𝒰.map (𝒰.f x)).1.base
  use Set.inter_subset_left _ _
  constructor
  · rw [← Set.image_preimage_eq_inter_range]
    apply (show IsOpenImmersion (𝒰.map (𝒰.f x)) from inferInstance).base_open.isOpenMap
    convert hU (𝒰.f x) using 1
    rw [← ι_fromGlued]; 

Proof state:
case h.e'_3.h
X : Scheme
𝒰 : OpenCover X
U :
  Set
    ((CategoryTheory.forget TopCat).obj
      ↑(GlueData.glued (gluedCover 𝒰)).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace)
hU : ∀ (i : (gluedCover 𝒰).toGlueData.J), _root_.IsOpen (⇑(GlueData.ι (gluedCover 𝒰) i).val.base ⁻¹' U)
x : (CategoryTheory.forget TopCat).obj ↑X.toPresheafedSpace
hx : x ∈ ⇑(fromGlued 𝒰).val.base '' U
e_1✝ :
  (CategoryTheory.forget TopCat).obj ↑(obj 𝒰 (f 𝒰 x)).toPresheafedSpace =
    (CategoryTheory.forget TopCat).obj ↑(CategoryTheory.GlueData.U (gluedCover 𝒰).toGlueData (f 𝒰 x)).toPresheafedSpace
⊢ ⇑(GlueData.ι (gluedCover 𝒰) (f 𝒰 x) ≫ fromGlued 𝒰).val.base ⁻¹' (⇑(fromGlued 𝒰).val.base '' U) =
    ⇑(GlueData.ι (gluedCover 𝒰) (f 𝒰 x)).val.base ⁻¹' U

Next tactic:
erw [coe_comp]
theorem fromGlued_open_map : IsOpenMap 𝒰.fromGlued.1.base := by
  intro U hU
  rw [isOpen_iff_forall_mem_open]
  intro x hx
  rw [𝒰.gluedCover.isOpen_iff] at hU
  use 𝒰.fromGlued.val.base '' U ∩ Set.range (𝒰.map (𝒰.f x)).1.base
  use Set.inter_subset_left _ _
  constructor
  · rw [← Set.image_preimage_eq_inter_range]
    apply (show IsOpenImmersion (𝒰.map (𝒰.f x)) from inferInstance).base_open.isOpenMap
    convert hU (𝒰.f x) using 1
    rw [← ι_fromGlued]; erw [coe_comp]; 

Proof state:
case h.e'_3.h
X : Scheme
𝒰 : OpenCover X
U :
  Set
    ((CategoryTheory.forget TopCat).obj
      ↑(GlueData.glued (gluedCover 𝒰)).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace)
hU : ∀ (i : (gluedCover 𝒰).toGlueData.J), _root_.IsOpen (⇑(GlueData.ι (gluedCover 𝒰) i).val.base ⁻¹' U)
x : (CategoryTheory.forget TopCat).obj ↑X.toPresheafedSpace
hx : x ∈ ⇑(fromGlued 𝒰).val.base '' U
e_1✝ :
  (CategoryTheory.forget TopCat).obj ↑(obj 𝒰 (f 𝒰 x)).toPresheafedSpace =
    (CategoryTheory.forget TopCat).obj ↑(CategoryTheory.GlueData.U (gluedCover 𝒰).toGlueData (f 𝒰 x)).toPresheafedSpace
⊢ ⇑(fromGlued 𝒰).val.base ∘ ⇑(GlueData.ι (gluedCover 𝒰) (f 𝒰 x)).val.base ⁻¹' (⇑(fromGlued 𝒰).val.base '' U) =
    ⇑(GlueData.ι (gluedCover 𝒰) (f 𝒰 x)).val.base ⁻¹' U

Next tactic:
rw [Set.preimage_comp]
theorem fromGlued_open_map : IsOpenMap 𝒰.fromGlued.1.base := by
  intro U hU
  rw [isOpen_iff_forall_mem_open]
  intro x hx
  rw [𝒰.gluedCover.isOpen_iff] at hU
  use 𝒰.fromGlued.val.base '' U ∩ Set.range (𝒰.map (𝒰.f x)).1.base
  use Set.inter_subset_left _ _
  constructor
  · rw [← Set.image_preimage_eq_inter_range]
    apply (show IsOpenImmersion (𝒰.map (𝒰.f x)) from inferInstance).base_open.isOpenMap
    convert hU (𝒰.f x) using 1
    rw [← ι_fromGlued]; erw [coe_comp]; rw [Set.preimage_comp]
    

Proof state:
case h.e'_3.h
X : Scheme
𝒰 : OpenCover X
U :
  Set
    ((CategoryTheory.forget TopCat).obj
      ↑(GlueData.glued (gluedCover 𝒰)).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace)
hU : ∀ (i : (gluedCover 𝒰).toGlueData.J), _root_.IsOpen (⇑(GlueData.ι (gluedCover 𝒰) i).val.base ⁻¹' U)
x : (CategoryTheory.forget TopCat).obj ↑X.toPresheafedSpace
hx : x ∈ ⇑(fromGlued 𝒰).val.base '' U
e_1✝ :
  (CategoryTheory.forget TopCat).obj ↑(obj 𝒰 (f 𝒰 x)).toPresheafedSpace =
    (CategoryTheory.forget TopCat).obj ↑(CategoryTheory.GlueData.U (gluedCover 𝒰).toGlueData (f 𝒰 x)).toPresheafedSpace
⊢ ⇑(GlueData.ι (gluedCover 𝒰) (f 𝒰 x)).val.base ⁻¹' (⇑(fromGlued 𝒰).val.base ⁻¹' (⇑(fromGlued 𝒰).val.base '' U)) =
    ⇑(GlueData.ι (gluedCover 𝒰) (f 𝒰 x)).val.base ⁻¹' U

Next tactic:
congr! 1
theorem fromGlued_open_map : IsOpenMap 𝒰.fromGlued.1.base := by
  intro U hU
  rw [isOpen_iff_forall_mem_open]
  intro x hx
  rw [𝒰.gluedCover.isOpen_iff] at hU
  use 𝒰.fromGlued.val.base '' U ∩ Set.range (𝒰.map (𝒰.f x)).1.base
  use Set.inter_subset_left _ _
  constructor
  · rw [← Set.image_preimage_eq_inter_range]
    apply (show IsOpenImmersion (𝒰.map (𝒰.f x)) from inferInstance).base_open.isOpenMap
    convert hU (𝒰.f x) using 1
    rw [← ι_fromGlued]; erw [coe_comp]; rw [Set.preimage_comp]
    congr! 1
    

Proof state:
case h.e'_3.h.h.e'_4
X : Scheme
𝒰 : OpenCover X
U :
  Set
    ((CategoryTheory.forget TopCat).obj
      ↑(GlueData.glued (gluedCover 𝒰)).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace)
hU : ∀ (i : (gluedCover 𝒰).toGlueData.J), _root_.IsOpen (⇑(GlueData.ι (gluedCover 𝒰) i).val.base ⁻¹' U)
x : (CategoryTheory.forget TopCat).obj ↑X.toPresheafedSpace
hx : x ∈ ⇑(fromGlued 𝒰).val.base '' U
e_1✝ :
  (CategoryTheory.forget TopCat).obj ↑(obj 𝒰 (f 𝒰 x)).toPresheafedSpace =
    (CategoryTheory.forget TopCat).obj ↑(CategoryTheory.GlueData.U (gluedCover 𝒰).toGlueData (f 𝒰 x)).toPresheafedSpace
⊢ ⇑(fromGlued 𝒰).val.base ⁻¹' (⇑(fromGlued 𝒰).val.base '' U) = U

Next tactic:
refine' Set.preimage_image_eq _ 𝒰.fromGlued_injective
theorem fromGlued_open_map : IsOpenMap 𝒰.fromGlued.1.base := by
  intro U hU
  rw [isOpen_iff_forall_mem_open]
  intro x hx
  rw [𝒰.gluedCover.isOpen_iff] at hU
  use 𝒰.fromGlued.val.base '' U ∩ Set.range (𝒰.map (𝒰.f x)).1.base
  use Set.inter_subset_left _ _
  constructor
  · rw [← Set.image_preimage_eq_inter_range]
    apply (show IsOpenImmersion (𝒰.map (𝒰.f x)) from inferInstance).base_open.isOpenMap
    convert hU (𝒰.f x) using 1
    rw [← ι_fromGlued]; erw [coe_comp]; rw [Set.preimage_comp]
    congr! 1
    refine' Set.preimage_image_eq _ 𝒰.fromGlued_injective
  · 

Proof state:
case right.right
X : Scheme
𝒰 : OpenCover X
U :
  Set
    ((CategoryTheory.forget TopCat).obj
      ↑(GlueData.glued (gluedCover 𝒰)).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace)
hU : ∀ (i : (gluedCover 𝒰).toGlueData.J), _root_.IsOpen (⇑(GlueData.ι (gluedCover 𝒰) i).val.base ⁻¹' U)
x : (CategoryTheory.forget TopCat).obj ↑X.toPresheafedSpace
hx : x ∈ ⇑(fromGlued 𝒰).val.base '' U
⊢ x ∈ ⇑(fromGlued 𝒰).val.base '' U ∩ Set.range ⇑(map 𝒰 (f 𝒰 x)).val.base

Next tactic:
exact ⟨hx, 𝒰.Covers x⟩
instance : Epi 𝒰.fromGlued.val.base := by
  

Proof state:
X : Scheme
𝒰 : OpenCover X
⊢ Epi (fromGlued 𝒰).val.base

Next tactic:
rw [TopCat.epi_iff_surjective]
instance : Epi 𝒰.fromGlued.val.base := by
  rw [TopCat.epi_iff_surjective]
  

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

Next tactic:
intro x
instance : Epi 𝒰.fromGlued.val.base := by
  rw [TopCat.epi_iff_surjective]
  intro x
  

Proof state:
X : Scheme
𝒰 : OpenCover X
x : (CategoryTheory.forget TopCat).obj ↑X.toPresheafedSpace
⊢ ∃ a, (fromGlued 𝒰).val.base a = x

Next tactic:
obtain ⟨y, h⟩ := 𝒰.Covers x
instance : Epi 𝒰.fromGlued.val.base := by
  rw [TopCat.epi_iff_surjective]
  intro x
  obtain ⟨y, h⟩ := 𝒰.Covers x
  

Proof state:
case intro
X : Scheme
𝒰 : OpenCover X
x : (CategoryTheory.forget TopCat).obj ↑X.toPresheafedSpace
y : (CategoryTheory.forget TopCat).obj ↑(obj 𝒰 (f 𝒰 x)).toPresheafedSpace
h : (map 𝒰 (f 𝒰 x)).val.base y = x
⊢ ∃ a, (fromGlued 𝒰).val.base a = x

Next tactic:
use (𝒰.gluedCover.ι (𝒰.f x)).1.base y
instance : Epi 𝒰.fromGlued.val.base := by
  rw [TopCat.epi_iff_surjective]
  intro x
  obtain ⟨y, h⟩ := 𝒰.Covers x
  use (𝒰.gluedCover.ι (𝒰.f x)).1.base y
  

Proof state:
case h
X : Scheme
𝒰 : OpenCover X
x : (CategoryTheory.forget TopCat).obj ↑X.toPresheafedSpace
y : (CategoryTheory.forget TopCat).obj ↑(obj 𝒰 (f 𝒰 x)).toPresheafedSpace
h : (map 𝒰 (f 𝒰 x)).val.base y = x
⊢ (fromGlued 𝒰).val.base ((GlueData.ι (gluedCover 𝒰) (f 𝒰 x)).val.base y) = x

Next tactic:
rw [← comp_apply]
instance : Epi 𝒰.fromGlued.val.base := by
  rw [TopCat.epi_iff_surjective]
  intro x
  obtain ⟨y, h⟩ := 𝒰.Covers x
  use (𝒰.gluedCover.ι (𝒰.f x)).1.base y
  rw [← comp_apply]
  

Proof state:
case h
X : Scheme
𝒰 : OpenCover X
x : (CategoryTheory.forget TopCat).obj ↑X.toPresheafedSpace
y : (CategoryTheory.forget TopCat).obj ↑(obj 𝒰 (f 𝒰 x)).toPresheafedSpace
h : (map 𝒰 (f 𝒰 x)).val.base y = x
⊢ ((GlueData.ι (gluedCover 𝒰) (f 𝒰 x)).val.base ≫ (fromGlued 𝒰).val.base) y = x

Next tactic:
rw [← 𝒰.ι_fromGlued (𝒰.f x)] at h
instance : Epi 𝒰.fromGlued.val.base := by
  rw [TopCat.epi_iff_surjective]
  intro x
  obtain ⟨y, h⟩ := 𝒰.Covers x
  use (𝒰.gluedCover.ι (𝒰.f x)).1.base y
  rw [← comp_apply]
  rw [← 𝒰.ι_fromGlued (𝒰.f x)] at h
  

Proof state:
case h
X : Scheme
𝒰 : OpenCover X
x : (CategoryTheory.forget TopCat).obj ↑X.toPresheafedSpace
y : (CategoryTheory.forget TopCat).obj ↑(obj 𝒰 (f 𝒰 x)).toPresheafedSpace
h : (GlueData.ι (gluedCover 𝒰) (f 𝒰 x) ≫ fromGlued 𝒰).val.base y = x
⊢ ((GlueData.ι (gluedCover 𝒰) (f 𝒰 x)).val.base ≫ (fromGlued 𝒰).val.base) y = x

Next tactic:
exact h
instance : IsIso 𝒰.fromGlued :=
  let F := Scheme.forgetToLocallyRingedSpace ⋙ LocallyRingedSpace.forgetToSheafedSpace ⋙
    SheafedSpace.forgetToPresheafedSpace
  have : IsIso (F.map (fromGlued 𝒰)) := by
    

Proof state:
X : Scheme
𝒰 : OpenCover X
F : Scheme ⥤ PresheafedSpace CommRingCat :=
  forgetToLocallyRingedSpace ⋙ LocallyRingedSpace.forgetToSheafedSpace ⋙ SheafedSpace.forgetToPresheafedSpace
⊢ IsIso (F.map (fromGlued 𝒰))

Next tactic:
change @IsIso (PresheafedSpace _) _ _ _ 𝒰.fromGlued.val
instance : IsIso 𝒰.fromGlued :=
  let F := Scheme.forgetToLocallyRingedSpace ⋙ LocallyRingedSpace.forgetToSheafedSpace ⋙
    SheafedSpace.forgetToPresheafedSpace
  have : IsIso (F.map (fromGlued 𝒰)) := by
    change @IsIso (PresheafedSpace _) _ _ _ 𝒰.fromGlued.val
    

Proof state:
X : Scheme
𝒰 : OpenCover X
F : Scheme ⥤ PresheafedSpace CommRingCat :=
  forgetToLocallyRingedSpace ⋙ LocallyRingedSpace.forgetToSheafedSpace ⋙ SheafedSpace.forgetToPresheafedSpace
⊢ IsIso (fromGlued 𝒰).val

Next tactic:
apply PresheafedSpace.IsOpenImmersion.to_iso
/-- Given an open cover of `X`, and a morphism `𝒰.obj x ⟶ Y` for each open subscheme in the cover,
such that these morphisms are compatible in the intersection (pullback), we may glue the morphisms
together into a morphism `X ⟶ Y`.

Note:
If `X` is exactly (defeq to) the gluing of `U i`, then using `Multicoequalizer.desc` suffices.
-/
def glueMorphisms {Y : Scheme} (f : ∀ x, 𝒰.obj x ⟶ Y)
    (hf : ∀ x y, (pullback.fst : pullback (𝒰.map x) (𝒰.map y) ⟶ _) ≫ f x = pullback.snd ≫ f y) :
    X ⟶ Y := by
  

Proof state:
X : Scheme
𝒰 : OpenCover X
Y : Scheme
f : (x : 𝒰.J) → obj 𝒰 x ⟶ Y
hf : ∀ (x y : 𝒰.J), pullback.fst ≫ f x = pullback.snd ≫ f y
⊢ X ⟶ Y

Next tactic:
refine' inv 𝒰.fromGlued ≫ _
/-- Given an open cover of `X`, and a morphism `𝒰.obj x ⟶ Y` for each open subscheme in the cover,
such that these morphisms are compatible in the intersection (pullback), we may glue the morphisms
together into a morphism `X ⟶ Y`.

Note:
If `X` is exactly (defeq to) the gluing of `U i`, then using `Multicoequalizer.desc` suffices.
-/
def glueMorphisms {Y : Scheme} (f : ∀ x, 𝒰.obj x ⟶ Y)
    (hf : ∀ x y, (pullback.fst : pullback (𝒰.map x) (𝒰.map y) ⟶ _) ≫ f x = pullback.snd ≫ f y) :
    X ⟶ Y := by
  refine' inv 𝒰.fromGlued ≫ _
  

Proof state:
X : Scheme
𝒰 : OpenCover X
Y : Scheme
f : (x : 𝒰.J) → obj 𝒰 x ⟶ Y
hf : ∀ (x y : 𝒰.J), pullback.fst ≫ f x = pullback.snd ≫ f y
⊢ GlueData.glued (gluedCover 𝒰) ⟶ Y

Next tactic:
fapply Multicoequalizer.desc
/-- Given an open cover of `X`, and a morphism `𝒰.obj x ⟶ Y` for each open subscheme in the cover,
such that these morphisms are compatible in the intersection (pullback), we may glue the morphisms
together into a morphism `X ⟶ Y`.

Note:
If `X` is exactly (defeq to) the gluing of `U i`, then using `Multicoequalizer.desc` suffices.
-/
def glueMorphisms {Y : Scheme} (f : ∀ x, 𝒰.obj x ⟶ Y)
    (hf : ∀ x y, (pullback.fst : pullback (𝒰.map x) (𝒰.map y) ⟶ _) ≫ f x = pullback.snd ≫ f y) :
    X ⟶ Y := by
  refine' inv 𝒰.fromGlued ≫ _
  fapply Multicoequalizer.desc
  

Proof state:
case k
X : Scheme
𝒰 : OpenCover X
Y : Scheme
f : (x : 𝒰.J) → obj 𝒰 x ⟶ Y
hf : ∀ (x y : 𝒰.J), pullback.fst ≫ f x = pullback.snd ≫ f y
⊢ (b : (diagram (gluedCover 𝒰).toGlueData).R) → MultispanIndex.right (diagram (gluedCover 𝒰).toGlueData) b ⟶ Y
case h
X : Scheme
𝒰 : OpenCover X
Y : Scheme
f : (x : 𝒰.J) → obj 𝒰 x ⟶ Y
hf : ∀ (x y : 𝒰.J), pullback.fst ≫ f x = pullback.snd ≫ f y
⊢ ∀ (a : (diagram (gluedCover 𝒰).toGlueData).L),
    MultispanIndex.fst (diagram (gluedCover 𝒰).toGlueData) a ≫
        ?k (MultispanIndex.fstFrom (diagram (gluedCover 𝒰).toGlueData) a) =
      MultispanIndex.snd (diagram (gluedCover 𝒰).toGlueData) a ≫
        ?k (MultispanIndex.sndFrom (diagram (gluedCover 𝒰).toGlueData) a)

Next tactic:
exact f