l3lab/ntp-mathlib huggingface dataset:
theorem sourceAffineLocally_of_source_open_cover_aux (h₁ : RingHom.RespectsIso @P)
    (h₃ : RingHom.OfLocalizationSpanTarget @P) {X Y : Scheme} (f : X ⟶ Y) (U : X.affineOpens)
    (s : Set (X.presheaf.obj (op U.1))) (hs : Ideal.span s = ⊤)
    (hs' : ∀ r : s, P (Scheme.Γ.map (Scheme.ιOpens (X.basicOpen r.1) ≫ f).op)) :
    P (Scheme.Γ.map (Scheme.ιOpens U ≫ f).op) := by
  

Proof state:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RingHom.PropertyIsLocal P
h₁ : RingHom.RespectsIso P
h₃ : RingHom.OfLocalizationSpanTarget P
X Y : Scheme
f : X ⟶ Y
U : ↑(Scheme.affineOpens X)
s : Set ↑(X.presheaf.obj (op ↑U))
hs : Ideal.span s = ⊤
hs' : ∀ (r : ↑s), P (Scheme.Γ.map (Scheme.ιOpens (X.basicOpen ↑r) ≫ f).op)
⊢ P (Scheme.Γ.map (Scheme.ιOpens ↑U ≫ f).op)

Next tactic:
apply_fun Ideal.map (X.presheaf.map (eqToHom U.1.openEmbedding_obj_top).op) at hs
theorem sourceAffineLocally_of_source_open_cover_aux (h₁ : RingHom.RespectsIso @P)
    (h₃ : RingHom.OfLocalizationSpanTarget @P) {X Y : Scheme} (f : X ⟶ Y) (U : X.affineOpens)
    (s : Set (X.presheaf.obj (op U.1))) (hs : Ideal.span s = ⊤)
    (hs' : ∀ r : s, P (Scheme.Γ.map (Scheme.ιOpens (X.basicOpen r.1) ≫ f).op)) :
    P (Scheme.Γ.map (Scheme.ιOpens U ≫ f).op) := by
  apply_fun Ideal.map (X.presheaf.map (eqToHom U.1.openEmbedding_obj_top).op) at hs
  

Proof state:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RingHom.PropertyIsLocal P
h₁ : RingHom.RespectsIso P
h₃ : RingHom.OfLocalizationSpanTarget P
X Y : Scheme
f : X ⟶ Y
U : ↑(Scheme.affineOpens X)
s : Set ↑(X.presheaf.obj (op ↑U))
hs' : ∀ (r : ↑s), P (Scheme.Γ.map (Scheme.ιOpens (X.basicOpen ↑r) ≫ f).op)
hs :
  Ideal.map (X.presheaf.map (eqToHom (_ : (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤ = ↑U)).op)
      (Ideal.span s) =
    Ideal.map (X.presheaf.map (eqToHom (_ : (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤ = ↑U)).op) ⊤
⊢ P (Scheme.Γ.map (Scheme.ιOpens ↑U ≫ f).op)

Next tactic:
rw [Ideal.map_span, Ideal.map_top] at hs
theorem sourceAffineLocally_of_source_open_cover_aux (h₁ : RingHom.RespectsIso @P)
    (h₃ : RingHom.OfLocalizationSpanTarget @P) {X Y : Scheme} (f : X ⟶ Y) (U : X.affineOpens)
    (s : Set (X.presheaf.obj (op U.1))) (hs : Ideal.span s = ⊤)
    (hs' : ∀ r : s, P (Scheme.Γ.map (Scheme.ιOpens (X.basicOpen r.1) ≫ f).op)) :
    P (Scheme.Γ.map (Scheme.ιOpens U ≫ f).op) := by
  apply_fun Ideal.map (X.presheaf.map (eqToHom U.1.openEmbedding_obj_top).op) at hs
  rw [Ideal.map_span, Ideal.map_top] at hs
  

Proof state:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RingHom.PropertyIsLocal P
h₁ : RingHom.RespectsIso P
h₃ : RingHom.OfLocalizationSpanTarget P
X Y : Scheme
f : X ⟶ Y
U : ↑(Scheme.affineOpens X)
s : Set ↑(X.presheaf.obj (op ↑U))
hs' : ∀ (r : ↑s), P (Scheme.Γ.map (Scheme.ιOpens (X.basicOpen ↑r) ≫ f).op)
hs :
  Ideal.span
      (⇑(X.presheaf.map (eqToHom (_ : (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤ = ↑U)).op) '' s) =
    ⊤
⊢ P (Scheme.Γ.map (Scheme.ιOpens ↑U ≫ f).op)

Next tactic:
apply h₃.ofIsLocalization h₁ _ _ hs
theorem sourceAffineLocally_of_source_open_cover_aux (h₁ : RingHom.RespectsIso @P)
    (h₃ : RingHom.OfLocalizationSpanTarget @P) {X Y : Scheme} (f : X ⟶ Y) (U : X.affineOpens)
    (s : Set (X.presheaf.obj (op U.1))) (hs : Ideal.span s = ⊤)
    (hs' : ∀ r : s, P (Scheme.Γ.map (Scheme.ιOpens (X.basicOpen r.1) ≫ f).op)) :
    P (Scheme.Γ.map (Scheme.ιOpens U ≫ f).op) := by
  apply_fun Ideal.map (X.presheaf.map (eqToHom U.1.openEmbedding_obj_top).op) at hs
  rw [Ideal.map_span, Ideal.map_top] at hs
  apply h₃.ofIsLocalization h₁ _ _ hs
  

Proof state:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RingHom.PropertyIsLocal P
h₁ : RingHom.RespectsIso P
h₃ : RingHom.OfLocalizationSpanTarget P
X Y : Scheme
f : X ⟶ Y
U : ↑(Scheme.affineOpens X)
s : Set ↑(X.presheaf.obj (op ↑U))
hs' : ∀ (r : ↑s), P (Scheme.Γ.map (Scheme.ιOpens (X.basicOpen ↑r) ≫ f).op)
hs :
  Ideal.span
      (⇑(X.presheaf.map (eqToHom (_ : (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤ = ↑U)).op) '' s) =
    ⊤
⊢ ∀
    (r :
      ↑(⇑(X.presheaf.map (eqToHom (_ : (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤ = ↑U)).op) ''
          s)),
    ∃ T x x_1,
      ∃ (_ : IsLocalization.Away (↑r) T),
        P
          (RingHom.comp
            (algebraMap (↑(X.presheaf.obj (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤)))) T)
            (Scheme.Γ.map (Scheme.ιOpens ↑U ≫ f).op))

Next tactic:
rintro ⟨s, r, hr, hs⟩
theorem sourceAffineLocally_of_source_open_cover_aux (h₁ : RingHom.RespectsIso @P)
    (h₃ : RingHom.OfLocalizationSpanTarget @P) {X Y : Scheme} (f : X ⟶ Y) (U : X.affineOpens)
    (s : Set (X.presheaf.obj (op U.1))) (hs : Ideal.span s = ⊤)
    (hs' : ∀ r : s, P (Scheme.Γ.map (Scheme.ιOpens (X.basicOpen r.1) ≫ f).op)) :
    P (Scheme.Γ.map (Scheme.ιOpens U ≫ f).op) := by
  apply_fun Ideal.map (X.presheaf.map (eqToHom U.1.openEmbedding_obj_top).op) at hs
  rw [Ideal.map_span, Ideal.map_top] at hs
  apply h₃.ofIsLocalization h₁ _ _ hs
  rintro ⟨s, r, hr, hs⟩
  

Proof state:
case mk.intro.intro
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RingHom.PropertyIsLocal P
h₁ : RingHom.RespectsIso P
h₃ : RingHom.OfLocalizationSpanTarget P
X Y : Scheme
f : X ⟶ Y
U : ↑(Scheme.affineOpens X)
s✝ : Set ↑(X.presheaf.obj (op ↑U))
hs' : ∀ (r : ↑s✝), P (Scheme.Γ.map (Scheme.ιOpens (X.basicOpen ↑r) ≫ f).op)
hs✝ :
  Ideal.span
      (⇑(X.presheaf.map (eqToHom (_ : (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤ = ↑U)).op) ''
        s✝) =
    ⊤
s : ↑(X.presheaf.obj (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤)))
r : ↑(X.presheaf.obj (op ↑U))
hr : r ∈ s✝
hs : (X.presheaf.map (eqToHom (_ : (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤ = ↑U)).op) r = s
⊢ ∃ T x x_1,
    ∃ (_ :
      IsLocalization.Away
        (↑{ val := s,
            property :=
              (_ :
                ∃ a ∈ s✝,
                  (X.presheaf.map
                        (eqToHom (_ : (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤ = ↑U)).op)
                      a =
                    s) })
        T),
      P
        (RingHom.comp
          (algebraMap (↑(X.presheaf.obj (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤)))) T)
          (Scheme.Γ.map (Scheme.ιOpens ↑U ≫ f).op))

Next tactic:
refine ⟨_, _, _, @AlgebraicGeometry.Γ_restrict_isLocalization (X ∣_ᵤ U.1) U.2 s, ?_⟩
theorem sourceAffineLocally_of_source_open_cover_aux (h₁ : RingHom.RespectsIso @P)
    (h₃ : RingHom.OfLocalizationSpanTarget @P) {X Y : Scheme} (f : X ⟶ Y) (U : X.affineOpens)
    (s : Set (X.presheaf.obj (op U.1))) (hs : Ideal.span s = ⊤)
    (hs' : ∀ r : s, P (Scheme.Γ.map (Scheme.ιOpens (X.basicOpen r.1) ≫ f).op)) :
    P (Scheme.Γ.map (Scheme.ιOpens U ≫ f).op) := by
  apply_fun Ideal.map (X.presheaf.map (eqToHom U.1.openEmbedding_obj_top).op) at hs
  rw [Ideal.map_span, Ideal.map_top] at hs
  apply h₃.ofIsLocalization h₁ _ _ hs
  rintro ⟨s, r, hr, hs⟩
  refine ⟨_, _, _, @AlgebraicGeometry.Γ_restrict_isLocalization (X ∣_ᵤ U.1) U.2 s, ?_⟩
  

Proof state:
case mk.intro.intro
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RingHom.PropertyIsLocal P
h₁ : RingHom.RespectsIso P
h₃ : RingHom.OfLocalizationSpanTarget P
X Y : Scheme
f : X ⟶ Y
U : ↑(Scheme.affineOpens X)
s✝ : Set ↑(X.presheaf.obj (op ↑U))
hs' : ∀ (r : ↑s✝), P (Scheme.Γ.map (Scheme.ιOpens (X.basicOpen ↑r) ≫ f).op)
hs✝ :
  Ideal.span
      (⇑(X.presheaf.map (eqToHom (_ : (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤ = ↑U)).op) ''
        s✝) =
    ⊤
s : ↑(X.presheaf.obj (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤)))
r : ↑(X.presheaf.obj (op ↑U))
hr : r ∈ s✝
hs : (X.presheaf.map (eqToHom (_ : (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤ = ↑U)).op) r = s
⊢ P
    (RingHom.comp
      (algebraMap ↑(X.presheaf.obj (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤)))
        ↑(Scheme.Γ.obj (op (X ∣_ᵤ ↑U ∣_ᵤ (X ∣_ᵤ ↑U).basicOpen s))))
      (Scheme.Γ.map (Scheme.ιOpens ↑U ≫ f).op))

Next tactic:
rw [RingHom.algebraMap_toAlgebra, ← CommRingCat.comp_eq_ring_hom_comp, ← Functor.map_comp,
    ← op_comp, ← h₁.cancel_right_isIso _ (Scheme.Γ.mapIso (Scheme.restrictRestrict _ _ _).op).inv]
theorem sourceAffineLocally_of_source_open_cover_aux (h₁ : RingHom.RespectsIso @P)
    (h₃ : RingHom.OfLocalizationSpanTarget @P) {X Y : Scheme} (f : X ⟶ Y) (U : X.affineOpens)
    (s : Set (X.presheaf.obj (op U.1))) (hs : Ideal.span s = ⊤)
    (hs' : ∀ r : s, P (Scheme.Γ.map (Scheme.ιOpens (X.basicOpen r.1) ≫ f).op)) :
    P (Scheme.Γ.map (Scheme.ιOpens U ≫ f).op) := by
  apply_fun Ideal.map (X.presheaf.map (eqToHom U.1.openEmbedding_obj_top).op) at hs
  rw [Ideal.map_span, Ideal.map_top] at hs
  apply h₃.ofIsLocalization h₁ _ _ hs
  rintro ⟨s, r, hr, hs⟩
  refine ⟨_, _, _, @AlgebraicGeometry.Γ_restrict_isLocalization (X ∣_ᵤ U.1) U.2 s, ?_⟩
  rw [RingHom.algebraMap_toAlgebra, ← CommRingCat.comp_eq_ring_hom_comp, ← Functor.map_comp,
    ← op_comp, ← h₁.cancel_right_isIso _ (Scheme.Γ.mapIso (Scheme.restrictRestrict _ _ _).op).inv]
  

Proof state:
case mk.intro.intro
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RingHom.PropertyIsLocal P
h₁ : RingHom.RespectsIso P
h₃ : RingHom.OfLocalizationSpanTarget P
X Y : Scheme
f : X ⟶ Y
U : ↑(Scheme.affineOpens X)
s✝ : Set ↑(X.presheaf.obj (op ↑U))
hs' : ∀ (r : ↑s✝), P (Scheme.Γ.map (Scheme.ιOpens (X.basicOpen ↑r) ≫ f).op)
hs✝ :
  Ideal.span
      (⇑(X.presheaf.map (eqToHom (_ : (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤ = ↑U)).op) ''
        s✝) =
    ⊤
s : ↑(X.presheaf.obj (op ((IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤)))
r : ↑(X.presheaf.obj (op ↑U))
hr : r ∈ s✝
hs : (X.presheaf.map (eqToHom (_ : (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤ = ↑U)).op) r = s
⊢ P
    (Scheme.Γ.map
        (Scheme.ofRestrict (X ∣_ᵤ ↑U) (_ : OpenEmbedding ⇑(Opens.inclusion ((X ∣_ᵤ ↑U).basicOpen s))) ≫
            Scheme.ιOpens ↑U ≫ f).op ≫
      (Scheme.Γ.mapIso (Iso.op (Scheme.restrictRestrict X (↑U) ((X ∣_ᵤ ↑U).basicOpen s)))).inv)

Next tactic:
subst hs
theorem sourceAffineLocally_of_source_open_cover_aux (h₁ : RingHom.RespectsIso @P)
    (h₃ : RingHom.OfLocalizationSpanTarget @P) {X Y : Scheme} (f : X ⟶ Y) (U : X.affineOpens)
    (s : Set (X.presheaf.obj (op U.1))) (hs : Ideal.span s = ⊤)
    (hs' : ∀ r : s, P (Scheme.Γ.map (Scheme.ιOpens (X.basicOpen r.1) ≫ f).op)) :
    P (Scheme.Γ.map (Scheme.ιOpens U ≫ f).op) := by
  apply_fun Ideal.map (X.presheaf.map (eqToHom U.1.openEmbedding_obj_top).op) at hs
  rw [Ideal.map_span, Ideal.map_top] at hs
  apply h₃.ofIsLocalization h₁ _ _ hs
  rintro ⟨s, r, hr, hs⟩
  refine ⟨_, _, _, @AlgebraicGeometry.Γ_restrict_isLocalization (X ∣_ᵤ U.1) U.2 s, ?_⟩
  rw [RingHom.algebraMap_toAlgebra, ← CommRingCat.comp_eq_ring_hom_comp, ← Functor.map_comp,
    ← op_comp, ← h₁.cancel_right_isIso _ (Scheme.Γ.mapIso (Scheme.restrictRestrict _ _ _).op).inv]
  subst hs
  

Proof state:
case mk.intro.intro
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RingHom.PropertyIsLocal P
h₁ : RingHom.RespectsIso P
h₃ : RingHom.OfLocalizationSpanTarget P
X Y : Scheme
f : X ⟶ Y
U : ↑(Scheme.affineOpens X)
s : Set ↑(X.presheaf.obj (op ↑U))
hs' : ∀ (r : ↑s), P (Scheme.Γ.map (Scheme.ιOpens (X.basicOpen ↑r) ≫ f).op)
hs :
  Ideal.span
      (⇑(X.presheaf.map (eqToHom (_ : (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤ = ↑U)).op) '' s) =
    ⊤
r : ↑(X.presheaf.obj (op ↑U))
hr : r ∈ s
⊢ P
    (Scheme.Γ.map
        (Scheme.ofRestrict (X ∣_ᵤ ↑U)
              (_ :
                OpenEmbedding
                  ⇑(Opens.inclusion
                      ((X ∣_ᵤ ↑U).basicOpen
                        ((X.presheaf.map
                            (eqToHom (_ : (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤ = ↑U)).op)
                          r)))) ≫
            Scheme.ιOpens ↑U ≫ f).op ≫
      (Scheme.Γ.mapIso
          (Iso.op
            (Scheme.restrictRestrict X (↑U)
              ((X ∣_ᵤ ↑U).basicOpen
                ((X.presheaf.map
                    (eqToHom (_ : (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤ = ↑U)).op)
                  r))))).inv)

Next tactic:
rw [← h₁.cancel_right_isIso _
    (Scheme.Γ.mapIso (Scheme.restrictIsoOfEq _ (Scheme.map_basicOpen_map _ _ _)).op).inv]
theorem sourceAffineLocally_of_source_open_cover_aux (h₁ : RingHom.RespectsIso @P)
    (h₃ : RingHom.OfLocalizationSpanTarget @P) {X Y : Scheme} (f : X ⟶ Y) (U : X.affineOpens)
    (s : Set (X.presheaf.obj (op U.1))) (hs : Ideal.span s = ⊤)
    (hs' : ∀ r : s, P (Scheme.Γ.map (Scheme.ιOpens (X.basicOpen r.1) ≫ f).op)) :
    P (Scheme.Γ.map (Scheme.ιOpens U ≫ f).op) := by
  apply_fun Ideal.map (X.presheaf.map (eqToHom U.1.openEmbedding_obj_top).op) at hs
  rw [Ideal.map_span, Ideal.map_top] at hs
  apply h₃.ofIsLocalization h₁ _ _ hs
  rintro ⟨s, r, hr, hs⟩
  refine ⟨_, _, _, @AlgebraicGeometry.Γ_restrict_isLocalization (X ∣_ᵤ U.1) U.2 s, ?_⟩
  rw [RingHom.algebraMap_toAlgebra, ← CommRingCat.comp_eq_ring_hom_comp, ← Functor.map_comp,
    ← op_comp, ← h₁.cancel_right_isIso _ (Scheme.Γ.mapIso (Scheme.restrictRestrict _ _ _).op).inv]
  subst hs
  rw [← h₁.cancel_right_isIso _
    (Scheme.Γ.mapIso (Scheme.restrictIsoOfEq _ (Scheme.map_basicOpen_map _ _ _)).op).inv]
  

Proof state:
case mk.intro.intro
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RingHom.PropertyIsLocal P
h₁ : RingHom.RespectsIso P
h₃ : RingHom.OfLocalizationSpanTarget P
X Y : Scheme
f : X ⟶ Y
U : ↑(Scheme.affineOpens X)
s : Set ↑(X.presheaf.obj (op ↑U))
hs' : ∀ (r : ↑s), P (Scheme.Γ.map (Scheme.ιOpens (X.basicOpen ↑r) ≫ f).op)
hs :
  Ideal.span
      (⇑(X.presheaf.map (eqToHom (_ : (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤ = ↑U)).op) '' s) =
    ⊤
r : ↑(X.presheaf.obj (op ↑U))
hr : r ∈ s
⊢ P
    ((Scheme.Γ.map
          (Scheme.ofRestrict (X ∣_ᵤ ↑U)
                (_ :
                  OpenEmbedding
                    ⇑(Opens.inclusion
                        ((X ∣_ᵤ ↑U).basicOpen
                          ((X.presheaf.map
                              (eqToHom (_ : (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤ = ↑U)).op)
                            r)))) ≫
              Scheme.ιOpens ↑U ≫ f).op ≫
        (Scheme.Γ.mapIso
            (Iso.op
              (Scheme.restrictRestrict X (↑U)
                ((X ∣_ᵤ ↑U).basicOpen
                  ((X.presheaf.map
                      (eqToHom (_ : (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤ = ↑U)).op)
                    r))))).inv) ≫
      (Scheme.Γ.mapIso
          (Iso.op
            (Scheme.restrictIsoOfEq X
              (_ :
                (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj
                    ((X ∣_ᵤ ↑U).basicOpen
                      ((X.presheaf.map
                          (eqToHom (_ : (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤ = ↑U)).op)
                        r)) =
                  X.basicOpen r)))).inv)

Next tactic:
simp only [Functor.mapIso_inv, Iso.op_inv, ← Functor.map_comp, ← op_comp,
    Scheme.restrictRestrict_inv_restrict_restrict_assoc, Scheme.restrictIsoOfEq,
    IsOpenImmersion.isoOfRangeEq_inv_fac_assoc]
theorem sourceAffineLocally_of_source_open_cover_aux (h₁ : RingHom.RespectsIso @P)
    (h₃ : RingHom.OfLocalizationSpanTarget @P) {X Y : Scheme} (f : X ⟶ Y) (U : X.affineOpens)
    (s : Set (X.presheaf.obj (op U.1))) (hs : Ideal.span s = ⊤)
    (hs' : ∀ r : s, P (Scheme.Γ.map (Scheme.ιOpens (X.basicOpen r.1) ≫ f).op)) :
    P (Scheme.Γ.map (Scheme.ιOpens U ≫ f).op) := by
  apply_fun Ideal.map (X.presheaf.map (eqToHom U.1.openEmbedding_obj_top).op) at hs
  rw [Ideal.map_span, Ideal.map_top] at hs
  apply h₃.ofIsLocalization h₁ _ _ hs
  rintro ⟨s, r, hr, hs⟩
  refine ⟨_, _, _, @AlgebraicGeometry.Γ_restrict_isLocalization (X ∣_ᵤ U.1) U.2 s, ?_⟩
  rw [RingHom.algebraMap_toAlgebra, ← CommRingCat.comp_eq_ring_hom_comp, ← Functor.map_comp,
    ← op_comp, ← h₁.cancel_right_isIso _ (Scheme.Γ.mapIso (Scheme.restrictRestrict _ _ _).op).inv]
  subst hs
  rw [← h₁.cancel_right_isIso _
    (Scheme.Γ.mapIso (Scheme.restrictIsoOfEq _ (Scheme.map_basicOpen_map _ _ _)).op).inv]
  simp only [Functor.mapIso_inv, Iso.op_inv, ← Functor.map_comp, ← op_comp,
    Scheme.restrictRestrict_inv_restrict_restrict_assoc, Scheme.restrictIsoOfEq,
    IsOpenImmersion.isoOfRangeEq_inv_fac_assoc]
  

Proof state:
case mk.intro.intro
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RingHom.PropertyIsLocal P
h₁ : RingHom.RespectsIso P
h₃ : RingHom.OfLocalizationSpanTarget P
X Y : Scheme
f : X ⟶ Y
U : ↑(Scheme.affineOpens X)
s : Set ↑(X.presheaf.obj (op ↑U))
hs' : ∀ (r : ↑s), P (Scheme.Γ.map (Scheme.ιOpens (X.basicOpen ↑r) ≫ f).op)
hs :
  Ideal.span
      (⇑(X.presheaf.map (eqToHom (_ : (IsOpenMap.functor (_ : IsOpenMap ⇑(Opens.inclusion ↑U))).obj ⊤ = ↑U)).op) '' s) =
    ⊤
r : ↑(X.presheaf.obj (op ↑U))
hr : r ∈ s
⊢ P (Scheme.Γ.map (Scheme.ιOpens (X.basicOpen r) ≫ f).op)

Next tactic:
exact hs' ⟨r, hr⟩
theorem isOpenImmersionCat_comp_of_sourceAffineLocally (h₁ : RingHom.RespectsIso @P)
    {X Y Z : Scheme} [IsAffine X] [IsAffine Z] (f : X ⟶ Y) [IsOpenImmersion f] (g : Y ⟶ Z)
    (h₂ : sourceAffineLocally (@P) g) : P (Scheme.Γ.map (f ≫ g).op) := by
  

Proof state:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RingHom.PropertyIsLocal P
h₁ : RingHom.RespectsIso P
X Y Z : Scheme
inst✝² : IsAffine X
inst✝¹ : IsAffine Z
f : X ⟶ Y
inst✝ : IsOpenImmersion f
g : Y ⟶ Z
h₂ : sourceAffineLocally P g
⊢ P (Scheme.Γ.map (f ≫ g).op)

Next tactic:
rw [← h₁.cancel_right_isIso _
    (Scheme.Γ.map (IsOpenImmersion.isoOfRangeEq (Y.ofRestrict _) f _).hom.op),
    ← Functor.map_comp, ← op_comp]
theorem isOpenImmersionCat_comp_of_sourceAffineLocally (h₁ : RingHom.RespectsIso @P)
    {X Y Z : Scheme} [IsAffine X] [IsAffine Z] (f : X ⟶ Y) [IsOpenImmersion f] (g : Y ⟶ Z)
    (h₂ : sourceAffineLocally (@P) g) : P (Scheme.Γ.map (f ≫ g).op) := by
  rw [← h₁.cancel_right_isIso _
    (Scheme.Γ.map (IsOpenImmersion.isoOfRangeEq (Y.ofRestrict _) f _).hom.op),
    ← Functor.map_comp, ← op_comp]
  convert h₂ ⟨_, rangeIsAffineOpenOfOpenImmersion f⟩ using 3
  · 

Proof state:
case h.e'_5.h.h.e'_8.h.e'_5
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RingHom.PropertyIsLocal P
h₁ : RingHom.RespectsIso P
X Y Z : Scheme
inst✝² : IsAffine X
inst✝¹ : IsAffine Z
f : X ⟶ Y
inst✝ : IsOpenImmersion f
g : Y ⟶ Z
h₂ : sourceAffineLocally P g
⊢ (IsOpenImmersion.isoOfRangeEq
          (Scheme.ofRestrict Y
            (_ :
              OpenEmbedding
                ⇑(Opens.inclusion
                    ↑{ val := Scheme.Hom.opensRange f, property := (_ : IsAffineOpen (Scheme.Hom.opensRange f)) })))
          f ?m.124811).hom ≫
      f ≫ g =
    Scheme.ofRestrict Y
        (_ :
          OpenEmbedding
            ⇑(Opens.inclusion
                ↑{ val := Scheme.Hom.opensRange f, property := (_ : IsAffineOpen (Scheme.Hom.opensRange f)) })) ≫
      g

Next tactic:
rw [IsOpenImmersion.isoOfRangeEq_hom_fac_assoc]
theorem isOpenImmersionCat_comp_of_sourceAffineLocally (h₁ : RingHom.RespectsIso @P)
    {X Y Z : Scheme} [IsAffine X] [IsAffine Z] (f : X ⟶ Y) [IsOpenImmersion f] (g : Y ⟶ Z)
    (h₂ : sourceAffineLocally (@P) g) : P (Scheme.Γ.map (f ≫ g).op) := by
  rw [← h₁.cancel_right_isIso _
    (Scheme.Γ.map (IsOpenImmersion.isoOfRangeEq (Y.ofRestrict _) f _).hom.op),
    ← Functor.map_comp, ← op_comp]
  convert h₂ ⟨_, rangeIsAffineOpenOfOpenImmersion f⟩ using 3
  · rw [IsOpenImmersion.isoOfRangeEq_hom_fac_assoc]
    

Proof state:
case h.e'_5.h.h.e'_8.h.e'_5.e
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RingHom.PropertyIsLocal P
h₁ : RingHom.RespectsIso P
X Y Z : Scheme
inst✝² : IsAffine X
inst✝¹ : IsAffine Z
f : X ⟶ Y
inst✝ : IsOpenImmersion f
g : Y ⟶ Z
h₂ : sourceAffineLocally P g
⊢ Set.range
      ⇑(Scheme.ofRestrict Y
              (_ :
                OpenEmbedding
                  ⇑(Opens.inclusion
                      ↑{ val := Scheme.Hom.opensRange f,
                          property := (_ : IsAffineOpen (Scheme.Hom.opensRange f)) }))).val.base =
    Set.range ⇑f.val.base

Next tactic:
exact Subtype.range_coe
theorem sourceAffineLocally_of_source_openCover {X Y : Scheme} (f : X ⟶ Y) [IsAffine Y]
    (𝒰 : X.OpenCover) [∀ i, IsAffine (𝒰.obj i)] (H : ∀ i, P (Scheme.Γ.map (𝒰.map i ≫ f).op)) :
    sourceAffineLocally (@P) f := by
  

Proof state:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
X Y : Scheme
f : X ⟶ Y
inst✝¹ : IsAffine Y
𝒰 : Scheme.OpenCover X
inst✝ : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)
H : ∀ (i : 𝒰.J), P (Scheme.Γ.map (Scheme.OpenCover.map 𝒰 i ≫ f).op)
⊢ sourceAffineLocally P f

Next tactic:
let S i := (⟨⟨Set.range (𝒰.map i).1.base, (𝒰.IsOpen i).base_open.open_range⟩,
    rangeIsAffineOpenOfOpenImmersion (𝒰.map i)⟩ : X.affineOpens)
theorem sourceAffineLocally_of_source_openCover {X Y : Scheme} (f : X ⟶ Y) [IsAffine Y]
    (𝒰 : X.OpenCover) [∀ i, IsAffine (𝒰.obj i)] (H : ∀ i, P (Scheme.Γ.map (𝒰.map i ≫ f).op)) :
    sourceAffineLocally (@P) f := by
  let S i := (⟨⟨Set.range (𝒰.map i).1.base, (𝒰.IsOpen i).base_open.open_range⟩,
    rangeIsAffineOpenOfOpenImmersion (𝒰.map i)⟩ : X.affineOpens)
  

Proof state:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
X Y : Scheme
f : X ⟶ Y
inst✝¹ : IsAffine Y
𝒰 : Scheme.OpenCover X
inst✝ : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)
H : ∀ (i : 𝒰.J), P (Scheme.Γ.map (Scheme.OpenCover.map 𝒰 i ≫ f).op)
S : 𝒰.J → { x // x ∈ Scheme.affineOpens X } :=
  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))) }
⊢ sourceAffineLocally P f

Next tactic:
intro U
theorem sourceAffineLocally_of_source_openCover {X Y : Scheme} (f : X ⟶ Y) [IsAffine Y]
    (𝒰 : X.OpenCover) [∀ i, IsAffine (𝒰.obj i)] (H : ∀ i, P (Scheme.Γ.map (𝒰.map i ≫ f).op)) :
    sourceAffineLocally (@P) f := by
  let S i := (⟨⟨Set.range (𝒰.map i).1.base, (𝒰.IsOpen i).base_open.open_range⟩,
    rangeIsAffineOpenOfOpenImmersion (𝒰.map i)⟩ : X.affineOpens)
  intro U
  -- Porting note: here is what we are eliminating into Lean
  

Proof state:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : PropertyIsLocal P
X Y : Scheme
f : X ⟶ Y
inst✝¹ : IsAffine Y
𝒰 : Scheme.OpenCover X
inst✝ : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)
H : ∀ (i : 𝒰.J), P (Scheme.Γ.map (Scheme.OpenCover.map 𝒰 i ≫ f).op)
S : 𝒰.J → { x // x ∈ Scheme.affineOpens X } :=
  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 X)
⊢ P (Scheme.Γ.map (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)) ≫ f).op)

Next tactic:
apply of_affine_open_cover
    (P := fun V => P (Scheme.Γ.map (X.ofRestrict (Opens.openEmbedding V.val) ≫ f).op)) U