Fixpoint einsert (c1 : coef) (l1 : line) (e : expr) :=
match e with
|   nil => (c1,l1) :: e
| (c2,l2)::e1 => match lcompare l1 l2 with
| Eq => let c := cadd c1 c2 in
if czerop c then e1 else (c,l1)::e1
| Gt => (c2,l2) :: einsert c1 l1 e1
| Lt => (c1,l1) :: e
end
end.

(* Specifications: *)
Lemma einsert_length c l e :  length (einsert c l e) <= 1 + length e.
Lemma einsert_c c1 l1 e :
{e[einsert c1 l1 e]} = ({c[c1]} * {l[l1]} + {e[e]})%f.