l3lab/ntp-mathlib huggingface dataset:
theorem exists_eq_pow_mul_of_isCompact_of_isQuasiSeparated (X : Scheme.{u}) (U : Opens X.carrier)
    (hU : IsCompact U.1) (hU' : IsQuasiSeparated U.1) (f : X.presheaf.obj (op U))
    (x : X.presheaf.obj (op <| X.basicOpen f)) :
    ∃ (n : ℕ) (y : X.presheaf.obj (op U)), y |_ X.basicOpen f = (f |_ X.basicOpen f) ^ n * x := by
  delta TopCat.Presheaf.restrictOpen TopCat.Presheaf.restrict
  revert hU' f x
  -- Porting note: complains `expected type is not available`, but tell Lean that it is underscore
  -- is sufficient
  

Proof state:
X✝ Y : Scheme
f : X✝ ⟶ Y
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact U.carrier
⊢ IsQuasiSeparated U.carrier →
    ∀ (f : ↑(X.presheaf.obj (op U))) (x : ↑(X.presheaf.obj (op (X.basicOpen f)))),
      ∃ n y,
        (X.presheaf.map (homOfLE (_ : X.basicOpen f ≤ U)).op) y =
          (X.presheaf.map (homOfLE (_ : X.basicOpen f ≤ U)).op) f ^ n * x

Next tactic:
apply compact_open_induction_on (P := _) U hU
theorem exists_eq_pow_mul_of_isCompact_of_isQuasiSeparated (X : Scheme.{u}) (U : Opens X.carrier)
    (hU : IsCompact U.1) (hU' : IsQuasiSeparated U.1) (f : X.presheaf.obj (op U))
    (x : X.presheaf.obj (op <| X.basicOpen f)) :
    ∃ (n : ℕ) (y : X.presheaf.obj (op U)), y |_ X.basicOpen f = (f |_ X.basicOpen f) ^ n * x := by
  delta TopCat.Presheaf.restrictOpen TopCat.Presheaf.restrict
  revert hU' f x
  -- Porting note: complains `expected type is not available`, but tell Lean that it is underscore
  -- is sufficient
  apply compact_open_induction_on (P := _) U hU
  · 

Proof state:
case h₁
X✝ Y : Scheme
f : X✝ ⟶ Y
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact U.carrier
⊢ IsQuasiSeparated ⊥.carrier →
    ∀ (f : ↑(X.presheaf.obj (op ⊥))) (x : ↑(X.presheaf.obj (op (X.basicOpen f)))),
      ∃ n y,
        (X.presheaf.map (homOfLE (_ : X.basicOpen f ≤ ⊥)).op) y =
          (X.presheaf.map (homOfLE (_ : X.basicOpen f ≤ ⊥)).op) f ^ n * x

Next tactic:
intro _ f x
theorem exists_eq_pow_mul_of_isCompact_of_isQuasiSeparated (X : Scheme.{u}) (U : Opens X.carrier)
    (hU : IsCompact U.1) (hU' : IsQuasiSeparated U.1) (f : X.presheaf.obj (op U))
    (x : X.presheaf.obj (op <| X.basicOpen f)) :
    ∃ (n : ℕ) (y : X.presheaf.obj (op U)), y |_ X.basicOpen f = (f |_ X.basicOpen f) ^ n * x := by
  delta TopCat.Presheaf.restrictOpen TopCat.Presheaf.restrict
  revert hU' f x
  -- Porting note: complains `expected type is not available`, but tell Lean that it is underscore
  -- is sufficient
  apply compact_open_induction_on (P := _) U hU
  · intro _ f x
    

Proof state:
case h₁
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact U.carrier
hU'✝ : IsQuasiSeparated ⊥.carrier
f : ↑(X.presheaf.obj (op ⊥))
x : ↑(X.presheaf.obj (op (X.basicOpen f)))
⊢ ∃ n y,
    (X.presheaf.map (homOfLE (_ : X.basicOpen f ≤ ⊥)).op) y =
      (X.presheaf.map (homOfLE (_ : X.basicOpen f ≤ ⊥)).op) f ^ n * x

Next tactic:
use 0, f
theorem exists_eq_pow_mul_of_isCompact_of_isQuasiSeparated (X : Scheme.{u}) (U : Opens X.carrier)
    (hU : IsCompact U.1) (hU' : IsQuasiSeparated U.1) (f : X.presheaf.obj (op U))
    (x : X.presheaf.obj (op <| X.basicOpen f)) :
    ∃ (n : ℕ) (y : X.presheaf.obj (op U)), y |_ X.basicOpen f = (f |_ X.basicOpen f) ^ n * x := by
  delta TopCat.Presheaf.restrictOpen TopCat.Presheaf.restrict
  revert hU' f x
  -- Porting note: complains `expected type is not available`, but tell Lean that it is underscore
  -- is sufficient
  apply compact_open_induction_on (P := _) U hU
  · intro _ f x
    use 0, f
    

Proof state:
case h
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact U.carrier
hU'✝ : IsQuasiSeparated ⊥.carrier
f : ↑(X.presheaf.obj (op ⊥))
x : ↑(X.presheaf.obj (op (X.basicOpen f)))
⊢ (X.presheaf.map (homOfLE (_ : X.basicOpen f ≤ ⊥)).op) f =
    (X.presheaf.map (homOfLE (_ : X.basicOpen f ≤ ⊥)).op) f ^ 0 * x

Next tactic:
refine' @Subsingleton.elim _
      (CommRingCat.subsingleton_of_isTerminal (X.sheaf.isTerminalOfEqEmpty _)) _ _
theorem exists_eq_pow_mul_of_isCompact_of_isQuasiSeparated (X : Scheme.{u}) (U : Opens X.carrier)
    (hU : IsCompact U.1) (hU' : IsQuasiSeparated U.1) (f : X.presheaf.obj (op U))
    (x : X.presheaf.obj (op <| X.basicOpen f)) :
    ∃ (n : ℕ) (y : X.presheaf.obj (op U)), y |_ X.basicOpen f = (f |_ X.basicOpen f) ^ n * x := by
  delta TopCat.Presheaf.restrictOpen TopCat.Presheaf.restrict
  revert hU' f x
  -- Porting note: complains `expected type is not available`, but tell Lean that it is underscore
  -- is sufficient
  apply compact_open_induction_on (P := _) U hU
  · intro _ f x
    use 0, f
    refine' @Subsingleton.elim _
      (CommRingCat.subsingleton_of_isTerminal (X.sheaf.isTerminalOfEqEmpty _)) _ _
    

Proof state:
case h
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact U.carrier
hU'✝ : IsQuasiSeparated ⊥.carrier
f : ↑(X.presheaf.obj (op ⊥))
x : ↑(X.presheaf.obj (op (X.basicOpen f)))
⊢ X.basicOpen f = ⊥

Next tactic:
erw [eq_bot_iff]
theorem exists_eq_pow_mul_of_isCompact_of_isQuasiSeparated (X : Scheme.{u}) (U : Opens X.carrier)
    (hU : IsCompact U.1) (hU' : IsQuasiSeparated U.1) (f : X.presheaf.obj (op U))
    (x : X.presheaf.obj (op <| X.basicOpen f)) :
    ∃ (n : ℕ) (y : X.presheaf.obj (op U)), y |_ X.basicOpen f = (f |_ X.basicOpen f) ^ n * x := by
  delta TopCat.Presheaf.restrictOpen TopCat.Presheaf.restrict
  revert hU' f x
  -- Porting note: complains `expected type is not available`, but tell Lean that it is underscore
  -- is sufficient
  apply compact_open_induction_on (P := _) U hU
  · intro _ f x
    use 0, f
    refine' @Subsingleton.elim _
      (CommRingCat.subsingleton_of_isTerminal (X.sheaf.isTerminalOfEqEmpty _)) _ _
    erw [eq_bot_iff]
    

Proof state:
case h
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact U.carrier
hU'✝ : IsQuasiSeparated ⊥.carrier
f : ↑(X.presheaf.obj (op ⊥))
x : ↑(X.presheaf.obj (op (X.basicOpen f)))
⊢ X.basicOpen f ≤ ⊥

Next tactic:
exact X.basicOpen_le f
theorem exists_eq_pow_mul_of_isCompact_of_isQuasiSeparated (X : Scheme.{u}) (U : Opens X.carrier)
    (hU : IsCompact U.1) (hU' : IsQuasiSeparated U.1) (f : X.presheaf.obj (op U))
    (x : X.presheaf.obj (op <| X.basicOpen f)) :
    ∃ (n : ℕ) (y : X.presheaf.obj (op U)), y |_ X.basicOpen f = (f |_ X.basicOpen f) ^ n * x := by
  delta TopCat.Presheaf.restrictOpen TopCat.Presheaf.restrict
  revert hU' f x
  -- Porting note: complains `expected type is not available`, but tell Lean that it is underscore
  -- is sufficient
  apply compact_open_induction_on (P := _) U hU
  · intro _ f x
    use 0, f
    refine' @Subsingleton.elim _
      (CommRingCat.subsingleton_of_isTerminal (X.sheaf.isTerminalOfEqEmpty _)) _ _
    erw [eq_bot_iff]
    exact X.basicOpen_le f
  · -- Given `f : 𝒪(S ∪ U), x : 𝒪(X_f)`, we need to show that `f ^ n * x` is the restriction of
    -- some `y : 𝒪(S ∪ U)` for some `n : ℕ`.
    

Proof state:
case h₂
X✝ Y : Scheme
f : X✝ ⟶ Y
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact U.carrier
⊢ ∀ (S : Opens ↑↑X.toPresheafedSpace),
    IsCompact S.carrier →
      ∀ (U : ↑(Scheme.affineOpens X)),
        (IsQuasiSeparated S.carrier →
            ∀ (f : ↑(X.presheaf.obj (op S))) (x : ↑(X.presheaf.obj (op (X.basicOpen f)))),
              ∃ n y,
                (X.presheaf.map (homOfLE (_ : X.basicOpen f ≤ S)).op) y =
                  (X.presheaf.map (homOfLE (_ : X.basicOpen f ≤ S)).op) f ^ n * x) →
          IsQuasiSeparated (S ⊔ ↑U).carrier →
            ∀ (f : ↑(X.presheaf.obj (op (S ⊔ ↑U)))) (x : ↑(X.presheaf.obj (op (X.basicOpen f)))),
              ∃ n y,
                (X.presheaf.map (homOfLE (_ : X.basicOpen f ≤ S ⊔ ↑U)).op) y =
                  (X.presheaf.map (homOfLE (_ : X.basicOpen f ≤ S ⊔ ↑U)).op) f ^ n * x

Next tactic:
intro S hS U hU hSU f x
theorem exists_eq_pow_mul_of_isCompact_of_isQuasiSeparated (X : Scheme.{u}) (U : Opens X.carrier)
    (hU : IsCompact U.1) (hU' : IsQuasiSeparated U.1) (f : X.presheaf.obj (op U))
    (x : X.presheaf.obj (op <| X.basicOpen f)) :
    ∃ (n : ℕ) (y : X.presheaf.obj (op U)), y |_ X.basicOpen f = (f |_ X.basicOpen f) ^ n * x := by
  delta TopCat.Presheaf.restrictOpen TopCat.Presheaf.restrict
  revert hU' f x
  -- Porting note: complains `expected type is not available`, but tell Lean that it is underscore
  -- is sufficient
  apply compact_open_induction_on (P := _) U hU
  · intro _ f x
    use 0, f
    refine' @Subsingleton.elim _
      (CommRingCat.subsingleton_of_isTerminal (X.sheaf.isTerminalOfEqEmpty _)) _ _
    erw [eq_bot_iff]
    exact X.basicOpen_le f
  · -- Given `f : 𝒪(S ∪ U), x : 𝒪(X_f)`, we need to show that `f ^ n * x` is the restriction of
    -- some `y : 𝒪(S ∪ U)` for some `n : ℕ`.
    intro S hS U hU hSU f x
    -- We know that such `y₁, n₁` exists on `S` by the induction hypothesis.
    

Proof state:
case h₂
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U✝ : Opens ↑↑X.toPresheafedSpace
hU✝ : IsCompact U✝.carrier
S : Opens ↑↑X.toPresheafedSpace
hS : IsCompact S.carrier
U : ↑(Scheme.affineOpens X)
hU :
  IsQuasiSeparated S.carrier →
    ∀ (f : ↑(X.presheaf.obj (op S))) (x : ↑(X.presheaf.obj (op (X.basicOpen f)))),
      ∃ n y,
        (X.presheaf.map (homOfLE (_ : X.basicOpen f ≤ S)).op) y =
          (X.presheaf.map (homOfLE (_ : X.basicOpen f ≤ S)).op) f ^ n * x
hSU : IsQuasiSeparated (S ⊔ ↑U).carrier
f : ↑(X.presheaf.obj (op (S ⊔ ↑U)))
x : ↑(X.presheaf.obj (op (X.basicOpen f)))
⊢ ∃ n y,
    (X.presheaf.map (homOfLE (_ : X.basicOpen f ≤ S ⊔ ↑U)).op) y =
      (X.presheaf.map (homOfLE (_ : X.basicOpen f ≤ S ⊔ ↑U)).op) f ^ n * x

Next tactic:
obtain ⟨n₁, y₁, hy₁⟩ :=
      hU (hSU.of_subset <| Set.subset_union_left _ _) (X.presheaf.map (homOfLE le_sup_left).op f)
        (X.presheaf.map (homOfLE _).op x)
theorem exists_eq_pow_mul_of_isCompact_of_isQuasiSeparated (X : Scheme.{u}) (U : Opens X.carrier)
    (hU : IsCompact U.1) (hU' : IsQuasiSeparated U.1) (f : X.presheaf.obj (op U))
    (x : X.presheaf.obj (op <| X.basicOpen f)) :
    ∃ (n : ℕ) (y : X.presheaf.obj (op U)), y |_ X.basicOpen f = (f |_ X.basicOpen f) ^ n * x := by
  delta TopCat.Presheaf.restrictOpen TopCat.Presheaf.restrict
  revert hU' f x
  -- Porting note: complains `expected type is not available`, but tell Lean that it is underscore
  -- is sufficient
  apply compact_open_induction_on (P := _) U hU
  · intro _ f x
    use 0, f
    refine' @Subsingleton.elim _
      (CommRingCat.subsingleton_of_isTerminal (X.sheaf.isTerminalOfEqEmpty _)) _ _
    erw [eq_bot_iff]
    exact X.basicOpen_le f
  · -- Given `f : 𝒪(S ∪ U), x : 𝒪(X_f)`, we need to show that `f ^ n * x` is the restriction of
    -- some `y : 𝒪(S ∪ U)` for some `n : ℕ`.
    intro S hS U hU hSU f x
    -- We know that such `y₁, n₁` exists on `S` by the induction hypothesis.
    obtain ⟨n₁, y₁, hy₁⟩ :=
      hU (hSU.of_subset <| Set.subset_union_left _ _) (X.presheaf.map (homOfLE le_sup_left).op f)
        (X.presheaf.map (homOfLE _).op x)
    -- · rw [X.basicOpen_res]; exact inf_le_right
    -- We know that such `y₂, n₂` exists on `U` since `U` is affine.
    

Proof state:
case h₂.intro.intro
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U✝ : Opens ↑↑X.toPresheafedSpace
hU✝ : IsCompact U✝.carrier
S : Opens ↑↑X.toPresheafedSpace
hS : IsCompact S.carrier
U : ↑(Scheme.affineOpens X)
hU :
  IsQuasiSeparated S.carrier →
    ∀ (f : ↑(X.presheaf.obj (op S))) (x : ↑(X.presheaf.obj (op (X.basicOpen f)))),
      ∃ n y,
        (X.presheaf.map (homOfLE (_ : X.basicOpen f ≤ S)).op) y =
          (X.presheaf.map (homOfLE (_ : X.basicOpen f ≤ S)).op) f ^ n * x
hSU : IsQuasiSeparated (S ⊔ ↑U).carrier
f : ↑(X.presheaf.obj (op (S ⊔ ↑U)))
x : ↑(X.presheaf.obj (op (X.basicOpen f)))
n₁ : ℕ
y₁ : ↑(X.presheaf.obj (op S))
hy₁ :
  (X.presheaf.map (homOfLE (_ : X.basicOpen ((X.presheaf.map (homOfLE (_ : S ≤ S ⊔ ↑U)).op) f) ≤ S)).op) y₁ =
    (X.presheaf.map (homOfLE (_ : X.basicOpen ((X.presheaf.map (homOfLE (_ : S ≤ S ⊔ ↑U)).op) f) ≤ S)).op)
          ((X.presheaf.map (homOfLE (_ : S ≤ S ⊔ ↑U)).op) f) ^
        n₁ *
      (X.presheaf.map (homOfLE ?m.404197).op) x
⊢ ∃ n y,
    (X.presheaf.map (homOfLE (_ : X.basicOpen f ≤ S ⊔ ↑U)).op) y =
      (X.presheaf.map (homOfLE (_ : X.basicOpen f ≤ S ⊔ ↑U)).op) f ^ n * x

Next tactic:
obtain ⟨n₂, y₂, hy₂⟩ :=
      exists_eq_pow_mul_of_isAffineOpen X _ U.2 (X.presheaf.map (homOfLE le_sup_right).op f)
        (X.presheaf.map (homOfLE _).op x)
theorem exists_eq_pow_mul_of_isCompact_of_isQuasiSeparated (X : Scheme.{u}) (U : Opens X.carrier)
    (hU : IsCompact U.1) (hU' : IsQuasiSeparated U.1) (f : X.presheaf.obj (op U))
    (x : X.presheaf.obj (op <| X.basicOpen f)) :
    ∃ (n : ℕ) (y : X.presheaf.obj (op U)), y |_ X.basicOpen f = (f |_ X.basicOpen f) ^ n * x := by
  delta TopCat.Presheaf.restrictOpen TopCat.Presheaf.restrict
  revert hU' f x
  -- Porting note: complains `expected type is not available`, but tell Lean that it is underscore
  -- is sufficient
  apply compact_open_induction_on (P := _) U hU
  · intro _ f x
    use 0, f
    refine' @Subsingleton.elim _
      (CommRingCat.subsingleton_of_isTerminal (X.sheaf.isTerminalOfEqEmpty _)) _ _
    erw [eq_bot_iff]
    exact X.basicOpen_le f
  · -- Given `f : 𝒪(S ∪ U), x : 𝒪(X_f)`, we need to show that `f ^ n * x` is the restriction of
    -- some `y : 𝒪(S ∪ U)` for some `n : ℕ`.
    intro S hS U hU hSU f x
    -- We know that such `y₁, n₁` exists on `S` by the induction hypothesis.
    obtain ⟨n₁, y₁, hy₁⟩ :=
      hU (hSU.of_subset <| Set.subset_union_left _ _) (X.presheaf.map (homOfLE le_sup_left).op f)
        (X.presheaf.map (homOfLE _).op x)
    -- · rw [X.basicOpen_res]; exact inf_le_right
    -- We know that such `y₂, n₂` exists on `U` since `U` is affine.
    obtain ⟨n₂, y₂, hy₂⟩ :=
      exists_eq_pow_mul_of_isAffineOpen X _ U.2 (X.presheaf.map (homOfLE le_sup_right).op f)
        (X.presheaf.map (homOfLE _).op x)
    

Proof state:
case h₂.intro.intro.intro.intro
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U✝ : Opens ↑↑X.toPresheafedSpace
hU✝ : IsCompact U✝.carrier
S : Opens ↑↑X.toPresheafedSpace
hS : IsCompact S.carrier
U : ↑(Scheme.affineOpens X)
hU :
  IsQuasiSeparated S.carrier →
    ∀ (f : ↑(X.presheaf.obj (op S))) (x : ↑(X.presheaf.obj (op (X.basicOpen f)))),
      ∃ n y,
        (X.presheaf.map (homOfLE (_ : X.basicOpen f ≤ S)).op) y =
          (X.presheaf.map (homOfLE (_ : X.basicOpen f ≤ S)).op) f ^ n * x
hSU : IsQuasiSeparated (S ⊔ ↑U).carrier
f : ↑(X.presheaf.obj (op (S ⊔ ↑U)))
x : ↑(X.presheaf.obj (op (X.basicOpen f)))
n₁ : ℕ
y₁ : ↑(X.presheaf.obj (op S))
hy₁ :
  (X.presheaf.map (homOfLE (_ : X.basicOpen ((X.presheaf.map (homOfLE (_ : S ≤ S ⊔ ↑U)).op) f) ≤ S)).op) y₁ =
    (X.presheaf.map (homOfLE (_ : X.basicOpen ((X.presheaf.map (homOfLE (_ : S ≤ S ⊔ ↑U)).op) f) ≤ S)).op)
          ((X.presheaf.map (homOfLE (_ : S ≤ S ⊔ ↑U)).op) f) ^
        n₁ *
      (X.presheaf.map (homOfLE ?m.404197).op) x
n₂ : ℕ
y₂ : ↑(X.presheaf.obj (op ↑U))
hy₂ :
  y₂ |_ X.basicOpen ((X.presheaf.map (homOfLE (_ : ↑U ≤ S ⊔ ↑U)).op) f) =
    ((X.presheaf.map (homOfLE (_ : ↑U ≤ S ⊔ ↑U)).op) f |_
          X.basicOpen ((X.presheaf.map (homOfLE (_ : ↑U ≤ S ⊔ ↑U)).op) f)) ^
        n₂ *
      (X.presheaf.map (homOfLE ?m.405056).op) x
⊢ ∃ n y,
    (X.presheaf.map (homOfLE (_ : X.basicOpen f ≤ S ⊔ ↑U)).op) y =
      (X.presheaf.map (homOfLE (_ : X.basicOpen f ≤ S ⊔ ↑U)).op) f ^ n * x

Next tactic:
delta TopCat.Presheaf.restrictOpen TopCat.Presheaf.restrict at hy₂
/-- If `U` is qcqs, then `Γ(X, D(f)) ≃ Γ(X, U)_f` for every `f : Γ(X, U)`.
This is known as the **Qcqs lemma** in [R. Vakil, *The rising sea*][RisingSea]. -/
theorem is_localization_basicOpen_of_qcqs {X : Scheme} {U : Opens X.carrier} (hU : IsCompact U.1)
    (hU' : IsQuasiSeparated U.1) (f : X.presheaf.obj (op U)) :
    IsLocalization.Away f (X.presheaf.obj (op <| X.basicOpen f)) := by
  

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

Next tactic:
constructor
/-- If `U` is qcqs, then `Γ(X, D(f)) ≃ Γ(X, U)_f` for every `f : Γ(X, U)`.
This is known as the **Qcqs lemma** in [R. Vakil, *The rising sea*][RisingSea]. -/
theorem is_localization_basicOpen_of_qcqs {X : Scheme} {U : Opens X.carrier} (hU : IsCompact U.1)
    (hU' : IsQuasiSeparated U.1) (f : X.presheaf.obj (op U)) :
    IsLocalization.Away f (X.presheaf.obj (op <| X.basicOpen f)) := by
  constructor
  · 

Proof state:
case map_units'
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact U.carrier
hU' : IsQuasiSeparated U.carrier
f : ↑(X.presheaf.obj (op U))
⊢ ∀ (y : ↥(Submonoid.powers f)),
    IsUnit ((algebraMap ↑(X.presheaf.obj (op U)) ↑(X.presheaf.obj (op (X.basicOpen f)))) ↑y)

Next tactic:
rintro ⟨_, n, rfl⟩
/-- If `U` is qcqs, then `Γ(X, D(f)) ≃ Γ(X, U)_f` for every `f : Γ(X, U)`.
This is known as the **Qcqs lemma** in [R. Vakil, *The rising sea*][RisingSea]. -/
theorem is_localization_basicOpen_of_qcqs {X : Scheme} {U : Opens X.carrier} (hU : IsCompact U.1)
    (hU' : IsQuasiSeparated U.1) (f : X.presheaf.obj (op U)) :
    IsLocalization.Away f (X.presheaf.obj (op <| X.basicOpen f)) := by
  constructor
  · rintro ⟨_, n, rfl⟩
    

Proof state:
case map_units'.mk.intro
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact U.carrier
hU' : IsQuasiSeparated U.carrier
f : ↑(X.presheaf.obj (op U))
n : ℕ
⊢ IsUnit
    ((algebraMap ↑(X.presheaf.obj (op U)) ↑(X.presheaf.obj (op (X.basicOpen f))))
      ↑{ val := (fun x => f ^ x) n, property := (_ : ∃ y, (fun x => f ^ x) y = (fun x => f ^ x) n) })

Next tactic:
simp only [map_pow, Subtype.coe_mk, RingHom.algebraMap_toAlgebra]
/-- If `U` is qcqs, then `Γ(X, D(f)) ≃ Γ(X, U)_f` for every `f : Γ(X, U)`.
This is known as the **Qcqs lemma** in [R. Vakil, *The rising sea*][RisingSea]. -/
theorem is_localization_basicOpen_of_qcqs {X : Scheme} {U : Opens X.carrier} (hU : IsCompact U.1)
    (hU' : IsQuasiSeparated U.1) (f : X.presheaf.obj (op U)) :
    IsLocalization.Away f (X.presheaf.obj (op <| X.basicOpen f)) := by
  constructor
  · rintro ⟨_, n, rfl⟩
    simp only [map_pow, Subtype.coe_mk, RingHom.algebraMap_toAlgebra]
    

Proof state:
case map_units'.mk.intro
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact U.carrier
hU' : IsQuasiSeparated U.carrier
f : ↑(X.presheaf.obj (op U))
n : ℕ
⊢ IsUnit ((X.presheaf.map (homOfLE (_ : X.basicOpen f ≤ U)).op) f ^ n)

Next tactic:
exact IsUnit.pow _ (RingedSpace.isUnit_res_basicOpen _ f)
/-- If `U` is qcqs, then `Γ(X, D(f)) ≃ Γ(X, U)_f` for every `f : Γ(X, U)`.
This is known as the **Qcqs lemma** in [R. Vakil, *The rising sea*][RisingSea]. -/
theorem is_localization_basicOpen_of_qcqs {X : Scheme} {U : Opens X.carrier} (hU : IsCompact U.1)
    (hU' : IsQuasiSeparated U.1) (f : X.presheaf.obj (op U)) :
    IsLocalization.Away f (X.presheaf.obj (op <| X.basicOpen f)) := by
  constructor
  · rintro ⟨_, n, rfl⟩
    simp only [map_pow, Subtype.coe_mk, RingHom.algebraMap_toAlgebra]
    exact IsUnit.pow _ (RingedSpace.isUnit_res_basicOpen _ f)
  · 

Proof state:
case surj'
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact U.carrier
hU' : IsQuasiSeparated U.carrier
f : ↑(X.presheaf.obj (op U))
⊢ ∀ (z : ↑(X.presheaf.obj (op (X.basicOpen f)))),
    ∃ x,
      z * (algebraMap ↑(X.presheaf.obj (op U)) ↑(X.presheaf.obj (op (X.basicOpen f)))) ↑x.2 =
        (algebraMap ↑(X.presheaf.obj (op U)) ↑(X.presheaf.obj (op (X.basicOpen f)))) x.1

Next tactic:
intro z
/-- If `U` is qcqs, then `Γ(X, D(f)) ≃ Γ(X, U)_f` for every `f : Γ(X, U)`.
This is known as the **Qcqs lemma** in [R. Vakil, *The rising sea*][RisingSea]. -/
theorem is_localization_basicOpen_of_qcqs {X : Scheme} {U : Opens X.carrier} (hU : IsCompact U.1)
    (hU' : IsQuasiSeparated U.1) (f : X.presheaf.obj (op U)) :
    IsLocalization.Away f (X.presheaf.obj (op <| X.basicOpen f)) := by
  constructor
  · rintro ⟨_, n, rfl⟩
    simp only [map_pow, Subtype.coe_mk, RingHom.algebraMap_toAlgebra]
    exact IsUnit.pow _ (RingedSpace.isUnit_res_basicOpen _ f)
  · intro z
    

Proof state:
case surj'
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact U.carrier
hU' : IsQuasiSeparated U.carrier
f : ↑(X.presheaf.obj (op U))
z : ↑(X.presheaf.obj (op (X.basicOpen f)))
⊢ ∃ x,
    z * (algebraMap ↑(X.presheaf.obj (op U)) ↑(X.presheaf.obj (op (X.basicOpen f)))) ↑x.2 =
      (algebraMap ↑(X.presheaf.obj (op U)) ↑(X.presheaf.obj (op (X.basicOpen f)))) x.1

Next tactic:
obtain ⟨n, y, e⟩ := exists_eq_pow_mul_of_isCompact_of_isQuasiSeparated X U hU hU' f z
/-- If `U` is qcqs, then `Γ(X, D(f)) ≃ Γ(X, U)_f` for every `f : Γ(X, U)`.
This is known as the **Qcqs lemma** in [R. Vakil, *The rising sea*][RisingSea]. -/
theorem is_localization_basicOpen_of_qcqs {X : Scheme} {U : Opens X.carrier} (hU : IsCompact U.1)
    (hU' : IsQuasiSeparated U.1) (f : X.presheaf.obj (op U)) :
    IsLocalization.Away f (X.presheaf.obj (op <| X.basicOpen f)) := by
  constructor
  · rintro ⟨_, n, rfl⟩
    simp only [map_pow, Subtype.coe_mk, RingHom.algebraMap_toAlgebra]
    exact IsUnit.pow _ (RingedSpace.isUnit_res_basicOpen _ f)
  · intro z
    obtain ⟨n, y, e⟩ := exists_eq_pow_mul_of_isCompact_of_isQuasiSeparated X U hU hU' f z
    

Proof state:
case surj'.intro.intro
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact U.carrier
hU' : IsQuasiSeparated U.carrier
f : ↑(X.presheaf.obj (op U))
z : ↑(X.presheaf.obj (op (X.basicOpen f)))
n : ℕ
y : ↑(X.presheaf.obj (op U))
e : y |_ X.basicOpen f = (f |_ X.basicOpen f) ^ n * z
⊢ ∃ x,
    z * (algebraMap ↑(X.presheaf.obj (op U)) ↑(X.presheaf.obj (op (X.basicOpen f)))) ↑x.2 =
      (algebraMap ↑(X.presheaf.obj (op U)) ↑(X.presheaf.obj (op (X.basicOpen f)))) x.1

Next tactic:
refine' ⟨⟨y, _, n, rfl⟩, _⟩
/-- If `U` is qcqs, then `Γ(X, D(f)) ≃ Γ(X, U)_f` for every `f : Γ(X, U)`.
This is known as the **Qcqs lemma** in [R. Vakil, *The rising sea*][RisingSea]. -/
theorem is_localization_basicOpen_of_qcqs {X : Scheme} {U : Opens X.carrier} (hU : IsCompact U.1)
    (hU' : IsQuasiSeparated U.1) (f : X.presheaf.obj (op U)) :
    IsLocalization.Away f (X.presheaf.obj (op <| X.basicOpen f)) := by
  constructor
  · rintro ⟨_, n, rfl⟩
    simp only [map_pow, Subtype.coe_mk, RingHom.algebraMap_toAlgebra]
    exact IsUnit.pow _ (RingedSpace.isUnit_res_basicOpen _ f)
  · intro z
    obtain ⟨n, y, e⟩ := exists_eq_pow_mul_of_isCompact_of_isQuasiSeparated X U hU hU' f z
    refine' ⟨⟨y, _, n, rfl⟩, _⟩
    

Proof state:
case surj'.intro.intro
X✝ Y : Scheme
f✝ : X✝ ⟶ Y
X : Scheme
U : Opens ↑↑X.toPresheafedSpace
hU : IsCompact U.carrier
hU' : IsQuasiSeparated U.carrier
f : ↑(X.presheaf.obj (op U))
z : ↑(X.presheaf.obj (op (X.basicOpen f)))
n : ℕ
y : ↑(X.presheaf.obj (op U))
e : y |_ X.basicOpen f = (f |_ X.basicOpen f) ^ n * z
⊢ z *
      (algebraMap ↑(X.presheaf.obj (op U)) ↑(X.presheaf.obj (op (X.basicOpen f))))
        ↑(y, { val := (fun x => f ^ x) n, property := (_ : ∃ y, (fun x => f ^ x) y = (fun x => f ^ x) n) }).2 =
    (algebraMap ↑(X.presheaf.obj (op U)) ↑(X.presheaf.obj (op (X.basicOpen f))))
      (y, { val := (fun x => f ^ x) n, property := (_ : ∃ y, (fun x => f ^ x) y = (fun x => f ^ x) n) }).1

Next tactic:
simpa only [map_pow, Subtype.coe_mk, RingHom.algebraMap_toAlgebra, mul_comm z] using e.symm