l3lab/ntp-mathlib huggingface dataset:
theorem quasiSeparatedSpace_iff_affine (X : Scheme) :
    QuasiSeparatedSpace X.carrier ↔ ∀ U V : X.affineOpens, IsCompact (U ∩ V : Set X.carrier) := by
  rw [QuasiSeparatedSpace_iff]
  constructor
  · intro H U V; exact H U V U.1.2 U.2.isCompact V.1.2 V.2.isCompact
  · intro H
    suffices
      ∀ (U : Opens X.carrier) (_ : IsCompact U.1) (V : Opens X.carrier) (_ : IsCompact V.1),
        IsCompact (U ⊓ V).1
      by intro U V hU hU' hV hV'; exact this ⟨U, hU⟩ hU' ⟨V, hV⟩ hV'
    intro U hU V hV
    -- Porting note: it complains "unable to find motive", but telling Lean that motive is
    -- underscore is actually sufficient, weird
    apply compact_open_induction_on (P := _) V hV
    · simp
    · intro S _ V hV
      change IsCompact (U.1 ∩ (S.1 ∪ V.1))
      rw [Set.inter_union_distrib_left]
      apply hV.union
      clear hV
      apply compact_open_induction_on (P := _) U hU
      · simp
      · intro S _ W hW
        

Proof state:
case mpr.h₂.h₂
X✝ Y : Scheme
f : X✝ ⟶ Y
X : Scheme
H : ∀ (U V : ↑(Scheme.affineOpens X)), IsCompact (↑↑U ∩ ↑↑V)
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact U.carrier
V✝ : Opens ↑↑X.toPresheafedSpace
hV : IsCompact V✝.carrier
S✝ : Opens ↑↑X.toPresheafedSpace
x✝¹ : IsCompact S✝.carrier
V : ↑(Scheme.affineOpens X)
S : Opens ↑↑X.toPresheafedSpace
x✝ : IsCompact S.carrier
W : ↑(Scheme.affineOpens X)
hW : IsCompact (S.carrier ∩ ↑↑V)
⊢ IsCompact ((S ⊔ ↑W).carrier ∩ ↑↑V)

Next tactic:
change IsCompact ((S.1 ∪ W.1) ∩ V.1)
theorem quasiSeparatedSpace_iff_affine (X : Scheme) :
    QuasiSeparatedSpace X.carrier ↔ ∀ U V : X.affineOpens, IsCompact (U ∩ V : Set X.carrier) := by
  rw [QuasiSeparatedSpace_iff]
  constructor
  · intro H U V; exact H U V U.1.2 U.2.isCompact V.1.2 V.2.isCompact
  · intro H
    suffices
      ∀ (U : Opens X.carrier) (_ : IsCompact U.1) (V : Opens X.carrier) (_ : IsCompact V.1),
        IsCompact (U ⊓ V).1
      by intro U V hU hU' hV hV'; exact this ⟨U, hU⟩ hU' ⟨V, hV⟩ hV'
    intro U hU V hV
    -- Porting note: it complains "unable to find motive", but telling Lean that motive is
    -- underscore is actually sufficient, weird
    apply compact_open_induction_on (P := _) V hV
    · simp
    · intro S _ V hV
      change IsCompact (U.1 ∩ (S.1 ∪ V.1))
      rw [Set.inter_union_distrib_left]
      apply hV.union
      clear hV
      apply compact_open_induction_on (P := _) U hU
      · simp
      · intro S _ W hW
        change IsCompact ((S.1 ∪ W.1) ∩ V.1)
        

Proof state:
case mpr.h₂.h₂
X✝ Y : Scheme
f : X✝ ⟶ Y
X : Scheme
H : ∀ (U V : ↑(Scheme.affineOpens X)), IsCompact (↑↑U ∩ ↑↑V)
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact U.carrier
V✝ : Opens ↑↑X.toPresheafedSpace
hV : IsCompact V✝.carrier
S✝ : Opens ↑↑X.toPresheafedSpace
x✝¹ : IsCompact S✝.carrier
V : ↑(Scheme.affineOpens X)
S : Opens ↑↑X.toPresheafedSpace
x✝ : IsCompact S.carrier
W : ↑(Scheme.affineOpens X)
hW : IsCompact (S.carrier ∩ ↑↑V)
⊢ IsCompact ((S.carrier ∪ ↑↑W) ∩ ↑↑V)

Next tactic:
rw [Set.union_inter_distrib_right]
theorem quasiSeparatedSpace_iff_affine (X : Scheme) :
    QuasiSeparatedSpace X.carrier ↔ ∀ U V : X.affineOpens, IsCompact (U ∩ V : Set X.carrier) := by
  rw [QuasiSeparatedSpace_iff]
  constructor
  · intro H U V; exact H U V U.1.2 U.2.isCompact V.1.2 V.2.isCompact
  · intro H
    suffices
      ∀ (U : Opens X.carrier) (_ : IsCompact U.1) (V : Opens X.carrier) (_ : IsCompact V.1),
        IsCompact (U ⊓ V).1
      by intro U V hU hU' hV hV'; exact this ⟨U, hU⟩ hU' ⟨V, hV⟩ hV'
    intro U hU V hV
    -- Porting note: it complains "unable to find motive", but telling Lean that motive is
    -- underscore is actually sufficient, weird
    apply compact_open_induction_on (P := _) V hV
    · simp
    · intro S _ V hV
      change IsCompact (U.1 ∩ (S.1 ∪ V.1))
      rw [Set.inter_union_distrib_left]
      apply hV.union
      clear hV
      apply compact_open_induction_on (P := _) U hU
      · simp
      · intro S _ W hW
        change IsCompact ((S.1 ∪ W.1) ∩ V.1)
        rw [Set.union_inter_distrib_right]
        

Proof state:
case mpr.h₂.h₂
X✝ Y : Scheme
f : X✝ ⟶ Y
X : Scheme
H : ∀ (U V : ↑(Scheme.affineOpens X)), IsCompact (↑↑U ∩ ↑↑V)
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact U.carrier
V✝ : Opens ↑↑X.toPresheafedSpace
hV : IsCompact V✝.carrier
S✝ : Opens ↑↑X.toPresheafedSpace
x✝¹ : IsCompact S✝.carrier
V : ↑(Scheme.affineOpens X)
S : Opens ↑↑X.toPresheafedSpace
x✝ : IsCompact S.carrier
W : ↑(Scheme.affineOpens X)
hW : IsCompact (S.carrier ∩ ↑↑V)
⊢ IsCompact (S.carrier ∩ ↑↑V ∪ ↑↑W ∩ ↑↑V)

Next tactic:
apply hW.union
theorem quasiSeparatedSpace_iff_affine (X : Scheme) :
    QuasiSeparatedSpace X.carrier ↔ ∀ U V : X.affineOpens, IsCompact (U ∩ V : Set X.carrier) := by
  rw [QuasiSeparatedSpace_iff]
  constructor
  · intro H U V; exact H U V U.1.2 U.2.isCompact V.1.2 V.2.isCompact
  · intro H
    suffices
      ∀ (U : Opens X.carrier) (_ : IsCompact U.1) (V : Opens X.carrier) (_ : IsCompact V.1),
        IsCompact (U ⊓ V).1
      by intro U V hU hU' hV hV'; exact this ⟨U, hU⟩ hU' ⟨V, hV⟩ hV'
    intro U hU V hV
    -- Porting note: it complains "unable to find motive", but telling Lean that motive is
    -- underscore is actually sufficient, weird
    apply compact_open_induction_on (P := _) V hV
    · simp
    · intro S _ V hV
      change IsCompact (U.1 ∩ (S.1 ∪ V.1))
      rw [Set.inter_union_distrib_left]
      apply hV.union
      clear hV
      apply compact_open_induction_on (P := _) U hU
      · simp
      · intro S _ W hW
        change IsCompact ((S.1 ∪ W.1) ∩ V.1)
        rw [Set.union_inter_distrib_right]
        apply hW.union
        

Proof state:
case mpr.h₂.h₂
X✝ Y : Scheme
f : X✝ ⟶ Y
X : Scheme
H : ∀ (U V : ↑(Scheme.affineOpens X)), IsCompact (↑↑U ∩ ↑↑V)
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact U.carrier
V✝ : Opens ↑↑X.toPresheafedSpace
hV : IsCompact V✝.carrier
S✝ : Opens ↑↑X.toPresheafedSpace
x✝¹ : IsCompact S✝.carrier
V : ↑(Scheme.affineOpens X)
S : Opens ↑↑X.toPresheafedSpace
x✝ : IsCompact S.carrier
W : ↑(Scheme.affineOpens X)
hW : IsCompact (S.carrier ∩ ↑↑V)
⊢ IsCompact (↑↑W ∩ ↑↑V)

Next tactic:
apply H
theorem quasi_compact_affineProperty_iff_quasiSeparatedSpace {X Y : Scheme} [IsAffine Y]
    (f : X ⟶ Y) : QuasiCompact.affineProperty.diagonal f ↔ QuasiSeparatedSpace X.carrier := by
  

Proof state:
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y : Scheme
inst✝ : IsAffine Y
f : X ⟶ Y
⊢ AffineTargetMorphismProperty.diagonal QuasiCompact.affineProperty f ↔ QuasiSeparatedSpace ↑↑X.toPresheafedSpace

Next tactic:
delta AffineTargetMorphismProperty.diagonal
theorem quasi_compact_affineProperty_iff_quasiSeparatedSpace {X Y : Scheme} [IsAffine Y]
    (f : X ⟶ Y) : QuasiCompact.affineProperty.diagonal f ↔ QuasiSeparatedSpace X.carrier := by
  delta AffineTargetMorphismProperty.diagonal
  

Proof state:
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y : Scheme
inst✝ : IsAffine Y
f : X ⟶ Y
⊢ (∀ {U₁ U₂ : Scheme} (f₁ : U₁ ⟶ X) (f₂ : U₂ ⟶ X) [inst : IsAffine U₁] [inst_1 : IsAffine U₂]
      [inst_2 : IsOpenImmersion f₁] [inst_3 : IsOpenImmersion f₂],
      QuasiCompact.affineProperty (pullback.mapDesc f₁ f₂ f)) ↔
    QuasiSeparatedSpace ↑↑X.toPresheafedSpace

Next tactic:
rw [quasiSeparatedSpace_iff_affine]
theorem quasi_compact_affineProperty_iff_quasiSeparatedSpace {X Y : Scheme} [IsAffine Y]
    (f : X ⟶ Y) : QuasiCompact.affineProperty.diagonal f ↔ QuasiSeparatedSpace X.carrier := by
  delta AffineTargetMorphismProperty.diagonal
  rw [quasiSeparatedSpace_iff_affine]
  

Proof state:
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y : Scheme
inst✝ : IsAffine Y
f : X ⟶ Y
⊢ (∀ {U₁ U₂ : Scheme} (f₁ : U₁ ⟶ X) (f₂ : U₂ ⟶ X) [inst : IsAffine U₁] [inst_1 : IsAffine U₂]
      [inst_2 : IsOpenImmersion f₁] [inst_3 : IsOpenImmersion f₂],
      QuasiCompact.affineProperty (pullback.mapDesc f₁ f₂ f)) ↔
    ∀ (U V : ↑(Scheme.affineOpens X)), IsCompact (↑↑U ∩ ↑↑V)

Next tactic:
constructor
theorem quasi_compact_affineProperty_iff_quasiSeparatedSpace {X Y : Scheme} [IsAffine Y]
    (f : X ⟶ Y) : QuasiCompact.affineProperty.diagonal f ↔ QuasiSeparatedSpace X.carrier := by
  delta AffineTargetMorphismProperty.diagonal
  rw [quasiSeparatedSpace_iff_affine]
  constructor
  · 

Proof state:
case mp
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y : Scheme
inst✝ : IsAffine Y
f : X ⟶ Y
⊢ (∀ {U₁ U₂ : Scheme} (f₁ : U₁ ⟶ X) (f₂ : U₂ ⟶ X) [inst : IsAffine U₁] [inst_1 : IsAffine U₂]
      [inst_2 : IsOpenImmersion f₁] [inst_3 : IsOpenImmersion f₂],
      QuasiCompact.affineProperty (pullback.mapDesc f₁ f₂ f)) →
    ∀ (U V : ↑(Scheme.affineOpens X)), IsCompact (↑↑U ∩ ↑↑V)

Next tactic:
intro H U V
theorem quasi_compact_affineProperty_iff_quasiSeparatedSpace {X Y : Scheme} [IsAffine Y]
    (f : X ⟶ Y) : QuasiCompact.affineProperty.diagonal f ↔ QuasiSeparatedSpace X.carrier := by
  delta AffineTargetMorphismProperty.diagonal
  rw [quasiSeparatedSpace_iff_affine]
  constructor
  · intro H U V
    

Proof state:
case mp
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y : Scheme
inst✝ : IsAffine Y
f : X ⟶ Y
H :
  ∀ {U₁ U₂ : Scheme} (f₁ : U₁ ⟶ X) (f₂ : U₂ ⟶ X) [inst : IsAffine U₁] [inst_1 : IsAffine U₂]
    [inst_2 : IsOpenImmersion f₁] [inst_3 : IsOpenImmersion f₂], QuasiCompact.affineProperty (pullback.mapDesc f₁ f₂ f)
U V : ↑(Scheme.affineOpens X)
⊢ IsCompact (↑↑U ∩ ↑↑V)

Next tactic:
haveI : IsAffine _ := U.2
theorem quasi_compact_affineProperty_iff_quasiSeparatedSpace {X Y : Scheme} [IsAffine Y]
    (f : X ⟶ Y) : QuasiCompact.affineProperty.diagonal f ↔ QuasiSeparatedSpace X.carrier := by
  delta AffineTargetMorphismProperty.diagonal
  rw [quasiSeparatedSpace_iff_affine]
  constructor
  · intro H U V
    haveI : IsAffine _ := U.2
    

Proof state:
case mp
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y : Scheme
inst✝ : IsAffine Y
f : X ⟶ Y
H :
  ∀ {U₁ U₂ : Scheme} (f₁ : U₁ ⟶ X) (f₂ : U₂ ⟶ X) [inst : IsAffine U₁] [inst_1 : IsAffine U₂]
    [inst_2 : IsOpenImmersion f₁] [inst_3 : IsOpenImmersion f₂], QuasiCompact.affineProperty (pullback.mapDesc f₁ f₂ f)
U V : ↑(Scheme.affineOpens X)
this : IsAffine (Scheme.restrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
⊢ IsCompact (↑↑U ∩ ↑↑V)

Next tactic:
haveI : IsAffine _ := V.2
theorem quasi_compact_affineProperty_iff_quasiSeparatedSpace {X Y : Scheme} [IsAffine Y]
    (f : X ⟶ Y) : QuasiCompact.affineProperty.diagonal f ↔ QuasiSeparatedSpace X.carrier := by
  delta AffineTargetMorphismProperty.diagonal
  rw [quasiSeparatedSpace_iff_affine]
  constructor
  · intro H U V
    haveI : IsAffine _ := U.2
    haveI : IsAffine _ := V.2
    

Proof state:
case mp
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y : Scheme
inst✝ : IsAffine Y
f : X ⟶ Y
H :
  ∀ {U₁ U₂ : Scheme} (f₁ : U₁ ⟶ X) (f₂ : U₂ ⟶ X) [inst : IsAffine U₁] [inst_1 : IsAffine U₂]
    [inst_2 : IsOpenImmersion f₁] [inst_3 : IsOpenImmersion f₂], QuasiCompact.affineProperty (pullback.mapDesc f₁ f₂ f)
U V : ↑(Scheme.affineOpens X)
this✝ : IsAffine (Scheme.restrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
this : IsAffine (Scheme.restrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑V)))
⊢ IsCompact (↑↑U ∩ ↑↑V)

Next tactic:
let g : pullback (X.ofRestrict U.1.openEmbedding) (X.ofRestrict V.1.openEmbedding) ⟶ X :=
      pullback.fst ≫ X.ofRestrict _
theorem quasi_compact_affineProperty_iff_quasiSeparatedSpace {X Y : Scheme} [IsAffine Y]
    (f : X ⟶ Y) : QuasiCompact.affineProperty.diagonal f ↔ QuasiSeparatedSpace X.carrier := by
  delta AffineTargetMorphismProperty.diagonal
  rw [quasiSeparatedSpace_iff_affine]
  constructor
  · intro H U V
    haveI : IsAffine _ := U.2
    haveI : IsAffine _ := V.2
    let g : pullback (X.ofRestrict U.1.openEmbedding) (X.ofRestrict V.1.openEmbedding) ⟶ X :=
      pullback.fst ≫ X.ofRestrict _
    -- Porting note: `inferInstance` does not work here
    

Proof state:
case mp
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y : Scheme
inst✝ : IsAffine Y
f : X ⟶ Y
H :
  ∀ {U₁ U₂ : Scheme} (f₁ : U₁ ⟶ X) (f₂ : U₂ ⟶ X) [inst : IsAffine U₁] [inst_1 : IsAffine U₂]
    [inst_2 : IsOpenImmersion f₁] [inst_3 : IsOpenImmersion f₂], QuasiCompact.affineProperty (pullback.mapDesc f₁ f₂ f)
U V : ↑(Scheme.affineOpens X)
this✝ : IsAffine (Scheme.restrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
this : IsAffine (Scheme.restrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑V)))
g : pullback (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
    (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑V))) ⟶
  X :=
  pullback.fst ≫ Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑U))
⊢ IsCompact (↑↑U ∩ ↑↑V)

Next tactic:
have : IsOpenImmersion g := PresheafedSpace.IsOpenImmersion.comp _ _
theorem quasi_compact_affineProperty_iff_quasiSeparatedSpace {X Y : Scheme} [IsAffine Y]
    (f : X ⟶ Y) : QuasiCompact.affineProperty.diagonal f ↔ QuasiSeparatedSpace X.carrier := by
  delta AffineTargetMorphismProperty.diagonal
  rw [quasiSeparatedSpace_iff_affine]
  constructor
  · intro H U V
    haveI : IsAffine _ := U.2
    haveI : IsAffine _ := V.2
    let g : pullback (X.ofRestrict U.1.openEmbedding) (X.ofRestrict V.1.openEmbedding) ⟶ X :=
      pullback.fst ≫ X.ofRestrict _
    -- Porting note: `inferInstance` does not work here
    have : IsOpenImmersion g := PresheafedSpace.IsOpenImmersion.comp _ _
    

Proof state:
case mp
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y : Scheme
inst✝ : IsAffine Y
f : X ⟶ Y
H :
  ∀ {U₁ U₂ : Scheme} (f₁ : U₁ ⟶ X) (f₂ : U₂ ⟶ X) [inst : IsAffine U₁] [inst_1 : IsAffine U₂]
    [inst_2 : IsOpenImmersion f₁] [inst_3 : IsOpenImmersion f₂], QuasiCompact.affineProperty (pullback.mapDesc f₁ f₂ f)
U V : ↑(Scheme.affineOpens X)
this✝¹ : IsAffine (Scheme.restrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
this✝ : IsAffine (Scheme.restrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑V)))
g : pullback (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
    (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑V))) ⟶
  X :=
  pullback.fst ≫ Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑U))
this : IsOpenImmersion g
⊢ IsCompact (↑↑U ∩ ↑↑V)

Next tactic:
have e := Homeomorph.ofEmbedding _ this.base_open.toEmbedding
theorem quasi_compact_affineProperty_iff_quasiSeparatedSpace {X Y : Scheme} [IsAffine Y]
    (f : X ⟶ Y) : QuasiCompact.affineProperty.diagonal f ↔ QuasiSeparatedSpace X.carrier := by
  delta AffineTargetMorphismProperty.diagonal
  rw [quasiSeparatedSpace_iff_affine]
  constructor
  · intro H U V
    haveI : IsAffine _ := U.2
    haveI : IsAffine _ := V.2
    let g : pullback (X.ofRestrict U.1.openEmbedding) (X.ofRestrict V.1.openEmbedding) ⟶ X :=
      pullback.fst ≫ X.ofRestrict _
    -- Porting note: `inferInstance` does not work here
    have : IsOpenImmersion g := PresheafedSpace.IsOpenImmersion.comp _ _
    have e := Homeomorph.ofEmbedding _ this.base_open.toEmbedding
    

Proof state:
case mp
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y : Scheme
inst✝ : IsAffine Y
f : X ⟶ Y
H :
  ∀ {U₁ U₂ : Scheme} (f₁ : U₁ ⟶ X) (f₂ : U₂ ⟶ X) [inst : IsAffine U₁] [inst_1 : IsAffine U₂]
    [inst_2 : IsOpenImmersion f₁] [inst_3 : IsOpenImmersion f₂], QuasiCompact.affineProperty (pullback.mapDesc f₁ f₂ f)
U V : ↑(Scheme.affineOpens X)
this✝¹ : IsAffine (Scheme.restrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
this✝ : IsAffine (Scheme.restrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑V)))
g : pullback (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
    (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑V))) ⟶
  X :=
  pullback.fst ≫ Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑U))
this : IsOpenImmersion g
e :
  (forget TopCat).obj
      ↑(pullback (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
                (Scheme.ofRestrict X
                  (_ : OpenEmbedding ⇑(Opens.inclusion ↑V)))).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace ≃ₜ
    ↑(Set.range ⇑g.val.base)
⊢ IsCompact (↑↑U ∩ ↑↑V)

Next tactic:
rw [IsOpenImmersion.range_pullback_to_base_of_left] at e
theorem quasi_compact_affineProperty_iff_quasiSeparatedSpace {X Y : Scheme} [IsAffine Y]
    (f : X ⟶ Y) : QuasiCompact.affineProperty.diagonal f ↔ QuasiSeparatedSpace X.carrier := by
  delta AffineTargetMorphismProperty.diagonal
  rw [quasiSeparatedSpace_iff_affine]
  constructor
  · intro H U V
    haveI : IsAffine _ := U.2
    haveI : IsAffine _ := V.2
    let g : pullback (X.ofRestrict U.1.openEmbedding) (X.ofRestrict V.1.openEmbedding) ⟶ X :=
      pullback.fst ≫ X.ofRestrict _
    -- Porting note: `inferInstance` does not work here
    have : IsOpenImmersion g := PresheafedSpace.IsOpenImmersion.comp _ _
    have e := Homeomorph.ofEmbedding _ this.base_open.toEmbedding
    rw [IsOpenImmersion.range_pullback_to_base_of_left] at e
    

Proof state:
case mp
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y : Scheme
inst✝ : IsAffine Y
f : X ⟶ Y
H :
  ∀ {U₁ U₂ : Scheme} (f₁ : U₁ ⟶ X) (f₂ : U₂ ⟶ X) [inst : IsAffine U₁] [inst_1 : IsAffine U₂]
    [inst_2 : IsOpenImmersion f₁] [inst_3 : IsOpenImmersion f₂], QuasiCompact.affineProperty (pullback.mapDesc f₁ f₂ f)
U V : ↑(Scheme.affineOpens X)
this✝¹ : IsAffine (Scheme.restrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
this✝ : IsAffine (Scheme.restrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑V)))
g : pullback (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
    (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑V))) ⟶
  X :=
  pullback.fst ≫ Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑U))
this : IsOpenImmersion g
e :
  (forget TopCat).obj
      ↑(pullback (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
                (Scheme.ofRestrict X
                  (_ : OpenEmbedding ⇑(Opens.inclusion ↑V)))).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace ≃ₜ
    ↑(Set.range ⇑(Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑U))).val.base ∩
        Set.range ⇑(Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑V))).val.base)
⊢ IsCompact (↑↑U ∩ ↑↑V)

Next tactic:
erw [Subtype.range_coe, Subtype.range_coe] at e
theorem quasi_compact_affineProperty_iff_quasiSeparatedSpace {X Y : Scheme} [IsAffine Y]
    (f : X ⟶ Y) : QuasiCompact.affineProperty.diagonal f ↔ QuasiSeparatedSpace X.carrier := by
  delta AffineTargetMorphismProperty.diagonal
  rw [quasiSeparatedSpace_iff_affine]
  constructor
  · intro H U V
    haveI : IsAffine _ := U.2
    haveI : IsAffine _ := V.2
    let g : pullback (X.ofRestrict U.1.openEmbedding) (X.ofRestrict V.1.openEmbedding) ⟶ X :=
      pullback.fst ≫ X.ofRestrict _
    -- Porting note: `inferInstance` does not work here
    have : IsOpenImmersion g := PresheafedSpace.IsOpenImmersion.comp _ _
    have e := Homeomorph.ofEmbedding _ this.base_open.toEmbedding
    rw [IsOpenImmersion.range_pullback_to_base_of_left] at e
    erw [Subtype.range_coe, Subtype.range_coe] at e
    

Proof state:
case mp
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y : Scheme
inst✝ : IsAffine Y
f : X ⟶ Y
H :
  ∀ {U₁ U₂ : Scheme} (f₁ : U₁ ⟶ X) (f₂ : U₂ ⟶ X) [inst : IsAffine U₁] [inst_1 : IsAffine U₂]
    [inst_2 : IsOpenImmersion f₁] [inst_3 : IsOpenImmersion f₂], QuasiCompact.affineProperty (pullback.mapDesc f₁ f₂ f)
U V : ↑(Scheme.affineOpens X)
this✝¹ : IsAffine (Scheme.restrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
this✝ : IsAffine (Scheme.restrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑V)))
g : pullback (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
    (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑V))) ⟶
  X :=
  pullback.fst ≫ Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑U))
this : IsOpenImmersion g
e :
  (forget TopCat).obj
      ↑(pullback (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
                (Scheme.ofRestrict X
                  (_ : OpenEmbedding ⇑(Opens.inclusion ↑V)))).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace ≃ₜ
    ↑(↑↑U ∩ ↑↑V)
⊢ IsCompact (↑↑U ∩ ↑↑V)

Next tactic:
rw [isCompact_iff_compactSpace]
theorem quasi_compact_affineProperty_iff_quasiSeparatedSpace {X Y : Scheme} [IsAffine Y]
    (f : X ⟶ Y) : QuasiCompact.affineProperty.diagonal f ↔ QuasiSeparatedSpace X.carrier := by
  delta AffineTargetMorphismProperty.diagonal
  rw [quasiSeparatedSpace_iff_affine]
  constructor
  · intro H U V
    haveI : IsAffine _ := U.2
    haveI : IsAffine _ := V.2
    let g : pullback (X.ofRestrict U.1.openEmbedding) (X.ofRestrict V.1.openEmbedding) ⟶ X :=
      pullback.fst ≫ X.ofRestrict _
    -- Porting note: `inferInstance` does not work here
    have : IsOpenImmersion g := PresheafedSpace.IsOpenImmersion.comp _ _
    have e := Homeomorph.ofEmbedding _ this.base_open.toEmbedding
    rw [IsOpenImmersion.range_pullback_to_base_of_left] at e
    erw [Subtype.range_coe, Subtype.range_coe] at e
    rw [isCompact_iff_compactSpace]
    

Proof state:
case mp
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y : Scheme
inst✝ : IsAffine Y
f : X ⟶ Y
H :
  ∀ {U₁ U₂ : Scheme} (f₁ : U₁ ⟶ X) (f₂ : U₂ ⟶ X) [inst : IsAffine U₁] [inst_1 : IsAffine U₂]
    [inst_2 : IsOpenImmersion f₁] [inst_3 : IsOpenImmersion f₂], QuasiCompact.affineProperty (pullback.mapDesc f₁ f₂ f)
U V : ↑(Scheme.affineOpens X)
this✝¹ : IsAffine (Scheme.restrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
this✝ : IsAffine (Scheme.restrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑V)))
g : pullback (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
    (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑V))) ⟶
  X :=
  pullback.fst ≫ Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑U))
this : IsOpenImmersion g
e :
  (forget TopCat).obj
      ↑(pullback (Scheme.ofRestrict X (_ : OpenEmbedding ⇑(Opens.inclusion ↑U)))
                (Scheme.ofRestrict X
                  (_ : OpenEmbedding ⇑(Opens.inclusion ↑V)))).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace ≃ₜ
    ↑(↑↑U ∩ ↑↑V)
⊢ CompactSpace ↑(↑↑U ∩ ↑↑V)

Next tactic:
exact @Homeomorph.compactSpace _ _ _ _ (H _ _) e
theorem quasi_compact_affineProperty_iff_quasiSeparatedSpace {X Y : Scheme} [IsAffine Y]
    (f : X ⟶ Y) : QuasiCompact.affineProperty.diagonal f ↔ QuasiSeparatedSpace X.carrier := by
  delta AffineTargetMorphismProperty.diagonal
  rw [quasiSeparatedSpace_iff_affine]
  constructor
  · intro H U V
    haveI : IsAffine _ := U.2
    haveI : IsAffine _ := V.2
    let g : pullback (X.ofRestrict U.1.openEmbedding) (X.ofRestrict V.1.openEmbedding) ⟶ X :=
      pullback.fst ≫ X.ofRestrict _
    -- Porting note: `inferInstance` does not work here
    have : IsOpenImmersion g := PresheafedSpace.IsOpenImmersion.comp _ _
    have e := Homeomorph.ofEmbedding _ this.base_open.toEmbedding
    rw [IsOpenImmersion.range_pullback_to_base_of_left] at e
    erw [Subtype.range_coe, Subtype.range_coe] at e
    rw [isCompact_iff_compactSpace]
    exact @Homeomorph.compactSpace _ _ _ _ (H _ _) e
  · 

Proof state:
case mpr
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y : Scheme
inst✝ : IsAffine Y
f : X ⟶ Y
⊢ (∀ (U V : ↑(Scheme.affineOpens X)), IsCompact (↑↑U ∩ ↑↑V)) →
    ∀ {U₁ U₂ : Scheme} (f₁ : U₁ ⟶ X) (f₂ : U₂ ⟶ X) [inst : IsAffine U₁] [inst_1 : IsAffine U₂]
      [inst_2 : IsOpenImmersion f₁] [inst_3 : IsOpenImmersion f₂],
      QuasiCompact.affineProperty (pullback.mapDesc f₁ f₂ f)

Next tactic:
introv H h₁ h₂
theorem quasi_compact_affineProperty_iff_quasiSeparatedSpace {X Y : Scheme} [IsAffine Y]
    (f : X ⟶ Y) : QuasiCompact.affineProperty.diagonal f ↔ QuasiSeparatedSpace X.carrier := by
  delta AffineTargetMorphismProperty.diagonal
  rw [quasiSeparatedSpace_iff_affine]
  constructor
  · intro H U V
    haveI : IsAffine _ := U.2
    haveI : IsAffine _ := V.2
    let g : pullback (X.ofRestrict U.1.openEmbedding) (X.ofRestrict V.1.openEmbedding) ⟶ X :=
      pullback.fst ≫ X.ofRestrict _
    -- Porting note: `inferInstance` does not work here
    have : IsOpenImmersion g := PresheafedSpace.IsOpenImmersion.comp _ _
    have e := Homeomorph.ofEmbedding _ this.base_open.toEmbedding
    rw [IsOpenImmersion.range_pullback_to_base_of_left] at e
    erw [Subtype.range_coe, Subtype.range_coe] at e
    rw [isCompact_iff_compactSpace]
    exact @Homeomorph.compactSpace _ _ _ _ (H _ _) e
  · introv H h₁ h₂
    

Proof state:
case mpr
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y : Scheme
inst✝² : IsAffine Y
f : X ⟶ Y
H : ∀ (U V : ↑(Scheme.affineOpens X)), IsCompact (↑↑U ∩ ↑↑V)
U₁ U₂ : Scheme
f₁ : U₁ ⟶ X
f₂ : U₂ ⟶ X
inst✝¹ : IsAffine U₁
inst✝ : IsAffine U₂
h₁ : IsOpenImmersion f₁
h₂ : IsOpenImmersion f₂
⊢ QuasiCompact.affineProperty (pullback.mapDesc f₁ f₂ f)

Next tactic:
let g : pullback f₁ f₂ ⟶ X := pullback.fst ≫ f₁