(** Author: Andrej Dudenhefner *)
Section WfList_Extension.
Variable A : Type.
Variable ltA : A -> A -> Prop.
(* List extension of the relation ltA see relation ">_red" [1] for which the transitive closure is the multiset ordering [1, Lemma 2]  [1] Solange Coupet-Grimal, William Delobel: An effective proof of the well-foundedness of the multiset path ordering. Applicable Algebra in Engineering, Communication and Computing 17(6): 453-469 (2006)  Intuition: to reduce a list, replace one element with zero or more smaller elements. For example, with Nat.lt, [2, 2] > [1, 1, 0, 2] > [1, 1, 0] > [1, 0] > [0, 0, 0] > [0, 0] > [0] > []. *)
Inductive list_ext : list A -> list A -> Prop :=
| list_ext_intro a (bs : list A) l1 l2 :
Forall (fun b => ltA b a) bs -> list_ext (l1 ++ bs ++ l2) (l1 ++ a :: l2).

(* Specifications: *)
Lemma list_ext_inv l l' : list_ext l l' ->
exists a bs l1 l2, l = l1 ++ bs ++ l2 /\ l' = l1 ++ a :: l2 /\ Forall (fun b => ltA b a) bs.
Lemma list_ext_nil_r l : not (list_ext l []).
Lemma Acc_list_ext_app l1 l2 : Acc list_ext l1 -> Acc list_ext l2 -> Acc list_ext (l1 ++ l2).
Lemma list_ext_app_r l1 l2 l : list_ext l1 l2 -> list_ext (l1 ++ l) (l2 ++ l).
Lemma list_ext_app_l l l1 l2 : list_ext l1 l2 -> list_ext (l ++ l1) (l ++ l2).
Lemma clos_refl_trans_list_ext_app_r l1 l2 l : list_ext ^* l1 l2 -> list_ext ^* (l1 ++ l) (l2 ++ l).
Lemma clos_refl_trans_list_ext_app_l l l1 l2 : list_ext ^* l1 l2 -> list_ext ^* (l ++ l1) (l ++ l2).
Lemma clos_trans_list_ext_app_l l1 l2 l3 l4 : list_ext ^+ l1 l3 -> list_ext ^* l2 l4 -> list_ext ^+ (l1 ++ l2) (l3 ++ l4).
Lemma clos_trans_list_ext_app_r l1 l2 l3 l4 : list_ext ^* l1 l3 -> list_ext ^+ l2 l4 -> list_ext ^+(l1 ++ l2) (l3 ++ l4).
End WfList_Extension.