l3lab/ntp-mathlib huggingface dataset:
theorem isCompact_basicOpen (X : Scheme) {U : Opens X.carrier} (hU : IsCompact (U : Set X.carrier))
    (f : X.presheaf.obj (op U)) : IsCompact (X.basicOpen f : Set X.carrier) := by
  classical
  

Proof state:
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact ↑U
f : ↑(X.presheaf.obj (op U))
⊢ IsCompact ↑(X.basicOpen f)

Next tactic:
refine' ((isCompact_open_iff_eq_finset_affine_union _).mpr _).1
theorem isCompact_basicOpen (X : Scheme) {U : Opens X.carrier} (hU : IsCompact (U : Set X.carrier))
    (f : X.presheaf.obj (op U)) : IsCompact (X.basicOpen f : Set X.carrier) := by
  classical
  refine' ((isCompact_open_iff_eq_finset_affine_union _).mpr _).1
  

Proof state:
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact ↑U
f : ↑(X.presheaf.obj (op U))
⊢ ∃ s, Set.Finite s ∧ ↑(X.basicOpen f) = ⋃ i ∈ s, ↑↑i

Next tactic:
obtain ⟨s, hs, e⟩ := (isCompact_open_iff_eq_finset_affine_union _).mp ⟨hU, U.isOpen⟩
theorem isCompact_basicOpen (X : Scheme) {U : Opens X.carrier} (hU : IsCompact (U : Set X.carrier))
    (f : X.presheaf.obj (op U)) : IsCompact (X.basicOpen f : Set X.carrier) := by
  classical
  refine' ((isCompact_open_iff_eq_finset_affine_union _).mpr _).1
  obtain ⟨s, hs, e⟩ := (isCompact_open_iff_eq_finset_affine_union _).mp ⟨hU, U.isOpen⟩
  

Proof state:
case intro.intro
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact ↑U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(Scheme.affineOpens X)
hs : Set.Finite s
e : ↑U = ⋃ i ∈ s, ↑↑i
⊢ ∃ s, Set.Finite s ∧ ↑(X.basicOpen f) = ⋃ i ∈ s, ↑↑i

Next tactic:
let g : s → X.affineOpens := by
    intro V
    use V.1 ⊓ X.basicOpen f
    have : V.1.1 ⟶ U := by
      apply homOfLE; change _ ⊆ (U : Set X.carrier); rw [e]
      convert @Set.subset_iUnion₂ _ _ _
        (fun (U : X.affineOpens) (_ : U ∈ s) => ↑U) V V.prop using 1
    erw [← X.toLocallyRingedSpace.toRingedSpace.basicOpen_res this.op]
    exact IsAffineOpen.basicOpenIsAffine V.1.prop _
theorem isCompact_basicOpen (X : Scheme) {U : Opens X.carrier} (hU : IsCompact (U : Set X.carrier))
    (f : X.presheaf.obj (op U)) : IsCompact (X.basicOpen f : Set X.carrier) := by
  classical
  refine' ((isCompact_open_iff_eq_finset_affine_union _).mpr _).1
  obtain ⟨s, hs, e⟩ := (isCompact_open_iff_eq_finset_affine_union _).mp ⟨hU, U.isOpen⟩
  let g : s → X.affineOpens := by
    

Proof state:
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact ↑U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(Scheme.affineOpens X)
hs : Set.Finite s
e : ↑U = ⋃ i ∈ s, ↑↑i
⊢ ↑s → ↑(Scheme.affineOpens X)

Next tactic:
intro V
theorem isCompact_basicOpen (X : Scheme) {U : Opens X.carrier} (hU : IsCompact (U : Set X.carrier))
    (f : X.presheaf.obj (op U)) : IsCompact (X.basicOpen f : Set X.carrier) := by
  classical
  refine' ((isCompact_open_iff_eq_finset_affine_union _).mpr _).1
  obtain ⟨s, hs, e⟩ := (isCompact_open_iff_eq_finset_affine_union _).mp ⟨hU, U.isOpen⟩
  let g : s → X.affineOpens := by
    intro V
    

Proof state:
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact ↑U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(Scheme.affineOpens X)
hs : Set.Finite s
e : ↑U = ⋃ i ∈ s, ↑↑i
V : ↑s
⊢ ↑(Scheme.affineOpens X)

Next tactic:
use V.1 ⊓ X.basicOpen f
theorem isCompact_basicOpen (X : Scheme) {U : Opens X.carrier} (hU : IsCompact (U : Set X.carrier))
    (f : X.presheaf.obj (op U)) : IsCompact (X.basicOpen f : Set X.carrier) := by
  classical
  refine' ((isCompact_open_iff_eq_finset_affine_union _).mpr _).1
  obtain ⟨s, hs, e⟩ := (isCompact_open_iff_eq_finset_affine_union _).mp ⟨hU, U.isOpen⟩
  let g : s → X.affineOpens := by
    intro V
    use V.1 ⊓ X.basicOpen f
    

Proof state:
case property
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact ↑U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(Scheme.affineOpens X)
hs : Set.Finite s
e : ↑U = ⋃ i ∈ s, ↑↑i
V : ↑s
⊢ ↑↑V ⊓ X.basicOpen f ∈ Scheme.affineOpens X

Next tactic:
have : V.1.1 ⟶ U := by
      apply homOfLE; change _ ⊆ (U : Set X.carrier); rw [e]
      convert @Set.subset_iUnion₂ _ _ _
        (fun (U : X.affineOpens) (_ : U ∈ s) => ↑U) V V.prop using 1
theorem isCompact_basicOpen (X : Scheme) {U : Opens X.carrier} (hU : IsCompact (U : Set X.carrier))
    (f : X.presheaf.obj (op U)) : IsCompact (X.basicOpen f : Set X.carrier) := by
  classical
  refine' ((isCompact_open_iff_eq_finset_affine_union _).mpr _).1
  obtain ⟨s, hs, e⟩ := (isCompact_open_iff_eq_finset_affine_union _).mp ⟨hU, U.isOpen⟩
  let g : s → X.affineOpens := by
    intro V
    use V.1 ⊓ X.basicOpen f
    have : V.1.1 ⟶ U := by
      

Proof state:
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact ↑U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(Scheme.affineOpens X)
hs : Set.Finite s
e : ↑U = ⋃ i ∈ s, ↑↑i
V : ↑s
⊢ ↑↑V ⟶ U

Next tactic:
apply homOfLE
theorem isCompact_basicOpen (X : Scheme) {U : Opens X.carrier} (hU : IsCompact (U : Set X.carrier))
    (f : X.presheaf.obj (op U)) : IsCompact (X.basicOpen f : Set X.carrier) := by
  classical
  refine' ((isCompact_open_iff_eq_finset_affine_union _).mpr _).1
  obtain ⟨s, hs, e⟩ := (isCompact_open_iff_eq_finset_affine_union _).mp ⟨hU, U.isOpen⟩
  let g : s → X.affineOpens := by
    intro V
    use V.1 ⊓ X.basicOpen f
    have : V.1.1 ⟶ U := by
      apply homOfLE; 

Proof state:
case h
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact ↑U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(Scheme.affineOpens X)
hs : Set.Finite s
e : ↑U = ⋃ i ∈ s, ↑↑i
V : ↑s
⊢ ↑↑V ≤ U

Next tactic:
change _ ⊆ (U : Set X.carrier)
theorem isCompact_basicOpen (X : Scheme) {U : Opens X.carrier} (hU : IsCompact (U : Set X.carrier))
    (f : X.presheaf.obj (op U)) : IsCompact (X.basicOpen f : Set X.carrier) := by
  classical
  refine' ((isCompact_open_iff_eq_finset_affine_union _).mpr _).1
  obtain ⟨s, hs, e⟩ := (isCompact_open_iff_eq_finset_affine_union _).mp ⟨hU, U.isOpen⟩
  let g : s → X.affineOpens := by
    intro V
    use V.1 ⊓ X.basicOpen f
    have : V.1.1 ⟶ U := by
      apply homOfLE; change _ ⊆ (U : Set X.carrier); 

Proof state:
case h
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact ↑U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(Scheme.affineOpens X)
hs : Set.Finite s
e : ↑U = ⋃ i ∈ s, ↑↑i
V : ↑s
⊢ ↑↑↑V ⊆ ↑U

Next tactic:
rw [e]
theorem isCompact_basicOpen (X : Scheme) {U : Opens X.carrier} (hU : IsCompact (U : Set X.carrier))
    (f : X.presheaf.obj (op U)) : IsCompact (X.basicOpen f : Set X.carrier) := by
  classical
  refine' ((isCompact_open_iff_eq_finset_affine_union _).mpr _).1
  obtain ⟨s, hs, e⟩ := (isCompact_open_iff_eq_finset_affine_union _).mp ⟨hU, U.isOpen⟩
  let g : s → X.affineOpens := by
    intro V
    use V.1 ⊓ X.basicOpen f
    have : V.1.1 ⟶ U := by
      apply homOfLE; change _ ⊆ (U : Set X.carrier); rw [e]
      

Proof state:
case h
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact ↑U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(Scheme.affineOpens X)
hs : Set.Finite s
e : ↑U = ⋃ i ∈ s, ↑↑i
V : ↑s
⊢ ↑↑↑V ⊆ ⋃ i ∈ s, ↑↑i

Next tactic:
convert @Set.subset_iUnion₂ _ _ _
        (fun (U : X.affineOpens) (_ : U ∈ s) => ↑U) V V.prop using 1
theorem isCompact_basicOpen (X : Scheme) {U : Opens X.carrier} (hU : IsCompact (U : Set X.carrier))
    (f : X.presheaf.obj (op U)) : IsCompact (X.basicOpen f : Set X.carrier) := by
  classical
  refine' ((isCompact_open_iff_eq_finset_affine_union _).mpr _).1
  obtain ⟨s, hs, e⟩ := (isCompact_open_iff_eq_finset_affine_union _).mp ⟨hU, U.isOpen⟩
  let g : s → X.affineOpens := by
    intro V
    use V.1 ⊓ X.basicOpen f
    have : V.1.1 ⟶ U := by
      apply homOfLE; change _ ⊆ (U : Set X.carrier); rw [e]
      convert @Set.subset_iUnion₂ _ _ _
        (fun (U : X.affineOpens) (_ : U ∈ s) => ↑U) V V.prop using 1
    

Proof state:
case property
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact ↑U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(Scheme.affineOpens X)
hs : Set.Finite s
e : ↑U = ⋃ i ∈ s, ↑↑i
V : ↑s
this : ↑↑V ⟶ U
⊢ ↑↑V ⊓ X.basicOpen f ∈ Scheme.affineOpens X

Next tactic:
erw [← X.toLocallyRingedSpace.toRingedSpace.basicOpen_res this.op]
theorem isCompact_basicOpen (X : Scheme) {U : Opens X.carrier} (hU : IsCompact (U : Set X.carrier))
    (f : X.presheaf.obj (op U)) : IsCompact (X.basicOpen f : Set X.carrier) := by
  classical
  refine' ((isCompact_open_iff_eq_finset_affine_union _).mpr _).1
  obtain ⟨s, hs, e⟩ := (isCompact_open_iff_eq_finset_affine_union _).mp ⟨hU, U.isOpen⟩
  let g : s → X.affineOpens := by
    intro V
    use V.1 ⊓ X.basicOpen f
    have : V.1.1 ⟶ U := by
      apply homOfLE; change _ ⊆ (U : Set X.carrier); rw [e]
      convert @Set.subset_iUnion₂ _ _ _
        (fun (U : X.affineOpens) (_ : U ∈ s) => ↑U) V V.prop using 1
    erw [← X.toLocallyRingedSpace.toRingedSpace.basicOpen_res this.op]
    

Proof state:
case property
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact ↑U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(Scheme.affineOpens X)
hs : Set.Finite s
e : ↑U = ⋃ i ∈ s, ↑↑i
V : ↑s
this : ↑↑V ⟶ U
⊢ RingedSpace.basicOpen (LocallyRingedSpace.toRingedSpace X.toLocallyRingedSpace)
      (((LocallyRingedSpace.toRingedSpace X.toLocallyRingedSpace).toPresheafedSpace.presheaf.map this.op) f) ∈
    Scheme.affineOpens X

Next tactic:
exact IsAffineOpen.basicOpenIsAffine V.1.prop _
theorem isCompact_basicOpen (X : Scheme) {U : Opens X.carrier} (hU : IsCompact (U : Set X.carrier))
    (f : X.presheaf.obj (op U)) : IsCompact (X.basicOpen f : Set X.carrier) := by
  classical
  refine' ((isCompact_open_iff_eq_finset_affine_union _).mpr _).1
  obtain ⟨s, hs, e⟩ := (isCompact_open_iff_eq_finset_affine_union _).mp ⟨hU, U.isOpen⟩
  let g : s → X.affineOpens := by
    intro V
    use V.1 ⊓ X.basicOpen f
    have : V.1.1 ⟶ U := by
      apply homOfLE; change _ ⊆ (U : Set X.carrier); rw [e]
      convert @Set.subset_iUnion₂ _ _ _
        (fun (U : X.affineOpens) (_ : U ∈ s) => ↑U) V V.prop using 1
    erw [← X.toLocallyRingedSpace.toRingedSpace.basicOpen_res this.op]
    exact IsAffineOpen.basicOpenIsAffine V.1.prop _
  

Proof state:
case intro.intro
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact ↑U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(Scheme.affineOpens X)
hs : Set.Finite s
e : ↑U = ⋃ i ∈ s, ↑↑i
g : ↑s → ↑(Scheme.affineOpens X) :=
  fun V => { val := ↑↑V ⊓ X.basicOpen f, property := (_ : ↑↑V ⊓ X.basicOpen f ∈ Scheme.affineOpens X) }
⊢ ∃ s, Set.Finite s ∧ ↑(X.basicOpen f) = ⋃ i ∈ s, ↑↑i

Next tactic:
haveI : Finite s := hs.to_subtype
theorem isCompact_basicOpen (X : Scheme) {U : Opens X.carrier} (hU : IsCompact (U : Set X.carrier))
    (f : X.presheaf.obj (op U)) : IsCompact (X.basicOpen f : Set X.carrier) := by
  classical
  refine' ((isCompact_open_iff_eq_finset_affine_union _).mpr _).1
  obtain ⟨s, hs, e⟩ := (isCompact_open_iff_eq_finset_affine_union _).mp ⟨hU, U.isOpen⟩
  let g : s → X.affineOpens := by
    intro V
    use V.1 ⊓ X.basicOpen f
    have : V.1.1 ⟶ U := by
      apply homOfLE; change _ ⊆ (U : Set X.carrier); rw [e]
      convert @Set.subset_iUnion₂ _ _ _
        (fun (U : X.affineOpens) (_ : U ∈ s) => ↑U) V V.prop using 1
    erw [← X.toLocallyRingedSpace.toRingedSpace.basicOpen_res this.op]
    exact IsAffineOpen.basicOpenIsAffine V.1.prop _
  haveI : Finite s := hs.to_subtype
  

Proof state:
case intro.intro
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact ↑U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(Scheme.affineOpens X)
hs : Set.Finite s
e : ↑U = ⋃ i ∈ s, ↑↑i
g : ↑s → ↑(Scheme.affineOpens X) :=
  fun V => { val := ↑↑V ⊓ X.basicOpen f, property := (_ : ↑↑V ⊓ X.basicOpen f ∈ Scheme.affineOpens X) }
this : Finite ↑s
⊢ ∃ s, Set.Finite s ∧ ↑(X.basicOpen f) = ⋃ i ∈ s, ↑↑i

Next tactic:
refine' ⟨Set.range g, Set.finite_range g, _⟩
theorem isCompact_basicOpen (X : Scheme) {U : Opens X.carrier} (hU : IsCompact (U : Set X.carrier))
    (f : X.presheaf.obj (op U)) : IsCompact (X.basicOpen f : Set X.carrier) := by
  classical
  refine' ((isCompact_open_iff_eq_finset_affine_union _).mpr _).1
  obtain ⟨s, hs, e⟩ := (isCompact_open_iff_eq_finset_affine_union _).mp ⟨hU, U.isOpen⟩
  let g : s → X.affineOpens := by
    intro V
    use V.1 ⊓ X.basicOpen f
    have : V.1.1 ⟶ U := by
      apply homOfLE; change _ ⊆ (U : Set X.carrier); rw [e]
      convert @Set.subset_iUnion₂ _ _ _
        (fun (U : X.affineOpens) (_ : U ∈ s) => ↑U) V V.prop using 1
    erw [← X.toLocallyRingedSpace.toRingedSpace.basicOpen_res this.op]
    exact IsAffineOpen.basicOpenIsAffine V.1.prop _
  haveI : Finite s := hs.to_subtype
  refine' ⟨Set.range g, Set.finite_range g, _⟩
  

Proof state:
case intro.intro
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact ↑U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(Scheme.affineOpens X)
hs : Set.Finite s
e : ↑U = ⋃ i ∈ s, ↑↑i
g : ↑s → ↑(Scheme.affineOpens X) :=
  fun V => { val := ↑↑V ⊓ X.basicOpen f, property := (_ : ↑↑V ⊓ X.basicOpen f ∈ Scheme.affineOpens X) }
this : Finite ↑s
⊢ ↑(X.basicOpen f) = ⋃ i ∈ Set.range g, ↑↑i

Next tactic:
refine' (Set.inter_eq_right.mpr
            (SetLike.coe_subset_coe.2 <| RingedSpace.basicOpen_le _ _)).symm.trans _
theorem isCompact_basicOpen (X : Scheme) {U : Opens X.carrier} (hU : IsCompact (U : Set X.carrier))
    (f : X.presheaf.obj (op U)) : IsCompact (X.basicOpen f : Set X.carrier) := by
  classical
  refine' ((isCompact_open_iff_eq_finset_affine_union _).mpr _).1
  obtain ⟨s, hs, e⟩ := (isCompact_open_iff_eq_finset_affine_union _).mp ⟨hU, U.isOpen⟩
  let g : s → X.affineOpens := by
    intro V
    use V.1 ⊓ X.basicOpen f
    have : V.1.1 ⟶ U := by
      apply homOfLE; change _ ⊆ (U : Set X.carrier); rw [e]
      convert @Set.subset_iUnion₂ _ _ _
        (fun (U : X.affineOpens) (_ : U ∈ s) => ↑U) V V.prop using 1
    erw [← X.toLocallyRingedSpace.toRingedSpace.basicOpen_res this.op]
    exact IsAffineOpen.basicOpenIsAffine V.1.prop _
  haveI : Finite s := hs.to_subtype
  refine' ⟨Set.range g, Set.finite_range g, _⟩
  refine' (Set.inter_eq_right.mpr
            (SetLike.coe_subset_coe.2 <| RingedSpace.basicOpen_le _ _)).symm.trans _
  

Proof state:
case intro.intro
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact ↑U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(Scheme.affineOpens X)
hs : Set.Finite s
e : ↑U = ⋃ i ∈ s, ↑↑i
g : ↑s → ↑(Scheme.affineOpens X) :=
  fun V => { val := ↑↑V ⊓ X.basicOpen f, property := (_ : ↑↑V ⊓ X.basicOpen f ∈ Scheme.affineOpens X) }
this : Finite ↑s
⊢ ↑U ∩ ↑(RingedSpace.basicOpen (LocallyRingedSpace.toRingedSpace X.toLocallyRingedSpace) f) = ⋃ i ∈ Set.range g, ↑↑i

Next tactic:
rw [e, Set.iUnion₂_inter]
theorem isCompact_basicOpen (X : Scheme) {U : Opens X.carrier} (hU : IsCompact (U : Set X.carrier))
    (f : X.presheaf.obj (op U)) : IsCompact (X.basicOpen f : Set X.carrier) := by
  classical
  refine' ((isCompact_open_iff_eq_finset_affine_union _).mpr _).1
  obtain ⟨s, hs, e⟩ := (isCompact_open_iff_eq_finset_affine_union _).mp ⟨hU, U.isOpen⟩
  let g : s → X.affineOpens := by
    intro V
    use V.1 ⊓ X.basicOpen f
    have : V.1.1 ⟶ U := by
      apply homOfLE; change _ ⊆ (U : Set X.carrier); rw [e]
      convert @Set.subset_iUnion₂ _ _ _
        (fun (U : X.affineOpens) (_ : U ∈ s) => ↑U) V V.prop using 1
    erw [← X.toLocallyRingedSpace.toRingedSpace.basicOpen_res this.op]
    exact IsAffineOpen.basicOpenIsAffine V.1.prop _
  haveI : Finite s := hs.to_subtype
  refine' ⟨Set.range g, Set.finite_range g, _⟩
  refine' (Set.inter_eq_right.mpr
            (SetLike.coe_subset_coe.2 <| RingedSpace.basicOpen_le _ _)).symm.trans _
  rw [e, Set.iUnion₂_inter]
  

Proof state:
case intro.intro
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact ↑U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(Scheme.affineOpens X)
hs : Set.Finite s
e : ↑U = ⋃ i ∈ s, ↑↑i
g : ↑s → ↑(Scheme.affineOpens X) :=
  fun V => { val := ↑↑V ⊓ X.basicOpen f, property := (_ : ↑↑V ⊓ X.basicOpen f ∈ Scheme.affineOpens X) }
this : Finite ↑s
⊢ ⋃ i ∈ s, ↑↑i ∩ ↑(RingedSpace.basicOpen (LocallyRingedSpace.toRingedSpace X.toLocallyRingedSpace) f) =
    ⋃ i ∈ Set.range g, ↑↑i

Next tactic:
apply le_antisymm
theorem isCompact_basicOpen (X : Scheme) {U : Opens X.carrier} (hU : IsCompact (U : Set X.carrier))
    (f : X.presheaf.obj (op U)) : IsCompact (X.basicOpen f : Set X.carrier) := by
  classical
  refine' ((isCompact_open_iff_eq_finset_affine_union _).mpr _).1
  obtain ⟨s, hs, e⟩ := (isCompact_open_iff_eq_finset_affine_union _).mp ⟨hU, U.isOpen⟩
  let g : s → X.affineOpens := by
    intro V
    use V.1 ⊓ X.basicOpen f
    have : V.1.1 ⟶ U := by
      apply homOfLE; change _ ⊆ (U : Set X.carrier); rw [e]
      convert @Set.subset_iUnion₂ _ _ _
        (fun (U : X.affineOpens) (_ : U ∈ s) => ↑U) V V.prop using 1
    erw [← X.toLocallyRingedSpace.toRingedSpace.basicOpen_res this.op]
    exact IsAffineOpen.basicOpenIsAffine V.1.prop _
  haveI : Finite s := hs.to_subtype
  refine' ⟨Set.range g, Set.finite_range g, _⟩
  refine' (Set.inter_eq_right.mpr
            (SetLike.coe_subset_coe.2 <| RingedSpace.basicOpen_le _ _)).symm.trans _
  rw [e, Set.iUnion₂_inter]
  apply le_antisymm <;> 

Proof state:
case intro.intro.a
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact ↑U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(Scheme.affineOpens X)
hs : Set.Finite s
e : ↑U = ⋃ i ∈ s, ↑↑i
g : ↑s → ↑(Scheme.affineOpens X) :=
  fun V => { val := ↑↑V ⊓ X.basicOpen f, property := (_ : ↑↑V ⊓ X.basicOpen f ∈ Scheme.affineOpens X) }
this : Finite ↑s
⊢ ⋃ i ∈ s, ↑↑i ∩ ↑(RingedSpace.basicOpen (LocallyRingedSpace.toRingedSpace X.toLocallyRingedSpace) f) ≤
    ⋃ i ∈ Set.range g, ↑↑i

Next tactic:
apply Set.iUnion₂_subset
theorem isCompact_basicOpen (X : Scheme) {U : Opens X.carrier} (hU : IsCompact (U : Set X.carrier))
    (f : X.presheaf.obj (op U)) : IsCompact (X.basicOpen f : Set X.carrier) := by
  classical
  refine' ((isCompact_open_iff_eq_finset_affine_union _).mpr _).1
  obtain ⟨s, hs, e⟩ := (isCompact_open_iff_eq_finset_affine_union _).mp ⟨hU, U.isOpen⟩
  let g : s → X.affineOpens := by
    intro V
    use V.1 ⊓ X.basicOpen f
    have : V.1.1 ⟶ U := by
      apply homOfLE; change _ ⊆ (U : Set X.carrier); rw [e]
      convert @Set.subset_iUnion₂ _ _ _
        (fun (U : X.affineOpens) (_ : U ∈ s) => ↑U) V V.prop using 1
    erw [← X.toLocallyRingedSpace.toRingedSpace.basicOpen_res this.op]
    exact IsAffineOpen.basicOpenIsAffine V.1.prop _
  haveI : Finite s := hs.to_subtype
  refine' ⟨Set.range g, Set.finite_range g, _⟩
  refine' (Set.inter_eq_right.mpr
            (SetLike.coe_subset_coe.2 <| RingedSpace.basicOpen_le _ _)).symm.trans _
  rw [e, Set.iUnion₂_inter]
  apply le_antisymm <;> 

Proof state:
case intro.intro.a
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact ↑U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(Scheme.affineOpens X)
hs : Set.Finite s
e : ↑U = ⋃ i ∈ s, ↑↑i
g : ↑s → ↑(Scheme.affineOpens X) :=
  fun V => { val := ↑↑V ⊓ X.basicOpen f, property := (_ : ↑↑V ⊓ X.basicOpen f ∈ Scheme.affineOpens X) }
this : Finite ↑s
⊢ ⋃ i ∈ Set.range g, ↑↑i ≤
    ⋃ i ∈ s, ↑↑i ∩ ↑(RingedSpace.basicOpen (LocallyRingedSpace.toRingedSpace X.toLocallyRingedSpace) f)

Next tactic:
apply Set.iUnion₂_subset
theorem isCompact_basicOpen (X : Scheme) {U : Opens X.carrier} (hU : IsCompact (U : Set X.carrier))
    (f : X.presheaf.obj (op U)) : IsCompact (X.basicOpen f : Set X.carrier) := by
  classical
  refine' ((isCompact_open_iff_eq_finset_affine_union _).mpr _).1
  obtain ⟨s, hs, e⟩ := (isCompact_open_iff_eq_finset_affine_union _).mp ⟨hU, U.isOpen⟩
  let g : s → X.affineOpens := by
    intro V
    use V.1 ⊓ X.basicOpen f
    have : V.1.1 ⟶ U := by
      apply homOfLE; change _ ⊆ (U : Set X.carrier); rw [e]
      convert @Set.subset_iUnion₂ _ _ _
        (fun (U : X.affineOpens) (_ : U ∈ s) => ↑U) V V.prop using 1
    erw [← X.toLocallyRingedSpace.toRingedSpace.basicOpen_res this.op]
    exact IsAffineOpen.basicOpenIsAffine V.1.prop _
  haveI : Finite s := hs.to_subtype
  refine' ⟨Set.range g, Set.finite_range g, _⟩
  refine' (Set.inter_eq_right.mpr
            (SetLike.coe_subset_coe.2 <| RingedSpace.basicOpen_le _ _)).symm.trans _
  rw [e, Set.iUnion₂_inter]
  apply le_antisymm <;> apply Set.iUnion₂_subset
  · 

Proof state:
case intro.intro.a.h
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact ↑U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(Scheme.affineOpens X)
hs : Set.Finite s
e : ↑U = ⋃ i ∈ s, ↑↑i
g : ↑s → ↑(Scheme.affineOpens X) :=
  fun V => { val := ↑↑V ⊓ X.basicOpen f, property := (_ : ↑↑V ⊓ X.basicOpen f ∈ Scheme.affineOpens X) }
this : Finite ↑s
⊢ ∀ i ∈ s,
    ↑↑i ∩ ↑(RingedSpace.basicOpen (LocallyRingedSpace.toRingedSpace X.toLocallyRingedSpace) f) ⊆ ⋃ i ∈ Set.range g, ↑↑i

Next tactic:
intro i hi
theorem isCompact_basicOpen (X : Scheme) {U : Opens X.carrier} (hU : IsCompact (U : Set X.carrier))
    (f : X.presheaf.obj (op U)) : IsCompact (X.basicOpen f : Set X.carrier) := by
  classical
  refine' ((isCompact_open_iff_eq_finset_affine_union _).mpr _).1
  obtain ⟨s, hs, e⟩ := (isCompact_open_iff_eq_finset_affine_union _).mp ⟨hU, U.isOpen⟩
  let g : s → X.affineOpens := by
    intro V
    use V.1 ⊓ X.basicOpen f
    have : V.1.1 ⟶ U := by
      apply homOfLE; change _ ⊆ (U : Set X.carrier); rw [e]
      convert @Set.subset_iUnion₂ _ _ _
        (fun (U : X.affineOpens) (_ : U ∈ s) => ↑U) V V.prop using 1
    erw [← X.toLocallyRingedSpace.toRingedSpace.basicOpen_res this.op]
    exact IsAffineOpen.basicOpenIsAffine V.1.prop _
  haveI : Finite s := hs.to_subtype
  refine' ⟨Set.range g, Set.finite_range g, _⟩
  refine' (Set.inter_eq_right.mpr
            (SetLike.coe_subset_coe.2 <| RingedSpace.basicOpen_le _ _)).symm.trans _
  rw [e, Set.iUnion₂_inter]
  apply le_antisymm <;> apply Set.iUnion₂_subset
  · intro i hi
    -- porting note: had to make explicit the first given parameter to `Set.subset_iUnion₂`
    

Proof state:
case intro.intro.a.h
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact ↑U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(Scheme.affineOpens X)
hs : Set.Finite s
e : ↑U = ⋃ i ∈ s, ↑↑i
g : ↑s → ↑(Scheme.affineOpens X) :=
  fun V => { val := ↑↑V ⊓ X.basicOpen f, property := (_ : ↑↑V ⊓ X.basicOpen f ∈ Scheme.affineOpens X) }
this : Finite ↑s
i : ↑(Scheme.affineOpens X)
hi : i ∈ s
⊢ ↑↑i ∩ ↑(RingedSpace.basicOpen (LocallyRingedSpace.toRingedSpace X.toLocallyRingedSpace) f) ⊆ ⋃ i ∈ Set.range g, ↑↑i

Next tactic:
exact Set.Subset.trans (Set.Subset.rfl : _ ≤ g ⟨i, hi⟩)
      (@Set.subset_iUnion₂ _ _ _
        (fun (i : Scheme.affineOpens X) (_ : i ∈ Set.range g) => (i : Set X.toPresheafedSpace)) _
        (Set.mem_range_self ⟨i, hi⟩))