l3lab/ntp-mathlib huggingface dataset:
@[nolint unusedHavesSuffices]
theorem source_openCover_iff {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} X) :
    affineLocally (@P) f ↔ ∀ i, affineLocally (@P) (𝒰.map i ≫ f) := by
  constructor
  · intro H i U
    rw [morphismRestrict_comp]
    delta morphismRestrict
    -- Porting note: Lean can no longer find these instances for the following apply
    have : IsAffine (Scheme.restrict Y <| Opens.openEmbedding U.val) := U.property
    

Proof state:
case mp
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover X
H : affineLocally P f
i : 𝒰.J
U : ↑(Scheme.affineOpens Y)
this : IsAffine (Y ∣_ᵤ ↑U)
⊢ sourceAffineLocally P
    (((pullbackRestrictIsoRestrict (Scheme.OpenCover.map 𝒰 i) (f⁻¹ᵁ ↑U)).inv ≫ pullback.snd) ≫
      (pullbackRestrictIsoRestrict f ↑U).inv ≫ pullback.snd)

Next tactic:
have : IsOpenImmersion ((pullbackRestrictIsoRestrict (Scheme.OpenCover.map 𝒰 i)
        ((Opens.map f.val.base).obj ↑U)).inv ≫ pullback.snd) :=
      LocallyRingedSpace.IsOpenImmersion.comp _ _
@[nolint unusedHavesSuffices]
theorem source_openCover_iff {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} X) :
    affineLocally (@P) f ↔ ∀ i, affineLocally (@P) (𝒰.map i ≫ f) := by
  constructor
  · intro H i U
    rw [morphismRestrict_comp]
    delta morphismRestrict
    -- Porting note: Lean can no longer find these instances for the following apply
    have : IsAffine (Scheme.restrict Y <| Opens.openEmbedding U.val) := U.property
    have : IsOpenImmersion ((pullbackRestrictIsoRestrict (Scheme.OpenCover.map 𝒰 i)
        ((Opens.map f.val.base).obj ↑U)).inv ≫ pullback.snd) :=
      LocallyRingedSpace.IsOpenImmersion.comp _ _
    

Proof state:
case mp
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover X
H : affineLocally P f
i : 𝒰.J
U : ↑(Scheme.affineOpens Y)
this✝ : IsAffine (Y ∣_ᵤ ↑U)
this : IsOpenImmersion ((pullbackRestrictIsoRestrict (Scheme.OpenCover.map 𝒰 i) (f⁻¹ᵁ ↑U)).inv ≫ pullback.snd)
⊢ sourceAffineLocally P
    (((pullbackRestrictIsoRestrict (Scheme.OpenCover.map 𝒰 i) (f⁻¹ᵁ ↑U)).inv ≫ pullback.snd) ≫
      (pullbackRestrictIsoRestrict f ↑U).inv ≫ pullback.snd)

Next tactic:
apply hP.sourceAffineLocally_comp_of_isOpenImmersion
@[nolint unusedHavesSuffices]
theorem source_openCover_iff {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} X) :
    affineLocally (@P) f ↔ ∀ i, affineLocally (@P) (𝒰.map i ≫ f) := by
  constructor
  · intro H i U
    rw [morphismRestrict_comp]
    delta morphismRestrict
    -- Porting note: Lean can no longer find these instances for the following apply
    have : IsAffine (Scheme.restrict Y <| Opens.openEmbedding U.val) := U.property
    have : IsOpenImmersion ((pullbackRestrictIsoRestrict (Scheme.OpenCover.map 𝒰 i)
        ((Opens.map f.val.base).obj ↑U)).inv ≫ pullback.snd) :=
      LocallyRingedSpace.IsOpenImmersion.comp _ _
    apply hP.sourceAffineLocally_comp_of_isOpenImmersion
    

Proof state:
case mp.H
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover X
H : affineLocally P f
i : 𝒰.J
U : ↑(Scheme.affineOpens Y)
this✝ : IsAffine (Y ∣_ᵤ ↑U)
this : IsOpenImmersion ((pullbackRestrictIsoRestrict (Scheme.OpenCover.map 𝒰 i) (f⁻¹ᵁ ↑U)).inv ≫ pullback.snd)
⊢ sourceAffineLocally P ((pullbackRestrictIsoRestrict f ↑U).inv ≫ pullback.snd)

Next tactic:
apply H
@[nolint unusedHavesSuffices]
theorem source_openCover_iff {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} X) :
    affineLocally (@P) f ↔ ∀ i, affineLocally (@P) (𝒰.map i ≫ f) := by
  constructor
  · intro H i U
    rw [morphismRestrict_comp]
    delta morphismRestrict
    -- Porting note: Lean can no longer find these instances for the following apply
    have : IsAffine (Scheme.restrict Y <| Opens.openEmbedding U.val) := U.property
    have : IsOpenImmersion ((pullbackRestrictIsoRestrict (Scheme.OpenCover.map 𝒰 i)
        ((Opens.map f.val.base).obj ↑U)).inv ≫ pullback.snd) :=
      LocallyRingedSpace.IsOpenImmersion.comp _ _
    apply hP.sourceAffineLocally_comp_of_isOpenImmersion
    apply H
  · 

Proof state:
case mpr
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover X
⊢ (∀ (i : 𝒰.J), affineLocally P (Scheme.OpenCover.map 𝒰 i ≫ f)) → affineLocally P f

Next tactic:
intro H U
@[nolint unusedHavesSuffices]
theorem source_openCover_iff {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} X) :
    affineLocally (@P) f ↔ ∀ i, affineLocally (@P) (𝒰.map i ≫ f) := by
  constructor
  · intro H i U
    rw [morphismRestrict_comp]
    delta morphismRestrict
    -- Porting note: Lean can no longer find these instances for the following apply
    have : IsAffine (Scheme.restrict Y <| Opens.openEmbedding U.val) := U.property
    have : IsOpenImmersion ((pullbackRestrictIsoRestrict (Scheme.OpenCover.map 𝒰 i)
        ((Opens.map f.val.base).obj ↑U)).inv ≫ pullback.snd) :=
      LocallyRingedSpace.IsOpenImmersion.comp _ _
    apply hP.sourceAffineLocally_comp_of_isOpenImmersion
    apply H
  · intro H U
    

Proof state:
case mpr
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover X
H : ∀ (i : 𝒰.J), affineLocally P (Scheme.OpenCover.map 𝒰 i ≫ f)
U : ↑(Scheme.affineOpens Y)
⊢ sourceAffineLocally P (f ∣_ ↑U)

Next tactic:
haveI : IsAffine _ := U.2
@[nolint unusedHavesSuffices]
theorem source_openCover_iff {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} X) :
    affineLocally (@P) f ↔ ∀ i, affineLocally (@P) (𝒰.map i ≫ f) := by
  constructor
  · intro H i U
    rw [morphismRestrict_comp]
    delta morphismRestrict
    -- Porting note: Lean can no longer find these instances for the following apply
    have : IsAffine (Scheme.restrict Y <| Opens.openEmbedding U.val) := U.property
    have : IsOpenImmersion ((pullbackRestrictIsoRestrict (Scheme.OpenCover.map 𝒰 i)
        ((Opens.map f.val.base).obj ↑U)).inv ≫ pullback.snd) :=
      LocallyRingedSpace.IsOpenImmersion.comp _ _
    apply hP.sourceAffineLocally_comp_of_isOpenImmersion
    apply H
  · intro H U
    haveI : IsAffine _ := U.2
    

Proof state:
case mpr
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover X
H : ∀ (i : 𝒰.J), affineLocally P (Scheme.OpenCover.map 𝒰 i ≫ f)
U : ↑(Scheme.affineOpens Y)
this : IsAffine (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
⊢ sourceAffineLocally P (f ∣_ ↑U)

Next tactic:
apply ((hP.openCover_TFAE (f ∣_ U.1)).out 1 0).mp
@[nolint unusedHavesSuffices]
theorem source_openCover_iff {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} X) :
    affineLocally (@P) f ↔ ∀ i, affineLocally (@P) (𝒰.map i ≫ f) := by
  constructor
  · intro H i U
    rw [morphismRestrict_comp]
    delta morphismRestrict
    -- Porting note: Lean can no longer find these instances for the following apply
    have : IsAffine (Scheme.restrict Y <| Opens.openEmbedding U.val) := U.property
    have : IsOpenImmersion ((pullbackRestrictIsoRestrict (Scheme.OpenCover.map 𝒰 i)
        ((Opens.map f.val.base).obj ↑U)).inv ≫ pullback.snd) :=
      LocallyRingedSpace.IsOpenImmersion.comp _ _
    apply hP.sourceAffineLocally_comp_of_isOpenImmersion
    apply H
  · intro H U
    haveI : IsAffine _ := U.2
    apply ((hP.openCover_TFAE (f ∣_ U.1)).out 1 0).mp
    

Proof state:
case mpr
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover X
H : ∀ (i : 𝒰.J), affineLocally P (Scheme.OpenCover.map 𝒰 i ≫ f)
U : ↑(Scheme.affineOpens Y)
this : IsAffine (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
⊢ ∃ 𝒰, ∀ (i : 𝒰.J), sourceAffineLocally P (Scheme.OpenCover.map 𝒰 i ≫ f ∣_ ↑U)

Next tactic:
use 𝒰.pullbackCover (X.ofRestrict _)
@[nolint unusedHavesSuffices]
theorem source_openCover_iff {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} X) :
    affineLocally (@P) f ↔ ∀ i, affineLocally (@P) (𝒰.map i ≫ f) := by
  constructor
  · intro H i U
    rw [morphismRestrict_comp]
    delta morphismRestrict
    -- Porting note: Lean can no longer find these instances for the following apply
    have : IsAffine (Scheme.restrict Y <| Opens.openEmbedding U.val) := U.property
    have : IsOpenImmersion ((pullbackRestrictIsoRestrict (Scheme.OpenCover.map 𝒰 i)
        ((Opens.map f.val.base).obj ↑U)).inv ≫ pullback.snd) :=
      LocallyRingedSpace.IsOpenImmersion.comp _ _
    apply hP.sourceAffineLocally_comp_of_isOpenImmersion
    apply H
  · intro H U
    haveI : IsAffine _ := U.2
    apply ((hP.openCover_TFAE (f ∣_ U.1)).out 1 0).mp
    use 𝒰.pullbackCover (X.ofRestrict _)
    

Proof state:
case h
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover X
H : ∀ (i : 𝒰.J), affineLocally P (Scheme.OpenCover.map 𝒰 i ≫ f)
U : ↑(Scheme.affineOpens Y)
this : IsAffine (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
⊢ ∀ (i : (Scheme.OpenCover.pullbackCover 𝒰 (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion (f⁻¹ᵁ ↑U))))).J),
    sourceAffineLocally P
      (Scheme.OpenCover.map
          (Scheme.OpenCover.pullbackCover 𝒰 (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion (f⁻¹ᵁ ↑U))))) i ≫
        f ∣_ ↑U)

Next tactic:
intro i
@[nolint unusedHavesSuffices]
theorem source_openCover_iff {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} X) :
    affineLocally (@P) f ↔ ∀ i, affineLocally (@P) (𝒰.map i ≫ f) := by
  constructor
  · intro H i U
    rw [morphismRestrict_comp]
    delta morphismRestrict
    -- Porting note: Lean can no longer find these instances for the following apply
    have : IsAffine (Scheme.restrict Y <| Opens.openEmbedding U.val) := U.property
    have : IsOpenImmersion ((pullbackRestrictIsoRestrict (Scheme.OpenCover.map 𝒰 i)
        ((Opens.map f.val.base).obj ↑U)).inv ≫ pullback.snd) :=
      LocallyRingedSpace.IsOpenImmersion.comp _ _
    apply hP.sourceAffineLocally_comp_of_isOpenImmersion
    apply H
  · intro H U
    haveI : IsAffine _ := U.2
    apply ((hP.openCover_TFAE (f ∣_ U.1)).out 1 0).mp
    use 𝒰.pullbackCover (X.ofRestrict _)
    intro i
    

Proof state:
case h
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover X
H : ∀ (i : 𝒰.J), affineLocally P (Scheme.OpenCover.map 𝒰 i ≫ f)
U : ↑(Scheme.affineOpens Y)
this : IsAffine (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
i : (Scheme.OpenCover.pullbackCover 𝒰 (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion (f⁻¹ᵁ ↑U))))).J
⊢ sourceAffineLocally P
    (Scheme.OpenCover.map
        (Scheme.OpenCover.pullbackCover 𝒰 (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion (f⁻¹ᵁ ↑U))))) i ≫
      f ∣_ ↑U)

Next tactic:
specialize H i U
@[nolint unusedHavesSuffices]
theorem source_openCover_iff {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} X) :
    affineLocally (@P) f ↔ ∀ i, affineLocally (@P) (𝒰.map i ≫ f) := by
  constructor
  · intro H i U
    rw [morphismRestrict_comp]
    delta morphismRestrict
    -- Porting note: Lean can no longer find these instances for the following apply
    have : IsAffine (Scheme.restrict Y <| Opens.openEmbedding U.val) := U.property
    have : IsOpenImmersion ((pullbackRestrictIsoRestrict (Scheme.OpenCover.map 𝒰 i)
        ((Opens.map f.val.base).obj ↑U)).inv ≫ pullback.snd) :=
      LocallyRingedSpace.IsOpenImmersion.comp _ _
    apply hP.sourceAffineLocally_comp_of_isOpenImmersion
    apply H
  · intro H U
    haveI : IsAffine _ := U.2
    apply ((hP.openCover_TFAE (f ∣_ U.1)).out 1 0).mp
    use 𝒰.pullbackCover (X.ofRestrict _)
    intro i
    specialize H i U
    

Proof state:
case h
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover X
U : ↑(Scheme.affineOpens Y)
this : IsAffine (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
i : (Scheme.OpenCover.pullbackCover 𝒰 (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion (f⁻¹ᵁ ↑U))))).J
H : sourceAffineLocally P ((Scheme.OpenCover.map 𝒰 i ≫ f) ∣_ ↑U)
⊢ sourceAffineLocally P
    (Scheme.OpenCover.map
        (Scheme.OpenCover.pullbackCover 𝒰 (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion (f⁻¹ᵁ ↑U))))) i ≫
      f ∣_ ↑U)

Next tactic:
rw [morphismRestrict_comp] at H
@[nolint unusedHavesSuffices]
theorem source_openCover_iff {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} X) :
    affineLocally (@P) f ↔ ∀ i, affineLocally (@P) (𝒰.map i ≫ f) := by
  constructor
  · intro H i U
    rw [morphismRestrict_comp]
    delta morphismRestrict
    -- Porting note: Lean can no longer find these instances for the following apply
    have : IsAffine (Scheme.restrict Y <| Opens.openEmbedding U.val) := U.property
    have : IsOpenImmersion ((pullbackRestrictIsoRestrict (Scheme.OpenCover.map 𝒰 i)
        ((Opens.map f.val.base).obj ↑U)).inv ≫ pullback.snd) :=
      LocallyRingedSpace.IsOpenImmersion.comp _ _
    apply hP.sourceAffineLocally_comp_of_isOpenImmersion
    apply H
  · intro H U
    haveI : IsAffine _ := U.2
    apply ((hP.openCover_TFAE (f ∣_ U.1)).out 1 0).mp
    use 𝒰.pullbackCover (X.ofRestrict _)
    intro i
    specialize H i U
    rw [morphismRestrict_comp] at H
    

Proof state:
case h
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover X
U : ↑(Scheme.affineOpens Y)
this : IsAffine (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
i : (Scheme.OpenCover.pullbackCover 𝒰 (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion (f⁻¹ᵁ ↑U))))).J
H : sourceAffineLocally P (Scheme.OpenCover.map 𝒰 i ∣_ f⁻¹ᵁ ↑U ≫ f ∣_ ↑U)
⊢ sourceAffineLocally P
    (Scheme.OpenCover.map
        (Scheme.OpenCover.pullbackCover 𝒰 (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion (f⁻¹ᵁ ↑U))))) i ≫
      f ∣_ ↑U)

Next tactic:
delta morphismRestrict at H
@[nolint unusedHavesSuffices]
theorem source_openCover_iff {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} X) :
    affineLocally (@P) f ↔ ∀ i, affineLocally (@P) (𝒰.map i ≫ f) := by
  constructor
  · intro H i U
    rw [morphismRestrict_comp]
    delta morphismRestrict
    -- Porting note: Lean can no longer find these instances for the following apply
    have : IsAffine (Scheme.restrict Y <| Opens.openEmbedding U.val) := U.property
    have : IsOpenImmersion ((pullbackRestrictIsoRestrict (Scheme.OpenCover.map 𝒰 i)
        ((Opens.map f.val.base).obj ↑U)).inv ≫ pullback.snd) :=
      LocallyRingedSpace.IsOpenImmersion.comp _ _
    apply hP.sourceAffineLocally_comp_of_isOpenImmersion
    apply H
  · intro H U
    haveI : IsAffine _ := U.2
    apply ((hP.openCover_TFAE (f ∣_ U.1)).out 1 0).mp
    use 𝒰.pullbackCover (X.ofRestrict _)
    intro i
    specialize H i U
    rw [morphismRestrict_comp] at H
    delta morphismRestrict at H
    

Proof state:
case h
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover X
U : ↑(Scheme.affineOpens Y)
this : IsAffine (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
i : (Scheme.OpenCover.pullbackCover 𝒰 (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion (f⁻¹ᵁ ↑U))))).J
H :
  sourceAffineLocally P
    (((pullbackRestrictIsoRestrict (Scheme.OpenCover.map 𝒰 i) (f⁻¹ᵁ ↑U)).inv ≫ pullback.snd) ≫
      (pullbackRestrictIsoRestrict f ↑U).inv ≫ pullback.snd)
⊢ sourceAffineLocally P
    (Scheme.OpenCover.map
        (Scheme.OpenCover.pullbackCover 𝒰 (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion (f⁻¹ᵁ ↑U))))) i ≫
      f ∣_ ↑U)

Next tactic:
have := sourceAffineLocally_respectsIso hP.respectsIso
@[nolint unusedHavesSuffices]
theorem source_openCover_iff {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} X) :
    affineLocally (@P) f ↔ ∀ i, affineLocally (@P) (𝒰.map i ≫ f) := by
  constructor
  · intro H i U
    rw [morphismRestrict_comp]
    delta morphismRestrict
    -- Porting note: Lean can no longer find these instances for the following apply
    have : IsAffine (Scheme.restrict Y <| Opens.openEmbedding U.val) := U.property
    have : IsOpenImmersion ((pullbackRestrictIsoRestrict (Scheme.OpenCover.map 𝒰 i)
        ((Opens.map f.val.base).obj ↑U)).inv ≫ pullback.snd) :=
      LocallyRingedSpace.IsOpenImmersion.comp _ _
    apply hP.sourceAffineLocally_comp_of_isOpenImmersion
    apply H
  · intro H U
    haveI : IsAffine _ := U.2
    apply ((hP.openCover_TFAE (f ∣_ U.1)).out 1 0).mp
    use 𝒰.pullbackCover (X.ofRestrict _)
    intro i
    specialize H i U
    rw [morphismRestrict_comp] at H
    delta morphismRestrict at H
    have := sourceAffineLocally_respectsIso hP.respectsIso
    

Proof state:
case h
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover X
U : ↑(Scheme.affineOpens Y)
this✝ : IsAffine (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
i : (Scheme.OpenCover.pullbackCover 𝒰 (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion (f⁻¹ᵁ ↑U))))).J
H :
  sourceAffineLocally P
    (((pullbackRestrictIsoRestrict (Scheme.OpenCover.map 𝒰 i) (f⁻¹ᵁ ↑U)).inv ≫ pullback.snd) ≫
      (pullbackRestrictIsoRestrict f ↑U).inv ≫ pullback.snd)
this : MorphismProperty.RespectsIso (AffineTargetMorphismProperty.toProperty (sourceAffineLocally P))
⊢ sourceAffineLocally P
    (Scheme.OpenCover.map
        (Scheme.OpenCover.pullbackCover 𝒰 (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion (f⁻¹ᵁ ↑U))))) i ≫
      f ∣_ ↑U)

Next tactic:
rw [Category.assoc, affine_cancel_left_isIso this, ←
      affine_cancel_left_isIso this (pullbackSymmetry _ _).hom,
      pullbackSymmetry_hom_comp_snd_assoc] at H
@[nolint unusedHavesSuffices]
theorem source_openCover_iff {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} X) :
    affineLocally (@P) f ↔ ∀ i, affineLocally (@P) (𝒰.map i ≫ f) := by
  constructor
  · intro H i U
    rw [morphismRestrict_comp]
    delta morphismRestrict
    -- Porting note: Lean can no longer find these instances for the following apply
    have : IsAffine (Scheme.restrict Y <| Opens.openEmbedding U.val) := U.property
    have : IsOpenImmersion ((pullbackRestrictIsoRestrict (Scheme.OpenCover.map 𝒰 i)
        ((Opens.map f.val.base).obj ↑U)).inv ≫ pullback.snd) :=
      LocallyRingedSpace.IsOpenImmersion.comp _ _
    apply hP.sourceAffineLocally_comp_of_isOpenImmersion
    apply H
  · intro H U
    haveI : IsAffine _ := U.2
    apply ((hP.openCover_TFAE (f ∣_ U.1)).out 1 0).mp
    use 𝒰.pullbackCover (X.ofRestrict _)
    intro i
    specialize H i U
    rw [morphismRestrict_comp] at H
    delta morphismRestrict at H
    have := sourceAffineLocally_respectsIso hP.respectsIso
    rw [Category.assoc, affine_cancel_left_isIso this, ←
      affine_cancel_left_isIso this (pullbackSymmetry _ _).hom,
      pullbackSymmetry_hom_comp_snd_assoc] at H
    

Proof state:
case h
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
X Y : Scheme
f : X ⟶ Y
𝒰 : Scheme.OpenCover X
U : ↑(Scheme.affineOpens Y)
this✝ : IsAffine (Scheme.restrict Y (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
i : (Scheme.OpenCover.pullbackCover 𝒰 (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion (f⁻¹ᵁ ↑U))))).J
H : sourceAffineLocally P (pullback.fst ≫ (pullbackRestrictIsoRestrict f ↑U).inv ≫ pullback.snd)
this : MorphismProperty.RespectsIso (AffineTargetMorphismProperty.toProperty (sourceAffineLocally P))
⊢ sourceAffineLocally P
    (Scheme.OpenCover.map
        (Scheme.OpenCover.pullbackCover 𝒰 (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion (f⁻¹ᵁ ↑U))))) i ≫
      f ∣_ ↑U)

Next tactic:
exact H
theorem affineLocally_of_isOpenImmersion (hP : RingHom.PropertyIsLocal @P) {X Y : Scheme}
    (f : X ⟶ Y) [hf : IsOpenImmersion f] : affineLocally (@P) f := by
  

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

Next tactic:
intro U
theorem affineLocally_of_isOpenImmersion (hP : RingHom.PropertyIsLocal @P) {X Y : Scheme}
    (f : X ⟶ Y) [hf : IsOpenImmersion f] : affineLocally (@P) f := by
  intro U
  

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)
⊢ sourceAffineLocally P (f ∣_ ↑U)

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

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)))
⊢ sourceAffineLocally P (f ∣_ ↑U)

Next tactic:
rw [← Category.comp_id (f ∣_ U)]
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)]
  

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)))
⊢ sourceAffineLocally P (f ∣_ ↑U ≫ 𝟙 (Y ∣_ᵤ ↑U))

Next tactic:
apply hP.sourceAffineLocally_comp_of_isOpenImmersion
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
  

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)))
⊢ sourceAffineLocally P (𝟙 (Y ∣_ᵤ ↑U))

Next tactic:
rw [@source_affine_openCover_iff _ hP _ _ _ _ (Scheme.openCoverOfIsIso (𝟙 _)) (_)]
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 (𝟙 _)) (_)]
  · 

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:
intro i