l3lab/ntp-mathlib huggingface dataset:
theorem image_morphismRestrict_preimage {X Y : Scheme} (f : X ⟶ Y) (U : Opens Y) (V : Opens U) :
    (f ⁻¹ᵁ U).openEmbedding.isOpenMap.functor.obj ((f ∣_ U) ⁻¹ᵁ V) =
      f ⁻¹ᵁ (U.openEmbedding.isOpenMap.functor.obj V) := by
  ext1
  ext x
  constructor
  · rintro ⟨⟨x, hx⟩, hx' : (f ∣_ U).1.base _ ∈ V, rfl⟩
    refine' ⟨⟨_, hx⟩, _, rfl⟩
    -- Porting note : this rewrite was not necessary
    rw [SetLike.mem_coe]
    convert hx'
    -- Porting note : `ext1` is not compiling
    refine Subtype.ext ?_
    

Proof state:
case h.e'_4.h
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
U : Opens ↑↑Y.toPresheafedSpace
V : Opens ↥U
x : ↑↑X.toPresheafedSpace
hx : x ∈ f⁻¹ᵁ U
hx' : (f ∣_ U).val.base { val := x, property := hx } ∈ V
e_1✝ :
  (forget TopCat).obj ((Opens.toTopCat ↑Y.toPresheafedSpace).obj U) =
    (forget TopCat).obj ↑(Y ∣_ᵤ U).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace
⊢ ↑{ val := f.val.base x, property := hx } = ↑((f ∣_ U).val.base { val := x, property := hx })

Next tactic:
exact (morphismRestrict_base_coe f U ⟨x, hx⟩).symm
theorem image_morphismRestrict_preimage {X Y : Scheme} (f : X ⟶ Y) (U : Opens Y) (V : Opens U) :
    (f ⁻¹ᵁ U).openEmbedding.isOpenMap.functor.obj ((f ∣_ U) ⁻¹ᵁ V) =
      f ⁻¹ᵁ (U.openEmbedding.isOpenMap.functor.obj V) := by
  ext1
  ext x
  constructor
  · rintro ⟨⟨x, hx⟩, hx' : (f ∣_ U).1.base _ ∈ V, rfl⟩
    refine' ⟨⟨_, hx⟩, _, rfl⟩
    -- Porting note : this rewrite was not necessary
    rw [SetLike.mem_coe]
    convert hx'
    -- Porting note : `ext1` is not compiling
    refine Subtype.ext ?_
    exact (morphismRestrict_base_coe f U ⟨x, hx⟩).symm
  · 

Proof state:
case h.h.mpr
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
U : Opens ↑↑Y.toPresheafedSpace
V : Opens ↥U
x : ↑↑X.toPresheafedSpace
⊢ x ∈ ↑(f⁻¹ᵁ (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V) →
    x ∈ ↑((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion (f⁻¹ᵁ U)))).obj ((f ∣_ U)⁻¹ᵁ V))

Next tactic:
rintro ⟨⟨x, hx⟩, hx' : _ ∈ V.1, rfl : x = _⟩
theorem image_morphismRestrict_preimage {X Y : Scheme} (f : X ⟶ Y) (U : Opens Y) (V : Opens U) :
    (f ⁻¹ᵁ U).openEmbedding.isOpenMap.functor.obj ((f ∣_ U) ⁻¹ᵁ V) =
      f ⁻¹ᵁ (U.openEmbedding.isOpenMap.functor.obj V) := by
  ext1
  ext x
  constructor
  · rintro ⟨⟨x, hx⟩, hx' : (f ∣_ U).1.base _ ∈ V, rfl⟩
    refine' ⟨⟨_, hx⟩, _, rfl⟩
    -- Porting note : this rewrite was not necessary
    rw [SetLike.mem_coe]
    convert hx'
    -- Porting note : `ext1` is not compiling
    refine Subtype.ext ?_
    exact (morphismRestrict_base_coe f U ⟨x, hx⟩).symm
  · rintro ⟨⟨x, hx⟩, hx' : _ ∈ V.1, rfl : x = _⟩
    

Proof state:
case h.h.mpr.intro.mk.intro
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
U : Opens ↑↑Y.toPresheafedSpace
V : Opens ↥U
x : ↑↑X.toPresheafedSpace
hx : f.val.base x ∈ U
hx' : { val := f.val.base x, property := hx } ∈ V.carrier
⊢ x ∈ ↑((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion (f⁻¹ᵁ U)))).obj ((f ∣_ U)⁻¹ᵁ V))

Next tactic:
refine' ⟨⟨_, hx⟩, (_ : (f ∣_ U).1.base ⟨x, hx⟩ ∈ V.1), rfl⟩
theorem image_morphismRestrict_preimage {X Y : Scheme} (f : X ⟶ Y) (U : Opens Y) (V : Opens U) :
    (f ⁻¹ᵁ U).openEmbedding.isOpenMap.functor.obj ((f ∣_ U) ⁻¹ᵁ V) =
      f ⁻¹ᵁ (U.openEmbedding.isOpenMap.functor.obj V) := by
  ext1
  ext x
  constructor
  · rintro ⟨⟨x, hx⟩, hx' : (f ∣_ U).1.base _ ∈ V, rfl⟩
    refine' ⟨⟨_, hx⟩, _, rfl⟩
    -- Porting note : this rewrite was not necessary
    rw [SetLike.mem_coe]
    convert hx'
    -- Porting note : `ext1` is not compiling
    refine Subtype.ext ?_
    exact (morphismRestrict_base_coe f U ⟨x, hx⟩).symm
  · rintro ⟨⟨x, hx⟩, hx' : _ ∈ V.1, rfl : x = _⟩
    refine' ⟨⟨_, hx⟩, (_ : (f ∣_ U).1.base ⟨x, hx⟩ ∈ V.1), rfl⟩
    

Proof state:
case h.h.mpr.intro.mk.intro
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
U : Opens ↑↑Y.toPresheafedSpace
V : Opens ↥U
x : ↑↑X.toPresheafedSpace
hx : f.val.base x ∈ U
hx' : { val := f.val.base x, property := hx } ∈ V.carrier
⊢ (f ∣_ U).val.base { val := x, property := hx } ∈ V.carrier

Next tactic:
convert hx'
theorem image_morphismRestrict_preimage {X Y : Scheme} (f : X ⟶ Y) (U : Opens Y) (V : Opens U) :
    (f ⁻¹ᵁ U).openEmbedding.isOpenMap.functor.obj ((f ∣_ U) ⁻¹ᵁ V) =
      f ⁻¹ᵁ (U.openEmbedding.isOpenMap.functor.obj V) := by
  ext1
  ext x
  constructor
  · rintro ⟨⟨x, hx⟩, hx' : (f ∣_ U).1.base _ ∈ V, rfl⟩
    refine' ⟨⟨_, hx⟩, _, rfl⟩
    -- Porting note : this rewrite was not necessary
    rw [SetLike.mem_coe]
    convert hx'
    -- Porting note : `ext1` is not compiling
    refine Subtype.ext ?_
    exact (morphismRestrict_base_coe f U ⟨x, hx⟩).symm
  · rintro ⟨⟨x, hx⟩, hx' : _ ∈ V.1, rfl : x = _⟩
    refine' ⟨⟨_, hx⟩, (_ : (f ∣_ U).1.base ⟨x, hx⟩ ∈ V.1), rfl⟩
    convert hx'
    -- Porting note : `ext1` is compiling
    

Proof state:
case h.e'_4.h
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
U : Opens ↑↑Y.toPresheafedSpace
V : Opens ↥U
x : ↑↑X.toPresheafedSpace
hx : f.val.base x ∈ U
hx' : { val := f.val.base x, property := hx } ∈ V.carrier
e_1✝ : (forget TopCat).obj ↑(Y ∣_ᵤ U).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace = ↥U
⊢ (f ∣_ U).val.base { val := x, property := hx } = { val := f.val.base x, property := hx }

Next tactic:
refine Subtype.ext ?_
theorem image_morphismRestrict_preimage {X Y : Scheme} (f : X ⟶ Y) (U : Opens Y) (V : Opens U) :
    (f ⁻¹ᵁ U).openEmbedding.isOpenMap.functor.obj ((f ∣_ U) ⁻¹ᵁ V) =
      f ⁻¹ᵁ (U.openEmbedding.isOpenMap.functor.obj V) := by
  ext1
  ext x
  constructor
  · rintro ⟨⟨x, hx⟩, hx' : (f ∣_ U).1.base _ ∈ V, rfl⟩
    refine' ⟨⟨_, hx⟩, _, rfl⟩
    -- Porting note : this rewrite was not necessary
    rw [SetLike.mem_coe]
    convert hx'
    -- Porting note : `ext1` is not compiling
    refine Subtype.ext ?_
    exact (morphismRestrict_base_coe f U ⟨x, hx⟩).symm
  · rintro ⟨⟨x, hx⟩, hx' : _ ∈ V.1, rfl : x = _⟩
    refine' ⟨⟨_, hx⟩, (_ : (f ∣_ U).1.base ⟨x, hx⟩ ∈ V.1), rfl⟩
    convert hx'
    -- Porting note : `ext1` is compiling
    refine Subtype.ext ?_
    

Proof state:
case h.e'_4.h
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
U : Opens ↑↑Y.toPresheafedSpace
V : Opens ↥U
x : ↑↑X.toPresheafedSpace
hx : f.val.base x ∈ U
hx' : { val := f.val.base x, property := hx } ∈ V.carrier
e_1✝ : (forget TopCat).obj ↑(Y ∣_ᵤ U).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace = ↥U
⊢ ↑((f ∣_ U).val.base { val := x, property := hx }) = ↑{ val := f.val.base x, property := hx }

Next tactic:
exact morphismRestrict_base_coe f U ⟨x, hx⟩
theorem morphismRestrict_c_app {X Y : Scheme} (f : X ⟶ Y) (U : Opens Y) (V : Opens U) :
    (f ∣_ U).1.c.app (op V) =
      f.1.c.app (op (U.openEmbedding.isOpenMap.functor.obj V)) ≫
        X.presheaf.map (eqToHom (image_morphismRestrict_preimage f U V)).op := by
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
U : Opens ↑↑Y.toPresheafedSpace
V : Opens ↥U
⊢ (f ∣_ U).val.c.app (op V) =
    f.val.c.app (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)) ≫
      X.presheaf.map
        (eqToHom
            (_ :
              (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion (f⁻¹ᵁ U)))).obj ((f ∣_ U)⁻¹ᵁ V) =
                f⁻¹ᵁ (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)).op

Next tactic:
have :=
    Scheme.congr_app (morphismRestrict_ι f U) (op (U.openEmbedding.isOpenMap.functor.obj V))
theorem morphismRestrict_c_app {X Y : Scheme} (f : X ⟶ Y) (U : Opens Y) (V : Opens U) :
    (f ∣_ U).1.c.app (op V) =
      f.1.c.app (op (U.openEmbedding.isOpenMap.functor.obj V)) ≫
        X.presheaf.map (eqToHom (image_morphismRestrict_preimage f U V)).op := by
  have :=
    Scheme.congr_app (morphismRestrict_ι f U) (op (U.openEmbedding.isOpenMap.functor.obj V))
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
U : Opens ↑↑Y.toPresheafedSpace
V : Opens ↥U
this :
  (f ∣_ U ≫ Scheme.ιOpens U).val.c.app (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)) =
    (Scheme.ιOpens (f⁻¹ᵁ U) ≫ f).val.c.app (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)) ≫
      (X ∣_ᵤ f⁻¹ᵁ U).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace.presheaf.map
        (eqToHom
          (_ :
            (Opens.map (Scheme.ιOpens (f⁻¹ᵁ U) ≫ f).val.base).op.obj
                (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)) =
              (Opens.map (f ∣_ U ≫ Scheme.ιOpens U).val.base).op.obj
                (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V))))
⊢ (f ∣_ U).val.c.app (op V) =
    f.val.c.app (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)) ≫
      X.presheaf.map
        (eqToHom
            (_ :
              (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion (f⁻¹ᵁ U)))).obj ((f ∣_ U)⁻¹ᵁ V) =
                f⁻¹ᵁ (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)).op

Next tactic:
rw [Scheme.comp_val_c_app, Scheme.comp_val_c_app_assoc] at this
theorem morphismRestrict_c_app {X Y : Scheme} (f : X ⟶ Y) (U : Opens Y) (V : Opens U) :
    (f ∣_ U).1.c.app (op V) =
      f.1.c.app (op (U.openEmbedding.isOpenMap.functor.obj V)) ≫
        X.presheaf.map (eqToHom (image_morphismRestrict_preimage f U V)).op := by
  have :=
    Scheme.congr_app (morphismRestrict_ι f U) (op (U.openEmbedding.isOpenMap.functor.obj V))
  rw [Scheme.comp_val_c_app, Scheme.comp_val_c_app_assoc] at this
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
U : Opens ↑↑Y.toPresheafedSpace
V : Opens ↥U
this :
  (Scheme.ιOpens U).val.c.app (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)) ≫
      (f ∣_ U).val.c.app
        ((Opens.map (Scheme.ιOpens U).val.base).op.obj
          (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V))) =
    f.val.c.app (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)) ≫
      (Scheme.ιOpens (f⁻¹ᵁ U)).val.c.app
          ((Opens.map f.val.base).op.obj (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V))) ≫
        (X ∣_ᵤ f⁻¹ᵁ U).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace.presheaf.map
          (eqToHom
            (_ :
              (Opens.map (Scheme.ιOpens (f⁻¹ᵁ U) ≫ f).val.base).op.obj
                  (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)) =
                (Opens.map (f ∣_ U ≫ Scheme.ιOpens U).val.base).op.obj
                  (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V))))
⊢ (f ∣_ U).val.c.app (op V) =
    f.val.c.app (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)) ≫
      X.presheaf.map
        (eqToHom
            (_ :
              (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion (f⁻¹ᵁ U)))).obj ((f ∣_ U)⁻¹ᵁ V) =
                f⁻¹ᵁ (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)).op

Next tactic:
have e : (Opens.map U.inclusion).obj (U.openEmbedding.isOpenMap.functor.obj V) = V := by
    ext1; exact Set.preimage_image_eq _ Subtype.coe_injective
theorem morphismRestrict_c_app {X Y : Scheme} (f : X ⟶ Y) (U : Opens Y) (V : Opens U) :
    (f ∣_ U).1.c.app (op V) =
      f.1.c.app (op (U.openEmbedding.isOpenMap.functor.obj V)) ≫
        X.presheaf.map (eqToHom (image_morphismRestrict_preimage f U V)).op := by
  have :=
    Scheme.congr_app (morphismRestrict_ι f U) (op (U.openEmbedding.isOpenMap.functor.obj V))
  rw [Scheme.comp_val_c_app, Scheme.comp_val_c_app_assoc] at this
  have e : (Opens.map U.inclusion).obj (U.openEmbedding.isOpenMap.functor.obj V) = V := by
    

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
U : Opens ↑↑Y.toPresheafedSpace
V : Opens ↥U
this :
  (Scheme.ιOpens U).val.c.app (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)) ≫
      (f ∣_ U).val.c.app
        ((Opens.map (Scheme.ιOpens U).val.base).op.obj
          (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V))) =
    f.val.c.app (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)) ≫
      (Scheme.ιOpens (f⁻¹ᵁ U)).val.c.app
          ((Opens.map f.val.base).op.obj (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V))) ≫
        (X ∣_ᵤ f⁻¹ᵁ U).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace.presheaf.map
          (eqToHom
            (_ :
              (Opens.map (Scheme.ιOpens (f⁻¹ᵁ U) ≫ f).val.base).op.obj
                  (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)) =
                (Opens.map (f ∣_ U ≫ Scheme.ιOpens U).val.base).op.obj
                  (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V))))
⊢ (Opens.map (Opens.inclusion U)).obj ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V) = V

Next tactic:
ext1
theorem morphismRestrict_c_app {X Y : Scheme} (f : X ⟶ Y) (U : Opens Y) (V : Opens U) :
    (f ∣_ U).1.c.app (op V) =
      f.1.c.app (op (U.openEmbedding.isOpenMap.functor.obj V)) ≫
        X.presheaf.map (eqToHom (image_morphismRestrict_preimage f U V)).op := by
  have :=
    Scheme.congr_app (morphismRestrict_ι f U) (op (U.openEmbedding.isOpenMap.functor.obj V))
  rw [Scheme.comp_val_c_app, Scheme.comp_val_c_app_assoc] at this
  have e : (Opens.map U.inclusion).obj (U.openEmbedding.isOpenMap.functor.obj V) = V := by
    ext1; 

Proof state:
case h
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
U : Opens ↑↑Y.toPresheafedSpace
V : Opens ↥U
this :
  (Scheme.ιOpens U).val.c.app (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)) ≫
      (f ∣_ U).val.c.app
        ((Opens.map (Scheme.ιOpens U).val.base).op.obj
          (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V))) =
    f.val.c.app (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)) ≫
      (Scheme.ιOpens (f⁻¹ᵁ U)).val.c.app
          ((Opens.map f.val.base).op.obj (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V))) ≫
        (X ∣_ᵤ f⁻¹ᵁ U).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace.presheaf.map
          (eqToHom
            (_ :
              (Opens.map (Scheme.ιOpens (f⁻¹ᵁ U) ≫ f).val.base).op.obj
                  (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)) =
                (Opens.map (f ∣_ U ≫ Scheme.ιOpens U).val.base).op.obj
                  (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V))))
⊢ ↑((Opens.map (Opens.inclusion U)).obj ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)) = ↑V

Next tactic:
exact Set.preimage_image_eq _ Subtype.coe_injective
theorem morphismRestrict_c_app {X Y : Scheme} (f : X ⟶ Y) (U : Opens Y) (V : Opens U) :
    (f ∣_ U).1.c.app (op V) =
      f.1.c.app (op (U.openEmbedding.isOpenMap.functor.obj V)) ≫
        X.presheaf.map (eqToHom (image_morphismRestrict_preimage f U V)).op := by
  have :=
    Scheme.congr_app (morphismRestrict_ι f U) (op (U.openEmbedding.isOpenMap.functor.obj V))
  rw [Scheme.comp_val_c_app, Scheme.comp_val_c_app_assoc] at this
  have e : (Opens.map U.inclusion).obj (U.openEmbedding.isOpenMap.functor.obj V) = V := by
    ext1; exact Set.preimage_image_eq _ Subtype.coe_injective
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
U : Opens ↑↑Y.toPresheafedSpace
V : Opens ↥U
this :
  (Scheme.ιOpens U).val.c.app (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)) ≫
      (f ∣_ U).val.c.app
        ((Opens.map (Scheme.ιOpens U).val.base).op.obj
          (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V))) =
    f.val.c.app (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)) ≫
      (Scheme.ιOpens (f⁻¹ᵁ U)).val.c.app
          ((Opens.map f.val.base).op.obj (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V))) ≫
        (X ∣_ᵤ f⁻¹ᵁ U).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace.presheaf.map
          (eqToHom
            (_ :
              (Opens.map (Scheme.ιOpens (f⁻¹ᵁ U) ≫ f).val.base).op.obj
                  (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)) =
                (Opens.map (f ∣_ U ≫ Scheme.ιOpens U).val.base).op.obj
                  (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V))))
e : (Opens.map (Opens.inclusion U)).obj ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V) = V
⊢ (f ∣_ U).val.c.app (op V) =
    f.val.c.app (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)) ≫
      X.presheaf.map
        (eqToHom
            (_ :
              (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion (f⁻¹ᵁ U)))).obj ((f ∣_ U)⁻¹ᵁ V) =
                f⁻¹ᵁ (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)).op

Next tactic:
have : _ ≫ X.presheaf.map _ = _ :=
    (((f ∣_ U).1.c.naturality (eqToHom e).op).symm.trans ?_).trans this
theorem morphismRestrict_c_app {X Y : Scheme} (f : X ⟶ Y) (U : Opens Y) (V : Opens U) :
    (f ∣_ U).1.c.app (op V) =
      f.1.c.app (op (U.openEmbedding.isOpenMap.functor.obj V)) ≫
        X.presheaf.map (eqToHom (image_morphismRestrict_preimage f U V)).op := by
  have :=
    Scheme.congr_app (morphismRestrict_ι f U) (op (U.openEmbedding.isOpenMap.functor.obj V))
  rw [Scheme.comp_val_c_app, Scheme.comp_val_c_app_assoc] at this
  have e : (Opens.map U.inclusion).obj (U.openEmbedding.isOpenMap.functor.obj V) = V := by
    ext1; exact Set.preimage_image_eq _ Subtype.coe_injective
  have : _ ≫ X.presheaf.map _ = _ :=
    (((f ∣_ U).1.c.naturality (eqToHom e).op).symm.trans ?_).trans this
  · rw [← IsIso.eq_comp_inv, ← Functor.map_inv, Category.assoc] at this
    rw [this]
    congr 1
    erw [← X.presheaf.map_comp, ← X.presheaf.map_comp]
    congr 1
  · 

Proof state:
case refine_1
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
U : Opens ↑↑Y.toPresheafedSpace
V : Opens ↥U
this :
  (Scheme.ιOpens U).val.c.app (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)) ≫
      (f ∣_ U).val.c.app
        ((Opens.map (Scheme.ιOpens U).val.base).op.obj
          (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V))) =
    f.val.c.app (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)) ≫
      (Scheme.ιOpens (f⁻¹ᵁ U)).val.c.app
          ((Opens.map f.val.base).op.obj (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V))) ≫
        (X ∣_ᵤ f⁻¹ᵁ U).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace.presheaf.map
          (eqToHom
            (_ :
              (Opens.map (Scheme.ιOpens (f⁻¹ᵁ U) ≫ f).val.base).op.obj
                  (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)) =
                (Opens.map (f ∣_ U ≫ Scheme.ιOpens U).val.base).op.obj
                  (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V))))
e : (Opens.map (Opens.inclusion U)).obj ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V) = V
⊢ (Y ∣_ᵤ U).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace.presheaf.map (eqToHom e).op ≫
      (f ∣_ U).val.c.app
        (op ((Opens.map (Opens.inclusion U)).obj ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V))) =
    (Scheme.ιOpens U).val.c.app (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)) ≫
      (f ∣_ U).val.c.app
        ((Opens.map (Scheme.ιOpens U).val.base).op.obj
          (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)))

Next tactic:
change Y.presheaf.map _ ≫ _ = Y.presheaf.map _ ≫ _
theorem morphismRestrict_c_app {X Y : Scheme} (f : X ⟶ Y) (U : Opens Y) (V : Opens U) :
    (f ∣_ U).1.c.app (op V) =
      f.1.c.app (op (U.openEmbedding.isOpenMap.functor.obj V)) ≫
        X.presheaf.map (eqToHom (image_morphismRestrict_preimage f U V)).op := by
  have :=
    Scheme.congr_app (morphismRestrict_ι f U) (op (U.openEmbedding.isOpenMap.functor.obj V))
  rw [Scheme.comp_val_c_app, Scheme.comp_val_c_app_assoc] at this
  have e : (Opens.map U.inclusion).obj (U.openEmbedding.isOpenMap.functor.obj V) = V := by
    ext1; exact Set.preimage_image_eq _ Subtype.coe_injective
  have : _ ≫ X.presheaf.map _ = _ :=
    (((f ∣_ U).1.c.naturality (eqToHom e).op).symm.trans ?_).trans this
  · rw [← IsIso.eq_comp_inv, ← Functor.map_inv, Category.assoc] at this
    rw [this]
    congr 1
    erw [← X.presheaf.map_comp, ← X.presheaf.map_comp]
    congr 1
  · change Y.presheaf.map _ ≫ _ = Y.presheaf.map _ ≫ _
    

Proof state:
case refine_1
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
U : Opens ↑↑Y.toPresheafedSpace
V : Opens ↥U
this :
  (Scheme.ιOpens U).val.c.app (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)) ≫
      (f ∣_ U).val.c.app
        ((Opens.map (Scheme.ιOpens U).val.base).op.obj
          (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V))) =
    f.val.c.app (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)) ≫
      (Scheme.ιOpens (f⁻¹ᵁ U)).val.c.app
          ((Opens.map f.val.base).op.obj (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V))) ≫
        (X ∣_ᵤ f⁻¹ᵁ U).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace.presheaf.map
          (eqToHom
            (_ :
              (Opens.map (Scheme.ιOpens (f⁻¹ᵁ U) ≫ f).val.base).op.obj
                  (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)) =
                (Opens.map (f ∣_ U ≫ Scheme.ιOpens U).val.base).op.obj
                  (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V))))
e : (Opens.map (Opens.inclusion U)).obj ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V) = V
⊢ Y.presheaf.map ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).op.map (eqToHom e).op) ≫
      (f ∣_ U).val.c.app
        (op ((Opens.map (Opens.inclusion U)).obj ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V))) =
    Y.presheaf.map
        ((IsOpenMap.adjunction (_ : IsOpenMap ⇑(Opens.inclusion U))).counit.app
            (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)).unop).op ≫
      (f ∣_ U).val.c.app
        ((Opens.map (Scheme.ιOpens U).val.base).op.obj
          (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)))

Next tactic:
congr 1
theorem Γ_map_morphismRestrict {X Y : Scheme} (f : X ⟶ Y) (U : Opens Y) :
    Scheme.Γ.map (f ∣_ U).op =
      Y.presheaf.map (eqToHom <| U.openEmbedding_obj_top.symm).op ≫
        f.1.c.app (op U) ≫ X.presheaf.map (eqToHom <| (f ⁻¹ᵁ U).openEmbedding_obj_top).op := by
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
U : Opens ↑↑Y.toPresheafedSpace
⊢ Scheme.Γ.map (f ∣_ U).op =
    Y.presheaf.map (eqToHom (_ : U = (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj ⊤)).op ≫
      f.val.c.app (op U) ≫
        X.presheaf.map (eqToHom (_ : (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion (f⁻¹ᵁ U)))).obj ⊤ = f⁻¹ᵁ U)).op

Next tactic:
rw [Scheme.Γ_map_op, morphismRestrict_c_app f U ⊤, f.val.c.naturality_assoc]
theorem Γ_map_morphismRestrict {X Y : Scheme} (f : X ⟶ Y) (U : Opens Y) :
    Scheme.Γ.map (f ∣_ U).op =
      Y.presheaf.map (eqToHom <| U.openEmbedding_obj_top.symm).op ≫
        f.1.c.app (op U) ≫ X.presheaf.map (eqToHom <| (f ⁻¹ᵁ U).openEmbedding_obj_top).op := by
  rw [Scheme.Γ_map_op, morphismRestrict_c_app f U ⊤, f.val.c.naturality_assoc]
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
U : Opens ↑↑Y.toPresheafedSpace
⊢ f.val.c.app (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj ⊤)) ≫
      X.presheaf.map
        (eqToHom
            (_ :
              (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion (f⁻¹ᵁ U)))).obj ((f ∣_ U)⁻¹ᵁ ⊤) =
                f⁻¹ᵁ (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj ⊤)).op =
    f.val.c.app (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj ⊤)) ≫
      (f.val.base _* X.presheaf).map
          (eqToHom (_ : U = (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj ⊤)).op ≫
        X.presheaf.map (eqToHom (_ : (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion (f⁻¹ᵁ U)))).obj ⊤ = f⁻¹ᵁ U)).op

Next tactic:
erw [← X.presheaf.map_comp]