Built with Alectryon, running Coq+SerAPI v8.10.0+0.7.0. Coq sources are in this panel; goals and messages will appear in the other. Bubbles () indicate interactive fragments: hover for details, tap to reveal contents. Use Ctrl+↑ Ctrl+↓ to navigate, Ctrl+🖱️ to focus.
(************************************************************************) (* * The Coq Proof Assistant / The Coq Development Team *) (* v * INRIA, CNRS and contributors - Copyright 1999-2018 *) (* <O___,, * (see CREDITS file for the list of authors) *) (* \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) *) (************************************************************************) Require Import Rbase. Require Import Rfunctions. Local Open Scope R_scope. Inductive Rlist : Type := | nil : Rlist | cons : R -> Rlist -> Rlist. Fixpoint In (x:R) (l:Rlist) : Prop := match l with | nil => False | cons a l' => x = a \/ In x l' end. Fixpoint Rlength (l:Rlist) : nat := match l with | nil => 0%nat | cons a l' => S (Rlength l') end. Fixpoint MaxRlist (l:Rlist) : R := match l with | nil => 0 | cons a l1 => match l1 with | nil => a | cons a' l2 => Rmax a (MaxRlist l1) end end. Fixpoint MinRlist (l:Rlist) : R := match l with | nil => 1 | cons a l1 => match l1 with | nil => a | cons a' l2 => Rmin a (MinRlist l1) end end.forall (l : Rlist) (x : R), In x l -> x <= MaxRlist lforall (l : Rlist) (x : R), In x l -> x <= MaxRlist lx:RH:In x nilx <= MaxRlist nilr:Rl:Rlistx:RH:In x (cons r l)Hrecl:In x l -> x <= MaxRlist lx <= MaxRlist (cons r l)r:Rl:Rlistx:RH:In x (cons r l)Hrecl:In x l -> x <= MaxRlist lx <= MaxRlist (cons r l)r, x:RH:In x (cons r nil)Hrecl:In x nil -> x <= MaxRlist nilx <= MaxRlist (cons r nil)r, r0:Rl:Rlistx:RH:In x (cons r (cons r0 l))Hrecl:In x (cons r0 l) -> x <= MaxRlist (cons r0 l)Hrecl0:In x (cons r l) -> (In x l -> x <= MaxRlist l) -> x <= MaxRlist (cons r l)x <= MaxRlist (cons r (cons r0 l))r, x:RH:x = r \/ FalseHrecl:In x nil -> x <= MaxRlist nilH0:x = rx <= MaxRlist (cons r nil)r, x:RH:x = r \/ FalseHrecl:In x nil -> x <= MaxRlist nilH0:Falsex <= MaxRlist (cons r nil)r, r0:Rl:Rlistx:RH:In x (cons r (cons r0 l))Hrecl:In x (cons r0 l) -> x <= MaxRlist (cons r0 l)Hrecl0:In x (cons r l) -> (In x l -> x <= MaxRlist l) -> x <= MaxRlist (cons r l)x <= MaxRlist (cons r (cons r0 l))r, x:RH:x = r \/ FalseHrecl:In x nil -> x <= MaxRlist nilH0:Falsex <= MaxRlist (cons r nil)r, r0:Rl:Rlistx:RH:In x (cons r (cons r0 l))Hrecl:In x (cons r0 l) -> x <= MaxRlist (cons r0 l)Hrecl0:In x (cons r l) -> (In x l -> x <= MaxRlist l) -> x <= MaxRlist (cons r l)x <= MaxRlist (cons r (cons r0 l))r, r0:Rl:Rlistx:RH:In x (cons r (cons r0 l))Hrecl:In x (cons r0 l) -> x <= MaxRlist (cons r0 l)Hrecl0:In x (cons r l) -> (In x l -> x <= MaxRlist l) -> x <= MaxRlist (cons r l)x <= MaxRlist (cons r (cons r0 l))r, r0:Rl:Rlistx:RH:In x (cons r (cons r0 l))Hrecl:In x (cons r0 l) -> x <= MaxRlist (cons r0 l)Hrecl0:In x (cons r l) -> (In x l -> x <= MaxRlist l) -> x <= MaxRlist (cons r l)x <= Rmax r (MaxRlist (cons r0 l))r, r0:Rl:Rlistx:RH:In x (cons r (cons r0 l))Hrecl:In x (cons r0 l) -> x <= MaxRlist (cons r0 l)Hrecl0:In x (cons r l) -> (In x l -> x <= MaxRlist l) -> x <= MaxRlist (cons r l)Rmax r (MaxRlist (cons r0 l)) = MaxRlist (cons r (cons r0 l))r, r0:Rl:Rlistx:RH:x = r \/ x = r0 \/ In x lHrecl:In x (cons r0 l) -> x <= MaxRlist (cons r0 l)Hrecl0:In x (cons r l) -> (In x l -> x <= MaxRlist l) -> x <= MaxRlist (cons r l)H0:x = rx <= Rmax r (MaxRlist (cons r0 l))r, r0:Rl:Rlistx:RH:x = r \/ x = r0 \/ In x lHrecl:In x (cons r0 l) -> x <= MaxRlist (cons r0 l)Hrecl0:In x (cons r l) -> (In x l -> x <= MaxRlist l) -> x <= MaxRlist (cons r l)H1:x = r0x <= Rmax r (MaxRlist (cons r0 l))r, r0:Rl:Rlistx:RH:x = r \/ x = r0 \/ In x lHrecl:In x (cons r0 l) -> x <= MaxRlist (cons r0 l)Hrecl0:In x (cons r l) -> (In x l -> x <= MaxRlist l) -> x <= MaxRlist (cons r l)H1:In x lx <= Rmax r (MaxRlist (cons r0 l))r, r0:Rl:Rlistx:RH:In x (cons r (cons r0 l))Hrecl:In x (cons r0 l) -> x <= MaxRlist (cons r0 l)Hrecl0:In x (cons r l) -> (In x l -> x <= MaxRlist l) -> x <= MaxRlist (cons r l)Rmax r (MaxRlist (cons r0 l)) = MaxRlist (cons r (cons r0 l))r, r0:Rl:Rlistx:RH:x = r \/ x = r0 \/ In x lHrecl:In x (cons r0 l) -> x <= MaxRlist (cons r0 l)Hrecl0:In x (cons r l) -> (In x l -> x <= MaxRlist l) -> x <= MaxRlist (cons r l)H1:x = r0x <= Rmax r (MaxRlist (cons r0 l))r, r0:Rl:Rlistx:RH:x = r \/ x = r0 \/ In x lHrecl:In x (cons r0 l) -> x <= MaxRlist (cons r0 l)Hrecl0:In x (cons r l) -> (In x l -> x <= MaxRlist l) -> x <= MaxRlist (cons r l)H1:In x lx <= Rmax r (MaxRlist (cons r0 l))r, r0:Rl:Rlistx:RH:In x (cons r (cons r0 l))Hrecl:In x (cons r0 l) -> x <= MaxRlist (cons r0 l)Hrecl0:In x (cons r l) -> (In x l -> x <= MaxRlist l) -> x <= MaxRlist (cons r l)Rmax r (MaxRlist (cons r0 l)) = MaxRlist (cons r (cons r0 l))r, r0:Rl:Rlistx:RH:x = r \/ x = r0 \/ In x lHrecl:In x (cons r0 l) -> x <= MaxRlist (cons r0 l)Hrecl0:In x (cons r l) -> (In x l -> x <= MaxRlist l) -> x <= MaxRlist (cons r l)H1:x = r0r1:r <= MaxRlist (cons r0 l)x <= MaxRlist (cons r0 l)r, r0:Rl:Rlistx:RH:x = r \/ x = r0 \/ In x lHrecl:In x (cons r0 l) -> x <= MaxRlist (cons r0 l)Hrecl0:In x (cons r l) -> (In x l -> x <= MaxRlist l) -> x <= MaxRlist (cons r l)H1:x = r0n:~ r <= MaxRlist (cons r0 l)x <= rr, r0:Rl:Rlistx:RH:x = r \/ x = r0 \/ In x lHrecl:In x (cons r0 l) -> x <= MaxRlist (cons r0 l)Hrecl0:In x (cons r l) -> (In x l -> x <= MaxRlist l) -> x <= MaxRlist (cons r l)H1:In x lx <= Rmax r (MaxRlist (cons r0 l))r, r0:Rl:Rlistx:RH:In x (cons r (cons r0 l))Hrecl:In x (cons r0 l) -> x <= MaxRlist (cons r0 l)Hrecl0:In x (cons r l) -> (In x l -> x <= MaxRlist l) -> x <= MaxRlist (cons r l)Rmax r (MaxRlist (cons r0 l)) = MaxRlist (cons r (cons r0 l))r, r0:Rl:Rlistx:RH:x = r \/ x = r0 \/ In x lHrecl:In x (cons r0 l) -> x <= MaxRlist (cons r0 l)Hrecl0:In x (cons r l) -> (In x l -> x <= MaxRlist l) -> x <= MaxRlist (cons r l)H1:x = r0n:~ r <= MaxRlist (cons r0 l)x <= rr, r0:Rl:Rlistx:RH:x = r \/ x = r0 \/ In x lHrecl:In x (cons r0 l) -> x <= MaxRlist (cons r0 l)Hrecl0:In x (cons r l) -> (In x l -> x <= MaxRlist l) -> x <= MaxRlist (cons r l)H1:In x lx <= Rmax r (MaxRlist (cons r0 l))r, r0:Rl:Rlistx:RH:In x (cons r (cons r0 l))Hrecl:In x (cons r0 l) -> x <= MaxRlist (cons r0 l)Hrecl0:In x (cons r l) -> (In x l -> x <= MaxRlist l) -> x <= MaxRlist (cons r l)Rmax r (MaxRlist (cons r0 l)) = MaxRlist (cons r (cons r0 l))r, r0:Rl:Rlistx:RH:x = r \/ x = r0 \/ In x lHrecl:In x (cons r0 l) -> x <= MaxRlist (cons r0 l)Hrecl0:In x (cons r l) -> (In x l -> x <= MaxRlist l) -> x <= MaxRlist (cons r l)H1:In x lx <= Rmax r (MaxRlist (cons r0 l))r, r0:Rl:Rlistx:RH:In x (cons r (cons r0 l))Hrecl:In x (cons r0 l) -> x <= MaxRlist (cons r0 l)Hrecl0:In x (cons r l) -> (In x l -> x <= MaxRlist l) -> x <= MaxRlist (cons r l)Rmax r (MaxRlist (cons r0 l)) = MaxRlist (cons r (cons r0 l))r, r0:Rl:Rlistx:RH:x = r \/ x = r0 \/ In x lHrecl:In x (cons r0 l) -> x <= MaxRlist (cons r0 l)Hrecl0:In x (cons r l) -> (In x l -> x <= MaxRlist l) -> x <= MaxRlist (cons r l)H1:In x lr1:r <= MaxRlist (cons r0 l)x <= MaxRlist (cons r0 l)r, r0:Rl:Rlistx:RH:x = r \/ x = r0 \/ In x lHrecl:In x (cons r0 l) -> x <= MaxRlist (cons r0 l)Hrecl0:In x (cons r l) -> (In x l -> x <= MaxRlist l) -> x <= MaxRlist (cons r l)H1:In x ln:~ r <= MaxRlist (cons r0 l)x <= rr, r0:Rl:Rlistx:RH:In x (cons r (cons r0 l))Hrecl:In x (cons r0 l) -> x <= MaxRlist (cons r0 l)Hrecl0:In x (cons r l) -> (In x l -> x <= MaxRlist l) -> x <= MaxRlist (cons r l)Rmax r (MaxRlist (cons r0 l)) = MaxRlist (cons r (cons r0 l))r, r0:Rl:Rlistx:RH:x = r \/ x = r0 \/ In x lHrecl:In x (cons r0 l) -> x <= MaxRlist (cons r0 l)Hrecl0:In x (cons r l) -> (In x l -> x <= MaxRlist l) -> x <= MaxRlist (cons r l)H1:In x ln:~ r <= MaxRlist (cons r0 l)x <= rr, r0:Rl:Rlistx:RH:In x (cons r (cons r0 l))Hrecl:In x (cons r0 l) -> x <= MaxRlist (cons r0 l)Hrecl0:In x (cons r l) -> (In x l -> x <= MaxRlist l) -> x <= MaxRlist (cons r l)Rmax r (MaxRlist (cons r0 l)) = MaxRlist (cons r (cons r0 l))reflexivity. Qed. Fixpoint AbsList (l:Rlist) (x:R) : Rlist := match l with | nil => nil | cons a l' => cons (Rabs (a - x) / 2) (AbsList l' x) end.r, r0:Rl:Rlistx:RH:In x (cons r (cons r0 l))Hrecl:In x (cons r0 l) -> x <= MaxRlist (cons r0 l)Hrecl0:In x (cons r l) -> (In x l -> x <= MaxRlist l) -> x <= MaxRlist (cons r l)Rmax r (MaxRlist (cons r0 l)) = MaxRlist (cons r (cons r0 l))forall (l : Rlist) (x : R), In x l -> MinRlist l <= xforall (l : Rlist) (x : R), In x l -> MinRlist l <= xx:RH:In x nilMinRlist nil <= xr:Rl:Rlistx:RH:In x (cons r l)Hrecl:In x l -> MinRlist l <= xMinRlist (cons r l) <= xr:Rl:Rlistx:RH:In x (cons r l)Hrecl:In x l -> MinRlist l <= xMinRlist (cons r l) <= xr, x:RH:In x (cons r nil)Hrecl:In x nil -> MinRlist nil <= xMinRlist (cons r nil) <= xr, r0:Rl:Rlistx:RH:In x (cons r (cons r0 l))Hrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xMinRlist (cons r (cons r0 l)) <= xr, x:RH:x = r \/ FalseHrecl:In x nil -> MinRlist nil <= xH0:x = rMinRlist (cons r nil) <= xr, x:RH:x = r \/ FalseHrecl:In x nil -> MinRlist nil <= xH0:FalseMinRlist (cons r nil) <= xr, r0:Rl:Rlistx:RH:In x (cons r (cons r0 l))Hrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xMinRlist (cons r (cons r0 l)) <= xr, x:RH:x = r \/ FalseHrecl:In x nil -> MinRlist nil <= xH0:FalseMinRlist (cons r nil) <= xr, r0:Rl:Rlistx:RH:In x (cons r (cons r0 l))Hrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xMinRlist (cons r (cons r0 l)) <= xr, r0:Rl:Rlistx:RH:In x (cons r (cons r0 l))Hrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xMinRlist (cons r (cons r0 l)) <= xr, r0:Rl:Rlistx:RH:In x (cons r (cons r0 l))Hrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xRmin r (MinRlist (cons r0 l)) <= xr, r0:Rl:Rlistx:RH:In x (cons r (cons r0 l))Hrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xRmin r (MinRlist (cons r0 l)) = MinRlist (cons r (cons r0 l))r, r0:Rl:Rlistx:RH:x = r \/ x = r0 \/ In x lHrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xH0:x = rRmin r (MinRlist (cons r0 l)) <= xr, r0:Rl:Rlistx:RH:x = r \/ x = r0 \/ In x lHrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xH1:x = r0Rmin r (MinRlist (cons r0 l)) <= xr, r0:Rl:Rlistx:RH:x = r \/ x = r0 \/ In x lHrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xH1:In x lRmin r (MinRlist (cons r0 l)) <= xr, r0:Rl:Rlistx:RH:In x (cons r (cons r0 l))Hrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xRmin r (MinRlist (cons r0 l)) = MinRlist (cons r (cons r0 l))r, r0:Rl:Rlistx:RH:x = r \/ x = r0 \/ In x lHrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xH1:x = r0Rmin r (MinRlist (cons r0 l)) <= xr, r0:Rl:Rlistx:RH:x = r \/ x = r0 \/ In x lHrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xH1:In x lRmin r (MinRlist (cons r0 l)) <= xr, r0:Rl:Rlistx:RH:In x (cons r (cons r0 l))Hrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xRmin r (MinRlist (cons r0 l)) = MinRlist (cons r (cons r0 l))r, r0:Rl:Rlistx:RH:x = r \/ x = r0 \/ In x lHrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xH1:x = r0r1:r <= MinRlist (cons r0 l)r <= xr, r0:Rl:Rlistx:RH:x = r \/ x = r0 \/ In x lHrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xH1:x = r0n:~ r <= MinRlist (cons r0 l)MinRlist (cons r0 l) <= xr, r0:Rl:Rlistx:RH:x = r \/ x = r0 \/ In x lHrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xH1:In x lRmin r (MinRlist (cons r0 l)) <= xr, r0:Rl:Rlistx:RH:In x (cons r (cons r0 l))Hrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xRmin r (MinRlist (cons r0 l)) = MinRlist (cons r (cons r0 l))r, r0:Rl:Rlistx:RH:x = r \/ x = r0 \/ In x lHrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xH1:x = r0r1:r <= MinRlist (cons r0 l)r <= MinRlist (cons r0 l)r, r0:Rl:Rlistx:RH:x = r \/ x = r0 \/ In x lHrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xH1:x = r0r1:r <= MinRlist (cons r0 l)MinRlist (cons r0 l) <= xr, r0:Rl:Rlistx:RH:x = r \/ x = r0 \/ In x lHrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xH1:x = r0n:~ r <= MinRlist (cons r0 l)MinRlist (cons r0 l) <= xr, r0:Rl:Rlistx:RH:x = r \/ x = r0 \/ In x lHrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xH1:In x lRmin r (MinRlist (cons r0 l)) <= xr, r0:Rl:Rlistx:RH:In x (cons r (cons r0 l))Hrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xRmin r (MinRlist (cons r0 l)) = MinRlist (cons r (cons r0 l))r, r0:Rl:Rlistx:RH:x = r \/ x = r0 \/ In x lHrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xH1:x = r0r1:r <= MinRlist (cons r0 l)MinRlist (cons r0 l) <= xr, r0:Rl:Rlistx:RH:x = r \/ x = r0 \/ In x lHrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xH1:x = r0n:~ r <= MinRlist (cons r0 l)MinRlist (cons r0 l) <= xr, r0:Rl:Rlistx:RH:x = r \/ x = r0 \/ In x lHrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xH1:In x lRmin r (MinRlist (cons r0 l)) <= xr, r0:Rl:Rlistx:RH:In x (cons r (cons r0 l))Hrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xRmin r (MinRlist (cons r0 l)) = MinRlist (cons r (cons r0 l))r, r0:Rl:Rlistx:RH:x = r \/ x = r0 \/ In x lHrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xH1:x = r0n:~ r <= MinRlist (cons r0 l)MinRlist (cons r0 l) <= xr, r0:Rl:Rlistx:RH:x = r \/ x = r0 \/ In x lHrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xH1:In x lRmin r (MinRlist (cons r0 l)) <= xr, r0:Rl:Rlistx:RH:In x (cons r (cons r0 l))Hrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xRmin r (MinRlist (cons r0 l)) = MinRlist (cons r (cons r0 l))r, r0:Rl:Rlistx:RH:x = r \/ x = r0 \/ In x lHrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xH1:In x lRmin r (MinRlist (cons r0 l)) <= xr, r0:Rl:Rlistx:RH:In x (cons r (cons r0 l))Hrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xRmin r (MinRlist (cons r0 l)) = MinRlist (cons r (cons r0 l))r, r0:Rl:Rlistx:RH:x = r \/ x = r0 \/ In x lHrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xH1:In x lRmin r (MinRlist (cons r0 l)) <= MinRlist (cons r0 l)r, r0:Rl:Rlistx:RH:x = r \/ x = r0 \/ In x lHrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xH1:In x lMinRlist (cons r0 l) <= xr, r0:Rl:Rlistx:RH:In x (cons r (cons r0 l))Hrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xRmin r (MinRlist (cons r0 l)) = MinRlist (cons r (cons r0 l))r, r0:Rl:Rlistx:RH:x = r \/ x = r0 \/ In x lHrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xH1:In x lMinRlist (cons r0 l) <= xr, r0:Rl:Rlistx:RH:In x (cons r (cons r0 l))Hrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xRmin r (MinRlist (cons r0 l)) = MinRlist (cons r (cons r0 l))reflexivity. Qed.r, r0:Rl:Rlistx:RH:In x (cons r (cons r0 l))Hrecl:In x (cons r0 l) -> MinRlist (cons r0 l) <= xHrecl0:In x (cons r l) -> (In x l -> MinRlist l <= x) -> MinRlist (cons r l) <= xRmin r (MinRlist (cons r0 l)) = MinRlist (cons r (cons r0 l))forall (l : Rlist) (x y : R), In y l -> In (Rabs (y - x) / 2) (AbsList l x)forall (l : Rlist) (x y : R), In y l -> In (Rabs (y - x) / 2) (AbsList l x)x, y:RH:In y nilIn (Rabs (y - x) / 2) (AbsList nil x)r:Rl:Rlistx, y:RH:In y (cons r l)Hrecl:In y l -> In (Rabs (y - x) / 2) (AbsList l x)In (Rabs (y - x) / 2) (AbsList (cons r l) x)r:Rl:Rlistx, y:RH:In y (cons r l)Hrecl:In y l -> In (Rabs (y - x) / 2) (AbsList l x)In (Rabs (y - x) / 2) (AbsList (cons r l) x)r:Rl:Rlistx, y:RH:y = r \/ In y lHrecl:In y l -> In (Rabs (y - x) / 2) (AbsList l x)H0:y = rRabs (y - x) / 2 = Rabs (r - x) / 2 \/ In (Rabs (y - x) / 2) (AbsList l x)r:Rl:Rlistx, y:RH:y = r \/ In y lHrecl:In y l -> In (Rabs (y - x) / 2) (AbsList l x)H0:In y lRabs (y - x) / 2 = Rabs (r - x) / 2 \/ In (Rabs (y - x) / 2) (AbsList l x)right; apply Hrecl; assumption. Qed.r:Rl:Rlistx, y:RH:y = r \/ In y lHrecl:In y l -> In (Rabs (y - x) / 2) (AbsList l x)H0:In y lRabs (y - x) / 2 = Rabs (r - x) / 2 \/ In (Rabs (y - x) / 2) (AbsList l x)forall l : Rlist, (forall y : R, In y l -> 0 < y) -> 0 < MinRlist lforall l : Rlist, (forall y : R, In y l -> 0 < y) -> 0 < MinRlist lH:forall y : R, In y nil -> 0 < y0 < MinRlist nilr:Rl:RlistH:forall y : R, In y (cons r l) -> 0 < yHrecl:(forall y : R, In y l -> 0 < y) -> 0 < MinRlist l0 < MinRlist (cons r l)r:Rl:RlistH:forall y : R, In y (cons r l) -> 0 < yHrecl:(forall y : R, In y l -> 0 < y) -> 0 < MinRlist l0 < MinRlist (cons r l)r:RH:forall y : R, In y (cons r nil) -> 0 < yHrecl:(forall y : R, In y nil -> 0 < y) -> 0 < MinRlist nil0 < MinRlist (cons r nil)r, r0:Rl:RlistH:forall y : R, In y (cons r (cons r0 l)) -> 0 < yHrecl:(forall y : R, In y (cons r0 l) -> 0 < y) -> 0 < MinRlist (cons r0 l)Hrecl0:(forall y : R, In y (cons r l) -> 0 < y) -> ((forall y : R, In y l -> 0 < y) -> 0 < MinRlist l) -> 0 < MinRlist (cons r l)0 < MinRlist (cons r (cons r0 l))r, r0:Rl:RlistH:forall y : R, In y (cons r (cons r0 l)) -> 0 < yHrecl:(forall y : R, In y (cons r0 l) -> 0 < y) -> 0 < MinRlist (cons r0 l)Hrecl0:(forall y : R, In y (cons r l) -> 0 < y) -> ((forall y : R, In y l -> 0 < y) -> 0 < MinRlist l) -> 0 < MinRlist (cons r l)0 < MinRlist (cons r (cons r0 l))r, r0:Rl:RlistH:forall y : R, In y (cons r (cons r0 l)) -> 0 < yHrecl:(forall y : R, In y (cons r0 l) -> 0 < y) -> 0 < MinRlist (cons r0 l)Hrecl0:(forall y : R, In y (cons r l) -> 0 < y) -> ((forall y : R, In y l -> 0 < y) -> 0 < MinRlist l) -> 0 < MinRlist (cons r l)0 < Rmin r (MinRlist (cons r0 l))r, r0:Rl:RlistH:forall y : R, In y (cons r (cons r0 l)) -> 0 < yHrecl:(forall y : R, In y (cons r0 l) -> 0 < y) -> 0 < MinRlist (cons r0 l)Hrecl0:(forall y : R, In y (cons r l) -> 0 < y) -> ((forall y : R, In y l -> 0 < y) -> 0 < MinRlist l) -> 0 < MinRlist (cons r l)Rmin r (MinRlist (cons r0 l)) = MinRlist (cons r (cons r0 l))r, r0:Rl:RlistH:forall y : R, In y (cons r (cons r0 l)) -> 0 < yHrecl:(forall y : R, In y (cons r0 l) -> 0 < y) -> 0 < MinRlist (cons r0 l)Hrecl0:(forall y : R, In y (cons r l) -> 0 < y) -> ((forall y : R, In y l -> 0 < y) -> 0 < MinRlist l) -> 0 < MinRlist (cons r l)r1:r <= MinRlist (cons r0 l)0 < rr, r0:Rl:RlistH:forall y : R, In y (cons r (cons r0 l)) -> 0 < yHrecl:(forall y : R, In y (cons r0 l) -> 0 < y) -> 0 < MinRlist (cons r0 l)Hrecl0:(forall y : R, In y (cons r l) -> 0 < y) -> ((forall y : R, In y l -> 0 < y) -> 0 < MinRlist l) -> 0 < MinRlist (cons r l)n:~ r <= MinRlist (cons r0 l)0 < MinRlist (cons r0 l)r, r0:Rl:RlistH:forall y : R, In y (cons r (cons r0 l)) -> 0 < yHrecl:(forall y : R, In y (cons r0 l) -> 0 < y) -> 0 < MinRlist (cons r0 l)Hrecl0:(forall y : R, In y (cons r l) -> 0 < y) -> ((forall y : R, In y l -> 0 < y) -> 0 < MinRlist l) -> 0 < MinRlist (cons r l)Rmin r (MinRlist (cons r0 l)) = MinRlist (cons r (cons r0 l))r, r0:Rl:RlistH:forall y : R, In y (cons r (cons r0 l)) -> 0 < yHrecl:(forall y : R, In y (cons r0 l) -> 0 < y) -> 0 < MinRlist (cons r0 l)Hrecl0:(forall y : R, In y (cons r l) -> 0 < y) -> ((forall y : R, In y l -> 0 < y) -> 0 < MinRlist l) -> 0 < MinRlist (cons r l)n:~ r <= MinRlist (cons r0 l)0 < MinRlist (cons r0 l)r, r0:Rl:RlistH:forall y : R, In y (cons r (cons r0 l)) -> 0 < yHrecl:(forall y : R, In y (cons r0 l) -> 0 < y) -> 0 < MinRlist (cons r0 l)Hrecl0:(forall y : R, In y (cons r l) -> 0 < y) -> ((forall y : R, In y l -> 0 < y) -> 0 < MinRlist l) -> 0 < MinRlist (cons r l)Rmin r (MinRlist (cons r0 l)) = MinRlist (cons r (cons r0 l))reflexivity. Qed.r, r0:Rl:RlistH:forall y : R, In y (cons r (cons r0 l)) -> 0 < yHrecl:(forall y : R, In y (cons r0 l) -> 0 < y) -> 0 < MinRlist (cons r0 l)Hrecl0:(forall y : R, In y (cons r l) -> 0 < y) -> ((forall y : R, In y l -> 0 < y) -> 0 < MinRlist l) -> 0 < MinRlist (cons r l)Rmin r (MinRlist (cons r0 l)) = MinRlist (cons r (cons r0 l))forall (l : Rlist) (x y : R), In y (AbsList l x) -> exists z : R, In z l /\ y = Rabs (z - x) / 2forall (l : Rlist) (x y : R), In y (AbsList l x) -> exists z : R, In z l /\ y = Rabs (z - x) / 2x, y:RH:In y (AbsList nil x)exists z : R, In z nil /\ y = Rabs (z - x) / 2r:Rl:Rlistx, y:RH:In y (AbsList (cons r l) x)Hrecl:In y (AbsList l x) -> exists z : R, In z l /\ y = Rabs (z - x) / 2exists z : R, In z (cons r l) /\ y = Rabs (z - x) / 2r:Rl:Rlistx, y:RH:In y (AbsList (cons r l) x)Hrecl:In y (AbsList l x) -> exists z : R, In z l /\ y = Rabs (z - x) / 2exists z : R, In z (cons r l) /\ y = Rabs (z - x) / 2r:Rl:Rlistx, y:RH:In y (AbsList (cons r l) x)Hrecl:In y (AbsList l x) -> exists z : R, In z l /\ y = Rabs (z - x) / 2H0:y = Rabs (r - x) / 2exists z : R, In z (cons r l) /\ y = Rabs (z - x) / 2r:Rl:Rlistx, y:RH:In y (AbsList (cons r l) x)Hrecl:In y (AbsList l x) -> exists z : R, In z l /\ y = Rabs (z - x) / 2H0:In y (AbsList l x)exists z : R, In z (cons r l) /\ y = Rabs (z - x) / 2r:Rl:Rlistx, y:RH:In y (AbsList (cons r l) x)Hrecl:In y (AbsList l x) -> exists z : R, In z l /\ y = Rabs (z - x) / 2H0:y = Rabs (r - x) / 2In r (cons r l)r:Rl:Rlistx, y:RH:In y (AbsList (cons r l) x)Hrecl:In y (AbsList l x) -> exists z : R, In z l /\ y = Rabs (z - x) / 2H0:y = Rabs (r - x) / 2y = Rabs (r - x) / 2r:Rl:Rlistx, y:RH:In y (AbsList (cons r l) x)Hrecl:In y (AbsList l x) -> exists z : R, In z l /\ y = Rabs (z - x) / 2H0:In y (AbsList l x)exists z : R, In z (cons r l) /\ y = Rabs (z - x) / 2r:Rl:Rlistx, y:RH:In y (AbsList (cons r l) x)Hrecl:In y (AbsList l x) -> exists z : R, In z l /\ y = Rabs (z - x) / 2H0:y = Rabs (r - x) / 2y = Rabs (r - x) / 2r:Rl:Rlistx, y:RH:In y (AbsList (cons r l) x)Hrecl:In y (AbsList l x) -> exists z : R, In z l /\ y = Rabs (z - x) / 2H0:In y (AbsList l x)exists z : R, In z (cons r l) /\ y = Rabs (z - x) / 2assert (H1 := Hrecl H0); elim H1; intros; elim H2; clear H2; intros; exists x0; simpl; simpl in H2; tauto. Qed.r:Rl:Rlistx, y:RH:In y (AbsList (cons r l) x)Hrecl:In y (AbsList l x) -> exists z : R, In z l /\ y = Rabs (z - x) / 2H0:In y (AbsList l x)exists z : R, In z (cons r l) /\ y = Rabs (z - x) / 2forall l : Rlist, (exists y : R, In y l) -> In (MaxRlist l) lforall l : Rlist, (exists y : R, In y l) -> In (MaxRlist l) lH:exists y : R, In y nilIn (MaxRlist nil) nilr:Rl:RlistH:exists y : R, In y (cons r l)Hrecl:(exists y : R, In y l) -> In (MaxRlist l) lIn (MaxRlist (cons r l)) (cons r l)r:Rl:RlistH:exists y : R, In y (cons r l)Hrecl:(exists y : R, In y l) -> In (MaxRlist l) lIn (MaxRlist (cons r l)) (cons r l)r:RH:exists y : R, In y (cons r nil)Hrecl:(exists y : R, In y nil) -> In (MaxRlist nil) nilIn (MaxRlist (cons r nil)) (cons r nil)r, r0:Rl:RlistH:exists y : R, In y (cons r (cons r0 l))Hrecl:(exists y : R, In y (cons r0 l)) -> In (MaxRlist (cons r0 l)) (cons r0 l)Hrecl0:(exists y : R, In y (cons r l)) -> ((exists y : R, In y l) -> In (MaxRlist l) l) -> In (MaxRlist (cons r l)) (cons r l)In (MaxRlist (cons r (cons r0 l))) (cons r (cons r0 l))r, r0:Rl:RlistH:exists y : R, In y (cons r (cons r0 l))Hrecl:(exists y : R, In y (cons r0 l)) -> In (MaxRlist (cons r0 l)) (cons r0 l)Hrecl0:(exists y : R, In y (cons r l)) -> ((exists y : R, In y l) -> In (MaxRlist l) l) -> In (MaxRlist (cons r l)) (cons r l)In (MaxRlist (cons r (cons r0 l))) (cons r (cons r0 l))r, r0:Rl:RlistH:exists y : R, In y (cons r (cons r0 l))Hrecl:(exists y : R, In y (cons r0 l)) -> In (MaxRlist (cons r0 l)) (cons r0 l)Hrecl0:(exists y : R, In y (cons r l)) -> ((exists y : R, In y l) -> In (MaxRlist l) l) -> In (MaxRlist (cons r l)) (cons r l)r1:r <= MaxRlist (cons r0 l)In (MaxRlist (cons r0 l)) (cons r (cons r0 l))r, r0:Rl:RlistH:exists y : R, In y (cons r (cons r0 l))Hrecl:(exists y : R, In y (cons r0 l)) -> In (MaxRlist (cons r0 l)) (cons r0 l)Hrecl0:(exists y : R, In y (cons r l)) -> ((exists y : R, In y l) -> In (MaxRlist l) l) -> In (MaxRlist (cons r l)) (cons r l)n:~ r <= MaxRlist (cons r0 l)In r (cons r (cons r0 l))left; reflexivity. Qed. Fixpoint pos_Rl (l:Rlist) (i:nat) : R := match l with | nil => 0 | cons a l' => match i with | O => a | S i' => pos_Rl l' i' end end.r, r0:Rl:RlistH:exists y : R, In y (cons r (cons r0 l))Hrecl:(exists y : R, In y (cons r0 l)) -> In (MaxRlist (cons r0 l)) (cons r0 l)Hrecl0:(exists y : R, In y (cons r l)) -> ((exists y : R, In y l) -> In (MaxRlist l) l) -> In (MaxRlist (cons r l)) (cons r l)n:~ r <= MaxRlist (cons r0 l)In r (cons r (cons r0 l))forall (l : Rlist) (a : R), (0 < Rlength l)%nat -> pos_Rl (cons a l) (Rlength l) = pos_Rl l (Init.Nat.pred (Rlength l))intros; induction l as [| r l Hrecl]; [ elim (lt_n_O _ H) | simpl; case (Rlength l); [ reflexivity | intro; reflexivity ] ]. Qed.forall (l : Rlist) (a : R), (0 < Rlength l)%nat -> pos_Rl (cons a l) (Rlength l) = pos_Rl l (Init.Nat.pred (Rlength l))forall (l : Rlist) (x : R), In x l <-> (exists i : nat, (i < Rlength l)%nat /\ x = pos_Rl l i)forall (l : Rlist) (x : R), In x l <-> (exists i : nat, (i < Rlength l)%nat /\ x = pos_Rl l i)x:RIn x nil <-> (exists i : nat, (i < Rlength nil)%nat /\ x = pos_Rl nil i)r:Rl:Rlistx:RHrecl:In x l <-> (exists i : nat, (i < Rlength l)%nat /\ x = pos_Rl l i)In x (cons r l) <-> (exists i : nat, (i < Rlength (cons r l))%nat /\ x = pos_Rl (cons r l) i)r:Rl:Rlistx:RHrecl:In x l <-> (exists i : nat, (i < Rlength l)%nat /\ x = pos_Rl l i)In x (cons r l) <-> (exists i : nat, (i < Rlength (cons r l))%nat /\ x = pos_Rl (cons r l) i)r:Rl:Rlistx:RHrecl:In x l <-> (exists i : nat, (i < Rlength l)%nat /\ x = pos_Rl l i)H:In x (cons r l)exists i : nat, (i < Rlength (cons r l))%nat /\ x = pos_Rl (cons r l) ir:Rl:Rlistx:RHrecl:In x l <-> (exists i : nat, (i < Rlength l)%nat /\ x = pos_Rl l i)H:exists i : nat, (i < Rlength (cons r l))%nat /\ x = pos_Rl (cons r l) iIn x (cons r l)r:Rl:Rlistx:RHrecl:In x l <-> (exists i : nat, (i < Rlength l)%nat /\ x = pos_Rl l i)H:In x (cons r l)H0:x = rexists i : nat, (i < Rlength (cons r l))%nat /\ x = pos_Rl (cons r l) ir:Rl:Rlistx:RHrecl:In x l <-> (exists i : nat, (i < Rlength l)%nat /\ x = pos_Rl l i)H:In x (cons r l)H0:In x lexists i : nat, (i < Rlength (cons r l))%nat /\ x = pos_Rl (cons r l) ir:Rl:Rlistx:RHrecl:In x l <-> (exists i : nat, (i < Rlength l)%nat /\ x = pos_Rl l i)H:exists i : nat, (i < Rlength (cons r l))%nat /\ x = pos_Rl (cons r l) iIn x (cons r l)r:Rl:Rlistx:RHrecl:In x l <-> (exists i : nat, (i < Rlength l)%nat /\ x = pos_Rl l i)H:In x (cons r l)H0:In x lexists i : nat, (i < Rlength (cons r l))%nat /\ x = pos_Rl (cons r l) ir:Rl:Rlistx:RHrecl:In x l <-> (exists i : nat, (i < Rlength l)%nat /\ x = pos_Rl l i)H:exists i : nat, (i < Rlength (cons r l))%nat /\ x = pos_Rl (cons r l) iIn x (cons r l)r:Rl:Rlistx:RHrecl:In x l <-> (exists i : nat, (i < Rlength l)%nat /\ x = pos_Rl l i)H:exists i : nat, (i < Rlength (cons r l))%nat /\ x = pos_Rl (cons r l) iIn x (cons r l)r:Rl:Rlistx:RHrecl:In x l <-> (exists i : nat, (i < Rlength l)%nat /\ x = pos_Rl l i)H:exists i : nat, (i < Rlength (cons r l))%nat /\ x = pos_Rl (cons r l) iH2:x = pos_Rl (cons r l) 0H1:(0 < Rlength (cons r l))%natH0:(0 < Rlength (cons r l))%nat /\ x = pos_Rl (cons r l) 0In x (cons r l)r:Rl:Rlistx:RHrecl:In x l <-> (exists i : nat, (i < Rlength l)%nat /\ x = pos_Rl l i)H:exists i : nat, (i < Rlength (cons r l))%nat /\ x = pos_Rl (cons r l) ix0:natH0:(x0 < Rlength (cons r l))%nat /\ x = pos_Rl (cons r l) x0H1:(x0 < Rlength (cons r l))%natH2:x = pos_Rl (cons r l) x0l0:(0 < x0)%natIn x (cons r l)r:Rl:Rlistx:RHrecl:In x l <-> (exists i : nat, (i < Rlength l)%nat /\ x = pos_Rl l i)H:exists i : nat, (i < Rlength (cons r l))%nat /\ x = pos_Rl (cons r l) ix0:natH0:(x0 < Rlength (cons r l))%nat /\ x = pos_Rl (cons r l) x0H1:(x0 < Rlength (cons r l))%natH2:x = pos_Rl (cons r l) x0l0:(0 < x0)%natIn x (cons r l)r:Rl:Rlistx:RHrecl:In x l <-> (exists i : nat, (i < Rlength l)%nat /\ x = pos_Rl l i)H:exists i : nat, (i < Rlength (cons r l))%nat /\ x = pos_Rl (cons r l) ix0:natH0:(x0 < Rlength (cons r l))%nat /\ x = pos_Rl (cons r l) x0H1:(x0 < Rlength (cons r l))%natH2:x = pos_Rl (cons r l) x0l0:(0 < x0)%natH4:In x l -> exists i : nat, (i < Rlength l)%nat /\ x = pos_Rl l iH5:(exists i : nat, (i < Rlength l)%nat /\ x = pos_Rl l i) -> In x lS (Init.Nat.pred x0) = x0r:Rl:Rlistx:RHrecl:In x l <-> (exists i : nat, (i < Rlength l)%nat /\ x = pos_Rl l i)H:exists i : nat, (i < Rlength (cons r l))%nat /\ x = pos_Rl (cons r l) ix0:natH0:(x0 < Rlength (cons r l))%nat /\ x = pos_Rl (cons r l) x0H1:(x0 < Rlength (cons r l))%natH2:x = pos_Rl (cons r l) x0l0:(0 < x0)%natH4:In x l -> exists i : nat, (i < Rlength l)%nat /\ x = pos_Rl l iH5:(exists i : nat, (i < Rlength l)%nat /\ x = pos_Rl l i) -> In x lH6:S (Init.Nat.pred x0) = x0exists i : nat, (i < Rlength l)%nat /\ x = pos_Rl l iexists (pred x0); split; [ simpl in H1; apply lt_S_n; rewrite H6; assumption | rewrite <- H6 in H2; simpl in H2; assumption ]. Qed.r:Rl:Rlistx:RHrecl:In x l <-> (exists i : nat, (i < Rlength l)%nat /\ x = pos_Rl l i)H:exists i : nat, (i < Rlength (cons r l))%nat /\ x = pos_Rl (cons r l) ix0:natH0:(x0 < Rlength (cons r l))%nat /\ x = pos_Rl (cons r l) x0H1:(x0 < Rlength (cons r l))%natH2:x = pos_Rl (cons r l) x0l0:(0 < x0)%natH4:In x l -> exists i : nat, (i < Rlength l)%nat /\ x = pos_Rl l iH5:(exists i : nat, (i < Rlength l)%nat /\ x = pos_Rl l i) -> In x lH6:S (Init.Nat.pred x0) = x0exists i : nat, (i < Rlength l)%nat /\ x = pos_Rl l iforall (l : Rlist) (P : R -> R -> Prop), (forall x : R, In x l -> exists y : R, P x y) -> exists l' : Rlist, Rlength l = Rlength l' /\ (forall i : nat, (i < Rlength l)%nat -> P (pos_Rl l i) (pos_Rl l' i))forall (l : Rlist) (P : R -> R -> Prop), (forall x : R, In x l -> exists y : R, P x y) -> exists l' : Rlist, Rlength l = Rlength l' /\ (forall i : nat, (i < Rlength l)%nat -> P (pos_Rl l i) (pos_Rl l' i))P:R -> R -> PropH:forall x : R, In x nil -> exists y : R, P x yexists l' : Rlist, Rlength nil = Rlength l' /\ (forall i : nat, (i < Rlength nil)%nat -> P (pos_Rl nil i) (pos_Rl l' i))r:Rl:RlistP:R -> R -> PropH:forall x : R, In x (cons r l) -> exists y : R, P x yHrecl:(forall x : R, In x l -> exists y : R, P x y) -> exists l' : Rlist, Rlength l = Rlength l' /\ (forall i : nat, (i < Rlength l)%nat -> P (pos_Rl l i) (pos_Rl l' i))exists l' : Rlist, Rlength (cons r l) = Rlength l' /\ (forall i : nat, (i < Rlength (cons r l))%nat -> P (pos_Rl (cons r l) i) (pos_Rl l' i))r:Rl:RlistP:R -> R -> PropH:forall x : R, In x (cons r l) -> exists y : R, P x yHrecl:(forall x : R, In x l -> exists y : R, P x y) -> exists l' : Rlist, Rlength l = Rlength l' /\ (forall i : nat, (i < Rlength l)%nat -> P (pos_Rl l i) (pos_Rl l' i))exists l' : Rlist, Rlength (cons r l) = Rlength l' /\ (forall i : nat, (i < Rlength (cons r l))%nat -> P (pos_Rl (cons r l) i) (pos_Rl l' i))r:Rl:RlistP:R -> R -> PropH:forall x : R, In x (cons r l) -> exists y : R, P x yHrecl:(forall x : R, In x l -> exists y : R, P x y) -> exists l' : Rlist, Rlength l = Rlength l' /\ (forall i : nat, (i < Rlength l)%nat -> P (pos_Rl l i) (pos_Rl l' i))In r (cons r l)r:Rl:RlistP:R -> R -> PropH:forall x : R, In x (cons r l) -> exists y : R, P x yHrecl:(forall x : R, In x l -> exists y : R, P x y) -> exists l' : Rlist, Rlength l = Rlength l' /\ (forall i : nat, (i < Rlength l)%nat -> P (pos_Rl l i) (pos_Rl l' i))H0:In r (cons r l)exists l' : Rlist, Rlength (cons r l) = Rlength l' /\ (forall i : nat, (i < Rlength (cons r l))%nat -> P (pos_Rl (cons r l) i) (pos_Rl l' i))r:Rl:RlistP:R -> R -> PropH:forall x : R, In x (cons r l) -> exists y : R, P x yHrecl:(forall x : R, In x l -> exists y : R, P x y) -> exists l' : Rlist, Rlength l = Rlength l' /\ (forall i : nat, (i < Rlength l)%nat -> P (pos_Rl l i) (pos_Rl l' i))H0:In r (cons r l)exists l' : Rlist, Rlength (cons r l) = Rlength l' /\ (forall i : nat, (i < Rlength (cons r l))%nat -> P (pos_Rl (cons r l) i) (pos_Rl l' i))r:Rl:RlistP:R -> R -> PropH:forall x : R, In x (cons r l) -> exists y : R, P x yHrecl:(forall x : R, In x l -> exists y : R, P x y) -> exists l' : Rlist, Rlength l = Rlength l' /\ (forall i : nat, (i < Rlength l)%nat -> P (pos_Rl l i) (pos_Rl l' i))H0:In r (cons r l)H1:exists y : R, P r yforall x : R, In x l -> exists y : R, P x yr:Rl:RlistP:R -> R -> PropH:forall x : R, In x (cons r l) -> exists y : R, P x yHrecl:(forall x : R, In x l -> exists y : R, P x y) -> exists l' : Rlist, Rlength l = Rlength l' /\ (forall i : nat, (i < Rlength l)%nat -> P (pos_Rl l i) (pos_Rl l' i))H0:In r (cons r l)H1:exists y : R, P r yH2:forall x : R, In x l -> exists y : R, P x yexists l' : Rlist, Rlength (cons r l) = Rlength l' /\ (forall i : nat, (i < Rlength (cons r l))%nat -> P (pos_Rl (cons r l) i) (pos_Rl l' i))r:Rl:RlistP:R -> R -> PropH:forall x : R, In x (cons r l) -> exists y : R, P x yHrecl:(forall x : R, In x l -> exists y : R, P x y) -> exists l' : Rlist, Rlength l = Rlength l' /\ (forall i : nat, (i < Rlength l)%nat -> P (pos_Rl l i) (pos_Rl l' i))H0:In r (cons r l)H1:exists y : R, P r yH2:forall x : R, In x l -> exists y : R, P x yexists l' : Rlist, Rlength (cons r l) = Rlength l' /\ (forall i : nat, (i < Rlength (cons r l))%nat -> P (pos_Rl (cons r l) i) (pos_Rl l' i))r:Rl:RlistP:R -> R -> PropH:forall x1 : R, In x1 (cons r l) -> exists y : R, P x1 yHrecl:(forall x1 : R, In x1 l -> exists y : R, P x1 y) -> exists l' : Rlist, Rlength l = Rlength l' /\ (forall i : nat, (i < Rlength l)%nat -> P (pos_Rl l i) (pos_Rl l' i))H0:In r (cons r l)H1:exists y : R, P r yH2:forall x1 : R, In x1 l -> exists y : R, P x1 yH3:exists l' : Rlist, Rlength l = Rlength l' /\ (forall i : nat, (i < Rlength l)%nat -> P (pos_Rl l i) (pos_Rl l' i))x:RH4:P r xx0:RlistH5:Rlength l = Rlength x0H6:forall i : nat, (i < Rlength l)%nat -> P (pos_Rl l i) (pos_Rl x0 i)Rlength (cons r l) = Rlength (cons x x0)r:Rl:RlistP:R -> R -> PropH:forall x1 : R, In x1 (cons r l) -> exists y : R, P x1 yHrecl:(forall x1 : R, In x1 l -> exists y : R, P x1 y) -> exists l' : Rlist, Rlength l = Rlength l' /\ (forall i : nat, (i < Rlength l)%nat -> P (pos_Rl l i) (pos_Rl l' i))H0:In r (cons r l)H1:exists y : R, P r yH2:forall x1 : R, In x1 l -> exists y : R, P x1 yH3:exists l' : Rlist, Rlength l = Rlength l' /\ (forall i : nat, (i < Rlength l)%nat -> P (pos_Rl l i) (pos_Rl l' i))x:RH4:P r xx0:RlistH5:Rlength l = Rlength x0H6:forall i : nat, (i < Rlength l)%nat -> P (pos_Rl l i) (pos_Rl x0 i)forall i : nat, (i < Rlength (cons r l))%nat -> P (pos_Rl (cons r l) i) (pos_Rl (cons x x0) i)r:Rl:RlistP:R -> R -> PropH:forall x1 : R, In x1 (cons r l) -> exists y : R, P x1 yHrecl:(forall x1 : R, In x1 l -> exists y : R, P x1 y) -> exists l' : Rlist, Rlength l = Rlength l' /\ (forall i : nat, (i < Rlength l)%nat -> P (pos_Rl l i) (pos_Rl l' i))H0:In r (cons r l)H1:exists y : R, P r yH2:forall x1 : R, In x1 l -> exists y : R, P x1 yH3:exists l' : Rlist, Rlength l = Rlength l' /\ (forall i : nat, (i < Rlength l)%nat -> P (pos_Rl l i) (pos_Rl l' i))x:RH4:P r xx0:RlistH5:Rlength l = Rlength x0H6:forall i : nat, (i < Rlength l)%nat -> P (pos_Rl l i) (pos_Rl x0 i)forall i : nat, (i < Rlength (cons r l))%nat -> P (pos_Rl (cons r l) i) (pos_Rl (cons x x0) i)r:Rl:RlistP:R -> R -> PropH:forall x1 : R, In x1 (cons r l) -> exists y : R, P x1 yHrecl:(forall x1 : R, In x1 l -> exists y : R, P x1 y) -> exists l' : Rlist, Rlength l = Rlength l' /\ (forall i : nat, (i < Rlength l)%nat -> P (pos_Rl l i) (pos_Rl l' i))H0:In r (cons r l)H1:exists y : R, P r yH2:forall x1 : R, In x1 l -> exists y : R, P x1 yH3:exists l' : Rlist, Rlength l = Rlength l' /\ (forall i : nat, (i < Rlength l)%nat -> P (pos_Rl l i) (pos_Rl l' i))x:RH4:P r xx0:RlistH5:Rlength l = Rlength x0H6:forall i : nat, (i < Rlength l)%nat -> P (pos_Rl l i) (pos_Rl x0 i)H7:(0 < Rlength (cons r l))%natP (pos_Rl (cons r l) 0) (pos_Rl (cons x x0) 0)r:Rl:RlistP:R -> R -> PropH:forall x1 : R, In x1 (cons r l) -> exists y : R, P x1 yHrecl:(forall x1 : R, In x1 l -> exists y : R, P x1 y) -> exists l' : Rlist, Rlength l = Rlength l' /\ (forall i0 : nat, (i0 < Rlength l)%nat -> P (pos_Rl l i0) (pos_Rl l' i0))H0:In r (cons r l)H1:exists y : R, P r yH2:forall x1 : R, In x1 l -> exists y : R, P x1 yH3:exists l' : Rlist, Rlength l = Rlength l' /\ (forall i0 : nat, (i0 < Rlength l)%nat -> P (pos_Rl l i0) (pos_Rl l' i0))x:RH4:P r xx0:RlistH5:Rlength l = Rlength x0H6:forall i0 : nat, (i0 < Rlength l)%nat -> P (pos_Rl l i0) (pos_Rl x0 i0)i:natH7:(i < Rlength (cons r l))%natl0:(0 < i)%natP (pos_Rl (cons r l) i) (pos_Rl (cons x x0) i)r:Rl:RlistP:R -> R -> PropH:forall x1 : R, In x1 (cons r l) -> exists y : R, P x1 yHrecl:(forall x1 : R, In x1 l -> exists y : R, P x1 y) -> exists l' : Rlist, Rlength l = Rlength l' /\ (forall i0 : nat, (i0 < Rlength l)%nat -> P (pos_Rl l i0) (pos_Rl l' i0))H0:In r (cons r l)H1:exists y : R, P r yH2:forall x1 : R, In x1 l -> exists y : R, P x1 yH3:exists l' : Rlist, Rlength l = Rlength l' /\ (forall i0 : nat, (i0 < Rlength l)%nat -> P (pos_Rl l i0) (pos_Rl l' i0))x:RH4:P r xx0:RlistH5:Rlength l = Rlength x0H6:forall i0 : nat, (i0 < Rlength l)%nat -> P (pos_Rl l i0) (pos_Rl x0 i0)i:natH7:(i < Rlength (cons r l))%natl0:(0 < i)%natP (pos_Rl (cons r l) i) (pos_Rl (cons x x0) i)r:Rl:RlistP:R -> R -> PropH:forall x1 : R, In x1 (cons r l) -> exists y : R, P x1 yHrecl:(forall x1 : R, In x1 l -> exists y : R, P x1 y) -> exists l' : Rlist, Rlength l = Rlength l' /\ (forall i0 : nat, (i0 < Rlength l)%nat -> P (pos_Rl l i0) (pos_Rl l' i0))H0:In r (cons r l)H1:exists y : R, P r yH2:forall x1 : R, In x1 l -> exists y : R, P x1 yH3:exists l' : Rlist, Rlength l = Rlength l' /\ (forall i0 : nat, (i0 < Rlength l)%nat -> P (pos_Rl l i0) (pos_Rl l' i0))x:RH4:P r xx0:RlistH5:Rlength l = Rlength x0H6:forall i0 : nat, (i0 < Rlength l)%nat -> P (pos_Rl l i0) (pos_Rl x0 i0)i:natH7:(i < Rlength (cons r l))%natl0:(0 < i)%nati = S (Init.Nat.pred i)r:Rl:RlistP:R -> R -> PropH:forall x1 : R, In x1 (cons r l) -> exists y : R, P x1 yHrecl:(forall x1 : R, In x1 l -> exists y : R, P x1 y) -> exists l' : Rlist, Rlength l = Rlength l' /\ (forall i0 : nat, (i0 < Rlength l)%nat -> P (pos_Rl l i0) (pos_Rl l' i0))H0:In r (cons r l)H1:exists y : R, P r yH2:forall x1 : R, In x1 l -> exists y : R, P x1 yH3:exists l' : Rlist, Rlength l = Rlength l' /\ (forall i0 : nat, (i0 < Rlength l)%nat -> P (pos_Rl l i0) (pos_Rl l' i0))x:RH4:P r xx0:RlistH5:Rlength l = Rlength x0H6:forall i0 : nat, (i0 < Rlength l)%nat -> P (pos_Rl l i0) (pos_Rl x0 i0)i:natH7:(i < Rlength (cons r l))%natl0:(0 < i)%natH9:i = S (Init.Nat.pred i)P (pos_Rl (cons r l) i) (pos_Rl (cons x x0) i)rewrite H9; simpl; apply H6; simpl in H7; apply lt_S_n; rewrite <- H9; assumption. Qed. Definition ordered_Rlist (l:Rlist) : Prop := forall i:nat, (i < pred (Rlength l))%nat -> pos_Rl l i <= pos_Rl l (S i). Fixpoint insert (l:Rlist) (x:R) : Rlist := match l with | nil => cons x nil | cons a l' => match Rle_dec a x with | left _ => cons a (insert l' x) | right _ => cons x l end end. Fixpoint cons_Rlist (l k:Rlist) : Rlist := match l with | nil => k | cons a l' => cons a (cons_Rlist l' k) end. Fixpoint cons_ORlist (k l:Rlist) : Rlist := match k with | nil => l | cons a k' => cons_ORlist k' (insert l a) end. Fixpoint app_Rlist (l:Rlist) (f:R -> R) : Rlist := match l with | nil => nil | cons a l' => cons (f a) (app_Rlist l' f) end. Fixpoint mid_Rlist (l:Rlist) (x:R) : Rlist := match l with | nil => nil | cons a l' => cons ((x + a) / 2) (mid_Rlist l' a) end. Definition Rtail (l:Rlist) : Rlist := match l with | nil => nil | cons a l' => l' end. Definition FF (l:Rlist) (f:R -> R) : Rlist := match l with | nil => nil | cons a l' => app_Rlist (mid_Rlist l' a) f end.r:Rl:RlistP:R -> R -> PropH:forall x1 : R, In x1 (cons r l) -> exists y : R, P x1 yHrecl:(forall x1 : R, In x1 l -> exists y : R, P x1 y) -> exists l' : Rlist, Rlength l = Rlength l' /\ (forall i0 : nat, (i0 < Rlength l)%nat -> P (pos_Rl l i0) (pos_Rl l' i0))H0:In r (cons r l)H1:exists y : R, P r yH2:forall x1 : R, In x1 l -> exists y : R, P x1 yH3:exists l' : Rlist, Rlength l = Rlength l' /\ (forall i0 : nat, (i0 < Rlength l)%nat -> P (pos_Rl l i0) (pos_Rl l' i0))x:RH4:P r xx0:RlistH5:Rlength l = Rlength x0H6:forall i0 : nat, (i0 < Rlength l)%nat -> P (pos_Rl l i0) (pos_Rl x0 i0)i:natH7:(i < Rlength (cons r l))%natl0:(0 < i)%natH9:i = S (Init.Nat.pred i)P (pos_Rl (cons r l) i) (pos_Rl (cons x x0) i)forall (l : Rlist) (a : R), pos_Rl (insert l a) 0 = a \/ pos_Rl (insert l a) 0 = pos_Rl l 0intros; induction l as [| r l Hrecl]; [ left; reflexivity | simpl; case (Rle_dec r a); intro; [ right; reflexivity | left; reflexivity ] ]. Qed.forall (l : Rlist) (a : R), pos_Rl (insert l a) 0 = a \/ pos_Rl (insert l a) 0 = pos_Rl l 0forall (l : Rlist) (a : R), ordered_Rlist l -> ordered_Rlist (insert l a)forall (l : Rlist) (a : R), ordered_Rlist l -> ordered_Rlist (insert l a)a:RH:ordered_Rlist nilordered_Rlist (insert nil a)r:Rl:Rlista:RH:ordered_Rlist (cons r l)Hrecl:ordered_Rlist l -> ordered_Rlist (insert l a)ordered_Rlist (insert (cons r l) a)r:Rl:Rlista:RH:ordered_Rlist (cons r l)Hrecl:ordered_Rlist l -> ordered_Rlist (insert l a)ordered_Rlist (insert (cons r l) a)r:Rl:Rlista:RH:ordered_Rlist (cons r l)Hrecl:ordered_Rlist l -> ordered_Rlist (insert l a)r0:r <= aordered_Rlist (cons r (insert l a))r:Rl:Rlista:RH:ordered_Rlist (cons r l)Hrecl:ordered_Rlist l -> ordered_Rlist (insert l a)n:~ r <= aordered_Rlist (cons a (cons r l))r:Rl:Rlista:RH:ordered_Rlist (cons r l)Hrecl:ordered_Rlist l -> ordered_Rlist (insert l a)r0:r <= aordered_Rlist lr:Rl:Rlista:RH:ordered_Rlist (cons r l)Hrecl:ordered_Rlist l -> ordered_Rlist (insert l a)r0:r <= aH1:ordered_Rlist lordered_Rlist (cons r (insert l a))r:Rl:Rlista:RH:ordered_Rlist (cons r l)Hrecl:ordered_Rlist l -> ordered_Rlist (insert l a)n:~ r <= aordered_Rlist (cons a (cons r l))r:Rl:Rlista:RH:ordered_Rlist (cons r l)Hrecl:ordered_Rlist l -> ordered_Rlist (insert l a)r0:r <= aH1:ordered_Rlist lordered_Rlist (cons r (insert l a))r:Rl:Rlista:RH:ordered_Rlist (cons r l)Hrecl:ordered_Rlist l -> ordered_Rlist (insert l a)n:~ r <= aordered_Rlist (cons a (cons r l))r:Rl:Rlista:RH:ordered_Rlist (cons r l)Hrecl:ordered_Rlist l -> ordered_Rlist (insert l a)r0:r <= aH1:ordered_Rlist lH2:ordered_Rlist (insert l a)H0:(0 < Init.Nat.pred (Rlength (cons r (insert l a))))%natpos_Rl (cons r (insert l a)) 0 <= pos_Rl (cons r (insert l a)) 1r:Rl:Rlista:RH:ordered_Rlist (cons r l)Hrecl:ordered_Rlist l -> ordered_Rlist (insert l a)r0:r <= aH1:ordered_Rlist lH2:ordered_Rlist (insert l a)i:natH0:(S i < Init.Nat.pred (Rlength (cons r (insert l a))))%natHreci:(i < Init.Nat.pred (Rlength (cons r (insert l a))))%nat -> pos_Rl (cons r (insert l a)) i <= pos_Rl (cons r (insert l a)) (S i)pos_Rl (cons r (insert l a)) (S i) <= pos_Rl (cons r (insert l a)) (S (S i))r:Rl:Rlista:RH:ordered_Rlist (cons r l)Hrecl:ordered_Rlist l -> ordered_Rlist (insert l a)n:~ r <= aordered_Rlist (cons a (cons r l))r:Rl:Rlista:RH:ordered_Rlist (cons r l)Hrecl:ordered_Rlist l -> ordered_Rlist (insert l a)r0:r <= aH1:ordered_Rlist lH2:ordered_Rlist (insert l a)H0:(0 < Init.Nat.pred (Rlength (cons r (insert l a))))%natH3:pos_Rl (insert l a) 0 = a \/ pos_Rl (insert l a) 0 = pos_Rl l 0H4:pos_Rl (insert l a) 0 = ar <= pos_Rl (insert l a) 0r:Rl:Rlista:RH:ordered_Rlist (cons r l)Hrecl:ordered_Rlist l -> ordered_Rlist (insert l a)r0:r <= aH1:ordered_Rlist lH2:ordered_Rlist (insert l a)H0:(0 < Init.Nat.pred (Rlength (cons r (insert l a))))%natH3:pos_Rl (insert l a) 0 = a \/ pos_Rl (insert l a) 0 = pos_Rl l 0H4:pos_Rl (insert l a) 0 = pos_Rl l 0r <= pos_Rl (insert l a) 0r:Rl:Rlista:RH:ordered_Rlist (cons r l)Hrecl:ordered_Rlist l -> ordered_Rlist (insert l a)r0:r <= aH1:ordered_Rlist lH2:ordered_Rlist (insert l a)i:natH0:(S i < Init.Nat.pred (Rlength (cons r (insert l a))))%natHreci:(i < Init.Nat.pred (Rlength (cons r (insert l a))))%nat -> pos_Rl (cons r (insert l a)) i <= pos_Rl (cons r (insert l a)) (S i)pos_Rl (cons r (insert l a)) (S i) <= pos_Rl (cons r (insert l a)) (S (S i))r:Rl:Rlista:RH:ordered_Rlist (cons r l)Hrecl:ordered_Rlist l -> ordered_Rlist (insert l a)n:~ r <= aordered_Rlist (cons a (cons r l))r:Rl:Rlista:RH:ordered_Rlist (cons r l)Hrecl:ordered_Rlist l -> ordered_Rlist (insert l a)r0:r <= aH1:ordered_Rlist lH2:ordered_Rlist (insert l a)H0:(0 < Init.Nat.pred (Rlength (cons r (insert l a))))%natH3:pos_Rl (insert l a) 0 = a \/ pos_Rl (insert l a) 0 = pos_Rl l 0H4:pos_Rl (insert l a) 0 = pos_Rl l 0r <= pos_Rl (insert l a) 0r:Rl:Rlista:RH:ordered_Rlist (cons r l)Hrecl:ordered_Rlist l -> ordered_Rlist (insert l a)r0:r <= aH1:ordered_Rlist lH2:ordered_Rlist (insert l a)i:natH0:(S i < Init.Nat.pred (Rlength (cons r (insert l a))))%natHreci:(i < Init.Nat.pred (Rlength (cons r (insert l a))))%nat -> pos_Rl (cons r (insert l a)) i <= pos_Rl (cons r (insert l a)) (S i)pos_Rl (cons r (insert l a)) (S i) <= pos_Rl (cons r (insert l a)) (S (S i))r:Rl:Rlista:RH:ordered_Rlist (cons r l)Hrecl:ordered_Rlist l -> ordered_Rlist (insert l a)n:~ r <= aordered_Rlist (cons a (cons r l))r:Rl:Rlista:RH:ordered_Rlist (cons r l)Hrecl:ordered_Rlist l -> ordered_Rlist (insert l a)r0:r <= aH1:ordered_Rlist lH2:ordered_Rlist (insert l a)i:natH0:(S i < Init.Nat.pred (Rlength (cons r (insert l a))))%natHreci:(i < Init.Nat.pred (Rlength (cons r (insert l a))))%nat -> pos_Rl (cons r (insert l a)) i <= pos_Rl (cons r (insert l a)) (S i)pos_Rl (cons r (insert l a)) (S i) <= pos_Rl (cons r (insert l a)) (S (S i))r:Rl:Rlista:RH:ordered_Rlist (cons r l)Hrecl:ordered_Rlist l -> ordered_Rlist (insert l a)n:~ r <= aordered_Rlist (cons a (cons r l))unfold ordered_Rlist; intros; induction i as [| i Hreci]; [ simpl; auto with real | change (pos_Rl (cons r l) i <= pos_Rl (cons r l) (S i)); apply H; simpl in H0; simpl; apply (lt_S_n _ _ H0) ]. Qed.r:Rl:Rlista:RH:ordered_Rlist (cons r l)Hrecl:ordered_Rlist l -> ordered_Rlist (insert l a)n:~ r <= aordered_Rlist (cons a (cons r l))forall l1 l2 : Rlist, ordered_Rlist l2 -> ordered_Rlist (cons_ORlist l1 l2)simple induction l1; [ intros; simpl; apply H | intros; simpl; apply H; apply RList_P1; assumption ]. Qed.forall l1 l2 : Rlist, ordered_Rlist l2 -> ordered_Rlist (cons_ORlist l1 l2)forall (l : Rlist) (x : R), In x l <-> (exists i : nat, x = pos_Rl l i /\ (i < Rlength l)%nat)forall (l : Rlist) (x : R), In x l <-> (exists i : nat, x = pos_Rl l i /\ (i < Rlength l)%nat)x:RH:In x nilexists i : nat, x = pos_Rl nil i /\ (i < Rlength nil)%natr:Rl:Rlistx:RH:In x (cons r l)Hrecl:In x l -> exists i : nat, x = pos_Rl l i /\ (i < Rlength l)%natexists i : nat, x = pos_Rl (cons r l) i /\ (i < Rlength (cons r l))%natx:RH:exists i : nat, x = pos_Rl nil i /\ (i < Rlength nil)%natIn x nilr:Rl:Rlistx:RH:exists i : nat, x = pos_Rl (cons r l) i /\ (i < Rlength (cons r l))%natHrecl:(exists i : nat, x = pos_Rl l i /\ (i < Rlength l)%nat) -> In x lIn x (cons r l)r:Rl:Rlistx:RH:In x (cons r l)Hrecl:In x l -> exists i : nat, x = pos_Rl l i /\ (i < Rlength l)%natexists i : nat, x = pos_Rl (cons r l) i /\ (i < Rlength (cons r l))%natx:RH:exists i : nat, x = pos_Rl nil i /\ (i < Rlength nil)%natIn x nilr:Rl:Rlistx:RH:exists i : nat, x = pos_Rl (cons r l) i /\ (i < Rlength (cons r l))%natHrecl:(exists i : nat, x = pos_Rl l i /\ (i < Rlength l)%nat) -> In x lIn x (cons r l)x:RH:exists i : nat, x = pos_Rl nil i /\ (i < Rlength nil)%natIn x nilr:Rl:Rlistx:RH:exists i : nat, x = pos_Rl (cons r l) i /\ (i < Rlength (cons r l))%natHrecl:(exists i : nat, x = pos_Rl l i /\ (i < Rlength l)%nat) -> In x lIn x (cons r l)simpl; elim H; intros; elim H0; clear H0; intros; induction x0 as [| x0 Hrecx0]; [ left; apply H0 | right; apply Hrecl; exists x0; split; [ apply H0 | simpl in H1; apply lt_S_n; assumption ] ]. Qed.r:Rl:Rlistx:RH:exists i : nat, x = pos_Rl (cons r l) i /\ (i < Rlength (cons r l))%natHrecl:(exists i : nat, x = pos_Rl l i /\ (i < Rlength l)%nat) -> In x lIn x (cons r l)forall (l1 : Rlist) (a : R), ordered_Rlist (cons a l1) -> ordered_Rlist l1intros; unfold ordered_Rlist; intros; apply (H (S i)); simpl; replace (Rlength l1) with (S (pred (Rlength l1))); [ apply lt_n_S; assumption | symmetry ; apply S_pred with 0%nat; apply neq_O_lt; red; intro; rewrite <- H1 in H0; elim (lt_n_O _ H0) ]. Qed.forall (l1 : Rlist) (a : R), ordered_Rlist (cons a l1) -> ordered_Rlist l1forall (l : Rlist) (x : R), ordered_Rlist l -> In x l -> pos_Rl l 0 <= xintros; induction l as [| r l Hrecl]; [ elim H0 | simpl; elim H0; intro; [ rewrite H1; right; reflexivity | apply Rle_trans with (pos_Rl l 0); [ apply (H 0%nat); simpl; induction l as [| r0 l Hrecl0]; [ elim H1 | simpl; apply lt_O_Sn ] | apply Hrecl; [ eapply RList_P4; apply H | assumption ] ] ] ]. Qed.forall (l : Rlist) (x : R), ordered_Rlist l -> In x l -> pos_Rl l 0 <= xforall l : Rlist, ordered_Rlist l <-> (forall i j : nat, (i <= j)%nat -> (j < Rlength l)%nat -> pos_Rl l i <= pos_Rl l j)forall l : Rlist, ordered_Rlist l <-> (forall i j : nat, (i <= j)%nat -> (j < Rlength l)%nat -> pos_Rl l i <= pos_Rl l j)l:RlistH:ordered_Rlist nilforall i j : nat, (i <= j)%nat -> (j < Rlength nil)%nat -> pos_Rl nil i <= pos_Rl nil jl:RlistH:forall i j : nat, (i <= j)%nat -> (j < Rlength nil)%nat -> pos_Rl nil i <= pos_Rl nil jordered_Rlist nill:Rlistr:Rr0:RlistH:ordered_Rlist r0 <-> (forall i j : nat, (i <= j)%nat -> (j < Rlength r0)%nat -> pos_Rl r0 i <= pos_Rl r0 j)H0:ordered_Rlist (cons r r0)forall i j : nat, (i <= j)%nat -> (j < Rlength (cons r r0))%nat -> pos_Rl (cons r r0) i <= pos_Rl (cons r r0) jl:Rlistr:Rr0:RlistH:ordered_Rlist r0 <-> (forall i j : nat, (i <= j)%nat -> (j < Rlength r0)%nat -> pos_Rl r0 i <= pos_Rl r0 j)H0:forall i j : nat, (i <= j)%nat -> (j < Rlength (cons r r0))%nat -> pos_Rl (cons r r0) i <= pos_Rl (cons r r0) jordered_Rlist (cons r r0)l:RlistH:forall i j : nat, (i <= j)%nat -> (j < Rlength nil)%nat -> pos_Rl nil i <= pos_Rl nil jordered_Rlist nill:Rlistr:Rr0:RlistH:ordered_Rlist r0 <-> (forall i j : nat, (i <= j)%nat -> (j < Rlength r0)%nat -> pos_Rl r0 i <= pos_Rl r0 j)H0:ordered_Rlist (cons r r0)forall i j : nat, (i <= j)%nat -> (j < Rlength (cons r r0))%nat -> pos_Rl (cons r r0) i <= pos_Rl (cons r r0) jl:Rlistr:Rr0:RlistH:ordered_Rlist r0 <-> (forall i j : nat, (i <= j)%nat -> (j < Rlength r0)%nat -> pos_Rl r0 i <= pos_Rl r0 j)H0:forall i j : nat, (i <= j)%nat -> (j < Rlength (cons r r0))%nat -> pos_Rl (cons r r0) i <= pos_Rl (cons r r0) jordered_Rlist (cons r r0)l:Rlistr:Rr0:RlistH:ordered_Rlist r0 <-> (forall i j : nat, (i <= j)%nat -> (j < Rlength r0)%nat -> pos_Rl r0 i <= pos_Rl r0 j)H0:ordered_Rlist (cons r r0)forall i j : nat, (i <= j)%nat -> (j < Rlength (cons r r0))%nat -> pos_Rl (cons r r0) i <= pos_Rl (cons r r0) jl:Rlistr:Rr0:RlistH:ordered_Rlist r0 <-> (forall i j : nat, (i <= j)%nat -> (j < Rlength r0)%nat -> pos_Rl r0 i <= pos_Rl r0 j)H0:forall i j : nat, (i <= j)%nat -> (j < Rlength (cons r r0))%nat -> pos_Rl (cons r r0) i <= pos_Rl (cons r r0) jordered_Rlist (cons r r0)unfold ordered_Rlist; intros; apply H0; [ apply le_n_Sn | simpl; simpl in H1; apply lt_n_S; assumption ]. Qed.l:Rlistr:Rr0:RlistH:ordered_Rlist r0 <-> (forall i j : nat, (i <= j)%nat -> (j < Rlength r0)%nat -> pos_Rl r0 i <= pos_Rl r0 j)H0:forall i j : nat, (i <= j)%nat -> (j < Rlength (cons r r0))%nat -> pos_Rl (cons r r0) i <= pos_Rl (cons r r0) jordered_Rlist (cons r r0)forall (l : Rlist) (x : R), ordered_Rlist l -> In x l -> x <= pos_Rl l (Init.Nat.pred (Rlength l))forall (l : Rlist) (x : R), ordered_Rlist l -> In x l -> x <= pos_Rl l (Init.Nat.pred (Rlength l))l:Rlistx:RH:ordered_Rlist lH0:In x lH3:forall i j : nat, (i <= j)%nat -> (j < Rlength l)%nat -> pos_Rl l i <= pos_Rl l jH1:In x l -> exists i : nat, x = pos_Rl l i /\ (i < Rlength l)%natH2:(exists i : nat, x = pos_Rl l i /\ (i < Rlength l)%nat) -> In x lx0:natH4:x = pos_Rl l x0H5:(x0 < Rlength l)%natRlength l = S (Init.Nat.pred (Rlength l))l:Rlistx:RH:ordered_Rlist lH0:In x lH3:forall i j : nat, (i <= j)%nat -> (j < Rlength l)%nat -> pos_Rl l i <= pos_Rl l jH1:In x l -> exists i : nat, x = pos_Rl l i /\ (i < Rlength l)%natH2:(exists i : nat, x = pos_Rl l i /\ (i < Rlength l)%nat) -> In x lx0:natH4:x = pos_Rl l x0H5:(x0 < Rlength l)%natH6:Rlength l = S (Init.Nat.pred (Rlength l))pos_Rl l x0 <= pos_Rl l (Init.Nat.pred (Rlength l))apply H3; [ rewrite H6 in H5; apply lt_n_Sm_le; assumption | apply lt_pred_n_n; apply neq_O_lt; red; intro; rewrite <- H7 in H5; elim (lt_n_O _ H5) ]. Qed.l:Rlistx:RH:ordered_Rlist lH0:In x lH3:forall i j : nat, (i <= j)%nat -> (j < Rlength l)%nat -> pos_Rl l i <= pos_Rl l jH1:In x l -> exists i : nat, x = pos_Rl l i /\ (i < Rlength l)%natH2:(exists i : nat, x = pos_Rl l i /\ (i < Rlength l)%nat) -> In x lx0:natH4:x = pos_Rl l x0H5:(x0 < Rlength l)%natH6:Rlength l = S (Init.Nat.pred (Rlength l))pos_Rl l x0 <= pos_Rl l (Init.Nat.pred (Rlength l))forall (l : Rlist) (a x : R), In x (insert l a) <-> x = a \/ In x lforall (l : Rlist) (a x : R), In x (insert l a) <-> x = a \/ In x ll:Rlistforall a x : R, In x (insert nil a) <-> x = a \/ In x nill:Rlistforall (r : R) (r0 : Rlist), (forall a x : R, In x (insert r0 a) <-> x = a \/ In x r0) -> forall a x : R, In x (insert (cons r r0) a) <-> x = a \/ In x (cons r r0)intros; split; intro; [ simpl in H0; generalize H0; case (Rle_dec r a); intros; [ simpl in H1; elim H1; intro; [ right; left; assumption | elim (H a x); intros; elim (H3 H2); intro; [ left; assumption | right; right; assumption ] ] | simpl in H1; decompose [or] H1; [ left; assumption | right; left; assumption | right; right; assumption ] ] | simpl; case (Rle_dec r a); intro; [ simpl in H0; decompose [or] H0; [ right; elim (H a x); intros; apply H3; left | left | right; elim (H a x); intros; apply H3; right ] | simpl in H0; decompose [or] H0; [ left | right; left | right; right ] ]; assumption ]. Qed.l:Rlistforall (r : R) (r0 : Rlist), (forall a x : R, In x (insert r0 a) <-> x = a \/ In x r0) -> forall a x : R, In x (insert (cons r r0) a) <-> x = a \/ In x (cons r r0)forall (l1 l2 : Rlist) (x : R), In x (cons_ORlist l1 l2) <-> In x l1 \/ In x l2forall (l1 l2 : Rlist) (x : R), In x (cons_ORlist l1 l2) <-> In x l1 \/ In x l2l1:Rlistforall (l2 : Rlist) (x : R), In x (cons_ORlist nil l2) <-> In x nil \/ In x l2l1:Rlistforall (r : R) (r0 : Rlist), (forall (l2 : Rlist) (x : R), In x (cons_ORlist r0 l2) <-> In x r0 \/ In x l2) -> forall (l2 : Rlist) (x : R), In x (cons_ORlist (cons r r0) l2) <-> In x (cons r r0) \/ In x l2l1:Rlistforall (r : R) (r0 : Rlist), (forall (l2 : Rlist) (x : R), In x (cons_ORlist r0 l2) <-> In x r0 \/ In x l2) -> forall (l2 : Rlist) (x : R), In x (cons_ORlist (cons r r0) l2) <-> In x (cons r r0) \/ In x l2l1:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (x0 : R), In x0 (cons_ORlist r0 l0) <-> In x0 r0 \/ In x0 l0l2:Rlistx:RIn x (cons_ORlist (cons r r0) l2) -> In x (cons r r0) \/ In x l2l1:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (x0 : R), In x0 (cons_ORlist r0 l0) <-> In x0 r0 \/ In x0 l0l2:Rlistx:RIn x (cons r r0) \/ In x l2 -> In x (cons_ORlist (cons r r0) l2)intro; simpl; elim (H (insert l2 r) x); intros _ H1; apply H1; elim H0; intro; [ elim H2; intro; [ right; elim (RList_P8 l2 r x); intros _ H4; apply H4; left; assumption | left; assumption ] | right; elim (RList_P8 l2 r x); intros _ H3; apply H3; right; assumption ]. Qed.l1:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (x0 : R), In x0 (cons_ORlist r0 l0) <-> In x0 r0 \/ In x0 l0l2:Rlistx:RIn x (cons r r0) \/ In x l2 -> In x (cons_ORlist (cons r r0) l2)forall (l : Rlist) (a : R), Rlength (insert l a) = S (Rlength l)intros; induction l as [| r l Hrecl]; [ reflexivity | simpl; case (Rle_dec r a); intro; [ simpl; rewrite Hrecl; reflexivity | reflexivity ] ]. Qed.forall (l : Rlist) (a : R), Rlength (insert l a) = S (Rlength l)forall l1 l2 : Rlist, Rlength (cons_ORlist l1 l2) = (Rlength l1 + Rlength l2)%natsimple induction l1; [ intro; reflexivity | intros; simpl; rewrite (H (insert l2 r)); rewrite RList_P10; apply INR_eq; rewrite S_INR; do 2 rewrite plus_INR; rewrite S_INR; ring ]. Qed.forall l1 l2 : Rlist, Rlength (cons_ORlist l1 l2) = (Rlength l1 + Rlength l2)%natforall (l : Rlist) (i : nat) (f : R -> R), (i < Rlength l)%nat -> pos_Rl (app_Rlist l f) i = f (pos_Rl l i)simple induction l; [ intros; elim (lt_n_O _ H) | intros; induction i as [| i Hreci]; [ reflexivity | simpl; apply H; apply lt_S_n; apply H0 ] ]. Qed.forall (l : Rlist) (i : nat) (f : R -> R), (i < Rlength l)%nat -> pos_Rl (app_Rlist l f) i = f (pos_Rl l i)forall (l : Rlist) (i : nat) (a : R), (i < Init.Nat.pred (Rlength l))%nat -> pos_Rl (mid_Rlist l a) (S i) = (pos_Rl l i + pos_Rl l (S i)) / 2forall (l : Rlist) (i : nat) (a : R), (i < Init.Nat.pred (Rlength l))%nat -> pos_Rl (mid_Rlist l a) (S i) = (pos_Rl l i + pos_Rl l (S i)) / 2l:Rlistforall (i : nat) (a : R), (i < Init.Nat.pred (Rlength nil))%nat -> pos_Rl (mid_Rlist nil a) (S i) = (pos_Rl nil i + pos_Rl nil (S i)) / 2l:Rlistforall (r : R) (r0 : Rlist), (forall (i : nat) (a : R), (i < Init.Nat.pred (Rlength r0))%nat -> pos_Rl (mid_Rlist r0 a) (S i) = (pos_Rl r0 i + pos_Rl r0 (S i)) / 2) -> forall (i : nat) (a : R), (i < Init.Nat.pred (Rlength (cons r r0)))%nat -> pos_Rl (mid_Rlist (cons r r0) a) (S i) = (pos_Rl (cons r r0) i + pos_Rl (cons r r0) (S i)) / 2l:Rlistforall (r : R) (r0 : Rlist), (forall (i : nat) (a : R), (i < Init.Nat.pred (Rlength r0))%nat -> pos_Rl (mid_Rlist r0 a) (S i) = (pos_Rl r0 i + pos_Rl r0 (S i)) / 2) -> forall (i : nat) (a : R), (i < Init.Nat.pred (Rlength (cons r r0)))%nat -> pos_Rl (mid_Rlist (cons r r0) a) (S i) = (pos_Rl (cons r r0) i + pos_Rl (cons r r0) (S i)) / 2l:Rlistr:Rr0:Rlist(forall (i : nat) (a : R), (i < Init.Nat.pred (Rlength nil))%nat -> pos_Rl (mid_Rlist nil a) (S i) = (pos_Rl nil i + pos_Rl nil (S i)) / 2) -> forall (i : nat) (a : R), (i < Init.Nat.pred (Rlength (cons r nil)))%nat -> pos_Rl (mid_Rlist (cons r nil) a) (S i) = (pos_Rl (cons r nil) i + pos_Rl (cons r nil) (S i)) / 2l:Rlistr:Rr0:Rlistforall (r1 : R) (r2 : Rlist), ((forall (i : nat) (a : R), (i < Init.Nat.pred (Rlength r2))%nat -> pos_Rl (mid_Rlist r2 a) (S i) = (pos_Rl r2 i + pos_Rl r2 (S i)) / 2) -> forall (i : nat) (a : R), (i < Init.Nat.pred (Rlength (cons r r2)))%nat -> pos_Rl (mid_Rlist (cons r r2) a) (S i) = (pos_Rl (cons r r2) i + pos_Rl (cons r r2) (S i)) / 2) -> (forall (i : nat) (a : R), (i < Init.Nat.pred (Rlength (cons r1 r2)))%nat -> pos_Rl (mid_Rlist (cons r1 r2) a) (S i) = (pos_Rl (cons r1 r2) i + pos_Rl (cons r1 r2) (S i)) / 2) -> forall (i : nat) (a : R), (i < Init.Nat.pred (Rlength (cons r (cons r1 r2))))%nat -> pos_Rl (mid_Rlist (cons r (cons r1 r2)) a) (S i) = (pos_Rl (cons r (cons r1 r2)) i + pos_Rl (cons r (cons r1 r2)) (S i)) / 2l:Rlistr:Rr0:Rlistforall (r1 : R) (r2 : Rlist), ((forall (i : nat) (a : R), (i < Init.Nat.pred (Rlength r2))%nat -> pos_Rl (mid_Rlist r2 a) (S i) = (pos_Rl r2 i + pos_Rl r2 (S i)) / 2) -> forall (i : nat) (a : R), (i < Init.Nat.pred (Rlength (cons r r2)))%nat -> pos_Rl (mid_Rlist (cons r r2) a) (S i) = (pos_Rl (cons r r2) i + pos_Rl (cons r r2) (S i)) / 2) -> (forall (i : nat) (a : R), (i < Init.Nat.pred (Rlength (cons r1 r2)))%nat -> pos_Rl (mid_Rlist (cons r1 r2) a) (S i) = (pos_Rl (cons r1 r2) i + pos_Rl (cons r1 r2) (S i)) / 2) -> forall (i : nat) (a : R), (i < Init.Nat.pred (Rlength (cons r (cons r1 r2))))%nat -> pos_Rl (mid_Rlist (cons r (cons r1 r2)) a) (S i) = (pos_Rl (cons r (cons r1 r2)) i + pos_Rl (cons r (cons r1 r2)) (S i)) / 2l:Rlistr:Rr0:Rlistr1:Rr2:RlistH:(forall (i : nat) (a0 : R), (i < Init.Nat.pred (Rlength r2))%nat -> pos_Rl (mid_Rlist r2 a0) (S i) = (pos_Rl r2 i + pos_Rl r2 (S i)) / 2) -> forall (i : nat) (a0 : R), (i < Init.Nat.pred (Rlength (cons r r2)))%nat -> pos_Rl (mid_Rlist (cons r r2) a0) (S i) = (pos_Rl (cons r r2) i + pos_Rl (cons r r2) (S i)) / 2H0:forall (i : nat) (a0 : R), (i < Init.Nat.pred (Rlength (cons r1 r2)))%nat -> pos_Rl (mid_Rlist (cons r1 r2) a0) (S i) = (pos_Rl (cons r1 r2) i + pos_Rl (cons r1 r2) (S i)) / 2a:RH1:(0 < S (Rlength r2))%natpos_Rl (mid_Rlist (cons r (cons r1 r2)) a) 1 = (pos_Rl (cons r (cons r1 r2)) 0 + pos_Rl (cons r (cons r1 r2)) 1) / 2l:Rlistr:Rr0:Rlistr1:Rr2:RlistH:(forall (i0 : nat) (a0 : R), (i0 < Init.Nat.pred (Rlength r2))%nat -> pos_Rl (mid_Rlist r2 a0) (S i0) = (pos_Rl r2 i0 + pos_Rl r2 (S i0)) / 2) -> forall (i0 : nat) (a0 : R), (i0 < Init.Nat.pred (Rlength (cons r r2)))%nat -> pos_Rl (mid_Rlist (cons r r2) a0) (S i0) = (pos_Rl (cons r r2) i0 + pos_Rl (cons r r2) (S i0)) / 2H0:forall (i0 : nat) (a0 : R), (i0 < Init.Nat.pred (Rlength (cons r1 r2)))%nat -> pos_Rl (mid_Rlist (cons r1 r2) a0) (S i0) = (pos_Rl (cons r1 r2) i0 + pos_Rl (cons r1 r2) (S i0)) / 2i:nata:RH1:(S i < S (Rlength r2))%natHreci:(i < S (Rlength r2))%nat -> pos_Rl (mid_Rlist (cons r (cons r1 r2)) a) (S i) = (pos_Rl (cons r (cons r1 r2)) i + pos_Rl (cons r (cons r1 r2)) (S i)) / 2pos_Rl (mid_Rlist (cons r (cons r1 r2)) a) (S (S i)) = (pos_Rl (cons r (cons r1 r2)) (S i) + pos_Rl (cons r (cons r1 r2)) (S (S i))) / 2change (pos_Rl (mid_Rlist (cons r1 r2) r) (S i) = (pos_Rl (cons r1 r2) i + pos_Rl (cons r1 r2) (S i)) / 2) ; apply H0; simpl; apply lt_S_n; assumption. Qed.l:Rlistr:Rr0:Rlistr1:Rr2:RlistH:(forall (i0 : nat) (a0 : R), (i0 < Init.Nat.pred (Rlength r2))%nat -> pos_Rl (mid_Rlist r2 a0) (S i0) = (pos_Rl r2 i0 + pos_Rl r2 (S i0)) / 2) -> forall (i0 : nat) (a0 : R), (i0 < Init.Nat.pred (Rlength (cons r r2)))%nat -> pos_Rl (mid_Rlist (cons r r2) a0) (S i0) = (pos_Rl (cons r r2) i0 + pos_Rl (cons r r2) (S i0)) / 2H0:forall (i0 : nat) (a0 : R), (i0 < Init.Nat.pred (Rlength (cons r1 r2)))%nat -> pos_Rl (mid_Rlist (cons r1 r2) a0) (S i0) = (pos_Rl (cons r1 r2) i0 + pos_Rl (cons r1 r2) (S i0)) / 2i:nata:RH1:(S i < S (Rlength r2))%natHreci:(i < S (Rlength r2))%nat -> pos_Rl (mid_Rlist (cons r (cons r1 r2)) a) (S i) = (pos_Rl (cons r (cons r1 r2)) i + pos_Rl (cons r (cons r1 r2)) (S i)) / 2pos_Rl (mid_Rlist (cons r (cons r1 r2)) a) (S (S i)) = (pos_Rl (cons r (cons r1 r2)) (S i) + pos_Rl (cons r (cons r1 r2)) (S (S i))) / 2forall (l : Rlist) (a : R), Rlength (mid_Rlist l a) = Rlength lsimple induction l; intros; [ reflexivity | simpl; rewrite (H r); reflexivity ]. Qed.forall (l : Rlist) (a : R), Rlength (mid_Rlist l a) = Rlength lforall l1 l2 : Rlist, ordered_Rlist l1 -> ordered_Rlist l2 -> pos_Rl l1 0 = pos_Rl l2 0 -> pos_Rl (cons_ORlist l1 l2) 0 = pos_Rl l1 0forall l1 l2 : Rlist, ordered_Rlist l1 -> ordered_Rlist l2 -> pos_Rl l1 0 = pos_Rl l2 0 -> pos_Rl (cons_ORlist l1 l2) 0 = pos_Rl l1 0l1, l2:RlistH:ordered_Rlist l1H0:ordered_Rlist l2H1:pos_Rl l1 0 = pos_Rl l2 0pos_Rl (cons_ORlist l1 l2) 0 <= pos_Rl l1 0l1, l2:RlistH:ordered_Rlist l1H0:ordered_Rlist l2H1:pos_Rl l1 0 = pos_Rl l2 0pos_Rl l1 0 <= pos_Rl (cons_ORlist l1 l2) 0induction l1 as [| r l1 Hrecl1]; [ simpl; simpl in H1; right; assumption | assert (H2 : In (pos_Rl (cons_ORlist (cons r l1) l2) 0) (cons_ORlist (cons r l1) l2)); [ elim (RList_P3 (cons_ORlist (cons r l1) l2) (pos_Rl (cons_ORlist (cons r l1) l2) 0)); intros; apply H3; exists 0%nat; split; [ reflexivity | rewrite RList_P11; simpl; apply lt_O_Sn ] | elim (RList_P9 (cons r l1) l2 (pos_Rl (cons_ORlist (cons r l1) l2) 0)); intros; assert (H5 := H3 H2); elim H5; intro; [ apply RList_P5; assumption | rewrite H1; apply RList_P5; assumption ] ] ]. Qed.l1, l2:RlistH:ordered_Rlist l1H0:ordered_Rlist l2H1:pos_Rl l1 0 = pos_Rl l2 0pos_Rl l1 0 <= pos_Rl (cons_ORlist l1 l2) 0forall l1 l2 : Rlist, ordered_Rlist l1 -> ordered_Rlist l2 -> pos_Rl l1 (Init.Nat.pred (Rlength l1)) = pos_Rl l2 (Init.Nat.pred (Rlength l2)) -> pos_Rl (cons_ORlist l1 l2) (Init.Nat.pred (Rlength (cons_ORlist l1 l2))) = pos_Rl l1 (Init.Nat.pred (Rlength l1))forall l1 l2 : Rlist, ordered_Rlist l1 -> ordered_Rlist l2 -> pos_Rl l1 (Init.Nat.pred (Rlength l1)) = pos_Rl l2 (Init.Nat.pred (Rlength l2)) -> pos_Rl (cons_ORlist l1 l2) (Init.Nat.pred (Rlength (cons_ORlist l1 l2))) = pos_Rl l1 (Init.Nat.pred (Rlength l1))l1, l2:RlistH:ordered_Rlist l1H0:ordered_Rlist l2H1:pos_Rl l1 (Init.Nat.pred (Rlength l1)) = pos_Rl l2 (Init.Nat.pred (Rlength l2))pos_Rl (cons_ORlist l1 l2) (Init.Nat.pred (Rlength (cons_ORlist l1 l2))) <= pos_Rl l1 (Init.Nat.pred (Rlength l1))l1, l2:RlistH:ordered_Rlist l1H0:ordered_Rlist l2H1:pos_Rl l1 (Init.Nat.pred (Rlength l1)) = pos_Rl l2 (Init.Nat.pred (Rlength l2))pos_Rl l1 (Init.Nat.pred (Rlength l1)) <= pos_Rl (cons_ORlist l1 l2) (Init.Nat.pred (Rlength (cons_ORlist l1 l2)))l2:RlistH:ordered_Rlist nilH0:ordered_Rlist l2H1:pos_Rl nil (Init.Nat.pred (Rlength nil)) = pos_Rl l2 (Init.Nat.pred (Rlength l2))pos_Rl (cons_ORlist nil l2) (Init.Nat.pred (Rlength (cons_ORlist nil l2))) <= pos_Rl nil (Init.Nat.pred (Rlength nil))r:Rl1, l2:RlistH:ordered_Rlist (cons r l1)H0:ordered_Rlist l2H1:pos_Rl (cons r l1) (Init.Nat.pred (Rlength (cons r l1))) = pos_Rl l2 (Init.Nat.pred (Rlength l2))Hrecl1:ordered_Rlist l1 -> pos_Rl l1 (Init.Nat.pred (Rlength l1)) = pos_Rl l2 (Init.Nat.pred (Rlength l2)) -> pos_Rl (cons_ORlist l1 l2) (Init.Nat.pred (Rlength (cons_ORlist l1 l2))) <= pos_Rl l1 (Init.Nat.pred (Rlength l1))pos_Rl (cons_ORlist (cons r l1) l2) (Init.Nat.pred (Rlength (cons_ORlist (cons r l1) l2))) <= pos_Rl (cons r l1) (Init.Nat.pred (Rlength (cons r l1)))l1, l2:RlistH:ordered_Rlist l1H0:ordered_Rlist l2H1:pos_Rl l1 (Init.Nat.pred (Rlength l1)) = pos_Rl l2 (Init.Nat.pred (Rlength l2))pos_Rl l1 (Init.Nat.pred (Rlength l1)) <= pos_Rl (cons_ORlist l1 l2) (Init.Nat.pred (Rlength (cons_ORlist l1 l2)))r:Rl1, l2:RlistH:ordered_Rlist (cons r l1)H0:ordered_Rlist l2H1:pos_Rl (cons r l1) (Init.Nat.pred (Rlength (cons r l1))) = pos_Rl l2 (Init.Nat.pred (Rlength l2))Hrecl1:ordered_Rlist l1 -> pos_Rl l1 (Init.Nat.pred (Rlength l1)) = pos_Rl l2 (Init.Nat.pred (Rlength l2)) -> pos_Rl (cons_ORlist l1 l2) (Init.Nat.pred (Rlength (cons_ORlist l1 l2))) <= pos_Rl l1 (Init.Nat.pred (Rlength l1))pos_Rl (cons_ORlist (cons r l1) l2) (Init.Nat.pred (Rlength (cons_ORlist (cons r l1) l2))) <= pos_Rl (cons r l1) (Init.Nat.pred (Rlength (cons r l1)))l1, l2:RlistH:ordered_Rlist l1H0:ordered_Rlist l2H1:pos_Rl l1 (Init.Nat.pred (Rlength l1)) = pos_Rl l2 (Init.Nat.pred (Rlength l2))pos_Rl l1 (Init.Nat.pred (Rlength l1)) <= pos_Rl (cons_ORlist l1 l2) (Init.Nat.pred (Rlength (cons_ORlist l1 l2)))l1, l2:RlistH:ordered_Rlist l1H0:ordered_Rlist l2H1:pos_Rl l1 (Init.Nat.pred (Rlength l1)) = pos_Rl l2 (Init.Nat.pred (Rlength l2))pos_Rl l1 (Init.Nat.pred (Rlength l1)) <= pos_Rl (cons_ORlist l1 l2) (Init.Nat.pred (Rlength (cons_ORlist l1 l2)))l2:RlistH:ordered_Rlist nilH0:ordered_Rlist l2H1:pos_Rl nil (Init.Nat.pred (Rlength nil)) = pos_Rl l2 (Init.Nat.pred (Rlength l2))pos_Rl nil (Init.Nat.pred (Rlength nil)) <= pos_Rl (cons_ORlist nil l2) (Init.Nat.pred (Rlength (cons_ORlist nil l2)))r:Rl1, l2:RlistH:ordered_Rlist (cons r l1)H0:ordered_Rlist l2H1:pos_Rl (cons r l1) (Init.Nat.pred (Rlength (cons r l1))) = pos_Rl l2 (Init.Nat.pred (Rlength l2))Hrecl1:ordered_Rlist l1 -> pos_Rl l1 (Init.Nat.pred (Rlength l1)) = pos_Rl l2 (Init.Nat.pred (Rlength l2)) -> pos_Rl l1 (Init.Nat.pred (Rlength l1)) <= pos_Rl (cons_ORlist l1 l2) (Init.Nat.pred (Rlength (cons_ORlist l1 l2)))pos_Rl (cons r l1) (Init.Nat.pred (Rlength (cons r l1))) <= pos_Rl (cons_ORlist (cons r l1) l2) (Init.Nat.pred (Rlength (cons_ORlist (cons r l1) l2)))elim (RList_P9 (cons r l1) l2 (pos_Rl (cons r l1) (pred (Rlength (cons r l1))))); intros; assert (H4 : In (pos_Rl (cons r l1) (pred (Rlength (cons r l1)))) (cons r l1) \/ In (pos_Rl (cons r l1) (pred (Rlength (cons r l1)))) l2); [ left; change (In (pos_Rl (cons r l1) (Rlength l1)) (cons r l1)); elim (RList_P3 (cons r l1) (pos_Rl (cons r l1) (Rlength l1))); intros; apply H5; exists (Rlength l1); split; [ reflexivity | simpl; apply lt_n_Sn ] | assert (H5 := H3 H4); apply RList_P7; [ apply RList_P2; assumption | elim (RList_P9 (cons r l1) l2 (pos_Rl (cons r l1) (pred (Rlength (cons r l1))))); intros; apply H7; left; elim (RList_P3 (cons r l1) (pos_Rl (cons r l1) (pred (Rlength (cons r l1))))); intros; apply H9; exists (pred (Rlength (cons r l1))); split; [ reflexivity | simpl; apply lt_n_Sn ] ] ]. Qed.r:Rl1, l2:RlistH:ordered_Rlist (cons r l1)H0:ordered_Rlist l2H1:pos_Rl (cons r l1) (Init.Nat.pred (Rlength (cons r l1))) = pos_Rl l2 (Init.Nat.pred (Rlength l2))Hrecl1:ordered_Rlist l1 -> pos_Rl l1 (Init.Nat.pred (Rlength l1)) = pos_Rl l2 (Init.Nat.pred (Rlength l2)) -> pos_Rl l1 (Init.Nat.pred (Rlength l1)) <= pos_Rl (cons_ORlist l1 l2) (Init.Nat.pred (Rlength (cons_ORlist l1 l2)))pos_Rl (cons r l1) (Init.Nat.pred (Rlength (cons r l1))) <= pos_Rl (cons_ORlist (cons r l1) l2) (Init.Nat.pred (Rlength (cons_ORlist (cons r l1) l2)))forall (l1 : Rlist) (x : R) (i : nat), ordered_Rlist l1 -> In x l1 -> pos_Rl l1 i < x -> (i < Init.Nat.pred (Rlength l1))%nat -> pos_Rl l1 (S i) <= xforall (l1 : Rlist) (x : R) (i : nat), ordered_Rlist l1 -> In x l1 -> pos_Rl l1 i < x -> (i < Init.Nat.pred (Rlength l1))%nat -> pos_Rl l1 (S i) <= xl1:Rlistforall (x : R) (i : nat), ordered_Rlist nil -> In x nil -> pos_Rl nil i < x -> (i < Init.Nat.pred (Rlength nil))%nat -> pos_Rl nil (S i) <= xl1:Rlistforall (r : R) (r0 : Rlist), (forall (x : R) (i : nat), ordered_Rlist r0 -> In x r0 -> pos_Rl r0 i < x -> (i < Init.Nat.pred (Rlength r0))%nat -> pos_Rl r0 (S i) <= x) -> forall (x : R) (i : nat), ordered_Rlist (cons r r0) -> In x (cons r r0) -> pos_Rl (cons r r0) i < x -> (i < Init.Nat.pred (Rlength (cons r r0)))%nat -> pos_Rl (cons r r0) (S i) <= xl1:Rlistforall (r : R) (r0 : Rlist), (forall (x : R) (i : nat), ordered_Rlist r0 -> In x r0 -> pos_Rl r0 i < x -> (i < Init.Nat.pred (Rlength r0))%nat -> pos_Rl r0 (S i) <= x) -> forall (x : R) (i : nat), ordered_Rlist (cons r r0) -> In x (cons r r0) -> pos_Rl (cons r r0) i < x -> (i < Init.Nat.pred (Rlength (cons r r0)))%nat -> pos_Rl (cons r r0) (S i) <= xl1:Rlistr:Rr0:RlistH:forall (x0 : R) (i : nat), ordered_Rlist r0 -> In x0 r0 -> pos_Rl r0 i < x0 -> (i < Init.Nat.pred (Rlength r0))%nat -> pos_Rl r0 (S i) <= x0x:RH0:ordered_Rlist (cons r r0)H1:In x (cons r r0)H2:pos_Rl (cons r r0) 0 < xH3:(0 < Init.Nat.pred (Rlength (cons r r0)))%natpos_Rl (cons r r0) 1 <= xl1:Rlistr:Rr0:RlistH:forall (x0 : R) (i0 : nat), ordered_Rlist r0 -> In x0 r0 -> pos_Rl r0 i0 < x0 -> (i0 < Init.Nat.pred (Rlength r0))%nat -> pos_Rl r0 (S i0) <= x0x:Ri:natH0:ordered_Rlist (cons r r0)H1:In x (cons r r0)H2:pos_Rl (cons r r0) (S i) < xH3:(S i < Init.Nat.pred (Rlength (cons r r0)))%natHreci:pos_Rl (cons r r0) i < x -> (i < Init.Nat.pred (Rlength (cons r r0)))%nat -> pos_Rl (cons r r0) (S i) <= xpos_Rl (cons r r0) (S (S i)) <= xl1:Rlistr:Rr0:RlistH:forall (x0 : R) (i0 : nat), ordered_Rlist r0 -> In x0 r0 -> pos_Rl r0 i0 < x0 -> (i0 < Init.Nat.pred (Rlength r0))%nat -> pos_Rl r0 (S i0) <= x0x:Ri:natH0:ordered_Rlist (cons r r0)H1:In x (cons r r0)H2:pos_Rl (cons r r0) (S i) < xH3:(S i < Init.Nat.pred (Rlength (cons r r0)))%natHreci:pos_Rl (cons r r0) i < x -> (i < Init.Nat.pred (Rlength (cons r r0)))%nat -> pos_Rl (cons r r0) (S i) <= xpos_Rl (cons r r0) (S (S i)) <= xl1:Rlistr:Rr0:RlistH:forall (x0 : R) (i0 : nat), ordered_Rlist r0 -> In x0 r0 -> pos_Rl r0 i0 < x0 -> (i0 < Init.Nat.pred (Rlength r0))%nat -> pos_Rl r0 (S i0) <= x0x:Ri:natH0:ordered_Rlist (cons r r0)H1:In x (cons r r0)H2:pos_Rl r0 i < xH3:(S i < Init.Nat.pred (Rlength (cons r r0)))%natHreci:pos_Rl (cons r r0) i < x -> (i < Init.Nat.pred (Rlength (cons r r0)))%nat -> pos_Rl (cons r r0) (S i) <= xH4:x = rpos_Rl r0 (S i) <= xl1:Rlistr:Rr0:RlistH:forall (x0 : R) (i0 : nat), ordered_Rlist r0 -> In x0 r0 -> pos_Rl r0 i0 < x0 -> (i0 < Init.Nat.pred (Rlength r0))%nat -> pos_Rl r0 (S i0) <= x0x:Ri:natH0:ordered_Rlist (cons r r0)H1:In x (cons r r0)H2:pos_Rl r0 i < xH3:(S i < Init.Nat.pred (Rlength (cons r r0)))%natHreci:pos_Rl (cons r r0) i < x -> (i < Init.Nat.pred (Rlength (cons r r0)))%nat -> pos_Rl (cons r r0) (S i) <= xH4:In x r0pos_Rl r0 (S i) <= xapply H; try assumption; [ apply RList_P4 with r; assumption | simpl in H3; apply lt_S_n; replace (S (pred (Rlength r0))) with (Rlength r0); [ apply H3 | apply S_pred with 0%nat; apply neq_O_lt; red; intro; rewrite <- H5 in H3; elim (lt_n_O _ H3) ] ]. Qed.l1:Rlistr:Rr0:RlistH:forall (x0 : R) (i0 : nat), ordered_Rlist r0 -> In x0 r0 -> pos_Rl r0 i0 < x0 -> (i0 < Init.Nat.pred (Rlength r0))%nat -> pos_Rl r0 (S i0) <= x0x:Ri:natH0:ordered_Rlist (cons r r0)H1:In x (cons r r0)H2:pos_Rl r0 i < xH3:(S i < Init.Nat.pred (Rlength (cons r r0)))%natHreci:pos_Rl (cons r r0) i < x -> (i < Init.Nat.pred (Rlength (cons r r0)))%nat -> pos_Rl (cons r r0) (S i) <= xH4:In x r0pos_Rl r0 (S i) <= xforall (l : Rlist) (f : R -> R), Rlength (app_Rlist l f) = Rlength lsimple induction l; intros; [ reflexivity | simpl; rewrite H; reflexivity ]. Qed.forall (l : Rlist) (f : R -> R), Rlength (app_Rlist l f) = Rlength lforall l : Rlist, l <> nil -> exists (r : R) (r0 : Rlist), l = cons r r0intros; induction l as [| r l Hrecl]; [ elim H; reflexivity | exists r; exists l; reflexivity ]. Qed.forall l : Rlist, l <> nil -> exists (r : R) (r0 : Rlist), l = cons r r0forall l : Rlist, (2 <= Rlength l)%nat -> exists (r r1 : R) (l' : Rlist), l = cons r (cons r1 l')intros; induction l as [| r l Hrecl]; [ simpl in H; elim (le_Sn_O _ H) | induction l as [| r0 l Hrecl0]; [ simpl in H; elim (le_Sn_O _ (le_S_n _ _ H)) | exists r; exists r0; exists l; reflexivity ] ]. Qed.forall l : Rlist, (2 <= Rlength l)%nat -> exists (r r1 : R) (l' : Rlist), l = cons r (cons r1 l')forall l l' : Rlist, l = l' -> Rtail l = Rtail l'intros; rewrite H; reflexivity. Qed.forall l l' : Rlist, l = l' -> Rtail l = Rtail l'forall l1 l2 : Rlist, l1 <> nil -> pos_Rl (cons_Rlist l1 l2) 0 = pos_Rl l1 0simple induction l1; [ intros; elim H; reflexivity | intros; reflexivity ]. Qed.forall l1 l2 : Rlist, l1 <> nil -> pos_Rl (cons_Rlist l1 l2) 0 = pos_Rl l1 0forall l1 l2 : Rlist, Rlength (cons_Rlist l1 l2) = (Rlength l1 + Rlength l2)%natsimple induction l1; [ intro; reflexivity | intros; simpl; rewrite H; reflexivity ]. Qed.forall l1 l2 : Rlist, Rlength (cons_Rlist l1 l2) = (Rlength l1 + Rlength l2)%natforall l1 l2 : Rlist, l2 <> nil -> pos_Rl (cons_Rlist l1 l2) (Init.Nat.pred (Rlength (cons_Rlist l1 l2))) = pos_Rl l2 (Init.Nat.pred (Rlength l2))forall l1 l2 : Rlist, l2 <> nil -> pos_Rl (cons_Rlist l1 l2) (Init.Nat.pred (Rlength (cons_Rlist l1 l2))) = pos_Rl l2 (Init.Nat.pred (Rlength l2))l1:Rlistforall l2 : Rlist, l2 <> nil -> pos_Rl (cons_Rlist nil l2) (Init.Nat.pred (Rlength (cons_Rlist nil l2))) = pos_Rl l2 (Init.Nat.pred (Rlength l2))l1:Rlistforall (r : R) (r0 : Rlist), (forall l2 : Rlist, l2 <> nil -> pos_Rl (cons_Rlist r0 l2) (Init.Nat.pred (Rlength (cons_Rlist r0 l2))) = pos_Rl l2 (Init.Nat.pred (Rlength l2))) -> forall l2 : Rlist, l2 <> nil -> pos_Rl (cons_Rlist (cons r r0) l2) (Init.Nat.pred (Rlength (cons_Rlist (cons r r0) l2))) = pos_Rl l2 (Init.Nat.pred (Rlength l2))l1:Rlistforall (r : R) (r0 : Rlist), (forall l2 : Rlist, l2 <> nil -> pos_Rl (cons_Rlist r0 l2) (Init.Nat.pred (Rlength (cons_Rlist r0 l2))) = pos_Rl l2 (Init.Nat.pred (Rlength l2))) -> forall l2 : Rlist, l2 <> nil -> pos_Rl (cons_Rlist (cons r r0) l2) (Init.Nat.pred (Rlength (cons_Rlist (cons r r0) l2))) = pos_Rl l2 (Init.Nat.pred (Rlength l2))l1:Rlistr:Rr0:RlistH:forall l2 : Rlist, l2 <> nil -> pos_Rl (cons_Rlist r0 l2) (Init.Nat.pred (Rlength (cons_Rlist r0 l2))) = pos_Rl l2 (Init.Nat.pred (Rlength l2))H0:nil <> nilpos_Rl (cons_Rlist (cons r r0) nil) (Init.Nat.pred (Rlength (cons_Rlist (cons r r0) nil))) = pos_Rl (cons_Rlist r0 nil) (Init.Nat.pred (Rlength (cons_Rlist r0 nil)))l1:Rlistr:Rr0:RlistH:forall l0 : Rlist, l0 <> nil -> pos_Rl (cons_Rlist r0 l0) (Init.Nat.pred (Rlength (cons_Rlist r0 l0))) = pos_Rl l0 (Init.Nat.pred (Rlength l0))r1:Rl2:RlistH0:cons r1 l2 <> nilHrecl2:l2 <> nil -> pos_Rl (cons_Rlist (cons r r0) l2) (Init.Nat.pred (Rlength (cons_Rlist (cons r r0) l2))) = pos_Rl (cons_Rlist r0 l2) (Init.Nat.pred (Rlength (cons_Rlist r0 l2)))pos_Rl (cons_Rlist (cons r r0) (cons r1 l2)) (Init.Nat.pred (Rlength (cons_Rlist (cons r r0) (cons r1 l2)))) = pos_Rl (cons_Rlist r0 (cons r1 l2)) (Init.Nat.pred (Rlength (cons_Rlist r0 (cons r1 l2))))do 2 rewrite RList_P23; replace (Rlength (cons r r0) + Rlength (cons r1 l2))%nat with (S (S (Rlength r0 + Rlength l2))); [ replace (Rlength r0 + Rlength (cons r1 l2))%nat with (S (Rlength r0 + Rlength l2)); [ reflexivity | simpl; apply INR_eq; rewrite S_INR; do 2 rewrite plus_INR; rewrite S_INR; ring ] | simpl; apply INR_eq; do 3 rewrite S_INR; do 2 rewrite plus_INR; rewrite S_INR; ring ]. Qed.l1:Rlistr:Rr0:RlistH:forall l0 : Rlist, l0 <> nil -> pos_Rl (cons_Rlist r0 l0) (Init.Nat.pred (Rlength (cons_Rlist r0 l0))) = pos_Rl l0 (Init.Nat.pred (Rlength l0))r1:Rl2:RlistH0:cons r1 l2 <> nilHrecl2:l2 <> nil -> pos_Rl (cons_Rlist (cons r r0) l2) (Init.Nat.pred (Rlength (cons_Rlist (cons r r0) l2))) = pos_Rl (cons_Rlist r0 l2) (Init.Nat.pred (Rlength (cons_Rlist r0 l2)))pos_Rl (cons_Rlist (cons r r0) (cons r1 l2)) (Init.Nat.pred (Rlength (cons_Rlist (cons r r0) (cons r1 l2)))) = pos_Rl (cons_Rlist r0 (cons r1 l2)) (Init.Nat.pred (Rlength (cons_Rlist r0 (cons r1 l2))))forall l1 l2 : Rlist, ordered_Rlist l1 -> ordered_Rlist l2 -> pos_Rl l1 (Init.Nat.pred (Rlength l1)) <= pos_Rl l2 0 -> ordered_Rlist (cons_Rlist l1 l2)forall l1 l2 : Rlist, ordered_Rlist l1 -> ordered_Rlist l2 -> pos_Rl l1 (Init.Nat.pred (Rlength l1)) <= pos_Rl l2 0 -> ordered_Rlist (cons_Rlist l1 l2)l1:Rlistforall l2 : Rlist, ordered_Rlist nil -> ordered_Rlist l2 -> pos_Rl nil (Init.Nat.pred (Rlength nil)) <= pos_Rl l2 0 -> ordered_Rlist (cons_Rlist nil l2)l1:Rlistforall (r : R) (r0 : Rlist), (forall l2 : Rlist, ordered_Rlist r0 -> ordered_Rlist l2 -> pos_Rl r0 (Init.Nat.pred (Rlength r0)) <= pos_Rl l2 0 -> ordered_Rlist (cons_Rlist r0 l2)) -> forall l2 : Rlist, ordered_Rlist (cons r r0) -> ordered_Rlist l2 -> pos_Rl (cons r r0) (Init.Nat.pred (Rlength (cons r r0))) <= pos_Rl l2 0 -> ordered_Rlist (cons_Rlist (cons r r0) l2)l1:Rlistforall (r : R) (r0 : Rlist), (forall l2 : Rlist, ordered_Rlist r0 -> ordered_Rlist l2 -> pos_Rl r0 (Init.Nat.pred (Rlength r0)) <= pos_Rl l2 0 -> ordered_Rlist (cons_Rlist r0 l2)) -> forall l2 : Rlist, ordered_Rlist (cons r r0) -> ordered_Rlist l2 -> pos_Rl (cons r r0) (Init.Nat.pred (Rlength (cons r r0))) <= pos_Rl l2 0 -> ordered_Rlist (cons_Rlist (cons r r0) l2)l1:Rlistr:Rr0:Rlist(forall l2 : Rlist, ordered_Rlist nil -> ordered_Rlist l2 -> pos_Rl nil (Init.Nat.pred (Rlength nil)) <= pos_Rl l2 0 -> ordered_Rlist (cons_Rlist nil l2)) -> forall l2 : Rlist, ordered_Rlist (cons r nil) -> ordered_Rlist l2 -> pos_Rl (cons r nil) (Init.Nat.pred (Rlength (cons r nil))) <= pos_Rl l2 0 -> ordered_Rlist (cons_Rlist (cons r nil) l2)l1:Rlistr:Rr0:Rlistforall (r1 : R) (r2 : Rlist), ((forall l2 : Rlist, ordered_Rlist r2 -> ordered_Rlist l2 -> pos_Rl r2 (Init.Nat.pred (Rlength r2)) <= pos_Rl l2 0 -> ordered_Rlist (cons_Rlist r2 l2)) -> forall l2 : Rlist, ordered_Rlist (cons r r2) -> ordered_Rlist l2 -> pos_Rl (cons r r2) (Init.Nat.pred (Rlength (cons r r2))) <= pos_Rl l2 0 -> ordered_Rlist (cons_Rlist (cons r r2) l2)) -> (forall l2 : Rlist, ordered_Rlist (cons r1 r2) -> ordered_Rlist l2 -> pos_Rl (cons r1 r2) (Init.Nat.pred (Rlength (cons r1 r2))) <= pos_Rl l2 0 -> ordered_Rlist (cons_Rlist (cons r1 r2) l2)) -> forall l2 : Rlist, ordered_Rlist (cons r (cons r1 r2)) -> ordered_Rlist l2 -> pos_Rl (cons r (cons r1 r2)) (Init.Nat.pred (Rlength (cons r (cons r1 r2)))) <= pos_Rl l2 0 -> ordered_Rlist (cons_Rlist (cons r (cons r1 r2)) l2)l1:Rlistr:Rr0:RlistH:forall l0 : Rlist, ordered_Rlist nil -> ordered_Rlist l0 -> pos_Rl nil (Init.Nat.pred (Rlength nil)) <= pos_Rl l0 0 -> ordered_Rlist (cons_Rlist nil l0)l2:RlistH0:ordered_Rlist (cons r nil)H1:ordered_Rlist l2H2:r <= pos_Rl l2 0i:natH3:(i < Rlength l2)%natpos_Rl (cons r l2) i <= pos_Rl (cons r l2) (S i)l1:Rlistr:Rr0:Rlistforall (r1 : R) (r2 : Rlist), ((forall l2 : Rlist, ordered_Rlist r2 -> ordered_Rlist l2 -> pos_Rl r2 (Init.Nat.pred (Rlength r2)) <= pos_Rl l2 0 -> ordered_Rlist (cons_Rlist r2 l2)) -> forall l2 : Rlist, ordered_Rlist (cons r r2) -> ordered_Rlist l2 -> pos_Rl (cons r r2) (Init.Nat.pred (Rlength (cons r r2))) <= pos_Rl l2 0 -> ordered_Rlist (cons_Rlist (cons r r2) l2)) -> (forall l2 : Rlist, ordered_Rlist (cons r1 r2) -> ordered_Rlist l2 -> pos_Rl (cons r1 r2) (Init.Nat.pred (Rlength (cons r1 r2))) <= pos_Rl l2 0 -> ordered_Rlist (cons_Rlist (cons r1 r2) l2)) -> forall l2 : Rlist, ordered_Rlist (cons r (cons r1 r2)) -> ordered_Rlist l2 -> pos_Rl (cons r (cons r1 r2)) (Init.Nat.pred (Rlength (cons r (cons r1 r2)))) <= pos_Rl l2 0 -> ordered_Rlist (cons_Rlist (cons r (cons r1 r2)) l2)l1:Rlistr:Rr0:RlistH:forall l0 : Rlist, ordered_Rlist nil -> ordered_Rlist l0 -> pos_Rl nil (Init.Nat.pred (Rlength nil)) <= pos_Rl l0 0 -> ordered_Rlist (cons_Rlist nil l0)l2:RlistH0:ordered_Rlist (cons r nil)H1:ordered_Rlist l2H2:r <= pos_Rl l2 0H3:(0 < Rlength l2)%natpos_Rl (cons r l2) 0 <= pos_Rl (cons r l2) 1l1:Rlistr:Rr0:RlistH:forall l0 : Rlist, ordered_Rlist nil -> ordered_Rlist l0 -> pos_Rl nil (Init.Nat.pred (Rlength nil)) <= pos_Rl l0 0 -> ordered_Rlist (cons_Rlist nil l0)l2:RlistH0:ordered_Rlist (cons r nil)H1:ordered_Rlist l2H2:r <= pos_Rl l2 0i:natH3:(S i < Rlength l2)%natHreci:(i < Rlength l2)%nat -> pos_Rl (cons r l2) i <= pos_Rl (cons r l2) (S i)pos_Rl (cons r l2) (S i) <= pos_Rl (cons r l2) (S (S i))l1:Rlistr:Rr0:Rlistforall (r1 : R) (r2 : Rlist), ((forall l2 : Rlist, ordered_Rlist r2 -> ordered_Rlist l2 -> pos_Rl r2 (Init.Nat.pred (Rlength r2)) <= pos_Rl l2 0 -> ordered_Rlist (cons_Rlist r2 l2)) -> forall l2 : Rlist, ordered_Rlist (cons r r2) -> ordered_Rlist l2 -> pos_Rl (cons r r2) (Init.Nat.pred (Rlength (cons r r2))) <= pos_Rl l2 0 -> ordered_Rlist (cons_Rlist (cons r r2) l2)) -> (forall l2 : Rlist, ordered_Rlist (cons r1 r2) -> ordered_Rlist l2 -> pos_Rl (cons r1 r2) (Init.Nat.pred (Rlength (cons r1 r2))) <= pos_Rl l2 0 -> ordered_Rlist (cons_Rlist (cons r1 r2) l2)) -> forall l2 : Rlist, ordered_Rlist (cons r (cons r1 r2)) -> ordered_Rlist l2 -> pos_Rl (cons r (cons r1 r2)) (Init.Nat.pred (Rlength (cons r (cons r1 r2)))) <= pos_Rl l2 0 -> ordered_Rlist (cons_Rlist (cons r (cons r1 r2)) l2)l1:Rlistr:Rr0:RlistH:forall l0 : Rlist, ordered_Rlist nil -> ordered_Rlist l0 -> pos_Rl nil (Init.Nat.pred (Rlength nil)) <= pos_Rl l0 0 -> ordered_Rlist (cons_Rlist nil l0)l2:RlistH0:ordered_Rlist (cons r nil)H1:ordered_Rlist l2H2:r <= pos_Rl l2 0i:natH3:(S i < Rlength l2)%natHreci:(i < Rlength l2)%nat -> pos_Rl (cons r l2) i <= pos_Rl (cons r l2) (S i)pos_Rl (cons r l2) (S i) <= pos_Rl (cons r l2) (S (S i))l1:Rlistr:Rr0:Rlistforall (r1 : R) (r2 : Rlist), ((forall l2 : Rlist, ordered_Rlist r2 -> ordered_Rlist l2 -> pos_Rl r2 (Init.Nat.pred (Rlength r2)) <= pos_Rl l2 0 -> ordered_Rlist (cons_Rlist r2 l2)) -> forall l2 : Rlist, ordered_Rlist (cons r r2) -> ordered_Rlist l2 -> pos_Rl (cons r r2) (Init.Nat.pred (Rlength (cons r r2))) <= pos_Rl l2 0 -> ordered_Rlist (cons_Rlist (cons r r2) l2)) -> (forall l2 : Rlist, ordered_Rlist (cons r1 r2) -> ordered_Rlist l2 -> pos_Rl (cons r1 r2) (Init.Nat.pred (Rlength (cons r1 r2))) <= pos_Rl l2 0 -> ordered_Rlist (cons_Rlist (cons r1 r2) l2)) -> forall l2 : Rlist, ordered_Rlist (cons r (cons r1 r2)) -> ordered_Rlist l2 -> pos_Rl (cons r (cons r1 r2)) (Init.Nat.pred (Rlength (cons r (cons r1 r2)))) <= pos_Rl l2 0 -> ordered_Rlist (cons_Rlist (cons r (cons r1 r2)) l2)l1:Rlistr:Rr0:Rlistforall (r1 : R) (r2 : Rlist), ((forall l2 : Rlist, ordered_Rlist r2 -> ordered_Rlist l2 -> pos_Rl r2 (Init.Nat.pred (Rlength r2)) <= pos_Rl l2 0 -> ordered_Rlist (cons_Rlist r2 l2)) -> forall l2 : Rlist, ordered_Rlist (cons r r2) -> ordered_Rlist l2 -> pos_Rl (cons r r2) (Init.Nat.pred (Rlength (cons r r2))) <= pos_Rl l2 0 -> ordered_Rlist (cons_Rlist (cons r r2) l2)) -> (forall l2 : Rlist, ordered_Rlist (cons r1 r2) -> ordered_Rlist l2 -> pos_Rl (cons r1 r2) (Init.Nat.pred (Rlength (cons r1 r2))) <= pos_Rl l2 0 -> ordered_Rlist (cons_Rlist (cons r1 r2) l2)) -> forall l2 : Rlist, ordered_Rlist (cons r (cons r1 r2)) -> ordered_Rlist l2 -> pos_Rl (cons r (cons r1 r2)) (Init.Nat.pred (Rlength (cons r (cons r1 r2)))) <= pos_Rl l2 0 -> ordered_Rlist (cons_Rlist (cons r (cons r1 r2)) l2)l1:Rlistr:Rr0:Rlistr1:Rr2:RlistH0:forall l0 : Rlist, ordered_Rlist (cons r1 r2) -> ordered_Rlist l0 -> pos_Rl (cons r1 r2) (Init.Nat.pred (Rlength (cons r1 r2))) <= pos_Rl l0 0 -> ordered_Rlist (cons_Rlist (cons r1 r2) l0)l2:RlistH1:ordered_Rlist (cons r (cons r1 r2))H2:ordered_Rlist l2H3:pos_Rl (cons r (cons r1 r2)) (Init.Nat.pred (Rlength (cons r (cons r1 r2)))) <= pos_Rl l2 0ordered_Rlist (cons_Rlist (cons r1 r2) l2)l1:Rlistr:Rr0:Rlistr1:Rr2:RlistH0:forall l0 : Rlist, ordered_Rlist (cons r1 r2) -> ordered_Rlist l0 -> pos_Rl (cons r1 r2) (Init.Nat.pred (Rlength (cons r1 r2))) <= pos_Rl l0 0 -> ordered_Rlist (cons_Rlist (cons r1 r2) l0)l2:RlistH1:ordered_Rlist (cons r (cons r1 r2))H2:ordered_Rlist l2H3:pos_Rl (cons r (cons r1 r2)) (Init.Nat.pred (Rlength (cons r (cons r1 r2)))) <= pos_Rl l2 0H:ordered_Rlist (cons_Rlist (cons r1 r2) l2)ordered_Rlist (cons_Rlist (cons r (cons r1 r2)) l2)l1:Rlistr:Rr0:Rlistr1:Rr2:RlistH0:forall l0 : Rlist, ordered_Rlist (cons r1 r2) -> ordered_Rlist l0 -> pos_Rl (cons r1 r2) (Init.Nat.pred (Rlength (cons r1 r2))) <= pos_Rl l0 0 -> ordered_Rlist (cons_Rlist (cons r1 r2) l0)l2:RlistH1:ordered_Rlist (cons r (cons r1 r2))H2:ordered_Rlist l2H3:pos_Rl (cons r (cons r1 r2)) (Init.Nat.pred (Rlength (cons r (cons r1 r2)))) <= pos_Rl l2 0ordered_Rlist (cons r1 r2)l1:Rlistr:Rr0:Rlistr1:Rr2:RlistH0:forall l0 : Rlist, ordered_Rlist (cons r1 r2) -> ordered_Rlist l0 -> pos_Rl (cons r1 r2) (Init.Nat.pred (Rlength (cons r1 r2))) <= pos_Rl l0 0 -> ordered_Rlist (cons_Rlist (cons r1 r2) l0)l2:RlistH1:ordered_Rlist (cons r (cons r1 r2))H2:ordered_Rlist l2H3:pos_Rl (cons r (cons r1 r2)) (Init.Nat.pred (Rlength (cons r (cons r1 r2)))) <= pos_Rl l2 0H:ordered_Rlist (cons_Rlist (cons r1 r2) l2)ordered_Rlist (cons_Rlist (cons r (cons r1 r2)) l2)l1:Rlistr:Rr0:Rlistr1:Rr2:RlistH0:forall l0 : Rlist, ordered_Rlist (cons r1 r2) -> ordered_Rlist l0 -> pos_Rl (cons r1 r2) (Init.Nat.pred (Rlength (cons r1 r2))) <= pos_Rl l0 0 -> ordered_Rlist (cons_Rlist (cons r1 r2) l0)l2:RlistH1:ordered_Rlist (cons r (cons r1 r2))H2:ordered_Rlist l2H3:pos_Rl (cons r (cons r1 r2)) (Init.Nat.pred (Rlength (cons r (cons r1 r2)))) <= pos_Rl l2 0H:ordered_Rlist (cons_Rlist (cons r1 r2) l2)ordered_Rlist (cons_Rlist (cons r (cons r1 r2)) l2)l1:Rlistr:Rr0:Rlistr1:Rr2:RlistH0:forall l0 : Rlist, ordered_Rlist (cons r1 r2) -> ordered_Rlist l0 -> pos_Rl (cons r1 r2) (Init.Nat.pred (Rlength (cons r1 r2))) <= pos_Rl l0 0 -> ordered_Rlist (cons_Rlist (cons r1 r2) l0)l2:RlistH1:ordered_Rlist (cons r (cons r1 r2))H2:ordered_Rlist l2H3:pos_Rl (cons r (cons r1 r2)) (Init.Nat.pred (Rlength (cons r (cons r1 r2)))) <= pos_Rl l2 0H:ordered_Rlist (cons_Rlist (cons r1 r2) l2)H4:(0 < S (Rlength (cons_Rlist r2 l2)))%natpos_Rl (cons_Rlist (cons r (cons r1 r2)) l2) 0 <= pos_Rl (cons_Rlist (cons r (cons r1 r2)) l2) 1l1:Rlistr:Rr0:Rlistr1:Rr2:RlistH0:forall l0 : Rlist, ordered_Rlist (cons r1 r2) -> ordered_Rlist l0 -> pos_Rl (cons r1 r2) (Init.Nat.pred (Rlength (cons r1 r2))) <= pos_Rl l0 0 -> ordered_Rlist (cons_Rlist (cons r1 r2) l0)l2:RlistH1:ordered_Rlist (cons r (cons r1 r2))H2:ordered_Rlist l2H3:pos_Rl (cons r (cons r1 r2)) (Init.Nat.pred (Rlength (cons r (cons r1 r2)))) <= pos_Rl l2 0H:ordered_Rlist (cons_Rlist (cons r1 r2) l2)i:natH4:(S i < S (Rlength (cons_Rlist r2 l2)))%natHreci:(i < S (Rlength (cons_Rlist r2 l2)))%nat -> pos_Rl (cons_Rlist (cons r (cons r1 r2)) l2) i <= pos_Rl (cons_Rlist (cons r (cons r1 r2)) l2) (S i)pos_Rl (cons_Rlist (cons r (cons r1 r2)) l2) (S i) <= pos_Rl (cons_Rlist (cons r (cons r1 r2)) l2) (S (S i))change (pos_Rl (cons_Rlist (cons r1 r2) l2) i <= pos_Rl (cons_Rlist (cons r1 r2) l2) (S i)); apply (H i); simpl; apply lt_S_n; assumption. Qed.l1:Rlistr:Rr0:Rlistr1:Rr2:RlistH0:forall l0 : Rlist, ordered_Rlist (cons r1 r2) -> ordered_Rlist l0 -> pos_Rl (cons r1 r2) (Init.Nat.pred (Rlength (cons r1 r2))) <= pos_Rl l0 0 -> ordered_Rlist (cons_Rlist (cons r1 r2) l0)l2:RlistH1:ordered_Rlist (cons r (cons r1 r2))H2:ordered_Rlist l2H3:pos_Rl (cons r (cons r1 r2)) (Init.Nat.pred (Rlength (cons r (cons r1 r2)))) <= pos_Rl l2 0H:ordered_Rlist (cons_Rlist (cons r1 r2) l2)i:natH4:(S i < S (Rlength (cons_Rlist r2 l2)))%natHreci:(i < S (Rlength (cons_Rlist r2 l2)))%nat -> pos_Rl (cons_Rlist (cons r (cons r1 r2)) l2) i <= pos_Rl (cons_Rlist (cons r (cons r1 r2)) l2) (S i)pos_Rl (cons_Rlist (cons r (cons r1 r2)) l2) (S i) <= pos_Rl (cons_Rlist (cons r (cons r1 r2)) l2) (S (S i))forall (l1 l2 : Rlist) (i : nat), (i < Rlength l1)%nat -> pos_Rl (cons_Rlist l1 l2) i = pos_Rl l1 iforall (l1 l2 : Rlist) (i : nat), (i < Rlength l1)%nat -> pos_Rl (cons_Rlist l1 l2) i = pos_Rl l1 il1:Rlistforall (l2 : Rlist) (i : nat), (i < Rlength nil)%nat -> pos_Rl (cons_Rlist nil l2) i = pos_Rl nil il1:Rlistforall (r : R) (r0 : Rlist), (forall (l2 : Rlist) (i : nat), (i < Rlength r0)%nat -> pos_Rl (cons_Rlist r0 l2) i = pos_Rl r0 i) -> forall (l2 : Rlist) (i : nat), (i < Rlength (cons r r0))%nat -> pos_Rl (cons_Rlist (cons r r0) l2) i = pos_Rl (cons r r0) il1:Rlistforall (r : R) (r0 : Rlist), (forall (l2 : Rlist) (i : nat), (i < Rlength r0)%nat -> pos_Rl (cons_Rlist r0 l2) i = pos_Rl r0 i) -> forall (l2 : Rlist) (i : nat), (i < Rlength (cons r r0))%nat -> pos_Rl (cons_Rlist (cons r r0) l2) i = pos_Rl (cons r r0) il1:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i : nat), (i < Rlength r0)%nat -> pos_Rl (cons_Rlist r0 l0) i = pos_Rl r0 il2:RlistH0:(0 < Rlength (cons r r0))%natpos_Rl (cons_Rlist (cons r r0) l2) 0 = pos_Rl (cons r r0) 0l1:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (i0 < Rlength r0)%nat -> pos_Rl (cons_Rlist r0 l0) i0 = pos_Rl r0 i0l2:Rlisti:natH0:(S i < Rlength (cons r r0))%natHreci:(i < Rlength (cons r r0))%nat -> pos_Rl (cons_Rlist (cons r r0) l2) i = pos_Rl (cons r r0) ipos_Rl (cons_Rlist (cons r r0) l2) (S i) = pos_Rl (cons r r0) (S i)apply (H l2 i); simpl in H0; apply lt_S_n; assumption. Qed.l1:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (i0 < Rlength r0)%nat -> pos_Rl (cons_Rlist r0 l0) i0 = pos_Rl r0 i0l2:Rlisti:natH0:(S i < Rlength (cons r r0))%natHreci:(i < Rlength (cons r r0))%nat -> pos_Rl (cons_Rlist (cons r r0) l2) i = pos_Rl (cons r r0) ipos_Rl (cons_Rlist (cons r r0) l2) (S i) = pos_Rl (cons r r0) (S i)forall l1 l2 l3 : Rlist, cons_Rlist l1 (cons_Rlist l2 l3) = cons_Rlist (cons_Rlist l1 l2) l3simple induction l1; intros; [ reflexivity | simpl; rewrite (H l2 l3); reflexivity ]. Qed.forall l1 l2 l3 : Rlist, cons_Rlist l1 (cons_Rlist l2 l3) = cons_Rlist (cons_Rlist l1 l2) l3forall l : Rlist, cons_Rlist l nil = lsimple induction l; [ reflexivity | intros; simpl; rewrite H; reflexivity ]. Qed.forall l : Rlist, cons_Rlist l nil = lforall (l2 l1 : Rlist) (i : nat), (Rlength l1 <= i)%nat -> (i < Rlength (cons_Rlist l1 l2))%nat -> pos_Rl (cons_Rlist l1 l2) i = pos_Rl l2 (i - Rlength l1)forall (l2 l1 : Rlist) (i : nat), (Rlength l1 <= i)%nat -> (i < Rlength (cons_Rlist l1 l2))%nat -> pos_Rl (cons_Rlist l1 l2) i = pos_Rl l2 (i - Rlength l1)l2:Rlistforall (l1 : Rlist) (i : nat), (Rlength l1 <= i)%nat -> (i < Rlength (cons_Rlist l1 nil))%nat -> pos_Rl (cons_Rlist l1 nil) i = pos_Rl nil (i - Rlength l1)l2:Rlistforall (r : R) (r0 : Rlist), (forall (l1 : Rlist) (i : nat), (Rlength l1 <= i)%nat -> (i < Rlength (cons_Rlist l1 r0))%nat -> pos_Rl (cons_Rlist l1 r0) i = pos_Rl r0 (i - Rlength l1)) -> forall (l1 : Rlist) (i : nat), (Rlength l1 <= i)%nat -> (i < Rlength (cons_Rlist l1 (cons r r0)))%nat -> pos_Rl (cons_Rlist l1 (cons r r0)) i = pos_Rl (cons r r0) (i - Rlength l1)l2:Rlistforall (r : R) (r0 : Rlist), (forall (l1 : Rlist) (i : nat), (Rlength l1 <= i)%nat -> (i < Rlength (cons_Rlist l1 r0))%nat -> pos_Rl (cons_Rlist l1 r0) i = pos_Rl r0 (i - Rlength l1)) -> forall (l1 : Rlist) (i : nat), (Rlength l1 <= i)%nat -> (i < Rlength (cons_Rlist l1 (cons r r0)))%nat -> pos_Rl (cons_Rlist l1 (cons r r0)) i = pos_Rl (cons r r0) (i - Rlength l1)l2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natpos_Rl (cons_Rlist (cons_Rlist l1 (cons r nil)) r0) i = pos_Rl (cons r r0) (i - Rlength l1)l2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natcons_Rlist (cons_Rlist l1 (cons r nil)) r0 = cons_Rlist l1 (cons r r0)l2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natH2:Rlength l1 = ipos_Rl (cons_Rlist (cons_Rlist l1 (cons r nil)) r0) (Rlength l1) = pos_Rl (cons r r0) (Rlength l1 - Rlength l1)l2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natm:natH2:(Rlength l1 <= m)%natH3:S m = ipos_Rl (cons_Rlist (cons_Rlist l1 (cons r nil)) r0) (S m) = pos_Rl (cons r r0) (S m - Rlength l1)l2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natcons_Rlist (cons_Rlist l1 (cons r nil)) r0 = cons_Rlist l1 (cons r r0)l2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natH2:Rlength l1 = ipos_Rl (cons_Rlist l1 (cons r nil)) (Rlength l1) = rl2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natH2:Rlength l1 = i(Rlength l1 < Rlength (cons_Rlist l1 (cons r nil)))%natl2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natm:natH2:(Rlength l1 <= m)%natH3:S m = ipos_Rl (cons_Rlist (cons_Rlist l1 (cons r nil)) r0) (S m) = pos_Rl (cons r r0) (S m - Rlength l1)l2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natcons_Rlist (cons_Rlist l1 (cons r nil)) r0 = cons_Rlist l1 (cons r r0)r:Rpos_Rl (cons_Rlist nil (cons r nil)) (Rlength nil) = rr, r0:Rl1:RlistHrecl1:pos_Rl (cons_Rlist l1 (cons r nil)) (Rlength l1) = rpos_Rl (cons_Rlist (cons r0 l1) (cons r nil)) (Rlength (cons r0 l1)) = rl2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natH2:Rlength l1 = i(Rlength l1 < Rlength (cons_Rlist l1 (cons r nil)))%natl2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natm:natH2:(Rlength l1 <= m)%natH3:S m = ipos_Rl (cons_Rlist (cons_Rlist l1 (cons r nil)) r0) (S m) = pos_Rl (cons r r0) (S m - Rlength l1)l2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natcons_Rlist (cons_Rlist l1 (cons r nil)) r0 = cons_Rlist l1 (cons r r0)r, r0:Rl1:RlistHrecl1:pos_Rl (cons_Rlist l1 (cons r nil)) (Rlength l1) = rpos_Rl (cons_Rlist (cons r0 l1) (cons r nil)) (Rlength (cons r0 l1)) = rl2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natH2:Rlength l1 = i(Rlength l1 < Rlength (cons_Rlist l1 (cons r nil)))%natl2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natm:natH2:(Rlength l1 <= m)%natH3:S m = ipos_Rl (cons_Rlist (cons_Rlist l1 (cons r nil)) r0) (S m) = pos_Rl (cons r r0) (S m - Rlength l1)l2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natcons_Rlist (cons_Rlist l1 (cons r nil)) r0 = cons_Rlist l1 (cons r r0)l2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natH2:Rlength l1 = i(Rlength l1 < Rlength (cons_Rlist l1 (cons r nil)))%natl2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natm:natH2:(Rlength l1 <= m)%natH3:S m = ipos_Rl (cons_Rlist (cons_Rlist l1 (cons r nil)) r0) (S m) = pos_Rl (cons r r0) (S m - Rlength l1)l2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natcons_Rlist (cons_Rlist l1 (cons r nil)) r0 = cons_Rlist l1 (cons r r0)l2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natm:natH2:(Rlength l1 <= m)%natH3:S m = ipos_Rl (cons_Rlist (cons_Rlist l1 (cons r nil)) r0) (S m) = pos_Rl (cons r r0) (S m - Rlength l1)l2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natcons_Rlist (cons_Rlist l1 (cons r nil)) r0 = cons_Rlist l1 (cons r r0)l2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natm:natH2:(Rlength l1 <= m)%natH3:S m = ipos_Rl (cons_Rlist (cons_Rlist l1 (cons r nil)) r0) (S m) = pos_Rl (cons r r0) (S (S m - S (Rlength l1)))l2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natm:natH2:(Rlength l1 <= m)%natH3:S m = iS (S m - S (Rlength l1)) = (S m - Rlength l1)%natl2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natcons_Rlist (cons_Rlist l1 (cons r nil)) r0 = cons_Rlist l1 (cons r r0)l2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natm:natH2:(Rlength l1 <= m)%natH3:S m = ipos_Rl (cons_Rlist (cons_Rlist l1 (cons r nil)) r0) i = pos_Rl r0 (i - Rlength (cons_Rlist l1 (cons r nil)))l2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natm:natH2:(Rlength l1 <= m)%natH3:S m = iRlength (cons_Rlist l1 (cons r nil)) = S (Rlength l1)l2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natm:natH2:(Rlength l1 <= m)%natH3:S m = iS (S m - S (Rlength l1)) = (S m - Rlength l1)%natl2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natcons_Rlist (cons_Rlist l1 (cons r nil)) r0 = cons_Rlist l1 (cons r r0)l2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natm:natH2:(Rlength l1 <= m)%natH3:S m = i(Rlength (cons_Rlist l1 (cons r nil)) <= i)%natl2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natm:natH2:(Rlength l1 <= m)%natH3:S m = i(i < Rlength (cons_Rlist (cons_Rlist l1 (cons r nil)) r0))%natl2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natm:natH2:(Rlength l1 <= m)%natH3:S m = iRlength (cons_Rlist l1 (cons r nil)) = S (Rlength l1)l2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natm:natH2:(Rlength l1 <= m)%natH3:S m = iS (S m - S (Rlength l1)) = (S m - Rlength l1)%natl2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natcons_Rlist (cons_Rlist l1 (cons r nil)) r0 = cons_Rlist l1 (cons r r0)l2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natm:natH2:(Rlength l1 <= m)%natH3:S m = i(i < Rlength (cons_Rlist (cons_Rlist l1 (cons r nil)) r0))%natl2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natm:natH2:(Rlength l1 <= m)%natH3:S m = iRlength (cons_Rlist l1 (cons r nil)) = S (Rlength l1)l2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natm:natH2:(Rlength l1 <= m)%natH3:S m = iS (S m - S (Rlength l1)) = (S m - Rlength l1)%natl2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natcons_Rlist (cons_Rlist l1 (cons r nil)) r0 = cons_Rlist l1 (cons r r0)l2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natm:natH2:(Rlength l1 <= m)%natH3:S m = iRlength (cons_Rlist l1 (cons r nil)) = S (Rlength l1)l2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natm:natH2:(Rlength l1 <= m)%natH3:S m = iS (S m - S (Rlength l1)) = (S m - Rlength l1)%natl2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natcons_Rlist (cons_Rlist l1 (cons r nil)) r0 = cons_Rlist l1 (cons r r0)l2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natm:natH2:(Rlength l1 <= m)%natH3:S m = iS (S m - S (Rlength l1)) = (S m - Rlength l1)%natl2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natcons_Rlist (cons_Rlist l1 (cons r nil)) r0 = cons_Rlist l1 (cons r r0)replace (cons r r0) with (cons_Rlist (cons r nil) r0); [ symmetry ; apply RList_P27 | reflexivity ]. Qed.l2:Rlistr:Rr0:RlistH:forall (l0 : Rlist) (i0 : nat), (Rlength l0 <= i0)%nat -> (i0 < Rlength (cons_Rlist l0 r0))%nat -> pos_Rl (cons_Rlist l0 r0) i0 = pos_Rl r0 (i0 - Rlength l0)l1:Rlisti:natH0:(Rlength l1 <= i)%natH1:(i < Rlength (cons_Rlist l1 (cons r r0)))%natcons_Rlist (cons_Rlist l1 (cons r nil)) r0 = cons_Rlist l1 (cons r r0)