Section LT_WF_REL.
(* This Section is copied from the Coq library, which unfortunately uses Set instead of Type for Variable A, so just modified the one word. *)
Variable A : Type.
Variable R : A -> A -> Prop.
(* Relational form of inversion *)
Variable F : A -> nat -> Prop.
Definition inv_lt_rel x y := exists2 n, F x n & (forall m, F y m -> n < m).
Hypothesis F_compat : forall x y:A, R x y -> inv_lt_rel x y.
Remark acc_lt_rel : forall x:A, (exists n, F x n) -> Acc R x.
End LT_WF_REL.
Definition lex_pair {A B} (Ra: A -> A -> Prop) (Rb: B -> B -> Prop)
(x: A*B) (y: A*B) : Prop :=
Ra (fst x) (fst y) \/ (fst x = fst y /\ Rb (snd x) (snd y)).
(* Lemma lex_pair_eqv: forall A B Ra Rb, lex_pair Ra Rb = (fun x y => lexprod A (fun _ => B) Ra (fun _ => Rb) (existT (fun _:A => B) (fst x) (snd x)) (existT (fun _:A => B) (fst y) (snd y))). *)
Definition lexprodx {B A : Type} (f: A -> B) (R1: B -> B -> Prop)
(R2: B -> A -> A -> Prop)
(x y : A) : Prop :=
R1 (f x) (f y) \/ f x = f y /\ R2 (f x) x y.
(* WARNING: Not sure simple_lexprod is useful! *)
Definition simple_lexprod {A: Type} (R1: A -> A -> Prop) (R2: A -> A -> Prop)
(x y: A) : Prop :=
R1 x y \/ x=y /\ R2 x y.

Lemma wellfounded_simple_lexprod:
forall A (R1: A -> A -> Prop) (R2: A -> A -> Prop),
well_founded R1 ->
well_founded R2 ->
well_founded (simple_lexprod R1 R2).