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.
unfold eq_list in |- *; intros n l.
dependent inversion_clear l; auto.
intros H; absurd (S n0 = 0); auto.
Qed.
Hint Resolve empty_dep.

Lemma empty : forall l : list 0, nil = l.