theorem AffineTargetMorphismProperty.IsLocal.targetAffineLocallyIsLocal
    {P : AffineTargetMorphismProperty} (hP : P.IsLocal) :
    PropertyIsLocalAtTarget (targetAffineLocally P) := by
  constructor
  · exact targetAffineLocally_respectsIso hP.1
  · intro X Y f U H V
    rw [← P.toProperty_apply (i := V.2), hP.1.arrow_mk_iso_iff (morphismRestrictRestrict f _ _)]
    convert H ⟨_, IsAffineOpen.imageIsOpenImmersion V.2 (Y.ofRestrict _)⟩
    rw [← P.toProperty_apply (i := IsAffineOpen.imageIsOpenImmersion V.2 (Y.ofRestrict _))]
  · rintro X Y f 𝒰 h𝒰
    -- Porting note : rewrite `[(hP.affine_openCover_TFAE f).out 0 1` directly complains about
    -- metavariables
    have h01 := (hP.affine_openCover_TFAE f).out 0 1
    rw [h01]
    refine' ⟨𝒰.bind fun _ => Scheme.affineCover _, _, _⟩
    · intro i; dsimp [Scheme.OpenCover.bind]; infer_instance
    · intro i
      specialize h𝒰 i.1
      -- Porting note : rewrite `[(hP.affine_openCover_TFAE pullback.snd).out 0 1` directly
      -- complains about metavariables
      have h02 := (hP.affine_openCover_TFAE (pullback.snd : pullback f (𝒰.map i.fst) ⟶ _)).out 0 2
      rw [h02] at h𝒰
      specialize h𝒰 (Scheme.affineCover _) i.2
      let e : pullback f ((𝒰.obj i.fst).affineCover.map i.snd ≫ 𝒰.map i.fst) ⟶
          pullback (pullback.snd : pullback f (𝒰.map i.fst) ⟶ _)
            ((𝒰.obj i.fst).affineCover.map i.snd) := by
        refine' (pullbackSymmetry _ _).hom ≫ _
        refine' (pullbackRightPullbackFstIso _ _ _).inv ≫ _
        refine' (pullbackSymmetry _ _).hom ≫ _
        refine' pullback.map _ _ _ _ (pullbackSymmetry _ _).hom (𝟙 _) (𝟙 _) _ _ <;>
        simp only [Category.comp_id, Category.id_comp, pullbackSymmetry_hom_comp_snd]
      rw [← affine_cancel_left_isIso hP.1 e] at h𝒰
      convert h𝒰 using 1
      

Proof state:
case h.e'_3.h
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover Y
h01 :
  targetAffineLocally P f ↔ ∃ 𝒰, ∃ (x : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)), ∀ (i : 𝒰.J), P pullback.snd
i : (Scheme.OpenCover.bind 𝒰 fun x => Scheme.affineCover (Scheme.OpenCover.obj 𝒰 x)).J
h02 :
  targetAffineLocally P pullback.snd ↔
    ∀ (𝒰_1 : Scheme.OpenCover (Scheme.OpenCover.obj 𝒰 i.fst))
      [inst : ∀ (i_1 : 𝒰_1.J), IsAffine (Scheme.OpenCover.obj 𝒰_1 i_1)] (i_1 : 𝒰_1.J), P pullback.snd
e : pullback f
    (Scheme.OpenCover.map (Scheme.affineCover (Scheme.OpenCover.obj 𝒰 i.fst)) i.snd ≫ Scheme.OpenCover.map 𝒰 i.fst) ⟶
  pullback pullback.snd (Scheme.OpenCover.map (Scheme.affineCover (Scheme.OpenCover.obj 𝒰 i.fst)) i.snd) :=
  (pullbackSymmetry f
        (Scheme.OpenCover.map (Scheme.affineCover (Scheme.OpenCover.obj 𝒰 i.fst)) i.snd ≫
          Scheme.OpenCover.map 𝒰 i.fst)).hom ≫
    (pullbackRightPullbackFstIso (Scheme.OpenCover.map 𝒰 i.fst) f
          (Scheme.OpenCover.map (Scheme.affineCover (Scheme.OpenCover.obj 𝒰 i.fst)) i.snd)).inv ≫
      (pullbackSymmetry (Scheme.OpenCover.map (Scheme.affineCover (Scheme.OpenCover.obj 𝒰 i.fst)) i.snd)
            pullback.fst).hom ≫
        pullback.map pullback.fst (Scheme.OpenCover.map (Scheme.affineCover (Scheme.OpenCover.obj 𝒰 i.fst)) i.snd)
          pullback.snd (Scheme.OpenCover.map (Scheme.affineCover (Scheme.OpenCover.obj 𝒰 i.fst)) i.snd)
          (pullbackSymmetry (Scheme.OpenCover.map 𝒰 i.fst) f).hom
          (𝟙 (Scheme.OpenCover.obj (Scheme.affineCover (Scheme.OpenCover.obj 𝒰 i.fst)) i.snd))
          (𝟙 (Scheme.OpenCover.obj 𝒰 i.fst))
          (_ :
            pullback.fst ≫ 𝟙 (Scheme.OpenCover.obj 𝒰 i.fst) =
              (pullbackSymmetry (Scheme.OpenCover.map 𝒰 i.fst) f).hom ≫ pullback.snd)
          (_ :
            Scheme.OpenCover.map (Scheme.affineCover (Scheme.OpenCover.obj 𝒰 i.fst)) i.snd ≫
                𝟙 (Scheme.OpenCover.obj 𝒰 i.fst) =
              𝟙 (Scheme.OpenCover.obj (Scheme.affineCover (Scheme.OpenCover.obj 𝒰 i.fst)) i.snd) ≫
                Scheme.OpenCover.map (Scheme.affineCover (Scheme.OpenCover.obj 𝒰 i.fst)) i.snd)
h𝒰 : P (e ≫ pullback.snd)
e_1✝ :
  pullback f (Scheme.OpenCover.map (Scheme.OpenCover.bind 𝒰 fun x => Scheme.affineCover (Scheme.OpenCover.obj 𝒰 x)) i) =
    pullback f
      (Scheme.OpenCover.map (Scheme.affineCover (Scheme.OpenCover.obj 𝒰 i.fst)) i.snd ≫ Scheme.OpenCover.map 𝒰 i.fst)
e_2✝ :
  Scheme.OpenCover.obj (Scheme.OpenCover.bind 𝒰 fun x => Scheme.affineCover (Scheme.OpenCover.obj 𝒰 x)) i =
    Scheme.OpenCover.obj (Scheme.affineCover (Scheme.OpenCover.obj 𝒰 i.fst)) i.snd
⊢ pullback.snd = e ≫ pullback.snd

Next tactic:
simp