-- Module: Mathlib.AlgebraicGeometry.AffineTransitionLimit
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
hi' :
  ∀ (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)
k : I
fki : k ⟶ i
ak : (j : ↥s) → (↑(D.map fki ⁻¹ᵁ 𝒱 j) : Scheme) ⟶ X
hak : ∀ (j : ↥s), ak j ≫ f = (D.map fki ⁻¹ᵁ 𝒱 j).ι ≫ t.app k
hak' : ∀ (j : ↥s), c.π.app k ∣_ D.map fki ⁻¹ᵁ 𝒱 j ≫ ak j = (c.π.app k ⁻¹ᵁ D.map fki ⁻¹ᵁ 𝒱 j).ι ≫ a
𝒱' : ↥s → (D.obj k).Opens := fun (x : ↥s) ↦ D.map fki ⁻¹ᵁ 𝒱 x
j₁ j₂ : ↥s
h : ∀ (x : Over k), CompactSpace.{u} ↥((opensDiagram D k (𝒱' j₁ ⊓ 𝒱' j₂)).obj x)
obtain :
  ∀ (l : I) (flk : Functor.obj (𝟭 I) l ⟶ Functor.obj (Functor.fromPUnit k) { as := PUnit.unit : Discrete PUnit.{1} })
    (flk' :
      { left := l, right := { as := PUnit.unit : Discrete PUnit.{1} }, hom := flk :
            Comma (𝟭 I) (Functor.fromPUnit k) }.left ⟶
        Comma.left (Over.mk (𝟙 k)))
    (h :
      CategoryTheory.Functor.map (𝟭 I) flk' ≫ Comma.hom (Over.mk (𝟙 k)) =
        { left := l, right := { as := PUnit.unit : Discrete PUnit.{1} }, hom := flk :
              Comma (𝟭 I) (Functor.fromPUnit k) }.hom ≫
          CategoryTheory.Functor.map (Functor.fromPUnit k) { down := { down := ⋯ } })
    (e :
      (opensDiagram D k (𝒱' j₁ ⊓ 𝒱' j₂)).map
            { left := flk',
              right :=
                {
                  down :=
                    { down := ⋯ :
                      PLift
                        ({ left := l, right := { as := PUnit.unit : Discrete PUnit.{1} }, hom := flk :
                                Comma (𝟭 I) (Functor.fromPUnit k) }.right.as =
                          (Comma.right (Over.mk (𝟙 k))).as) } :
                  ULift.{0, 0}
                    (PLift
                      ({ left := l, right := { as := PUnit.unit : Discrete PUnit.{1} }, hom := flk :
                              Comma (𝟭 I) (Functor.fromPUnit k) }.right.as =
                        (Comma.right (Over.mk (𝟙 k))).as)) },
              w := h :
              CommaMorphism
                { left := l, right := { as := PUnit.unit : Discrete PUnit.{1} }, hom := flk :
                  Comma (𝟭 I) (Functor.fromPUnit k) }
                (Over.mk (𝟙 k)) } ≫
          (D.obj (Over.left (Over.mk (𝟙 k)))).homOfLE ⋯ ≫ ak j₁ =
        (opensDiagram D k (𝒱' j₁ ⊓ 𝒱' j₂)).map
            { left := flk',
              right :=
                {
                  down :=
                    { down := ⋯ :
                      PLift
                        ({ left := l, right := { as := PUnit.unit : Discrete PUnit.{1} }, hom := flk :
                                Comma (𝟭 I) (Functor.fromPUnit k) }.right.as =
                          (Comma.right (Over.mk (𝟙 k))).as) } :
                  ULift.{0, 0}
                    (PLift
                      ({ left := l, right := { as := PUnit.unit : Discrete PUnit.{1} }, hom := flk :
                              Comma (𝟭 I) (Functor.fromPUnit k) }.right.as =
                        (Comma.right (Over.mk (𝟙 k))).as)) },
              w := h :
              CommaMorphism
                { left := l, right := { as := PUnit.unit : Discrete PUnit.{1} }, hom := flk :
                  Comma (𝟭 I) (Functor.fromPUnit k) }
                (Over.mk (𝟙 k)) } ≫
          (D.obj (Over.left (Over.mk (𝟙 k)))).homOfLE ⋯ ≫ ak j₂),
    ∃ (l : I) (flk : l ⟶ k),
      (D.obj l).homOfLE ⋯ ≫ D.map flk ∣_ D.map fki ⁻¹ᵁ 𝒱 j₁ ≫ ak j₁ =
        (D.obj l).homOfLE ⋯ ≫ D.map flk ∣_ D.map fki ⁻¹ᵁ 𝒱 j₂ ≫ ak j₂
⊢ ∃ (l : I) (flk : l ⟶ k),
    (D.obj l).homOfLE ⋯ ≫ D.map flk ∣_ D.map fki ⁻¹ᵁ 𝒱 j₁ ≫ ak j₁ =
      (D.obj l).homOfLE ⋯ ≫ D.map flk ∣_ D.map fki ⁻¹ᵁ 𝒱 j₂ ≫ ak j₂

Tactic:
obtain ⟨⟨l, ⟨⟨⟩⟩, flk⟩, ⟨flk', ⟨⟨⟨⟩⟩⟩, h⟩, e⟩ :=
        Scheme.exists_hom_comp_eq_comp_of_locallyOfFiniteType _
          (opensDiagramι .. ≫ (Over.forget k).whiskerLeft t) f _
          (isLimitOpensCone D c hc k (𝒱' j₁ ⊓ 𝒱' j₂)) (i := .mk (𝟙 k))
          (Scheme.homOfLE _ (by simp [𝒱']) ≫ ak j₁) (Scheme.homOfLE _ (by simp [𝒱']) ≫ ak j₂)
          (by simp [hak]) (by simp [hak]) (by simp; simp [Hom.resLE, hak'])

Premises used: AlgebraicGeometry.Scheme.homOfLE, AlgebraicGeometry.Scheme.exists_hom_comp_eq_comp_of_locallyOfFiniteType, AlgebraicGeometry.isLimitOpensCone, CategoryTheory.Over.forget, CategoryTheory.Functor.whiskerLeft, CategoryTheory.CategoryStruct.comp, AlgebraicGeometry.opensDiagramι, Min.min