Ltac solve_perm :=
    (* solves goals of the form (R ++ ?i = S)
          where R and S are lists, and ?i is a unification variable *)
  try match goal with
       | |-  Permutation (?A ++ ?B) _ =>
            is_evar A; first [is_evar B; fail 1| idtac];
            apply Permutation_app_comm_trans
       end;
  repeat first [ apply Permutation_refl
       | apply perm_skip
       | eapply perm_search
       ].Goal exists e, Permutation ((1::2::nil)++e) (3::2::1::5::nil).

Lemma range_pred_dec: forall (P: nat -> Prop), (forall n, {P n} + {~ P n}) -> forall m, {forall n, (n < m)%nat -> P n} + {~ forall n, (n < m)%nat -> P n}.