l3lab/ntp-mathlib huggingface dataset:
theorem eq_zero_of_basicOpen_eq_bot {X : Scheme} [hX : IsReduced X] {U : Opens X.carrier}
    (s : X.presheaf.obj (op U)) (hs : X.basicOpen s = ⊥) : s = 0 := by
  apply TopCat.Presheaf.section_ext X.sheaf U
  conv => intro x; rw [RingHom.map_zero]
  refine' (@reduce_to_affine_global (fun X U =>
     ∀ [IsReduced X] (s : X.presheaf.obj (op U)),
       X.basicOpen s = ⊥ → ∀ x, (X.sheaf.presheaf.germ x) s = 0) _ _ _) X U s hs
  · intro X U hx hX s hs x
    obtain ⟨V, hx, i, H⟩ := hx x
    specialize H (X.presheaf.map i.op s)
    erw [Scheme.basicOpen_res] at H
    rw [hs] at H
    specialize H inf_bot_eq ⟨x, hx⟩
    erw [TopCat.Presheaf.germ_res_apply] at H
    exact H
  · rintro X Y f hf
    have e : f.val.base ⁻¹' Set.range ↑f.val.base = Set.univ := by
      rw [← Set.image_univ, Set.preimage_image_eq _ hf.base_open.inj]
    refine' ⟨_, _, e, rfl, _⟩
    rintro H hX s hs ⟨_, x, rfl⟩
    haveI := isReducedOfOpenImmersion f
    specialize H (f.1.c.app _ s) _ ⟨x, by rw [Opens.mem_mk, e]; trivial⟩
    · rw [← Scheme.preimage_basicOpen, hs]; 

Proof state:
case h.refine'_2.mk.intro
X✝¹ : Scheme
X✝ : Scheme
hX✝ : IsReduced X✝
U : Opens ↑↑X✝.toPresheafedSpace
s✝ : ↑(X✝.presheaf.obj (op U))
hs✝ : X✝.basicOpen s✝ = ⊥
X Y : Scheme
f : X ⟶ Y
hf : IsOpenImmersion f
e : ⇑f.val.base ⁻¹' Set.range ⇑f.val.base = Set.univ
H :
  ∀ [inst : IsReduced X]
    (s :
      ↑(X.presheaf.obj
          (op
            { carrier := ⇑f.val.base ⁻¹' Set.range ⇑f.val.base,
              is_open' := (_ : IsOpen (⇑f.val.base ⁻¹' Set.range ⇑f.val.base)) }))),
    X.basicOpen s = ⊥ →
      ∀
        (x :
          ↥{ carrier := ⇑f.val.base ⁻¹' Set.range ⇑f.val.base,
              is_open' := (_ : IsOpen (⇑f.val.base ⁻¹' Set.range ⇑f.val.base)) }),
        (Presheaf.germ (Sheaf.presheaf (Scheme.sheaf X)) x) s = 0
hX : IsReduced Y
s : ↑(Y.presheaf.obj (op { carrier := Set.range ⇑f.val.base, is_open' := (_ : IsOpen (Set.range ⇑f.val.base)) }))
hs : Y.basicOpen s = ⊥
x : (forget TopCat).obj ↑X.toPresheafedSpace
this : IsReduced X
⊢ f⁻¹ᵁ ⊥ = ⊥

Next tactic:
ext1
theorem eq_zero_of_basicOpen_eq_bot {X : Scheme} [hX : IsReduced X] {U : Opens X.carrier}
    (s : X.presheaf.obj (op U)) (hs : X.basicOpen s = ⊥) : s = 0 := by
  apply TopCat.Presheaf.section_ext X.sheaf U
  conv => intro x; rw [RingHom.map_zero]
  refine' (@reduce_to_affine_global (fun X U =>
     ∀ [IsReduced X] (s : X.presheaf.obj (op U)),
       X.basicOpen s = ⊥ → ∀ x, (X.sheaf.presheaf.germ x) s = 0) _ _ _) X U s hs
  · intro X U hx hX s hs x
    obtain ⟨V, hx, i, H⟩ := hx x
    specialize H (X.presheaf.map i.op s)
    erw [Scheme.basicOpen_res] at H
    rw [hs] at H
    specialize H inf_bot_eq ⟨x, hx⟩
    erw [TopCat.Presheaf.germ_res_apply] at H
    exact H
  · rintro X Y f hf
    have e : f.val.base ⁻¹' Set.range ↑f.val.base = Set.univ := by
      rw [← Set.image_univ, Set.preimage_image_eq _ hf.base_open.inj]
    refine' ⟨_, _, e, rfl, _⟩
    rintro H hX s hs ⟨_, x, rfl⟩
    haveI := isReducedOfOpenImmersion f
    specialize H (f.1.c.app _ s) _ ⟨x, by rw [Opens.mem_mk, e]; trivial⟩
    · rw [← Scheme.preimage_basicOpen, hs]; ext1; 

Proof state:
case h.refine'_2.mk.intro.h
X✝¹ : Scheme
X✝ : Scheme
hX✝ : IsReduced X✝
U : Opens ↑↑X✝.toPresheafedSpace
s✝ : ↑(X✝.presheaf.obj (op U))
hs✝ : X✝.basicOpen s✝ = ⊥
X Y : Scheme
f : X ⟶ Y
hf : IsOpenImmersion f
e : ⇑f.val.base ⁻¹' Set.range ⇑f.val.base = Set.univ
H :
  ∀ [inst : IsReduced X]
    (s :
      ↑(X.presheaf.obj
          (op
            { carrier := ⇑f.val.base ⁻¹' Set.range ⇑f.val.base,
              is_open' := (_ : IsOpen (⇑f.val.base ⁻¹' Set.range ⇑f.val.base)) }))),
    X.basicOpen s = ⊥ →
      ∀
        (x :
          ↥{ carrier := ⇑f.val.base ⁻¹' Set.range ⇑f.val.base,
              is_open' := (_ : IsOpen (⇑f.val.base ⁻¹' Set.range ⇑f.val.base)) }),
        (Presheaf.germ (Sheaf.presheaf (Scheme.sheaf X)) x) s = 0
hX : IsReduced Y
s : ↑(Y.presheaf.obj (op { carrier := Set.range ⇑f.val.base, is_open' := (_ : IsOpen (Set.range ⇑f.val.base)) }))
hs : Y.basicOpen s = ⊥
x : (forget TopCat).obj ↑X.toPresheafedSpace
this : IsReduced X
⊢ ↑(f⁻¹ᵁ ⊥) = ↑⊥

Next tactic:
simp [Opens.map]
theorem eq_zero_of_basicOpen_eq_bot {X : Scheme} [hX : IsReduced X] {U : Opens X.carrier}
    (s : X.presheaf.obj (op U)) (hs : X.basicOpen s = ⊥) : s = 0 := by
  apply TopCat.Presheaf.section_ext X.sheaf U
  conv => intro x; rw [RingHom.map_zero]
  refine' (@reduce_to_affine_global (fun X U =>
     ∀ [IsReduced X] (s : X.presheaf.obj (op U)),
       X.basicOpen s = ⊥ → ∀ x, (X.sheaf.presheaf.germ x) s = 0) _ _ _) X U s hs
  · intro X U hx hX s hs x
    obtain ⟨V, hx, i, H⟩ := hx x
    specialize H (X.presheaf.map i.op s)
    erw [Scheme.basicOpen_res] at H
    rw [hs] at H
    specialize H inf_bot_eq ⟨x, hx⟩
    erw [TopCat.Presheaf.germ_res_apply] at H
    exact H
  · rintro X Y f hf
    have e : f.val.base ⁻¹' Set.range ↑f.val.base = Set.univ := by
      rw [← Set.image_univ, Set.preimage_image_eq _ hf.base_open.inj]
    refine' ⟨_, _, e, rfl, _⟩
    rintro H hX s hs ⟨_, x, rfl⟩
    haveI := isReducedOfOpenImmersion f
    specialize H (f.1.c.app _ s) _ ⟨x, by rw [Opens.mem_mk, e]; trivial⟩
    · rw [← Scheme.preimage_basicOpen, hs]; ext1; simp [Opens.map]
    · 

Proof state:
case h.refine'_2.mk.intro
X✝¹ : Scheme
X✝ : Scheme
hX✝ : IsReduced X✝
U : Opens ↑↑X✝.toPresheafedSpace
s✝ : ↑(X✝.presheaf.obj (op U))
hs✝ : X✝.basicOpen s✝ = ⊥
X Y : Scheme
f : X ⟶ Y
hf : IsOpenImmersion f
e : ⇑f.val.base ⁻¹' Set.range ⇑f.val.base = Set.univ
hX : IsReduced Y
s : ↑(Y.presheaf.obj (op { carrier := Set.range ⇑f.val.base, is_open' := (_ : IsOpen (Set.range ⇑f.val.base)) }))
hs : Y.basicOpen s = ⊥
x : (forget TopCat).obj ↑X.toPresheafedSpace
this : IsReduced X
H :
  (Presheaf.germ (Sheaf.presheaf (Scheme.sheaf X))
        { val := x,
          property :=
            (_ :
              x ∈
                { carrier := ⇑f.val.base ⁻¹' Set.range ⇑f.val.base,
                  is_open' := (_ : IsOpen (⇑f.val.base ⁻¹' Set.range ⇑f.val.base)) }) })
      ((f.val.c.app (op { carrier := Set.range ⇑f.val.base, is_open' := (_ : IsOpen (Set.range ⇑f.val.base)) })) s) =
    0
⊢ (Presheaf.germ (Sheaf.presheaf (Scheme.sheaf Y))
        { val := f.val.base x, property := (_ : ∃ y, f.val.base y = f.val.base x) })
      s =
    0

Next tactic:
erw [← PresheafedSpace.stalkMap_germ_apply f.1 ⟨_, _⟩ ⟨x, _⟩] at H
theorem eq_zero_of_basicOpen_eq_bot {X : Scheme} [hX : IsReduced X] {U : Opens X.carrier}
    (s : X.presheaf.obj (op U)) (hs : X.basicOpen s = ⊥) : s = 0 := by
  apply TopCat.Presheaf.section_ext X.sheaf U
  conv => intro x; rw [RingHom.map_zero]
  refine' (@reduce_to_affine_global (fun X U =>
     ∀ [IsReduced X] (s : X.presheaf.obj (op U)),
       X.basicOpen s = ⊥ → ∀ x, (X.sheaf.presheaf.germ x) s = 0) _ _ _) X U s hs
  · intro X U hx hX s hs x
    obtain ⟨V, hx, i, H⟩ := hx x
    specialize H (X.presheaf.map i.op s)
    erw [Scheme.basicOpen_res] at H
    rw [hs] at H
    specialize H inf_bot_eq ⟨x, hx⟩
    erw [TopCat.Presheaf.germ_res_apply] at H
    exact H
  · rintro X Y f hf
    have e : f.val.base ⁻¹' Set.range ↑f.val.base = Set.univ := by
      rw [← Set.image_univ, Set.preimage_image_eq _ hf.base_open.inj]
    refine' ⟨_, _, e, rfl, _⟩
    rintro H hX s hs ⟨_, x, rfl⟩
    haveI := isReducedOfOpenImmersion f
    specialize H (f.1.c.app _ s) _ ⟨x, by rw [Opens.mem_mk, e]; trivial⟩
    · rw [← Scheme.preimage_basicOpen, hs]; ext1; simp [Opens.map]
    · erw [← PresheafedSpace.stalkMap_germ_apply f.1 ⟨_, _⟩ ⟨x, _⟩] at H
      

Proof state:
case h.refine'_2.mk.intro
X✝¹ : Scheme
X✝ : Scheme
hX✝ : IsReduced X✝
U : Opens ↑↑X✝.toPresheafedSpace
s✝ : ↑(X✝.presheaf.obj (op U))
hs✝ : X✝.basicOpen s✝ = ⊥
X Y : Scheme
f : X ⟶ Y
hf : IsOpenImmersion f
e : ⇑f.val.base ⁻¹' Set.range ⇑f.val.base = Set.univ
hX : IsReduced Y
s : ↑(Y.presheaf.obj (op { carrier := Set.range ⇑f.val.base, is_open' := (_ : IsOpen (Set.range ⇑f.val.base)) }))
hs : Y.basicOpen s = ⊥
x : (forget TopCat).obj ↑X.toPresheafedSpace
this : IsReduced X
H :
  (PresheafedSpace.stalkMap f.val
        ↑{ val := x,
            property :=
              (_ :
                x ∈
                  { carrier := ⇑f.val.base ⁻¹' Set.range ⇑f.val.base,
                    is_open' := (_ : IsOpen (⇑f.val.base ⁻¹' Set.range ⇑f.val.base)) }) })
      ((Presheaf.germ Y.presheaf
          {
            val :=
              f.val.base
                ↑{ val := x,
                    property :=
                      (_ :
                        x ∈
                          { carrier := ⇑f.val.base ⁻¹' Set.range ⇑f.val.base,
                            is_open' := (_ : IsOpen (⇑f.val.base ⁻¹' Set.range ⇑f.val.base)) }) },
            property :=
              (_ :
                ↑{ val := x,
                      property :=
                        (_ :
                          x ∈
                            { carrier := ⇑f.val.base ⁻¹' Set.range ⇑f.val.base,
                              is_open' := (_ : IsOpen (⇑f.val.base ⁻¹' Set.range ⇑f.val.base)) }) } ∈
                  f⁻¹ᵁ
                    { carrier := fun x => ∃ y, f.val.base y = x, is_open' := (_ : IsOpen (Set.range ⇑f.val.base)) }) })
        s) =
    0
⊢ (Presheaf.germ (Sheaf.presheaf (Scheme.sheaf Y))
        { val := f.val.base x, property := (_ : ∃ y, f.val.base y = f.val.base x) })
      s =
    0

Next tactic:
apply_fun inv <| PresheafedSpace.stalkMap f.val x at H
theorem eq_zero_of_basicOpen_eq_bot {X : Scheme} [hX : IsReduced X] {U : Opens X.carrier}
    (s : X.presheaf.obj (op U)) (hs : X.basicOpen s = ⊥) : s = 0 := by
  apply TopCat.Presheaf.section_ext X.sheaf U
  conv => intro x; rw [RingHom.map_zero]
  refine' (@reduce_to_affine_global (fun X U =>
     ∀ [IsReduced X] (s : X.presheaf.obj (op U)),
       X.basicOpen s = ⊥ → ∀ x, (X.sheaf.presheaf.germ x) s = 0) _ _ _) X U s hs
  · intro X U hx hX s hs x
    obtain ⟨V, hx, i, H⟩ := hx x
    specialize H (X.presheaf.map i.op s)
    erw [Scheme.basicOpen_res] at H
    rw [hs] at H
    specialize H inf_bot_eq ⟨x, hx⟩
    erw [TopCat.Presheaf.germ_res_apply] at H
    exact H
  · rintro X Y f hf
    have e : f.val.base ⁻¹' Set.range ↑f.val.base = Set.univ := by
      rw [← Set.image_univ, Set.preimage_image_eq _ hf.base_open.inj]
    refine' ⟨_, _, e, rfl, _⟩
    rintro H hX s hs ⟨_, x, rfl⟩
    haveI := isReducedOfOpenImmersion f
    specialize H (f.1.c.app _ s) _ ⟨x, by rw [Opens.mem_mk, e]; trivial⟩
    · rw [← Scheme.preimage_basicOpen, hs]; ext1; simp [Opens.map]
    · erw [← PresheafedSpace.stalkMap_germ_apply f.1 ⟨_, _⟩ ⟨x, _⟩] at H
      apply_fun inv <| PresheafedSpace.stalkMap f.val x at H
      erw [CategoryTheory.IsIso.hom_inv_id_apply, map_zero] at H
      

Proof state:
case h.refine'_2.mk.intro
X✝¹ : Scheme
X✝ : Scheme
hX✝ : IsReduced X✝
U : Opens ↑↑X✝.toPresheafedSpace
s✝ : ↑(X✝.presheaf.obj (op U))
hs✝ : X✝.basicOpen s✝ = ⊥
X Y : Scheme
f : X ⟶ Y
hf : IsOpenImmersion f
e : ⇑f.val.base ⁻¹' Set.range ⇑f.val.base = Set.univ
hX : IsReduced Y
s : ↑(Y.presheaf.obj (op { carrier := Set.range ⇑f.val.base, is_open' := (_ : IsOpen (Set.range ⇑f.val.base)) }))
hs : Y.basicOpen s = ⊥
x : (forget TopCat).obj ↑X.toPresheafedSpace
this : IsReduced X
H :
  (Presheaf.germ Y.presheaf
        {
          val :=
            f.val.base
              ↑{ val := x,
                  property :=
                    (_ :
                      x ∈
                        { carrier := ⇑f.val.base ⁻¹' Set.range ⇑f.val.base,
                          is_open' := (_ : IsOpen (⇑f.val.base ⁻¹' Set.range ⇑f.val.base)) }) },
          property :=
            (_ :
              ↑{ val := x,
                    property :=
                      (_ :
                        x ∈
                          { carrier := ⇑f.val.base ⁻¹' Set.range ⇑f.val.base,
                            is_open' := (_ : IsOpen (⇑f.val.base ⁻¹' Set.range ⇑f.val.base)) }) } ∈
                f⁻¹ᵁ { carrier := fun x => ∃ y, f.val.base y = x, is_open' := (_ : IsOpen (Set.range ⇑f.val.base)) }) })
      s =
    0
⊢ (Presheaf.germ (Sheaf.presheaf (Scheme.sheaf Y))
        { val := f.val.base x, property := (_ : ∃ y, f.val.base y = f.val.base x) })
      s =
    0

Next tactic:
exact H
theorem eq_zero_of_basicOpen_eq_bot {X : Scheme} [hX : IsReduced X] {U : Opens X.carrier}
    (s : X.presheaf.obj (op U)) (hs : X.basicOpen s = ⊥) : s = 0 := by
  apply TopCat.Presheaf.section_ext X.sheaf U
  conv => intro x; rw [RingHom.map_zero]
  refine' (@reduce_to_affine_global (fun X U =>
     ∀ [IsReduced X] (s : X.presheaf.obj (op U)),
       X.basicOpen s = ⊥ → ∀ x, (X.sheaf.presheaf.germ x) s = 0) _ _ _) X U s hs
  · intro X U hx hX s hs x
    obtain ⟨V, hx, i, H⟩ := hx x
    specialize H (X.presheaf.map i.op s)
    erw [Scheme.basicOpen_res] at H
    rw [hs] at H
    specialize H inf_bot_eq ⟨x, hx⟩
    erw [TopCat.Presheaf.germ_res_apply] at H
    exact H
  · rintro X Y f hf
    have e : f.val.base ⁻¹' Set.range ↑f.val.base = Set.univ := by
      rw [← Set.image_univ, Set.preimage_image_eq _ hf.base_open.inj]
    refine' ⟨_, _, e, rfl, _⟩
    rintro H hX s hs ⟨_, x, rfl⟩
    haveI := isReducedOfOpenImmersion f
    specialize H (f.1.c.app _ s) _ ⟨x, by rw [Opens.mem_mk, e]; trivial⟩
    · rw [← Scheme.preimage_basicOpen, hs]; ext1; simp [Opens.map]
    · erw [← PresheafedSpace.stalkMap_germ_apply f.1 ⟨_, _⟩ ⟨x, _⟩] at H
      apply_fun inv <| PresheafedSpace.stalkMap f.val x at H
      erw [CategoryTheory.IsIso.hom_inv_id_apply, map_zero] at H
      exact H
  · 

Proof state:
case h.refine'_3
X✝ : Scheme
X : Scheme
hX : IsReduced X
U : Opens ↑↑X.toPresheafedSpace
s : ↑(X.presheaf.obj (op U))
hs : X.basicOpen s = ⊥
⊢ ∀ (R : CommRingCat),
    (fun X U =>
        ∀ [inst : IsReduced X] (s : ↑(X.presheaf.obj (op U))),
          X.basicOpen s = ⊥ → ∀ (x : ↥U), (Presheaf.germ (Sheaf.presheaf (Scheme.sheaf X)) x) s = 0)
      (Scheme.Spec.obj (op R)) ⊤

Next tactic:
intro R hX s hs x
theorem eq_zero_of_basicOpen_eq_bot {X : Scheme} [hX : IsReduced X] {U : Opens X.carrier}
    (s : X.presheaf.obj (op U)) (hs : X.basicOpen s = ⊥) : s = 0 := by
  apply TopCat.Presheaf.section_ext X.sheaf U
  conv => intro x; rw [RingHom.map_zero]
  refine' (@reduce_to_affine_global (fun X U =>
     ∀ [IsReduced X] (s : X.presheaf.obj (op U)),
       X.basicOpen s = ⊥ → ∀ x, (X.sheaf.presheaf.germ x) s = 0) _ _ _) X U s hs
  · intro X U hx hX s hs x
    obtain ⟨V, hx, i, H⟩ := hx x
    specialize H (X.presheaf.map i.op s)
    erw [Scheme.basicOpen_res] at H
    rw [hs] at H
    specialize H inf_bot_eq ⟨x, hx⟩
    erw [TopCat.Presheaf.germ_res_apply] at H
    exact H
  · rintro X Y f hf
    have e : f.val.base ⁻¹' Set.range ↑f.val.base = Set.univ := by
      rw [← Set.image_univ, Set.preimage_image_eq _ hf.base_open.inj]
    refine' ⟨_, _, e, rfl, _⟩
    rintro H hX s hs ⟨_, x, rfl⟩
    haveI := isReducedOfOpenImmersion f
    specialize H (f.1.c.app _ s) _ ⟨x, by rw [Opens.mem_mk, e]; trivial⟩
    · rw [← Scheme.preimage_basicOpen, hs]; ext1; simp [Opens.map]
    · erw [← PresheafedSpace.stalkMap_germ_apply f.1 ⟨_, _⟩ ⟨x, _⟩] at H
      apply_fun inv <| PresheafedSpace.stalkMap f.val x at H
      erw [CategoryTheory.IsIso.hom_inv_id_apply, map_zero] at H
      exact H
  · intro R hX s hs x
    

Proof state:
case h.refine'_3
X✝ : Scheme
X : Scheme
hX✝ : IsReduced X
U : Opens ↑↑X.toPresheafedSpace
s✝ : ↑(X.presheaf.obj (op U))
hs✝ : X.basicOpen s✝ = ⊥
R : CommRingCat
hX : IsReduced (Scheme.Spec.obj (op R))
s : ↑((Scheme.Spec.obj (op R)).presheaf.obj (op ⊤))
hs : (Scheme.Spec.obj (op R)).basicOpen s = ⊥
x : ↥⊤
⊢ (Presheaf.germ (Sheaf.presheaf (Scheme.sheaf (Scheme.Spec.obj (op R)))) x) s = 0

Next tactic:
erw [basicOpen_eq_of_affine', PrimeSpectrum.basicOpen_eq_bot_iff] at hs
theorem eq_zero_of_basicOpen_eq_bot {X : Scheme} [hX : IsReduced X] {U : Opens X.carrier}
    (s : X.presheaf.obj (op U)) (hs : X.basicOpen s = ⊥) : s = 0 := by
  apply TopCat.Presheaf.section_ext X.sheaf U
  conv => intro x; rw [RingHom.map_zero]
  refine' (@reduce_to_affine_global (fun X U =>
     ∀ [IsReduced X] (s : X.presheaf.obj (op U)),
       X.basicOpen s = ⊥ → ∀ x, (X.sheaf.presheaf.germ x) s = 0) _ _ _) X U s hs
  · intro X U hx hX s hs x
    obtain ⟨V, hx, i, H⟩ := hx x
    specialize H (X.presheaf.map i.op s)
    erw [Scheme.basicOpen_res] at H
    rw [hs] at H
    specialize H inf_bot_eq ⟨x, hx⟩
    erw [TopCat.Presheaf.germ_res_apply] at H
    exact H
  · rintro X Y f hf
    have e : f.val.base ⁻¹' Set.range ↑f.val.base = Set.univ := by
      rw [← Set.image_univ, Set.preimage_image_eq _ hf.base_open.inj]
    refine' ⟨_, _, e, rfl, _⟩
    rintro H hX s hs ⟨_, x, rfl⟩
    haveI := isReducedOfOpenImmersion f
    specialize H (f.1.c.app _ s) _ ⟨x, by rw [Opens.mem_mk, e]; trivial⟩
    · rw [← Scheme.preimage_basicOpen, hs]; ext1; simp [Opens.map]
    · erw [← PresheafedSpace.stalkMap_germ_apply f.1 ⟨_, _⟩ ⟨x, _⟩] at H
      apply_fun inv <| PresheafedSpace.stalkMap f.val x at H
      erw [CategoryTheory.IsIso.hom_inv_id_apply, map_zero] at H
      exact H
  · intro R hX s hs x
    erw [basicOpen_eq_of_affine', PrimeSpectrum.basicOpen_eq_bot_iff] at hs
    

Proof state:
case h.refine'_3
X✝ : Scheme
X : Scheme
hX✝ : IsReduced X
U : Opens ↑↑X.toPresheafedSpace
s✝ : ↑(X.presheaf.obj (op U))
hs✝ : X.basicOpen s✝ = ⊥
R : CommRingCat
hX : IsReduced (Scheme.Spec.obj (op R))
s : ↑((Scheme.Spec.obj (op R)).presheaf.obj (op ⊤))
hs : IsNilpotent ((SpecΓIdentity.app R).hom s)
x : ↥⊤
⊢ (Presheaf.germ (Sheaf.presheaf (Scheme.sheaf (Scheme.Spec.obj (op R)))) x) s = 0

Next tactic:
replace hs := hs.map (SpecΓIdentity.app R).inv
theorem eq_zero_of_basicOpen_eq_bot {X : Scheme} [hX : IsReduced X] {U : Opens X.carrier}
    (s : X.presheaf.obj (op U)) (hs : X.basicOpen s = ⊥) : s = 0 := by
  apply TopCat.Presheaf.section_ext X.sheaf U
  conv => intro x; rw [RingHom.map_zero]
  refine' (@reduce_to_affine_global (fun X U =>
     ∀ [IsReduced X] (s : X.presheaf.obj (op U)),
       X.basicOpen s = ⊥ → ∀ x, (X.sheaf.presheaf.germ x) s = 0) _ _ _) X U s hs
  · intro X U hx hX s hs x
    obtain ⟨V, hx, i, H⟩ := hx x
    specialize H (X.presheaf.map i.op s)
    erw [Scheme.basicOpen_res] at H
    rw [hs] at H
    specialize H inf_bot_eq ⟨x, hx⟩
    erw [TopCat.Presheaf.germ_res_apply] at H
    exact H
  · rintro X Y f hf
    have e : f.val.base ⁻¹' Set.range ↑f.val.base = Set.univ := by
      rw [← Set.image_univ, Set.preimage_image_eq _ hf.base_open.inj]
    refine' ⟨_, _, e, rfl, _⟩
    rintro H hX s hs ⟨_, x, rfl⟩
    haveI := isReducedOfOpenImmersion f
    specialize H (f.1.c.app _ s) _ ⟨x, by rw [Opens.mem_mk, e]; trivial⟩
    · rw [← Scheme.preimage_basicOpen, hs]; ext1; simp [Opens.map]
    · erw [← PresheafedSpace.stalkMap_germ_apply f.1 ⟨_, _⟩ ⟨x, _⟩] at H
      apply_fun inv <| PresheafedSpace.stalkMap f.val x at H
      erw [CategoryTheory.IsIso.hom_inv_id_apply, map_zero] at H
      exact H
  · intro R hX s hs x
    erw [basicOpen_eq_of_affine', PrimeSpectrum.basicOpen_eq_bot_iff] at hs
    replace hs := hs.map (SpecΓIdentity.app R).inv
    -- what the hell?!
    

Proof state:
case h.refine'_3
X✝ : Scheme
X : Scheme
hX✝ : IsReduced X
U : Opens ↑↑X.toPresheafedSpace
s✝ : ↑(X.presheaf.obj (op U))
hs✝ : X.basicOpen s✝ = ⊥
R : CommRingCat
hX : IsReduced (Scheme.Spec.obj (op R))
s : ↑((Scheme.Spec.obj (op R)).presheaf.obj (op ⊤))
x : ↥⊤
hs : IsNilpotent ((SpecΓIdentity.app R).inv ((SpecΓIdentity.app R).hom s))
⊢ (Presheaf.germ (Sheaf.presheaf (Scheme.sheaf (Scheme.Spec.obj (op R)))) x) s = 0

Next tactic:
replace hs := @IsNilpotent.eq_zero _ _ _ _ (show _ from ?_) hs
theorem eq_zero_of_basicOpen_eq_bot {X : Scheme} [hX : IsReduced X] {U : Opens X.carrier}
    (s : X.presheaf.obj (op U)) (hs : X.basicOpen s = ⊥) : s = 0 := by
  apply TopCat.Presheaf.section_ext X.sheaf U
  conv => intro x; rw [RingHom.map_zero]
  refine' (@reduce_to_affine_global (fun X U =>
     ∀ [IsReduced X] (s : X.presheaf.obj (op U)),
       X.basicOpen s = ⊥ → ∀ x, (X.sheaf.presheaf.germ x) s = 0) _ _ _) X U s hs
  · intro X U hx hX s hs x
    obtain ⟨V, hx, i, H⟩ := hx x
    specialize H (X.presheaf.map i.op s)
    erw [Scheme.basicOpen_res] at H
    rw [hs] at H
    specialize H inf_bot_eq ⟨x, hx⟩
    erw [TopCat.Presheaf.germ_res_apply] at H
    exact H
  · rintro X Y f hf
    have e : f.val.base ⁻¹' Set.range ↑f.val.base = Set.univ := by
      rw [← Set.image_univ, Set.preimage_image_eq _ hf.base_open.inj]
    refine' ⟨_, _, e, rfl, _⟩
    rintro H hX s hs ⟨_, x, rfl⟩
    haveI := isReducedOfOpenImmersion f
    specialize H (f.1.c.app _ s) _ ⟨x, by rw [Opens.mem_mk, e]; trivial⟩
    · rw [← Scheme.preimage_basicOpen, hs]; ext1; simp [Opens.map]
    · erw [← PresheafedSpace.stalkMap_germ_apply f.1 ⟨_, _⟩ ⟨x, _⟩] at H
      apply_fun inv <| PresheafedSpace.stalkMap f.val x at H
      erw [CategoryTheory.IsIso.hom_inv_id_apply, map_zero] at H
      exact H
  · intro R hX s hs x
    erw [basicOpen_eq_of_affine', PrimeSpectrum.basicOpen_eq_bot_iff] at hs
    replace hs := hs.map (SpecΓIdentity.app R).inv
    -- what the hell?!
    replace hs := @IsNilpotent.eq_zero _ _ _ _ (show _ from ?_) hs
    

Proof state:
case h.refine'_3.refine_2
X✝ : Scheme
X : Scheme
hX✝ : IsReduced X
U : Opens ↑↑X.toPresheafedSpace
s✝ : ↑(X.presheaf.obj (op U))
hs✝ : X.basicOpen s✝ = ⊥
R : CommRingCat
hX : IsReduced (Scheme.Spec.obj (op R))
s : ↑((Scheme.Spec.obj (op R)).presheaf.obj (op ⊤))
x : ↥⊤
hs : (SpecΓIdentity.app R).inv ((SpecΓIdentity.app R).hom s) = 0
⊢ (Presheaf.germ (Sheaf.presheaf (Scheme.sheaf (Scheme.Spec.obj (op R)))) x) s = 0
case h.refine'_3.refine_1
X✝ : Scheme
X : Scheme
hX✝ : IsReduced X
U : Opens ↑↑X.toPresheafedSpace
s✝ : ↑(X.presheaf.obj (op U))
hs✝ : X.basicOpen s✝ = ⊥
R : CommRingCat
hX : IsReduced (Scheme.Spec.obj (op R))
s : ↑((Scheme.Spec.obj (op R)).presheaf.obj (op ⊤))
x : ↥⊤
hs : IsNilpotent ((SpecΓIdentity.app R).inv ((SpecΓIdentity.app R).hom s))
⊢ _root_.IsReduced ↑((Spec.toLocallyRingedSpace.rightOp ⋙ LocallyRingedSpace.Γ).obj R)

Next tactic:
rw [Iso.hom_inv_id_apply] at hs
theorem eq_zero_of_basicOpen_eq_bot {X : Scheme} [hX : IsReduced X] {U : Opens X.carrier}
    (s : X.presheaf.obj (op U)) (hs : X.basicOpen s = ⊥) : s = 0 := by
  apply TopCat.Presheaf.section_ext X.sheaf U
  conv => intro x; rw [RingHom.map_zero]
  refine' (@reduce_to_affine_global (fun X U =>
     ∀ [IsReduced X] (s : X.presheaf.obj (op U)),
       X.basicOpen s = ⊥ → ∀ x, (X.sheaf.presheaf.germ x) s = 0) _ _ _) X U s hs
  · intro X U hx hX s hs x
    obtain ⟨V, hx, i, H⟩ := hx x
    specialize H (X.presheaf.map i.op s)
    erw [Scheme.basicOpen_res] at H
    rw [hs] at H
    specialize H inf_bot_eq ⟨x, hx⟩
    erw [TopCat.Presheaf.germ_res_apply] at H
    exact H
  · rintro X Y f hf
    have e : f.val.base ⁻¹' Set.range ↑f.val.base = Set.univ := by
      rw [← Set.image_univ, Set.preimage_image_eq _ hf.base_open.inj]
    refine' ⟨_, _, e, rfl, _⟩
    rintro H hX s hs ⟨_, x, rfl⟩
    haveI := isReducedOfOpenImmersion f
    specialize H (f.1.c.app _ s) _ ⟨x, by rw [Opens.mem_mk, e]; trivial⟩
    · rw [← Scheme.preimage_basicOpen, hs]; ext1; simp [Opens.map]
    · erw [← PresheafedSpace.stalkMap_germ_apply f.1 ⟨_, _⟩ ⟨x, _⟩] at H
      apply_fun inv <| PresheafedSpace.stalkMap f.val x at H
      erw [CategoryTheory.IsIso.hom_inv_id_apply, map_zero] at H
      exact H
  · intro R hX s hs x
    erw [basicOpen_eq_of_affine', PrimeSpectrum.basicOpen_eq_bot_iff] at hs
    replace hs := hs.map (SpecΓIdentity.app R).inv
    -- what the hell?!
    replace hs := @IsNilpotent.eq_zero _ _ _ _ (show _ from ?_) hs
    rw [Iso.hom_inv_id_apply] at hs
    

Proof state:
case h.refine'_3.refine_2
X✝ : Scheme
X : Scheme
hX✝ : IsReduced X
U : Opens ↑↑X.toPresheafedSpace
s✝ : ↑(X.presheaf.obj (op U))
hs✝ : X.basicOpen s✝ = ⊥
R : CommRingCat
hX : IsReduced (Scheme.Spec.obj (op R))
s : ↑((Scheme.Spec.obj (op R)).presheaf.obj (op ⊤))
x : ↥⊤
hs : s = 0
⊢ (Presheaf.germ (Sheaf.presheaf (Scheme.sheaf (Scheme.Spec.obj (op R)))) x) s = 0
case h.refine'_3.refine_1
X✝ : Scheme
X : Scheme
hX✝ : IsReduced X
U : Opens ↑↑X.toPresheafedSpace
s✝ : ↑(X.presheaf.obj (op U))
hs✝ : X.basicOpen s✝ = ⊥
R : CommRingCat
hX : IsReduced (Scheme.Spec.obj (op R))
s : ↑((Scheme.Spec.obj (op R)).presheaf.obj (op ⊤))
x : ↥⊤
hs : IsNilpotent ((SpecΓIdentity.app R).inv ((SpecΓIdentity.app R).hom s))
⊢ _root_.IsReduced ↑((Spec.toLocallyRingedSpace.rightOp ⋙ LocallyRingedSpace.Γ).obj R)

Next tactic:
rw [hs, map_zero]