(* * Maximum element in a list *)
From Undecidability Require Export TM.Util.Prelim TM.Util.ArithPrelim.
(* ** Basic lemmas about upper bounds *)
(* ** Tail Recursive Definition *)
(* Compute the maximum of a list and a start-value tail-recursively *)
Fixpoint max_list_rec (s : nat) (xs : list nat) { struct xs } : nat :=
match xs with
| nil => s
| x :: xs' => max_list_rec (max x s) xs'
end.
(* ** Definition of the maximum of a list *)
(* We simply instantiate the accu to [0] *)
Definition max_list (xs : list nat) := max_list_rec 0 xs.

(* If the list is not empty, then the maximum is in the list *)
Lemma max_list_In (xs : list nat) :
xs <> nil ->
In (max_list xs) xs.