l3lab/ntp-mathlib huggingface dataset:
/-- If `U = V`, then `X ∣_ U` is isomorphic to `X ∣_ V`. -/
noncomputable
def Scheme.restrictIsoOfEq (X : Scheme) {U V : Opens X.carrier} (e : U = V) :
    X ∣_ᵤ U ≅ X ∣_ᵤ V := by
  exact IsOpenImmersion.isoOfRangeEq (ιOpens U) (ιOpens V) (by 

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X✝ : Scheme
X : Scheme
U V : Opens ↑↑X.toPresheafedSpace
e : U = V
⊢ Set.range ⇑(ιOpens U).val.base = Set.range ⇑(ιOpens V).val.base

Next tactic:
rw [e]
/-- The restriction of an isomorphism onto an open set. -/
noncomputable abbrev Scheme.restrictMapIso {X Y : Scheme} (f : X ⟶ Y) [IsIso f]
    (U : Opens Y) : X ∣_ᵤ f ⁻¹ᵁ U ≅ Y ∣_ᵤ U := by
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
inst✝ : IsIso f
U : Opens ↑↑Y.toPresheafedSpace
⊢ X ∣_ᵤ f⁻¹ᵁ U ≅ Y ∣_ᵤ U

Next tactic:
apply IsOpenImmersion.isoOfRangeEq (f := X.ofRestrict _ ≫ f)
    (H := PresheafedSpace.IsOpenImmersion.comp (hf := inferInstance) (hg := inferInstance))
    (Y.ofRestrict _) _
/-- The restriction of an isomorphism onto an open set. -/
noncomputable abbrev Scheme.restrictMapIso {X Y : Scheme} (f : X ⟶ Y) [IsIso f]
    (U : Opens Y) : X ∣_ᵤ f ⁻¹ᵁ U ≅ Y ∣_ᵤ U := by
  apply IsOpenImmersion.isoOfRangeEq (f := X.ofRestrict _ ≫ f)
    (H := PresheafedSpace.IsOpenImmersion.comp (hf := inferInstance) (hg := inferInstance))
    (Y.ofRestrict _) _
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
inst✝ : IsIso f
U : Opens ↑↑Y.toPresheafedSpace
⊢ Set.range ⇑(ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion (f⁻¹ᵁ U))) ≫ f).val.base =
    Set.range ⇑(ofRestrict Y (_ : OpenEmbedding ⇑(Opens.inclusion U))).val.base

Next tactic:
dsimp[restrict]
/-- The restriction of an isomorphism onto an open set. -/
noncomputable abbrev Scheme.restrictMapIso {X Y : Scheme} (f : X ⟶ Y) [IsIso f]
    (U : Opens Y) : X ∣_ᵤ f ⁻¹ᵁ U ≅ Y ∣_ᵤ U := by
  apply IsOpenImmersion.isoOfRangeEq (f := X.ofRestrict _ ≫ f)
    (H := PresheafedSpace.IsOpenImmersion.comp (hf := inferInstance) (hg := inferInstance))
    (Y.ofRestrict _) _
  dsimp[restrict]
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
inst✝ : IsIso f
U : Opens ↑↑Y.toPresheafedSpace
⊢ Set.range ⇑(Opens.inclusion (f⁻¹ᵁ U) ≫ f.val.base) = Set.range Subtype.val

Next tactic:
rw [coe_comp, Set.range_comp, Opens.coe_inclusion, Subtype.range_val, Subtype.range_coe]
/-- The restriction of an isomorphism onto an open set. -/
noncomputable abbrev Scheme.restrictMapIso {X Y : Scheme} (f : X ⟶ Y) [IsIso f]
    (U : Opens Y) : X ∣_ᵤ f ⁻¹ᵁ U ≅ Y ∣_ᵤ U := by
  apply IsOpenImmersion.isoOfRangeEq (f := X.ofRestrict _ ≫ f)
    (H := PresheafedSpace.IsOpenImmersion.comp (hf := inferInstance) (hg := inferInstance))
    (Y.ofRestrict _) _
  dsimp[restrict]
  rw [coe_comp, Set.range_comp, Opens.coe_inclusion, Subtype.range_val, Subtype.range_coe]
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
inst✝ : IsIso f
U : Opens ↑↑Y.toPresheafedSpace
⊢ ⇑f.val.base '' ↑(f⁻¹ᵁ U) = ↑U

Next tactic:
refine' @Set.image_preimage_eq _ _ f.1.base U.1 _
/-- The restriction of an isomorphism onto an open set. -/
noncomputable abbrev Scheme.restrictMapIso {X Y : Scheme} (f : X ⟶ Y) [IsIso f]
    (U : Opens Y) : X ∣_ᵤ f ⁻¹ᵁ U ≅ Y ∣_ᵤ U := by
  apply IsOpenImmersion.isoOfRangeEq (f := X.ofRestrict _ ≫ f)
    (H := PresheafedSpace.IsOpenImmersion.comp (hf := inferInstance) (hg := inferInstance))
    (Y.ofRestrict _) _
  dsimp[restrict]
  rw [coe_comp, Set.range_comp, Opens.coe_inclusion, Subtype.range_val, Subtype.range_coe]
  refine' @Set.image_preimage_eq _ _ f.1.base U.1 _
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
inst✝ : IsIso f
U : Opens ↑↑Y.toPresheafedSpace
⊢ Function.Surjective ⇑f.val.base

Next tactic:
rw [← TopCat.epi_iff_surjective]
/-- The restriction of an isomorphism onto an open set. -/
noncomputable abbrev Scheme.restrictMapIso {X Y : Scheme} (f : X ⟶ Y) [IsIso f]
    (U : Opens Y) : X ∣_ᵤ f ⁻¹ᵁ U ≅ Y ∣_ᵤ U := by
  apply IsOpenImmersion.isoOfRangeEq (f := X.ofRestrict _ ≫ f)
    (H := PresheafedSpace.IsOpenImmersion.comp (hf := inferInstance) (hg := inferInstance))
    (Y.ofRestrict _) _
  dsimp[restrict]
  rw [coe_comp, Set.range_comp, Opens.coe_inclusion, Subtype.range_val, Subtype.range_coe]
  refine' @Set.image_preimage_eq _ _ f.1.base U.1 _
  rw [← TopCat.epi_iff_surjective]
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
inst✝ : IsIso f
U : Opens ↑↑Y.toPresheafedSpace
⊢ Epi f.val.base

Next tactic:
infer_instance
/-- Given a morphism `f : X ⟶ Y` and an open set `U ⊆ Y`, we have `X ×[Y] U ≅ X |_{f ⁻¹ U}` -/
def pullbackRestrictIsoRestrict {X Y : Scheme} (f : X ⟶ Y) (U : Opens Y) :
    pullback f (Scheme.ιOpens U) ≅ X ∣_ᵤ f ⁻¹ᵁ U := by
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
U : Opens ↑↑Y.toPresheafedSpace
⊢ pullback f (Scheme.ιOpens U) ≅ X ∣_ᵤ f⁻¹ᵁ U

Next tactic:
refine' IsOpenImmersion.isoOfRangeEq pullback.fst (X.ofRestrict _) _
/-- Given a morphism `f : X ⟶ Y` and an open set `U ⊆ Y`, we have `X ×[Y] U ≅ X |_{f ⁻¹ U}` -/
def pullbackRestrictIsoRestrict {X Y : Scheme} (f : X ⟶ Y) (U : Opens Y) :
    pullback f (Scheme.ιOpens U) ≅ X ∣_ᵤ f ⁻¹ᵁ U := by
  refine' IsOpenImmersion.isoOfRangeEq pullback.fst (X.ofRestrict _) _
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
U : Opens ↑↑Y.toPresheafedSpace
⊢ Set.range ⇑pullback.fst.val.base =
    Set.range ⇑(Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion (f⁻¹ᵁ U)))).val.base

Next tactic:
rw [IsOpenImmersion.range_pullback_fst_of_right]
/-- Given a morphism `f : X ⟶ Y` and an open set `U ⊆ Y`, we have `X ×[Y] U ≅ X |_{f ⁻¹ U}` -/
def pullbackRestrictIsoRestrict {X Y : Scheme} (f : X ⟶ Y) (U : Opens Y) :
    pullback f (Scheme.ιOpens U) ≅ X ∣_ᵤ f ⁻¹ᵁ U := by
  refine' IsOpenImmersion.isoOfRangeEq pullback.fst (X.ofRestrict _) _
  rw [IsOpenImmersion.range_pullback_fst_of_right]
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
U : Opens ↑↑Y.toPresheafedSpace
⊢ (f⁻¹ᵁ
        { carrier := Set.range ⇑(Scheme.ιOpens U).val.base,
          is_open' := (_ : IsOpen (Set.range ⇑(Scheme.ιOpens U).val.base)) }).carrier =
    Set.range ⇑(Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion (f⁻¹ᵁ U)))).val.base

Next tactic:
dsimp [Opens.coe_inclusion, Scheme.restrict]
/-- Given a morphism `f : X ⟶ Y` and an open set `U ⊆ Y`, we have `X ×[Y] U ≅ X |_{f ⁻¹ U}` -/
def pullbackRestrictIsoRestrict {X Y : Scheme} (f : X ⟶ Y) (U : Opens Y) :
    pullback f (Scheme.ιOpens U) ≅ X ∣_ᵤ f ⁻¹ᵁ U := by
  refine' IsOpenImmersion.isoOfRangeEq pullback.fst (X.ofRestrict _) _
  rw [IsOpenImmersion.range_pullback_fst_of_right]
  dsimp [Opens.coe_inclusion, Scheme.restrict]
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
U : Opens ↑↑Y.toPresheafedSpace
⊢ ⇑f.val.base ⁻¹' Set.range Subtype.val = Set.range Subtype.val

Next tactic:
rw [Subtype.range_val, Subtype.range_coe]
/-- Given a morphism `f : X ⟶ Y` and an open set `U ⊆ Y`, we have `X ×[Y] U ≅ X |_{f ⁻¹ U}` -/
def pullbackRestrictIsoRestrict {X Y : Scheme} (f : X ⟶ Y) (U : Opens Y) :
    pullback f (Scheme.ιOpens U) ≅ X ∣_ᵤ f ⁻¹ᵁ U := by
  refine' IsOpenImmersion.isoOfRangeEq pullback.fst (X.ofRestrict _) _
  rw [IsOpenImmersion.range_pullback_fst_of_right]
  dsimp [Opens.coe_inclusion, Scheme.restrict]
  rw [Subtype.range_val, Subtype.range_coe]
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
U : Opens ↑↑Y.toPresheafedSpace
⊢ ⇑f.val.base ⁻¹' ↑U = ↑(f⁻¹ᵁ U)

Next tactic:
rfl
@[simp, reassoc]
theorem pullbackRestrictIsoRestrict_inv_fst {X Y : Scheme} (f : X ⟶ Y) (U : Opens Y) :
    (pullbackRestrictIsoRestrict f U).inv ≫ pullback.fst = X.ofRestrict _ := by
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
U : Opens ↑↑Y.toPresheafedSpace
⊢ (pullbackRestrictIsoRestrict f U).inv ≫ pullback.fst =
    Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion (f⁻¹ᵁ U)))

Next tactic:
delta pullbackRestrictIsoRestrict
@[simp, reassoc]
theorem pullbackRestrictIsoRestrict_inv_fst {X Y : Scheme} (f : X ⟶ Y) (U : Opens Y) :
    (pullbackRestrictIsoRestrict f U).inv ≫ pullback.fst = X.ofRestrict _ := by
  delta pullbackRestrictIsoRestrict; 

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
U : Opens ↑↑Y.toPresheafedSpace
⊢ (IsOpenImmersion.isoOfRangeEq pullback.fst (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion (f⁻¹ᵁ U))))
          (_ :
            Set.range ⇑pullback.fst.val.base =
              Set.range ⇑(Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion (f⁻¹ᵁ U)))).val.base)).inv ≫
      pullback.fst =
    Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion (f⁻¹ᵁ U)))

Next tactic:
simp
@[simp, reassoc]
theorem pullbackRestrictIsoRestrict_hom_restrict {X Y : Scheme} (f : X ⟶ Y) (U : Opens Y) :
    (pullbackRestrictIsoRestrict f U).hom ≫ Scheme.ιOpens (f ⁻¹ᵁ U) = pullback.fst := by
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
U : Opens ↑↑Y.toPresheafedSpace
⊢ (pullbackRestrictIsoRestrict f U).hom ≫ Scheme.ιOpens (f⁻¹ᵁ U) = pullback.fst

Next tactic:
delta pullbackRestrictIsoRestrict
@[simp, reassoc]
theorem pullbackRestrictIsoRestrict_hom_restrict {X Y : Scheme} (f : X ⟶ Y) (U : Opens Y) :
    (pullbackRestrictIsoRestrict f U).hom ≫ Scheme.ιOpens (f ⁻¹ᵁ U) = pullback.fst := by
  delta pullbackRestrictIsoRestrict; 

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
U : Opens ↑↑Y.toPresheafedSpace
⊢ (IsOpenImmersion.isoOfRangeEq pullback.fst (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion (f⁻¹ᵁ U))))
          (_ :
            Set.range ⇑pullback.fst.val.base =
              Set.range ⇑(Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion (f⁻¹ᵁ U)))).val.base)).hom ≫
      Scheme.ιOpens (f⁻¹ᵁ U) =
    pullback.fst

Next tactic:
simp
@[simp, reassoc]
theorem morphismRestrict_ι {X Y : Scheme} (f : X ⟶ Y) (U : Opens Y) :
    (f ∣_ U) ≫ Scheme.ιOpens U = Scheme.ιOpens (f ⁻¹ᵁ U) ≫ f := by
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
U : Opens ↑↑Y.toPresheafedSpace
⊢ f ∣_ U ≫ Scheme.ιOpens U = Scheme.ιOpens (f⁻¹ᵁ U) ≫ f

Next tactic:
delta morphismRestrict
@[simp, reassoc]
theorem morphismRestrict_ι {X Y : Scheme} (f : X ⟶ Y) (U : Opens Y) :
    (f ∣_ U) ≫ Scheme.ιOpens U = Scheme.ιOpens (f ⁻¹ᵁ U) ≫ f := by
  delta morphismRestrict
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
U : Opens ↑↑Y.toPresheafedSpace
⊢ ((pullbackRestrictIsoRestrict f U).inv ≫ pullback.snd) ≫ Scheme.ιOpens U = Scheme.ιOpens (f⁻¹ᵁ U) ≫ f

Next tactic:
rw [Category.assoc, pullback.condition.symm, pullbackRestrictIsoRestrict_inv_fst_assoc]
theorem isPullback_morphismRestrict {X Y : Scheme} (f : X ⟶ Y) (U : Opens Y) :
    IsPullback (f ∣_ U) (Scheme.ιOpens (f ⁻¹ᵁ U)) (Scheme.ιOpens U) f := by
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
U : Opens ↑↑Y.toPresheafedSpace
⊢ IsPullback (f ∣_ U) (Scheme.ιOpens (f⁻¹ᵁ U)) (Scheme.ιOpens U) f

Next tactic:
delta morphismRestrict
theorem isPullback_morphismRestrict {X Y : Scheme} (f : X ⟶ Y) (U : Opens Y) :
    IsPullback (f ∣_ U) (Scheme.ιOpens (f ⁻¹ᵁ U)) (Scheme.ιOpens U) f := by
  delta morphismRestrict
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
U : Opens ↑↑Y.toPresheafedSpace
⊢ IsPullback ((pullbackRestrictIsoRestrict f U).inv ≫ pullback.snd) (Scheme.ιOpens (f⁻¹ᵁ U)) (Scheme.ιOpens U) f

Next tactic:
rw [← Category.id_comp f]
theorem isPullback_morphismRestrict {X Y : Scheme} (f : X ⟶ Y) (U : Opens Y) :
    IsPullback (f ∣_ U) (Scheme.ιOpens (f ⁻¹ᵁ U)) (Scheme.ιOpens U) f := by
  delta morphismRestrict
  rw [← Category.id_comp f]
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
U : Opens ↑↑Y.toPresheafedSpace
⊢ IsPullback ((pullbackRestrictIsoRestrict (𝟙 X ≫ f) U).inv ≫ pullback.snd) (Scheme.ιOpens ((𝟙 X ≫ f)⁻¹ᵁ U))
    (Scheme.ιOpens U) (𝟙 X ≫ f)

Next tactic:
refine'
    (IsPullback.of_horiz_isIso ⟨_⟩).paste_horiz
      (IsPullback.of_hasPullback f (Y.ofRestrict U.openEmbedding)).flip
theorem isPullback_morphismRestrict {X Y : Scheme} (f : X ⟶ Y) (U : Opens Y) :
    IsPullback (f ∣_ U) (Scheme.ιOpens (f ⁻¹ᵁ U)) (Scheme.ιOpens U) f := by
  delta morphismRestrict
  rw [← Category.id_comp f]
  refine'
    (IsPullback.of_horiz_isIso ⟨_⟩).paste_horiz
      (IsPullback.of_hasPullback f (Y.ofRestrict U.openEmbedding)).flip
  -- Porting note : changed `rw` to `erw`
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
U : Opens ↑↑Y.toPresheafedSpace
⊢ (pullbackRestrictIsoRestrict (𝟙 X ≫ f) U).inv ≫ pullback.fst = Scheme.ιOpens ((𝟙 X ≫ f)⁻¹ᵁ U) ≫ 𝟙 X

Next tactic:
erw [pullbackRestrictIsoRestrict_inv_fst]
theorem isPullback_morphismRestrict {X Y : Scheme} (f : X ⟶ Y) (U : Opens Y) :
    IsPullback (f ∣_ U) (Scheme.ιOpens (f ⁻¹ᵁ U)) (Scheme.ιOpens U) f := by
  delta morphismRestrict
  rw [← Category.id_comp f]
  refine'
    (IsPullback.of_horiz_isIso ⟨_⟩).paste_horiz
      (IsPullback.of_hasPullback f (Y.ofRestrict U.openEmbedding)).flip
  -- Porting note : changed `rw` to `erw`
  erw [pullbackRestrictIsoRestrict_inv_fst]; 

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
U : Opens ↑↑Y.toPresheafedSpace
⊢ Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion ((𝟙 X ≫ f)⁻¹ᵁ U))) = Scheme.ιOpens ((𝟙 X ≫ f)⁻¹ᵁ U) ≫ 𝟙 X

Next tactic:
rw [Category.comp_id]
theorem morphismRestrict_comp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) (U : Opens Z) :
    (f ≫ g) ∣_ U = f ∣_ g ⁻¹ᵁ U ≫ g ∣_ U := by
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Scheme
f : X ⟶ Y
g : Y ⟶ Z
U : Opens ↑↑Z.toPresheafedSpace
⊢ (f ≫ g) ∣_ U = f ∣_ g⁻¹ᵁ U ≫ g ∣_ U

Next tactic:
delta morphismRestrict
theorem morphismRestrict_comp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) (U : Opens Z) :
    (f ≫ g) ∣_ U = f ∣_ g ⁻¹ᵁ U ≫ g ∣_ U := by
  delta morphismRestrict
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Scheme
f : X ⟶ Y
g : Y ⟶ Z
U : Opens ↑↑Z.toPresheafedSpace
⊢ (pullbackRestrictIsoRestrict (f ≫ g) U).inv ≫ pullback.snd =
    ((pullbackRestrictIsoRestrict f (g⁻¹ᵁ U)).inv ≫ pullback.snd) ≫ (pullbackRestrictIsoRestrict g U).inv ≫ pullback.snd

Next tactic:
rw [← pullbackRightPullbackFstIso_inv_snd_snd]
theorem morphismRestrict_comp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) (U : Opens Z) :
    (f ≫ g) ∣_ U = f ∣_ g ⁻¹ᵁ U ≫ g ∣_ U := by
  delta morphismRestrict
  rw [← pullbackRightPullbackFstIso_inv_snd_snd]
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Scheme
f : X ⟶ Y
g : Y ⟶ Z
U : Opens ↑↑Z.toPresheafedSpace
⊢ (pullbackRestrictIsoRestrict (f ≫ g) U).inv ≫
      (pullbackRightPullbackFstIso g (Scheme.ιOpens U) f).inv ≫ pullback.snd ≫ pullback.snd =
    ((pullbackRestrictIsoRestrict f (g⁻¹ᵁ U)).inv ≫ pullback.snd) ≫ (pullbackRestrictIsoRestrict g U).inv ≫ pullback.snd

Next tactic:
simp_rw [← Category.assoc]
theorem morphismRestrict_comp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) (U : Opens Z) :
    (f ≫ g) ∣_ U = f ∣_ g ⁻¹ᵁ U ≫ g ∣_ U := by
  delta morphismRestrict
  rw [← pullbackRightPullbackFstIso_inv_snd_snd]
  simp_rw [← Category.assoc]
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Scheme
f : X ⟶ Y
g : Y ⟶ Z
U : Opens ↑↑Z.toPresheafedSpace
⊢ (((pullbackRestrictIsoRestrict (f ≫ g) U).inv ≫ (pullbackRightPullbackFstIso g (Scheme.ιOpens U) f).inv) ≫
        pullback.snd) ≫
      pullback.snd =
    (((pullbackRestrictIsoRestrict f (g⁻¹ᵁ U)).inv ≫ pullback.snd) ≫ (pullbackRestrictIsoRestrict g U).inv) ≫
      pullback.snd

Next tactic:
congr 1
theorem morphismRestrict_comp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) (U : Opens Z) :
    (f ≫ g) ∣_ U = f ∣_ g ⁻¹ᵁ U ≫ g ∣_ U := by
  delta morphismRestrict
  rw [← pullbackRightPullbackFstIso_inv_snd_snd]
  simp_rw [← Category.assoc]
  congr 1
  

Proof state:
case e_a
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Scheme
f : X ⟶ Y
g : Y ⟶ Z
U : Opens ↑↑Z.toPresheafedSpace
⊢ ((pullbackRestrictIsoRestrict (f ≫ g) U).inv ≫ (pullbackRightPullbackFstIso g (Scheme.ιOpens U) f).inv) ≫
      pullback.snd =
    ((pullbackRestrictIsoRestrict f (g⁻¹ᵁ U)).inv ≫ pullback.snd) ≫ (pullbackRestrictIsoRestrict g U).inv

Next tactic:
rw [← cancel_mono pullback.fst]
theorem morphismRestrict_comp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) (U : Opens Z) :
    (f ≫ g) ∣_ U = f ∣_ g ⁻¹ᵁ U ≫ g ∣_ U := by
  delta morphismRestrict
  rw [← pullbackRightPullbackFstIso_inv_snd_snd]
  simp_rw [← Category.assoc]
  congr 1
  rw [← cancel_mono pullback.fst]
  

Proof state:
case e_a
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Scheme
f : X ⟶ Y
g : Y ⟶ Z
U : Opens ↑↑Z.toPresheafedSpace
⊢ (((pullbackRestrictIsoRestrict (f ≫ g) U).inv ≫ (pullbackRightPullbackFstIso g (Scheme.ιOpens U) f).inv) ≫
        pullback.snd) ≫
      pullback.fst =
    (((pullbackRestrictIsoRestrict f (g⁻¹ᵁ U)).inv ≫ pullback.snd) ≫ (pullbackRestrictIsoRestrict g U).inv) ≫
      pullback.fst

Next tactic:
simp_rw [Category.assoc]
theorem morphismRestrict_comp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) (U : Opens Z) :
    (f ≫ g) ∣_ U = f ∣_ g ⁻¹ᵁ U ≫ g ∣_ U := by
  delta morphismRestrict
  rw [← pullbackRightPullbackFstIso_inv_snd_snd]
  simp_rw [← Category.assoc]
  congr 1
  rw [← cancel_mono pullback.fst]
  simp_rw [Category.assoc]
  

Proof state:
case e_a
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Scheme
f : X ⟶ Y
g : Y ⟶ Z
U : Opens ↑↑Z.toPresheafedSpace
⊢ (pullbackRestrictIsoRestrict (f ≫ g) U).inv ≫
      (pullbackRightPullbackFstIso g (Scheme.ιOpens U) f).inv ≫ pullback.snd ≫ pullback.fst =
    (pullbackRestrictIsoRestrict f (g⁻¹ᵁ U)).inv ≫ pullback.snd ≫ (pullbackRestrictIsoRestrict g U).inv ≫ pullback.fst

Next tactic:
rw [pullbackRestrictIsoRestrict_inv_fst, pullbackRightPullbackFstIso_inv_snd_fst, ←
    pullback.condition, pullbackRestrictIsoRestrict_inv_fst_assoc,
    pullbackRestrictIsoRestrict_inv_fst_assoc]
instance {X Y : Scheme} (f : X ⟶ Y) [IsIso f] (U : Opens Y) : IsIso (f ∣_ U) := by
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
inst✝ : IsIso f
U : Opens ↑↑Y.toPresheafedSpace
⊢ IsIso (f ∣_ U)

Next tactic:
delta morphismRestrict
instance {X Y : Scheme} (f : X ⟶ Y) [IsIso f] (U : Opens Y) : IsIso (f ∣_ U) := by
  delta morphismRestrict; 

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X Y : Scheme
f : X ⟶ Y
inst✝ : IsIso f
U : Opens ↑↑Y.toPresheafedSpace
⊢ IsIso ((pullbackRestrictIsoRestrict f U).inv ≫ pullback.snd)

Next tactic:
infer_instance
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
  

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

Next tactic:
ext1
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
  

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
⊢ ↑((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion (f⁻¹ᵁ U)))).obj ((f ∣_ U)⁻¹ᵁ V)) =
    ↑(f⁻¹ᵁ (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)

Next tactic:
ext 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
  

Proof state:
case h.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
⊢ x ∈ ↑((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion (f⁻¹ᵁ U)))).obj ((f ∣_ U)⁻¹ᵁ V)) ↔
    x ∈ ↑(f⁻¹ᵁ (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)

Next tactic:
constructor
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
  · 

Proof state:
case h.h.mp
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 ∈ ↑((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion (f⁻¹ᵁ U)))).obj ((f ∣_ U)⁻¹ᵁ V)) →
    x ∈ ↑(f⁻¹ᵁ (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)

Next tactic:
rintro ⟨⟨x, hx⟩, hx' : (f ∣_ U).1.base _ ∈ V, 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⟩
    

Proof state:
case h.h.mp.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 : x ∈ f⁻¹ᵁ U
hx' : (f ∣_ U).val.base { val := x, property := hx } ∈ V
⊢ (Opens.inclusion (f⁻¹ᵁ U)) { val := x, property := hx } ∈
    ↑(f⁻¹ᵁ (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj V)

Next tactic:
refine' ⟨⟨_, hx⟩, _, 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
    

Proof state:
case h.h.mp.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 : x ∈ f⁻¹ᵁ U
hx' : (f ∣_ U).val.base { val := x, property := hx } ∈ V
⊢ { val := f.val.base x, property := hx } ∈ ↑V

Next tactic:
rw [SetLike.mem_coe]
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]
    

Proof state:
case h.h.mp.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 : x ∈ f⁻¹ᵁ U
hx' : (f ∣_ U).val.base { val := x, property := hx } ∈ V
⊢ { val := f.val.base x, property := hx } ∈ V

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
    

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:
refine Subtype.ext ?_