Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - refactor(polynomial/*): make polynomials irreducible #7421

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0b4a650
first file
sgouezel Apr 10, 2021
aacda4f
progress
sgouezel Apr 11, 2021
c8e40cc
staging
sgouezel Apr 13, 2021
c2f1433
fix eval
sgouezel Apr 13, 2021
748622d
trailing_degree
sgouezel Apr 13, 2021
d06c72c
merge master
sgouezel Apr 29, 2021
d98cadb
fix breakage from update
sgouezel Apr 29, 2021
95c50d6
add a handy lemma on card le one
sgouezel Apr 29, 2021
4ca9b91
fix derivative
sgouezel Apr 29, 2021
33ad5ec
fix erase_lead
sgouezel Apr 29, 2021
284f68f
fix reverse
sgouezel Apr 29, 2021
c5d4a15
fix polynomial_algebra
sgouezel Apr 29, 2021
4236687
fix
sgouezel Apr 29, 2021
a46f38b
fix div
sgouezel Apr 29, 2021
f25e8c2
fixes
sgouezel Apr 29, 2021
ab27564
fix integral_closure
sgouezel Apr 29, 2021
12bfc3f
further fixes
sgouezel Apr 29, 2021
efbe26b
more fixes
sgouezel Apr 30, 2021
c2c995f
style
sgouezel Apr 30, 2021
3d0e2e9
long line
sgouezel Apr 30, 2021
4155669
remove simp attribute
sgouezel Apr 30, 2021
bbf99e7
move to the right place
sgouezel Apr 30, 2021
83e6913
merge other branch
sgouezel Apr 30, 2021
11efc6a
Merge remote-tracking branch 'upstream/master' into polynomial_irreduc
sgouezel Apr 30, 2021
9babc62
lint
sgouezel Apr 30, 2021
3f4a718
lint again
sgouezel Apr 30, 2021
9fd237f
merge master
sgouezel May 3, 2021
4b110d8
fix build
sgouezel May 3, 2021
afa39c7
make 0 semireducible again
sgouezel May 5, 2021
26cd4cd
Merge remote-tracking branch 'upstream/master' into polynomial_irreduc
sgouezel May 5, 2021
be1c7a1
cleanup from semireducibility of 0
sgouezel May 5, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/data/mv_polynomial/basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ by rw [X_pow_eq_single, monomial, monomial, monomial, single_mul_single]; simp
lemma monomial_single_add : monomial (single n e + s) a = (X n ^ e * monomial s a) :=
by rw [X_pow_eq_single, monomial, monomial, monomial, single_mul_single]; simp

lemma single_eq_C_mul_X {s : σ} {a : R} {n : ℕ} :
lemma monomial_eq_C_mul_X {s : σ} {a : R} {n : ℕ} :
monomial (single s n) a = C a * (X s)^n :=
by rw [← zero_add (single s n), monomial_add_single, C_apply]

Expand All @@ -218,7 +218,7 @@ add_monoid_algebra.single_mul_single
@[simp] lemma monomial_zero {s : σ →₀ ℕ}: monomial s (0 : R) = 0 :=
single_zero

@[simp] lemma sum_monomial {A : Type*} [add_comm_monoid A]
@[simp] lemma sum_monomial_eq {A : Type*} [add_comm_monoid A]
{u : σ →₀ ℕ} {r : R} {b : (σ →₀ ℕ) → R → A} (w : b u 0 = 0) :
sum (monomial u r) b = b u r :=
sum_single_index w
Expand Down
2 changes: 1 addition & 1 deletion src/data/mv_polynomial/pderiv.lean
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def pderiv (i : σ) : mv_polynomial σ R →ₗ[R] mv_polynomial σ R :=
@[simp]
lemma pderiv_monomial {i : σ} :
pderiv i (monomial s a) = monomial (s - single i 1) (a * (s i)) :=
by simp only [pderiv, monomial_zero, sum_monomial, zero_mul, linear_map.coe_mk]
by simp only [pderiv, monomial_zero, sum_monomial_eq, zero_mul, linear_map.coe_mk]


@[simp]
Expand Down
31 changes: 24 additions & 7 deletions src/data/polynomial/algebra_map.lean
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,20 @@ variables [comm_semiring R] {p q r : polynomial R}
variables [semiring A] [algebra R A]

/-- Note that this instance also provides `algebra R (polynomial R)`. -/
instance algebra_of_algebra : algebra R (polynomial A) := add_monoid_algebra.algebra
instance algebra_of_algebra : algebra R (polynomial A) :=
{ smul_def' := λ r p, begin
rcases p,
simp only [C, monomial, monomial_fun, ring_hom.coe_mk, ring_hom.to_fun_eq_coe,
function.comp_app, ring_hom.coe_comp, smul_to_finsupp, mul_to_finsupp],
exact algebra.smul_def' _ _,
end,
commutes' := λ r p, begin
rcases p,
simp only [C, monomial, monomial_fun, ring_hom.coe_mk, ring_hom.to_fun_eq_coe,
function.comp_app, ring_hom.coe_comp, mul_to_finsupp],
convert algebra.commutes' r p,
end,
.. C.comp (algebra_map R A) }

lemma algebra_map_apply (r : R) :
algebra_map R (polynomial A) r = C (algebra_map R A r) :=
Expand Down Expand Up @@ -62,7 +75,7 @@ lemma alg_hom_eval₂_algebra_map
(p : polynomial R) (f : A →ₐ[R] B) (a : A) :
f (eval₂ (algebra_map R A) a p) = eval₂ (algebra_map R B) (f a) p :=
begin
dsimp [eval₂, finsupp.sum],
dsimp [eval₂, sum],
simp only [f.map_sum, f.map_mul, f.map_pow, ring_hom.eq_int_cast, ring_hom.map_int_cast,
alg_hom.commutes],
end
Expand All @@ -73,7 +86,7 @@ lemma eval₂_algebra_map_X {R A : Type*} [comm_ring R] [ring A] [algebra R A]
eval₂ (algebra_map R A) (f X) p = f p :=
begin
conv_rhs { rw [←polynomial.sum_C_mul_X_eq p], },
dsimp [eval₂, finsupp.sum],
dsimp [eval₂, sum],
simp only [f.map_sum, f.map_mul, f.map_pow, ring_hom.eq_int_cast, ring_hom.map_int_cast],
simp [polynomial.C_eq_algebra_map],
end
Expand Down Expand Up @@ -108,7 +121,11 @@ def aeval : polynomial R →ₐ[R] A :=
variables {R A}

@[ext] lemma alg_hom_ext {f g : polynomial R →ₐ[R] A} (h : f X = g X) : f = g :=
by { ext, exact h }
begin
ext p,
rw [← sum_monomial_eq p],
simp [sum, f.map_sum, g.map_sum, monomial_eq_smul_X, h],
end

theorem aeval_def (p : polynomial R) : aeval x p = eval₂ (algebra_map R A) x p := rfl

Expand Down Expand Up @@ -212,15 +229,15 @@ begin
by_cases hf : f = 0,
{ simp [hf] },
by_cases hi : i ∈ f.support,
{ rw [eval, eval₂, sum_def] at dvd_eval,
{ rw [eval, eval₂, sum] at dvd_eval,
rw [←finset.insert_erase hi, finset.sum_insert (finset.not_mem_erase _ _)] at dvd_eval,
refine (dvd_add_left _).mp dvd_eval,
apply finset.dvd_sum,
intros j hj,
exact dvd_terms j (finset.ne_of_mem_erase hj) },
{ convert dvd_zero p,
convert _root_.zero_mul _,
exact finsupp.not_mem_support_iff.mp hi }
rw not_mem_support_iff at hi,
simp [hi] }
end

lemma dvd_term_of_is_root_of_dvd_terms {r p : S} {f : polynomial S} (i : ℕ)
Expand Down