l3lab/ntp-mathlib huggingface dataset:
theorem _root_.AlgebraicGeometry.exists_basicOpen_le_affine_inter
    {V : Opens X} (hV : IsAffineOpen V) (x : X) (hx : x ∈ U ⊓ V) :
    ∃ (f : X.presheaf.obj <| op U) (g : X.presheaf.obj <| op V),
      X.basicOpen f = X.basicOpen g ∧ x ∈ X.basicOpen f := by
  obtain ⟨f, hf₁, hf₂⟩ := hU.exists_basicOpen_le ⟨x, hx.2⟩ hx.1
  obtain ⟨g, hg₁, hg₂⟩ := hV.exists_basicOpen_le ⟨x, hf₂⟩ hx.2
  obtain ⟨f', hf'⟩ :=
    basicOpen_basicOpen_is_basicOpen hU f (X.presheaf.map (homOfLE hf₁ : _ ⟶ V).op g)
  replace hf' := (hf'.trans (RingedSpace.basicOpen_res _ _ _)).trans (inf_eq_right.mpr hg₁)
  

Proof state:
case intro.intro.intro.intro.intro
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f✝ : ↑(X.presheaf.obj (op U))
V : Opens ↑↑X.toPresheafedSpace
hV : IsAffineOpen V
x : ↑↑X.toPresheafedSpace
hx : x ∈ U ⊓ V
f : ↑(X.presheaf.obj (op U))
hf₁ : X.basicOpen f ≤ V
hf₂ : ↑{ val := x, property := (_ : x ∈ ↑V) } ∈ X.basicOpen f
g : ↑(X.presheaf.obj (op V))
hg₁ : X.basicOpen g ≤ X.basicOpen f
hg₂ : ↑{ val := x, property := hf₂ } ∈ X.basicOpen g
f' : ↑(X.presheaf.obj (op U))
hf' : X.basicOpen f' = RingedSpace.basicOpen (LocallyRingedSpace.toRingedSpace X.toLocallyRingedSpace) g
⊢ ∃ f g, X.basicOpen f = X.basicOpen g ∧ x ∈ X.basicOpen f

Next tactic:
exact ⟨f', g, hf', hf'.symm ▸ hg₂⟩
theorem fromSpec_primeIdealOf (x : U) :
    hU.fromSpec.val.base (hU.primeIdealOf x) = x.1 := by
  

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

Next tactic:
dsimp only [IsAffineOpen.fromSpec, Subtype.coe_mk, IsAffineOpen.primeIdealOf]
theorem fromSpec_primeIdealOf (x : U) :
    hU.fromSpec.val.base (hU.primeIdealOf x) = x.1 := by
  dsimp only [IsAffineOpen.fromSpec, Subtype.coe_mk, IsAffineOpen.primeIdealOf]
  -- Porting note : in the porting note of `Scheme.comp_val_base`, it says that `elementwise` is
  -- unnecessary, indeed, the linter did not like it, so I just use `elementwise_of%` instead of
  -- adding the corresponding lemma in `Scheme.lean` file
  

Proof state:
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
x : ↥U
⊢ (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
      (((Scheme.isoSpec (Scheme.restrict X (_ : OpenEmbedding ⇑(Opens.inclusion U)))).hom ≫
              Scheme.Spec.map
                (X.presheaf.map
                    (eqToHom (_ : (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj ⊤ = U)).op).op).val.base
        x) =
    ↑x

Next tactic:
rw [← elementwise_of% Scheme.comp_val_base]
theorem fromSpec_primeIdealOf (x : U) :
    hU.fromSpec.val.base (hU.primeIdealOf x) = x.1 := by
  dsimp only [IsAffineOpen.fromSpec, Subtype.coe_mk, IsAffineOpen.primeIdealOf]
  -- Porting note : in the porting note of `Scheme.comp_val_base`, it says that `elementwise` is
  -- unnecessary, indeed, the linter did not like it, so I just use `elementwise_of%` instead of
  -- adding the corresponding lemma in `Scheme.lean` file
  rw [← elementwise_of% Scheme.comp_val_base]
  

Proof state:
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
x : ↥U
⊢ (((Scheme.isoSpec (Scheme.restrict X (_ : OpenEmbedding ⇑(Opens.inclusion U)))).hom ≫
              Scheme.Spec.map
                (X.presheaf.map
                    (eqToHom (_ : (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj ⊤ = U)).op).op) ≫
            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
      x =
    ↑x

Next tactic:
simp only [Scheme.Γ_obj, unop_op, Scheme.restrict_presheaf_obj, Category.assoc, ←
    Functor.map_comp_assoc, ← op_comp, ← Functor.map_comp, eqToHom_trans, eqToHom_refl, op_id,
    CategoryTheory.Functor.map_id, Category.id_comp, Iso.hom_inv_id_assoc,
    Scheme.ofRestrict_val_base, Scheme.restrict_carrier, Opens.coe_inclusion]
theorem isLocalization_stalk'
    (y : PrimeSpectrum (X.presheaf.obj <| op U)) (hy : hU.fromSpec.1.base y ∈ U) :
    @IsLocalization.AtPrime
      (R := X.presheaf.obj <| op U)
      (S := X.presheaf.stalk <| hU.fromSpec.1.base y) _ _
      ((TopCat.Presheaf.algebra_section_stalk X.presheaf _)) y.asIdeal _ := by
  

Proof state:
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
y : PrimeSpectrum ↑(X.presheaf.obj (op U))
hy : (fromSpec hU).val.base y ∈ U
⊢ IsLocalization.AtPrime (↑(TopCat.Presheaf.stalk X.presheaf ((fromSpec hU).val.base y))) y.asIdeal

Next tactic:
apply
    (@IsLocalization.isLocalization_iff_of_ringEquiv (R := X.presheaf.obj <| op U)
      (S := X.presheaf.stalk (hU.fromSpec.1.base y)) _ y.asIdeal.primeCompl _
      (TopCat.Presheaf.algebra_section_stalk X.presheaf ⟨hU.fromSpec.1.base y, hy⟩) _ _
      (asIso <| PresheafedSpace.stalkMap hU.fromSpec.1 y).commRingCatIsoToRingEquiv).mpr
theorem isLocalization_stalk'
    (y : PrimeSpectrum (X.presheaf.obj <| op U)) (hy : hU.fromSpec.1.base y ∈ U) :
    @IsLocalization.AtPrime
      (R := X.presheaf.obj <| op U)
      (S := X.presheaf.stalk <| hU.fromSpec.1.base y) _ _
      ((TopCat.Presheaf.algebra_section_stalk X.presheaf _)) y.asIdeal _ := by
  apply
    (@IsLocalization.isLocalization_iff_of_ringEquiv (R := X.presheaf.obj <| op U)
      (S := X.presheaf.stalk (hU.fromSpec.1.base y)) _ y.asIdeal.primeCompl _
      (TopCat.Presheaf.algebra_section_stalk X.presheaf ⟨hU.fromSpec.1.base y, hy⟩) _ _
      (asIso <| PresheafedSpace.stalkMap hU.fromSpec.1 y).commRingCatIsoToRingEquiv).mpr
  -- Porting note : need to know what the ring is and after convert, instead of equality
  -- we get an `iff`.
  

Proof state:
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
y : PrimeSpectrum ↑(X.presheaf.obj (op U))
hy : (fromSpec hU).val.base y ∈ U
⊢ IsLocalization (Ideal.primeCompl y.asIdeal)
    ↑(PresheafedSpace.stalk (Scheme.Spec.obj (op (X.presheaf.obj (op U)))).toPresheafedSpace y)

Next tactic:
convert StructureSheaf.IsLocalization.to_stalk (X.presheaf.obj <| op U) y using 1
theorem isLocalization_stalk'
    (y : PrimeSpectrum (X.presheaf.obj <| op U)) (hy : hU.fromSpec.1.base y ∈ U) :
    @IsLocalization.AtPrime
      (R := X.presheaf.obj <| op U)
      (S := X.presheaf.stalk <| hU.fromSpec.1.base y) _ _
      ((TopCat.Presheaf.algebra_section_stalk X.presheaf _)) y.asIdeal _ := by
  apply
    (@IsLocalization.isLocalization_iff_of_ringEquiv (R := X.presheaf.obj <| op U)
      (S := X.presheaf.stalk (hU.fromSpec.1.base y)) _ y.asIdeal.primeCompl _
      (TopCat.Presheaf.algebra_section_stalk X.presheaf ⟨hU.fromSpec.1.base y, hy⟩) _ _
      (asIso <| PresheafedSpace.stalkMap hU.fromSpec.1 y).commRingCatIsoToRingEquiv).mpr
  -- Porting note : need to know what the ring is and after convert, instead of equality
  -- we get an `iff`.
  convert StructureSheaf.IsLocalization.to_stalk (X.presheaf.obj <| op U) y using 1
  

Proof state:
case a
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
y : PrimeSpectrum ↑(X.presheaf.obj (op U))
hy : (fromSpec hU).val.base y ∈ U
⊢ IsLocalization (Ideal.primeCompl y.asIdeal)
      ↑(PresheafedSpace.stalk (Scheme.Spec.obj (op (X.presheaf.obj (op U)))).toPresheafedSpace y) ↔
    IsLocalization.AtPrime
      (↑(TopCat.Presheaf.stalk (TopCat.Sheaf.presheaf (structureSheaf ↑(X.presheaf.obj (op U)))) y)) y.asIdeal

Next tactic:
delta IsLocalization.AtPrime StructureSheaf.stalkAlgebra
theorem isLocalization_stalk'
    (y : PrimeSpectrum (X.presheaf.obj <| op U)) (hy : hU.fromSpec.1.base y ∈ U) :
    @IsLocalization.AtPrime
      (R := X.presheaf.obj <| op U)
      (S := X.presheaf.stalk <| hU.fromSpec.1.base y) _ _
      ((TopCat.Presheaf.algebra_section_stalk X.presheaf _)) y.asIdeal _ := by
  apply
    (@IsLocalization.isLocalization_iff_of_ringEquiv (R := X.presheaf.obj <| op U)
      (S := X.presheaf.stalk (hU.fromSpec.1.base y)) _ y.asIdeal.primeCompl _
      (TopCat.Presheaf.algebra_section_stalk X.presheaf ⟨hU.fromSpec.1.base y, hy⟩) _ _
      (asIso <| PresheafedSpace.stalkMap hU.fromSpec.1 y).commRingCatIsoToRingEquiv).mpr
  -- Porting note : need to know what the ring is and after convert, instead of equality
  -- we get an `iff`.
  convert StructureSheaf.IsLocalization.to_stalk (X.presheaf.obj <| op U) y using 1
  delta IsLocalization.AtPrime StructureSheaf.stalkAlgebra
  

Proof state:
case a
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
y : PrimeSpectrum ↑(X.presheaf.obj (op U))
hy : (fromSpec hU).val.base y ∈ U
⊢ IsLocalization (Ideal.primeCompl y.asIdeal)
      ↑(PresheafedSpace.stalk (Scheme.Spec.obj (op (X.presheaf.obj (op U)))).toPresheafedSpace y) ↔
    IsLocalization (Ideal.primeCompl y.asIdeal)
      ↑(TopCat.Presheaf.stalk (TopCat.Sheaf.presheaf (structureSheaf ↑(X.presheaf.obj (op U)))) y)

Next tactic:
rw [iff_iff_eq]
theorem isLocalization_stalk'
    (y : PrimeSpectrum (X.presheaf.obj <| op U)) (hy : hU.fromSpec.1.base y ∈ U) :
    @IsLocalization.AtPrime
      (R := X.presheaf.obj <| op U)
      (S := X.presheaf.stalk <| hU.fromSpec.1.base y) _ _
      ((TopCat.Presheaf.algebra_section_stalk X.presheaf _)) y.asIdeal _ := by
  apply
    (@IsLocalization.isLocalization_iff_of_ringEquiv (R := X.presheaf.obj <| op U)
      (S := X.presheaf.stalk (hU.fromSpec.1.base y)) _ y.asIdeal.primeCompl _
      (TopCat.Presheaf.algebra_section_stalk X.presheaf ⟨hU.fromSpec.1.base y, hy⟩) _ _
      (asIso <| PresheafedSpace.stalkMap hU.fromSpec.1 y).commRingCatIsoToRingEquiv).mpr
  -- Porting note : need to know what the ring is and after convert, instead of equality
  -- we get an `iff`.
  convert StructureSheaf.IsLocalization.to_stalk (X.presheaf.obj <| op U) y using 1
  delta IsLocalization.AtPrime StructureSheaf.stalkAlgebra
  rw [iff_iff_eq]
  

Proof state:
case a
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
y : PrimeSpectrum ↑(X.presheaf.obj (op U))
hy : (fromSpec hU).val.base y ∈ U
⊢ IsLocalization (Ideal.primeCompl y.asIdeal)
      ↑(PresheafedSpace.stalk (Scheme.Spec.obj (op (X.presheaf.obj (op U)))).toPresheafedSpace y) =
    IsLocalization (Ideal.primeCompl y.asIdeal)
      ↑(TopCat.Presheaf.stalk (TopCat.Sheaf.presheaf (structureSheaf ↑(X.presheaf.obj (op U)))) y)

Next tactic:
congr 2
theorem isLocalization_stalk'
    (y : PrimeSpectrum (X.presheaf.obj <| op U)) (hy : hU.fromSpec.1.base y ∈ U) :
    @IsLocalization.AtPrime
      (R := X.presheaf.obj <| op U)
      (S := X.presheaf.stalk <| hU.fromSpec.1.base y) _ _
      ((TopCat.Presheaf.algebra_section_stalk X.presheaf _)) y.asIdeal _ := by
  apply
    (@IsLocalization.isLocalization_iff_of_ringEquiv (R := X.presheaf.obj <| op U)
      (S := X.presheaf.stalk (hU.fromSpec.1.base y)) _ y.asIdeal.primeCompl _
      (TopCat.Presheaf.algebra_section_stalk X.presheaf ⟨hU.fromSpec.1.base y, hy⟩) _ _
      (asIso <| PresheafedSpace.stalkMap hU.fromSpec.1 y).commRingCatIsoToRingEquiv).mpr
  -- Porting note : need to know what the ring is and after convert, instead of equality
  -- we get an `iff`.
  convert StructureSheaf.IsLocalization.to_stalk (X.presheaf.obj <| op U) y using 1
  delta IsLocalization.AtPrime StructureSheaf.stalkAlgebra
  rw [iff_iff_eq]
  congr 2
  

Proof state:
case a.h.e_6.h.e_i
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
y : PrimeSpectrum ↑(X.presheaf.obj (op U))
hy : (fromSpec hU).val.base y ∈ U
⊢ RingHom.comp
      (RingEquiv.toRingHom (Iso.commRingCatIsoToRingEquiv (asIso (PresheafedSpace.stalkMap (fromSpec hU).val y))))
      (algebraMap ↑(X.presheaf.obj (op U)) ↑(TopCat.Presheaf.stalk X.presheaf ((fromSpec hU).val.base y))) =
    StructureSheaf.toStalk (↑(X.presheaf.obj (op U))) y

Next tactic:
rw [RingHom.algebraMap_toAlgebra]
theorem isLocalization_stalk'
    (y : PrimeSpectrum (X.presheaf.obj <| op U)) (hy : hU.fromSpec.1.base y ∈ U) :
    @IsLocalization.AtPrime
      (R := X.presheaf.obj <| op U)
      (S := X.presheaf.stalk <| hU.fromSpec.1.base y) _ _
      ((TopCat.Presheaf.algebra_section_stalk X.presheaf _)) y.asIdeal _ := by
  apply
    (@IsLocalization.isLocalization_iff_of_ringEquiv (R := X.presheaf.obj <| op U)
      (S := X.presheaf.stalk (hU.fromSpec.1.base y)) _ y.asIdeal.primeCompl _
      (TopCat.Presheaf.algebra_section_stalk X.presheaf ⟨hU.fromSpec.1.base y, hy⟩) _ _
      (asIso <| PresheafedSpace.stalkMap hU.fromSpec.1 y).commRingCatIsoToRingEquiv).mpr
  -- Porting note : need to know what the ring is and after convert, instead of equality
  -- we get an `iff`.
  convert StructureSheaf.IsLocalization.to_stalk (X.presheaf.obj <| op U) y using 1
  delta IsLocalization.AtPrime StructureSheaf.stalkAlgebra
  rw [iff_iff_eq]
  congr 2
  rw [RingHom.algebraMap_toAlgebra]
  

Proof state:
case a.h.e_6.h.e_i
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
y : PrimeSpectrum ↑(X.presheaf.obj (op U))
hy : (fromSpec hU).val.base y ∈ U
⊢ RingHom.comp
      (RingEquiv.toRingHom (Iso.commRingCatIsoToRingEquiv (asIso (PresheafedSpace.stalkMap (fromSpec hU).val y))))
      (TopCat.Presheaf.germ X.presheaf { val := (fromSpec hU).val.base y, property := hy }) =
    StructureSheaf.toStalk (↑(X.presheaf.obj (op U))) y

Next tactic:
refine' (PresheafedSpace.stalkMap_germ hU.fromSpec.1 _ ⟨_, hy⟩).trans _
theorem isLocalization_stalk'
    (y : PrimeSpectrum (X.presheaf.obj <| op U)) (hy : hU.fromSpec.1.base y ∈ U) :
    @IsLocalization.AtPrime
      (R := X.presheaf.obj <| op U)
      (S := X.presheaf.stalk <| hU.fromSpec.1.base y) _ _
      ((TopCat.Presheaf.algebra_section_stalk X.presheaf _)) y.asIdeal _ := by
  apply
    (@IsLocalization.isLocalization_iff_of_ringEquiv (R := X.presheaf.obj <| op U)
      (S := X.presheaf.stalk (hU.fromSpec.1.base y)) _ y.asIdeal.primeCompl _
      (TopCat.Presheaf.algebra_section_stalk X.presheaf ⟨hU.fromSpec.1.base y, hy⟩) _ _
      (asIso <| PresheafedSpace.stalkMap hU.fromSpec.1 y).commRingCatIsoToRingEquiv).mpr
  -- Porting note : need to know what the ring is and after convert, instead of equality
  -- we get an `iff`.
  convert StructureSheaf.IsLocalization.to_stalk (X.presheaf.obj <| op U) y using 1
  delta IsLocalization.AtPrime StructureSheaf.stalkAlgebra
  rw [iff_iff_eq]
  congr 2
  rw [RingHom.algebraMap_toAlgebra]
  refine' (PresheafedSpace.stalkMap_germ hU.fromSpec.1 _ ⟨_, hy⟩).trans _
  

Proof state:
case a.h.e_6.h.e_i
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
y : PrimeSpectrum ↑(X.presheaf.obj (op U))
hy : (fromSpec hU).val.base y ∈ U
⊢ (fromSpec hU).val.c.app (op U) ≫
      TopCat.Presheaf.germ (Scheme.Spec.obj (op (X.presheaf.obj (op U)))).presheaf { val := y, property := hy } =
    StructureSheaf.toStalk (↑(X.presheaf.obj (op U))) y

Next tactic:
rw [IsAffineOpen.fromSpec_app_self, Category.assoc, TopCat.Presheaf.germ_res]
theorem isLocalization_stalk'
    (y : PrimeSpectrum (X.presheaf.obj <| op U)) (hy : hU.fromSpec.1.base y ∈ U) :
    @IsLocalization.AtPrime
      (R := X.presheaf.obj <| op U)
      (S := X.presheaf.stalk <| hU.fromSpec.1.base y) _ _
      ((TopCat.Presheaf.algebra_section_stalk X.presheaf _)) y.asIdeal _ := by
  apply
    (@IsLocalization.isLocalization_iff_of_ringEquiv (R := X.presheaf.obj <| op U)
      (S := X.presheaf.stalk (hU.fromSpec.1.base y)) _ y.asIdeal.primeCompl _
      (TopCat.Presheaf.algebra_section_stalk X.presheaf ⟨hU.fromSpec.1.base y, hy⟩) _ _
      (asIso <| PresheafedSpace.stalkMap hU.fromSpec.1 y).commRingCatIsoToRingEquiv).mpr
  -- Porting note : need to know what the ring is and after convert, instead of equality
  -- we get an `iff`.
  convert StructureSheaf.IsLocalization.to_stalk (X.presheaf.obj <| op U) y using 1
  delta IsLocalization.AtPrime StructureSheaf.stalkAlgebra
  rw [iff_iff_eq]
  congr 2
  rw [RingHom.algebraMap_toAlgebra]
  refine' (PresheafedSpace.stalkMap_germ hU.fromSpec.1 _ ⟨_, hy⟩).trans _
  rw [IsAffineOpen.fromSpec_app_self, Category.assoc, TopCat.Presheaf.germ_res]
  

Proof state:
case a.h.e_6.h.e_i
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
y : PrimeSpectrum ↑(X.presheaf.obj (op U))
hy : (fromSpec hU).val.base y ∈ U
⊢ SpecΓIdentity.inv.app (X.presheaf.obj (op U)) ≫
      TopCat.Presheaf.germ (Scheme.Spec.obj (op (X.presheaf.obj (op U)))).presheaf
        ((fun x => { val := ↑x, property := (_ : ↑x ∈ ↑⊤) }) { val := y, property := hy }) =
    StructureSheaf.toStalk (↑(X.presheaf.obj (op U))) y

Next tactic:
rfl
theorem isLocalization_stalk (x : U) :
    IsLocalization.AtPrime (X.presheaf.stalk x) (hU.primeIdealOf x).asIdeal := by
  

Proof state:
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
x : ↥U
⊢ IsLocalization.AtPrime (↑(TopCat.Presheaf.stalk X.presheaf ↑x)) (primeIdealOf hU x).asIdeal

Next tactic:
rcases x with ⟨x, hx⟩
theorem isLocalization_stalk (x : U) :
    IsLocalization.AtPrime (X.presheaf.stalk x) (hU.primeIdealOf x).asIdeal := by
  rcases x with ⟨x, hx⟩
  

Proof state:
case mk
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
x : ↑↑X.toPresheafedSpace
hx : x ∈ U
⊢ IsLocalization.AtPrime (↑(TopCat.Presheaf.stalk X.presheaf ↑{ val := x, property := hx }))
    (primeIdealOf hU { val := x, property := hx }).asIdeal

Next tactic:
set y := hU.primeIdealOf ⟨x, hx⟩ with hy
theorem isLocalization_stalk (x : U) :
    IsLocalization.AtPrime (X.presheaf.stalk x) (hU.primeIdealOf x).asIdeal := by
  rcases x with ⟨x, hx⟩
  set y := hU.primeIdealOf ⟨x, hx⟩ with hy
  

Proof state:
case mk
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
x : ↑↑X.toPresheafedSpace
hx : x ∈ U
y : PrimeSpectrum ↑(X.presheaf.obj (op U)) := primeIdealOf hU { val := x, property := hx }
hy : y = primeIdealOf hU { val := x, property := hx }
⊢ IsLocalization.AtPrime (↑(TopCat.Presheaf.stalk X.presheaf ↑{ val := x, property := hx })) y.asIdeal

Next tactic:
have : hU.fromSpec.val.base y = x := hy ▸ hU.fromSpec_primeIdealOf ⟨x, hx⟩
theorem isLocalization_stalk (x : U) :
    IsLocalization.AtPrime (X.presheaf.stalk x) (hU.primeIdealOf x).asIdeal := by
  rcases x with ⟨x, hx⟩
  set y := hU.primeIdealOf ⟨x, hx⟩ with hy
  have : hU.fromSpec.val.base y = x := hy ▸ hU.fromSpec_primeIdealOf ⟨x, hx⟩
  

Proof state:
case mk
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
x : ↑↑X.toPresheafedSpace
hx : x ∈ U
y : PrimeSpectrum ↑(X.presheaf.obj (op U)) := primeIdealOf hU { val := x, property := hx }
hy : y = primeIdealOf hU { val := x, property := hx }
this : (fromSpec hU).val.base y = x
⊢ IsLocalization.AtPrime (↑(TopCat.Presheaf.stalk X.presheaf ↑{ val := x, property := hx })) y.asIdeal

Next tactic:
clear_value y
theorem isLocalization_stalk (x : U) :
    IsLocalization.AtPrime (X.presheaf.stalk x) (hU.primeIdealOf x).asIdeal := by
  rcases x with ⟨x, hx⟩
  set y := hU.primeIdealOf ⟨x, hx⟩ with hy
  have : hU.fromSpec.val.base y = x := hy ▸ hU.fromSpec_primeIdealOf ⟨x, hx⟩
  clear_value y
  

Proof state:
case mk
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
x : ↑↑X.toPresheafedSpace
hx : x ∈ U
y : PrimeSpectrum ↑(X.presheaf.obj (op U))
hy : y = primeIdealOf hU { val := x, property := hx }
this : (fromSpec hU).val.base y = x
⊢ IsLocalization.AtPrime (↑(TopCat.Presheaf.stalk X.presheaf ↑{ val := x, property := hx })) y.asIdeal

Next tactic:
subst this
theorem isLocalization_stalk (x : U) :
    IsLocalization.AtPrime (X.presheaf.stalk x) (hU.primeIdealOf x).asIdeal := by
  rcases x with ⟨x, hx⟩
  set y := hU.primeIdealOf ⟨x, hx⟩ with hy
  have : hU.fromSpec.val.base y = x := hy ▸ hU.fromSpec_primeIdealOf ⟨x, hx⟩
  clear_value y
  subst this
  

Proof state:
case mk
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
y : PrimeSpectrum ↑(X.presheaf.obj (op U))
hx : (fromSpec hU).val.base y ∈ U
hy : y = primeIdealOf hU { val := (fromSpec hU).val.base y, property := hx }
⊢ IsLocalization.AtPrime (↑(TopCat.Presheaf.stalk X.presheaf ↑{ val := (fromSpec hU).val.base y, property := hx }))
    y.asIdeal

Next tactic:
exact hU.isLocalization_stalk' y hx
theorem basicOpen_union_eq_self_iff (s : Set (X.presheaf.obj <| op U)) :
    ⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U) = U ↔ Ideal.span s = ⊤ := by
  

Proof state:
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(X.presheaf.obj (op U))
⊢ ⨆ f, X.basicOpen ↑f = U ↔ Ideal.span s = ⊤

Next tactic:
trans ⋃ i : s, (PrimeSpectrum.basicOpen i.1).1 = Set.univ
theorem basicOpen_union_eq_self_iff (s : Set (X.presheaf.obj <| op U)) :
    ⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U) = U ↔ Ideal.span s = ⊤ := by
  trans ⋃ i : s, (PrimeSpectrum.basicOpen i.1).1 = Set.univ
  

Proof state:
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(X.presheaf.obj (op U))
⊢ ⨆ f, X.basicOpen ↑f = U ↔ ⋃ i, (PrimeSpectrum.basicOpen ↑i).carrier = Set.univ
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(X.presheaf.obj (op U))
⊢ ⋃ i, (PrimeSpectrum.basicOpen ↑i).carrier = Set.univ ↔ Ideal.span s = ⊤

Next tactic:
trans
    hU.fromSpec.1.base ⁻¹' (⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U)).1 =
      hU.fromSpec.1.base ⁻¹' U.1
theorem basicOpen_union_eq_self_iff (s : Set (X.presheaf.obj <| op U)) :
    ⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U) = U ↔ Ideal.span s = ⊤ := by
  trans ⋃ i : s, (PrimeSpectrum.basicOpen i.1).1 = Set.univ
  trans
    hU.fromSpec.1.base ⁻¹' (⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U)).1 =
      hU.fromSpec.1.base ⁻¹' U.1
  · 

Proof state:
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(X.presheaf.obj (op U))
⊢ ⨆ f, X.basicOpen ↑f = U ↔
    ⇑(fromSpec hU).val.base ⁻¹' (⨆ f, X.basicOpen ↑f).carrier = ⇑(fromSpec hU).val.base ⁻¹' U.carrier

Next tactic:
refine' ⟨fun h => by rw [h], _⟩
theorem basicOpen_union_eq_self_iff (s : Set (X.presheaf.obj <| op U)) :
    ⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U) = U ↔ Ideal.span s = ⊤ := by
  trans ⋃ i : s, (PrimeSpectrum.basicOpen i.1).1 = Set.univ
  trans
    hU.fromSpec.1.base ⁻¹' (⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U)).1 =
      hU.fromSpec.1.base ⁻¹' U.1
  · refine' ⟨fun h => by 

Proof state:
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(X.presheaf.obj (op U))
h : ⨆ f, X.basicOpen ↑f = U
⊢ ⇑(fromSpec hU).val.base ⁻¹' (⨆ f, X.basicOpen ↑f).carrier = ⇑(fromSpec hU).val.base ⁻¹' U.carrier

Next tactic:
rw [h]
theorem basicOpen_union_eq_self_iff (s : Set (X.presheaf.obj <| op U)) :
    ⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U) = U ↔ Ideal.span s = ⊤ := by
  trans ⋃ i : s, (PrimeSpectrum.basicOpen i.1).1 = Set.univ
  trans
    hU.fromSpec.1.base ⁻¹' (⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U)).1 =
      hU.fromSpec.1.base ⁻¹' U.1
  · refine' ⟨fun h => by rw [h], _⟩
    

Proof state:
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(X.presheaf.obj (op U))
⊢ ⇑(fromSpec hU).val.base ⁻¹' (⨆ f, X.basicOpen ↑f).carrier = ⇑(fromSpec hU).val.base ⁻¹' U.carrier →
    ⨆ f, X.basicOpen ↑f = U

Next tactic:
intro h