Notation parity := (@fst nat (list mon)).
(** * Well-formedness of polynomials *)
Definition pWF_pow (ar:nat)(xn:pow) : Prop :=
fst xn < ar.
Definition pWF_mon (ar:nat)(m:mon) : Prop :=
andl (pWF_pow ar) (snd m).
Definition pWF' (ar:nat)(ml:list mon) : Prop :=
andl (pWF_mon ar) ml.
Definition pWF (p:pol) : Prop :=
pWF' (fst p) (snd p).

(* Specifications: *)
Lemma pWF_mon_le : forall ar1 ar2 m,
ar1 <= ar2 ->
pWF_mon ar1 m -> pWF_mon ar2 m.
Lemma pWF'_le ar1 ar2 ml :
ar1 <= ar2 -> pWF' ar1 ml -> pWF' ar2 ml.
Lemma pWF_mon_app : forall ar a1 xl1 a2 xl2,
pWF_mon ar (a1, xl1) -> pWF_mon ar (a2, xl2) ->
pWF_mon ar (a1*a2, xl1++xl2).
Lemma pWF'_app ar ml1 ml2 :
pWF' ar ml1 -> pWF' ar ml2 -> pWF' ar (ml1++ml2).
Lemma pWF_nth i pl p0 :
andl pWF pl -> pWF p0 -> pWF (nth i pl p0).
Lemma parity_mon_correct : forall ar m l l1 l2,
pWF_mon ar m -> length l = ar -> peval_mon m (l++l1) = peval_mon m (l++l2).
Lemma parity_correct : forall p l l1 l2,
pWF p -> length l = parity p -> peval p (l++l1) = peval p (l++l2).