l3lab/ntp-mathlib huggingface dataset:
theorem basicOpen_union_eq_self_iff (s : Set (X.presheaf.obj <| op U)) :
    ⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U) = U ↔ Ideal.span s = ⊤ := by
  trans ⋃ i : s, (PrimeSpectrum.basicOpen i.1).1 = Set.univ
  trans
    hU.fromSpec.1.base ⁻¹' (⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U)).1 =
      hU.fromSpec.1.base ⁻¹' U.1
  · refine' ⟨fun h => by rw [h], _⟩
    intro h
    

Proof state:
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(X.presheaf.obj (op U))
h : ⇑(fromSpec hU).val.base ⁻¹' (⨆ f, X.basicOpen ↑f).carrier = ⇑(fromSpec hU).val.base ⁻¹' U.carrier
⊢ ⨆ f, X.basicOpen ↑f = U

Next tactic:
apply_fun Set.image hU.fromSpec.1.base at h
theorem basicOpen_union_eq_self_iff (s : Set (X.presheaf.obj <| op U)) :
    ⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U) = U ↔ Ideal.span s = ⊤ := by
  trans ⋃ i : s, (PrimeSpectrum.basicOpen i.1).1 = Set.univ
  trans
    hU.fromSpec.1.base ⁻¹' (⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U)).1 =
      hU.fromSpec.1.base ⁻¹' U.1
  · refine' ⟨fun h => by rw [h], _⟩
    intro h
    apply_fun Set.image hU.fromSpec.1.base at h
    

Proof state:
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(X.presheaf.obj (op U))
h :
  ⇑(fromSpec hU).val.base '' (⇑(fromSpec hU).val.base ⁻¹' (⨆ f, X.basicOpen ↑f).carrier) =
    ⇑(fromSpec hU).val.base '' (⇑(fromSpec hU).val.base ⁻¹' U.carrier)
⊢ ⨆ f, X.basicOpen ↑f = U

Next tactic:
rw [Set.image_preimage_eq_inter_range, Set.image_preimage_eq_inter_range, hU.fromSpec_range]
      at h
theorem basicOpen_union_eq_self_iff (s : Set (X.presheaf.obj <| op U)) :
    ⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U) = U ↔ Ideal.span s = ⊤ := by
  trans ⋃ i : s, (PrimeSpectrum.basicOpen i.1).1 = Set.univ
  trans
    hU.fromSpec.1.base ⁻¹' (⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U)).1 =
      hU.fromSpec.1.base ⁻¹' U.1
  · refine' ⟨fun h => by rw [h], _⟩
    intro h
    apply_fun Set.image hU.fromSpec.1.base at h
    rw [Set.image_preimage_eq_inter_range, Set.image_preimage_eq_inter_range, hU.fromSpec_range]
      at h
    

Proof state:
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(X.presheaf.obj (op U))
h : (⨆ f, X.basicOpen ↑f).carrier ∩ ↑U = U.carrier ∩ ↑U
⊢ ⨆ f, X.basicOpen ↑f = U

Next tactic:
simp only [Set.inter_self, Opens.carrier_eq_coe, Set.inter_eq_right] at h
theorem basicOpen_union_eq_self_iff (s : Set (X.presheaf.obj <| op U)) :
    ⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U) = U ↔ Ideal.span s = ⊤ := by
  trans ⋃ i : s, (PrimeSpectrum.basicOpen i.1).1 = Set.univ
  trans
    hU.fromSpec.1.base ⁻¹' (⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U)).1 =
      hU.fromSpec.1.base ⁻¹' U.1
  · refine' ⟨fun h => by rw [h], _⟩
    intro h
    apply_fun Set.image hU.fromSpec.1.base at h
    rw [Set.image_preimage_eq_inter_range, Set.image_preimage_eq_inter_range, hU.fromSpec_range]
      at h
    simp only [Set.inter_self, Opens.carrier_eq_coe, Set.inter_eq_right] at h
    

Proof state:
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(X.presheaf.obj (op U))
h : ↑U ⊆ ↑(⨆ f, X.basicOpen ↑f)
⊢ ⨆ f, X.basicOpen ↑f = U

Next tactic:
ext1
theorem basicOpen_union_eq_self_iff (s : Set (X.presheaf.obj <| op U)) :
    ⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U) = U ↔ Ideal.span s = ⊤ := by
  trans ⋃ i : s, (PrimeSpectrum.basicOpen i.1).1 = Set.univ
  trans
    hU.fromSpec.1.base ⁻¹' (⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U)).1 =
      hU.fromSpec.1.base ⁻¹' U.1
  · refine' ⟨fun h => by rw [h], _⟩
    intro h
    apply_fun Set.image hU.fromSpec.1.base at h
    rw [Set.image_preimage_eq_inter_range, Set.image_preimage_eq_inter_range, hU.fromSpec_range]
      at h
    simp only [Set.inter_self, Opens.carrier_eq_coe, Set.inter_eq_right] at h
    ext1
    

Proof state:
case h
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(X.presheaf.obj (op U))
h : ↑U ⊆ ↑(⨆ f, X.basicOpen ↑f)
⊢ ↑(⨆ f, X.basicOpen ↑f) = ↑U

Next tactic:
refine' Set.Subset.antisymm _ h
theorem basicOpen_union_eq_self_iff (s : Set (X.presheaf.obj <| op U)) :
    ⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U) = U ↔ Ideal.span s = ⊤ := by
  trans ⋃ i : s, (PrimeSpectrum.basicOpen i.1).1 = Set.univ
  trans
    hU.fromSpec.1.base ⁻¹' (⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U)).1 =
      hU.fromSpec.1.base ⁻¹' U.1
  · refine' ⟨fun h => by rw [h], _⟩
    intro h
    apply_fun Set.image hU.fromSpec.1.base at h
    rw [Set.image_preimage_eq_inter_range, Set.image_preimage_eq_inter_range, hU.fromSpec_range]
      at h
    simp only [Set.inter_self, Opens.carrier_eq_coe, Set.inter_eq_right] at h
    ext1
    refine' Set.Subset.antisymm _ h
    

Proof state:
case h
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(X.presheaf.obj (op U))
h : ↑U ⊆ ↑(⨆ f, X.basicOpen ↑f)
⊢ ↑(⨆ f, X.basicOpen ↑f) ⊆ ↑U

Next tactic:
simp only [Set.iUnion_subset_iff, SetCoe.forall, Opens.coe_iSup]
theorem basicOpen_union_eq_self_iff (s : Set (X.presheaf.obj <| op U)) :
    ⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U) = U ↔ Ideal.span s = ⊤ := by
  trans ⋃ i : s, (PrimeSpectrum.basicOpen i.1).1 = Set.univ
  trans
    hU.fromSpec.1.base ⁻¹' (⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U)).1 =
      hU.fromSpec.1.base ⁻¹' U.1
  · refine' ⟨fun h => by rw [h], _⟩
    intro h
    apply_fun Set.image hU.fromSpec.1.base at h
    rw [Set.image_preimage_eq_inter_range, Set.image_preimage_eq_inter_range, hU.fromSpec_range]
      at h
    simp only [Set.inter_self, Opens.carrier_eq_coe, Set.inter_eq_right] at h
    ext1
    refine' Set.Subset.antisymm _ h
    simp only [Set.iUnion_subset_iff, SetCoe.forall, Opens.coe_iSup]
    

Proof state:
case h
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(X.presheaf.obj (op U))
h : ↑U ⊆ ↑(⨆ f, X.basicOpen ↑f)
⊢ ∀ x ∈ s, ↑(X.basicOpen x) ⊆ ↑U

Next tactic:
intro x _
theorem basicOpen_union_eq_self_iff (s : Set (X.presheaf.obj <| op U)) :
    ⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U) = U ↔ Ideal.span s = ⊤ := by
  trans ⋃ i : s, (PrimeSpectrum.basicOpen i.1).1 = Set.univ
  trans
    hU.fromSpec.1.base ⁻¹' (⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U)).1 =
      hU.fromSpec.1.base ⁻¹' U.1
  · refine' ⟨fun h => by rw [h], _⟩
    intro h
    apply_fun Set.image hU.fromSpec.1.base at h
    rw [Set.image_preimage_eq_inter_range, Set.image_preimage_eq_inter_range, hU.fromSpec_range]
      at h
    simp only [Set.inter_self, Opens.carrier_eq_coe, Set.inter_eq_right] at h
    ext1
    refine' Set.Subset.antisymm _ h
    simp only [Set.iUnion_subset_iff, SetCoe.forall, Opens.coe_iSup]
    intro x _
    

Proof state:
case h
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(X.presheaf.obj (op U))
h : ↑U ⊆ ↑(⨆ f, X.basicOpen ↑f)
x : ↑(X.presheaf.obj (op U))
h✝ : x ∈ s
⊢ ↑(X.basicOpen x) ⊆ ↑U

Next tactic:
exact X.basicOpen_le x
theorem basicOpen_union_eq_self_iff (s : Set (X.presheaf.obj <| op U)) :
    ⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U) = U ↔ Ideal.span s = ⊤ := by
  trans ⋃ i : s, (PrimeSpectrum.basicOpen i.1).1 = Set.univ
  trans
    hU.fromSpec.1.base ⁻¹' (⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U)).1 =
      hU.fromSpec.1.base ⁻¹' U.1
  · refine' ⟨fun h => by rw [h], _⟩
    intro h
    apply_fun Set.image hU.fromSpec.1.base at h
    rw [Set.image_preimage_eq_inter_range, Set.image_preimage_eq_inter_range, hU.fromSpec_range]
      at h
    simp only [Set.inter_self, Opens.carrier_eq_coe, Set.inter_eq_right] at h
    ext1
    refine' Set.Subset.antisymm _ h
    simp only [Set.iUnion_subset_iff, SetCoe.forall, Opens.coe_iSup]
    intro x _
    exact X.basicOpen_le x
  · 

Proof state:
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(X.presheaf.obj (op U))
⊢ ⇑(fromSpec hU).val.base ⁻¹' (⨆ f, X.basicOpen ↑f).carrier = ⇑(fromSpec hU).val.base ⁻¹' U.carrier ↔
    ⋃ i, (PrimeSpectrum.basicOpen ↑i).carrier = Set.univ

Next tactic:
simp only [Opens.iSup_def, Subtype.coe_mk, Set.preimage_iUnion]
theorem basicOpen_union_eq_self_iff (s : Set (X.presheaf.obj <| op U)) :
    ⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U) = U ↔ Ideal.span s = ⊤ := by
  trans ⋃ i : s, (PrimeSpectrum.basicOpen i.1).1 = Set.univ
  trans
    hU.fromSpec.1.base ⁻¹' (⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U)).1 =
      hU.fromSpec.1.base ⁻¹' U.1
  · refine' ⟨fun h => by rw [h], _⟩
    intro h
    apply_fun Set.image hU.fromSpec.1.base at h
    rw [Set.image_preimage_eq_inter_range, Set.image_preimage_eq_inter_range, hU.fromSpec_range]
      at h
    simp only [Set.inter_self, Opens.carrier_eq_coe, Set.inter_eq_right] at h
    ext1
    refine' Set.Subset.antisymm _ h
    simp only [Set.iUnion_subset_iff, SetCoe.forall, Opens.coe_iSup]
    intro x _
    exact X.basicOpen_le x
  · simp only [Opens.iSup_def, Subtype.coe_mk, Set.preimage_iUnion]
    -- Porting note : need an extra rewrite here, after simp, it is in `↔` form
    

Proof state:
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(X.presheaf.obj (op U))
⊢ ⋃ i, ⇑(fromSpec hU).val.base ⁻¹' ↑(X.basicOpen ↑i) = ⇑(fromSpec hU).val.base ⁻¹' U.carrier ↔
    ⋃ i, (PrimeSpectrum.basicOpen ↑i).carrier = Set.univ

Next tactic:
rw [iff_iff_eq]
theorem basicOpen_union_eq_self_iff (s : Set (X.presheaf.obj <| op U)) :
    ⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U) = U ↔ Ideal.span s = ⊤ := by
  trans ⋃ i : s, (PrimeSpectrum.basicOpen i.1).1 = Set.univ
  trans
    hU.fromSpec.1.base ⁻¹' (⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U)).1 =
      hU.fromSpec.1.base ⁻¹' U.1
  · refine' ⟨fun h => by rw [h], _⟩
    intro h
    apply_fun Set.image hU.fromSpec.1.base at h
    rw [Set.image_preimage_eq_inter_range, Set.image_preimage_eq_inter_range, hU.fromSpec_range]
      at h
    simp only [Set.inter_self, Opens.carrier_eq_coe, Set.inter_eq_right] at h
    ext1
    refine' Set.Subset.antisymm _ h
    simp only [Set.iUnion_subset_iff, SetCoe.forall, Opens.coe_iSup]
    intro x _
    exact X.basicOpen_le x
  · simp only [Opens.iSup_def, Subtype.coe_mk, Set.preimage_iUnion]
    -- Porting note : need an extra rewrite here, after simp, it is in `↔` form
    rw [iff_iff_eq]
    

Proof state:
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(X.presheaf.obj (op U))
⊢ (⋃ i, ⇑(fromSpec hU).val.base ⁻¹' ↑(X.basicOpen ↑i) = ⇑(fromSpec hU).val.base ⁻¹' U.carrier) =
    (⋃ i, (PrimeSpectrum.basicOpen ↑i).carrier = Set.univ)

Next tactic:
congr 3
theorem basicOpen_union_eq_self_iff (s : Set (X.presheaf.obj <| op U)) :
    ⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U) = U ↔ Ideal.span s = ⊤ := by
  trans ⋃ i : s, (PrimeSpectrum.basicOpen i.1).1 = Set.univ
  trans
    hU.fromSpec.1.base ⁻¹' (⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U)).1 =
      hU.fromSpec.1.base ⁻¹' U.1
  · refine' ⟨fun h => by rw [h], _⟩
    intro h
    apply_fun Set.image hU.fromSpec.1.base at h
    rw [Set.image_preimage_eq_inter_range, Set.image_preimage_eq_inter_range, hU.fromSpec_range]
      at h
    simp only [Set.inter_self, Opens.carrier_eq_coe, Set.inter_eq_right] at h
    ext1
    refine' Set.Subset.antisymm _ h
    simp only [Set.iUnion_subset_iff, SetCoe.forall, Opens.coe_iSup]
    intro x _
    exact X.basicOpen_le x
  · simp only [Opens.iSup_def, Subtype.coe_mk, Set.preimage_iUnion]
    -- Porting note : need an extra rewrite here, after simp, it is in `↔` form
    rw [iff_iff_eq]
    congr 3
    · 

Proof state:
case e_a
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(X.presheaf.obj (op U))
⊢ ⋃ i, ⇑(fromSpec hU).val.base ⁻¹' ↑(X.basicOpen ↑i) = ⋃ i, (PrimeSpectrum.basicOpen ↑i).carrier

Next tactic:
refine congr_arg (Set.iUnion ·) ?_
theorem basicOpen_union_eq_self_iff (s : Set (X.presheaf.obj <| op U)) :
    ⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U) = U ↔ Ideal.span s = ⊤ := by
  trans ⋃ i : s, (PrimeSpectrum.basicOpen i.1).1 = Set.univ
  trans
    hU.fromSpec.1.base ⁻¹' (⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U)).1 =
      hU.fromSpec.1.base ⁻¹' U.1
  · refine' ⟨fun h => by rw [h], _⟩
    intro h
    apply_fun Set.image hU.fromSpec.1.base at h
    rw [Set.image_preimage_eq_inter_range, Set.image_preimage_eq_inter_range, hU.fromSpec_range]
      at h
    simp only [Set.inter_self, Opens.carrier_eq_coe, Set.inter_eq_right] at h
    ext1
    refine' Set.Subset.antisymm _ h
    simp only [Set.iUnion_subset_iff, SetCoe.forall, Opens.coe_iSup]
    intro x _
    exact X.basicOpen_le x
  · simp only [Opens.iSup_def, Subtype.coe_mk, Set.preimage_iUnion]
    -- Porting note : need an extra rewrite here, after simp, it is in `↔` form
    rw [iff_iff_eq]
    congr 3
    · refine congr_arg (Set.iUnion ·) ?_
      

Proof state:
case e_a
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(X.presheaf.obj (op U))
⊢ (fun i => ⇑(fromSpec hU).val.base ⁻¹' ↑(X.basicOpen ↑i)) = fun i => (PrimeSpectrum.basicOpen ↑i).carrier

Next tactic:
ext1 x
theorem basicOpen_union_eq_self_iff (s : Set (X.presheaf.obj <| op U)) :
    ⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U) = U ↔ Ideal.span s = ⊤ := by
  trans ⋃ i : s, (PrimeSpectrum.basicOpen i.1).1 = Set.univ
  trans
    hU.fromSpec.1.base ⁻¹' (⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U)).1 =
      hU.fromSpec.1.base ⁻¹' U.1
  · refine' ⟨fun h => by rw [h], _⟩
    intro h
    apply_fun Set.image hU.fromSpec.1.base at h
    rw [Set.image_preimage_eq_inter_range, Set.image_preimage_eq_inter_range, hU.fromSpec_range]
      at h
    simp only [Set.inter_self, Opens.carrier_eq_coe, Set.inter_eq_right] at h
    ext1
    refine' Set.Subset.antisymm _ h
    simp only [Set.iUnion_subset_iff, SetCoe.forall, Opens.coe_iSup]
    intro x _
    exact X.basicOpen_le x
  · simp only [Opens.iSup_def, Subtype.coe_mk, Set.preimage_iUnion]
    -- Porting note : need an extra rewrite here, after simp, it is in `↔` form
    rw [iff_iff_eq]
    congr 3
    · refine congr_arg (Set.iUnion ·) ?_
      ext1 x
      

Proof state:
case e_a.h
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(X.presheaf.obj (op U))
x : ↑s
⊢ ⇑(fromSpec hU).val.base ⁻¹' ↑(X.basicOpen ↑x) = (PrimeSpectrum.basicOpen ↑x).carrier

Next tactic:
exact congr_arg Opens.carrier (hU.fromSpec_map_basicOpen _)
theorem basicOpen_union_eq_self_iff (s : Set (X.presheaf.obj <| op U)) :
    ⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U) = U ↔ Ideal.span s = ⊤ := by
  trans ⋃ i : s, (PrimeSpectrum.basicOpen i.1).1 = Set.univ
  trans
    hU.fromSpec.1.base ⁻¹' (⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U)).1 =
      hU.fromSpec.1.base ⁻¹' U.1
  · refine' ⟨fun h => by rw [h], _⟩
    intro h
    apply_fun Set.image hU.fromSpec.1.base at h
    rw [Set.image_preimage_eq_inter_range, Set.image_preimage_eq_inter_range, hU.fromSpec_range]
      at h
    simp only [Set.inter_self, Opens.carrier_eq_coe, Set.inter_eq_right] at h
    ext1
    refine' Set.Subset.antisymm _ h
    simp only [Set.iUnion_subset_iff, SetCoe.forall, Opens.coe_iSup]
    intro x _
    exact X.basicOpen_le x
  · simp only [Opens.iSup_def, Subtype.coe_mk, Set.preimage_iUnion]
    -- Porting note : need an extra rewrite here, after simp, it is in `↔` form
    rw [iff_iff_eq]
    congr 3
    · refine congr_arg (Set.iUnion ·) ?_
      ext1 x
      exact congr_arg Opens.carrier (hU.fromSpec_map_basicOpen _)
    · 

Proof state:
case e_a
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(X.presheaf.obj (op U))
⊢ ⇑(fromSpec hU).val.base ⁻¹' U.carrier = Set.univ

Next tactic:
exact congr_arg Opens.carrier hU.fromSpec_base_preimage
theorem basicOpen_union_eq_self_iff (s : Set (X.presheaf.obj <| op U)) :
    ⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U) = U ↔ Ideal.span s = ⊤ := by
  trans ⋃ i : s, (PrimeSpectrum.basicOpen i.1).1 = Set.univ
  trans
    hU.fromSpec.1.base ⁻¹' (⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U)).1 =
      hU.fromSpec.1.base ⁻¹' U.1
  · refine' ⟨fun h => by rw [h], _⟩
    intro h
    apply_fun Set.image hU.fromSpec.1.base at h
    rw [Set.image_preimage_eq_inter_range, Set.image_preimage_eq_inter_range, hU.fromSpec_range]
      at h
    simp only [Set.inter_self, Opens.carrier_eq_coe, Set.inter_eq_right] at h
    ext1
    refine' Set.Subset.antisymm _ h
    simp only [Set.iUnion_subset_iff, SetCoe.forall, Opens.coe_iSup]
    intro x _
    exact X.basicOpen_le x
  · simp only [Opens.iSup_def, Subtype.coe_mk, Set.preimage_iUnion]
    -- Porting note : need an extra rewrite here, after simp, it is in `↔` form
    rw [iff_iff_eq]
    congr 3
    · refine congr_arg (Set.iUnion ·) ?_
      ext1 x
      exact congr_arg Opens.carrier (hU.fromSpec_map_basicOpen _)
    · exact congr_arg Opens.carrier hU.fromSpec_base_preimage
  · 

Proof state:
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(X.presheaf.obj (op U))
⊢ ⋃ i, (PrimeSpectrum.basicOpen ↑i).carrier = Set.univ ↔ Ideal.span s = ⊤

Next tactic:
simp only [Opens.carrier_eq_coe, PrimeSpectrum.basicOpen_eq_zeroLocus_compl]
theorem basicOpen_union_eq_self_iff (s : Set (X.presheaf.obj <| op U)) :
    ⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U) = U ↔ Ideal.span s = ⊤ := by
  trans ⋃ i : s, (PrimeSpectrum.basicOpen i.1).1 = Set.univ
  trans
    hU.fromSpec.1.base ⁻¹' (⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U)).1 =
      hU.fromSpec.1.base ⁻¹' U.1
  · refine' ⟨fun h => by rw [h], _⟩
    intro h
    apply_fun Set.image hU.fromSpec.1.base at h
    rw [Set.image_preimage_eq_inter_range, Set.image_preimage_eq_inter_range, hU.fromSpec_range]
      at h
    simp only [Set.inter_self, Opens.carrier_eq_coe, Set.inter_eq_right] at h
    ext1
    refine' Set.Subset.antisymm _ h
    simp only [Set.iUnion_subset_iff, SetCoe.forall, Opens.coe_iSup]
    intro x _
    exact X.basicOpen_le x
  · simp only [Opens.iSup_def, Subtype.coe_mk, Set.preimage_iUnion]
    -- Porting note : need an extra rewrite here, after simp, it is in `↔` form
    rw [iff_iff_eq]
    congr 3
    · refine congr_arg (Set.iUnion ·) ?_
      ext1 x
      exact congr_arg Opens.carrier (hU.fromSpec_map_basicOpen _)
    · exact congr_arg Opens.carrier hU.fromSpec_base_preimage
  · simp only [Opens.carrier_eq_coe, PrimeSpectrum.basicOpen_eq_zeroLocus_compl]
    

Proof state:
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(X.presheaf.obj (op U))
⊢ ⋃ i, (PrimeSpectrum.zeroLocus {↑i})ᶜ = Set.univ ↔ Ideal.span s = ⊤

Next tactic:
rw [← Set.compl_iInter, Set.compl_univ_iff, ← PrimeSpectrum.zeroLocus_iUnion, ←
      PrimeSpectrum.zeroLocus_empty_iff_eq_top, PrimeSpectrum.zeroLocus_span]
theorem basicOpen_union_eq_self_iff (s : Set (X.presheaf.obj <| op U)) :
    ⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U) = U ↔ Ideal.span s = ⊤ := by
  trans ⋃ i : s, (PrimeSpectrum.basicOpen i.1).1 = Set.univ
  trans
    hU.fromSpec.1.base ⁻¹' (⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U)).1 =
      hU.fromSpec.1.base ⁻¹' U.1
  · refine' ⟨fun h => by rw [h], _⟩
    intro h
    apply_fun Set.image hU.fromSpec.1.base at h
    rw [Set.image_preimage_eq_inter_range, Set.image_preimage_eq_inter_range, hU.fromSpec_range]
      at h
    simp only [Set.inter_self, Opens.carrier_eq_coe, Set.inter_eq_right] at h
    ext1
    refine' Set.Subset.antisymm _ h
    simp only [Set.iUnion_subset_iff, SetCoe.forall, Opens.coe_iSup]
    intro x _
    exact X.basicOpen_le x
  · simp only [Opens.iSup_def, Subtype.coe_mk, Set.preimage_iUnion]
    -- Porting note : need an extra rewrite here, after simp, it is in `↔` form
    rw [iff_iff_eq]
    congr 3
    · refine congr_arg (Set.iUnion ·) ?_
      ext1 x
      exact congr_arg Opens.carrier (hU.fromSpec_map_basicOpen _)
    · exact congr_arg Opens.carrier hU.fromSpec_base_preimage
  · simp only [Opens.carrier_eq_coe, PrimeSpectrum.basicOpen_eq_zeroLocus_compl]
    rw [← Set.compl_iInter, Set.compl_univ_iff, ← PrimeSpectrum.zeroLocus_iUnion, ←
      PrimeSpectrum.zeroLocus_empty_iff_eq_top, PrimeSpectrum.zeroLocus_span]
    

Proof state:
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(X.presheaf.obj (op U))
⊢ PrimeSpectrum.zeroLocus (⋃ i, {↑i}) = ∅ ↔ PrimeSpectrum.zeroLocus s = ∅

Next tactic:
simp only [Set.iUnion_singleton_eq_range, Subtype.range_val_subtype, Set.setOf_mem_eq]
theorem self_le_basicOpen_union_iff (s : Set (X.presheaf.obj <| op U)) :
    (U ≤ ⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U)) ↔ Ideal.span s = ⊤ := by
  

Proof state:
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(X.presheaf.obj (op U))
⊢ U ≤ ⨆ f, X.basicOpen ↑f ↔ Ideal.span s = ⊤

Next tactic:
rw [← hU.basicOpen_union_eq_self_iff, @comm _ Eq]
theorem self_le_basicOpen_union_iff (s : Set (X.presheaf.obj <| op U)) :
    (U ≤ ⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U)) ↔ Ideal.span s = ⊤ := by
  rw [← hU.basicOpen_union_eq_self_iff, @comm _ Eq]
  

Proof state:
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(X.presheaf.obj (op U))
⊢ U ≤ ⨆ f, X.basicOpen ↑f ↔ U = ⨆ f, X.basicOpen ↑f

Next tactic:
refine' ⟨fun h => le_antisymm h _, le_of_eq⟩
theorem self_le_basicOpen_union_iff (s : Set (X.presheaf.obj <| op U)) :
    (U ≤ ⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U)) ↔ Ideal.span s = ⊤ := by
  rw [← hU.basicOpen_union_eq_self_iff, @comm _ Eq]
  refine' ⟨fun h => le_antisymm h _, le_of_eq⟩
  

Proof state:
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(X.presheaf.obj (op U))
h : U ≤ ⨆ f, X.basicOpen ↑f
⊢ ⨆ f, X.basicOpen ↑f ≤ U

Next tactic:
simp only [iSup_le_iff, SetCoe.forall]
theorem self_le_basicOpen_union_iff (s : Set (X.presheaf.obj <| op U)) :
    (U ≤ ⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U)) ↔ Ideal.span s = ⊤ := by
  rw [← hU.basicOpen_union_eq_self_iff, @comm _ Eq]
  refine' ⟨fun h => le_antisymm h _, le_of_eq⟩
  simp only [iSup_le_iff, SetCoe.forall]
  

Proof state:
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(X.presheaf.obj (op U))
h : U ≤ ⨆ f, X.basicOpen ↑f
⊢ ∀ x ∈ s, X.basicOpen x ≤ U

Next tactic:
intro x _
theorem self_le_basicOpen_union_iff (s : Set (X.presheaf.obj <| op U)) :
    (U ≤ ⨆ f : s, X.basicOpen (f : X.presheaf.obj <| op U)) ↔ Ideal.span s = ⊤ := by
  rw [← hU.basicOpen_union_eq_self_iff, @comm _ Eq]
  refine' ⟨fun h => le_antisymm h _, le_of_eq⟩
  simp only [iSup_le_iff, SetCoe.forall]
  intro x _
  

Proof state:
X : Scheme
Y : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsAffineOpen U
f : ↑(X.presheaf.obj (op U))
s : Set ↑(X.presheaf.obj (op U))
h : U ≤ ⨆ f, X.basicOpen ↑f
x : ↑(X.presheaf.obj (op U))
h✝ : x ∈ s
⊢ X.basicOpen x ≤ U

Next tactic:
exact X.basicOpen_le x