theorem IsLocal.stableUnderBaseChange {P : AffineTargetMorphismProperty} (hP : P.IsLocal)
    (hP' : P.StableUnderBaseChange) : (targetAffineLocally P).StableUnderBaseChange :=
  MorphismProperty.StableUnderBaseChange.mk (targetAffineLocally_respectsIso hP.RespectsIso)
    (fun X Y S f g H => by
      -- Porting note : rewrite `(...openCover_TFAE).out 0 1` directly doesn't work, complains about
      -- metavariable
      have h01 := (hP.targetAffineLocallyIsLocal.openCover_TFAE
        (pullback.fst : pullback f g ⟶ X)).out 0 1
      rw [h01]
      use S.affineCover.pullbackCover f
      intro i
      -- Porting note : rewrite `(hP.affine_openCover_TFAE g).out 0 3` directly doesn't work
      -- complains about metavariable
      have h03 := (hP.affine_openCover_TFAE g).out 0 3
      rw [h03] at H
      let e : pullback (pullback.fst : pullback f g ⟶ _) ((S.affineCover.pullbackCover f).map i) ≅
          _ := by
        refine' pullbackSymmetry _ _ ≪≫ pullbackRightPullbackFstIso f g _ ≪≫ _ ≪≫
          (pullbackRightPullbackFstIso (S.affineCover.map i) g
            (pullback.snd : pullback f (S.affineCover.map i) ⟶ _)).symm
        exact asIso
          (pullback.map _ _ _ _ (𝟙 _) (𝟙 _) (𝟙 _) (by simpa using pullback.condition) (by simp))
      have : e.hom ≫ pullback.fst = pullback.snd := by simp
      rw [← this, (targetAffineLocally_respectsIso hP.1).cancel_left_isIso]
      apply hP.targetAffineLocallyPullbackFstOfRightOfStableUnderBaseChange hP'
      

Proof state:
case h.H
P : AffineTargetMorphismProperty
hP : IsLocal P
hP' : StableUnderBaseChange P
X Y S : Scheme
f : X ⟶ S
g : Y ⟶ S
H : ∀ {U : Scheme} (g_1 : U ⟶ S) [inst : IsAffine U] [inst_1 : IsOpenImmersion g_1], P pullback.snd
h01 : targetAffineLocally P pullback.fst ↔ ∃ 𝒰, ∀ (i : 𝒰.J), targetAffineLocally P pullback.snd
i : (Scheme.OpenCover.pullbackCover (Scheme.affineCover S) f).J
h03 :
  targetAffineLocally P g ↔
    ∀ {U : Scheme} (g_1 : U ⟶ S) [inst : IsAffine U] [inst_1 : IsOpenImmersion g_1], P pullback.snd
e : pullback pullback.fst (Scheme.OpenCover.map (Scheme.OpenCover.pullbackCover (Scheme.affineCover S) f) i) ≅
  pullback pullback.snd pullback.fst :=
  pullbackSymmetry pullback.fst (Scheme.OpenCover.map (Scheme.OpenCover.pullbackCover (Scheme.affineCover S) f) i) ≪≫
    pullbackRightPullbackFstIso f g
        (Scheme.OpenCover.map (Scheme.OpenCover.pullbackCover (Scheme.affineCover S) f) i) ≪≫
      asIso
          (pullback.map (Scheme.OpenCover.map (Scheme.OpenCover.pullbackCover (Scheme.affineCover S) f) i ≫ f) g
            (pullback.snd ≫ Scheme.OpenCover.map (Scheme.affineCover S) i) g
            (𝟙 (Scheme.OpenCover.obj (Scheme.OpenCover.pullbackCover (Scheme.affineCover S) f) i)) (𝟙 Y) (𝟙 S)
            (_ :
              (Scheme.OpenCover.map (Scheme.OpenCover.pullbackCover (Scheme.affineCover S) f) i ≫ f) ≫ 𝟙 S =
                𝟙 (Scheme.OpenCover.obj (Scheme.OpenCover.pullbackCover (Scheme.affineCover S) f) i) ≫
                  pullback.snd ≫ Scheme.OpenCover.map (Scheme.affineCover S) i)
            (_ : g ≫ 𝟙 S = 𝟙 Y ≫ g)) ≪≫
        (pullbackRightPullbackFstIso (Scheme.OpenCover.map (Scheme.affineCover S) i) g pullback.snd).symm
this : e.hom ≫ pullback.fst = pullback.snd
⊢ P pullback.fst

Next tactic:
rw [← pullbackSymmetry_hom_comp_snd, affine_cancel_left_isIso hP.1]