l3lab/ntp-mathlib huggingface dataset:
theorem RespectsIso.basicOpen_iff (hP : RespectsIso @P) {X Y : Scheme} [IsAffine X] [IsAffine Y]
    (f : X ⟶ Y) (r : Y.presheaf.obj (Opposite.op ⊤)) :
    P (Scheme.Γ.map (f ∣_ Y.basicOpen r).op) ↔
    P (@IsLocalization.Away.map (Y.presheaf.obj (Opposite.op ⊤)) _
      (Y.presheaf.obj (Opposite.op <| Y.basicOpen r)) _ _ (X.presheaf.obj (Opposite.op ⊤)) _
      (X.presheaf.obj (Opposite.op <| X.basicOpen (Scheme.Γ.map f.op r))) _ _
      (Scheme.Γ.map f.op) r _ <| @isLocalization_away_of_isAffine X _ (Scheme.Γ.map f.op r)) := by
  rw [Γ_map_morphismRestrict, hP.cancel_left_isIso, hP.cancel_right_isIso,
    ← hP.cancel_right_isIso (f.val.c.app (Opposite.op (Y.basicOpen r)))
      (X.presheaf.map (eqToHom (Scheme.preimage_basicOpen f r).symm).op), ← eq_iff_iff]
  congr
  delta IsLocalization.Away.map
  refine' IsLocalization.ringHom_ext (Submonoid.powers r) _
  generalize_proofs h1 h2 h3
  haveI i1 := @isLocalization_away_of_isAffine X _ (Scheme.Γ.map f.op r)
  -- Porting note : needs to be very explicit here
  convert
    (@IsLocalization.map_comp (hy := h3) (Y.presheaf.obj <| Opposite.op (Scheme.basicOpen Y r))
    _ _ (isLocalization_away_of_isAffine _) _ _ _ i1).symm using 1
  

Proof state:
case h.e'_2.h
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RespectsIso P
X Y : Scheme
inst✝¹ : IsAffine X
inst✝ : IsAffine Y
f : X ⟶ Y
r : ↑(Y.presheaf.obj (Opposite.op ⊤))
h1 : X.basicOpen ((f.val.c.app (Opposite.op ⊤)) r) = f⁻¹ᵁ Y.basicOpen r
h2 : IsLocalization.Away ((Scheme.Γ.map f.op) r) ↑(X.presheaf.obj (Opposite.op (X.basicOpen ((Scheme.Γ.map f.op) r))))
h3 : Submonoid.powers r ≤ Submonoid.comap (Scheme.Γ.map f.op) (Submonoid.powers ((Scheme.Γ.map f.op) r))
i1 : IsLocalization.Away ((Scheme.Γ.map f.op) r) ↑(X.presheaf.obj (Opposite.op (X.basicOpen ((Scheme.Γ.map f.op) r))))
e_1✝ :
  (↑(Y.presheaf.obj (Opposite.op ⊤)) →+*
      ↑(X.presheaf.obj (Opposite.op (X.basicOpen ((f.val.c.app (Opposite.op ⊤)) r))))) =
    (↑(Y.presheaf.obj (Opposite.op ⊤)) →+* ↑(X.presheaf.obj (Opposite.op (X.basicOpen ((Scheme.Γ.map f.op) r)))))
⊢ comp (f.val.c.app (Opposite.op (Y.basicOpen r)) ≫ X.presheaf.map (eqToHom h1).op)
      (algebraMap ↑(Y.presheaf.obj (Opposite.op ⊤)) ↑(Y.presheaf.obj (Opposite.op (Y.basicOpen r)))) =
    comp
      (algebraMap ↑(X.presheaf.obj (Opposite.op ⊤))
        ↑(X.presheaf.obj (Opposite.op (X.basicOpen ((Scheme.Γ.map f.op) r)))))
      (Scheme.Γ.map f.op)

Next tactic:
change Y.presheaf.map _ ≫ _ = _ ≫ X.presheaf.map _
theorem RespectsIso.basicOpen_iff (hP : RespectsIso @P) {X Y : Scheme} [IsAffine X] [IsAffine Y]
    (f : X ⟶ Y) (r : Y.presheaf.obj (Opposite.op ⊤)) :
    P (Scheme.Γ.map (f ∣_ Y.basicOpen r).op) ↔
    P (@IsLocalization.Away.map (Y.presheaf.obj (Opposite.op ⊤)) _
      (Y.presheaf.obj (Opposite.op <| Y.basicOpen r)) _ _ (X.presheaf.obj (Opposite.op ⊤)) _
      (X.presheaf.obj (Opposite.op <| X.basicOpen (Scheme.Γ.map f.op r))) _ _
      (Scheme.Γ.map f.op) r _ <| @isLocalization_away_of_isAffine X _ (Scheme.Γ.map f.op r)) := by
  rw [Γ_map_morphismRestrict, hP.cancel_left_isIso, hP.cancel_right_isIso,
    ← hP.cancel_right_isIso (f.val.c.app (Opposite.op (Y.basicOpen r)))
      (X.presheaf.map (eqToHom (Scheme.preimage_basicOpen f r).symm).op), ← eq_iff_iff]
  congr
  delta IsLocalization.Away.map
  refine' IsLocalization.ringHom_ext (Submonoid.powers r) _
  generalize_proofs h1 h2 h3
  haveI i1 := @isLocalization_away_of_isAffine X _ (Scheme.Γ.map f.op r)
  -- Porting note : needs to be very explicit here
  convert
    (@IsLocalization.map_comp (hy := h3) (Y.presheaf.obj <| Opposite.op (Scheme.basicOpen Y r))
    _ _ (isLocalization_away_of_isAffine _) _ _ _ i1).symm using 1
  change Y.presheaf.map _ ≫ _ = _ ≫ X.presheaf.map _
  

Proof state:
case h.e'_2.h
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RespectsIso P
X Y : Scheme
inst✝¹ : IsAffine X
inst✝ : IsAffine Y
f : X ⟶ Y
r : ↑(Y.presheaf.obj (Opposite.op ⊤))
h1 : X.basicOpen ((f.val.c.app (Opposite.op ⊤)) r) = f⁻¹ᵁ Y.basicOpen r
h2 : IsLocalization.Away ((Scheme.Γ.map f.op) r) ↑(X.presheaf.obj (Opposite.op (X.basicOpen ((Scheme.Γ.map f.op) r))))
h3 : Submonoid.powers r ≤ Submonoid.comap (Scheme.Γ.map f.op) (Submonoid.powers ((Scheme.Γ.map f.op) r))
i1 : IsLocalization.Away ((Scheme.Γ.map f.op) r) ↑(X.presheaf.obj (Opposite.op (X.basicOpen ((Scheme.Γ.map f.op) r))))
e_1✝ :
  (↑(Y.presheaf.obj (Opposite.op ⊤)) →+*
      ↑(X.presheaf.obj (Opposite.op (X.basicOpen ((f.val.c.app (Opposite.op ⊤)) r))))) =
    (↑(Y.presheaf.obj (Opposite.op ⊤)) →+* ↑(X.presheaf.obj (Opposite.op (X.basicOpen ((Scheme.Γ.map f.op) r)))))
⊢ Y.presheaf.map (homOfLE (_ : Y.basicOpen r ≤ ⊤)).op ≫
      f.val.c.app (Opposite.op (Y.basicOpen r)) ≫ X.presheaf.map (eqToHom h1).op =
    Scheme.Γ.map f.op ≫ X.presheaf.map (homOfLE (_ : X.basicOpen ((Scheme.Γ.map f.op) r) ≤ ⊤)).op

Next tactic:
rw [f.val.c.naturality_assoc]
theorem RespectsIso.basicOpen_iff (hP : RespectsIso @P) {X Y : Scheme} [IsAffine X] [IsAffine Y]
    (f : X ⟶ Y) (r : Y.presheaf.obj (Opposite.op ⊤)) :
    P (Scheme.Γ.map (f ∣_ Y.basicOpen r).op) ↔
    P (@IsLocalization.Away.map (Y.presheaf.obj (Opposite.op ⊤)) _
      (Y.presheaf.obj (Opposite.op <| Y.basicOpen r)) _ _ (X.presheaf.obj (Opposite.op ⊤)) _
      (X.presheaf.obj (Opposite.op <| X.basicOpen (Scheme.Γ.map f.op r))) _ _
      (Scheme.Γ.map f.op) r _ <| @isLocalization_away_of_isAffine X _ (Scheme.Γ.map f.op r)) := by
  rw [Γ_map_morphismRestrict, hP.cancel_left_isIso, hP.cancel_right_isIso,
    ← hP.cancel_right_isIso (f.val.c.app (Opposite.op (Y.basicOpen r)))
      (X.presheaf.map (eqToHom (Scheme.preimage_basicOpen f r).symm).op), ← eq_iff_iff]
  congr
  delta IsLocalization.Away.map
  refine' IsLocalization.ringHom_ext (Submonoid.powers r) _
  generalize_proofs h1 h2 h3
  haveI i1 := @isLocalization_away_of_isAffine X _ (Scheme.Γ.map f.op r)
  -- Porting note : needs to be very explicit here
  convert
    (@IsLocalization.map_comp (hy := h3) (Y.presheaf.obj <| Opposite.op (Scheme.basicOpen Y r))
    _ _ (isLocalization_away_of_isAffine _) _ _ _ i1).symm using 1
  change Y.presheaf.map _ ≫ _ = _ ≫ X.presheaf.map _
  rw [f.val.c.naturality_assoc]
  

Proof state:
case h.e'_2.h
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RespectsIso P
X Y : Scheme
inst✝¹ : IsAffine X
inst✝ : IsAffine Y
f : X ⟶ Y
r : ↑(Y.presheaf.obj (Opposite.op ⊤))
h1 : X.basicOpen ((f.val.c.app (Opposite.op ⊤)) r) = f⁻¹ᵁ Y.basicOpen r
h2 : IsLocalization.Away ((Scheme.Γ.map f.op) r) ↑(X.presheaf.obj (Opposite.op (X.basicOpen ((Scheme.Γ.map f.op) r))))
h3 : Submonoid.powers r ≤ Submonoid.comap (Scheme.Γ.map f.op) (Submonoid.powers ((Scheme.Γ.map f.op) r))
i1 : IsLocalization.Away ((Scheme.Γ.map f.op) r) ↑(X.presheaf.obj (Opposite.op (X.basicOpen ((Scheme.Γ.map f.op) r))))
e_1✝ :
  (↑(Y.presheaf.obj (Opposite.op ⊤)) →+*
      ↑(X.presheaf.obj (Opposite.op (X.basicOpen ((f.val.c.app (Opposite.op ⊤)) r))))) =
    (↑(Y.presheaf.obj (Opposite.op ⊤)) →+* ↑(X.presheaf.obj (Opposite.op (X.basicOpen ((Scheme.Γ.map f.op) r)))))
⊢ f.val.c.app (Opposite.op ⊤) ≫
      (f.val.base _* X.presheaf).map (homOfLE (_ : Y.basicOpen r ≤ ⊤)).op ≫ X.presheaf.map (eqToHom h1).op =
    Scheme.Γ.map f.op ≫ X.presheaf.map (homOfLE (_ : X.basicOpen ((Scheme.Γ.map f.op) r) ≤ ⊤)).op

Next tactic:
erw [← X.presheaf.map_comp]
theorem RespectsIso.basicOpen_iff (hP : RespectsIso @P) {X Y : Scheme} [IsAffine X] [IsAffine Y]
    (f : X ⟶ Y) (r : Y.presheaf.obj (Opposite.op ⊤)) :
    P (Scheme.Γ.map (f ∣_ Y.basicOpen r).op) ↔
    P (@IsLocalization.Away.map (Y.presheaf.obj (Opposite.op ⊤)) _
      (Y.presheaf.obj (Opposite.op <| Y.basicOpen r)) _ _ (X.presheaf.obj (Opposite.op ⊤)) _
      (X.presheaf.obj (Opposite.op <| X.basicOpen (Scheme.Γ.map f.op r))) _ _
      (Scheme.Γ.map f.op) r _ <| @isLocalization_away_of_isAffine X _ (Scheme.Γ.map f.op r)) := by
  rw [Γ_map_morphismRestrict, hP.cancel_left_isIso, hP.cancel_right_isIso,
    ← hP.cancel_right_isIso (f.val.c.app (Opposite.op (Y.basicOpen r)))
      (X.presheaf.map (eqToHom (Scheme.preimage_basicOpen f r).symm).op), ← eq_iff_iff]
  congr
  delta IsLocalization.Away.map
  refine' IsLocalization.ringHom_ext (Submonoid.powers r) _
  generalize_proofs h1 h2 h3
  haveI i1 := @isLocalization_away_of_isAffine X _ (Scheme.Γ.map f.op r)
  -- Porting note : needs to be very explicit here
  convert
    (@IsLocalization.map_comp (hy := h3) (Y.presheaf.obj <| Opposite.op (Scheme.basicOpen Y r))
    _ _ (isLocalization_away_of_isAffine _) _ _ _ i1).symm using 1
  change Y.presheaf.map _ ≫ _ = _ ≫ X.presheaf.map _
  rw [f.val.c.naturality_assoc]
  erw [← X.presheaf.map_comp]
  

Proof state:
case h.e'_2.h
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RespectsIso P
X Y : Scheme
inst✝¹ : IsAffine X
inst✝ : IsAffine Y
f : X ⟶ Y
r : ↑(Y.presheaf.obj (Opposite.op ⊤))
h1 : X.basicOpen ((f.val.c.app (Opposite.op ⊤)) r) = f⁻¹ᵁ Y.basicOpen r
h2 : IsLocalization.Away ((Scheme.Γ.map f.op) r) ↑(X.presheaf.obj (Opposite.op (X.basicOpen ((Scheme.Γ.map f.op) r))))
h3 : Submonoid.powers r ≤ Submonoid.comap (Scheme.Γ.map f.op) (Submonoid.powers ((Scheme.Γ.map f.op) r))
i1 : IsLocalization.Away ((Scheme.Γ.map f.op) r) ↑(X.presheaf.obj (Opposite.op (X.basicOpen ((Scheme.Γ.map f.op) r))))
e_1✝ :
  (↑(Y.presheaf.obj (Opposite.op ⊤)) →+*
      ↑(X.presheaf.obj (Opposite.op (X.basicOpen ((f.val.c.app (Opposite.op ⊤)) r))))) =
    (↑(Y.presheaf.obj (Opposite.op ⊤)) →+* ↑(X.presheaf.obj (Opposite.op (X.basicOpen ((Scheme.Γ.map f.op) r)))))
⊢ f.val.c.app (Opposite.op ⊤) ≫
      X.presheaf.map ((Opens.map f.val.base).op.map (homOfLE (_ : Y.basicOpen r ≤ ⊤)).op ≫ (eqToHom h1).op) =
    Scheme.Γ.map f.op ≫ X.presheaf.map (homOfLE (_ : X.basicOpen ((Scheme.Γ.map f.op) r) ≤ ⊤)).op

Next tactic:
congr 1
theorem RespectsIso.basicOpen_iff_localization (hP : RespectsIso @P) {X Y : Scheme} [IsAffine X]
    [IsAffine Y] (f : X ⟶ Y) (r : Y.presheaf.obj (Opposite.op ⊤)) :
    P (Scheme.Γ.map (f ∣_ Y.basicOpen r).op) ↔ P (Localization.awayMap (Scheme.Γ.map f.op) r) := by
  

Proof state:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RespectsIso P
X Y : Scheme
inst✝¹ : IsAffine X
inst✝ : IsAffine Y
f : X ⟶ Y
r : ↑(Y.presheaf.obj (Opposite.op ⊤))
⊢ P (Scheme.Γ.map (f ∣_ Y.basicOpen r).op) ↔ P (Localization.awayMap (Scheme.Γ.map f.op) r)

Next tactic:
refine (hP.basicOpen_iff _ _).trans ?_
theorem RespectsIso.basicOpen_iff_localization (hP : RespectsIso @P) {X Y : Scheme} [IsAffine X]
    [IsAffine Y] (f : X ⟶ Y) (r : Y.presheaf.obj (Opposite.op ⊤)) :
    P (Scheme.Γ.map (f ∣_ Y.basicOpen r).op) ↔ P (Localization.awayMap (Scheme.Γ.map f.op) r) := by
  refine (hP.basicOpen_iff _ _).trans ?_
  -- Porting note : was a one line term mode proof, but this `dsimp` is vital so the term mode
  -- one liner is not possible
  

Proof state:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RespectsIso P
X Y : Scheme
inst✝¹ : IsAffine X
inst✝ : IsAffine Y
f : X ⟶ Y
r : ↑(Y.presheaf.obj (Opposite.op ⊤))
⊢ P
      (IsLocalization.Away.map (↑(Y.presheaf.obj (Opposite.op (Y.basicOpen r))))
        (↑(X.presheaf.obj (Opposite.op (X.basicOpen ((Scheme.Γ.map f.op) r))))) (Scheme.Γ.map f.op) r) ↔
    P (Localization.awayMap (Scheme.Γ.map f.op) r)

Next tactic:
dsimp
theorem RespectsIso.basicOpen_iff_localization (hP : RespectsIso @P) {X Y : Scheme} [IsAffine X]
    [IsAffine Y] (f : X ⟶ Y) (r : Y.presheaf.obj (Opposite.op ⊤)) :
    P (Scheme.Γ.map (f ∣_ Y.basicOpen r).op) ↔ P (Localization.awayMap (Scheme.Γ.map f.op) r) := by
  refine (hP.basicOpen_iff _ _).trans ?_
  -- Porting note : was a one line term mode proof, but this `dsimp` is vital so the term mode
  -- one liner is not possible
  dsimp
  

Proof state:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RespectsIso P
X Y : Scheme
inst✝¹ : IsAffine X
inst✝ : IsAffine Y
f : X ⟶ Y
r : ↑(Y.presheaf.obj (Opposite.op ⊤))
⊢ P
      (IsLocalization.Away.map (↑(Y.presheaf.obj (Opposite.op (Y.basicOpen r))))
        (↑(X.presheaf.obj (Opposite.op (X.basicOpen ((f.val.c.app (Opposite.op ⊤)) r))))) (f.val.c.app (Opposite.op ⊤))
        r) ↔
    P (Localization.awayMap (f.val.c.app (Opposite.op ⊤)) r)

Next tactic:
rw [← hP.is_localization_away_iff]
theorem RespectsIso.ofRestrict_morphismRestrict_iff_of_isAffine (hP : RingHom.RespectsIso @P)
    {X Y : Scheme} [IsAffine X] [IsAffine Y] (f : X ⟶ Y) (r : Y.presheaf.obj (Opposite.op ⊤)) :
    P (Scheme.Γ.map (f ∣_ Y.basicOpen r).op) ↔
    P (Localization.awayMap (Scheme.Γ.map f.op) r) := by
  

Proof state:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RespectsIso P
X Y : Scheme
inst✝¹ : IsAffine X
inst✝ : IsAffine Y
f : X ⟶ Y
r : ↑(Y.presheaf.obj (Opposite.op ⊤))
⊢ P (Scheme.Γ.map (f ∣_ Y.basicOpen r).op) ↔ P (Localization.awayMap (Scheme.Γ.map f.op) r)

Next tactic:
have : IsLocalization.Away (R := ↑Γ(X)) (Scheme.Γ.map f.op r) ↑Γ(X ∣_ᵤ f⁻¹ᵁ Y.basicOpen r)
theorem RespectsIso.ofRestrict_morphismRestrict_iff_of_isAffine (hP : RingHom.RespectsIso @P)
    {X Y : Scheme} [IsAffine X] [IsAffine Y] (f : X ⟶ Y) (r : Y.presheaf.obj (Opposite.op ⊤)) :
    P (Scheme.Γ.map (f ∣_ Y.basicOpen r).op) ↔
    P (Localization.awayMap (Scheme.Γ.map f.op) r) := by
  have : IsLocalization.Away (R := ↑Γ(X)) (Scheme.Γ.map f.op r) ↑Γ(X ∣_ᵤ f⁻¹ᵁ Y.basicOpen r)
  · 

Proof state:
case this
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RespectsIso P
X Y : Scheme
inst✝¹ : IsAffine X
inst✝ : IsAffine Y
f : X ⟶ Y
r : ↑(Y.presheaf.obj (Opposite.op ⊤))
⊢ IsLocalization.Away ((Scheme.Γ.map f.op) r) ↑Γ(X ∣_ᵤ f⁻¹ᵁ Y.basicOpen r)

Next tactic:
rw [Scheme.preimage_basicOpen]
theorem RespectsIso.ofRestrict_morphismRestrict_iff_of_isAffine (hP : RingHom.RespectsIso @P)
    {X Y : Scheme} [IsAffine X] [IsAffine Y] (f : X ⟶ Y) (r : Y.presheaf.obj (Opposite.op ⊤)) :
    P (Scheme.Γ.map (f ∣_ Y.basicOpen r).op) ↔
    P (Localization.awayMap (Scheme.Γ.map f.op) r) := by
  have : IsLocalization.Away (R := ↑Γ(X)) (Scheme.Γ.map f.op r) ↑Γ(X ∣_ᵤ f⁻¹ᵁ Y.basicOpen r)
  · rw [Scheme.preimage_basicOpen]
    

Proof state:
case this
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RespectsIso P
X Y : Scheme
inst✝¹ : IsAffine X
inst✝ : IsAffine Y
f : X ⟶ Y
r : ↑(Y.presheaf.obj (Opposite.op ⊤))
⊢ IsLocalization.Away ((Scheme.Γ.map f.op) r) ↑Γ(X ∣_ᵤ X.basicOpen ((f.val.c.app (Opposite.op ⊤)) r))

Next tactic:
show IsLocalization.Away (R := ↑Γ(X)) (Scheme.Γ.map f.op r)
      ↑Γ(X ∣_ᵤ X.basicOpen (Scheme.Γ.map f.op r))
theorem RespectsIso.ofRestrict_morphismRestrict_iff_of_isAffine (hP : RingHom.RespectsIso @P)
    {X Y : Scheme} [IsAffine X] [IsAffine Y] (f : X ⟶ Y) (r : Y.presheaf.obj (Opposite.op ⊤)) :
    P (Scheme.Γ.map (f ∣_ Y.basicOpen r).op) ↔
    P (Localization.awayMap (Scheme.Γ.map f.op) r) := by
  have : IsLocalization.Away (R := ↑Γ(X)) (Scheme.Γ.map f.op r) ↑Γ(X ∣_ᵤ f⁻¹ᵁ Y.basicOpen r)
  · rw [Scheme.preimage_basicOpen]
    show IsLocalization.Away (R := ↑Γ(X)) (Scheme.Γ.map f.op r)
      ↑Γ(X ∣_ᵤ X.basicOpen (Scheme.Γ.map f.op r))
    

Proof state:
case this
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RespectsIso P
X Y : Scheme
inst✝¹ : IsAffine X
inst✝ : IsAffine Y
f : X ⟶ Y
r : ↑(Y.presheaf.obj (Opposite.op ⊤))
⊢ IsLocalization.Away ((Scheme.Γ.map f.op) r) ↑Γ(X ∣_ᵤ X.basicOpen ((Scheme.Γ.map f.op) r))

Next tactic:
infer_instance
theorem RespectsIso.ofRestrict_morphismRestrict_iff_of_isAffine (hP : RingHom.RespectsIso @P)
    {X Y : Scheme} [IsAffine X] [IsAffine Y] (f : X ⟶ Y) (r : Y.presheaf.obj (Opposite.op ⊤)) :
    P (Scheme.Γ.map (f ∣_ Y.basicOpen r).op) ↔
    P (Localization.awayMap (Scheme.Γ.map f.op) r) := by
  have : IsLocalization.Away (R := ↑Γ(X)) (Scheme.Γ.map f.op r) ↑Γ(X ∣_ᵤ f⁻¹ᵁ Y.basicOpen r)
  · rw [Scheme.preimage_basicOpen]
    show IsLocalization.Away (R := ↑Γ(X)) (Scheme.Γ.map f.op r)
      ↑Γ(X ∣_ᵤ X.basicOpen (Scheme.Γ.map f.op r))
    infer_instance
  

Proof state:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RespectsIso P
X Y : Scheme
inst✝¹ : IsAffine X
inst✝ : IsAffine Y
f : X ⟶ Y
r : ↑(Y.presheaf.obj (Opposite.op ⊤))
this : IsLocalization.Away ((Scheme.Γ.map f.op) r) ↑Γ(X ∣_ᵤ f⁻¹ᵁ Y.basicOpen r)
⊢ P (Scheme.Γ.map (f ∣_ Y.basicOpen r).op) ↔ P (Localization.awayMap (Scheme.Γ.map f.op) r)

Next tactic:
rw [hP.is_localization_away_iff ↑Γ(Y ∣_ᵤ Scheme.basicOpen Y r) ↑Γ(X ∣_ᵤ f⁻¹ᵁ Scheme.basicOpen Y r)
    (Scheme.Γ.map f.op) r, iff_iff_eq]
theorem RespectsIso.ofRestrict_morphismRestrict_iff_of_isAffine (hP : RingHom.RespectsIso @P)
    {X Y : Scheme} [IsAffine X] [IsAffine Y] (f : X ⟶ Y) (r : Y.presheaf.obj (Opposite.op ⊤)) :
    P (Scheme.Γ.map (f ∣_ Y.basicOpen r).op) ↔
    P (Localization.awayMap (Scheme.Γ.map f.op) r) := by
  have : IsLocalization.Away (R := ↑Γ(X)) (Scheme.Γ.map f.op r) ↑Γ(X ∣_ᵤ f⁻¹ᵁ Y.basicOpen r)
  · rw [Scheme.preimage_basicOpen]
    show IsLocalization.Away (R := ↑Γ(X)) (Scheme.Γ.map f.op r)
      ↑Γ(X ∣_ᵤ X.basicOpen (Scheme.Γ.map f.op r))
    infer_instance
  rw [hP.is_localization_away_iff ↑Γ(Y ∣_ᵤ Scheme.basicOpen Y r) ↑Γ(X ∣_ᵤ f⁻¹ᵁ Scheme.basicOpen Y r)
    (Scheme.Γ.map f.op) r, iff_iff_eq]
  

Proof state:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RespectsIso P
X Y : Scheme
inst✝¹ : IsAffine X
inst✝ : IsAffine Y
f : X ⟶ Y
r : ↑(Y.presheaf.obj (Opposite.op ⊤))
this : IsLocalization.Away ((Scheme.Γ.map f.op) r) ↑Γ(X ∣_ᵤ f⁻¹ᵁ Y.basicOpen r)
⊢ P (Scheme.Γ.map (f ∣_ Y.basicOpen r).op) =
    P (IsLocalization.Away.map (↑Γ(Y ∣_ᵤ Y.basicOpen r)) (↑Γ(X ∣_ᵤ f⁻¹ᵁ Y.basicOpen r)) (Scheme.Γ.map f.op) r)

Next tactic:
congr 1
theorem RespectsIso.ofRestrict_morphismRestrict_iff_of_isAffine (hP : RingHom.RespectsIso @P)
    {X Y : Scheme} [IsAffine X] [IsAffine Y] (f : X ⟶ Y) (r : Y.presheaf.obj (Opposite.op ⊤)) :
    P (Scheme.Γ.map (f ∣_ Y.basicOpen r).op) ↔
    P (Localization.awayMap (Scheme.Γ.map f.op) r) := by
  have : IsLocalization.Away (R := ↑Γ(X)) (Scheme.Γ.map f.op r) ↑Γ(X ∣_ᵤ f⁻¹ᵁ Y.basicOpen r)
  · rw [Scheme.preimage_basicOpen]
    show IsLocalization.Away (R := ↑Γ(X)) (Scheme.Γ.map f.op r)
      ↑Γ(X ∣_ᵤ X.basicOpen (Scheme.Γ.map f.op r))
    infer_instance
  rw [hP.is_localization_away_iff ↑Γ(Y ∣_ᵤ Scheme.basicOpen Y r) ↑Γ(X ∣_ᵤ f⁻¹ᵁ Scheme.basicOpen Y r)
    (Scheme.Γ.map f.op) r, iff_iff_eq]
  congr 1
  

Proof state:
case e_a
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RespectsIso P
X Y : Scheme
inst✝¹ : IsAffine X
inst✝ : IsAffine Y
f : X ⟶ Y
r : ↑(Y.presheaf.obj (Opposite.op ⊤))
this : IsLocalization.Away ((Scheme.Γ.map f.op) r) ↑Γ(X ∣_ᵤ f⁻¹ᵁ Y.basicOpen r)
⊢ Scheme.Γ.map (f ∣_ Y.basicOpen r).op =
    IsLocalization.Away.map (↑Γ(Y ∣_ᵤ Y.basicOpen r)) (↑Γ(X ∣_ᵤ f⁻¹ᵁ Y.basicOpen r)) (Scheme.Γ.map f.op) r

Next tactic:
apply IsLocalization.ringHom_ext (R := ↑Γ(Y)) (Submonoid.powers r) _
theorem RespectsIso.ofRestrict_morphismRestrict_iff_of_isAffine (hP : RingHom.RespectsIso @P)
    {X Y : Scheme} [IsAffine X] [IsAffine Y] (f : X ⟶ Y) (r : Y.presheaf.obj (Opposite.op ⊤)) :
    P (Scheme.Γ.map (f ∣_ Y.basicOpen r).op) ↔
    P (Localization.awayMap (Scheme.Γ.map f.op) r) := by
  have : IsLocalization.Away (R := ↑Γ(X)) (Scheme.Γ.map f.op r) ↑Γ(X ∣_ᵤ f⁻¹ᵁ Y.basicOpen r)
  · rw [Scheme.preimage_basicOpen]
    show IsLocalization.Away (R := ↑Γ(X)) (Scheme.Γ.map f.op r)
      ↑Γ(X ∣_ᵤ X.basicOpen (Scheme.Γ.map f.op r))
    infer_instance
  rw [hP.is_localization_away_iff ↑Γ(Y ∣_ᵤ Scheme.basicOpen Y r) ↑Γ(X ∣_ᵤ f⁻¹ᵁ Scheme.basicOpen Y r)
    (Scheme.Γ.map f.op) r, iff_iff_eq]
  congr 1
  apply IsLocalization.ringHom_ext (R := ↑Γ(Y)) (Submonoid.powers r) _
  

Proof state:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RespectsIso P
X Y : Scheme
inst✝¹ : IsAffine X
inst✝ : IsAffine Y
f : X ⟶ Y
r : ↑(Y.presheaf.obj (Opposite.op ⊤))
this : IsLocalization.Away ((Scheme.Γ.map f.op) r) ↑Γ(X ∣_ᵤ f⁻¹ᵁ Y.basicOpen r)
⊢ comp (Scheme.Γ.map (f ∣_ Y.basicOpen r).op) (algebraMap ↑Γ(Y) ↑Γ(Y ∣_ᵤ Y.basicOpen r)) =
    comp (IsLocalization.Away.map (↑Γ(Y ∣_ᵤ Y.basicOpen r)) (↑Γ(X ∣_ᵤ f⁻¹ᵁ Y.basicOpen r)) (Scheme.Γ.map f.op) r)
      (algebraMap ↑Γ(Y) ↑Γ(Y ∣_ᵤ Y.basicOpen r))

Next tactic:
rw [IsLocalization.Away.map, IsLocalization.map_comp, RingHom.algebraMap_toAlgebra,
    RingHom.algebraMap_toAlgebra]
theorem RespectsIso.ofRestrict_morphismRestrict_iff_of_isAffine (hP : RingHom.RespectsIso @P)
    {X Y : Scheme} [IsAffine X] [IsAffine Y] (f : X ⟶ Y) (r : Y.presheaf.obj (Opposite.op ⊤)) :
    P (Scheme.Γ.map (f ∣_ Y.basicOpen r).op) ↔
    P (Localization.awayMap (Scheme.Γ.map f.op) r) := by
  have : IsLocalization.Away (R := ↑Γ(X)) (Scheme.Γ.map f.op r) ↑Γ(X ∣_ᵤ f⁻¹ᵁ Y.basicOpen r)
  · rw [Scheme.preimage_basicOpen]
    show IsLocalization.Away (R := ↑Γ(X)) (Scheme.Γ.map f.op r)
      ↑Γ(X ∣_ᵤ X.basicOpen (Scheme.Γ.map f.op r))
    infer_instance
  rw [hP.is_localization_away_iff ↑Γ(Y ∣_ᵤ Scheme.basicOpen Y r) ↑Γ(X ∣_ᵤ f⁻¹ᵁ Scheme.basicOpen Y r)
    (Scheme.Γ.map f.op) r, iff_iff_eq]
  congr 1
  apply IsLocalization.ringHom_ext (R := ↑Γ(Y)) (Submonoid.powers r) _
  rw [IsLocalization.Away.map, IsLocalization.map_comp, RingHom.algebraMap_toAlgebra,
    RingHom.algebraMap_toAlgebra]
  

Proof state:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RespectsIso P
X Y : Scheme
inst✝¹ : IsAffine X
inst✝ : IsAffine Y
f : X ⟶ Y
r : ↑(Y.presheaf.obj (Opposite.op ⊤))
this : IsLocalization.Away ((Scheme.Γ.map f.op) r) ↑Γ(X ∣_ᵤ f⁻¹ᵁ Y.basicOpen r)
⊢ comp (Scheme.Γ.map (f ∣_ Y.basicOpen r).op)
      (Scheme.Γ.map (Scheme.ofRestrict Y (_ : OpenEmbedding ⇑(Opens.inclusion (Y.basicOpen r)))).op) =
    comp (Scheme.Γ.map (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion (f⁻¹ᵁ Y.basicOpen r)))).op)
      (Scheme.Γ.map f.op)

Next tactic:
show Scheme.Γ.map _ ≫ Scheme.Γ.map _ = Scheme.Γ.map _ ≫ Scheme.Γ.map _
theorem RespectsIso.ofRestrict_morphismRestrict_iff_of_isAffine (hP : RingHom.RespectsIso @P)
    {X Y : Scheme} [IsAffine X] [IsAffine Y] (f : X ⟶ Y) (r : Y.presheaf.obj (Opposite.op ⊤)) :
    P (Scheme.Γ.map (f ∣_ Y.basicOpen r).op) ↔
    P (Localization.awayMap (Scheme.Γ.map f.op) r) := by
  have : IsLocalization.Away (R := ↑Γ(X)) (Scheme.Γ.map f.op r) ↑Γ(X ∣_ᵤ f⁻¹ᵁ Y.basicOpen r)
  · rw [Scheme.preimage_basicOpen]
    show IsLocalization.Away (R := ↑Γ(X)) (Scheme.Γ.map f.op r)
      ↑Γ(X ∣_ᵤ X.basicOpen (Scheme.Γ.map f.op r))
    infer_instance
  rw [hP.is_localization_away_iff ↑Γ(Y ∣_ᵤ Scheme.basicOpen Y r) ↑Γ(X ∣_ᵤ f⁻¹ᵁ Scheme.basicOpen Y r)
    (Scheme.Γ.map f.op) r, iff_iff_eq]
  congr 1
  apply IsLocalization.ringHom_ext (R := ↑Γ(Y)) (Submonoid.powers r) _
  rw [IsLocalization.Away.map, IsLocalization.map_comp, RingHom.algebraMap_toAlgebra,
    RingHom.algebraMap_toAlgebra]
  show Scheme.Γ.map _ ≫ Scheme.Γ.map _ = Scheme.Γ.map _ ≫ Scheme.Γ.map _
  

Proof state:
P : {R S : Type u} → [inst : CommRing R] → [inst_1 : CommRing S] → (R →+* S) → Prop
hP : RespectsIso P
X Y : Scheme
inst✝¹ : IsAffine X
inst✝ : IsAffine Y
f : X ⟶ Y
r : ↑(Y.presheaf.obj (Opposite.op ⊤))
this : IsLocalization.Away ((Scheme.Γ.map f.op) r) ↑Γ(X ∣_ᵤ f⁻¹ᵁ Y.basicOpen r)
⊢ Scheme.Γ.map (Scheme.ofRestrict Y (_ : OpenEmbedding ⇑(Opens.inclusion (Y.basicOpen r)))).op ≫
      Scheme.Γ.map (f ∣_ Y.basicOpen r).op =
    Scheme.Γ.map f.op ≫
      Scheme.Γ.map (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion (f⁻¹ᵁ Y.basicOpen r)))).op

Next tactic:
simp_rw [← Functor.map_comp, ← op_comp, morphismRestrict_ι]