l3lab/ntp-mathlib huggingface dataset:
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₂
    let g : pullback f₁ f₂ ⟶ X := pullback.fst ≫ f₁
    -- Porting note: `inferInstance` does not work here
    

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₂
g : pullback f₁ f₂ ⟶ X := pullback.fst ≫ f₁
⊢ QuasiCompact.affineProperty (pullback.mapDesc f₁ f₂ f)

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 _ _
    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₂
    let g : pullback f₁ f₂ ⟶ X := pullback.fst ≫ f₁
    -- Porting note: `inferInstance` does not work here
    have : IsOpenImmersion g := PresheafedSpace.IsOpenImmersion.comp _ _
    

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₂
g : pullback f₁ f₂ ⟶ X := pullback.fst ≫ f₁
this : IsOpenImmersion g
⊢ QuasiCompact.affineProperty (pullback.mapDesc f₁ f₂ f)

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
    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₂
    let g : pullback f₁ f₂ ⟶ X := pullback.fst ≫ f₁
    -- Porting note: `inferInstance` does not work here
    have : IsOpenImmersion g := PresheafedSpace.IsOpenImmersion.comp _ _
    have e := Homeomorph.ofEmbedding _ this.base_open.toEmbedding
    

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₂
g : pullback f₁ f₂ ⟶ X := pullback.fst ≫ f₁
this : IsOpenImmersion g
e :
  (forget TopCat).obj ↑(pullback f₁ f₂).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace ≃ₜ
    ↑(Set.range ⇑g.val.base)
⊢ QuasiCompact.affineProperty (pullback.mapDesc f₁ f₂ f)

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
    erw [Subtype.range_coe, Subtype.range_coe] at e
    rw [isCompact_iff_compactSpace]
    exact @Homeomorph.compactSpace _ _ _ _ (H _ _) e
  · introv H h₁ h₂
    let g : pullback f₁ f₂ ⟶ X := pullback.fst ≫ f₁
    -- 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 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₂
g : pullback f₁ f₂ ⟶ X := pullback.fst ≫ f₁
this : IsOpenImmersion g
e :
  (forget TopCat).obj ↑(pullback f₁ f₂).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace ≃ₜ
    ↑(Set.range ⇑f₁.val.base ∩ Set.range ⇑f₂.val.base)
⊢ QuasiCompact.affineProperty (pullback.mapDesc f₁ f₂ f)

Next tactic:
simp_rw [isCompact_iff_compactSpace] at 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₂
    let g : pullback f₁ f₂ ⟶ X := pullback.fst ≫ f₁
    -- 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
    simp_rw [isCompact_iff_compactSpace] at H
    

Proof state:
case mpr
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✝ : IsAffine U₂
h₁ : IsOpenImmersion f₁
h₂ : IsOpenImmersion f₂
g : pullback f₁ f₂ ⟶ X := pullback.fst ≫ f₁
this : IsOpenImmersion g
e :
  (forget TopCat).obj ↑(pullback f₁ f₂).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace ≃ₜ
    ↑(Set.range ⇑f₁.val.base ∩ Set.range ⇑f₂.val.base)
H : ∀ (U V : ↑(Scheme.affineOpens X)), CompactSpace ↑(↑↑U ∩ ↑↑V)
⊢ QuasiCompact.affineProperty (pullback.mapDesc f₁ f₂ f)

Next tactic:
exact
      @Homeomorph.compactSpace _ _ _ _
        (H ⟨⟨_, h₁.base_open.open_range⟩, rangeIsAffineOpenOfOpenImmersion _⟩
          ⟨⟨_, h₂.base_open.open_range⟩, rangeIsAffineOpenOfOpenImmersion _⟩)
        e.symm
theorem quasiSeparated_eq_diagonal_is_quasiCompact :
    @QuasiSeparated = MorphismProperty.diagonal @QuasiCompact := by 

Proof state:
X Y : Scheme
f : X ⟶ Y
⊢ @QuasiSeparated = MorphismProperty.diagonal @QuasiCompact

Next tactic:
ext
theorem quasiSeparated_eq_diagonal_is_quasiCompact :
    @QuasiSeparated = MorphismProperty.diagonal @QuasiCompact := by ext; 

Proof state:
case h.h.h.a
X Y : Scheme
f : X ⟶ Y
x✝² x✝¹ : Scheme
x✝ : x✝² ⟶ x✝¹
⊢ QuasiSeparated x✝ ↔ MorphismProperty.diagonal (@QuasiCompact) x✝

Next tactic:
exact QuasiSeparated_iff _
theorem quasi_compact_affineProperty_diagonal_eq :
    QuasiCompact.affineProperty.diagonal = QuasiSeparated.affineProperty := by
  

Proof state:
X Y : Scheme
f : X ⟶ Y
⊢ AffineTargetMorphismProperty.diagonal QuasiCompact.affineProperty = QuasiSeparated.affineProperty

Next tactic:
funext
theorem quasi_compact_affineProperty_diagonal_eq :
    QuasiCompact.affineProperty.diagonal = QuasiSeparated.affineProperty := by
  funext; 

Proof state:
case h.h.h.h
X Y : Scheme
f : X ⟶ Y
x✝³ x✝² : Scheme
x✝¹ : x✝³ ⟶ x✝²
x✝ : IsAffine x✝²
⊢ AffineTargetMorphismProperty.diagonal QuasiCompact.affineProperty x✝¹ = QuasiSeparated.affineProperty x✝¹

Next tactic:
rw [quasi_compact_affineProperty_iff_quasiSeparatedSpace]
theorem quasi_compact_affineProperty_diagonal_eq :
    QuasiCompact.affineProperty.diagonal = QuasiSeparated.affineProperty := by
  funext; rw [quasi_compact_affineProperty_iff_quasiSeparatedSpace]; 

Proof state:
case h.h.h.h
X Y : Scheme
f : X ⟶ Y
x✝³ x✝² : Scheme
x✝¹ : x✝³ ⟶ x✝²
x✝ : IsAffine x✝²
⊢ QuasiSeparatedSpace ↑↑x✝³.toPresheafedSpace = QuasiSeparated.affineProperty x✝¹

Next tactic:
rfl
theorem quasiSeparated_eq_affineProperty_diagonal :
    @QuasiSeparated = targetAffineLocally QuasiCompact.affineProperty.diagonal := by
  

Proof state:
X Y : Scheme
f : X ⟶ Y
⊢ @QuasiSeparated = targetAffineLocally (AffineTargetMorphismProperty.diagonal QuasiCompact.affineProperty)

Next tactic:
rw [quasiSeparated_eq_diagonal_is_quasiCompact, quasiCompact_eq_affineProperty]
theorem quasiSeparated_eq_affineProperty_diagonal :
    @QuasiSeparated = targetAffineLocally QuasiCompact.affineProperty.diagonal := by
  rw [quasiSeparated_eq_diagonal_is_quasiCompact, quasiCompact_eq_affineProperty]
  

Proof state:
X Y : Scheme
f : X ⟶ Y
⊢ MorphismProperty.diagonal (targetAffineLocally QuasiCompact.affineProperty) =
    targetAffineLocally (AffineTargetMorphismProperty.diagonal QuasiCompact.affineProperty)

Next tactic:
exact
    diagonal_targetAffineLocally_eq_targetAffineLocally _ QuasiCompact.affineProperty_isLocal
theorem quasiSeparated_eq_affineProperty :
    @QuasiSeparated = targetAffineLocally QuasiSeparated.affineProperty := by
  

Proof state:
X Y : Scheme
f : X ⟶ Y
⊢ @QuasiSeparated = targetAffineLocally QuasiSeparated.affineProperty

Next tactic:
rw [quasiSeparated_eq_affineProperty_diagonal, quasi_compact_affineProperty_diagonal_eq]
open List in
theorem QuasiSeparated.affine_openCover_TFAE {X Y : Scheme.{u}} (f : X ⟶ Y) :
    TFAE
      [QuasiSeparated f,
        ∃ (𝒰 : Scheme.OpenCover.{u} Y) (_ : ∀ i, IsAffine (𝒰.obj i)),
          ∀ i : 𝒰.J, QuasiSeparatedSpace (pullback f (𝒰.map i)).carrier,
        ∀ (𝒰 : Scheme.OpenCover.{u} Y) [∀ i, IsAffine (𝒰.obj i)] (i : 𝒰.J),
          QuasiSeparatedSpace (pullback f (𝒰.map i)).carrier,
        ∀ {U : Scheme} (g : U ⟶ Y) [IsAffine U] [IsOpenImmersion g],
          QuasiSeparatedSpace (pullback f g).carrier,
        ∃ (𝒰 : Scheme.OpenCover.{u} Y) (_ : ∀ i, IsAffine (𝒰.obj i)) (𝒰' :
          ∀ i : 𝒰.J, Scheme.OpenCover.{u} (pullback f (𝒰.map i))) (_ :
          ∀ i j, IsAffine ((𝒰' i).obj j)),
          ∀ (i : 𝒰.J) (j k : (𝒰' i).J),
            CompactSpace (pullback ((𝒰' i).map j) ((𝒰' i).map k)).carrier] := by
  

Proof state:
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y : Scheme
f : X ⟶ Y
⊢ TFAE
    [QuasiSeparated f,
      ∃ 𝒰,
        ∃ (_ : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)),
          ∀ (i : 𝒰.J),
            QuasiSeparatedSpace
              ↑↑(pullback f (Scheme.OpenCover.map 𝒰 i)).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace,
      ∀ (𝒰 : Scheme.OpenCover Y) [inst : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)] (i : 𝒰.J),
        QuasiSeparatedSpace
          ↑↑(pullback f (Scheme.OpenCover.map 𝒰 i)).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace,
      ∀ {U : Scheme} (g : U ⟶ Y) [inst : IsAffine U] [inst : IsOpenImmersion g],
        QuasiSeparatedSpace ↑↑(pullback f g).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace,
      ∃ 𝒰,
        ∃ (_ : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)),
          ∃ 𝒰',
            ∃ (_ : ∀ (i : 𝒰.J) (j : (𝒰' i).J), IsAffine (Scheme.OpenCover.obj (𝒰' i) j)),
              ∀ (i : 𝒰.J) (j k : (𝒰' i).J),
                CompactSpace
                  ↑↑(pullback (Scheme.OpenCover.map (𝒰' i) j)
                              (Scheme.OpenCover.map (𝒰' i) k)).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace]

Next tactic:
have := QuasiCompact.affineProperty_isLocal.diagonal_affine_openCover_TFAE f
open List in
theorem QuasiSeparated.affine_openCover_TFAE {X Y : Scheme.{u}} (f : X ⟶ Y) :
    TFAE
      [QuasiSeparated f,
        ∃ (𝒰 : Scheme.OpenCover.{u} Y) (_ : ∀ i, IsAffine (𝒰.obj i)),
          ∀ i : 𝒰.J, QuasiSeparatedSpace (pullback f (𝒰.map i)).carrier,
        ∀ (𝒰 : Scheme.OpenCover.{u} Y) [∀ i, IsAffine (𝒰.obj i)] (i : 𝒰.J),
          QuasiSeparatedSpace (pullback f (𝒰.map i)).carrier,
        ∀ {U : Scheme} (g : U ⟶ Y) [IsAffine U] [IsOpenImmersion g],
          QuasiSeparatedSpace (pullback f g).carrier,
        ∃ (𝒰 : Scheme.OpenCover.{u} Y) (_ : ∀ i, IsAffine (𝒰.obj i)) (𝒰' :
          ∀ i : 𝒰.J, Scheme.OpenCover.{u} (pullback f (𝒰.map i))) (_ :
          ∀ i j, IsAffine ((𝒰' i).obj j)),
          ∀ (i : 𝒰.J) (j k : (𝒰' i).J),
            CompactSpace (pullback ((𝒰' i).map j) ((𝒰' i).map k)).carrier] := by
  have := QuasiCompact.affineProperty_isLocal.diagonal_affine_openCover_TFAE f
  simp_rw [← quasiCompact_eq_affineProperty, ← quasiSeparated_eq_diagonal_is_quasiCompact,
    quasi_compact_affineProperty_diagonal_eq] at this
  

Proof state:
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y : Scheme
f : X ⟶ Y
this :
  TFAE
    [QuasiSeparated f,
      ∃ 𝒰, ∃ (h : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)), ∀ (i : 𝒰.J), affineProperty pullback.snd,
      ∀ (𝒰 : Scheme.OpenCover Y) [inst : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)] (i : 𝒰.J),
        affineProperty pullback.snd,
      ∀ {U : Scheme} (g : U ⟶ Y) [inst : IsAffine U] [inst_1 : IsOpenImmersion g], affineProperty pullback.snd,
      ∃ 𝒰,
        ∃ (x : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)),
          ∃ 𝒰',
            ∃ (x_1 : ∀ (i : 𝒰.J) (j : (𝒰' i).J), IsAffine (Scheme.OpenCover.obj (𝒰' i) j)),
              ∀ (i : 𝒰.J) (j k : (𝒰' i).J),
                QuasiCompact.affineProperty
                  (pullback.mapDesc (Scheme.OpenCover.map (𝒰' i) j) (Scheme.OpenCover.map (𝒰' i) k) pullback.snd)]
⊢ TFAE
    [QuasiSeparated f,
      ∃ 𝒰,
        ∃ (_ : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)),
          ∀ (i : 𝒰.J),
            QuasiSeparatedSpace
              ↑↑(pullback f (Scheme.OpenCover.map 𝒰 i)).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace,
      ∀ (𝒰 : Scheme.OpenCover Y) [inst : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)] (i : 𝒰.J),
        QuasiSeparatedSpace
          ↑↑(pullback f (Scheme.OpenCover.map 𝒰 i)).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace,
      ∀ {U : Scheme} (g : U ⟶ Y) [inst : IsAffine U] [inst : IsOpenImmersion g],
        QuasiSeparatedSpace ↑↑(pullback f g).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace,
      ∃ 𝒰,
        ∃ (_ : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)),
          ∃ 𝒰',
            ∃ (_ : ∀ (i : 𝒰.J) (j : (𝒰' i).J), IsAffine (Scheme.OpenCover.obj (𝒰' i) j)),
              ∀ (i : 𝒰.J) (j k : (𝒰' i).J),
                CompactSpace
                  ↑↑(pullback (Scheme.OpenCover.map (𝒰' i) j)
                              (Scheme.OpenCover.map (𝒰' i) k)).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace]

Next tactic:
exact this
theorem quasiSeparated_over_affine_iff {X Y : Scheme} (f : X ⟶ Y) [IsAffine Y] :
    QuasiSeparated f ↔ QuasiSeparatedSpace X.carrier := by
  

Proof state:
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y : Scheme
f : X ⟶ Y
inst✝ : IsAffine Y
⊢ QuasiSeparated f ↔ QuasiSeparatedSpace ↑↑X.toPresheafedSpace

Next tactic:
rw [quasiSeparated_eq_affineProperty,
    QuasiSeparated.affineProperty_isLocal.affine_target_iff f, QuasiSeparated.affineProperty]
theorem QuasiSeparated.affine_openCover_iff {X Y : Scheme.{u}} (𝒰 : Scheme.OpenCover.{u} Y)
    [∀ i, IsAffine (𝒰.obj i)] (f : X ⟶ Y) :
    QuasiSeparated f ↔ ∀ i, QuasiSeparatedSpace (pullback f (𝒰.map i)).carrier := by
  

Proof state:
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y : Scheme
𝒰 : Scheme.OpenCover Y
inst✝ : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)
f : X ⟶ Y
⊢ QuasiSeparated f ↔
    ∀ (i : 𝒰.J),
      QuasiSeparatedSpace
        ↑↑(pullback f (Scheme.OpenCover.map 𝒰 i)).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace

Next tactic:
rw [quasiSeparated_eq_affineProperty,
    QuasiSeparated.affineProperty_isLocal.affine_openCover_iff f 𝒰]
theorem QuasiSeparated.affine_openCover_iff {X Y : Scheme.{u}} (𝒰 : Scheme.OpenCover.{u} Y)
    [∀ i, IsAffine (𝒰.obj i)] (f : X ⟶ Y) :
    QuasiSeparated f ↔ ∀ i, QuasiSeparatedSpace (pullback f (𝒰.map i)).carrier := by
  rw [quasiSeparated_eq_affineProperty,
    QuasiSeparated.affineProperty_isLocal.affine_openCover_iff f 𝒰]
  

Proof state:
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y : Scheme
𝒰 : Scheme.OpenCover Y
inst✝ : ∀ (i : 𝒰.J), IsAffine (Scheme.OpenCover.obj 𝒰 i)
f : X ⟶ Y
⊢ (∀ (i : 𝒰.J), affineProperty pullback.snd) ↔
    ∀ (i : 𝒰.J),
      QuasiSeparatedSpace
        ↑↑(pullback f (Scheme.OpenCover.map 𝒰 i)).toLocallyRingedSpace.toSheafedSpace.toPresheafedSpace

Next tactic:
rfl
theorem quasiSeparatedSpace_of_quasiSeparated {X Y : Scheme} (f : X ⟶ Y)
    [hY : QuasiSeparatedSpace Y.carrier] [QuasiSeparated f] : QuasiSeparatedSpace X.carrier := by
  

Proof state:
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y : Scheme
f : X ⟶ Y
hY : QuasiSeparatedSpace ↑↑Y.toPresheafedSpace
inst✝ : QuasiSeparated f
⊢ QuasiSeparatedSpace ↑↑X.toPresheafedSpace

Next tactic:
rw [quasiSeparatedSpace_iff_quasiSeparated] at hY ⊢
theorem quasiSeparatedSpace_of_quasiSeparated {X Y : Scheme} (f : X ⟶ Y)
    [hY : QuasiSeparatedSpace Y.carrier] [QuasiSeparated f] : QuasiSeparatedSpace X.carrier := by
  rw [quasiSeparatedSpace_iff_quasiSeparated] at hY ⊢
  

Proof state:
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y : Scheme
f : X ⟶ Y
hY : QuasiSeparated (terminal.from Y)
inst✝ : QuasiSeparated f
⊢ QuasiSeparated (terminal.from X)

Next tactic:
have : f ≫ terminal.from Y = terminal.from X := terminalIsTerminal.hom_ext _ _
theorem quasiSeparatedSpace_of_quasiSeparated {X Y : Scheme} (f : X ⟶ Y)
    [hY : QuasiSeparatedSpace Y.carrier] [QuasiSeparated f] : QuasiSeparatedSpace X.carrier := by
  rw [quasiSeparatedSpace_iff_quasiSeparated] at hY ⊢
  have : f ≫ terminal.from Y = terminal.from X := terminalIsTerminal.hom_ext _ _
  

Proof state:
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y : Scheme
f : X ⟶ Y
hY : QuasiSeparated (terminal.from Y)
inst✝ : QuasiSeparated f
this : f ≫ terminal.from Y = terminal.from X
⊢ QuasiSeparated (terminal.from X)

Next tactic:
rw [← this]
theorem quasiSeparatedSpace_of_quasiSeparated {X Y : Scheme} (f : X ⟶ Y)
    [hY : QuasiSeparatedSpace Y.carrier] [QuasiSeparated f] : QuasiSeparatedSpace X.carrier := by
  rw [quasiSeparatedSpace_iff_quasiSeparated] at hY ⊢
  have : f ≫ terminal.from Y = terminal.from X := terminalIsTerminal.hom_ext _ _
  rw [← this]
  

Proof state:
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y : Scheme
f : X ⟶ Y
hY : QuasiSeparated (terminal.from Y)
inst✝ : QuasiSeparated f
this : f ≫ terminal.from Y = terminal.from X
⊢ QuasiSeparated (f ≫ terminal.from Y)

Next tactic:
infer_instance
instance quasiSeparatedSpace_of_isAffine (X : Scheme) [IsAffine X] :
    QuasiSeparatedSpace X.carrier := by
  

Proof state:
X✝ Y : Scheme
f : X✝ ⟶ Y
X : Scheme
inst✝ : IsAffine X
⊢ QuasiSeparatedSpace ↑↑X.toPresheafedSpace

Next tactic:
constructor
instance quasiSeparatedSpace_of_isAffine (X : Scheme) [IsAffine X] :
    QuasiSeparatedSpace X.carrier := by
  constructor
  

Proof state:
case inter_isCompact
X✝ Y : Scheme
f : X✝ ⟶ Y
X : Scheme
inst✝ : IsAffine X
⊢ ∀ (U V : Set ↑↑X.toPresheafedSpace), IsOpen U → IsCompact U → IsOpen V → IsCompact V → IsCompact (U ∩ V)

Next tactic:
intro U V hU hU' hV hV'
instance quasiSeparatedSpace_of_isAffine (X : Scheme) [IsAffine X] :
    QuasiSeparatedSpace X.carrier := by
  constructor
  intro U V hU hU' hV hV'
  

Proof state:
case inter_isCompact
X✝ Y : Scheme
f : X✝ ⟶ Y
X : Scheme
inst✝ : IsAffine X
U V : Set ↑↑X.toPresheafedSpace
hU : IsOpen U
hU' : IsCompact U
hV : IsOpen V
hV' : IsCompact V
⊢ IsCompact (U ∩ V)

Next tactic:
obtain ⟨s, hs, e⟩ := (isCompact_open_iff_eq_basicOpen_union _).mp ⟨hU', hU⟩
instance quasiSeparatedSpace_of_isAffine (X : Scheme) [IsAffine X] :
    QuasiSeparatedSpace X.carrier := by
  constructor
  intro U V hU hU' hV hV'
  obtain ⟨s, hs, e⟩ := (isCompact_open_iff_eq_basicOpen_union _).mp ⟨hU', hU⟩
  

Proof state:
case inter_isCompact.intro.intro
X✝ Y : Scheme
f : X✝ ⟶ Y
X : Scheme
inst✝ : IsAffine X
U V : Set ↑↑X.toPresheafedSpace
hU : IsOpen U
hU' : IsCompact U
hV : IsOpen V
hV' : IsCompact V
s : Set ↑(X.presheaf.obj (op ⊤))
hs : Set.Finite s
e : U = ⋃ i ∈ s, ↑(X.basicOpen i)
⊢ IsCompact (U ∩ V)

Next tactic:
obtain ⟨s', hs', e'⟩ := (isCompact_open_iff_eq_basicOpen_union _).mp ⟨hV', hV⟩
instance quasiSeparatedSpace_of_isAffine (X : Scheme) [IsAffine X] :
    QuasiSeparatedSpace X.carrier := by
  constructor
  intro U V hU hU' hV hV'
  obtain ⟨s, hs, e⟩ := (isCompact_open_iff_eq_basicOpen_union _).mp ⟨hU', hU⟩
  obtain ⟨s', hs', e'⟩ := (isCompact_open_iff_eq_basicOpen_union _).mp ⟨hV', hV⟩
  

Proof state:
case inter_isCompact.intro.intro.intro.intro
X✝ Y : Scheme
f : X✝ ⟶ Y
X : Scheme
inst✝ : IsAffine X
U V : Set ↑↑X.toPresheafedSpace
hU : IsOpen U
hU' : IsCompact U
hV : IsOpen V
hV' : IsCompact V
s : Set ↑(X.presheaf.obj (op ⊤))
hs : Set.Finite s
e : U = ⋃ i ∈ s, ↑(X.basicOpen i)
s' : Set ↑(X.presheaf.obj (op ⊤))
hs' : Set.Finite s'
e' : V = ⋃ i ∈ s', ↑(X.basicOpen i)
⊢ IsCompact (U ∩ V)

Next tactic:
rw [e, e', Set.iUnion₂_inter]
instance quasiSeparatedSpace_of_isAffine (X : Scheme) [IsAffine X] :
    QuasiSeparatedSpace X.carrier := by
  constructor
  intro U V hU hU' hV hV'
  obtain ⟨s, hs, e⟩ := (isCompact_open_iff_eq_basicOpen_union _).mp ⟨hU', hU⟩
  obtain ⟨s', hs', e'⟩ := (isCompact_open_iff_eq_basicOpen_union _).mp ⟨hV', hV⟩
  rw [e, e', Set.iUnion₂_inter]
  

Proof state:
case inter_isCompact.intro.intro.intro.intro
X✝ Y : Scheme
f : X✝ ⟶ Y
X : Scheme
inst✝ : IsAffine X
U V : Set ↑↑X.toPresheafedSpace
hU : IsOpen U
hU' : IsCompact U
hV : IsOpen V
hV' : IsCompact V
s : Set ↑(X.presheaf.obj (op ⊤))
hs : Set.Finite s
e : U = ⋃ i ∈ s, ↑(X.basicOpen i)
s' : Set ↑(X.presheaf.obj (op ⊤))
hs' : Set.Finite s'
e' : V = ⋃ i ∈ s', ↑(X.basicOpen i)
⊢ IsCompact (⋃ i ∈ s, ↑(X.basicOpen i) ∩ ⋃ i ∈ s', ↑(X.basicOpen i))

Next tactic:
simp_rw [Set.inter_iUnion₂]