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]; 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
    rw [hs, map_zero]
    

Proof state:
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:
exact @IsReduced.component_reduced _ hX ⊤
@[simp]
theorem basicOpen_eq_bot_iff {X : Scheme} [IsReduced X] {U : Opens X.carrier}
    (s : X.presheaf.obj <| op U) : X.basicOpen s = ⊥ ↔ s = 0 := by
  

Proof state:
X✝ : Scheme
X : Scheme
inst✝ : IsReduced X
U : Opens ↑↑X.toPresheafedSpace
s : ↑(X.presheaf.obj (op U))
⊢ X.basicOpen s = ⊥ ↔ s = 0

Next tactic:
refine' ⟨eq_zero_of_basicOpen_eq_bot s, _⟩
@[simp]
theorem basicOpen_eq_bot_iff {X : Scheme} [IsReduced X] {U : Opens X.carrier}
    (s : X.presheaf.obj <| op U) : X.basicOpen s = ⊥ ↔ s = 0 := by
  refine' ⟨eq_zero_of_basicOpen_eq_bot s, _⟩
  

Proof state:
X✝ : Scheme
X : Scheme
inst✝ : IsReduced X
U : Opens ↑↑X.toPresheafedSpace
s : ↑(X.presheaf.obj (op U))
⊢ s = 0 → X.basicOpen s = ⊥

Next tactic:
rintro rfl
@[simp]
theorem basicOpen_eq_bot_iff {X : Scheme} [IsReduced X] {U : Opens X.carrier}
    (s : X.presheaf.obj <| op U) : X.basicOpen s = ⊥ ↔ s = 0 := by
  refine' ⟨eq_zero_of_basicOpen_eq_bot s, _⟩
  rintro rfl
  

Proof state:
X✝ : Scheme
X : Scheme
inst✝ : IsReduced X
U : Opens ↑↑X.toPresheafedSpace
⊢ X.basicOpen 0 = ⊥

Next tactic:
simp
instance [h : IsIntegral X] : IsDomain (X.presheaf.obj (op ⊤)) :=
  @IsIntegral.component_integral _ _ _ (by
    

Proof state:
X : Scheme
h : IsIntegral X
⊢ Nonempty ↥⊤

Next tactic:
simp only [Set.univ_nonempty, Opens.nonempty_coeSort, Opens.coe_top]
instance (priority := 900) isReducedOfIsIntegral [IsIntegral X] : IsReduced X := by
  

Proof state:
X : Scheme
inst✝ : IsIntegral X
⊢ IsReduced X

Next tactic:
constructor
instance (priority := 900) isReducedOfIsIntegral [IsIntegral X] : IsReduced X := by
  constructor
  

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

Next tactic:
intro U
instance (priority := 900) isReducedOfIsIntegral [IsIntegral X] : IsReduced X := by
  constructor
  intro U
  

Proof state:
case component_reduced
X : Scheme
inst✝ : IsIntegral X
U : Opens ↑↑X.toPresheafedSpace
⊢ _root_.IsReduced ↑(X.presheaf.obj (op U))

Next tactic:
rcases U.1.eq_empty_or_nonempty with h | h
instance (priority := 900) isReducedOfIsIntegral [IsIntegral X] : IsReduced X := by
  constructor
  intro U
  rcases U.1.eq_empty_or_nonempty with h | h
  · 

Proof state:
case component_reduced.inl
X : Scheme
inst✝ : IsIntegral X
U : Opens ↑↑X.toPresheafedSpace
h : U.carrier = ∅
⊢ _root_.IsReduced ↑(X.presheaf.obj (op U))

Next tactic:
have : U = ⊥ := SetLike.ext' h
instance (priority := 900) isReducedOfIsIntegral [IsIntegral X] : IsReduced X := by
  constructor
  intro U
  rcases U.1.eq_empty_or_nonempty with h | h
  · have : U = ⊥ := SetLike.ext' h
    

Proof state:
case component_reduced.inl
X : Scheme
inst✝ : IsIntegral X
U : Opens ↑↑X.toPresheafedSpace
h : U.carrier = ∅
this : U = ⊥
⊢ _root_.IsReduced ↑(X.presheaf.obj (op U))

Next tactic:
haveI := CommRingCat.subsingleton_of_isTerminal (X.sheaf.isTerminalOfEqEmpty this)
instance (priority := 900) isReducedOfIsIntegral [IsIntegral X] : IsReduced X := by
  constructor
  intro U
  rcases U.1.eq_empty_or_nonempty with h | h
  · have : U = ⊥ := SetLike.ext' h
    haveI := CommRingCat.subsingleton_of_isTerminal (X.sheaf.isTerminalOfEqEmpty this)
    

Proof state:
case component_reduced.inl
X : Scheme
inst✝ : IsIntegral X
U : Opens ↑↑X.toPresheafedSpace
h : U.carrier = ∅
this✝ : U = ⊥
this : Subsingleton ↑((Scheme.sheaf X).val.obj (op U))
⊢ _root_.IsReduced ↑(X.presheaf.obj (op U))

Next tactic:
change _root_.IsReduced (X.sheaf.val.obj (op U))
instance (priority := 900) isReducedOfIsIntegral [IsIntegral X] : IsReduced X := by
  constructor
  intro U
  rcases U.1.eq_empty_or_nonempty with h | h
  · have : U = ⊥ := SetLike.ext' h
    haveI := CommRingCat.subsingleton_of_isTerminal (X.sheaf.isTerminalOfEqEmpty this)
    change _root_.IsReduced (X.sheaf.val.obj (op U))
    

Proof state:
case component_reduced.inl
X : Scheme
inst✝ : IsIntegral X
U : Opens ↑↑X.toPresheafedSpace
h : U.carrier = ∅
this✝ : U = ⊥
this : Subsingleton ↑((Scheme.sheaf X).val.obj (op U))
⊢ _root_.IsReduced ↑((Scheme.sheaf X).val.obj (op U))

Next tactic:
infer_instance
instance (priority := 900) isReducedOfIsIntegral [IsIntegral X] : IsReduced X := by
  constructor
  intro U
  rcases U.1.eq_empty_or_nonempty with h | h
  · have : U = ⊥ := SetLike.ext' h
    haveI := CommRingCat.subsingleton_of_isTerminal (X.sheaf.isTerminalOfEqEmpty this)
    change _root_.IsReduced (X.sheaf.val.obj (op U))
    infer_instance
  · 

Proof state:
case component_reduced.inr
X : Scheme
inst✝ : IsIntegral X
U : Opens ↑↑X.toPresheafedSpace
h : Set.Nonempty U.carrier
⊢ _root_.IsReduced ↑(X.presheaf.obj (op U))

Next tactic:
haveI : Nonempty U := by simpa
instance (priority := 900) isReducedOfIsIntegral [IsIntegral X] : IsReduced X := by
  constructor
  intro U
  rcases U.1.eq_empty_or_nonempty with h | h
  · have : U = ⊥ := SetLike.ext' h
    haveI := CommRingCat.subsingleton_of_isTerminal (X.sheaf.isTerminalOfEqEmpty this)
    change _root_.IsReduced (X.sheaf.val.obj (op U))
    infer_instance
  · haveI : Nonempty U := by 

Proof state:
X : Scheme
inst✝ : IsIntegral X
U : Opens ↑↑X.toPresheafedSpace
h : Set.Nonempty U.carrier
⊢ Nonempty ↥U

Next tactic:
simpa
instance (priority := 900) isReducedOfIsIntegral [IsIntegral X] : IsReduced X := by
  constructor
  intro U
  rcases U.1.eq_empty_or_nonempty with h | h
  · have : U = ⊥ := SetLike.ext' h
    haveI := CommRingCat.subsingleton_of_isTerminal (X.sheaf.isTerminalOfEqEmpty this)
    change _root_.IsReduced (X.sheaf.val.obj (op U))
    infer_instance
  · haveI : Nonempty U := by simpa
    

Proof state:
case component_reduced.inr
X : Scheme
inst✝ : IsIntegral X
U : Opens ↑↑X.toPresheafedSpace
h : Set.Nonempty U.carrier
this : Nonempty ↥U
⊢ _root_.IsReduced ↑(X.presheaf.obj (op U))

Next tactic:
infer_instance
instance is_irreducible_of_isIntegral [IsIntegral X] : IrreducibleSpace X.carrier := by
  

Proof state:
X : Scheme
inst✝ : IsIntegral X
⊢ IrreducibleSpace ↑↑X.toPresheafedSpace

Next tactic:
by_contra H
instance is_irreducible_of_isIntegral [IsIntegral X] : IrreducibleSpace X.carrier := by
  by_contra H
  

Proof state:
X : Scheme
inst✝ : IsIntegral X
H : ¬IrreducibleSpace ↑↑X.toPresheafedSpace
⊢ False

Next tactic:
replace H : ¬IsPreirreducible (⊤ : Set X.carrier) := fun h =>
    H { toPreirreducibleSpace := ⟨h⟩
        toNonempty := inferInstance }
instance is_irreducible_of_isIntegral [IsIntegral X] : IrreducibleSpace X.carrier := by
  by_contra H
  replace H : ¬IsPreirreducible (⊤ : Set X.carrier) := fun h =>
    H { toPreirreducibleSpace := ⟨h⟩
        toNonempty := inferInstance }
  

Proof state:
X : Scheme
inst✝ : IsIntegral X
H : ¬IsPreirreducible ⊤
⊢ False

Next tactic:
simp_rw [isPreirreducible_iff_closed_union_closed, not_forall, not_or] at H
instance is_irreducible_of_isIntegral [IsIntegral X] : IrreducibleSpace X.carrier := by
  by_contra H
  replace H : ¬IsPreirreducible (⊤ : Set X.carrier) := fun h =>
    H { toPreirreducibleSpace := ⟨h⟩
        toNonempty := inferInstance }
  simp_rw [isPreirreducible_iff_closed_union_closed, not_forall, not_or] at H
  

Proof state:
X : Scheme
inst✝ : IsIntegral X
H : ∃ x x_1, ∃ (_ : IsClosed x) (_ : IsClosed x_1) (_ : ⊤ ⊆ x ∪ x_1), ¬⊤ ⊆ x ∧ ¬⊤ ⊆ x_1
⊢ False

Next tactic:
rcases H with ⟨S, T, hS, hT, h₁, h₂, h₃⟩
instance is_irreducible_of_isIntegral [IsIntegral X] : IrreducibleSpace X.carrier := by
  by_contra H
  replace H : ¬IsPreirreducible (⊤ : Set X.carrier) := fun h =>
    H { toPreirreducibleSpace := ⟨h⟩
        toNonempty := inferInstance }
  simp_rw [isPreirreducible_iff_closed_union_closed, not_forall, not_or] at H
  rcases H with ⟨S, T, hS, hT, h₁, h₂, h₃⟩
  

Proof state:
case intro.intro.intro.intro.intro.intro
X : Scheme
inst✝ : IsIntegral X
S T : Set ↑↑X.toPresheafedSpace
hS : IsClosed S
hT : IsClosed T
h₁ : ⊤ ⊆ S ∪ T
h₂ : ¬⊤ ⊆ S
h₃ : ¬⊤ ⊆ T
⊢ False

Next tactic:
erw [not_forall] at h₂ h₃
instance is_irreducible_of_isIntegral [IsIntegral X] : IrreducibleSpace X.carrier := by
  by_contra H
  replace H : ¬IsPreirreducible (⊤ : Set X.carrier) := fun h =>
    H { toPreirreducibleSpace := ⟨h⟩
        toNonempty := inferInstance }
  simp_rw [isPreirreducible_iff_closed_union_closed, not_forall, not_or] at H
  rcases H with ⟨S, T, hS, hT, h₁, h₂, h₃⟩
  erw [not_forall] at h₂ h₃
  

Proof state:
case intro.intro.intro.intro.intro.intro
X : Scheme
inst✝ : IsIntegral X
S T : Set ↑↑X.toPresheafedSpace
hS : IsClosed S
hT : IsClosed T
h₁ : ⊤ ⊆ S ∪ T
h₂ : ∃ x, ¬(x ∈ ⊤ → x ∈ S)
h₃ : ∃ x, ¬(x ∈ ⊤ → x ∈ T)
⊢ False

Next tactic:
simp_rw [not_forall] at h₂ h₃
instance is_irreducible_of_isIntegral [IsIntegral X] : IrreducibleSpace X.carrier := by
  by_contra H
  replace H : ¬IsPreirreducible (⊤ : Set X.carrier) := fun h =>
    H { toPreirreducibleSpace := ⟨h⟩
        toNonempty := inferInstance }
  simp_rw [isPreirreducible_iff_closed_union_closed, not_forall, not_or] at H
  rcases H with ⟨S, T, hS, hT, h₁, h₂, h₃⟩
  erw [not_forall] at h₂ h₃
  simp_rw [not_forall] at h₂ h₃
  

Proof state:
case intro.intro.intro.intro.intro.intro
X : Scheme
inst✝ : IsIntegral X
S T : Set ↑↑X.toPresheafedSpace
hS : IsClosed S
hT : IsClosed T
h₁ : ⊤ ⊆ S ∪ T
h₂ : ∃ x, ∃ (_ : x ∈ ⊤), x ∉ S
h₃ : ∃ x, ∃ (_ : x ∈ ⊤), x ∉ T
⊢ False

Next tactic:
haveI : Nonempty (⟨Sᶜ, hS.1⟩ : Opens X.carrier) := ⟨⟨_, h₂.choose_spec.choose_spec⟩⟩
instance is_irreducible_of_isIntegral [IsIntegral X] : IrreducibleSpace X.carrier := by
  by_contra H
  replace H : ¬IsPreirreducible (⊤ : Set X.carrier) := fun h =>
    H { toPreirreducibleSpace := ⟨h⟩
        toNonempty := inferInstance }
  simp_rw [isPreirreducible_iff_closed_union_closed, not_forall, not_or] at H
  rcases H with ⟨S, T, hS, hT, h₁, h₂, h₃⟩
  erw [not_forall] at h₂ h₃
  simp_rw [not_forall] at h₂ h₃
  haveI : Nonempty (⟨Sᶜ, hS.1⟩ : Opens X.carrier) := ⟨⟨_, h₂.choose_spec.choose_spec⟩⟩
  

Proof state:
case intro.intro.intro.intro.intro.intro
X : Scheme
inst✝ : IsIntegral X
S T : Set ↑↑X.toPresheafedSpace
hS : IsClosed S
hT : IsClosed T
h₁ : ⊤ ⊆ S ∪ T
h₂ : ∃ x, ∃ (_ : x ∈ ⊤), x ∉ S
h₃ : ∃ x, ∃ (_ : x ∈ ⊤), x ∉ T
this : Nonempty ↥{ carrier := Sᶜ, is_open' := (_ : IsOpen Sᶜ) }
⊢ False

Next tactic:
haveI : Nonempty (⟨Tᶜ, hT.1⟩ : Opens X.carrier) := ⟨⟨_, h₃.choose_spec.choose_spec⟩⟩
instance is_irreducible_of_isIntegral [IsIntegral X] : IrreducibleSpace X.carrier := by
  by_contra H
  replace H : ¬IsPreirreducible (⊤ : Set X.carrier) := fun h =>
    H { toPreirreducibleSpace := ⟨h⟩
        toNonempty := inferInstance }
  simp_rw [isPreirreducible_iff_closed_union_closed, not_forall, not_or] at H
  rcases H with ⟨S, T, hS, hT, h₁, h₂, h₃⟩
  erw [not_forall] at h₂ h₃
  simp_rw [not_forall] at h₂ h₃
  haveI : Nonempty (⟨Sᶜ, hS.1⟩ : Opens X.carrier) := ⟨⟨_, h₂.choose_spec.choose_spec⟩⟩
  haveI : Nonempty (⟨Tᶜ, hT.1⟩ : Opens X.carrier) := ⟨⟨_, h₃.choose_spec.choose_spec⟩⟩
  

Proof state:
case intro.intro.intro.intro.intro.intro
X : Scheme
inst✝ : IsIntegral X
S T : Set ↑↑X.toPresheafedSpace
hS : IsClosed S
hT : IsClosed T
h₁ : ⊤ ⊆ S ∪ T
h₂ : ∃ x, ∃ (_ : x ∈ ⊤), x ∉ S
h₃ : ∃ x, ∃ (_ : x ∈ ⊤), x ∉ T
this✝ : Nonempty ↥{ carrier := Sᶜ, is_open' := (_ : IsOpen Sᶜ) }
this : Nonempty ↥{ carrier := Tᶜ, is_open' := (_ : IsOpen Tᶜ) }
⊢ False

Next tactic:
haveI : Nonempty (⟨Sᶜ, hS.1⟩ ⊔ ⟨Tᶜ, hT.1⟩ : Opens X.carrier) :=
    ⟨⟨_, Or.inl h₂.choose_spec.choose_spec⟩⟩
instance is_irreducible_of_isIntegral [IsIntegral X] : IrreducibleSpace X.carrier := by
  by_contra H
  replace H : ¬IsPreirreducible (⊤ : Set X.carrier) := fun h =>
    H { toPreirreducibleSpace := ⟨h⟩
        toNonempty := inferInstance }
  simp_rw [isPreirreducible_iff_closed_union_closed, not_forall, not_or] at H
  rcases H with ⟨S, T, hS, hT, h₁, h₂, h₃⟩
  erw [not_forall] at h₂ h₃
  simp_rw [not_forall] at h₂ h₃
  haveI : Nonempty (⟨Sᶜ, hS.1⟩ : Opens X.carrier) := ⟨⟨_, h₂.choose_spec.choose_spec⟩⟩
  haveI : Nonempty (⟨Tᶜ, hT.1⟩ : Opens X.carrier) := ⟨⟨_, h₃.choose_spec.choose_spec⟩⟩
  haveI : Nonempty (⟨Sᶜ, hS.1⟩ ⊔ ⟨Tᶜ, hT.1⟩ : Opens X.carrier) :=
    ⟨⟨_, Or.inl h₂.choose_spec.choose_spec⟩⟩
  

Proof state:
case intro.intro.intro.intro.intro.intro
X : Scheme
inst✝ : IsIntegral X
S T : Set ↑↑X.toPresheafedSpace
hS : IsClosed S
hT : IsClosed T
h₁ : ⊤ ⊆ S ∪ T
h₂ : ∃ x, ∃ (_ : x ∈ ⊤), x ∉ S
h₃ : ∃ x, ∃ (_ : x ∈ ⊤), x ∉ T
this✝¹ : Nonempty ↥{ carrier := Sᶜ, is_open' := (_ : IsOpen Sᶜ) }
this✝ : Nonempty ↥{ carrier := Tᶜ, is_open' := (_ : IsOpen Tᶜ) }
this : Nonempty ↥({ carrier := Sᶜ, is_open' := (_ : IsOpen Sᶜ) } ⊔ { carrier := Tᶜ, is_open' := (_ : IsOpen Tᶜ) })
⊢ False

Next tactic:
let e : X.presheaf.obj _ ≅ CommRingCat.of _ :=
    (X.sheaf.isProductOfDisjoint ⟨_, hS.1⟩ ⟨_, hT.1⟩ ?_).conePointUniqueUpToIso
      (CommRingCat.prodFanIsLimit _ _)
instance is_irreducible_of_isIntegral [IsIntegral X] : IrreducibleSpace X.carrier := by
  by_contra H
  replace H : ¬IsPreirreducible (⊤ : Set X.carrier) := fun h =>
    H { toPreirreducibleSpace := ⟨h⟩
        toNonempty := inferInstance }
  simp_rw [isPreirreducible_iff_closed_union_closed, not_forall, not_or] at H
  rcases H with ⟨S, T, hS, hT, h₁, h₂, h₃⟩
  erw [not_forall] at h₂ h₃
  simp_rw [not_forall] at h₂ h₃
  haveI : Nonempty (⟨Sᶜ, hS.1⟩ : Opens X.carrier) := ⟨⟨_, h₂.choose_spec.choose_spec⟩⟩
  haveI : Nonempty (⟨Tᶜ, hT.1⟩ : Opens X.carrier) := ⟨⟨_, h₃.choose_spec.choose_spec⟩⟩
  haveI : Nonempty (⟨Sᶜ, hS.1⟩ ⊔ ⟨Tᶜ, hT.1⟩ : Opens X.carrier) :=
    ⟨⟨_, Or.inl h₂.choose_spec.choose_spec⟩⟩
  let e : X.presheaf.obj _ ≅ CommRingCat.of _ :=
    (X.sheaf.isProductOfDisjoint ⟨_, hS.1⟩ ⟨_, hT.1⟩ ?_).conePointUniqueUpToIso
      (CommRingCat.prodFanIsLimit _ _)
  

Proof state:
case intro.intro.intro.intro.intro.intro.refine_2
X : Scheme
inst✝ : IsIntegral X
S T : Set ↑↑X.toPresheafedSpace
hS : IsClosed S
hT : IsClosed T
h₁ : ⊤ ⊆ S ∪ T
h₂ : ∃ x, ∃ (_ : x ∈ ⊤), x ∉ S
h₃ : ∃ x, ∃ (_ : x ∈ ⊤), x ∉ T
this✝¹ : Nonempty ↥{ carrier := Sᶜ, is_open' := (_ : IsOpen Sᶜ) }
this✝ : Nonempty ↥{ carrier := Tᶜ, is_open' := (_ : IsOpen Tᶜ) }
this : Nonempty ↥({ carrier := Sᶜ, is_open' := (_ : IsOpen Sᶜ) } ⊔ { carrier := Tᶜ, is_open' := (_ : IsOpen Tᶜ) })
e : X.presheaf.obj
    (op ({ carrier := Sᶜ, is_open' := (_ : IsOpen Sᶜ) } ⊔ { carrier := Tᶜ, is_open' := (_ : IsOpen Tᶜ) })) ≅
  CommRingCat.of
    ↑(CommRingCat.prodFan ((Scheme.sheaf X).val.obj (op { carrier := Sᶜ, is_open' := (_ : IsOpen Sᶜ) }))
          ((Scheme.sheaf X).val.obj (op { carrier := Tᶜ, is_open' := (_ : IsOpen Tᶜ) }))).1 :=
  IsLimit.conePointUniqueUpToIso
    (Sheaf.isProductOfDisjoint (Scheme.sheaf X) { carrier := Sᶜ, is_open' := (_ : IsOpen Sᶜ) }
      { carrier := Tᶜ, is_open' := (_ : IsOpen Tᶜ) } ?intro.intro.intro.intro.intro.intro.refine_1)
    (CommRingCat.prodFanIsLimit ((Scheme.sheaf X).val.obj (op { carrier := Sᶜ, is_open' := (_ : IsOpen Sᶜ) }))
      ((Scheme.sheaf X).val.obj (op { carrier := Tᶜ, is_open' := (_ : IsOpen Tᶜ) })))
⊢ False
case intro.intro.intro.intro.intro.intro.refine_1
X : Scheme
inst✝ : IsIntegral X
S T : Set ↑↑X.toPresheafedSpace
hS : IsClosed S
hT : IsClosed T
h₁ : ⊤ ⊆ S ∪ T
h₂ : ∃ x, ∃ (_ : x ∈ ⊤), x ∉ S
h₃ : ∃ x, ∃ (_ : x ∈ ⊤), x ∉ T
this✝¹ : Nonempty ↥{ carrier := Sᶜ, is_open' := (_ : IsOpen Sᶜ) }
this✝ : Nonempty ↥{ carrier := Tᶜ, is_open' := (_ : IsOpen Tᶜ) }
this : Nonempty ↥({ carrier := Sᶜ, is_open' := (_ : IsOpen Sᶜ) } ⊔ { carrier := Tᶜ, is_open' := (_ : IsOpen Tᶜ) })
⊢ { carrier := Sᶜ, is_open' := (_ : IsOpen Sᶜ) } ⊓ { carrier := Tᶜ, is_open' := (_ : IsOpen Tᶜ) } = ⊥

Next tactic:
apply (config := { allowSynthFailures := true }) false_of_nontrivial_of_product_domain
instance is_irreducible_of_isIntegral [IsIntegral X] : IrreducibleSpace X.carrier := by
  by_contra H
  replace H : ¬IsPreirreducible (⊤ : Set X.carrier) := fun h =>
    H { toPreirreducibleSpace := ⟨h⟩
        toNonempty := inferInstance }
  simp_rw [isPreirreducible_iff_closed_union_closed, not_forall, not_or] at H
  rcases H with ⟨S, T, hS, hT, h₁, h₂, h₃⟩
  erw [not_forall] at h₂ h₃
  simp_rw [not_forall] at h₂ h₃
  haveI : Nonempty (⟨Sᶜ, hS.1⟩ : Opens X.carrier) := ⟨⟨_, h₂.choose_spec.choose_spec⟩⟩
  haveI : Nonempty (⟨Tᶜ, hT.1⟩ : Opens X.carrier) := ⟨⟨_, h₃.choose_spec.choose_spec⟩⟩
  haveI : Nonempty (⟨Sᶜ, hS.1⟩ ⊔ ⟨Tᶜ, hT.1⟩ : Opens X.carrier) :=
    ⟨⟨_, Or.inl h₂.choose_spec.choose_spec⟩⟩
  let e : X.presheaf.obj _ ≅ CommRingCat.of _ :=
    (X.sheaf.isProductOfDisjoint ⟨_, hS.1⟩ ⟨_, hT.1⟩ ?_).conePointUniqueUpToIso
      (CommRingCat.prodFanIsLimit _ _)
  apply (config := { allowSynthFailures := true }) false_of_nontrivial_of_product_domain
  · 

Proof state:
case inst
X : Scheme
inst✝ : IsIntegral X
S T : Set ↑↑X.toPresheafedSpace
hS : IsClosed S
hT : IsClosed T
h₁ : ⊤ ⊆ S ∪ T
h₂ : ∃ x, ∃ (_ : x ∈ ⊤), x ∉ S
h₃ : ∃ x, ∃ (_ : x ∈ ⊤), x ∉ T
this✝¹ : Nonempty ↥{ carrier := Sᶜ, is_open' := (_ : IsOpen Sᶜ) }
this✝ : Nonempty ↥{ carrier := Tᶜ, is_open' := (_ : IsOpen Tᶜ) }
this : Nonempty ↥({ carrier := Sᶜ, is_open' := (_ : IsOpen Sᶜ) } ⊔ { carrier := Tᶜ, is_open' := (_ : IsOpen Tᶜ) })
e : X.presheaf.obj
    (op ({ carrier := Sᶜ, is_open' := (_ : IsOpen Sᶜ) } ⊔ { carrier := Tᶜ, is_open' := (_ : IsOpen Tᶜ) })) ≅
  CommRingCat.of
    ↑(CommRingCat.prodFan ((Scheme.sheaf X).val.obj (op { carrier := Sᶜ, is_open' := (_ : IsOpen Sᶜ) }))
          ((Scheme.sheaf X).val.obj (op { carrier := Tᶜ, is_open' := (_ : IsOpen Tᶜ) }))).1 :=
  IsLimit.conePointUniqueUpToIso
    (Sheaf.isProductOfDisjoint (Scheme.sheaf X) { carrier := Sᶜ, is_open' := (_ : IsOpen Sᶜ) }
      { carrier := Tᶜ, is_open' := (_ : IsOpen Tᶜ) } ?intro.intro.intro.intro.intro.intro.refine_1)
    (CommRingCat.prodFanIsLimit ((Scheme.sheaf X).val.obj (op { carrier := Sᶜ, is_open' := (_ : IsOpen Sᶜ) }))
      ((Scheme.sheaf X).val.obj (op { carrier := Tᶜ, is_open' := (_ : IsOpen Tᶜ) })))
⊢ IsDomain (?intro.intro.intro.intro.intro.intro.refine_2.R × ?intro.intro.intro.intro.intro.intro.refine_2.S)

Next tactic:
exact e.symm.commRingCatIsoToRingEquiv.toMulEquiv.isDomain _
instance is_irreducible_of_isIntegral [IsIntegral X] : IrreducibleSpace X.carrier := by
  by_contra H
  replace H : ¬IsPreirreducible (⊤ : Set X.carrier) := fun h =>
    H { toPreirreducibleSpace := ⟨h⟩
        toNonempty := inferInstance }
  simp_rw [isPreirreducible_iff_closed_union_closed, not_forall, not_or] at H
  rcases H with ⟨S, T, hS, hT, h₁, h₂, h₃⟩
  erw [not_forall] at h₂ h₃
  simp_rw [not_forall] at h₂ h₃
  haveI : Nonempty (⟨Sᶜ, hS.1⟩ : Opens X.carrier) := ⟨⟨_, h₂.choose_spec.choose_spec⟩⟩
  haveI : Nonempty (⟨Tᶜ, hT.1⟩ : Opens X.carrier) := ⟨⟨_, h₃.choose_spec.choose_spec⟩⟩
  haveI : Nonempty (⟨Sᶜ, hS.1⟩ ⊔ ⟨Tᶜ, hT.1⟩ : Opens X.carrier) :=
    ⟨⟨_, Or.inl h₂.choose_spec.choose_spec⟩⟩
  let e : X.presheaf.obj _ ≅ CommRingCat.of _ :=
    (X.sheaf.isProductOfDisjoint ⟨_, hS.1⟩ ⟨_, hT.1⟩ ?_).conePointUniqueUpToIso
      (CommRingCat.prodFanIsLimit _ _)
  apply (config := { allowSynthFailures := true }) false_of_nontrivial_of_product_domain
  · exact e.symm.commRingCatIsoToRingEquiv.toMulEquiv.isDomain _
  · 

Proof state:
case inst
X : Scheme
inst✝ : IsIntegral X
S T : Set ↑↑X.toPresheafedSpace
hS : IsClosed S
hT : IsClosed T
h₁ : ⊤ ⊆ S ∪ T
h₂ : ∃ x, ∃ (_ : x ∈ ⊤), x ∉ S
h₃ : ∃ x, ∃ (_ : x ∈ ⊤), x ∉ T
this✝¹ : Nonempty ↥{ carrier := Sᶜ, is_open' := (_ : IsOpen Sᶜ) }
this✝ : Nonempty ↥{ carrier := Tᶜ, is_open' := (_ : IsOpen Tᶜ) }
this : Nonempty ↥({ carrier := Sᶜ, is_open' := (_ : IsOpen Sᶜ) } ⊔ { carrier := Tᶜ, is_open' := (_ : IsOpen Tᶜ) })
e : X.presheaf.obj
    (op ({ carrier := Sᶜ, is_open' := (_ : IsOpen Sᶜ) } ⊔ { carrier := Tᶜ, is_open' := (_ : IsOpen Tᶜ) })) ≅
  CommRingCat.of
    ↑(CommRingCat.prodFan ((Scheme.sheaf X).val.obj (op { carrier := Sᶜ, is_open' := (_ : IsOpen Sᶜ) }))
          ((Scheme.sheaf X).val.obj (op { carrier := Tᶜ, is_open' := (_ : IsOpen Tᶜ) }))).1 :=
  IsLimit.conePointUniqueUpToIso
    (Sheaf.isProductOfDisjoint (Scheme.sheaf X) { carrier := Sᶜ, is_open' := (_ : IsOpen Sᶜ) }
      { carrier := Tᶜ, is_open' := (_ : IsOpen Tᶜ) } ?intro.intro.intro.intro.intro.intro.refine_1)
    (CommRingCat.prodFanIsLimit ((Scheme.sheaf X).val.obj (op { carrier := Sᶜ, is_open' := (_ : IsOpen Sᶜ) }))
      ((Scheme.sheaf X).val.obj (op { carrier := Tᶜ, is_open' := (_ : IsOpen Tᶜ) })))
⊢ Nontrivial ↑((Scheme.sheaf X).val.obj (op { carrier := Sᶜ, is_open' := (_ : IsOpen Sᶜ) }))

Next tactic:
apply X.toLocallyRingedSpace.component_nontrivial