(* This program is free software; you can redistribute it and/or      *)
(* modify it under the terms of the GNU Lesser General Public License *)
(* as published by the Free Software Foundation; either version 2.1   *)
(* of the License, or (at your option) any later version.             *)
(*                                                                    *)
(* This program is distributed in the hope that it will be useful,    *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of     *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      *)
(* GNU General Public License for more details.                       *)
(*                                                                    *)
(* You should have received a copy of the GNU Lesser General Public   *)
(* License along with this program; if not, write to the Free         *)
(* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *)
(* 02110-1301 USA                                                     *)
(** %\subsection*{ support :  conshdtl.v }%*)
Set Implicit Arguments.
Unset Strict Implicit.
Require Export finite.
From Algebra Require Export Parts.
(** - This file introduces the "cons" operator on sequences (called "conseq" here to avoid confusion with the normal notion for Lists). It is denoted as "a;;v" instead of "a::v" since the latter is already taken in coq. - Also it defines "Seqtl" (the "tail" operator) and "head". *)
Section MAIN.
(* conseq adjoins an element x of X to finite functions f:(fin N)->X *)
(* This is done by {0->x; m+1->f(m)} : (fin N+1)->X, ie. the new element *)
(* is inserted at the front. That's why it's called conseq: it's the seq *)
(* variant of the cons operator as seen in lists *)
(** %\label{conseq}% *)
Definition conseq :
forall (A : Setoid) (n : Nat) (a : A) (v : seq n A), seq (S n) A.
intros.
apply
(Build_Map
(Ap:=fun m : fin (S n) =>
match m return (A:Type) with
| Build_finiteT x0 x1 =>
match x0 as x2 return (x2 < S n -> (A:Type)) with
| O => fun _ : 0 < S n => a
| S m' =>
fun HSm' : S m' < S n =>
Ap v (Build_finiteT (lt_S_n m' n HSm'))
end x1
end)).
red in |- *.
simpl in |- *.
intros x0 y.
case x0.
case y.
simpl in |- *.
intros x2 y1.
induction x2.
intros x2 y2.
induction x2.
intro; apply Refl.
intro H.
inversion H.
clear IHx2.
simple induction index.
intros h H.
inversion H.
intros.
clear H.
apply Ap_comp; auto with algebra.
Defined.
Notation "a ;; b" := (conseq a b) (at level 60, right associativity).
Variables (A : Setoid) (n : Nat) (a : A).

(* Specifications: *)
Lemma cons_comp :
forall (a' : A) (v v' : seq n A),
a =' a' in _ -> v =' v' in _ -> a;; v =' a';; v' in _.