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 Z2Nat_neg: forall i, i < 0 -> Z.to_nat i = 0%nat.