(** ** Composition of polynomials  - [pcomp p pl] is the polynomial [p] where each variable [i] is replaced by the [i]th polynomial in the list [pl]. *)
Definition pcomp_pow' (xn:pow)(pl:list pol) : pol :=
ppower (nth (fst xn) pl (pcst 0 0)) (snd xn).
Definition pcomp_pow (xn:pow)(pl:list pol) : pol :=
(maxl (map parity pl), snd (pcomp_pow' xn pl)).
Definition pcomp_mon' (m:mon)(pl:list pol) : pol :=
pscalar (fst m) (pmultl (map (fun xn => pcomp_pow xn pl) (snd m))).
Definition pcomp_mon (m:mon)(pl:list pol) : pol :=
(maxl (map parity pl), snd (pcomp_mon' m pl)).
Definition pcomp' (p:pol)(pl:list pol) : pol :=
pplusl (map (fun m => pcomp_mon m pl) (snd p)).
Definition pcomp (p:pol)(pl:list pol) : pol :=
(maxl (map parity pl), snd (pcomp' p pl)).

Lemma map_parity_pcomp_pow xl pl :
map (fun xn => parity (pcomp_pow xn pl)) xl = map (fun _ => maxl (map parity pl)) xl.