l3lab/ntp-mathlib huggingface dataset:
theorem targetAffineLocallyOfOpenCover {P : AffineTargetMorphismProperty} (hP : P.IsLocal)
    {X Y : Scheme} (f : X ⟶ Y) (𝒰 : Y.OpenCover) [∀ i, IsAffine (𝒰.obj i)]
    (h𝒰 : ∀ i, P (pullback.snd : (𝒰.pullbackCover f).obj i ⟶ 𝒰.obj i)) :
    targetAffineLocally P f := by
  classical
  let S i := (⟨⟨Set.range (𝒰.map i).1.base, (𝒰.IsOpen i).base_open.open_range⟩,
    rangeIsAffineOpenOfOpenImmersion (𝒰.map i)⟩ : Y.affineOpens)
  intro U
  apply of_affine_open_cover (P := _) U (Set.range S)
  · intro U r h
    haveI : IsAffine _ := U.2
    have := hP.2 (f ∣_ U.1)
    replace this := this (Y.presheaf.map (eqToHom U.1.openEmbedding_obj_top).op r) h
    -- Porting note : the following 2 instances was not necessary
    haveI i1 : IsAffine (Y.restrict (Scheme.affineBasicOpen Y r).1.openEmbedding) :=
      (Scheme.affineBasicOpen Y r).2
    haveI i2 : IsAffine
      ((Y.restrict U.1.openEmbedding).restrict
        ((Y.restrict U.1.openEmbedding).basicOpen <|
          (Y.presheaf.map (eqToHom U.1.openEmbedding_obj_top).op r)).openEmbedding) :=
      IsAffineOpen.basicOpenIsAffine (X := Y.restrict U.1.openEmbedding) (topIsAffineOpen _) _
    rw [← P.toProperty_apply] at this ⊢
    exact (hP.1.arrow_mk_iso_iff (morphismRestrictRestrictBasicOpen f _ r)).mp this
  · intro U s hs H
    haveI : IsAffine _ := U.2
    apply hP.3 (f ∣_ U.1) (s.image (Y.presheaf.map (eqToHom U.1.openEmbedding_obj_top).op))
    · apply_fun Ideal.comap (Y.presheaf.map (eqToHom U.1.openEmbedding_obj_top.symm).op) at hs
      rw [Ideal.comap_top] at hs
      rw [← hs]
      simp only [eqToHom_op, eqToHom_map, Finset.coe_image]
      have : ∀ {R S : CommRingCat} (e : S = R) (s : Set S),
          Ideal.span (eqToHom e '' s) = Ideal.comap (eqToHom e.symm) (Ideal.span s) := by
        

Proof state:
P : AffineTargetMorphismProperty
hP : AffineTargetMorphismProperty.IsLocal P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover Y
inst✝ : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)
h𝒰 : ∀ (i : (Scheme.OpenCover.pullbackCover 𝒰 f).J), P pullback.snd
S : 𝒰.J → { x // x ∈ Scheme.affineOpens Y } :=
  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 Y)
s : Finset ↑(Y.presheaf.obj (op ↑U))
H : ∀ (f_1 : { x // x ∈ s }), P (f ∣_ ↑(Scheme.affineBasicOpen Y ↑f_1))
this : IsAffine (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
hs :
  Ideal.comap (Y.presheaf.map (eqToHom (_ : ↑U = (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤)).op)
      (Ideal.span ↑s) =
    ⊤
⊢ ∀ {R S : CommRingCat} (e : S = R) (s : Set ↑S),
    Ideal.span (⇑(eqToHom e) '' s) = Ideal.comap (eqToHom (_ : R = S)) (Ideal.span s)

Next tactic:
intro _ _ e _
theorem targetAffineLocallyOfOpenCover {P : AffineTargetMorphismProperty} (hP : P.IsLocal)
    {X Y : Scheme} (f : X ⟶ Y) (𝒰 : Y.OpenCover) [∀ i, IsAffine (𝒰.obj i)]
    (h𝒰 : ∀ i, P (pullback.snd : (𝒰.pullbackCover f).obj i ⟶ 𝒰.obj i)) :
    targetAffineLocally P f := by
  classical
  let S i := (⟨⟨Set.range (𝒰.map i).1.base, (𝒰.IsOpen i).base_open.open_range⟩,
    rangeIsAffineOpenOfOpenImmersion (𝒰.map i)⟩ : Y.affineOpens)
  intro U
  apply of_affine_open_cover (P := _) U (Set.range S)
  · intro U r h
    haveI : IsAffine _ := U.2
    have := hP.2 (f ∣_ U.1)
    replace this := this (Y.presheaf.map (eqToHom U.1.openEmbedding_obj_top).op r) h
    -- Porting note : the following 2 instances was not necessary
    haveI i1 : IsAffine (Y.restrict (Scheme.affineBasicOpen Y r).1.openEmbedding) :=
      (Scheme.affineBasicOpen Y r).2
    haveI i2 : IsAffine
      ((Y.restrict U.1.openEmbedding).restrict
        ((Y.restrict U.1.openEmbedding).basicOpen <|
          (Y.presheaf.map (eqToHom U.1.openEmbedding_obj_top).op r)).openEmbedding) :=
      IsAffineOpen.basicOpenIsAffine (X := Y.restrict U.1.openEmbedding) (topIsAffineOpen _) _
    rw [← P.toProperty_apply] at this ⊢
    exact (hP.1.arrow_mk_iso_iff (morphismRestrictRestrictBasicOpen f _ r)).mp this
  · intro U s hs H
    haveI : IsAffine _ := U.2
    apply hP.3 (f ∣_ U.1) (s.image (Y.presheaf.map (eqToHom U.1.openEmbedding_obj_top).op))
    · apply_fun Ideal.comap (Y.presheaf.map (eqToHom U.1.openEmbedding_obj_top.symm).op) at hs
      rw [Ideal.comap_top] at hs
      rw [← hs]
      simp only [eqToHom_op, eqToHom_map, Finset.coe_image]
      have : ∀ {R S : CommRingCat} (e : S = R) (s : Set S),
          Ideal.span (eqToHom e '' s) = Ideal.comap (eqToHom e.symm) (Ideal.span s) := by
        intro _ _ e _
        

Proof state:
P : AffineTargetMorphismProperty
hP : AffineTargetMorphismProperty.IsLocal P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover Y
inst✝ : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)
h𝒰 : ∀ (i : (Scheme.OpenCover.pullbackCover 𝒰 f).J), P pullback.snd
S : 𝒰.J → { x // x ∈ Scheme.affineOpens Y } :=
  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 Y)
s : Finset ↑(Y.presheaf.obj (op ↑U))
H : ∀ (f_1 : { x // x ∈ s }), P (f ∣_ ↑(Scheme.affineBasicOpen Y ↑f_1))
this : IsAffine (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
hs :
  Ideal.comap (Y.presheaf.map (eqToHom (_ : ↑U = (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤)).op)
      (Ideal.span ↑s) =
    ⊤
R✝ S✝ : CommRingCat
e : S✝ = R✝
s✝ : Set ↑S✝
⊢ Ideal.span (⇑(eqToHom e) '' s✝) = Ideal.comap (eqToHom (_ : R✝ = S✝)) (Ideal.span s✝)

Next tactic:
subst e
theorem targetAffineLocallyOfOpenCover {P : AffineTargetMorphismProperty} (hP : P.IsLocal)
    {X Y : Scheme} (f : X ⟶ Y) (𝒰 : Y.OpenCover) [∀ i, IsAffine (𝒰.obj i)]
    (h𝒰 : ∀ i, P (pullback.snd : (𝒰.pullbackCover f).obj i ⟶ 𝒰.obj i)) :
    targetAffineLocally P f := by
  classical
  let S i := (⟨⟨Set.range (𝒰.map i).1.base, (𝒰.IsOpen i).base_open.open_range⟩,
    rangeIsAffineOpenOfOpenImmersion (𝒰.map i)⟩ : Y.affineOpens)
  intro U
  apply of_affine_open_cover (P := _) U (Set.range S)
  · intro U r h
    haveI : IsAffine _ := U.2
    have := hP.2 (f ∣_ U.1)
    replace this := this (Y.presheaf.map (eqToHom U.1.openEmbedding_obj_top).op r) h
    -- Porting note : the following 2 instances was not necessary
    haveI i1 : IsAffine (Y.restrict (Scheme.affineBasicOpen Y r).1.openEmbedding) :=
      (Scheme.affineBasicOpen Y r).2
    haveI i2 : IsAffine
      ((Y.restrict U.1.openEmbedding).restrict
        ((Y.restrict U.1.openEmbedding).basicOpen <|
          (Y.presheaf.map (eqToHom U.1.openEmbedding_obj_top).op r)).openEmbedding) :=
      IsAffineOpen.basicOpenIsAffine (X := Y.restrict U.1.openEmbedding) (topIsAffineOpen _) _
    rw [← P.toProperty_apply] at this ⊢
    exact (hP.1.arrow_mk_iso_iff (morphismRestrictRestrictBasicOpen f _ r)).mp this
  · intro U s hs H
    haveI : IsAffine _ := U.2
    apply hP.3 (f ∣_ U.1) (s.image (Y.presheaf.map (eqToHom U.1.openEmbedding_obj_top).op))
    · apply_fun Ideal.comap (Y.presheaf.map (eqToHom U.1.openEmbedding_obj_top.symm).op) at hs
      rw [Ideal.comap_top] at hs
      rw [← hs]
      simp only [eqToHom_op, eqToHom_map, Finset.coe_image]
      have : ∀ {R S : CommRingCat} (e : S = R) (s : Set S),
          Ideal.span (eqToHom e '' s) = Ideal.comap (eqToHom e.symm) (Ideal.span s) := by
        intro _ _ e _
        subst e
        

Proof state:
P : AffineTargetMorphismProperty
hP : AffineTargetMorphismProperty.IsLocal P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover Y
inst✝ : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)
h𝒰 : ∀ (i : (Scheme.OpenCover.pullbackCover 𝒰 f).J), P pullback.snd
S : 𝒰.J → { x // x ∈ Scheme.affineOpens Y } :=
  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 Y)
s : Finset ↑(Y.presheaf.obj (op ↑U))
H : ∀ (f_1 : { x // x ∈ s }), P (f ∣_ ↑(Scheme.affineBasicOpen Y ↑f_1))
this : IsAffine (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
hs :
  Ideal.comap (Y.presheaf.map (eqToHom (_ : ↑U = (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤)).op)
      (Ideal.span ↑s) =
    ⊤
S✝ : CommRingCat
s✝ : Set ↑S✝
⊢ Ideal.span (⇑(eqToHom (_ : S✝ = S✝)) '' s✝) = Ideal.comap (eqToHom (_ : S✝ = S✝)) (Ideal.span s✝)

Next tactic:
simp only [eqToHom_refl, id_apply, Set.image_id']
theorem targetAffineLocallyOfOpenCover {P : AffineTargetMorphismProperty} (hP : P.IsLocal)
    {X Y : Scheme} (f : X ⟶ Y) (𝒰 : Y.OpenCover) [∀ i, IsAffine (𝒰.obj i)]
    (h𝒰 : ∀ i, P (pullback.snd : (𝒰.pullbackCover f).obj i ⟶ 𝒰.obj i)) :
    targetAffineLocally P f := by
  classical
  let S i := (⟨⟨Set.range (𝒰.map i).1.base, (𝒰.IsOpen i).base_open.open_range⟩,
    rangeIsAffineOpenOfOpenImmersion (𝒰.map i)⟩ : Y.affineOpens)
  intro U
  apply of_affine_open_cover (P := _) U (Set.range S)
  · intro U r h
    haveI : IsAffine _ := U.2
    have := hP.2 (f ∣_ U.1)
    replace this := this (Y.presheaf.map (eqToHom U.1.openEmbedding_obj_top).op r) h
    -- Porting note : the following 2 instances was not necessary
    haveI i1 : IsAffine (Y.restrict (Scheme.affineBasicOpen Y r).1.openEmbedding) :=
      (Scheme.affineBasicOpen Y r).2
    haveI i2 : IsAffine
      ((Y.restrict U.1.openEmbedding).restrict
        ((Y.restrict U.1.openEmbedding).basicOpen <|
          (Y.presheaf.map (eqToHom U.1.openEmbedding_obj_top).op r)).openEmbedding) :=
      IsAffineOpen.basicOpenIsAffine (X := Y.restrict U.1.openEmbedding) (topIsAffineOpen _) _
    rw [← P.toProperty_apply] at this ⊢
    exact (hP.1.arrow_mk_iso_iff (morphismRestrictRestrictBasicOpen f _ r)).mp this
  · intro U s hs H
    haveI : IsAffine _ := U.2
    apply hP.3 (f ∣_ U.1) (s.image (Y.presheaf.map (eqToHom U.1.openEmbedding_obj_top).op))
    · apply_fun Ideal.comap (Y.presheaf.map (eqToHom U.1.openEmbedding_obj_top.symm).op) at hs
      rw [Ideal.comap_top] at hs
      rw [← hs]
      simp only [eqToHom_op, eqToHom_map, Finset.coe_image]
      have : ∀ {R S : CommRingCat} (e : S = R) (s : Set S),
          Ideal.span (eqToHom e '' s) = Ideal.comap (eqToHom e.symm) (Ideal.span s) := by
        intro _ _ e _
        subst e
        simp only [eqToHom_refl, id_apply, Set.image_id']
        -- Porting note : Lean didn't see `𝟙 _` is just ring hom id
        

Proof state:
P : AffineTargetMorphismProperty
hP : AffineTargetMorphismProperty.IsLocal P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover Y
inst✝ : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)
h𝒰 : ∀ (i : (Scheme.OpenCover.pullbackCover 𝒰 f).J), P pullback.snd
S : 𝒰.J → { x // x ∈ Scheme.affineOpens Y } :=
  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 Y)
s : Finset ↑(Y.presheaf.obj (op ↑U))
H : ∀ (f_1 : { x // x ∈ s }), P (f ∣_ ↑(Scheme.affineBasicOpen Y ↑f_1))
this : IsAffine (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
hs :
  Ideal.comap (Y.presheaf.map (eqToHom (_ : ↑U = (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤)).op)
      (Ideal.span ↑s) =
    ⊤
S✝ : CommRingCat
s✝ : Set ↑S✝
⊢ Ideal.span s✝ = Ideal.comap (𝟙 S✝) (Ideal.span s✝)

Next tactic:
exact (Ideal.comap_id _).symm
theorem targetAffineLocallyOfOpenCover {P : AffineTargetMorphismProperty} (hP : P.IsLocal)
    {X Y : Scheme} (f : X ⟶ Y) (𝒰 : Y.OpenCover) [∀ i, IsAffine (𝒰.obj i)]
    (h𝒰 : ∀ i, P (pullback.snd : (𝒰.pullbackCover f).obj i ⟶ 𝒰.obj i)) :
    targetAffineLocally P f := by
  classical
  let S i := (⟨⟨Set.range (𝒰.map i).1.base, (𝒰.IsOpen i).base_open.open_range⟩,
    rangeIsAffineOpenOfOpenImmersion (𝒰.map i)⟩ : Y.affineOpens)
  intro U
  apply of_affine_open_cover (P := _) U (Set.range S)
  · intro U r h
    haveI : IsAffine _ := U.2
    have := hP.2 (f ∣_ U.1)
    replace this := this (Y.presheaf.map (eqToHom U.1.openEmbedding_obj_top).op r) h
    -- Porting note : the following 2 instances was not necessary
    haveI i1 : IsAffine (Y.restrict (Scheme.affineBasicOpen Y r).1.openEmbedding) :=
      (Scheme.affineBasicOpen Y r).2
    haveI i2 : IsAffine
      ((Y.restrict U.1.openEmbedding).restrict
        ((Y.restrict U.1.openEmbedding).basicOpen <|
          (Y.presheaf.map (eqToHom U.1.openEmbedding_obj_top).op r)).openEmbedding) :=
      IsAffineOpen.basicOpenIsAffine (X := Y.restrict U.1.openEmbedding) (topIsAffineOpen _) _
    rw [← P.toProperty_apply] at this ⊢
    exact (hP.1.arrow_mk_iso_iff (morphismRestrictRestrictBasicOpen f _ r)).mp this
  · intro U s hs H
    haveI : IsAffine _ := U.2
    apply hP.3 (f ∣_ U.1) (s.image (Y.presheaf.map (eqToHom U.1.openEmbedding_obj_top).op))
    · apply_fun Ideal.comap (Y.presheaf.map (eqToHom U.1.openEmbedding_obj_top.symm).op) at hs
      rw [Ideal.comap_top] at hs
      rw [← hs]
      simp only [eqToHom_op, eqToHom_map, Finset.coe_image]
      have : ∀ {R S : CommRingCat} (e : S = R) (s : Set S),
          Ideal.span (eqToHom e '' s) = Ideal.comap (eqToHom e.symm) (Ideal.span s) := by
        intro _ _ e _
        subst e
        simp only [eqToHom_refl, id_apply, Set.image_id']
        -- Porting note : Lean didn't see `𝟙 _` is just ring hom id
        exact (Ideal.comap_id _).symm
      apply this
    · 

Proof state:
case hP₂.a
P : AffineTargetMorphismProperty
hP : AffineTargetMorphismProperty.IsLocal P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover Y
inst✝ : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)
h𝒰 : ∀ (i : (Scheme.OpenCover.pullbackCover 𝒰 f).J), P pullback.snd
S : 𝒰.J → { x // x ∈ Scheme.affineOpens Y } :=
  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 Y)
s : Finset ↑(Y.presheaf.obj (op ↑U))
hs : Ideal.span ↑s = ⊤
H : ∀ (f_1 : { x // x ∈ s }), P (f ∣_ ↑(Scheme.affineBasicOpen Y ↑f_1))
this : IsAffine (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
⊢ ∀
    (r :
      { x //
        x ∈
          Finset.image
            (⇑(Y.presheaf.map (eqToHom (_ : (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤ = ↑U)).op))
            s }),
    P (f ∣_ ↑U ∣_ (Y ∣_ᵤ ↑U).basicOpen ↑r)

Next tactic:
rintro ⟨r, hr⟩
open List in
theorem AffineTargetMorphismProperty.IsLocal.affine_openCover_TFAE
    {P : AffineTargetMorphismProperty} (hP : P.IsLocal) {X Y : Scheme.{u}} (f : X ⟶ Y) :
    TFAE
      [targetAffineLocally P f,
        ∃ (𝒰 : Scheme.OpenCover.{u} Y) (_ : ∀ i, IsAffine (𝒰.obj i)),
          ∀ i : 𝒰.J, P (pullback.snd : (𝒰.pullbackCover f).obj i ⟶ 𝒰.obj i),
        ∀ (𝒰 : 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),
        ∃ (ι : Type u) (U : ι → Opens Y.carrier) (_ : iSup U = ⊤) (hU' : ∀ i, IsAffineOpen (U i)),
          ∀ i, @P _ _ (f ∣_ U i) (hU' i)] := by
  

Proof state:
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y : Scheme
f : X ⟶ Y
⊢ TFAE
    [targetAffineLocally P f,
      ∃ 𝒰, ∃ (x : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)), ∀ (i : 𝒰.J), P pullback.snd,
      ∀ (𝒰 : Scheme.OpenCover Y) [inst : ∀ (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,
      ∃ ι U, ∃ (_ : iSup U = ⊤) (hU' : ∀ (i : ι), IsAffineOpen (U i)), ∀ (i : ι), P (f ∣_ U i)]

Next tactic:
tfae_have 1 → 4
open List in
theorem AffineTargetMorphismProperty.IsLocal.affine_openCover_TFAE
    {P : AffineTargetMorphismProperty} (hP : P.IsLocal) {X Y : Scheme.{u}} (f : X ⟶ Y) :
    TFAE
      [targetAffineLocally P f,
        ∃ (𝒰 : Scheme.OpenCover.{u} Y) (_ : ∀ i, IsAffine (𝒰.obj i)),
          ∀ i : 𝒰.J, P (pullback.snd : (𝒰.pullbackCover f).obj i ⟶ 𝒰.obj i),
        ∀ (𝒰 : 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),
        ∃ (ι : Type u) (U : ι → Opens Y.carrier) (_ : iSup U = ⊤) (hU' : ∀ i, IsAffineOpen (U i)),
          ∀ i, @P _ _ (f ∣_ U i) (hU' i)] := by
  tfae_have 1 → 4
  · 

Proof state:
case tfae_1_to_4
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y : Scheme
f : X ⟶ Y
⊢ targetAffineLocally P f → ∀ {U : Scheme} (g : U ⟶ Y) [inst : IsAffine U] [inst_1 : IsOpenImmersion g], P pullback.snd

Next tactic:
intro H U g h₁ h₂
open List in
theorem AffineTargetMorphismProperty.IsLocal.affine_openCover_TFAE
    {P : AffineTargetMorphismProperty} (hP : P.IsLocal) {X Y : Scheme.{u}} (f : X ⟶ Y) :
    TFAE
      [targetAffineLocally P f,
        ∃ (𝒰 : Scheme.OpenCover.{u} Y) (_ : ∀ i, IsAffine (𝒰.obj i)),
          ∀ i : 𝒰.J, P (pullback.snd : (𝒰.pullbackCover f).obj i ⟶ 𝒰.obj i),
        ∀ (𝒰 : 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),
        ∃ (ι : Type u) (U : ι → Opens Y.carrier) (_ : iSup U = ⊤) (hU' : ∀ i, IsAffineOpen (U i)),
          ∀ i, @P _ _ (f ∣_ U i) (hU' i)] := by
  tfae_have 1 → 4
  · intro H U g h₁ h₂
    -- Porting note : I need to add `i1` manually, so to save some typing, named this variable
    

Proof state:
case tfae_1_to_4
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y : Scheme
f : X ⟶ Y
H : targetAffineLocally P f
U : Scheme
g : U ⟶ Y
h₁ : IsAffine U
h₂ : IsOpenImmersion g
⊢ P pullback.snd

Next tactic:
set U' : Opens _ := ⟨_, h₂.base_open.open_range⟩
open List in
theorem AffineTargetMorphismProperty.IsLocal.affine_openCover_TFAE
    {P : AffineTargetMorphismProperty} (hP : P.IsLocal) {X Y : Scheme.{u}} (f : X ⟶ Y) :
    TFAE
      [targetAffineLocally P f,
        ∃ (𝒰 : Scheme.OpenCover.{u} Y) (_ : ∀ i, IsAffine (𝒰.obj i)),
          ∀ i : 𝒰.J, P (pullback.snd : (𝒰.pullbackCover f).obj i ⟶ 𝒰.obj i),
        ∀ (𝒰 : 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),
        ∃ (ι : Type u) (U : ι → Opens Y.carrier) (_ : iSup U = ⊤) (hU' : ∀ i, IsAffineOpen (U i)),
          ∀ i, @P _ _ (f ∣_ U i) (hU' i)] := by
  tfae_have 1 → 4
  · intro H U g h₁ h₂
    -- Porting note : I need to add `i1` manually, so to save some typing, named this variable
    set U' : Opens _ := ⟨_, h₂.base_open.open_range⟩
    

Proof state:
case tfae_1_to_4
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y : Scheme
f : X ⟶ Y
H : targetAffineLocally P f
U : Scheme
g : U ⟶ Y
h₁ : IsAffine U
h₂ : IsOpenImmersion g
U' : Opens ((forget TopCat).obj ↑Y.toPresheafedSpace) :=
  { carrier := Set.range ⇑g.val.base, is_open' := (_ : IsOpen (Set.range ⇑g.val.base)) }
⊢ P pullback.snd

Next tactic:
replace H := H ⟨U', rangeIsAffineOpenOfOpenImmersion g⟩
open List in
theorem AffineTargetMorphismProperty.IsLocal.affine_openCover_TFAE
    {P : AffineTargetMorphismProperty} (hP : P.IsLocal) {X Y : Scheme.{u}} (f : X ⟶ Y) :
    TFAE
      [targetAffineLocally P f,
        ∃ (𝒰 : Scheme.OpenCover.{u} Y) (_ : ∀ i, IsAffine (𝒰.obj i)),
          ∀ i : 𝒰.J, P (pullback.snd : (𝒰.pullbackCover f).obj i ⟶ 𝒰.obj i),
        ∀ (𝒰 : 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),
        ∃ (ι : Type u) (U : ι → Opens Y.carrier) (_ : iSup U = ⊤) (hU' : ∀ i, IsAffineOpen (U i)),
          ∀ i, @P _ _ (f ∣_ U i) (hU' i)] := by
  tfae_have 1 → 4
  · intro H U g h₁ h₂
    -- Porting note : I need to add `i1` manually, so to save some typing, named this variable
    set U' : Opens _ := ⟨_, h₂.base_open.open_range⟩
    replace H := H ⟨U', rangeIsAffineOpenOfOpenImmersion g⟩
    

Proof state:
case tfae_1_to_4
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y : Scheme
f : X ⟶ Y
U : Scheme
g : U ⟶ Y
h₁ : IsAffine U
h₂ : IsOpenImmersion g
U' : Opens ((forget TopCat).obj ↑Y.toPresheafedSpace) :=
  { carrier := Set.range ⇑g.val.base, is_open' := (_ : IsOpen (Set.range ⇑g.val.base)) }
H : P (f ∣_ ↑{ val := U', property := (_ : IsAffineOpen (Scheme.Hom.opensRange g)) })
⊢ P pullback.snd

Next tactic:
haveI i1 : IsAffine (Y.restrict U'.openEmbedding) := rangeIsAffineOpenOfOpenImmersion g
open List in
theorem AffineTargetMorphismProperty.IsLocal.affine_openCover_TFAE
    {P : AffineTargetMorphismProperty} (hP : P.IsLocal) {X Y : Scheme.{u}} (f : X ⟶ Y) :
    TFAE
      [targetAffineLocally P f,
        ∃ (𝒰 : Scheme.OpenCover.{u} Y) (_ : ∀ i, IsAffine (𝒰.obj i)),
          ∀ i : 𝒰.J, P (pullback.snd : (𝒰.pullbackCover f).obj i ⟶ 𝒰.obj i),
        ∀ (𝒰 : 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),
        ∃ (ι : Type u) (U : ι → Opens Y.carrier) (_ : iSup U = ⊤) (hU' : ∀ i, IsAffineOpen (U i)),
          ∀ i, @P _ _ (f ∣_ U i) (hU' i)] := by
  tfae_have 1 → 4
  · intro H U g h₁ h₂
    -- Porting note : I need to add `i1` manually, so to save some typing, named this variable
    set U' : Opens _ := ⟨_, h₂.base_open.open_range⟩
    replace H := H ⟨U', rangeIsAffineOpenOfOpenImmersion g⟩
    haveI i1 : IsAffine (Y.restrict U'.openEmbedding) := rangeIsAffineOpenOfOpenImmersion g
    

Proof state:
case tfae_1_to_4
P : AffineTargetMorphismProperty
hP : IsLocal P
X Y : Scheme
f : X ⟶ Y
U : Scheme
g : U ⟶ Y
h₁ : IsAffine U
h₂ : IsOpenImmersion g
U' : Opens ((forget TopCat).obj ↑Y.toPresheafedSpace) :=
  { carrier := Set.range ⇑g.val.base, is_open' := (_ : IsOpen (Set.range ⇑g.val.base)) }
H : P (f ∣_ ↑{ val := U', property := (_ : IsAffineOpen (Scheme.Hom.opensRange g)) })
i1 : IsAffine (Y ∣_ᵤ U')
⊢ P pullback.snd

Next tactic:
rw [← P.toProperty_apply] at H ⊢