fact
stringlengths
8
1.54k
type
stringclasses
19 values
library
stringclasses
8 values
imports
listlengths
1
10
filename
stringclasses
98 values
symbolic_name
stringlengths
1
42
docstring
stringclasses
1 value
size_mulp q : p != 0 -> q != 0 -> size (p * q) = (size p + size q).-1. Proof. by move=> nz_p nz_q; rewrite -size_proper_mul ?mulf_neq0 ?lead_coef_eq0. Qed. Fact poly_idomainAxiom p q : p * q = 0 -> (p == 0) || (q == 0). Proof. move=> pq0; apply/norP=> [[p_nz q_nz]]; move/eqP: (size_mul p_nz q_nz). by rewrite eq_sym pq0 size_poly0 (polySpred p_nz) (polySpred q_nz) addnS. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
size_mul
poly_unit: pred {poly R} := fun p => (size p == 1) && (p`_0 \in GRing.unit).
Definition
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
poly_unit
poly_invp := if p \in poly_unit then (p`_0)^-1%:P else p. Fact poly_mulVp : {in poly_unit, left_inverse 1 poly_inv *%R}. Proof. move=> p Up; rewrite /poly_inv Up. by case/andP: Up => /size_poly1P[c _ ->]; rewrite coefC -polyCM => /mulVr->. Qed. Fact poly_intro_unit p q : q * p = 1 -> p \in poly_unit. Proof. move=> pq1; apply/andP; split; last first. apply/unitrP; exists q`_0. by rewrite 2!mulrC -!/(coefp 0 _) -rmorphM pq1 rmorph1. have: size (q * p) == 1 by rewrite pq1 size_poly1. have [-> | nz_p] := eqVneq p 0; first by rewrite mulr0 size_poly0. have [-> | nz_q] := eqVneq q 0; first by rewrite mul0r size_poly0. rewrite size_mul // (polySpred nz_p) (polySpred nz_q) addnS addSn !eqSS. by rewrite addn_eq0 => /andP[]. Qed. Fact poly_inv_out : {in [predC poly_unit], poly_inv =1 id}. Proof. by rewrite /poly_inv => p /negbTE/= ->. Qed. HB.instance Definition _ := GRing.ComNzRing_hasMulInverse.Build (polynomial R) poly_mulVp poly_intro_unit poly_inv_out. HB.instance Definition _ := GRing.ComUnitRing_isIntegral.Build (polynomial R) poly_idomainAxiom.
Definition
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
poly_inv
poly_unitEp : (p \in GRing.unit) = (size p == 1) && (p`_0 \in GRing.unit). Proof. by []. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
poly_unitE
poly_invEp : p ^-1 = if p \in GRing.unit then (p`_0)^-1%:P else p. Proof. by []. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
poly_invE
polyCVc : c%:P^-1 = (c^-1)%:P. Proof. have [/rmorphV-> // | nUc] := boolP (c \in GRing.unit). by rewrite !invr_out // poly_unitE coefC (negbTE nUc) andbF. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
polyCV
rootMp q x : root (p * q) x = root p x || root q x. Proof. by rewrite !rootE hornerM mulf_eq0. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
rootM
rootZx a p : a != 0 -> root (a *: p) x = root p x. Proof. by move=> nz_a; rewrite -mul_polyC rootM rootC (negPf nz_a). Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
rootZ
root_expp n a: comm_poly p a -> (0 < n)%N -> root (p ^+ n) a = root p a. Proof. by move=> ? n0; rewrite !rootE horner_exp_comm// expf_eq0 n0. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
root_exp
size_scalea p : a != 0 -> size (a *: p) = size p. Proof. by move/lregP/lreg_size->. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
size_scale
size_Cmula p : a != 0 -> size (a%:P * p) = size p. Proof. by rewrite mul_polyC => /size_scale->. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
size_Cmul
lead_coefMp q : lead_coef (p * q) = lead_coef p * lead_coef q. Proof. have [-> | nz_p] := eqVneq p 0; first by rewrite !(mul0r, lead_coef0). have [-> | nz_q] := eqVneq q 0; first by rewrite !(mulr0, lead_coef0). by rewrite lead_coef_proper_mul // mulf_neq0 ?lead_coef_eq0. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
lead_coefM
lead_coef_prodI rI (P : {pred I}) (p : I -> {poly R}) : lead_coef (\prod_(i <- rI | P i) p i) = \prod_(i <- rI | P i) lead_coef (p i). Proof. by apply/big_morph/lead_coef1; apply: lead_coefM. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
lead_coef_prod
lead_coefZa p : lead_coef (a *: p) = a * lead_coef p. Proof. by rewrite -mul_polyC lead_coefM lead_coefC. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
lead_coefZ
scale_poly_eq0a p : (a *: p == 0) = (a == 0) || (p == 0). Proof. by rewrite -mul_polyC mulf_eq0 polyC_eq0. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
scale_poly_eq0
size_prod(I : finType) (P : pred I) (F : I -> {poly R}) : (forall i, P i -> F i != 0) -> size (\prod_(i | P i) F i) = ((\sum_(i | P i) size (F i)).+1 - #|P|)%N. Proof. move=> nzF; transitivity (\sum_(i | P i) (size (F i)).-1).+1; last first. apply: canRL (addKn _) _; rewrite addnS -sum1_card -big_split /=. by congr _.+1; apply: eq_bigr => i /nzF/polySpred. elim/big_rec2: _ => [|i d p /nzF nzFi IHp]; first by rewrite size_poly1. by rewrite size_mul // -?size_poly_eq0 IHp // addnS polySpred. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
size_prod
size_prod_seq(I : eqType) (s : seq I) (F : I -> {poly R}) : (forall i, i \in s -> F i != 0) -> size (\prod_(i <- s) F i) = ((\sum_(i <- s) size (F i)).+1 - size s)%N. Proof. move=> nzF; rewrite big_tnth size_prod; last by move=> i; rewrite nzF ?mem_tnth. by rewrite cardT /= size_enum_ord [in RHS]big_tnth. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
size_prod_seq
size_mul_eq1p q : (size (p * q) == 1) = ((size p == 1) && (size q == 1)). Proof. have [->|pNZ] := eqVneq p 0; first by rewrite mul0r size_poly0. have [->|qNZ] := eqVneq q 0; first by rewrite mulr0 size_poly0 andbF. rewrite size_mul //. by move: pNZ qNZ; rewrite -!size_poly_gt0; (do 2 case: size) => //= n [|[|]]. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
size_mul_eq1
size_prod_seq_eq1(I : eqType) (s : seq I) (P : pred I) (F : I -> {poly R}) : reflect (forall i, P i && (i \in s) -> size (F i) = 1) (size (\prod_(i <- s | P i) F i) == 1%N). Proof. rewrite (big_morph _ (id1:=true) size_mul_eq1) ?size_polyC ?oner_neq0//. rewrite big_all_cond; apply/(iffP allP). by move=> h i /andP[Pi ins]; apply/eqP/(implyP (h i ins) Pi). by move=> h i ins; apply/implyP => Pi; rewrite h ?Pi. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
size_prod_seq_eq1
size_prod_eq1(I : finType) (P : pred I) (F : I -> {poly R}) : reflect (forall i, P i -> size (F i) = 1) (size (\prod_(i | P i) F i) == 1). Proof. apply: (iffP (size_prod_seq_eq1 _ _ _)) => Hi i. by move=> Pi; apply: Hi; rewrite Pi /= mem_index_enum. by rewrite mem_index_enum andbT; apply: Hi. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
size_prod_eq1
size_expp n : (size (p ^+ n)).-1 = ((size p).-1 * n)%N. Proof. elim: n => [|n IHn]; first by rewrite size_poly1 muln0. have [-> | nz_p] := eqVneq p 0; first by rewrite exprS mul0r size_poly0. rewrite exprS size_mul ?expf_neq0 // mulnS -{}IHn. by rewrite polySpred // [size (p ^+ n)]polySpred ?expf_neq0 ?addnS. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
size_exp
lead_coef_expp n : lead_coef (p ^+ n) = lead_coef p ^+ n. Proof. elim: n => [|n IHn]; first by rewrite !expr0 lead_coef1. by rewrite !exprS lead_coefM IHn. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
lead_coef_exp
root_prod_XsubCrs x : root (\prod_(a <- rs) ('X - a%:P)) x = (x \in rs). Proof. elim: rs => [|a rs IHrs]; first by rewrite rootE big_nil hornerC oner_eq0. by rewrite big_cons rootM IHrs root_XsubC. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
root_prod_XsubC
root_exp_XsubCn a x : root (('X - a%:P) ^+ n.+1) x = (x == a). Proof. by rewrite rootE horner_exp expf_eq0 [_ == 0]root_XsubC. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
root_exp_XsubC
size_comp_polyp q : (size (p \Po q)).-1 = ((size p).-1 * (size q).-1)%N. Proof. have [-> | nz_p] := eqVneq p 0; first by rewrite comp_poly0 size_poly0. have [/size1_polyC-> | nc_q] := leqP (size q) 1. by rewrite comp_polyCr !size_polyC -!sub1b -!subnS muln0. have nz_q: q != 0 by rewrite -size_poly_eq0 -(subnKC nc_q). rewrite mulnC comp_polyE (polySpred nz_p) /= big_ord_recr /= addrC. rewrite size_polyDl size_scale ?lead_coef_eq0 ?size_exp //=. rewrite [ltnRHS]polySpred ?expf_neq0 // ltnS size_exp. rewrite (leq_trans (size_sum _ _ _)) //; apply/bigmax_leqP => i _. rewrite (leq_trans (size_scale_leq _ _)) // polySpred ?expf_neq0 //. by rewrite size_exp -(subnKC nc_q) ltn_pmul2l. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
size_comp_poly
lead_coef_compp q : size q > 1 -> lead_coef (p \Po q) = (lead_coef p) * lead_coef q ^+ (size p).-1. Proof. move=> q_gt1; rewrite !lead_coefE coef_comp_poly size_comp_poly. have [->|nz_p] := eqVneq p 0; first by rewrite size_poly0 big_ord0 coef0 mul0r. rewrite polySpred //= big_ord_recr /= big1 ?add0r => [|i _]. by rewrite -!lead_coefE -lead_coef_exp !lead_coefE size_exp mulnC. rewrite [X in _ * X]nth_default ?mulr0 ?(leq_trans (size_poly_exp_leq _ _)) //. by rewrite mulnC ltn_mul2r -subn1 subn_gt0 q_gt1 /=. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
lead_coef_comp
comp_poly_eq0p q : size q > 1 -> (p \Po q == 0) = (p == 0). Proof. move=> sq_gt1; rewrite -!lead_coef_eq0 lead_coef_comp //. rewrite mulf_eq0 expf_eq0 !lead_coef_eq0 -[q == 0]size_poly_leq0. by rewrite [_ <= 0]leqNgt (leq_ltn_trans _ sq_gt1) ?andbF ?orbF. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
comp_poly_eq0
size_comp_poly2p q : size q = 2 -> size (p \Po q) = size p. Proof. move=> sq2; have [->|pN0] := eqVneq p 0; first by rewrite comp_polyC. by rewrite polySpred ?size_comp_poly ?comp_poly_eq0 ?sq2 // muln1 polySpred. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
size_comp_poly2
comp_poly2_eq0p q : size q = 2 -> (p \Po q == 0) = (p == 0). Proof. by rewrite -!size_poly_eq0 => /size_comp_poly2->. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
comp_poly2_eq0
max_poly_rootsp rs : p != 0 -> all (root p) rs -> uniq rs -> size rs < size p. Proof. elim: rs p => [p pn0 _ _ | r rs ihrs p pn0] /=; first by rewrite size_poly_gt0. case/andP => rpr arrs /andP [rnrs urs]; case/factor_theorem: rpr => q epq. have [q0 | ?] := eqVneq q 0; first by move: pn0; rewrite epq q0 mul0r eqxx. have -> : size p = (size q).+1. by rewrite epq size_Mmonic ?monicXsubC // size_XsubC addnC. suff /eq_in_all h : {in rs, root q =1 root p} by apply: ihrs => //; rewrite h. move=> x xrs; rewrite epq rootM root_XsubC orbC; case: (eqVneq x r) => // exr. by move: rnrs; rewrite -exr xrs. Qed.
Theorem
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
max_poly_roots
roots_geq_poly_eq0p (rs : seq R) : all (root p) rs -> uniq rs -> (size rs >= size p)%N -> p = 0. Proof. by move=> ??; apply: contraTeq => ?; rewrite leqNgt max_poly_roots. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
roots_geq_poly_eq0
Definition_ (R : countNzSemiRingType) := [Countable of polynomial R by <:]. HB.instance Definition _ (R : countNzRingType) := [Countable of polynomial R by <:]. HB.instance Definition _ (R : countComNzSemiRingType) := [Countable of polynomial R by <:]. HB.instance Definition _ (R : countComNzRingType) := [Countable of polynomial R by <:]. HB.instance Definition _ (R : countIdomainType) := [Countable of polynomial R by <:].
HB.instance
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
Definition
size_map_polyp : size p^f = size p. Proof. have [-> | nz_p] := eqVneq p 0; first by rewrite rmorph0 !size_poly0. by rewrite size_poly_eq // fmorph_eq0 // lead_coef_eq0. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
size_map_poly
lead_coef_mapp : lead_coef p^f = f (lead_coef p). Proof. have [-> | nz_p] := eqVneq p 0; first by rewrite !(rmorph0, lead_coef0). by rewrite lead_coef_map_eq // fmorph_eq0 // lead_coef_eq0. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
lead_coef_map
map_poly_eq0p : (p^f == 0) = (p == 0). Proof. by rewrite -!size_poly_eq0 size_map_poly. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
map_poly_eq0
map_poly_inj: injective (map_poly f). Proof. move=> p q eqfpq; apply/eqP; rewrite -subr_eq0 -map_poly_eq0. by rewrite rmorphB /= eqfpq subrr. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
map_poly_inj
map_monicp : (p^f \is monic) = (p \is monic). Proof. by rewrite [in LHS]monicE lead_coef_map fmorph_eq1. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
map_monic
map_poly_comp x : comm_poly p^f (f x). Proof. exact: map_comm_poly (mulrC x _). Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
map_poly_com
fmorph_rootp x : root p^f (f x) = root p x. Proof. by rewrite rootE horner_map // fmorph_eq0. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
fmorph_root
fmorph_unity_rootn z : n.-unity_root (f z) = n.-unity_root z. Proof. by rewrite !unity_rootE -(inj_eq (fmorph_inj f)) rmorphXn ?rmorph1. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
fmorph_unity_root
fmorph_primitive_rootn z : n.-primitive_root (f z) = n.-primitive_root z. Proof. by congr (_ && _); apply: eq_forallb => i; rewrite fmorph_unity_root. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
fmorph_primitive_root
diff_roots(x y : R) := (x * y == y * x) && (y - x \in GRing.unit).
Definition
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
diff_roots
uniq_rootsrs := if rs is x :: rs' then all (diff_roots x) rs' && uniq_roots rs' else true.
Fixpoint
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
uniq_roots
uniq_roots_prod_XsubCp rs : all (root p) rs -> uniq_roots rs -> exists q, p = q * \prod_(z <- rs) ('X - z%:P). Proof. elim: rs => [|z rs IHrs] /=; first by rewrite big_nil; exists p; rewrite mulr1. case/andP=> rpz rprs /andP[drs urs]; case: IHrs => {urs rprs}// q def_p. have [|q' def_q] := factor_theorem q z _; last first. by exists q'; rewrite big_cons mulrA -def_q. rewrite {p}def_p in rpz. elim/last_ind: rs drs rpz => [|rs t IHrs] /=; first by rewrite big_nil mulr1. rewrite all_rcons => /andP[/andP[/eqP czt Uzt] /IHrs{}IHrs]. rewrite -cats1 big_cat big_seq1 /= mulrA rootE hornerM_comm; last first. by rewrite /comm_poly hornerXsubC mulrBl mulrBr czt. rewrite hornerXsubC -opprB mulrN oppr_eq0 -(mul0r (t - z)). by rewrite (inj_eq (mulIr Uzt)) => /IHrs. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
uniq_roots_prod_XsubC
max_ring_poly_rootsp rs : p != 0 -> all (root p) rs -> uniq_roots rs -> size rs < size p. Proof. move=> nz_p _ /(@uniq_roots_prod_XsubC p)[// | q def_p]; rewrite def_p in nz_p *. have nz_q: q != 0 by apply: contraNneq nz_p => ->; rewrite mul0r. rewrite size_Mmonic ?monic_prod_XsubC // (polySpred nz_q) addSn /=. by rewrite size_prod_XsubC leq_addl. Qed.
Theorem
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
max_ring_poly_roots
all_roots_prod_XsubCp rs : size p = (size rs).+1 -> all (root p) rs -> uniq_roots rs -> p = lead_coef p *: \prod_(z <- rs) ('X - z%:P). Proof. move=> size_p /uniq_roots_prod_XsubC def_p Urs. case/def_p: Urs => q -> {p def_p} in size_p *. have [q0 | nz_q] := eqVneq q 0; first by rewrite q0 mul0r size_poly0 in size_p. have{q nz_q size_p} /size_poly1P[c _ ->]: size q == 1. rewrite -(eqn_add2r (size rs)) add1n -size_p. by rewrite size_Mmonic ?monic_prod_XsubC // size_prod_XsubC addnS. by rewrite lead_coef_Mmonic ?monic_prod_XsubC // lead_coefC mul_polyC. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
all_roots_prod_XsubC
poly2_rootp : size p = 2 -> {r | root p r}. Proof. case: p => [[|p0 [|p1 []]] //= nz_p1]; exists (- p0 / p1). by rewrite /root addr_eq0 /= mul0r add0r mulrC divfK ?opprK. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
poly2_root
uniq_rootsErs : uniq_roots rs = uniq rs. Proof. elim: rs => //= r rs ->; congr (_ && _); rewrite -has_pred1 -all_predC. by apply: eq_all => t; rewrite /diff_roots mulrC eqxx unitfE subr_eq0. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
uniq_rootsE
root_ZXsubC(a b r : F) : a != 0 -> root (a *: 'X - b%:P) r = (r == b / a). Proof. move=> a0; rewrite rootE !hornerE. by rewrite -[r in RHS]divr1 eqr_div ?oner_neq0// mulr1 mulrC subr_eq0. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
root_ZXsubC
max_unity_rootsrs : n > 0 -> all n.-unity_root rs -> uniq rs -> size rs <= n. Proof. move=> n_gt0 rs_n_1 Urs; have szPn := size_XnsubC (1 : F) n_gt0. by rewrite -ltnS -szPn max_poly_roots -?size_poly_eq0 ?szPn. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
max_unity_roots
mem_unity_rootsrs : n > 0 -> all n.-unity_root rs -> uniq rs -> size rs = n -> n.-unity_root =i rs. Proof. move=> n_gt0 rs_n_1 Urs sz_rs_n x; rewrite -topredE /=. apply/idP/idP=> xn1; last exact: (allP rs_n_1). apply: contraFT (ltnn n) => not_rs_x. by rewrite -{1}sz_rs_n (@max_unity_roots (x :: rs)) //= ?xn1 ?not_rs_x. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
mem_unity_roots
factor_Xn_sub_1: \prod_(0 <= i < n) ('X - (z ^+ i)%:P) = 'X^n - 1. Proof. transitivity (\prod_(w <- zn) ('X - w%:P)); first by rewrite big_map. have n_gt0: n > 0 := prim_order_gt0 prim_z. rewrite (@all_roots_prod_XsubC _ ('X^n - 1) zn); first 1 last. - by rewrite size_XnsubC // size_map size_iota subn0. - apply/allP=> _ /mapP[i _ ->] /=; rewrite rootE !hornerE. by rewrite exprAC (prim_expr_order prim_z) expr1n subrr. - rewrite uniq_rootsE map_inj_in_uniq ?iota_uniq // => i j. rewrite !mem_index_iota => ltin ltjn /eqP. by rewrite (eq_prim_root_expr prim_z) !modn_small // => /eqP. by rewrite (monicP (monicXnsubC 1 n_gt0)) scale1r. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
factor_Xn_sub_1
prim_rootPx : x ^+ n = 1 -> {i : 'I_n | x = z ^+ i}. Proof. move=> xn1; pose logx := [pred i : 'I_n | x == z ^+ i]. case: (pickP logx) => [i /eqP-> | no_i]; first by exists i. case: notF; suffices{no_i}: x \in zn. case/mapP=> i; rewrite mem_index_iota => lt_i_n def_x. by rewrite -(no_i (Ordinal lt_i_n)) /= -def_x. rewrite -root_prod_XsubC big_map factor_Xn_sub_1. by rewrite [root _ x]unity_rootE xn1. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
prim_rootP
map_diff_rootsx y : diff_roots (f x) (f y) = (x != y). Proof. rewrite /diff_roots -rmorphB // fmorph_unit // subr_eq0 //. by rewrite rmorph_comm // eqxx eq_sym. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
map_diff_roots
map_uniq_rootss : uniq_roots (map f s) = uniq s. Proof. elim: s => //= x s ->; congr (_ && _); elim: s => //= y s ->. by rewrite map_diff_roots -negb_or. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
map_uniq_roots
aut_prim_rootPu z n : n.-primitive_root z -> {k | coprime k n & u z = z ^+ k}. Proof. move=> prim_z; have:= prim_z; rewrite -(fmorph_primitive_root u) => prim_uz. have [[k _] /= def_uz] := prim_rootP prim_z (prim_expr_order prim_uz). by exists k; rewrite // -(prim_root_exp_coprime _ prim_z) -def_uz. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
aut_prim_rootP
aut_unity_rootPu z n : n > 0 -> z ^+ n = 1 -> {k | u z = z ^+ k}. Proof. by move=> _ /prim_order_exists[// | m /(aut_prim_rootP u)[k]]; exists k. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
aut_unity_rootP
aut_unity_rootCu v z n : n > 0 -> z ^+ n = 1 -> u (v z) = v (u z). Proof. move=> n_gt0 /(aut_unity_rootP _ n_gt0) def_z. have [[i def_uz] [j def_vz]] := (def_z u, def_z v). by rewrite def_vz def_uz !rmorphXn /= def_vz def_uz exprAC. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
aut_unity_rootC
unity_rootE:= unity_rootE.
Definition
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
unity_rootE
unity_rootP:= @unity_rootP. Arguments unity_rootP {R n z}.
Definition
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
unity_rootP
prim_order_exists:= prim_order_exists.
Definition
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
prim_order_exists
prim_order_gt0:= prim_order_gt0.
Notation
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
prim_order_gt0
prim_expr_order:= prim_expr_order.
Notation
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
prim_expr_order
prim_expr_mod:= prim_expr_mod.
Definition
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
prim_expr_mod
prim_order_dvd:= prim_order_dvd.
Definition
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
prim_order_dvd
eq_prim_root_expr:= eq_prim_root_expr.
Definition
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
eq_prim_root_expr
rmorph_unity_root:= rmorph_unity_root.
Definition
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
rmorph_unity_root
fmorph_unity_root:= fmorph_unity_root.
Definition
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
fmorph_unity_root
fmorph_primitive_root:= fmorph_primitive_root.
Definition
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
fmorph_primitive_root
max_unity_roots:= max_unity_roots.
Definition
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
max_unity_roots
mem_unity_roots:= mem_unity_roots.
Definition
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
mem_unity_roots
prim_rootP:= prim_rootP.
Definition
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
prim_rootP
deg2_poly_canonical: p = a *: (('X + (b / (2 * a))%:P)^+2 - (delta / (4 * a ^+ 2))%:P). Proof. rewrite pE sqrrD -!addrA scalerDr; congr +%R; rewrite addrA scalerDr; congr +%R. - rewrite -mulrDr -polyCD -!mul_polyC mulrA mulrAC -polyCM. by rewrite [a * _]mulrC mulrDl invfM -!mulrA mulVf// mulr1 -splitr. - rewrite [a ^+ 2]expr2 mulrA aa4 -polyC_exp -polyCB expr_div_n -mulrBl subKr. by rewrite scale_polyC mulrCA mulrACA aa4 mulrCA mulfV// mulr1. Qed. Variable r : F. Hypothesis r_sqrt_delta : r ^+ 2 = delta. Let r1 := (- b - r) / (2 * a). Let r2 := (- b + r) / (2 * a).
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
deg2_poly_canonical
deg2_poly_factor: p = a *: ('X - r1%:P) * ('X - r2%:P). Proof. rewrite [p]deg2_poly_canonical//= -/a -/b -/c -/delta /r1 /r2. rewrite ![(- b + _) * _]mulrDl 2!polyCD 2!opprD 2!addrA !mulNr !polyCN !opprK. rewrite -scalerAl [in RHS]mulrC -subr_sqr -polyC_exp -[4]/(2 * 2)%:R natrM. by rewrite -expr2 -exprMn [in RHS]exprMn exprVn r_sqrt_delta. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
deg2_poly_factor
deg2_poly_root1: root p r1. Proof. apply/factor_theorem. by exists (a *: ('X - r2%:P)); rewrite deg2_poly_factor -!scalerAl mulrC. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
deg2_poly_root1
deg2_poly_root2: root p r2. Proof. apply/factor_theorem. by exists (a *: ('X - r1%:P)); rewrite deg2_poly_factor -!scalerAl. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
deg2_poly_root2
deg2_poly_canonical: p = (('X + (b / 2)%:P)^+2 - (delta / 4)%:P). Proof. by rewrite [p]deg2_poly_canonical// -/a a1 scale1r expr1n !mulr1. Qed. Variable r : F. Hypothesis r_sqrt_delta : r ^+ 2 = delta. Let r1 := (- b - r) / 2. Let r2 := (- b + r) / 2.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
deg2_poly_canonical
deg2_poly_factor: p = ('X - r1%:P) * ('X - r2%:P). Proof. by rewrite [p](@deg2_poly_factor _ _ _ _ r)// -/a a1 !mulr1 ?scale1r. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
deg2_poly_factor
deg2_poly_root1: root p r1. Proof. rewrite /r1 -[2]mulr1 -[X in 2 * X]a1. by apply: deg2_poly_root1; rewrite // -/a a1 mulr1. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
deg2_poly_root1
deg2_poly_root2: root p r2. Proof. rewrite /r2 -[2]mulr1 -[X in 2 * X]a1. by apply: deg2_poly_root2; rewrite // -/a a1 mulr1. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
deg2_poly_root2
dec_factor_theorem(p : {poly F}) : {s : seq F & {q : {poly F} | p = q * \prod_(x <- s) ('X - x%:P) /\ (q != 0 -> forall x, ~~ root q x)}}. Proof. pose polyT (p : seq F) := (foldr (fun c f => f * 'X_0 + c%:T) (0%R)%:T p)%T. have eval_polyT (q : {poly F}) x : GRing.eval [:: x] (polyT q) = q.[x]. by rewrite /horner; elim: (val q) => //= ? ? ->. have [n] := ubnP (size p); elim: n => // n IHn in p *. have /decPcases /= := @satP F [::] ('exists 'X_0, polyT p == 0%T). case: ifP => [_ /sig_eqW[x]|_ noroot]; last first. exists [::], p; rewrite big_nil mulr1; split => // p_neq0 x. by apply/negP=> /rootP rpx; apply: noroot; exists x; rewrite eval_polyT. rewrite eval_polyT => /rootP/factor_theorem/sig_eqW[p1 ->]. have [->|nz_p1] := eqVneq p1 0; first by exists [::], 0; rewrite !mul0r eqxx. rewrite size_Mmonic ?monicXsubC // size_XsubC addn2 => /IHn[s [q [-> irr_q]]]. by exists (rcons s x), q; rewrite -cats1 big_cat big_seq1 mulrA. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
dec_factor_theorem
closed_rootPp : reflect (exists x, root p x) (size p != 1). Proof. have [-> | nz_p] := eqVneq p 0. by rewrite size_poly0; left; exists 0; rewrite root0. rewrite neq_ltn [in _ < 1]polySpred //=. apply: (iffP idP) => [p_gt1 | [a]]; last exact: root_size_gt1. pose n := (size p).-1; have n_gt0: n > 0 by rewrite -ltnS -polySpred. have [a Dan] := closedF (fun i => - p`_i / lead_coef p) n_gt0. exists a; apply/rootP; rewrite horner_coef polySpred // big_ord_recr /= -/n. rewrite {}Dan mulr_sumr -big_split big1 //= => i _. by rewrite -!mulrA mulrCA mulNr mulVKf ?subrr ?lead_coef_eq0. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
closed_rootP
closed_nonrootPp : reflect (exists x, ~~ root p x) (p != 0). Proof. apply: (iffP idP) => [nz_p | [x]]; last first. by apply: contraNneq => ->; apply: root0. have [[x /rootP p1x0]|] := altP (closed_rootP (p - 1)). by exists x; rewrite -[p](subrK 1) /root hornerD p1x0 add0r hornerC oner_eq0. rewrite negbK => /size_poly1P[c _ /(canRL (subrK 1)) Dp]. by exists 0; rewrite Dp -raddfD polyC_eq0 rootC in nz_p *. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
closed_nonrootP
closed_rootPp : reflect (exists x, root p x) (size p != 1). Proof. exact: PreClosedField.closed_rootP. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
closed_rootP
closed_nonrootPp : reflect (exists x, ~~ root p x) (p != 0). Proof. exact: PreClosedField.closed_nonrootP. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
closed_nonrootP
closed_field_poly_normalp : {r : seq F | p = lead_coef p *: \prod_(z <- r) ('X - z%:P)}. Proof. apply: sig_eqW; have [r [q [->]]] /= := dec_factor_theorem p. have [->|] := eqVneq; first by exists [::]; rewrite mul0r lead_coef0 scale0r. have [[x rqx ? /(_ isT x) /negP /(_ rqx)] //|] := altP (closed_rootP q). rewrite negbK => /size_poly1P [c c_neq0-> _ _]; exists r. rewrite mul_polyC lead_coefZ (monicP _) ?mulr1 //. by rewrite monic_prod => // i; rewrite monicXsubC. Qed.
Lemma
algebra
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop finset tuple div ssralg", "From mathcomp Require Import countalg binomial" ]
algebra/poly.v
closed_field_poly_normal
redivp_rec(q : {poly R}) := let sq := size q in let cq := lead_coef q in fix loop (k : nat) (qq r : {poly R})(n : nat) {struct n} := if size r < sq then (k, qq, r) else let m := (lead_coef r) *: 'X^(size r - sq) in let qq1 := qq * cq%:P + m in let r1 := r * cq%:P - m * q in if n is n1.+1 then loop k.+1 qq1 r1 n1 else (k.+1, qq1, r1).
Definition
algebra
[ "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop ssralg poly" ]
algebra/polydiv.v
redivp_rec
redivp_expanded_defp q := if q == 0 then (0, 0, p) else redivp_rec q 0 0 p (size p). Fact redivp_key : unit. Proof. by []. Qed.
Definition
algebra
[ "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop ssralg poly" ]
algebra/polydiv.v
redivp_expanded_def
redivp: {poly R} -> {poly R} -> nat * {poly R} * {poly R} := locked_with redivp_key redivp_expanded_def.
Definition
algebra
[ "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop ssralg poly" ]
algebra/polydiv.v
redivp
redivp_unlockable:= [unlockable fun redivp].
Canonical
algebra
[ "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop ssralg poly" ]
algebra/polydiv.v
redivp_unlockable
rdivpp q := ((redivp p q).1).2.
Definition
algebra
[ "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop ssralg poly" ]
algebra/polydiv.v
rdivp
rmodpp q := (redivp p q).2.
Definition
algebra
[ "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop ssralg poly" ]
algebra/polydiv.v
rmodp
rscalpp q := ((redivp p q).1).1.
Definition
algebra
[ "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop ssralg poly" ]
algebra/polydiv.v
rscalp
rdvdpp q := rmodp q p == 0.
Definition
algebra
[ "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop ssralg poly" ]
algebra/polydiv.v
rdvdp
redivp_defp q : redivp p q = (rscalp p q, rdivp p q, rmodp p q). Proof. by rewrite /rscalp /rdivp /rmodp; case: (redivp p q) => [[]] /=. Qed.
Lemma
algebra
[ "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop ssralg poly" ]
algebra/polydiv.v
redivp_def
rdiv0pp : rdivp 0 p = 0. Proof. rewrite /rdivp unlock; case: ifP => // Hp; rewrite /redivp_rec !size_poly0. by rewrite polySpred ?Hp. Qed.
Lemma
algebra
[ "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop ssralg poly" ]
algebra/polydiv.v
rdiv0p
rdivp0p : rdivp p 0 = 0. Proof. by rewrite /rdivp unlock eqxx. Qed.
Lemma
algebra
[ "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop ssralg poly" ]
algebra/polydiv.v
rdivp0
rdivp_smallp q : size p < size q -> rdivp p q = 0. Proof. rewrite /rdivp unlock; have [-> | _ ltpq] := eqP; first by rewrite size_poly0. by case: (size p) => [|s]; rewrite /= ltpq. Qed.
Lemma
algebra
[ "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop ssralg poly" ]
algebra/polydiv.v
rdivp_small
leq_rdivpp q : size (rdivp p q) <= size p. Proof. have [/rdivp_small->|] := ltnP (size p) (size q); first by rewrite size_poly0. rewrite /rdivp /rmodp /rscalp unlock. have [->|q0] //= := eqVneq q 0. have: size (0 : {poly R}) <= size p by rewrite size_poly0. move: {2 3 4 6}(size p) (leqnn (size p)) => A. elim: (size p) 0%N (0 : {poly R}) {1 3 4}p (leqnn (size p)) => [|n ihn] k q1 r. by move/size_poly_leq0P->; rewrite /= size_poly0 size_poly_gt0 q0. move=> /= hrn hr hq1 hq; case: ltnP => //= hqr. have sq: 0 < size q by rewrite size_poly_gt0. have sr: 0 < size r by apply: leq_trans sq hqr. apply: ihn => //. - apply/leq_sizeP => j hnj. rewrite coefB -scalerAl coefZ coefXnM ltn_subRL ltnNge. have hj : (size r).-1 <= j by apply: leq_trans hnj; rewrite -ltnS prednK. rewrite [leqLHS]polySpred -?size_poly_gt0 // coefMC. rewrite (leq_ltn_trans hj) /=; last by rewrite -add1n leq_add2r. move: hj; rewrite leq_eqVlt prednK // => /predU1P [<- | hj]. by rewrite -subn1 subnAC subKn // !subn1 !lead_coefE subrr. have/leq_sizeP-> //: size q <= j - (size r - size q). by rewrite subnBA // leq_psubRL // leq_add2r. by move/leq_sizeP: (hj) => -> //; rewrite mul0r mulr0 subr0. - apply: leq_trans (size_polyD _ _) _; rewrite geq_max; apply/andP; split. apply: leq_trans (size_polyMleq _ _) _. by rewrite size_polyC lead_coef_eq0 q0 /= addn1. rewrite size_polyN; apply: leq_trans (size_polyMleq _ _) _. apply: leq_trans hr; rewrite -subn1 leq_subLR -[in (1 + _)%N](subnK hqr). by ...
Lemma
algebra
[ "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop ssralg poly" ]
algebra/polydiv.v
leq_rdivp
rmod0pp : rmodp 0 p = 0. Proof. rewrite /rmodp unlock; case: ifP => // Hp; rewrite /redivp_rec !size_poly0. by rewrite polySpred ?Hp. Qed.
Lemma
algebra
[ "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice", "From mathcomp Require Import fintype bigop ssralg poly" ]
algebra/polydiv.v
rmod0p