Section Dependent_lists.
Variable A : Set.
Inductive list : nat -> Set :=
| nil : list 0
| cons : forall n : nat, A -> list n -> list (S n).
Definition eq_list := eq_dep nat list.
Definition hd (n : nat) (l : list n) : Exc A :=
match l in (list m) return (Exc A) with
| nil => error
| cons p a l' => value a
end.
Definition head (n : nat) (l : list n) :=
match l in (list p) return (0 < p -> A) with
| nil =>
(* nil*)
fun h : 0 < 0 => False_rec A (lt_irrefl 0 h)
(*cons p a l' *)
| cons p a l' => fun h : 0 < S p => a
end.
Definition Head (n : nat) (l : list (S n)) := head (S n) l (lt_O_Sn n).
Definition tl (n : nat) (l : list n) : list (pred n) :=
match l in (list m) return (list (pred m)) with
| nil => nil
| cons p a l' => l'
end.

Lemma empty_dep : forall (n : nat) (l : list n), n = 0 -> eq_list 0 nil n l.