l3lab/ntp-mathlib huggingface dataset:
open List in
theorem PropertyIsLocalAtTarget.openCover_TFAE {P : MorphismProperty Scheme}
    (hP : PropertyIsLocalAtTarget P) {X Y : Scheme.{u}} (f : X ⟶ Y) :
    TFAE
      [P f,
        ∃ 𝒰 : Scheme.OpenCover.{u} Y,
          ∀ i : 𝒰.J, P (pullback.snd : (𝒰.pullbackCover f).obj i ⟶ 𝒰.obj i),
        ∀ (𝒰 : Scheme.OpenCover.{u} Y) (i : 𝒰.J),
          P (pullback.snd : (𝒰.pullbackCover f).obj i ⟶ 𝒰.obj i),
        ∀ U : Opens Y.carrier, P (f ∣_ U),
        ∀ {U : Scheme} (g : U ⟶ Y) [IsOpenImmersion g], P (pullback.snd : pullback f g ⟶ U),
        ∃ (ι : Type u) (U : ι → Opens Y.carrier) (_ : iSup U = ⊤), ∀ i, P (f ∣_ U i)] := by
  tfae_have 2 → 1
  · rintro ⟨𝒰, H⟩; exact hP.3 f 𝒰 H
  tfae_have 1 → 4
  · intro H U; exact hP.2 f U H
  tfae_have 4 → 3
  · intro H 𝒰 i
    rw [← hP.1.arrow_mk_iso_iff (morphismRestrictOpensRange f _)]
    exact H <| Scheme.Hom.opensRange (𝒰.map i)
  tfae_have 3 → 2
  · exact fun H => ⟨Y.affineCover, H Y.affineCover⟩
  tfae_have 4 → 5
  · intro H U g hg
    rw [← hP.1.arrow_mk_iso_iff (morphismRestrictOpensRange f _)]
    apply H
  tfae_have 5 → 4
  · intro H U
    erw [hP.1.cancel_left_isIso]
    apply H
  tfae_have 4 → 6
  · intro H; exact ⟨PUnit, fun _ => ⊤, ciSup_const, fun _ => H _⟩
  tfae_have 6 → 2
  · rintro ⟨ι, U, hU, H⟩
    refine' ⟨Y.openCoverOfSuprEqTop U hU, _⟩
    intro i
    rw [← hP.1.arrow_mk_iso_iff (morphismRestrictOpensRange f _)]
    convert H i
    all_goals 

Proof state:
case h.e'_3.e'_4
P : MorphismProperty Scheme
hP : PropertyIsLocalAtTarget P
X Y : Scheme
f : X ⟶ Y
tfae_2_to_1 : (∃ 𝒰, ∀ (i : 𝒰.J), P pullback.snd) → P f
tfae_1_to_4 : P f → ∀ (U : Opens ↑↑Y.toPresheafedSpace), P (f ∣_ U)
tfae_4_to_3 : (∀ (U : Opens ↑↑Y.toPresheafedSpace), P (f ∣_ U)) → ∀ (𝒰 : Scheme.OpenCover Y) (i : 𝒰.J), P pullback.snd
tfae_3_to_2 : (∀ (𝒰 : Scheme.OpenCover Y) (i : 𝒰.J), P pullback.snd) → ∃ 𝒰, ∀ (i : 𝒰.J), P pullback.snd
tfae_4_to_5 :
  (∀ (U : Opens ↑↑Y.toPresheafedSpace), P (f ∣_ U)) →
    ∀ {U : Scheme} (g : U ⟶ Y) [inst : IsOpenImmersion g], P pullback.snd
tfae_5_to_4 :
  (∀ {U : Scheme} (g : U ⟶ Y) [inst : IsOpenImmersion g], P pullback.snd) →
    ∀ (U : Opens ↑↑Y.toPresheafedSpace), P (f ∣_ U)
tfae_4_to_6 : (∀ (U : Opens ↑↑Y.toPresheafedSpace), P (f ∣_ U)) → ∃ ι U, ∃ (_ : iSup U = ⊤), ∀ (i : ι), P (f ∣_ U i)
ι : Type u
U : ι → Opens ↑↑Y.toPresheafedSpace
hU : iSup U = ⊤
H : ∀ (i : ι), P (f ∣_ U i)
i : (Scheme.openCoverOfSuprEqTop Y U hU).J
e_1✝ : X ∣_ᵤ f⁻¹ᵁ Scheme.Hom.opensRange (Scheme.OpenCover.map (Scheme.openCoverOfSuprEqTop Y U hU) i) = X ∣_ᵤ f⁻¹ᵁ U i
e_2✝ : Y ∣_ᵤ Scheme.Hom.opensRange (Scheme.OpenCover.map (Scheme.openCoverOfSuprEqTop Y U hU) i) = Y ∣_ᵤ U i
⊢ Scheme.Hom.opensRange (Scheme.OpenCover.map (Scheme.openCoverOfSuprEqTop Y U hU) i) = U i

Next tactic:
ext1
open List in
theorem PropertyIsLocalAtTarget.openCover_TFAE {P : MorphismProperty Scheme}
    (hP : PropertyIsLocalAtTarget P) {X Y : Scheme.{u}} (f : X ⟶ Y) :
    TFAE
      [P f,
        ∃ 𝒰 : Scheme.OpenCover.{u} Y,
          ∀ i : 𝒰.J, P (pullback.snd : (𝒰.pullbackCover f).obj i ⟶ 𝒰.obj i),
        ∀ (𝒰 : Scheme.OpenCover.{u} Y) (i : 𝒰.J),
          P (pullback.snd : (𝒰.pullbackCover f).obj i ⟶ 𝒰.obj i),
        ∀ U : Opens Y.carrier, P (f ∣_ U),
        ∀ {U : Scheme} (g : U ⟶ Y) [IsOpenImmersion g], P (pullback.snd : pullback f g ⟶ U),
        ∃ (ι : Type u) (U : ι → Opens Y.carrier) (_ : iSup U = ⊤), ∀ i, P (f ∣_ U i)] := by
  tfae_have 2 → 1
  · rintro ⟨𝒰, H⟩; exact hP.3 f 𝒰 H
  tfae_have 1 → 4
  · intro H U; exact hP.2 f U H
  tfae_have 4 → 3
  · intro H 𝒰 i
    rw [← hP.1.arrow_mk_iso_iff (morphismRestrictOpensRange f _)]
    exact H <| Scheme.Hom.opensRange (𝒰.map i)
  tfae_have 3 → 2
  · exact fun H => ⟨Y.affineCover, H Y.affineCover⟩
  tfae_have 4 → 5
  · intro H U g hg
    rw [← hP.1.arrow_mk_iso_iff (morphismRestrictOpensRange f _)]
    apply H
  tfae_have 5 → 4
  · intro H U
    erw [hP.1.cancel_left_isIso]
    apply H
  tfae_have 4 → 6
  · intro H; exact ⟨PUnit, fun _ => ⊤, ciSup_const, fun _ => H _⟩
  tfae_have 6 → 2
  · rintro ⟨ι, U, hU, H⟩
    refine' ⟨Y.openCoverOfSuprEqTop U hU, _⟩
    intro i
    rw [← hP.1.arrow_mk_iso_iff (morphismRestrictOpensRange f _)]
    convert H i
    all_goals ext1; 

Proof state:
case h.e'_3.e'_4.h
P : MorphismProperty Scheme
hP : PropertyIsLocalAtTarget P
X Y : Scheme
f : X ⟶ Y
tfae_2_to_1 : (∃ 𝒰, ∀ (i : 𝒰.J), P pullback.snd) → P f
tfae_1_to_4 : P f → ∀ (U : Opens ↑↑Y.toPresheafedSpace), P (f ∣_ U)
tfae_4_to_3 : (∀ (U : Opens ↑↑Y.toPresheafedSpace), P (f ∣_ U)) → ∀ (𝒰 : Scheme.OpenCover Y) (i : 𝒰.J), P pullback.snd
tfae_3_to_2 : (∀ (𝒰 : Scheme.OpenCover Y) (i : 𝒰.J), P pullback.snd) → ∃ 𝒰, ∀ (i : 𝒰.J), P pullback.snd
tfae_4_to_5 :
  (∀ (U : Opens ↑↑Y.toPresheafedSpace), P (f ∣_ U)) →
    ∀ {U : Scheme} (g : U ⟶ Y) [inst : IsOpenImmersion g], P pullback.snd
tfae_5_to_4 :
  (∀ {U : Scheme} (g : U ⟶ Y) [inst : IsOpenImmersion g], P pullback.snd) →
    ∀ (U : Opens ↑↑Y.toPresheafedSpace), P (f ∣_ U)
tfae_4_to_6 : (∀ (U : Opens ↑↑Y.toPresheafedSpace), P (f ∣_ U)) → ∃ ι U, ∃ (_ : iSup U = ⊤), ∀ (i : ι), P (f ∣_ U i)
ι : Type u
U : ι → Opens ↑↑Y.toPresheafedSpace
hU : iSup U = ⊤
H : ∀ (i : ι), P (f ∣_ U i)
i : (Scheme.openCoverOfSuprEqTop Y U hU).J
e_1✝ : X ∣_ᵤ f⁻¹ᵁ Scheme.Hom.opensRange (Scheme.OpenCover.map (Scheme.openCoverOfSuprEqTop Y U hU) i) = X ∣_ᵤ f⁻¹ᵁ U i
e_2✝ : Y ∣_ᵤ Scheme.Hom.opensRange (Scheme.OpenCover.map (Scheme.openCoverOfSuprEqTop Y U hU) i) = Y ∣_ᵤ U i
⊢ ↑(Scheme.Hom.opensRange (Scheme.OpenCover.map (Scheme.openCoverOfSuprEqTop Y U hU) i)) = ↑(U i)

Next tactic:
exact Subtype.range_coe
open List in
theorem PropertyIsLocalAtTarget.openCover_TFAE {P : MorphismProperty Scheme}
    (hP : PropertyIsLocalAtTarget P) {X Y : Scheme.{u}} (f : X ⟶ Y) :
    TFAE
      [P f,
        ∃ 𝒰 : Scheme.OpenCover.{u} Y,
          ∀ i : 𝒰.J, P (pullback.snd : (𝒰.pullbackCover f).obj i ⟶ 𝒰.obj i),
        ∀ (𝒰 : Scheme.OpenCover.{u} Y) (i : 𝒰.J),
          P (pullback.snd : (𝒰.pullbackCover f).obj i ⟶ 𝒰.obj i),
        ∀ U : Opens Y.carrier, P (f ∣_ U),
        ∀ {U : Scheme} (g : U ⟶ Y) [IsOpenImmersion g], P (pullback.snd : pullback f g ⟶ U),
        ∃ (ι : Type u) (U : ι → Opens Y.carrier) (_ : iSup U = ⊤), ∀ i, P (f ∣_ U i)] := by
  tfae_have 2 → 1
  · rintro ⟨𝒰, H⟩; exact hP.3 f 𝒰 H
  tfae_have 1 → 4
  · intro H U; exact hP.2 f U H
  tfae_have 4 → 3
  · intro H 𝒰 i
    rw [← hP.1.arrow_mk_iso_iff (morphismRestrictOpensRange f _)]
    exact H <| Scheme.Hom.opensRange (𝒰.map i)
  tfae_have 3 → 2
  · exact fun H => ⟨Y.affineCover, H Y.affineCover⟩
  tfae_have 4 → 5
  · intro H U g hg
    rw [← hP.1.arrow_mk_iso_iff (morphismRestrictOpensRange f _)]
    apply H
  tfae_have 5 → 4
  · intro H U
    erw [hP.1.cancel_left_isIso]
    apply H
  tfae_have 4 → 6
  · intro H; exact ⟨PUnit, fun _ => ⊤, ciSup_const, fun _ => H _⟩
  tfae_have 6 → 2
  · rintro ⟨ι, U, hU, H⟩
    refine' ⟨Y.openCoverOfSuprEqTop U hU, _⟩
    intro i
    rw [← hP.1.arrow_mk_iso_iff (morphismRestrictOpensRange f _)]
    convert H i
    all_goals ext1; exact Subtype.range_coe
  

Proof state:
P : MorphismProperty Scheme
hP : PropertyIsLocalAtTarget P
X Y : Scheme
f : X ⟶ Y
tfae_2_to_1 : (∃ 𝒰, ∀ (i : 𝒰.J), P pullback.snd) → P f
tfae_1_to_4 : P f → ∀ (U : Opens ↑↑Y.toPresheafedSpace), P (f ∣_ U)
tfae_4_to_3 : (∀ (U : Opens ↑↑Y.toPresheafedSpace), P (f ∣_ U)) → ∀ (𝒰 : Scheme.OpenCover Y) (i : 𝒰.J), P pullback.snd
tfae_3_to_2 : (∀ (𝒰 : Scheme.OpenCover Y) (i : 𝒰.J), P pullback.snd) → ∃ 𝒰, ∀ (i : 𝒰.J), P pullback.snd
tfae_4_to_5 :
  (∀ (U : Opens ↑↑Y.toPresheafedSpace), P (f ∣_ U)) →
    ∀ {U : Scheme} (g : U ⟶ Y) [inst : IsOpenImmersion g], P pullback.snd
tfae_5_to_4 :
  (∀ {U : Scheme} (g : U ⟶ Y) [inst : IsOpenImmersion g], P pullback.snd) →
    ∀ (U : Opens ↑↑Y.toPresheafedSpace), P (f ∣_ U)
tfae_4_to_6 : (∀ (U : Opens ↑↑Y.toPresheafedSpace), P (f ∣_ U)) → ∃ ι U, ∃ (_ : iSup U = ⊤), ∀ (i : ι), P (f ∣_ U i)
tfae_6_to_2 : (∃ ι U, ∃ (_ : iSup U = ⊤), ∀ (i : ι), P (f ∣_ U i)) → ∃ 𝒰, ∀ (i : 𝒰.J), P pullback.snd
⊢ TFAE
    [P f, ∃ 𝒰, ∀ (i : 𝒰.J), P pullback.snd, ∀ (𝒰 : Scheme.OpenCover Y) (i : 𝒰.J), P pullback.snd,
      ∀ (U : Opens ↑↑Y.toPresheafedSpace), P (f ∣_ U),
      ∀ {U : Scheme} (g : U ⟶ Y) [inst : IsOpenImmersion g], P pullback.snd,
      ∃ ι U, ∃ (_ : iSup U = ⊤), ∀ (i : ι), P (f ∣_ U i)]

Next tactic:
tfae_finish
theorem PropertyIsLocalAtTarget.openCover_iff {P : MorphismProperty Scheme}
    (hP : PropertyIsLocalAtTarget P) {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} Y) :
    P f ↔ ∀ i, P (pullback.snd : pullback f (𝒰.map i) ⟶ _) := by
  -- Porting note : couldn't get the term mode proof work
  

Proof state:
P : MorphismProperty Scheme
hP : PropertyIsLocalAtTarget P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover Y
⊢ P f ↔ ∀ (i : 𝒰.J), P pullback.snd

Next tactic:
refine ⟨fun H => let h := ((hP.openCover_TFAE f).out 0 2).mp H; fun i => ?_,
    fun H => let h := ((hP.openCover_TFAE f).out 1 0).mp; ?_⟩
theorem PropertyIsLocalAtTarget.openCover_iff {P : MorphismProperty Scheme}
    (hP : PropertyIsLocalAtTarget P) {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} Y) :
    P f ↔ ∀ i, P (pullback.snd : pullback f (𝒰.map i) ⟶ _) := by
  -- Porting note : couldn't get the term mode proof work
  refine ⟨fun H => let h := ((hP.openCover_TFAE f).out 0 2).mp H; fun i => ?_,
    fun H => let h := ((hP.openCover_TFAE f).out 1 0).mp; ?_⟩
  · 

Proof state:
case refine_1
P : MorphismProperty Scheme
hP : PropertyIsLocalAtTarget P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover Y
H : P f
h : ∀ (𝒰 : Scheme.OpenCover Y) (i : 𝒰.J), P pullback.snd := (List.TFAE.out (openCover_TFAE hP f) 0 2).mp H
i : 𝒰.J
⊢ P pullback.snd

Next tactic:
exact h 𝒰 i
theorem PropertyIsLocalAtTarget.openCover_iff {P : MorphismProperty Scheme}
    (hP : PropertyIsLocalAtTarget P) {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} Y) :
    P f ↔ ∀ i, P (pullback.snd : pullback f (𝒰.map i) ⟶ _) := by
  -- Porting note : couldn't get the term mode proof work
  refine ⟨fun H => let h := ((hP.openCover_TFAE f).out 0 2).mp H; fun i => ?_,
    fun H => let h := ((hP.openCover_TFAE f).out 1 0).mp; ?_⟩
  · exact h 𝒰 i
  · 

Proof state:
case refine_2
P : MorphismProperty Scheme
hP : PropertyIsLocalAtTarget P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover Y
H : ∀ (i : 𝒰.J), P pullback.snd
h : (∃ 𝒰, ∀ (i : 𝒰.J), P pullback.snd) → P f := (List.TFAE.out (openCover_TFAE hP f) 1 0).mp
⊢ P f

Next tactic:
exact h ⟨𝒰, H⟩
theorem IsLocal.targetAffineLocallyPullbackFstOfRightOfStableUnderBaseChange
    {P : AffineTargetMorphismProperty} (hP : P.IsLocal) (hP' : P.StableUnderBaseChange)
    {X Y S : Scheme} (f : X ⟶ S) (g : Y ⟶ S) [IsAffine S] (H : P g) :
    targetAffineLocally P (pullback.fst : pullback f g ⟶ X) := by
  -- Porting note : rewrite `(hP.affine_openCover_TFAE ...).out 0 1` doesn't work
  

Proof state:
P : AffineTargetMorphismProperty
hP : IsLocal P
hP' : StableUnderBaseChange P
X Y S : Scheme
f : X ⟶ S
g : Y ⟶ S
inst✝ : IsAffine S
H : P g
⊢ targetAffineLocally P pullback.fst

Next tactic:
have h01 := (hP.affine_openCover_TFAE (pullback.fst : pullback f g ⟶ X)).out 0 1
theorem IsLocal.targetAffineLocallyPullbackFstOfRightOfStableUnderBaseChange
    {P : AffineTargetMorphismProperty} (hP : P.IsLocal) (hP' : P.StableUnderBaseChange)
    {X Y S : Scheme} (f : X ⟶ S) (g : Y ⟶ S) [IsAffine S] (H : P g) :
    targetAffineLocally P (pullback.fst : pullback f g ⟶ X) := by
  -- Porting note : rewrite `(hP.affine_openCover_TFAE ...).out 0 1` doesn't work
  have h01 := (hP.affine_openCover_TFAE (pullback.fst : pullback f g ⟶ X)).out 0 1
  

Proof state:
P : AffineTargetMorphismProperty
hP : IsLocal P
hP' : StableUnderBaseChange P
X Y S : Scheme
f : X ⟶ S
g : Y ⟶ S
inst✝ : IsAffine S
H : P g
h01 :
  targetAffineLocally P pullback.fst ↔
    ∃ 𝒰, ∃ (x : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)), ∀ (i : 𝒰.J), P pullback.snd
⊢ targetAffineLocally P pullback.fst

Next tactic:
rw [h01]
theorem IsLocal.targetAffineLocallyPullbackFstOfRightOfStableUnderBaseChange
    {P : AffineTargetMorphismProperty} (hP : P.IsLocal) (hP' : P.StableUnderBaseChange)
    {X Y S : Scheme} (f : X ⟶ S) (g : Y ⟶ S) [IsAffine S] (H : P g) :
    targetAffineLocally P (pullback.fst : pullback f g ⟶ X) := by
  -- Porting note : rewrite `(hP.affine_openCover_TFAE ...).out 0 1` doesn't work
  have h01 := (hP.affine_openCover_TFAE (pullback.fst : pullback f g ⟶ X)).out 0 1
  rw [h01]
  

Proof state:
P : AffineTargetMorphismProperty
hP : IsLocal P
hP' : StableUnderBaseChange P
X Y S : Scheme
f : X ⟶ S
g : Y ⟶ S
inst✝ : IsAffine S
H : P g
h01 :
  targetAffineLocally P pullback.fst ↔
    ∃ 𝒰, ∃ (x : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)), ∀ (i : 𝒰.J), P pullback.snd
⊢ ∃ 𝒰, ∃ (x : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)), ∀ (i : 𝒰.J), P pullback.snd

Next tactic:
use X.affineCover, inferInstance
theorem IsLocal.targetAffineLocallyPullbackFstOfRightOfStableUnderBaseChange
    {P : AffineTargetMorphismProperty} (hP : P.IsLocal) (hP' : P.StableUnderBaseChange)
    {X Y S : Scheme} (f : X ⟶ S) (g : Y ⟶ S) [IsAffine S] (H : P g) :
    targetAffineLocally P (pullback.fst : pullback f g ⟶ X) := by
  -- Porting note : rewrite `(hP.affine_openCover_TFAE ...).out 0 1` doesn't work
  have h01 := (hP.affine_openCover_TFAE (pullback.fst : pullback f g ⟶ X)).out 0 1
  rw [h01]
  use X.affineCover, inferInstance
  

Proof state:
case h
P : AffineTargetMorphismProperty
hP : IsLocal P
hP' : StableUnderBaseChange P
X Y S : Scheme
f : X ⟶ S
g : Y ⟶ S
inst✝ : IsAffine S
H : P g
h01 :
  targetAffineLocally P pullback.fst ↔
    ∃ 𝒰, ∃ (x : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)), ∀ (i : 𝒰.J), P pullback.snd
⊢ ∀ (i : (Scheme.affineCover X).J), P pullback.snd

Next tactic:
intro i
theorem IsLocal.targetAffineLocallyPullbackFstOfRightOfStableUnderBaseChange
    {P : AffineTargetMorphismProperty} (hP : P.IsLocal) (hP' : P.StableUnderBaseChange)
    {X Y S : Scheme} (f : X ⟶ S) (g : Y ⟶ S) [IsAffine S] (H : P g) :
    targetAffineLocally P (pullback.fst : pullback f g ⟶ X) := by
  -- Porting note : rewrite `(hP.affine_openCover_TFAE ...).out 0 1` doesn't work
  have h01 := (hP.affine_openCover_TFAE (pullback.fst : pullback f g ⟶ X)).out 0 1
  rw [h01]
  use X.affineCover, inferInstance
  intro i
  

Proof state:
case h
P : AffineTargetMorphismProperty
hP : IsLocal P
hP' : StableUnderBaseChange P
X Y S : Scheme
f : X ⟶ S
g : Y ⟶ S
inst✝ : IsAffine S
H : P g
h01 :
  targetAffineLocally P pullback.fst ↔
    ∃ 𝒰, ∃ (x : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)), ∀ (i : 𝒰.J), P pullback.snd
i : (Scheme.affineCover X).J
⊢ P pullback.snd

Next tactic:
let e := pullbackSymmetry _ _ ≪≫ pullbackRightPullbackFstIso f g (X.affineCover.map i)
theorem IsLocal.targetAffineLocallyPullbackFstOfRightOfStableUnderBaseChange
    {P : AffineTargetMorphismProperty} (hP : P.IsLocal) (hP' : P.StableUnderBaseChange)
    {X Y S : Scheme} (f : X ⟶ S) (g : Y ⟶ S) [IsAffine S] (H : P g) :
    targetAffineLocally P (pullback.fst : pullback f g ⟶ X) := by
  -- Porting note : rewrite `(hP.affine_openCover_TFAE ...).out 0 1` doesn't work
  have h01 := (hP.affine_openCover_TFAE (pullback.fst : pullback f g ⟶ X)).out 0 1
  rw [h01]
  use X.affineCover, inferInstance
  intro i
  let e := pullbackSymmetry _ _ ≪≫ pullbackRightPullbackFstIso f g (X.affineCover.map i)
  

Proof state:
case h
P : AffineTargetMorphismProperty
hP : IsLocal P
hP' : StableUnderBaseChange P
X Y S : Scheme
f : X ⟶ S
g : Y ⟶ S
inst✝ : IsAffine S
H : P g
h01 :
  targetAffineLocally P pullback.fst ↔
    ∃ 𝒰, ∃ (x : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)), ∀ (i : 𝒰.J), P pullback.snd
i : (Scheme.affineCover X).J
e : pullback pullback.fst (Scheme.OpenCover.map (Scheme.affineCover X) i) ≅
  pullback (Scheme.OpenCover.map (Scheme.affineCover X) i ≫ f) g :=
  pullbackSymmetry pullback.fst (Scheme.OpenCover.map (Scheme.affineCover X) i) ≪≫
    pullbackRightPullbackFstIso f g (Scheme.OpenCover.map (Scheme.affineCover X) i)
⊢ P pullback.snd

Next tactic:
have : e.hom ≫ pullback.fst = pullback.snd := by simp
theorem IsLocal.targetAffineLocallyPullbackFstOfRightOfStableUnderBaseChange
    {P : AffineTargetMorphismProperty} (hP : P.IsLocal) (hP' : P.StableUnderBaseChange)
    {X Y S : Scheme} (f : X ⟶ S) (g : Y ⟶ S) [IsAffine S] (H : P g) :
    targetAffineLocally P (pullback.fst : pullback f g ⟶ X) := by
  -- Porting note : rewrite `(hP.affine_openCover_TFAE ...).out 0 1` doesn't work
  have h01 := (hP.affine_openCover_TFAE (pullback.fst : pullback f g ⟶ X)).out 0 1
  rw [h01]
  use X.affineCover, inferInstance
  intro i
  let e := pullbackSymmetry _ _ ≪≫ pullbackRightPullbackFstIso f g (X.affineCover.map i)
  have : e.hom ≫ pullback.fst = pullback.snd := by 

Proof state:
P : AffineTargetMorphismProperty
hP : IsLocal P
hP' : StableUnderBaseChange P
X Y S : Scheme
f : X ⟶ S
g : Y ⟶ S
inst✝ : IsAffine S
H : P g
h01 :
  targetAffineLocally P pullback.fst ↔
    ∃ 𝒰, ∃ (x : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)), ∀ (i : 𝒰.J), P pullback.snd
i : (Scheme.affineCover X).J
e : pullback pullback.fst (Scheme.OpenCover.map (Scheme.affineCover X) i) ≅
  pullback (Scheme.OpenCover.map (Scheme.affineCover X) i ≫ f) g :=
  pullbackSymmetry pullback.fst (Scheme.OpenCover.map (Scheme.affineCover X) i) ≪≫
    pullbackRightPullbackFstIso f g (Scheme.OpenCover.map (Scheme.affineCover X) i)
⊢ e.hom ≫ pullback.fst = pullback.snd

Next tactic:
simp
theorem IsLocal.targetAffineLocallyPullbackFstOfRightOfStableUnderBaseChange
    {P : AffineTargetMorphismProperty} (hP : P.IsLocal) (hP' : P.StableUnderBaseChange)
    {X Y S : Scheme} (f : X ⟶ S) (g : Y ⟶ S) [IsAffine S] (H : P g) :
    targetAffineLocally P (pullback.fst : pullback f g ⟶ X) := by
  -- Porting note : rewrite `(hP.affine_openCover_TFAE ...).out 0 1` doesn't work
  have h01 := (hP.affine_openCover_TFAE (pullback.fst : pullback f g ⟶ X)).out 0 1
  rw [h01]
  use X.affineCover, inferInstance
  intro i
  let e := pullbackSymmetry _ _ ≪≫ pullbackRightPullbackFstIso f g (X.affineCover.map i)
  have : e.hom ≫ pullback.fst = pullback.snd := by simp
  

Proof state:
case h
P : AffineTargetMorphismProperty
hP : IsLocal P
hP' : StableUnderBaseChange P
X Y S : Scheme
f : X ⟶ S
g : Y ⟶ S
inst✝ : IsAffine S
H : P g
h01 :
  targetAffineLocally P pullback.fst ↔
    ∃ 𝒰, ∃ (x : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)), ∀ (i : 𝒰.J), P pullback.snd
i : (Scheme.affineCover X).J
e : pullback pullback.fst (Scheme.OpenCover.map (Scheme.affineCover X) i) ≅
  pullback (Scheme.OpenCover.map (Scheme.affineCover X) i ≫ f) g :=
  pullbackSymmetry pullback.fst (Scheme.OpenCover.map (Scheme.affineCover X) i) ≪≫
    pullbackRightPullbackFstIso f g (Scheme.OpenCover.map (Scheme.affineCover X) i)
this : e.hom ≫ pullback.fst = pullback.snd
⊢ P pullback.snd

Next tactic:
rw [← this, affine_cancel_left_isIso hP.1]
theorem IsLocal.targetAffineLocallyPullbackFstOfRightOfStableUnderBaseChange
    {P : AffineTargetMorphismProperty} (hP : P.IsLocal) (hP' : P.StableUnderBaseChange)
    {X Y S : Scheme} (f : X ⟶ S) (g : Y ⟶ S) [IsAffine S] (H : P g) :
    targetAffineLocally P (pullback.fst : pullback f g ⟶ X) := by
  -- Porting note : rewrite `(hP.affine_openCover_TFAE ...).out 0 1` doesn't work
  have h01 := (hP.affine_openCover_TFAE (pullback.fst : pullback f g ⟶ X)).out 0 1
  rw [h01]
  use X.affineCover, inferInstance
  intro i
  let e := pullbackSymmetry _ _ ≪≫ pullbackRightPullbackFstIso f g (X.affineCover.map i)
  have : e.hom ≫ pullback.fst = pullback.snd := by simp
  rw [← this, affine_cancel_left_isIso hP.1]
  

Proof state:
case h
P : AffineTargetMorphismProperty
hP : IsLocal P
hP' : StableUnderBaseChange P
X Y S : Scheme
f : X ⟶ S
g : Y ⟶ S
inst✝ : IsAffine S
H : P g
h01 :
  targetAffineLocally P pullback.fst ↔
    ∃ 𝒰, ∃ (x : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)), ∀ (i : 𝒰.J), P pullback.snd
i : (Scheme.affineCover X).J
e : pullback pullback.fst (Scheme.OpenCover.map (Scheme.affineCover X) i) ≅
  pullback (Scheme.OpenCover.map (Scheme.affineCover X) i ≫ f) g :=
  pullbackSymmetry pullback.fst (Scheme.OpenCover.map (Scheme.affineCover X) i) ≪≫
    pullbackRightPullbackFstIso f g (Scheme.OpenCover.map (Scheme.affineCover X) i)
this : e.hom ≫ pullback.fst = pullback.snd
⊢ P pullback.fst

Next tactic:
apply hP'
theorem IsLocal.targetAffineLocallyPullbackFstOfRightOfStableUnderBaseChange
    {P : AffineTargetMorphismProperty} (hP : P.IsLocal) (hP' : P.StableUnderBaseChange)
    {X Y S : Scheme} (f : X ⟶ S) (g : Y ⟶ S) [IsAffine S] (H : P g) :
    targetAffineLocally P (pullback.fst : pullback f g ⟶ X) := by
  -- Porting note : rewrite `(hP.affine_openCover_TFAE ...).out 0 1` doesn't work
  have h01 := (hP.affine_openCover_TFAE (pullback.fst : pullback f g ⟶ X)).out 0 1
  rw [h01]
  use X.affineCover, inferInstance
  intro i
  let e := pullbackSymmetry _ _ ≪≫ pullbackRightPullbackFstIso f g (X.affineCover.map i)
  have : e.hom ≫ pullback.fst = pullback.snd := by simp
  rw [← this, affine_cancel_left_isIso hP.1]
  apply hP'; 

Proof state:
case h.a
P : AffineTargetMorphismProperty
hP : IsLocal P
hP' : StableUnderBaseChange P
X Y S : Scheme
f : X ⟶ S
g : Y ⟶ S
inst✝ : IsAffine S
H : P g
h01 :
  targetAffineLocally P pullback.fst ↔
    ∃ 𝒰, ∃ (x : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)), ∀ (i : 𝒰.J), P pullback.snd
i : (Scheme.affineCover X).J
e : pullback pullback.fst (Scheme.OpenCover.map (Scheme.affineCover X) i) ≅
  pullback (Scheme.OpenCover.map (Scheme.affineCover X) i ≫ f) g :=
  pullbackSymmetry pullback.fst (Scheme.OpenCover.map (Scheme.affineCover X) i) ≪≫
    pullbackRightPullbackFstIso f g (Scheme.OpenCover.map (Scheme.affineCover X) i)
this : e.hom ≫ pullback.fst = pullback.snd
⊢ P g

Next tactic:
assumption
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
      

Proof state:
P : AffineTargetMorphismProperty
hP : IsLocal P
hP' : StableUnderBaseChange P
X Y S : Scheme
f : X ⟶ S
g : Y ⟶ S
H : targetAffineLocally P g
⊢ targetAffineLocally P pullback.fst

Next tactic:
have h01 := (hP.targetAffineLocallyIsLocal.openCover_TFAE
        (pullback.fst : pullback f g ⟶ X)).out 0 1
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
      

Proof state:
P : AffineTargetMorphismProperty
hP : IsLocal P
hP' : StableUnderBaseChange P
X Y S : Scheme
f : X ⟶ S
g : Y ⟶ S
H : targetAffineLocally P g
h01 : targetAffineLocally P pullback.fst ↔ ∃ 𝒰, ∀ (i : 𝒰.J), targetAffineLocally P pullback.snd
⊢ targetAffineLocally P pullback.fst

Next tactic:
rw [h01]
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]
      

Proof state:
P : AffineTargetMorphismProperty
hP : IsLocal P
hP' : StableUnderBaseChange P
X Y S : Scheme
f : X ⟶ S
g : Y ⟶ S
H : targetAffineLocally P g
h01 : targetAffineLocally P pullback.fst ↔ ∃ 𝒰, ∀ (i : 𝒰.J), targetAffineLocally P pullback.snd
⊢ ∃ 𝒰, ∀ (i : 𝒰.J), targetAffineLocally P pullback.snd

Next tactic:
use S.affineCover.pullbackCover f