-- Lean 4 proof step from Mathlib.AlgebraicGeometry.AffineTransitionLimit (goal)
Goal:
I : Type u
inst : Category.{u, u} I
S X : Scheme
D : I ⥤ Scheme
t : D ⟶ Functor.obj (Functor.const I) S
f : X ⟶ S
c : Cone D
hc : IsLimit c
inst_1 : IsCofiltered I
inst_2 : LocallyOfFinitePresentation f
inst_3 : ∀ {i j : I} (f : i ⟶ j), IsAffineHom (D.map f)
inst_4 : ∀ (i : I), CompactSpace.{u} ↥(D.obj i)
inst_5 : ∀ (i : I), QuasiSeparatedSpace.{u} ↥(D.obj i)
a : c.pt ⟶ X
ha : c.π ≫ t = CategoryTheory.Functor.map (Functor.const I) (a ≫ f)
𝒰 :
  IsOpenCover (X := ↥c.pt)
    fun
      (V :
        { x :
          TopologicalSpace.Opens ↥c.pt ×
            { x : TopologicalSpace.Opens ↥X × (↑S.affineOpens : Type u) //
              x.1 ∈ X.affineOpens ∧
                x.1 ≤
                  (Opens.comap (TopCat.Hom.hom f.base) : (a : TopologicalSpace.Opens ↥S) → TopologicalSpace.Opens ↥X)
                    (↑x.2 : TopologicalSpace.Opens ↥S) } //
          Membership.mem (γ := Set (TopologicalSpace.Opens ↥c.pt)) c.pt.affineOpens x.1 ∧
            x.1 ≤
              (Opens.comap (TopCat.Hom.hom a.base) : (a : TopologicalSpace.Opens ↥X) → TopologicalSpace.Opens ↥c.pt)
                (↑x.2 : TopologicalSpace.Opens ↥X × (↑S.affineOpens : Type u)).1 }) ↦
    (↑V :
        TopologicalSpace.Opens ↥c.pt ×
          { x : TopologicalSpace.Opens ↥X × (↑S.affineOpens : Type u) //
            x.1 ∈ X.affineOpens ∧
              x.1 ≤
                (Opens.comap (TopCat.Hom.hom f.base) : (a : TopologicalSpace.Opens ↥S) → TopologicalSpace.Opens ↥X)
                  (↑x.2 : TopologicalSpace.Opens ↥S) }).1
i : I
s :
  Finset
    { x :
      TopologicalSpace.Opens ↥c.pt ×
        { x : TopologicalSpace.Opens ↥X × (↑S.affineOpens : Type u) //
          x.1 ∈ X.affineOpens ∧
            x.1 ≤
              (Opens.comap (TopCat.Hom.hom f.base) : (a : TopologicalSpace.Opens ↥S) → TopologicalSpace.Opens ↥X)
                (↑x.2 : TopologicalSpace.Opens ↥S) } //
      Membership.mem (γ := Set (TopologicalSpace.Opens ↥c.pt)) c.pt.affineOpens x.1 ∧
        x.1 ≤
          (Opens.comap (TopCat.Hom.hom a.base) : (a : TopologicalSpace.Opens ↥X) → TopologicalSpace.Opens ↥c.pt)
            (↑x.2 : TopologicalSpace.Opens ↥X × (↑S.affineOpens : Type u)).1 }
𝒱 : ↥s → (D.obj i).Opens
h𝒱 : IsOpenCover 𝒱
h𝒱𝒰 :
  ∀ (j : ↥s),
    IsAffineOpen (𝒱 j) ∧
      (↑(↑j :
                { x :
                  TopologicalSpace.Opens ↥c.pt ×
                    { x : TopologicalSpace.Opens ↥X × (↑S.affineOpens : Type u) //
                      x.1 ∈ X.affineOpens ∧
                        x.1 ≤
                          (Opens.comap (TopCat.Hom.hom f.base) :
                              (a : TopologicalSpace.Opens ↥S) → TopologicalSpace.Opens ↥X)
                            (↑x.2 : TopologicalSpace.Opens ↥S) } //
                  x.1 ∈ c.pt.affineOpens ∧
                    x.1 ≤
                      (Opens.comap (TopCat.Hom.hom a.base) :
                          (a : TopologicalSpace.Opens ↥X) → TopologicalSpace.Opens ↥c.pt)
                        (↑x.2 : TopologicalSpace.Opens ↥X × (↑S.affineOpens : Type u)).1 }) :
            TopologicalSpace.Opens ↥c.pt ×
              { x : TopologicalSpace.Opens ↥X × (↑S.affineOpens : Type u) //
                x.1 ∈ X.affineOpens ∧
                  x.1 ≤
                    (Opens.comap (TopCat.Hom.hom f.base) : (a : TopologicalSpace.Opens ↥S) → TopologicalSpace.Opens ↥X)
                      (↑x.2 : TopologicalSpace.Opens ↥S) }).1 =
        c.π.app i ⁻¹ᵁ 𝒱 j
⊢ ∃ (i' : I) (fi'i : i' ⟶ i),
    ∀ (j : ↥s),
      D.map fi'i ⁻¹ᵁ 𝒱 j ≤
        t.app i' ⁻¹ᵁ
          (↑(↑(↑(↑j :
                            { x :
                              TopologicalSpace.Opens ↥c.pt ×
                                { x : TopologicalSpace.Opens ↥X × (↑S.affineOpens : Type u) //
                                  x.1 ∈ X.affineOpens ∧
                                    x.1 ≤
                                      (Opens.comap (TopCat.Hom.hom f.base) :
                                          (a : TopologicalSpace.Opens ↥S) → TopologicalSpace.Opens ↥X)
                                        (↑x.2 : TopologicalSpace.Opens ↥S) } //
                              x.1 ∈ c.pt.affineOpens ∧
                                x.1 ≤
                                  (Opens.comap (TopCat.Hom.hom a.base) :
                                      (a : TopologicalSpace.Opens ↥X) → TopologicalSpace.Opens ↥c.pt)
                                    (↑x.2 : TopologicalSpace.Opens ↥X × (↑S.affineOpens : Type u)).1 }) :
                        TopologicalSpace.Opens ↥c.pt ×
                          { x : TopologicalSpace.Opens ↥X × (↑S.affineOpens : Type u) //
                            x.1 ∈ X.affineOpens ∧
                              x.1 ≤
                                (Opens.comap (TopCat.Hom.hom f.base) :
                                    (a : TopologicalSpace.Opens ↥S) → TopologicalSpace.Opens ↥X)
                                  (↑x.2 : TopologicalSpace.Opens ↥S) }).2 :
                  TopologicalSpace.Opens ↥X × (↑S.affineOpens : Type u)).2 :
            TopologicalSpace.Opens ↥S)
have choose : ∀ (k : (j : ↥s) → I) (fk : (j : ↥s) → k j ⟶ i)
  (hk :
    ∀ (j : ↥s),
      D.map (fk j) ⁻¹ᵁ 𝒱 j ≤
        D.map (fk j) ⁻¹ᵁ
          t.app i ⁻¹ᵁ
            (↑(↑(↑(↑j :
                              { x :
                                TopologicalSpace.Opens ↥c.pt ×
                                  { x : TopologicalSpace.Opens ↥X × (↑S.affineOpens : Type u) //
                                    x.1 ∈ X.affineOpens ∧
                                      x.1 ≤
                                        (Opens.comap (TopCat.Hom.hom f.base) :
                                            (a : TopologicalSpace.Opens ↥S) → TopologicalSpace.Opens ↥X)
                                          (↑x.2 : TopologicalSpace.Opens ↥S) } //
                                x.1 ∈ c.pt.affineOpens ∧
                                  x.1 ≤
                                    (Opens.comap (TopCat.Hom.hom a.base) :
                                        (a : TopologicalSpace.Opens ↥X) → TopologicalSpace.Opens ↥c.pt)
                                      (↑x.2 : TopologicalSpace.Opens ↥X × (↑S.affineOpens : Type u)).1 }) :
                          TopologicalSpace.Opens ↥c.pt ×
                            { x : TopologicalSpace.Opens ↥X × (↑S.affineOpens : Type u) //
                              x.1 ∈ X.affineOpens ∧
                                x.1 ≤
                                  (Opens.comap (TopCat.Hom.hom f.base) :
                                      (a : TopologicalSpace.Opens ↥S) → TopologicalSpace.Opens ↥X)
                                    (↑x.2 : TopologicalSpace.Opens ↥S) }).2 :
                    TopologicalSpace.Opens ↥X × (↑S.affineOpens : Type u)).2 :
              TopologicalSpace.Opens ↥S)),
  ∃ (i' : I) (fi'i : i' ⟶ i),
    ∀ (j : ↥s),
      D.map fi'i ⁻¹ᵁ 𝒱 j ≤
        t.app i' ⁻¹ᵁ
          (↑(↑(↑(↑j :
                            { x :
                              TopologicalSpace.Opens ↥c.pt ×
                                { x : TopologicalSpace.Opens ↥X × (↑S.affineOpens : Type u) //
                                  x.1 ∈ X.affineOpens ∧
                                    x.1 ≤
                                      (Opens.comap (TopCat.Hom.hom f.base) :
                                          (a : TopologicalSpace.Opens ↥S) → TopologicalSpace.Opens ↥X)
                                        (↑x.2 : TopologicalSpace.Opens ↥S) } //
                              x.1 ∈ c.pt.affineOpens ∧
                                x.1 ≤
                                  (Opens.comap (TopCat.Hom.hom a.base) :
                                      (a : TopologicalSpace.Opens ↥X) → TopologicalSpace.Opens ↥c.pt)
                                    (↑x.2 : TopologicalSpace.Opens ↥X × (↑S.affineOpens : Type u)).1 }) :
                        TopologicalSpace.Opens ↥c.pt ×
                          { x : TopologicalSpace.Opens ↥X × (↑S.affineOpens : Type u) //
                            x.1 ∈ X.affineOpens ∧
                              x.1 ≤
                                (Opens.comap (TopCat.Hom.hom f.base) :
                                    (a : TopologicalSpace.Opens ↥S) → TopologicalSpace.Opens ↥X)
                                  (↑x.2 : TopologicalSpace.Opens ↥S) }).2 :
                  TopologicalSpace.Opens ↥X × (↑S.affineOpens : Type u)).2 :
            TopologicalSpace.Opens ↥S)
Tactic: choose k fk hk using fun j ↦ exists_map_preimage_le_map_preimage D c hc (h𝒱𝒰 j).1.isCompact
      (V := t.app i ⁻¹ᵁ j.1.1.2.1.2.1) (by
      rw [← Hom.comp_preimage, ← NatTrans.comp_app, ha]
      exact (h𝒱𝒰 j).2.symm.trans_le (j.1.prop.2.trans (a.preimage_mono j.1.1.2.prop.2)))