Inductive list_order {A : Type} (R : A -> A -> Prop) : list A -> list A -> Prop :=
| lo_cons:  forall l1 l2 h, Forall (fun x => R x h) l1 -> list_order R (l1 ++ l2) (h :: l2).Inductive list_order {A : Type} (R : A -> A -> Prop) : list A -> list A -> Prop :=
| lo_cons:  forall l1 l2 h, Forall (fun x => R x h) l1 -> list_order R (l1 ++ l2) (h :: l2).Definition W {A : Type} (R : A -> A -> Prop) (l : list A) : Prop :=
  Acc (list_order R) l.

(* Specifications: *)
Lemma deuxpointun (A : Type) (R : A -> A -> Prop) (l : list A) (a : A) : (forall b, R b a -> forall l', W R l' -> W R (b :: l')) -> W R l (* /\ (forall l', list_order R l' l -> W R (a :: l')) *) -> W R (a :: l).
Lemma deuxpointdeux (A : Type) (R : A -> A -> Prop) (l : list A) (a : A) : (forall b, R b a -> forall l, W R l -> W R (b :: l)) -> (forall l, W R l -> W R (a :: l)).
Lemma deuxpointtrois (A : Type) (R : A -> A -> Prop) (l : list A) (a : A) : well_founded R -> W R l -> W R (a :: l).
Lemma list_order_wf (A : Type) (R : A -> A -> Prop) : well_founded R -> well_founded (list_order R).
Lemma product_suml_lt l1 l2 : product lt l1 l2 -> suml l1 < suml l2.
Lemma PPO_active_term_order_superset act act' : PPO rank (term_from_active_term act) (term_from_active_term act') -> active_term_order_superset act act'.
Lemma term_order_PPO t1 t2 : term_order t1 t2 -> PPO rank t1 t2.
Lemma max_arity_subst s t f lp : rule_vars_defined (rule_intro f lp t) -> let t' := fapply f (map (fun p => term_from_value variable function (@psubst variable constructor s p)) lp) in max_arity_term (subst s t) <= Nat.max (max_arity_rule (rule_intro f lp t)) (max_arity_term t').
Lemma first_rule_max_arity act t i s : wf_prog max_arity prog -> first_rule act = Some (i, s, t) -> max_arity_term (term_from_active_term act) <= max_arity -> max_arity_term t <= max_arity.