| 1 |
Module Vector. |
| 2 |
Inductive t (A : Type) : nat -> Type := |
| 3 |
| nil : t A 0 |
| 4 |
| cons : A -> forall n : nat, t A n -> t A (S n). |
| 5 |
Fixpoint map {A B} (f : A -> B) {n} (v : t A n) : t B n := |
| 6 |
match v in (Vector.t _ n0) return (Vector.t B n0) with |
| 7 |
| nil _ => nil B |
| 8 |
| cons _ a n0 v' => cons B (f a) n0 (map f v') |
| 9 |
end. |
| 10 |
Definition caseS {A} (P : forall {n}, t A (S n) -> Type) |
| 11 |
(H : forall h {n} t, @P n (cons _ h _ t)) {n} (v: t A (S n)) : P v := |
| 12 |
match v with |
| 13 |
| cons _ h _ t => H h t |
| 14 |
| _ => fun devil => False_ind (@IDProp) devil (* subterm !!! *) |
| 15 |
end. |
| 16 |
Definition tl {A} := @caseS _ (fun n v => t A n) (fun h n t => t). |
| 17 |
End Vector. |