l3lab/ntp-mathlib huggingface dataset:
theorem pullback_snd_isIso_of_range_subset (H' : Set.range g.1.base ⊆ Set.range f.1.base) :
    IsIso (pullback.snd : pullback f g ⟶ _) := by
  -- Porting note : was `apply (config := { instances := False }) ...`
  -- See https://github.com/leanprover/lean4/issues/2273
  have h1 := @ReflectsIsomorphisms.reflects (F := LocallyRingedSpace.forgetToSheafedSpace) _ _ _
  refine @h1 _ _ _ ?_; clear h1
  -- Porting note : was `apply (config := { instances := False }) ...`
  -- See https://github.com/leanprover/lean4/issues/2273
  have h2 := @ReflectsIsomorphisms.reflects
    (F := SheafedSpace.forgetToPresheafedSpace (C := CommRingCat)) _ _ _
  refine @h2 _ _ _ ?_; clear h2
  erw [← PreservesPullback.iso_hom_snd
      (LocallyRingedSpace.forgetToSheafedSpace ⋙ SheafedSpace.forgetToPresheafedSpace) f g]
  -- Porting note : was `inferInstance`
  

Proof state:
C : Type u_1
inst✝ : Category.{?u.534473, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
H' : Set.range ⇑g.val.base ⊆ Set.range ⇑f.val.base
⊢ IsIso ((PreservesPullback.iso (forgetToSheafedSpace ⋙ SheafedSpace.forgetToPresheafedSpace) f g).hom ≫ pullback.snd)

Next tactic:
exact @IsIso.comp_isIso _ _ _ _ _ _ _ _ <|
    PresheafedSpace.IsOpenImmersion.pullback_snd_isIso_of_range_subset _ _ H'
@[simp, reassoc]
theorem lift_fac (H' : Set.range g.1.base ⊆ Set.range f.1.base) : lift f g H' ≫ f = g := by
  -- Porting note : added instance manually
  

Proof state:
C : Type u_1
inst✝ : Category.{?u.540273, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
H' : Set.range ⇑g.val.base ⊆ Set.range ⇑f.val.base
⊢ lift f g H' ≫ f = g

Next tactic:
haveI := pullback_snd_isIso_of_range_subset f g H'
@[simp, reassoc]
theorem lift_fac (H' : Set.range g.1.base ⊆ Set.range f.1.base) : lift f g H' ≫ f = g := by
  -- Porting note : added instance manually
  haveI := pullback_snd_isIso_of_range_subset f g H'
  

Proof state:
C : Type u_1
inst✝ : Category.{?u.540273, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
H' : Set.range ⇑g.val.base ⊆ Set.range ⇑f.val.base
this : IsIso pullback.snd
⊢ lift f g H' ≫ f = g

Next tactic:
erw [Category.assoc]
@[simp, reassoc]
theorem lift_fac (H' : Set.range g.1.base ⊆ Set.range f.1.base) : lift f g H' ≫ f = g := by
  -- Porting note : added instance manually
  haveI := pullback_snd_isIso_of_range_subset f g H'
  erw [Category.assoc]; 

Proof state:
C : Type u_1
inst✝ : Category.{?u.540273, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
H' : Set.range ⇑g.val.base ⊆ Set.range ⇑f.val.base
this : IsIso pullback.snd
⊢ inv pullback.snd ≫ pullback.fst ≫ f = g

Next tactic:
rw [IsIso.inv_comp_eq]
@[simp, reassoc]
theorem lift_fac (H' : Set.range g.1.base ⊆ Set.range f.1.base) : lift f g H' ≫ f = g := by
  -- Porting note : added instance manually
  haveI := pullback_snd_isIso_of_range_subset f g H'
  erw [Category.assoc]; rw [IsIso.inv_comp_eq]; 

Proof state:
C : Type u_1
inst✝ : Category.{?u.540273, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
H' : Set.range ⇑g.val.base ⊆ Set.range ⇑f.val.base
this : IsIso pullback.snd
⊢ pullback.fst ≫ f = pullback.snd ≫ g

Next tactic:
exact pullback.condition
theorem lift_uniq (H' : Set.range g.1.base ⊆ Set.range f.1.base) (l : Y ⟶ X) (hl : l ≫ f = g) :
    l = lift f g H' := by 

Proof state:
C : Type u_1
inst✝ : Category.{?u.542346, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
H' : Set.range ⇑g.val.base ⊆ Set.range ⇑f.val.base
l : Y ⟶ X
hl : l ≫ f = g
⊢ l = lift f g H'

Next tactic:
rw [← cancel_mono f, hl, lift_fac]
theorem lift_range (H' : Set.range g.1.base ⊆ Set.range f.1.base) :
    Set.range (lift f g H').1.base = f.1.base ⁻¹' Set.range g.1.base := by
  -- Porting note : added instance manually
  

Proof state:
C : Type u_1
inst✝ : Category.{?u.542810, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
H' : Set.range ⇑g.val.base ⊆ Set.range ⇑f.val.base
⊢ Set.range ⇑(lift f g H').val.base = ⇑f.val.base ⁻¹' Set.range ⇑g.val.base

Next tactic:
have := pullback_snd_isIso_of_range_subset f g H'
theorem lift_range (H' : Set.range g.1.base ⊆ Set.range f.1.base) :
    Set.range (lift f g H').1.base = f.1.base ⁻¹' Set.range g.1.base := by
  -- Porting note : added instance manually
  have := pullback_snd_isIso_of_range_subset f g H'
  

Proof state:
C : Type u_1
inst✝ : Category.{?u.542810, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
H' : Set.range ⇑g.val.base ⊆ Set.range ⇑f.val.base
this : IsIso pullback.snd
⊢ Set.range ⇑(lift f g H').val.base = ⇑f.val.base ⁻¹' Set.range ⇑g.val.base

Next tactic:
dsimp only [lift]
theorem lift_range (H' : Set.range g.1.base ⊆ Set.range f.1.base) :
    Set.range (lift f g H').1.base = f.1.base ⁻¹' Set.range g.1.base := by
  -- Porting note : added instance manually
  have := pullback_snd_isIso_of_range_subset f g H'
  dsimp only [lift]
  

Proof state:
C : Type u_1
inst✝ : Category.{?u.542810, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
H' : Set.range ⇑g.val.base ⊆ Set.range ⇑f.val.base
this : IsIso pullback.snd
⊢ Set.range ⇑(inv pullback.snd ≫ pullback.fst).val.base = ⇑f.val.base ⁻¹' Set.range ⇑g.val.base

Next tactic:
have : _ = (pullback.fst : pullback f g ⟶ _).val.base :=
    PreservesPullback.iso_hom_fst
      (LocallyRingedSpace.forgetToSheafedSpace ⋙ SheafedSpace.forget _) f g
theorem lift_range (H' : Set.range g.1.base ⊆ Set.range f.1.base) :
    Set.range (lift f g H').1.base = f.1.base ⁻¹' Set.range g.1.base := by
  -- Porting note : added instance manually
  have := pullback_snd_isIso_of_range_subset f g H'
  dsimp only [lift]
  have : _ = (pullback.fst : pullback f g ⟶ _).val.base :=
    PreservesPullback.iso_hom_fst
      (LocallyRingedSpace.forgetToSheafedSpace ⋙ SheafedSpace.forget _) f g
  

Proof state:
C : Type u_1
inst✝ : Category.{?u.542810, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
H' : Set.range ⇑g.val.base ⊆ Set.range ⇑f.val.base
this✝ : IsIso pullback.snd
this :
  (PreservesPullback.iso (forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat) f g).hom ≫ pullback.fst =
    pullback.fst.val.base
⊢ Set.range ⇑(inv pullback.snd ≫ pullback.fst).val.base = ⇑f.val.base ⁻¹' Set.range ⇑g.val.base

Next tactic:
rw [LocallyRingedSpace.comp_val, SheafedSpace.comp_base, ← this, ← Category.assoc, coe_comp]
theorem lift_range (H' : Set.range g.1.base ⊆ Set.range f.1.base) :
    Set.range (lift f g H').1.base = f.1.base ⁻¹' Set.range g.1.base := by
  -- Porting note : added instance manually
  have := pullback_snd_isIso_of_range_subset f g H'
  dsimp only [lift]
  have : _ = (pullback.fst : pullback f g ⟶ _).val.base :=
    PreservesPullback.iso_hom_fst
      (LocallyRingedSpace.forgetToSheafedSpace ⋙ SheafedSpace.forget _) f g
  rw [LocallyRingedSpace.comp_val, SheafedSpace.comp_base, ← this, ← Category.assoc, coe_comp]
  

Proof state:
C : Type u_1
inst✝ : Category.{?u.542810, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
H' : Set.range ⇑g.val.base ⊆ Set.range ⇑f.val.base
this✝ : IsIso pullback.snd
this :
  (PreservesPullback.iso (forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat) f g).hom ≫ pullback.fst =
    pullback.fst.val.base
⊢ Set.range
      (⇑pullback.fst ∘
        ⇑((inv pullback.snd).val.base ≫
            (PreservesPullback.iso (forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat) f g).hom)) =
    ⇑f.val.base ⁻¹' Set.range ⇑g.val.base

Next tactic:
rw [Set.range_comp, Set.range_iff_surjective.mpr, Set.image_univ]
theorem lift_range (H' : Set.range g.1.base ⊆ Set.range f.1.base) :
    Set.range (lift f g H').1.base = f.1.base ⁻¹' Set.range g.1.base := by
  -- Porting note : added instance manually
  have := pullback_snd_isIso_of_range_subset f g H'
  dsimp only [lift]
  have : _ = (pullback.fst : pullback f g ⟶ _).val.base :=
    PreservesPullback.iso_hom_fst
      (LocallyRingedSpace.forgetToSheafedSpace ⋙ SheafedSpace.forget _) f g
  rw [LocallyRingedSpace.comp_val, SheafedSpace.comp_base, ← this, ← Category.assoc, coe_comp]
  rw [Set.range_comp, Set.range_iff_surjective.mpr, Set.image_univ]
  -- Porting note : change `rw` to `erw` on this lemma
  

Proof state:
C : Type u_1
inst✝ : Category.{?u.542810, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
H' : Set.range ⇑g.val.base ⊆ Set.range ⇑f.val.base
this✝ : IsIso pullback.snd
this :
  (PreservesPullback.iso (forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat) f g).hom ≫ pullback.fst =
    pullback.fst.val.base
⊢ Set.range ⇑pullback.fst = ⇑f.val.base ⁻¹' Set.range ⇑g.val.base
C : Type u_1
inst✝ : Category.{?u.542810, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
H' : Set.range ⇑g.val.base ⊆ Set.range ⇑f.val.base
this✝ : IsIso pullback.snd
this :
  (PreservesPullback.iso (forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat) f g).hom ≫ pullback.fst =
    pullback.fst.val.base
⊢ Function.Surjective
    ⇑((inv pullback.snd).val.base ≫
        (PreservesPullback.iso (forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat) f g).hom)

Next tactic:
erw [TopCat.pullback_fst_range]
theorem lift_range (H' : Set.range g.1.base ⊆ Set.range f.1.base) :
    Set.range (lift f g H').1.base = f.1.base ⁻¹' Set.range g.1.base := by
  -- Porting note : added instance manually
  have := pullback_snd_isIso_of_range_subset f g H'
  dsimp only [lift]
  have : _ = (pullback.fst : pullback f g ⟶ _).val.base :=
    PreservesPullback.iso_hom_fst
      (LocallyRingedSpace.forgetToSheafedSpace ⋙ SheafedSpace.forget _) f g
  rw [LocallyRingedSpace.comp_val, SheafedSpace.comp_base, ← this, ← Category.assoc, coe_comp]
  rw [Set.range_comp, Set.range_iff_surjective.mpr, Set.image_univ]
  -- Porting note : change `rw` to `erw` on this lemma
  erw [TopCat.pullback_fst_range]
  

Proof state:
C : Type u_1
inst✝ : Category.{?u.542810, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
H' : Set.range ⇑g.val.base ⊆ Set.range ⇑f.val.base
this✝ : IsIso pullback.snd
this :
  (PreservesPullback.iso (forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat) f g).hom ≫ pullback.fst =
    pullback.fst.val.base
⊢ {x |
      ∃ y,
        ((forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat).map f) x =
          ((forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat).map g) y} =
    ⇑f.val.base ⁻¹' Set.range ⇑g.val.base
C : Type u_1
inst✝ : Category.{?u.542810, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
H' : Set.range ⇑g.val.base ⊆ Set.range ⇑f.val.base
this✝ : IsIso pullback.snd
this :
  (PreservesPullback.iso (forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat) f g).hom ≫ pullback.fst =
    pullback.fst.val.base
⊢ Function.Surjective
    ⇑((inv pullback.snd).val.base ≫
        (PreservesPullback.iso (forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat) f g).hom)

Next tactic:
ext
theorem lift_range (H' : Set.range g.1.base ⊆ Set.range f.1.base) :
    Set.range (lift f g H').1.base = f.1.base ⁻¹' Set.range g.1.base := by
  -- Porting note : added instance manually
  have := pullback_snd_isIso_of_range_subset f g H'
  dsimp only [lift]
  have : _ = (pullback.fst : pullback f g ⟶ _).val.base :=
    PreservesPullback.iso_hom_fst
      (LocallyRingedSpace.forgetToSheafedSpace ⋙ SheafedSpace.forget _) f g
  rw [LocallyRingedSpace.comp_val, SheafedSpace.comp_base, ← this, ← Category.assoc, coe_comp]
  rw [Set.range_comp, Set.range_iff_surjective.mpr, Set.image_univ]
  -- Porting note : change `rw` to `erw` on this lemma
  erw [TopCat.pullback_fst_range]
  ext
  

Proof state:
case h
C : Type u_1
inst✝ : Category.{?u.542810, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
H' : Set.range ⇑g.val.base ⊆ Set.range ⇑f.val.base
this✝ : IsIso pullback.snd
this :
  (PreservesPullback.iso (forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat) f g).hom ≫ pullback.fst =
    pullback.fst.val.base
x✝ : ↑((forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat).obj X)
⊢ x✝ ∈
      {x |
        ∃ y,
          ((forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat).map f) x =
            ((forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat).map g) y} ↔
    x✝ ∈ ⇑f.val.base ⁻¹' Set.range ⇑g.val.base
C : Type u_1
inst✝ : Category.{?u.542810, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
H' : Set.range ⇑g.val.base ⊆ Set.range ⇑f.val.base
this✝ : IsIso pullback.snd
this :
  (PreservesPullback.iso (forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat) f g).hom ≫ pullback.fst =
    pullback.fst.val.base
⊢ Function.Surjective
    ⇑((inv pullback.snd).val.base ≫
        (PreservesPullback.iso (forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat) f g).hom)

Next tactic:
constructor
theorem lift_range (H' : Set.range g.1.base ⊆ Set.range f.1.base) :
    Set.range (lift f g H').1.base = f.1.base ⁻¹' Set.range g.1.base := by
  -- Porting note : added instance manually
  have := pullback_snd_isIso_of_range_subset f g H'
  dsimp only [lift]
  have : _ = (pullback.fst : pullback f g ⟶ _).val.base :=
    PreservesPullback.iso_hom_fst
      (LocallyRingedSpace.forgetToSheafedSpace ⋙ SheafedSpace.forget _) f g
  rw [LocallyRingedSpace.comp_val, SheafedSpace.comp_base, ← this, ← Category.assoc, coe_comp]
  rw [Set.range_comp, Set.range_iff_surjective.mpr, Set.image_univ]
  -- Porting note : change `rw` to `erw` on this lemma
  erw [TopCat.pullback_fst_range]
  ext
  constructor
  · 

Proof state:
case h.mp
C : Type u_1
inst✝ : Category.{?u.542810, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
H' : Set.range ⇑g.val.base ⊆ Set.range ⇑f.val.base
this✝ : IsIso pullback.snd
this :
  (PreservesPullback.iso (forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat) f g).hom ≫ pullback.fst =
    pullback.fst.val.base
x✝ : ↑((forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat).obj X)
⊢ x✝ ∈
      {x |
        ∃ y,
          ((forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat).map f) x =
            ((forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat).map g) y} →
    x✝ ∈ ⇑f.val.base ⁻¹' Set.range ⇑g.val.base

Next tactic:
rintro ⟨y, eq⟩
theorem lift_range (H' : Set.range g.1.base ⊆ Set.range f.1.base) :
    Set.range (lift f g H').1.base = f.1.base ⁻¹' Set.range g.1.base := by
  -- Porting note : added instance manually
  have := pullback_snd_isIso_of_range_subset f g H'
  dsimp only [lift]
  have : _ = (pullback.fst : pullback f g ⟶ _).val.base :=
    PreservesPullback.iso_hom_fst
      (LocallyRingedSpace.forgetToSheafedSpace ⋙ SheafedSpace.forget _) f g
  rw [LocallyRingedSpace.comp_val, SheafedSpace.comp_base, ← this, ← Category.assoc, coe_comp]
  rw [Set.range_comp, Set.range_iff_surjective.mpr, Set.image_univ]
  -- Porting note : change `rw` to `erw` on this lemma
  erw [TopCat.pullback_fst_range]
  ext
  constructor
  · rintro ⟨y, eq⟩; 

Proof state:
case h.mp.intro
C : Type u_1
inst✝ : Category.{?u.542810, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
H' : Set.range ⇑g.val.base ⊆ Set.range ⇑f.val.base
this✝ : IsIso pullback.snd
this :
  (PreservesPullback.iso (forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat) f g).hom ≫ pullback.fst =
    pullback.fst.val.base
x✝ : ↑((forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat).obj X)
y : ↑((forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat).obj Y)
eq :
  ((forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat).map f) x✝ =
    ((forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat).map g) y
⊢ x✝ ∈ ⇑f.val.base ⁻¹' Set.range ⇑g.val.base

Next tactic:
exact ⟨y, eq.symm⟩
theorem lift_range (H' : Set.range g.1.base ⊆ Set.range f.1.base) :
    Set.range (lift f g H').1.base = f.1.base ⁻¹' Set.range g.1.base := by
  -- Porting note : added instance manually
  have := pullback_snd_isIso_of_range_subset f g H'
  dsimp only [lift]
  have : _ = (pullback.fst : pullback f g ⟶ _).val.base :=
    PreservesPullback.iso_hom_fst
      (LocallyRingedSpace.forgetToSheafedSpace ⋙ SheafedSpace.forget _) f g
  rw [LocallyRingedSpace.comp_val, SheafedSpace.comp_base, ← this, ← Category.assoc, coe_comp]
  rw [Set.range_comp, Set.range_iff_surjective.mpr, Set.image_univ]
  -- Porting note : change `rw` to `erw` on this lemma
  erw [TopCat.pullback_fst_range]
  ext
  constructor
  · rintro ⟨y, eq⟩; exact ⟨y, eq.symm⟩
  · 

Proof state:
case h.mpr
C : Type u_1
inst✝ : Category.{?u.542810, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
H' : Set.range ⇑g.val.base ⊆ Set.range ⇑f.val.base
this✝ : IsIso pullback.snd
this :
  (PreservesPullback.iso (forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat) f g).hom ≫ pullback.fst =
    pullback.fst.val.base
x✝ : ↑((forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat).obj X)
⊢ x✝ ∈ ⇑f.val.base ⁻¹' Set.range ⇑g.val.base →
    x✝ ∈
      {x |
        ∃ y,
          ((forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat).map f) x =
            ((forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat).map g) y}

Next tactic:
rintro ⟨y, eq⟩
theorem lift_range (H' : Set.range g.1.base ⊆ Set.range f.1.base) :
    Set.range (lift f g H').1.base = f.1.base ⁻¹' Set.range g.1.base := by
  -- Porting note : added instance manually
  have := pullback_snd_isIso_of_range_subset f g H'
  dsimp only [lift]
  have : _ = (pullback.fst : pullback f g ⟶ _).val.base :=
    PreservesPullback.iso_hom_fst
      (LocallyRingedSpace.forgetToSheafedSpace ⋙ SheafedSpace.forget _) f g
  rw [LocallyRingedSpace.comp_val, SheafedSpace.comp_base, ← this, ← Category.assoc, coe_comp]
  rw [Set.range_comp, Set.range_iff_surjective.mpr, Set.image_univ]
  -- Porting note : change `rw` to `erw` on this lemma
  erw [TopCat.pullback_fst_range]
  ext
  constructor
  · rintro ⟨y, eq⟩; exact ⟨y, eq.symm⟩
  · rintro ⟨y, eq⟩; 

Proof state:
case h.mpr.intro
C : Type u_1
inst✝ : Category.{?u.542810, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
H' : Set.range ⇑g.val.base ⊆ Set.range ⇑f.val.base
this✝ : IsIso pullback.snd
this :
  (PreservesPullback.iso (forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat) f g).hom ≫ pullback.fst =
    pullback.fst.val.base
x✝ : ↑((forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat).obj X)
y : (forget TopCat).obj ↑Y.toPresheafedSpace
eq : g.val.base y = f.val.base x✝
⊢ x✝ ∈
    {x |
      ∃ y,
        ((forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat).map f) x =
          ((forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat).map g) y}

Next tactic:
exact ⟨y, eq.symm⟩
theorem lift_range (H' : Set.range g.1.base ⊆ Set.range f.1.base) :
    Set.range (lift f g H').1.base = f.1.base ⁻¹' Set.range g.1.base := by
  -- Porting note : added instance manually
  have := pullback_snd_isIso_of_range_subset f g H'
  dsimp only [lift]
  have : _ = (pullback.fst : pullback f g ⟶ _).val.base :=
    PreservesPullback.iso_hom_fst
      (LocallyRingedSpace.forgetToSheafedSpace ⋙ SheafedSpace.forget _) f g
  rw [LocallyRingedSpace.comp_val, SheafedSpace.comp_base, ← this, ← Category.assoc, coe_comp]
  rw [Set.range_comp, Set.range_iff_surjective.mpr, Set.image_univ]
  -- Porting note : change `rw` to `erw` on this lemma
  erw [TopCat.pullback_fst_range]
  ext
  constructor
  · rintro ⟨y, eq⟩; exact ⟨y, eq.symm⟩
  · rintro ⟨y, eq⟩; exact ⟨y, eq.symm⟩
  · 

Proof state:
C : Type u_1
inst✝ : Category.{?u.542810, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
H' : Set.range ⇑g.val.base ⊆ Set.range ⇑f.val.base
this✝ : IsIso pullback.snd
this :
  (PreservesPullback.iso (forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat) f g).hom ≫ pullback.fst =
    pullback.fst.val.base
⊢ Function.Surjective
    ⇑((inv pullback.snd).val.base ≫
        (PreservesPullback.iso (forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat) f g).hom)

Next tactic:
rw [← TopCat.epi_iff_surjective]
theorem lift_range (H' : Set.range g.1.base ⊆ Set.range f.1.base) :
    Set.range (lift f g H').1.base = f.1.base ⁻¹' Set.range g.1.base := by
  -- Porting note : added instance manually
  have := pullback_snd_isIso_of_range_subset f g H'
  dsimp only [lift]
  have : _ = (pullback.fst : pullback f g ⟶ _).val.base :=
    PreservesPullback.iso_hom_fst
      (LocallyRingedSpace.forgetToSheafedSpace ⋙ SheafedSpace.forget _) f g
  rw [LocallyRingedSpace.comp_val, SheafedSpace.comp_base, ← this, ← Category.assoc, coe_comp]
  rw [Set.range_comp, Set.range_iff_surjective.mpr, Set.image_univ]
  -- Porting note : change `rw` to `erw` on this lemma
  erw [TopCat.pullback_fst_range]
  ext
  constructor
  · rintro ⟨y, eq⟩; exact ⟨y, eq.symm⟩
  · rintro ⟨y, eq⟩; exact ⟨y, eq.symm⟩
  · rw [← TopCat.epi_iff_surjective]
    

Proof state:
C : Type u_1
inst✝ : Category.{?u.542810, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
H' : Set.range ⇑g.val.base ⊆ Set.range ⇑f.val.base
this✝ : IsIso pullback.snd
this :
  (PreservesPullback.iso (forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat) f g).hom ≫ pullback.fst =
    pullback.fst.val.base
⊢ Epi
    ((inv pullback.snd).val.base ≫
      (PreservesPullback.iso (forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat) f g).hom)

Next tactic:
rw [show (inv (pullback.snd : pullback f g ⟶ _)).val.base = _ from
        (LocallyRingedSpace.forgetToSheafedSpace ⋙ SheafedSpace.forget _).map_inv _]
theorem lift_range (H' : Set.range g.1.base ⊆ Set.range f.1.base) :
    Set.range (lift f g H').1.base = f.1.base ⁻¹' Set.range g.1.base := by
  -- Porting note : added instance manually
  have := pullback_snd_isIso_of_range_subset f g H'
  dsimp only [lift]
  have : _ = (pullback.fst : pullback f g ⟶ _).val.base :=
    PreservesPullback.iso_hom_fst
      (LocallyRingedSpace.forgetToSheafedSpace ⋙ SheafedSpace.forget _) f g
  rw [LocallyRingedSpace.comp_val, SheafedSpace.comp_base, ← this, ← Category.assoc, coe_comp]
  rw [Set.range_comp, Set.range_iff_surjective.mpr, Set.image_univ]
  -- Porting note : change `rw` to `erw` on this lemma
  erw [TopCat.pullback_fst_range]
  ext
  constructor
  · rintro ⟨y, eq⟩; exact ⟨y, eq.symm⟩
  · rintro ⟨y, eq⟩; exact ⟨y, eq.symm⟩
  · rw [← TopCat.epi_iff_surjective]
    rw [show (inv (pullback.snd : pullback f g ⟶ _)).val.base = _ from
        (LocallyRingedSpace.forgetToSheafedSpace ⋙ SheafedSpace.forget _).map_inv _]
    

Proof state:
C : Type u_1
inst✝ : Category.{?u.542810, u_1} C
X Y Z : LocallyRingedSpace
f : X ⟶ Z
g : Y ⟶ Z
H : IsOpenImmersion f
H' : Set.range ⇑g.val.base ⊆ Set.range ⇑f.val.base
this✝ : IsIso pullback.snd
this :
  (PreservesPullback.iso (forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat) f g).hom ≫ pullback.fst =
    pullback.fst.val.base
⊢ Epi
    (inv ((forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat).map pullback.snd) ≫
      (PreservesPullback.iso (forgetToSheafedSpace ⋙ SheafedSpace.forget CommRingCat) f g).hom)

Next tactic:
infer_instance
/-- An open immersion is isomorphic to the induced open subscheme on its image. -/
noncomputable def isoRestrict {X Y : LocallyRingedSpace} {f : X ⟶ Y}
    (H : LocallyRingedSpace.IsOpenImmersion f) :
    X ≅ Y.restrict H.base_open := by
  

Proof state:
C : Type u_1
inst✝ : Category.{?u.554179, u_1} C
X Y : LocallyRingedSpace
f : X ⟶ Y
H : IsOpenImmersion f
⊢ X ≅ restrict Y (_ : OpenEmbedding ⇑f.val.base)

Next tactic:
apply LocallyRingedSpace.isoOfSheafedSpaceIso
/-- An open immersion is isomorphic to the induced open subscheme on its image. -/
noncomputable def isoRestrict {X Y : LocallyRingedSpace} {f : X ⟶ Y}
    (H : LocallyRingedSpace.IsOpenImmersion f) :
    X ≅ Y.restrict H.base_open := by
  apply LocallyRingedSpace.isoOfSheafedSpaceIso
  

Proof state:
case f
C : Type u_1
inst✝ : Category.{?u.554179, u_1} C
X Y : LocallyRingedSpace
f : X ⟶ Y
H : IsOpenImmersion f
⊢ X.toSheafedSpace ≅ (restrict Y (_ : OpenEmbedding ⇑f.val.base)).toSheafedSpace

Next tactic:
refine' SheafedSpace.forgetToPresheafedSpace.preimageIso _