Section seteq.
Variable X : Type.
(* When viewed as sets, the lists are equivalent, ie closed under perm + contraction + RST *)
Inductive seteq : list X -> list X -> Prop :=
| seteq_nil   : nil ≡ nil
| seteq_skip  : forall x l m, l ≡ m -> x::l ≡ x::m
| seteq_swap  : forall x y l, x::y::l ≡ y::x::l
| seteq_dup   : forall x l, x::x::l ≡ x::l
| seteq_sym   : forall l m, l ≡ m -> m ≡ l
| seteq_trans : forall l m k, l ≡ m -> m ≡ k -> l ≡ k
where "l ≡ m" := (seteq l m).
Hint Constructors seteq : core.
Fact perm_seteq l m : l ~p m -> l ≡ m.
(* The proof by induction on |l|+|m| for l ⊆ m and m ⊆ l  Three cases:  (1) m has dup    (2) l ~p m      (3) l has dup  For (2) If l ~p m then it is trivial  Otherwise (1 or 3), if eg l has dup then l ≡ l' for a shorter l' we deduce l' ⊆ m and m ⊆ l' by seqeq_incl and apply the induction hypothesis to (l',m)  *)

Lemma incl_seteq l m : l ⊆ m -> m ⊆ l -> l ≡ m.