l3lab/ntp-mathlib huggingface dataset:
theorem AffineTargetMorphismProperty.isLocalOfOpenCoverImply (P : AffineTargetMorphismProperty)
    (hP : P.toProperty.RespectsIso)
    (H : ∀ {X Y : Scheme.{u}} (f : X ⟶ Y),
      (∃ (𝒰 : Scheme.OpenCover.{u} Y) (_ : ∀ i, IsAffine (𝒰.obj i)),
        ∀ i : 𝒰.J, P (pullback.snd : (𝒰.pullbackCover f).obj i ⟶ 𝒰.obj i)) →
        ∀ {U : Scheme} (g : U ⟶ Y) [IsAffine U] [IsOpenImmersion g],
          P (pullback.snd : pullback f g ⟶ U)) :
    P.IsLocal := by
  refine' ⟨hP, _, _⟩
  · introv h
    haveI : IsAffine _ := (topIsAffineOpen Y).basicOpenIsAffine r
    delta morphismRestrict
    rw [affine_cancel_left_isIso hP]
    refine' @H _ _ f ⟨Scheme.openCoverOfIsIso (𝟙 Y), _, _⟩ _ (Y.ofRestrict _) _ _
    · intro i; dsimp; infer_instance
    · intro i; dsimp
      rwa [← Category.comp_id pullback.snd, ← pullback.condition, affine_cancel_left_isIso hP]
  · introv hs hs'
    replace hs := ((topIsAffineOpen Y).basicOpen_union_eq_self_iff _).mpr hs
    have := H f ⟨Y.openCoverOfSuprEqTop _ hs, ?_, ?_⟩ (𝟙 _)
    rwa [← Category.comp_id pullback.snd, ← pullback.condition, affine_cancel_left_isIso hP]
      at this
    · intro i; exact (topIsAffineOpen Y).basicOpenIsAffine _
    · rintro (i : s)
      specialize hs' i
      haveI : IsAffine _ := (topIsAffineOpen Y).basicOpenIsAffine i.1
      

Proof state:
case refine'_2.refine_2
P : AffineTargetMorphismProperty
hP : MorphismProperty.RespectsIso (toProperty P)
H :
  ∀ {X Y : Scheme} (f : X ⟶ Y),
    (∃ 𝒰, ∃ (x : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)), ∀ (i : 𝒰.J), P pullback.snd) →
      ∀ {U : Scheme} (g : U ⟶ Y) [inst : IsAffine U] [inst_1 : IsOpenImmersion g], P pullback.snd
X Y : Scheme
inst✝ : IsAffine Y
f : X ⟶ Y
s : Finset ↑(Y.presheaf.obj (op ⊤))
hs : ⨆ f, Y.basicOpen ↑f = ⊤
i : { x // x ∈ s }
hs' : P (f ∣_ Y.basicOpen ↑i)
this : IsAffine (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion (Y.basicOpen ↑i))))
⊢ P pullback.snd

Next tactic:
delta morphismRestrict at hs'
theorem AffineTargetMorphismProperty.isLocalOfOpenCoverImply (P : AffineTargetMorphismProperty)
    (hP : P.toProperty.RespectsIso)
    (H : ∀ {X Y : Scheme.{u}} (f : X ⟶ Y),
      (∃ (𝒰 : Scheme.OpenCover.{u} Y) (_ : ∀ i, IsAffine (𝒰.obj i)),
        ∀ i : 𝒰.J, P (pullback.snd : (𝒰.pullbackCover f).obj i ⟶ 𝒰.obj i)) →
        ∀ {U : Scheme} (g : U ⟶ Y) [IsAffine U] [IsOpenImmersion g],
          P (pullback.snd : pullback f g ⟶ U)) :
    P.IsLocal := by
  refine' ⟨hP, _, _⟩
  · introv h
    haveI : IsAffine _ := (topIsAffineOpen Y).basicOpenIsAffine r
    delta morphismRestrict
    rw [affine_cancel_left_isIso hP]
    refine' @H _ _ f ⟨Scheme.openCoverOfIsIso (𝟙 Y), _, _⟩ _ (Y.ofRestrict _) _ _
    · intro i; dsimp; infer_instance
    · intro i; dsimp
      rwa [← Category.comp_id pullback.snd, ← pullback.condition, affine_cancel_left_isIso hP]
  · introv hs hs'
    replace hs := ((topIsAffineOpen Y).basicOpen_union_eq_self_iff _).mpr hs
    have := H f ⟨Y.openCoverOfSuprEqTop _ hs, ?_, ?_⟩ (𝟙 _)
    rwa [← Category.comp_id pullback.snd, ← pullback.condition, affine_cancel_left_isIso hP]
      at this
    · intro i; exact (topIsAffineOpen Y).basicOpenIsAffine _
    · rintro (i : s)
      specialize hs' i
      haveI : IsAffine _ := (topIsAffineOpen Y).basicOpenIsAffine i.1
      delta morphismRestrict at hs'
      

Proof state:
case refine'_2.refine_2
P : AffineTargetMorphismProperty
hP : MorphismProperty.RespectsIso (toProperty P)
H :
  ∀ {X Y : Scheme} (f : X ⟶ Y),
    (∃ 𝒰, ∃ (x : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)), ∀ (i : 𝒰.J), P pullback.snd) →
      ∀ {U : Scheme} (g : U ⟶ Y) [inst : IsAffine U] [inst_1 : IsOpenImmersion g], P pullback.snd
X Y : Scheme
inst✝ : IsAffine Y
f : X ⟶ Y
s : Finset ↑(Y.presheaf.obj (op ⊤))
hs : ⨆ f, Y.basicOpen ↑f = ⊤
i : { x // x ∈ s }
hs' : P ((pullbackRestrictIsoRestrict f (Y.basicOpen ↑i)).inv ≫ pullback.snd)
this : IsAffine (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion (Y.basicOpen ↑i))))
⊢ P pullback.snd

Next tactic:
rwa [affine_cancel_left_isIso hP] at hs'
theorem AffineTargetMorphismProperty.IsLocal.affine_openCover_iff {P : AffineTargetMorphismProperty}
    (hP : P.IsLocal) {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} Y)
    [h𝒰 : ∀ i, IsAffine (𝒰.obj i)] :
    targetAffineLocally P f ↔ ∀ i, @P _ _ (pullback.snd : pullback f (𝒰.map i) ⟶ _) (h𝒰 i) := by
  

Proof state:
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover Y
h𝒰 : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)
⊢ targetAffineLocally P f ↔ ∀ (i : 𝒰.J), P pullback.snd

Next tactic:
refine' ⟨fun H => let h := ((hP.affine_openCover_TFAE f).out 0 2).mp H; _,
    fun H => let h := ((hP.affine_openCover_TFAE f).out 1 0).mp; _⟩
theorem AffineTargetMorphismProperty.IsLocal.affine_openCover_iff {P : AffineTargetMorphismProperty}
    (hP : P.IsLocal) {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} Y)
    [h𝒰 : ∀ i, IsAffine (𝒰.obj i)] :
    targetAffineLocally P f ↔ ∀ i, @P _ _ (pullback.snd : pullback f (𝒰.map i) ⟶ _) (h𝒰 i) := by
  refine' ⟨fun H => let h := ((hP.affine_openCover_TFAE f).out 0 2).mp H; _,
    fun H => let h := ((hP.affine_openCover_TFAE f).out 1 0).mp; _⟩
  · 

Proof state:
case refine'_1
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover Y
h𝒰 : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)
H : targetAffineLocally P f
h : ∀ (𝒰 : Scheme.OpenCover Y) [inst : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)] (i : 𝒰.J), P pullback.snd :=
  (List.TFAE.out (affine_openCover_TFAE hP f) 0 2).mp H
⊢ ∀ (i : 𝒰.J), P pullback.snd

Next tactic:
exact fun i => h 𝒰 i
theorem AffineTargetMorphismProperty.IsLocal.affine_openCover_iff {P : AffineTargetMorphismProperty}
    (hP : P.IsLocal) {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} Y)
    [h𝒰 : ∀ i, IsAffine (𝒰.obj i)] :
    targetAffineLocally P f ↔ ∀ i, @P _ _ (pullback.snd : pullback f (𝒰.map i) ⟶ _) (h𝒰 i) := by
  refine' ⟨fun H => let h := ((hP.affine_openCover_TFAE f).out 0 2).mp H; _,
    fun H => let h := ((hP.affine_openCover_TFAE f).out 1 0).mp; _⟩
  · exact fun i => h 𝒰 i
  · 

Proof state:
case refine'_2
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover Y
h𝒰 : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)
H : ∀ (i : 𝒰.J), P pullback.snd
h : (∃ 𝒰, ∃ (x : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)), ∀ (i : 𝒰.J), P pullback.snd) →
  targetAffineLocally P f :=
  (List.TFAE.out (affine_openCover_TFAE hP f) 1 0).mp
⊢ targetAffineLocally P f

Next tactic:
exact h ⟨𝒰, inferInstance, H⟩
theorem AffineTargetMorphismProperty.IsLocal.affine_target_iff {P : AffineTargetMorphismProperty}
    (hP : P.IsLocal) {X Y : Scheme.{u}} (f : X ⟶ Y) [IsAffine Y] :
    targetAffineLocally P f ↔ P f := by
  

Proof state:
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y : Scheme
f : X ⟶ Y
inst✝ : IsAffine Y
⊢ targetAffineLocally P f ↔ P f

Next tactic:
haveI : ∀ i, IsAffine (Scheme.OpenCover.obj (Scheme.openCoverOfIsIso (𝟙 Y)) i) := fun i => by
    dsimp; infer_instance
theorem AffineTargetMorphismProperty.IsLocal.affine_target_iff {P : AffineTargetMorphismProperty}
    (hP : P.IsLocal) {X Y : Scheme.{u}} (f : X ⟶ Y) [IsAffine Y] :
    targetAffineLocally P f ↔ P f := by
  haveI : ∀ i, IsAffine (Scheme.OpenCover.obj (Scheme.openCoverOfIsIso (𝟙 Y)) i) := fun i => by
    

Proof state:
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y : Scheme
f : X ⟶ Y
inst✝ : IsAffine Y
i : (Scheme.openCoverOfIsIso (𝟙 Y)).J
⊢ IsAffine (Scheme.OpenCover.obj (Scheme.openCoverOfIsIso (𝟙 Y)) i)

Next tactic:
dsimp
theorem AffineTargetMorphismProperty.IsLocal.affine_target_iff {P : AffineTargetMorphismProperty}
    (hP : P.IsLocal) {X Y : Scheme.{u}} (f : X ⟶ Y) [IsAffine Y] :
    targetAffineLocally P f ↔ P f := by
  haveI : ∀ i, IsAffine (Scheme.OpenCover.obj (Scheme.openCoverOfIsIso (𝟙 Y)) i) := fun i => by
    dsimp; 

Proof state:
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y : Scheme
f : X ⟶ Y
inst✝ : IsAffine Y
i : (Scheme.openCoverOfIsIso (𝟙 Y)).J
⊢ IsAffine Y

Next tactic:
infer_instance
theorem AffineTargetMorphismProperty.IsLocal.affine_target_iff {P : AffineTargetMorphismProperty}
    (hP : P.IsLocal) {X Y : Scheme.{u}} (f : X ⟶ Y) [IsAffine Y] :
    targetAffineLocally P f ↔ P f := by
  haveI : ∀ i, IsAffine (Scheme.OpenCover.obj (Scheme.openCoverOfIsIso (𝟙 Y)) i) := fun i => by
    dsimp; infer_instance
  

Proof state:
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y : Scheme
f : X ⟶ Y
inst✝ : IsAffine Y
this : ∀ (i : (Scheme.openCoverOfIsIso (𝟙 Y)).J), IsAffine (Scheme.OpenCover.obj (Scheme.openCoverOfIsIso (𝟙 Y)) i)
⊢ targetAffineLocally P f ↔ P f

Next tactic:
rw [hP.affine_openCover_iff f (Scheme.openCoverOfIsIso (𝟙 Y))]
theorem AffineTargetMorphismProperty.IsLocal.affine_target_iff {P : AffineTargetMorphismProperty}
    (hP : P.IsLocal) {X Y : Scheme.{u}} (f : X ⟶ Y) [IsAffine Y] :
    targetAffineLocally P f ↔ P f := by
  haveI : ∀ i, IsAffine (Scheme.OpenCover.obj (Scheme.openCoverOfIsIso (𝟙 Y)) i) := fun i => by
    dsimp; infer_instance
  rw [hP.affine_openCover_iff f (Scheme.openCoverOfIsIso (𝟙 Y))]
  

Proof state:
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y : Scheme
f : X ⟶ Y
inst✝ : IsAffine Y
this : ∀ (i : (Scheme.openCoverOfIsIso (𝟙 Y)).J), IsAffine (Scheme.OpenCover.obj (Scheme.openCoverOfIsIso (𝟙 Y)) i)
⊢ (∀ (i : (Scheme.openCoverOfIsIso (𝟙 Y)).J), P pullback.snd) ↔ P f

Next tactic:
trans P (pullback.snd : pullback f (𝟙 _) ⟶ _)
theorem AffineTargetMorphismProperty.IsLocal.affine_target_iff {P : AffineTargetMorphismProperty}
    (hP : P.IsLocal) {X Y : Scheme.{u}} (f : X ⟶ Y) [IsAffine Y] :
    targetAffineLocally P f ↔ P f := by
  haveI : ∀ i, IsAffine (Scheme.OpenCover.obj (Scheme.openCoverOfIsIso (𝟙 Y)) i) := fun i => by
    dsimp; infer_instance
  rw [hP.affine_openCover_iff f (Scheme.openCoverOfIsIso (𝟙 Y))]
  trans P (pullback.snd : pullback f (𝟙 _) ⟶ _)
  · 

Proof state:
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y : Scheme
f : X ⟶ Y
inst✝ : IsAffine Y
this : ∀ (i : (Scheme.openCoverOfIsIso (𝟙 Y)).J), IsAffine (Scheme.OpenCover.obj (Scheme.openCoverOfIsIso (𝟙 Y)) i)
⊢ (∀ (i : (Scheme.openCoverOfIsIso (𝟙 Y)).J), P pullback.snd) ↔ P pullback.snd

Next tactic:
exact ⟨fun H => H PUnit.unit, fun H _ => H⟩
theorem AffineTargetMorphismProperty.IsLocal.affine_target_iff {P : AffineTargetMorphismProperty}
    (hP : P.IsLocal) {X Y : Scheme.{u}} (f : X ⟶ Y) [IsAffine Y] :
    targetAffineLocally P f ↔ P f := by
  haveI : ∀ i, IsAffine (Scheme.OpenCover.obj (Scheme.openCoverOfIsIso (𝟙 Y)) i) := fun i => by
    dsimp; infer_instance
  rw [hP.affine_openCover_iff f (Scheme.openCoverOfIsIso (𝟙 Y))]
  trans P (pullback.snd : pullback f (𝟙 _) ⟶ _)
  · exact ⟨fun H => H PUnit.unit, fun H _ => H⟩
  

Proof state:
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y : Scheme
f : X ⟶ Y
inst✝ : IsAffine Y
this : ∀ (i : (Scheme.openCoverOfIsIso (𝟙 Y)).J), IsAffine (Scheme.OpenCover.obj (Scheme.openCoverOfIsIso (𝟙 Y)) i)
⊢ P pullback.snd ↔ P f

Next tactic:
rw [← Category.comp_id pullback.snd, ← pullback.condition, affine_cancel_left_isIso hP.1]
theorem AffineTargetMorphismProperty.IsLocal.targetAffineLocallyIsLocal
    {P : AffineTargetMorphismProperty} (hP : P.IsLocal) :
    PropertyIsLocalAtTarget (targetAffineLocally P) := by
  

Proof state:
P : AffineTargetMorphismProperty
hP : IsLocal P
⊢ PropertyIsLocalAtTarget (targetAffineLocally P)

Next tactic:
constructor
theorem AffineTargetMorphismProperty.IsLocal.targetAffineLocallyIsLocal
    {P : AffineTargetMorphismProperty} (hP : P.IsLocal) :
    PropertyIsLocalAtTarget (targetAffineLocally P) := by
  constructor
  · 

Proof state:
case RespectsIso
P : AffineTargetMorphismProperty
hP : IsLocal P
⊢ MorphismProperty.RespectsIso (targetAffineLocally P)

Next tactic:
exact targetAffineLocally_respectsIso hP.1
theorem AffineTargetMorphismProperty.IsLocal.targetAffineLocallyIsLocal
    {P : AffineTargetMorphismProperty} (hP : P.IsLocal) :
    PropertyIsLocalAtTarget (targetAffineLocally P) := by
  constructor
  · exact targetAffineLocally_respectsIso hP.1
  · 

Proof state:
case restrict
P : AffineTargetMorphismProperty
hP : IsLocal P
⊢ ∀ {X Y : Scheme} (f : X ⟶ Y) (U : Opens ↑↑Y.toPresheafedSpace),
    targetAffineLocally P f → targetAffineLocally P (f ∣_ U)

Next tactic:
intro X Y f U H V
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
    

Proof state:
case restrict
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y : Scheme
f : X ⟶ Y
U : Opens ↑↑Y.toPresheafedSpace
H : targetAffineLocally P f
V : ↑(Scheme.affineOpens (Y ∣_ᵤ U))
⊢ P (f ∣_ U ∣_ ↑V)

Next tactic:
rw [← P.toProperty_apply (i := V.2), hP.1.arrow_mk_iso_iff (morphismRestrictRestrict f _ _)]
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 _ _)]
    

Proof state:
case restrict
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y : Scheme
f : X ⟶ Y
U : Opens ↑↑Y.toPresheafedSpace
H : targetAffineLocally P f
V : ↑(Scheme.affineOpens (Y ∣_ᵤ U))
⊢ toProperty P (f ∣_ (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj ↑V)

Next tactic:
convert H ⟨_, IsAffineOpen.imageIsOpenImmersion V.2 (Y.ofRestrict _)⟩
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 _)⟩
    

Proof state:
case a
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y : Scheme
f : X ⟶ Y
U : Opens ↑↑Y.toPresheafedSpace
H : targetAffineLocally P f
V : ↑(Scheme.affineOpens (Y ∣_ᵤ U))
⊢ toProperty P (f ∣_ (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion U))).obj ↑V) ↔
    P
      (f ∣_
        ↑{ val := (Scheme.Hom.opensFunctor (Scheme.ofRestrict Y (_ : OpenEmbedding ⇑(Opens.inclusion U)))).obj ↑V,
            property :=
              (_ :
                IsAffineOpen
                  ((Scheme.Hom.opensFunctor (Scheme.ofRestrict Y (_ : OpenEmbedding ⇑(Opens.inclusion U)))).obj ↑V)) })

Next tactic:
rw [← P.toProperty_apply (i := IsAffineOpen.imageIsOpenImmersion V.2 (Y.ofRestrict _))]
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 _))]
  · 

Proof state:
case of_openCover
P : AffineTargetMorphismProperty
hP : IsLocal P
⊢ ∀ {X Y : Scheme} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover Y),
    (∀ (i : 𝒰.J), targetAffineLocally P pullback.snd) → targetAffineLocally P f

Next tactic:
rintro X Y f 𝒰 h𝒰
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
    

Proof state:
case of_openCover
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover Y
h𝒰 : ∀ (i : 𝒰.J), targetAffineLocally P pullback.snd
⊢ targetAffineLocally P f

Next tactic:
have h01 := (hP.affine_openCover_TFAE f).out 0 1
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
    

Proof state:
case of_openCover
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover Y
h𝒰 : ∀ (i : 𝒰.J), targetAffineLocally P pullback.snd
h01 :
  targetAffineLocally P f ↔ ∃ 𝒰, ∃ (x : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)), ∀ (i : 𝒰.J), P pullback.snd
⊢ targetAffineLocally P f

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

Proof state:
case of_openCover
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover Y
h𝒰 : ∀ (i : 𝒰.J), targetAffineLocally P pullback.snd
h01 :
  targetAffineLocally P f ↔ ∃ 𝒰, ∃ (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:
refine' ⟨𝒰.bind fun _ => Scheme.affineCover _, _, _⟩
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 _, _, _⟩
    · 

Proof state:
case of_openCover.refine'_1
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover Y
h𝒰 : ∀ (i : 𝒰.J), targetAffineLocally P pullback.snd
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),
    IsAffine (Scheme.OpenCover.obj (Scheme.OpenCover.bind 𝒰 fun x => Scheme.affineCover (Scheme.OpenCover.obj 𝒰 x)) i)

Next tactic:
intro i
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; 

Proof state:
case of_openCover.refine'_1
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover Y
h𝒰 : ∀ (i : 𝒰.J), targetAffineLocally P pullback.snd
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
⊢ IsAffine (Scheme.OpenCover.obj (Scheme.OpenCover.bind 𝒰 fun x => Scheme.affineCover (Scheme.OpenCover.obj 𝒰 x)) i)

Next tactic:
dsimp [Scheme.OpenCover.bind]
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]; 

Proof state:
case of_openCover.refine'_1
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover Y
h𝒰 : ∀ (i : 𝒰.J), targetAffineLocally P pullback.snd
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
⊢ IsAffine (Scheme.OpenCover.obj (Scheme.affineCover (Scheme.OpenCover.obj 𝒰 i.fst)) i.snd)

Next tactic:
infer_instance
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
    · 

Proof state:
case of_openCover.refine'_2
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover Y
h𝒰 : ∀ (i : 𝒰.J), targetAffineLocally P pullback.snd
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), P pullback.snd

Next tactic:
intro i