theorem sourceAffineLocally_of_source_openCover {X Y : Scheme} (f : X ⟶ Y) [IsAffine Y]
    (𝒰 : X.OpenCover) [∀ i, IsAffine (𝒰.obj i)] (H : ∀ i, P (Scheme.Γ.map (𝒰.map i ≫ f).op)) :
    sourceAffineLocally (@P) f := by
  let S i := (⟨⟨Set.range (𝒰.map i).1.base, (𝒰.IsOpen i).base_open.open_range⟩,
    rangeIsAffineOpenOfOpenImmersion (𝒰.map i)⟩ : X.affineOpens)
  intro U
  -- Porting note: here is what we are eliminating into Lean
  apply of_affine_open_cover
    (P := fun V => P (Scheme.Γ.map (X.ofRestrict (Opens.openEmbedding V.val) ≫ f).op)) U
  pick_goal 5
  · exact Set.range S
  · intro U r H
    -- Porting note: failing on instance synthesis for an (unspecified) meta variable
    -- made φ explicit and forced to use dsimp in the proof
    convert hP.StableUnderComposition
      (S := Scheme.Γ.obj (Opposite.op (X.restrict <| Opens.openEmbedding U.val)))
      (T := Scheme.Γ.obj (Opposite.op (X.restrict <| Opens.openEmbedding (X.basicOpen r))))
      ?_ ?_ H ?_ using 1
    swap
    · refine' X.presheaf.map
          (@homOfLE _ _ ((IsOpenMap.functor _).obj _) ((IsOpenMap.functor _).obj _) _).op
      rw [unop_op, unop_op, Opens.openEmbedding_obj_top, Opens.openEmbedding_obj_top]
      exact X.basicOpen_le _
    · rw [op_comp, op_comp, Functor.map_comp, Functor.map_comp]
      refine' (Eq.trans _ (Category.assoc (obj := CommRingCat) _ _ _).symm : _)
      congr 1
      dsimp
      refine' Eq.trans _ (X.presheaf.map_comp _ _)
      change X.presheaf.map _ = _
      congr!
    -- Porting note: need to pass Algebra through explicitly
    convert @HoldsForLocalizationAway _ hP _
      (Scheme.Γ.obj (Opposite.op (X.restrict (X.basicOpen r).openEmbedding))) _ _ ?_
      (X.presheaf.map (eqToHom U.1.openEmbedding_obj_top).op r) ?_
    · exact RingHom.algebraMap_toAlgebra
        (R := Scheme.Γ.obj <| Opposite.op <| X.restrict (U.1.openEmbedding))
        (S :=
          Scheme.Γ.obj (Opposite.op <| X.restrict (X.affineBasicOpen r).1.openEmbedding)) _|>.symm
    · dsimp [Scheme.Γ]
      have := U.2
      rw [← U.1.openEmbedding_obj_top] at this
      -- Porting note: the second argument of `IsLocalization.Away` is a type, and we want
      -- to generate an equality, so using `typeEqs := true` to force allowing type equalities.
      convert (config := {typeEqs := true, transparency := .default})
          this.isLocalization_basicOpen _ using 5
      all_goals rw [Opens.openEmbedding_obj_top]; 

Proof state:
case h.e'_6.e'_5.h.e'_8.e'_3
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
X Y : Scheme
f : X ⟶ Y
inst✝¹ : IsAffine Y
𝒰 : Scheme.OpenCover X
inst✝ : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)
H✝ : ∀ (i : 𝒰.J), P (Scheme.Γ.map (Scheme.OpenCover.map 𝒰 i ≫ f).op)
S : 𝒰.J → { x // x ∈ Scheme.affineOpens X } :=
  fun i =>
    {
      val :=
        { carrier := Set.range ⇑(Scheme.OpenCover.map 𝒰 i).val.base,
          is_open' := (_ : IsOpen (Set.range ⇑(Scheme.OpenCover.map 𝒰 i).val.base)) },
      property := (_ : IsAffineOpen (Scheme.Hom.opensRange (Scheme.OpenCover.map 𝒰 i))) }
U✝ U : ↑(Scheme.affineOpens X)
r : ↑(X.presheaf.obj (Opposite.op ↑U))
H : P (Scheme.Γ.map (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)) ≫ f).op)
this : (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤ ∈ Scheme.affineOpens X
e_4✝¹ :
  ↑(X.presheaf.obj (Opposite.op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion (X.basicOpen r)))).obj ⊤))) =
    ↑(X.presheaf.obj
        (Opposite.op
          (X.basicOpen
            ((X.presheaf.map (eqToHom (_ : (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤ = ↑U)).op)
              r))))
e_5✝ : HEq CommRing.toCommSemiring CommRing.toCommSemiring
e_1✝ :
  ↑(X.presheaf.obj (Opposite.op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤))) =
    ↑(X.presheaf.obj (Opposite.op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤)))
e_2✝ :
  ↑(X.presheaf.obj (Opposite.op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion (X.basicOpen r)))).obj ⊤))) =
    ↑(X.presheaf.obj
        (Opposite.op
          (X.basicOpen
            ((X.presheaf.map (eqToHom (_ : (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤ = ↑U)).op)
              r))))
he✝ : CommRing.toCommSemiring = CommRing.toCommSemiring
e_4✝ : HEq CommRing.toCommSemiring CommRing.toCommSemiring
e_7✝ :
  Opposite.op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion (X.basicOpen r)))).obj ⊤) =
    Opposite.op
      (X.basicOpen
        ((X.presheaf.map (eqToHom (_ : (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤ = ↑U)).op) r))
⊢ X.basicOpen r =
    X.basicOpen
      ((X.presheaf.map (eqToHom (_ : (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤ = ↑U)).op) r)

Next tactic:
exact (Scheme.basicOpen_res_eq _ _ _).symm