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

Commit f55e3ce

Browse files
urkudbryangingechenmergify[bot]
authored
refactor(*): move algebra below polynomial in the import chain (#2294)
* Move `algebra` below `polynomial` in the `import` chain This PR only moves code and slightly generalizes `mv_polynomial.aeval`. * Fix compile * Update src/data/mv_polynomial.lean * Apply suggestions from code review * Apply suggestions from code review Co-Authored-By: Bryan Gin-ge Chen <bryangingechen@gmail.com> Co-authored-by: Bryan Gin-ge Chen <bryangingechen@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 652fc17 commit f55e3ce

File tree

7 files changed

+87
-89
lines changed

7 files changed

+87
-89
lines changed

src/analysis/calculus/deriv.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Copyright (c) 2019 Gabriel Ebner. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Gabriel Ebner, Sébastien Gouëzel
55
-/
6-
import analysis.calculus.fderiv
6+
import analysis.calculus.fderiv data.polynomial
77

88
/-!
99

src/data/mv_polynomial.lean

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,48 @@ eval₂.is_ring_hom _ _
931931

932932
end map
933933

934+
section aeval
935+
936+
/-- The algebra of multivariate polynomials. -/
937+
instance mv_polynomial (R : Type u) [comm_ring R]
938+
(σ : Type v) : algebra R (mv_polynomial σ R) :=
939+
{ to_fun := mv_polynomial.C,
940+
commutes' := λ _ _, mul_comm _ _,
941+
smul_def' := λ c p, (mv_polynomial.C_mul' c p).symm,
942+
.. mv_polynomial.module }
943+
944+
variables (R : Type u) (A : Type v) (f : σ → A)
945+
variables [comm_ring R] [comm_ring A] [algebra R A]
946+
947+
/-- A map `σ → A` where `A` is an algebra over `R` generates an `R`-algebra homomorphism
948+
from multivariate polynomials over `σ` to `A`. -/
949+
def aeval : mv_polynomial σ R →ₐ[R] A :=
950+
{ commutes' := λ r, eval₂_C _ _ _
951+
..ring_hom.of (eval₂ (algebra_map A) f) }
952+
953+
theorem aeval_def (p : mv_polynomial σ R) : aeval R A f p = eval₂ (algebra_map A) f p := rfl
954+
955+
@[simp] lemma aeval_X (s : σ) : aeval R A f (X s) = f s := eval₂_X _ _ _
956+
957+
@[simp] lemma aeval_C (r : R) : aeval R A f (C r) = algebra_map A r := eval₂_C _ _ _
958+
959+
instance aeval.is_ring_hom : is_ring_hom (aeval R A f) :=
960+
by apply_instance
961+
962+
theorem eval_unique (φ : mv_polynomial σ R →ₐ[R] A) :
963+
φ = aeval R A (φ ∘ X) :=
964+
begin
965+
ext p,
966+
apply mv_polynomial.induction_on p,
967+
{ intro r, rw aeval_C, exact φ.commutes r },
968+
{ intros f g ih1 ih2,
969+
rw [φ.map_add, ih1, ih2, alg_hom.map_add] },
970+
{ intros p j ih,
971+
rw [φ.map_mul, alg_hom.map_mul, aeval_X, ih] }
972+
end
973+
974+
end aeval
975+
934976
end comm_ring
935977

936978
section rename

src/data/polynomial.lean

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Authors: Chris Hughes, Johannes Hölzl, Scott Morrison, Jens Wagemaker
55
66
Theory of univariate polynomials, represented as `add_monoid_algebra α ℕ`, where α is a commutative semiring.
77
-/
8-
import data.monoid_algebra
8+
import data.monoid_algebra ring_theory.algebra
99
import algebra.gcd_domain ring_theory.euclidean_domain ring_theory.multiplicity
1010
import tactic.ring_exp
1111

@@ -1347,6 +1347,46 @@ is_ring_hom.map_neg _
13471347
@[simp] lemma eval_sub (p q : polynomial α) (x : α) : (p - q).eval x = p.eval x - q.eval x :=
13481348
is_ring_hom.map_sub _
13491349

1350+
section aeval
1351+
/-- `R[X]` is the generator of the category `R-Alg`. -/
1352+
instance polynomial (R : Type u) [comm_ring R] : algebra R (polynomial R) :=
1353+
{ to_fun := polynomial.C,
1354+
commutes' := λ _ _, mul_comm _ _,
1355+
smul_def' := λ c p, (polynomial.C_mul' c p).symm,
1356+
.. polynomial.module }
1357+
1358+
variables (R : Type u) (A : Type v)
1359+
variables [comm_ring R] [comm_ring A] [algebra R A]
1360+
variables (x : A)
1361+
1362+
/-- Given a valuation `x` of the variable in an `R`-algebra `A`, `aeval R A x` is
1363+
the unique `R`-algebra homomorphism from `R[X]` to `A` sending `X` to `x`. -/
1364+
def aeval : polynomial R →ₐ[R] A :=
1365+
{ commutes' := λ r, eval₂_C _ _,
1366+
..ring_hom.of (eval₂ (algebra_map A) x) }
1367+
1368+
theorem aeval_def (p : polynomial R) : aeval R A x p = eval₂ (algebra_map A) x p := rfl
1369+
1370+
@[simp] lemma aeval_X : aeval R A x X = x := eval₂_X _ x
1371+
1372+
@[simp] lemma aeval_C (r : R) : aeval R A x (C r) = algebra_map A r := eval₂_C _ x
1373+
1374+
instance aeval.is_ring_hom : is_ring_hom (aeval R A x) :=
1375+
by apply_instance
1376+
1377+
theorem eval_unique (φ : polynomial R →ₐ[R] A) (p) :
1378+
φ p = eval₂ (algebra_map A) (φ X) p :=
1379+
begin
1380+
apply polynomial.induction_on p,
1381+
{ intro r, rw eval₂_C, exact φ.commutes r },
1382+
{ intros f g ih1 ih2,
1383+
rw [is_ring_hom.map_add φ, ih1, ih2, eval₂_add] },
1384+
{ intros n r ih,
1385+
rw [pow_succ', ← mul_assoc, is_ring_hom.map_mul φ, eval₂_mul (algebra_map A : R → A), eval₂_X, ih] }
1386+
end
1387+
1388+
end aeval
1389+
13501390
lemma degree_sub_lt (hd : degree p = degree q)
13511391
(hp0 : p ≠ 0) (hlc : leading_coeff p = leading_coeff q) :
13521392
degree (p - q) < degree p :=

src/ring_theory/adjoin.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ begin
7070
end
7171

7272
theorem adjoin_eq_range [decidable_eq R] [decidable_eq A] :
73-
adjoin R s = (mv_polynomial.aeval R A s).range :=
73+
adjoin R s = (mv_polynomial.aeval R A (coe : s → A)).range :=
7474
le_antisymm
7575
(adjoin_le $ λ x hx, ⟨mv_polynomial.X ⟨x, hx⟩, mv_polynomial.eval₂_X _ _ _⟩)
7676
(λ x ⟨p, hp⟩, hp ▸ mv_polynomial.induction_on p

src/ring_theory/algebra.lean

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ Authors: Kenny Lau
66
Algebra over Commutative Ring (under category)
77
-/
88

9-
import data.polynomial data.mv_polynomial
109
import data.complex.basic
1110
import data.matrix.basic
1211
import linear_algebra.tensor_product
@@ -103,21 +102,6 @@ by rw [smul_def, smul_def, left_comm]
103102
(r • x) * y = r • (x * y) :=
104103
by rw [smul_def, smul_def, mul_assoc]
105104

106-
/-- R[X] is the generator of the category R-Alg. -/
107-
instance polynomial (R : Type u) [comm_ring R] : algebra R (polynomial R) :=
108-
{ to_fun := polynomial.C,
109-
commutes' := λ _ _, mul_comm _ _,
110-
smul_def' := λ c p, (polynomial.C_mul' c p).symm,
111-
.. polynomial.module }
112-
113-
/-- The algebra of multivariate polynomials. -/
114-
instance mv_polynomial (R : Type u) [comm_ring R]
115-
(ι : Type v) : algebra R (mv_polynomial ι R) :=
116-
{ to_fun := mv_polynomial.C,
117-
commutes' := λ _ _, mul_comm _ _,
118-
smul_def' := λ c p, (mv_polynomial.C_mul' c p).symm,
119-
.. mv_polynomial.module }
120-
121105
/-- Creating an algebra from a subring. This is the dual of ring extension. -/
122106
instance of_subring (S : set R) [is_subring S] : algebra S R :=
123107
of_ring_hom subtype.val ⟨rfl, λ _ _, rfl, λ _ _, rfl⟩
@@ -319,74 +303,6 @@ def comap : algebra.comap R S A →ₐ[R] algebra.comap R S B :=
319303

320304
end alg_hom
321305

322-
namespace polynomial
323-
324-
variables (R : Type u) (A : Type v)
325-
variables [comm_ring R] [comm_ring A] [algebra R A]
326-
variables (x : A)
327-
328-
/-- A → Hom[R-Alg](R[X],A) -/
329-
def aeval : polynomial R →ₐ[R] A :=
330-
{ commutes' := λ r, eval₂_C _ _,
331-
..ring_hom.of (eval₂ (algebra_map A) x) }
332-
333-
theorem aeval_def (p : polynomial R) : aeval R A x p = eval₂ (algebra_map A) x p := rfl
334-
335-
@[simp] lemma aeval_X : aeval R A x X = x := eval₂_X _ x
336-
337-
@[simp] lemma aeval_C (r : R) : aeval R A x (C r) = algebra_map A r := eval₂_C _ x
338-
339-
instance aeval.is_ring_hom : is_ring_hom (aeval R A x) :=
340-
by apply_instance
341-
342-
theorem eval_unique (φ : polynomial R →ₐ[R] A) (p) :
343-
φ p = eval₂ (algebra_map A) (φ X) p :=
344-
begin
345-
apply polynomial.induction_on p,
346-
{ intro r, rw eval₂_C, exact φ.commutes r },
347-
{ intros f g ih1 ih2,
348-
rw [is_ring_hom.map_add φ, ih1, ih2, eval₂_add] },
349-
{ intros n r ih,
350-
rw [pow_succ', ← mul_assoc, is_ring_hom.map_mul φ, eval₂_mul (algebra_map A : R → A), eval₂_X, ih] }
351-
end
352-
353-
end polynomial
354-
355-
namespace mv_polynomial
356-
357-
variables (R : Type u) (A : Type v)
358-
variables [comm_ring R] [comm_ring A] [algebra R A]
359-
variables (σ : set A)
360-
361-
/-- (ι → A) → Hom[R-Alg](R[ι],A) -/
362-
def aeval : mv_polynomial σ R →ₐ[R] A :=
363-
{ commutes' := λ r, eval₂_C _ _ _
364-
..ring_hom.of (eval₂ (algebra_map A) subtype.val) }
365-
366-
theorem aeval_def (p : mv_polynomial σ R) : aeval R A σ p = eval₂ (algebra_map A) subtype.val p := rfl
367-
368-
@[simp] lemma aeval_X (s : σ) : aeval R A σ (X s) = s := eval₂_X _ _ _
369-
370-
@[simp] lemma aeval_C (r : R) : aeval R A σ (C r) = algebra_map A r := eval₂_C _ _ _
371-
372-
instance aeval.is_ring_hom : is_ring_hom (aeval R A σ) :=
373-
by apply_instance
374-
375-
variables (ι : Type w)
376-
377-
theorem eval_unique (φ : mv_polynomial ι R →ₐ[R] A) (p) :
378-
φ p = eval₂ (algebra_map A) (φ ∘ X) p :=
379-
begin
380-
apply mv_polynomial.induction_on p,
381-
{ intro r, rw eval₂_C, exact φ.commutes r },
382-
{ intros f g ih1 ih2,
383-
rw [is_ring_hom.map_add φ, ih1, ih2, eval₂_add] },
384-
{ intros p j ih,
385-
rw [is_ring_hom.map_mul φ, eval₂_mul, eval₂_X, ih] }
386-
end
387-
388-
end mv_polynomial
389-
390306
namespace rat
391307

392308
instance algebra_rat {α} [division_ring α] [char_zero α] : algebra ℚ α :=

src/ring_theory/algebra_operations.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Authors: Kenny Lau
66
Multiplication and division of submodules of an algebra.
77
-/
88

9-
import ring_theory.algebra algebra.pointwise
9+
import ring_theory.algebra ring_theory.ideals algebra.pointwise
1010
import tactic.chain
1111
import tactic.monotonicity.basic
1212

src/ring_theory/free_comm_ring.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Kenny Lau, Johan Commelin
55
-/
66

7-
import group_theory.free_abelian_group data.equiv.functor data.polynomial
7+
import group_theory.free_abelian_group data.equiv.functor data.mv_polynomial
88
import ring_theory.ideal_operations ring_theory.free_ring
99

1010
noncomputable theory

0 commit comments

Comments
 (0)