(** This file is part of the Coquelicot formalization of real analysis in Coq: http://coquelicot.saclay.inria.fr/  Copyright (C) 2011-2015 Sylvie Boldo #<br /># Copyright (C) 2011-2015 Catherine Lelay #<br /># Copyright (C) 2011-2015 Guillaume Melquiond  This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.  This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the COPYING file for more details. *)
(** This file describes many properties about sequences of real numbers. Several formalizations are provided. They are mainly used for defining pointed subvivision in order to define Riemann sums. *)
Open Scope R_scope.
(** * Complements abouts lists *)
(** seq R <-> Rlist *)
Fixpoint seq2Rlist (s : seq R) :=
match s with
| [::] => RList.nil
| h::t => RList.cons h (seq2Rlist t)
end.
Fixpoint Rlist2seq (s : Rlist) : seq R :=
match s with
| RList.nil => [::]
| RList.cons h t => h::(Rlist2seq t)
end.
(** Various properties *)
(** sorted *)
Fixpoint sorted {T : Type} (Ord : T -> T -> Prop) (s : seq T) :=
match s with
| [::] | [:: _] => True
| h0 :: (h1 :: t1) as t0 => Ord h0 h1 /\ sorted Ord t0
end.

Lemma sorted_nth {T : Type} (Ord : T -> T -> Prop) (s : seq T) :
sorted Ord s <-> (forall i : nat,
(i < Peano.pred (size s))%nat -> forall x0 : T, Ord (nth x0 s i) (nth x0 s (S i))).