l3lab/ntp-mathlib huggingface dataset:
theorem AffineTargetMorphismProperty.respectsIso_mk {P : AffineTargetMorphismProperty}
    (h₁ : ∀ {X Y Z} (e : X ≅ Y) (f : Y ⟶ Z) [IsAffine Z], P f → P (e.hom ≫ f))
    (h₂ : ∀ {X Y Z} (e : Y ≅ Z) (f : X ⟶ Y) [h : IsAffine Y],
      P f → @P _ _ (f ≫ e.hom) (isAffineOfIso e.inv)) :
    P.toProperty.RespectsIso := by
  constructor
  · rintro X Y Z e f ⟨a, h⟩; 

Proof state:
case left.intro
P : AffineTargetMorphismProperty
h₁ : ∀ {X Y Z : Scheme} (e : X ≅ Y) (f : Y ⟶ Z) [inst : IsAffine Z], P f → P (e.hom ≫ f)
h₂ : ∀ {X Y Z : Scheme} (e : Y ≅ Z) (f : X ⟶ Y) [h : IsAffine Y], P f → P (f ≫ e.hom)
X Y Z : Scheme
e : X ≅ Y
f : Y ⟶ Z
a : IsAffine Z
h : P f
⊢ toProperty P (e.hom ≫ f)

Next tactic:
exact ⟨a, h₁ e f h⟩
theorem AffineTargetMorphismProperty.respectsIso_mk {P : AffineTargetMorphismProperty}
    (h₁ : ∀ {X Y Z} (e : X ≅ Y) (f : Y ⟶ Z) [IsAffine Z], P f → P (e.hom ≫ f))
    (h₂ : ∀ {X Y Z} (e : Y ≅ Z) (f : X ⟶ Y) [h : IsAffine Y],
      P f → @P _ _ (f ≫ e.hom) (isAffineOfIso e.inv)) :
    P.toProperty.RespectsIso := by
  constructor
  · rintro X Y Z e f ⟨a, h⟩; exact ⟨a, h₁ e f h⟩
  · 

Proof state:
case right
P : AffineTargetMorphismProperty
h₁ : ∀ {X Y Z : Scheme} (e : X ≅ Y) (f : Y ⟶ Z) [inst : IsAffine Z], P f → P (e.hom ≫ f)
h₂ : ∀ {X Y Z : Scheme} (e : Y ≅ Z) (f : X ⟶ Y) [h : IsAffine Y], P f → P (f ≫ e.hom)
⊢ ∀ {X Y Z : Scheme} (e : Y ≅ Z) (f : X ⟶ Y), toProperty P f → toProperty P (f ≫ e.hom)

Next tactic:
rintro X Y Z e f ⟨a, h⟩
theorem AffineTargetMorphismProperty.respectsIso_mk {P : AffineTargetMorphismProperty}
    (h₁ : ∀ {X Y Z} (e : X ≅ Y) (f : Y ⟶ Z) [IsAffine Z], P f → P (e.hom ≫ f))
    (h₂ : ∀ {X Y Z} (e : Y ≅ Z) (f : X ⟶ Y) [h : IsAffine Y],
      P f → @P _ _ (f ≫ e.hom) (isAffineOfIso e.inv)) :
    P.toProperty.RespectsIso := by
  constructor
  · rintro X Y Z e f ⟨a, h⟩; exact ⟨a, h₁ e f h⟩
  · rintro X Y Z e f ⟨a, h⟩; 

Proof state:
case right.intro
P : AffineTargetMorphismProperty
h₁ : ∀ {X Y Z : Scheme} (e : X ≅ Y) (f : Y ⟶ Z) [inst : IsAffine Z], P f → P (e.hom ≫ f)
h₂ : ∀ {X Y Z : Scheme} (e : Y ≅ Z) (f : X ⟶ Y) [h : IsAffine Y], P f → P (f ≫ e.hom)
X Y Z : Scheme
e : Y ≅ Z
f : X ⟶ Y
a : IsAffine Y
h : P f
⊢ toProperty P (f ≫ e.hom)

Next tactic:
exact ⟨isAffineOfIso e.inv, h₂ e f h⟩
theorem targetAffineLocally_respectsIso {P : AffineTargetMorphismProperty}
    (hP : P.toProperty.RespectsIso) : (targetAffineLocally P).RespectsIso := by
  

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

Next tactic:
constructor
theorem targetAffineLocally_respectsIso {P : AffineTargetMorphismProperty}
    (hP : P.toProperty.RespectsIso) : (targetAffineLocally P).RespectsIso := by
  constructor
  · 

Proof state:
case left
P : AffineTargetMorphismProperty
hP : MorphismProperty.RespectsIso (AffineTargetMorphismProperty.toProperty P)
⊢ ∀ {X Y Z : Scheme} (e : X ≅ Y) (f : Y ⟶ Z), targetAffineLocally P f → targetAffineLocally P (e.hom ≫ f)

Next tactic:
introv H U
theorem targetAffineLocally_respectsIso {P : AffineTargetMorphismProperty}
    (hP : P.toProperty.RespectsIso) : (targetAffineLocally P).RespectsIso := by
  constructor
  · introv H U
    -- Porting note : added this instance
    

Proof state:
case left
P : AffineTargetMorphismProperty
hP : MorphismProperty.RespectsIso (AffineTargetMorphismProperty.toProperty P)
X Y Z : Scheme
e : X ≅ Y
f : Y ⟶ Z
H : targetAffineLocally P f
U : ↑(Scheme.affineOpens Z)
⊢ P ((e.hom ≫ f) ∣_ ↑U)

Next tactic:
haveI : IsAffine _ := U.prop
theorem targetAffineLocally_respectsIso {P : AffineTargetMorphismProperty}
    (hP : P.toProperty.RespectsIso) : (targetAffineLocally P).RespectsIso := by
  constructor
  · introv H U
    -- Porting note : added this instance
    haveI : IsAffine _ := U.prop
    

Proof state:
case left
P : AffineTargetMorphismProperty
hP : MorphismProperty.RespectsIso (AffineTargetMorphismProperty.toProperty P)
X Y Z : Scheme
e : X ≅ Y
f : Y ⟶ Z
H : targetAffineLocally P f
U : ↑(Scheme.affineOpens Z)
this : IsAffine (Scheme.restrict Z (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
⊢ P ((e.hom ≫ f) ∣_ ↑U)

Next tactic:
rw [morphismRestrict_comp, affine_cancel_left_isIso hP]
theorem targetAffineLocally_respectsIso {P : AffineTargetMorphismProperty}
    (hP : P.toProperty.RespectsIso) : (targetAffineLocally P).RespectsIso := by
  constructor
  · introv H U
    -- Porting note : added this instance
    haveI : IsAffine _ := U.prop
    rw [morphismRestrict_comp, affine_cancel_left_isIso hP]
    

Proof state:
case left
P : AffineTargetMorphismProperty
hP : MorphismProperty.RespectsIso (AffineTargetMorphismProperty.toProperty P)
X Y Z : Scheme
e : X ≅ Y
f : Y ⟶ Z
H : targetAffineLocally P f
U : ↑(Scheme.affineOpens Z)
this : IsAffine (Scheme.restrict Z (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
⊢ P (f ∣_ ↑U)

Next tactic:
exact H U
theorem targetAffineLocally_respectsIso {P : AffineTargetMorphismProperty}
    (hP : P.toProperty.RespectsIso) : (targetAffineLocally P).RespectsIso := by
  constructor
  · introv H U
    -- Porting note : added this instance
    haveI : IsAffine _ := U.prop
    rw [morphismRestrict_comp, affine_cancel_left_isIso hP]
    exact H U
  · 

Proof state:
case right
P : AffineTargetMorphismProperty
hP : MorphismProperty.RespectsIso (AffineTargetMorphismProperty.toProperty P)
⊢ ∀ {X Y Z : Scheme} (e : Y ≅ Z) (f : X ⟶ Y), targetAffineLocally P f → targetAffineLocally P (f ≫ e.hom)

Next tactic:
introv H
theorem targetAffineLocally_respectsIso {P : AffineTargetMorphismProperty}
    (hP : P.toProperty.RespectsIso) : (targetAffineLocally P).RespectsIso := by
  constructor
  · introv H U
    -- Porting note : added this instance
    haveI : IsAffine _ := U.prop
    rw [morphismRestrict_comp, affine_cancel_left_isIso hP]
    exact H U
  · introv H
    

Proof state:
case right
P : AffineTargetMorphismProperty
hP : MorphismProperty.RespectsIso (AffineTargetMorphismProperty.toProperty P)
X Y Z : Scheme
e : Y ≅ Z
f : X ⟶ Y
H : targetAffineLocally P f
⊢ targetAffineLocally P (f ≫ e.hom)

Next tactic:
rintro ⟨U, hU : IsAffineOpen U⟩
theorem targetAffineLocally_respectsIso {P : AffineTargetMorphismProperty}
    (hP : P.toProperty.RespectsIso) : (targetAffineLocally P).RespectsIso := by
  constructor
  · introv H U
    -- Porting note : added this instance
    haveI : IsAffine _ := U.prop
    rw [morphismRestrict_comp, affine_cancel_left_isIso hP]
    exact H U
  · introv H
    rintro ⟨U, hU : IsAffineOpen U⟩; 

Proof state:
case right.mk
P : AffineTargetMorphismProperty
hP : MorphismProperty.RespectsIso (AffineTargetMorphismProperty.toProperty P)
X Y Z : Scheme
e : Y ≅ Z
f : X ⟶ Y
H : targetAffineLocally P f
U : Opens ↑↑Z.toPresheafedSpace
hU : IsAffineOpen U
⊢ P ((f ≫ e.hom) ∣_ ↑{ val := U, property := hU })

Next tactic:
dsimp
theorem targetAffineLocally_respectsIso {P : AffineTargetMorphismProperty}
    (hP : P.toProperty.RespectsIso) : (targetAffineLocally P).RespectsIso := by
  constructor
  · introv H U
    -- Porting note : added this instance
    haveI : IsAffine _ := U.prop
    rw [morphismRestrict_comp, affine_cancel_left_isIso hP]
    exact H U
  · introv H
    rintro ⟨U, hU : IsAffineOpen U⟩; dsimp
    

Proof state:
case right.mk
P : AffineTargetMorphismProperty
hP : MorphismProperty.RespectsIso (AffineTargetMorphismProperty.toProperty P)
X Y Z : Scheme
e : Y ≅ Z
f : X ⟶ Y
H : targetAffineLocally P f
U : Opens ↑↑Z.toPresheafedSpace
hU : IsAffineOpen U
⊢ P ((f ≫ e.hom) ∣_ U)

Next tactic:
haveI : IsAffine _ := hU
theorem targetAffineLocally_respectsIso {P : AffineTargetMorphismProperty}
    (hP : P.toProperty.RespectsIso) : (targetAffineLocally P).RespectsIso := by
  constructor
  · introv H U
    -- Porting note : added this instance
    haveI : IsAffine _ := U.prop
    rw [morphismRestrict_comp, affine_cancel_left_isIso hP]
    exact H U
  · introv H
    rintro ⟨U, hU : IsAffineOpen U⟩; dsimp
    haveI : IsAffine _ := hU
    

Proof state:
case right.mk
P : AffineTargetMorphismProperty
hP : MorphismProperty.RespectsIso (AffineTargetMorphismProperty.toProperty P)
X Y Z : Scheme
e : Y ≅ Z
f : X ⟶ Y
H : targetAffineLocally P f
U : Opens ↑↑Z.toPresheafedSpace
hU : IsAffineOpen U
this : IsAffine (Scheme.restrict Z (_ : OpenEmbedding ⇑(Opens.inclusion U)))
⊢ P ((f ≫ e.hom) ∣_ U)

Next tactic:
haveI : IsAffine _ := hU.map_isIso e.hom
theorem targetAffineLocally_respectsIso {P : AffineTargetMorphismProperty}
    (hP : P.toProperty.RespectsIso) : (targetAffineLocally P).RespectsIso := by
  constructor
  · introv H U
    -- Porting note : added this instance
    haveI : IsAffine _ := U.prop
    rw [morphismRestrict_comp, affine_cancel_left_isIso hP]
    exact H U
  · introv H
    rintro ⟨U, hU : IsAffineOpen U⟩; dsimp
    haveI : IsAffine _ := hU
    haveI : IsAffine _ := hU.map_isIso e.hom
    

Proof state:
case right.mk
P : AffineTargetMorphismProperty
hP : MorphismProperty.RespectsIso (AffineTargetMorphismProperty.toProperty P)
X Y Z : Scheme
e : Y ≅ Z
f : X ⟶ Y
H : targetAffineLocally P f
U : Opens ↑↑Z.toPresheafedSpace
hU : IsAffineOpen U
this✝ : IsAffine (Scheme.restrict Z (_ : OpenEmbedding ⇑(Opens.inclusion U)))
this : IsAffine (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion (e.hom⁻¹ᵁ U))))
⊢ P ((f ≫ e.hom) ∣_ U)

Next tactic:
rw [morphismRestrict_comp, affine_cancel_right_isIso hP]
theorem targetAffineLocally_respectsIso {P : AffineTargetMorphismProperty}
    (hP : P.toProperty.RespectsIso) : (targetAffineLocally P).RespectsIso := by
  constructor
  · introv H U
    -- Porting note : added this instance
    haveI : IsAffine _ := U.prop
    rw [morphismRestrict_comp, affine_cancel_left_isIso hP]
    exact H U
  · introv H
    rintro ⟨U, hU : IsAffineOpen U⟩; dsimp
    haveI : IsAffine _ := hU
    haveI : IsAffine _ := hU.map_isIso e.hom
    rw [morphismRestrict_comp, affine_cancel_right_isIso hP]
    

Proof state:
case right.mk
P : AffineTargetMorphismProperty
hP : MorphismProperty.RespectsIso (AffineTargetMorphismProperty.toProperty P)
X Y Z : Scheme
e : Y ≅ Z
f : X ⟶ Y
H : targetAffineLocally P f
U : Opens ↑↑Z.toPresheafedSpace
hU : IsAffineOpen U
this✝ : IsAffine (Scheme.restrict Z (_ : OpenEmbedding ⇑(Opens.inclusion U)))
this : IsAffine (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion (e.hom⁻¹ᵁ U))))
⊢ P (f ∣_ e.hom⁻¹ᵁ U)

Next tactic:
exact H ⟨(Opens.map e.hom.val.base).obj U, hU.map_isIso e.hom⟩
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
  

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
⊢ targetAffineLocally P f

Next tactic:
let S i := (⟨⟨Set.range (𝒰.map i).1.base, (𝒰.IsOpen i).base_open.open_range⟩,
    rangeIsAffineOpenOfOpenImmersion (𝒰.map i)⟩ : Y.affineOpens)
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)
  

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))) }
⊢ targetAffineLocally P f

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

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 : ↑(Scheme.affineOpens Y)
⊢ P (f ∣_ ↑U)

Next tactic:
apply of_affine_open_cover (P := _) U (Set.range S)
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)
  · 

Proof state:
case hP₁
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 : ↑(Scheme.affineOpens Y)
⊢ ∀ (U : ↑(Scheme.affineOpens Y)) (f_1 : ↑(Y.presheaf.obj (op ↑U))),
    P (f ∣_ ↑U) → P (f ∣_ ↑(Scheme.affineBasicOpen Y f_1))

Next tactic:
intro U r h
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
    

Proof state:
case hP₁
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)
r : ↑(Y.presheaf.obj (op ↑U))
h : P (f ∣_ ↑U)
⊢ P (f ∣_ ↑(Scheme.affineBasicOpen Y r))

Next tactic:
haveI : IsAffine _ := U.2
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
    

Proof state:
case hP₁
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)
r : ↑(Y.presheaf.obj (op ↑U))
h : P (f ∣_ ↑U)
this : IsAffine (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
⊢ P (f ∣_ ↑(Scheme.affineBasicOpen Y r))

Next tactic:
have := hP.2 (f ∣_ U.1)
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)
    

Proof state:
case hP₁
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)
r : ↑(Y.presheaf.obj (op ↑U))
h : P (f ∣_ ↑U)
this✝ : IsAffine (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
this :
  ∀ (r : ↑((Y ∣_ᵤ ↑U).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace.presheaf.obj (op ⊤))),
    P (f ∣_ ↑U) → P (f ∣_ ↑U ∣_ (Y ∣_ᵤ ↑U).basicOpen r)
⊢ P (f ∣_ ↑(Scheme.affineBasicOpen Y r))

Next tactic:
replace this := this (Y.presheaf.map (eqToHom U.1.openEmbedding_obj_top).op r) h
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
    

Proof state:
case hP₁
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)
r : ↑(Y.presheaf.obj (op ↑U))
h : P (f ∣_ ↑U)
this✝ : IsAffine (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
this :
  P
    (f ∣_ ↑U ∣_
      (Y ∣_ᵤ ↑U).basicOpen
        ((Y.presheaf.map (eqToHom (_ : (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤ = ↑U)).op) r))
⊢ P (f ∣_ ↑(Scheme.affineBasicOpen Y r))

Next tactic:
haveI i1 : IsAffine (Y.restrict (Scheme.affineBasicOpen Y r).1.openEmbedding) :=
      (Scheme.affineBasicOpen Y r).2
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
    

Proof state:
case hP₁
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)
r : ↑(Y.presheaf.obj (op ↑U))
h : P (f ∣_ ↑U)
this✝ : IsAffine (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
this :
  P
    (f ∣_ ↑U ∣_
      (Y ∣_ᵤ ↑U).basicOpen
        ((Y.presheaf.map (eqToHom (_ : (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤ = ↑U)).op) r))
i1 : IsAffine (Y ∣_ᵤ ↑(Scheme.affineBasicOpen Y r))
⊢ P (f ∣_ ↑(Scheme.affineBasicOpen Y r))

Next tactic:
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 _) _