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

Commit f7825bf

Browse files
feat(algebra/polynomial): big_operators lemmas for polynomials (#3378)
This starts a new folder algebra/polynomial. As we refactor data/polynomial.lean, much of that content should land in this folder. Co-authored-by: Aaron Anderson <awainverse@gmail.com>
1 parent bcf61df commit f7825bf

File tree

2 files changed

+156
-0
lines changed

2 files changed

+156
-0
lines changed

src/algebra/polynomial/basic.lean

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/-
2+
Copyright (c) 2020 Aaron Anderson. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Aaron Anderson, Jalex Stark.
5+
-/
6+
import data.polynomial
7+
open polynomial finset
8+
9+
/-!
10+
# Polynomials
11+
12+
Eventually, much of data/polynomial.lean should land here.
13+
14+
## Main results
15+
16+
We relate `eval` and the constant coefficient map to `aeval`, so we can use `alg_hom` properties.
17+
18+
We define a `monoid_hom` of type `polynomial R →* R`,
19+
under the assumption that `R` is an integral domain.
20+
- `leading_coeff_hom`
21+
-/
22+
23+
universes u w
24+
25+
noncomputable theory
26+
27+
variables {R : Type u} {α : Type w}
28+
29+
namespace polynomial
30+
31+
section comm_semiring
32+
variables [comm_semiring R]
33+
34+
@[simp] lemma coe_aeval_eq_eval (r : R) :
35+
(aeval R R r : polynomial R → R) = eval r := rfl
36+
37+
lemma coeff_zero_eq_aeval_zero (p : polynomial R) : p.coeff 0 = aeval R R 0 p :=
38+
by { rw coeff_zero_eq_eval_zero, rw coe_aeval_eq_eval, }
39+
40+
end comm_semiring
41+
42+
section integral_domain
43+
variable [integral_domain R]
44+
45+
/-- `polynomial.leading_coeff` bundled as a `monoid_hom` when `R` is an `integral_domain`, and thus
46+
`leading_coeff` is multiplicative -/
47+
def leading_coeff_hom : polynomial R →* R :=
48+
{ to_fun := leading_coeff,
49+
map_one' := by simp,
50+
map_mul' := leading_coeff_mul }
51+
52+
@[simp] lemma leading_coeff_hom_apply (p : polynomial R) :
53+
leading_coeff_hom p = leading_coeff p := rfl
54+
55+
end integral_domain
56+
end polynomial
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/-
2+
Copyright (c) 2020 Aaron Anderson. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Aaron Anderson, Jalex Stark.
5+
-/
6+
import algebra.polynomial.basic
7+
open polynomial finset
8+
9+
/-!
10+
# Polynomials
11+
12+
Lemmas for the interaction between polynomials and ∑ and ∏.
13+
14+
## Main results
15+
16+
- `nat_degree_prod_eq_of_monic` : the degree of a product of monic polynomials is the product of
17+
degrees. We prove this only for [comm_semiring R],
18+
but it ought to be true for [semiring R] and list.prod.
19+
- `nat_degree_prod_eq` : for polynomials over an integral domain,
20+
the degree of the product is the sum of degrees
21+
- `leading_coeff_prod` : for polynomials over an integral domain,
22+
the leading coefficient is the product of leading coefficients
23+
-/
24+
25+
open_locale big_operators
26+
27+
universes u w
28+
29+
variables {R : Type u} {α : Type w}
30+
31+
namespace polynomial
32+
33+
variable (s : finset α)
34+
35+
section comm_semiring
36+
variables [comm_semiring R] (f : α → polynomial R)
37+
38+
lemma nat_degree_prod_le : (∏ i in s, f i).nat_degree ≤ ∑ i in s, (f i).nat_degree :=
39+
begin
40+
classical,
41+
induction s using finset.induction with a s ha hs, { simp },
42+
rw [prod_insert ha, sum_insert ha],
43+
transitivity (f a).nat_degree + (∏ (x : α) in s, (f x)).nat_degree,
44+
apply polynomial.nat_degree_mul_le, linarith,
45+
end
46+
47+
/-- The leading coefficient of a product of polynomials is equal to the product of the leading coefficients, provided that this product is nonzero.
48+
See `leading_coeff_prod` (without the `'`) for a version for integral domains, where this condition is automatically satisfied. -/
49+
lemma leading_coeff_prod' (h : ∏ i in s, (f i).leading_coeff ≠ 0) :
50+
(∏ i in s, f i).leading_coeff = ∏ i in s, (f i).leading_coeff :=
51+
begin
52+
classical,
53+
revert h, induction s using finset.induction with a s ha hs, { simp },
54+
repeat { rw prod_insert ha },
55+
intro h, rw polynomial.leading_coeff_mul'; { rwa hs, apply right_ne_zero_of_mul h },
56+
end
57+
58+
/-- The degree of a product of polynomials is equal to the product of the degrees, provided that the product of leading coefficients is nonzero.
59+
See `nat_degree_prod_eq` (without the `'`) for a version for integral domains, where this condition is automatically satisfied. -/
60+
lemma nat_degree_prod_eq' (h : ∏ i in s, (f i).leading_coeff ≠ 0) :
61+
(∏ i in s, f i).nat_degree = ∑ i in s, (f i).nat_degree :=
62+
begin
63+
classical,
64+
revert h, induction s using finset.induction with a s ha hs, { simp },
65+
rw [prod_insert ha, prod_insert ha, sum_insert ha],
66+
intro h, rw polynomial.nat_degree_mul_eq', rw hs,
67+
apply right_ne_zero_of_mul h,
68+
rwa polynomial.leading_coeff_prod', apply right_ne_zero_of_mul h,
69+
end
70+
71+
lemma monic_prod_of_monic :
72+
(∀ a : α, a ∈ s → monic (f a)) → monic (∏ i in s, f i) :=
73+
by { apply prod_induction, apply monic_mul, apply monic_one }
74+
75+
lemma nat_degree_prod_eq_of_monic [nontrivial R] (h : ∀ i : α, i ∈ s → (f i).monic) :
76+
(∏ i in s, f i).nat_degree = ∑ i in s, (f i).nat_degree :=
77+
begin
78+
apply nat_degree_prod_eq',
79+
suffices : ∏ (i : α) in s, (f i).leading_coeff = 1, { rw this, simp },
80+
rw prod_eq_one, intros, apply h, assumption,
81+
end
82+
83+
end comm_semiring
84+
85+
section integral_domain
86+
variables [integral_domain R] (f : α → polynomial R)
87+
88+
lemma nat_degree_prod_eq (h : ∀ i ∈ s, f i ≠ 0) :
89+
(∏ i in s, f i).nat_degree = ∑ i in s, (f i).nat_degree :=
90+
begin
91+
apply nat_degree_prod_eq', rw prod_ne_zero_iff,
92+
intros x hx, simp [h x hx],
93+
end
94+
95+
lemma leading_coeff_prod :
96+
(∏ i in s, f i).leading_coeff = ∏ i in s, (f i).leading_coeff :=
97+
by { rw ← leading_coeff_hom_apply, apply monoid_hom.map_prod }
98+
99+
end integral_domain
100+
end polynomial

0 commit comments

Comments
 (0)