l3lab/ntp-mathlib huggingface dataset:
noncomputable instance [IsIntegral X] : Field X.functionField := by
  apply fieldOfIsUnitOrEqZero
  

Proof state:
case h
X : Scheme
inst✝ : IsIntegral X
⊢ ∀ (a : ↑(Scheme.functionField X)), IsUnit a ∨ a = 0

Next tactic:
intro a
noncomputable instance [IsIntegral X] : Field X.functionField := by
  apply fieldOfIsUnitOrEqZero
  intro a
  

Proof state:
case h
X : Scheme
inst✝ : IsIntegral X
a : ↑(Scheme.functionField X)
⊢ IsUnit a ∨ a = 0

Next tactic:
obtain ⟨U, m, s, rfl⟩ := TopCat.Presheaf.germ_exist _ _ a
noncomputable instance [IsIntegral X] : Field X.functionField := by
  apply fieldOfIsUnitOrEqZero
  intro a
  obtain ⟨U, m, s, rfl⟩ := TopCat.Presheaf.germ_exist _ _ a
  

Proof state:
case h.intro.intro.intro
X : Scheme
inst✝ : IsIntegral X
U : Opens ↑↑X.toPresheafedSpace
m : genericPoint ↑↑X.toPresheafedSpace ∈ U
s : (forget CommRingCat).obj (X.presheaf.obj (op U))
⊢ IsUnit ((Presheaf.germ X.presheaf { val := genericPoint ↑↑X.toPresheafedSpace, property := m }) s) ∨
    (Presheaf.germ X.presheaf { val := genericPoint ↑↑X.toPresheafedSpace, property := m }) s = 0

Next tactic:
rw [or_iff_not_imp_right, ← (X.presheaf.germ ⟨_, m⟩).map_zero]
noncomputable instance [IsIntegral X] : Field X.functionField := by
  apply fieldOfIsUnitOrEqZero
  intro a
  obtain ⟨U, m, s, rfl⟩ := TopCat.Presheaf.germ_exist _ _ a
  rw [or_iff_not_imp_right, ← (X.presheaf.germ ⟨_, m⟩).map_zero]
  

Proof state:
case h.intro.intro.intro
X : Scheme
inst✝ : IsIntegral X
U : Opens ↑↑X.toPresheafedSpace
m : genericPoint ↑↑X.toPresheafedSpace ∈ U
s : (forget CommRingCat).obj (X.presheaf.obj (op U))
⊢ ¬(Presheaf.germ X.presheaf { val := genericPoint ↑↑X.toPresheafedSpace, property := m }) s =
        (Presheaf.germ X.presheaf { val := genericPoint ↑↑X.toPresheafedSpace, property := m }) 0 →
    IsUnit ((Presheaf.germ X.presheaf { val := genericPoint ↑↑X.toPresheafedSpace, property := m }) s)

Next tactic:
intro ha
noncomputable instance [IsIntegral X] : Field X.functionField := by
  apply fieldOfIsUnitOrEqZero
  intro a
  obtain ⟨U, m, s, rfl⟩ := TopCat.Presheaf.germ_exist _ _ a
  rw [or_iff_not_imp_right, ← (X.presheaf.germ ⟨_, m⟩).map_zero]
  intro ha
  

Proof state:
case h.intro.intro.intro
X : Scheme
inst✝ : IsIntegral X
U : Opens ↑↑X.toPresheafedSpace
m : genericPoint ↑↑X.toPresheafedSpace ∈ U
s : (forget CommRingCat).obj (X.presheaf.obj (op U))
ha :
  ¬(Presheaf.germ X.presheaf { val := genericPoint ↑↑X.toPresheafedSpace, property := m }) s =
      (Presheaf.germ X.presheaf { val := genericPoint ↑↑X.toPresheafedSpace, property := m }) 0
⊢ IsUnit ((Presheaf.germ X.presheaf { val := genericPoint ↑↑X.toPresheafedSpace, property := m }) s)

Next tactic:
replace ha := ne_of_apply_ne _ ha
noncomputable instance [IsIntegral X] : Field X.functionField := by
  apply fieldOfIsUnitOrEqZero
  intro a
  obtain ⟨U, m, s, rfl⟩ := TopCat.Presheaf.germ_exist _ _ a
  rw [or_iff_not_imp_right, ← (X.presheaf.germ ⟨_, m⟩).map_zero]
  intro ha
  replace ha := ne_of_apply_ne _ ha
  

Proof state:
case h.intro.intro.intro
X : Scheme
inst✝ : IsIntegral X
U : Opens ↑↑X.toPresheafedSpace
m : genericPoint ↑↑X.toPresheafedSpace ∈ U
s : (forget CommRingCat).obj (X.presheaf.obj (op U))
ha : s ≠ 0
⊢ IsUnit ((Presheaf.germ X.presheaf { val := genericPoint ↑↑X.toPresheafedSpace, property := m }) s)

Next tactic:
have hs : genericPoint X.carrier ∈ RingedSpace.basicOpen _ s := by
    rw [← SetLike.mem_coe, (genericPoint_spec X.carrier).mem_open_set_iff, Set.top_eq_univ,
      Set.univ_inter, Set.nonempty_iff_ne_empty, Ne.def, ← Opens.coe_bot, ← SetLike.ext'_iff]
    erw [basicOpen_eq_bot_iff]
    exacts [ha, (RingedSpace.basicOpen _ _).isOpen]
noncomputable instance [IsIntegral X] : Field X.functionField := by
  apply fieldOfIsUnitOrEqZero
  intro a
  obtain ⟨U, m, s, rfl⟩ := TopCat.Presheaf.germ_exist _ _ a
  rw [or_iff_not_imp_right, ← (X.presheaf.germ ⟨_, m⟩).map_zero]
  intro ha
  replace ha := ne_of_apply_ne _ ha
  have hs : genericPoint X.carrier ∈ RingedSpace.basicOpen _ s := by
    

Proof state:
X : Scheme
inst✝ : IsIntegral X
U : Opens ↑↑X.toPresheafedSpace
m : genericPoint ↑↑X.toPresheafedSpace ∈ U
s : (forget CommRingCat).obj (X.presheaf.obj (op U))
ha : s ≠ 0
⊢ genericPoint ↑↑X.toPresheafedSpace ∈ RingedSpace.basicOpen X.toSheafedSpace s

Next tactic:
rw [← SetLike.mem_coe, (genericPoint_spec X.carrier).mem_open_set_iff, Set.top_eq_univ,
      Set.univ_inter, Set.nonempty_iff_ne_empty, Ne.def, ← Opens.coe_bot, ← SetLike.ext'_iff]
noncomputable instance [IsIntegral X] : Field X.functionField := by
  apply fieldOfIsUnitOrEqZero
  intro a
  obtain ⟨U, m, s, rfl⟩ := TopCat.Presheaf.germ_exist _ _ a
  rw [or_iff_not_imp_right, ← (X.presheaf.germ ⟨_, m⟩).map_zero]
  intro ha
  replace ha := ne_of_apply_ne _ ha
  have hs : genericPoint X.carrier ∈ RingedSpace.basicOpen _ s := by
    rw [← SetLike.mem_coe, (genericPoint_spec X.carrier).mem_open_set_iff, Set.top_eq_univ,
      Set.univ_inter, Set.nonempty_iff_ne_empty, Ne.def, ← Opens.coe_bot, ← SetLike.ext'_iff]
    

Proof state:
X : Scheme
inst✝ : IsIntegral X
U : Opens ↑↑X.toPresheafedSpace
m : genericPoint ↑↑X.toPresheafedSpace ∈ U
s : (forget CommRingCat).obj (X.presheaf.obj (op U))
ha : s ≠ 0
⊢ ¬RingedSpace.basicOpen X.toSheafedSpace s = ⊥
X : Scheme
inst✝ : IsIntegral X
U : Opens ↑↑X.toPresheafedSpace
m : genericPoint ↑↑X.toPresheafedSpace ∈ U
s : (forget CommRingCat).obj (X.presheaf.obj (op U))
ha : s ≠ 0
⊢ IsOpen ↑(RingedSpace.basicOpen X.toSheafedSpace s)

Next tactic:
erw [basicOpen_eq_bot_iff]
noncomputable instance [IsIntegral X] : Field X.functionField := by
  apply fieldOfIsUnitOrEqZero
  intro a
  obtain ⟨U, m, s, rfl⟩ := TopCat.Presheaf.germ_exist _ _ a
  rw [or_iff_not_imp_right, ← (X.presheaf.germ ⟨_, m⟩).map_zero]
  intro ha
  replace ha := ne_of_apply_ne _ ha
  have hs : genericPoint X.carrier ∈ RingedSpace.basicOpen _ s := by
    rw [← SetLike.mem_coe, (genericPoint_spec X.carrier).mem_open_set_iff, Set.top_eq_univ,
      Set.univ_inter, Set.nonempty_iff_ne_empty, Ne.def, ← Opens.coe_bot, ← SetLike.ext'_iff]
    erw [basicOpen_eq_bot_iff]
    

Proof state:
X : Scheme
inst✝ : IsIntegral X
U : Opens ↑↑X.toPresheafedSpace
m : genericPoint ↑↑X.toPresheafedSpace ∈ U
s : (forget CommRingCat).obj (X.presheaf.obj (op U))
ha : s ≠ 0
⊢ ¬s = 0
X : Scheme
inst✝ : IsIntegral X
U : Opens ↑↑X.toPresheafedSpace
m : genericPoint ↑↑X.toPresheafedSpace ∈ U
s : (forget CommRingCat).obj (X.presheaf.obj (op U))
ha : s ≠ 0
⊢ IsOpen ↑(RingedSpace.basicOpen X.toSheafedSpace s)

Next tactic:
exacts [ha, (RingedSpace.basicOpen _ _).isOpen]
noncomputable instance [IsIntegral X] : Field X.functionField := by
  apply fieldOfIsUnitOrEqZero
  intro a
  obtain ⟨U, m, s, rfl⟩ := TopCat.Presheaf.germ_exist _ _ a
  rw [or_iff_not_imp_right, ← (X.presheaf.germ ⟨_, m⟩).map_zero]
  intro ha
  replace ha := ne_of_apply_ne _ ha
  have hs : genericPoint X.carrier ∈ RingedSpace.basicOpen _ s := by
    rw [← SetLike.mem_coe, (genericPoint_spec X.carrier).mem_open_set_iff, Set.top_eq_univ,
      Set.univ_inter, Set.nonempty_iff_ne_empty, Ne.def, ← Opens.coe_bot, ← SetLike.ext'_iff]
    erw [basicOpen_eq_bot_iff]
    exacts [ha, (RingedSpace.basicOpen _ _).isOpen]
  

Proof state:
case h.intro.intro.intro
X : Scheme
inst✝ : IsIntegral X
U : Opens ↑↑X.toPresheafedSpace
m : genericPoint ↑↑X.toPresheafedSpace ∈ U
s : (forget CommRingCat).obj (X.presheaf.obj (op U))
ha : s ≠ 0
hs : genericPoint ↑↑X.toPresheafedSpace ∈ RingedSpace.basicOpen X.toSheafedSpace s
⊢ IsUnit ((Presheaf.germ X.presheaf { val := genericPoint ↑↑X.toPresheafedSpace, property := m }) s)

Next tactic:
have := (X.presheaf.germ ⟨_, hs⟩).isUnit_map (RingedSpace.isUnit_res_basicOpen _ s)
noncomputable instance [IsIntegral X] : Field X.functionField := by
  apply fieldOfIsUnitOrEqZero
  intro a
  obtain ⟨U, m, s, rfl⟩ := TopCat.Presheaf.germ_exist _ _ a
  rw [or_iff_not_imp_right, ← (X.presheaf.germ ⟨_, m⟩).map_zero]
  intro ha
  replace ha := ne_of_apply_ne _ ha
  have hs : genericPoint X.carrier ∈ RingedSpace.basicOpen _ s := by
    rw [← SetLike.mem_coe, (genericPoint_spec X.carrier).mem_open_set_iff, Set.top_eq_univ,
      Set.univ_inter, Set.nonempty_iff_ne_empty, Ne.def, ← Opens.coe_bot, ← SetLike.ext'_iff]
    erw [basicOpen_eq_bot_iff]
    exacts [ha, (RingedSpace.basicOpen _ _).isOpen]
  have := (X.presheaf.germ ⟨_, hs⟩).isUnit_map (RingedSpace.isUnit_res_basicOpen _ s)
  

Proof state:
case h.intro.intro.intro
X : Scheme
inst✝ : IsIntegral X
U : Opens ↑↑X.toPresheafedSpace
m : genericPoint ↑↑X.toPresheafedSpace ∈ U
s : (forget CommRingCat).obj (X.presheaf.obj (op U))
ha : s ≠ 0
hs : genericPoint ↑↑X.toPresheafedSpace ∈ RingedSpace.basicOpen X.toSheafedSpace s
this :
  IsUnit
    ((Presheaf.germ X.presheaf { val := genericPoint ↑↑X.toPresheafedSpace, property := hs })
      ((X.presheaf.map (homOfLE (_ : RingedSpace.basicOpen X.toSheafedSpace s ≤ U)).op) s))
⊢ IsUnit ((Presheaf.germ X.presheaf { val := genericPoint ↑↑X.toPresheafedSpace, property := m }) s)

Next tactic:
rwa [TopCat.Presheaf.germ_res_apply] at this
theorem germ_injective_of_isIntegral [IsIntegral X] {U : Opens X.carrier} (x : U) :
    Function.Injective (X.presheaf.germ x) := by
  

Proof state:
X : Scheme
inst✝ : IsIntegral X
U : Opens ↑↑X.toPresheafedSpace
x : ↥U
⊢ Function.Injective ⇑(Presheaf.germ X.presheaf x)

Next tactic:
rw [injective_iff_map_eq_zero]
theorem germ_injective_of_isIntegral [IsIntegral X] {U : Opens X.carrier} (x : U) :
    Function.Injective (X.presheaf.germ x) := by
  rw [injective_iff_map_eq_zero]
  

Proof state:
X : Scheme
inst✝ : IsIntegral X
U : Opens ↑↑X.toPresheafedSpace
x : ↥U
⊢ ∀ (a : (forget CommRingCat).obj (X.presheaf.obj (op U))), (Presheaf.germ X.presheaf x) a = 0 → a = 0

Next tactic:
intro y hy
theorem germ_injective_of_isIntegral [IsIntegral X] {U : Opens X.carrier} (x : U) :
    Function.Injective (X.presheaf.germ x) := by
  rw [injective_iff_map_eq_zero]
  intro y hy
  

Proof state:
X : Scheme
inst✝ : IsIntegral X
U : Opens ↑↑X.toPresheafedSpace
x : ↥U
y : (forget CommRingCat).obj (X.presheaf.obj (op U))
hy : (Presheaf.germ X.presheaf x) y = 0
⊢ y = 0

Next tactic:
rw [← (X.presheaf.germ x).map_zero] at hy
theorem germ_injective_of_isIntegral [IsIntegral X] {U : Opens X.carrier} (x : U) :
    Function.Injective (X.presheaf.germ x) := by
  rw [injective_iff_map_eq_zero]
  intro y hy
  rw [← (X.presheaf.germ x).map_zero] at hy
  

Proof state:
X : Scheme
inst✝ : IsIntegral X
U : Opens ↑↑X.toPresheafedSpace
x : ↥U
y : (forget CommRingCat).obj (X.presheaf.obj (op U))
hy : (Presheaf.germ X.presheaf x) y = (Presheaf.germ X.presheaf x) 0
⊢ y = 0

Next tactic:
obtain ⟨W, hW, iU, iV, e⟩ := X.presheaf.germ_eq _ x.prop x.prop _ _ hy
theorem germ_injective_of_isIntegral [IsIntegral X] {U : Opens X.carrier} (x : U) :
    Function.Injective (X.presheaf.germ x) := by
  rw [injective_iff_map_eq_zero]
  intro y hy
  rw [← (X.presheaf.germ x).map_zero] at hy
  obtain ⟨W, hW, iU, iV, e⟩ := X.presheaf.germ_eq _ x.prop x.prop _ _ hy
  

Proof state:
case intro.intro.intro.intro
X : Scheme
inst✝ : IsIntegral X
U : Opens ↑↑X.toPresheafedSpace
x : ↥U
y : (forget CommRingCat).obj (X.presheaf.obj (op U))
hy : (Presheaf.germ X.presheaf x) y = (Presheaf.germ X.presheaf x) 0
W : Opens ↑↑X.toPresheafedSpace
hW : ↑x ∈ W
iU iV : W ⟶ U
e : (X.presheaf.map iU.op) y = (X.presheaf.map iV.op) 0
⊢ y = 0

Next tactic:
cases show iU = iV from Subsingleton.elim _ _
theorem germ_injective_of_isIntegral [IsIntegral X] {U : Opens X.carrier} (x : U) :
    Function.Injective (X.presheaf.germ x) := by
  rw [injective_iff_map_eq_zero]
  intro y hy
  rw [← (X.presheaf.germ x).map_zero] at hy
  obtain ⟨W, hW, iU, iV, e⟩ := X.presheaf.germ_eq _ x.prop x.prop _ _ hy
  cases show iU = iV from Subsingleton.elim _ _
  

Proof state:
case intro.intro.intro.intro.refl
X : Scheme
inst✝ : IsIntegral X
U : Opens ↑↑X.toPresheafedSpace
x : ↥U
y : (forget CommRingCat).obj (X.presheaf.obj (op U))
hy : (Presheaf.germ X.presheaf x) y = (Presheaf.germ X.presheaf x) 0
W : Opens ↑↑X.toPresheafedSpace
hW : ↑x ∈ W
iU : W ⟶ U
e : (X.presheaf.map iU.op) y = (X.presheaf.map iU.op) 0
⊢ y = 0

Next tactic:
haveI : Nonempty W := ⟨⟨_, hW⟩⟩
theorem germ_injective_of_isIntegral [IsIntegral X] {U : Opens X.carrier} (x : U) :
    Function.Injective (X.presheaf.germ x) := by
  rw [injective_iff_map_eq_zero]
  intro y hy
  rw [← (X.presheaf.germ x).map_zero] at hy
  obtain ⟨W, hW, iU, iV, e⟩ := X.presheaf.germ_eq _ x.prop x.prop _ _ hy
  cases show iU = iV from Subsingleton.elim _ _
  haveI : Nonempty W := ⟨⟨_, hW⟩⟩
  

Proof state:
case intro.intro.intro.intro.refl
X : Scheme
inst✝ : IsIntegral X
U : Opens ↑↑X.toPresheafedSpace
x : ↥U
y : (forget CommRingCat).obj (X.presheaf.obj (op U))
hy : (Presheaf.germ X.presheaf x) y = (Presheaf.germ X.presheaf x) 0
W : Opens ↑↑X.toPresheafedSpace
hW : ↑x ∈ W
iU : W ⟶ U
e : (X.presheaf.map iU.op) y = (X.presheaf.map iU.op) 0
this : Nonempty ↥W
⊢ y = 0

Next tactic:
exact map_injective_of_isIntegral X iU e
theorem genericPoint_eq_of_isOpenImmersion {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f]
    [hX : IrreducibleSpace X.carrier] [IrreducibleSpace Y.carrier] :
    f.1.base (genericPoint X.carrier : _) = (genericPoint Y.carrier : _) := by
  

Proof state:
X✝ : Scheme
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
hX : IrreducibleSpace ↑↑X.toPresheafedSpace
inst✝ : IrreducibleSpace ↑↑Y.toPresheafedSpace
⊢ f.val.base (genericPoint ↑↑X.toPresheafedSpace) = genericPoint ↑↑Y.toPresheafedSpace

Next tactic:
apply ((genericPoint_spec Y).eq _).symm
theorem genericPoint_eq_of_isOpenImmersion {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f]
    [hX : IrreducibleSpace X.carrier] [IrreducibleSpace Y.carrier] :
    f.1.base (genericPoint X.carrier : _) = (genericPoint Y.carrier : _) := by
  apply ((genericPoint_spec Y).eq _).symm
  -- Porting note: the continuity argument used to be `by continuity`
  

Proof state:
X✝ : Scheme
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
hX : IrreducibleSpace ↑↑X.toPresheafedSpace
inst✝ : IrreducibleSpace ↑↑Y.toPresheafedSpace
⊢ IsGenericPoint (f.val.base (genericPoint ↑↑X.toPresheafedSpace)) ⊤

Next tactic:
convert (genericPoint_spec X.carrier).image
    (show Continuous f.1.base from ContinuousMap.continuous_toFun _)
theorem genericPoint_eq_of_isOpenImmersion {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f]
    [hX : IrreducibleSpace X.carrier] [IrreducibleSpace Y.carrier] :
    f.1.base (genericPoint X.carrier : _) = (genericPoint Y.carrier : _) := by
  apply ((genericPoint_spec Y).eq _).symm
  -- Porting note: the continuity argument used to be `by continuity`
  convert (genericPoint_spec X.carrier).image
    (show Continuous f.1.base from ContinuousMap.continuous_toFun _)
  

Proof state:
case h.e'_4.h
X✝ : Scheme
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
hX : IrreducibleSpace ↑↑X.toPresheafedSpace
inst✝ : IrreducibleSpace ↑↑Y.toPresheafedSpace
e_1✝ : ↑↑Y.toPresheafedSpace = (forget TopCat).obj ↑Y.toPresheafedSpace
⊢ ⊤ = closure (⇑f.val.base '' ⊤)

Next tactic:
symm
theorem genericPoint_eq_of_isOpenImmersion {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f]
    [hX : IrreducibleSpace X.carrier] [IrreducibleSpace Y.carrier] :
    f.1.base (genericPoint X.carrier : _) = (genericPoint Y.carrier : _) := by
  apply ((genericPoint_spec Y).eq _).symm
  -- Porting note: the continuity argument used to be `by continuity`
  convert (genericPoint_spec X.carrier).image
    (show Continuous f.1.base from ContinuousMap.continuous_toFun _)
  symm
  

Proof state:
case h.e'_4.h
X✝ : Scheme
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
hX : IrreducibleSpace ↑↑X.toPresheafedSpace
inst✝ : IrreducibleSpace ↑↑Y.toPresheafedSpace
e_1✝ : ↑↑Y.toPresheafedSpace = (forget TopCat).obj ↑Y.toPresheafedSpace
⊢ closure (⇑f.val.base '' ⊤) = ⊤

Next tactic:
rw [eq_top_iff, Set.top_eq_univ, Set.top_eq_univ]
theorem genericPoint_eq_of_isOpenImmersion {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f]
    [hX : IrreducibleSpace X.carrier] [IrreducibleSpace Y.carrier] :
    f.1.base (genericPoint X.carrier : _) = (genericPoint Y.carrier : _) := by
  apply ((genericPoint_spec Y).eq _).symm
  -- Porting note: the continuity argument used to be `by continuity`
  convert (genericPoint_spec X.carrier).image
    (show Continuous f.1.base from ContinuousMap.continuous_toFun _)
  symm
  rw [eq_top_iff, Set.top_eq_univ, Set.top_eq_univ]
  

Proof state:
case h.e'_4.h
X✝ : Scheme
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
hX : IrreducibleSpace ↑↑X.toPresheafedSpace
inst✝ : IrreducibleSpace ↑↑Y.toPresheafedSpace
e_1✝ : ↑↑Y.toPresheafedSpace = (forget TopCat).obj ↑Y.toPresheafedSpace
⊢ Set.univ ≤ closure (⇑f.val.base '' Set.univ)

Next tactic:
convert subset_closure_inter_of_isPreirreducible_of_isOpen _ H.base_open.open_range _
theorem genericPoint_eq_of_isOpenImmersion {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f]
    [hX : IrreducibleSpace X.carrier] [IrreducibleSpace Y.carrier] :
    f.1.base (genericPoint X.carrier : _) = (genericPoint Y.carrier : _) := by
  apply ((genericPoint_spec Y).eq _).symm
  -- Porting note: the continuity argument used to be `by continuity`
  convert (genericPoint_spec X.carrier).image
    (show Continuous f.1.base from ContinuousMap.continuous_toFun _)
  symm
  rw [eq_top_iff, Set.top_eq_univ, Set.top_eq_univ]
  convert subset_closure_inter_of_isPreirreducible_of_isOpen _ H.base_open.open_range _
  

Proof state:
case h.e'_2.h.e'_3
X✝ : Scheme
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
hX : IrreducibleSpace ↑↑X.toPresheafedSpace
inst✝ : IrreducibleSpace ↑↑Y.toPresheafedSpace
e_1✝ : ↑↑Y.toPresheafedSpace = (forget TopCat).obj ↑Y.toPresheafedSpace
⊢ ⇑f.val.base '' Set.univ = Set.univ ∩ Set.range ⇑f.val.base
case h.e'_4.h.convert_2
X✝ : Scheme
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
hX : IrreducibleSpace ↑↑X.toPresheafedSpace
inst✝ : IrreducibleSpace ↑↑Y.toPresheafedSpace
e_1✝ : ↑↑Y.toPresheafedSpace = (forget TopCat).obj ↑Y.toPresheafedSpace
⊢ IsPreirreducible Set.univ
case h.e'_4.h.convert_3
X✝ : Scheme
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
hX : IrreducibleSpace ↑↑X.toPresheafedSpace
inst✝ : IrreducibleSpace ↑↑Y.toPresheafedSpace
e_1✝ : ↑↑Y.toPresheafedSpace = (forget TopCat).obj ↑Y.toPresheafedSpace
⊢ Set.Nonempty (Set.univ ∩ Set.range ⇑f.val.base)

Next tactic:
rw [Set.univ_inter, Set.image_univ]
theorem genericPoint_eq_of_isOpenImmersion {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f]
    [hX : IrreducibleSpace X.carrier] [IrreducibleSpace Y.carrier] :
    f.1.base (genericPoint X.carrier : _) = (genericPoint Y.carrier : _) := by
  apply ((genericPoint_spec Y).eq _).symm
  -- Porting note: the continuity argument used to be `by continuity`
  convert (genericPoint_spec X.carrier).image
    (show Continuous f.1.base from ContinuousMap.continuous_toFun _)
  symm
  rw [eq_top_iff, Set.top_eq_univ, Set.top_eq_univ]
  convert subset_closure_inter_of_isPreirreducible_of_isOpen _ H.base_open.open_range _
  rw [Set.univ_inter, Set.image_univ]
  

Proof state:
case h.e'_4.h.convert_2
X✝ : Scheme
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
hX : IrreducibleSpace ↑↑X.toPresheafedSpace
inst✝ : IrreducibleSpace ↑↑Y.toPresheafedSpace
e_1✝ : ↑↑Y.toPresheafedSpace = (forget TopCat).obj ↑Y.toPresheafedSpace
⊢ IsPreirreducible Set.univ
case h.e'_4.h.convert_3
X✝ : Scheme
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
hX : IrreducibleSpace ↑↑X.toPresheafedSpace
inst✝ : IrreducibleSpace ↑↑Y.toPresheafedSpace
e_1✝ : ↑↑Y.toPresheafedSpace = (forget TopCat).obj ↑Y.toPresheafedSpace
⊢ Set.Nonempty (Set.univ ∩ Set.range ⇑f.val.base)

Next tactic:
apply PreirreducibleSpace.isPreirreducible_univ (X := Y.carrier)
theorem genericPoint_eq_of_isOpenImmersion {X Y : Scheme} (f : X ⟶ Y) [H : IsOpenImmersion f]
    [hX : IrreducibleSpace X.carrier] [IrreducibleSpace Y.carrier] :
    f.1.base (genericPoint X.carrier : _) = (genericPoint Y.carrier : _) := by
  apply ((genericPoint_spec Y).eq _).symm
  -- Porting note: the continuity argument used to be `by continuity`
  convert (genericPoint_spec X.carrier).image
    (show Continuous f.1.base from ContinuousMap.continuous_toFun _)
  symm
  rw [eq_top_iff, Set.top_eq_univ, Set.top_eq_univ]
  convert subset_closure_inter_of_isPreirreducible_of_isOpen _ H.base_open.open_range _
  rw [Set.univ_inter, Set.image_univ]
  apply PreirreducibleSpace.isPreirreducible_univ (X := Y.carrier)
  

Proof state:
case h.e'_4.h.convert_3
X✝ : Scheme
X Y : Scheme
f : X ⟶ Y
H : IsOpenImmersion f
hX : IrreducibleSpace ↑↑X.toPresheafedSpace
inst✝ : IrreducibleSpace ↑↑Y.toPresheafedSpace
e_1✝ : ↑↑Y.toPresheafedSpace = (forget TopCat).obj ↑Y.toPresheafedSpace
⊢ Set.Nonempty (Set.univ ∩ Set.range ⇑f.val.base)

Next tactic:
exact ⟨_, trivial, Set.mem_range_self hX.2.some⟩
noncomputable instance stalkFunctionFieldAlgebra [IrreducibleSpace X.carrier] (x : X.carrier) :
    Algebra (X.presheaf.stalk x) X.functionField := by
  

Proof state:
X : Scheme
inst✝ : IrreducibleSpace ↑↑X.toPresheafedSpace
x : ↑↑X.toPresheafedSpace
⊢ Algebra ↑(Presheaf.stalk X.presheaf x) ↑(Scheme.functionField X)

Next tactic:
apply RingHom.toAlgebra
noncomputable instance stalkFunctionFieldAlgebra [IrreducibleSpace X.carrier] (x : X.carrier) :
    Algebra (X.presheaf.stalk x) X.functionField := by
  apply RingHom.toAlgebra
  

Proof state:
case i
X : Scheme
inst✝ : IrreducibleSpace ↑↑X.toPresheafedSpace
x : ↑↑X.toPresheafedSpace
⊢ ↑(Presheaf.stalk X.presheaf x) →+* ↑(Scheme.functionField X)

Next tactic:
exact X.presheaf.stalkSpecializes ((genericPoint_spec X.carrier).specializes trivial)
instance functionField_isScalarTower [IrreducibleSpace X.carrier] (U : Opens X.carrier) (x : U)
    [Nonempty U] : IsScalarTower (X.presheaf.obj <| op U) (X.presheaf.stalk x) X.functionField := by
  

Proof state:
X : Scheme
inst✝¹ : IrreducibleSpace ↑↑X.toPresheafedSpace
U : Opens ↑↑X.toPresheafedSpace
x : ↥U
inst✝ : Nonempty ↥U
⊢ IsScalarTower ↑(X.presheaf.obj (op U)) ↑(Presheaf.stalk X.presheaf ↑x) ↑(Scheme.functionField X)

Next tactic:
apply IsScalarTower.of_algebraMap_eq'
instance functionField_isScalarTower [IrreducibleSpace X.carrier] (U : Opens X.carrier) (x : U)
    [Nonempty U] : IsScalarTower (X.presheaf.obj <| op U) (X.presheaf.stalk x) X.functionField := by
  apply IsScalarTower.of_algebraMap_eq'
  

Proof state:
case h
X : Scheme
inst✝¹ : IrreducibleSpace ↑↑X.toPresheafedSpace
U : Opens ↑↑X.toPresheafedSpace
x : ↥U
inst✝ : Nonempty ↥U
⊢ algebraMap ↑(X.presheaf.obj (op U)) ↑(Scheme.functionField X) =
    RingHom.comp (algebraMap ↑(Presheaf.stalk X.presheaf ↑x) ↑(Scheme.functionField X))
      (algebraMap ↑(X.presheaf.obj (op U)) ↑(Presheaf.stalk X.presheaf ↑x))

Next tactic:
simp_rw [RingHom.algebraMap_toAlgebra]
instance functionField_isScalarTower [IrreducibleSpace X.carrier] (U : Opens X.carrier) (x : U)
    [Nonempty U] : IsScalarTower (X.presheaf.obj <| op U) (X.presheaf.stalk x) X.functionField := by
  apply IsScalarTower.of_algebraMap_eq'
  simp_rw [RingHom.algebraMap_toAlgebra]
  

Proof state:
case h
X : Scheme
inst✝¹ : IrreducibleSpace ↑↑X.toPresheafedSpace
U : Opens ↑↑X.toPresheafedSpace
x : ↥U
inst✝ : Nonempty ↥U
⊢ Scheme.germToFunctionField X U =
    RingHom.comp (Presheaf.stalkSpecializes X.presheaf (_ : genericPoint ↑↑X.toPresheafedSpace ⤳ ↑x))
      (Presheaf.germ X.presheaf x)

Next tactic:
change _ = X.presheaf.germ x ≫ _
instance functionField_isScalarTower [IrreducibleSpace X.carrier] (U : Opens X.carrier) (x : U)
    [Nonempty U] : IsScalarTower (X.presheaf.obj <| op U) (X.presheaf.stalk x) X.functionField := by
  apply IsScalarTower.of_algebraMap_eq'
  simp_rw [RingHom.algebraMap_toAlgebra]
  change _ = X.presheaf.germ x ≫ _
  

Proof state:
case h
X : Scheme
inst✝¹ : IrreducibleSpace ↑↑X.toPresheafedSpace
U : Opens ↑↑X.toPresheafedSpace
x : ↥U
inst✝ : Nonempty ↥U
⊢ Scheme.germToFunctionField X U =
    Presheaf.germ X.presheaf x ≫ Presheaf.stalkSpecializes X.presheaf (_ : genericPoint ↑↑X.toPresheafedSpace ⤳ ↑x)

Next tactic:
rw [X.presheaf.germ_stalkSpecializes]
noncomputable instance (R : CommRingCat) [IsDomain R] :
    Algebra R (Scheme.Spec.obj <| op R).functionField :=
  RingHom.toAlgebra <| by 

Proof state:
X : Scheme
R : CommRingCat
inst✝ : IsDomain ↑R
⊢ ↑R →+* ↑(Scheme.functionField (Scheme.Spec.obj (op R)))

Next tactic:
change CommRingCat.of R ⟶ _