l3lab/ntp-mathlib huggingface dataset:
instance stalk_isReduced_of_reduced [IsReduced X] (x : X.carrier) :
    _root_.IsReduced (X.presheaf.stalk x) := by
  constructor
  rintro g ⟨n, e⟩
  obtain ⟨U, hxU, s, rfl⟩ := X.presheaf.germ_exist x g
  rw [← map_pow, ← map_zero (X.presheaf.germ ⟨x, hxU⟩)] at e
  obtain ⟨V, hxV, iU, iV, e'⟩ := X.presheaf.germ_eq x hxU hxU _ 0 e
  rw [map_pow, map_zero] at e'
  replace e' := (IsNilpotent.mk _ _ e').eq_zero (R := X.presheaf.obj <| op V)
  

Proof state:
case eq_zero.intro.intro.intro.intro.intro.intro.intro.intro
X : Scheme
inst✝ : IsReduced X
x : ↑↑X.toPresheafedSpace
n : ℕ
U : Opens ↑↑X.toPresheafedSpace
hxU : x ∈ U
s : (forget CommRingCat).obj (X.presheaf.obj (op U))
e :
  (Presheaf.germ X.presheaf { val := x, property := hxU }) (s ^ n) =
    (Presheaf.germ X.presheaf { val := x, property := hxU }) 0
V : Opens ↑↑X.toPresheafedSpace
hxV : x ∈ V
iU iV : V ⟶ U
e' : (X.presheaf.map iU.op) s = 0
⊢ (Presheaf.germ X.presheaf { val := x, property := hxU }) s = 0

Next tactic:
erw [← ConcreteCategory.congr_hom (X.presheaf.germ_res iU ⟨x, hxV⟩) s]
instance stalk_isReduced_of_reduced [IsReduced X] (x : X.carrier) :
    _root_.IsReduced (X.presheaf.stalk x) := by
  constructor
  rintro g ⟨n, e⟩
  obtain ⟨U, hxU, s, rfl⟩ := X.presheaf.germ_exist x g
  rw [← map_pow, ← map_zero (X.presheaf.germ ⟨x, hxU⟩)] at e
  obtain ⟨V, hxV, iU, iV, e'⟩ := X.presheaf.germ_eq x hxU hxU _ 0 e
  rw [map_pow, map_zero] at e'
  replace e' := (IsNilpotent.mk _ _ e').eq_zero (R := X.presheaf.obj <| op V)
  erw [← ConcreteCategory.congr_hom (X.presheaf.germ_res iU ⟨x, hxV⟩) s]
  

Proof state:
case eq_zero.intro.intro.intro.intro.intro.intro.intro.intro
X : Scheme
inst✝ : IsReduced X
x : ↑↑X.toPresheafedSpace
n : ℕ
U : Opens ↑↑X.toPresheafedSpace
hxU : x ∈ U
s : (forget CommRingCat).obj (X.presheaf.obj (op U))
e :
  (Presheaf.germ X.presheaf { val := x, property := hxU }) (s ^ n) =
    (Presheaf.germ X.presheaf { val := x, property := hxU }) 0
V : Opens ↑↑X.toPresheafedSpace
hxV : x ∈ V
iU iV : V ⟶ U
e' : (X.presheaf.map iU.op) s = 0
⊢ (X.presheaf.map iU.op ≫ Presheaf.germ X.presheaf { val := x, property := hxV }) s = 0

Next tactic:
rw [comp_apply, e', map_zero]
theorem isReducedOfOpenImmersion {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f]
    [IsReduced Y] : IsReduced X := by
  

Proof state:
X✝ : Scheme
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
inst✝ : IsReduced Y
⊢ IsReduced X

Next tactic:
constructor
theorem isReducedOfOpenImmersion {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f]
    [IsReduced Y] : IsReduced X := by
  constructor
  

Proof state:
case component_reduced
X✝ : Scheme
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
inst✝ : IsReduced Y
⊢ autoParam (∀ (U : Opens ↑↑X.toPresheafedSpace), _root_.IsReduced ↑(X.presheaf.obj (op U))) _auto✝

Next tactic:
intro U
theorem isReducedOfOpenImmersion {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f]
    [IsReduced Y] : IsReduced X := by
  constructor
  intro U
  

Proof state:
case component_reduced
X✝ : Scheme
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
inst✝ : IsReduced Y
U : Opens ↑↑X.toPresheafedSpace
⊢ _root_.IsReduced ↑(X.presheaf.obj (op U))

Next tactic:
have : U = (Opens.map f.1.base).obj (H.base_open.isOpenMap.functor.obj U) := by
    ext1; exact (Set.preimage_image_eq _ H.base_open.inj).symm
theorem isReducedOfOpenImmersion {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f]
    [IsReduced Y] : IsReduced X := by
  constructor
  intro U
  have : U = (Opens.map f.1.base).obj (H.base_open.isOpenMap.functor.obj U) := by
    

Proof state:
X✝ : Scheme
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
inst✝ : IsReduced Y
U : Opens ↑↑X.toPresheafedSpace
⊢ U = f⁻¹ᵁ (IsOpenMap.functor (_ : IsOpenMap ⇑f.val.base)).obj U

Next tactic:
ext1
theorem isReducedOfOpenImmersion {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f]
    [IsReduced Y] : IsReduced X := by
  constructor
  intro U
  have : U = (Opens.map f.1.base).obj (H.base_open.isOpenMap.functor.obj U) := by
    ext1; 

Proof state:
case h
X✝ : Scheme
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
inst✝ : IsReduced Y
U : Opens ↑↑X.toPresheafedSpace
⊢ ↑U = ↑(f⁻¹ᵁ (IsOpenMap.functor (_ : IsOpenMap ⇑f.val.base)).obj U)

Next tactic:
exact (Set.preimage_image_eq _ H.base_open.inj).symm
theorem isReducedOfOpenImmersion {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f]
    [IsReduced Y] : IsReduced X := by
  constructor
  intro U
  have : U = (Opens.map f.1.base).obj (H.base_open.isOpenMap.functor.obj U) := by
    ext1; exact (Set.preimage_image_eq _ H.base_open.inj).symm
  

Proof state:
case component_reduced
X✝ : Scheme
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
inst✝ : IsReduced Y
U : Opens ↑↑X.toPresheafedSpace
this : U = f⁻¹ᵁ (IsOpenMap.functor (_ : IsOpenMap ⇑f.val.base)).obj U
⊢ _root_.IsReduced ↑(X.presheaf.obj (op U))

Next tactic:
rw [this]
theorem isReducedOfOpenImmersion {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f]
    [IsReduced Y] : IsReduced X := by
  constructor
  intro U
  have : U = (Opens.map f.1.base).obj (H.base_open.isOpenMap.functor.obj U) := by
    ext1; exact (Set.preimage_image_eq _ H.base_open.inj).symm
  rw [this]
  

Proof state:
case component_reduced
X✝ : Scheme
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
inst✝ : IsReduced Y
U : Opens ↑↑X.toPresheafedSpace
this : U = f⁻¹ᵁ (IsOpenMap.functor (_ : IsOpenMap ⇑f.val.base)).obj U
⊢ _root_.IsReduced ↑(X.presheaf.obj (op (f⁻¹ᵁ (IsOpenMap.functor (_ : IsOpenMap ⇑f.val.base)).obj U)))

Next tactic:
exact isReduced_of_injective (inv <| f.1.c.app (op <| H.base_open.isOpenMap.functor.obj U))
    (asIso <| f.1.c.app (op <| H.base_open.isOpenMap.functor.obj U) :
      Y.presheaf.obj _ ≅ _).symm.commRingCatIsoToRingEquiv.injective
instance {R : CommRingCat} [H : _root_.IsReduced R] : IsReduced (Scheme.Spec.obj <| op R) := by
  

Proof state:
X : Scheme
R : CommRingCat
H : _root_.IsReduced ↑R
⊢ IsReduced (Scheme.Spec.obj (op R))

Next tactic:
apply (config := { allowSynthFailures := true }) isReducedOfStalkIsReduced
instance {R : CommRingCat} [H : _root_.IsReduced R] : IsReduced (Scheme.Spec.obj <| op R) := by
  apply (config := { allowSynthFailures := true }) isReducedOfStalkIsReduced
  

Proof state:
case inst
X : Scheme
R : CommRingCat
H : _root_.IsReduced ↑R
⊢ ∀ (x : ↑↑(Scheme.Spec.obj (op R)).toPresheafedSpace),
    _root_.IsReduced ↑(Presheaf.stalk (Scheme.Spec.obj (op R)).presheaf x)

Next tactic:
intro x
instance {R : CommRingCat} [H : _root_.IsReduced R] : IsReduced (Scheme.Spec.obj <| op R) := by
  apply (config := { allowSynthFailures := true }) isReducedOfStalkIsReduced
  intro x; 

Proof state:
case inst
X : Scheme
R : CommRingCat
H : _root_.IsReduced ↑R
x : ↑↑(Scheme.Spec.obj (op R)).toPresheafedSpace
⊢ _root_.IsReduced ↑(Presheaf.stalk (Scheme.Spec.obj (op R)).presheaf x)

Next tactic:
dsimp
instance {R : CommRingCat} [H : _root_.IsReduced R] : IsReduced (Scheme.Spec.obj <| op R) := by
  apply (config := { allowSynthFailures := true }) isReducedOfStalkIsReduced
  intro x; dsimp
  

Proof state:
case inst
X : Scheme
R : CommRingCat
H : _root_.IsReduced ↑R
x : ↑↑(Scheme.Spec.obj (op R)).toPresheafedSpace
⊢ _root_.IsReduced ↑(Presheaf.stalk (Scheme.Spec.obj (op R)).presheaf x)

Next tactic:
have : _root_.IsReduced (CommRingCat.of <| Localization.AtPrime (PrimeSpectrum.asIdeal x)) := by
    dsimp; infer_instance
instance {R : CommRingCat} [H : _root_.IsReduced R] : IsReduced (Scheme.Spec.obj <| op R) := by
  apply (config := { allowSynthFailures := true }) isReducedOfStalkIsReduced
  intro x; dsimp
  have : _root_.IsReduced (CommRingCat.of <| Localization.AtPrime (PrimeSpectrum.asIdeal x)) := by
    

Proof state:
X : Scheme
R : CommRingCat
H : _root_.IsReduced ↑R
x : ↑↑(Scheme.Spec.obj (op R)).toPresheafedSpace
⊢ _root_.IsReduced ↑(CommRingCat.of (Localization.AtPrime x.asIdeal))

Next tactic:
dsimp
instance {R : CommRingCat} [H : _root_.IsReduced R] : IsReduced (Scheme.Spec.obj <| op R) := by
  apply (config := { allowSynthFailures := true }) isReducedOfStalkIsReduced
  intro x; dsimp
  have : _root_.IsReduced (CommRingCat.of <| Localization.AtPrime (PrimeSpectrum.asIdeal x)) := by
    dsimp; 

Proof state:
X : Scheme
R : CommRingCat
H : _root_.IsReduced ↑R
x : ↑↑(Scheme.Spec.obj (op R)).toPresheafedSpace
⊢ _root_.IsReduced (Localization.AtPrime x.asIdeal)

Next tactic:
infer_instance
instance {R : CommRingCat} [H : _root_.IsReduced R] : IsReduced (Scheme.Spec.obj <| op R) := by
  apply (config := { allowSynthFailures := true }) isReducedOfStalkIsReduced
  intro x; dsimp
  have : _root_.IsReduced (CommRingCat.of <| Localization.AtPrime (PrimeSpectrum.asIdeal x)) := by
    dsimp; infer_instance
  

Proof state:
case inst
X : Scheme
R : CommRingCat
H : _root_.IsReduced ↑R
x : ↑↑(Scheme.Spec.obj (op R)).toPresheafedSpace
this : _root_.IsReduced ↑(CommRingCat.of (Localization.AtPrime x.asIdeal))
⊢ _root_.IsReduced ↑(Presheaf.stalk (Scheme.Spec.obj (op R)).presheaf x)

Next tactic:
rw [show (Scheme.Spec.obj <| op R).presheaf = (Spec.structureSheaf R).presheaf from rfl]
instance {R : CommRingCat} [H : _root_.IsReduced R] : IsReduced (Scheme.Spec.obj <| op R) := by
  apply (config := { allowSynthFailures := true }) isReducedOfStalkIsReduced
  intro x; dsimp
  have : _root_.IsReduced (CommRingCat.of <| Localization.AtPrime (PrimeSpectrum.asIdeal x)) := by
    dsimp; infer_instance
  rw [show (Scheme.Spec.obj <| op R).presheaf = (Spec.structureSheaf R).presheaf from rfl]
  

Proof state:
case inst
X : Scheme
R : CommRingCat
H : _root_.IsReduced ↑R
x : ↑↑(Scheme.Spec.obj (op R)).toPresheafedSpace
this : _root_.IsReduced ↑(CommRingCat.of (Localization.AtPrime x.asIdeal))
⊢ _root_.IsReduced ↑(Presheaf.stalk (Sheaf.presheaf (Spec.structureSheaf ↑R)) x)

Next tactic:
exact isReduced_of_injective (StructureSheaf.stalkIso R x).hom
    (StructureSheaf.stalkIso R x).commRingCatIsoToRingEquiv.injective
theorem affine_isReduced_iff (R : CommRingCat) :
    IsReduced (Scheme.Spec.obj <| op R) ↔ _root_.IsReduced R := by
  

Proof state:
X : Scheme
R : CommRingCat
⊢ IsReduced (Scheme.Spec.obj (op R)) ↔ _root_.IsReduced ↑R

Next tactic:
refine' ⟨_, fun h => inferInstance⟩
theorem affine_isReduced_iff (R : CommRingCat) :
    IsReduced (Scheme.Spec.obj <| op R) ↔ _root_.IsReduced R := by
  refine' ⟨_, fun h => inferInstance⟩
  

Proof state:
X : Scheme
R : CommRingCat
⊢ IsReduced (Scheme.Spec.obj (op R)) → _root_.IsReduced ↑R

Next tactic:
intro h
theorem affine_isReduced_iff (R : CommRingCat) :
    IsReduced (Scheme.Spec.obj <| op R) ↔ _root_.IsReduced R := by
  refine' ⟨_, fun h => inferInstance⟩
  intro h
  

Proof state:
X : Scheme
R : CommRingCat
h : IsReduced (Scheme.Spec.obj (op R))
⊢ _root_.IsReduced ↑R

Next tactic:
have : _root_.IsReduced
      (LocallyRingedSpace.Γ.obj (op <| Spec.toLocallyRingedSpace.obj <| op R)) := by
    change _root_.IsReduced ((Scheme.Spec.obj <| op R).presheaf.obj <| op ⊤); infer_instance
theorem affine_isReduced_iff (R : CommRingCat) :
    IsReduced (Scheme.Spec.obj <| op R) ↔ _root_.IsReduced R := by
  refine' ⟨_, fun h => inferInstance⟩
  intro h
  have : _root_.IsReduced
      (LocallyRingedSpace.Γ.obj (op <| Spec.toLocallyRingedSpace.obj <| op R)) := by
    

Proof state:
X : Scheme
R : CommRingCat
h : IsReduced (Scheme.Spec.obj (op R))
⊢ _root_.IsReduced ↑(LocallyRingedSpace.Γ.obj (op (Spec.toLocallyRingedSpace.obj (op R))))

Next tactic:
change _root_.IsReduced ((Scheme.Spec.obj <| op R).presheaf.obj <| op ⊤)
theorem affine_isReduced_iff (R : CommRingCat) :
    IsReduced (Scheme.Spec.obj <| op R) ↔ _root_.IsReduced R := by
  refine' ⟨_, fun h => inferInstance⟩
  intro h
  have : _root_.IsReduced
      (LocallyRingedSpace.Γ.obj (op <| Spec.toLocallyRingedSpace.obj <| op R)) := by
    change _root_.IsReduced ((Scheme.Spec.obj <| op R).presheaf.obj <| op ⊤); 

Proof state:
X : Scheme
R : CommRingCat
h : IsReduced (Scheme.Spec.obj (op R))
⊢ _root_.IsReduced ↑((Scheme.Spec.obj (op R)).presheaf.obj (op ⊤))

Next tactic:
infer_instance
theorem affine_isReduced_iff (R : CommRingCat) :
    IsReduced (Scheme.Spec.obj <| op R) ↔ _root_.IsReduced R := by
  refine' ⟨_, fun h => inferInstance⟩
  intro h
  have : _root_.IsReduced
      (LocallyRingedSpace.Γ.obj (op <| Spec.toLocallyRingedSpace.obj <| op R)) := by
    change _root_.IsReduced ((Scheme.Spec.obj <| op R).presheaf.obj <| op ⊤); infer_instance
  

Proof state:
X : Scheme
R : CommRingCat
h : IsReduced (Scheme.Spec.obj (op R))
this : _root_.IsReduced ↑(LocallyRingedSpace.Γ.obj (op (Spec.toLocallyRingedSpace.obj (op R))))
⊢ _root_.IsReduced ↑R

Next tactic:
exact isReduced_of_injective (toSpecΓ R) (asIso <| toSpecΓ R).commRingCatIsoToRingEquiv.injective
theorem isReducedOfIsAffineIsReduced [IsAffine X] [h : _root_.IsReduced (X.presheaf.obj (op ⊤))] :
    IsReduced X :=
  haveI : IsReduced (Scheme.Spec.obj (op (Scheme.Γ.obj (op X)))) := by
    

Proof state:
X : Scheme
inst✝ : IsAffine X
h : _root_.IsReduced ↑(X.presheaf.obj (op ⊤))
⊢ IsReduced (Scheme.Spec.obj (op (Scheme.Γ.obj (op X))))

Next tactic:
rw [affine_isReduced_iff]
theorem isReducedOfIsAffineIsReduced [IsAffine X] [h : _root_.IsReduced (X.presheaf.obj (op ⊤))] :
    IsReduced X :=
  haveI : IsReduced (Scheme.Spec.obj (op (Scheme.Γ.obj (op X)))) := by
    rw [affine_isReduced_iff]; 

Proof state:
X : Scheme
inst✝ : IsAffine X
h : _root_.IsReduced ↑(X.presheaf.obj (op ⊤))
⊢ _root_.IsReduced ↑(Scheme.Γ.obj (op X))

Next tactic:
exact h
/-- To show that a statement `P` holds for all open subsets of all schemes, it suffices to show that
1. In any scheme `X`, if `P` holds for an open cover of `U`, then `P` holds for `U`.
2. For an open immerison `f : X ⟶ Y`, if `P` holds for the entire space of `X`, then `P` holds for
  the image of `f`.
3. `P` holds for the entire space of an affine scheme.
-/
theorem reduce_to_affine_global (P : ∀ (X : Scheme) (_ : Opens X.carrier), Prop)
    (h₁ : ∀ (X : Scheme) (U : Opens X.carrier),
      (∀ x : U, ∃ (V : _) (_ : x.1 ∈ V) (_ : V ⟶ U), P X V) → P X U)
    (h₂ : ∀ {X Y} (f : X ⟶ Y) [hf : IsOpenImmersion f],
      ∃ (U : Set X.carrier) (V : Set Y.carrier) (hU : U = ⊤) (hV : V = Set.range f.1.base),
        P X ⟨U, hU.symm ▸ isOpen_univ⟩ → P Y ⟨V, hV.symm ▸ hf.base_open.open_range⟩)
    (h₃ : ∀ R : CommRingCat, P (Scheme.Spec.obj <| op R) ⊤) :
    ∀ (X : Scheme) (U : Opens X.carrier), P X U := by
  

Proof state:
X : Scheme
P : (X : Scheme) → Opens ↑↑X.toPresheafedSpace → Prop
h₁ : ∀ (X : Scheme) (U : Opens ↑↑X.toPresheafedSpace), (∀ (x : ↥U), ∃ V, ∃ (_ : ↑x ∈ V), ∃ x, P X V) → P X U
h₂ :
  ∀ {X Y : Scheme} (f : X ⟶ Y) [hf : IsOpenImmersion f],
    ∃ U V,
      ∃ (hU : U = ⊤) (hV : V = Set.range ⇑f.val.base),
        P X { carrier := U, is_open' := (_ : IsOpen U) } → P Y { carrier := V, is_open' := (_ : IsOpen V) }
h₃ : ∀ (R : CommRingCat), P (Scheme.Spec.obj (op R)) ⊤
⊢ ∀ (X : Scheme) (U : Opens ↑↑X.toPresheafedSpace), P X U

Next tactic:
intro X U
/-- To show that a statement `P` holds for all open subsets of all schemes, it suffices to show that
1. In any scheme `X`, if `P` holds for an open cover of `U`, then `P` holds for `U`.
2. For an open immerison `f : X ⟶ Y`, if `P` holds for the entire space of `X`, then `P` holds for
  the image of `f`.
3. `P` holds for the entire space of an affine scheme.
-/
theorem reduce_to_affine_global (P : ∀ (X : Scheme) (_ : Opens X.carrier), Prop)
    (h₁ : ∀ (X : Scheme) (U : Opens X.carrier),
      (∀ x : U, ∃ (V : _) (_ : x.1 ∈ V) (_ : V ⟶ U), P X V) → P X U)
    (h₂ : ∀ {X Y} (f : X ⟶ Y) [hf : IsOpenImmersion f],
      ∃ (U : Set X.carrier) (V : Set Y.carrier) (hU : U = ⊤) (hV : V = Set.range f.1.base),
        P X ⟨U, hU.symm ▸ isOpen_univ⟩ → P Y ⟨V, hV.symm ▸ hf.base_open.open_range⟩)
    (h₃ : ∀ R : CommRingCat, P (Scheme.Spec.obj <| op R) ⊤) :
    ∀ (X : Scheme) (U : Opens X.carrier), P X U := by
  intro X U
  

Proof state:
X✝ : Scheme
P : (X : Scheme) → Opens ↑↑X.toPresheafedSpace → Prop
h₁ : ∀ (X : Scheme) (U : Opens ↑↑X.toPresheafedSpace), (∀ (x : ↥U), ∃ V, ∃ (_ : ↑x ∈ V), ∃ x, P X V) → P X U
h₂ :
  ∀ {X Y : Scheme} (f : X ⟶ Y) [hf : IsOpenImmersion f],
    ∃ U V,
      ∃ (hU : U = ⊤) (hV : V = Set.range ⇑f.val.base),
        P X { carrier := U, is_open' := (_ : IsOpen U) } → P Y { carrier := V, is_open' := (_ : IsOpen V) }
h₃ : ∀ (R : CommRingCat), P (Scheme.Spec.obj (op R)) ⊤
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
⊢ P X U

Next tactic:
apply h₁
/-- To show that a statement `P` holds for all open subsets of all schemes, it suffices to show that
1. In any scheme `X`, if `P` holds for an open cover of `U`, then `P` holds for `U`.
2. For an open immerison `f : X ⟶ Y`, if `P` holds for the entire space of `X`, then `P` holds for
  the image of `f`.
3. `P` holds for the entire space of an affine scheme.
-/
theorem reduce_to_affine_global (P : ∀ (X : Scheme) (_ : Opens X.carrier), Prop)
    (h₁ : ∀ (X : Scheme) (U : Opens X.carrier),
      (∀ x : U, ∃ (V : _) (_ : x.1 ∈ V) (_ : V ⟶ U), P X V) → P X U)
    (h₂ : ∀ {X Y} (f : X ⟶ Y) [hf : IsOpenImmersion f],
      ∃ (U : Set X.carrier) (V : Set Y.carrier) (hU : U = ⊤) (hV : V = Set.range f.1.base),
        P X ⟨U, hU.symm ▸ isOpen_univ⟩ → P Y ⟨V, hV.symm ▸ hf.base_open.open_range⟩)
    (h₃ : ∀ R : CommRingCat, P (Scheme.Spec.obj <| op R) ⊤) :
    ∀ (X : Scheme) (U : Opens X.carrier), P X U := by
  intro X U
  apply h₁
  

Proof state:
case a
X✝ : Scheme
P : (X : Scheme) → Opens ↑↑X.toPresheafedSpace → Prop
h₁ : ∀ (X : Scheme) (U : Opens ↑↑X.toPresheafedSpace), (∀ (x : ↥U), ∃ V, ∃ (_ : ↑x ∈ V), ∃ x, P X V) → P X U
h₂ :
  ∀ {X Y : Scheme} (f : X ⟶ Y) [hf : IsOpenImmersion f],
    ∃ U V,
      ∃ (hU : U = ⊤) (hV : V = Set.range ⇑f.val.base),
        P X { carrier := U, is_open' := (_ : IsOpen U) } → P Y { carrier := V, is_open' := (_ : IsOpen V) }
h₃ : ∀ (R : CommRingCat), P (Scheme.Spec.obj (op R)) ⊤
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
⊢ ∀ (x : ↥U), ∃ V, ∃ (_ : ↑x ∈ V), ∃ x, P X V

Next tactic:
intro x
/-- To show that a statement `P` holds for all open subsets of all schemes, it suffices to show that
1. In any scheme `X`, if `P` holds for an open cover of `U`, then `P` holds for `U`.
2. For an open immerison `f : X ⟶ Y`, if `P` holds for the entire space of `X`, then `P` holds for
  the image of `f`.
3. `P` holds for the entire space of an affine scheme.
-/
theorem reduce_to_affine_global (P : ∀ (X : Scheme) (_ : Opens X.carrier), Prop)
    (h₁ : ∀ (X : Scheme) (U : Opens X.carrier),
      (∀ x : U, ∃ (V : _) (_ : x.1 ∈ V) (_ : V ⟶ U), P X V) → P X U)
    (h₂ : ∀ {X Y} (f : X ⟶ Y) [hf : IsOpenImmersion f],
      ∃ (U : Set X.carrier) (V : Set Y.carrier) (hU : U = ⊤) (hV : V = Set.range f.1.base),
        P X ⟨U, hU.symm ▸ isOpen_univ⟩ → P Y ⟨V, hV.symm ▸ hf.base_open.open_range⟩)
    (h₃ : ∀ R : CommRingCat, P (Scheme.Spec.obj <| op R) ⊤) :
    ∀ (X : Scheme) (U : Opens X.carrier), P X U := by
  intro X U
  apply h₁
  intro x
  

Proof state:
case a
X✝ : Scheme
P : (X : Scheme) → Opens ↑↑X.toPresheafedSpace → Prop
h₁ : ∀ (X : Scheme) (U : Opens ↑↑X.toPresheafedSpace), (∀ (x : ↥U), ∃ V, ∃ (_ : ↑x ∈ V), ∃ x, P X V) → P X U
h₂ :
  ∀ {X Y : Scheme} (f : X ⟶ Y) [hf : IsOpenImmersion f],
    ∃ U V,
      ∃ (hU : U = ⊤) (hV : V = Set.range ⇑f.val.base),
        P X { carrier := U, is_open' := (_ : IsOpen U) } → P Y { carrier := V, is_open' := (_ : IsOpen V) }
h₃ : ∀ (R : CommRingCat), P (Scheme.Spec.obj (op R)) ⊤
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
x : ↥U
⊢ ∃ V, ∃ (_ : ↑x ∈ V), ∃ x, P X V

Next tactic:
obtain ⟨_, ⟨j, rfl⟩, hx, i⟩ :=
    X.affineBasisCover_is_basis.exists_subset_of_mem_open (SetLike.mem_coe.2 x.prop) U.isOpen
/-- To show that a statement `P` holds for all open subsets of all schemes, it suffices to show that
1. In any scheme `X`, if `P` holds for an open cover of `U`, then `P` holds for `U`.
2. For an open immerison `f : X ⟶ Y`, if `P` holds for the entire space of `X`, then `P` holds for
  the image of `f`.
3. `P` holds for the entire space of an affine scheme.
-/
theorem reduce_to_affine_global (P : ∀ (X : Scheme) (_ : Opens X.carrier), Prop)
    (h₁ : ∀ (X : Scheme) (U : Opens X.carrier),
      (∀ x : U, ∃ (V : _) (_ : x.1 ∈ V) (_ : V ⟶ U), P X V) → P X U)
    (h₂ : ∀ {X Y} (f : X ⟶ Y) [hf : IsOpenImmersion f],
      ∃ (U : Set X.carrier) (V : Set Y.carrier) (hU : U = ⊤) (hV : V = Set.range f.1.base),
        P X ⟨U, hU.symm ▸ isOpen_univ⟩ → P Y ⟨V, hV.symm ▸ hf.base_open.open_range⟩)
    (h₃ : ∀ R : CommRingCat, P (Scheme.Spec.obj <| op R) ⊤) :
    ∀ (X : Scheme) (U : Opens X.carrier), P X U := by
  intro X U
  apply h₁
  intro x
  obtain ⟨_, ⟨j, rfl⟩, hx, i⟩ :=
    X.affineBasisCover_is_basis.exists_subset_of_mem_open (SetLike.mem_coe.2 x.prop) U.isOpen
  

Proof state:
case a.intro.intro.intro.intro
X✝ : Scheme
P : (X : Scheme) → Opens ↑↑X.toPresheafedSpace → Prop
h₁ : ∀ (X : Scheme) (U : Opens ↑↑X.toPresheafedSpace), (∀ (x : ↥U), ∃ V, ∃ (_ : ↑x ∈ V), ∃ x, P X V) → P X U
h₂ :
  ∀ {X Y : Scheme} (f : X ⟶ Y) [hf : IsOpenImmersion f],
    ∃ U V,
      ∃ (hU : U = ⊤) (hV : V = Set.range ⇑f.val.base),
        P X { carrier := U, is_open' := (_ : IsOpen U) } → P Y { carrier := V, is_open' := (_ : IsOpen V) }
h₃ : ∀ (R : CommRingCat), P (Scheme.Spec.obj (op R)) ⊤
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
x : ↥U
j : (Scheme.affineBasisCover X).J
hx : ↑x ∈ Set.range ⇑(Scheme.OpenCover.map (Scheme.affineBasisCover X) j).val.base
i : Set.range ⇑(Scheme.OpenCover.map (Scheme.affineBasisCover X) j).val.base ⊆ ↑U
⊢ ∃ V, ∃ (_ : ↑x ∈ V), ∃ x, P X V

Next tactic:
let U' : Opens _ := ⟨_, (X.affineBasisCover.IsOpen j).base_open.open_range⟩
/-- To show that a statement `P` holds for all open subsets of all schemes, it suffices to show that
1. In any scheme `X`, if `P` holds for an open cover of `U`, then `P` holds for `U`.
2. For an open immerison `f : X ⟶ Y`, if `P` holds for the entire space of `X`, then `P` holds for
  the image of `f`.
3. `P` holds for the entire space of an affine scheme.
-/
theorem reduce_to_affine_global (P : ∀ (X : Scheme) (_ : Opens X.carrier), Prop)
    (h₁ : ∀ (X : Scheme) (U : Opens X.carrier),
      (∀ x : U, ∃ (V : _) (_ : x.1 ∈ V) (_ : V ⟶ U), P X V) → P X U)
    (h₂ : ∀ {X Y} (f : X ⟶ Y) [hf : IsOpenImmersion f],
      ∃ (U : Set X.carrier) (V : Set Y.carrier) (hU : U = ⊤) (hV : V = Set.range f.1.base),
        P X ⟨U, hU.symm ▸ isOpen_univ⟩ → P Y ⟨V, hV.symm ▸ hf.base_open.open_range⟩)
    (h₃ : ∀ R : CommRingCat, P (Scheme.Spec.obj <| op R) ⊤) :
    ∀ (X : Scheme) (U : Opens X.carrier), P X U := by
  intro X U
  apply h₁
  intro x
  obtain ⟨_, ⟨j, rfl⟩, hx, i⟩ :=
    X.affineBasisCover_is_basis.exists_subset_of_mem_open (SetLike.mem_coe.2 x.prop) U.isOpen
  let U' : Opens _ := ⟨_, (X.affineBasisCover.IsOpen j).base_open.open_range⟩
  

Proof state:
case a.intro.intro.intro.intro
X✝ : Scheme
P : (X : Scheme) → Opens ↑↑X.toPresheafedSpace → Prop
h₁ : ∀ (X : Scheme) (U : Opens ↑↑X.toPresheafedSpace), (∀ (x : ↥U), ∃ V, ∃ (_ : ↑x ∈ V), ∃ x, P X V) → P X U
h₂ :
  ∀ {X Y : Scheme} (f : X ⟶ Y) [hf : IsOpenImmersion f],
    ∃ U V,
      ∃ (hU : U = ⊤) (hV : V = Set.range ⇑f.val.base),
        P X { carrier := U, is_open' := (_ : IsOpen U) } → P Y { carrier := V, is_open' := (_ : IsOpen V) }
h₃ : ∀ (R : CommRingCat), P (Scheme.Spec.obj (op R)) ⊤
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
x : ↥U
j : (Scheme.affineBasisCover X).J
hx : ↑x ∈ Set.range ⇑(Scheme.OpenCover.map (Scheme.affineBasisCover X) j).val.base
i : Set.range ⇑(Scheme.OpenCover.map (Scheme.affineBasisCover X) j).val.base ⊆ ↑U
U' : Opens ((forget TopCat).obj ↑X.toPresheafedSpace) :=
  { carrier := Set.range ⇑(Scheme.OpenCover.map (Scheme.affineBasisCover X) j).val.base,
    is_open' := (_ : IsOpen (Set.range ⇑(Scheme.OpenCover.map (Scheme.affineBasisCover X) j).val.base)) }
⊢ ∃ V, ∃ (_ : ↑x ∈ V), ∃ x, P X V

Next tactic:
let i' : U' ⟶ U := homOfLE i