l3lab/ntp-mathlib huggingface dataset:
theorem isBasis_affine_open (X : Scheme) : Opens.IsBasis X.affineOpens := by
  rw [Opens.isBasis_iff_nbhd]
  rintro U x (hU : x ∈ (U : Set X))
  obtain ⟨S, hS, hxS, hSU⟩ := X.affineBasisCover_is_basis.exists_subset_of_mem_open hU U.isOpen
  refine' ⟨⟨S, X.affineBasisCover_is_basis.isOpen hS⟩, _, hxS, hSU⟩
  

Proof state:
case intro.intro.intro
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
x : ↑↑X.toPresheafedSpace
hU : x ∈ ↑U
S : Set ↑↑X.toPresheafedSpace
hS : S ∈ {x | ∃ a, x = Set.range ⇑(Scheme.OpenCover.map (Scheme.affineBasisCover X) a).val.base}
hxS : x ∈ S
hSU : S ⊆ ↑U
⊢ { carrier := S, is_open' := (_ : IsOpen S) } ∈ Scheme.affineOpens X

Next tactic:
rcases hS with ⟨i, rfl⟩
theorem isBasis_affine_open (X : Scheme) : Opens.IsBasis X.affineOpens := by
  rw [Opens.isBasis_iff_nbhd]
  rintro U x (hU : x ∈ (U : Set X))
  obtain ⟨S, hS, hxS, hSU⟩ := X.affineBasisCover_is_basis.exists_subset_of_mem_open hU U.isOpen
  refine' ⟨⟨S, X.affineBasisCover_is_basis.isOpen hS⟩, _, hxS, hSU⟩
  rcases hS with ⟨i, rfl⟩
  

Proof state:
case intro.intro.intro.intro
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
x : ↑↑X.toPresheafedSpace
hU : x ∈ ↑U
i : (Scheme.affineBasisCover X).J
hxS : x ∈ Set.range ⇑(Scheme.OpenCover.map (Scheme.affineBasisCover X) i).val.base
hSU : Set.range ⇑(Scheme.OpenCover.map (Scheme.affineBasisCover X) i).val.base ⊆ ↑U
⊢ { carrier := Set.range ⇑(Scheme.OpenCover.map (Scheme.affineBasisCover X) i).val.base,
      is_open' := (_ : IsOpen (Set.range ⇑(Scheme.OpenCover.map (Scheme.affineBasisCover X) i).val.base)) } ∈
    Scheme.affineOpens X

Next tactic:
exact rangeIsAffineOpenOfOpenImmersion _
theorem Scheme.map_PrimeSpectrum_basicOpen_of_affine
    (X : Scheme) [IsAffine X] (f : Scheme.Γ.obj (op X)) :
    X.isoSpec.hom ⁻¹ᵁ PrimeSpectrum.basicOpen f = X.basicOpen f := by
  

Proof state:
X : Scheme
inst✝ : IsAffine X
f : ↑(Γ.obj (op X))
⊢ (isoSpec X).hom⁻¹ᵁ PrimeSpectrum.basicOpen f = X.basicOpen f

Next tactic:
rw [← basicOpen_eq_of_affine]
theorem Scheme.map_PrimeSpectrum_basicOpen_of_affine
    (X : Scheme) [IsAffine X] (f : Scheme.Γ.obj (op X)) :
    X.isoSpec.hom ⁻¹ᵁ PrimeSpectrum.basicOpen f = X.basicOpen f := by
  rw [← basicOpen_eq_of_affine]
  

Proof state:
X : Scheme
inst✝ : IsAffine X
f : ↑(Γ.obj (op X))
⊢ (isoSpec X).hom⁻¹ᵁ (Spec.obj (op (Γ.obj (op X)))).basicOpen ((SpecΓIdentity.app (Γ.obj (op X))).inv f) = X.basicOpen f

Next tactic:
trans
    X.isoSpec.hom ⁻¹ᵁ (Scheme.Spec.obj (op (Scheme.Γ.obj (op X)))).basicOpen
        ((inv (X.isoSpec.hom.1.c.app (op ((Opens.map (inv X.isoSpec.hom).val.base).obj ⊤)))) f)
theorem Scheme.map_PrimeSpectrum_basicOpen_of_affine
    (X : Scheme) [IsAffine X] (f : Scheme.Γ.obj (op X)) :
    X.isoSpec.hom ⁻¹ᵁ PrimeSpectrum.basicOpen f = X.basicOpen f := by
  rw [← basicOpen_eq_of_affine]
  trans
    X.isoSpec.hom ⁻¹ᵁ (Scheme.Spec.obj (op (Scheme.Γ.obj (op X)))).basicOpen
        ((inv (X.isoSpec.hom.1.c.app (op ((Opens.map (inv X.isoSpec.hom).val.base).obj ⊤)))) f)
  · 

Proof state:
X : Scheme
inst✝ : IsAffine X
f : ↑(Γ.obj (op X))
⊢ (isoSpec X).hom⁻¹ᵁ (Spec.obj (op (Γ.obj (op X)))).basicOpen ((SpecΓIdentity.app (Γ.obj (op X))).inv f) =
    (isoSpec X).hom⁻¹ᵁ
      (Spec.obj (op (Γ.obj (op X)))).basicOpen ((inv ((isoSpec X).hom.val.c.app (op (inv (isoSpec X).hom⁻¹ᵁ ⊤)))) f)

Next tactic:
congr
theorem Scheme.map_PrimeSpectrum_basicOpen_of_affine
    (X : Scheme) [IsAffine X] (f : Scheme.Γ.obj (op X)) :
    X.isoSpec.hom ⁻¹ᵁ PrimeSpectrum.basicOpen f = X.basicOpen f := by
  rw [← basicOpen_eq_of_affine]
  trans
    X.isoSpec.hom ⁻¹ᵁ (Scheme.Spec.obj (op (Scheme.Γ.obj (op X)))).basicOpen
        ((inv (X.isoSpec.hom.1.c.app (op ((Opens.map (inv X.isoSpec.hom).val.base).obj ⊤)))) f)
  · congr
    

Proof state:
case e_a.e_f.e_a
X : Scheme
inst✝ : IsAffine X
f : ↑(Γ.obj (op X))
⊢ (SpecΓIdentity.app (Γ.obj (op X))).inv = inv ((isoSpec X).hom.val.c.app (op (inv (isoSpec X).hom⁻¹ᵁ ⊤)))

Next tactic:
rw [← IsIso.inv_eq_inv, IsIso.inv_inv, IsIso.Iso.inv_inv, NatIso.app_hom]
theorem Scheme.map_PrimeSpectrum_basicOpen_of_affine
    (X : Scheme) [IsAffine X] (f : Scheme.Γ.obj (op X)) :
    X.isoSpec.hom ⁻¹ᵁ PrimeSpectrum.basicOpen f = X.basicOpen f := by
  rw [← basicOpen_eq_of_affine]
  trans
    X.isoSpec.hom ⁻¹ᵁ (Scheme.Spec.obj (op (Scheme.Γ.obj (op X)))).basicOpen
        ((inv (X.isoSpec.hom.1.c.app (op ((Opens.map (inv X.isoSpec.hom).val.base).obj ⊤)))) f)
  · congr
    rw [← IsIso.inv_eq_inv, IsIso.inv_inv, IsIso.Iso.inv_inv, NatIso.app_hom]
    -- Porting note : added this `change` to prevent timeout
    

Proof state:
case e_a.e_f.e_a
X : Scheme
inst✝ : IsAffine X
f : ↑(Γ.obj (op X))
⊢ SpecΓIdentity.hom.app (Γ.obj (op X)) = (isoSpec X).hom.val.c.app (op (inv (isoSpec X).hom⁻¹ᵁ ⊤))

Next tactic:
change SpecΓIdentity.hom.app (X.presheaf.obj <| op ⊤) = _
theorem Scheme.map_PrimeSpectrum_basicOpen_of_affine
    (X : Scheme) [IsAffine X] (f : Scheme.Γ.obj (op X)) :
    X.isoSpec.hom ⁻¹ᵁ PrimeSpectrum.basicOpen f = X.basicOpen f := by
  rw [← basicOpen_eq_of_affine]
  trans
    X.isoSpec.hom ⁻¹ᵁ (Scheme.Spec.obj (op (Scheme.Γ.obj (op X)))).basicOpen
        ((inv (X.isoSpec.hom.1.c.app (op ((Opens.map (inv X.isoSpec.hom).val.base).obj ⊤)))) f)
  · congr
    rw [← IsIso.inv_eq_inv, IsIso.inv_inv, IsIso.Iso.inv_inv, NatIso.app_hom]
    -- Porting note : added this `change` to prevent timeout
    change SpecΓIdentity.hom.app (X.presheaf.obj <| op ⊤) = _
    

Proof state:
case e_a.e_f.e_a
X : Scheme
inst✝ : IsAffine X
f : ↑(Γ.obj (op X))
⊢ SpecΓIdentity.hom.app (X.presheaf.obj (op ⊤)) = (isoSpec X).hom.val.c.app (op (inv (isoSpec X).hom⁻¹ᵁ ⊤))

Next tactic:
rw [← ΓSpec.adjunction_unit_app_app_top X]
theorem Scheme.map_PrimeSpectrum_basicOpen_of_affine
    (X : Scheme) [IsAffine X] (f : Scheme.Γ.obj (op X)) :
    X.isoSpec.hom ⁻¹ᵁ PrimeSpectrum.basicOpen f = X.basicOpen f := by
  rw [← basicOpen_eq_of_affine]
  trans
    X.isoSpec.hom ⁻¹ᵁ (Scheme.Spec.obj (op (Scheme.Γ.obj (op X)))).basicOpen
        ((inv (X.isoSpec.hom.1.c.app (op ((Opens.map (inv X.isoSpec.hom).val.base).obj ⊤)))) f)
  · congr
    rw [← IsIso.inv_eq_inv, IsIso.inv_inv, IsIso.Iso.inv_inv, NatIso.app_hom]
    -- Porting note : added this `change` to prevent timeout
    change SpecΓIdentity.hom.app (X.presheaf.obj <| op ⊤) = _
    rw [← ΓSpec.adjunction_unit_app_app_top X]
    

Proof state:
case e_a.e_f.e_a
X : Scheme
inst✝ : IsAffine X
f : ↑(Γ.obj (op X))
⊢ (ΓSpec.adjunction.unit.app X).val.c.app (op ⊤) = (isoSpec X).hom.val.c.app (op (inv (isoSpec X).hom⁻¹ᵁ ⊤))

Next tactic:
rfl
theorem Scheme.map_PrimeSpectrum_basicOpen_of_affine
    (X : Scheme) [IsAffine X] (f : Scheme.Γ.obj (op X)) :
    X.isoSpec.hom ⁻¹ᵁ PrimeSpectrum.basicOpen f = X.basicOpen f := by
  rw [← basicOpen_eq_of_affine]
  trans
    X.isoSpec.hom ⁻¹ᵁ (Scheme.Spec.obj (op (Scheme.Γ.obj (op X)))).basicOpen
        ((inv (X.isoSpec.hom.1.c.app (op ((Opens.map (inv X.isoSpec.hom).val.base).obj ⊤)))) f)
  · congr
    rw [← IsIso.inv_eq_inv, IsIso.inv_inv, IsIso.Iso.inv_inv, NatIso.app_hom]
    -- Porting note : added this `change` to prevent timeout
    change SpecΓIdentity.hom.app (X.presheaf.obj <| op ⊤) = _
    rw [← ΓSpec.adjunction_unit_app_app_top X]
    rfl
  · 

Proof state:
X : Scheme
inst✝ : IsAffine X
f : ↑(Γ.obj (op X))
⊢ (isoSpec X).hom⁻¹ᵁ
      (Spec.obj (op (Γ.obj (op X)))).basicOpen ((inv ((isoSpec X).hom.val.c.app (op (inv (isoSpec X).hom⁻¹ᵁ ⊤)))) f) =
    X.basicOpen f

Next tactic:
dsimp
theorem Scheme.map_PrimeSpectrum_basicOpen_of_affine
    (X : Scheme) [IsAffine X] (f : Scheme.Γ.obj (op X)) :
    X.isoSpec.hom ⁻¹ᵁ PrimeSpectrum.basicOpen f = X.basicOpen f := by
  rw [← basicOpen_eq_of_affine]
  trans
    X.isoSpec.hom ⁻¹ᵁ (Scheme.Spec.obj (op (Scheme.Γ.obj (op X)))).basicOpen
        ((inv (X.isoSpec.hom.1.c.app (op ((Opens.map (inv X.isoSpec.hom).val.base).obj ⊤)))) f)
  · congr
    rw [← IsIso.inv_eq_inv, IsIso.inv_inv, IsIso.Iso.inv_inv, NatIso.app_hom]
    -- Porting note : added this `change` to prevent timeout
    change SpecΓIdentity.hom.app (X.presheaf.obj <| op ⊤) = _
    rw [← ΓSpec.adjunction_unit_app_app_top X]
    rfl
  · dsimp; 

Proof state:
X : Scheme
inst✝ : IsAffine X
f : ↑(Γ.obj (op X))
⊢ (isoSpec X).hom⁻¹ᵁ (Spec.obj (op (X.presheaf.obj (op ⊤)))).basicOpen ((inv ((isoSpec X).hom.val.c.app (op ⊤))) f) =
    X.basicOpen f

Next tactic:
congr
theorem Scheme.map_PrimeSpectrum_basicOpen_of_affine
    (X : Scheme) [IsAffine X] (f : Scheme.Γ.obj (op X)) :
    X.isoSpec.hom ⁻¹ᵁ PrimeSpectrum.basicOpen f = X.basicOpen f := by
  rw [← basicOpen_eq_of_affine]
  trans
    X.isoSpec.hom ⁻¹ᵁ (Scheme.Spec.obj (op (Scheme.Γ.obj (op X)))).basicOpen
        ((inv (X.isoSpec.hom.1.c.app (op ((Opens.map (inv X.isoSpec.hom).val.base).obj ⊤)))) f)
  · congr
    rw [← IsIso.inv_eq_inv, IsIso.inv_inv, IsIso.Iso.inv_inv, NatIso.app_hom]
    -- Porting note : added this `change` to prevent timeout
    change SpecΓIdentity.hom.app (X.presheaf.obj <| op ⊤) = _
    rw [← ΓSpec.adjunction_unit_app_app_top X]
    rfl
  · dsimp; congr
    

Proof state:
X : Scheme
inst✝ : IsAffine X
f : ↑(Γ.obj (op X))
⊢ (isoSpec X).hom⁻¹ᵁ (Spec.obj (op (X.presheaf.obj (op ⊤)))).basicOpen ((inv ((isoSpec X).hom.val.c.app (op ⊤))) f) =
    X.basicOpen f

Next tactic:
refine' (Scheme.preimage_basicOpen _ _).trans _
theorem Scheme.map_PrimeSpectrum_basicOpen_of_affine
    (X : Scheme) [IsAffine X] (f : Scheme.Γ.obj (op X)) :
    X.isoSpec.hom ⁻¹ᵁ PrimeSpectrum.basicOpen f = X.basicOpen f := by
  rw [← basicOpen_eq_of_affine]
  trans
    X.isoSpec.hom ⁻¹ᵁ (Scheme.Spec.obj (op (Scheme.Γ.obj (op X)))).basicOpen
        ((inv (X.isoSpec.hom.1.c.app (op ((Opens.map (inv X.isoSpec.hom).val.base).obj ⊤)))) f)
  · congr
    rw [← IsIso.inv_eq_inv, IsIso.inv_inv, IsIso.Iso.inv_inv, NatIso.app_hom]
    -- Porting note : added this `change` to prevent timeout
    change SpecΓIdentity.hom.app (X.presheaf.obj <| op ⊤) = _
    rw [← ΓSpec.adjunction_unit_app_app_top X]
    rfl
  · dsimp; congr
    refine' (Scheme.preimage_basicOpen _ _).trans _
    

Proof state:
X : Scheme
inst✝ : IsAffine X
f : ↑(Γ.obj (op X))
⊢ X.basicOpen (((isoSpec X).hom.val.c.app (op ⊤)) ((inv ((isoSpec X).hom.val.c.app (op ⊤))) f)) = X.basicOpen f

Next tactic:
congr 1
theorem Scheme.map_PrimeSpectrum_basicOpen_of_affine
    (X : Scheme) [IsAffine X] (f : Scheme.Γ.obj (op X)) :
    X.isoSpec.hom ⁻¹ᵁ PrimeSpectrum.basicOpen f = X.basicOpen f := by
  rw [← basicOpen_eq_of_affine]
  trans
    X.isoSpec.hom ⁻¹ᵁ (Scheme.Spec.obj (op (Scheme.Γ.obj (op X)))).basicOpen
        ((inv (X.isoSpec.hom.1.c.app (op ((Opens.map (inv X.isoSpec.hom).val.base).obj ⊤)))) f)
  · congr
    rw [← IsIso.inv_eq_inv, IsIso.inv_inv, IsIso.Iso.inv_inv, NatIso.app_hom]
    -- Porting note : added this `change` to prevent timeout
    change SpecΓIdentity.hom.app (X.presheaf.obj <| op ⊤) = _
    rw [← ΓSpec.adjunction_unit_app_app_top X]
    rfl
  · dsimp; congr
    refine' (Scheme.preimage_basicOpen _ _).trans _
    congr 1
    

Proof state:
case e_f
X : Scheme
inst✝ : IsAffine X
f : ↑(Γ.obj (op X))
⊢ ((isoSpec X).hom.val.c.app (op ⊤)) ((inv ((isoSpec X).hom.val.c.app (op ⊤))) f) = f

Next tactic:
exact IsIso.inv_hom_id_apply _ _
theorem isBasis_basicOpen (X : Scheme) [IsAffine X] :
    Opens.IsBasis (Set.range (X.basicOpen : X.presheaf.obj (op ⊤) → Opens X)) := by
  

Proof state:
X : Scheme
inst✝ : IsAffine X
⊢ Opens.IsBasis (Set.range X.basicOpen)

Next tactic:
delta Opens.IsBasis
theorem isBasis_basicOpen (X : Scheme) [IsAffine X] :
    Opens.IsBasis (Set.range (X.basicOpen : X.presheaf.obj (op ⊤) → Opens X)) := by
  delta Opens.IsBasis
  

Proof state:
X : Scheme
inst✝ : IsAffine X
⊢ IsTopologicalBasis (SetLike.coe '' Set.range X.basicOpen)

Next tactic:
convert PrimeSpectrum.isBasis_basic_opens.inducing
    (TopCat.homeoOfIso (Scheme.forgetToTop.mapIso X.isoSpec)).inducing using 1
theorem isBasis_basicOpen (X : Scheme) [IsAffine X] :
    Opens.IsBasis (Set.range (X.basicOpen : X.presheaf.obj (op ⊤) → Opens X)) := by
  delta Opens.IsBasis
  convert PrimeSpectrum.isBasis_basic_opens.inducing
    (TopCat.homeoOfIso (Scheme.forgetToTop.mapIso X.isoSpec)).inducing using 1
  

Proof state:
case h.e'_3
X : Scheme
inst✝ : IsAffine X
⊢ SetLike.coe '' Set.range X.basicOpen =
    Set.preimage ⇑(TopCat.homeoOfIso (Scheme.forgetToTop.mapIso (Scheme.isoSpec X))) ''
      (SetLike.coe '' Set.range PrimeSpectrum.basicOpen)

Next tactic:
ext
theorem isBasis_basicOpen (X : Scheme) [IsAffine X] :
    Opens.IsBasis (Set.range (X.basicOpen : X.presheaf.obj (op ⊤) → Opens X)) := by
  delta Opens.IsBasis
  convert PrimeSpectrum.isBasis_basic_opens.inducing
    (TopCat.homeoOfIso (Scheme.forgetToTop.mapIso X.isoSpec)).inducing using 1
  ext
  

Proof state:
case h.e'_3.h
X : Scheme
inst✝ : IsAffine X
x✝ : Set ↑↑X.toPresheafedSpace
⊢ x✝ ∈ SetLike.coe '' Set.range X.basicOpen ↔
    x✝ ∈
      Set.preimage ⇑(TopCat.homeoOfIso (Scheme.forgetToTop.mapIso (Scheme.isoSpec X))) ''
        (SetLike.coe '' Set.range PrimeSpectrum.basicOpen)

Next tactic:
simp only [Set.mem_image, exists_exists_eq_and]
theorem isBasis_basicOpen (X : Scheme) [IsAffine X] :
    Opens.IsBasis (Set.range (X.basicOpen : X.presheaf.obj (op ⊤) → Opens X)) := by
  delta Opens.IsBasis
  convert PrimeSpectrum.isBasis_basic_opens.inducing
    (TopCat.homeoOfIso (Scheme.forgetToTop.mapIso X.isoSpec)).inducing using 1
  ext
  simp only [Set.mem_image, exists_exists_eq_and]
  

Proof state:
case h.e'_3.h
X : Scheme
inst✝ : IsAffine X
x✝ : Set ↑↑X.toPresheafedSpace
⊢ (∃ x ∈ Set.range X.basicOpen, ↑x = x✝) ↔
    ∃ x,
      (∃ x_1 ∈ Set.range PrimeSpectrum.basicOpen, ↑x_1 = x) ∧
        ⇑(TopCat.homeoOfIso (Scheme.forgetToTop.mapIso (Scheme.isoSpec X))) ⁻¹' x = x✝

Next tactic:
constructor
theorem isBasis_basicOpen (X : Scheme) [IsAffine X] :
    Opens.IsBasis (Set.range (X.basicOpen : X.presheaf.obj (op ⊤) → Opens X)) := by
  delta Opens.IsBasis
  convert PrimeSpectrum.isBasis_basic_opens.inducing
    (TopCat.homeoOfIso (Scheme.forgetToTop.mapIso X.isoSpec)).inducing using 1
  ext
  simp only [Set.mem_image, exists_exists_eq_and]
  constructor
  · 

Proof state:
case h.e'_3.h.mp
X : Scheme
inst✝ : IsAffine X
x✝ : Set ↑↑X.toPresheafedSpace
⊢ (∃ x ∈ Set.range X.basicOpen, ↑x = x✝) →
    ∃ x,
      (∃ x_1 ∈ Set.range PrimeSpectrum.basicOpen, ↑x_1 = x) ∧
        ⇑(TopCat.homeoOfIso (Scheme.forgetToTop.mapIso (Scheme.isoSpec X))) ⁻¹' x = x✝

Next tactic:
rintro ⟨_, ⟨x, rfl⟩, rfl⟩
theorem isBasis_basicOpen (X : Scheme) [IsAffine X] :
    Opens.IsBasis (Set.range (X.basicOpen : X.presheaf.obj (op ⊤) → Opens X)) := by
  delta Opens.IsBasis
  convert PrimeSpectrum.isBasis_basic_opens.inducing
    (TopCat.homeoOfIso (Scheme.forgetToTop.mapIso X.isoSpec)).inducing using 1
  ext
  simp only [Set.mem_image, exists_exists_eq_and]
  constructor
  · rintro ⟨_, ⟨x, rfl⟩, rfl⟩
    

Proof state:
case h.e'_3.h.mp.intro.intro.intro
X : Scheme
inst✝ : IsAffine X
x : ↑(X.presheaf.obj (op ⊤))
⊢ ∃ x_1,
    (∃ x ∈ Set.range PrimeSpectrum.basicOpen, ↑x = x_1) ∧
      ⇑(TopCat.homeoOfIso (Scheme.forgetToTop.mapIso (Scheme.isoSpec X))) ⁻¹' x_1 = ↑(X.basicOpen x)

Next tactic:
refine' ⟨_, ⟨_, ⟨x, rfl⟩, rfl⟩, _⟩
theorem isBasis_basicOpen (X : Scheme) [IsAffine X] :
    Opens.IsBasis (Set.range (X.basicOpen : X.presheaf.obj (op ⊤) → Opens X)) := by
  delta Opens.IsBasis
  convert PrimeSpectrum.isBasis_basic_opens.inducing
    (TopCat.homeoOfIso (Scheme.forgetToTop.mapIso X.isoSpec)).inducing using 1
  ext
  simp only [Set.mem_image, exists_exists_eq_and]
  constructor
  · rintro ⟨_, ⟨x, rfl⟩, rfl⟩
    refine' ⟨_, ⟨_, ⟨x, rfl⟩, rfl⟩, _⟩
    

Proof state:
case h.e'_3.h.mp.intro.intro.intro
X : Scheme
inst✝ : IsAffine X
x : ↑(X.presheaf.obj (op ⊤))
⊢ ⇑(TopCat.homeoOfIso (Scheme.forgetToTop.mapIso (Scheme.isoSpec X))) ⁻¹' ↑(PrimeSpectrum.basicOpen x) =
    ↑(X.basicOpen x)

Next tactic:
exact congr_arg Opens.carrier (X.map_PrimeSpectrum_basicOpen_of_affine x)
theorem isBasis_basicOpen (X : Scheme) [IsAffine X] :
    Opens.IsBasis (Set.range (X.basicOpen : X.presheaf.obj (op ⊤) → Opens X)) := by
  delta Opens.IsBasis
  convert PrimeSpectrum.isBasis_basic_opens.inducing
    (TopCat.homeoOfIso (Scheme.forgetToTop.mapIso X.isoSpec)).inducing using 1
  ext
  simp only [Set.mem_image, exists_exists_eq_and]
  constructor
  · rintro ⟨_, ⟨x, rfl⟩, rfl⟩
    refine' ⟨_, ⟨_, ⟨x, rfl⟩, rfl⟩, _⟩
    exact congr_arg Opens.carrier (X.map_PrimeSpectrum_basicOpen_of_affine x)
  · 

Proof state:
case h.e'_3.h.mpr
X : Scheme
inst✝ : IsAffine X
x✝ : Set ↑↑X.toPresheafedSpace
⊢ (∃ x,
      (∃ x_1 ∈ Set.range PrimeSpectrum.basicOpen, ↑x_1 = x) ∧
        ⇑(TopCat.homeoOfIso (Scheme.forgetToTop.mapIso (Scheme.isoSpec X))) ⁻¹' x = x✝) →
    ∃ x ∈ Set.range X.basicOpen, ↑x = x✝

Next tactic:
rintro ⟨_, ⟨_, ⟨x, rfl⟩, rfl⟩, rfl⟩
theorem isBasis_basicOpen (X : Scheme) [IsAffine X] :
    Opens.IsBasis (Set.range (X.basicOpen : X.presheaf.obj (op ⊤) → Opens X)) := by
  delta Opens.IsBasis
  convert PrimeSpectrum.isBasis_basic_opens.inducing
    (TopCat.homeoOfIso (Scheme.forgetToTop.mapIso X.isoSpec)).inducing using 1
  ext
  simp only [Set.mem_image, exists_exists_eq_and]
  constructor
  · rintro ⟨_, ⟨x, rfl⟩, rfl⟩
    refine' ⟨_, ⟨_, ⟨x, rfl⟩, rfl⟩, _⟩
    exact congr_arg Opens.carrier (X.map_PrimeSpectrum_basicOpen_of_affine x)
  · rintro ⟨_, ⟨_, ⟨x, rfl⟩, rfl⟩, rfl⟩
    

Proof state:
case h.e'_3.h.mpr.intro.intro.intro.intro.intro
X : Scheme
inst✝ : IsAffine X
x : ↑(op (Scheme.Γ.obj (op X))).unop
⊢ ∃ x_1 ∈ Set.range X.basicOpen,
    ↑x_1 = ⇑(TopCat.homeoOfIso (Scheme.forgetToTop.mapIso (Scheme.isoSpec X))) ⁻¹' ↑(PrimeSpectrum.basicOpen x)

Next tactic:
refine' ⟨_, ⟨x, rfl⟩, _⟩
theorem isBasis_basicOpen (X : Scheme) [IsAffine X] :
    Opens.IsBasis (Set.range (X.basicOpen : X.presheaf.obj (op ⊤) → Opens X)) := by
  delta Opens.IsBasis
  convert PrimeSpectrum.isBasis_basic_opens.inducing
    (TopCat.homeoOfIso (Scheme.forgetToTop.mapIso X.isoSpec)).inducing using 1
  ext
  simp only [Set.mem_image, exists_exists_eq_and]
  constructor
  · rintro ⟨_, ⟨x, rfl⟩, rfl⟩
    refine' ⟨_, ⟨_, ⟨x, rfl⟩, rfl⟩, _⟩
    exact congr_arg Opens.carrier (X.map_PrimeSpectrum_basicOpen_of_affine x)
  · rintro ⟨_, ⟨_, ⟨x, rfl⟩, rfl⟩, rfl⟩
    refine' ⟨_, ⟨x, rfl⟩, _⟩
    

Proof state:
case h.e'_3.h.mpr.intro.intro.intro.intro.intro
X : Scheme
inst✝ : IsAffine X
x : ↑(op (Scheme.Γ.obj (op X))).unop
⊢ ↑(X.basicOpen x) =
    ⇑(TopCat.homeoOfIso (Scheme.forgetToTop.mapIso (Scheme.isoSpec X))) ⁻¹' ↑(PrimeSpectrum.basicOpen x)

Next tactic:
exact congr_arg Opens.carrier (X.map_PrimeSpectrum_basicOpen_of_affine x).symm
instance isOpenImmersion_fromSpec :
    IsOpenImmersion hU.fromSpec := by
  

Proof state:
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
⊢ IsOpenImmersion (fromSpec hU)

Next tactic:
delta fromSpec
instance isOpenImmersion_fromSpec :
    IsOpenImmersion hU.fromSpec := by
  delta fromSpec
  

Proof state:
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
⊢ IsOpenImmersion
    (Scheme.Spec.map
        (X.presheaf.map (eqToHom (_ : U = (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj ⊤)).op).op ≫
      (Scheme.isoSpec (Scheme.restrict X (_ : OpenEmbedding ⇑(Opens.inclusion U)))).inv ≫ Scheme.ιOpens U)

Next tactic:
infer_instance
theorem fromSpec_range :
    Set.range hU.fromSpec.1.base = (U : Set X) := by
  

Proof state:
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
⊢ Set.range ⇑(fromSpec hU).val.base = ↑U

Next tactic:
delta IsAffineOpen.fromSpec
theorem fromSpec_range :
    Set.range hU.fromSpec.1.base = (U : Set X) := by
  delta IsAffineOpen.fromSpec; 

Proof state:
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
⊢ Set.range
      ⇑(Scheme.Spec.map
                (X.presheaf.map
                    (eqToHom (_ : U = (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj ⊤)).op).op ≫
              (Scheme.isoSpec (Scheme.restrict X (_ : OpenEmbedding ⇑(Opens.inclusion U)))).inv ≫
                Scheme.ιOpens U).val.base =
    ↑U

Next tactic:
dsimp
theorem fromSpec_range :
    Set.range hU.fromSpec.1.base = (U : Set X) := by
  delta IsAffineOpen.fromSpec; dsimp
  

Proof state:
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
⊢ Set.range
      ⇑((Scheme.Spec.map
                (X.presheaf.map
                    (eqToHom
                        (_ : U = (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj ⊤)).op).op).val.base ≫
          (Scheme.isoSpec (Scheme.restrict X (_ : OpenEmbedding ⇑(Opens.inclusion U)))).inv.val.base ≫
            Opens.inclusion U) =
    ↑U

Next tactic:
rw [← Category.assoc, coe_comp, Set.range_comp, Set.range_iff_surjective.mpr, Set.image_univ]
theorem fromSpec_range :
    Set.range hU.fromSpec.1.base = (U : Set X) := by
  delta IsAffineOpen.fromSpec; dsimp
  rw [← Category.assoc, coe_comp, Set.range_comp, Set.range_iff_surjective.mpr, Set.image_univ]
  

Proof state:
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
⊢ Set.range ⇑(Opens.inclusion U) = ↑U
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
⊢ Function.Surjective
    ⇑((Scheme.Spec.map
              (X.presheaf.map
                  (eqToHom (_ : U = (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj ⊤)).op).op).val.base ≫
        (Scheme.isoSpec (Scheme.restrict X (_ : OpenEmbedding ⇑(Opens.inclusion U)))).inv.val.base)

Next tactic:
exact Subtype.range_coe
theorem fromSpec_range :
    Set.range hU.fromSpec.1.base = (U : Set X) := by
  delta IsAffineOpen.fromSpec; dsimp
  rw [← Category.assoc, coe_comp, Set.range_comp, Set.range_iff_surjective.mpr, Set.image_univ]
  exact Subtype.range_coe
  

Proof state:
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
⊢ Function.Surjective
    ⇑((Scheme.Spec.map
              (X.presheaf.map
                  (eqToHom (_ : U = (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj ⊤)).op).op).val.base ≫
        (Scheme.isoSpec (Scheme.restrict X (_ : OpenEmbedding ⇑(Opens.inclusion U)))).inv.val.base)

Next tactic:
rw [← TopCat.epi_iff_surjective]
theorem fromSpec_range :
    Set.range hU.fromSpec.1.base = (U : Set X) := by
  delta IsAffineOpen.fromSpec; dsimp
  rw [← Category.assoc, coe_comp, Set.range_comp, Set.range_iff_surjective.mpr, Set.image_univ]
  exact Subtype.range_coe
  rw [← TopCat.epi_iff_surjective]
  

Proof state:
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
⊢ Epi
    ((Scheme.Spec.map
            (X.presheaf.map
                (eqToHom (_ : U = (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj ⊤)).op).op).val.base ≫
      (Scheme.isoSpec (Scheme.restrict X (_ : OpenEmbedding ⇑(Opens.inclusion U)))).inv.val.base)

Next tactic:
infer_instance
theorem fromSpec_image_top :
    hU.fromSpec.opensFunctor.obj ⊤ = U := by
  

Proof state:
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
⊢ (Scheme.Hom.opensFunctor (fromSpec hU)).obj ⊤ = U

Next tactic:
ext1
theorem fromSpec_image_top :
    hU.fromSpec.opensFunctor.obj ⊤ = U := by
  ext1; 

Proof state:
case h
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
⊢ ↑((Scheme.Hom.opensFunctor (fromSpec hU)).obj ⊤) = ↑U

Next tactic:
exact Set.image_univ.trans hU.fromSpec_range
protected theorem isCompact :
    IsCompact (U : Set X) := by
  

Proof state:
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
⊢ IsCompact ↑U

Next tactic:
convert @IsCompact.image _ _ _ _ Set.univ hU.fromSpec.1.base PrimeSpectrum.compactSpace.1
    ((fromSpec hU).val.base.2)
protected theorem isCompact :
    IsCompact (U : Set X) := by
  convert @IsCompact.image _ _ _ _ Set.univ hU.fromSpec.1.base PrimeSpectrum.compactSpace.1
    ((fromSpec hU).val.base.2) -- Porting note : `continuity` can't do this
  

Proof state:
case h.e'_3.h
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
e_1✝ : ↑↑X.toPresheafedSpace = (forget TopCat).obj ↑X.toPresheafedSpace
⊢ ↑U = ⇑(fromSpec hU).val.base '' Set.univ

Next tactic:
convert hU.fromSpec_range.symm