l3lab/ntp-mathlib huggingface dataset:
theorem affineBasisCover_is_basis (X : Scheme) :
    TopologicalSpace.IsTopologicalBasis
      {x : Set X |
        ∃ a : X.affineBasisCover.J, x = Set.range (X.affineBasisCover.map a).1.base} := by
  apply TopologicalSpace.isTopologicalBasis_of_isOpen_of_nhds
  · rintro _ ⟨a, rfl⟩
    exact IsOpenImmersion.open_range (X.affineBasisCover.map a)
  · rintro a U haU hU
    rcases X.affineCover.Covers a with ⟨x, e⟩
    let U' := (X.affineCover.map (X.affineCover.f a)).1.base ⁻¹' U
    have hxU' : x ∈ U' := by rw [← e] at haU; exact haU
    rcases PrimeSpectrum.isBasis_basic_opens.exists_subset_of_mem_open hxU'
        ((X.affineCover.map (X.affineCover.f a)).1.base.continuous_toFun.isOpen_preimage _
          hU) with
      ⟨_, ⟨_, ⟨s, rfl⟩, rfl⟩, hxV, hVU⟩
    refine' ⟨_, ⟨⟨_, s⟩, rfl⟩, _, _⟩ <;> erw [affineBasisCover_map_range]
    · exact ⟨x, hxV, e⟩
    · 

Proof state:
case h_nhds.intro.intro.intro.intro.intro.intro.intro.refine'_2
C : Type u
inst✝¹ : Category.{v, u} C
X✝ Y Z : Scheme
𝒰 : OpenCover X✝
f : X✝ ⟶ Z
g : Y ⟶ Z
inst✝ : ∀ (x : 𝒰.J), HasPullback (OpenCover.map 𝒰 x ≫ f) g
X : Scheme
a : ↑↑X.toPresheafedSpace
U : Set ↑↑X.toPresheafedSpace
haU : a ∈ U
hU : IsOpen U
x : (forget TopCat).obj ↑(OpenCover.obj (affineCover X) (OpenCover.f (affineCover X) a)).toPresheafedSpace
e : (OpenCover.map (affineCover X) (OpenCover.f (affineCover X) a)).val.base x = a
U' : Set ((forget TopCat).obj ↑(OpenCover.obj (affineCover X) (OpenCover.f (affineCover X) a)).toPresheafedSpace) :=
  ⇑(OpenCover.map (affineCover X) (OpenCover.f (affineCover X) a)).val.base ⁻¹' U
hxU' : x ∈ U'
s :
  ↑(op
        (Exists.choose
          (_ :
            ∃ R,
              Nonempty
                (LocallyRingedSpace.restrict X.toLocallyRingedSpace
                    (_ :
                      OpenEmbedding
                        ⇑(Opens.inclusion
                            (Exists.choose
                                (_ :
                                  ∃ U R,
                                    Nonempty
                                      (LocallyRingedSpace.restrict X.toLocallyRingedSpace
                                          (_ : OpenEmbedding ⇑(Opens.inclusion U.obj)) ≅
                                        Spec.toLocallyRingedSpace.obj (op R)))).obj)) ≅
                  Spec.toLocallyRingedSpace.obj (op R))))).unop
hxV : x ∈ ↑(PrimeSpectrum.basicOpen s)
hVU : ↑(PrimeSpectrum.basicOpen s) ⊆ U'
⊢ ⇑(OpenCover.map (affineCover X) (OpenCover.f (affineCover X) a)).val.base '' (PrimeSpectrum.basicOpen s).carrier ⊆ U

Next tactic:
rw [Set.image_subset_iff]
theorem affineBasisCover_is_basis (X : Scheme) :
    TopologicalSpace.IsTopologicalBasis
      {x : Set X |
        ∃ a : X.affineBasisCover.J, x = Set.range (X.affineBasisCover.map a).1.base} := by
  apply TopologicalSpace.isTopologicalBasis_of_isOpen_of_nhds
  · rintro _ ⟨a, rfl⟩
    exact IsOpenImmersion.open_range (X.affineBasisCover.map a)
  · rintro a U haU hU
    rcases X.affineCover.Covers a with ⟨x, e⟩
    let U' := (X.affineCover.map (X.affineCover.f a)).1.base ⁻¹' U
    have hxU' : x ∈ U' := by rw [← e] at haU; exact haU
    rcases PrimeSpectrum.isBasis_basic_opens.exists_subset_of_mem_open hxU'
        ((X.affineCover.map (X.affineCover.f a)).1.base.continuous_toFun.isOpen_preimage _
          hU) with
      ⟨_, ⟨_, ⟨s, rfl⟩, rfl⟩, hxV, hVU⟩
    refine' ⟨_, ⟨⟨_, s⟩, rfl⟩, _, _⟩ <;> erw [affineBasisCover_map_range]
    · exact ⟨x, hxV, e⟩
    · rw [Set.image_subset_iff]; 

Proof state:
case h_nhds.intro.intro.intro.intro.intro.intro.intro.refine'_2
C : Type u
inst✝¹ : Category.{v, u} C
X✝ Y Z : Scheme
𝒰 : OpenCover X✝
f : X✝ ⟶ Z
g : Y ⟶ Z
inst✝ : ∀ (x : 𝒰.J), HasPullback (OpenCover.map 𝒰 x ≫ f) g
X : Scheme
a : ↑↑X.toPresheafedSpace
U : Set ↑↑X.toPresheafedSpace
haU : a ∈ U
hU : IsOpen U
x : (forget TopCat).obj ↑(OpenCover.obj (affineCover X) (OpenCover.f (affineCover X) a)).toPresheafedSpace
e : (OpenCover.map (affineCover X) (OpenCover.f (affineCover X) a)).val.base x = a
U' : Set ((forget TopCat).obj ↑(OpenCover.obj (affineCover X) (OpenCover.f (affineCover X) a)).toPresheafedSpace) :=
  ⇑(OpenCover.map (affineCover X) (OpenCover.f (affineCover X) a)).val.base ⁻¹' U
hxU' : x ∈ U'
s :
  ↑(op
        (Exists.choose
          (_ :
            ∃ R,
              Nonempty
                (LocallyRingedSpace.restrict X.toLocallyRingedSpace
                    (_ :
                      OpenEmbedding
                        ⇑(Opens.inclusion
                            (Exists.choose
                                (_ :
                                  ∃ U R,
                                    Nonempty
                                      (LocallyRingedSpace.restrict X.toLocallyRingedSpace
                                          (_ : OpenEmbedding ⇑(Opens.inclusion U.obj)) ≅
                                        Spec.toLocallyRingedSpace.obj (op R)))).obj)) ≅
                  Spec.toLocallyRingedSpace.obj (op R))))).unop
hxV : x ∈ ↑(PrimeSpectrum.basicOpen s)
hVU : ↑(PrimeSpectrum.basicOpen s) ⊆ U'
⊢ (PrimeSpectrum.basicOpen s).carrier ⊆ ⇑(OpenCover.map (affineCover X) (OpenCover.f (affineCover X) a)).val.base ⁻¹' U

Next tactic:
exact hVU
/-- Every open cover of a quasi-compact scheme can be refined into a finite subcover.
-/
@[simps! obj map]
def OpenCover.finiteSubcover {X : Scheme} (𝒰 : OpenCover X) [H : CompactSpace X] :
    OpenCover X := by
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X✝ Y Z : Scheme
𝒰✝ : OpenCover X✝
f : X✝ ⟶ Z
g : Y ⟶ Z
inst✝ : ∀ (x : 𝒰✝.J), HasPullback (map 𝒰✝ x ≫ f) g
X : Scheme
𝒰 : OpenCover X
H : CompactSpace ↑↑X.toPresheafedSpace
⊢ OpenCover X

Next tactic:
have :=
    @CompactSpace.elim_nhds_subcover _ _ H (fun x : X => Set.range (𝒰.map (𝒰.f x)).1.base)
      fun x => (IsOpenImmersion.open_range (𝒰.map (𝒰.f x))).mem_nhds (𝒰.Covers x)
/-- Every open cover of a quasi-compact scheme can be refined into a finite subcover.
-/
@[simps! obj map]
def OpenCover.finiteSubcover {X : Scheme} (𝒰 : OpenCover X) [H : CompactSpace X] :
    OpenCover X := by
  have :=
    @CompactSpace.elim_nhds_subcover _ _ H (fun x : X => Set.range (𝒰.map (𝒰.f x)).1.base)
      fun x => (IsOpenImmersion.open_range (𝒰.map (𝒰.f x))).mem_nhds (𝒰.Covers x)
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X✝ Y Z : Scheme
𝒰✝ : OpenCover X✝
f : X✝ ⟶ Z
g : Y ⟶ Z
inst✝ : ∀ (x : 𝒰✝.J), HasPullback (map 𝒰✝ x ≫ f) g
X : Scheme
𝒰 : OpenCover X
H : CompactSpace ↑↑X.toPresheafedSpace
this : ∃ t, ⋃ x ∈ t, (fun x => Set.range ⇑(map 𝒰 (AlgebraicGeometry.Scheme.OpenCover.f 𝒰 x)).val.base) x = ⊤
⊢ OpenCover X

Next tactic:
let t := this.choose
/-- Every open cover of a quasi-compact scheme can be refined into a finite subcover.
-/
@[simps! obj map]
def OpenCover.finiteSubcover {X : Scheme} (𝒰 : OpenCover X) [H : CompactSpace X] :
    OpenCover X := by
  have :=
    @CompactSpace.elim_nhds_subcover _ _ H (fun x : X => Set.range (𝒰.map (𝒰.f x)).1.base)
      fun x => (IsOpenImmersion.open_range (𝒰.map (𝒰.f x))).mem_nhds (𝒰.Covers x)
  let t := this.choose
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X✝ Y Z : Scheme
𝒰✝ : OpenCover X✝
f : X✝ ⟶ Z
g : Y ⟶ Z
inst✝ : ∀ (x : 𝒰✝.J), HasPullback (map 𝒰✝ x ≫ f) g
X : Scheme
𝒰 : OpenCover X
H : CompactSpace ↑↑X.toPresheafedSpace
this : ∃ t, ⋃ x ∈ t, (fun x => Set.range ⇑(map 𝒰 (AlgebraicGeometry.Scheme.OpenCover.f 𝒰 x)).val.base) x = ⊤
t : Finset ↑↑X.toPresheafedSpace := Exists.choose this
⊢ OpenCover X

Next tactic:
have h : ∀ x : X, ∃ y : t, x ∈ Set.range (𝒰.map (𝒰.f y)).1.base := by
    intro x
    have h' : x ∈ (⊤ : Set X) := trivial
    rw [← Classical.choose_spec this, Set.mem_iUnion] at h'
    rcases h' with ⟨y, _, ⟨hy, rfl⟩, hy'⟩
    exact ⟨⟨y, hy⟩, hy'⟩
/-- Every open cover of a quasi-compact scheme can be refined into a finite subcover.
-/
@[simps! obj map]
def OpenCover.finiteSubcover {X : Scheme} (𝒰 : OpenCover X) [H : CompactSpace X] :
    OpenCover X := by
  have :=
    @CompactSpace.elim_nhds_subcover _ _ H (fun x : X => Set.range (𝒰.map (𝒰.f x)).1.base)
      fun x => (IsOpenImmersion.open_range (𝒰.map (𝒰.f x))).mem_nhds (𝒰.Covers x)
  let t := this.choose
  have h : ∀ x : X, ∃ y : t, x ∈ Set.range (𝒰.map (𝒰.f y)).1.base := by
    

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X✝ Y Z : Scheme
𝒰✝ : OpenCover X✝
f : X✝ ⟶ Z
g : Y ⟶ Z
inst✝ : ∀ (x : 𝒰✝.J), HasPullback (map 𝒰✝ x ≫ f) g
X : Scheme
𝒰 : OpenCover X
H : CompactSpace ↑↑X.toPresheafedSpace
this : ∃ t, ⋃ x ∈ t, (fun x => Set.range ⇑(map 𝒰 (AlgebraicGeometry.Scheme.OpenCover.f 𝒰 x)).val.base) x = ⊤
t : Finset ↑↑X.toPresheafedSpace := Exists.choose this
⊢ ∀ (x : ↑↑X.toPresheafedSpace), ∃ y, x ∈ Set.range ⇑(map 𝒰 (AlgebraicGeometry.Scheme.OpenCover.f 𝒰 ↑y)).val.base

Next tactic:
intro x
/-- Every open cover of a quasi-compact scheme can be refined into a finite subcover.
-/
@[simps! obj map]
def OpenCover.finiteSubcover {X : Scheme} (𝒰 : OpenCover X) [H : CompactSpace X] :
    OpenCover X := by
  have :=
    @CompactSpace.elim_nhds_subcover _ _ H (fun x : X => Set.range (𝒰.map (𝒰.f x)).1.base)
      fun x => (IsOpenImmersion.open_range (𝒰.map (𝒰.f x))).mem_nhds (𝒰.Covers x)
  let t := this.choose
  have h : ∀ x : X, ∃ y : t, x ∈ Set.range (𝒰.map (𝒰.f y)).1.base := by
    intro x
    

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X✝ Y Z : Scheme
𝒰✝ : OpenCover X✝
f : X✝ ⟶ Z
g : Y ⟶ Z
inst✝ : ∀ (x : 𝒰✝.J), HasPullback (map 𝒰✝ x ≫ f) g
X : Scheme
𝒰 : OpenCover X
H : CompactSpace ↑↑X.toPresheafedSpace
this : ∃ t, ⋃ x ∈ t, (fun x => Set.range ⇑(map 𝒰 (AlgebraicGeometry.Scheme.OpenCover.f 𝒰 x)).val.base) x = ⊤
t : Finset ↑↑X.toPresheafedSpace := Exists.choose this
x : ↑↑X.toPresheafedSpace
⊢ ∃ y, x ∈ Set.range ⇑(map 𝒰 (AlgebraicGeometry.Scheme.OpenCover.f 𝒰 ↑y)).val.base

Next tactic:
have h' : x ∈ (⊤ : Set X) := trivial
/-- Every open cover of a quasi-compact scheme can be refined into a finite subcover.
-/
@[simps! obj map]
def OpenCover.finiteSubcover {X : Scheme} (𝒰 : OpenCover X) [H : CompactSpace X] :
    OpenCover X := by
  have :=
    @CompactSpace.elim_nhds_subcover _ _ H (fun x : X => Set.range (𝒰.map (𝒰.f x)).1.base)
      fun x => (IsOpenImmersion.open_range (𝒰.map (𝒰.f x))).mem_nhds (𝒰.Covers x)
  let t := this.choose
  have h : ∀ x : X, ∃ y : t, x ∈ Set.range (𝒰.map (𝒰.f y)).1.base := by
    intro x
    have h' : x ∈ (⊤ : Set X) := trivial
    

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X✝ Y Z : Scheme
𝒰✝ : OpenCover X✝
f : X✝ ⟶ Z
g : Y ⟶ Z
inst✝ : ∀ (x : 𝒰✝.J), HasPullback (map 𝒰✝ x ≫ f) g
X : Scheme
𝒰 : OpenCover X
H : CompactSpace ↑↑X.toPresheafedSpace
this : ∃ t, ⋃ x ∈ t, (fun x => Set.range ⇑(map 𝒰 (AlgebraicGeometry.Scheme.OpenCover.f 𝒰 x)).val.base) x = ⊤
t : Finset ↑↑X.toPresheafedSpace := Exists.choose this
x : ↑↑X.toPresheafedSpace
h' : x ∈ ⊤
⊢ ∃ y, x ∈ Set.range ⇑(map 𝒰 (AlgebraicGeometry.Scheme.OpenCover.f 𝒰 ↑y)).val.base

Next tactic:
rw [← Classical.choose_spec this, Set.mem_iUnion] at h'
/-- Every open cover of a quasi-compact scheme can be refined into a finite subcover.
-/
@[simps! obj map]
def OpenCover.finiteSubcover {X : Scheme} (𝒰 : OpenCover X) [H : CompactSpace X] :
    OpenCover X := by
  have :=
    @CompactSpace.elim_nhds_subcover _ _ H (fun x : X => Set.range (𝒰.map (𝒰.f x)).1.base)
      fun x => (IsOpenImmersion.open_range (𝒰.map (𝒰.f x))).mem_nhds (𝒰.Covers x)
  let t := this.choose
  have h : ∀ x : X, ∃ y : t, x ∈ Set.range (𝒰.map (𝒰.f y)).1.base := by
    intro x
    have h' : x ∈ (⊤ : Set X) := trivial
    rw [← Classical.choose_spec this, Set.mem_iUnion] at h'
    

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X✝ Y Z : Scheme
𝒰✝ : OpenCover X✝
f : X✝ ⟶ Z
g : Y ⟶ Z
inst✝ : ∀ (x : 𝒰✝.J), HasPullback (map 𝒰✝ x ≫ f) g
X : Scheme
𝒰 : OpenCover X
H : CompactSpace ↑↑X.toPresheafedSpace
this : ∃ t, ⋃ x ∈ t, (fun x => Set.range ⇑(map 𝒰 (AlgebraicGeometry.Scheme.OpenCover.f 𝒰 x)).val.base) x = ⊤
t : Finset ↑↑X.toPresheafedSpace := Exists.choose this
x : ↑↑X.toPresheafedSpace
h' :
  ∃ i,
    x ∈
      ⋃ (_ : i ∈ Classical.choose this),
        (fun x => Set.range ⇑(map 𝒰 (AlgebraicGeometry.Scheme.OpenCover.f 𝒰 x)).val.base) i
⊢ ∃ y, x ∈ Set.range ⇑(map 𝒰 (AlgebraicGeometry.Scheme.OpenCover.f 𝒰 ↑y)).val.base

Next tactic:
rcases h' with ⟨y, _, ⟨hy, rfl⟩, hy'⟩
/-- Every open cover of a quasi-compact scheme can be refined into a finite subcover.
-/
@[simps! obj map]
def OpenCover.finiteSubcover {X : Scheme} (𝒰 : OpenCover X) [H : CompactSpace X] :
    OpenCover X := by
  have :=
    @CompactSpace.elim_nhds_subcover _ _ H (fun x : X => Set.range (𝒰.map (𝒰.f x)).1.base)
      fun x => (IsOpenImmersion.open_range (𝒰.map (𝒰.f x))).mem_nhds (𝒰.Covers x)
  let t := this.choose
  have h : ∀ x : X, ∃ y : t, x ∈ Set.range (𝒰.map (𝒰.f y)).1.base := by
    intro x
    have h' : x ∈ (⊤ : Set X) := trivial
    rw [← Classical.choose_spec this, Set.mem_iUnion] at h'
    rcases h' with ⟨y, _, ⟨hy, rfl⟩, hy'⟩
    

Proof state:
case intro.intro.intro.intro
C : Type u
inst✝¹ : Category.{v, u} C
X✝ Y Z : Scheme
𝒰✝ : OpenCover X✝
f : X✝ ⟶ Z
g : Y ⟶ Z
inst✝ : ∀ (x : 𝒰✝.J), HasPullback (map 𝒰✝ x ≫ f) g
X : Scheme
𝒰 : OpenCover X
H : CompactSpace ↑↑X.toPresheafedSpace
this : ∃ t, ⋃ x ∈ t, (fun x => Set.range ⇑(map 𝒰 (AlgebraicGeometry.Scheme.OpenCover.f 𝒰 x)).val.base) x = ⊤
t : Finset ↑↑X.toPresheafedSpace := Exists.choose this
x y : ↑↑X.toPresheafedSpace
hy : y ∈ Classical.choose this
hy' : x ∈ (fun h => (fun x => Set.range ⇑(map 𝒰 (AlgebraicGeometry.Scheme.OpenCover.f 𝒰 x)).val.base) y) hy
⊢ ∃ y, x ∈ Set.range ⇑(map 𝒰 (AlgebraicGeometry.Scheme.OpenCover.f 𝒰 ↑y)).val.base

Next tactic:
exact ⟨⟨y, hy⟩, hy'⟩
/-- Every open cover of a quasi-compact scheme can be refined into a finite subcover.
-/
@[simps! obj map]
def OpenCover.finiteSubcover {X : Scheme} (𝒰 : OpenCover X) [H : CompactSpace X] :
    OpenCover X := by
  have :=
    @CompactSpace.elim_nhds_subcover _ _ H (fun x : X => Set.range (𝒰.map (𝒰.f x)).1.base)
      fun x => (IsOpenImmersion.open_range (𝒰.map (𝒰.f x))).mem_nhds (𝒰.Covers x)
  let t := this.choose
  have h : ∀ x : X, ∃ y : t, x ∈ Set.range (𝒰.map (𝒰.f y)).1.base := by
    intro x
    have h' : x ∈ (⊤ : Set X) := trivial
    rw [← Classical.choose_spec this, Set.mem_iUnion] at h'
    rcases h' with ⟨y, _, ⟨hy, rfl⟩, hy'⟩
    exact ⟨⟨y, hy⟩, hy'⟩
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X✝ Y Z : Scheme
𝒰✝ : OpenCover X✝
f : X✝ ⟶ Z
g : Y ⟶ Z
inst✝ : ∀ (x : 𝒰✝.J), HasPullback (map 𝒰✝ x ≫ f) g
X : Scheme
𝒰 : OpenCover X
H : CompactSpace ↑↑X.toPresheafedSpace
this : ∃ t, ⋃ x ∈ t, (fun x => Set.range ⇑(map 𝒰 (AlgebraicGeometry.Scheme.OpenCover.f 𝒰 x)).val.base) x = ⊤
t : Finset ↑↑X.toPresheafedSpace := Exists.choose this
h : ∀ (x : ↑↑X.toPresheafedSpace), ∃ y, x ∈ Set.range ⇑(map 𝒰 (AlgebraicGeometry.Scheme.OpenCover.f 𝒰 ↑y)).val.base
⊢ OpenCover X

Next tactic:
exact
    { J := t
      obj := fun x => 𝒰.obj (𝒰.f x.1)
      map := fun x => 𝒰.map (𝒰.f x.1)
      f := fun x => (h x).choose
      Covers := fun x => (h x).choose_spec }
instance [H : CompactSpace X] : Fintype 𝒰.finiteSubcover.J := by
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X Y Z : Scheme
𝒰 : OpenCover X
f : X ⟶ Z
g : Y ⟶ Z
inst✝ : ∀ (x : 𝒰.J), HasPullback (OpenCover.map 𝒰 x ≫ f) g
H : CompactSpace ↑↑X.toPresheafedSpace
⊢ Fintype (OpenCover.finiteSubcover 𝒰).J

Next tactic:
delta OpenCover.finiteSubcover
instance [H : CompactSpace X] : Fintype 𝒰.finiteSubcover.J := by
  delta OpenCover.finiteSubcover; 

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X Y Z : Scheme
𝒰 : OpenCover X
f : X ⟶ Z
g : Y ⟶ Z
inst✝ : ∀ (x : 𝒰.J), HasPullback (OpenCover.map 𝒰 x ≫ f) g
H : CompactSpace ↑↑X.toPresheafedSpace
⊢ Fintype
    (let_fun this := (_ : ∃ t, ⋃ x ∈ t, Set.range ⇑(OpenCover.map 𝒰 (OpenCover.f 𝒰 x)).val.base = ⊤);
      let t := Exists.choose this;
      let_fun h :=
        (_ : ∀ (x : ↑↑X.toPresheafedSpace), ∃ y, x ∈ Set.range ⇑(OpenCover.map 𝒰 (OpenCover.f 𝒰 ↑y)).val.base);
      OpenCover.mk { x // x ∈ t } (fun x => OpenCover.obj 𝒰 (OpenCover.f 𝒰 ↑x))
        (fun x => OpenCover.map 𝒰 (OpenCover.f 𝒰 ↑x))
        (fun x => Exists.choose (_ : ∃ y, x ∈ Set.range ⇑(OpenCover.map 𝒰 (OpenCover.f 𝒰 ↑y)).val.base))
        (_ :
          ∀ (x : ↑↑X.toPresheafedSpace),
            x ∈
              Set.range
                ⇑(OpenCover.map 𝒰
                        (OpenCover.f 𝒰
                          ↑(Exists.choose
                              (_ : ∃ y, x ∈ Set.range ⇑(OpenCover.map 𝒰 (OpenCover.f 𝒰 ↑y)).val.base)))).val.base)).J

Next tactic:
infer_instance
/-- If `X ⟶ Y` is an open immersion, and `Y` is a scheme, then so is `X`. -/
def toScheme : Scheme := by
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X : PresheafedSpace CommRingCat
Y : Scheme
f : X ⟶ Y.toPresheafedSpace
H : IsOpenImmersion f
⊢ Scheme

Next tactic:
apply LocallyRingedSpace.IsOpenImmersion.scheme (toLocallyRingedSpace _ f)
/-- If `X ⟶ Y` is an open immersion, and `Y` is a scheme, then so is `X`. -/
def toScheme : Scheme := by
  apply LocallyRingedSpace.IsOpenImmersion.scheme (toLocallyRingedSpace _ f)
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X : PresheafedSpace CommRingCat
Y : Scheme
f : X ⟶ Y.toPresheafedSpace
H : IsOpenImmersion f
⊢ ∀ (x : ↑(LocallyRingedSpace.toTopCat (toLocallyRingedSpace Y.toLocallyRingedSpace f))),
    ∃ R f_1, x ∈ Set.range ⇑f_1.val.base ∧ LocallyRingedSpace.IsOpenImmersion f_1

Next tactic:
intro x
/-- If `X ⟶ Y` is an open immersion, and `Y` is a scheme, then so is `X`. -/
def toScheme : Scheme := by
  apply LocallyRingedSpace.IsOpenImmersion.scheme (toLocallyRingedSpace _ f)
  intro x
  

Proof state:
C : Type u
inst✝ : Category.{v, u} C
X : PresheafedSpace CommRingCat
Y : Scheme
f : X ⟶ Y.toPresheafedSpace
H : IsOpenImmersion f
x : ↑(LocallyRingedSpace.toTopCat (toLocallyRingedSpace Y.toLocallyRingedSpace f))
⊢ ∃ R f_1, x ∈ Set.range ⇑f_1.val.base ∧ LocallyRingedSpace.IsOpenImmersion f_1

Next tactic:
obtain ⟨_, ⟨i, rfl⟩, hx, hi⟩ :=
    Y.affineBasisCover_is_basis.exists_subset_of_mem_open (Set.mem_range_self x)
      H.base_open.open_range
/-- If `X ⟶ Y` is an open immersion, and `Y` is a scheme, then so is `X`. -/
def toScheme : Scheme := by
  apply LocallyRingedSpace.IsOpenImmersion.scheme (toLocallyRingedSpace _ f)
  intro x
  obtain ⟨_, ⟨i, rfl⟩, hx, hi⟩ :=
    Y.affineBasisCover_is_basis.exists_subset_of_mem_open (Set.mem_range_self x)
      H.base_open.open_range
  

Proof state:
case intro.intro.intro.intro
C : Type u
inst✝ : Category.{v, u} C
X : PresheafedSpace CommRingCat
Y : Scheme
f : X ⟶ Y.toPresheafedSpace
H : IsOpenImmersion f
x : ↑(LocallyRingedSpace.toTopCat (toLocallyRingedSpace Y.toLocallyRingedSpace f))
i : (Scheme.affineBasisCover Y).J
hx : f.base x ∈ Set.range ⇑(Scheme.OpenCover.map (Scheme.affineBasisCover Y) i).val.base
hi : Set.range ⇑(Scheme.OpenCover.map (Scheme.affineBasisCover Y) i).val.base ⊆ Set.range ⇑f.base
⊢ ∃ R f_1, x ∈ Set.range ⇑f_1.val.base ∧ LocallyRingedSpace.IsOpenImmersion f_1

Next tactic:
use Y.affineBasisCoverRing i
/-- If `X ⟶ Y` is an open immersion, and `Y` is a scheme, then so is `X`. -/
def toScheme : Scheme := by
  apply LocallyRingedSpace.IsOpenImmersion.scheme (toLocallyRingedSpace _ f)
  intro x
  obtain ⟨_, ⟨i, rfl⟩, hx, hi⟩ :=
    Y.affineBasisCover_is_basis.exists_subset_of_mem_open (Set.mem_range_self x)
      H.base_open.open_range
  use Y.affineBasisCoverRing i
  

Proof state:
case h
C : Type u
inst✝ : Category.{v, u} C
X : PresheafedSpace CommRingCat
Y : Scheme
f : X ⟶ Y.toPresheafedSpace
H : IsOpenImmersion f
x : ↑(LocallyRingedSpace.toTopCat (toLocallyRingedSpace Y.toLocallyRingedSpace f))
i : (Scheme.affineBasisCover Y).J
hx : f.base x ∈ Set.range ⇑(Scheme.OpenCover.map (Scheme.affineBasisCover Y) i).val.base
hi : Set.range ⇑(Scheme.OpenCover.map (Scheme.affineBasisCover Y) i).val.base ⊆ Set.range ⇑f.base
⊢ ∃ f_1, x ∈ Set.range ⇑f_1.val.base ∧ LocallyRingedSpace.IsOpenImmersion f_1

Next tactic:
use LocallyRingedSpace.IsOpenImmersion.lift (toLocallyRingedSpaceHom _ f) _ hi
/-- If `X ⟶ Y` is an open immersion, and `Y` is a scheme, then so is `X`. -/
def toScheme : Scheme := by
  apply LocallyRingedSpace.IsOpenImmersion.scheme (toLocallyRingedSpace _ f)
  intro x
  obtain ⟨_, ⟨i, rfl⟩, hx, hi⟩ :=
    Y.affineBasisCover_is_basis.exists_subset_of_mem_open (Set.mem_range_self x)
      H.base_open.open_range
  use Y.affineBasisCoverRing i
  use LocallyRingedSpace.IsOpenImmersion.lift (toLocallyRingedSpaceHom _ f) _ hi
  

Proof state:
case h
C : Type u
inst✝ : Category.{v, u} C
X : PresheafedSpace CommRingCat
Y : Scheme
f : X ⟶ Y.toPresheafedSpace
H : IsOpenImmersion f
x : ↑(LocallyRingedSpace.toTopCat (toLocallyRingedSpace Y.toLocallyRingedSpace f))
i : (Scheme.affineBasisCover Y).J
hx : f.base x ∈ Set.range ⇑(Scheme.OpenCover.map (Scheme.affineBasisCover Y) i).val.base
hi : Set.range ⇑(Scheme.OpenCover.map (Scheme.affineBasisCover Y) i).val.base ⊆ Set.range ⇑f.base
⊢ x ∈
      Set.range
        ⇑(LocallyRingedSpace.IsOpenImmersion.lift (toLocallyRingedSpaceHom Y.toLocallyRingedSpace f)
                (Scheme.OpenCover.map (Scheme.affineBasisCover Y) i) hi).val.base ∧
    LocallyRingedSpace.IsOpenImmersion
      (LocallyRingedSpace.IsOpenImmersion.lift (toLocallyRingedSpaceHom Y.toLocallyRingedSpace f)
        (Scheme.OpenCover.map (Scheme.affineBasisCover Y) i) hi)

Next tactic:
constructor
/-- If `X ⟶ Y` is an open immersion, and `Y` is a scheme, then so is `X`. -/
def toScheme : Scheme := by
  apply LocallyRingedSpace.IsOpenImmersion.scheme (toLocallyRingedSpace _ f)
  intro x
  obtain ⟨_, ⟨i, rfl⟩, hx, hi⟩ :=
    Y.affineBasisCover_is_basis.exists_subset_of_mem_open (Set.mem_range_self x)
      H.base_open.open_range
  use Y.affineBasisCoverRing i
  use LocallyRingedSpace.IsOpenImmersion.lift (toLocallyRingedSpaceHom _ f) _ hi
  constructor
  · 

Proof state:
case h.left
C : Type u
inst✝ : Category.{v, u} C
X : PresheafedSpace CommRingCat
Y : Scheme
f : X ⟶ Y.toPresheafedSpace
H : IsOpenImmersion f
x : ↑(LocallyRingedSpace.toTopCat (toLocallyRingedSpace Y.toLocallyRingedSpace f))
i : (Scheme.affineBasisCover Y).J
hx : f.base x ∈ Set.range ⇑(Scheme.OpenCover.map (Scheme.affineBasisCover Y) i).val.base
hi : Set.range ⇑(Scheme.OpenCover.map (Scheme.affineBasisCover Y) i).val.base ⊆ Set.range ⇑f.base
⊢ x ∈
    Set.range
      ⇑(LocallyRingedSpace.IsOpenImmersion.lift (toLocallyRingedSpaceHom Y.toLocallyRingedSpace f)
              (Scheme.OpenCover.map (Scheme.affineBasisCover Y) i) hi).val.base

Next tactic:
rw [LocallyRingedSpace.IsOpenImmersion.lift_range]
/-- If `X ⟶ Y` is an open immersion, and `Y` is a scheme, then so is `X`. -/
def toScheme : Scheme := by
  apply LocallyRingedSpace.IsOpenImmersion.scheme (toLocallyRingedSpace _ f)
  intro x
  obtain ⟨_, ⟨i, rfl⟩, hx, hi⟩ :=
    Y.affineBasisCover_is_basis.exists_subset_of_mem_open (Set.mem_range_self x)
      H.base_open.open_range
  use Y.affineBasisCoverRing i
  use LocallyRingedSpace.IsOpenImmersion.lift (toLocallyRingedSpaceHom _ f) _ hi
  constructor
  · rw [LocallyRingedSpace.IsOpenImmersion.lift_range]; 

Proof state:
case h.left
C : Type u
inst✝ : Category.{v, u} C
X : PresheafedSpace CommRingCat
Y : Scheme
f : X ⟶ Y.toPresheafedSpace
H : IsOpenImmersion f
x : ↑(LocallyRingedSpace.toTopCat (toLocallyRingedSpace Y.toLocallyRingedSpace f))
i : (Scheme.affineBasisCover Y).J
hx : f.base x ∈ Set.range ⇑(Scheme.OpenCover.map (Scheme.affineBasisCover Y) i).val.base
hi : Set.range ⇑(Scheme.OpenCover.map (Scheme.affineBasisCover Y) i).val.base ⊆ Set.range ⇑f.base
⊢ x ∈
    ⇑(toLocallyRingedSpaceHom Y.toLocallyRingedSpace f).val.base ⁻¹'
      Set.range ⇑(Scheme.OpenCover.map (Scheme.affineBasisCover Y) i).val.base

Next tactic:
exact hx