Section permutation.
Variable A : Type.
(* Definition of permutations as sequences of adjacent transpositions *)
Inductive permutation : list A -> list A -> Prop :=
| permutation_nil : permutation nil nil
| permutation_skip :
forall (a : A) (l1 l2 : list A),
permutation l2 l1 -> permutation (a :: l2) (a :: l1)
| permutation_swap :
forall (a b : A) (l : list A), permutation (a :: b :: l) (b :: a :: l)
| permutation_trans :
forall l1 l2 l3 : list A,
permutation l1 l2 -> permutation l2 l3 -> permutation l1 l3.
Hint Constructors permutation : core.
Proof using.
simple induction l.
apply permutation_nil.
intros a l1 H.
apply permutation_skip with (1 := H).
Qed.
Hint Resolve permutation_refl : core.
Proof using.
intros l1 l2 H'; elim H'.
apply permutation_nil.
intros a l1' l2' H1 H2.
apply permutation_skip with (1 := H2).
intros a b l1'.
apply permutation_swap.
intros l1' l2' l3' H1 H2 H3 H4.
apply permutation_trans with (1 := H4) (2 := H2).
Qed.

(* Compatibility with list length *)
Theorem permutation_length :
forall l m : list A, permutation l m -> length l = length m.