(* conversion to/from list *)

Fixpoint to_list X (n: nat) (v: Vector.t X n) {struct v}: List.list X :=
  match v with
  | Vector.nil => List.nil | Vector.cons x _ v' => List.cons x (to_list v')
  end.Fixpoint from_list A (l: List.list A): Vector.t A (List.length l) :=
  match l return Vector.t A (List.length l) with
  | List.nil => Vector.nil | List.cons h t => Vector.cons h (from_list t)
  end.

(* Specifications: *)
Lemma list_round_trip A (l: List.list A): to_list (from_list l) = l.
Lemma vec_round_trip (X T: Set) (n : nat) (v : Vector.t X n) (f: forall n, Vector.t X n -> T): (f _ (from_list (to_list v))) = f _ v.
Lemma eq_as_lists X n (x y: Vector.t X n): to_list x = to_list y -> x = y.
Lemma eq_list A (l: List.list A) (v: Vector.t A (List.length l)): from_list l = v -> l = to_list v.
Lemma double_rect A B (P: forall n, Vector.t A n -> Vector.t B n -> Prop): P 0 Vector.nil Vector.nil -> (forall n (v: Vector.t A n) (w: Vector.t B n) (x: A) (y: B), P n v w -> P (S n) (Vector.cons x v) (Vector.cons y w)) -> forall n (v: Vector.t A n) (w: Vector.t B n), P n v w.
Lemma length A n (l: Vector.t A n): List.length l = n.