l3lab/ntp-mathlib huggingface dataset:
theorem scheme_restrict_basicOpen_of_localizationPreserves (h₁ : RingHom.RespectsIso @P)
    (h₂ : RingHom.LocalizationPreserves @P) {X Y : Scheme} [IsAffine Y] (f : X ⟶ Y)
    (r : Y.presheaf.obj (op ⊤)) (H : sourceAffineLocally (@P) f)
    (U : (X.restrict ((Opens.map f.1.base).obj <| Y.basicOpen r).openEmbedding).affineOpens) :
    P (Scheme.Γ.map ((X.restrict ((Opens.map f.1.base).obj <|
      Y.basicOpen r).openEmbedding).ofRestrict U.1.openEmbedding ≫ f ∣_ Y.basicOpen r).op) := by
  specialize H ⟨_, U.2.imageIsOpenImmersion (X.ofRestrict _)⟩
  letI i1 : Algebra (Y.presheaf.obj <| Opposite.op ⊤) (Localization.Away r) := Localization.algebra
  

Proof state:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
h₁ : RingHom.RespectsIso P
h₂ : RingHom.LocalizationPreserves P
X Y : Scheme
inst✝ : IsAffine Y
f : X ⟶ Y
r : ↑(Y.presheaf.obj (op ⊤))
U : ↑(Scheme.affineOpens (X ∣_ᵤ f⁻¹ᵁ Y.basicOpen r))
H :
  P
    (Scheme.Γ.map
      (Scheme.ofRestrict X
            (_ :
              OpenEmbedding
                ⇑(Opens.inclusion
                    ↑{
                        val :=
                          (Scheme.Hom.opensFunctor
                                (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion (f⁻¹ᵁ Y.basicOpen r))))).obj
                            ↑U,
                        property :=
                          (_ :
                            IsAffineOpen
                              ((Scheme.Hom.opensFunctor
                                    (Scheme.ofRestrict X
                                      (_ : OpenEmbedding ⇑(Opens.inclusion (f⁻¹ᵁ Y.basicOpen r))))).obj
                                ↑U)) })) ≫
          f).op)
i1 : Algebra (↑(Y.presheaf.obj (op ⊤))) (Localization.Away r) := Localization.algebra
⊢ P
    (Scheme.Γ.map
      (Scheme.ofRestrict (X ∣_ᵤ f⁻¹ᵁ Y.basicOpen r) (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)) ≫ f ∣_ Y.basicOpen r).op)

Next tactic:
exact (h₁.ofRestrict_morphismRestrict_iff f r
    ((Scheme.Hom.opensFunctor
      (X.ofRestrict ((Opens.map f.1.base).obj <| Y.basicOpen r).openEmbedding)).obj U.1)
    (IsAffineOpen.imageIsOpenImmersion U.2
      (X.ofRestrict ((Opens.map f.1.base).obj <| Y.basicOpen r).openEmbedding))
    (Opens.ext (Set.preimage_image_eq _ Subtype.coe_injective).symm)).mpr (h₂.away r H)
theorem sourceAffineLocally_isLocal (h₁ : RingHom.RespectsIso @P)
    (h₂ : RingHom.LocalizationPreserves @P) (h₃ : RingHom.OfLocalizationSpan @P) :
    (sourceAffineLocally @P).IsLocal := by
  

Proof state:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
h₁ : RingHom.RespectsIso P
h₂ : RingHom.LocalizationPreserves P
h₃ : RingHom.OfLocalizationSpan P
⊢ AffineTargetMorphismProperty.IsLocal (sourceAffineLocally P)

Next tactic:
constructor
theorem sourceAffineLocally_isLocal (h₁ : RingHom.RespectsIso @P)
    (h₂ : RingHom.LocalizationPreserves @P) (h₃ : RingHom.OfLocalizationSpan @P) :
    (sourceAffineLocally @P).IsLocal := by
  constructor
  · 

Proof state:
case RespectsIso
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
h₁ : RingHom.RespectsIso P
h₂ : RingHom.LocalizationPreserves P
h₃ : RingHom.OfLocalizationSpan P
⊢ MorphismProperty.RespectsIso (AffineTargetMorphismProperty.toProperty (sourceAffineLocally P))

Next tactic:
exact sourceAffineLocally_respectsIso h₁
theorem sourceAffineLocally_isLocal (h₁ : RingHom.RespectsIso @P)
    (h₂ : RingHom.LocalizationPreserves @P) (h₃ : RingHom.OfLocalizationSpan @P) :
    (sourceAffineLocally @P).IsLocal := by
  constructor
  · exact sourceAffineLocally_respectsIso h₁
  · 

Proof state:
case toBasicOpen
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
h₁ : RingHom.RespectsIso P
h₂ : RingHom.LocalizationPreserves P
h₃ : RingHom.OfLocalizationSpan P
⊢ ∀ {X Y : Scheme} [inst : IsAffine Y] (f : X ⟶ Y) (r : ↑(Y.presheaf.obj (op ⊤))),
    sourceAffineLocally P f → sourceAffineLocally P (f ∣_ Y.basicOpen r)

Next tactic:
introv H U
theorem sourceAffineLocally_isLocal (h₁ : RingHom.RespectsIso @P)
    (h₂ : RingHom.LocalizationPreserves @P) (h₃ : RingHom.OfLocalizationSpan @P) :
    (sourceAffineLocally @P).IsLocal := by
  constructor
  · exact sourceAffineLocally_respectsIso h₁
  · introv H U
    

Proof state:
case toBasicOpen
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
h₁ : RingHom.RespectsIso P
h₂ : RingHom.LocalizationPreserves P
h₃ : RingHom.OfLocalizationSpan P
X Y : Scheme
inst✝ : IsAffine Y
f : X ⟶ Y
r : ↑(Y.presheaf.obj (op ⊤))
H : sourceAffineLocally P f
U : ↑(Scheme.affineOpens (X ∣_ᵤ f⁻¹ᵁ Y.basicOpen r))
⊢ P
    (Scheme.Γ.map
      (Scheme.ofRestrict (X ∣_ᵤ f⁻¹ᵁ Y.basicOpen r) (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)) ≫ f ∣_ Y.basicOpen r).op)

Next tactic:
apply scheme_restrict_basicOpen_of_localizationPreserves h₁ h₂
theorem sourceAffineLocally_isLocal (h₁ : RingHom.RespectsIso @P)
    (h₂ : RingHom.LocalizationPreserves @P) (h₃ : RingHom.OfLocalizationSpan @P) :
    (sourceAffineLocally @P).IsLocal := by
  constructor
  · exact sourceAffineLocally_respectsIso h₁
  · introv H U
    apply scheme_restrict_basicOpen_of_localizationPreserves h₁ h₂; 

Proof state:
case toBasicOpen.H
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
h₁ : RingHom.RespectsIso P
h₂ : RingHom.LocalizationPreserves P
h₃ : RingHom.OfLocalizationSpan P
X Y : Scheme
inst✝ : IsAffine Y
f : X ⟶ Y
r : ↑(Y.presheaf.obj (op ⊤))
H : sourceAffineLocally P f
U : ↑(Scheme.affineOpens (X ∣_ᵤ f⁻¹ᵁ Y.basicOpen r))
⊢ sourceAffineLocally P f

Next tactic:
assumption
theorem sourceAffineLocally_isLocal (h₁ : RingHom.RespectsIso @P)
    (h₂ : RingHom.LocalizationPreserves @P) (h₃ : RingHom.OfLocalizationSpan @P) :
    (sourceAffineLocally @P).IsLocal := by
  constructor
  · exact sourceAffineLocally_respectsIso h₁
  · introv H U
    apply scheme_restrict_basicOpen_of_localizationPreserves h₁ h₂; assumption
  · 

Proof state:
case ofBasicOpenCover
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
h₁ : RingHom.RespectsIso P
h₂ : RingHom.LocalizationPreserves P
h₃ : RingHom.OfLocalizationSpan P
⊢ ∀ {X Y : Scheme} [inst : IsAffine Y] (f : X ⟶ Y) (s : Finset ↑(Y.presheaf.obj (op ⊤))),
    Ideal.span ↑s = ⊤ → (∀ (r : { x // x ∈ s }), sourceAffineLocally P (f ∣_ Y.basicOpen ↑r)) → sourceAffineLocally P f

Next tactic:
introv hs hs' U
theorem sourceAffineLocally_isLocal (h₁ : RingHom.RespectsIso @P)
    (h₂ : RingHom.LocalizationPreserves @P) (h₃ : RingHom.OfLocalizationSpan @P) :
    (sourceAffineLocally @P).IsLocal := by
  constructor
  · exact sourceAffineLocally_respectsIso h₁
  · introv H U
    apply scheme_restrict_basicOpen_of_localizationPreserves h₁ h₂; assumption
  · introv hs hs' U
    

Proof state:
case ofBasicOpenCover
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
h₁ : RingHom.RespectsIso P
h₂ : RingHom.LocalizationPreserves P
h₃ : RingHom.OfLocalizationSpan P
X Y : Scheme
inst✝ : IsAffine Y
f : X ⟶ Y
s : Finset ↑(Y.presheaf.obj (op ⊤))
hs : Ideal.span ↑s = ⊤
hs' : ∀ (r : { x // x ∈ s }), sourceAffineLocally P (f ∣_ Y.basicOpen ↑r)
U : ↑(Scheme.affineOpens X)
⊢ P (Scheme.Γ.map (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)) ≫ f).op)

Next tactic:
skip
theorem sourceAffineLocally_isLocal (h₁ : RingHom.RespectsIso @P)
    (h₂ : RingHom.LocalizationPreserves @P) (h₃ : RingHom.OfLocalizationSpan @P) :
    (sourceAffineLocally @P).IsLocal := by
  constructor
  · exact sourceAffineLocally_respectsIso h₁
  · introv H U
    apply scheme_restrict_basicOpen_of_localizationPreserves h₁ h₂; assumption
  · introv hs hs' U
    skip
    

Proof state:
case ofBasicOpenCover
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
h₁ : RingHom.RespectsIso P
h₂ : RingHom.LocalizationPreserves P
h₃ : RingHom.OfLocalizationSpan P
X Y : Scheme
inst✝ : IsAffine Y
f : X ⟶ Y
s : Finset ↑(Y.presheaf.obj (op ⊤))
hs : Ideal.span ↑s = ⊤
hs' : ∀ (r : { x // x ∈ s }), sourceAffineLocally P (f ∣_ Y.basicOpen ↑r)
U : ↑(Scheme.affineOpens X)
⊢ P (Scheme.Γ.map (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)) ≫ f).op)

Next tactic:
apply h₃ _ _ hs
theorem sourceAffineLocally_isLocal (h₁ : RingHom.RespectsIso @P)
    (h₂ : RingHom.LocalizationPreserves @P) (h₃ : RingHom.OfLocalizationSpan @P) :
    (sourceAffineLocally @P).IsLocal := by
  constructor
  · exact sourceAffineLocally_respectsIso h₁
  · introv H U
    apply scheme_restrict_basicOpen_of_localizationPreserves h₁ h₂; assumption
  · introv hs hs' U
    skip
    apply h₃ _ _ hs
    

Proof state:
case ofBasicOpenCover
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
h₁ : RingHom.RespectsIso P
h₂ : RingHom.LocalizationPreserves P
h₃ : RingHom.OfLocalizationSpan P
X Y : Scheme
inst✝ : IsAffine Y
f : X ⟶ Y
s : Finset ↑(Y.presheaf.obj (op ⊤))
hs : Ideal.span ↑s = ⊤
hs' : ∀ (r : { x // x ∈ s }), sourceAffineLocally P (f ∣_ Y.basicOpen ↑r)
U : ↑(Scheme.affineOpens X)
⊢ ∀ (r : ↑↑s),
    P (Localization.awayMap (Scheme.Γ.map (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)) ≫ f).op) ↑r)

Next tactic:
intro r
theorem sourceAffineLocally_isLocal (h₁ : RingHom.RespectsIso @P)
    (h₂ : RingHom.LocalizationPreserves @P) (h₃ : RingHom.OfLocalizationSpan @P) :
    (sourceAffineLocally @P).IsLocal := by
  constructor
  · exact sourceAffineLocally_respectsIso h₁
  · introv H U
    apply scheme_restrict_basicOpen_of_localizationPreserves h₁ h₂; assumption
  · introv hs hs' U
    skip
    apply h₃ _ _ hs
    intro r
    

Proof state:
case ofBasicOpenCover
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
h₁ : RingHom.RespectsIso P
h₂ : RingHom.LocalizationPreserves P
h₃ : RingHom.OfLocalizationSpan P
X Y : Scheme
inst✝ : IsAffine Y
f : X ⟶ Y
s : Finset ↑(Y.presheaf.obj (op ⊤))
hs : Ideal.span ↑s = ⊤
hs' : ∀ (r : { x // x ∈ s }), sourceAffineLocally P (f ∣_ Y.basicOpen ↑r)
U : ↑(Scheme.affineOpens X)
r : ↑↑s
⊢ P (Localization.awayMap (Scheme.Γ.map (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)) ≫ f).op) ↑r)

Next tactic:
have := hs' r ⟨(Opens.map (X.ofRestrict _).1.base).obj U.1, ?_⟩
theorem sourceAffineLocally_isLocal (h₁ : RingHom.RespectsIso @P)
    (h₂ : RingHom.LocalizationPreserves @P) (h₃ : RingHom.OfLocalizationSpan @P) :
    (sourceAffineLocally @P).IsLocal := by
  constructor
  · exact sourceAffineLocally_respectsIso h₁
  · introv H U
    apply scheme_restrict_basicOpen_of_localizationPreserves h₁ h₂; assumption
  · introv hs hs' U
    skip
    apply h₃ _ _ hs
    intro r
    have := hs' r ⟨(Opens.map (X.ofRestrict _).1.base).obj U.1, ?_⟩
    

Proof state:
case ofBasicOpenCover.refine_2
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
h₁ : RingHom.RespectsIso P
h₂ : RingHom.LocalizationPreserves P
h₃ : RingHom.OfLocalizationSpan P
X Y : Scheme
inst✝ : IsAffine Y
f : X ⟶ Y
s : Finset ↑(Y.presheaf.obj (op ⊤))
hs : Ideal.span ↑s = ⊤
hs' : ∀ (r : { x // x ∈ s }), sourceAffineLocally P (f ∣_ Y.basicOpen ↑r)
U : ↑(Scheme.affineOpens X)
r : ↑↑s
this :
  P
    (Scheme.Γ.map
      (Scheme.ofRestrict (X ∣_ᵤ f⁻¹ᵁ Y.basicOpen ↑r)
            (_ :
              OpenEmbedding
                ⇑(Opens.inclusion
                    ↑{ val := Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion (f⁻¹ᵁ Y.basicOpen ↑r)))⁻¹ᵁ ↑U,
                        property := ?ofBasicOpenCover.refine_1 })) ≫
          f ∣_ Y.basicOpen ↑r).op)
⊢ P (Localization.awayMap (Scheme.Γ.map (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)) ≫ f).op) ↑r)
case ofBasicOpenCover.refine_1
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
h₁ : RingHom.RespectsIso P
h₂ : RingHom.LocalizationPreserves P
h₃ : RingHom.OfLocalizationSpan P
X Y : Scheme
inst✝ : IsAffine Y
f : X ⟶ Y
s : Finset ↑(Y.presheaf.obj (op ⊤))
hs : Ideal.span ↑s = ⊤
hs' : ∀ (r : { x // x ∈ s }), sourceAffineLocally P (f ∣_ Y.basicOpen ↑r)
U : ↑(Scheme.affineOpens X)
r : ↑↑s
⊢ Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion (f⁻¹ᵁ Y.basicOpen ↑r)))⁻¹ᵁ ↑U ∈
    Scheme.affineOpens (X ∣_ᵤ f⁻¹ᵁ Y.basicOpen ↑r)

Next tactic:
rwa [h₁.ofRestrict_morphismRestrict_iff] at this
theorem sourceAffineLocally_isLocal (h₁ : RingHom.RespectsIso @P)
    (h₂ : RingHom.LocalizationPreserves @P) (h₃ : RingHom.OfLocalizationSpan @P) :
    (sourceAffineLocally @P).IsLocal := by
  constructor
  · exact sourceAffineLocally_respectsIso h₁
  · introv H U
    apply scheme_restrict_basicOpen_of_localizationPreserves h₁ h₂; assumption
  · introv hs hs' U
    skip
    apply h₃ _ _ hs
    intro r
    have := hs' r ⟨(Opens.map (X.ofRestrict _).1.base).obj U.1, ?_⟩
    rwa [h₁.ofRestrict_morphismRestrict_iff] at this
    · 

Proof state:
case ofBasicOpenCover.refine_2.hU
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
h₁ : RingHom.RespectsIso P
h₂ : RingHom.LocalizationPreserves P
h₃ : RingHom.OfLocalizationSpan P
X Y : Scheme
inst✝ : IsAffine Y
f : X ⟶ Y
s : Finset ↑(Y.presheaf.obj (op ⊤))
hs : Ideal.span ↑s = ⊤
hs' : ∀ (r : { x // x ∈ s }), sourceAffineLocally P (f ∣_ Y.basicOpen ↑r)
U : ↑(Scheme.affineOpens X)
r : ↑↑s
this :
  P
    (Scheme.Γ.map
      (Scheme.ofRestrict (X ∣_ᵤ f⁻¹ᵁ Y.basicOpen ↑r)
            (_ :
              OpenEmbedding
                ⇑(Opens.inclusion
                    ↑{ val := Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion (f⁻¹ᵁ Y.basicOpen ↑r)))⁻¹ᵁ ↑U,
                        property := ?ofBasicOpenCover.refine_1 })) ≫
          f ∣_ Y.basicOpen ↑r).op)
⊢ IsAffineOpen ↑U

Next tactic:
exact U.2
theorem sourceAffineLocally_isLocal (h₁ : RingHom.RespectsIso @P)
    (h₂ : RingHom.LocalizationPreserves @P) (h₃ : RingHom.OfLocalizationSpan @P) :
    (sourceAffineLocally @P).IsLocal := by
  constructor
  · exact sourceAffineLocally_respectsIso h₁
  · introv H U
    apply scheme_restrict_basicOpen_of_localizationPreserves h₁ h₂; assumption
  · introv hs hs' U
    skip
    apply h₃ _ _ hs
    intro r
    have := hs' r ⟨(Opens.map (X.ofRestrict _).1.base).obj U.1, ?_⟩
    rwa [h₁.ofRestrict_morphismRestrict_iff] at this
    · exact U.2
    · 

Proof state:
case ofBasicOpenCover.refine_2.e
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
h₁ : RingHom.RespectsIso P
h₂ : RingHom.LocalizationPreserves P
h₃ : RingHom.OfLocalizationSpan P
X Y : Scheme
inst✝ : IsAffine Y
f : X ⟶ Y
s : Finset ↑(Y.presheaf.obj (op ⊤))
hs : Ideal.span ↑s = ⊤
hs' : ∀ (r : { x // x ∈ s }), sourceAffineLocally P (f ∣_ Y.basicOpen ↑r)
U : ↑(Scheme.affineOpens X)
r : ↑↑s
this :
  P
    (Scheme.Γ.map
      (Scheme.ofRestrict (X ∣_ᵤ f⁻¹ᵁ Y.basicOpen ↑r)
            (_ :
              OpenEmbedding
                ⇑(Opens.inclusion
                    ↑{ val := Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion (f⁻¹ᵁ Y.basicOpen ↑r)))⁻¹ᵁ ↑U,
                        property := ?ofBasicOpenCover.refine_1 })) ≫
          f ∣_ Y.basicOpen ↑r).op)
⊢ ↑{ val := Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion (f⁻¹ᵁ Y.basicOpen ↑r)))⁻¹ᵁ ↑U,
        property := ?ofBasicOpenCover.refine_1 } =
    Scheme.ιOpens (f⁻¹ᵁ Y.basicOpen ↑r)⁻¹ᵁ ↑U

Next tactic:
rfl
theorem sourceAffineLocally_isLocal (h₁ : RingHom.RespectsIso @P)
    (h₂ : RingHom.LocalizationPreserves @P) (h₃ : RingHom.OfLocalizationSpan @P) :
    (sourceAffineLocally @P).IsLocal := by
  constructor
  · exact sourceAffineLocally_respectsIso h₁
  · introv H U
    apply scheme_restrict_basicOpen_of_localizationPreserves h₁ h₂; assumption
  · introv hs hs' U
    skip
    apply h₃ _ _ hs
    intro r
    have := hs' r ⟨(Opens.map (X.ofRestrict _).1.base).obj U.1, ?_⟩
    rwa [h₁.ofRestrict_morphismRestrict_iff] at this
    · exact U.2
    · rfl
    · 

Proof state:
case ofBasicOpenCover.refine_1
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
h₁ : RingHom.RespectsIso P
h₂ : RingHom.LocalizationPreserves P
h₃ : RingHom.OfLocalizationSpan P
X Y : Scheme
inst✝ : IsAffine Y
f : X ⟶ Y
s : Finset ↑(Y.presheaf.obj (op ⊤))
hs : Ideal.span ↑s = ⊤
hs' : ∀ (r : { x // x ∈ s }), sourceAffineLocally P (f ∣_ Y.basicOpen ↑r)
U : ↑(Scheme.affineOpens X)
r : ↑↑s
⊢ Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion (f⁻¹ᵁ Y.basicOpen ↑r)))⁻¹ᵁ ↑U ∈
    Scheme.affineOpens (X ∣_ᵤ f⁻¹ᵁ Y.basicOpen ↑r)

Next tactic:
suffices ∀ (V) (_ : V = (Opens.map f.val.base).obj (Y.basicOpen r.val)),
          IsAffineOpen ((Opens.map (X.ofRestrict V.openEmbedding).1.base).obj U.1) by
        exact this _ rfl
theorem sourceAffineLocally_isLocal (h₁ : RingHom.RespectsIso @P)
    (h₂ : RingHom.LocalizationPreserves @P) (h₃ : RingHom.OfLocalizationSpan @P) :
    (sourceAffineLocally @P).IsLocal := by
  constructor
  · exact sourceAffineLocally_respectsIso h₁
  · introv H U
    apply scheme_restrict_basicOpen_of_localizationPreserves h₁ h₂; assumption
  · introv hs hs' U
    skip
    apply h₃ _ _ hs
    intro r
    have := hs' r ⟨(Opens.map (X.ofRestrict _).1.base).obj U.1, ?_⟩
    rwa [h₁.ofRestrict_morphismRestrict_iff] at this
    · exact U.2
    · rfl
    · suffices ∀ (V) (_ : V = (Opens.map f.val.base).obj (Y.basicOpen r.val)),
          IsAffineOpen ((Opens.map (X.ofRestrict V.openEmbedding).1.base).obj U.1) by
        

Proof state:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
h₁ : RingHom.RespectsIso P
h₂ : RingHom.LocalizationPreserves P
h₃ : RingHom.OfLocalizationSpan P
X Y : Scheme
inst✝ : IsAffine Y
f : X ⟶ Y
s : Finset ↑(Y.presheaf.obj (op ⊤))
hs : Ideal.span ↑s = ⊤
hs' : ∀ (r : { x // x ∈ s }), sourceAffineLocally P (f ∣_ Y.basicOpen ↑r)
U : ↑(Scheme.affineOpens X)
r : ↑↑s
this :
  ∀ (V : Opens ↑↑X.toPresheafedSpace),
    V = f⁻¹ᵁ Y.basicOpen ↑r → IsAffineOpen (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion V))⁻¹ᵁ ↑U)
⊢ Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion (f⁻¹ᵁ Y.basicOpen ↑r)))⁻¹ᵁ ↑U ∈
    Scheme.affineOpens (X ∣_ᵤ f⁻¹ᵁ Y.basicOpen ↑r)

Next tactic:
exact this _ rfl
theorem sourceAffineLocally_isLocal (h₁ : RingHom.RespectsIso @P)
    (h₂ : RingHom.LocalizationPreserves @P) (h₃ : RingHom.OfLocalizationSpan @P) :
    (sourceAffineLocally @P).IsLocal := by
  constructor
  · exact sourceAffineLocally_respectsIso h₁
  · introv H U
    apply scheme_restrict_basicOpen_of_localizationPreserves h₁ h₂; assumption
  · introv hs hs' U
    skip
    apply h₃ _ _ hs
    intro r
    have := hs' r ⟨(Opens.map (X.ofRestrict _).1.base).obj U.1, ?_⟩
    rwa [h₁.ofRestrict_morphismRestrict_iff] at this
    · exact U.2
    · rfl
    · suffices ∀ (V) (_ : V = (Opens.map f.val.base).obj (Y.basicOpen r.val)),
          IsAffineOpen ((Opens.map (X.ofRestrict V.openEmbedding).1.base).obj U.1) by
        exact this _ rfl
      

Proof state:
case ofBasicOpenCover.refine_1
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
h₁ : RingHom.RespectsIso P
h₂ : RingHom.LocalizationPreserves P
h₃ : RingHom.OfLocalizationSpan P
X Y : Scheme
inst✝ : IsAffine Y
f : X ⟶ Y
s : Finset ↑(Y.presheaf.obj (op ⊤))
hs : Ideal.span ↑s = ⊤
hs' : ∀ (r : { x // x ∈ s }), sourceAffineLocally P (f ∣_ Y.basicOpen ↑r)
U : ↑(Scheme.affineOpens X)
r : ↑↑s
⊢ ∀ (V : Opens ↑↑X.toPresheafedSpace),
    V = f⁻¹ᵁ Y.basicOpen ↑r → IsAffineOpen (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion V))⁻¹ᵁ ↑U)

Next tactic:
intro V hV
theorem sourceAffineLocally_isLocal (h₁ : RingHom.RespectsIso @P)
    (h₂ : RingHom.LocalizationPreserves @P) (h₃ : RingHom.OfLocalizationSpan @P) :
    (sourceAffineLocally @P).IsLocal := by
  constructor
  · exact sourceAffineLocally_respectsIso h₁
  · introv H U
    apply scheme_restrict_basicOpen_of_localizationPreserves h₁ h₂; assumption
  · introv hs hs' U
    skip
    apply h₃ _ _ hs
    intro r
    have := hs' r ⟨(Opens.map (X.ofRestrict _).1.base).obj U.1, ?_⟩
    rwa [h₁.ofRestrict_morphismRestrict_iff] at this
    · exact U.2
    · rfl
    · suffices ∀ (V) (_ : V = (Opens.map f.val.base).obj (Y.basicOpen r.val)),
          IsAffineOpen ((Opens.map (X.ofRestrict V.openEmbedding).1.base).obj U.1) by
        exact this _ rfl
      intro V hV
      

Proof state:
case ofBasicOpenCover.refine_1
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
h₁ : RingHom.RespectsIso P
h₂ : RingHom.LocalizationPreserves P
h₃ : RingHom.OfLocalizationSpan P
X Y : Scheme
inst✝ : IsAffine Y
f : X ⟶ Y
s : Finset ↑(Y.presheaf.obj (op ⊤))
hs : Ideal.span ↑s = ⊤
hs' : ∀ (r : { x // x ∈ s }), sourceAffineLocally P (f ∣_ Y.basicOpen ↑r)
U : ↑(Scheme.affineOpens X)
r : ↑↑s
V : Opens ↑↑X.toPresheafedSpace
hV : V = f⁻¹ᵁ Y.basicOpen ↑r
⊢ IsAffineOpen (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion V))⁻¹ᵁ ↑U)

Next tactic:
rw [Scheme.preimage_basicOpen] at hV
theorem sourceAffineLocally_isLocal (h₁ : RingHom.RespectsIso @P)
    (h₂ : RingHom.LocalizationPreserves @P) (h₃ : RingHom.OfLocalizationSpan @P) :
    (sourceAffineLocally @P).IsLocal := by
  constructor
  · exact sourceAffineLocally_respectsIso h₁
  · introv H U
    apply scheme_restrict_basicOpen_of_localizationPreserves h₁ h₂; assumption
  · introv hs hs' U
    skip
    apply h₃ _ _ hs
    intro r
    have := hs' r ⟨(Opens.map (X.ofRestrict _).1.base).obj U.1, ?_⟩
    rwa [h₁.ofRestrict_morphismRestrict_iff] at this
    · exact U.2
    · rfl
    · suffices ∀ (V) (_ : V = (Opens.map f.val.base).obj (Y.basicOpen r.val)),
          IsAffineOpen ((Opens.map (X.ofRestrict V.openEmbedding).1.base).obj U.1) by
        exact this _ rfl
      intro V hV
      rw [Scheme.preimage_basicOpen] at hV
      

Proof state:
case ofBasicOpenCover.refine_1
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
h₁ : RingHom.RespectsIso P
h₂ : RingHom.LocalizationPreserves P
h₃ : RingHom.OfLocalizationSpan P
X Y : Scheme
inst✝ : IsAffine Y
f : X ⟶ Y
s : Finset ↑(Y.presheaf.obj (op ⊤))
hs : Ideal.span ↑s = ⊤
hs' : ∀ (r : { x // x ∈ s }), sourceAffineLocally P (f ∣_ Y.basicOpen ↑r)
U : ↑(Scheme.affineOpens X)
r : ↑↑s
V : Opens ↑↑X.toPresheafedSpace
hV : V = X.basicOpen ((f.val.c.app (op ⊤)) ↑r)
⊢ IsAffineOpen (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion V))⁻¹ᵁ ↑U)

Next tactic:
subst hV
theorem sourceAffineLocally_isLocal (h₁ : RingHom.RespectsIso @P)
    (h₂ : RingHom.LocalizationPreserves @P) (h₃ : RingHom.OfLocalizationSpan @P) :
    (sourceAffineLocally @P).IsLocal := by
  constructor
  · exact sourceAffineLocally_respectsIso h₁
  · introv H U
    apply scheme_restrict_basicOpen_of_localizationPreserves h₁ h₂; assumption
  · introv hs hs' U
    skip
    apply h₃ _ _ hs
    intro r
    have := hs' r ⟨(Opens.map (X.ofRestrict _).1.base).obj U.1, ?_⟩
    rwa [h₁.ofRestrict_morphismRestrict_iff] at this
    · exact U.2
    · rfl
    · suffices ∀ (V) (_ : V = (Opens.map f.val.base).obj (Y.basicOpen r.val)),
          IsAffineOpen ((Opens.map (X.ofRestrict V.openEmbedding).1.base).obj U.1) by
        exact this _ rfl
      intro V hV
      rw [Scheme.preimage_basicOpen] at hV
      subst hV
      

Proof state:
case ofBasicOpenCover.refine_1
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
h₁ : RingHom.RespectsIso P
h₂ : RingHom.LocalizationPreserves P
h₃ : RingHom.OfLocalizationSpan P
X Y : Scheme
inst✝ : IsAffine Y
f : X ⟶ Y
s : Finset ↑(Y.presheaf.obj (op ⊤))
hs : Ideal.span ↑s = ⊤
hs' : ∀ (r : { x // x ∈ s }), sourceAffineLocally P (f ∣_ Y.basicOpen ↑r)
U : ↑(Scheme.affineOpens X)
r : ↑↑s
⊢ IsAffineOpen
    (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion (X.basicOpen ((f.val.c.app (op ⊤)) ↑r))))⁻¹ᵁ ↑U)

Next tactic:
exact U.2.mapRestrictBasicOpen (Scheme.Γ.map f.op r.1)