algebraic_geometry.structure_sheafMathlib.AlgebraicGeometry.StructureSheaf

This file has been ported!

Changes since the initial port

The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.

Changes in mathlib3

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(last sync)

chore(topology/sheaves): revert universe generalizations from #19153 (#19230)

This reverts commit 13361559.

These are just too difficult to forward port as is because of the max u v =?= max u ?v issue https://github.com/leanprover/lean4/issues/2297.

We have another candidate approach to this, using a new UnivLE typeclass, and I would prefer if we investigated that without the pressure of the port at the same time.

This will delay @hrmacbeth's plans to define meromorphic functions, perhaps.

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -772,10 +772,10 @@ begin
   rw to_basic_open_mk',
 
   -- Since the structure sheaf is a sheaf, we can show the desired equality locally.
-  -- Annoyingly, `sheaf.eq_of_locally_eq'` requires an open cover indexed by a *type*, so we need to
+  -- Annoyingly, `sheaf.eq_of_locally_eq` requires an open cover indexed by a *type*, so we need to
   -- coerce our finset `t` to a type first.
   let tt := ((t : set (basic_open f)) : Type u),
-  apply Top.sheaf.eq_of_locally_eq'.{(u+1) u} (structure_sheaf R)
+  apply (structure_sheaf R).eq_of_locally_eq'
     (λ i : tt, basic_open (h i)) (basic_open f) (λ i : tt, iDh i),
   { -- This feels a little redundant, since already have `ht_cover` as a hypothesis
     -- Unfortunately, `ht_cover` uses a bounded union over the set `t`, while here we have the

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

chore(topology/sheaves/*): universe generalizations (#19153)

Necessary but sadly insufficient for the request at https://leanprover.zulipchat.com/#narrow/stream/144837-PR-reviews/topic/.2319146.20sheaves.20on.20manifolds

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -772,10 +772,10 @@ begin
   rw to_basic_open_mk',
 
   -- Since the structure sheaf is a sheaf, we can show the desired equality locally.
-  -- Annoyingly, `sheaf.eq_of_locally_eq` requires an open cover indexed by a *type*, so we need to
+  -- Annoyingly, `sheaf.eq_of_locally_eq'` requires an open cover indexed by a *type*, so we need to
   -- coerce our finset `t` to a type first.
   let tt := ((t : set (basic_open f)) : Type u),
-  apply (structure_sheaf R).eq_of_locally_eq'
+  apply Top.sheaf.eq_of_locally_eq'.{(u+1) u} (structure_sheaf R)
     (λ i : tt, basic_open (h i)) (basic_open f) (λ i : tt, iDh i),
   { -- This feels a little redundant, since already have `ht_cover` as a hypothesis
     -- Unfortunately, `ht_cover` uses a bounded union over the set `t`, while here we have the

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(first ported)

Changes in mathlib3port

mathlib3
mathlib3port
Diff
@@ -815,7 +815,7 @@ theorem locally_const_basicOpen (U : Opens (PrimeSpectrum.Top R))
   -- This is because we will need the equality `basic_open (h ^ n) = basic_open h`, which only
   -- holds for a nonzero power `n`. We therefore artificially increase `n` by one.
   replace hn := Ideal.mul_mem_left (Ideal.span {g}) h hn
-  rw [← pow_succ, Ideal.mem_span_singleton'] at hn
+  rw [← pow_succ', Ideal.mem_span_singleton'] at hn
   cases' hn with c hc
   have basic_opens_eq := basic_open_pow h (n + 1) (by linarith)
   have i_basic_open := eq_to_hom basic_opens_eq ≫ hom_of_le hDhV
@@ -835,7 +835,7 @@ theorem locally_const_basicOpen (U : Opens (PrimeSpectrum.Top R))
 -/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (i j «expr ∈ » t) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:642:2: warning: expanding binder collection (i j «expr ∈ » t) -/
 #print AlgebraicGeometry.StructureSheaf.normalize_finite_fraction_representation /-
 /-
 Auxiliary lemma for surjectivity of `to_basic_open`.
@@ -887,7 +887,7 @@ theorem normalize_finite_fraction_representation (U : Opens (PrimeSpectrum.Top R
     intro i j
     obtain ⟨⟨c, n, rfl⟩, hc⟩ := is_localization.eq.mp (fractions_eq i j)
     use n + 1
-    rw [pow_succ]
+    rw [pow_succ']
     dsimp at hc
     convert hc using 1 <;> ring
   let n := fun p : ι × ι => (exists_power p.1 p.2).some
@@ -920,7 +920,7 @@ theorem normalize_finite_fraction_representation (U : Opens (PrimeSpectrum.Top R
   swap;
   exact (basic_opens_eq i).le
   apply const_ext
-  rw [pow_succ]
+  rw [pow_succ']
   ring
 #align algebraic_geometry.structure_sheaf.normalize_finite_fraction_representation AlgebraicGeometry.StructureSheaf.normalize_finite_fraction_representation
 -/
@@ -967,7 +967,7 @@ theorem toBasicOpen_surjective (f : R) : Function.Surjective (toBasicOpen R f) :
     apply vanishing_ideal_anti_mono ht_cover
     exact subset_vanishing_ideal_zero_locus {f} (Set.mem_singleton f)
   replace hn := Ideal.mul_mem_left _ f hn
-  erw [← pow_succ, Finsupp.mem_span_image_iff_total] at hn
+  erw [← pow_succ', Finsupp.mem_span_image_iff_total] at hn
   rcases hn with ⟨b, b_supp, hb⟩
   rw [Finsupp.total_apply_of_mem_supported R b_supp] at hb
   dsimp at hb
Diff
@@ -765,7 +765,7 @@ theorem toBasicOpen_injective (f : R) : Function.Injective (toBasicOpen R f) :=
   intro s t h_eq
   obtain ⟨a, ⟨b, hb⟩, rfl⟩ := IsLocalization.mk'_surjective (Submonoid.powers f) s
   obtain ⟨c, ⟨d, hd⟩, rfl⟩ := IsLocalization.mk'_surjective (Submonoid.powers f) t
-  simp only [to_basic_open_mk'] at h_eq 
+  simp only [to_basic_open_mk'] at h_eq
   rw [IsLocalization.eq]
   -- We know that the fractions `a/b` and `c/d` are equal as sections of the structure sheaf on
   -- `basic_open f`. We need to show that they agree as elements in the localization of `R` at `f`.
@@ -785,7 +785,7 @@ theorem toBasicOpen_injective (f : R) : Function.Injective (toBasicOpen R f) :=
   contrapose hfp
   rw [mem_zero_locus, Set.not_subset]
   have := congr_fun (congr_arg Subtype.val h_eq) ⟨p, hfp⟩
-  rw [const_apply, const_apply, IsLocalization.eq] at this 
+  rw [const_apply, const_apply, IsLocalization.eq] at this
   cases' this with r hr
   exact ⟨r.1, hr, r.2⟩
 #align algebraic_geometry.structure_sheaf.to_basic_open_injective AlgebraicGeometry.StructureSheaf.toBasicOpen_injective
@@ -815,7 +815,7 @@ theorem locally_const_basicOpen (U : Opens (PrimeSpectrum.Top R))
   -- This is because we will need the equality `basic_open (h ^ n) = basic_open h`, which only
   -- holds for a nonzero power `n`. We therefore artificially increase `n` by one.
   replace hn := Ideal.mul_mem_left (Ideal.span {g}) h hn
-  rw [← pow_succ, Ideal.mem_span_singleton'] at hn 
+  rw [← pow_succ, Ideal.mem_span_singleton'] at hn
   cases' hn with c hc
   have basic_opens_eq := basic_open_pow h (n + 1) (by linarith)
   have i_basic_open := eq_to_hom basic_opens_eq ≫ hom_of_le hDhV
@@ -826,7 +826,7 @@ theorem locally_const_basicOpen (U : Opens (PrimeSpectrum.Top R))
   -- of `res_const`. We prove this goal first
   swap
   · intro y hy
-    rw [basic_opens_eq] at hy 
+    rw [basic_opens_eq] at hy
     exact (Set.Subset.trans hDhV hVDg : _) hy
   -- All that is left is a simple calculation
   apply const_ext
@@ -888,7 +888,7 @@ theorem normalize_finite_fraction_representation (U : Opens (PrimeSpectrum.Top R
     obtain ⟨⟨c, n, rfl⟩, hc⟩ := is_localization.eq.mp (fractions_eq i j)
     use n + 1
     rw [pow_succ]
-    dsimp at hc 
+    dsimp at hc
     convert hc using 1 <;> ring
   let n := fun p : ι × ι => (exists_power p.1 p.2).some
   have n_spec := fun p : ι × ι => (exists_power p.fst p.snd).choose_spec
@@ -949,28 +949,28 @@ theorem toBasicOpen_surjective (f : R) : Function.Surjective (toBasicOpen R f) :
   · -- Here, we need to show that our basic opens actually form a cover of `basic_open f`
     rw [Set.mem_iUnion]
     exact ⟨⟨x, hx⟩, hxDh' ⟨x, hx⟩⟩
-  simp only [← opens.coe_supr, SetLike.coe_subset_coe] at ht_cover' 
+  simp only [← opens.coe_supr, SetLike.coe_subset_coe] at ht_cover'
   -- We use the normalization lemma from above to obtain the relation `a i * h j = h i * a j`
   obtain ⟨a, h, iDh, ht_cover, ah_ha, s_eq⟩ :=
     normalize_finite_fraction_representation R (basic_open f) s t a' h' iDh' ht_cover' s_eq'
   clear s_eq' iDh' hxDh' ht_cover' a' h'
-  simp only [← SetLike.coe_subset_coe, opens.coe_supr] at ht_cover 
+  simp only [← SetLike.coe_subset_coe, opens.coe_supr] at ht_cover
   -- Next we show that some power of `f` is a linear combination of the `h i`
   obtain ⟨n, hn⟩ : f ∈ (Ideal.span (h '' ↑t)).radical :=
     by
     rw [← vanishing_ideal_zero_locus_eq_radical, zero_locus_span]
-    simp only [basic_open_eq_zero_locus_compl] at ht_cover 
-    rw [Set.compl_subset_comm] at ht_cover 
+    simp only [basic_open_eq_zero_locus_compl] at ht_cover
+    rw [Set.compl_subset_comm] at ht_cover
     -- Why doesn't `simp_rw` do this?
     simp_rw [Set.compl_iUnion, compl_compl, ← zero_locus_Union, ← Finset.set_biUnion_coe, ←
-      Set.image_eq_iUnion] at ht_cover 
+      Set.image_eq_iUnion] at ht_cover
     apply vanishing_ideal_anti_mono ht_cover
     exact subset_vanishing_ideal_zero_locus {f} (Set.mem_singleton f)
   replace hn := Ideal.mul_mem_left _ f hn
-  erw [← pow_succ, Finsupp.mem_span_image_iff_total] at hn 
+  erw [← pow_succ, Finsupp.mem_span_image_iff_total] at hn
   rcases hn with ⟨b, b_supp, hb⟩
-  rw [Finsupp.total_apply_of_mem_supported R b_supp] at hb 
-  dsimp at hb 
+  rw [Finsupp.total_apply_of_mem_supported R b_supp] at hb
+  dsimp at hb
   -- Finally, we have all the ingredients.
   -- We claim that our preimage is given by `(∑ (i : ι) in t, b i * a i) / f ^ (n+1)`
   use IsLocalization.mk' (Localization.Away f) (∑ i : ι in t, b i * a i)
@@ -989,7 +989,7 @@ theorem toBasicOpen_surjective (f : R) : Function.Surjective (toBasicOpen R f) :
     intro x hx
     erw [TopologicalSpace.Opens.mem_iSup]
     have := ht_cover hx
-    rw [← Finset.set_biUnion_coe, Set.mem_iUnion₂] at this 
+    rw [← Finset.set_biUnion_coe, Set.mem_iUnion₂] at this
     rcases this with ⟨i, i_mem, x_mem⟩
     use i, i_mem
   rintro ⟨i, hi⟩
@@ -1321,7 +1321,7 @@ theorem comap_id_eq_map (U V : Opens (PrimeSpectrum.Top R)) (iVU : V ⟶ U) :
         obtain ⟨hb₁, s_eq₁⟩ := h' ⟨p, hpW⟩
         obtain ⟨hb₂, s_eq₂⟩ :=
           h' ⟨PrimeSpectrum.comap (RingHom.id _) p.1, by rwa [PrimeSpectrum.comap_id]⟩
-        dsimp only at s_eq₁ s_eq₂ 
+        dsimp only at s_eq₁ s_eq₂
         erw [s_eq₂, Localization.localRingHom_mk', ← s_eq₁, ← res_apply]
 #align algebraic_geometry.structure_sheaf.comap_id_eq_map AlgebraicGeometry.StructureSheaf.comap_id_eq_map
 -/
Diff
@@ -734,7 +734,7 @@ def toBasicOpen (f : R) : Localization.Away f →+* (structureSheaf R).1.obj (op
 @[simp]
 theorem toBasicOpen_mk' (s f : R) (g : Submonoid.powers s) :
     toBasicOpen R s (IsLocalization.mk' (Localization.Away s) f g) =
-      const R f g (basicOpen s) fun x hx => Submonoid.powers_subset hx g.2 :=
+      const R f g (basicOpen s) fun x hx => Submonoid.powers_le hx g.2 :=
   (IsLocalization.lift_mk'_spec _ _ _ _).2 <| by
     rw [to_open_eq_const, to_open_eq_const, const_mul_cancel']
 #align algebraic_geometry.structure_sheaf.to_basic_open_mk' AlgebraicGeometry.StructureSheaf.toBasicOpen_mk'
Diff
@@ -3,12 +3,12 @@ Copyright (c) 2020 Scott Morrison. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Johan Commelin, Scott Morrison
 -/
-import Mathbin.AlgebraicGeometry.PrimeSpectrum.Basic
-import Mathbin.Algebra.Category.Ring.Colimits
-import Mathbin.Algebra.Category.Ring.Limits
-import Mathbin.Topology.Sheaves.LocalPredicate
-import Mathbin.RingTheory.Localization.AtPrime
-import Mathbin.RingTheory.Subring.Basic
+import AlgebraicGeometry.PrimeSpectrum.Basic
+import Algebra.Category.Ring.Colimits
+import Algebra.Category.Ring.Limits
+import Topology.Sheaves.LocalPredicate
+import RingTheory.Localization.AtPrime
+import RingTheory.Subring.Basic
 
 #align_import algebraic_geometry.structure_sheaf from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8"
 
@@ -835,7 +835,7 @@ theorem locally_const_basicOpen (U : Opens (PrimeSpectrum.Top R))
 -/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (i j «expr ∈ » t) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (i j «expr ∈ » t) -/
 #print AlgebraicGeometry.StructureSheaf.normalize_finite_fraction_representation /-
 /-
 Auxiliary lemma for surjectivity of `to_basic_open`.
Diff
@@ -212,7 +212,7 @@ def sectionsSubring (U : (Opens (PrimeSpectrum.Top R))ᵒᵖ) :
     · simp only [RingHom.map_neg, Pi.neg_apply]
       erw [← w]
       simp only [neg_mul]
-  mul_mem' := by
+  hMul_mem' := by
     intro a b ha hb x
     rcases ha x with ⟨Va, ma, ia, ra, sa, wa⟩
     rcases hb x with ⟨Vb, mb, ib, rb, sb, wb⟩
Diff
@@ -973,8 +973,7 @@ theorem toBasicOpen_surjective (f : R) : Function.Surjective (toBasicOpen R f) :
   dsimp at hb 
   -- Finally, we have all the ingredients.
   -- We claim that our preimage is given by `(∑ (i : ι) in t, b i * a i) / f ^ (n+1)`
-  use
-    IsLocalization.mk' (Localization.Away f) (∑ i : ι in t, b i * a i)
+  use IsLocalization.mk' (Localization.Away f) (∑ i : ι in t, b i * a i)
       (⟨f ^ (n + 1), n + 1, rfl⟩ : Submonoid.powers _)
   rw [to_basic_open_mk']
   -- Since the structure sheaf is a sheaf, we can show the desired equality locally.
Diff
@@ -2,11 +2,6 @@
 Copyright (c) 2020 Scott Morrison. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Johan Commelin, Scott Morrison
-
-! This file was ported from Lean 3 source module algebraic_geometry.structure_sheaf
-! leanprover-community/mathlib commit 5dc6092d09e5e489106865241986f7f2ad28d4c8
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.AlgebraicGeometry.PrimeSpectrum.Basic
 import Mathbin.Algebra.Category.Ring.Colimits
@@ -15,6 +10,8 @@ import Mathbin.Topology.Sheaves.LocalPredicate
 import Mathbin.RingTheory.Localization.AtPrime
 import Mathbin.RingTheory.Subring.Basic
 
+#align_import algebraic_geometry.structure_sheaf from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8"
+
 /-!
 # The structure sheaf on `prime_spectrum R`.
 
@@ -838,7 +835,7 @@ theorem locally_const_basicOpen (U : Opens (PrimeSpectrum.Top R))
 -/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (i j «expr ∈ » t) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (i j «expr ∈ » t) -/
 #print AlgebraicGeometry.StructureSheaf.normalize_finite_fraction_representation /-
 /-
 Auxiliary lemma for surjectivity of `to_basic_open`.
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Johan Commelin, Scott Morrison
 
 ! This file was ported from Lean 3 source module algebraic_geometry.structure_sheaf
-! leanprover-community/mathlib commit 13361559d66b84f80b6d5a1c4a26aa5054766725
+! leanprover-community/mathlib commit 5dc6092d09e5e489106865241986f7f2ad28d4c8
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -981,12 +981,12 @@ theorem toBasicOpen_surjective (f : R) : Function.Surjective (toBasicOpen R f) :
       (⟨f ^ (n + 1), n + 1, rfl⟩ : Submonoid.powers _)
   rw [to_basic_open_mk']
   -- Since the structure sheaf is a sheaf, we can show the desired equality locally.
-  -- Annoyingly, `sheaf.eq_of_locally_eq'` requires an open cover indexed by a *type*, so we need to
+  -- Annoyingly, `sheaf.eq_of_locally_eq` requires an open cover indexed by a *type*, so we need to
   -- coerce our finset `t` to a type first.
   let tt := ((t : Set (basic_open f)) : Type u)
   apply
-    TopCat.Sheaf.eq_of_locally_eq'.{u + 1, u} (structure_sheaf R) (fun i : tt => basic_open (h i))
-      (basic_open f) fun i : tt => iDh i
+    (structure_sheaf R).eq_of_locally_eq' (fun i : tt => basic_open (h i)) (basic_open f)
+      fun i : tt => iDh i
   · -- This feels a little redundant, since already have `ht_cover` as a hypothesis
     -- Unfortunately, `ht_cover` uses a bounded union over the set `t`, while here we have the
     -- Union indexed by the type `tt`, so we need some boilerplate to translate one to the other
Diff
@@ -109,6 +109,7 @@ def IsFraction {U : Opens (PrimeSpectrum.Top R)} (f : ∀ x : U, Localizations R
 #align algebraic_geometry.structure_sheaf.is_fraction AlgebraicGeometry.StructureSheaf.IsFraction
 -/
 
+#print AlgebraicGeometry.StructureSheaf.IsFraction.eq_mk' /-
 theorem IsFraction.eq_mk' {U : Opens (PrimeSpectrum.Top R)} {f : ∀ x : U, Localizations R x}
     (hf : IsFraction f) :
     ∃ r s : R,
@@ -122,6 +123,7 @@ theorem IsFraction.eq_mk' {U : Opens (PrimeSpectrum.Top R)} {f : ∀ x : U, Loca
   refine' ⟨r, s, fun x => ⟨(h x).1, (is_localization.mk'_eq_iff_eq_mul.mpr _).symm⟩⟩
   exact (h x).2.symm
 #align algebraic_geometry.structure_sheaf.is_fraction.eq_mk' AlgebraicGeometry.StructureSheaf.IsFraction.eq_mk'
+-/
 
 variable (R)
 
@@ -172,6 +174,7 @@ theorem isLocallyFraction_pred {U : Opens (PrimeSpectrum.Top R)} (f : ∀ x : U,
 #align algebraic_geometry.structure_sheaf.is_locally_fraction_pred AlgebraicGeometry.StructureSheaf.isLocallyFraction_pred
 -/
 
+#print AlgebraicGeometry.StructureSheaf.sectionsSubring /-
 /-- The functions satisfying `is_locally_fraction` form a subring.
 -/
 def sectionsSubring (U : (Opens (PrimeSpectrum.Top R))ᵒᵖ) :
@@ -227,6 +230,7 @@ def sectionsSubring (U : (Opens (PrimeSpectrum.Top R))ᵒᵖ) :
       simp only [mul_left_comm, mul_assoc, mul_comm]
       rfl
 #align algebraic_geometry.structure_sheaf.sections_subring AlgebraicGeometry.StructureSheaf.sectionsSubring
+-/
 
 end StructureSheaf
 
@@ -241,10 +245,12 @@ def structureSheafInType : Sheaf (Type u) (PrimeSpectrum.Top R) :=
 #align algebraic_geometry.structure_sheaf_in_Type AlgebraicGeometry.structureSheafInType
 -/
 
+#print AlgebraicGeometry.commRingStructureSheafInTypeObj /-
 instance commRingStructureSheafInTypeObj (U : (Opens (PrimeSpectrum.Top R))ᵒᵖ) :
     CommRing ((structureSheafInType R).1.obj U) :=
   (sectionsSubring R U).toCommRing
 #align algebraic_geometry.comm_ring_structure_sheaf_in_Type_obj AlgebraicGeometry.commRingStructureSheafInTypeObj
+-/
 
 open _Root_.PrimeSpectrum
 
@@ -265,6 +271,7 @@ def structurePresheafInCommRing : Presheaf CommRingCat (PrimeSpectrum.Top R)
 #align algebraic_geometry.structure_presheaf_in_CommRing AlgebraicGeometry.structurePresheafInCommRing
 -/
 
+#print AlgebraicGeometry.structurePresheafCompForget /-
 /-- Some glue, verifying that that structure presheaf valued in `CommRing` agrees
 with the `Type` valued structure presheaf.
 -/
@@ -272,6 +279,7 @@ def structurePresheafCompForget :
     structurePresheafInCommRing R ⋙ forget CommRingCat ≅ (structureSheafInType R).1 :=
   NatIso.ofComponents (fun U => Iso.refl _) (by tidy)
 #align algebraic_geometry.structure_presheaf_comp_forget AlgebraicGeometry.structurePresheafCompForget
+-/
 
 open TopCat.Presheaf
 
@@ -293,13 +301,16 @@ open Spec (structureSheaf)
 
 namespace StructureSheaf
 
+#print AlgebraicGeometry.StructureSheaf.res_apply /-
 @[simp]
 theorem res_apply (U V : Opens (PrimeSpectrum.Top R)) (i : V ⟶ U)
     (s : (structureSheaf R).1.obj (op U)) (x : V) :
     ((structureSheaf R).1.map i.op s).1 x = (s.1 (i x) : _) :=
   rfl
 #align algebraic_geometry.structure_sheaf.res_apply AlgebraicGeometry.StructureSheaf.res_apply
+-/
 
+#print AlgebraicGeometry.StructureSheaf.const /-
 /-
 
 Notation in this comment
@@ -332,21 +343,27 @@ def const (f g : R) (U : Opens (PrimeSpectrum.Top R))
   ⟨fun x => IsLocalization.mk' _ f ⟨g, hu x x.2⟩, fun x =>
     ⟨U, x.2, 𝟙 _, f, g, fun y => ⟨hu y y.2, IsLocalization.mk'_spec _ _ _⟩⟩⟩
 #align algebraic_geometry.structure_sheaf.const AlgebraicGeometry.StructureSheaf.const
+-/
 
+#print AlgebraicGeometry.StructureSheaf.const_apply /-
 @[simp]
 theorem const_apply (f g : R) (U : Opens (PrimeSpectrum.Top R))
     (hu : ∀ x ∈ U, g ∈ (x : PrimeSpectrum.Top R).asIdeal.primeCompl) (x : U) :
     (const R f g U hu).1 x = IsLocalization.mk' _ f ⟨g, hu x x.2⟩ :=
   rfl
 #align algebraic_geometry.structure_sheaf.const_apply AlgebraicGeometry.StructureSheaf.const_apply
+-/
 
+#print AlgebraicGeometry.StructureSheaf.const_apply' /-
 theorem const_apply' (f g : R) (U : Opens (PrimeSpectrum.Top R))
     (hu : ∀ x ∈ U, g ∈ (x : PrimeSpectrum.Top R).asIdeal.primeCompl) (x : U)
     (hx : g ∈ (asIdeal (x : PrimeSpectrum.Top R)).primeCompl) :
     (const R f g U hu).1 x = IsLocalization.mk' _ f ⟨g, hx⟩ :=
   rfl
 #align algebraic_geometry.structure_sheaf.const_apply' AlgebraicGeometry.StructureSheaf.const_apply'
+-/
 
+#print AlgebraicGeometry.StructureSheaf.exists_const /-
 theorem exists_const (U) (s : (structureSheaf R).1.obj (op U)) (x : PrimeSpectrum.Top R)
     (hx : x ∈ U) :
     ∃ (V : Opens (PrimeSpectrum.Top R)) (hxV : x ∈ V) (i : V ⟶ U) (f g : R) (hg : _),
@@ -355,19 +372,25 @@ theorem exists_const (U) (s : (structureSheaf R).1.obj (op U)) (x : PrimeSpectru
   ⟨V, hxV, iVU, f, g, fun y hyV => (hfg ⟨y, hyV⟩).1,
     Subtype.eq <| funext fun y => IsLocalization.mk'_eq_iff_eq_mul.2 <| Eq.symm <| (hfg y).2⟩
 #align algebraic_geometry.structure_sheaf.exists_const AlgebraicGeometry.StructureSheaf.exists_const
+-/
 
+#print AlgebraicGeometry.StructureSheaf.res_const /-
 @[simp]
 theorem res_const (f g : R) (U hu V hv i) :
     (structureSheaf R).1.map i (const R f g U hu) = const R f g V hv :=
   rfl
 #align algebraic_geometry.structure_sheaf.res_const AlgebraicGeometry.StructureSheaf.res_const
+-/
 
+#print AlgebraicGeometry.StructureSheaf.res_const' /-
 theorem res_const' (f g : R) (V hv) :
     (structureSheaf R).1.map (homOfLE hv).op (const R f g (basicOpen g) fun _ => id) =
       const R f g V hv :=
   rfl
 #align algebraic_geometry.structure_sheaf.res_const' AlgebraicGeometry.StructureSheaf.res_const'
+-/
 
+#print AlgebraicGeometry.StructureSheaf.const_zero /-
 theorem const_zero (f : R) (U hu) : const R 0 f U hu = 0 :=
   Subtype.eq <|
     funext fun x =>
@@ -375,15 +398,21 @@ theorem const_zero (f : R) (U hu) : const R 0 f U hu = 0 :=
         erw [RingHom.map_zero, Subtype.val_eq_coe, Subring.coe_zero, Pi.zero_apply,
           MulZeroClass.zero_mul]
 #align algebraic_geometry.structure_sheaf.const_zero AlgebraicGeometry.StructureSheaf.const_zero
+-/
 
+#print AlgebraicGeometry.StructureSheaf.const_self /-
 theorem const_self (f : R) (U hu) : const R f f U hu = 1 :=
   Subtype.eq <| funext fun x => IsLocalization.mk'_self _ _
 #align algebraic_geometry.structure_sheaf.const_self AlgebraicGeometry.StructureSheaf.const_self
+-/
 
+#print AlgebraicGeometry.StructureSheaf.const_one /-
 theorem const_one (U) : (const R 1 1 U fun p _ => Submonoid.one_mem _) = 1 :=
   const_self R 1 U _
 #align algebraic_geometry.structure_sheaf.const_one AlgebraicGeometry.StructureSheaf.const_one
+-/
 
+#print AlgebraicGeometry.StructureSheaf.const_add /-
 theorem const_add (f₁ f₂ g₁ g₂ : R) (U hu₁ hu₂) :
     const R f₁ g₁ U hu₁ + const R f₂ g₂ U hu₂ =
       const R (f₁ * g₂ + f₂ * g₁) (g₁ * g₂) U fun x hx =>
@@ -392,7 +421,9 @@ theorem const_add (f₁ f₂ g₁ g₂ : R) (U hu₁ hu₂) :
     funext fun x =>
       Eq.symm <| by convert IsLocalization.mk'_add f₁ f₂ ⟨g₁, hu₁ x x.2⟩ ⟨g₂, hu₂ x x.2⟩
 #align algebraic_geometry.structure_sheaf.const_add AlgebraicGeometry.StructureSheaf.const_add
+-/
 
+#print AlgebraicGeometry.StructureSheaf.const_mul /-
 theorem const_mul (f₁ f₂ g₁ g₂ : R) (U hu₁ hu₂) :
     const R f₁ g₁ U hu₁ * const R f₂ g₂ U hu₂ =
       const R (f₁ * f₂) (g₁ * g₂) U fun x hx => Submonoid.mul_mem _ (hu₁ x hx) (hu₂ x hx) :=
@@ -400,32 +431,44 @@ theorem const_mul (f₁ f₂ g₁ g₂ : R) (U hu₁ hu₂) :
     funext fun x =>
       Eq.symm <| by convert IsLocalization.mk'_mul _ f₁ f₂ ⟨g₁, hu₁ x x.2⟩ ⟨g₂, hu₂ x x.2⟩
 #align algebraic_geometry.structure_sheaf.const_mul AlgebraicGeometry.StructureSheaf.const_mul
+-/
 
+#print AlgebraicGeometry.StructureSheaf.const_ext /-
 theorem const_ext {f₁ f₂ g₁ g₂ : R} {U hu₁ hu₂} (h : f₁ * g₂ = f₂ * g₁) :
     const R f₁ g₁ U hu₁ = const R f₂ g₂ U hu₂ :=
   Subtype.eq <|
     funext fun x =>
       IsLocalization.mk'_eq_of_eq (by rw [mul_comm, Subtype.coe_mk, ← h, mul_comm, Subtype.coe_mk])
 #align algebraic_geometry.structure_sheaf.const_ext AlgebraicGeometry.StructureSheaf.const_ext
+-/
 
+#print AlgebraicGeometry.StructureSheaf.const_congr /-
 theorem const_congr {f₁ f₂ g₁ g₂ : R} {U hu} (hf : f₁ = f₂) (hg : g₁ = g₂) :
     const R f₁ g₁ U hu = const R f₂ g₂ U (hg ▸ hu) := by substs hf hg
 #align algebraic_geometry.structure_sheaf.const_congr AlgebraicGeometry.StructureSheaf.const_congr
+-/
 
+#print AlgebraicGeometry.StructureSheaf.const_mul_rev /-
 theorem const_mul_rev (f g : R) (U hu₁ hu₂) : const R f g U hu₁ * const R g f U hu₂ = 1 := by
   rw [const_mul, const_congr R rfl (mul_comm g f), const_self]
 #align algebraic_geometry.structure_sheaf.const_mul_rev AlgebraicGeometry.StructureSheaf.const_mul_rev
+-/
 
+#print AlgebraicGeometry.StructureSheaf.const_mul_cancel /-
 theorem const_mul_cancel (f g₁ g₂ : R) (U hu₁ hu₂) :
     const R f g₁ U hu₁ * const R g₁ g₂ U hu₂ = const R f g₂ U hu₂ := by rw [const_mul, const_ext];
   rw [mul_assoc]
 #align algebraic_geometry.structure_sheaf.const_mul_cancel AlgebraicGeometry.StructureSheaf.const_mul_cancel
+-/
 
+#print AlgebraicGeometry.StructureSheaf.const_mul_cancel' /-
 theorem const_mul_cancel' (f g₁ g₂ : R) (U hu₁ hu₂) :
     const R g₁ g₂ U hu₂ * const R f g₁ U hu₁ = const R f g₂ U hu₂ := by
   rw [mul_comm, const_mul_cancel]
 #align algebraic_geometry.structure_sheaf.const_mul_cancel' AlgebraicGeometry.StructureSheaf.const_mul_cancel'
+-/
 
+#print AlgebraicGeometry.StructureSheaf.toOpen /-
 /-- The canonical ring homomorphism interpreting an element of `R` as
 a section of the structure sheaf. -/
 def toOpen (U : Opens (PrimeSpectrum.Top R)) : CommRingCat.of R ⟶ (structureSheaf R).1.obj (op U)
@@ -439,12 +482,15 @@ def toOpen (U : Opens (PrimeSpectrum.Top R)) : CommRingCat.of R ⟶ (structureSh
   map_zero' := Subtype.eq <| funext fun x => RingHom.map_zero _
   map_add' f g := Subtype.eq <| funext fun x => RingHom.map_add _ _ _
 #align algebraic_geometry.structure_sheaf.to_open AlgebraicGeometry.StructureSheaf.toOpen
+-/
 
+#print AlgebraicGeometry.StructureSheaf.toOpen_res /-
 @[simp]
 theorem toOpen_res (U V : Opens (PrimeSpectrum.Top R)) (i : V ⟶ U) :
     toOpen R U ≫ (structureSheaf R).1.map i.op = toOpen R V :=
   rfl
 #align algebraic_geometry.structure_sheaf.to_open_res AlgebraicGeometry.StructureSheaf.toOpen_res
+-/
 
 #print AlgebraicGeometry.StructureSheaf.toOpen_apply /-
 @[simp]
@@ -454,10 +500,12 @@ theorem toOpen_apply (U : Opens (PrimeSpectrum.Top R)) (f : R) (x : U) :
 #align algebraic_geometry.structure_sheaf.to_open_apply AlgebraicGeometry.StructureSheaf.toOpen_apply
 -/
 
+#print AlgebraicGeometry.StructureSheaf.toOpen_eq_const /-
 theorem toOpen_eq_const (U : Opens (PrimeSpectrum.Top R)) (f : R) :
     toOpen R U f = const R f 1 U fun x _ => (Ideal.ne_top_iff_one _).1 x.2.1 :=
   Subtype.eq <| funext fun x => Eq.symm <| IsLocalization.mk'_one _ f
 #align algebraic_geometry.structure_sheaf.to_open_eq_const AlgebraicGeometry.StructureSheaf.toOpen_eq_const
+-/
 
 #print AlgebraicGeometry.StructureSheaf.toStalk /-
 /-- The canonical ring homomorphism interpreting an element of `R` as an element of
@@ -475,43 +523,56 @@ theorem toOpen_germ (U : Opens (PrimeSpectrum.Top R)) (x : U) :
 #align algebraic_geometry.structure_sheaf.to_open_germ AlgebraicGeometry.StructureSheaf.toOpen_germ
 -/
 
+#print AlgebraicGeometry.StructureSheaf.germ_toOpen /-
 @[simp]
 theorem germ_toOpen (U : Opens (PrimeSpectrum.Top R)) (x : U) (f : R) :
     (structureSheaf R).Presheaf.germ x (toOpen R U f) = toStalk R x f := by rw [← to_open_germ]; rfl
 #align algebraic_geometry.structure_sheaf.germ_to_open AlgebraicGeometry.StructureSheaf.germ_toOpen
+-/
 
+#print AlgebraicGeometry.StructureSheaf.germ_to_top /-
 theorem germ_to_top (x : PrimeSpectrum.Top R) (f : R) :
     (structureSheaf R).Presheaf.germ (⟨x, trivial⟩ : (⊤ : Opens (PrimeSpectrum.Top R)))
         (toOpen R ⊤ f) =
       toStalk R x f :=
   rfl
 #align algebraic_geometry.structure_sheaf.germ_to_top AlgebraicGeometry.StructureSheaf.germ_to_top
+-/
 
+#print AlgebraicGeometry.StructureSheaf.isUnit_to_basicOpen_self /-
 theorem isUnit_to_basicOpen_self (f : R) : IsUnit (toOpen R (basicOpen f) f) :=
   isUnit_of_mul_eq_one _ (const R 1 f (basicOpen f) fun _ => id) <| by
     rw [to_open_eq_const, const_mul_rev]
 #align algebraic_geometry.structure_sheaf.is_unit_to_basic_open_self AlgebraicGeometry.StructureSheaf.isUnit_to_basicOpen_self
+-/
 
+#print AlgebraicGeometry.StructureSheaf.isUnit_toStalk /-
 theorem isUnit_toStalk (x : PrimeSpectrum.Top R) (f : x.asIdeal.primeCompl) :
     IsUnit (toStalk R x (f : R)) :=
   by
   erw [← germ_to_open R (basic_open (f : R)) ⟨x, f.2⟩ (f : R)]
   exact RingHom.isUnit_map _ (is_unit_to_basic_open_self R f)
 #align algebraic_geometry.structure_sheaf.is_unit_to_stalk AlgebraicGeometry.StructureSheaf.isUnit_toStalk
+-/
 
+#print AlgebraicGeometry.StructureSheaf.localizationToStalk /-
 /-- The canonical ring homomorphism from the localization of `R` at `p` to the stalk
 of the structure sheaf at the point `p`. -/
 def localizationToStalk (x : PrimeSpectrum.Top R) :
     CommRingCat.of (Localization.AtPrime x.asIdeal) ⟶ (structureSheaf R).Presheaf.stalk x :=
   show Localization.AtPrime x.asIdeal →+* _ from IsLocalization.lift (isUnit_toStalk R x)
 #align algebraic_geometry.structure_sheaf.localization_to_stalk AlgebraicGeometry.StructureSheaf.localizationToStalk
+-/
 
+#print AlgebraicGeometry.StructureSheaf.localizationToStalk_of /-
 @[simp]
 theorem localizationToStalk_of (x : PrimeSpectrum.Top R) (f : R) :
     localizationToStalk R x (algebraMap _ (Localization _) f) = toStalk R x f :=
   IsLocalization.lift_eq _ f
 #align algebraic_geometry.structure_sheaf.localization_to_stalk_of AlgebraicGeometry.StructureSheaf.localizationToStalk_of
+-/
 
+#print AlgebraicGeometry.StructureSheaf.localizationToStalk_mk' /-
 @[simp]
 theorem localizationToStalk_mk' (x : PrimeSpectrum.Top R) (f : R) (s : (asIdeal x).primeCompl) :
     localizationToStalk R x (IsLocalization.mk' _ f s : Localization _) =
@@ -521,7 +582,9 @@ theorem localizationToStalk_mk' (x : PrimeSpectrum.Top R) (f : R) (s : (asIdeal
     erw [← germ_to_open R (basic_open s) ⟨x, s.2⟩, ← germ_to_open R (basic_open s) ⟨x, s.2⟩, ←
       RingHom.map_mul, to_open_eq_const, to_open_eq_const, const_mul_cancel']
 #align algebraic_geometry.structure_sheaf.localization_to_stalk_mk' AlgebraicGeometry.StructureSheaf.localizationToStalk_mk'
+-/
 
+#print AlgebraicGeometry.StructureSheaf.openToLocalization /-
 /-- The ring homomorphism that takes a section of the structure sheaf of `R` on the open set `U`,
 implemented as a subtype of dependent functions to localizations at prime ideals, and evaluates
 the section on the point corresponding to a given prime ideal. -/
@@ -534,7 +597,9 @@ def openToLocalization (U : Opens (PrimeSpectrum.Top R)) (x : PrimeSpectrum.Top
   map_zero' := rfl
   map_add' _ _ := rfl
 #align algebraic_geometry.structure_sheaf.open_to_localization AlgebraicGeometry.StructureSheaf.openToLocalization
+-/
 
+#print AlgebraicGeometry.StructureSheaf.coe_openToLocalization /-
 @[simp]
 theorem coe_openToLocalization (U : Opens (PrimeSpectrum.Top R)) (x : PrimeSpectrum.Top R)
     (hx : x ∈ U) :
@@ -543,13 +608,17 @@ theorem coe_openToLocalization (U : Opens (PrimeSpectrum.Top R)) (x : PrimeSpect
       fun s => (s.1 ⟨x, hx⟩ : _) :=
   rfl
 #align algebraic_geometry.structure_sheaf.coe_open_to_localization AlgebraicGeometry.StructureSheaf.coe_openToLocalization
+-/
 
+#print AlgebraicGeometry.StructureSheaf.openToLocalization_apply /-
 theorem openToLocalization_apply (U : Opens (PrimeSpectrum.Top R)) (x : PrimeSpectrum.Top R)
     (hx : x ∈ U) (s : (structureSheaf R).1.obj (op U)) :
     openToLocalization R U x hx s = (s.1 ⟨x, hx⟩ : _) :=
   rfl
 #align algebraic_geometry.structure_sheaf.open_to_localization_apply AlgebraicGeometry.StructureSheaf.openToLocalization_apply
+-/
 
+#print AlgebraicGeometry.StructureSheaf.stalkToFiberRingHom /-
 /-- The ring homomorphism from the stalk of the structure sheaf of `R` at a point corresponding to
 a prime ideal `p` to the localization of `R` at `p`,
 formed by gluing the `open_to_localization` maps. -/
@@ -562,39 +631,51 @@ def stalkToFiberRingHom (x : PrimeSpectrum.Top R) :
           app := fun U =>
             openToLocalization R ((OpenNhds.inclusion _).obj (unop U)) x (unop U).2 } }
 #align algebraic_geometry.structure_sheaf.stalk_to_fiber_ring_hom AlgebraicGeometry.StructureSheaf.stalkToFiberRingHom
+-/
 
+#print AlgebraicGeometry.StructureSheaf.germ_comp_stalkToFiberRingHom /-
 @[simp]
 theorem germ_comp_stalkToFiberRingHom (U : Opens (PrimeSpectrum.Top R)) (x : U) :
     (structureSheaf R).Presheaf.germ x ≫ stalkToFiberRingHom R x = openToLocalization R U x x.2 :=
   Limits.colimit.ι_desc _ _
 #align algebraic_geometry.structure_sheaf.germ_comp_stalk_to_fiber_ring_hom AlgebraicGeometry.StructureSheaf.germ_comp_stalkToFiberRingHom
+-/
 
+#print AlgebraicGeometry.StructureSheaf.stalkToFiberRingHom_germ' /-
 @[simp]
 theorem stalkToFiberRingHom_germ' (U : Opens (PrimeSpectrum.Top R)) (x : PrimeSpectrum.Top R)
     (hx : x ∈ U) (s : (structureSheaf R).1.obj (op U)) :
     stalkToFiberRingHom R x ((structureSheaf R).Presheaf.germ ⟨x, hx⟩ s) = (s.1 ⟨x, hx⟩ : _) :=
   RingHom.ext_iff.1 (germ_comp_stalkToFiberRingHom R U ⟨x, hx⟩ : _) s
 #align algebraic_geometry.structure_sheaf.stalk_to_fiber_ring_hom_germ' AlgebraicGeometry.StructureSheaf.stalkToFiberRingHom_germ'
+-/
 
+#print AlgebraicGeometry.StructureSheaf.stalkToFiberRingHom_germ /-
 @[simp]
 theorem stalkToFiberRingHom_germ (U : Opens (PrimeSpectrum.Top R)) (x : U)
     (s : (structureSheaf R).1.obj (op U)) :
     stalkToFiberRingHom R x ((structureSheaf R).Presheaf.germ x s) = s.1 x := by cases x;
   exact stalk_to_fiber_ring_hom_germ' R U _ _ _
 #align algebraic_geometry.structure_sheaf.stalk_to_fiber_ring_hom_germ AlgebraicGeometry.StructureSheaf.stalkToFiberRingHom_germ
+-/
 
+#print AlgebraicGeometry.StructureSheaf.toStalk_comp_stalkToFiberRingHom /-
 @[simp]
 theorem toStalk_comp_stalkToFiberRingHom (x : PrimeSpectrum.Top R) :
     toStalk R x ≫ stalkToFiberRingHom R x = (algebraMap _ _ : R →+* Localization _) := by
   erw [to_stalk, category.assoc, germ_comp_stalk_to_fiber_ring_hom]; rfl
 #align algebraic_geometry.structure_sheaf.to_stalk_comp_stalk_to_fiber_ring_hom AlgebraicGeometry.StructureSheaf.toStalk_comp_stalkToFiberRingHom
+-/
 
+#print AlgebraicGeometry.StructureSheaf.stalkToFiberRingHom_toStalk /-
 @[simp]
 theorem stalkToFiberRingHom_toStalk (x : PrimeSpectrum.Top R) (f : R) :
     stalkToFiberRingHom R x (toStalk R x f) = algebraMap _ (Localization _) f :=
   RingHom.ext_iff.1 (toStalk_comp_stalkToFiberRingHom R x) _
 #align algebraic_geometry.structure_sheaf.stalk_to_fiber_ring_hom_to_stalk AlgebraicGeometry.StructureSheaf.stalkToFiberRingHom_toStalk
+-/
 
+#print AlgebraicGeometry.StructureSheaf.stalkIso /-
 /-- The ring isomorphism between the stalk of the structure sheaf of `R` at a point `p`
 corresponding to a prime ideal in `R` and the localization of `R` at `p`. -/
 @[simps]
@@ -620,6 +701,7 @@ def stalkIso (x : PrimeSpectrum.Top R) :
       simp only [RingHom.comp_apply, RingHom.id_apply, localization_to_stalk_of,
         stalk_to_fiber_ring_hom_to_stalk]
 #align algebraic_geometry.structure_sheaf.stalk_iso AlgebraicGeometry.StructureSheaf.stalkIso
+-/
 
 instance (x : PrimeSpectrum R) : IsIso (stalkToFiberRingHom R x) :=
   IsIso.of_iso (stalkIso R x)
@@ -635,18 +717,23 @@ theorem stalkToFiberRingHom_localizationToStalk (x : PrimeSpectrum.Top R) :
 #align algebraic_geometry.structure_sheaf.stalk_to_fiber_ring_hom_localization_to_stalk AlgebraicGeometry.StructureSheaf.stalkToFiberRingHom_localizationToStalk
 -/
 
+#print AlgebraicGeometry.StructureSheaf.localizationToStalk_stalkToFiberRingHom /-
 @[simp, reassoc]
 theorem localizationToStalk_stalkToFiberRingHom (x : PrimeSpectrum.Top R) :
     localizationToStalk R x ≫ stalkToFiberRingHom R x = 𝟙 _ :=
   (stalkIso R x).inv_hom_id
 #align algebraic_geometry.structure_sheaf.localization_to_stalk_stalk_to_fiber_ring_hom AlgebraicGeometry.StructureSheaf.localizationToStalk_stalkToFiberRingHom
+-/
 
+#print AlgebraicGeometry.StructureSheaf.toBasicOpen /-
 /-- The canonical ring homomorphism interpreting `s ∈ R_f` as a section of the structure sheaf
 on the basic open defined by `f ∈ R`. -/
 def toBasicOpen (f : R) : Localization.Away f →+* (structureSheaf R).1.obj (op <| basicOpen f) :=
   IsLocalization.Away.lift f (isUnit_to_basicOpen_self R f)
 #align algebraic_geometry.structure_sheaf.to_basic_open AlgebraicGeometry.StructureSheaf.toBasicOpen
+-/
 
+#print AlgebraicGeometry.StructureSheaf.toBasicOpen_mk' /-
 @[simp]
 theorem toBasicOpen_mk' (s f : R) (g : Submonoid.powers s) :
     toBasicOpen R s (IsLocalization.mk' (Localization.Away s) f g) =
@@ -654,21 +741,27 @@ theorem toBasicOpen_mk' (s f : R) (g : Submonoid.powers s) :
   (IsLocalization.lift_mk'_spec _ _ _ _).2 <| by
     rw [to_open_eq_const, to_open_eq_const, const_mul_cancel']
 #align algebraic_geometry.structure_sheaf.to_basic_open_mk' AlgebraicGeometry.StructureSheaf.toBasicOpen_mk'
+-/
 
+#print AlgebraicGeometry.StructureSheaf.localization_toBasicOpen /-
 @[simp]
 theorem localization_toBasicOpen (f : R) :
     RingHom.comp (toBasicOpen R f) (algebraMap R (Localization.Away f)) = toOpen R (basicOpen f) :=
   RingHom.ext fun g => by
     rw [to_basic_open, IsLocalization.Away.lift, RingHom.comp_apply, IsLocalization.lift_eq]
 #align algebraic_geometry.structure_sheaf.localization_to_basic_open AlgebraicGeometry.StructureSheaf.localization_toBasicOpen
+-/
 
+#print AlgebraicGeometry.StructureSheaf.toBasicOpen_to_map /-
 @[simp]
 theorem toBasicOpen_to_map (s f : R) :
     toBasicOpen R s (algebraMap R (Localization.Away s) f) =
       const R f 1 (basicOpen s) fun _ _ => Submonoid.one_mem _ :=
   (IsLocalization.lift_eq _ _).trans <| toOpen_eq_const _ _ _
 #align algebraic_geometry.structure_sheaf.to_basic_open_to_map AlgebraicGeometry.StructureSheaf.toBasicOpen_to_map
+-/
 
+#print AlgebraicGeometry.StructureSheaf.toBasicOpen_injective /-
 -- The proof here follows the argument in Hartshorne's Algebraic Geometry, Proposition II.2.2.
 theorem toBasicOpen_injective (f : R) : Function.Injective (toBasicOpen R f) :=
   by
@@ -699,7 +792,9 @@ theorem toBasicOpen_injective (f : R) : Function.Injective (toBasicOpen R f) :=
   cases' this with r hr
   exact ⟨r.1, hr, r.2⟩
 #align algebraic_geometry.structure_sheaf.to_basic_open_injective AlgebraicGeometry.StructureSheaf.toBasicOpen_injective
+-/
 
+#print AlgebraicGeometry.StructureSheaf.locally_const_basicOpen /-
 /-
 Auxiliary lemma for surjectivity of `to_basic_open`.
 Every section can locally be represented on basic opens `basic_opens g` as a fraction `f/g`
@@ -740,9 +835,11 @@ theorem locally_const_basicOpen (U : Opens (PrimeSpectrum.Top R))
   apply const_ext
   rw [mul_assoc f c g, hc]
 #align algebraic_geometry.structure_sheaf.locally_const_basic_open AlgebraicGeometry.StructureSheaf.locally_const_basicOpen
+-/
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
 /- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (i j «expr ∈ » t) -/
+#print AlgebraicGeometry.StructureSheaf.normalize_finite_fraction_representation /-
 /-
 Auxiliary lemma for surjectivity of `to_basic_open`.
 A local representation of a section `s` as fractions `a i / h i` on finitely many basic opens
@@ -829,11 +926,13 @@ theorem normalize_finite_fraction_representation (U : Opens (PrimeSpectrum.Top R
   rw [pow_succ]
   ring
 #align algebraic_geometry.structure_sheaf.normalize_finite_fraction_representation AlgebraicGeometry.StructureSheaf.normalize_finite_fraction_representation
+-/
 
 open scoped Classical
 
 open scoped BigOperators
 
+#print AlgebraicGeometry.StructureSheaf.toBasicOpen_surjective /-
 -- The proof here follows the argument in Hartshorne's Algebraic Geometry, Proposition II.2.2.
 theorem toBasicOpen_surjective (f : R) : Function.Surjective (toBasicOpen R f) :=
   by
@@ -915,6 +1014,7 @@ theorem toBasicOpen_surjective (f : R) : Function.Surjective (toBasicOpen R f) :
   rw [mul_assoc, ah_ha j hj i hi]
   ring
 #align algebraic_geometry.structure_sheaf.to_basic_open_surjective AlgebraicGeometry.StructureSheaf.toBasicOpen_surjective
+-/
 
 #print AlgebraicGeometry.StructureSheaf.isIso_toBasicOpen /-
 instance isIso_toBasicOpen (f : R) : IsIso (show CommRingCat.of _ ⟶ _ from toBasicOpen R f) :=
@@ -924,12 +1024,14 @@ instance isIso_toBasicOpen (f : R) : IsIso (show CommRingCat.of _ ⟶ _ from toB
 #align algebraic_geometry.structure_sheaf.is_iso_to_basic_open AlgebraicGeometry.StructureSheaf.isIso_toBasicOpen
 -/
 
+#print AlgebraicGeometry.StructureSheaf.basicOpenIso /-
 /-- The ring isomorphism between the structure sheaf on `basic_open f` and the localization of `R`
 at the submonoid of powers of `f`. -/
 def basicOpenIso (f : R) :
     (structureSheaf R).1.obj (op (basicOpen f)) ≅ CommRingCat.of (Localization.Away f) :=
   (asIso (show CommRingCat.of _ ⟶ _ from toBasicOpen R f)).symm
 #align algebraic_geometry.structure_sheaf.basic_open_iso AlgebraicGeometry.StructureSheaf.basicOpenIso
+-/
 
 #print AlgebraicGeometry.StructureSheaf.stalkAlgebra /-
 instance stalkAlgebra (p : PrimeSpectrum R) : Algebra R ((structureSheaf R).Presheaf.stalk p) :=
@@ -937,11 +1039,13 @@ instance stalkAlgebra (p : PrimeSpectrum R) : Algebra R ((structureSheaf R).Pres
 #align algebraic_geometry.structure_sheaf.stalk_algebra AlgebraicGeometry.StructureSheaf.stalkAlgebra
 -/
 
+#print AlgebraicGeometry.StructureSheaf.stalkAlgebra_map /-
 @[simp]
 theorem stalkAlgebra_map (p : PrimeSpectrum R) (r : R) :
     algebraMap R ((structureSheaf R).Presheaf.stalk p) r = toStalk R p r :=
   rfl
 #align algebraic_geometry.structure_sheaf.stalk_algebra_map AlgebraicGeometry.StructureSheaf.stalkAlgebra_map
+-/
 
 #print AlgebraicGeometry.StructureSheaf.IsLocalization.to_stalk /-
 /-- Stalk of the structure sheaf at a prime p as localization of R -/
@@ -961,16 +1065,21 @@ instance IsLocalization.to_stalk (p : PrimeSpectrum R) :
 #align algebraic_geometry.structure_sheaf.is_localization.to_stalk AlgebraicGeometry.StructureSheaf.IsLocalization.to_stalk
 -/
 
+#print AlgebraicGeometry.StructureSheaf.openAlgebra /-
 instance openAlgebra (U : (Opens (PrimeSpectrum R))ᵒᵖ) : Algebra R ((structureSheaf R).val.obj U) :=
   (toOpen R (unop U)).toAlgebra
 #align algebraic_geometry.structure_sheaf.open_algebra AlgebraicGeometry.StructureSheaf.openAlgebra
+-/
 
+#print AlgebraicGeometry.StructureSheaf.openAlgebra_map /-
 @[simp]
 theorem openAlgebra_map (U : (Opens (PrimeSpectrum R))ᵒᵖ) (r : R) :
     algebraMap R ((structureSheaf R).val.obj U) r = toOpen R (unop U) r :=
   rfl
 #align algebraic_geometry.structure_sheaf.open_algebra_map AlgebraicGeometry.StructureSheaf.openAlgebra_map
+-/
 
+#print AlgebraicGeometry.StructureSheaf.IsLocalization.to_basicOpen /-
 /-- Sections of the structure sheaf of Spec R on a basic open as localization of R -/
 instance IsLocalization.to_basicOpen (r : R) :
     IsLocalization.Away r ((structureSheaf R).val.obj (op <| basicOpen r)) :=
@@ -984,13 +1093,17 @@ instance IsLocalization.to_basicOpen (r : R) :
   congr 1
   exact (localization_to_basic_open R r).symm
 #align algebraic_geometry.structure_sheaf.is_localization.to_basic_open AlgebraicGeometry.StructureSheaf.IsLocalization.to_basicOpen
+-/
 
+#print AlgebraicGeometry.StructureSheaf.to_basicOpen_epi /-
 instance to_basicOpen_epi (r : R) : Epi (toOpen R (basicOpen r)) :=
   ⟨fun S f g h => by
     refine' IsLocalization.ringHom_ext _ _
     pick_goal 5; exact is_localization.to_basic_open R r; exact h⟩
 #align algebraic_geometry.structure_sheaf.to_basic_open_epi AlgebraicGeometry.StructureSheaf.to_basicOpen_epi
+-/
 
+#print AlgebraicGeometry.StructureSheaf.to_global_factors /-
 @[elementwise]
 theorem to_global_factors :
     toOpen R ⊤ =
@@ -1002,7 +1115,9 @@ theorem to_global_factors :
   unfold CommRingCat.ofHom
   rw [localization_to_basic_open R, to_open_res]
 #align algebraic_geometry.structure_sheaf.to_global_factors AlgebraicGeometry.StructureSheaf.to_global_factors
+-/
 
+#print AlgebraicGeometry.StructureSheaf.isIso_to_global /-
 instance isIso_to_global : IsIso (toOpen R ⊤) :=
   by
   let hom := CommRingCat.ofHom (algebraMap R (Localization.Away (1 : R)))
@@ -1011,17 +1126,22 @@ instance isIso_to_global : IsIso (toOpen R ⊤) :=
   rw [to_global_factors R]
   infer_instance
 #align algebraic_geometry.structure_sheaf.is_iso_to_global AlgebraicGeometry.StructureSheaf.isIso_to_global
+-/
 
+#print AlgebraicGeometry.StructureSheaf.globalSectionsIso /-
 /-- The ring isomorphism between the ring `R` and the global sections `Γ(X, 𝒪ₓ)`. -/
 @[simps (config := { rhsMd := Tactic.Transparency.semireducible })]
 def globalSectionsIso : CommRingCat.of R ≅ (structureSheaf R).1.obj (op ⊤) :=
   asIso (toOpen R ⊤)
 #align algebraic_geometry.structure_sheaf.global_sections_iso AlgebraicGeometry.StructureSheaf.globalSectionsIso
+-/
 
+#print AlgebraicGeometry.StructureSheaf.globalSectionsIso_hom /-
 @[simp]
 theorem globalSectionsIso_hom (R : CommRingCat) : (globalSectionsIso R).hom = toOpen R ⊤ :=
   rfl
 #align algebraic_geometry.structure_sheaf.global_sections_iso_hom AlgebraicGeometry.StructureSheaf.globalSectionsIso_hom
+-/
 
 #print AlgebraicGeometry.StructureSheaf.toStalk_stalkSpecializes /-
 @[simp, reassoc, elementwise]
@@ -1033,6 +1153,7 @@ theorem toStalk_stalkSpecializes {R : Type _} [CommRing R] {x y : PrimeSpectrum
 
 /- warning: algebraic_geometry.structure_sheaf.localization_to_stalk_stalk_specializes clashes with algebraic_geometry.structure_sheaf.localizationToStalk_stalk_specializes -> AlgebraicGeometry.StructureSheaf.localizationToStalk_stalkSpecializes
 Case conversion may be inaccurate. Consider using '#align algebraic_geometry.structure_sheaf.localization_to_stalk_stalk_specializes AlgebraicGeometry.StructureSheaf.localizationToStalk_stalkSpecializesₓ'. -/
+#print AlgebraicGeometry.StructureSheaf.localizationToStalk_stalkSpecializes /-
 @[simp, reassoc, elementwise]
 theorem localizationToStalk_stalkSpecializes {R : Type _} [CommRing R] {x y : PrimeSpectrum R}
     (h : x ⤳ y) :
@@ -1048,7 +1169,9 @@ theorem localizationToStalk_stalkSpecializes {R : Type _} [CommRing R] {x y : Pr
   rw [IsLocalization.lift_comp, IsLocalization.lift_comp, IsLocalization.lift_comp]
   exact to_stalk_stalk_specializes h
 #align algebraic_geometry.structure_sheaf.localization_to_stalk_stalk_specializes AlgebraicGeometry.StructureSheaf.localizationToStalk_stalkSpecializes
+-/
 
+#print AlgebraicGeometry.StructureSheaf.stalkSpecializes_stalk_to_fiber /-
 @[simp, reassoc, elementwise]
 theorem stalkSpecializes_stalk_to_fiber {R : Type _} [CommRing R] {x y : PrimeSpectrum R}
     (h : x ⤳ y) :
@@ -1059,11 +1182,13 @@ theorem stalkSpecializes_stalk_to_fiber {R : Type _} [CommRing R] {x y : PrimeSp
   rw [← iso.eq_comp_inv, category.assoc, ← iso.inv_comp_eq]
   exact localization_to_stalk_stalk_specializes h
 #align algebraic_geometry.structure_sheaf.stalk_specializes_stalk_to_fiber AlgebraicGeometry.StructureSheaf.stalkSpecializes_stalk_to_fiber
+-/
 
 section Comap
 
 variable {R} {S : Type u} [CommRing S] {P : Type u} [CommRing P]
 
+#print AlgebraicGeometry.StructureSheaf.comapFun /-
 /--
 Given a ring homomorphism `f : R →+* S`, an open set `U` of the prime spectrum of `R` and an open
 set `V` of the prime spectrum of `S`, such that `V ⊆ (comap f) ⁻¹' U`, we can push a section `s`
@@ -1081,7 +1206,9 @@ def comapFun (f : R →+* S) (U : Opens (PrimeSpectrum.Top R)) (V : Opens (Prime
   Localization.localRingHom (PrimeSpectrum.comap f y.1).asIdeal _ f rfl
     (s ⟨PrimeSpectrum.comap f y.1, hUV y.2⟩ : _)
 #align algebraic_geometry.structure_sheaf.comap_fun AlgebraicGeometry.StructureSheaf.comapFun
+-/
 
+#print AlgebraicGeometry.StructureSheaf.comapFunIsLocallyFraction /-
 theorem comapFunIsLocallyFraction (f : R →+* S) (U : Opens (PrimeSpectrum.Top R))
     (V : Opens (PrimeSpectrum.Top S)) (hUV : V.1 ⊆ PrimeSpectrum.comap f ⁻¹' U.1)
     (s : ∀ x : U, Localizations R x) (hs : (isLocallyFraction R).toPrelocalPredicate.pred s) :
@@ -1102,7 +1229,9 @@ theorem comapFunIsLocallyFraction (f : R →+* S) (U : Opens (PrimeSpectrum.Top
     h_frac.2, Localization.localRingHom_to_map]
   rfl
 #align algebraic_geometry.structure_sheaf.comap_fun_is_locally_fraction AlgebraicGeometry.StructureSheaf.comapFunIsLocallyFraction
+-/
 
+#print AlgebraicGeometry.StructureSheaf.comap /-
 /-- For a ring homomorphism `f : R →+* S` and open sets `U` and `V` of the prime spectra of `R` and
 `S` such that `V ⊆ (comap f) ⁻¹ U`, the induced ring homomorphism from the structure sheaf of `R`
 at `U` to the structure sheaf of `S` at `V`.
@@ -1144,7 +1273,9 @@ def comap (f : R →+* S) (U : Opens (PrimeSpectrum.Top R)) (V : Opens (PrimeSpe
           Pi.mul_apply, RingHom.map_mul]
         rfl
 #align algebraic_geometry.structure_sheaf.comap AlgebraicGeometry.StructureSheaf.comap
+-/
 
+#print AlgebraicGeometry.StructureSheaf.comap_apply /-
 @[simp]
 theorem comap_apply (f : R →+* S) (U : Opens (PrimeSpectrum.Top R))
     (V : Opens (PrimeSpectrum.Top S)) (hUV : V.1 ⊆ PrimeSpectrum.comap f ⁻¹' U.1)
@@ -1154,7 +1285,9 @@ theorem comap_apply (f : R →+* S) (U : Opens (PrimeSpectrum.Top R))
         (s.1 ⟨PrimeSpectrum.comap f p.1, hUV p.2⟩ : _) :=
   rfl
 #align algebraic_geometry.structure_sheaf.comap_apply AlgebraicGeometry.StructureSheaf.comap_apply
+-/
 
+#print AlgebraicGeometry.StructureSheaf.comap_const /-
 theorem comap_const (f : R →+* S) (U : Opens (PrimeSpectrum.Top R))
     (V : Opens (PrimeSpectrum.Top S)) (hUV : V.1 ⊆ PrimeSpectrum.comap f ⁻¹' U.1) (a b : R)
     (hb : ∀ x : PrimeSpectrum R, x ∈ U → b ∈ x.asIdeal.primeCompl) :
@@ -1166,7 +1299,9 @@ theorem comap_const (f : R →+* S) (U : Opens (PrimeSpectrum.Top R))
       erw [Localization.localRingHom_mk']
       rfl
 #align algebraic_geometry.structure_sheaf.comap_const AlgebraicGeometry.StructureSheaf.comap_const
+-/
 
+#print AlgebraicGeometry.StructureSheaf.comap_id_eq_map /-
 /-- For an inclusion `i : V ⟶ U` between open sets of the prime spectrum of `R`, the comap of the
 identity from OO_X(U) to OO_X(V) equals as the restriction map of the structure sheaf.
 
@@ -1193,7 +1328,9 @@ theorem comap_id_eq_map (U V : Opens (PrimeSpectrum.Top R)) (iVU : V ⟶ U) :
         dsimp only at s_eq₁ s_eq₂ 
         erw [s_eq₂, Localization.localRingHom_mk', ← s_eq₁, ← res_apply]
 #align algebraic_geometry.structure_sheaf.comap_id_eq_map AlgebraicGeometry.StructureSheaf.comap_id_eq_map
+-/
 
+#print AlgebraicGeometry.StructureSheaf.comap_id /-
 /--
 The comap of the identity is the identity. In this variant of the lemma, two open subsets `U` and
 `V` are given as arguments, together with a proof that `U = V`. This is be useful when `U` and `V`
@@ -1204,13 +1341,17 @@ theorem comap_id (U V : Opens (PrimeSpectrum.Top R)) (hUV : U = V) :
       eqToHom (show (structureSheaf R).1.obj (op U) = _ by rw [hUV]) :=
   by erw [comap_id_eq_map U V (eq_to_hom hUV.symm), eq_to_hom_op, eq_to_hom_map]
 #align algebraic_geometry.structure_sheaf.comap_id AlgebraicGeometry.StructureSheaf.comap_id
+-/
 
+#print AlgebraicGeometry.StructureSheaf.comap_id' /-
 @[simp]
 theorem comap_id' (U : Opens (PrimeSpectrum.Top R)) :
     (comap (RingHom.id R) U U fun p hpU => by rwa [PrimeSpectrum.comap_id]) = RingHom.id _ := by
   rw [comap_id U U rfl]; rfl
 #align algebraic_geometry.structure_sheaf.comap_id' AlgebraicGeometry.StructureSheaf.comap_id'
+-/
 
+#print AlgebraicGeometry.StructureSheaf.comap_comp /-
 theorem comap_comp (f : R →+* S) (g : S →+* P) (U : Opens (PrimeSpectrum.Top R))
     (V : Opens (PrimeSpectrum.Top S)) (W : Opens (PrimeSpectrum.Top P))
     (hUV : ∀ p ∈ V, PrimeSpectrum.comap f p ∈ U) (hVW : ∀ p ∈ W, PrimeSpectrum.comap g p ∈ V) :
@@ -1225,7 +1366,9 @@ theorem comap_comp (f : R →+* S) (g : S →+* P) (U : Opens (PrimeSpectrum.Top
         -- `prime_spectrum.comap f (prime_spectrum.comap g p)`
         rfl
 #align algebraic_geometry.structure_sheaf.comap_comp AlgebraicGeometry.StructureSheaf.comap_comp
+-/
 
+#print AlgebraicGeometry.StructureSheaf.toOpen_comp_comap /-
 @[elementwise, reassoc]
 theorem toOpen_comp_comap (f : R →+* S) (U : Opens (PrimeSpectrum.Top R)) :
     (toOpen R U ≫ comap f U (Opens.comap (PrimeSpectrum.comap f) U) fun _ => id) =
@@ -1237,6 +1380,7 @@ theorem toOpen_comp_comap (f : R →+* S) (U : Opens (PrimeSpectrum.Top R)) :
         erw [Localization.localRingHom_to_map]
         rfl
 #align algebraic_geometry.structure_sheaf.to_open_comp_comap AlgebraicGeometry.StructureSheaf.toOpen_comp_comap
+-/
 
 end Comap
 
Diff
@@ -742,7 +742,7 @@ theorem locally_const_basicOpen (U : Opens (PrimeSpectrum.Top R))
 #align algebraic_geometry.structure_sheaf.locally_const_basic_open AlgebraicGeometry.StructureSheaf.locally_const_basicOpen
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (i j «expr ∈ » t) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (i j «expr ∈ » t) -/
 /-
 Auxiliary lemma for surjectivity of `to_basic_open`.
 A local representation of a section `s` as fractions `a i / h i` on finitely many basic opens
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Johan Commelin, Scott Morrison
 
 ! This file was ported from Lean 3 source module algebraic_geometry.structure_sheaf
-! leanprover-community/mathlib commit 2ebc1d6c2fed9f54c95bbc3998eaa5570527129a
+! leanprover-community/mathlib commit 13361559d66b84f80b6d5a1c4a26aa5054766725
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -160,6 +160,7 @@ def isLocallyFraction : LocalPredicate (Localizations R) :=
 #align algebraic_geometry.structure_sheaf.is_locally_fraction AlgebraicGeometry.StructureSheaf.isLocallyFraction
 -/
 
+#print AlgebraicGeometry.StructureSheaf.isLocallyFraction_pred /-
 @[simp]
 theorem isLocallyFraction_pred {U : Opens (PrimeSpectrum.Top R)} (f : ∀ x : U, Localizations R x) :
     (isLocallyFraction R).pred f =
@@ -169,6 +170,7 @@ theorem isLocallyFraction_pred {U : Opens (PrimeSpectrum.Top R)} (f : ∀ x : U,
             ∀ y : V, ¬s ∈ y.1.asIdeal ∧ f (i y : U) * algebraMap _ _ s = algebraMap _ _ r :=
   rfl
 #align algebraic_geometry.structure_sheaf.is_locally_fraction_pred AlgebraicGeometry.StructureSheaf.isLocallyFraction_pred
+-/
 
 /-- The functions satisfying `is_locally_fraction` form a subring.
 -/
@@ -880,12 +882,12 @@ theorem toBasicOpen_surjective (f : R) : Function.Surjective (toBasicOpen R f) :
       (⟨f ^ (n + 1), n + 1, rfl⟩ : Submonoid.powers _)
   rw [to_basic_open_mk']
   -- Since the structure sheaf is a sheaf, we can show the desired equality locally.
-  -- Annoyingly, `sheaf.eq_of_locally_eq` requires an open cover indexed by a *type*, so we need to
+  -- Annoyingly, `sheaf.eq_of_locally_eq'` requires an open cover indexed by a *type*, so we need to
   -- coerce our finset `t` to a type first.
   let tt := ((t : Set (basic_open f)) : Type u)
   apply
-    (structure_sheaf R).eq_of_locally_eq' (fun i : tt => basic_open (h i)) (basic_open f)
-      fun i : tt => iDh i
+    TopCat.Sheaf.eq_of_locally_eq'.{u + 1, u} (structure_sheaf R) (fun i : tt => basic_open (h i))
+      (basic_open f) fun i : tt => iDh i
   · -- This feels a little redundant, since already have `ht_cover` as a hypothesis
     -- Unfortunately, `ht_cover` uses a bounded union over the set `t`, while here we have the
     -- Union indexed by the type `tt`, so we need some boilerplate to translate one to the other
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Johan Commelin, Scott Morrison
 
 ! This file was ported from Lean 3 source module algebraic_geometry.structure_sheaf
-! leanprover-community/mathlib commit d39590fc8728fbf6743249802486f8c91ffe07bc
+! leanprover-community/mathlib commit 2ebc1d6c2fed9f54c95bbc3998eaa5570527129a
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -18,6 +18,9 @@ import Mathbin.RingTheory.Subring.Basic
 /-!
 # The structure sheaf on `prime_spectrum R`.
 
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
 We define the structure sheaf on `Top.of (prime_spectrum R)`, for a commutative ring `R` and prove
 basic properties about it. We define this as a subsheaf of the sheaf of dependent functions into the
 localizations, cut out by the condition that the function must be locally equal to a ratio of
@@ -172,7 +175,7 @@ theorem isLocallyFraction_pred {U : Opens (PrimeSpectrum.Top R)} (f : ∀ x : U,
 def sectionsSubring (U : (Opens (PrimeSpectrum.Top R))ᵒᵖ) :
     Subring (∀ x : unop U, Localizations R x)
     where
-  carrier := { f | (isLocallyFraction R).pred f }
+  carrier := {f | (isLocallyFraction R).pred f}
   zero_mem' := by
     refine' fun x => ⟨unop U, x.2, 𝟙 _, 0, 1, fun y => ⟨_, _⟩⟩
     · rw [← Ideal.ne_top_iff_one]; exact y.1.IsPrime.1
@@ -677,7 +680,7 @@ theorem toBasicOpen_injective (f : R) : Function.Injective (toBasicOpen R f) :=
   -- This amounts showing that `r * (d * a) = r * (b * c)`, for some power `r = f ^ n` of `f`.
   -- We define `I` as the ideal of *all* elements `r` satisfying the above equation.
   let I : Ideal R :=
-    { carrier := { r : R | r * (d * a) = r * (b * c) }
+    { carrier := {r : R | r * (d * a) = r * (b * c)}
       zero_mem' := by simp only [Set.mem_setOf_eq, MulZeroClass.zero_mul]
       add_mem' := fun r₁ r₂ hr₁ hr₂ => by dsimp at hr₁ hr₂ ⊢; simp only [add_mul, hr₁, hr₂]
       smul_mem' := fun r₁ r₂ hr₂ => by dsimp at hr₂ ⊢; simp only [mul_assoc, hr₂] }
@@ -943,7 +946,8 @@ theorem stalkAlgebra_map (p : PrimeSpectrum R) (r : R) :
 instance IsLocalization.to_stalk (p : PrimeSpectrum R) :
     IsLocalization.AtPrime ((structureSheaf R).Presheaf.stalk p) p.asIdeal :=
   by
-  convert(IsLocalization.isLocalization_iff_of_ringEquiv _
+  convert
+    (IsLocalization.isLocalization_iff_of_ringEquiv _
           (stalk_iso R p).symm.commRingCatIsoToRingEquiv).mp
       Localization.isLocalization
   apply Algebra.algebra_ext
@@ -969,7 +973,8 @@ theorem openAlgebra_map (U : (Opens (PrimeSpectrum R))ᵒᵖ) (r : R) :
 instance IsLocalization.to_basicOpen (r : R) :
     IsLocalization.Away r ((structureSheaf R).val.obj (op <| basicOpen r)) :=
   by
-  convert(IsLocalization.isLocalization_iff_of_ringEquiv _
+  convert
+    (IsLocalization.isLocalization_iff_of_ringEquiv _
           (basic_open_iso R r).symm.commRingCatIsoToRingEquiv).mp
       Localization.isLocalization
   apply Algebra.algebra_ext
Diff
@@ -66,47 +66,54 @@ open Opposite
 
 namespace AlgebraicGeometry
 
+#print AlgebraicGeometry.PrimeSpectrum.Top /-
 /-- The prime spectrum, just as a topological space.
 -/
-def PrimeSpectrum.top : TopCat :=
+def PrimeSpectrum.Top : TopCat :=
   TopCat.of (PrimeSpectrum R)
-#align algebraic_geometry.prime_spectrum.Top AlgebraicGeometry.PrimeSpectrum.top
+#align algebraic_geometry.prime_spectrum.Top AlgebraicGeometry.PrimeSpectrum.Top
+-/
 
 namespace StructureSheaf
 
+#print AlgebraicGeometry.StructureSheaf.Localizations /-
 /-- The type family over `prime_spectrum R` consisting of the localization over each point.
 -/
-def Localizations (P : PrimeSpectrum.top R) : Type u :=
-  Localization.AtPrime P.asIdeal deriving CommRing, LocalRing
+def Localizations (P : PrimeSpectrum.Top R) : Type u :=
+  Localization.AtPrime P.asIdeal
+deriving CommRing, LocalRing
 #align algebraic_geometry.structure_sheaf.localizations AlgebraicGeometry.StructureSheaf.Localizations
+-/
 
-instance (P : PrimeSpectrum.top R) : Inhabited (Localizations R P) :=
+instance (P : PrimeSpectrum.Top R) : Inhabited (Localizations R P) :=
   ⟨1⟩
 
-instance (U : Opens (PrimeSpectrum.top R)) (x : U) : Algebra R (Localizations R x) :=
+instance (U : Opens (PrimeSpectrum.Top R)) (x : U) : Algebra R (Localizations R x) :=
   Localization.algebra
 
-instance (U : Opens (PrimeSpectrum.top R)) (x : U) :
-    IsLocalization.AtPrime (Localizations R x) (x : PrimeSpectrum.top R).asIdeal :=
+instance (U : Opens (PrimeSpectrum.Top R)) (x : U) :
+    IsLocalization.AtPrime (Localizations R x) (x : PrimeSpectrum.Top R).asIdeal :=
   Localization.isLocalization
 
 variable {R}
 
+#print AlgebraicGeometry.StructureSheaf.IsFraction /-
 /-- The predicate saying that a dependent function on an open `U` is realised as a fixed fraction
 `r / s` in each of the stalks (which are localizations at various prime ideals).
 -/
-def IsFraction {U : Opens (PrimeSpectrum.top R)} (f : ∀ x : U, Localizations R x) : Prop :=
+def IsFraction {U : Opens (PrimeSpectrum.Top R)} (f : ∀ x : U, Localizations R x) : Prop :=
   ∃ r s : R, ∀ x : U, ¬s ∈ x.1.asIdeal ∧ f x * algebraMap _ _ s = algebraMap _ _ r
 #align algebraic_geometry.structure_sheaf.is_fraction AlgebraicGeometry.StructureSheaf.IsFraction
+-/
 
-theorem IsFraction.eq_mk' {U : Opens (PrimeSpectrum.top R)} {f : ∀ x : U, Localizations R x}
+theorem IsFraction.eq_mk' {U : Opens (PrimeSpectrum.Top R)} {f : ∀ x : U, Localizations R x}
     (hf : IsFraction f) :
     ∃ r s : R,
       ∀ x : U,
         ∃ hs : s ∉ x.1.asIdeal,
           f x =
             IsLocalization.mk' (Localization.AtPrime _) r
-              (⟨s, hs⟩ : (x : PrimeSpectrum.top R).asIdeal.primeCompl) :=
+              (⟨s, hs⟩ : (x : PrimeSpectrum.Top R).asIdeal.primeCompl) :=
   by
   rcases hf with ⟨r, s, h⟩
   refine' ⟨r, s, fun x => ⟨(h x).1, (is_localization.mk'_eq_iff_eq_mul.mpr _).symm⟩⟩
@@ -115,6 +122,7 @@ theorem IsFraction.eq_mk' {U : Opens (PrimeSpectrum.top R)} {f : ∀ x : U, Loca
 
 variable (R)
 
+#print AlgebraicGeometry.StructureSheaf.isFractionPrelocal /-
 /-- The predicate `is_fraction` is "prelocal",
 in the sense that if it holds on `U` it holds on any open subset `V` of `U`.
 -/
@@ -123,7 +131,9 @@ def isFractionPrelocal : PrelocalPredicate (Localizations R)
   pred U f := IsFraction f
   res := by rintro V U i f ⟨r, s, w⟩; exact ⟨r, s, fun x => w (i x)⟩
 #align algebraic_geometry.structure_sheaf.is_fraction_prelocal AlgebraicGeometry.StructureSheaf.isFractionPrelocal
+-/
 
+#print AlgebraicGeometry.StructureSheaf.isLocallyFraction /-
 /-- We will define the structure sheaf as
 the subsheaf of all dependent functions in `Π x : U, localizations R x`
 consisting of those functions which can locally be expressed as a ratio of
@@ -145,12 +155,13 @@ so we replace his circumlocution about functions into a disjoint union with
 def isLocallyFraction : LocalPredicate (Localizations R) :=
   (isFractionPrelocal R).sheafify
 #align algebraic_geometry.structure_sheaf.is_locally_fraction AlgebraicGeometry.StructureSheaf.isLocallyFraction
+-/
 
 @[simp]
-theorem isLocallyFraction_pred {U : Opens (PrimeSpectrum.top R)} (f : ∀ x : U, Localizations R x) :
+theorem isLocallyFraction_pred {U : Opens (PrimeSpectrum.Top R)} (f : ∀ x : U, Localizations R x) :
     (isLocallyFraction R).pred f =
       ∀ x : U,
-        ∃ (V : _)(m : x.1 ∈ V)(i : V ⟶ U),
+        ∃ (V : _) (m : x.1 ∈ V) (i : V ⟶ U),
           ∃ r s : R,
             ∀ y : V, ¬s ∈ y.1.asIdeal ∧ f (i y : U) * algebraMap _ _ s = algebraMap _ _ r :=
   rfl
@@ -158,7 +169,7 @@ theorem isLocallyFraction_pred {U : Opens (PrimeSpectrum.top R)} (f : ∀ x : U,
 
 /-- The functions satisfying `is_locally_fraction` form a subring.
 -/
-def sectionsSubring (U : (Opens (PrimeSpectrum.top R))ᵒᵖ) :
+def sectionsSubring (U : (Opens (PrimeSpectrum.Top R))ᵒᵖ) :
     Subring (∀ x : unop U, Localizations R x)
     where
   carrier := { f | (isLocallyFraction R).pred f }
@@ -216,25 +227,28 @@ end StructureSheaf
 
 open StructureSheaf
 
+#print AlgebraicGeometry.structureSheafInType /-
 /-- The structure sheaf (valued in `Type`, not yet `CommRing`) is the subsheaf consisting of
 functions satisfying `is_locally_fraction`.
 -/
-def structureSheafInType : Sheaf (Type u) (PrimeSpectrum.top R) :=
+def structureSheafInType : Sheaf (Type u) (PrimeSpectrum.Top R) :=
   subsheafToTypes (isLocallyFraction R)
 #align algebraic_geometry.structure_sheaf_in_Type AlgebraicGeometry.structureSheafInType
+-/
 
-instance commRingStructureSheafInTypeObj (U : (Opens (PrimeSpectrum.top R))ᵒᵖ) :
+instance commRingStructureSheafInTypeObj (U : (Opens (PrimeSpectrum.Top R))ᵒᵖ) :
     CommRing ((structureSheafInType R).1.obj U) :=
   (sectionsSubring R U).toCommRing
 #align algebraic_geometry.comm_ring_structure_sheaf_in_Type_obj AlgebraicGeometry.commRingStructureSheafInTypeObj
 
 open _Root_.PrimeSpectrum
 
+#print AlgebraicGeometry.structurePresheafInCommRing /-
 /-- The structure presheaf, valued in `CommRing`, constructed by dressing up the `Type` valued
 structure presheaf.
 -/
 @[simps]
-def structurePresheafInCommRing : Presheaf CommRingCat (PrimeSpectrum.top R)
+def structurePresheafInCommRing : Presheaf CommRingCat (PrimeSpectrum.Top R)
     where
   obj U := CommRingCat.of ((structureSheafInType R).1.obj U)
   map U V i :=
@@ -244,6 +258,7 @@ def structurePresheafInCommRing : Presheaf CommRingCat (PrimeSpectrum.top R)
       map_one' := rfl
       map_mul' := fun x y => rfl }
 #align algebraic_geometry.structure_presheaf_in_CommRing AlgebraicGeometry.structurePresheafInCommRing
+-/
 
 /-- Some glue, verifying that that structure presheaf valued in `CommRing` agrees
 with the `Type` valued structure presheaf.
@@ -255,24 +270,26 @@ def structurePresheafCompForget :
 
 open TopCat.Presheaf
 
+#print AlgebraicGeometry.Spec.structureSheaf /-
 /-- The structure sheaf on $Spec R$, valued in `CommRing`.
 
 This is provided as a bundled `SheafedSpace` as `Spec.SheafedSpace R` later.
 -/
-def Spec.structureSheaf : Sheaf CommRingCat (PrimeSpectrum.top R) :=
+def Spec.structureSheaf : Sheaf CommRingCat (PrimeSpectrum.Top R) :=
   ⟨structurePresheafInCommRing R,
     (-- We check the sheaf condition under `forget CommRing`.
           isSheaf_iff_isSheaf_comp
           _ _).mpr
       (isSheaf_of_iso (structurePresheafCompForget R).symm (structureSheafInType R).cond)⟩
 #align algebraic_geometry.Spec.structure_sheaf AlgebraicGeometry.Spec.structureSheaf
+-/
 
 open Spec (structureSheaf)
 
 namespace StructureSheaf
 
 @[simp]
-theorem res_apply (U V : Opens (PrimeSpectrum.top R)) (i : V ⟶ U)
+theorem res_apply (U V : Opens (PrimeSpectrum.Top R)) (i : V ⟶ U)
     (s : (structureSheaf R).1.obj (op U)) (x : V) :
     ((structureSheaf R).1.map i.op s).1 x = (s.1 (i x) : _) :=
   rfl
@@ -304,30 +321,30 @@ In the square brackets we list the dependencies of a construction on the previou
 -/
 /-- The section of `structure_sheaf R` on an open `U` sending each `x ∈ U` to the element
 `f/g` in the localization of `R` at `x`. -/
-def const (f g : R) (U : Opens (PrimeSpectrum.top R))
-    (hu : ∀ x ∈ U, g ∈ (x : PrimeSpectrum.top R).asIdeal.primeCompl) :
+def const (f g : R) (U : Opens (PrimeSpectrum.Top R))
+    (hu : ∀ x ∈ U, g ∈ (x : PrimeSpectrum.Top R).asIdeal.primeCompl) :
     (structureSheaf R).1.obj (op U) :=
   ⟨fun x => IsLocalization.mk' _ f ⟨g, hu x x.2⟩, fun x =>
     ⟨U, x.2, 𝟙 _, f, g, fun y => ⟨hu y y.2, IsLocalization.mk'_spec _ _ _⟩⟩⟩
 #align algebraic_geometry.structure_sheaf.const AlgebraicGeometry.StructureSheaf.const
 
 @[simp]
-theorem const_apply (f g : R) (U : Opens (PrimeSpectrum.top R))
-    (hu : ∀ x ∈ U, g ∈ (x : PrimeSpectrum.top R).asIdeal.primeCompl) (x : U) :
+theorem const_apply (f g : R) (U : Opens (PrimeSpectrum.Top R))
+    (hu : ∀ x ∈ U, g ∈ (x : PrimeSpectrum.Top R).asIdeal.primeCompl) (x : U) :
     (const R f g U hu).1 x = IsLocalization.mk' _ f ⟨g, hu x x.2⟩ :=
   rfl
 #align algebraic_geometry.structure_sheaf.const_apply AlgebraicGeometry.StructureSheaf.const_apply
 
-theorem const_apply' (f g : R) (U : Opens (PrimeSpectrum.top R))
-    (hu : ∀ x ∈ U, g ∈ (x : PrimeSpectrum.top R).asIdeal.primeCompl) (x : U)
-    (hx : g ∈ (asIdeal (x : PrimeSpectrum.top R)).primeCompl) :
+theorem const_apply' (f g : R) (U : Opens (PrimeSpectrum.Top R))
+    (hu : ∀ x ∈ U, g ∈ (x : PrimeSpectrum.Top R).asIdeal.primeCompl) (x : U)
+    (hx : g ∈ (asIdeal (x : PrimeSpectrum.Top R)).primeCompl) :
     (const R f g U hu).1 x = IsLocalization.mk' _ f ⟨g, hx⟩ :=
   rfl
 #align algebraic_geometry.structure_sheaf.const_apply' AlgebraicGeometry.StructureSheaf.const_apply'
 
-theorem exists_const (U) (s : (structureSheaf R).1.obj (op U)) (x : PrimeSpectrum.top R)
+theorem exists_const (U) (s : (structureSheaf R).1.obj (op U)) (x : PrimeSpectrum.Top R)
     (hx : x ∈ U) :
-    ∃ (V : Opens (PrimeSpectrum.top R))(hxV : x ∈ V)(i : V ⟶ U)(f g : R)(hg : _),
+    ∃ (V : Opens (PrimeSpectrum.Top R)) (hxV : x ∈ V) (i : V ⟶ U) (f g : R) (hg : _),
       const R f g V hg = (structureSheaf R).1.map i.op s :=
   let ⟨V, hxV, iVU, f, g, hfg⟩ := s.2 ⟨x, hx⟩
   ⟨V, hxV, iVU, f, g, fun y hyV => (hfg ⟨y, hyV⟩).1,
@@ -406,7 +423,7 @@ theorem const_mul_cancel' (f g₁ g₂ : R) (U hu₁ hu₂) :
 
 /-- The canonical ring homomorphism interpreting an element of `R` as
 a section of the structure sheaf. -/
-def toOpen (U : Opens (PrimeSpectrum.top R)) : CommRingCat.of R ⟶ (structureSheaf R).1.obj (op U)
+def toOpen (U : Opens (PrimeSpectrum.Top R)) : CommRingCat.of R ⟶ (structureSheaf R).1.obj (op U)
     where
   toFun f :=
     ⟨fun x => algebraMap R _ f, fun x =>
@@ -419,41 +436,47 @@ def toOpen (U : Opens (PrimeSpectrum.top R)) : CommRingCat.of R ⟶ (structureSh
 #align algebraic_geometry.structure_sheaf.to_open AlgebraicGeometry.StructureSheaf.toOpen
 
 @[simp]
-theorem toOpen_res (U V : Opens (PrimeSpectrum.top R)) (i : V ⟶ U) :
+theorem toOpen_res (U V : Opens (PrimeSpectrum.Top R)) (i : V ⟶ U) :
     toOpen R U ≫ (structureSheaf R).1.map i.op = toOpen R V :=
   rfl
 #align algebraic_geometry.structure_sheaf.to_open_res AlgebraicGeometry.StructureSheaf.toOpen_res
 
+#print AlgebraicGeometry.StructureSheaf.toOpen_apply /-
 @[simp]
-theorem toOpen_apply (U : Opens (PrimeSpectrum.top R)) (f : R) (x : U) :
+theorem toOpen_apply (U : Opens (PrimeSpectrum.Top R)) (f : R) (x : U) :
     (toOpen R U f).1 x = algebraMap _ _ f :=
   rfl
 #align algebraic_geometry.structure_sheaf.to_open_apply AlgebraicGeometry.StructureSheaf.toOpen_apply
+-/
 
-theorem toOpen_eq_const (U : Opens (PrimeSpectrum.top R)) (f : R) :
+theorem toOpen_eq_const (U : Opens (PrimeSpectrum.Top R)) (f : R) :
     toOpen R U f = const R f 1 U fun x _ => (Ideal.ne_top_iff_one _).1 x.2.1 :=
   Subtype.eq <| funext fun x => Eq.symm <| IsLocalization.mk'_one _ f
 #align algebraic_geometry.structure_sheaf.to_open_eq_const AlgebraicGeometry.StructureSheaf.toOpen_eq_const
 
+#print AlgebraicGeometry.StructureSheaf.toStalk /-
 /-- The canonical ring homomorphism interpreting an element of `R` as an element of
 the stalk of `structure_sheaf R` at `x`. -/
-def toStalk (x : PrimeSpectrum.top R) : CommRingCat.of R ⟶ (structureSheaf R).Presheaf.stalk x :=
+def toStalk (x : PrimeSpectrum.Top R) : CommRingCat.of R ⟶ (structureSheaf R).Presheaf.stalk x :=
   (toOpen R ⊤ ≫ (structureSheaf R).Presheaf.germ ⟨x, ⟨⟩⟩ : _)
 #align algebraic_geometry.structure_sheaf.to_stalk AlgebraicGeometry.StructureSheaf.toStalk
+-/
 
+#print AlgebraicGeometry.StructureSheaf.toOpen_germ /-
 @[simp]
-theorem toOpen_germ (U : Opens (PrimeSpectrum.top R)) (x : U) :
+theorem toOpen_germ (U : Opens (PrimeSpectrum.Top R)) (x : U) :
     toOpen R U ≫ (structureSheaf R).Presheaf.germ x = toStalk R x := by
   rw [← to_open_res R ⊤ U (hom_of_le le_top : U ⟶ ⊤), category.assoc, presheaf.germ_res]; rfl
 #align algebraic_geometry.structure_sheaf.to_open_germ AlgebraicGeometry.StructureSheaf.toOpen_germ
+-/
 
 @[simp]
-theorem germ_toOpen (U : Opens (PrimeSpectrum.top R)) (x : U) (f : R) :
+theorem germ_toOpen (U : Opens (PrimeSpectrum.Top R)) (x : U) (f : R) :
     (structureSheaf R).Presheaf.germ x (toOpen R U f) = toStalk R x f := by rw [← to_open_germ]; rfl
 #align algebraic_geometry.structure_sheaf.germ_to_open AlgebraicGeometry.StructureSheaf.germ_toOpen
 
-theorem germ_to_top (x : PrimeSpectrum.top R) (f : R) :
-    (structureSheaf R).Presheaf.germ (⟨x, trivial⟩ : (⊤ : Opens (PrimeSpectrum.top R)))
+theorem germ_to_top (x : PrimeSpectrum.Top R) (f : R) :
+    (structureSheaf R).Presheaf.germ (⟨x, trivial⟩ : (⊤ : Opens (PrimeSpectrum.Top R)))
         (toOpen R ⊤ f) =
       toStalk R x f :=
   rfl
@@ -464,7 +487,7 @@ theorem isUnit_to_basicOpen_self (f : R) : IsUnit (toOpen R (basicOpen f) f) :=
     rw [to_open_eq_const, const_mul_rev]
 #align algebraic_geometry.structure_sheaf.is_unit_to_basic_open_self AlgebraicGeometry.StructureSheaf.isUnit_to_basicOpen_self
 
-theorem isUnit_toStalk (x : PrimeSpectrum.top R) (f : x.asIdeal.primeCompl) :
+theorem isUnit_toStalk (x : PrimeSpectrum.Top R) (f : x.asIdeal.primeCompl) :
     IsUnit (toStalk R x (f : R)) :=
   by
   erw [← germ_to_open R (basic_open (f : R)) ⟨x, f.2⟩ (f : R)]
@@ -473,19 +496,19 @@ theorem isUnit_toStalk (x : PrimeSpectrum.top R) (f : x.asIdeal.primeCompl) :
 
 /-- The canonical ring homomorphism from the localization of `R` at `p` to the stalk
 of the structure sheaf at the point `p`. -/
-def localizationToStalk (x : PrimeSpectrum.top R) :
+def localizationToStalk (x : PrimeSpectrum.Top R) :
     CommRingCat.of (Localization.AtPrime x.asIdeal) ⟶ (structureSheaf R).Presheaf.stalk x :=
   show Localization.AtPrime x.asIdeal →+* _ from IsLocalization.lift (isUnit_toStalk R x)
 #align algebraic_geometry.structure_sheaf.localization_to_stalk AlgebraicGeometry.StructureSheaf.localizationToStalk
 
 @[simp]
-theorem localizationToStalk_of (x : PrimeSpectrum.top R) (f : R) :
+theorem localizationToStalk_of (x : PrimeSpectrum.Top R) (f : R) :
     localizationToStalk R x (algebraMap _ (Localization _) f) = toStalk R x f :=
   IsLocalization.lift_eq _ f
 #align algebraic_geometry.structure_sheaf.localization_to_stalk_of AlgebraicGeometry.StructureSheaf.localizationToStalk_of
 
 @[simp]
-theorem localizationToStalk_mk' (x : PrimeSpectrum.top R) (f : R) (s : (asIdeal x).primeCompl) :
+theorem localizationToStalk_mk' (x : PrimeSpectrum.Top R) (f : R) (s : (asIdeal x).primeCompl) :
     localizationToStalk R x (IsLocalization.mk' _ f s : Localization _) =
       (structureSheaf R).Presheaf.germ (⟨x, s.2⟩ : basicOpen (s : R))
         (const R f s (basicOpen s) fun _ => id) :=
@@ -497,7 +520,7 @@ theorem localizationToStalk_mk' (x : PrimeSpectrum.top R) (f : R) (s : (asIdeal
 /-- The ring homomorphism that takes a section of the structure sheaf of `R` on the open set `U`,
 implemented as a subtype of dependent functions to localizations at prime ideals, and evaluates
 the section on the point corresponding to a given prime ideal. -/
-def openToLocalization (U : Opens (PrimeSpectrum.top R)) (x : PrimeSpectrum.top R) (hx : x ∈ U) :
+def openToLocalization (U : Opens (PrimeSpectrum.Top R)) (x : PrimeSpectrum.Top R) (hx : x ∈ U) :
     (structureSheaf R).1.obj (op U) ⟶ CommRingCat.of (Localization.AtPrime x.asIdeal)
     where
   toFun s := (s.1 ⟨x, hx⟩ : _)
@@ -508,7 +531,7 @@ def openToLocalization (U : Opens (PrimeSpectrum.top R)) (x : PrimeSpectrum.top
 #align algebraic_geometry.structure_sheaf.open_to_localization AlgebraicGeometry.StructureSheaf.openToLocalization
 
 @[simp]
-theorem coe_openToLocalization (U : Opens (PrimeSpectrum.top R)) (x : PrimeSpectrum.top R)
+theorem coe_openToLocalization (U : Opens (PrimeSpectrum.Top R)) (x : PrimeSpectrum.Top R)
     (hx : x ∈ U) :
     (openToLocalization R U x hx :
         (structureSheaf R).1.obj (op U) → Localization.AtPrime x.asIdeal) =
@@ -516,7 +539,7 @@ theorem coe_openToLocalization (U : Opens (PrimeSpectrum.top R)) (x : PrimeSpect
   rfl
 #align algebraic_geometry.structure_sheaf.coe_open_to_localization AlgebraicGeometry.StructureSheaf.coe_openToLocalization
 
-theorem openToLocalization_apply (U : Opens (PrimeSpectrum.top R)) (x : PrimeSpectrum.top R)
+theorem openToLocalization_apply (U : Opens (PrimeSpectrum.Top R)) (x : PrimeSpectrum.Top R)
     (hx : x ∈ U) (s : (structureSheaf R).1.obj (op U)) :
     openToLocalization R U x hx s = (s.1 ⟨x, hx⟩ : _) :=
   rfl
@@ -525,7 +548,7 @@ theorem openToLocalization_apply (U : Opens (PrimeSpectrum.top R)) (x : PrimeSpe
 /-- The ring homomorphism from the stalk of the structure sheaf of `R` at a point corresponding to
 a prime ideal `p` to the localization of `R` at `p`,
 formed by gluing the `open_to_localization` maps. -/
-def stalkToFiberRingHom (x : PrimeSpectrum.top R) :
+def stalkToFiberRingHom (x : PrimeSpectrum.Top R) :
     (structureSheaf R).Presheaf.stalk x ⟶ CommRingCat.of (Localization.AtPrime x.asIdeal) :=
   Limits.colimit.desc ((OpenNhds.inclusion x).op ⋙ (structureSheaf R).1)
     { X := _
@@ -536,33 +559,33 @@ def stalkToFiberRingHom (x : PrimeSpectrum.top R) :
 #align algebraic_geometry.structure_sheaf.stalk_to_fiber_ring_hom AlgebraicGeometry.StructureSheaf.stalkToFiberRingHom
 
 @[simp]
-theorem germ_comp_stalkToFiberRingHom (U : Opens (PrimeSpectrum.top R)) (x : U) :
+theorem germ_comp_stalkToFiberRingHom (U : Opens (PrimeSpectrum.Top R)) (x : U) :
     (structureSheaf R).Presheaf.germ x ≫ stalkToFiberRingHom R x = openToLocalization R U x x.2 :=
   Limits.colimit.ι_desc _ _
 #align algebraic_geometry.structure_sheaf.germ_comp_stalk_to_fiber_ring_hom AlgebraicGeometry.StructureSheaf.germ_comp_stalkToFiberRingHom
 
 @[simp]
-theorem stalkToFiberRingHom_germ' (U : Opens (PrimeSpectrum.top R)) (x : PrimeSpectrum.top R)
+theorem stalkToFiberRingHom_germ' (U : Opens (PrimeSpectrum.Top R)) (x : PrimeSpectrum.Top R)
     (hx : x ∈ U) (s : (structureSheaf R).1.obj (op U)) :
     stalkToFiberRingHom R x ((structureSheaf R).Presheaf.germ ⟨x, hx⟩ s) = (s.1 ⟨x, hx⟩ : _) :=
   RingHom.ext_iff.1 (germ_comp_stalkToFiberRingHom R U ⟨x, hx⟩ : _) s
 #align algebraic_geometry.structure_sheaf.stalk_to_fiber_ring_hom_germ' AlgebraicGeometry.StructureSheaf.stalkToFiberRingHom_germ'
 
 @[simp]
-theorem stalkToFiberRingHom_germ (U : Opens (PrimeSpectrum.top R)) (x : U)
+theorem stalkToFiberRingHom_germ (U : Opens (PrimeSpectrum.Top R)) (x : U)
     (s : (structureSheaf R).1.obj (op U)) :
     stalkToFiberRingHom R x ((structureSheaf R).Presheaf.germ x s) = s.1 x := by cases x;
   exact stalk_to_fiber_ring_hom_germ' R U _ _ _
 #align algebraic_geometry.structure_sheaf.stalk_to_fiber_ring_hom_germ AlgebraicGeometry.StructureSheaf.stalkToFiberRingHom_germ
 
 @[simp]
-theorem toStalk_comp_stalkToFiberRingHom (x : PrimeSpectrum.top R) :
+theorem toStalk_comp_stalkToFiberRingHom (x : PrimeSpectrum.Top R) :
     toStalk R x ≫ stalkToFiberRingHom R x = (algebraMap _ _ : R →+* Localization _) := by
   erw [to_stalk, category.assoc, germ_comp_stalk_to_fiber_ring_hom]; rfl
 #align algebraic_geometry.structure_sheaf.to_stalk_comp_stalk_to_fiber_ring_hom AlgebraicGeometry.StructureSheaf.toStalk_comp_stalkToFiberRingHom
 
 @[simp]
-theorem stalkToFiberRingHom_toStalk (x : PrimeSpectrum.top R) (f : R) :
+theorem stalkToFiberRingHom_toStalk (x : PrimeSpectrum.Top R) (f : R) :
     stalkToFiberRingHom R x (toStalk R x f) = algebraMap _ (Localization _) f :=
   RingHom.ext_iff.1 (toStalk_comp_stalkToFiberRingHom R x) _
 #align algebraic_geometry.structure_sheaf.stalk_to_fiber_ring_hom_to_stalk AlgebraicGeometry.StructureSheaf.stalkToFiberRingHom_toStalk
@@ -570,7 +593,7 @@ theorem stalkToFiberRingHom_toStalk (x : PrimeSpectrum.top R) (f : R) :
 /-- The ring isomorphism between the stalk of the structure sheaf of `R` at a point `p`
 corresponding to a prime ideal in `R` and the localization of `R` at `p`. -/
 @[simps]
-def stalkIso (x : PrimeSpectrum.top R) :
+def stalkIso (x : PrimeSpectrum.Top R) :
     (structureSheaf R).Presheaf.stalk x ≅ CommRingCat.of (Localization.AtPrime x.asIdeal)
     where
   hom := stalkToFiberRingHom R x
@@ -599,14 +622,16 @@ instance (x : PrimeSpectrum R) : IsIso (stalkToFiberRingHom R x) :=
 instance (x : PrimeSpectrum R) : IsIso (localizationToStalk R x) :=
   IsIso.of_iso (stalkIso R x).symm
 
+#print AlgebraicGeometry.StructureSheaf.stalkToFiberRingHom_localizationToStalk /-
 @[simp, reassoc]
-theorem stalkToFiberRingHom_localizationToStalk (x : PrimeSpectrum.top R) :
+theorem stalkToFiberRingHom_localizationToStalk (x : PrimeSpectrum.Top R) :
     stalkToFiberRingHom R x ≫ localizationToStalk R x = 𝟙 _ :=
   (stalkIso R x).hom_inv_id
 #align algebraic_geometry.structure_sheaf.stalk_to_fiber_ring_hom_localization_to_stalk AlgebraicGeometry.StructureSheaf.stalkToFiberRingHom_localizationToStalk
+-/
 
 @[simp, reassoc]
-theorem localizationToStalk_stalkToFiberRingHom (x : PrimeSpectrum.top R) :
+theorem localizationToStalk_stalkToFiberRingHom (x : PrimeSpectrum.Top R) :
     localizationToStalk R x ≫ stalkToFiberRingHom R x = 𝟙 _ :=
   (stalkIso R x).inv_hom_id
 #align algebraic_geometry.structure_sheaf.localization_to_stalk_stalk_to_fiber_ring_hom AlgebraicGeometry.StructureSheaf.localizationToStalk_stalkToFiberRingHom
@@ -645,7 +670,7 @@ theorem toBasicOpen_injective (f : R) : Function.Injective (toBasicOpen R f) :=
   intro s t h_eq
   obtain ⟨a, ⟨b, hb⟩, rfl⟩ := IsLocalization.mk'_surjective (Submonoid.powers f) s
   obtain ⟨c, ⟨d, hd⟩, rfl⟩ := IsLocalization.mk'_surjective (Submonoid.powers f) t
-  simp only [to_basic_open_mk'] at h_eq
+  simp only [to_basic_open_mk'] at h_eq 
   rw [IsLocalization.eq]
   -- We know that the fractions `a/b` and `c/d` are equal as sections of the structure sheaf on
   -- `basic_open f`. We need to show that they agree as elements in the localization of `R` at `f`.
@@ -654,8 +679,8 @@ theorem toBasicOpen_injective (f : R) : Function.Injective (toBasicOpen R f) :=
   let I : Ideal R :=
     { carrier := { r : R | r * (d * a) = r * (b * c) }
       zero_mem' := by simp only [Set.mem_setOf_eq, MulZeroClass.zero_mul]
-      add_mem' := fun r₁ r₂ hr₁ hr₂ => by dsimp at hr₁ hr₂⊢; simp only [add_mul, hr₁, hr₂]
-      smul_mem' := fun r₁ r₂ hr₂ => by dsimp at hr₂⊢; simp only [mul_assoc, hr₂] }
+      add_mem' := fun r₁ r₂ hr₁ hr₂ => by dsimp at hr₁ hr₂ ⊢; simp only [add_mul, hr₁, hr₂]
+      smul_mem' := fun r₁ r₂ hr₂ => by dsimp at hr₂ ⊢; simp only [mul_assoc, hr₂] }
   -- Our claim now reduces to showing that `f` is contained in the radical of `I`
   suffices f ∈ I.radical by
     cases' this with n hn
@@ -665,7 +690,7 @@ theorem toBasicOpen_injective (f : R) : Function.Injective (toBasicOpen R f) :=
   contrapose hfp
   rw [mem_zero_locus, Set.not_subset]
   have := congr_fun (congr_arg Subtype.val h_eq) ⟨p, hfp⟩
-  rw [const_apply, const_apply, IsLocalization.eq] at this
+  rw [const_apply, const_apply, IsLocalization.eq] at this 
   cases' this with r hr
   exact ⟨r.1, hr, r.2⟩
 #align algebraic_geometry.structure_sheaf.to_basic_open_injective AlgebraicGeometry.StructureSheaf.toBasicOpen_injective
@@ -674,9 +699,9 @@ theorem toBasicOpen_injective (f : R) : Function.Injective (toBasicOpen R f) :=
 Auxiliary lemma for surjectivity of `to_basic_open`.
 Every section can locally be represented on basic opens `basic_opens g` as a fraction `f/g`
 -/
-theorem locally_const_basicOpen (U : Opens (PrimeSpectrum.top R))
+theorem locally_const_basicOpen (U : Opens (PrimeSpectrum.Top R))
     (s : (structureSheaf R).1.obj (op U)) (x : U) :
-    ∃ (f g : R)(i : basicOpen g ⟶ U),
+    ∃ (f g : R) (i : basicOpen g ⟶ U),
       x.1 ∈ basicOpen g ∧
         (const R f g (basicOpen g) fun y hy => hy) = (structureSheaf R).1.map i.op s :=
   by
@@ -693,7 +718,7 @@ theorem locally_const_basicOpen (U : Opens (PrimeSpectrum.top R))
   -- This is because we will need the equality `basic_open (h ^ n) = basic_open h`, which only
   -- holds for a nonzero power `n`. We therefore artificially increase `n` by one.
   replace hn := Ideal.mul_mem_left (Ideal.span {g}) h hn
-  rw [← pow_succ, Ideal.mem_span_singleton'] at hn
+  rw [← pow_succ, Ideal.mem_span_singleton'] at hn 
   cases' hn with c hc
   have basic_opens_eq := basic_open_pow h (n + 1) (by linarith)
   have i_basic_open := eq_to_hom basic_opens_eq ≫ hom_of_le hDhV
@@ -704,7 +729,7 @@ theorem locally_const_basicOpen (U : Opens (PrimeSpectrum.top R))
   -- of `res_const`. We prove this goal first
   swap
   · intro y hy
-    rw [basic_opens_eq] at hy
+    rw [basic_opens_eq] at hy 
     exact (Set.Subset.trans hDhV hVDg : _) hy
   -- All that is left is a simple calculation
   apply const_ext
@@ -718,14 +743,14 @@ Auxiliary lemma for surjectivity of `to_basic_open`.
 A local representation of a section `s` as fractions `a i / h i` on finitely many basic opens
 `basic_open (h i)` can be "normalized" in such a way that `a i * h j = h i * a j` for all `i, j`
 -/
-theorem normalize_finite_fraction_representation (U : Opens (PrimeSpectrum.top R))
+theorem normalize_finite_fraction_representation (U : Opens (PrimeSpectrum.Top R))
     (s : (structureSheaf R).1.obj (op U)) {ι : Type _} (t : Finset ι) (a h : ι → R)
     (iDh : ∀ i : ι, basicOpen (h i) ⟶ U) (h_cover : U ≤ ⨆ i ∈ t, basicOpen (h i))
     (hs :
       ∀ i : ι,
         (const R (a i) (h i) (basicOpen (h i)) fun y hy => hy) =
           (structureSheaf R).1.map (iDh i).op s) :
-    ∃ (a' h' : ι → R)(iDh' : ∀ i : ι, basicOpen (h' i) ⟶ U),
+    ∃ (a' h' : ι → R) (iDh' : ∀ i : ι, basicOpen (h' i) ⟶ U),
       (U ≤ ⨆ i ∈ t, basicOpen (h' i)) ∧
         (∀ (i) (_ : i ∈ t) (j) (_ : j ∈ t), a' i * h' j = h' i * a' j) ∧
           ∀ i ∈ t,
@@ -754,7 +779,7 @@ theorem normalize_finite_fraction_representation (U : Opens (PrimeSpectrum.top R
     all_goals rw [res_const]; apply const_ext; ring
     -- The remaining two goals were generated during the rewrite of `res_const`
     -- These can be solved immediately
-    exacts[basic_open_mul_le_right _ _, basic_open_mul_le_left _ _]
+    exacts [basic_open_mul_le_right _ _, basic_open_mul_le_left _ _]
   -- From the equality in the localization, we obtain for each `(i,j)` some power `(h i * h j) ^ n`
   -- which equalizes `a i * h j` and `h i * a j`
   have exists_power :
@@ -764,7 +789,7 @@ theorem normalize_finite_fraction_representation (U : Opens (PrimeSpectrum.top R
     obtain ⟨⟨c, n, rfl⟩, hc⟩ := is_localization.eq.mp (fractions_eq i j)
     use n + 1
     rw [pow_succ]
-    dsimp at hc
+    dsimp at hc 
     convert hc using 1 <;> ring
   let n := fun p : ι × ι => (exists_power p.1 p.2).some
   have n_spec := fun p : ι × ι => (exists_power p.fst p.snd).choose_spec
@@ -823,28 +848,28 @@ theorem toBasicOpen_surjective (f : R) : Function.Surjective (toBasicOpen R f) :
   · -- Here, we need to show that our basic opens actually form a cover of `basic_open f`
     rw [Set.mem_iUnion]
     exact ⟨⟨x, hx⟩, hxDh' ⟨x, hx⟩⟩
-  simp only [← opens.coe_supr, SetLike.coe_subset_coe] at ht_cover'
+  simp only [← opens.coe_supr, SetLike.coe_subset_coe] at ht_cover' 
   -- We use the normalization lemma from above to obtain the relation `a i * h j = h i * a j`
   obtain ⟨a, h, iDh, ht_cover, ah_ha, s_eq⟩ :=
     normalize_finite_fraction_representation R (basic_open f) s t a' h' iDh' ht_cover' s_eq'
   clear s_eq' iDh' hxDh' ht_cover' a' h'
-  simp only [← SetLike.coe_subset_coe, opens.coe_supr] at ht_cover
+  simp only [← SetLike.coe_subset_coe, opens.coe_supr] at ht_cover 
   -- Next we show that some power of `f` is a linear combination of the `h i`
   obtain ⟨n, hn⟩ : f ∈ (Ideal.span (h '' ↑t)).radical :=
     by
     rw [← vanishing_ideal_zero_locus_eq_radical, zero_locus_span]
-    simp only [basic_open_eq_zero_locus_compl] at ht_cover
-    rw [Set.compl_subset_comm] at ht_cover
+    simp only [basic_open_eq_zero_locus_compl] at ht_cover 
+    rw [Set.compl_subset_comm] at ht_cover 
     -- Why doesn't `simp_rw` do this?
     simp_rw [Set.compl_iUnion, compl_compl, ← zero_locus_Union, ← Finset.set_biUnion_coe, ←
-      Set.image_eq_iUnion] at ht_cover
+      Set.image_eq_iUnion] at ht_cover 
     apply vanishing_ideal_anti_mono ht_cover
     exact subset_vanishing_ideal_zero_locus {f} (Set.mem_singleton f)
   replace hn := Ideal.mul_mem_left _ f hn
-  erw [← pow_succ, Finsupp.mem_span_image_iff_total] at hn
+  erw [← pow_succ, Finsupp.mem_span_image_iff_total] at hn 
   rcases hn with ⟨b, b_supp, hb⟩
-  rw [Finsupp.total_apply_of_mem_supported R b_supp] at hb
-  dsimp at hb
+  rw [Finsupp.total_apply_of_mem_supported R b_supp] at hb 
+  dsimp at hb 
   -- Finally, we have all the ingredients.
   -- We claim that our preimage is given by `(∑ (i : ι) in t, b i * a i) / f ^ (n+1)`
   use
@@ -864,7 +889,7 @@ theorem toBasicOpen_surjective (f : R) : Function.Surjective (toBasicOpen R f) :
     intro x hx
     erw [TopologicalSpace.Opens.mem_iSup]
     have := ht_cover hx
-    rw [← Finset.set_biUnion_coe, Set.mem_iUnion₂] at this
+    rw [← Finset.set_biUnion_coe, Set.mem_iUnion₂] at this 
     rcases this with ⟨i, i_mem, x_mem⟩
     use i, i_mem
   rintro ⟨i, hi⟩
@@ -886,11 +911,13 @@ theorem toBasicOpen_surjective (f : R) : Function.Surjective (toBasicOpen R f) :
   ring
 #align algebraic_geometry.structure_sheaf.to_basic_open_surjective AlgebraicGeometry.StructureSheaf.toBasicOpen_surjective
 
+#print AlgebraicGeometry.StructureSheaf.isIso_toBasicOpen /-
 instance isIso_toBasicOpen (f : R) : IsIso (show CommRingCat.of _ ⟶ _ from toBasicOpen R f) :=
   haveI : is_iso ((forget CommRingCat).map (show CommRingCat.of _ ⟶ _ from to_basic_open R f)) :=
     (is_iso_iff_bijective _).mpr ⟨to_basic_open_injective R f, to_basic_open_surjective R f⟩
   is_iso_of_reflects_iso _ (forget CommRingCat)
 #align algebraic_geometry.structure_sheaf.is_iso_to_basic_open AlgebraicGeometry.StructureSheaf.isIso_toBasicOpen
+-/
 
 /-- The ring isomorphism between the structure sheaf on `basic_open f` and the localization of `R`
 at the submonoid of powers of `f`. -/
@@ -899,9 +926,11 @@ def basicOpenIso (f : R) :
   (asIso (show CommRingCat.of _ ⟶ _ from toBasicOpen R f)).symm
 #align algebraic_geometry.structure_sheaf.basic_open_iso AlgebraicGeometry.StructureSheaf.basicOpenIso
 
+#print AlgebraicGeometry.StructureSheaf.stalkAlgebra /-
 instance stalkAlgebra (p : PrimeSpectrum R) : Algebra R ((structureSheaf R).Presheaf.stalk p) :=
   (toStalk R p).toAlgebra
 #align algebraic_geometry.structure_sheaf.stalk_algebra AlgebraicGeometry.StructureSheaf.stalkAlgebra
+-/
 
 @[simp]
 theorem stalkAlgebra_map (p : PrimeSpectrum R) (r : R) :
@@ -909,6 +938,7 @@ theorem stalkAlgebra_map (p : PrimeSpectrum R) (r : R) :
   rfl
 #align algebraic_geometry.structure_sheaf.stalk_algebra_map AlgebraicGeometry.StructureSheaf.stalkAlgebra_map
 
+#print AlgebraicGeometry.StructureSheaf.IsLocalization.to_stalk /-
 /-- Stalk of the structure sheaf at a prime p as localization of R -/
 instance IsLocalization.to_stalk (p : PrimeSpectrum R) :
     IsLocalization.AtPrime ((structureSheaf R).Presheaf.stalk p) p.asIdeal :=
@@ -923,6 +953,7 @@ instance IsLocalization.to_stalk (p : PrimeSpectrum R) :
   erw [iso.eq_comp_inv]
   exact to_stalk_comp_stalk_to_fiber_ring_hom R p
 #align algebraic_geometry.structure_sheaf.is_localization.to_stalk AlgebraicGeometry.StructureSheaf.IsLocalization.to_stalk
+-/
 
 instance openAlgebra (U : (Opens (PrimeSpectrum R))ᵒᵖ) : Algebra R ((structureSheaf R).val.obj U) :=
   (toOpen R (unop U)).toAlgebra
@@ -985,12 +1016,16 @@ theorem globalSectionsIso_hom (R : CommRingCat) : (globalSectionsIso R).hom = to
   rfl
 #align algebraic_geometry.structure_sheaf.global_sections_iso_hom AlgebraicGeometry.StructureSheaf.globalSectionsIso_hom
 
+#print AlgebraicGeometry.StructureSheaf.toStalk_stalkSpecializes /-
 @[simp, reassoc, elementwise]
 theorem toStalk_stalkSpecializes {R : Type _} [CommRing R] {x y : PrimeSpectrum R} (h : x ⤳ y) :
     toStalk R y ≫ (structureSheaf R).Presheaf.stalkSpecializes h = toStalk R x := by
   dsimp [to_stalk]; simpa [-to_open_germ]
 #align algebraic_geometry.structure_sheaf.to_stalk_stalk_specializes AlgebraicGeometry.StructureSheaf.toStalk_stalkSpecializes
+-/
 
+/- warning: algebraic_geometry.structure_sheaf.localization_to_stalk_stalk_specializes clashes with algebraic_geometry.structure_sheaf.localizationToStalk_stalk_specializes -> AlgebraicGeometry.StructureSheaf.localizationToStalk_stalkSpecializes
+Case conversion may be inaccurate. Consider using '#align algebraic_geometry.structure_sheaf.localization_to_stalk_stalk_specializes AlgebraicGeometry.StructureSheaf.localizationToStalk_stalkSpecializesₓ'. -/
 @[simp, reassoc, elementwise]
 theorem localizationToStalk_stalkSpecializes {R : Type _} [CommRing R] {x y : PrimeSpectrum R}
     (h : x ⤳ y) :
@@ -1033,15 +1068,15 @@ At the moment, we work with arbitrary dependent functions `s : Π x : U, localiz
 we prove the predicate `is_locally_fraction` is preserved by this map, hence it can be extended to
 a morphism between the structure sheaves of `R` and `S`.
 -/
-def comapFun (f : R →+* S) (U : Opens (PrimeSpectrum.top R)) (V : Opens (PrimeSpectrum.top S))
+def comapFun (f : R →+* S) (U : Opens (PrimeSpectrum.Top R)) (V : Opens (PrimeSpectrum.Top S))
     (hUV : V.1 ⊆ PrimeSpectrum.comap f ⁻¹' U.1) (s : ∀ x : U, Localizations R x) (y : V) :
     Localizations S y :=
   Localization.localRingHom (PrimeSpectrum.comap f y.1).asIdeal _ f rfl
     (s ⟨PrimeSpectrum.comap f y.1, hUV y.2⟩ : _)
 #align algebraic_geometry.structure_sheaf.comap_fun AlgebraicGeometry.StructureSheaf.comapFun
 
-theorem comapFun_isLocallyFraction (f : R →+* S) (U : Opens (PrimeSpectrum.top R))
-    (V : Opens (PrimeSpectrum.top S)) (hUV : V.1 ⊆ PrimeSpectrum.comap f ⁻¹' U.1)
+theorem comapFunIsLocallyFraction (f : R →+* S) (U : Opens (PrimeSpectrum.Top R))
+    (V : Opens (PrimeSpectrum.Top S)) (hUV : V.1 ⊆ PrimeSpectrum.comap f ⁻¹' U.1)
     (s : ∀ x : U, Localizations R x) (hs : (isLocallyFraction R).toPrelocalPredicate.pred s) :
     (isLocallyFraction S).toPrelocalPredicate.pred (comapFun f U V hUV s) :=
   by
@@ -1059,7 +1094,7 @@ theorem comapFun_isLocallyFraction (f : R →+* S) (U : Opens (PrimeSpectrum.top
   erw [← Localization.localRingHom_to_map (PrimeSpectrum.comap f q).asIdeal, ← RingHom.map_mul,
     h_frac.2, Localization.localRingHom_to_map]
   rfl
-#align algebraic_geometry.structure_sheaf.comap_fun_is_locally_fraction AlgebraicGeometry.StructureSheaf.comapFun_isLocallyFraction
+#align algebraic_geometry.structure_sheaf.comap_fun_is_locally_fraction AlgebraicGeometry.StructureSheaf.comapFunIsLocallyFraction
 
 /-- For a ring homomorphism `f : R →+* S` and open sets `U` and `V` of the prime spectra of `R` and
 `S` such that `V ⊆ (comap f) ⁻¹ U`, the induced ring homomorphism from the structure sheaf of `R`
@@ -1068,11 +1103,11 @@ at `U` to the structure sheaf of `S` at `V`.
 Explicitly, this map is given as follows: For a point `p : V`, if the section `s` evaluates on `p`
 to the fraction `a / b`, its image on `V` evaluates on `p` to the fraction `f(a) / f(b)`.
 -/
-def comap (f : R →+* S) (U : Opens (PrimeSpectrum.top R)) (V : Opens (PrimeSpectrum.top S))
+def comap (f : R →+* S) (U : Opens (PrimeSpectrum.Top R)) (V : Opens (PrimeSpectrum.Top S))
     (hUV : V.1 ⊆ PrimeSpectrum.comap f ⁻¹' U.1) :
     (structureSheaf R).1.obj (op U) →+* (structureSheaf S).1.obj (op V)
     where
-  toFun s := ⟨comapFun f U V hUV s.1, comapFun_isLocallyFraction f U V hUV s.1 s.2⟩
+  toFun s := ⟨comapFun f U V hUV s.1, comapFunIsLocallyFraction f U V hUV s.1 s.2⟩
   map_one' :=
     Subtype.ext <|
       funext fun p =>
@@ -1104,8 +1139,8 @@ def comap (f : R →+* S) (U : Opens (PrimeSpectrum.top R)) (V : Opens (PrimeSpe
 #align algebraic_geometry.structure_sheaf.comap AlgebraicGeometry.StructureSheaf.comap
 
 @[simp]
-theorem comap_apply (f : R →+* S) (U : Opens (PrimeSpectrum.top R))
-    (V : Opens (PrimeSpectrum.top S)) (hUV : V.1 ⊆ PrimeSpectrum.comap f ⁻¹' U.1)
+theorem comap_apply (f : R →+* S) (U : Opens (PrimeSpectrum.Top R))
+    (V : Opens (PrimeSpectrum.Top S)) (hUV : V.1 ⊆ PrimeSpectrum.comap f ⁻¹' U.1)
     (s : (structureSheaf R).1.obj (op U)) (p : V) :
     (comap f U V hUV s).1 p =
       Localization.localRingHom (PrimeSpectrum.comap f p.1).asIdeal _ f rfl
@@ -1113,8 +1148,8 @@ theorem comap_apply (f : R →+* S) (U : Opens (PrimeSpectrum.top R))
   rfl
 #align algebraic_geometry.structure_sheaf.comap_apply AlgebraicGeometry.StructureSheaf.comap_apply
 
-theorem comap_const (f : R →+* S) (U : Opens (PrimeSpectrum.top R))
-    (V : Opens (PrimeSpectrum.top S)) (hUV : V.1 ⊆ PrimeSpectrum.comap f ⁻¹' U.1) (a b : R)
+theorem comap_const (f : R →+* S) (U : Opens (PrimeSpectrum.Top R))
+    (V : Opens (PrimeSpectrum.Top S)) (hUV : V.1 ⊆ PrimeSpectrum.comap f ⁻¹' U.1) (a b : R)
     (hb : ∀ x : PrimeSpectrum R, x ∈ U → b ∈ x.asIdeal.primeCompl) :
     comap f U V hUV (const R a b U hb) =
       const S (f a) (f b) V fun p hpV => hb (PrimeSpectrum.comap f p) (hUV hpV) :=
@@ -1131,7 +1166,7 @@ identity from OO_X(U) to OO_X(V) equals as the restriction map of the structure
 This is a generalization of the fact that, for fixed `U`, the comap of the identity from OO_X(U)
 to OO_X(U) is the identity.
 -/
-theorem comap_id_eq_map (U V : Opens (PrimeSpectrum.top R)) (iVU : V ⟶ U) :
+theorem comap_id_eq_map (U V : Opens (PrimeSpectrum.Top R)) (iVU : V ⟶ U) :
     (comap (RingHom.id R) U V fun p hpV => leOfHom iVU <| by rwa [PrimeSpectrum.comap_id]) =
       (structureSheaf R).1.map iVU.op :=
   RingHom.ext fun s =>
@@ -1148,7 +1183,7 @@ theorem comap_id_eq_map (U V : Opens (PrimeSpectrum.top R)) (iVU : V ⟶ U) :
         obtain ⟨hb₁, s_eq₁⟩ := h' ⟨p, hpW⟩
         obtain ⟨hb₂, s_eq₂⟩ :=
           h' ⟨PrimeSpectrum.comap (RingHom.id _) p.1, by rwa [PrimeSpectrum.comap_id]⟩
-        dsimp only at s_eq₁ s_eq₂
+        dsimp only at s_eq₁ s_eq₂ 
         erw [s_eq₂, Localization.localRingHom_mk', ← s_eq₁, ← res_apply]
 #align algebraic_geometry.structure_sheaf.comap_id_eq_map AlgebraicGeometry.StructureSheaf.comap_id_eq_map
 
@@ -1157,20 +1192,20 @@ The comap of the identity is the identity. In this variant of the lemma, two ope
 `V` are given as arguments, together with a proof that `U = V`. This is be useful when `U` and `V`
 are not definitionally equal.
 -/
-theorem comap_id (U V : Opens (PrimeSpectrum.top R)) (hUV : U = V) :
+theorem comap_id (U V : Opens (PrimeSpectrum.Top R)) (hUV : U = V) :
     (comap (RingHom.id R) U V fun p hpV => by rwa [hUV, PrimeSpectrum.comap_id]) =
       eqToHom (show (structureSheaf R).1.obj (op U) = _ by rw [hUV]) :=
   by erw [comap_id_eq_map U V (eq_to_hom hUV.symm), eq_to_hom_op, eq_to_hom_map]
 #align algebraic_geometry.structure_sheaf.comap_id AlgebraicGeometry.StructureSheaf.comap_id
 
 @[simp]
-theorem comap_id' (U : Opens (PrimeSpectrum.top R)) :
+theorem comap_id' (U : Opens (PrimeSpectrum.Top R)) :
     (comap (RingHom.id R) U U fun p hpU => by rwa [PrimeSpectrum.comap_id]) = RingHom.id _ := by
   rw [comap_id U U rfl]; rfl
 #align algebraic_geometry.structure_sheaf.comap_id' AlgebraicGeometry.StructureSheaf.comap_id'
 
-theorem comap_comp (f : R →+* S) (g : S →+* P) (U : Opens (PrimeSpectrum.top R))
-    (V : Opens (PrimeSpectrum.top S)) (W : Opens (PrimeSpectrum.top P))
+theorem comap_comp (f : R →+* S) (g : S →+* P) (U : Opens (PrimeSpectrum.Top R))
+    (V : Opens (PrimeSpectrum.Top S)) (W : Opens (PrimeSpectrum.Top P))
     (hUV : ∀ p ∈ V, PrimeSpectrum.comap f p ∈ U) (hVW : ∀ p ∈ W, PrimeSpectrum.comap g p ∈ V) :
     (comap (g.comp f) U W fun p hpW => hUV (PrimeSpectrum.comap g p) (hVW p hpW)) =
       (comap g V W hVW).comp (comap f U V hUV) :=
@@ -1185,7 +1220,7 @@ theorem comap_comp (f : R →+* S) (g : S →+* P) (U : Opens (PrimeSpectrum.top
 #align algebraic_geometry.structure_sheaf.comap_comp AlgebraicGeometry.StructureSheaf.comap_comp
 
 @[elementwise, reassoc]
-theorem toOpen_comp_comap (f : R →+* S) (U : Opens (PrimeSpectrum.top R)) :
+theorem toOpen_comp_comap (f : R →+* S) (U : Opens (PrimeSpectrum.Top R)) :
     (toOpen R U ≫ comap f U (Opens.comap (PrimeSpectrum.comap f) U) fun _ => id) =
       CommRingCat.ofHom f ≫ toOpen S _ :=
   RingHom.ext fun s =>
Diff
@@ -746,7 +746,7 @@ theorem normalize_finite_fraction_representation (U : Opens (PrimeSpectrum.top R
     -- Crucially, we need injectivity of `to_basic_open`
     apply to_basic_open_injective R (h i * h j)
     rw [to_basic_open_mk', to_basic_open_mk']
-    simp only [[anonymous]]
+    simp only [SetLike.coe_mk]
     -- Here, both sides of the equation are equal to a restriction of `s`
     trans
     convert congr_arg ((structure_sheaf R).1.map iDj.op) (hs j).symm using 1
@@ -1040,7 +1040,7 @@ def comapFun (f : R →+* S) (U : Opens (PrimeSpectrum.top R)) (V : Opens (Prime
     (s ⟨PrimeSpectrum.comap f y.1, hUV y.2⟩ : _)
 #align algebraic_geometry.structure_sheaf.comap_fun AlgebraicGeometry.StructureSheaf.comapFun
 
-theorem comapFunIsLocallyFraction (f : R →+* S) (U : Opens (PrimeSpectrum.top R))
+theorem comapFun_isLocallyFraction (f : R →+* S) (U : Opens (PrimeSpectrum.top R))
     (V : Opens (PrimeSpectrum.top S)) (hUV : V.1 ⊆ PrimeSpectrum.comap f ⁻¹' U.1)
     (s : ∀ x : U, Localizations R x) (hs : (isLocallyFraction R).toPrelocalPredicate.pred s) :
     (isLocallyFraction S).toPrelocalPredicate.pred (comapFun f U V hUV s) :=
@@ -1059,7 +1059,7 @@ theorem comapFunIsLocallyFraction (f : R →+* S) (U : Opens (PrimeSpectrum.top
   erw [← Localization.localRingHom_to_map (PrimeSpectrum.comap f q).asIdeal, ← RingHom.map_mul,
     h_frac.2, Localization.localRingHom_to_map]
   rfl
-#align algebraic_geometry.structure_sheaf.comap_fun_is_locally_fraction AlgebraicGeometry.StructureSheaf.comapFunIsLocallyFraction
+#align algebraic_geometry.structure_sheaf.comap_fun_is_locally_fraction AlgebraicGeometry.StructureSheaf.comapFun_isLocallyFraction
 
 /-- For a ring homomorphism `f : R →+* S` and open sets `U` and `V` of the prime spectra of `R` and
 `S` such that `V ⊆ (comap f) ⁻¹ U`, the induced ring homomorphism from the structure sheaf of `R`
@@ -1072,7 +1072,7 @@ def comap (f : R →+* S) (U : Opens (PrimeSpectrum.top R)) (V : Opens (PrimeSpe
     (hUV : V.1 ⊆ PrimeSpectrum.comap f ⁻¹' U.1) :
     (structureSheaf R).1.obj (op U) →+* (structureSheaf S).1.obj (op V)
     where
-  toFun s := ⟨comapFun f U V hUV s.1, comapFunIsLocallyFraction f U V hUV s.1 s.2⟩
+  toFun s := ⟨comapFun f U V hUV s.1, comapFun_isLocallyFraction f U V hUV s.1 s.2⟩
   map_one' :=
     Subtype.ext <|
       funext fun p =>
Diff
@@ -800,9 +800,9 @@ theorem normalize_finite_fraction_representation (U : Opens (PrimeSpectrum.top R
   ring
 #align algebraic_geometry.structure_sheaf.normalize_finite_fraction_representation AlgebraicGeometry.StructureSheaf.normalize_finite_fraction_representation
 
-open Classical
+open scoped Classical
 
-open BigOperators
+open scoped BigOperators
 
 -- The proof here follows the argument in Hartshorne's Algebraic Geometry, Proposition II.2.2.
 theorem toBasicOpen_surjective (f : R) : Function.Surjective (toBasicOpen R f) :=
Diff
@@ -121,9 +121,7 @@ in the sense that if it holds on `U` it holds on any open subset `V` of `U`.
 def isFractionPrelocal : PrelocalPredicate (Localizations R)
     where
   pred U f := IsFraction f
-  res := by
-    rintro V U i f ⟨r, s, w⟩
-    exact ⟨r, s, fun x => w (i x)⟩
+  res := by rintro V U i f ⟨r, s, w⟩; exact ⟨r, s, fun x => w (i x)⟩
 #align algebraic_geometry.structure_sheaf.is_fraction_prelocal AlgebraicGeometry.StructureSheaf.isFractionPrelocal
 
 /-- We will define the structure sheaf as
@@ -166,13 +164,11 @@ def sectionsSubring (U : (Opens (PrimeSpectrum.top R))ᵒᵖ) :
   carrier := { f | (isLocallyFraction R).pred f }
   zero_mem' := by
     refine' fun x => ⟨unop U, x.2, 𝟙 _, 0, 1, fun y => ⟨_, _⟩⟩
-    · rw [← Ideal.ne_top_iff_one]
-      exact y.1.IsPrime.1
+    · rw [← Ideal.ne_top_iff_one]; exact y.1.IsPrime.1
     · simp
   one_mem' := by
     refine' fun x => ⟨unop U, x.2, 𝟙 _, 1, 1, fun y => ⟨_, _⟩⟩
-    · rw [← Ideal.ne_top_iff_one]
-      exact y.1.IsPrime.1
+    · rw [← Ideal.ne_top_iff_one]; exact y.1.IsPrime.1
     · simp
   add_mem' := by
     intro a b ha hb x
@@ -183,14 +179,12 @@ def sectionsSubring (U : (Opens (PrimeSpectrum.top R))ᵒᵖ) :
     rcases wa (opens.inf_le_left _ _ y) with ⟨nma, wa⟩
     rcases wb (opens.inf_le_right _ _ y) with ⟨nmb, wb⟩
     fconstructor
-    · intro H
-      cases y.1.IsPrime.mem_or_mem H <;> contradiction
+    · intro H; cases y.1.IsPrime.mem_or_mem H <;> contradiction
     · simp only [add_mul, RingHom.map_add, Pi.add_apply, RingHom.map_mul]
       erw [← wa, ← wb]
       simp only [mul_assoc]
       congr 2
-      rw [mul_comm]
-      rfl
+      rw [mul_comm]; rfl
   neg_mem' := by
     intro a ha x
     rcases ha x with ⟨V, m, i, r, s, w⟩
@@ -211,8 +205,7 @@ def sectionsSubring (U : (Opens (PrimeSpectrum.top R))ᵒᵖ) :
     rcases wa (opens.inf_le_left _ _ y) with ⟨nma, wa⟩
     rcases wb (opens.inf_le_right _ _ y) with ⟨nmb, wb⟩
     fconstructor
-    · intro H
-      cases y.1.IsPrime.mem_or_mem H <;> contradiction
+    · intro H; cases y.1.IsPrime.mem_or_mem H <;> contradiction
     · simp only [Pi.mul_apply, RingHom.map_mul]
       erw [← wa, ← wb]
       simp only [mul_left_comm, mul_assoc, mul_comm]
@@ -402,9 +395,7 @@ theorem const_mul_rev (f g : R) (U hu₁ hu₂) : const R f g U hu₁ * const R
 #align algebraic_geometry.structure_sheaf.const_mul_rev AlgebraicGeometry.StructureSheaf.const_mul_rev
 
 theorem const_mul_cancel (f g₁ g₂ : R) (U hu₁ hu₂) :
-    const R f g₁ U hu₁ * const R g₁ g₂ U hu₂ = const R f g₂ U hu₂ :=
-  by
-  rw [const_mul, const_ext]
+    const R f g₁ U hu₁ * const R g₁ g₂ U hu₂ = const R f g₂ U hu₂ := by rw [const_mul, const_ext];
   rw [mul_assoc]
 #align algebraic_geometry.structure_sheaf.const_mul_cancel AlgebraicGeometry.StructureSheaf.const_mul_cancel
 
@@ -420,10 +411,7 @@ def toOpen (U : Opens (PrimeSpectrum.top R)) : CommRingCat.of R ⟶ (structureSh
   toFun f :=
     ⟨fun x => algebraMap R _ f, fun x =>
       ⟨U, x.2, 𝟙 _, f, 1, fun y =>
-        ⟨(Ideal.ne_top_iff_one _).1 y.1.2.1,
-          by
-          rw [RingHom.map_one, mul_one]
-          rfl⟩⟩⟩
+        ⟨(Ideal.ne_top_iff_one _).1 y.1.2.1, by rw [RingHom.map_one, mul_one]; rfl⟩⟩⟩
   map_one' := Subtype.eq <| funext fun x => RingHom.map_one _
   map_mul' f g := Subtype.eq <| funext fun x => RingHom.map_mul _ _ _
   map_zero' := Subtype.eq <| funext fun x => RingHom.map_zero _
@@ -455,18 +443,13 @@ def toStalk (x : PrimeSpectrum.top R) : CommRingCat.of R ⟶ (structureSheaf R).
 
 @[simp]
 theorem toOpen_germ (U : Opens (PrimeSpectrum.top R)) (x : U) :
-    toOpen R U ≫ (structureSheaf R).Presheaf.germ x = toStalk R x :=
-  by
-  rw [← to_open_res R ⊤ U (hom_of_le le_top : U ⟶ ⊤), category.assoc, presheaf.germ_res]
-  rfl
+    toOpen R U ≫ (structureSheaf R).Presheaf.germ x = toStalk R x := by
+  rw [← to_open_res R ⊤ U (hom_of_le le_top : U ⟶ ⊤), category.assoc, presheaf.germ_res]; rfl
 #align algebraic_geometry.structure_sheaf.to_open_germ AlgebraicGeometry.StructureSheaf.toOpen_germ
 
 @[simp]
 theorem germ_toOpen (U : Opens (PrimeSpectrum.top R)) (x : U) (f : R) :
-    (structureSheaf R).Presheaf.germ x (toOpen R U f) = toStalk R x f :=
-  by
-  rw [← to_open_germ]
-  rfl
+    (structureSheaf R).Presheaf.germ x (toOpen R U f) = toStalk R x f := by rw [← to_open_germ]; rfl
 #align algebraic_geometry.structure_sheaf.germ_to_open AlgebraicGeometry.StructureSheaf.germ_toOpen
 
 theorem germ_to_top (x : PrimeSpectrum.top R) (f : R) :
@@ -568,18 +551,14 @@ theorem stalkToFiberRingHom_germ' (U : Opens (PrimeSpectrum.top R)) (x : PrimeSp
 @[simp]
 theorem stalkToFiberRingHom_germ (U : Opens (PrimeSpectrum.top R)) (x : U)
     (s : (structureSheaf R).1.obj (op U)) :
-    stalkToFiberRingHom R x ((structureSheaf R).Presheaf.germ x s) = s.1 x :=
-  by
-  cases x
+    stalkToFiberRingHom R x ((structureSheaf R).Presheaf.germ x s) = s.1 x := by cases x;
   exact stalk_to_fiber_ring_hom_germ' R U _ _ _
 #align algebraic_geometry.structure_sheaf.stalk_to_fiber_ring_hom_germ AlgebraicGeometry.StructureSheaf.stalkToFiberRingHom_germ
 
 @[simp]
 theorem toStalk_comp_stalkToFiberRingHom (x : PrimeSpectrum.top R) :
-    toStalk R x ≫ stalkToFiberRingHom R x = (algebraMap _ _ : R →+* Localization _) :=
-  by
-  erw [to_stalk, category.assoc, germ_comp_stalk_to_fiber_ring_hom]
-  rfl
+    toStalk R x ≫ stalkToFiberRingHom R x = (algebraMap _ _ : R →+* Localization _) := by
+  erw [to_stalk, category.assoc, germ_comp_stalk_to_fiber_ring_hom]; rfl
 #align algebraic_geometry.structure_sheaf.to_stalk_comp_stalk_to_fiber_ring_hom AlgebraicGeometry.StructureSheaf.toStalk_comp_stalkToFiberRingHom
 
 @[simp]
@@ -609,8 +588,7 @@ def stalkIso (x : PrimeSpectrum.top R) :
         (Localization.AtPrime x.asIdeal) _ _
         (RingHom.comp (stalkToFiberRingHom R x) (localizationToStalk R x))
         (RingHom.id (Localization.AtPrime _)) <|
-      by
-      ext f
+      by ext f;
       simp only [RingHom.comp_apply, RingHom.id_apply, localization_to_stalk_of,
         stalk_to_fiber_ring_hom_to_stalk]
 #align algebraic_geometry.structure_sheaf.stalk_iso AlgebraicGeometry.StructureSheaf.stalkIso
@@ -676,12 +654,8 @@ theorem toBasicOpen_injective (f : R) : Function.Injective (toBasicOpen R f) :=
   let I : Ideal R :=
     { carrier := { r : R | r * (d * a) = r * (b * c) }
       zero_mem' := by simp only [Set.mem_setOf_eq, MulZeroClass.zero_mul]
-      add_mem' := fun r₁ r₂ hr₁ hr₂ => by
-        dsimp at hr₁ hr₂⊢
-        simp only [add_mul, hr₁, hr₂]
-      smul_mem' := fun r₁ r₂ hr₂ => by
-        dsimp at hr₂⊢
-        simp only [mul_assoc, hr₂] }
+      add_mem' := fun r₁ r₂ hr₁ hr₂ => by dsimp at hr₁ hr₂⊢; simp only [add_mul, hr₁, hr₂]
+      smul_mem' := fun r₁ r₂ hr₂ => by dsimp at hr₂⊢; simp only [mul_assoc, hr₂] }
   -- Our claim now reduces to showing that `f` is contained in the radical of `I`
   suffices f ∈ I.radical by
     cases' this with n hn
@@ -776,8 +750,7 @@ theorem normalize_finite_fraction_representation (U : Opens (PrimeSpectrum.top R
     -- Here, both sides of the equation are equal to a restriction of `s`
     trans
     convert congr_arg ((structure_sheaf R).1.map iDj.op) (hs j).symm using 1
-    convert congr_arg ((structure_sheaf R).1.map iDi.op) (hs i) using 1
-    swap
+    convert congr_arg ((structure_sheaf R).1.map iDi.op) (hs i) using 1; swap
     all_goals rw [res_const]; apply const_ext; ring
     -- The remaining two goals were generated during the rewrite of `res_const`
     -- These can be solved immediately
@@ -815,13 +788,12 @@ theorem normalize_finite_fraction_representation (U : Opens (PrimeSpectrum.top R
     -- To accommodate for the difference `k`, we multiply both sides of the equation `n_spec (i, j)`
       -- by `(h i * h j) ^ k`
       convert congr_arg (fun z => z * (h i * h j) ^ k) (n_spec (i, j)) using 1 <;>
-      · simp only [n, mul_pow]
-        ring
+      · simp only [n, mul_pow]; ring
   -- Lastly, we need to show that the new fractions still represent our original `s`
   intro i hi
   rw [op_comp, functor.map_comp, comp_apply, ← hs, res_const]
   -- additional goal spit out by `res_const`
-  swap
+  swap;
   exact (basic_opens_eq i).le
   apply const_ext
   rw [pow_succ]
@@ -978,9 +950,7 @@ instance IsLocalization.to_basicOpen (r : R) :
 instance to_basicOpen_epi (r : R) : Epi (toOpen R (basicOpen r)) :=
   ⟨fun S f g h => by
     refine' IsLocalization.ringHom_ext _ _
-    pick_goal 5
-    exact is_localization.to_basic_open R r
-    exact h⟩
+    pick_goal 5; exact is_localization.to_basic_open R r; exact h⟩
 #align algebraic_geometry.structure_sheaf.to_basic_open_epi AlgebraicGeometry.StructureSheaf.to_basicOpen_epi
 
 @[elementwise]
@@ -1017,10 +987,8 @@ theorem globalSectionsIso_hom (R : CommRingCat) : (globalSectionsIso R).hom = to
 
 @[simp, reassoc, elementwise]
 theorem toStalk_stalkSpecializes {R : Type _} [CommRing R] {x y : PrimeSpectrum R} (h : x ⤳ y) :
-    toStalk R y ≫ (structureSheaf R).Presheaf.stalkSpecializes h = toStalk R x :=
-  by
-  dsimp [to_stalk]
-  simpa [-to_open_germ]
+    toStalk R y ≫ (structureSheaf R).Presheaf.stalkSpecializes h = toStalk R x := by
+  dsimp [to_stalk]; simpa [-to_open_germ]
 #align algebraic_geometry.structure_sheaf.to_stalk_stalk_specializes AlgebraicGeometry.StructureSheaf.toStalk_stalkSpecializes
 
 @[simp, reassoc, elementwise]
@@ -1197,10 +1165,8 @@ theorem comap_id (U V : Opens (PrimeSpectrum.top R)) (hUV : U = V) :
 
 @[simp]
 theorem comap_id' (U : Opens (PrimeSpectrum.top R)) :
-    (comap (RingHom.id R) U U fun p hpU => by rwa [PrimeSpectrum.comap_id]) = RingHom.id _ :=
-  by
-  rw [comap_id U U rfl]
-  rfl
+    (comap (RingHom.id R) U U fun p hpU => by rwa [PrimeSpectrum.comap_id]) = RingHom.id _ := by
+  rw [comap_id U U rfl]; rfl
 #align algebraic_geometry.structure_sheaf.comap_id' AlgebraicGeometry.StructureSheaf.comap_id'
 
 theorem comap_comp (f : R →+* S) (g : S →+* P) (U : Opens (PrimeSpectrum.top R))
Diff
@@ -621,13 +621,13 @@ instance (x : PrimeSpectrum R) : IsIso (stalkToFiberRingHom R x) :=
 instance (x : PrimeSpectrum R) : IsIso (localizationToStalk R x) :=
   IsIso.of_iso (stalkIso R x).symm
 
-@[simp, reassoc.1]
+@[simp, reassoc]
 theorem stalkToFiberRingHom_localizationToStalk (x : PrimeSpectrum.top R) :
     stalkToFiberRingHom R x ≫ localizationToStalk R x = 𝟙 _ :=
   (stalkIso R x).hom_inv_id
 #align algebraic_geometry.structure_sheaf.stalk_to_fiber_ring_hom_localization_to_stalk AlgebraicGeometry.StructureSheaf.stalkToFiberRingHom_localizationToStalk
 
-@[simp, reassoc.1]
+@[simp, reassoc]
 theorem localizationToStalk_stalkToFiberRingHom (x : PrimeSpectrum.top R) :
     localizationToStalk R x ≫ stalkToFiberRingHom R x = 𝟙 _ :=
   (stalkIso R x).inv_hom_id
@@ -1015,7 +1015,7 @@ theorem globalSectionsIso_hom (R : CommRingCat) : (globalSectionsIso R).hom = to
   rfl
 #align algebraic_geometry.structure_sheaf.global_sections_iso_hom AlgebraicGeometry.StructureSheaf.globalSectionsIso_hom
 
-@[simp, reassoc.1, elementwise]
+@[simp, reassoc, elementwise]
 theorem toStalk_stalkSpecializes {R : Type _} [CommRing R] {x y : PrimeSpectrum R} (h : x ⤳ y) :
     toStalk R y ≫ (structureSheaf R).Presheaf.stalkSpecializes h = toStalk R x :=
   by
@@ -1023,7 +1023,7 @@ theorem toStalk_stalkSpecializes {R : Type _} [CommRing R] {x y : PrimeSpectrum
   simpa [-to_open_germ]
 #align algebraic_geometry.structure_sheaf.to_stalk_stalk_specializes AlgebraicGeometry.StructureSheaf.toStalk_stalkSpecializes
 
-@[simp, reassoc.1, elementwise]
+@[simp, reassoc, elementwise]
 theorem localizationToStalk_stalkSpecializes {R : Type _} [CommRing R] {x y : PrimeSpectrum R}
     (h : x ⤳ y) :
     StructureSheaf.localizationToStalk R y ≫ (structureSheaf R).Presheaf.stalkSpecializes h =
@@ -1039,7 +1039,7 @@ theorem localizationToStalk_stalkSpecializes {R : Type _} [CommRing R] {x y : Pr
   exact to_stalk_stalk_specializes h
 #align algebraic_geometry.structure_sheaf.localization_to_stalk_stalk_specializes AlgebraicGeometry.StructureSheaf.localizationToStalk_stalkSpecializes
 
-@[simp, reassoc.1, elementwise]
+@[simp, reassoc, elementwise]
 theorem stalkSpecializes_stalk_to_fiber {R : Type _} [CommRing R] {x y : PrimeSpectrum R}
     (h : x ⤳ y) :
     (structureSheaf R).Presheaf.stalkSpecializes h ≫ StructureSheaf.stalkToFiberRingHom R x =
@@ -1218,7 +1218,7 @@ theorem comap_comp (f : R →+* S) (g : S →+* P) (U : Opens (PrimeSpectrum.top
         rfl
 #align algebraic_geometry.structure_sheaf.comap_comp AlgebraicGeometry.StructureSheaf.comap_comp
 
-@[elementwise, reassoc.1]
+@[elementwise, reassoc]
 theorem toOpen_comp_comap (f : R →+* S) (U : Opens (PrimeSpectrum.top R)) :
     (toOpen R U ≫ comap f U (Opens.comap (PrimeSpectrum.comap f) U) fun _ => id) =
       CommRingCat.ofHom f ≫ toOpen S _ :=
Diff
@@ -849,7 +849,7 @@ theorem toBasicOpen_surjective (f : R) : Function.Surjective (toBasicOpen R f) :
       (fun i => is_open_basic_open) fun x hx => _
   swap
   · -- Here, we need to show that our basic opens actually form a cover of `basic_open f`
-    rw [Set.mem_unionᵢ]
+    rw [Set.mem_iUnion]
     exact ⟨⟨x, hx⟩, hxDh' ⟨x, hx⟩⟩
   simp only [← opens.coe_supr, SetLike.coe_subset_coe] at ht_cover'
   -- We use the normalization lemma from above to obtain the relation `a i * h j = h i * a j`
@@ -864,8 +864,8 @@ theorem toBasicOpen_surjective (f : R) : Function.Surjective (toBasicOpen R f) :
     simp only [basic_open_eq_zero_locus_compl] at ht_cover
     rw [Set.compl_subset_comm] at ht_cover
     -- Why doesn't `simp_rw` do this?
-    simp_rw [Set.compl_unionᵢ, compl_compl, ← zero_locus_Union, ← Finset.set_bunionᵢ_coe, ←
-      Set.image_eq_unionᵢ] at ht_cover
+    simp_rw [Set.compl_iUnion, compl_compl, ← zero_locus_Union, ← Finset.set_biUnion_coe, ←
+      Set.image_eq_iUnion] at ht_cover
     apply vanishing_ideal_anti_mono ht_cover
     exact subset_vanishing_ideal_zero_locus {f} (Set.mem_singleton f)
   replace hn := Ideal.mul_mem_left _ f hn
@@ -890,9 +890,9 @@ theorem toBasicOpen_surjective (f : R) : Function.Surjective (toBasicOpen R f) :
     -- Unfortunately, `ht_cover` uses a bounded union over the set `t`, while here we have the
     -- Union indexed by the type `tt`, so we need some boilerplate to translate one to the other
     intro x hx
-    erw [TopologicalSpace.Opens.mem_supᵢ]
+    erw [TopologicalSpace.Opens.mem_iSup]
     have := ht_cover hx
-    rw [← Finset.set_bunionᵢ_coe, Set.mem_unionᵢ₂] at this
+    rw [← Finset.set_biUnion_coe, Set.mem_iUnion₂] at this
     rcases this with ⟨i, i_mem, x_mem⟩
     use i, i_mem
   rintro ⟨i, hi⟩
Diff
@@ -942,7 +942,7 @@ instance IsLocalization.to_stalk (p : PrimeSpectrum R) :
     IsLocalization.AtPrime ((structureSheaf R).Presheaf.stalk p) p.asIdeal :=
   by
   convert(IsLocalization.isLocalization_iff_of_ringEquiv _
-          (stalk_iso R p).symm.commRingIsoToRingEquiv).mp
+          (stalk_iso R p).symm.commRingCatIsoToRingEquiv).mp
       Localization.isLocalization
   apply Algebra.algebra_ext
   intro
@@ -967,7 +967,7 @@ instance IsLocalization.to_basicOpen (r : R) :
     IsLocalization.Away r ((structureSheaf R).val.obj (op <| basicOpen r)) :=
   by
   convert(IsLocalization.isLocalization_iff_of_ringEquiv _
-          (basic_open_iso R r).symm.commRingIsoToRingEquiv).mp
+          (basic_open_iso R r).symm.commRingCatIsoToRingEquiv).mp
       Localization.isLocalization
   apply Algebra.algebra_ext
   intro x
@@ -999,7 +999,7 @@ instance isIso_to_global : IsIso (toOpen R ⊤) :=
   by
   let hom := CommRingCat.ofHom (algebraMap R (Localization.Away (1 : R)))
   haveI : is_iso hom :=
-    is_iso.of_iso (IsLocalization.atOne R (Localization.Away (1 : R))).toRingEquiv.toCommRingIso
+    is_iso.of_iso (IsLocalization.atOne R (Localization.Away (1 : R))).toRingEquiv.toCommRingCatIso
   rw [to_global_factors R]
   infer_instance
 #align algebraic_geometry.structure_sheaf.is_iso_to_global AlgebraicGeometry.StructureSheaf.isIso_to_global
Diff
@@ -1072,7 +1072,7 @@ def comapFun (f : R →+* S) (U : Opens (PrimeSpectrum.top R)) (V : Opens (Prime
     (s ⟨PrimeSpectrum.comap f y.1, hUV y.2⟩ : _)
 #align algebraic_geometry.structure_sheaf.comap_fun AlgebraicGeometry.StructureSheaf.comapFun
 
-theorem comapFun_isLocallyFraction (f : R →+* S) (U : Opens (PrimeSpectrum.top R))
+theorem comapFunIsLocallyFraction (f : R →+* S) (U : Opens (PrimeSpectrum.top R))
     (V : Opens (PrimeSpectrum.top S)) (hUV : V.1 ⊆ PrimeSpectrum.comap f ⁻¹' U.1)
     (s : ∀ x : U, Localizations R x) (hs : (isLocallyFraction R).toPrelocalPredicate.pred s) :
     (isLocallyFraction S).toPrelocalPredicate.pred (comapFun f U V hUV s) :=
@@ -1091,7 +1091,7 @@ theorem comapFun_isLocallyFraction (f : R →+* S) (U : Opens (PrimeSpectrum.top
   erw [← Localization.localRingHom_to_map (PrimeSpectrum.comap f q).asIdeal, ← RingHom.map_mul,
     h_frac.2, Localization.localRingHom_to_map]
   rfl
-#align algebraic_geometry.structure_sheaf.comap_fun_is_locally_fraction AlgebraicGeometry.StructureSheaf.comapFun_isLocallyFraction
+#align algebraic_geometry.structure_sheaf.comap_fun_is_locally_fraction AlgebraicGeometry.StructureSheaf.comapFunIsLocallyFraction
 
 /-- For a ring homomorphism `f : R →+* S` and open sets `U` and `V` of the prime spectra of `R` and
 `S` such that `V ⊆ (comap f) ⁻¹ U`, the induced ring homomorphism from the structure sheaf of `R`
@@ -1104,7 +1104,7 @@ def comap (f : R →+* S) (U : Opens (PrimeSpectrum.top R)) (V : Opens (PrimeSpe
     (hUV : V.1 ⊆ PrimeSpectrum.comap f ⁻¹' U.1) :
     (structureSheaf R).1.obj (op U) →+* (structureSheaf S).1.obj (op V)
     where
-  toFun s := ⟨comapFun f U V hUV s.1, comapFun_isLocallyFraction f U V hUV s.1 s.2⟩
+  toFun s := ⟨comapFun f U V hUV s.1, comapFunIsLocallyFraction f U V hUV s.1 s.2⟩
   map_one' :=
     Subtype.ext <|
       funext fun p =>
Diff
@@ -941,8 +941,7 @@ theorem stalkAlgebra_map (p : PrimeSpectrum R) (r : R) :
 instance IsLocalization.to_stalk (p : PrimeSpectrum R) :
     IsLocalization.AtPrime ((structureSheaf R).Presheaf.stalk p) p.asIdeal :=
   by
-  convert
-    (IsLocalization.isLocalization_iff_of_ringEquiv _
+  convert(IsLocalization.isLocalization_iff_of_ringEquiv _
           (stalk_iso R p).symm.commRingIsoToRingEquiv).mp
       Localization.isLocalization
   apply Algebra.algebra_ext
@@ -967,8 +966,7 @@ theorem openAlgebra_map (U : (Opens (PrimeSpectrum R))ᵒᵖ) (r : R) :
 instance IsLocalization.to_basicOpen (r : R) :
     IsLocalization.Away r ((structureSheaf R).val.obj (op <| basicOpen r)) :=
   by
-  convert
-    (IsLocalization.isLocalization_iff_of_ringEquiv _
+  convert(IsLocalization.isLocalization_iff_of_ringEquiv _
           (basic_open_iso R r).symm.commRingIsoToRingEquiv).mp
       Localization.isLocalization
   apply Algebra.algebra_ext
Diff
@@ -545,7 +545,7 @@ formed by gluing the `open_to_localization` maps. -/
 def stalkToFiberRingHom (x : PrimeSpectrum.top R) :
     (structureSheaf R).Presheaf.stalk x ⟶ CommRingCat.of (Localization.AtPrime x.asIdeal) :=
   Limits.colimit.desc ((OpenNhds.inclusion x).op ⋙ (structureSheaf R).1)
-    { x := _
+    { X := _
       ι :=
         {
           app := fun U =>
Diff
@@ -357,7 +357,8 @@ theorem const_zero (f : R) (U hu) : const R 0 f U hu = 0 :=
   Subtype.eq <|
     funext fun x =>
       IsLocalization.mk'_eq_iff_eq_mul.2 <| by
-        erw [RingHom.map_zero, Subtype.val_eq_coe, Subring.coe_zero, Pi.zero_apply, zero_mul]
+        erw [RingHom.map_zero, Subtype.val_eq_coe, Subring.coe_zero, Pi.zero_apply,
+          MulZeroClass.zero_mul]
 #align algebraic_geometry.structure_sheaf.const_zero AlgebraicGeometry.StructureSheaf.const_zero
 
 theorem const_self (f : R) (U hu) : const R f f U hu = 1 :=
@@ -674,7 +675,7 @@ theorem toBasicOpen_injective (f : R) : Function.Injective (toBasicOpen R f) :=
   -- We define `I` as the ideal of *all* elements `r` satisfying the above equation.
   let I : Ideal R :=
     { carrier := { r : R | r * (d * a) = r * (b * c) }
-      zero_mem' := by simp only [Set.mem_setOf_eq, zero_mul]
+      zero_mem' := by simp only [Set.mem_setOf_eq, MulZeroClass.zero_mul]
       add_mem' := fun r₁ r₂ hr₁ hr₂ => by
         dsimp at hr₁ hr₂⊢
         simp only [add_mul, hr₁, hr₂]
Diff
@@ -737,7 +737,7 @@ theorem locally_const_basicOpen (U : Opens (PrimeSpectrum.top R))
 #align algebraic_geometry.structure_sheaf.locally_const_basic_open AlgebraicGeometry.StructureSheaf.locally_const_basicOpen
 
 /- ./././Mathport/Syntax/Translate/Expr.lean:177:8: unsupported: ambiguous notation -/
-/- ./././Mathport/Syntax/Translate/Basic.lean:628:2: warning: expanding binder collection (i j «expr ∈ » t) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (i j «expr ∈ » t) -/
 /-
 Auxiliary lemma for surjectivity of `to_basic_open`.
 A local representation of a section `s` as fractions `a i / h i` on finitely many basic opens

Changes in mathlib4

mathlib3
mathlib4
change the order of operation in zsmulRec and nsmulRec (#11451)

We change the following field in the definition of an additive commutative monoid:

 nsmul_succ : ∀ (n : ℕ) (x : G),
-  AddMonoid.nsmul (n + 1) x = x + AddMonoid.nsmul n x
+  AddMonoid.nsmul (n + 1) x = AddMonoid.nsmul n x + x

where the latter is more natural

We adjust the definitions of ^ in monoids, groups, etc. Originally there was a warning comment about why this natural order was preferred

use x * npowRec n x and not npowRec n x * x in the definition to make sure that definitional unfolding of npowRec is blocked, to avoid deep recursion issues.

but it seems to no longer apply.

Remarks on the PR :

  • pow_succ and pow_succ' have switched their meanings.
  • Most of the time, the proofs were adjusted by priming/unpriming one lemma, or exchanging left and right; a few proofs were more complicated to adjust.
  • In particular, [Mathlib/NumberTheory/RamificationInertia.lean] used Ideal.IsPrime.mul_mem_pow which is defined in [Mathlib/RingTheory/DedekindDomain/Ideal.lean]. Changing the order of operation forced me to add the symmetric lemma Ideal.IsPrime.mem_pow_mul.
  • the docstring for Cauchy condensation test in [Mathlib/Analysis/PSeries.lean] was mathematically incorrect, I added the mention that the function is antitone.
Diff
@@ -702,7 +702,7 @@ theorem locally_const_basicOpen (U : Opens (PrimeSpectrum.Top R))
   -- Actually, we will need a *nonzero* power of `h`.
   -- This is because we will need the equality `basicOpen (h ^ n) = basicOpen h`, which only
   -- holds for a nonzero power `n`. We therefore artificially increase `n` by one.
-  replace hn := Ideal.mul_mem_left (Ideal.span {g}) h hn
+  replace hn := Ideal.mul_mem_right h (Ideal.span {g}) hn
   rw [← pow_succ, Ideal.mem_span_singleton'] at hn
   cases' hn with c hc
   have basic_opens_eq := PrimeSpectrum.basicOpen_pow h (n + 1) (by omega)
@@ -869,7 +869,7 @@ theorem toBasicOpen_surjective (f : R) : Function.Surjective (toBasicOpen R f) :
       ← Finset.set_biUnion_coe, ← Set.image_eq_iUnion] at ht_cover
     apply PrimeSpectrum.vanishingIdeal_anti_mono ht_cover
     exact PrimeSpectrum.subset_vanishingIdeal_zeroLocus {f} (Set.mem_singleton f)
-  replace hn := Ideal.mul_mem_left _ f hn
+  replace hn := Ideal.mul_mem_right f _ hn
   erw [← pow_succ, Finsupp.mem_span_image_iff_total] at hn
   rcases hn with ⟨b, b_supp, hb⟩
   rw [Finsupp.total_apply_of_mem_supported R b_supp] at hb
refactor: optimize proofs with omega (#11093)

I ran tryAtEachStep on all files under Mathlib to find all locations where omega succeeds. For each that was a linarith without an only, I tried replacing it with omega, and I verified that elaboration time got smaller. (In almost all cases, there was a noticeable speedup.) I also replaced some slow aesops along the way.

Diff
@@ -705,7 +705,7 @@ theorem locally_const_basicOpen (U : Opens (PrimeSpectrum.Top R))
   replace hn := Ideal.mul_mem_left (Ideal.span {g}) h hn
   rw [← pow_succ, Ideal.mem_span_singleton'] at hn
   cases' hn with c hc
-  have basic_opens_eq := PrimeSpectrum.basicOpen_pow h (n + 1) (by linarith)
+  have basic_opens_eq := PrimeSpectrum.basicOpen_pow h (n + 1) (by omega)
   have i_basic_open := eqToHom basic_opens_eq ≫ homOfLE hDhV
   -- We claim that `(f * c) / h ^ (n+1)` is our desired representation
   use f * c, h ^ (n + 1), i_basic_open ≫ iVU, (basic_opens_eq.symm.le : _) hxDh
@@ -784,7 +784,7 @@ theorem normalize_finite_fraction_representation (U : Opens (PrimeSpectrum.Top R
   -- Since there are only finitely many indices involved, we can pick the supremum.
   let N := (t ×ˢ t).sup n
   have basic_opens_eq : ∀ i : ι, PrimeSpectrum.basicOpen (h i ^ (N + 1)) =
-    PrimeSpectrum.basicOpen (h i) := fun i => PrimeSpectrum.basicOpen_pow _ _ (by linarith)
+    PrimeSpectrum.basicOpen (h i) := fun i => PrimeSpectrum.basicOpen_pow _ _ (by omega)
   -- Expanding the fraction `a i / h i` by the power `(h i) ^ n` gives the desired normalization
   refine'
     ⟨fun i => a i * h i ^ N, fun i => h i ^ (N + 1), fun i => eqToHom (basic_opens_eq i) ≫ iDh i,
@@ -904,7 +904,7 @@ theorem toBasicOpen_surjective (f : R) : Function.Surjective (toBasicOpen R f) :
   swap
   · intro y hy
     change y ∈ PrimeSpectrum.basicOpen (f ^ (n + 1))
-    rw [PrimeSpectrum.basicOpen_pow f (n + 1) (by linarith)]
+    rw [PrimeSpectrum.basicOpen_pow f (n + 1) (by omega)]
     exact (leOfHom (iDh i) : _) hy
   -- The rest of the proof is just computation
   apply const_ext
chore(AlgebraicGeometry.StructureSheaf): remove erw (#11022)

We replace a erw chain with a single rw and exact. Readability is also arguably improved.

Diff
@@ -355,7 +355,8 @@ theorem res_const' (f g : R) (V hv) :
 
 theorem const_zero (f : R) (U hu) : const R 0 f U hu = 0 :=
   Subtype.eq <| funext fun x => IsLocalization.mk'_eq_iff_eq_mul.2 <| by
-    erw [RingHom.map_zero, Subring.coe_zero, Pi.zero_apply, zero_mul]
+    rw [RingHom.map_zero]
+    exact (mul_eq_zero_of_left rfl ((algebraMap R (Localizations R x)) _)).symm
 #align algebraic_geometry.structure_sheaf.const_zero AlgebraicGeometry.StructureSheaf.const_zero
 
 theorem const_self (f : R) (U hu) : const R f f U hu = 1 :=
chore: prepare Lean version bump with explicit simp (#10999)

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -799,7 +799,7 @@ theorem normalize_finite_fraction_representation (U : Opens (PrimeSpectrum.Top R
     -- To accommodate for the difference `k`, we multiply both sides of the equation `n_spec (i, j)`
     -- by `(h i * h j) ^ k`
     convert congr_arg (fun z => z * (h i * h j) ^ k) (n_spec (i, j)) using 1 <;>
-      · simp only [mul_pow]; ring
+      · simp only [n, mul_pow]; ring
   -- Lastly, we need to show that the new fractions still represent our original `s`
   intro i _
   rw [op_comp, Functor.map_comp]
style: reduce spacing variation in "porting note" comments (#10886)

In this pull request, I have systematically eliminated the leading whitespace preceding the colon (:) within all unlabelled or unclassified porting notes. This adjustment facilitates a more efficient review process for the remaining notes by ensuring no entries are overlooked due to formatting inconsistencies.

Diff
@@ -78,11 +78,11 @@ def Localizations (P : PrimeSpectrum.Top R) : Type u :=
   Localization.AtPrime P.asIdeal
 #align algebraic_geometry.structure_sheaf.localizations AlgebraicGeometry.StructureSheaf.Localizations
 
--- Porting note : can't derive `CommRingCat`
+-- Porting note: can't derive `CommRingCat`
 instance commRingLocalizations (P : PrimeSpectrum.Top R) : CommRing <| Localizations R P :=
   inferInstanceAs <| CommRing <| Localization.AtPrime P.asIdeal
 
--- Porting note : can't derive `LocalRing`
+-- Porting note: can't derive `LocalRing`
 instance localRingLocalizations (P : PrimeSpectrum.Top R) : LocalRing <| Localizations R P :=
   inferInstanceAs <| LocalRing <| Localization.AtPrime P.asIdeal
 
@@ -557,14 +557,14 @@ theorem stalkToFiberRingHom_germ (U : Opens (PrimeSpectrum.Top R)) (x : U)
 
 @[simp]
 theorem toStalk_comp_stalkToFiberRingHom (x : PrimeSpectrum.Top R) :
-    -- Porting note : now `algebraMap _ _` needs to be explicitly typed
+    -- Porting note: now `algebraMap _ _` needs to be explicitly typed
     toStalk R x ≫ stalkToFiberRingHom R x = algebraMap R (Localization.AtPrime x.asIdeal) := by
   erw [toStalk, Category.assoc, germ_comp_stalkToFiberRingHom]; rfl
 #align algebraic_geometry.structure_sheaf.to_stalk_comp_stalk_to_fiber_ring_hom AlgebraicGeometry.StructureSheaf.toStalk_comp_stalkToFiberRingHom
 
 @[simp]
 theorem stalkToFiberRingHom_toStalk (x : PrimeSpectrum.Top R) (f : R) :
-    -- Porting note : now `algebraMap _ _` needs to be explicitly typed
+    -- Porting note: now `algebraMap _ _` needs to be explicitly typed
     stalkToFiberRingHom R x (toStalk R x f) = algebraMap R (Localization.AtPrime x.asIdeal) f :=
   RingHom.ext_iff.1 (toStalk_comp_stalkToFiberRingHom R x) _
 #align algebraic_geometry.structure_sheaf.stalk_to_fiber_ring_hom_to_stalk AlgebraicGeometry.StructureSheaf.stalkToFiberRingHom_toStalk
@@ -673,7 +673,7 @@ theorem toBasicOpen_injective (f : R) : Function.Injective (toBasicOpen R f) :=
   rw [PrimeSpectrum.mem_zeroLocus, Set.not_subset]
   have := congr_fun (congr_arg Subtype.val h_eq) ⟨p, hfp⟩
   dsimp at this
-  -- Porting note : need to tell Lean what `S` is and need to change to `erw`
+  -- Porting note: need to tell Lean what `S` is and need to change to `erw`
   -- https://github.com/leanprover-community/mathlib4/issues/5164
   erw [IsLocalization.eq (S := Localization.AtPrime p.asIdeal)] at this
   cases' this with r hr
@@ -709,7 +709,7 @@ theorem locally_const_basicOpen (U : Opens (PrimeSpectrum.Top R))
   -- We claim that `(f * c) / h ^ (n+1)` is our desired representation
   use f * c, h ^ (n + 1), i_basic_open ≫ iVU, (basic_opens_eq.symm.le : _) hxDh
   rw [op_comp, Functor.map_comp] --, comp_apply, ← s_eq, res_const]
-  -- Porting note : `comp_apply` can't be rewritten, so use a change
+  -- Porting note: `comp_apply` can't be rewritten, so use a change
   change const R _ _ _ _ = (structureSheaf R).1.map i_basic_open.op
     ((structureSheaf R).1.map iVU.op s)
   rw [← s_eq, res_const]
@@ -803,7 +803,7 @@ theorem normalize_finite_fraction_representation (U : Opens (PrimeSpectrum.Top R
   -- Lastly, we need to show that the new fractions still represent our original `s`
   intro i _
   rw [op_comp, Functor.map_comp]
-  -- Porting note : `comp_apply` can't be rewritten, so use a change
+  -- Porting note: `comp_apply` can't be rewritten, so use a change
   change (structureSheaf R).1.map (eqToHom (basic_opens_eq _)).op
     ((structureSheaf R).1.map (iDh i).op s) = _
   rw [← hs, res_const]
@@ -820,7 +820,7 @@ open scoped Classical
 
 open scoped BigOperators
 
--- Porting note : in the following proof there are two places where `⋃ i, ⋃ (hx : i ∈ _), ... `
+-- Porting note: in the following proof there are two places where `⋃ i, ⋃ (hx : i ∈ _), ... `
 -- though `hx` is not used in `...` part, it is still required to maintain the structure of
 -- the original proof in mathlib3.
 set_option linter.unusedVariables false in
@@ -846,7 +846,7 @@ theorem toBasicOpen_surjective (f : R) : Function.Surjective (toBasicOpen R f) :
     normalize_finite_fraction_representation R (PrimeSpectrum.basicOpen f)
       s t a' h' iDh' ht_cover' s_eq'
   clear s_eq' iDh' hxDh' ht_cover' a' h'
-  -- Porting note : simp with `[← SetLike.coe_subset_coe, Opens.coe_iSup]` does not result in
+  -- Porting note: simp with `[← SetLike.coe_subset_coe, Opens.coe_iSup]` does not result in
   -- desired form
   rw [← SetLike.coe_subset_coe, Opens.coe_iSup] at ht_cover
   replace ht_cover : (PrimeSpectrum.basicOpen f : Set <| PrimeSpectrum R) ⊆
@@ -856,7 +856,7 @@ theorem toBasicOpen_surjective (f : R) : Function.Surjective (toBasicOpen R f) :
   -- Next we show that some power of `f` is a linear combination of the `h i`
   obtain ⟨n, hn⟩ : f ∈ (Ideal.span (h '' ↑t)).radical := by
     rw [← PrimeSpectrum.vanishingIdeal_zeroLocus_eq_radical, PrimeSpectrum.zeroLocus_span]
-    -- Porting note : simp with `PrimeSpectrum.basicOpen_eq_zeroLocus_compl` does not work
+    -- Porting note: simp with `PrimeSpectrum.basicOpen_eq_zeroLocus_compl` does not work
     replace ht_cover : (PrimeSpectrum.zeroLocus {f})ᶜ ⊆
         ⋃ (i : ι) (x : i ∈ t), (PrimeSpectrum.zeroLocus {h i})ᶜ := by
       convert ht_cover
@@ -1007,7 +1007,7 @@ instance isIso_to_global : IsIso (toOpen R ⊤) := by
 #align algebraic_geometry.structure_sheaf.is_iso_to_global AlgebraicGeometry.StructureSheaf.isIso_to_global
 
 /-- The ring isomorphism between the ring `R` and the global sections `Γ(X, 𝒪ₓ)`. -/
--- Porting note : was @[simps (config := { rhsMd := Tactic.Transparency.semireducible })]
+-- Porting note: was @[simps (config := { rhsMd := Tactic.Transparency.semireducible })]
 @[simps!]
 def globalSectionsIso : CommRingCat.of R ≅ (structureSheaf R).1.obj (op ⊤) :=
   asIso (toOpen R ⊤)
@@ -1047,7 +1047,7 @@ theorem stalkSpecializes_stalk_to_fiber {R : Type*} [CommRing R] {x y : PrimeSpe
     (h : x ⤳ y) :
     (structureSheaf R).presheaf.stalkSpecializes h ≫ StructureSheaf.stalkToFiberRingHom R x =
       StructureSheaf.stalkToFiberRingHom R y ≫
-      -- Porting note : `PrimeSpectrum.localizationMapOfSpecializes h` by itself is interpreted as a
+      -- Porting note: `PrimeSpectrum.localizationMapOfSpecializes h` by itself is interpreted as a
       -- ring homomorphism, so it is changed in a way to force it being interpreted as categorical
       -- arrow.
       (show CommRingCat.of (Localization.AtPrime y.asIdeal) ⟶
chore: remove terminal, terminal refines (#10762)

I replaced a few "terminal" refine/refine's with exact.

The strategy was very simple-minded: essentially any refine whose following line had smaller indentation got replaced by exact and then I cleaned up the mess.

This PR certainly leaves some further terminal refines, but maybe the current change is beneficial.

Diff
@@ -894,7 +894,7 @@ theorem toBasicOpen_surjective (f : R) : Function.Surjective (toBasicOpen R f) :
     have := ht_cover hx
     rw [← Finset.set_biUnion_coe, Set.mem_iUnion₂] at this
     rcases this with ⟨i, i_mem, x_mem⟩
-    refine ⟨⟨i, i_mem⟩, x_mem⟩
+    exact ⟨⟨i, i_mem⟩, x_mem⟩
   rintro ⟨i, hi⟩
   dsimp
   change (structureSheaf R).1.map _ _ = (structureSheaf R).1.map _ _
chore: remove stream-of-consciousness uses of have, replace and suffices (#10640)

No changes to tactic file, it's just boring fixes throughout the library.

This follows on from #6964.

Co-authored-by: sgouezel <sebastien.gouezel@univ-rennes1.fr> Co-authored-by: Eric Wieser <wieser.eric@gmail.com>

Diff
@@ -850,16 +850,16 @@ theorem toBasicOpen_surjective (f : R) : Function.Surjective (toBasicOpen R f) :
   -- desired form
   rw [← SetLike.coe_subset_coe, Opens.coe_iSup] at ht_cover
   replace ht_cover : (PrimeSpectrum.basicOpen f : Set <| PrimeSpectrum R) ⊆
-    ⋃ (i : ι) (x : i ∈ t), (PrimeSpectrum.basicOpen (h i) : Set _)
-  · convert ht_cover using 2
+      ⋃ (i : ι) (x : i ∈ t), (PrimeSpectrum.basicOpen (h i) : Set _) := by
+    convert ht_cover using 2
     exact funext fun j => by rw [Opens.coe_iSup]
   -- Next we show that some power of `f` is a linear combination of the `h i`
   obtain ⟨n, hn⟩ : f ∈ (Ideal.span (h '' ↑t)).radical := by
     rw [← PrimeSpectrum.vanishingIdeal_zeroLocus_eq_radical, PrimeSpectrum.zeroLocus_span]
     -- Porting note : simp with `PrimeSpectrum.basicOpen_eq_zeroLocus_compl` does not work
     replace ht_cover : (PrimeSpectrum.zeroLocus {f})ᶜ ⊆
-      ⋃ (i : ι) (x : i ∈ t), (PrimeSpectrum.zeroLocus {h i})ᶜ
-    · convert ht_cover
+        ⋃ (i : ι) (x : i ∈ t), (PrimeSpectrum.zeroLocus {h i})ᶜ := by
+      convert ht_cover
       · rw [PrimeSpectrum.basicOpen_eq_zeroLocus_compl]
       · simp only [Opens.iSup_mk, Opens.carrier_eq_coe, PrimeSpectrum.basicOpen_eq_zeroLocus_compl]
     rw [Set.compl_subset_comm] at ht_cover
refactor(Data/FunLike): use unbundled inheritance from FunLike (#8386)

The FunLike hierarchy is very big and gets scanned through each time we need a coercion (via the CoeFun instance). It looks like unbundled inheritance suits Lean 4 better here. The only class that still extends FunLike is EquivLike, since that has a custom coe_injective' field that is easier to implement. All other classes should take FunLike or EquivLike as a parameter.

Zulip thread

Important changes

Previously, morphism classes would be Type-valued and extend FunLike:

/-- `MyHomClass F A B` states that `F` is a type of `MyClass.op`-preserving morphisms.
You should extend this class when you extend `MyHom`. -/
class MyHomClass (F : Type*) (A B : outParam <| Type*) [MyClass A] [MyClass B]
  extends FunLike F A B :=
(map_op : ∀ (f : F) (x y : A), f (MyClass.op x y) = MyClass.op (f x) (f y))

After this PR, they should be Prop-valued and take FunLike as a parameter:

/-- `MyHomClass F A B` states that `F` is a type of `MyClass.op`-preserving morphisms.
You should extend this class when you extend `MyHom`. -/
class MyHomClass (F : Type*) (A B : outParam <| Type*) [MyClass A] [MyClass B]
  [FunLike F A B] : Prop :=
(map_op : ∀ (f : F) (x y : A), f (MyClass.op x y) = MyClass.op (f x) (f y))

(Note that A B stay marked as outParam even though they are not purely required to be so due to the FunLike parameter already filling them in. This is required to see through type synonyms, which is important in the category theory library. Also, I think keeping them as outParam is slightly faster.)

Similarly, MyEquivClass should take EquivLike as a parameter.

As a result, every mention of [MyHomClass F A B] should become [FunLike F A B] [MyHomClass F A B].

Remaining issues

Slower (failing) search

While overall this gives some great speedups, there are some cases that are noticeably slower. In particular, a failing application of a lemma such as map_mul is more expensive. This is due to suboptimal processing of arguments. For example:

variable [FunLike F M N] [Mul M] [Mul N] (f : F) (x : M) (y : M)

theorem map_mul [MulHomClass F M N] : f (x * y) = f x * f y

example [AddHomClass F A B] : f (x * y) = f x * f y := map_mul f _ _

Before this PR, applying map_mul f gives the goals [Mul ?M] [Mul ?N] [MulHomClass F ?M ?N]. Since M and N are out_params, [MulHomClass F ?M ?N] is synthesized first, supplies values for ?M and ?N and then the Mul M and Mul N instances can be found.

After this PR, the goals become [FunLike F ?M ?N] [Mul ?M] [Mul ?N] [MulHomClass F ?M ?N]. Now [FunLike F ?M ?N] is synthesized first, supplies values for ?M and ?N and then the Mul M and Mul N instances can be found, before trying MulHomClass F M N which fails. Since the Mul hierarchy is very big, this can be slow to fail, especially when there is no such Mul instance.

A long-term but harder to achieve solution would be to specify the order in which instance goals get solved. For example, we'd like to change the arguments to map_mul to look like [FunLike F M N] [Mul M] [Mul N] [highPriority <| MulHomClass F M N] because MulHomClass fails or succeeds much faster than the others.

As a consequence, the simpNF linter is much slower since by design it tries and fails to apply many map_ lemmas. The same issue occurs a few times in existing calls to simp [map_mul], where map_mul is tried "too soon" and fails. Thanks to the speedup of leanprover/lean4#2478 the impact is very limited, only in files that already were close to the timeout.

simp not firing sometimes

This affects map_smulₛₗ and related definitions. For simp lemmas Lean apparently uses a slightly different mechanism to find instances, so that rw can find every argument to map_smulₛₗ successfully but simp can't: leanprover/lean4#3701.

Missing instances due to unification failing

Especially in the category theory library, we might sometimes have a type A which is also accessible as a synonym (Bundled A hA).1. Instance synthesis doesn't always work if we have f : A →* B but x * y : (Bundled A hA).1 or vice versa. This seems to be mostly fixed by keeping A B as outParams in MulHomClass F A B. (Presumably because Lean will do a definitional check A =?= (Bundled A hA).1 instead of using the syntax in the discrimination tree.)

Workaround for issues

The timeouts can be worked around for now by specifying which map_mul we mean, either as map_mul f for some explicit f, or as e.g. MonoidHomClass.map_mul.

map_smulₛₗ not firing as simp lemma can be worked around by going back to the pre-FunLike situation and making LinearMap.map_smulₛₗ a simp lemma instead of the generic map_smulₛₗ. Writing simp [map_smulₛₗ _] also works.

Co-authored-by: Matthew Ballard <matt@mrb.email> Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Scott Morrison <scott@tqft.net> Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>

Diff
@@ -578,9 +578,9 @@ def stalkIso (x : PrimeSpectrum.Top R) :
   inv := localizationToStalk R x
   hom_inv_id := by
     ext U hxU s
-    simp only [FunctorToTypes.map_comp_apply, CommRingCat.forget_map,
-      CommRingCat.coe_of, Category.comp_id]
-    rw [comp_apply, comp_apply, stalkToFiberRingHom_germ']
+    -- Note: this `simp` was longer, but the line below had to become an `erw`
+    simp only [Category.comp_id]
+    erw [comp_apply, comp_apply, stalkToFiberRingHom_germ']
     obtain ⟨V, hxV, iVU, f, g, (hg : V ≤ PrimeSpectrum.basicOpen _), hs⟩ :=
       exists_const _ _ s x hxU
     erw [← res_apply R U V iVU s ⟨x, hxV⟩, ← hs, const_apply, localizationToStalk_mk']
perf(FunLike.Basic): beta reduce CoeFun.coe (#7905)

This eliminates (fun a ↦ β) α in the type when applying a FunLike.

Co-authored-by: Matthew Ballard <matt@mrb.email> Co-authored-by: Eric Wieser <wieser.eric@gmail.com>

Diff
@@ -483,7 +483,7 @@ def localizationToStalk (x : PrimeSpectrum.Top R) :
 @[simp]
 theorem localizationToStalk_of (x : PrimeSpectrum.Top R) (f : R) :
     localizationToStalk R x (algebraMap _ (Localization _) f) = toStalk R x f :=
-  IsLocalization.lift_eq _ f
+  IsLocalization.lift_eq (S := Localization x.asIdeal.primeCompl) _ f
 #align algebraic_geometry.structure_sheaf.localization_to_stalk_of AlgebraicGeometry.StructureSheaf.localizationToStalk_of
 
 @[simp]
feat: Order of elements of a subgroup (#8385)

The cardinality of a subgroup is greater than the order of any of its elements.

Rename

  • order_eq_card_zpowersFintype.card_zpowers
  • order_eq_card_zpowers'Nat.card_zpowers (and turn it around to match Nat.card_subgroupPowers)
  • Submonoid.powers_subsetSubmonoid.powers_le
  • orderOf_dvd_card_univorderOf_dvd_card
  • orderOf_subgroupSubgroup.orderOf
  • Subgroup.nonemptySubgroup.coe_nonempty
Diff
@@ -626,7 +626,7 @@ def toBasicOpen (f : R) :
 @[simp]
 theorem toBasicOpen_mk' (s f : R) (g : Submonoid.powers s) :
     toBasicOpen R s (IsLocalization.mk' (Localization.Away s) f g) =
-      const R f g (PrimeSpectrum.basicOpen s) fun x hx => Submonoid.powers_subset hx g.2 :=
+      const R f g (PrimeSpectrum.basicOpen s) fun x hx => Submonoid.powers_le.2 hx g.2 :=
   (IsLocalization.lift_mk'_spec _ _ _ _).2 <| by
     -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
     erw [toOpen_eq_const, toOpen_eq_const]; rw [const_mul_cancel']
Revert "chore: revert #7703 (#7710)"

This reverts commit f3695eb2.

Diff
@@ -247,6 +247,9 @@ def structurePresheafInCommRing : Presheaf CommRingCat (PrimeSpectrum.Top R) whe
 set_option linter.uppercaseLean3 false in
 #align algebraic_geometry.structure_presheaf_in_CommRing AlgebraicGeometry.structurePresheafInCommRing
 
+-- These lemmas have always been bad (#7657), but leanprover/lean4#2644 made `simp` start noticing
+attribute [nolint simpNF] AlgebraicGeometry.structurePresheafInCommRing_map_apply
+
 /-- Some glue, verifying that that structure presheaf valued in `CommRingCat` agrees
 with the `Type` valued structure presheaf.
 -/
@@ -590,8 +593,9 @@ def stalkIso (x : PrimeSpectrum.Top R) :
       (RingHom.comp (stalkToFiberRingHom R x) (localizationToStalk R x))
       (RingHom.id (Localization.AtPrime _)) <| by
         ext f
-        rw [RingHom.comp_apply, RingHom.comp_apply, localizationToStalk_of,
-          stalkToFiberRingHom_toStalk, RingHom.comp_apply, RingHom.id_apply]
+        -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
+        rw [RingHom.comp_apply, RingHom.comp_apply]; erw [localizationToStalk_of,
+          stalkToFiberRingHom_toStalk]; rw [RingHom.comp_apply, RingHom.id_apply]
 #align algebraic_geometry.structure_sheaf.stalk_iso AlgebraicGeometry.StructureSheaf.stalkIso
 
 instance (x : PrimeSpectrum R) : IsIso (stalkToFiberRingHom R x) :=
@@ -624,7 +628,8 @@ theorem toBasicOpen_mk' (s f : R) (g : Submonoid.powers s) :
     toBasicOpen R s (IsLocalization.mk' (Localization.Away s) f g) =
       const R f g (PrimeSpectrum.basicOpen s) fun x hx => Submonoid.powers_subset hx g.2 :=
   (IsLocalization.lift_mk'_spec _ _ _ _).2 <| by
-    rw [toOpen_eq_const, toOpen_eq_const, const_mul_cancel']
+    -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
+    erw [toOpen_eq_const, toOpen_eq_const]; rw [const_mul_cancel']
 #align algebraic_geometry.structure_sheaf.to_basic_open_mk' AlgebraicGeometry.StructureSheaf.toBasicOpen_mk'
 
 @[simp]
@@ -1008,6 +1013,9 @@ def globalSectionsIso : CommRingCat.of R ≅ (structureSheaf R).1.obj (op ⊤) :
   asIso (toOpen R ⊤)
 #align algebraic_geometry.structure_sheaf.global_sections_iso AlgebraicGeometry.StructureSheaf.globalSectionsIso
 
+-- These lemmas have always been bad (#7657), but leanprover/lean4#2644 made `simp` start noticing
+attribute [nolint simpNF] AlgebraicGeometry.StructureSheaf.globalSectionsIso_hom_apply_coe
+
 @[simp]
 theorem globalSectionsIso_hom (R : CommRingCat) : (globalSectionsIso R).hom = toOpen R ⊤ :=
   rfl
chore: revert #7703 (#7710)

This reverts commit 26eb2b0a.

Diff
@@ -247,9 +247,6 @@ def structurePresheafInCommRing : Presheaf CommRingCat (PrimeSpectrum.Top R) whe
 set_option linter.uppercaseLean3 false in
 #align algebraic_geometry.structure_presheaf_in_CommRing AlgebraicGeometry.structurePresheafInCommRing
 
--- These lemmas have always been bad (#7657), but leanprover/lean4#2644 made `simp` start noticing
-attribute [nolint simpNF] AlgebraicGeometry.structurePresheafInCommRing_map_apply
-
 /-- Some glue, verifying that that structure presheaf valued in `CommRingCat` agrees
 with the `Type` valued structure presheaf.
 -/
@@ -593,9 +590,8 @@ def stalkIso (x : PrimeSpectrum.Top R) :
       (RingHom.comp (stalkToFiberRingHom R x) (localizationToStalk R x))
       (RingHom.id (Localization.AtPrime _)) <| by
         ext f
-        -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
-        rw [RingHom.comp_apply, RingHom.comp_apply]; erw [localizationToStalk_of,
-          stalkToFiberRingHom_toStalk]; rw [RingHom.comp_apply, RingHom.id_apply]
+        rw [RingHom.comp_apply, RingHom.comp_apply, localizationToStalk_of,
+          stalkToFiberRingHom_toStalk, RingHom.comp_apply, RingHom.id_apply]
 #align algebraic_geometry.structure_sheaf.stalk_iso AlgebraicGeometry.StructureSheaf.stalkIso
 
 instance (x : PrimeSpectrum R) : IsIso (stalkToFiberRingHom R x) :=
@@ -628,8 +624,7 @@ theorem toBasicOpen_mk' (s f : R) (g : Submonoid.powers s) :
     toBasicOpen R s (IsLocalization.mk' (Localization.Away s) f g) =
       const R f g (PrimeSpectrum.basicOpen s) fun x hx => Submonoid.powers_subset hx g.2 :=
   (IsLocalization.lift_mk'_spec _ _ _ _).2 <| by
-    -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
-    erw [toOpen_eq_const, toOpen_eq_const]; rw [const_mul_cancel']
+    rw [toOpen_eq_const, toOpen_eq_const, const_mul_cancel']
 #align algebraic_geometry.structure_sheaf.to_basic_open_mk' AlgebraicGeometry.StructureSheaf.toBasicOpen_mk'
 
 @[simp]
@@ -1013,9 +1008,6 @@ def globalSectionsIso : CommRingCat.of R ≅ (structureSheaf R).1.obj (op ⊤) :
   asIso (toOpen R ⊤)
 #align algebraic_geometry.structure_sheaf.global_sections_iso AlgebraicGeometry.StructureSheaf.globalSectionsIso
 
--- These lemmas have always been bad (#7657), but leanprover/lean4#2644 made `simp` start noticing
-attribute [nolint simpNF] AlgebraicGeometry.StructureSheaf.globalSectionsIso_hom_apply_coe
-
 @[simp]
 theorem globalSectionsIso_hom (R : CommRingCat) : (globalSectionsIso R).hom = toOpen R ⊤ :=
   rfl
chore: bump toolchain to v4.2.0-rc2 (#7703)

This includes all the changes from #7606.

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -247,6 +247,9 @@ def structurePresheafInCommRing : Presheaf CommRingCat (PrimeSpectrum.Top R) whe
 set_option linter.uppercaseLean3 false in
 #align algebraic_geometry.structure_presheaf_in_CommRing AlgebraicGeometry.structurePresheafInCommRing
 
+-- These lemmas have always been bad (#7657), but leanprover/lean4#2644 made `simp` start noticing
+attribute [nolint simpNF] AlgebraicGeometry.structurePresheafInCommRing_map_apply
+
 /-- Some glue, verifying that that structure presheaf valued in `CommRingCat` agrees
 with the `Type` valued structure presheaf.
 -/
@@ -590,8 +593,9 @@ def stalkIso (x : PrimeSpectrum.Top R) :
       (RingHom.comp (stalkToFiberRingHom R x) (localizationToStalk R x))
       (RingHom.id (Localization.AtPrime _)) <| by
         ext f
-        rw [RingHom.comp_apply, RingHom.comp_apply, localizationToStalk_of,
-          stalkToFiberRingHom_toStalk, RingHom.comp_apply, RingHom.id_apply]
+        -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
+        rw [RingHom.comp_apply, RingHom.comp_apply]; erw [localizationToStalk_of,
+          stalkToFiberRingHom_toStalk]; rw [RingHom.comp_apply, RingHom.id_apply]
 #align algebraic_geometry.structure_sheaf.stalk_iso AlgebraicGeometry.StructureSheaf.stalkIso
 
 instance (x : PrimeSpectrum R) : IsIso (stalkToFiberRingHom R x) :=
@@ -624,7 +628,8 @@ theorem toBasicOpen_mk' (s f : R) (g : Submonoid.powers s) :
     toBasicOpen R s (IsLocalization.mk' (Localization.Away s) f g) =
       const R f g (PrimeSpectrum.basicOpen s) fun x hx => Submonoid.powers_subset hx g.2 :=
   (IsLocalization.lift_mk'_spec _ _ _ _).2 <| by
-    rw [toOpen_eq_const, toOpen_eq_const, const_mul_cancel']
+    -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
+    erw [toOpen_eq_const, toOpen_eq_const]; rw [const_mul_cancel']
 #align algebraic_geometry.structure_sheaf.to_basic_open_mk' AlgebraicGeometry.StructureSheaf.toBasicOpen_mk'
 
 @[simp]
@@ -1008,6 +1013,9 @@ def globalSectionsIso : CommRingCat.of R ≅ (structureSheaf R).1.obj (op ⊤) :
   asIso (toOpen R ⊤)
 #align algebraic_geometry.structure_sheaf.global_sections_iso AlgebraicGeometry.StructureSheaf.globalSectionsIso
 
+-- These lemmas have always been bad (#7657), but leanprover/lean4#2644 made `simp` start noticing
+attribute [nolint simpNF] AlgebraicGeometry.StructureSheaf.globalSectionsIso_hom_apply_coe
+
 @[simp]
 theorem globalSectionsIso_hom (R : CommRingCat) : (globalSectionsIso R).hom = toOpen R ⊤ :=
   rfl
chore (AlgebraicGeometry.StructureSheaf): clean up some instances (#7473)

We replace a few show X from inferInstance with inferInstanceAs which reduces some let_fun's in the resulting term. We also align the names with casing convention.

Diff
@@ -79,18 +79,18 @@ def Localizations (P : PrimeSpectrum.Top R) : Type u :=
 #align algebraic_geometry.structure_sheaf.localizations AlgebraicGeometry.StructureSheaf.Localizations
 
 -- Porting note : can't derive `CommRingCat`
-instance CommRingLocalizations (P : PrimeSpectrum.Top R) : CommRing <| Localizations R P :=
-  show CommRing <| Localization.AtPrime P.asIdeal from inferInstance
+instance commRingLocalizations (P : PrimeSpectrum.Top R) : CommRing <| Localizations R P :=
+  inferInstanceAs <| CommRing <| Localization.AtPrime P.asIdeal
 
 -- Porting note : can't derive `LocalRing`
-instance LocalRingLocalizations (P : PrimeSpectrum.Top R) : LocalRing <| Localizations R P :=
-  show LocalRing <| Localization.AtPrime P.asIdeal from inferInstance
+instance localRingLocalizations (P : PrimeSpectrum.Top R) : LocalRing <| Localizations R P :=
+  inferInstanceAs <| LocalRing <| Localization.AtPrime P.asIdeal
 
 instance (P : PrimeSpectrum.Top R) : Inhabited (Localizations R P) :=
   ⟨1⟩
 
 instance (U : Opens (PrimeSpectrum.Top R)) (x : U) : Algebra R (Localizations R x) :=
-  show Algebra R (Localization.AtPrime x.1.asIdeal) from inferInstance
+  inferInstanceAs <| Algebra R (Localization.AtPrime x.1.asIdeal)
 
 instance (U : Opens (PrimeSpectrum.Top R)) (x : U) :
     IsLocalization.AtPrime (Localizations R x) (x : PrimeSpectrum.Top R).asIdeal :=
chore: only four spaces for subsequent lines (#7286)

Co-authored-by: Moritz Firsching <firsching@google.com>

Diff
@@ -554,14 +554,14 @@ theorem stalkToFiberRingHom_germ (U : Opens (PrimeSpectrum.Top R)) (x : U)
 
 @[simp]
 theorem toStalk_comp_stalkToFiberRingHom (x : PrimeSpectrum.Top R) :
-  -- Porting note : now `algebraMap _ _` needs to be explicitly typed
+    -- Porting note : now `algebraMap _ _` needs to be explicitly typed
     toStalk R x ≫ stalkToFiberRingHom R x = algebraMap R (Localization.AtPrime x.asIdeal) := by
   erw [toStalk, Category.assoc, germ_comp_stalkToFiberRingHom]; rfl
 #align algebraic_geometry.structure_sheaf.to_stalk_comp_stalk_to_fiber_ring_hom AlgebraicGeometry.StructureSheaf.toStalk_comp_stalkToFiberRingHom
 
 @[simp]
 theorem stalkToFiberRingHom_toStalk (x : PrimeSpectrum.Top R) (f : R) :
-  -- Porting note : now `algebraMap _ _` needs to be explicitly typed
+    -- Porting note : now `algebraMap _ _` needs to be explicitly typed
     stalkToFiberRingHom R x (toStalk R x f) = algebraMap R (Localization.AtPrime x.asIdeal) f :=
   RingHom.ext_iff.1 (toStalk_comp_stalkToFiberRingHom R x) _
 #align algebraic_geometry.structure_sheaf.stalk_to_fiber_ring_hom_to_stalk AlgebraicGeometry.StructureSheaf.stalkToFiberRingHom_toStalk
chore: drop MulZeroClass. in mul_zero/zero_mul (#6682)

Search&replace MulZeroClass.mul_zero -> mul_zero, MulZeroClass.zero_mul -> zero_mul.

These were introduced by Mathport, as the full name of mul_zero is actually MulZeroClass.mul_zero (it's exported with the short name).

Diff
@@ -352,7 +352,7 @@ theorem res_const' (f g : R) (V hv) :
 
 theorem const_zero (f : R) (U hu) : const R 0 f U hu = 0 :=
   Subtype.eq <| funext fun x => IsLocalization.mk'_eq_iff_eq_mul.2 <| by
-    erw [RingHom.map_zero, Subring.coe_zero, Pi.zero_apply, MulZeroClass.zero_mul]
+    erw [RingHom.map_zero, Subring.coe_zero, Pi.zero_apply, zero_mul]
 #align algebraic_geometry.structure_sheaf.const_zero AlgebraicGeometry.StructureSheaf.const_zero
 
 theorem const_self (f : R) (U hu) : const R f f U hu = 1 :=
@@ -655,7 +655,7 @@ theorem toBasicOpen_injective (f : R) : Function.Injective (toBasicOpen R f) :=
   -- We define `I` as the ideal of *all* elements `r` satisfying the above equation.
   let I : Ideal R :=
     { carrier := { r : R | r * (d * a) = r * (b * c) }
-      zero_mem' := by simp only [Set.mem_setOf_eq, MulZeroClass.zero_mul]
+      zero_mem' := by simp only [Set.mem_setOf_eq, zero_mul]
       add_mem' := fun {r₁ r₂} hr₁ hr₂ => by dsimp at hr₁ hr₂ ⊢; simp only [add_mul, hr₁, hr₂]
       smul_mem' := fun {r₁ r₂} hr₂ => by dsimp at hr₂ ⊢; simp only [mul_assoc, hr₂] }
   -- Our claim now reduces to showing that `f` is contained in the radical of `I`
chore: tidy various files (#6534)
Diff
@@ -25,18 +25,18 @@ the subset of functions satisfying this condition is automatically a subpresheaf
 Because the condition "is locally equal to a fraction" is local,
 it is also a subsheaf.
 
-(It may be helpful to refer back to `topology.sheaves.sheaf_of_functions`,
+(It may be helpful to refer back to `Mathlib/Topology/Sheaves/SheafOfFunctions.lean`,
 where we show that dependent functions into any type family form a sheaf,
-and also `topology.sheaves.local_predicate`, where we characterise the predicates
+and also `Mathlib/Topology/Sheaves/LocalPredicate.lean`, where we characterise the predicates
 which pick out sub-presheaves and sub-sheaves of these sheaves.)
 
 We also set up the ring structure, obtaining
-`structure_sheaf R : sheaf CommRingCat (TopCat.of (PrimeSpectrum R))`.
+`structureSheaf : Sheaf CommRingCat (PrimeSpectrum.Top R)`.
 
 We then construct two basic isomorphisms, relating the structure sheaf to the underlying ring `R`.
-First, `structure_sheaf.stalk_iso` gives an isomorphism between the stalk of the structure sheaf
+First, `StructureSheaf.stalkIso` gives an isomorphism between the stalk of the structure sheaf
 at a point `p` and the localization of `R` at the prime ideal `p`. Second,
-`structure_sheaf.basic_open_iso` gives an isomorphism between the structure sheaf on `basic_open f`
+`StructureSheaf.basicOpenIso` gives an isomorphism between the structure sheaf on `basicOpen f`
 and the localization of `R` at the submonoid of powers of `f`.
 
 ## References
@@ -120,7 +120,7 @@ theorem IsFraction.eq_mk' {U : Opens (PrimeSpectrum.Top R)} {f : ∀ x : U, Loca
 
 variable (R)
 
-/-- The predicate `is_fraction` is "prelocal",
+/-- The predicate `IsFraction` is "prelocal",
 in the sense that if it holds on `U` it holds on any open subset `V` of `U`.
 -/
 def isFractionPrelocal : PrelocalPredicate (Localizations R) where
@@ -129,7 +129,7 @@ def isFractionPrelocal : PrelocalPredicate (Localizations R) where
 #align algebraic_geometry.structure_sheaf.is_fraction_prelocal AlgebraicGeometry.StructureSheaf.isFractionPrelocal
 
 /-- We will define the structure sheaf as
-the subsheaf of all dependent functions in `Π x : U, localizations R x`
+the subsheaf of all dependent functions in `Π x : U, Localizations R x`
 consisting of those functions which can locally be expressed as a ratio of
 (the images in the localization of) elements of `R`.
 
@@ -144,7 +144,7 @@ and $s(𝔮) = a/f$ in $A_𝔮$.
 
 Now Hartshorne had the disadvantage of not knowing about dependent functions,
 so we replace his circumlocution about functions into a disjoint union with
-`Π x : U, localizations x`.
+`Π x : U, Localizations x`.
 -/
 def isLocallyFraction : LocalPredicate (Localizations R) :=
   (isFractionPrelocal R).sheafify
@@ -160,7 +160,7 @@ theorem isLocallyFraction_pred {U : Opens (PrimeSpectrum.Top R)} (f : ∀ x : U,
   rfl
 #align algebraic_geometry.structure_sheaf.is_locally_fraction_pred AlgebraicGeometry.StructureSheaf.isLocallyFraction_pred
 
-/-- The functions satisfying `is_locally_fraction` form a subring.
+/-- The functions satisfying `isLocallyFraction` form a subring.
 -/
 def sectionsSubring (U : (Opens (PrimeSpectrum.Top R))ᵒᵖ) :
     Subring (∀ x : U.unop, Localizations R x) where
@@ -219,7 +219,7 @@ end StructureSheaf
 open StructureSheaf
 
 /-- The structure sheaf (valued in `Type`, not yet `CommRingCat`) is the subsheaf consisting of
-functions satisfying `is_locally_fraction`.
+functions satisfying `isLocallyFraction`.
 -/
 def structureSheafInType : Sheaf (Type u) (PrimeSpectrum.Top R) :=
   subsheafToTypes (isLocallyFraction R)
@@ -295,18 +295,18 @@ to a prime ideal in R.
 We do this via 8 steps:
 
 1. def const (f g : R) (V) (hv : V ≤ D_g) : OX(V) [for api]
-2. def to_open (U) : R ⟶ OX(U)
-3. [2] def to_stalk (p : Spec R) : R ⟶ OX_p
-4. [2] def to_basic_open (f : R) : R_f ⟶ OX(D_f)
-5. [3] def localization_to_stalk (p : Spec R) : R_p ⟶ OX_p
-6. def open_to_localization (U) (p) (hp : p ∈ U) : OX(U) ⟶ R_p
-7. [6] def stalk_to_fiber_ring_hom (p : Spec R) : OX_p ⟶ R_p
-8. [5,7] def stalk_iso (p : Spec R) : OX_p ≅ R_p
+2. def toOpen (U) : R ⟶ OX(U)
+3. [2] def toStalk (p : Spec R) : R ⟶ OX_p
+4. [2] def toBasicOpen (f : R) : R_f ⟶ OX(D_f)
+5. [3] def localizationToStalk (p : Spec R) : R_p ⟶ OX_p
+6. def openToLocalization (U) (p) (hp : p ∈ U) : OX(U) ⟶ R_p
+7. [6] def stalkToFiberRingHom (p : Spec R) : OX_p ⟶ R_p
+8. [5,7] def stalkIso (p : Spec R) : OX_p ≅ R_p
 
 In the square brackets we list the dependencies of a construction on the previous steps.
 
 -/
-/-- The section of `structure_sheaf R` on an open `U` sending each `x ∈ U` to the element
+/-- The section of `structureSheaf R` on an open `U` sending each `x ∈ U` to the element
 `f/g` in the localization of `R` at `x`. -/
 def const (f g : R) (U : Opens (PrimeSpectrum.Top R))
     (hu : ∀ x ∈ U, g ∈ (x : PrimeSpectrum.Top R).asIdeal.primeCompl) :
@@ -436,7 +436,7 @@ theorem toOpen_eq_const (U : Opens (PrimeSpectrum.Top R)) (f : R) :
 #align algebraic_geometry.structure_sheaf.to_open_eq_const AlgebraicGeometry.StructureSheaf.toOpen_eq_const
 
 /-- The canonical ring homomorphism interpreting an element of `R` as an element of
-the stalk of `structure_sheaf R` at `x`. -/
+the stalk of `structureSheaf R` at `x`. -/
 def toStalk (x : PrimeSpectrum.Top R) : CommRingCat.of R ⟶ (structureSheaf R).presheaf.stalk x :=
   (toOpen R ⊤ ≫ (structureSheaf R).presheaf.germ ⟨x, by trivial⟩)
 #align algebraic_geometry.structure_sheaf.to_stalk AlgebraicGeometry.StructureSheaf.toStalk
@@ -523,7 +523,7 @@ theorem openToLocalization_apply (U : Opens (PrimeSpectrum.Top R)) (x : PrimeSpe
 
 /-- The ring homomorphism from the stalk of the structure sheaf of `R` at a point corresponding to
 a prime ideal `p` to the localization of `R` at `p`,
-formed by gluing the `open_to_localization` maps. -/
+formed by gluing the `openToLocalization` maps. -/
 def stalkToFiberRingHom (x : PrimeSpectrum.Top R) :
     (structureSheaf R).presheaf.stalk x ⟶ CommRingCat.of (Localization.AtPrime x.asIdeal) :=
   Limits.colimit.desc ((OpenNhds.inclusion x).op ⋙ (structureSheaf R).1)
@@ -573,22 +573,17 @@ def stalkIso (x : PrimeSpectrum.Top R) :
     (structureSheaf R).presheaf.stalk x ≅ CommRingCat.of (Localization.AtPrime x.asIdeal) where
   hom := stalkToFiberRingHom R x
   inv := localizationToStalk R x
-  hom_inv_id :=
-    -- Porting note: We should be able to replace the next two lines with `ext U hxU s`,
-    -- but there seems to be a bug in `ext` whereby
-    -- it will not do multiple introductions for a single lemma, if you name the arguments.
-    -- See https://github.com/leanprover/std4/pull/159
-    (structureSheaf R).presheaf.stalk_hom_ext fun U hxU => by
-      ext s
-      simp only [FunctorToTypes.map_comp_apply, CommRingCat.forget_map,
-        CommRingCat.coe_of, Category.comp_id]
-      rw [comp_apply, comp_apply, stalkToFiberRingHom_germ']
-      obtain ⟨V, hxV, iVU, f, g, (hg : V ≤ PrimeSpectrum.basicOpen _), hs⟩ :=
-        exists_const _ _ s x hxU
-      erw [← res_apply R U V iVU s ⟨x, hxV⟩, ← hs, const_apply, localizationToStalk_mk']
-      refine' (structureSheaf R).presheaf.germ_ext V hxV (homOfLE hg) iVU _
-      dsimp
-      erw [← hs, res_const']
+  hom_inv_id := by
+    ext U hxU s
+    simp only [FunctorToTypes.map_comp_apply, CommRingCat.forget_map,
+      CommRingCat.coe_of, Category.comp_id]
+    rw [comp_apply, comp_apply, stalkToFiberRingHom_germ']
+    obtain ⟨V, hxV, iVU, f, g, (hg : V ≤ PrimeSpectrum.basicOpen _), hs⟩ :=
+      exists_const _ _ s x hxU
+    erw [← res_apply R U V iVU s ⟨x, hxV⟩, ← hs, const_apply, localizationToStalk_mk']
+    refine' (structureSheaf R).presheaf.germ_ext V hxV (homOfLE hg) iVU _
+    dsimp
+    erw [← hs, res_const']
   inv_hom_id :=
     @IsLocalization.ringHom_ext R _ x.asIdeal.primeCompl (Localization.AtPrime x.asIdeal) _ _
       (Localization.AtPrime x.asIdeal) _ _
@@ -655,7 +650,7 @@ theorem toBasicOpen_injective (f : R) : Function.Injective (toBasicOpen R f) :=
   simp only [toBasicOpen_mk'] at h_eq
   rw [IsLocalization.eq]
   -- We know that the fractions `a/b` and `c/d` are equal as sections of the structure sheaf on
-  -- `basic_open f`. We need to show that they agree as elements in the localization of `R` at `f`.
+  -- `basicOpen f`. We need to show that they agree as elements in the localization of `R` at `f`.
   -- This amounts showing that `r * (d * a) = r * (b * c)`, for some power `r = f ^ n` of `f`.
   -- We define `I` as the ideal of *all* elements `r` satisfying the above equation.
   let I : Ideal R :=
@@ -681,8 +676,8 @@ theorem toBasicOpen_injective (f : R) : Function.Injective (toBasicOpen R f) :=
 #align algebraic_geometry.structure_sheaf.to_basic_open_injective AlgebraicGeometry.StructureSheaf.toBasicOpen_injective
 
 /-
-Auxiliary lemma for surjectivity of `to_basic_open`.
-Every section can locally be represented on basic opens `basic_opens g` as a fraction `f/g`
+Auxiliary lemma for surjectivity of `toBasicOpen`.
+Every section can locally be represented on basic opens `basicOpen g` as a fraction `f/g`
 -/
 theorem locally_const_basicOpen (U : Opens (PrimeSpectrum.Top R))
     (s : (structureSheaf R).1.obj (op U)) (x : U) :
@@ -690,16 +685,16 @@ theorem locally_const_basicOpen (U : Opens (PrimeSpectrum.Top R))
       (const R f g (PrimeSpectrum.basicOpen g) fun y hy => hy) =
       (structureSheaf R).1.map i.op s := by
   -- First, any section `s` can be represented as a fraction `f/g` on some open neighborhood of `x`
-  -- and we may pass to a `basic_open h`, since these form a basis
+  -- and we may pass to a `basicOpen h`, since these form a basis
   obtain ⟨V, hxV : x.1 ∈ V.1, iVU, f, g, hVDg : V ≤ PrimeSpectrum.basicOpen g, s_eq⟩ :=
     exists_const R U s x.1 x.2
   obtain ⟨_, ⟨h, rfl⟩, hxDh, hDhV : PrimeSpectrum.basicOpen h ≤ V⟩ :=
     PrimeSpectrum.isTopologicalBasis_basic_opens.exists_subset_of_mem_open hxV V.2
   -- The problem is of course, that `g` and `h` don't need to coincide.
-  -- But, since `basic_open h ≤ basic_open g`, some power of `h` must be a multiple of `g`
+  -- But, since `basicOpen h ≤ basicOpen g`, some power of `h` must be a multiple of `g`
   cases' (PrimeSpectrum.basicOpen_le_basicOpen_iff h g).mp (Set.Subset.trans hDhV hVDg) with n hn
   -- Actually, we will need a *nonzero* power of `h`.
-  -- This is because we will need the equality `basic_open (h ^ n) = basic_open h`, which only
+  -- This is because we will need the equality `basicOpen (h ^ n) = basicOpen h`, which only
   -- holds for a nonzero power `n`. We therefore artificially increase `n` by one.
   replace hn := Ideal.mul_mem_left (Ideal.span {g}) h hn
   rw [← pow_succ, Ideal.mem_span_singleton'] at hn
@@ -725,9 +720,9 @@ theorem locally_const_basicOpen (U : Opens (PrimeSpectrum.Top R))
 #align algebraic_geometry.structure_sheaf.locally_const_basic_open AlgebraicGeometry.StructureSheaf.locally_const_basicOpen
 
 /-
-Auxiliary lemma for surjectivity of `to_basic_open`.
+Auxiliary lemma for surjectivity of `toBasicOpen`.
 A local representation of a section `s` as fractions `a i / h i` on finitely many basic opens
-`basic_open (h i)` can be "normalized" in such a way that `a i * h j = h i * a j` for all `i, j`
+`basicOpen (h i)` can be "normalized" in such a way that `a i * h j = h i * a j` for all `i, j`
 -/
 theorem normalize_finite_fraction_representation (U : Opens (PrimeSpectrum.Top R))
     (s : (structureSheaf R).1.obj (op U)) {ι : Type*} (t : Finset ι) (a h : ι → R)
@@ -755,7 +750,7 @@ theorem normalize_finite_fraction_representation (U : Opens (PrimeSpectrum.Top R
     let iDi : D ⟶ PrimeSpectrum.basicOpen (h i) := homOfLE (PrimeSpectrum.basicOpen_mul_le_left _ _)
     let iDj : D ⟶ PrimeSpectrum.basicOpen (h j) :=
       homOfLE (PrimeSpectrum.basicOpen_mul_le_right _ _)
-    -- Crucially, we need injectivity of `to_basic_open`
+    -- Crucially, we need injectivity of `toBasicOpen`
     apply toBasicOpen_injective R (h i * h j)
     rw [toBasicOpen_mk', toBasicOpen_mk']
     simp only []
@@ -808,8 +803,8 @@ theorem normalize_finite_fraction_representation (U : Opens (PrimeSpectrum.Top R
     ((structureSheaf R).1.map (iDh i).op s) = _
   rw [← hs, res_const]
   -- additional goal spit out by `res_const`
-  swap;
-  exact (basic_opens_eq i).le
+  swap
+  · exact (basic_opens_eq i).le
   apply const_ext
   dsimp
   rw [pow_succ]
@@ -827,7 +822,7 @@ set_option linter.unusedVariables false in
 -- The proof here follows the argument in Hartshorne's Algebraic Geometry, Proposition II.2.2.
 theorem toBasicOpen_surjective (f : R) : Function.Surjective (toBasicOpen R f) := by
   intro s
-  -- In this proof, `basic_open f` will play two distinct roles: Firstly, it is an open set in the
+  -- In this proof, `basicOpen f` will play two distinct roles: Firstly, it is an open set in the
   -- prime spectrum. Secondly, it is used as an indexing type for various families of objects
   -- (open sets, ring elements, ...). In order to make the distinction clear, we introduce a type
   -- alias `ι` that is used whenever we want think of it as an indexing type.
@@ -838,7 +833,7 @@ theorem toBasicOpen_surjective (f : R) : Function.Surjective (toBasicOpen R f) :
   obtain ⟨t, ht_cover'⟩ :=
     (PrimeSpectrum.isCompact_basicOpen f).elim_finite_subcover
       (fun i : ι => PrimeSpectrum.basicOpen (h' i)) (fun i => PrimeSpectrum.isOpen_basicOpen)
-      -- Here, we need to show that our basic opens actually form a cover of `basic_open f`
+      -- Here, we need to show that our basic opens actually form a cover of `basicOpen f`
       fun x hx => by rw [Set.mem_iUnion]; exact ⟨⟨x, hx⟩, hxDh' ⟨x, hx⟩⟩
   simp only [← Opens.coe_iSup, SetLike.coe_subset_coe] at ht_cover'
   -- We use the normalization lemma from above to obtain the relation `a i * h j = h i * a j`
@@ -880,7 +875,7 @@ theorem toBasicOpen_surjective (f : R) : Function.Surjective (toBasicOpen R f) :
       (⟨f ^ (n + 1), n + 1, rfl⟩ : Submonoid.powers _)
   rw [toBasicOpen_mk']
   -- Since the structure sheaf is a sheaf, we can show the desired equality locally.
-  -- Annoyingly, `sheaf.eq_of_locally_eq` requires an open cover indexed by a *type*, so we need to
+  -- Annoyingly, `Sheaf.eq_of_locally_eq'` requires an open cover indexed by a *type*, so we need to
   -- coerce our finset `t` to a type first.
   let tt := ((t : Set (PrimeSpectrum.basicOpen f)) : Type u)
   apply
@@ -922,7 +917,7 @@ instance isIso_toBasicOpen (f : R) :
   isIso_of_reflects_iso _ (forget CommRingCat)
 #align algebraic_geometry.structure_sheaf.is_iso_to_basic_open AlgebraicGeometry.StructureSheaf.isIso_toBasicOpen
 
-/-- The ring isomorphism between the structure sheaf on `basic_open f` and the localization of `R`
+/-- The ring isomorphism between the structure sheaf on `basicOpen f` and the localization of `R`
 at the submonoid of powers of `f`. -/
 def basicOpenIso (f : R) :
     (structureSheaf R).1.obj (op (PrimeSpectrum.basicOpen f)) ≅
@@ -943,7 +938,7 @@ theorem stalkAlgebra_map (p : PrimeSpectrum R) (r : R) :
 /-- Stalk of the structure sheaf at a prime p as localization of R -/
 instance IsLocalization.to_stalk (p : PrimeSpectrum R) :
     IsLocalization.AtPrime ((structureSheaf R).presheaf.stalk p) p.asIdeal := by
-  convert(IsLocalization.isLocalization_iff_of_ringEquiv (S := Localization.AtPrime p.asIdeal) _
+  convert (IsLocalization.isLocalization_iff_of_ringEquiv (S := Localization.AtPrime p.asIdeal) _
           (stalkIso R p).symm.commRingCatIsoToRingEquiv).mp
       Localization.isLocalization
   apply Algebra.algebra_ext
@@ -1066,8 +1061,8 @@ on `U` to a section on `V`, by composing with `Localization.localRingHom _ _ f`
 `comap f` from the right. Explicitly, if `s` evaluates on `comap f p` to `a / b`, its image on `V`
 evaluates on `p` to `f(a) / f(b)`.
 
-At the moment, we work with arbitrary dependent functions `s : Π x : U, localizations R x`. Below,
-we prove the predicate `is_locally_fraction` is preserved by this map, hence it can be extended to
+At the moment, we work with arbitrary dependent functions `s : Π x : U, Localizations R x`. Below,
+we prove the predicate `isLocallyFraction` is preserved by this map, hence it can be extended to
 a morphism between the structure sheaves of `R` and `S`.
 -/
 def comapFun (f : R →+* S) (U : Opens (PrimeSpectrum.Top R)) (V : Opens (PrimeSpectrum.Top S))
chore: banish Type _ and Sort _ (#6499)

We remove all possible occurences of Type _ and Sort _ in favor of Type* and Sort*.

This has nice performance benefits.

Diff
@@ -730,7 +730,7 @@ A local representation of a section `s` as fractions `a i / h i` on finitely man
 `basic_open (h i)` can be "normalized" in such a way that `a i * h j = h i * a j` for all `i, j`
 -/
 theorem normalize_finite_fraction_representation (U : Opens (PrimeSpectrum.Top R))
-    (s : (structureSheaf R).1.obj (op U)) {ι : Type _} (t : Finset ι) (a h : ι → R)
+    (s : (structureSheaf R).1.obj (op U)) {ι : Type*} (t : Finset ι) (a h : ι → R)
     (iDh : ∀ i : ι, PrimeSpectrum.basicOpen (h i) ⟶ U)
     (h_cover : U ≤ ⨆ i ∈ t, PrimeSpectrum.basicOpen (h i))
     (hs :
@@ -1019,13 +1019,13 @@ theorem globalSectionsIso_hom (R : CommRingCat) : (globalSectionsIso R).hom = to
 #align algebraic_geometry.structure_sheaf.global_sections_iso_hom AlgebraicGeometry.StructureSheaf.globalSectionsIso_hom
 
 @[simp, reassoc, elementwise]
-theorem toStalk_stalkSpecializes {R : Type _} [CommRing R] {x y : PrimeSpectrum R} (h : x ⤳ y) :
+theorem toStalk_stalkSpecializes {R : Type*} [CommRing R] {x y : PrimeSpectrum R} (h : x ⤳ y) :
     toStalk R y ≫ (structureSheaf R).presheaf.stalkSpecializes h = toStalk R x := by
   dsimp [toStalk]; simp [-toOpen_germ]
 #align algebraic_geometry.structure_sheaf.to_stalk_stalk_specializes AlgebraicGeometry.StructureSheaf.toStalk_stalkSpecializes
 
 @[simp, reassoc, elementwise]
-theorem localizationToStalk_stalkSpecializes {R : Type _} [CommRing R] {x y : PrimeSpectrum R}
+theorem localizationToStalk_stalkSpecializes {R : Type*} [CommRing R] {x y : PrimeSpectrum R}
     (h : x ⤳ y) :
     StructureSheaf.localizationToStalk R y ≫ (structureSheaf R).presheaf.stalkSpecializes h =
       CommRingCat.ofHom (PrimeSpectrum.localizationMapOfSpecializes h) ≫
@@ -1040,7 +1040,7 @@ set_option linter.uppercaseLean3 false in
 #align algebraic_geometry.structure_sheaf.localizationToStalk_stalk_specializes AlgebraicGeometry.StructureSheaf.localizationToStalk_stalkSpecializes
 
 @[simp, reassoc, elementwise]
-theorem stalkSpecializes_stalk_to_fiber {R : Type _} [CommRing R] {x y : PrimeSpectrum R}
+theorem stalkSpecializes_stalk_to_fiber {R : Type*} [CommRing R] {x y : PrimeSpectrum R}
     (h : x ⤳ y) :
     (structureSheaf R).presheaf.stalkSpecializes h ≫ StructureSheaf.stalkToFiberRingHom R x =
       StructureSheaf.stalkToFiberRingHom R y ≫
chore: fix grammar mistakes (#6121)
Diff
@@ -1183,7 +1183,7 @@ theorem comap_id_eq_map (U V : Opens (PrimeSpectrum.Top R)) (iVU : V ⟶ U) :
 
 /--
 The comap of the identity is the identity. In this variant of the lemma, two open subsets `U` and
-`V` are given as arguments, together with a proof that `U = V`. This is be useful when `U` and `V`
+`V` are given as arguments, together with a proof that `U = V`. This is useful when `U` and `V`
 are not definitionally equal.
 -/
 theorem comap_id (U V : Opens (PrimeSpectrum.Top R)) (hUV : U = V) :
chore: script to replace headers with #align_import statements (#5979)

Open in Gitpod

Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -2,11 +2,6 @@
 Copyright (c) 2020 Scott Morrison. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Johan Commelin, Scott Morrison
-
-! This file was ported from Lean 3 source module algebraic_geometry.structure_sheaf
-! leanprover-community/mathlib commit 5dc6092d09e5e489106865241986f7f2ad28d4c8
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.AlgebraicGeometry.PrimeSpectrum.Basic
 import Mathlib.Algebra.Category.Ring.Colimits
@@ -15,6 +10,8 @@ import Mathlib.Topology.Sheaves.LocalPredicate
 import Mathlib.RingTheory.Localization.AtPrime
 import Mathlib.RingTheory.Subring.Basic
 
+#align_import algebraic_geometry.structure_sheaf from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8"
+
 /-!
 # The structure sheaf on `PrimeSpectrum R`.
 
chore: cleanup whitespace (#5988)

Grepping for [^ .:{-] [^ :] and reviewing the results. Once I started I couldn't stop. :-)

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -557,14 +557,14 @@ theorem stalkToFiberRingHom_germ (U : Opens (PrimeSpectrum.Top R)) (x : U)
 
 @[simp]
 theorem toStalk_comp_stalkToFiberRingHom (x : PrimeSpectrum.Top R) :
-  -- Porting note : now `algebraMap _ _` needs to be  explicitly typed
+  -- Porting note : now `algebraMap _ _` needs to be explicitly typed
     toStalk R x ≫ stalkToFiberRingHom R x = algebraMap R (Localization.AtPrime x.asIdeal) := by
   erw [toStalk, Category.assoc, germ_comp_stalkToFiberRingHom]; rfl
 #align algebraic_geometry.structure_sheaf.to_stalk_comp_stalk_to_fiber_ring_hom AlgebraicGeometry.StructureSheaf.toStalk_comp_stalkToFiberRingHom
 
 @[simp]
 theorem stalkToFiberRingHom_toStalk (x : PrimeSpectrum.Top R) (f : R) :
-  -- Porting note : now `algebraMap _ _` needs to be  explicitly typed
+  -- Porting note : now `algebraMap _ _` needs to be explicitly typed
     stalkToFiberRingHom R x (toStalk R x f) = algebraMap R (Localization.AtPrime x.asIdeal) f :=
   RingHom.ext_iff.1 (toStalk_comp_stalkToFiberRingHom R x) _
 #align algebraic_geometry.structure_sheaf.stalk_to_fiber_ring_hom_to_stalk AlgebraicGeometry.StructureSheaf.stalkToFiberRingHom_toStalk
chore: fix focusing dots (#5708)

This PR is the result of running

find . -type f -name "*.lean" -exec sed -i -E 's/^( +)\. /\1· /' {} \;
find . -type f -name "*.lean" -exec sed -i -E 'N;s/^( +·)\n +(.*)$/\1 \2/;P;D' {} \;

which firstly replaces . focusing dots with · and secondly removes isolated instances of such dots, unifying them with the following line. A new rule is placed in the style linter to verify this.

Diff
@@ -854,7 +854,7 @@ theorem toBasicOpen_surjective (f : R) : Function.Surjective (toBasicOpen R f) :
   rw [← SetLike.coe_subset_coe, Opens.coe_iSup] at ht_cover
   replace ht_cover : (PrimeSpectrum.basicOpen f : Set <| PrimeSpectrum R) ⊆
     ⋃ (i : ι) (x : i ∈ t), (PrimeSpectrum.basicOpen (h i) : Set _)
-  . convert ht_cover using 2
+  · convert ht_cover using 2
     exact funext fun j => by rw [Opens.coe_iSup]
   -- Next we show that some power of `f` is a linear combination of the `h i`
   obtain ⟨n, hn⟩ : f ∈ (Ideal.span (h '' ↑t)).radical := by
@@ -862,9 +862,9 @@ theorem toBasicOpen_surjective (f : R) : Function.Surjective (toBasicOpen R f) :
     -- Porting note : simp with `PrimeSpectrum.basicOpen_eq_zeroLocus_compl` does not work
     replace ht_cover : (PrimeSpectrum.zeroLocus {f})ᶜ ⊆
       ⋃ (i : ι) (x : i ∈ t), (PrimeSpectrum.zeroLocus {h i})ᶜ
-    . convert ht_cover
-      . rw [PrimeSpectrum.basicOpen_eq_zeroLocus_compl]
-      . simp only [Opens.iSup_mk, Opens.carrier_eq_coe, PrimeSpectrum.basicOpen_eq_zeroLocus_compl]
+    · convert ht_cover
+      · rw [PrimeSpectrum.basicOpen_eq_zeroLocus_compl]
+      · simp only [Opens.iSup_mk, Opens.carrier_eq_coe, PrimeSpectrum.basicOpen_eq_zeroLocus_compl]
     rw [Set.compl_subset_comm] at ht_cover
     -- Why doesn't `simp_rw` do this?
     simp_rw [Set.compl_iUnion, compl_compl, ← PrimeSpectrum.zeroLocus_iUnion,
chore: update SHAs after #19153 was reverted (#5712)

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Johan Commelin, Scott Morrison
 
 ! This file was ported from Lean 3 source module algebraic_geometry.structure_sheaf
-! leanprover-community/mathlib commit d39590fc8728fbf6743249802486f8c91ffe07bc
+! leanprover-community/mathlib commit 5dc6092d09e5e489106865241986f7f2ad28d4c8
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
feat: more consistent use of ext, and updating porting notes. (#5242)

Co-authored-by: Scott Morrison <scott.morrison@anu.edu.au>

Diff
@@ -577,6 +577,10 @@ def stalkIso (x : PrimeSpectrum.Top R) :
   hom := stalkToFiberRingHom R x
   inv := localizationToStalk R x
   hom_inv_id :=
+    -- Porting note: We should be able to replace the next two lines with `ext U hxU s`,
+    -- but there seems to be a bug in `ext` whereby
+    -- it will not do multiple introductions for a single lemma, if you name the arguments.
+    -- See https://github.com/leanprover/std4/pull/159
     (structureSheaf R).presheaf.stalk_hom_ext fun U hxU => by
       ext s
       simp only [FunctorToTypes.map_comp_apply, CommRingCat.forget_map,
chore: add links to issue for rw regressions (#5167)

Co-authored-by: Scott Morrison <scott.morrison@anu.edu.au>

Diff
@@ -673,6 +673,7 @@ theorem toBasicOpen_injective (f : R) : Function.Injective (toBasicOpen R f) :=
   have := congr_fun (congr_arg Subtype.val h_eq) ⟨p, hfp⟩
   dsimp at this
   -- Porting note : need to tell Lean what `S` is and need to change to `erw`
+  -- https://github.com/leanprover-community/mathlib4/issues/5164
   erw [IsLocalization.eq (S := Localization.AtPrime p.asIdeal)] at this
   cases' this with r hr
   exact ⟨r.1, hr, r.2⟩
feat: change ConcreteCategory.hasCoeToFun to FunLike (#4693)
Diff
@@ -581,7 +581,7 @@ def stalkIso (x : PrimeSpectrum.Top R) :
       ext s
       simp only [FunctorToTypes.map_comp_apply, CommRingCat.forget_map,
         CommRingCat.coe_of, Category.comp_id]
-      rw [stalkToFiberRingHom_germ']
+      rw [comp_apply, comp_apply, stalkToFiberRingHom_germ']
       obtain ⟨V, hxV, iVU, f, g, (hg : V ≤ PrimeSpectrum.basicOpen _), hs⟩ :=
         exists_const _ _ s x hxU
       erw [← res_apply R U V iVU s ⟨x, hxV⟩, ← hs, const_apply, localizationToStalk_mk']
chore: formatting issues (#4947)

Co-authored-by: Scott Morrison <scott.morrison@anu.edu.au> Co-authored-by: Parcly Taxel <reddeloostw@gmail.com>

Diff
@@ -83,11 +83,11 @@ def Localizations (P : PrimeSpectrum.Top R) : Type u :=
 
 -- Porting note : can't derive `CommRingCat`
 instance CommRingLocalizations (P : PrimeSpectrum.Top R) : CommRing <| Localizations R P :=
-show CommRing <| Localization.AtPrime P.asIdeal from inferInstance
+  show CommRing <| Localization.AtPrime P.asIdeal from inferInstance
 
 -- Porting note : can't derive `LocalRing`
 instance LocalRingLocalizations (P : PrimeSpectrum.Top R) : LocalRing <| Localizations R P :=
-show LocalRing <| Localization.AtPrime P.asIdeal from inferInstance
+  show LocalRing <| Localization.AtPrime P.asIdeal from inferInstance
 
 instance (P : PrimeSpectrum.Top R) : Inhabited (Localizations R P) :=
   ⟨1⟩
@@ -530,7 +530,7 @@ formed by gluing the `open_to_localization` maps. -/
 def stalkToFiberRingHom (x : PrimeSpectrum.Top R) :
     (structureSheaf R).presheaf.stalk x ⟶ CommRingCat.of (Localization.AtPrime x.asIdeal) :=
   Limits.colimit.desc ((OpenNhds.inclusion x).op ⋙ (structureSheaf R).1)
-    { pt:= _
+    { pt := _
       ι := { app := fun U =>
         openToLocalization R ((OpenNhds.inclusion _).obj (unop U)) x (unop U).2 } }
 #align algebraic_geometry.structure_sheaf.stalk_to_fiber_ring_hom AlgebraicGeometry.StructureSheaf.stalkToFiberRingHom
@@ -557,14 +557,14 @@ theorem stalkToFiberRingHom_germ (U : Opens (PrimeSpectrum.Top R)) (x : U)
 
 @[simp]
 theorem toStalk_comp_stalkToFiberRingHom (x : PrimeSpectrum.Top R) :
--- Porting note : now `algebraMap _ _` needs to be  explicitly typed
+  -- Porting note : now `algebraMap _ _` needs to be  explicitly typed
     toStalk R x ≫ stalkToFiberRingHom R x = algebraMap R (Localization.AtPrime x.asIdeal) := by
   erw [toStalk, Category.assoc, germ_comp_stalkToFiberRingHom]; rfl
 #align algebraic_geometry.structure_sheaf.to_stalk_comp_stalk_to_fiber_ring_hom AlgebraicGeometry.StructureSheaf.toStalk_comp_stalkToFiberRingHom
 
 @[simp]
 theorem stalkToFiberRingHom_toStalk (x : PrimeSpectrum.Top R) (f : R) :
--- Porting note : now `algebraMap _ _` needs to be  explicitly typed
+  -- Porting note : now `algebraMap _ _` needs to be  explicitly typed
     stalkToFiberRingHom R x (toStalk R x f) = algebraMap R (Localization.AtPrime x.asIdeal) f :=
   RingHom.ext_iff.1 (toStalk_comp_stalkToFiberRingHom R x) _
 #align algebraic_geometry.structure_sheaf.stalk_to_fiber_ring_hom_to_stalk AlgebraicGeometry.StructureSheaf.stalkToFiberRingHom_toStalk
@@ -684,7 +684,7 @@ Every section can locally be represented on basic opens `basic_opens g` as a fra
 -/
 theorem locally_const_basicOpen (U : Opens (PrimeSpectrum.Top R))
     (s : (structureSheaf R).1.obj (op U)) (x : U) :
-    ∃ (f g : R)(i : PrimeSpectrum.basicOpen g ⟶ U), x.1 ∈ PrimeSpectrum.basicOpen g ∧
+    ∃ (f g : R) (i : PrimeSpectrum.basicOpen g ⟶ U), x.1 ∈ PrimeSpectrum.basicOpen g ∧
       (const R f g (PrimeSpectrum.basicOpen g) fun y hy => hy) =
       (structureSheaf R).1.map i.op s := by
   -- First, any section `s` can be represented as a fraction `f/g` on some open neighborhood of `x`
@@ -735,7 +735,7 @@ theorem normalize_finite_fraction_representation (U : Opens (PrimeSpectrum.Top R
       ∀ i : ι,
         (const R (a i) (h i) (PrimeSpectrum.basicOpen (h i)) fun y hy => hy) =
           (structureSheaf R).1.map (iDh i).op s) :
-    ∃ (a' h' : ι → R)(iDh' : ∀ i : ι, PrimeSpectrum.basicOpen (h' i) ⟶ U),
+    ∃ (a' h' : ι → R) (iDh' : ∀ i : ι, PrimeSpectrum.basicOpen (h' i) ⟶ U),
       (U ≤ ⨆ i ∈ t, PrimeSpectrum.basicOpen (h' i)) ∧
         (∀ (i) (_ : i ∈ t) (j) (_ : j ∈ t), a' i * h' j = h' i * a' j) ∧
           ∀ i ∈ t,
chore: add space after exacts (#4945)

Too often tempted to change these during other PRs, so doing a mass edit here.

Co-authored-by: Scott Morrison <scott.morrison@anu.edu.au>

Diff
@@ -764,7 +764,7 @@ theorem normalize_finite_fraction_representation (U : Opens (PrimeSpectrum.Top R
     all_goals rw [res_const]; apply const_ext; ring
     -- The remaining two goals were generated during the rewrite of `res_const`
     -- These can be solved immediately
-    exacts[PrimeSpectrum.basicOpen_mul_le_right _ _, PrimeSpectrum.basicOpen_mul_le_left _ _]
+    exacts [PrimeSpectrum.basicOpen_mul_le_right _ _, PrimeSpectrum.basicOpen_mul_le_left _ _]
   -- From the equality in the localization, we obtain for each `(i,j)` some power `(h i * h j) ^ n`
   -- which equalizes `a i * h j` and `h i * a j`
   have exists_power :
chore: review of automation in category theory (#4793)

Clean up of automation in the category theory library. Leaving out unnecessary proof steps, or fields done by aesop_cat, and making more use of available autoparameters.

Co-authored-by: Scott Morrison <scott.morrison@anu.edu.au>

Diff
@@ -255,7 +255,7 @@ with the `Type` valued structure presheaf.
 -/
 def structurePresheafCompForget :
     structurePresheafInCommRing R ⋙ forget CommRingCat ≅ (structureSheafInType R).1 :=
-  NatIso.ofComponents (fun U => Iso.refl _) (fun i => by aesop)
+  NatIso.ofComponents fun U => Iso.refl _
 set_option linter.uppercaseLean3 false in
 #align algebraic_geometry.structure_presheaf_comp_forget AlgebraicGeometry.structurePresheafCompForget
 
feat: port AlgebraicGeometry.StructureSheaf (#4522)

Co-authored-by: Jeremy Tan Jie Rui <reddeloostw@gmail.com>

Dependencies 11 + 888

889 files ported (98.8%)
368270 lines ported (98.6%)
Show graph

The unported dependencies are