-- Lean 4 proof step from Mathlib.AlgebraicGeometry.Morphisms.Separated (hypothesis)
Goal:
X Y : Scheme
f : X ⟶ Y
𝒰 : Y.OpenCover
𝒱 : (i : 𝒰.I₀) → OpenCover.{u_1, u} (pullback f (𝒰.f i))
inst : ∀ (i : 𝒰.I₀), IsAffine.{u} (𝒰.X i)
inst_1 : ∀ (i : 𝒰.I₀) (j : (𝒱 i).I₀), IsAffine.{u} ((𝒱 i).X j)
U : (i : 𝒰.I₀) × (𝒱 i).I₀ → (↑(diagonalCoverDiagonalRange f 𝒰 𝒱) : Scheme).Opens :=
  fun (i : (i : 𝒰.I₀) × (𝒱 i).I₀) ↦
    (diagonalCoverDiagonalRange f 𝒰 𝒱).ι ⁻¹ᵁ
      Hom.opensRange (X :=
        (diagonalCover f 𝒰 𝒱).X
          (Sigma.mk (β := fun (i : (openCoverOfBase 𝒰 f f).I₀) ↦
            PreZeroHypercover.I₀.{u_1, u, u + 1} (C := Scheme) (S := (openCoverOfBase 𝒰 f f).X i)
              ((fun (i : (openCoverOfBase 𝒰 f f).I₀) ↦
                  (Precoverage.ZeroHypercover.toPreZeroHypercover (J := precoverage IsOpenImmersion)
                      ((fun (i : (openCoverOfBase 𝒰 f f).I₀) ↦
                          (openCoverOfLeftRight (𝒱 i) (𝒱 i) (Cover.pullbackHom (P := IsOpenImmersion) 𝒰 f i)
                              (Cover.pullbackHom (P := IsOpenImmersion) 𝒰 f i) :
                            OpenCover.{u_1, u}
                              (pullback (X := (Precoverage.ZeroHypercover.pullback₁ f 𝒰).X i) (Y :=
                                (Precoverage.ZeroHypercover.pullback₁ f 𝒰).X i)
                                (Cover.pullbackHom (P := IsOpenImmersion) 𝒰 f i :
                                  (Precoverage.ZeroHypercover.pullback₁ f 𝒰).X i ⟶ 𝒰.X i)
                                (Cover.pullbackHom (P := IsOpenImmersion) 𝒰 f i :
                                  (Precoverage.ZeroHypercover.pullback₁ f 𝒰).X i ⟶ 𝒰.X i))))
                        i) :
                    PreZeroHypercover.{u_1, u, u + 1} ((openCoverOfBase 𝒰 f f).X i)))
                i))
            (i.fst (β := fun (i : 𝒰.I₀) ↦ (𝒱 i).I₀))
            (i.snd (β := fun (i : 𝒰.I₀) ↦ (𝒱 i).I₀), i.snd (β := fun (i : 𝒰.I₀) ↦ (𝒱 i).I₀))))
        ((diagonalCover f 𝒰 𝒱).f
          (Sigma.mk (β := fun (i : (openCoverOfBase 𝒰 f f).I₀) ↦
            PreZeroHypercover.I₀.{u_1, u, u + 1} (C := Scheme) (S := (openCoverOfBase 𝒰 f f).X i)
              ((fun (i : (openCoverOfBase 𝒰 f f).I₀) ↦
                  (Precoverage.ZeroHypercover.toPreZeroHypercover (J := precoverage IsOpenImmersion)
                      ((fun (i : (openCoverOfBase 𝒰 f f).I₀) ↦
                          (openCoverOfLeftRight (𝒱 i) (𝒱 i) (Cover.pullbackHom (P := IsOpenImmersion) 𝒰 f i)
                              (Cover.pullbackHom (P := IsOpenImmersion) 𝒰 f i) :
                            OpenCover.{u_1, u}
                              (pullback (X := (Precoverage.ZeroHypercover.pullback₁ f 𝒰).X i) (Y :=
                                (Precoverage.ZeroHypercover.pullback₁ f 𝒰).X i)
                                (Cover.pullbackHom (P := IsOpenImmersion) 𝒰 f i :
                                  (Precoverage.ZeroHypercover.pullback₁ f 𝒰).X i ⟶ 𝒰.X i)
                                (Cover.pullbackHom (P := IsOpenImmersion) 𝒰 f i :
                                  (Precoverage.ZeroHypercover.pullback₁ f 𝒰).X i ⟶ 𝒰.X i))))
                        i) :
                    PreZeroHypercover.{u_1, u, u + 1} ((openCoverOfBase 𝒰 f f).X i)))
                i))
            (i.fst (β := fun (i : 𝒰.I₀) ↦ (𝒱 i).I₀))
            (i.snd (β := fun (i : 𝒰.I₀) ↦ (𝒱 i).I₀), i.snd (β := fun (i : 𝒰.I₀) ↦ (𝒱 i).I₀))))
⊢ IsClosedImmersion (X := (↑(pullback.diagonal f ⁻¹ᵁ diagonalCoverDiagonalRange f 𝒰 𝒱) : Scheme))
    (pullback.diagonal f ∣_ diagonalCoverDiagonalRange f 𝒰 𝒱)
have hU : ∀ (i : (i : 𝒰.I₀) × (𝒱 i).I₀),
  (diagonalCoverDiagonalRange f 𝒰 𝒱).ι ''ᵁ U i =
    Hom.opensRange (X :=
      (diagonalCover f 𝒰 𝒱).X
        (Sigma.mk (β := fun (i : (openCoverOfBase 𝒰 f f).I₀) ↦
          PreZeroHypercover.I₀.{u_1, u, u + 1} (C := Scheme) (S := (openCoverOfBase 𝒰 f f).X i)
            ((fun (i : (openCoverOfBase 𝒰 f f).I₀) ↦
                (Precoverage.ZeroHypercover.toPreZeroHypercover (J := precoverage IsOpenImmersion)
                    ((fun (i : (openCoverOfBase 𝒰 f f).I₀) ↦
                        (openCoverOfLeftRight (𝒱 i) (𝒱 i) (Cover.pullbackHom (P := IsOpenImmersion) 𝒰 f i)
                            (Cover.pullbackHom (P := IsOpenImmersion) 𝒰 f i) :
                          OpenCover.{u_1, u}
                            (pullback (X := (Precoverage.ZeroHypercover.pullback₁ f 𝒰).X i) (Y :=
                              (Precoverage.ZeroHypercover.pullback₁ f 𝒰).X i)
                              (Cover.pullbackHom (P := IsOpenImmersion) 𝒰 f i :
                                (Precoverage.ZeroHypercover.pullback₁ f 𝒰).X i ⟶ 𝒰.X i)
                              (Cover.pullbackHom (P := IsOpenImmersion) 𝒰 f i :
                                (Precoverage.ZeroHypercover.pullback₁ f 𝒰).X i ⟶ 𝒰.X i))))
                      i) :
                  PreZeroHypercover.{u_1, u, u + 1} ((openCoverOfBase 𝒰 f f).X i)))
              i))
          (i.fst (β := fun (i : 𝒰.I₀) ↦ (𝒱 i).I₀))
          (i.snd (β := fun (i : 𝒰.I₀) ↦ (𝒱 i).I₀), i.snd (β := fun (i : 𝒰.I₀) ↦ (𝒱 i).I₀))))
      ((diagonalCover f 𝒰 𝒱).f
        (Sigma.mk (β := fun (i : (openCoverOfBase 𝒰 f f).I₀) ↦
          PreZeroHypercover.I₀.{u_1, u, u + 1} (C := Scheme) (S := (openCoverOfBase 𝒰 f f).X i)
            ((fun (i : (openCoverOfBase 𝒰 f f).I₀) ↦
                (Precoverage.ZeroHypercover.toPreZeroHypercover (J := precoverage IsOpenImmersion)
                    ((fun (i : (openCoverOfBase 𝒰 f f).I₀) ↦
                        (openCoverOfLeftRight (𝒱 i) (𝒱 i) (Cover.pullbackHom (P := IsOpenImmersion) 𝒰 f i)
                            (Cover.pullbackHom (P := IsOpenImmersion) 𝒰 f i) :
                          OpenCover.{u_1, u}
                            (pullback (X := (Precoverage.ZeroHypercover.pullback₁ f 𝒰).X i) (Y :=
                              (Precoverage.ZeroHypercover.pullback₁ f 𝒰).X i)
                              (Cover.pullbackHom (P := IsOpenImmersion) 𝒰 f i :
                                (Precoverage.ZeroHypercover.pullback₁ f 𝒰).X i ⟶ 𝒰.X i)
                              (Cover.pullbackHom (P := IsOpenImmersion) 𝒰 f i :
                                (Precoverage.ZeroHypercover.pullback₁ f 𝒰).X i ⟶ 𝒰.X i))))
                      i) :
                  PreZeroHypercover.{u_1, u, u + 1} ((openCoverOfBase 𝒰 f f).X i)))
              i))
          (i.fst (β := fun (i : 𝒰.I₀) ↦ (𝒱 i).I₀))
          (i.snd (β := fun (i : 𝒰.I₀) ↦ (𝒱 i).I₀), i.snd (β := fun (i : 𝒰.I₀) ↦ (𝒱 i).I₀))))
Tactic: have hU (i) : (diagonalCoverDiagonalRange f 𝒰 𝒱).ι ''ᵁ U i =
      ((diagonalCover f 𝒰 𝒱).f ⟨i.1, i.2, i.2⟩).opensRange := by
    rw [Scheme.Hom.image_preimage_eq_opensRange_inf, inf_eq_right, Opens.opensRange_ι]
    exact le_iSup (fun i : Σ i, (𝒱 i).I₀ ↦ ((diagonalCover f 𝒰 𝒱).f ⟨i.1, i.2, i.2⟩).opensRange) i