l3lab/ntp-mathlib huggingface dataset:
instance isIso_asLimitCone_lift : IsIso ((limitConeIsLimit.{u, u} X.diagram).lift X.asLimitCone) :=
  isIso_of_bijective _
    (by
      refine' ⟨fun a b h => _, fun a => _⟩
      · refine' DiscreteQuotient.eq_of_forall_proj_eq fun S => _
        apply_fun fun f : (limitCone.{u, u} X.diagram).pt => f.val S at h
        exact h
      · obtain ⟨b, hb⟩ :=
          DiscreteQuotient.exists_of_compat (fun S => a.val S) fun _ _ h => a.prop (homOfLE h)
        use b
        -- ext S : 3 -- Porting note: `ext` does not work, replaced with following three lines.
        apply Subtype.ext
        apply funext
        

Proof state:
case h.a.h
X : Profinite
a : (forget Profinite).obj (limitCone (diagram X)).pt
b : ↑X.toCompHaus.toTop
hb : ∀ (Q : DiscreteQuotient ↑X.toCompHaus.toTop), DiscreteQuotient.proj Q b = ↑a Q
⊢ ∀ (x : DiscreteQuotient ↑X.toCompHaus.toTop),
    ↑((Limits.IsLimit.lift (limitConeIsLimit (diagram X)) (asLimitCone X)) b) x = ↑a x

Next tactic:
rintro S
instance isIso_asLimitCone_lift : IsIso ((limitConeIsLimit.{u, u} X.diagram).lift X.asLimitCone) :=
  isIso_of_bijective _
    (by
      refine' ⟨fun a b h => _, fun a => _⟩
      · refine' DiscreteQuotient.eq_of_forall_proj_eq fun S => _
        apply_fun fun f : (limitCone.{u, u} X.diagram).pt => f.val S at h
        exact h
      · obtain ⟨b, hb⟩ :=
          DiscreteQuotient.exists_of_compat (fun S => a.val S) fun _ _ h => a.prop (homOfLE h)
        use b
        -- ext S : 3 -- Porting note: `ext` does not work, replaced with following three lines.
        apply Subtype.ext
        apply funext
        rintro S
        -- Porting note: end replacement block
        

Proof state:
case h.a.h
X : Profinite
a : (forget Profinite).obj (limitCone (diagram X)).pt
b : ↑X.toCompHaus.toTop
hb : ∀ (Q : DiscreteQuotient ↑X.toCompHaus.toTop), DiscreteQuotient.proj Q b = ↑a Q
S : DiscreteQuotient ↑X.toCompHaus.toTop
⊢ ↑((Limits.IsLimit.lift (limitConeIsLimit (diagram X)) (asLimitCone X)) b) S = ↑a S

Next tactic:
apply hb
@[to_additive]
theorem isSimpleGroup_of_surjective {H : Type*} [Group H] [IsSimpleGroup G] [Nontrivial H]
    (f : G →* H) (hf : Function.Surjective f) : IsSimpleGroup H :=
  ⟨fun H iH => by
    

Proof state:
G : Type u_1
inst✝⁴ : Group G
A : Type u_2
inst✝³ : AddGroup A
H✝ : Type u_3
inst✝² : Group H✝
inst✝¹ : IsSimpleGroup G
inst✝ : Nontrivial H✝
f : G →* H✝
hf : Function.Surjective ⇑f
H : Subgroup H✝
iH : Normal H
⊢ H = ⊥ ∨ H = ⊤

Next tactic:
refine' (iH.comap f).eq_bot_or_eq_top.imp (fun h => _) fun h => _
@[to_additive]
theorem isSimpleGroup_of_surjective {H : Type*} [Group H] [IsSimpleGroup G] [Nontrivial H]
    (f : G →* H) (hf : Function.Surjective f) : IsSimpleGroup H :=
  ⟨fun H iH => by
    refine' (iH.comap f).eq_bot_or_eq_top.imp (fun h => _) fun h => _
    · 

Proof state:
case refine'_1
G : Type u_1
inst✝⁴ : Group G
A : Type u_2
inst✝³ : AddGroup A
H✝ : Type u_3
inst✝² : Group H✝
inst✝¹ : IsSimpleGroup G
inst✝ : Nontrivial H✝
f : G →* H✝
hf : Function.Surjective ⇑f
H : Subgroup H✝
iH : Normal H
h : comap f H = ⊥
⊢ H = ⊥

Next tactic:
rw [← map_bot f, ← h, map_comap_eq_self_of_surjective hf]
@[to_additive]
theorem isSimpleGroup_of_surjective {H : Type*} [Group H] [IsSimpleGroup G] [Nontrivial H]
    (f : G →* H) (hf : Function.Surjective f) : IsSimpleGroup H :=
  ⟨fun H iH => by
    refine' (iH.comap f).eq_bot_or_eq_top.imp (fun h => _) fun h => _
    · rw [← map_bot f, ← h, map_comap_eq_self_of_surjective hf]
    · 

Proof state:
case refine'_2
G : Type u_1
inst✝⁴ : Group G
A : Type u_2
inst✝³ : AddGroup A
H✝ : Type u_3
inst✝² : Group H✝
inst✝¹ : IsSimpleGroup G
inst✝ : Nontrivial H✝
f : G →* H✝
hf : Function.Surjective ⇑f
H : Subgroup H✝
iH : Normal H
h : comap f H = ⊤
⊢ H = ⊤

Next tactic:
rw [← comap_top f] at h
@[to_additive]
theorem isSimpleGroup_of_surjective {H : Type*} [Group H] [IsSimpleGroup G] [Nontrivial H]
    (f : G →* H) (hf : Function.Surjective f) : IsSimpleGroup H :=
  ⟨fun H iH => by
    refine' (iH.comap f).eq_bot_or_eq_top.imp (fun h => _) fun h => _
    · rw [← map_bot f, ← h, map_comap_eq_self_of_surjective hf]
    · rw [← comap_top f] at h
      

Proof state:
case refine'_2
G : Type u_1
inst✝⁴ : Group G
A : Type u_2
inst✝³ : AddGroup A
H✝ : Type u_3
inst✝² : Group H✝
inst✝¹ : IsSimpleGroup G
inst✝ : Nontrivial H✝
f : G →* H✝
hf : Function.Surjective ⇑f
H : Subgroup H✝
iH : Normal H
h : comap f H = comap f ⊤
⊢ H = ⊤

Next tactic:
exact comap_injective hf h
theorem quasiCompact_iff_spectral : QuasiCompact f ↔ IsSpectralMap f.1.base :=
  ⟨fun ⟨h⟩ => ⟨by 

Proof state:
X Y : Scheme
f : X ⟶ Y
x✝ : QuasiCompact f
h : ∀ (U : Set ↑↑Y.toPresheafedSpace), IsOpen U → IsCompact U → IsCompact (⇑f.val.base ⁻¹' U)
⊢ Continuous ⇑f.val.base

Next tactic:
continuity
instance (priority := 900) quasiCompactOfIsIso {X Y : Scheme} (f : X ⟶ Y) [IsIso f] :
    QuasiCompact f := by
  

Proof state:
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y : Scheme
f : X ⟶ Y
inst✝ : IsIso f
⊢ QuasiCompact f

Next tactic:
constructor
instance (priority := 900) quasiCompactOfIsIso {X Y : Scheme} (f : X ⟶ Y) [IsIso f] :
    QuasiCompact f := by
  constructor
  

Proof state:
case isCompact_preimage
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y : Scheme
f : X ⟶ Y
inst✝ : IsIso f
⊢ ∀ (U : Set ↑↑Y.toPresheafedSpace), IsOpen U → IsCompact U → IsCompact (⇑f.val.base ⁻¹' U)

Next tactic:
intro U _ hU'
instance (priority := 900) quasiCompactOfIsIso {X Y : Scheme} (f : X ⟶ Y) [IsIso f] :
    QuasiCompact f := by
  constructor
  intro U _ hU'
  

Proof state:
case isCompact_preimage
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y : Scheme
f : X ⟶ Y
inst✝ : IsIso f
U : Set ↑↑Y.toPresheafedSpace
a✝ : IsOpen U
hU' : IsCompact U
⊢ IsCompact (⇑f.val.base ⁻¹' U)

Next tactic:
convert hU'.image (inv f.1.base).continuous_toFun using 1
instance (priority := 900) quasiCompactOfIsIso {X Y : Scheme} (f : X ⟶ Y) [IsIso f] :
    QuasiCompact f := by
  constructor
  intro U _ hU'
  convert hU'.image (inv f.1.base).continuous_toFun using 1
  

Proof state:
case h.e'_3.h
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y : Scheme
f : X ⟶ Y
inst✝ : IsIso f
U : Set ↑↑Y.toPresheafedSpace
a✝ : IsOpen U
hU' : IsCompact U
e_1✝ : (forget TopCat).obj ↑X.toPresheafedSpace = ↑↑X.toPresheafedSpace
⊢ ⇑f.val.base ⁻¹' U = (inv f.val.base).toFun '' U

Next tactic:
rw [Set.image_eq_preimage_of_inverse]
instance (priority := 900) quasiCompactOfIsIso {X Y : Scheme} (f : X ⟶ Y) [IsIso f] :
    QuasiCompact f := by
  constructor
  intro U _ hU'
  convert hU'.image (inv f.1.base).continuous_toFun using 1
  rw [Set.image_eq_preimage_of_inverse]
  

Proof state:
case h.e'_3.h.h₁
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y : Scheme
f : X ⟶ Y
inst✝ : IsIso f
U : Set ↑↑Y.toPresheafedSpace
a✝ : IsOpen U
hU' : IsCompact U
e_1✝ : (forget TopCat).obj ↑X.toPresheafedSpace = ↑↑X.toPresheafedSpace
⊢ Function.LeftInverse (⇑f.val.base) (inv f.val.base).toFun
case h.e'_3.h.h₂
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y : Scheme
f : X ⟶ Y
inst✝ : IsIso f
U : Set ↑↑Y.toPresheafedSpace
a✝ : IsOpen U
hU' : IsCompact U
e_1✝ : (forget TopCat).obj ↑X.toPresheafedSpace = ↑↑X.toPresheafedSpace
⊢ Function.RightInverse (⇑f.val.base) (inv f.val.base).toFun

Next tactic:
delta Function.LeftInverse
instance (priority := 900) quasiCompactOfIsIso {X Y : Scheme} (f : X ⟶ Y) [IsIso f] :
    QuasiCompact f := by
  constructor
  intro U _ hU'
  convert hU'.image (inv f.1.base).continuous_toFun using 1
  rw [Set.image_eq_preimage_of_inverse]
  delta Function.LeftInverse
  

Proof state:
case h.e'_3.h.h₁
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y : Scheme
f : X ⟶ Y
inst✝ : IsIso f
U : Set ↑↑Y.toPresheafedSpace
a✝ : IsOpen U
hU' : IsCompact U
e_1✝ : (forget TopCat).obj ↑X.toPresheafedSpace = ↑↑X.toPresheafedSpace
⊢ ∀ (x : ↑↑Y.toPresheafedSpace), f.val.base (ContinuousMap.toFun (inv f.val.base) x) = x
case h.e'_3.h.h₂
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y : Scheme
f : X ⟶ Y
inst✝ : IsIso f
U : Set ↑↑Y.toPresheafedSpace
a✝ : IsOpen U
hU' : IsCompact U
e_1✝ : (forget TopCat).obj ↑X.toPresheafedSpace = ↑↑X.toPresheafedSpace
⊢ Function.RightInverse (⇑f.val.base) (inv f.val.base).toFun

Next tactic:
exacts [IsIso.inv_hom_id_apply f.1.base, IsIso.hom_inv_id_apply f.1.base]
instance quasiCompactComp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [QuasiCompact f]
    [QuasiCompact g] : QuasiCompact (f ≫ g) := by
  

Proof state:
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y Z : Scheme
f : X ⟶ Y
g : Y ⟶ Z
inst✝¹ : QuasiCompact f
inst✝ : QuasiCompact g
⊢ QuasiCompact (f ≫ g)

Next tactic:
constructor
instance quasiCompactComp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [QuasiCompact f]
    [QuasiCompact g] : QuasiCompact (f ≫ g) := by
  constructor
  

Proof state:
case isCompact_preimage
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y Z : Scheme
f : X ⟶ Y
g : Y ⟶ Z
inst✝¹ : QuasiCompact f
inst✝ : QuasiCompact g
⊢ ∀ (U : Set ↑↑Z.toPresheafedSpace), IsOpen U → IsCompact U → IsCompact (⇑(f ≫ g).val.base ⁻¹' U)

Next tactic:
intro U hU hU'
instance quasiCompactComp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [QuasiCompact f]
    [QuasiCompact g] : QuasiCompact (f ≫ g) := by
  constructor
  intro U hU hU'
  

Proof state:
case isCompact_preimage
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y Z : Scheme
f : X ⟶ Y
g : Y ⟶ Z
inst✝¹ : QuasiCompact f
inst✝ : QuasiCompact g
U : Set ↑↑Z.toPresheafedSpace
hU : IsOpen U
hU' : IsCompact U
⊢ IsCompact (⇑(f ≫ g).val.base ⁻¹' U)

Next tactic:
rw [Scheme.comp_val_base, coe_comp, Set.preimage_comp]
instance quasiCompactComp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [QuasiCompact f]
    [QuasiCompact g] : QuasiCompact (f ≫ g) := by
  constructor
  intro U hU hU'
  rw [Scheme.comp_val_base, coe_comp, Set.preimage_comp]
  

Proof state:
case isCompact_preimage
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y Z : Scheme
f : X ⟶ Y
g : Y ⟶ Z
inst✝¹ : QuasiCompact f
inst✝ : QuasiCompact g
U : Set ↑↑Z.toPresheafedSpace
hU : IsOpen U
hU' : IsCompact U
⊢ IsCompact (⇑f.val.base ⁻¹' (⇑g.val.base ⁻¹' U))

Next tactic:
apply QuasiCompact.isCompact_preimage
instance quasiCompactComp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [QuasiCompact f]
    [QuasiCompact g] : QuasiCompact (f ≫ g) := by
  constructor
  intro U hU hU'
  rw [Scheme.comp_val_base, coe_comp, Set.preimage_comp]
  apply QuasiCompact.isCompact_preimage
  · 

Proof state:
case isCompact_preimage.a
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y Z : Scheme
f : X ⟶ Y
g : Y ⟶ Z
inst✝¹ : QuasiCompact f
inst✝ : QuasiCompact g
U : Set ↑↑Z.toPresheafedSpace
hU : IsOpen U
hU' : IsCompact U
⊢ IsOpen (⇑g.val.base ⁻¹' U)

Next tactic:
exact Continuous.isOpen_preimage (by
    -- porting note: `continuity` failed
    -- see https://github.com/leanprover-community/mathlib4/issues/5030
      exact Scheme.Hom.continuous g) _ hU
instance quasiCompactComp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [QuasiCompact f]
    [QuasiCompact g] : QuasiCompact (f ≫ g) := by
  constructor
  intro U hU hU'
  rw [Scheme.comp_val_base, coe_comp, Set.preimage_comp]
  apply QuasiCompact.isCompact_preimage
  · exact Continuous.isOpen_preimage (by
    -- porting note: `continuity` failed
    -- see https://github.com/leanprover-community/mathlib4/issues/5030
      

Proof state:
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y Z : Scheme
f : X ⟶ Y
g : Y ⟶ Z
inst✝¹ : QuasiCompact f
inst✝ : QuasiCompact g
U : Set ↑↑Z.toPresheafedSpace
hU : IsOpen U
hU' : IsCompact U
⊢ Continuous ⇑g.val.base

Next tactic:
exact Scheme.Hom.continuous g
instance quasiCompactComp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [QuasiCompact f]
    [QuasiCompact g] : QuasiCompact (f ≫ g) := by
  constructor
  intro U hU hU'
  rw [Scheme.comp_val_base, coe_comp, Set.preimage_comp]
  apply QuasiCompact.isCompact_preimage
  · exact Continuous.isOpen_preimage (by
    -- porting note: `continuity` failed
    -- see https://github.com/leanprover-community/mathlib4/issues/5030
      exact Scheme.Hom.continuous g) _ hU
  

Proof state:
case isCompact_preimage.a
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y Z : Scheme
f : X ⟶ Y
g : Y ⟶ Z
inst✝¹ : QuasiCompact f
inst✝ : QuasiCompact g
U : Set ↑↑Z.toPresheafedSpace
hU : IsOpen U
hU' : IsCompact U
⊢ IsCompact (⇑g.val.base ⁻¹' U)

Next tactic:
apply QuasiCompact.isCompact_preimage
instance quasiCompactComp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [QuasiCompact f]
    [QuasiCompact g] : QuasiCompact (f ≫ g) := by
  constructor
  intro U hU hU'
  rw [Scheme.comp_val_base, coe_comp, Set.preimage_comp]
  apply QuasiCompact.isCompact_preimage
  · exact Continuous.isOpen_preimage (by
    -- porting note: `continuity` failed
    -- see https://github.com/leanprover-community/mathlib4/issues/5030
      exact Scheme.Hom.continuous g) _ hU
  apply QuasiCompact.isCompact_preimage <;> 

Proof state:
case isCompact_preimage.a.a
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y Z : Scheme
f : X ⟶ Y
g : Y ⟶ Z
inst✝¹ : QuasiCompact f
inst✝ : QuasiCompact g
U : Set ↑↑Z.toPresheafedSpace
hU : IsOpen U
hU' : IsCompact U
⊢ IsOpen U

Next tactic:
assumption
instance quasiCompactComp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [QuasiCompact f]
    [QuasiCompact g] : QuasiCompact (f ≫ g) := by
  constructor
  intro U hU hU'
  rw [Scheme.comp_val_base, coe_comp, Set.preimage_comp]
  apply QuasiCompact.isCompact_preimage
  · exact Continuous.isOpen_preimage (by
    -- porting note: `continuity` failed
    -- see https://github.com/leanprover-community/mathlib4/issues/5030
      exact Scheme.Hom.continuous g) _ hU
  apply QuasiCompact.isCompact_preimage <;> 

Proof state:
case isCompact_preimage.a.a
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y Z : Scheme
f : X ⟶ Y
g : Y ⟶ Z
inst✝¹ : QuasiCompact f
inst✝ : QuasiCompact g
U : Set ↑↑Z.toPresheafedSpace
hU : IsOpen U
hU' : IsCompact U
⊢ IsCompact U

Next tactic:
assumption
theorem isCompact_open_iff_eq_finset_affine_union {X : Scheme} (U : Set X.carrier) :
    IsCompact U ∧ IsOpen U ↔
      ∃ s : Set X.affineOpens, s.Finite ∧ U = ⋃ (i : X.affineOpens) (_ : i ∈ s), i := by
  

Proof state:
X✝ Y : Scheme
f : X✝ ⟶ Y
X : Scheme
U : Set ↑↑X.toPresheafedSpace
⊢ IsCompact U ∧ IsOpen U ↔ ∃ s, Set.Finite s ∧ U = ⋃ i ∈ s, ↑↑i

Next tactic:
apply Opens.IsBasis.isCompact_open_iff_eq_finite_iUnion
    (fun (U : X.affineOpens) => (U : Opens X.carrier))
theorem isCompact_open_iff_eq_finset_affine_union {X : Scheme} (U : Set X.carrier) :
    IsCompact U ∧ IsOpen U ↔
      ∃ s : Set X.affineOpens, s.Finite ∧ U = ⋃ (i : X.affineOpens) (_ : i ∈ s), i := by
  apply Opens.IsBasis.isCompact_open_iff_eq_finite_iUnion
    (fun (U : X.affineOpens) => (U : Opens X.carrier))
  · 

Proof state:
case hb
X✝ Y : Scheme
f : X✝ ⟶ Y
X : Scheme
U : Set ↑↑X.toPresheafedSpace
⊢ Opens.IsBasis (Set.range fun U => ↑U)

Next tactic:
rw [Subtype.range_coe]
theorem isCompact_open_iff_eq_finset_affine_union {X : Scheme} (U : Set X.carrier) :
    IsCompact U ∧ IsOpen U ↔
      ∃ s : Set X.affineOpens, s.Finite ∧ U = ⋃ (i : X.affineOpens) (_ : i ∈ s), i := by
  apply Opens.IsBasis.isCompact_open_iff_eq_finite_iUnion
    (fun (U : X.affineOpens) => (U : Opens X.carrier))
  · rw [Subtype.range_coe]; 

Proof state:
case hb
X✝ Y : Scheme
f : X✝ ⟶ Y
X : Scheme
U : Set ↑↑X.toPresheafedSpace
⊢ Opens.IsBasis (Scheme.affineOpens X)

Next tactic:
exact isBasis_affine_open X
theorem isCompact_open_iff_eq_finset_affine_union {X : Scheme} (U : Set X.carrier) :
    IsCompact U ∧ IsOpen U ↔
      ∃ s : Set X.affineOpens, s.Finite ∧ U = ⋃ (i : X.affineOpens) (_ : i ∈ s), i := by
  apply Opens.IsBasis.isCompact_open_iff_eq_finite_iUnion
    (fun (U : X.affineOpens) => (U : Opens X.carrier))
  · rw [Subtype.range_coe]; exact isBasis_affine_open X
  · 

Proof state:
case hb'
X✝ Y : Scheme
f : X✝ ⟶ Y
X : Scheme
U : Set ↑↑X.toPresheafedSpace
⊢ ∀ (i : ↑(Scheme.affineOpens X)), IsCompact ↑↑i

Next tactic:
exact fun i => i.2.isCompact
theorem quasiCompact_iff_forall_affine :
    QuasiCompact f ↔
      ∀ U : Opens Y.carrier, IsAffineOpen U → IsCompact (f.1.base ⁻¹' (U : Set Y.carrier)) := by
  

Proof state:
X Y : Scheme
f : X ⟶ Y
⊢ QuasiCompact f ↔ ∀ (U : Opens ↑↑Y.toPresheafedSpace), IsAffineOpen U → IsCompact (⇑f.val.base ⁻¹' ↑U)

Next tactic:
rw [QuasiCompact_iff]
theorem quasiCompact_iff_forall_affine :
    QuasiCompact f ↔
      ∀ U : Opens Y.carrier, IsAffineOpen U → IsCompact (f.1.base ⁻¹' (U : Set Y.carrier)) := by
  rw [QuasiCompact_iff]
  

Proof state:
X Y : Scheme
f : X ⟶ Y
⊢ (∀ (U : Set ↑↑Y.toPresheafedSpace), IsOpen U → IsCompact U → IsCompact (⇑f.val.base ⁻¹' U)) ↔
    ∀ (U : Opens ↑↑Y.toPresheafedSpace), IsAffineOpen U → IsCompact (⇑f.val.base ⁻¹' ↑U)

Next tactic:
refine' ⟨fun H U hU => H U U.isOpen hU.isCompact, _⟩
theorem quasiCompact_iff_forall_affine :
    QuasiCompact f ↔
      ∀ U : Opens Y.carrier, IsAffineOpen U → IsCompact (f.1.base ⁻¹' (U : Set Y.carrier)) := by
  rw [QuasiCompact_iff]
  refine' ⟨fun H U hU => H U U.isOpen hU.isCompact, _⟩
  

Proof state:
X Y : Scheme
f : X ⟶ Y
⊢ (∀ (U : Opens ↑↑Y.toPresheafedSpace), IsAffineOpen U → IsCompact (⇑f.val.base ⁻¹' ↑U)) →
    ∀ (U : Set ↑↑Y.toPresheafedSpace), IsOpen U → IsCompact U → IsCompact (⇑f.val.base ⁻¹' U)

Next tactic:
intro H U hU hU'
theorem quasiCompact_iff_forall_affine :
    QuasiCompact f ↔
      ∀ U : Opens Y.carrier, IsAffineOpen U → IsCompact (f.1.base ⁻¹' (U : Set Y.carrier)) := by
  rw [QuasiCompact_iff]
  refine' ⟨fun H U hU => H U U.isOpen hU.isCompact, _⟩
  intro H U hU hU'
  

Proof state:
X Y : Scheme
f : X ⟶ Y
H : ∀ (U : Opens ↑↑Y.toPresheafedSpace), IsAffineOpen U → IsCompact (⇑f.val.base ⁻¹' ↑U)
U : Set ↑↑Y.toPresheafedSpace
hU : IsOpen U
hU' : IsCompact U
⊢ IsCompact (⇑f.val.base ⁻¹' U)

Next tactic:
obtain ⟨S, hS, rfl⟩ := (isCompact_open_iff_eq_finset_affine_union U).mp ⟨hU', hU⟩
theorem quasiCompact_iff_forall_affine :
    QuasiCompact f ↔
      ∀ U : Opens Y.carrier, IsAffineOpen U → IsCompact (f.1.base ⁻¹' (U : Set Y.carrier)) := by
  rw [QuasiCompact_iff]
  refine' ⟨fun H U hU => H U U.isOpen hU.isCompact, _⟩
  intro H U hU hU'
  obtain ⟨S, hS, rfl⟩ := (isCompact_open_iff_eq_finset_affine_union U).mp ⟨hU', hU⟩
  

Proof state:
case intro.intro
X Y : Scheme
f : X ⟶ Y
H : ∀ (U : Opens ↑↑Y.toPresheafedSpace), IsAffineOpen U → IsCompact (⇑f.val.base ⁻¹' ↑U)
S : Set ↑(Scheme.affineOpens Y)
hS : Set.Finite S
hU : IsOpen (⋃ i ∈ S, ↑↑i)
hU' : IsCompact (⋃ i ∈ S, ↑↑i)
⊢ IsCompact (⇑f.val.base ⁻¹' ⋃ i ∈ S, ↑↑i)

Next tactic:
simp only [Set.preimage_iUnion]
theorem quasiCompact_iff_forall_affine :
    QuasiCompact f ↔
      ∀ U : Opens Y.carrier, IsAffineOpen U → IsCompact (f.1.base ⁻¹' (U : Set Y.carrier)) := by
  rw [QuasiCompact_iff]
  refine' ⟨fun H U hU => H U U.isOpen hU.isCompact, _⟩
  intro H U hU hU'
  obtain ⟨S, hS, rfl⟩ := (isCompact_open_iff_eq_finset_affine_union U).mp ⟨hU', hU⟩
  simp only [Set.preimage_iUnion]
  

Proof state:
case intro.intro
X Y : Scheme
f : X ⟶ Y
H : ∀ (U : Opens ↑↑Y.toPresheafedSpace), IsAffineOpen U → IsCompact (⇑f.val.base ⁻¹' ↑U)
S : Set ↑(Scheme.affineOpens Y)
hS : Set.Finite S
hU : IsOpen (⋃ i ∈ S, ↑↑i)
hU' : IsCompact (⋃ i ∈ S, ↑↑i)
⊢ IsCompact (⋃ i ∈ S, ⇑f.val.base ⁻¹' ↑↑i)

Next tactic:
exact Set.Finite.isCompact_biUnion hS (fun i _ => H i i.prop)
@[simp]
theorem QuasiCompact.affineProperty_toProperty {X Y : Scheme} (f : X ⟶ Y) :
    (QuasiCompact.affineProperty : _).toProperty f ↔ IsAffine Y ∧ CompactSpace X.carrier := by
  

Proof state:
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y : Scheme
f : X ⟶ Y
⊢ AffineTargetMorphismProperty.toProperty affineProperty f ↔ IsAffine Y ∧ CompactSpace ↑↑X.toPresheafedSpace

Next tactic:
delta AffineTargetMorphismProperty.toProperty QuasiCompact.affineProperty
@[simp]
theorem QuasiCompact.affineProperty_toProperty {X Y : Scheme} (f : X ⟶ Y) :
    (QuasiCompact.affineProperty : _).toProperty f ↔ IsAffine Y ∧ CompactSpace X.carrier := by
  delta AffineTargetMorphismProperty.toProperty QuasiCompact.affineProperty; 

Proof state:
X✝ Y✝ : Scheme
f✝ : X✝ ⟶ Y✝
X Y : Scheme
f : X ⟶ Y
⊢ (∃ (_ : IsAffine Y), CompactSpace ↑↑X.toPresheafedSpace) ↔ IsAffine Y ∧ CompactSpace ↑↑X.toPresheafedSpace

Next tactic:
simp
theorem quasiCompact_iff_affineProperty :
    QuasiCompact f ↔ targetAffineLocally QuasiCompact.affineProperty f := by
  

Proof state:
X Y : Scheme
f : X ⟶ Y
⊢ QuasiCompact f ↔ targetAffineLocally QuasiCompact.affineProperty f

Next tactic:
rw [quasiCompact_iff_forall_affine]
theorem quasiCompact_iff_affineProperty :
    QuasiCompact f ↔ targetAffineLocally QuasiCompact.affineProperty f := by
  rw [quasiCompact_iff_forall_affine]
  

Proof state:
X Y : Scheme
f : X ⟶ Y
⊢ (∀ (U : Opens ↑↑Y.toPresheafedSpace), IsAffineOpen U → IsCompact (⇑f.val.base ⁻¹' ↑U)) ↔
    targetAffineLocally QuasiCompact.affineProperty f

Next tactic:
trans ∀ U : Y.affineOpens, IsCompact (f.1.base ⁻¹' (U : Set Y.carrier))
theorem quasiCompact_iff_affineProperty :
    QuasiCompact f ↔ targetAffineLocally QuasiCompact.affineProperty f := by
  rw [quasiCompact_iff_forall_affine]
  trans ∀ U : Y.affineOpens, IsCompact (f.1.base ⁻¹' (U : Set Y.carrier))
  · 

Proof state:
X Y : Scheme
f : X ⟶ Y
⊢ (∀ (U : Opens ↑↑Y.toPresheafedSpace), IsAffineOpen U → IsCompact (⇑f.val.base ⁻¹' ↑U)) ↔
    ∀ (U : ↑(Scheme.affineOpens Y)), IsCompact (⇑f.val.base ⁻¹' ↑↑U)

Next tactic:
exact ⟨fun h U => h U U.prop, fun h U hU => h ⟨U, hU⟩⟩
theorem quasiCompact_iff_affineProperty :
    QuasiCompact f ↔ targetAffineLocally QuasiCompact.affineProperty f := by
  rw [quasiCompact_iff_forall_affine]
  trans ∀ U : Y.affineOpens, IsCompact (f.1.base ⁻¹' (U : Set Y.carrier))
  · exact ⟨fun h U => h U U.prop, fun h U hU => h ⟨U, hU⟩⟩
  

Proof state:
X Y : Scheme
f : X ⟶ Y
⊢ (∀ (U : ↑(Scheme.affineOpens Y)), IsCompact (⇑f.val.base ⁻¹' ↑↑U)) ↔ targetAffineLocally QuasiCompact.affineProperty f

Next tactic:
apply forall_congr'
theorem quasiCompact_iff_affineProperty :
    QuasiCompact f ↔ targetAffineLocally QuasiCompact.affineProperty f := by
  rw [quasiCompact_iff_forall_affine]
  trans ∀ U : Y.affineOpens, IsCompact (f.1.base ⁻¹' (U : Set Y.carrier))
  · exact ⟨fun h U => h U U.prop, fun h U hU => h ⟨U, hU⟩⟩
  apply forall_congr'
  

Proof state:
case h
X Y : Scheme
f : X ⟶ Y
⊢ ∀ (a : ↑(Scheme.affineOpens Y)), IsCompact (⇑f.val.base ⁻¹' ↑↑a) ↔ QuasiCompact.affineProperty (f ∣_ ↑a)

Next tactic:
exact fun _ => isCompact_iff_compactSpace
theorem quasiCompact_eq_affineProperty :
    @QuasiCompact = targetAffineLocally QuasiCompact.affineProperty := by
  

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

Next tactic:
ext
theorem quasiCompact_eq_affineProperty :
    @QuasiCompact = targetAffineLocally QuasiCompact.affineProperty := by
  ext
  

Proof state:
case h.h.h.a
X Y : Scheme
f : X ⟶ Y
x✝² x✝¹ : Scheme
x✝ : x✝² ⟶ x✝¹
⊢ QuasiCompact x✝ ↔ targetAffineLocally QuasiCompact.affineProperty x✝

Next tactic:
exact quasiCompact_iff_affineProperty _
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
  

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:
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₂`
    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⟩))
  · rintro ⟨i, hi⟩ ⟨⟨j, hj⟩, hj'⟩
    rw [← hj']
    refine' Set.Subset.trans _ (Set.subset_iUnion₂ j hj)
    exact Set.Subset.rfl