Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 85d9f21

Browse files
pecherskyjcommelin
andcommitted
feat(*): localized R[X] notation for polynomial R (#11895)
I did not change `polynomial (complex_term_here taking args)` in many places because I thought it would be more confusing. Also, in some files that prove things about polynomials incidentally, I also did not include the notation and change the files. Co-authored-by: Johan Commelin <johan@commelin.net>
1 parent 5932581 commit 85d9f21

106 files changed

Lines changed: 1922 additions & 1880 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

archive/100-theorems-list/16_abel_ruffini.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@ Then all that remains is the construction of a specific polynomial satisfying th
2424
namespace abel_ruffini
2525

2626
open function polynomial polynomial.gal ideal
27+
open_locale polynomial
2728

2829
local attribute [instance] splits_ℚ_ℂ
2930

3031
variables (R : Type*) [comm_ring R] (a b : ℕ)
3132

3233
/-- A quintic polynomial that we will show is irreducible -/
33-
noncomputable def Φ : polynomial R := X ^ 5 - C ↑a * X + C ↑b
34+
noncomputable def Φ : R[X] := X ^ 5 - C ↑a * X + C ↑b
3435

3536
variables {R}
3637

src/algebra/algebra/spectrum.lean

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ begin
8585
end
8686

8787
namespace spectrum
88+
open_locale polynomial
8889

8990
section scalar_ring
9091

@@ -134,7 +135,7 @@ begin
134135
rw [h_eq, ←smul_sub, is_unit_smul_iff],
135136
end
136137

137-
open_locale pointwise
138+
open_locale pointwise polynomial
138139

139140
theorem unit_smul_eq_smul (a : A) (r : Rˣ) :
140141
σ (r • a) = r • σ a :=
@@ -247,7 +248,7 @@ open polynomial
247248
/-- Half of the spectral mapping theorem for polynomials. We prove it separately
248249
because it holds over any field, whereas `spectrum.map_polynomial_aeval_of_degree_pos` and
249250
`spectrum.map_polynomial_aeval_of_nonempty` need the field to be algebraically closed. -/
250-
theorem subset_polynomial_aeval (a : A) (p : polynomial 𝕜) :
251+
theorem subset_polynomial_aeval (a : A) (p : 𝕜[X]) :
251252
(λ k, eval k p) '' (σ a) ⊆ σ (aeval a p) :=
252253
begin
253254
rintros _ ⟨k, hk, rfl⟩,
@@ -262,7 +263,7 @@ begin
262263
simpa only [aeval_X, aeval_C, alg_hom.map_sub] using hk,
263264
end
264265

265-
lemma exists_mem_of_not_is_unit_aeval_prod {p : polynomial 𝕜} {a : A} (hp : p ≠ 0)
266+
lemma exists_mem_of_not_is_unit_aeval_prod {p : 𝕜[X]} {a : A} (hp : p ≠ 0)
266267
(h : ¬is_unit (aeval a (multiset.map (λ (x : 𝕜), X - C x) p.roots).prod)) :
267268
∃ k : 𝕜, k ∈ σ a ∧ eval k p = 0 :=
268269
begin
@@ -277,7 +278,7 @@ end
277278
/-- The *spectral mapping theorem* for polynomials. Note: the assumption `degree p > 0`
278279
is necessary in case `σ a = ∅`, for then the left-hand side is `∅` and the right-hand side,
279280
assuming `[nontrivial A]`, is `{k}` where `p = polynomial.C k`. -/
280-
theorem map_polynomial_aeval_of_degree_pos [is_alg_closed 𝕜] (a : A) (p : polynomial 𝕜)
281+
theorem map_polynomial_aeval_of_degree_pos [is_alg_closed 𝕜] (a : A) (p : 𝕜[X])
281282
(hdeg : 0 < degree p) : σ (aeval a p) = (λ k, eval k p) '' (σ a) :=
282283
begin
283284
/- handle the easy direction via `spectrum.subset_polynomial_aeval` -/
@@ -302,7 +303,7 @@ end
302303
/-- In this version of the spectral mapping theorem, we assume the spectrum
303304
is nonempty instead of assuming the degree of the polynomial is positive. Note: the
304305
assumption `[nontrivial A]` is necessary for the same reason as in `spectrum.zero_eq`. -/
305-
theorem map_polynomial_aeval_of_nonempty [is_alg_closed 𝕜] [nontrivial A] (a : A) (p : polynomial 𝕜)
306+
theorem map_polynomial_aeval_of_nonempty [is_alg_closed 𝕜] [nontrivial A] (a : A) (p : 𝕜[X])
306307
(hnon : (σ a).nonempty) : σ (aeval a p) = (λ k, eval k p) '' (σ a) :=
307308
begin
308309
refine or.elim (le_or_gt (degree p) 0) (λ h, _) (map_polynomial_aeval_of_degree_pos a p),

src/algebra/cubic_discriminant.lean

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ noncomputable theory
3939
namespace cubic
4040

4141
open cubic polynomial
42+
open_locale polynomial
4243

4344
variables {R S F K : Type*}
4445

@@ -51,7 +52,7 @@ section basic
5152
variables {P : cubic R} [semiring R]
5253

5354
/-- Convert a cubic polynomial to a polynomial. -/
54-
def to_poly (P : cubic R) : polynomial R := C P.a * X ^ 3 + C P.b * X ^ 2 + C P.c * X + C P.d
55+
def to_poly (P : cubic R) : R[X] := C P.a * X ^ 3 + C P.b * X ^ 2 + C P.c * X + C P.d
5556

5657
/-! ### Coefficients -/
5758

@@ -131,7 +132,7 @@ end coeff
131132
section degree
132133

133134
/-- The equivalence between cubic polynomials and polynomials of degree at most three. -/
134-
@[simps] def equiv : cubic R ≃ {p : polynomial R // p.degree ≤ 3} :=
135+
@[simps] def equiv : cubic R ≃ {p : R[X] // p.degree ≤ 3} :=
135136
{ to_fun := λ P, ⟨P.to_poly, degree_cubic_le⟩,
136137
inv_fun := λ f, ⟨coeff f 3, coeff f 2, coeff f 1, coeff f 0⟩,
137138
left_inv := λ P, by ext; simp only [subtype.coe_mk, coeffs],
@@ -140,7 +141,7 @@ section degree
140141
ext (_ | _ | _ | _ | n); simp only [subtype.coe_mk, coeffs],
141142
have h3 : 3 < n + 4 := by linarith only,
142143
rw [coeff_gt_three _ h3,
143-
(degree_le_iff_coeff_zero (f : polynomial R) 3).mp f.2 _ $ with_bot.coe_lt_coe.mpr h3]
144+
(degree_le_iff_coeff_zero (f : R[X]) 3).mp f.2 _ $ with_bot.coe_lt_coe.mpr h3]
144145
end }
145146

146147
lemma degree (ha : P.a ≠ 0) : P.to_poly.degree = 3 := degree_cubic ha

src/algebra/linear_recurrence.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ properties of eigenvalues and eigenvectors.
3737

3838
noncomputable theory
3939
open finset
40-
open_locale big_operators
40+
open_locale big_operators polynomial
4141

4242
/-- A "linear recurrence relation" over a commutative semiring is given by its
4343
order `n` and `n` coefficients. -/
@@ -183,7 +183,7 @@ variables {α : Type*} [comm_ring α] (E : linear_recurrence α)
183183

184184
/-- The characteristic polynomial of `E` is
185185
`X ^ E.order - ∑ i : fin E.order, (E.coeffs i) * X ^ i`. -/
186-
def char_poly : polynomial α :=
186+
def char_poly : α[X] :=
187187
polynomial.monomial E.order 1 - (∑ i : fin E.order, polynomial.monomial i (E.coeffs i))
188188

189189
/-- The geometric sequence `q^n` is a solution of `E` iff

src/algebra/polynomial/big_operators.lean

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Recall that `∑` and `∏` are notation for `finset.sum` and `finset.prod` resp
2626
open finset
2727
open multiset
2828

29-
open_locale big_operators
29+
open_locale big_operators polynomial
3030

3131
universes u w
3232

@@ -38,21 +38,21 @@ variables (s : finset ι)
3838

3939
section semiring
4040

41-
variables {α : Type*} [semiring α]
41+
variables {S : Type*} [semiring S]
4242

43-
lemma nat_degree_list_sum_le (l : list (polynomial α)) :
43+
lemma nat_degree_list_sum_le (l : list S[X]) :
4444
nat_degree l.sum ≤ (l.map nat_degree).foldr max 0 :=
4545
list.sum_le_foldr_max nat_degree (by simp) nat_degree_add_le _
4646

47-
lemma nat_degree_multiset_sum_le (l : multiset (polynomial α)) :
47+
lemma nat_degree_multiset_sum_le (l : multiset S[X]) :
4848
nat_degree l.sum ≤ (l.map nat_degree).foldr max max_left_comm 0 :=
4949
quotient.induction_on l (by simpa using nat_degree_list_sum_le)
5050

51-
lemma nat_degree_sum_le (f : ι → polynomial α) :
51+
lemma nat_degree_sum_le (f : ι → S[X]) :
5252
nat_degree (∑ i in s, f i) ≤ s.fold max 0 (nat_degree ∘ f) :=
5353
by simpa using nat_degree_multiset_sum_le (s.val.map f)
5454

55-
lemma degree_list_sum_le (l : list (polynomial α)) :
55+
lemma degree_list_sum_le (l : list S[X]) :
5656
degree l.sum ≤ (l.map nat_degree).maximum :=
5757
begin
5858
by_cases h : l.sum = 0,
@@ -68,23 +68,23 @@ begin
6868
simp [h] }
6969
end
7070

71-
lemma nat_degree_list_prod_le (l : list (polynomial α)) :
71+
lemma nat_degree_list_prod_le (l : list S[X]) :
7272
nat_degree l.prod ≤ (l.map nat_degree).sum :=
7373
begin
7474
induction l with hd tl IH,
7575
{ simp },
7676
{ simpa using nat_degree_mul_le.trans (add_le_add_left IH _) }
7777
end
7878

79-
lemma degree_list_prod_le (l : list (polynomial α)) :
79+
lemma degree_list_prod_le (l : list S[X]) :
8080
degree l.prod ≤ (l.map degree).sum :=
8181
begin
8282
induction l with hd tl IH,
8383
{ simp },
8484
{ simpa using (degree_mul_le _ _).trans (add_le_add_left IH _) }
8585
end
8686

87-
lemma coeff_list_prod_of_nat_degree_le (l : list (polynomial α)) (n : ℕ)
87+
lemma coeff_list_prod_of_nat_degree_le (l : list S[X]) (n : ℕ)
8888
(hl : ∀ p ∈ l, nat_degree p ≤ n) :
8989
coeff (list.prod l) (l.length * n) = (l.map (λ p, coeff p n)).prod :=
9090
begin
@@ -111,7 +111,7 @@ end
111111
end semiring
112112

113113
section comm_semiring
114-
variables [comm_semiring R] (f : ι → polynomial R) (t : multiset (polynomial R))
114+
variables [comm_semiring R] (f : ι → R[X]) (t : multiset R[X])
115115

116116
lemma nat_degree_multiset_prod_le :
117117
t.prod.nat_degree ≤ (t.map nat_degree).sum :=
@@ -211,7 +211,7 @@ begin
211211
simpa using coeff_list_prod_of_nat_degree_le _ _ hl
212212
end
213213

214-
lemma coeff_prod_of_nat_degree_le (f : ι → polynomial R) (n : ℕ)
214+
lemma coeff_prod_of_nat_degree_le (f : ι → R[X]) (n : ℕ)
215215
(h : ∀ p ∈ s, nat_degree (f p) ≤ n) :
216216
coeff (∏ i in s, f i) (s.card * n) = ∏ i in s, coeff (f i) n :=
217217
begin
@@ -275,7 +275,7 @@ by simpa using multiset_prod_X_sub_C_coeff_card_pred (s.1.map f) (by simpa using
275275
end comm_ring
276276

277277
section no_zero_divisors
278-
variables [comm_ring R] [no_zero_divisors R] (f : ι → polynomial R) (t : multiset (polynomial R))
278+
variables [comm_ring R] [no_zero_divisors R] (f : ι → R[X]) (t : multiset R[X])
279279

280280
/--
281281
The degree of a product of polynomials is equal to
@@ -292,8 +292,8 @@ begin
292292
intros x hx, simp [h x hx]
293293
end
294294

295-
lemma nat_degree_multiset_prod [nontrivial R] (s : multiset (polynomial R))
296-
(h : (0 : polynomial R) ∉ s) :
295+
lemma nat_degree_multiset_prod [nontrivial R] (s : multiset R[X])
296+
(h : (0 : R[X]) ∉ s) :
297297
nat_degree s.prod = (s.map nat_degree).sum :=
298298
begin
299299
rw nat_degree_multiset_prod',

src/algebra/polynomial/group_ring_action.lean

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ This file contains instances and definitions relating `mul_semiring_action` to `
1717

1818
variables (M : Type*) [monoid M]
1919

20+
open_locale polynomial
2021
namespace polynomial
2122

2223
variables (R : Type*) [semiring R]
@@ -27,7 +28,7 @@ lemma smul_eq_map [mul_semiring_action M R] (m : M) :
2728
((•) m) = map (mul_semiring_action.to_ring_hom M R m) :=
2829
begin
2930
suffices :
30-
distrib_mul_action.to_add_monoid_hom (polynomial R) m =
31+
distrib_mul_action.to_add_monoid_hom R[X] m =
3132
(map_ring_hom (mul_semiring_action.to_ring_hom M R m)).to_add_monoid_hom,
3233
{ ext1 r, exact add_monoid_hom.congr_fun this r, },
3334
ext n r : 2,
@@ -37,7 +38,7 @@ end
3738

3839
variables (M)
3940

40-
noncomputable instance [mul_semiring_action M R] : mul_semiring_action M (polynomial R) :=
41+
noncomputable instance [mul_semiring_action M R] : mul_semiring_action M R[X] :=
4142
{ smul := (•),
4243
smul_one := λ m, (smul_eq_map R m).symm ▸ map_one (mul_semiring_action.to_ring_hom M R m),
4344
smul_mul := λ m p q, (smul_eq_map R m).symm ▸ map_mul (mul_semiring_action.to_ring_hom M R m),
@@ -47,12 +48,12 @@ variables {M R}
4748

4849
variables [mul_semiring_action M R]
4950

50-
@[simp] lemma smul_X (m : M) : (m • X : polynomial R) = X :=
51+
@[simp] lemma smul_X (m : M) : (m • X : R[X]) = X :=
5152
(smul_eq_map R m).symm ▸ map_X _
5253

5354
variables (S : Type*) [comm_semiring S] [mul_semiring_action M S]
5455

55-
theorem smul_eval_smul (m : M) (f : polynomial S) (x : S) :
56+
theorem smul_eval_smul (m : M) (f : S[X]) (x : S) :
5657
(m • f).eval (m • x) = m • f.eval x :=
5758
polynomial.induction_on f
5859
(λ r, by rw [smul_C, eval_C, eval_C])
@@ -62,11 +63,11 @@ polynomial.induction_on f
6263

6364
variables (G : Type*) [group G]
6465

65-
theorem eval_smul' [mul_semiring_action G S] (g : G) (f : polynomial S) (x : S) :
66+
theorem eval_smul' [mul_semiring_action G S] (g : G) (f : S[X]) (x : S) :
6667
f.eval (g • x) = g • (g⁻¹ • f).eval x :=
6768
by rw [← smul_eval_smul, smul_inv_smul]
6869

69-
theorem smul_eval [mul_semiring_action G S] (g : G) (f : polynomial S) (x : S) :
70+
theorem smul_eval [mul_semiring_action G S] (g : G) (f : S[X]) (x : S) :
7071
(g • f).eval x = g • f.eval (g⁻¹ • x) :=
7172
by rw [← smul_eval_smul, smul_inv_smul]
7273

@@ -80,7 +81,7 @@ open mul_action
8081
open_locale classical
8182

8283
/-- the product of `(X - g • x)` over distinct `g • x`. -/
83-
noncomputable def prod_X_sub_smul (x : R) : polynomial R :=
84+
noncomputable def prod_X_sub_smul (x : R) : R[X] :=
8485
(finset.univ : finset (G ⧸ mul_action.stabilizer G x)).prod $
8586
λ g, polynomial.X - polynomial.C (of_quotient_stabilizer G x g)
8687

@@ -89,7 +90,7 @@ polynomial.monic_prod_of_monic _ _ $ λ g _, polynomial.monic_X_sub_C _
8990

9091
theorem prod_X_sub_smul.eval (x : R) : (prod_X_sub_smul G R x).eval x = 0 :=
9192
(monoid_hom.map_prod
92-
((polynomial.aeval x).to_ring_hom.to_monoid_hom : polynomial R →* R) _ _).trans $
93+
((polynomial.aeval x).to_ring_hom.to_monoid_hom : R[X] →* R) _ _).trans $
9394
finset.prod_eq_zero (finset.mem_univ $ quotient_group.mk 1) $
9495
by simp
9596

@@ -112,7 +113,7 @@ variables {Q : Type*} [comm_semiring Q] [mul_semiring_action M Q]
112113
open polynomial
113114

114115
/-- An equivariant map induces an equivariant map on polynomials. -/
115-
protected noncomputable def polynomial (g : P →+*[M] Q) : polynomial P →+*[M] polynomial Q :=
116+
protected noncomputable def polynomial (g : P →+*[M] Q) : P[X] →+*[M] Q[X] :=
116117
{ to_fun := map g,
117118
map_smul' := λ m p, polynomial.induction_on p
118119
(λ b, by rw [smul_C, map_C, coe_fn_coe, g.map_smul, map_C, coe_fn_coe, smul_C])
@@ -126,7 +127,7 @@ protected noncomputable def polynomial (g : P →+*[M] Q) : polynomial P →+*[M
126127
map_mul' := λ p q, polynomial.map_mul g }
127128

128129
@[simp] theorem coe_polynomial (g : P →+*[M] Q) :
129-
(g.polynomial : polynomial Ppolynomial Q) = map g :=
130+
(g.polynomial : P[X]Q[X]) = map g :=
130131
rfl
131132

132133
end mul_semiring_action_hom

src/algebraic_geometry/prime_spectrum/is_open_comap_C.lean

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ https://stacks.math.columbia.edu/tag/00FB
1414
-/
1515

1616
open ideal polynomial prime_spectrum set
17+
open_locale polynomial
1718

1819
namespace algebraic_geometry
1920

2021
namespace polynomial
2122

22-
variables {R : Type*} [comm_ring R] {f : polynomial R}
23+
variables {R : Type*} [comm_ring R] {f : R[X]}
2324

2425
/-- Given a polynomial `f ∈ R[x]`, `image_of_Df` is the subset of `Spec R` where at least one
2526
of the coefficients of `f` does not vanish. Lemma `image_of_Df_eq_comap_C_compl_zero_locus`
@@ -37,15 +38,15 @@ end
3738
/-- If a point of `Spec R[x]` is not contained in the vanishing set of `f`, then its image in
3839
`Spec R` is contained in the open set where at least one of the coefficients of `f` is non-zero.
3940
This lemma is a reformulation of `exists_coeff_not_mem_C_inverse`. -/
40-
lemma comap_C_mem_image_of_Df {I : prime_spectrum (polynomial R)}
41-
(H : I ∈ (zero_locus {f} : set (prime_spectrum (polynomial R)))ᶜ ) :
42-
prime_spectrum.comap (polynomial.C : R →+* polynomial R) I ∈ image_of_Df f :=
41+
lemma comap_C_mem_image_of_Df {I : prime_spectrum R[X]}
42+
(H : I ∈ (zero_locus {f} : set (prime_spectrum R[X]))ᶜ ) :
43+
prime_spectrum.comap (polynomial.C : R →+* R[X]) I ∈ image_of_Df f :=
4344
exists_coeff_not_mem_C_inverse (mem_compl_zero_locus_iff_not_mem.mp H)
4445

4546
/-- The open set `image_of_Df f` coincides with the image of `basic_open f` under the
4647
morphism `C⁺ : Spec R[x] → Spec R`. -/
4748
lemma image_of_Df_eq_comap_C_compl_zero_locus :
48-
image_of_Df f = prime_spectrum.comap (C : R →+* polynomial R) '' (zero_locus {f})ᶜ :=
49+
image_of_Df f = prime_spectrum.comap (C : R →+* R[X]) '' (zero_locus {f})ᶜ :=
4950
begin
5051
refine ext (λ x, ⟨λ hx, ⟨⟨map C x.val, (is_prime_map_C_of_is_prime x.property)⟩, ⟨_, _⟩⟩, _⟩),
5152
{ rw [mem_compl_eq, mem_zero_locus, singleton_subset_iff],
@@ -64,7 +65,7 @@ Stacks Project "Lemma 00FB", first part.
6465
https://stacks.math.columbia.edu/tag/00FB
6566
-/
6667
theorem is_open_map_comap_C :
67-
is_open_map (prime_spectrum.comap (C : R →+* polynomial R)) :=
68+
is_open_map (prime_spectrum.comap (C : R →+* R[X])) :=
6869
begin
6970
rintros U ⟨s, z⟩,
7071
rw [← compl_compl U, ← z, ← Union_of_singleton_coe s, zero_locus_Union, compl_Inter, image_Union],

src/analysis/calculus/deriv.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ See the explanations there.
8383

8484
universes u v w
8585
noncomputable theory
86-
open_locale classical topological_space big_operators filter ennreal
86+
open_locale classical topological_space big_operators filter ennreal polynomial
8787
open filter asymptotics set
8888
open continuous_linear_map (smul_right smul_right_one_eq_iff)
8989

@@ -1774,7 +1774,7 @@ namespace polynomial
17741774
/-! ### Derivative of a polynomial -/
17751775

17761776
variables {x : 𝕜} {s : set 𝕜}
1777-
variable (p : polynomial 𝕜)
1777+
variable (p : 𝕜[X])
17781778

17791779
/-- The derivative (in the analysis sense) of a polynomial `p` is given by `p.derivative`. -/
17801780
protected lemma has_strict_deriv_at (x : 𝕜) :

src/analysis/calculus/local_extr.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ local extremum, Fermat's Theorem, Rolle's Theorem
6565
universes u v
6666

6767
open filter set
68-
open_locale topological_space classical
68+
open_locale topological_space classical polynomial
6969

7070
section module
7171

@@ -357,7 +357,7 @@ end Rolle
357357

358358
namespace polynomial
359359

360-
lemma card_root_set_le_derivative {F : Type*} [field F] [algebra F ℝ] (p : polynomial F) :
360+
lemma card_root_set_le_derivative {F : Type*} [field F] [algebra F ℝ] (p : F[X]) :
361361
fintype.card (p.root_set ℝ) ≤ fintype.card (p.derivative.root_set ℝ) + 1 :=
362362
begin
363363
haveI : char_zero F :=

0 commit comments

Comments
 (0)