l3lab/ntp-mathlib huggingface dataset:
theorem isIntegralOfIsIrreducibleIsReduced [IsReduced X] [H : IrreducibleSpace X.carrier] :
    IsIntegral X := by
  constructor; · infer_instance
  intro U hU
  haveI := (@LocallyRingedSpace.component_nontrivial X.toLocallyRingedSpace U hU).1
  have : NoZeroDivisors
      (X.toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace.presheaf.obj (op U)) := by
    refine' ⟨fun {a b} e => _⟩
    simp_rw [← basicOpen_eq_bot_iff, ← Opens.not_nonempty_iff_eq_bot]
    by_contra! h
    

Proof state:
X : Scheme
inst✝ : IsReduced X
H : IrreducibleSpace ↑↑X.toPresheafedSpace
U : Opens ↑↑X.toPresheafedSpace
hU : Nonempty ↥U
this : ∃ x y, x ≠ y
a b : ↑(X.presheaf.obj (op U))
e : a * b = 0
h : Set.Nonempty ↑(X.basicOpen a) ∧ Set.Nonempty ↑(X.basicOpen b)
⊢ False

Next tactic:
obtain ⟨_, ⟨x, hx₁, rfl⟩, ⟨x, hx₂, e'⟩⟩ :=
      nonempty_preirreducible_inter (X.basicOpen a).2 (X.basicOpen b).2 h.1 h.2
theorem isIntegralOfIsIrreducibleIsReduced [IsReduced X] [H : IrreducibleSpace X.carrier] :
    IsIntegral X := by
  constructor; · infer_instance
  intro U hU
  haveI := (@LocallyRingedSpace.component_nontrivial X.toLocallyRingedSpace U hU).1
  have : NoZeroDivisors
      (X.toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace.presheaf.obj (op U)) := by
    refine' ⟨fun {a b} e => _⟩
    simp_rw [← basicOpen_eq_bot_iff, ← Opens.not_nonempty_iff_eq_bot]
    by_contra! h
    obtain ⟨_, ⟨x, hx₁, rfl⟩, ⟨x, hx₂, e'⟩⟩ :=
      nonempty_preirreducible_inter (X.basicOpen a).2 (X.basicOpen b).2 h.1 h.2
    

Proof state:
case intro.intro.intro.intro.intro.intro
X : Scheme
inst✝ : IsReduced X
H : IrreducibleSpace ↑↑X.toPresheafedSpace
U : Opens ↑↑X.toPresheafedSpace
hU : Nonempty ↥U
this : ∃ x y, x ≠ y
a b : ↑(X.presheaf.obj (op U))
e : a * b = 0
h : Set.Nonempty ↑(X.basicOpen a) ∧ Set.Nonempty ↑(X.basicOpen b)
x✝ : ↥U
hx₁ :
  x✝ ∈
    {x |
      IsUnit ((Presheaf.germ (LocallyRingedSpace.toRingedSpace X.toLocallyRingedSpace).toPresheafedSpace.presheaf x) a)}
x : ↥U
hx₂ :
  x ∈
    {x |
      IsUnit ((Presheaf.germ (LocallyRingedSpace.toRingedSpace X.toLocallyRingedSpace).toPresheafedSpace.presheaf x) b)}
e' : ↑x = ↑x✝
⊢ False

Next tactic:
replace e' := Subtype.eq e'
theorem isIntegralOfIsIrreducibleIsReduced [IsReduced X] [H : IrreducibleSpace X.carrier] :
    IsIntegral X := by
  constructor; · infer_instance
  intro U hU
  haveI := (@LocallyRingedSpace.component_nontrivial X.toLocallyRingedSpace U hU).1
  have : NoZeroDivisors
      (X.toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace.presheaf.obj (op U)) := by
    refine' ⟨fun {a b} e => _⟩
    simp_rw [← basicOpen_eq_bot_iff, ← Opens.not_nonempty_iff_eq_bot]
    by_contra! h
    obtain ⟨_, ⟨x, hx₁, rfl⟩, ⟨x, hx₂, e'⟩⟩ :=
      nonempty_preirreducible_inter (X.basicOpen a).2 (X.basicOpen b).2 h.1 h.2
    replace e' := Subtype.eq e'
    

Proof state:
case intro.intro.intro.intro.intro.intro
X : Scheme
inst✝ : IsReduced X
H : IrreducibleSpace ↑↑X.toPresheafedSpace
U : Opens ↑↑X.toPresheafedSpace
hU : Nonempty ↥U
this : ∃ x y, x ≠ y
a b : ↑(X.presheaf.obj (op U))
e : a * b = 0
h : Set.Nonempty ↑(X.basicOpen a) ∧ Set.Nonempty ↑(X.basicOpen b)
x✝ : ↥U
hx₁ :
  x✝ ∈
    {x |
      IsUnit ((Presheaf.germ (LocallyRingedSpace.toRingedSpace X.toLocallyRingedSpace).toPresheafedSpace.presheaf x) a)}
x : ↥U
hx₂ :
  x ∈
    {x |
      IsUnit ((Presheaf.germ (LocallyRingedSpace.toRingedSpace X.toLocallyRingedSpace).toPresheafedSpace.presheaf x) b)}
e' : x = x✝
⊢ False

Next tactic:
subst e'
theorem isIntegralOfIsIrreducibleIsReduced [IsReduced X] [H : IrreducibleSpace X.carrier] :
    IsIntegral X := by
  constructor; · infer_instance
  intro U hU
  haveI := (@LocallyRingedSpace.component_nontrivial X.toLocallyRingedSpace U hU).1
  have : NoZeroDivisors
      (X.toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace.presheaf.obj (op U)) := by
    refine' ⟨fun {a b} e => _⟩
    simp_rw [← basicOpen_eq_bot_iff, ← Opens.not_nonempty_iff_eq_bot]
    by_contra! h
    obtain ⟨_, ⟨x, hx₁, rfl⟩, ⟨x, hx₂, e'⟩⟩ :=
      nonempty_preirreducible_inter (X.basicOpen a).2 (X.basicOpen b).2 h.1 h.2
    replace e' := Subtype.eq e'
    subst e'
    

Proof state:
case intro.intro.intro.intro.intro.intro
X : Scheme
inst✝ : IsReduced X
H : IrreducibleSpace ↑↑X.toPresheafedSpace
U : Opens ↑↑X.toPresheafedSpace
hU : Nonempty ↥U
this : ∃ x y, x ≠ y
a b : ↑(X.presheaf.obj (op U))
e : a * b = 0
h : Set.Nonempty ↑(X.basicOpen a) ∧ Set.Nonempty ↑(X.basicOpen b)
x : ↥U
hx₂ :
  x ∈
    {x |
      IsUnit ((Presheaf.germ (LocallyRingedSpace.toRingedSpace X.toLocallyRingedSpace).toPresheafedSpace.presheaf x) b)}
hx₁ :
  x ∈
    {x |
      IsUnit ((Presheaf.germ (LocallyRingedSpace.toRingedSpace X.toLocallyRingedSpace).toPresheafedSpace.presheaf x) a)}
⊢ False

Next tactic:
replace e := congr_arg (X.presheaf.germ x) e
theorem isIntegralOfIsIrreducibleIsReduced [IsReduced X] [H : IrreducibleSpace X.carrier] :
    IsIntegral X := by
  constructor; · infer_instance
  intro U hU
  haveI := (@LocallyRingedSpace.component_nontrivial X.toLocallyRingedSpace U hU).1
  have : NoZeroDivisors
      (X.toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace.presheaf.obj (op U)) := by
    refine' ⟨fun {a b} e => _⟩
    simp_rw [← basicOpen_eq_bot_iff, ← Opens.not_nonempty_iff_eq_bot]
    by_contra! h
    obtain ⟨_, ⟨x, hx₁, rfl⟩, ⟨x, hx₂, e'⟩⟩ :=
      nonempty_preirreducible_inter (X.basicOpen a).2 (X.basicOpen b).2 h.1 h.2
    replace e' := Subtype.eq e'
    subst e'
    replace e := congr_arg (X.presheaf.germ x) e
    

Proof state:
case intro.intro.intro.intro.intro.intro
X : Scheme
inst✝ : IsReduced X
H : IrreducibleSpace ↑↑X.toPresheafedSpace
U : Opens ↑↑X.toPresheafedSpace
hU : Nonempty ↥U
this : ∃ x y, x ≠ y
a b : ↑(X.presheaf.obj (op U))
h : Set.Nonempty ↑(X.basicOpen a) ∧ Set.Nonempty ↑(X.basicOpen b)
x : ↥U
hx₂ :
  x ∈
    {x |
      IsUnit ((Presheaf.germ (LocallyRingedSpace.toRingedSpace X.toLocallyRingedSpace).toPresheafedSpace.presheaf x) b)}
hx₁ :
  x ∈
    {x |
      IsUnit ((Presheaf.germ (LocallyRingedSpace.toRingedSpace X.toLocallyRingedSpace).toPresheafedSpace.presheaf x) a)}
e : (Presheaf.germ X.presheaf x) (a * b) = (Presheaf.germ X.presheaf x) 0
⊢ False

Next tactic:
rw [RingHom.map_mul, RingHom.map_zero] at e
theorem isIntegralOfIsIrreducibleIsReduced [IsReduced X] [H : IrreducibleSpace X.carrier] :
    IsIntegral X := by
  constructor; · infer_instance
  intro U hU
  haveI := (@LocallyRingedSpace.component_nontrivial X.toLocallyRingedSpace U hU).1
  have : NoZeroDivisors
      (X.toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace.presheaf.obj (op U)) := by
    refine' ⟨fun {a b} e => _⟩
    simp_rw [← basicOpen_eq_bot_iff, ← Opens.not_nonempty_iff_eq_bot]
    by_contra! h
    obtain ⟨_, ⟨x, hx₁, rfl⟩, ⟨x, hx₂, e'⟩⟩ :=
      nonempty_preirreducible_inter (X.basicOpen a).2 (X.basicOpen b).2 h.1 h.2
    replace e' := Subtype.eq e'
    subst e'
    replace e := congr_arg (X.presheaf.germ x) e
    rw [RingHom.map_mul, RingHom.map_zero] at e
    

Proof state:
case intro.intro.intro.intro.intro.intro
X : Scheme
inst✝ : IsReduced X
H : IrreducibleSpace ↑↑X.toPresheafedSpace
U : Opens ↑↑X.toPresheafedSpace
hU : Nonempty ↥U
this : ∃ x y, x ≠ y
a b : ↑(X.presheaf.obj (op U))
h : Set.Nonempty ↑(X.basicOpen a) ∧ Set.Nonempty ↑(X.basicOpen b)
x : ↥U
hx₂ :
  x ∈
    {x |
      IsUnit ((Presheaf.germ (LocallyRingedSpace.toRingedSpace X.toLocallyRingedSpace).toPresheafedSpace.presheaf x) b)}
hx₁ :
  x ∈
    {x |
      IsUnit ((Presheaf.germ (LocallyRingedSpace.toRingedSpace X.toLocallyRingedSpace).toPresheafedSpace.presheaf x) a)}
e : (Presheaf.germ X.presheaf x) a * (Presheaf.germ X.presheaf x) b = 0
⊢ False

Next tactic:
refine' zero_ne_one' (X.presheaf.stalk x.1) (isUnit_zero_iff.1 _)
theorem isIntegralOfIsIrreducibleIsReduced [IsReduced X] [H : IrreducibleSpace X.carrier] :
    IsIntegral X := by
  constructor; · infer_instance
  intro U hU
  haveI := (@LocallyRingedSpace.component_nontrivial X.toLocallyRingedSpace U hU).1
  have : NoZeroDivisors
      (X.toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace.presheaf.obj (op U)) := by
    refine' ⟨fun {a b} e => _⟩
    simp_rw [← basicOpen_eq_bot_iff, ← Opens.not_nonempty_iff_eq_bot]
    by_contra! h
    obtain ⟨_, ⟨x, hx₁, rfl⟩, ⟨x, hx₂, e'⟩⟩ :=
      nonempty_preirreducible_inter (X.basicOpen a).2 (X.basicOpen b).2 h.1 h.2
    replace e' := Subtype.eq e'
    subst e'
    replace e := congr_arg (X.presheaf.germ x) e
    rw [RingHom.map_mul, RingHom.map_zero] at e
    refine' zero_ne_one' (X.presheaf.stalk x.1) (isUnit_zero_iff.1 _)
    

Proof state:
case intro.intro.intro.intro.intro.intro
X : Scheme
inst✝ : IsReduced X
H : IrreducibleSpace ↑↑X.toPresheafedSpace
U : Opens ↑↑X.toPresheafedSpace
hU : Nonempty ↥U
this : ∃ x y, x ≠ y
a b : ↑(X.presheaf.obj (op U))
h : Set.Nonempty ↑(X.basicOpen a) ∧ Set.Nonempty ↑(X.basicOpen b)
x : ↥U
hx₂ :
  x ∈
    {x |
      IsUnit ((Presheaf.germ (LocallyRingedSpace.toRingedSpace X.toLocallyRingedSpace).toPresheafedSpace.presheaf x) b)}
hx₁ :
  x ∈
    {x |
      IsUnit ((Presheaf.germ (LocallyRingedSpace.toRingedSpace X.toLocallyRingedSpace).toPresheafedSpace.presheaf x) a)}
e : (Presheaf.germ X.presheaf x) a * (Presheaf.germ X.presheaf x) b = 0
⊢ IsUnit 0

Next tactic:
convert hx₁.mul hx₂
theorem isIntegralOfIsIrreducibleIsReduced [IsReduced X] [H : IrreducibleSpace X.carrier] :
    IsIntegral X := by
  constructor; · infer_instance
  intro U hU
  haveI := (@LocallyRingedSpace.component_nontrivial X.toLocallyRingedSpace U hU).1
  have : NoZeroDivisors
      (X.toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace.presheaf.obj (op U)) := by
    refine' ⟨fun {a b} e => _⟩
    simp_rw [← basicOpen_eq_bot_iff, ← Opens.not_nonempty_iff_eq_bot]
    by_contra! h
    obtain ⟨_, ⟨x, hx₁, rfl⟩, ⟨x, hx₂, e'⟩⟩ :=
      nonempty_preirreducible_inter (X.basicOpen a).2 (X.basicOpen b).2 h.1 h.2
    replace e' := Subtype.eq e'
    subst e'
    replace e := congr_arg (X.presheaf.germ x) e
    rw [RingHom.map_mul, RingHom.map_zero] at e
    refine' zero_ne_one' (X.presheaf.stalk x.1) (isUnit_zero_iff.1 _)
    convert hx₁.mul hx₂
    

Proof state:
case h.e'_3.h
X : Scheme
inst✝ : IsReduced X
H : IrreducibleSpace ↑↑X.toPresheafedSpace
U : Opens ↑↑X.toPresheafedSpace
hU : Nonempty ↥U
this : ∃ x y, x ≠ y
a b : ↑(X.presheaf.obj (op U))
h : Set.Nonempty ↑(X.basicOpen a) ∧ Set.Nonempty ↑(X.basicOpen b)
x : ↥U
hx₂ :
  x ∈
    {x |
      IsUnit ((Presheaf.germ (LocallyRingedSpace.toRingedSpace X.toLocallyRingedSpace).toPresheafedSpace.presheaf x) b)}
hx₁ :
  x ∈
    {x |
      IsUnit ((Presheaf.germ (LocallyRingedSpace.toRingedSpace X.toLocallyRingedSpace).toPresheafedSpace.presheaf x) a)}
e : (Presheaf.germ X.presheaf x) a * (Presheaf.germ X.presheaf x) b = 0
e_1✝ :
  ↑(Presheaf.stalk X.presheaf ↑x) =
    (forget CommRingCat).obj
      (Presheaf.stalk (LocallyRingedSpace.toRingedSpace X.toLocallyRingedSpace).toPresheafedSpace.presheaf ↑x)
⊢ 0 =
    (Presheaf.germ (LocallyRingedSpace.toRingedSpace X.toLocallyRingedSpace).toPresheafedSpace.presheaf x) a *
      (Presheaf.germ (LocallyRingedSpace.toRingedSpace X.toLocallyRingedSpace).toPresheafedSpace.presheaf x) b

Next tactic:
exact e.symm
theorem isIntegralOfIsIrreducibleIsReduced [IsReduced X] [H : IrreducibleSpace X.carrier] :
    IsIntegral X := by
  constructor; · infer_instance
  intro U hU
  haveI := (@LocallyRingedSpace.component_nontrivial X.toLocallyRingedSpace U hU).1
  have : NoZeroDivisors
      (X.toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace.presheaf.obj (op U)) := by
    refine' ⟨fun {a b} e => _⟩
    simp_rw [← basicOpen_eq_bot_iff, ← Opens.not_nonempty_iff_eq_bot]
    by_contra! h
    obtain ⟨_, ⟨x, hx₁, rfl⟩, ⟨x, hx₂, e'⟩⟩ :=
      nonempty_preirreducible_inter (X.basicOpen a).2 (X.basicOpen b).2 h.1 h.2
    replace e' := Subtype.eq e'
    subst e'
    replace e := congr_arg (X.presheaf.germ x) e
    rw [RingHom.map_mul, RingHom.map_zero] at e
    refine' zero_ne_one' (X.presheaf.stalk x.1) (isUnit_zero_iff.1 _)
    convert hx₁.mul hx₂
    exact e.symm
  

Proof state:
case component_integral
X : Scheme
inst✝ : IsReduced X
H : IrreducibleSpace ↑↑X.toPresheafedSpace
U : Opens ↑↑X.toPresheafedSpace
hU : Nonempty ↥U
this✝ : ∃ x y, x ≠ y
this : NoZeroDivisors ↑(X.presheaf.obj (op U))
⊢ IsDomain ↑(X.presheaf.obj (op U))

Next tactic:
exact NoZeroDivisors.to_isDomain _
theorem isIntegralOfOpenImmersion {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f]
    [IsIntegral Y] [Nonempty X.carrier] : IsIntegral X := by
  

Proof state:
X✝ : Scheme
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
inst✝¹ : IsIntegral Y
inst✝ : Nonempty ↑↑X.toPresheafedSpace
⊢ IsIntegral X

Next tactic:
constructor
theorem isIntegralOfOpenImmersion {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f]
    [IsIntegral Y] [Nonempty X.carrier] : IsIntegral X := by
  constructor; · 

Proof state:
case nonempty
X✝ : Scheme
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
inst✝¹ : IsIntegral Y
inst✝ : Nonempty ↑↑X.toPresheafedSpace
⊢ autoParam (Nonempty ↑↑X.toPresheafedSpace) _auto✝

Next tactic:
infer_instance
theorem isIntegralOfOpenImmersion {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f]
    [IsIntegral Y] [Nonempty X.carrier] : IsIntegral X := by
  constructor; · infer_instance
  

Proof state:
case component_integral
X✝ : Scheme
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
inst✝¹ : IsIntegral Y
inst✝ : Nonempty ↑↑X.toPresheafedSpace
⊢ autoParam (∀ (U : Opens ↑↑X.toPresheafedSpace) [inst : Nonempty ↥U], IsDomain ↑(X.presheaf.obj (op U))) _auto✝

Next tactic:
intro U hU
theorem isIntegralOfOpenImmersion {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f]
    [IsIntegral Y] [Nonempty X.carrier] : IsIntegral X := by
  constructor; · infer_instance
  intro U hU
  

Proof state:
case component_integral
X✝ : Scheme
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
inst✝¹ : IsIntegral Y
inst✝ : Nonempty ↑↑X.toPresheafedSpace
U : Opens ↑↑X.toPresheafedSpace
hU : Nonempty ↥U
⊢ IsDomain ↑(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 isIntegralOfOpenImmersion {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f]
    [IsIntegral Y] [Nonempty X.carrier] : IsIntegral X := by
  constructor; · infer_instance
  intro U hU
  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✝¹ : IsIntegral Y
inst✝ : Nonempty ↑↑X.toPresheafedSpace
U : Opens ↑↑X.toPresheafedSpace
hU : Nonempty ↥U
⊢ U = f⁻¹ᵁ (IsOpenMap.functor (_ : IsOpenMap ⇑f.val.base)).obj U

Next tactic:
ext1
theorem isIntegralOfOpenImmersion {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f]
    [IsIntegral Y] [Nonempty X.carrier] : IsIntegral X := by
  constructor; · infer_instance
  intro U hU
  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✝¹ : IsIntegral Y
inst✝ : Nonempty ↑↑X.toPresheafedSpace
U : Opens ↑↑X.toPresheafedSpace
hU : Nonempty ↥U
⊢ ↑U = ↑(f⁻¹ᵁ (IsOpenMap.functor (_ : IsOpenMap ⇑f.val.base)).obj U)

Next tactic:
exact (Set.preimage_image_eq _ H.base_open.inj).symm
theorem isIntegralOfOpenImmersion {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f]
    [IsIntegral Y] [Nonempty X.carrier] : IsIntegral X := by
  constructor; · infer_instance
  intro U hU
  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_integral
X✝ : Scheme
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
inst✝¹ : IsIntegral Y
inst✝ : Nonempty ↑↑X.toPresheafedSpace
U : Opens ↑↑X.toPresheafedSpace
hU : Nonempty ↥U
this : U = f⁻¹ᵁ (IsOpenMap.functor (_ : IsOpenMap ⇑f.val.base)).obj U
⊢ IsDomain ↑(X.presheaf.obj (op U))

Next tactic:
rw [this]
theorem isIntegralOfOpenImmersion {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f]
    [IsIntegral Y] [Nonempty X.carrier] : IsIntegral X := by
  constructor; · infer_instance
  intro U hU
  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_integral
X✝ : Scheme
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
inst✝¹ : IsIntegral Y
inst✝ : Nonempty ↑↑X.toPresheafedSpace
U : Opens ↑↑X.toPresheafedSpace
hU : Nonempty ↥U
this : U = f⁻¹ᵁ (IsOpenMap.functor (_ : IsOpenMap ⇑f.val.base)).obj U
⊢ IsDomain ↑(X.presheaf.obj (op (f⁻¹ᵁ (IsOpenMap.functor (_ : IsOpenMap ⇑f.val.base)).obj U)))

Next tactic:
have : IsDomain (Y.presheaf.obj (op (H.base_open.isOpenMap.functor.obj U))) := by
    apply (config := { allowSynthFailures := true }) IsIntegral.component_integral
    refine' ⟨⟨_, _, hU.some.prop, rfl⟩⟩
theorem isIntegralOfOpenImmersion {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f]
    [IsIntegral Y] [Nonempty X.carrier] : IsIntegral X := by
  constructor; · infer_instance
  intro U hU
  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]
  have : IsDomain (Y.presheaf.obj (op (H.base_open.isOpenMap.functor.obj U))) := by
    

Proof state:
X✝ : Scheme
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
inst✝¹ : IsIntegral Y
inst✝ : Nonempty ↑↑X.toPresheafedSpace
U : Opens ↑↑X.toPresheafedSpace
hU : Nonempty ↥U
this : U = f⁻¹ᵁ (IsOpenMap.functor (_ : IsOpenMap ⇑f.val.base)).obj U
⊢ IsDomain ↑(Y.presheaf.obj (op ((IsOpenMap.functor (_ : IsOpenMap ⇑f.val.base)).obj U)))

Next tactic:
apply (config := { allowSynthFailures := true }) IsIntegral.component_integral
theorem isIntegralOfOpenImmersion {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f]
    [IsIntegral Y] [Nonempty X.carrier] : IsIntegral X := by
  constructor; · infer_instance
  intro U hU
  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]
  have : IsDomain (Y.presheaf.obj (op (H.base_open.isOpenMap.functor.obj U))) := by
    apply (config := { allowSynthFailures := true }) IsIntegral.component_integral
    

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

Next tactic:
refine' ⟨⟨_, _, hU.some.prop, rfl⟩⟩
theorem isIntegralOfOpenImmersion {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f]
    [IsIntegral Y] [Nonempty X.carrier] : IsIntegral X := by
  constructor; · infer_instance
  intro U hU
  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]
  have : IsDomain (Y.presheaf.obj (op (H.base_open.isOpenMap.functor.obj U))) := by
    apply (config := { allowSynthFailures := true }) IsIntegral.component_integral
    refine' ⟨⟨_, _, hU.some.prop, rfl⟩⟩
  

Proof state:
case component_integral
X✝ : Scheme
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
inst✝¹ : IsIntegral Y
inst✝ : Nonempty ↑↑X.toPresheafedSpace
U : Opens ↑↑X.toPresheafedSpace
hU : Nonempty ↥U
this✝ : U = f⁻¹ᵁ (IsOpenMap.functor (_ : IsOpenMap ⇑f.val.base)).obj U
this : IsDomain ↑(Y.presheaf.obj (op ((IsOpenMap.functor (_ : IsOpenMap ⇑f.val.base)).obj U)))
⊢ IsDomain ↑(X.presheaf.obj (op (f⁻¹ᵁ (IsOpenMap.functor (_ : IsOpenMap ⇑f.val.base)).obj U)))

Next tactic:
exact (asIso <| f.1.c.app (op <| H.base_open.isOpenMap.functor.obj U) :
    Y.presheaf.obj _ ≅ _).symm.commRingCatIsoToRingEquiv.toMulEquiv.isDomain _
instance {R : CommRingCat} [H : IsDomain R] :
    IrreducibleSpace (Scheme.Spec.obj <| op R).carrier := by
  

Proof state:
X : Scheme
R : CommRingCat
H : IsDomain ↑R
⊢ IrreducibleSpace ↑↑(Scheme.Spec.obj (op R)).toPresheafedSpace

Next tactic:
convert PrimeSpectrum.irreducibleSpace (R := R)
theorem isIntegralOfIsAffineIsDomain [IsAffine X] [Nonempty X.carrier]
    [h : IsDomain (X.presheaf.obj (op ⊤))] : IsIntegral X :=
  haveI : IsIntegral (Scheme.Spec.obj (op (Scheme.Γ.obj (op X)))) := by
    

Proof state:
X : Scheme
inst✝¹ : IsAffine X
inst✝ : Nonempty ↑↑X.toPresheafedSpace
h : IsDomain ↑(X.presheaf.obj (op ⊤))
⊢ IsIntegral (Scheme.Spec.obj (op (Scheme.Γ.obj (op X))))

Next tactic:
rw [affine_isIntegral_iff]
theorem isIntegralOfIsAffineIsDomain [IsAffine X] [Nonempty X.carrier]
    [h : IsDomain (X.presheaf.obj (op ⊤))] : IsIntegral X :=
  haveI : IsIntegral (Scheme.Spec.obj (op (Scheme.Γ.obj (op X)))) := by
    rw [affine_isIntegral_iff]; 

Proof state:
X : Scheme
inst✝¹ : IsAffine X
inst✝ : Nonempty ↑↑X.toPresheafedSpace
h : IsDomain ↑(X.presheaf.obj (op ⊤))
⊢ IsDomain ↑(Scheme.Γ.obj (op X))

Next tactic:
exact h
theorem map_injective_of_isIntegral [IsIntegral X] {U V : Opens X.carrier} (i : U ⟶ V)
    [H : Nonempty U] : Function.Injective (X.presheaf.map i.op) := by
  

Proof state:
X : Scheme
inst✝ : IsIntegral X
U V : Opens ↑↑X.toPresheafedSpace
i : U ⟶ V
H : Nonempty ↥U
⊢ Function.Injective ⇑(X.presheaf.map i.op)

Next tactic:
rw [injective_iff_map_eq_zero]
theorem map_injective_of_isIntegral [IsIntegral X] {U V : Opens X.carrier} (i : U ⟶ V)
    [H : Nonempty U] : Function.Injective (X.presheaf.map i.op) := by
  rw [injective_iff_map_eq_zero]
  

Proof state:
X : Scheme
inst✝ : IsIntegral X
U V : Opens ↑↑X.toPresheafedSpace
i : U ⟶ V
H : Nonempty ↥U
⊢ ∀ (a : (forget CommRingCat).obj (X.presheaf.obj (op V))), (X.presheaf.map i.op) a = 0 → a = 0

Next tactic:
intro x hx
theorem map_injective_of_isIntegral [IsIntegral X] {U V : Opens X.carrier} (i : U ⟶ V)
    [H : Nonempty U] : Function.Injective (X.presheaf.map i.op) := by
  rw [injective_iff_map_eq_zero]
  intro x hx
  

Proof state:
X : Scheme
inst✝ : IsIntegral X
U V : Opens ↑↑X.toPresheafedSpace
i : U ⟶ V
H : Nonempty ↥U
x : (forget CommRingCat).obj (X.presheaf.obj (op V))
hx : (X.presheaf.map i.op) x = 0
⊢ x = 0

Next tactic:
rw [← basicOpen_eq_bot_iff] at hx ⊢
theorem map_injective_of_isIntegral [IsIntegral X] {U V : Opens X.carrier} (i : U ⟶ V)
    [H : Nonempty U] : Function.Injective (X.presheaf.map i.op) := by
  rw [injective_iff_map_eq_zero]
  intro x hx
  rw [← basicOpen_eq_bot_iff] at hx ⊢
  

Proof state:
X : Scheme
inst✝ : IsIntegral X
U V : Opens ↑↑X.toPresheafedSpace
i : U ⟶ V
H : Nonempty ↥U
x : (forget CommRingCat).obj (X.presheaf.obj (op V))
hx : X.basicOpen ((X.presheaf.map i.op) x) = ⊥
⊢ X.basicOpen x = ⊥

Next tactic:
rw [Scheme.basicOpen_res] at hx
theorem map_injective_of_isIntegral [IsIntegral X] {U V : Opens X.carrier} (i : U ⟶ V)
    [H : Nonempty U] : Function.Injective (X.presheaf.map i.op) := by
  rw [injective_iff_map_eq_zero]
  intro x hx
  rw [← basicOpen_eq_bot_iff] at hx ⊢
  rw [Scheme.basicOpen_res] at hx
  

Proof state:
X : Scheme
inst✝ : IsIntegral X
U V : Opens ↑↑X.toPresheafedSpace
i : U ⟶ V
H : Nonempty ↥U
x : (forget CommRingCat).obj (X.presheaf.obj (op V))
hx : U ⊓ X.basicOpen x = ⊥
⊢ X.basicOpen x = ⊥

Next tactic:
revert hx
theorem map_injective_of_isIntegral [IsIntegral X] {U V : Opens X.carrier} (i : U ⟶ V)
    [H : Nonempty U] : Function.Injective (X.presheaf.map i.op) := by
  rw [injective_iff_map_eq_zero]
  intro x hx
  rw [← basicOpen_eq_bot_iff] at hx ⊢
  rw [Scheme.basicOpen_res] at hx
  revert hx
  

Proof state:
X : Scheme
inst✝ : IsIntegral X
U V : Opens ↑↑X.toPresheafedSpace
i : U ⟶ V
H : Nonempty ↥U
x : (forget CommRingCat).obj (X.presheaf.obj (op V))
⊢ U ⊓ X.basicOpen x = ⊥ → X.basicOpen x = ⊥

Next tactic:
contrapose!
theorem map_injective_of_isIntegral [IsIntegral X] {U V : Opens X.carrier} (i : U ⟶ V)
    [H : Nonempty U] : Function.Injective (X.presheaf.map i.op) := by
  rw [injective_iff_map_eq_zero]
  intro x hx
  rw [← basicOpen_eq_bot_iff] at hx ⊢
  rw [Scheme.basicOpen_res] at hx
  revert hx
  contrapose!
  

Proof state:
X : Scheme
inst✝ : IsIntegral X
U V : Opens ↑↑X.toPresheafedSpace
i : U ⟶ V
H : Nonempty ↥U
x : (forget CommRingCat).obj (X.presheaf.obj (op V))
⊢ X.basicOpen x ≠ ⊥ → U ⊓ X.basicOpen x ≠ ⊥

Next tactic:
simp_rw [Ne.def, ← Opens.not_nonempty_iff_eq_bot, Classical.not_not]