l3lab/ntp-mathlib huggingface dataset:
theorem affineLocally_of_isOpenImmersion (hP : RingHom.PropertyIsLocal @P) {X Y : Scheme}
    (f : X ⟶ Y) [hf : IsOpenImmersion f] : affineLocally (@P) f := by
  intro U
  haveI H : IsAffine _ := U.2
  rw [← Category.comp_id (f ∣_ U)]
  apply hP.sourceAffineLocally_comp_of_isOpenImmersion
  -- Porting note: need to excuse Lean from synthesizing an instance
  rw [@source_affine_openCover_iff _ hP _ _ _ _ (Scheme.openCoverOfIsIso (𝟙 _)) (_)]
  · intro i; 

Proof state:
case H
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP✝ hP : PropertyIsLocal P
X Y : Scheme
f : X ⟶ Y
hf : IsOpenImmersion f
U : ↑(Scheme.affineOpens Y)
H : IsAffine (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
i : (Scheme.openCoverOfIsIso (𝟙 (Y ∣_ᵤ ↑U))).J
⊢ P (Scheme.Γ.map (Scheme.OpenCover.map (Scheme.openCoverOfIsIso (𝟙 (Y ∣_ᵤ ↑U))) i ≫ 𝟙 (Y ∣_ᵤ ↑U)).op)

Next tactic:
erw [Category.id_comp, op_id, Scheme.Γ.map_id]
theorem affineLocally_of_isOpenImmersion (hP : RingHom.PropertyIsLocal @P) {X Y : Scheme}
    (f : X ⟶ Y) [hf : IsOpenImmersion f] : affineLocally (@P) f := by
  intro U
  haveI H : IsAffine _ := U.2
  rw [← Category.comp_id (f ∣_ U)]
  apply hP.sourceAffineLocally_comp_of_isOpenImmersion
  -- Porting note: need to excuse Lean from synthesizing an instance
  rw [@source_affine_openCover_iff _ hP _ _ _ _ (Scheme.openCoverOfIsIso (𝟙 _)) (_)]
  · intro i; erw [Category.id_comp, op_id, Scheme.Γ.map_id]
    

Proof state:
case H
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP✝ hP : PropertyIsLocal P
X Y : Scheme
f : X ⟶ Y
hf : IsOpenImmersion f
U : ↑(Scheme.affineOpens Y)
H : IsAffine (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
i : (Scheme.openCoverOfIsIso (𝟙 (Y ∣_ᵤ ↑U))).J
⊢ P (𝟙 (Scheme.Γ.obj (Opposite.op (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion ↑U))))))

Next tactic:
let esto := Scheme.Γ.obj (Opposite.op (Y.restrict <| Opens.openEmbedding U.val))
theorem affineLocally_of_isOpenImmersion (hP : RingHom.PropertyIsLocal @P) {X Y : Scheme}
    (f : X ⟶ Y) [hf : IsOpenImmersion f] : affineLocally (@P) f := by
  intro U
  haveI H : IsAffine _ := U.2
  rw [← Category.comp_id (f ∣_ U)]
  apply hP.sourceAffineLocally_comp_of_isOpenImmersion
  -- Porting note: need to excuse Lean from synthesizing an instance
  rw [@source_affine_openCover_iff _ hP _ _ _ _ (Scheme.openCoverOfIsIso (𝟙 _)) (_)]
  · intro i; erw [Category.id_comp, op_id, Scheme.Γ.map_id]
    let esto := Scheme.Γ.obj (Opposite.op (Y.restrict <| Opens.openEmbedding U.val))
    

Proof state:
case H
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP✝ hP : PropertyIsLocal P
X Y : Scheme
f : X ⟶ Y
hf : IsOpenImmersion f
U : ↑(Scheme.affineOpens Y)
H : IsAffine (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
i : (Scheme.openCoverOfIsIso (𝟙 (Y ∣_ᵤ ↑U))).J
esto : CommRingCat := Scheme.Γ.obj (Opposite.op (Y ∣_ᵤ ↑U))
⊢ P (𝟙 (Scheme.Γ.obj (Opposite.op (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion ↑U))))))

Next tactic:
let eso := Scheme.Γ.obj (Opposite.op ((Scheme.openCoverOfIsIso
      (𝟙 (Y.restrict <| Opens.openEmbedding U.val))).obj i))
theorem affineLocally_of_isOpenImmersion (hP : RingHom.PropertyIsLocal @P) {X Y : Scheme}
    (f : X ⟶ Y) [hf : IsOpenImmersion f] : affineLocally (@P) f := by
  intro U
  haveI H : IsAffine _ := U.2
  rw [← Category.comp_id (f ∣_ U)]
  apply hP.sourceAffineLocally_comp_of_isOpenImmersion
  -- Porting note: need to excuse Lean from synthesizing an instance
  rw [@source_affine_openCover_iff _ hP _ _ _ _ (Scheme.openCoverOfIsIso (𝟙 _)) (_)]
  · intro i; erw [Category.id_comp, op_id, Scheme.Γ.map_id]
    let esto := Scheme.Γ.obj (Opposite.op (Y.restrict <| Opens.openEmbedding U.val))
    let eso := Scheme.Γ.obj (Opposite.op ((Scheme.openCoverOfIsIso
      (𝟙 (Y.restrict <| Opens.openEmbedding U.val))).obj i))
    -- Porting note: Lean this needed this spelled out before
    -- convert hP.HoldsAwayLocalizationAway _ (1 : Scheme.Γ.obj _) _
    

Proof state:
case H
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP✝ hP : PropertyIsLocal P
X Y : Scheme
f : X ⟶ Y
hf : IsOpenImmersion f
U : ↑(Scheme.affineOpens Y)
H : IsAffine (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
i : (Scheme.openCoverOfIsIso (𝟙 (Y ∣_ᵤ ↑U))).J
esto : CommRingCat := Scheme.Γ.obj (Opposite.op (Y ∣_ᵤ ↑U))
eso : CommRingCat := Scheme.Γ.obj (Opposite.op (Scheme.OpenCover.obj (Scheme.openCoverOfIsIso (𝟙 (Y ∣_ᵤ ↑U))) i))
⊢ P (𝟙 (Scheme.Γ.obj (Opposite.op (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion ↑U))))))

Next tactic:
have : 𝟙 (Scheme.Γ.obj (Opposite.op (Y.restrict <| Opens.openEmbedding U.val)))
      = @algebraMap esto eso _ _ (_) := (RingHom.algebraMap_toAlgebra _).symm
theorem affineLocally_of_isOpenImmersion (hP : RingHom.PropertyIsLocal @P) {X Y : Scheme}
    (f : X ⟶ Y) [hf : IsOpenImmersion f] : affineLocally (@P) f := by
  intro U
  haveI H : IsAffine _ := U.2
  rw [← Category.comp_id (f ∣_ U)]
  apply hP.sourceAffineLocally_comp_of_isOpenImmersion
  -- Porting note: need to excuse Lean from synthesizing an instance
  rw [@source_affine_openCover_iff _ hP _ _ _ _ (Scheme.openCoverOfIsIso (𝟙 _)) (_)]
  · intro i; erw [Category.id_comp, op_id, Scheme.Γ.map_id]
    let esto := Scheme.Γ.obj (Opposite.op (Y.restrict <| Opens.openEmbedding U.val))
    let eso := Scheme.Γ.obj (Opposite.op ((Scheme.openCoverOfIsIso
      (𝟙 (Y.restrict <| Opens.openEmbedding U.val))).obj i))
    -- Porting note: Lean this needed this spelled out before
    -- convert hP.HoldsAwayLocalizationAway _ (1 : Scheme.Γ.obj _) _
    have : 𝟙 (Scheme.Γ.obj (Opposite.op (Y.restrict <| Opens.openEmbedding U.val)))
      = @algebraMap esto eso _ _ (_) := (RingHom.algebraMap_toAlgebra _).symm
    

Proof state:
case H
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP✝ hP : PropertyIsLocal P
X Y : Scheme
f : X ⟶ Y
hf : IsOpenImmersion f
U : ↑(Scheme.affineOpens Y)
H : IsAffine (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
i : (Scheme.openCoverOfIsIso (𝟙 (Y ∣_ᵤ ↑U))).J
esto : CommRingCat := Scheme.Γ.obj (Opposite.op (Y ∣_ᵤ ↑U))
eso : CommRingCat := Scheme.Γ.obj (Opposite.op (Scheme.OpenCover.obj (Scheme.openCoverOfIsIso (𝟙 (Y ∣_ᵤ ↑U))) i))
this : 𝟙 (Scheme.Γ.obj (Opposite.op (Y ∣_ᵤ ↑U))) = algebraMap ↑esto ↑eso
⊢ P (𝟙 (Scheme.Γ.obj (Opposite.op (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion ↑U))))))

Next tactic:
rw [this]
theorem affineLocally_of_isOpenImmersion (hP : RingHom.PropertyIsLocal @P) {X Y : Scheme}
    (f : X ⟶ Y) [hf : IsOpenImmersion f] : affineLocally (@P) f := by
  intro U
  haveI H : IsAffine _ := U.2
  rw [← Category.comp_id (f ∣_ U)]
  apply hP.sourceAffineLocally_comp_of_isOpenImmersion
  -- Porting note: need to excuse Lean from synthesizing an instance
  rw [@source_affine_openCover_iff _ hP _ _ _ _ (Scheme.openCoverOfIsIso (𝟙 _)) (_)]
  · intro i; erw [Category.id_comp, op_id, Scheme.Γ.map_id]
    let esto := Scheme.Γ.obj (Opposite.op (Y.restrict <| Opens.openEmbedding U.val))
    let eso := Scheme.Γ.obj (Opposite.op ((Scheme.openCoverOfIsIso
      (𝟙 (Y.restrict <| Opens.openEmbedding U.val))).obj i))
    -- Porting note: Lean this needed this spelled out before
    -- convert hP.HoldsAwayLocalizationAway _ (1 : Scheme.Γ.obj _) _
    have : 𝟙 (Scheme.Γ.obj (Opposite.op (Y.restrict <| Opens.openEmbedding U.val)))
      = @algebraMap esto eso _ _ (_) := (RingHom.algebraMap_toAlgebra _).symm
    rw [this]
    

Proof state:
case H
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP✝ hP : PropertyIsLocal P
X Y : Scheme
f : X ⟶ Y
hf : IsOpenImmersion f
U : ↑(Scheme.affineOpens Y)
H : IsAffine (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
i : (Scheme.openCoverOfIsIso (𝟙 (Y ∣_ᵤ ↑U))).J
esto : CommRingCat := Scheme.Γ.obj (Opposite.op (Y ∣_ᵤ ↑U))
eso : CommRingCat := Scheme.Γ.obj (Opposite.op (Scheme.OpenCover.obj (Scheme.openCoverOfIsIso (𝟙 (Y ∣_ᵤ ↑U))) i))
this : 𝟙 (Scheme.Γ.obj (Opposite.op (Y ∣_ᵤ ↑U))) = algebraMap ↑esto ↑eso
⊢ P (algebraMap ↑esto ↑eso)

Next tactic:
have := hP.HoldsForLocalizationAway
theorem affineLocally_of_isOpenImmersion (hP : RingHom.PropertyIsLocal @P) {X Y : Scheme}
    (f : X ⟶ Y) [hf : IsOpenImmersion f] : affineLocally (@P) f := by
  intro U
  haveI H : IsAffine _ := U.2
  rw [← Category.comp_id (f ∣_ U)]
  apply hP.sourceAffineLocally_comp_of_isOpenImmersion
  -- Porting note: need to excuse Lean from synthesizing an instance
  rw [@source_affine_openCover_iff _ hP _ _ _ _ (Scheme.openCoverOfIsIso (𝟙 _)) (_)]
  · intro i; erw [Category.id_comp, op_id, Scheme.Γ.map_id]
    let esto := Scheme.Γ.obj (Opposite.op (Y.restrict <| Opens.openEmbedding U.val))
    let eso := Scheme.Γ.obj (Opposite.op ((Scheme.openCoverOfIsIso
      (𝟙 (Y.restrict <| Opens.openEmbedding U.val))).obj i))
    -- Porting note: Lean this needed this spelled out before
    -- convert hP.HoldsAwayLocalizationAway _ (1 : Scheme.Γ.obj _) _
    have : 𝟙 (Scheme.Γ.obj (Opposite.op (Y.restrict <| Opens.openEmbedding U.val)))
      = @algebraMap esto eso _ _ (_) := (RingHom.algebraMap_toAlgebra _).symm
    rw [this]
    have := hP.HoldsForLocalizationAway
    

Proof state:
case H
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP✝ hP : PropertyIsLocal P
X Y : Scheme
f : X ⟶ Y
hf : IsOpenImmersion f
U : ↑(Scheme.affineOpens Y)
H : IsAffine (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
i : (Scheme.openCoverOfIsIso (𝟙 (Y ∣_ᵤ ↑U))).J
esto : CommRingCat := Scheme.Γ.obj (Opposite.op (Y ∣_ᵤ ↑U))
eso : CommRingCat := Scheme.Γ.obj (Opposite.op (Scheme.OpenCover.obj (Scheme.openCoverOfIsIso (𝟙 (Y ∣_ᵤ ↑U))) i))
this✝ : 𝟙 (Scheme.Γ.obj (Opposite.op (Y ∣_ᵤ ↑U))) = algebraMap ↑esto ↑eso
this : RingHom.HoldsForLocalizationAway P
⊢ P (algebraMap ↑esto ↑eso)

Next tactic:
convert @this esto eso _ _ ?_ ?_ ?_
theorem affineLocally_of_isOpenImmersion (hP : RingHom.PropertyIsLocal @P) {X Y : Scheme}
    (f : X ⟶ Y) [hf : IsOpenImmersion f] : affineLocally (@P) f := by
  intro U
  haveI H : IsAffine _ := U.2
  rw [← Category.comp_id (f ∣_ U)]
  apply hP.sourceAffineLocally_comp_of_isOpenImmersion
  -- Porting note: need to excuse Lean from synthesizing an instance
  rw [@source_affine_openCover_iff _ hP _ _ _ _ (Scheme.openCoverOfIsIso (𝟙 _)) (_)]
  · intro i; erw [Category.id_comp, op_id, Scheme.Γ.map_id]
    let esto := Scheme.Γ.obj (Opposite.op (Y.restrict <| Opens.openEmbedding U.val))
    let eso := Scheme.Γ.obj (Opposite.op ((Scheme.openCoverOfIsIso
      (𝟙 (Y.restrict <| Opens.openEmbedding U.val))).obj i))
    -- Porting note: Lean this needed this spelled out before
    -- convert hP.HoldsAwayLocalizationAway _ (1 : Scheme.Γ.obj _) _
    have : 𝟙 (Scheme.Γ.obj (Opposite.op (Y.restrict <| Opens.openEmbedding U.val)))
      = @algebraMap esto eso _ _ (_) := (RingHom.algebraMap_toAlgebra _).symm
    rw [this]
    have := hP.HoldsForLocalizationAway
    convert @this esto eso _ _ ?_ ?_ ?_
    · 

Proof state:
case H.convert_2
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP✝ hP : PropertyIsLocal P
X Y : Scheme
f : X ⟶ Y
hf : IsOpenImmersion f
U : ↑(Scheme.affineOpens Y)
H : IsAffine (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
i : (Scheme.openCoverOfIsIso (𝟙 (Y ∣_ᵤ ↑U))).J
esto : CommRingCat := Scheme.Γ.obj (Opposite.op (Y ∣_ᵤ ↑U))
eso : CommRingCat := Scheme.Γ.obj (Opposite.op (Scheme.OpenCover.obj (Scheme.openCoverOfIsIso (𝟙 (Y ∣_ᵤ ↑U))) i))
this✝ : 𝟙 (Scheme.Γ.obj (Opposite.op (Y ∣_ᵤ ↑U))) = algebraMap ↑esto ↑eso
this : RingHom.HoldsForLocalizationAway P
⊢ ↑esto

Next tactic:
exact 1
theorem affineLocally_of_isOpenImmersion (hP : RingHom.PropertyIsLocal @P) {X Y : Scheme}
    (f : X ⟶ Y) [hf : IsOpenImmersion f] : affineLocally (@P) f := by
  intro U
  haveI H : IsAffine _ := U.2
  rw [← Category.comp_id (f ∣_ U)]
  apply hP.sourceAffineLocally_comp_of_isOpenImmersion
  -- Porting note: need to excuse Lean from synthesizing an instance
  rw [@source_affine_openCover_iff _ hP _ _ _ _ (Scheme.openCoverOfIsIso (𝟙 _)) (_)]
  · intro i; erw [Category.id_comp, op_id, Scheme.Γ.map_id]
    let esto := Scheme.Γ.obj (Opposite.op (Y.restrict <| Opens.openEmbedding U.val))
    let eso := Scheme.Γ.obj (Opposite.op ((Scheme.openCoverOfIsIso
      (𝟙 (Y.restrict <| Opens.openEmbedding U.val))).obj i))
    -- Porting note: Lean this needed this spelled out before
    -- convert hP.HoldsAwayLocalizationAway _ (1 : Scheme.Γ.obj _) _
    have : 𝟙 (Scheme.Γ.obj (Opposite.op (Y.restrict <| Opens.openEmbedding U.val)))
      = @algebraMap esto eso _ _ (_) := (RingHom.algebraMap_toAlgebra _).symm
    rw [this]
    have := hP.HoldsForLocalizationAway
    convert @this esto eso _ _ ?_ ?_ ?_
    · exact 1
    -- Porting note: again we have to bypass TC synthesis to keep Lean from running away
    · 

Proof state:
case H.convert_3
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP✝ hP : PropertyIsLocal P
X Y : Scheme
f : X ⟶ Y
hf : IsOpenImmersion f
U : ↑(Scheme.affineOpens Y)
H : IsAffine (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
i : (Scheme.openCoverOfIsIso (𝟙 (Y ∣_ᵤ ↑U))).J
esto : CommRingCat := Scheme.Γ.obj (Opposite.op (Y ∣_ᵤ ↑U))
eso : CommRingCat := Scheme.Γ.obj (Opposite.op (Scheme.OpenCover.obj (Scheme.openCoverOfIsIso (𝟙 (Y ∣_ᵤ ↑U))) i))
this✝ : 𝟙 (Scheme.Γ.obj (Opposite.op (Y ∣_ᵤ ↑U))) = algebraMap ↑esto ↑eso
this : RingHom.HoldsForLocalizationAway P
⊢ IsLocalization.Away 1 ↑eso

Next tactic:
refine'
        @IsLocalization.away_of_isUnit_of_bijective _ _ _ _ (_) _ isUnit_one Function.bijective_id
theorem affineLocally_of_isOpenImmersion (hP : RingHom.PropertyIsLocal @P) {X Y : Scheme}
    (f : X ⟶ Y) [hf : IsOpenImmersion f] : affineLocally (@P) f := by
  intro U
  haveI H : IsAffine _ := U.2
  rw [← Category.comp_id (f ∣_ U)]
  apply hP.sourceAffineLocally_comp_of_isOpenImmersion
  -- Porting note: need to excuse Lean from synthesizing an instance
  rw [@source_affine_openCover_iff _ hP _ _ _ _ (Scheme.openCoverOfIsIso (𝟙 _)) (_)]
  · intro i; erw [Category.id_comp, op_id, Scheme.Γ.map_id]
    let esto := Scheme.Γ.obj (Opposite.op (Y.restrict <| Opens.openEmbedding U.val))
    let eso := Scheme.Γ.obj (Opposite.op ((Scheme.openCoverOfIsIso
      (𝟙 (Y.restrict <| Opens.openEmbedding U.val))).obj i))
    -- Porting note: Lean this needed this spelled out before
    -- convert hP.HoldsAwayLocalizationAway _ (1 : Scheme.Γ.obj _) _
    have : 𝟙 (Scheme.Γ.obj (Opposite.op (Y.restrict <| Opens.openEmbedding U.val)))
      = @algebraMap esto eso _ _ (_) := (RingHom.algebraMap_toAlgebra _).symm
    rw [this]
    have := hP.HoldsForLocalizationAway
    convert @this esto eso _ _ ?_ ?_ ?_
    · exact 1
    -- Porting note: again we have to bypass TC synthesis to keep Lean from running away
    · refine'
        @IsLocalization.away_of_isUnit_of_bijective _ _ _ _ (_) _ isUnit_one Function.bijective_id
  · 

Proof state:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP✝ hP : PropertyIsLocal P
X Y : Scheme
f : X ⟶ Y
hf : IsOpenImmersion f
U : ↑(Scheme.affineOpens Y)
H : IsAffine (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
⊢ ∀ (i : (Scheme.openCoverOfIsIso (𝟙 (Y ∣_ᵤ ↑U))).J),
    IsAffine (Scheme.OpenCover.obj (Scheme.openCoverOfIsIso (𝟙 (Y ∣_ᵤ ↑U))) i)

Next tactic:
intro
theorem affineLocally_of_isOpenImmersion (hP : RingHom.PropertyIsLocal @P) {X Y : Scheme}
    (f : X ⟶ Y) [hf : IsOpenImmersion f] : affineLocally (@P) f := by
  intro U
  haveI H : IsAffine _ := U.2
  rw [← Category.comp_id (f ∣_ U)]
  apply hP.sourceAffineLocally_comp_of_isOpenImmersion
  -- Porting note: need to excuse Lean from synthesizing an instance
  rw [@source_affine_openCover_iff _ hP _ _ _ _ (Scheme.openCoverOfIsIso (𝟙 _)) (_)]
  · intro i; erw [Category.id_comp, op_id, Scheme.Γ.map_id]
    let esto := Scheme.Γ.obj (Opposite.op (Y.restrict <| Opens.openEmbedding U.val))
    let eso := Scheme.Γ.obj (Opposite.op ((Scheme.openCoverOfIsIso
      (𝟙 (Y.restrict <| Opens.openEmbedding U.val))).obj i))
    -- Porting note: Lean this needed this spelled out before
    -- convert hP.HoldsAwayLocalizationAway _ (1 : Scheme.Γ.obj _) _
    have : 𝟙 (Scheme.Γ.obj (Opposite.op (Y.restrict <| Opens.openEmbedding U.val)))
      = @algebraMap esto eso _ _ (_) := (RingHom.algebraMap_toAlgebra _).symm
    rw [this]
    have := hP.HoldsForLocalizationAway
    convert @this esto eso _ _ ?_ ?_ ?_
    · exact 1
    -- Porting note: again we have to bypass TC synthesis to keep Lean from running away
    · refine'
        @IsLocalization.away_of_isUnit_of_bijective _ _ _ _ (_) _ isUnit_one Function.bijective_id
  · intro; 

Proof state:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP✝ hP : PropertyIsLocal P
X Y : Scheme
f : X ⟶ Y
hf : IsOpenImmersion f
U : ↑(Scheme.affineOpens Y)
H : IsAffine (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
i✝ : (Scheme.openCoverOfIsIso (𝟙 (Y ∣_ᵤ ↑U))).J
⊢ IsAffine (Scheme.OpenCover.obj (Scheme.openCoverOfIsIso (𝟙 (Y ∣_ᵤ ↑U))) i✝)

Next tactic:
exact H
theorem affineLocally_of_comp
    (H : ∀ {R S T : Type u} [CommRing R] [CommRing S] [CommRing T],
      ∀ (f : R →+* S) (g : S →+* T), P (g.comp f) → P g)
    {X Y Z : Scheme} {f : X ⟶ Y} {g : Y ⟶ Z} (h : affineLocally (@P) (f ≫ g)) :
    affineLocally (@P) f := by
  

Proof state:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
H :
  ∀ {R S T : Type u} [inst : CommRing R] [inst_1 : CommRing S] [inst_2 : CommRing T] (f : R →+* S) (g : S →+* T),
    P (comp g f) → P g
X Y Z : Scheme
f : X ⟶ Y
g : Y ⟶ Z
h : affineLocally P (f ≫ g)
⊢ affineLocally P f

Next tactic:
let 𝒰 : ∀ i, ((Z.affineCover.pullbackCover (f ≫ g)).obj i).OpenCover := by
    intro i
    refine' Scheme.OpenCover.bind _ fun i => Scheme.affineCover _
    apply Scheme.OpenCover.pushforwardIso _
      (pullbackRightPullbackFstIso g (Z.affineCover.map i) f).hom
    apply Scheme.Pullback.openCoverOfRight
    exact (pullback g (Z.affineCover.map i)).affineCover
theorem affineLocally_of_comp
    (H : ∀ {R S T : Type u} [CommRing R] [CommRing S] [CommRing T],
      ∀ (f : R →+* S) (g : S →+* T), P (g.comp f) → P g)
    {X Y Z : Scheme} {f : X ⟶ Y} {g : Y ⟶ Z} (h : affineLocally (@P) (f ≫ g)) :
    affineLocally (@P) f := by
  let 𝒰 : ∀ i, ((Z.affineCover.pullbackCover (f ≫ g)).obj i).OpenCover := by
    

Proof state:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
H :
  ∀ {R S T : Type u} [inst : CommRing R] [inst_1 : CommRing S] [inst_2 : CommRing T] (f : R →+* S) (g : S →+* T),
    P (comp g f) → P g
X Y Z : Scheme
f : X ⟶ Y
g : Y ⟶ Z
h : affineLocally P (f ≫ g)
⊢ (i : (Scheme.OpenCover.pullbackCover (Scheme.affineCover Z) (f ≫ g)).J) →
    Scheme.OpenCover (Scheme.OpenCover.obj (Scheme.OpenCover.pullbackCover (Scheme.affineCover Z) (f ≫ g)) i)

Next tactic:
intro i
theorem affineLocally_of_comp
    (H : ∀ {R S T : Type u} [CommRing R] [CommRing S] [CommRing T],
      ∀ (f : R →+* S) (g : S →+* T), P (g.comp f) → P g)
    {X Y Z : Scheme} {f : X ⟶ Y} {g : Y ⟶ Z} (h : affineLocally (@P) (f ≫ g)) :
    affineLocally (@P) f := by
  let 𝒰 : ∀ i, ((Z.affineCover.pullbackCover (f ≫ g)).obj i).OpenCover := by
    intro i
    

Proof state:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
H :
  ∀ {R S T : Type u} [inst : CommRing R] [inst_1 : CommRing S] [inst_2 : CommRing T] (f : R →+* S) (g : S →+* T),
    P (comp g f) → P g
X Y Z : Scheme
f : X ⟶ Y
g : Y ⟶ Z
h : affineLocally P (f ≫ g)
i : (Scheme.OpenCover.pullbackCover (Scheme.affineCover Z) (f ≫ g)).J
⊢ Scheme.OpenCover (Scheme.OpenCover.obj (Scheme.OpenCover.pullbackCover (Scheme.affineCover Z) (f ≫ g)) i)

Next tactic:
refine' Scheme.OpenCover.bind _ fun i => Scheme.affineCover _
theorem affineLocally_of_comp
    (H : ∀ {R S T : Type u} [CommRing R] [CommRing S] [CommRing T],
      ∀ (f : R →+* S) (g : S →+* T), P (g.comp f) → P g)
    {X Y Z : Scheme} {f : X ⟶ Y} {g : Y ⟶ Z} (h : affineLocally (@P) (f ≫ g)) :
    affineLocally (@P) f := by
  let 𝒰 : ∀ i, ((Z.affineCover.pullbackCover (f ≫ g)).obj i).OpenCover := by
    intro i
    refine' Scheme.OpenCover.bind _ fun i => Scheme.affineCover _
    

Proof state:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
H :
  ∀ {R S T : Type u} [inst : CommRing R] [inst_1 : CommRing S] [inst_2 : CommRing T] (f : R →+* S) (g : S →+* T),
    P (comp g f) → P g
X Y Z : Scheme
f : X ⟶ Y
g : Y ⟶ Z
h : affineLocally P (f ≫ g)
i : (Scheme.OpenCover.pullbackCover (Scheme.affineCover Z) (f ≫ g)).J
⊢ Scheme.OpenCover (Scheme.OpenCover.obj (Scheme.OpenCover.pullbackCover (Scheme.affineCover Z) (f ≫ g)) i)

Next tactic:
apply Scheme.OpenCover.pushforwardIso _
      (pullbackRightPullbackFstIso g (Z.affineCover.map i) f).hom
theorem affineLocally_of_comp
    (H : ∀ {R S T : Type u} [CommRing R] [CommRing S] [CommRing T],
      ∀ (f : R →+* S) (g : S →+* T), P (g.comp f) → P g)
    {X Y Z : Scheme} {f : X ⟶ Y} {g : Y ⟶ Z} (h : affineLocally (@P) (f ≫ g)) :
    affineLocally (@P) f := by
  let 𝒰 : ∀ i, ((Z.affineCover.pullbackCover (f ≫ g)).obj i).OpenCover := by
    intro i
    refine' Scheme.OpenCover.bind _ fun i => Scheme.affineCover _
    apply Scheme.OpenCover.pushforwardIso _
      (pullbackRightPullbackFstIso g (Z.affineCover.map i) f).hom
    

Proof state:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
H :
  ∀ {R S T : Type u} [inst : CommRing R] [inst_1 : CommRing S] [inst_2 : CommRing T] (f : R →+* S) (g : S →+* T),
    P (comp g f) → P g
X Y Z : Scheme
f : X ⟶ Y
g : Y ⟶ Z
h : affineLocally P (f ≫ g)
i : (Scheme.OpenCover.pullbackCover (Scheme.affineCover Z) (f ≫ g)).J
⊢ Scheme.OpenCover (pullback f pullback.fst)

Next tactic:
apply Scheme.Pullback.openCoverOfRight
theorem affineLocally_of_comp
    (H : ∀ {R S T : Type u} [CommRing R] [CommRing S] [CommRing T],
      ∀ (f : R →+* S) (g : S →+* T), P (g.comp f) → P g)
    {X Y Z : Scheme} {f : X ⟶ Y} {g : Y ⟶ Z} (h : affineLocally (@P) (f ≫ g)) :
    affineLocally (@P) f := by
  let 𝒰 : ∀ i, ((Z.affineCover.pullbackCover (f ≫ g)).obj i).OpenCover := by
    intro i
    refine' Scheme.OpenCover.bind _ fun i => Scheme.affineCover _
    apply Scheme.OpenCover.pushforwardIso _
      (pullbackRightPullbackFstIso g (Z.affineCover.map i) f).hom
    apply Scheme.Pullback.openCoverOfRight
    

Proof state:
case 𝒰
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
H :
  ∀ {R S T : Type u} [inst : CommRing R] [inst_1 : CommRing S] [inst_2 : CommRing T] (f : R →+* S) (g : S →+* T),
    P (comp g f) → P g
X Y Z : Scheme
f : X ⟶ Y
g : Y ⟶ Z
h : affineLocally P (f ≫ g)
i : (Scheme.OpenCover.pullbackCover (Scheme.affineCover Z) (f ≫ g)).J
⊢ Scheme.OpenCover (pullback g (Scheme.OpenCover.map (Scheme.affineCover Z) i))

Next tactic:
exact (pullback g (Z.affineCover.map i)).affineCover