(** * Permutations modulo p. *)
Fixpoint permmod (p : nat) (l1 : Zlist) {struct l1} :
Zlist -> Prop :=
fun l2 : Zlist =>
match l1 with
| Nil => l2 = Nil Z
| Cons x t =>
exists y : Z, inlist Z y l2 /\ Mod x y p /\ permmod p t (zdrop y l2)
end.

Lemma permmod_drop_cons :
forall (p : nat) (x1 x2 : Z) (t1 l2 : Zlist),
Mod x1 x2 p ->
inlist Z x2 l2 -> permmod p t1 (zdrop x2 l2) -> permmod p (Cons Z x1 t1) l2.