(************************************************************************)
(*         *      The Rocq Prover / The Rocq Development Team           *)
(*  v      *         Copyright INRIA, CNRS and contributors             *)
(* <O___,, * (see version control and CREDITS file for authors & dates) *)
(*   \VV/  **************************************************************)
(*    //   *    This file is distributed under the terms of the         *)
(*         *     GNU Lesser General Public License Version 2.1          *)
(*         *     (see LICENSE file for the text of the license)         *)
(************************************************************************)
Local Open Scope R_scope.
Fixpoint MaxRlist (l:list R) : R :=
match l with
| nil => 0
| a :: l1 =>
match l1 with
| nil => a
| a' :: l2 => Rmax a (MaxRlist l1)
end
end.
Fixpoint MinRlist (l:list R) : R :=
match l with
| nil => 1
| a :: l1 =>
match l1 with
| nil => a
| a' :: l2 => Rmin a (MinRlist l1)
end
end.

(* Specifications: *)
Lemma MaxRlist_P1 : forall (l:list R) (x:R), In x l -> x <= MaxRlist l.
Fixpoint AbsList (l:list R) (x:R) : list R :=
match l with
| nil => nil
| a :: l' => (Rabs (a - x) / 2) :: (AbsList l' x)
end.
Lemma MinRlist_P1 : forall (l:list R) (x:R), In x l -> MinRlist l <= x.
Lemma AbsList_P1 :
forall (l:list R) (x y:R), In y l -> In (Rabs (y - x) / 2) (AbsList l x).
Lemma MinRlist_P2 :
forall l:list R, (forall y:R, In y l -> 0 < y) -> 0 < MinRlist l.
Lemma AbsList_P2 :
forall (l:list R) (x y:R),
In y (AbsList l x) ->  exists z : R, In z l /\ y = Rabs (z - x) / 2.
Lemma MaxRlist_P2 :
forall l:list R, (exists y : R, In y l) -> In (MaxRlist l) l.