l3lab/ntp-mathlib huggingface dataset:
theorem range_pullback_snd_of_left :
    Set.range (pullback.snd : pullback f g ⟶ Y).1.base =
      ((Opens.map g.1.base).obj ⟨Set.range f.1.base, H.base_open.open_range⟩).1 := by
  rw [←
    show _ = (pullback.snd : pullback f g ⟶ _).1.base from
      PreservesPullback.iso_hom_snd Scheme.forgetToTop f g]
  -- Porting note : was `rw`
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Scheme
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
⊢ Set.range ⇑((PreservesPullback.iso Scheme.forgetToTop f g).hom ≫ pullback.snd) =
    ((Opens.map g.val.base).obj
        { carrier := Set.range ⇑f.val.base, is_open' := (_ : IsOpen (Set.range ⇑f.val.base)) }).carrier

Next tactic:
erw [coe_comp]
theorem range_pullback_snd_of_left :
    Set.range (pullback.snd : pullback f g ⟶ Y).1.base =
      ((Opens.map g.1.base).obj ⟨Set.range f.1.base, H.base_open.open_range⟩).1 := by
  rw [←
    show _ = (pullback.snd : pullback f g ⟶ _).1.base from
      PreservesPullback.iso_hom_snd Scheme.forgetToTop f g]
  -- Porting note : was `rw`
  erw [coe_comp]
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Scheme
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
⊢ Set.range (⇑pullback.snd ∘ ⇑(PreservesPullback.iso Scheme.forgetToTop f g).hom) =
    ((Opens.map g.val.base).obj
        { carrier := Set.range ⇑f.val.base, is_open' := (_ : IsOpen (Set.range ⇑f.val.base)) }).carrier

Next tactic:
rw [Set.range_comp, Set.range_iff_surjective.mpr, ←
    @Set.preimage_univ _ _ (pullback.fst : pullback f.1.base g.1.base ⟶ _)]
theorem range_pullback_snd_of_left :
    Set.range (pullback.snd : pullback f g ⟶ Y).1.base =
      ((Opens.map g.1.base).obj ⟨Set.range f.1.base, H.base_open.open_range⟩).1 := by
  rw [←
    show _ = (pullback.snd : pullback f g ⟶ _).1.base from
      PreservesPullback.iso_hom_snd Scheme.forgetToTop f g]
  -- Porting note : was `rw`
  erw [coe_comp]
  rw [Set.range_comp, Set.range_iff_surjective.mpr, ←
    @Set.preimage_univ _ _ (pullback.fst : pullback f.1.base g.1.base ⟶ _)]
  -- Porting note : was `rw`
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Scheme
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
⊢ ⇑pullback.snd '' (⇑pullback.fst ⁻¹' Set.univ) =
    ((Opens.map g.val.base).obj
        { carrier := Set.range ⇑f.val.base, is_open' := (_ : IsOpen (Set.range ⇑f.val.base)) }).carrier
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Scheme
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
⊢ Function.Surjective ⇑(PreservesPullback.iso Scheme.forgetToTop f g).hom

Next tactic:
erw [TopCat.pullback_snd_image_fst_preimage]
theorem range_pullback_snd_of_left :
    Set.range (pullback.snd : pullback f g ⟶ Y).1.base =
      ((Opens.map g.1.base).obj ⟨Set.range f.1.base, H.base_open.open_range⟩).1 := by
  rw [←
    show _ = (pullback.snd : pullback f g ⟶ _).1.base from
      PreservesPullback.iso_hom_snd Scheme.forgetToTop f g]
  -- Porting note : was `rw`
  erw [coe_comp]
  rw [Set.range_comp, Set.range_iff_surjective.mpr, ←
    @Set.preimage_univ _ _ (pullback.fst : pullback f.1.base g.1.base ⟶ _)]
  -- Porting note : was `rw`
  erw [TopCat.pullback_snd_image_fst_preimage]
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Scheme
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
⊢ ⇑(Scheme.forgetToTop.map g) ⁻¹' (⇑(Scheme.forgetToTop.map f) '' Set.univ) =
    ((Opens.map g.val.base).obj
        { carrier := Set.range ⇑f.val.base, is_open' := (_ : IsOpen (Set.range ⇑f.val.base)) }).carrier
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Scheme
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
⊢ Function.Surjective ⇑(PreservesPullback.iso Scheme.forgetToTop f g).hom

Next tactic:
rw [Set.image_univ]
theorem range_pullback_snd_of_left :
    Set.range (pullback.snd : pullback f g ⟶ Y).1.base =
      ((Opens.map g.1.base).obj ⟨Set.range f.1.base, H.base_open.open_range⟩).1 := by
  rw [←
    show _ = (pullback.snd : pullback f g ⟶ _).1.base from
      PreservesPullback.iso_hom_snd Scheme.forgetToTop f g]
  -- Porting note : was `rw`
  erw [coe_comp]
  rw [Set.range_comp, Set.range_iff_surjective.mpr, ←
    @Set.preimage_univ _ _ (pullback.fst : pullback f.1.base g.1.base ⟶ _)]
  -- Porting note : was `rw`
  erw [TopCat.pullback_snd_image_fst_preimage]
  rw [Set.image_univ]
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Scheme
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
⊢ ⇑(Scheme.forgetToTop.map g) ⁻¹' Set.range ⇑(Scheme.forgetToTop.map f) =
    ((Opens.map g.val.base).obj
        { carrier := Set.range ⇑f.val.base, is_open' := (_ : IsOpen (Set.range ⇑f.val.base)) }).carrier
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Scheme
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
⊢ Function.Surjective ⇑(PreservesPullback.iso Scheme.forgetToTop f g).hom

Next tactic:
rfl
theorem range_pullback_snd_of_left :
    Set.range (pullback.snd : pullback f g ⟶ Y).1.base =
      ((Opens.map g.1.base).obj ⟨Set.range f.1.base, H.base_open.open_range⟩).1 := by
  rw [←
    show _ = (pullback.snd : pullback f g ⟶ _).1.base from
      PreservesPullback.iso_hom_snd Scheme.forgetToTop f g]
  -- Porting note : was `rw`
  erw [coe_comp]
  rw [Set.range_comp, Set.range_iff_surjective.mpr, ←
    @Set.preimage_univ _ _ (pullback.fst : pullback f.1.base g.1.base ⟶ _)]
  -- Porting note : was `rw`
  erw [TopCat.pullback_snd_image_fst_preimage]
  rw [Set.image_univ]
  rfl
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Scheme
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
⊢ Function.Surjective ⇑(PreservesPullback.iso Scheme.forgetToTop f g).hom

Next tactic:
rw [← TopCat.epi_iff_surjective]
theorem range_pullback_snd_of_left :
    Set.range (pullback.snd : pullback f g ⟶ Y).1.base =
      ((Opens.map g.1.base).obj ⟨Set.range f.1.base, H.base_open.open_range⟩).1 := by
  rw [←
    show _ = (pullback.snd : pullback f g ⟶ _).1.base from
      PreservesPullback.iso_hom_snd Scheme.forgetToTop f g]
  -- Porting note : was `rw`
  erw [coe_comp]
  rw [Set.range_comp, Set.range_iff_surjective.mpr, ←
    @Set.preimage_univ _ _ (pullback.fst : pullback f.1.base g.1.base ⟶ _)]
  -- Porting note : was `rw`
  erw [TopCat.pullback_snd_image_fst_preimage]
  rw [Set.image_univ]
  rfl
  rw [← TopCat.epi_iff_surjective]
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Scheme
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
⊢ Epi (PreservesPullback.iso Scheme.forgetToTop f g).hom

Next tactic:
infer_instance
theorem range_pullback_fst_of_right :
    Set.range (pullback.fst : pullback g f ⟶ Y).1.base =
      ((Opens.map g.1.base).obj ⟨Set.range f.1.base, H.base_open.open_range⟩).1 := by
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Scheme
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
⊢ Set.range ⇑pullback.fst.val.base =
    ((Opens.map g.val.base).obj
        { carrier := Set.range ⇑f.val.base, is_open' := (_ : IsOpen (Set.range ⇑f.val.base)) }).carrier

Next tactic:
rw [←
    show _ = (pullback.fst : pullback g f ⟶ _).1.base from
      PreservesPullback.iso_hom_fst Scheme.forgetToTop g f]
theorem range_pullback_fst_of_right :
    Set.range (pullback.fst : pullback g f ⟶ Y).1.base =
      ((Opens.map g.1.base).obj ⟨Set.range f.1.base, H.base_open.open_range⟩).1 := by
  rw [←
    show _ = (pullback.fst : pullback g f ⟶ _).1.base from
      PreservesPullback.iso_hom_fst Scheme.forgetToTop g f]
  -- Porting note : was `rw`
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Scheme
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
⊢ Set.range ⇑((PreservesPullback.iso Scheme.forgetToTop g f).hom ≫ pullback.fst) =
    ((Opens.map g.val.base).obj
        { carrier := Set.range ⇑f.val.base, is_open' := (_ : IsOpen (Set.range ⇑f.val.base)) }).carrier

Next tactic:
erw [coe_comp]
theorem range_pullback_fst_of_right :
    Set.range (pullback.fst : pullback g f ⟶ Y).1.base =
      ((Opens.map g.1.base).obj ⟨Set.range f.1.base, H.base_open.open_range⟩).1 := by
  rw [←
    show _ = (pullback.fst : pullback g f ⟶ _).1.base from
      PreservesPullback.iso_hom_fst Scheme.forgetToTop g f]
  -- Porting note : was `rw`
  erw [coe_comp]
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Scheme
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
⊢ Set.range (⇑pullback.fst ∘ ⇑(PreservesPullback.iso Scheme.forgetToTop g f).hom) =
    ((Opens.map g.val.base).obj
        { carrier := Set.range ⇑f.val.base, is_open' := (_ : IsOpen (Set.range ⇑f.val.base)) }).carrier

Next tactic:
rw [Set.range_comp, Set.range_iff_surjective.mpr, ←
    @Set.preimage_univ _ _ (pullback.snd : pullback g.1.base f.1.base ⟶ _)]
theorem range_pullback_fst_of_right :
    Set.range (pullback.fst : pullback g f ⟶ Y).1.base =
      ((Opens.map g.1.base).obj ⟨Set.range f.1.base, H.base_open.open_range⟩).1 := by
  rw [←
    show _ = (pullback.fst : pullback g f ⟶ _).1.base from
      PreservesPullback.iso_hom_fst Scheme.forgetToTop g f]
  -- Porting note : was `rw`
  erw [coe_comp]
  rw [Set.range_comp, Set.range_iff_surjective.mpr, ←
    @Set.preimage_univ _ _ (pullback.snd : pullback g.1.base f.1.base ⟶ _)]
  -- Porting note : was `rw`
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Scheme
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
⊢ ⇑pullback.fst '' (⇑pullback.snd ⁻¹' Set.univ) =
    ((Opens.map g.val.base).obj
        { carrier := Set.range ⇑f.val.base, is_open' := (_ : IsOpen (Set.range ⇑f.val.base)) }).carrier
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Scheme
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
⊢ Function.Surjective ⇑(PreservesPullback.iso Scheme.forgetToTop g f).hom

Next tactic:
erw [TopCat.pullback_fst_image_snd_preimage]
theorem range_pullback_fst_of_right :
    Set.range (pullback.fst : pullback g f ⟶ Y).1.base =
      ((Opens.map g.1.base).obj ⟨Set.range f.1.base, H.base_open.open_range⟩).1 := by
  rw [←
    show _ = (pullback.fst : pullback g f ⟶ _).1.base from
      PreservesPullback.iso_hom_fst Scheme.forgetToTop g f]
  -- Porting note : was `rw`
  erw [coe_comp]
  rw [Set.range_comp, Set.range_iff_surjective.mpr, ←
    @Set.preimage_univ _ _ (pullback.snd : pullback g.1.base f.1.base ⟶ _)]
  -- Porting note : was `rw`
  erw [TopCat.pullback_fst_image_snd_preimage]
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Scheme
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
⊢ ⇑(Scheme.forgetToTop.map g) ⁻¹' (⇑(Scheme.forgetToTop.map f) '' Set.univ) =
    ((Opens.map g.val.base).obj
        { carrier := Set.range ⇑f.val.base, is_open' := (_ : IsOpen (Set.range ⇑f.val.base)) }).carrier
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Scheme
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
⊢ Function.Surjective ⇑(PreservesPullback.iso Scheme.forgetToTop g f).hom

Next tactic:
rw [Set.image_univ]
theorem range_pullback_fst_of_right :
    Set.range (pullback.fst : pullback g f ⟶ Y).1.base =
      ((Opens.map g.1.base).obj ⟨Set.range f.1.base, H.base_open.open_range⟩).1 := by
  rw [←
    show _ = (pullback.fst : pullback g f ⟶ _).1.base from
      PreservesPullback.iso_hom_fst Scheme.forgetToTop g f]
  -- Porting note : was `rw`
  erw [coe_comp]
  rw [Set.range_comp, Set.range_iff_surjective.mpr, ←
    @Set.preimage_univ _ _ (pullback.snd : pullback g.1.base f.1.base ⟶ _)]
  -- Porting note : was `rw`
  erw [TopCat.pullback_fst_image_snd_preimage]
  rw [Set.image_univ]
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Scheme
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
⊢ ⇑(Scheme.forgetToTop.map g) ⁻¹' Set.range ⇑(Scheme.forgetToTop.map f) =
    ((Opens.map g.val.base).obj
        { carrier := Set.range ⇑f.val.base, is_open' := (_ : IsOpen (Set.range ⇑f.val.base)) }).carrier
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Scheme
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
⊢ Function.Surjective ⇑(PreservesPullback.iso Scheme.forgetToTop g f).hom

Next tactic:
rfl
theorem range_pullback_fst_of_right :
    Set.range (pullback.fst : pullback g f ⟶ Y).1.base =
      ((Opens.map g.1.base).obj ⟨Set.range f.1.base, H.base_open.open_range⟩).1 := by
  rw [←
    show _ = (pullback.fst : pullback g f ⟶ _).1.base from
      PreservesPullback.iso_hom_fst Scheme.forgetToTop g f]
  -- Porting note : was `rw`
  erw [coe_comp]
  rw [Set.range_comp, Set.range_iff_surjective.mpr, ←
    @Set.preimage_univ _ _ (pullback.snd : pullback g.1.base f.1.base ⟶ _)]
  -- Porting note : was `rw`
  erw [TopCat.pullback_fst_image_snd_preimage]
  rw [Set.image_univ]
  rfl
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Scheme
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
⊢ Function.Surjective ⇑(PreservesPullback.iso Scheme.forgetToTop g f).hom

Next tactic:
rw [← TopCat.epi_iff_surjective]
theorem range_pullback_fst_of_right :
    Set.range (pullback.fst : pullback g f ⟶ Y).1.base =
      ((Opens.map g.1.base).obj ⟨Set.range f.1.base, H.base_open.open_range⟩).1 := by
  rw [←
    show _ = (pullback.fst : pullback g f ⟶ _).1.base from
      PreservesPullback.iso_hom_fst Scheme.forgetToTop g f]
  -- Porting note : was `rw`
  erw [coe_comp]
  rw [Set.range_comp, Set.range_iff_surjective.mpr, ←
    @Set.preimage_univ _ _ (pullback.snd : pullback g.1.base f.1.base ⟶ _)]
  -- Porting note : was `rw`
  erw [TopCat.pullback_fst_image_snd_preimage]
  rw [Set.image_univ]
  rfl
  rw [← TopCat.epi_iff_surjective]
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Scheme
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
⊢ Epi (PreservesPullback.iso Scheme.forgetToTop g f).hom

Next tactic:
infer_instance
theorem range_pullback_to_base_of_left :
    Set.range (pullback.fst ≫ f : pullback f g ⟶ Z).1.base =
      Set.range f.1.base ∩ Set.range g.1.base := by
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Scheme
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
⊢ Set.range ⇑(pullback.fst ≫ f).val.base = Set.range ⇑f.val.base ∩ Set.range ⇑g.val.base

Next tactic:
rw [pullback.condition, Scheme.comp_val_base, coe_comp, Set.range_comp,
    range_pullback_snd_of_left, Opens.carrier_eq_coe,
    Opens.map_obj, Opens.coe_mk, Set.image_preimage_eq_inter_range,
    Set.inter_comm]
theorem range_pullback_to_base_of_right :
    Set.range (pullback.fst ≫ g : pullback g f ⟶ Z).1.base =
      Set.range g.1.base ∩ Set.range f.1.base := by
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X Y Z : Scheme
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
⊢ Set.range ⇑(pullback.fst ≫ g).val.base = Set.range ⇑g.val.base ∩ Set.range ⇑f.val.base

Next tactic:
rw [Scheme.comp_val_base, coe_comp, Set.range_comp, range_pullback_fst_of_right, Opens.map_obj,
    Opens.carrier_eq_coe, Opens.coe_mk, Set.image_preimage_eq_inter_range, Set.inter_comm]
/-- Two open immersions with equal range are isomorphic. -/
def isoOfRangeEq [IsOpenImmersion g] (e : Set.range f.1.base = Set.range g.1.base) : X ≅ Y where
  hom := lift g f (le_of_eq e)
  inv := lift f g (le_of_eq e.symm)
  hom_inv_id := by 

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X Y Z : Scheme
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
inst✝ : IsOpenImmersion g
e : Set.range ⇑f.val.base = Set.range ⇑g.val.base
⊢ lift g f (_ : Set.range ⇑f.val.base ≤ Set.range ⇑g.val.base) ≫
      lift f g (_ : Set.range ⇑g.val.base ≤ Set.range ⇑f.val.base) =
    𝟙 X

Next tactic:
rw [← cancel_mono f]
/-- Two open immersions with equal range are isomorphic. -/
def isoOfRangeEq [IsOpenImmersion g] (e : Set.range f.1.base = Set.range g.1.base) : X ≅ Y where
  hom := lift g f (le_of_eq e)
  inv := lift f g (le_of_eq e.symm)
  hom_inv_id := by rw [← cancel_mono f]; 

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X Y Z : Scheme
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
inst✝ : IsOpenImmersion g
e : Set.range ⇑f.val.base = Set.range ⇑g.val.base
⊢ (lift g f (_ : Set.range ⇑f.val.base ≤ Set.range ⇑g.val.base) ≫
        lift f g (_ : Set.range ⇑g.val.base ≤ Set.range ⇑f.val.base)) ≫
      f =
    𝟙 X ≫ f

Next tactic:
simp
/-- Two open immersions with equal range are isomorphic. -/
def isoOfRangeEq [IsOpenImmersion g] (e : Set.range f.1.base = Set.range g.1.base) : X ≅ Y where
  hom := lift g f (le_of_eq e)
  inv := lift f g (le_of_eq e.symm)
  hom_inv_id := by rw [← cancel_mono f]; simp
  inv_hom_id := by 

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X Y Z : Scheme
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
inst✝ : IsOpenImmersion g
e : Set.range ⇑f.val.base = Set.range ⇑g.val.base
⊢ lift f g (_ : Set.range ⇑g.val.base ≤ Set.range ⇑f.val.base) ≫
      lift g f (_ : Set.range ⇑f.val.base ≤ Set.range ⇑g.val.base) =
    𝟙 Y

Next tactic:
rw [← cancel_mono g]
/-- Two open immersions with equal range are isomorphic. -/
def isoOfRangeEq [IsOpenImmersion g] (e : Set.range f.1.base = Set.range g.1.base) : X ≅ Y where
  hom := lift g f (le_of_eq e)
  inv := lift f g (le_of_eq e.symm)
  hom_inv_id := by rw [← cancel_mono f]; simp
  inv_hom_id := by rw [← cancel_mono g]; 

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X Y Z : Scheme
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
inst✝ : IsOpenImmersion g
e : Set.range ⇑f.val.base = Set.range ⇑g.val.base
⊢ (lift f g (_ : Set.range ⇑g.val.base ≤ Set.range ⇑f.val.base) ≫
        lift g f (_ : Set.range ⇑f.val.base ≤ Set.range ⇑g.val.base)) ≫
      g =
    𝟙 Y ≫ g

Next tactic:
simp
theorem app_eq_inv_app_app_of_comp_eq_aux {X Y U : Scheme} (f : Y ⟶ U) (g : U ⟶ X) (fg : Y ⟶ X)
    (H : fg = f ≫ g) [h : IsOpenImmersion g] (V : Opens U) :
    (Opens.map f.1.base).obj V = (Opens.map fg.1.base).obj (g.opensFunctor.obj V) := by
  

Proof state:
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
fg : Y ⟶ X
H : fg = f ≫ g
h : IsOpenImmersion g
V : Opens ↑↑U.toPresheafedSpace
⊢ (Opens.map f.val.base).obj V = (Opens.map fg.val.base).obj ((Scheme.Hom.opensFunctor g).obj V)

Next tactic:
subst H
theorem app_eq_inv_app_app_of_comp_eq_aux {X Y U : Scheme} (f : Y ⟶ U) (g : U ⟶ X) (fg : Y ⟶ X)
    (H : fg = f ≫ g) [h : IsOpenImmersion g] (V : Opens U) :
    (Opens.map f.1.base).obj V = (Opens.map fg.1.base).obj (g.opensFunctor.obj V) := by
  subst H
  

Proof state:
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
⊢ (Opens.map f.val.base).obj V = (Opens.map (f ≫ g).val.base).obj ((Scheme.Hom.opensFunctor g).obj V)

Next tactic:
rw [Scheme.comp_val_base, Opens.map_comp_obj]
theorem app_eq_inv_app_app_of_comp_eq_aux {X Y U : Scheme} (f : Y ⟶ U) (g : U ⟶ X) (fg : Y ⟶ X)
    (H : fg = f ≫ g) [h : IsOpenImmersion g] (V : Opens U) :
    (Opens.map f.1.base).obj V = (Opens.map fg.1.base).obj (g.opensFunctor.obj V) := by
  subst H
  rw [Scheme.comp_val_base, Opens.map_comp_obj]
  

Proof state:
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
⊢ (Opens.map f.val.base).obj V =
    (Opens.map f.val.base).obj ((Opens.map g.val.base).obj ((Scheme.Hom.opensFunctor g).obj V))

Next tactic:
congr 1
theorem app_eq_inv_app_app_of_comp_eq_aux {X Y U : Scheme} (f : Y ⟶ U) (g : U ⟶ X) (fg : Y ⟶ X)
    (H : fg = f ≫ g) [h : IsOpenImmersion g] (V : Opens U) :
    (Opens.map f.1.base).obj V = (Opens.map fg.1.base).obj (g.opensFunctor.obj V) := by
  subst H
  rw [Scheme.comp_val_base, Opens.map_comp_obj]
  congr 1
  

Proof state:
case e_a
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
⊢ V = (Opens.map g.val.base).obj ((Scheme.Hom.opensFunctor g).obj V)

Next tactic:
ext1
theorem app_eq_inv_app_app_of_comp_eq_aux {X Y U : Scheme} (f : Y ⟶ U) (g : U ⟶ X) (fg : Y ⟶ X)
    (H : fg = f ≫ g) [h : IsOpenImmersion g] (V : Opens U) :
    (Opens.map f.1.base).obj V = (Opens.map fg.1.base).obj (g.opensFunctor.obj V) := by
  subst H
  rw [Scheme.comp_val_base, Opens.map_comp_obj]
  congr 1
  ext1
  

Proof state:
case e_a.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
⊢ ↑V = ↑((Opens.map g.val.base).obj ((Scheme.Hom.opensFunctor g).obj V))

Next tactic:
exact (Set.preimage_image_eq _ h.base_open.inj).symm
/-- 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
  

Proof state:
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
fg : Y ⟶ X
H : fg = f ≫ g
h : IsOpenImmersion g
V : Opens ↑↑U.toPresheafedSpace
⊢ f.val.c.app (op V) =
    Scheme.Hom.invApp g V ≫
      fg.val.c.app (op ((Scheme.Hom.opensFunctor g).obj V)) ≫
        Y.presheaf.map
          (eqToHom
              (_ : (Opens.map f.val.base).obj V = (Opens.map fg.val.base).obj ((Scheme.Hom.opensFunctor g).obj V))).op

Next tactic:
subst H
/-- 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
  

Proof state:
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
⊢ f.val.c.app (op V) =
    Scheme.Hom.invApp g V ≫
      (f ≫ g).val.c.app (op ((Scheme.Hom.opensFunctor g).obj V)) ≫
        Y.presheaf.map
          (eqToHom
              (_ :
                (Opens.map f.val.base).obj V = (Opens.map (f ≫ g).val.base).obj ((Scheme.Hom.opensFunctor g).obj V))).op

Next tactic:
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]
/-- 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]
  

Proof state:
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
⊢ f.val.c.app (op V) =
    f.val.c.app (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)

Next tactic:
convert (Category.comp_id <| f.1.c.app (op V)).symm