#[local] Ltac caseq :=
  match goal with [ |- context [match ?t with _ => _ end] ] =>
    let cmp := fresh in
    let H := fresh in
    remember t as cmp eqn:H; symmetry in H; destruct cmp
  end.

Lemma compare_aux_Cmp : forall e, Cmp (compare_aux e) (flatten_e (fst e)) (flatten_e (snd e)).