l3lab/ntp-mathlib huggingface dataset:
/-- An isomorphism `X ⟶ Y` is an open cover of `Y`. -/
@[simps J obj map]
def openCoverOfIsIso {X Y : Scheme.{u}} (f : X ⟶ Y) [IsIso f] : OpenCover Y where
  J := PUnit.{v + 1}
  obj _ := X
  map _ := f
  f _ := PUnit.unit
  Covers x := by
    rw [Set.range_iff_surjective.mpr]
    all_goals try 

Proof state:
C : Type u
inst✝² : Category.{v, u} C
X✝ Y✝ Z : Scheme
𝒰 : OpenCover X✝
f✝ : X✝ ⟶ Z
g : Y✝ ⟶ Z
inst✝¹ : ∀ (x : 𝒰.J), HasPullback (OpenCover.map 𝒰 x ≫ f✝) g
X Y : Scheme
f : X ⟶ Y
inst✝ : IsIso f
x : ↑↑Y.toPresheafedSpace
⊢ Function.Surjective ⇑((fun x => f) ((fun x => PUnit.unit) x)).val.base

Next tactic:
trivial
/-- An isomorphism `X ⟶ Y` is an open cover of `Y`. -/
@[simps J obj map]
def openCoverOfIsIso {X Y : Scheme.{u}} (f : X ⟶ Y) [IsIso f] : OpenCover Y where
  J := PUnit.{v + 1}
  obj _ := X
  map _ := f
  f _ := PUnit.unit
  Covers x := by
    rw [Set.range_iff_surjective.mpr]
    all_goals try trivial
    

Proof state:
C : Type u
inst✝² : Category.{v, u} C
X✝ Y✝ Z : Scheme
𝒰 : OpenCover X✝
f✝ : X✝ ⟶ Z
g : Y✝ ⟶ Z
inst✝¹ : ∀ (x : 𝒰.J), HasPullback (OpenCover.map 𝒰 x ≫ f✝) g
X Y : Scheme
f : X ⟶ Y
inst✝ : IsIso f
x : ↑↑Y.toPresheafedSpace
⊢ Function.Surjective ⇑((fun x => f) ((fun x => PUnit.unit) x)).val.base

Next tactic:
rw [← TopCat.epi_iff_surjective]
/-- An isomorphism `X ⟶ Y` is an open cover of `Y`. -/
@[simps J obj map]
def openCoverOfIsIso {X Y : Scheme.{u}} (f : X ⟶ Y) [IsIso f] : OpenCover Y where
  J := PUnit.{v + 1}
  obj _ := X
  map _ := f
  f _ := PUnit.unit
  Covers x := by
    rw [Set.range_iff_surjective.mpr]
    all_goals try trivial
    rw [← TopCat.epi_iff_surjective]
    

Proof state:
C : Type u
inst✝² : Category.{v, u} C
X✝ Y✝ Z : Scheme
𝒰 : OpenCover X✝
f✝ : X✝ ⟶ Z
g : Y✝ ⟶ Z
inst✝¹ : ∀ (x : 𝒰.J), HasPullback (OpenCover.map 𝒰 x ≫ f✝) g
X Y : Scheme
f : X ⟶ Y
inst✝ : IsIso f
x : ↑↑Y.toPresheafedSpace
⊢ Epi ((fun x => f) ((fun x => PUnit.unit) x)).val.base

Next tactic:
infer_instance
/-- We construct an open cover from another, by providing the needed fields and showing that the
provided fields are isomorphic with the original open cover. -/
@[simps J obj map]
def OpenCover.copy {X : Scheme} (𝒰 : OpenCover X) (J : Type*) (obj : J → Scheme)
    (map : ∀ i, obj i ⟶ X) (e₁ : J ≃ 𝒰.J) (e₂ : ∀ i, obj i ≅ 𝒰.obj (e₁ i))
    (e₂ : ∀ i, map i = (e₂ i).hom ≫ 𝒰.map (e₁ i)) : OpenCover X :=
  { J, obj, map
    f := fun x => e₁.symm (𝒰.f x)
    Covers := fun x => by
      

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X✝ Y Z : Scheme
𝒰✝ : OpenCover X✝
f : X✝ ⟶ Z
g : Y ⟶ Z
inst✝ : ∀ (x : 𝒰✝.J), HasPullback (AlgebraicGeometry.Scheme.OpenCover.map 𝒰✝ x ≫ f) g
X : Scheme
𝒰 : OpenCover X
J : Type u_1
obj : J → Scheme
map : (i : J) → obj i ⟶ X
e₁ : J ≃ 𝒰.J
e₂✝ : (i : J) → obj i ≅ AlgebraicGeometry.Scheme.OpenCover.obj 𝒰 (e₁ i)
e₂ : ∀ (i : J), map i = (e₂✝ i).hom ≫ AlgebraicGeometry.Scheme.OpenCover.map 𝒰 (e₁ i)
x : ↑↑X.toPresheafedSpace
⊢ x ∈ Set.range ⇑(map ((fun x => e₁.symm (AlgebraicGeometry.Scheme.OpenCover.f 𝒰 x)) x)).val.base

Next tactic:
rw [e₂, Scheme.comp_val_base, coe_comp, Set.range_comp, Set.range_iff_surjective.mpr,
        Set.image_univ, e₁.rightInverse_symm]
/-- We construct an open cover from another, by providing the needed fields and showing that the
provided fields are isomorphic with the original open cover. -/
@[simps J obj map]
def OpenCover.copy {X : Scheme} (𝒰 : OpenCover X) (J : Type*) (obj : J → Scheme)
    (map : ∀ i, obj i ⟶ X) (e₁ : J ≃ 𝒰.J) (e₂ : ∀ i, obj i ≅ 𝒰.obj (e₁ i))
    (e₂ : ∀ i, map i = (e₂ i).hom ≫ 𝒰.map (e₁ i)) : OpenCover X :=
  { J, obj, map
    f := fun x => e₁.symm (𝒰.f x)
    Covers := fun x => by
      rw [e₂, Scheme.comp_val_base, coe_comp, Set.range_comp, Set.range_iff_surjective.mpr,
        Set.image_univ, e₁.rightInverse_symm]
      · 

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X✝ Y Z : Scheme
𝒰✝ : OpenCover X✝
f : X✝ ⟶ Z
g : Y ⟶ Z
inst✝ : ∀ (x : 𝒰✝.J), HasPullback (AlgebraicGeometry.Scheme.OpenCover.map 𝒰✝ x ≫ f) g
X : Scheme
𝒰 : OpenCover X
J : Type u_1
obj : J → Scheme
map : (i : J) → obj i ⟶ X
e₁ : J ≃ 𝒰.J
e₂✝ : (i : J) → obj i ≅ AlgebraicGeometry.Scheme.OpenCover.obj 𝒰 (e₁ i)
e₂ : ∀ (i : J), map i = (e₂✝ i).hom ≫ AlgebraicGeometry.Scheme.OpenCover.map 𝒰 (e₁ i)
x : ↑↑X.toPresheafedSpace
⊢ x ∈ Set.range ⇑(AlgebraicGeometry.Scheme.OpenCover.map 𝒰 (AlgebraicGeometry.Scheme.OpenCover.f 𝒰 x)).val.base

Next tactic:
exact 𝒰.Covers x
/-- We construct an open cover from another, by providing the needed fields and showing that the
provided fields are isomorphic with the original open cover. -/
@[simps J obj map]
def OpenCover.copy {X : Scheme} (𝒰 : OpenCover X) (J : Type*) (obj : J → Scheme)
    (map : ∀ i, obj i ⟶ X) (e₁ : J ≃ 𝒰.J) (e₂ : ∀ i, obj i ≅ 𝒰.obj (e₁ i))
    (e₂ : ∀ i, map i = (e₂ i).hom ≫ 𝒰.map (e₁ i)) : OpenCover X :=
  { J, obj, map
    f := fun x => e₁.symm (𝒰.f x)
    Covers := fun x => by
      rw [e₂, Scheme.comp_val_base, coe_comp, Set.range_comp, Set.range_iff_surjective.mpr,
        Set.image_univ, e₁.rightInverse_symm]
      · exact 𝒰.Covers x
      · 

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X✝ Y Z : Scheme
𝒰✝ : OpenCover X✝
f : X✝ ⟶ Z
g : Y ⟶ Z
inst✝ : ∀ (x : 𝒰✝.J), HasPullback (AlgebraicGeometry.Scheme.OpenCover.map 𝒰✝ x ≫ f) g
X : Scheme
𝒰 : OpenCover X
J : Type u_1
obj : J → Scheme
map : (i : J) → obj i ⟶ X
e₁ : J ≃ 𝒰.J
e₂✝ : (i : J) → obj i ≅ AlgebraicGeometry.Scheme.OpenCover.obj 𝒰 (e₁ i)
e₂ : ∀ (i : J), map i = (e₂✝ i).hom ≫ AlgebraicGeometry.Scheme.OpenCover.map 𝒰 (e₁ i)
x : ↑↑X.toPresheafedSpace
⊢ Function.Surjective ⇑(e₂✝ ((fun x => e₁.symm (AlgebraicGeometry.Scheme.OpenCover.f 𝒰 x)) x)).hom.val.base

Next tactic:
rw [← TopCat.epi_iff_surjective]
/-- We construct an open cover from another, by providing the needed fields and showing that the
provided fields are isomorphic with the original open cover. -/
@[simps J obj map]
def OpenCover.copy {X : Scheme} (𝒰 : OpenCover X) (J : Type*) (obj : J → Scheme)
    (map : ∀ i, obj i ⟶ X) (e₁ : J ≃ 𝒰.J) (e₂ : ∀ i, obj i ≅ 𝒰.obj (e₁ i))
    (e₂ : ∀ i, map i = (e₂ i).hom ≫ 𝒰.map (e₁ i)) : OpenCover X :=
  { J, obj, map
    f := fun x => e₁.symm (𝒰.f x)
    Covers := fun x => by
      rw [e₂, Scheme.comp_val_base, coe_comp, Set.range_comp, Set.range_iff_surjective.mpr,
        Set.image_univ, e₁.rightInverse_symm]
      · exact 𝒰.Covers x
      · rw [← TopCat.epi_iff_surjective]; 

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X✝ Y Z : Scheme
𝒰✝ : OpenCover X✝
f : X✝ ⟶ Z
g : Y ⟶ Z
inst✝ : ∀ (x : 𝒰✝.J), HasPullback (AlgebraicGeometry.Scheme.OpenCover.map 𝒰✝ x ≫ f) g
X : Scheme
𝒰 : OpenCover X
J : Type u_1
obj : J → Scheme
map : (i : J) → obj i ⟶ X
e₁ : J ≃ 𝒰.J
e₂✝ : (i : J) → obj i ≅ AlgebraicGeometry.Scheme.OpenCover.obj 𝒰 (e₁ i)
e₂ : ∀ (i : J), map i = (e₂✝ i).hom ≫ AlgebraicGeometry.Scheme.OpenCover.map 𝒰 (e₁ i)
x : ↑↑X.toPresheafedSpace
⊢ Epi (e₂✝ ((fun x => e₁.symm (AlgebraicGeometry.Scheme.OpenCover.f 𝒰 x)) x)).hom.val.base

Next tactic:
infer_instance
/-- We construct an open cover from another, by providing the needed fields and showing that the
provided fields are isomorphic with the original open cover. -/
@[simps J obj map]
def OpenCover.copy {X : Scheme} (𝒰 : OpenCover X) (J : Type*) (obj : J → Scheme)
    (map : ∀ i, obj i ⟶ X) (e₁ : J ≃ 𝒰.J) (e₂ : ∀ i, obj i ≅ 𝒰.obj (e₁ i))
    (e₂ : ∀ i, map i = (e₂ i).hom ≫ 𝒰.map (e₁ i)) : OpenCover X :=
  { J, obj, map
    f := fun x => e₁.symm (𝒰.f x)
    Covers := fun x => by
      rw [e₂, Scheme.comp_val_base, coe_comp, Set.range_comp, Set.range_iff_surjective.mpr,
        Set.image_univ, e₁.rightInverse_symm]
      · exact 𝒰.Covers x
      · rw [← TopCat.epi_iff_surjective]; infer_instance
    -- Porting note : weirdly, even though no input is needed, `inferInstance` does not work
    -- `PresheafedSpace.IsOpenImmersion.comp` is marked as `instance`
    IsOpen := fun i => by 

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X✝ Y Z : Scheme
𝒰✝ : OpenCover X✝
f : X✝ ⟶ Z
g : Y ⟶ Z
inst✝ : ∀ (x : 𝒰✝.J), HasPullback (AlgebraicGeometry.Scheme.OpenCover.map 𝒰✝ x ≫ f) g
X : Scheme
𝒰 : OpenCover X
J : Type u_1
obj : J → Scheme
map : (i : J) → obj i ⟶ X
e₁ : J ≃ 𝒰.J
e₂✝ : (i : J) → obj i ≅ AlgebraicGeometry.Scheme.OpenCover.obj 𝒰 (e₁ i)
e₂ : ∀ (i : J), map i = (e₂✝ i).hom ≫ AlgebraicGeometry.Scheme.OpenCover.map 𝒰 (e₁ i)
i : J
⊢ IsOpenImmersion (map i)

Next tactic:
rw [e₂]
/-- We construct an open cover from another, by providing the needed fields and showing that the
provided fields are isomorphic with the original open cover. -/
@[simps J obj map]
def OpenCover.copy {X : Scheme} (𝒰 : OpenCover X) (J : Type*) (obj : J → Scheme)
    (map : ∀ i, obj i ⟶ X) (e₁ : J ≃ 𝒰.J) (e₂ : ∀ i, obj i ≅ 𝒰.obj (e₁ i))
    (e₂ : ∀ i, map i = (e₂ i).hom ≫ 𝒰.map (e₁ i)) : OpenCover X :=
  { J, obj, map
    f := fun x => e₁.symm (𝒰.f x)
    Covers := fun x => by
      rw [e₂, Scheme.comp_val_base, coe_comp, Set.range_comp, Set.range_iff_surjective.mpr,
        Set.image_univ, e₁.rightInverse_symm]
      · exact 𝒰.Covers x
      · rw [← TopCat.epi_iff_surjective]; infer_instance
    -- Porting note : weirdly, even though no input is needed, `inferInstance` does not work
    -- `PresheafedSpace.IsOpenImmersion.comp` is marked as `instance`
    IsOpen := fun i => by rw [e₂]; 

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X✝ Y Z : Scheme
𝒰✝ : OpenCover X✝
f : X✝ ⟶ Z
g : Y ⟶ Z
inst✝ : ∀ (x : 𝒰✝.J), HasPullback (AlgebraicGeometry.Scheme.OpenCover.map 𝒰✝ x ≫ f) g
X : Scheme
𝒰 : OpenCover X
J : Type u_1
obj : J → Scheme
map : (i : J) → obj i ⟶ X
e₁ : J ≃ 𝒰.J
e₂✝ : (i : J) → obj i ≅ AlgebraicGeometry.Scheme.OpenCover.obj 𝒰 (e₁ i)
e₂ : ∀ (i : J), map i = (e₂✝ i).hom ≫ AlgebraicGeometry.Scheme.OpenCover.map 𝒰 (e₁ i)
i : J
⊢ IsOpenImmersion ((e₂✝ i).hom ≫ AlgebraicGeometry.Scheme.OpenCover.map 𝒰 (e₁ i))

Next tactic:
exact PresheafedSpace.IsOpenImmersion.comp _ _
/-- Adding an open immersion into an open cover gives another open cover. -/
@[simps]
def OpenCover.add {X : Scheme} (𝒰 : X.OpenCover) {Y : Scheme} (f : Y ⟶ X) [IsOpenImmersion f] :
    X.OpenCover where
  J := Option 𝒰.J
  obj i := Option.rec Y 𝒰.obj i
  map i := Option.rec f 𝒰.map i
  f x := some (𝒰.f x)
  Covers := 𝒰.Covers
  IsOpen := by 

Proof state:
C : Type u
inst✝² : Category.{v, u} C
X✝ Y✝ Z : Scheme
𝒰✝ : OpenCover X✝
f✝ : X✝ ⟶ Z
g : Y✝ ⟶ Z
inst✝¹ : ∀ (x : 𝒰✝.J), HasPullback (map 𝒰✝ x ≫ f✝) g
X : Scheme
𝒰 : OpenCover X
Y : Scheme
f : Y ⟶ X
inst✝ : IsOpenImmersion f
⊢ ∀ (x : Option 𝒰.J), IsOpenImmersion ((fun i => Option.rec f 𝒰.map i) x)

Next tactic:
rintro (_ | _)
/-- Adding an open immersion into an open cover gives another open cover. -/
@[simps]
def OpenCover.add {X : Scheme} (𝒰 : X.OpenCover) {Y : Scheme} (f : Y ⟶ X) [IsOpenImmersion f] :
    X.OpenCover where
  J := Option 𝒰.J
  obj i := Option.rec Y 𝒰.obj i
  map i := Option.rec f 𝒰.map i
  f x := some (𝒰.f x)
  Covers := 𝒰.Covers
  IsOpen := by rintro (_ | _) <;> 

Proof state:
case none
C : Type u
inst✝² : Category.{v, u} C
X✝ Y✝ Z : Scheme
𝒰✝ : OpenCover X✝
f✝ : X✝ ⟶ Z
g : Y✝ ⟶ Z
inst✝¹ : ∀ (x : 𝒰✝.J), HasPullback (map 𝒰✝ x ≫ f✝) g
X : Scheme
𝒰 : OpenCover X
Y : Scheme
f : Y ⟶ X
inst✝ : IsOpenImmersion f
⊢ IsOpenImmersion ((fun i => Option.rec f 𝒰.map i) none)

Next tactic:
dsimp
/-- Adding an open immersion into an open cover gives another open cover. -/
@[simps]
def OpenCover.add {X : Scheme} (𝒰 : X.OpenCover) {Y : Scheme} (f : Y ⟶ X) [IsOpenImmersion f] :
    X.OpenCover where
  J := Option 𝒰.J
  obj i := Option.rec Y 𝒰.obj i
  map i := Option.rec f 𝒰.map i
  f x := some (𝒰.f x)
  Covers := 𝒰.Covers
  IsOpen := by rintro (_ | _) <;> 

Proof state:
case some
C : Type u
inst✝² : Category.{v, u} C
X✝ Y✝ Z : Scheme
𝒰✝ : OpenCover X✝
f✝ : X✝ ⟶ Z
g : Y✝ ⟶ Z
inst✝¹ : ∀ (x : 𝒰✝.J), HasPullback (map 𝒰✝ x ≫ f✝) g
X : Scheme
𝒰 : OpenCover X
Y : Scheme
f : Y ⟶ X
inst✝ : IsOpenImmersion f
val✝ : 𝒰.J
⊢ IsOpenImmersion ((fun i => Option.rec f 𝒰.map i) (some val✝))

Next tactic:
dsimp
/-- Adding an open immersion into an open cover gives another open cover. -/
@[simps]
def OpenCover.add {X : Scheme} (𝒰 : X.OpenCover) {Y : Scheme} (f : Y ⟶ X) [IsOpenImmersion f] :
    X.OpenCover where
  J := Option 𝒰.J
  obj i := Option.rec Y 𝒰.obj i
  map i := Option.rec f 𝒰.map i
  f x := some (𝒰.f x)
  Covers := 𝒰.Covers
  IsOpen := by rintro (_ | _) <;> dsimp <;> 

Proof state:
case none
C : Type u
inst✝² : Category.{v, u} C
X✝ Y✝ Z : Scheme
𝒰✝ : OpenCover X✝
f✝ : X✝ ⟶ Z
g : Y✝ ⟶ Z
inst✝¹ : ∀ (x : 𝒰✝.J), HasPullback (map 𝒰✝ x ≫ f✝) g
X : Scheme
𝒰 : OpenCover X
Y : Scheme
f : Y ⟶ X
inst✝ : IsOpenImmersion f
⊢ IsOpenImmersion f

Next tactic:
infer_instance
/-- Adding an open immersion into an open cover gives another open cover. -/
@[simps]
def OpenCover.add {X : Scheme} (𝒰 : X.OpenCover) {Y : Scheme} (f : Y ⟶ X) [IsOpenImmersion f] :
    X.OpenCover where
  J := Option 𝒰.J
  obj i := Option.rec Y 𝒰.obj i
  map i := Option.rec f 𝒰.map i
  f x := some (𝒰.f x)
  Covers := 𝒰.Covers
  IsOpen := by rintro (_ | _) <;> dsimp <;> 

Proof state:
case some
C : Type u
inst✝² : Category.{v, u} C
X✝ Y✝ Z : Scheme
𝒰✝ : OpenCover X✝
f✝ : X✝ ⟶ Z
g : Y✝ ⟶ Z
inst✝¹ : ∀ (x : 𝒰✝.J), HasPullback (map 𝒰✝ x ≫ f✝) g
X : Scheme
𝒰 : OpenCover X
Y : Scheme
f : Y ⟶ X
inst✝ : IsOpenImmersion f
val✝ : 𝒰.J
⊢ IsOpenImmersion (map 𝒰 val✝)

Next tactic:
infer_instance
instance basic_open_isOpenImmersion {R : CommRingCat} (f : R) :
    AlgebraicGeometry.IsOpenImmersion
      (Scheme.Spec.map (CommRingCat.ofHom (algebraMap R (Localization.Away f))).op) := by
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X Y Z : Scheme
𝒰 : OpenCover X
f✝ : X ⟶ Z
g : Y ⟶ Z
inst✝ : ∀ (x : 𝒰.J), HasPullback (OpenCover.map 𝒰 x ≫ f✝) g
R : CommRingCat
f : ↑R
⊢ IsOpenImmersion (Spec.map (CommRingCat.ofHom (algebraMap (↑R) (Localization.Away f))).op)

Next tactic:
apply SheafedSpace.IsOpenImmersion.of_stalk_iso (H := ?_)
instance basic_open_isOpenImmersion {R : CommRingCat} (f : R) :
    AlgebraicGeometry.IsOpenImmersion
      (Scheme.Spec.map (CommRingCat.ofHom (algebraMap R (Localization.Away f))).op) := by
  apply SheafedSpace.IsOpenImmersion.of_stalk_iso (H := ?_)
  · 

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X Y Z : Scheme
𝒰 : OpenCover X
f✝ : X ⟶ Z
g : Y ⟶ Z
inst✝ : ∀ (x : 𝒰.J), HasPullback (OpenCover.map 𝒰 x ≫ f✝) g
R : CommRingCat
f : ↑R
⊢ OpenEmbedding ⇑(Spec.map (CommRingCat.ofHom (algebraMap (↑R) (Localization.Away f))).op).val.base

Next tactic:
exact (PrimeSpectrum.localization_away_openEmbedding (Localization.Away f) f : _)
instance basic_open_isOpenImmersion {R : CommRingCat} (f : R) :
    AlgebraicGeometry.IsOpenImmersion
      (Scheme.Spec.map (CommRingCat.ofHom (algebraMap R (Localization.Away f))).op) := by
  apply SheafedSpace.IsOpenImmersion.of_stalk_iso (H := ?_)
  · exact (PrimeSpectrum.localization_away_openEmbedding (Localization.Away f) f : _)
  · 

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X Y Z : Scheme
𝒰 : OpenCover X
f✝ : X ⟶ Z
g : Y ⟶ Z
inst✝ : ∀ (x : 𝒰.J), HasPullback (OpenCover.map 𝒰 x ≫ f✝) g
R : CommRingCat
f : ↑R
hf : OpenEmbedding ⇑(Spec.map (CommRingCat.ofHom (algebraMap (↑R) (Localization.Away f))).op).val.base
⊢ ∀ (x : ↑↑(Spec.obj (op (CommRingCat.of (Localization.Away f)))).toPresheafedSpace),
    IsIso (PresheafedSpace.stalkMap (Spec.map (CommRingCat.ofHom (algebraMap (↑R) (Localization.Away f))).op).val x)

Next tactic:
intro x
instance basic_open_isOpenImmersion {R : CommRingCat} (f : R) :
    AlgebraicGeometry.IsOpenImmersion
      (Scheme.Spec.map (CommRingCat.ofHom (algebraMap R (Localization.Away f))).op) := by
  apply SheafedSpace.IsOpenImmersion.of_stalk_iso (H := ?_)
  · exact (PrimeSpectrum.localization_away_openEmbedding (Localization.Away f) f : _)
  · intro x
    

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X Y Z : Scheme
𝒰 : OpenCover X
f✝ : X ⟶ Z
g : Y ⟶ Z
inst✝ : ∀ (x : 𝒰.J), HasPullback (OpenCover.map 𝒰 x ≫ f✝) g
R : CommRingCat
f : ↑R
hf : OpenEmbedding ⇑(Spec.map (CommRingCat.ofHom (algebraMap (↑R) (Localization.Away f))).op).val.base
x : ↑↑(Spec.obj (op (CommRingCat.of (Localization.Away f)))).toPresheafedSpace
⊢ IsIso (PresheafedSpace.stalkMap (Spec.map (CommRingCat.ofHom (algebraMap (↑R) (Localization.Away f))).op).val x)

Next tactic:
exact Spec_map_localization_isIso R (Submonoid.powers f) x
/-- The basic open sets form an affine open cover of `Spec R`. -/
def affineBasisCoverOfAffine (R : CommRingCat) : OpenCover (Spec.obj (Opposite.op R)) where
  J := R
  obj r := Spec.obj (Opposite.op <| CommRingCat.of <| Localization.Away r)
  map r := Spec.map (Quiver.Hom.op (algebraMap R (Localization.Away r) : _))
  f _ := 1
  Covers r := by
    

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X Y Z : Scheme
𝒰 : OpenCover X
f : X ⟶ Z
g : Y ⟶ Z
inst✝ : ∀ (x : 𝒰.J), HasPullback (OpenCover.map 𝒰 x ≫ f) g
R : CommRingCat
r : ↑↑(Spec.obj (op R)).toPresheafedSpace
⊢ r ∈ Set.range ⇑((fun r => Spec.map (algebraMap (↑R) (Localization.Away r)).op) ((fun x => 1) r)).val.base

Next tactic:
rw [Set.range_iff_surjective.mpr ((TopCat.epi_iff_surjective _).mp _)]
/-- The basic open sets form an affine open cover of `Spec R`. -/
def affineBasisCoverOfAffine (R : CommRingCat) : OpenCover (Spec.obj (Opposite.op R)) where
  J := R
  obj r := Spec.obj (Opposite.op <| CommRingCat.of <| Localization.Away r)
  map r := Spec.map (Quiver.Hom.op (algebraMap R (Localization.Away r) : _))
  f _ := 1
  Covers r := by
    rw [Set.range_iff_surjective.mpr ((TopCat.epi_iff_surjective _).mp _)]
    · 

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X Y Z : Scheme
𝒰 : OpenCover X
f : X ⟶ Z
g : Y ⟶ Z
inst✝ : ∀ (x : 𝒰.J), HasPullback (OpenCover.map 𝒰 x ≫ f) g
R : CommRingCat
r : ↑↑(Spec.obj (op R)).toPresheafedSpace
⊢ r ∈ Set.univ

Next tactic:
exact trivial
/-- The basic open sets form an affine open cover of `Spec R`. -/
def affineBasisCoverOfAffine (R : CommRingCat) : OpenCover (Spec.obj (Opposite.op R)) where
  J := R
  obj r := Spec.obj (Opposite.op <| CommRingCat.of <| Localization.Away r)
  map r := Spec.map (Quiver.Hom.op (algebraMap R (Localization.Away r) : _))
  f _ := 1
  Covers r := by
    rw [Set.range_iff_surjective.mpr ((TopCat.epi_iff_surjective _).mp _)]
    · exact trivial
    · -- Porting note : need more hand holding here because Lean knows that
      -- `CommRing.ofHom ...` is iso, but without `ofHom` Lean does not know what to do
      

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X Y Z : Scheme
𝒰 : OpenCover X
f : X ⟶ Z
g : Y ⟶ Z
inst✝ : ∀ (x : 𝒰.J), HasPullback (OpenCover.map 𝒰 x ≫ f) g
R : CommRingCat
r : ↑↑(Spec.obj (op R)).toPresheafedSpace
⊢ Epi ((fun r => Spec.map (algebraMap (↑R) (Localization.Away r)).op) ((fun x => 1) r)).val.base

Next tactic:
change Epi (Spec.map (CommRingCat.ofHom (algebraMap _ _)).op).1.base
/-- The basic open sets form an affine open cover of `Spec R`. -/
def affineBasisCoverOfAffine (R : CommRingCat) : OpenCover (Spec.obj (Opposite.op R)) where
  J := R
  obj r := Spec.obj (Opposite.op <| CommRingCat.of <| Localization.Away r)
  map r := Spec.map (Quiver.Hom.op (algebraMap R (Localization.Away r) : _))
  f _ := 1
  Covers r := by
    rw [Set.range_iff_surjective.mpr ((TopCat.epi_iff_surjective _).mp _)]
    · exact trivial
    · -- Porting note : need more hand holding here because Lean knows that
      -- `CommRing.ofHom ...` is iso, but without `ofHom` Lean does not know what to do
      change Epi (Spec.map (CommRingCat.ofHom (algebraMap _ _)).op).1.base
      

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X Y Z : Scheme
𝒰 : OpenCover X
f : X ⟶ Z
g : Y ⟶ Z
inst✝ : ∀ (x : 𝒰.J), HasPullback (OpenCover.map 𝒰 x ≫ f) g
R : CommRingCat
r : ↑↑(Spec.obj (op R)).toPresheafedSpace
⊢ Epi (Spec.map (CommRingCat.ofHom (algebraMap (↑R) (Localization.Away ((fun x => 1) r)))).op).val.base

Next tactic:
infer_instance
theorem affineBasisCover_map_range (X : Scheme) (x : X)
    (r : (X.local_affine x).choose_spec.choose) :
    Set.range (X.affineBasisCover.map ⟨x, r⟩).1.base =
      (X.affineCover.map x).1.base '' (PrimeSpectrum.basicOpen r).1 := by
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X✝ Y Z : Scheme
𝒰 : OpenCover X✝
f : X✝ ⟶ Z
g : Y ⟶ Z
inst✝ : ∀ (x : 𝒰.J), HasPullback (OpenCover.map 𝒰 x ≫ f) g
X : Scheme
x : ↑↑X.toPresheafedSpace
r :
  ↑(Exists.choose
      (_ :
        ∃ R,
          Nonempty
            (LocallyRingedSpace.restrict X.toLocallyRingedSpace
                (_ :
                  OpenEmbedding
                    ⇑(Opens.inclusion
                        (Exists.choose
                            (_ :
                              ∃ U R,
                                Nonempty
                                  (LocallyRingedSpace.restrict X.toLocallyRingedSpace
                                      (_ : OpenEmbedding ⇑(Opens.inclusion U.obj)) ≅
                                    Spec.toLocallyRingedSpace.obj (op R)))).obj)) ≅
              Spec.toLocallyRingedSpace.obj (op R))))
⊢ Set.range ⇑(OpenCover.map (affineBasisCover X) { fst := x, snd := r }).val.base =
    ⇑(OpenCover.map (affineCover X) x).val.base '' (PrimeSpectrum.basicOpen r).carrier

Next tactic:
erw [coe_comp, Set.range_comp]
theorem affineBasisCover_map_range (X : Scheme) (x : X)
    (r : (X.local_affine x).choose_spec.choose) :
    Set.range (X.affineBasisCover.map ⟨x, r⟩).1.base =
      (X.affineCover.map x).1.base '' (PrimeSpectrum.basicOpen r).1 := by
  erw [coe_comp, Set.range_comp]
  -- Porting note : `congr` fails to see the goal is comparing image of the same function
  

Proof state:
C : Type u
inst✝¹ : Category.{v, u} C
X✝ Y Z : Scheme
𝒰 : OpenCover X✝
f : X✝ ⟶ Z
g : Y ⟶ Z
inst✝ : ∀ (x : 𝒰.J), HasPullback (OpenCover.map 𝒰 x ≫ f) g
X : Scheme
x : ↑↑X.toPresheafedSpace
r :
  ↑(Exists.choose
      (_ :
        ∃ R,
          Nonempty
            (LocallyRingedSpace.restrict X.toLocallyRingedSpace
                (_ :
                  OpenEmbedding
                    ⇑(Opens.inclusion
                        (Exists.choose
                            (_ :
                              ∃ U R,
                                Nonempty
                                  (LocallyRingedSpace.restrict X.toLocallyRingedSpace
                                      (_ : OpenEmbedding ⇑(Opens.inclusion U.obj)) ≅
                                    Spec.toLocallyRingedSpace.obj (op R)))).obj)) ≅
              Spec.toLocallyRingedSpace.obj (op R))))
⊢ ⇑(OpenCover.map (affineCover X) { fst := x, snd := r }.fst).val.base ''
      Set.range
        ⇑(OpenCover.map
                ((fun x =>
                    affineBasisCoverOfAffine
                      (Exists.choose
                        (_ :
                          ∃ R,
                            Nonempty
                              (LocallyRingedSpace.restrict X.toLocallyRingedSpace
                                  (_ :
                                    OpenEmbedding
                                      ⇑(Opens.inclusion
                                          (Exists.choose
                                              (_ :
                                                ∃ U R,
                                                  Nonempty
                                                    (LocallyRingedSpace.restrict X.toLocallyRingedSpace
                                                        (_ : OpenEmbedding ⇑(Opens.inclusion U.obj)) ≅
                                                      Spec.toLocallyRingedSpace.obj (op R)))).obj)) ≅
                                Spec.toLocallyRingedSpace.obj (op R)))))
                  { fst := x, snd := r }.fst)
                { fst := x, snd := r }.snd).val.base =
    ⇑(OpenCover.map (affineCover X) x).val.base '' (PrimeSpectrum.basicOpen r).carrier

Next tactic:
refine congr_arg (_ '' ·) ?_