l3lab/ntp-mathlib huggingface dataset:
/-- The `fg` argument is to avoid nasty stuff about dependent types. -/
theorem app_eq_invApp_app_of_comp_eq {X Y U : Scheme} (f : Y ⟶ U) (g : U ⟶ X) (fg : Y ⟶ X)
    (H : fg = f ≫ g) [h : IsOpenImmersion g] (V : Opens U) :
    f.1.c.app (op V) =
      Scheme.Hom.invApp g _ ≫
        fg.1.c.app _ ≫
          Y.presheaf.map
            (eqToHom <| IsOpenImmersion.app_eq_inv_app_app_of_comp_eq_aux f g fg H V).op := by
  subst H
  rw [Scheme.comp_val_c_app, Category.assoc, Scheme.Hom.invApp,
    PresheafedSpace.IsOpenImmersion.invApp_app_assoc, f.val.c.naturality_assoc,
    TopCat.Presheaf.pushforwardObj_map, ← Functor.map_comp]
  convert (Category.comp_id <| f.1.c.app (op V)).symm
  

Proof state:
case h.e'_3.h.e'_7.h
C : Type u
inst✝ : Category.{v, u} C
X✝ Y✝ Z : Scheme
f✝ : X✝ ⟶ Z
g✝ : Y✝ ⟶ Z
H : IsOpenImmersion f✝
X Y U : Scheme
f : Y ⟶ U
g : U ⟶ X
h : IsOpenImmersion g
V : Opens ↑↑U.toPresheafedSpace
e_5✝ : Y.presheaf.obj (op ((Opens.map f.val.base).obj V)) = (f.val.base _* Y.presheaf).obj (op V)
⊢ Y.presheaf.map
      ((Opens.map f.val.base).op.map
          (eqToHom
            (_ :
              op V =
                op ((Opens.map g.val.base).obj (op ((PresheafedSpace.IsOpenImmersion.openFunctor h).obj V)).unop))) ≫
        (eqToHom
            (_ :
              (Opens.map f.val.base).obj V =
                (Opens.map (f ≫ g).val.base).obj ((Scheme.Hom.opensFunctor g).obj V))).op) =
    𝟙 ((f.val.base _* Y.presheaf).obj (op V))

Next tactic:
convert Y.presheaf.map_id _
theorem image_basicOpen {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f] {U : Opens X}
    (r : X.presheaf.obj (op U)) :
    f.opensFunctor.obj (X.basicOpen r) = Y.basicOpen (Scheme.Hom.invApp f U r) := by
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
U : Opens ↑↑X.toPresheafedSpace
r : ↑(X.presheaf.obj (op U))
⊢ (Hom.opensFunctor f).obj (X.basicOpen r) = Y.basicOpen ((Hom.invApp f U) r)

Next tactic:
have e := Scheme.preimage_basicOpen f (Scheme.Hom.invApp f U r)
theorem image_basicOpen {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f] {U : Opens X}
    (r : X.presheaf.obj (op U)) :
    f.opensFunctor.obj (X.basicOpen r) = Y.basicOpen (Scheme.Hom.invApp f U r) := by
  have e := Scheme.preimage_basicOpen f (Scheme.Hom.invApp f U r)
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
U : Opens ↑↑X.toPresheafedSpace
r : ↑(X.presheaf.obj (op U))
e :
  (Opens.map f.val.base).obj (Y.basicOpen ((Hom.invApp f U) r)) =
    X.basicOpen ((f.val.c.app (op ((Hom.opensFunctor f).obj U))) ((Hom.invApp f U) r))
⊢ (Hom.opensFunctor f).obj (X.basicOpen r) = Y.basicOpen ((Hom.invApp f U) r)

Next tactic:
rw [Scheme.Hom.invApp] at e
theorem image_basicOpen {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f] {U : Opens X}
    (r : X.presheaf.obj (op U)) :
    f.opensFunctor.obj (X.basicOpen r) = Y.basicOpen (Scheme.Hom.invApp f U r) := by
  have e := Scheme.preimage_basicOpen f (Scheme.Hom.invApp f U r)
  rw [Scheme.Hom.invApp] at e
  -- Porting note : was `rw`
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
U : Opens ↑↑X.toPresheafedSpace
r : ↑(X.presheaf.obj (op U))
e :
  (Opens.map f.val.base).obj (Y.basicOpen ((PresheafedSpace.IsOpenImmersion.invApp H U) r)) =
    X.basicOpen ((f.val.c.app (op ((Hom.opensFunctor f).obj U))) ((PresheafedSpace.IsOpenImmersion.invApp H U) r))
⊢ (Hom.opensFunctor f).obj (X.basicOpen r) = Y.basicOpen ((Hom.invApp f U) r)

Next tactic:
erw [PresheafedSpace.IsOpenImmersion.invApp_app_apply] at e
theorem image_basicOpen {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f] {U : Opens X}
    (r : X.presheaf.obj (op U)) :
    f.opensFunctor.obj (X.basicOpen r) = Y.basicOpen (Scheme.Hom.invApp f U r) := by
  have e := Scheme.preimage_basicOpen f (Scheme.Hom.invApp f U r)
  rw [Scheme.Hom.invApp] at e
  -- Porting note : was `rw`
  erw [PresheafedSpace.IsOpenImmersion.invApp_app_apply] at e
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
U : Opens ↑↑X.toPresheafedSpace
r : ↑(X.presheaf.obj (op U))
e :
  (Opens.map f.val.base).obj (Y.basicOpen ((PresheafedSpace.IsOpenImmersion.invApp H U) r)) =
    X.basicOpen
      ((X.presheaf.map
          (eqToHom
            (_ :
              op U =
                op ((Opens.map f.val.base).obj (op ((PresheafedSpace.IsOpenImmersion.openFunctor H).obj U)).unop))))
        r)
⊢ (Hom.opensFunctor f).obj (X.basicOpen r) = Y.basicOpen ((Hom.invApp f U) r)

Next tactic:
rw [Scheme.basicOpen_res, inf_eq_right.mpr _] at e
theorem image_basicOpen {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f] {U : Opens X}
    (r : X.presheaf.obj (op U)) :
    f.opensFunctor.obj (X.basicOpen r) = Y.basicOpen (Scheme.Hom.invApp f U r) := by
  have e := Scheme.preimage_basicOpen f (Scheme.Hom.invApp f U r)
  rw [Scheme.Hom.invApp] at e
  -- Porting note : was `rw`
  erw [PresheafedSpace.IsOpenImmersion.invApp_app_apply] at e
  rw [Scheme.basicOpen_res, inf_eq_right.mpr _] at e
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
U : Opens ↑↑X.toPresheafedSpace
r : ↑(X.presheaf.obj (op U))
e : (Opens.map f.val.base).obj (Y.basicOpen ((PresheafedSpace.IsOpenImmersion.invApp H U) r)) = X.basicOpen r
⊢ (Hom.opensFunctor f).obj (X.basicOpen r) = Y.basicOpen ((Hom.invApp f U) r)
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
U : Opens ↑↑X.toPresheafedSpace
r : ↑(X.presheaf.obj (op U))
e :
  (Opens.map f.val.base).obj (Y.basicOpen ((PresheafedSpace.IsOpenImmersion.invApp H U) r)) =
    (Opens.map f.val.base).obj ((Hom.opensFunctor f).obj U) ⊓ X.basicOpen r
⊢ X.basicOpen r ≤ (Opens.map f.val.base).obj ((Hom.opensFunctor f).obj U)

Next tactic:
rw [← e]
theorem image_basicOpen {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f] {U : Opens X}
    (r : X.presheaf.obj (op U)) :
    f.opensFunctor.obj (X.basicOpen r) = Y.basicOpen (Scheme.Hom.invApp f U r) := by
  have e := Scheme.preimage_basicOpen f (Scheme.Hom.invApp f U r)
  rw [Scheme.Hom.invApp] at e
  -- Porting note : was `rw`
  erw [PresheafedSpace.IsOpenImmersion.invApp_app_apply] at e
  rw [Scheme.basicOpen_res, inf_eq_right.mpr _] at e
  rw [← e]
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
U : Opens ↑↑X.toPresheafedSpace
r : ↑(X.presheaf.obj (op U))
e : (Opens.map f.val.base).obj (Y.basicOpen ((PresheafedSpace.IsOpenImmersion.invApp H U) r)) = X.basicOpen r
⊢ (Hom.opensFunctor f).obj ((Opens.map f.val.base).obj (Y.basicOpen ((PresheafedSpace.IsOpenImmersion.invApp H U) r))) =
    Y.basicOpen ((Hom.invApp f U) r)
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
U : Opens ↑↑X.toPresheafedSpace
r : ↑(X.presheaf.obj (op U))
e :
  (Opens.map f.val.base).obj (Y.basicOpen ((PresheafedSpace.IsOpenImmersion.invApp H U) r)) =
    (Opens.map f.val.base).obj ((Hom.opensFunctor f).obj U) ⊓ X.basicOpen r
⊢ X.basicOpen r ≤ (Opens.map f.val.base).obj ((Hom.opensFunctor f).obj U)

Next tactic:
ext1
theorem image_basicOpen {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f] {U : Opens X}
    (r : X.presheaf.obj (op U)) :
    f.opensFunctor.obj (X.basicOpen r) = Y.basicOpen (Scheme.Hom.invApp f U r) := by
  have e := Scheme.preimage_basicOpen f (Scheme.Hom.invApp f U r)
  rw [Scheme.Hom.invApp] at e
  -- Porting note : was `rw`
  erw [PresheafedSpace.IsOpenImmersion.invApp_app_apply] at e
  rw [Scheme.basicOpen_res, inf_eq_right.mpr _] at e
  rw [← e]
  ext1
  -- Porting note : this `dsimp` was not necessary
  

Proof state:
case h
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
U : Opens ↑↑X.toPresheafedSpace
r : ↑(X.presheaf.obj (op U))
e : (Opens.map f.val.base).obj (Y.basicOpen ((PresheafedSpace.IsOpenImmersion.invApp H U) r)) = X.basicOpen r
⊢ ↑((Hom.opensFunctor f).obj
        ((Opens.map f.val.base).obj (Y.basicOpen ((PresheafedSpace.IsOpenImmersion.invApp H U) r)))) =
    ↑(Y.basicOpen ((Hom.invApp f U) r))
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
U : Opens ↑↑X.toPresheafedSpace
r : ↑(X.presheaf.obj (op U))
e :
  (Opens.map f.val.base).obj (Y.basicOpen ((PresheafedSpace.IsOpenImmersion.invApp H U) r)) =
    (Opens.map f.val.base).obj ((Hom.opensFunctor f).obj U) ⊓ X.basicOpen r
⊢ X.basicOpen r ≤ (Opens.map f.val.base).obj ((Hom.opensFunctor f).obj U)

Next tactic:
dsimp [Opens.map]
theorem image_basicOpen {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f] {U : Opens X}
    (r : X.presheaf.obj (op U)) :
    f.opensFunctor.obj (X.basicOpen r) = Y.basicOpen (Scheme.Hom.invApp f U r) := by
  have e := Scheme.preimage_basicOpen f (Scheme.Hom.invApp f U r)
  rw [Scheme.Hom.invApp] at e
  -- Porting note : was `rw`
  erw [PresheafedSpace.IsOpenImmersion.invApp_app_apply] at e
  rw [Scheme.basicOpen_res, inf_eq_right.mpr _] at e
  rw [← e]
  ext1
  -- Porting note : this `dsimp` was not necessary
  dsimp [Opens.map]
  

Proof state:
case h
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
U : Opens ↑↑X.toPresheafedSpace
r : ↑(X.presheaf.obj (op U))
e : (Opens.map f.val.base).obj (Y.basicOpen ((PresheafedSpace.IsOpenImmersion.invApp H U) r)) = X.basicOpen r
⊢ ⇑f.val.base '' (⇑f.val.base ⁻¹' ↑(Y.basicOpen ((PresheafedSpace.IsOpenImmersion.invApp H U) r))) =
    ↑(Y.basicOpen ((Hom.invApp f U) r))
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
U : Opens ↑↑X.toPresheafedSpace
r : ↑(X.presheaf.obj (op U))
e :
  (Opens.map f.val.base).obj (Y.basicOpen ((PresheafedSpace.IsOpenImmersion.invApp H U) r)) =
    (Opens.map f.val.base).obj ((Hom.opensFunctor f).obj U) ⊓ X.basicOpen r
⊢ X.basicOpen r ≤ (Opens.map f.val.base).obj ((Hom.opensFunctor f).obj U)

Next tactic:
refine' Set.image_preimage_eq_inter_range.trans _
theorem image_basicOpen {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f] {U : Opens X}
    (r : X.presheaf.obj (op U)) :
    f.opensFunctor.obj (X.basicOpen r) = Y.basicOpen (Scheme.Hom.invApp f U r) := by
  have e := Scheme.preimage_basicOpen f (Scheme.Hom.invApp f U r)
  rw [Scheme.Hom.invApp] at e
  -- Porting note : was `rw`
  erw [PresheafedSpace.IsOpenImmersion.invApp_app_apply] at e
  rw [Scheme.basicOpen_res, inf_eq_right.mpr _] at e
  rw [← e]
  ext1
  -- Porting note : this `dsimp` was not necessary
  dsimp [Opens.map]
  refine' Set.image_preimage_eq_inter_range.trans _
  

Proof state:
case h
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
U : Opens ↑↑X.toPresheafedSpace
r : ↑(X.presheaf.obj (op U))
e : (Opens.map f.val.base).obj (Y.basicOpen ((PresheafedSpace.IsOpenImmersion.invApp H U) r)) = X.basicOpen r
⊢ ↑(Y.basicOpen ((PresheafedSpace.IsOpenImmersion.invApp H U) r)) ∩ Set.range ⇑f.val.base =
    ↑(Y.basicOpen ((Hom.invApp f U) r))
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
U : Opens ↑↑X.toPresheafedSpace
r : ↑(X.presheaf.obj (op U))
e :
  (Opens.map f.val.base).obj (Y.basicOpen ((PresheafedSpace.IsOpenImmersion.invApp H U) r)) =
    (Opens.map f.val.base).obj ((Hom.opensFunctor f).obj U) ⊓ X.basicOpen r
⊢ X.basicOpen r ≤ (Opens.map f.val.base).obj ((Hom.opensFunctor f).obj U)

Next tactic:
erw [Set.inter_eq_left]
theorem image_basicOpen {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f] {U : Opens X}
    (r : X.presheaf.obj (op U)) :
    f.opensFunctor.obj (X.basicOpen r) = Y.basicOpen (Scheme.Hom.invApp f U r) := by
  have e := Scheme.preimage_basicOpen f (Scheme.Hom.invApp f U r)
  rw [Scheme.Hom.invApp] at e
  -- Porting note : was `rw`
  erw [PresheafedSpace.IsOpenImmersion.invApp_app_apply] at e
  rw [Scheme.basicOpen_res, inf_eq_right.mpr _] at e
  rw [← e]
  ext1
  -- Porting note : this `dsimp` was not necessary
  dsimp [Opens.map]
  refine' Set.image_preimage_eq_inter_range.trans _
  erw [Set.inter_eq_left]
  

Proof state:
case h
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
U : Opens ↑↑X.toPresheafedSpace
r : ↑(X.presheaf.obj (op U))
e : (Opens.map f.val.base).obj (Y.basicOpen ((PresheafedSpace.IsOpenImmersion.invApp H U) r)) = X.basicOpen r
⊢ ↑(Y.basicOpen ((PresheafedSpace.IsOpenImmersion.invApp H U) r)) ⊆ Set.range ⇑f.val.base
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
U : Opens ↑↑X.toPresheafedSpace
r : ↑(X.presheaf.obj (op U))
e :
  (Opens.map f.val.base).obj (Y.basicOpen ((PresheafedSpace.IsOpenImmersion.invApp H U) r)) =
    (Opens.map f.val.base).obj ((Hom.opensFunctor f).obj U) ⊓ X.basicOpen r
⊢ X.basicOpen r ≤ (Opens.map f.val.base).obj ((Hom.opensFunctor f).obj U)

Next tactic:
refine' Set.Subset.trans (Scheme.basicOpen_le _ _) (Set.image_subset_range _ _)
theorem image_basicOpen {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f] {U : Opens X}
    (r : X.presheaf.obj (op U)) :
    f.opensFunctor.obj (X.basicOpen r) = Y.basicOpen (Scheme.Hom.invApp f U r) := by
  have e := Scheme.preimage_basicOpen f (Scheme.Hom.invApp f U r)
  rw [Scheme.Hom.invApp] at e
  -- Porting note : was `rw`
  erw [PresheafedSpace.IsOpenImmersion.invApp_app_apply] at e
  rw [Scheme.basicOpen_res, inf_eq_right.mpr _] at e
  rw [← e]
  ext1
  -- Porting note : this `dsimp` was not necessary
  dsimp [Opens.map]
  refine' Set.image_preimage_eq_inter_range.trans _
  erw [Set.inter_eq_left]
  refine' Set.Subset.trans (Scheme.basicOpen_le _ _) (Set.image_subset_range _ _)
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
U : Opens ↑↑X.toPresheafedSpace
r : ↑(X.presheaf.obj (op U))
e :
  (Opens.map f.val.base).obj (Y.basicOpen ((PresheafedSpace.IsOpenImmersion.invApp H U) r)) =
    (Opens.map f.val.base).obj ((Hom.opensFunctor f).obj U) ⊓ X.basicOpen r
⊢ X.basicOpen r ≤ (Opens.map f.val.base).obj ((Hom.opensFunctor f).obj U)

Next tactic:
refine' le_trans (Scheme.basicOpen_le _ _) (le_of_eq _)
theorem image_basicOpen {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f] {U : Opens X}
    (r : X.presheaf.obj (op U)) :
    f.opensFunctor.obj (X.basicOpen r) = Y.basicOpen (Scheme.Hom.invApp f U r) := by
  have e := Scheme.preimage_basicOpen f (Scheme.Hom.invApp f U r)
  rw [Scheme.Hom.invApp] at e
  -- Porting note : was `rw`
  erw [PresheafedSpace.IsOpenImmersion.invApp_app_apply] at e
  rw [Scheme.basicOpen_res, inf_eq_right.mpr _] at e
  rw [← e]
  ext1
  -- Porting note : this `dsimp` was not necessary
  dsimp [Opens.map]
  refine' Set.image_preimage_eq_inter_range.trans _
  erw [Set.inter_eq_left]
  refine' Set.Subset.trans (Scheme.basicOpen_le _ _) (Set.image_subset_range _ _)
  refine' le_trans (Scheme.basicOpen_le _ _) (le_of_eq _)
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
U : Opens ↑↑X.toPresheafedSpace
r : ↑(X.presheaf.obj (op U))
e :
  (Opens.map f.val.base).obj (Y.basicOpen ((PresheafedSpace.IsOpenImmersion.invApp H U) r)) =
    (Opens.map f.val.base).obj ((Hom.opensFunctor f).obj U) ⊓ X.basicOpen r
⊢ U = (Opens.map f.val.base).obj ((Hom.opensFunctor f).obj U)

Next tactic:
ext1
theorem image_basicOpen {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f] {U : Opens X}
    (r : X.presheaf.obj (op U)) :
    f.opensFunctor.obj (X.basicOpen r) = Y.basicOpen (Scheme.Hom.invApp f U r) := by
  have e := Scheme.preimage_basicOpen f (Scheme.Hom.invApp f U r)
  rw [Scheme.Hom.invApp] at e
  -- Porting note : was `rw`
  erw [PresheafedSpace.IsOpenImmersion.invApp_app_apply] at e
  rw [Scheme.basicOpen_res, inf_eq_right.mpr _] at e
  rw [← e]
  ext1
  -- Porting note : this `dsimp` was not necessary
  dsimp [Opens.map]
  refine' Set.image_preimage_eq_inter_range.trans _
  erw [Set.inter_eq_left]
  refine' Set.Subset.trans (Scheme.basicOpen_le _ _) (Set.image_subset_range _ _)
  refine' le_trans (Scheme.basicOpen_le _ _) (le_of_eq _)
  ext1
  

Proof state:
case h
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
U : Opens ↑↑X.toPresheafedSpace
r : ↑(X.presheaf.obj (op U))
e :
  (Opens.map f.val.base).obj (Y.basicOpen ((PresheafedSpace.IsOpenImmersion.invApp H U) r)) =
    (Opens.map f.val.base).obj ((Hom.opensFunctor f).obj U) ⊓ X.basicOpen r
⊢ ↑U = ↑((Opens.map f.val.base).obj ((Hom.opensFunctor f).obj U))

Next tactic:
exact (Set.preimage_image_eq _ H.base_open.inj).symm
/-- Given an open cover on `X`, we may pull them back along a morphism `W ⟶ X` to obtain
an open cover of `W`. -/
@[simps]
def Scheme.OpenCover.pullbackCover {X : Scheme} (𝒰 : X.OpenCover) {W : Scheme} (f : W ⟶ X) :
    W.OpenCover where
  J := 𝒰.J
  obj x := pullback f (𝒰.map x)
  map x := pullback.fst
  f x := 𝒰.f (f.1.base x)
  Covers x := by
    

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X : Scheme
𝒰 : OpenCover X
W : Scheme
f : W ⟶ X
x : ↑↑W.toPresheafedSpace
⊢ x ∈ Set.range ⇑((fun x => pullback.fst) ((fun x => AlgebraicGeometry.Scheme.OpenCover.f 𝒰 (f.val.base x)) x)).val.base

Next tactic:
rw [←
      show _ = (pullback.fst : pullback f (𝒰.map (𝒰.f (f.1.base x))) ⟶ _).1.base from
        PreservesPullback.iso_hom_fst Scheme.forgetToTop f (𝒰.map (𝒰.f (f.1.base x)))]
/-- Given an open cover on `X`, we may pull them back along a morphism `W ⟶ X` to obtain
an open cover of `W`. -/
@[simps]
def Scheme.OpenCover.pullbackCover {X : Scheme} (𝒰 : X.OpenCover) {W : Scheme} (f : W ⟶ X) :
    W.OpenCover where
  J := 𝒰.J
  obj x := pullback f (𝒰.map x)
  map x := pullback.fst
  f x := 𝒰.f (f.1.base x)
  Covers x := by
    rw [←
      show _ = (pullback.fst : pullback f (𝒰.map (𝒰.f (f.1.base x))) ⟶ _).1.base from
        PreservesPullback.iso_hom_fst Scheme.forgetToTop f (𝒰.map (𝒰.f (f.1.base x)))]
    -- Porting note : `rw` to `erw` on this single lemma
    

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X : Scheme
𝒰 : OpenCover X
W : Scheme
f : W ⟶ X
x : ↑↑W.toPresheafedSpace
⊢ x ∈
    Set.range
      ⇑((PreservesPullback.iso forgetToTop f (map 𝒰 (AlgebraicGeometry.Scheme.OpenCover.f 𝒰 (f.val.base x)))).hom ≫
          pullback.fst)

Next tactic:
erw [coe_comp]
/-- Given an open cover on `X`, we may pull them back along a morphism `W ⟶ X` to obtain
an open cover of `W`. -/
@[simps]
def Scheme.OpenCover.pullbackCover {X : Scheme} (𝒰 : X.OpenCover) {W : Scheme} (f : W ⟶ X) :
    W.OpenCover where
  J := 𝒰.J
  obj x := pullback f (𝒰.map x)
  map x := pullback.fst
  f x := 𝒰.f (f.1.base x)
  Covers x := by
    rw [←
      show _ = (pullback.fst : pullback f (𝒰.map (𝒰.f (f.1.base x))) ⟶ _).1.base from
        PreservesPullback.iso_hom_fst Scheme.forgetToTop f (𝒰.map (𝒰.f (f.1.base x)))]
    -- Porting note : `rw` to `erw` on this single lemma
    erw [coe_comp]
    

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X : Scheme
𝒰 : OpenCover X
W : Scheme
f : W ⟶ X
x : ↑↑W.toPresheafedSpace
⊢ x ∈
    Set.range
      (⇑pullback.fst ∘
        ⇑(PreservesPullback.iso forgetToTop f (map 𝒰 (AlgebraicGeometry.Scheme.OpenCover.f 𝒰 (f.val.base x)))).hom)

Next tactic:
rw [Set.range_comp, Set.range_iff_surjective.mpr, Set.image_univ,
      TopCat.pullback_fst_range]
/-- Given an open cover on `X`, we may pull them back along a morphism `W ⟶ X` to obtain
an open cover of `W`. -/
@[simps]
def Scheme.OpenCover.pullbackCover {X : Scheme} (𝒰 : X.OpenCover) {W : Scheme} (f : W ⟶ X) :
    W.OpenCover where
  J := 𝒰.J
  obj x := pullback f (𝒰.map x)
  map x := pullback.fst
  f x := 𝒰.f (f.1.base x)
  Covers x := by
    rw [←
      show _ = (pullback.fst : pullback f (𝒰.map (𝒰.f (f.1.base x))) ⟶ _).1.base from
        PreservesPullback.iso_hom_fst Scheme.forgetToTop f (𝒰.map (𝒰.f (f.1.base x)))]
    -- Porting note : `rw` to `erw` on this single lemma
    erw [coe_comp]
    rw [Set.range_comp, Set.range_iff_surjective.mpr, Set.image_univ,
      TopCat.pullback_fst_range]
    

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X : Scheme
𝒰 : OpenCover X
W : Scheme
f : W ⟶ X
x : ↑↑W.toPresheafedSpace
⊢ x ∈
    {x_1 |
      ∃ y,
        (forgetToTop.map f) x_1 = (forgetToTop.map (map 𝒰 (AlgebraicGeometry.Scheme.OpenCover.f 𝒰 (f.val.base x)))) y}
C : Type u
inst✝ : Category.{v, u} C
X : Scheme
𝒰 : OpenCover X
W : Scheme
f : W ⟶ X
x : ↑↑W.toPresheafedSpace
⊢ Function.Surjective
    ⇑(PreservesPullback.iso forgetToTop f (map 𝒰 (AlgebraicGeometry.Scheme.OpenCover.f 𝒰 (f.val.base x)))).hom

Next tactic:
obtain ⟨y, h⟩ := 𝒰.Covers (f.1.base x)
/-- Given an open cover on `X`, we may pull them back along a morphism `W ⟶ X` to obtain
an open cover of `W`. -/
@[simps]
def Scheme.OpenCover.pullbackCover {X : Scheme} (𝒰 : X.OpenCover) {W : Scheme} (f : W ⟶ X) :
    W.OpenCover where
  J := 𝒰.J
  obj x := pullback f (𝒰.map x)
  map x := pullback.fst
  f x := 𝒰.f (f.1.base x)
  Covers x := by
    rw [←
      show _ = (pullback.fst : pullback f (𝒰.map (𝒰.f (f.1.base x))) ⟶ _).1.base from
        PreservesPullback.iso_hom_fst Scheme.forgetToTop f (𝒰.map (𝒰.f (f.1.base x)))]
    -- Porting note : `rw` to `erw` on this single lemma
    erw [coe_comp]
    rw [Set.range_comp, Set.range_iff_surjective.mpr, Set.image_univ,
      TopCat.pullback_fst_range]
    obtain ⟨y, h⟩ := 𝒰.Covers (f.1.base x)
    

Proof state:
case intro
C : Type u
inst✝ : Category.{v, u} C
X : Scheme
𝒰 : OpenCover X
W : Scheme
f : W ⟶ X
x : ↑↑W.toPresheafedSpace
y : (forget TopCat).obj ↑(obj 𝒰 (AlgebraicGeometry.Scheme.OpenCover.f 𝒰 (f.val.base x))).toPresheafedSpace
h : (map 𝒰 (AlgebraicGeometry.Scheme.OpenCover.f 𝒰 (f.val.base x))).val.base y = f.val.base x
⊢ x ∈
    {x_1 |
      ∃ y,
        (forgetToTop.map f) x_1 = (forgetToTop.map (map 𝒰 (AlgebraicGeometry.Scheme.OpenCover.f 𝒰 (f.val.base x)))) y}
C : Type u
inst✝ : Category.{v, u} C
X : Scheme
𝒰 : OpenCover X
W : Scheme
f : W ⟶ X
x : ↑↑W.toPresheafedSpace
⊢ Function.Surjective
    ⇑(PreservesPullback.iso forgetToTop f (map 𝒰 (AlgebraicGeometry.Scheme.OpenCover.f 𝒰 (f.val.base x)))).hom

Next tactic:
exact ⟨y, h.symm⟩
/-- Given an open cover on `X`, we may pull them back along a morphism `W ⟶ X` to obtain
an open cover of `W`. -/
@[simps]
def Scheme.OpenCover.pullbackCover {X : Scheme} (𝒰 : X.OpenCover) {W : Scheme} (f : W ⟶ X) :
    W.OpenCover where
  J := 𝒰.J
  obj x := pullback f (𝒰.map x)
  map x := pullback.fst
  f x := 𝒰.f (f.1.base x)
  Covers x := by
    rw [←
      show _ = (pullback.fst : pullback f (𝒰.map (𝒰.f (f.1.base x))) ⟶ _).1.base from
        PreservesPullback.iso_hom_fst Scheme.forgetToTop f (𝒰.map (𝒰.f (f.1.base x)))]
    -- Porting note : `rw` to `erw` on this single lemma
    erw [coe_comp]
    rw [Set.range_comp, Set.range_iff_surjective.mpr, Set.image_univ,
      TopCat.pullback_fst_range]
    obtain ⟨y, h⟩ := 𝒰.Covers (f.1.base x)
    exact ⟨y, h.symm⟩
    · 

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X : Scheme
𝒰 : OpenCover X
W : Scheme
f : W ⟶ X
x : ↑↑W.toPresheafedSpace
⊢ Function.Surjective
    ⇑(PreservesPullback.iso forgetToTop f (map 𝒰 (AlgebraicGeometry.Scheme.OpenCover.f 𝒰 (f.val.base x)))).hom

Next tactic:
rw [← TopCat.epi_iff_surjective]
/-- Given an open cover on `X`, we may pull them back along a morphism `W ⟶ X` to obtain
an open cover of `W`. -/
@[simps]
def Scheme.OpenCover.pullbackCover {X : Scheme} (𝒰 : X.OpenCover) {W : Scheme} (f : W ⟶ X) :
    W.OpenCover where
  J := 𝒰.J
  obj x := pullback f (𝒰.map x)
  map x := pullback.fst
  f x := 𝒰.f (f.1.base x)
  Covers x := by
    rw [←
      show _ = (pullback.fst : pullback f (𝒰.map (𝒰.f (f.1.base x))) ⟶ _).1.base from
        PreservesPullback.iso_hom_fst Scheme.forgetToTop f (𝒰.map (𝒰.f (f.1.base x)))]
    -- Porting note : `rw` to `erw` on this single lemma
    erw [coe_comp]
    rw [Set.range_comp, Set.range_iff_surjective.mpr, Set.image_univ,
      TopCat.pullback_fst_range]
    obtain ⟨y, h⟩ := 𝒰.Covers (f.1.base x)
    exact ⟨y, h.symm⟩
    · rw [← TopCat.epi_iff_surjective]; 

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X : Scheme
𝒰 : OpenCover X
W : Scheme
f : W ⟶ X
x : ↑↑W.toPresheafedSpace
⊢ Epi (PreservesPullback.iso forgetToTop f (map 𝒰 (AlgebraicGeometry.Scheme.OpenCover.f 𝒰 (f.val.base x)))).hom

Next tactic:
infer_instance