Definition ccons (t : term) (c : coef) :=
if term_zerop t then c else t :: c.

(* Specifications: *)
Lemma ccons_c t c : {c[ccons t c]} = ({m[t]} + {c[c]})%f.
Fixpoint cadd (a b : coef) : coef :=
match a with
| nil => b
| t1 :: a1 =>
(fix cadd1 (b : coef) : coef :=
match  b with
| nil => a
| t2 :: b1 =>
match term_cmp t1 t2 with
| Eq => ccons (term_add t1 t2) (cadd a1 b1)
| Lt => ccons t1 (cadd a1 b)
| Gt => ccons t2 (cadd1 b1)
end
end) b
end.
Lemma cadd_c c1 c2 : {c[cadd c1 c2]} = ({c[c1]} + {c[c2]})%f.
Definition ccmp (c1 c2 : coef) :=
list_compare _ term_cmp c1 c2.