Fixpoint has_delta (c : coef) (l : line) (e : expr) :=
match e with
| nil => None
| (c1,l1)::e1  =>
match delta 2 2 l l1 nil nil nil with
| Some (t1 :: t2 :: nil, t3 :: t4 :: nil, rl) =>
let s :=
if czerop (cadd c c1) then Sm1 else
if czerop (cadd c (copp c1)) then S1 else
S0 in
if match s with S0 => true | _ => false end then
has_delta c l e1
else
match contraction_rule s t1 t3 t2 t4 with
| None=> has_delta c l e1
| Some (c5, t5, t6) =>
Some ((c1,l1),
(scmp c5 c,
linsert t5 (linsert t6 rl)))
end
| _ => has_delta c l e1
end
end.

Lemma has_delta_c c l e :
match has_delta c l e with None => True | Some ((c1,l1),(c2,l2)) =>
({c[c]} * {l[l]} + {c[c1]} * {l[l1]} =  {c[c2]} * {l[l2]})%f
end.