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

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
this : (ConcreteCategory.hom (Spec.map stalk_y_to_A).base) (closedPoint ↥A) = closedPoint ↑(Y.presheaf.stalk y)
⊢ (ConcreteCategory.hom (Y.fromSpecStalk y).base)
      ((ConcreteCategory.hom (Spec.map stalk_y_to_A).base) (closedPoint ↥A)) =
    y

Tactic:
rw [this, Y.fromSpecStalk_closedPoint]

Result:
no goals

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 f.base) ((ConcreteCategory.hom l.base) (closedPoint ↥A)) = y

Tactic:
rw [← Scheme.comp_base_apply, hl₂]

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 (Spec.map stalk_y_to_A ≫ Y.fromSpecStalk y).base) (closedPoint ↥A) = y

Proof state:
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)
stalk_y_to_A : Y.presheaf.stalk y ⟶ CommRingCat.of ↥A :=
  CommRingCat.ofHom ((CommRingCat.Hom.hom stalk_y_to_residue_x').codRestrict A hA)
⊢ ∃ a', flip (fun x1 x2 => x1 ⤳ x2) a' x' ∧ (ConcreteCategory.hom f.base) a' = y

Tactic:
have w : X.fromSpecResidueField x' ≫ f =
    Spec.map (CommRingCat.ofHom (algebraMap A (X.residueField x'))) ≫
      Spec.map stalk_y_to_A ≫ Y.fromSpecStalk y := by
  rw [Scheme.fromSpecResidueField, Category.assoc, ← Scheme.Spec_map_stalkMap_fromSpecStalk,
    ← Scheme.Spec_map_stalkSpecializes_fromSpecStalk h]
  simp_rw [← Spec.map_comp_assoc]
  rfl

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)
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
⊢ ∃ a', flip (fun x1 x2 => x1 ⤳ x2) a' x' ∧ (ConcreteCategory.hom f.base) a' = y