-- Mathlib/AlgebraicGeometry/ValuativeCriterion.lean
@[stacks 01KE]
lemma specializingMap (H : ValuativeCriterion.Existence f) :
    SpecializingMap f.base

Proof state:
X Y : Scheme
f : X ⟶ Y
H : Existence f
x' : ↑↑X.toPresheafedSpace
y : ↑↑Y.toPresheafedSpace
h : flip (fun x1 x2 => x1 ⤳ x2) y ((ConcreteCategory.hom f.base) x')
stalk_y_to_residue_x' : Y.presheaf.stalk y ⟶ X.residueField x' :=
  Y.presheaf.stalkSpecializes h ≫ Scheme.Hom.stalkMap f x' ≫ X.residue x'
A : ValuationSubring ↑(X.residueField x')
hA : ∀ (x : ↑(Y.presheaf.stalk y)), (CommRingCat.Hom.hom stalk_y_to_residue_x') x ∈ A.toSubring
hA_local : IsLocalHom ((CommRingCat.Hom.hom stalk_y_to_residue_x').codRestrict A.toSubring hA)
stalk_y_to_A : Y.presheaf.stalk y ⟶ CommRingCat.of ↥A :=
  CommRingCat.ofHom ((CommRingCat.Hom.hom stalk_y_to_residue_x').codRestrict A hA)
⊢ X.fromSpecResidueField x' ≫ f =
    Spec.map (CommRingCat.ofHom (algebraMap ↥A ↑(X.residueField x'))) ≫ Spec.map stalk_y_to_A ≫ Y.fromSpecStalk y

Tactic:
rw [Scheme.fromSpecResidueField, Category.assoc, ← Scheme.Spec_map_stalkMap_fromSpecStalk,
  ← Scheme.Spec_map_stalkSpecializes_fromSpecStalk h]

Result:
X Y : Scheme
f : X ⟶ Y
H : Existence f
x' : ↑↑X.toPresheafedSpace
y : ↑↑Y.toPresheafedSpace
h : flip (fun x1 x2 => x1 ⤳ x2) y ((ConcreteCategory.hom f.base) x')
stalk_y_to_residue_x' : Y.presheaf.stalk y ⟶ X.residueField x' :=
  Y.presheaf.stalkSpecializes h ≫ Scheme.Hom.stalkMap f x' ≫ X.residue x'
A : ValuationSubring ↑(X.residueField x')
hA : ∀ (x : ↑(Y.presheaf.stalk y)), (CommRingCat.Hom.hom stalk_y_to_residue_x') x ∈ A.toSubring
hA_local : IsLocalHom ((CommRingCat.Hom.hom stalk_y_to_residue_x').codRestrict A.toSubring hA)
stalk_y_to_A : Y.presheaf.stalk y ⟶ CommRingCat.of ↥A :=
  CommRingCat.ofHom ((CommRingCat.Hom.hom stalk_y_to_residue_x').codRestrict A hA)
⊢ Spec.map (X.residue x') ≫
      Spec.map (Scheme.Hom.stalkMap f x') ≫ Spec.map (Y.presheaf.stalkSpecializes h) ≫ Y.fromSpecStalk y =
    Spec.map (CommRingCat.ofHom (algebraMap ↥A ↑(X.residueField x'))) ≫ Spec.map stalk_y_to_A ≫ Y.fromSpecStalk y

Proof state:
case intro.intro.intro.mk.refine_1
X Y : Scheme
f : X ⟶ Y
H : Existence f
x' : ↑↑X.toPresheafedSpace
y : ↑↑Y.toPresheafedSpace
h : flip (fun x1 x2 => x1 ⤳ x2) y ((ConcreteCategory.hom f.base) x')
stalk_y_to_residue_x' : Y.presheaf.stalk y ⟶ X.residueField x' :=
  Y.presheaf.stalkSpecializes h ≫ Scheme.Hom.stalkMap f x' ≫ X.residue x'
A : ValuationSubring ↑(X.residueField x')
hA : ∀ (x : ↑(Y.presheaf.stalk y)), (CommRingCat.Hom.hom stalk_y_to_residue_x') x ∈ A.toSubring
hA_local : IsLocalHom ((CommRingCat.Hom.hom stalk_y_to_residue_x').codRestrict A.toSubring hA)
stalk_y_to_A : Y.presheaf.stalk y ⟶ CommRingCat.of ↥A :=
  CommRingCat.ofHom ((CommRingCat.Hom.hom stalk_y_to_residue_x').codRestrict A hA)
w :
  X.fromSpecResidueField x' ≫ f =
    Spec.map (CommRingCat.ofHom (algebraMap ↥A ↑(X.residueField x'))) ≫ Spec.map stalk_y_to_A ≫ Y.fromSpecStalk y
l :
  Spec
      (CommRingCat.of
        (ValuativeCommSq.mk (↥A) (↑(X.residueField x')) (X.fromSpecResidueField x')
            (Spec.map stalk_y_to_A ≫ Y.fromSpecStalk y) ⋯).R) ⟶
    X
hl₁ : Spec.map (CommRingCat.ofHom (algebraMap ↥A ↑(X.residueField x'))) ≫ l = X.fromSpecResidueField x'
hl₂ : l ≫ f = Spec.map stalk_y_to_A ≫ Y.fromSpecStalk y
⊢ flip (fun x1 x2 => x1 ⤳ x2) ((ConcreteCategory.hom l.base) (closedPoint ↥A))
    ((ConcreteCategory.hom (Spec.map (CommRingCat.ofHom (algebraMap ↥A ↑(X.residueField x'))) ≫ l).base)
      (closedPoint ↑(X.residueField x')))

Tactic:
exact (specializes_closedPoint _).map l.base.hom.2

Result:
no goals

Proof state:
X Y : Scheme
f : X ⟶ Y
H : Existence f
x' : ↑↑X.toPresheafedSpace
y : ↑↑Y.toPresheafedSpace
h : flip (fun x1 x2 => x1 ⤳ x2) y ((ConcreteCategory.hom f.base) x')
stalk_y_to_residue_x' : Y.presheaf.stalk y ⟶ X.residueField x' :=
  Y.presheaf.stalkSpecializes h ≫ Scheme.Hom.stalkMap f x' ≫ X.residue x'
⊢ ∃ a', flip (fun x1 x2 => x1 ⤳ x2) a' x' ∧ (ConcreteCategory.hom f.base) a' = y

Tactic:
obtain ⟨A, hA, hA_local⟩ := exists_factor_valuationRing stalk_y_to_residue_x'.hom

Result:
case intro.intro
X Y : Scheme
f : X ⟶ Y
H : Existence f
x' : ↑↑X.toPresheafedSpace
y : ↑↑Y.toPresheafedSpace
h : flip (fun x1 x2 => x1 ⤳ x2) y ((ConcreteCategory.hom f.base) x')
stalk_y_to_residue_x' : Y.presheaf.stalk y ⟶ X.residueField x' :=
  Y.presheaf.stalkSpecializes h ≫ Scheme.Hom.stalkMap f x' ≫ X.residue x'
A : ValuationSubring ↑(X.residueField x')
hA : ∀ (x : ↑(Y.presheaf.stalk y)), (CommRingCat.Hom.hom stalk_y_to_residue_x') x ∈ A.toSubring
hA_local : IsLocalHom ((CommRingCat.Hom.hom stalk_y_to_residue_x').codRestrict A.toSubring hA)
⊢ ∃ a', flip (fun x1 x2 => x1 ⤳ x2) a' x' ∧ (ConcreteCategory.hom f.base) a' = y

Proof state:
case intro.intro.intro.mk.refine_2
X Y : Scheme
f : X ⟶ Y
H : Existence f
x' : ↑↑X.toPresheafedSpace
y : ↑↑Y.toPresheafedSpace
h : flip (fun x1 x2 => x1 ⤳ x2) y ((ConcreteCategory.hom f.base) x')
stalk_y_to_residue_x' : Y.presheaf.stalk y ⟶ X.residueField x' :=
  Y.presheaf.stalkSpecializes h ≫ Scheme.Hom.stalkMap f x' ≫ X.residue x'
A : ValuationSubring ↑(X.residueField x')
hA : ∀ (x : ↑(Y.presheaf.stalk y)), (CommRingCat.Hom.hom stalk_y_to_residue_x') x ∈ A.toSubring
hA_local : IsLocalHom ((CommRingCat.Hom.hom stalk_y_to_residue_x').codRestrict A.toSubring hA)
stalk_y_to_A : Y.presheaf.stalk y ⟶ CommRingCat.of ↥A :=
  CommRingCat.ofHom ((CommRingCat.Hom.hom stalk_y_to_residue_x').codRestrict A hA)
w :
  X.fromSpecResidueField x' ≫ f =
    Spec.map (CommRingCat.ofHom (algebraMap ↥A ↑(X.residueField x'))) ≫ Spec.map stalk_y_to_A ≫ Y.fromSpecStalk y
l :
  Spec
      (CommRingCat.of
        (ValuativeCommSq.mk (↥A) (↑(X.residueField x')) (X.fromSpecResidueField x')
            (Spec.map stalk_y_to_A ≫ Y.fromSpecStalk y) ⋯).R) ⟶
    X
hl₁ : Spec.map (CommRingCat.ofHom (algebraMap ↥A ↑(X.residueField x'))) ≫ l = X.fromSpecResidueField x'
hl₂ : l ≫ f = Spec.map stalk_y_to_A ≫ Y.fromSpecStalk y
⊢ (ConcreteCategory.hom (Spec.map stalk_y_to_A ≫ Y.fromSpecStalk y).base) (closedPoint ↥A) = y

Tactic:
simp only [Scheme.comp_coeBase, TopCat.coe_comp, Function.comp_apply]

Result:
case intro.intro.intro.mk.refine_2
X Y : Scheme
f : X ⟶ Y
H : Existence f
x' : ↑↑X.toPresheafedSpace
y : ↑↑Y.toPresheafedSpace
h : flip (fun x1 x2 => x1 ⤳ x2) y ((ConcreteCategory.hom f.base) x')
stalk_y_to_residue_x' : Y.presheaf.stalk y ⟶ X.residueField x' :=
  Y.presheaf.stalkSpecializes h ≫ Scheme.Hom.stalkMap f x' ≫ X.residue x'
A : ValuationSubring ↑(X.residueField x')
hA : ∀ (x : ↑(Y.presheaf.stalk y)), (CommRingCat.Hom.hom stalk_y_to_residue_x') x ∈ A.toSubring
hA_local : IsLocalHom ((CommRingCat.Hom.hom stalk_y_to_residue_x').codRestrict A.toSubring hA)
stalk_y_to_A : Y.presheaf.stalk y ⟶ CommRingCat.of ↥A :=
  CommRingCat.ofHom ((CommRingCat.Hom.hom stalk_y_to_residue_x').codRestrict A hA)
w :
  X.fromSpecResidueField x' ≫ f =
    Spec.map (CommRingCat.ofHom (algebraMap ↥A ↑(X.residueField x'))) ≫ Spec.map stalk_y_to_A ≫ Y.fromSpecStalk y
l :
  Spec
      (CommRingCat.of
        (ValuativeCommSq.mk (↥A) (↑(X.residueField x')) (X.fromSpecResidueField x')
            (Spec.map stalk_y_to_A ≫ Y.fromSpecStalk y) ⋯).R) ⟶
    X
hl₁ : Spec.map (CommRingCat.ofHom (algebraMap ↥A ↑(X.residueField x'))) ≫ l = X.fromSpecResidueField x'
hl₂ : l ≫ f = Spec.map stalk_y_to_A ≫ Y.fromSpecStalk y
⊢ (ConcreteCategory.hom (Y.fromSpecStalk y).base)
      ((ConcreteCategory.hom (Spec.map stalk_y_to_A).base) (closedPoint ↥A)) =
    y