Section INSTANCES.
#[global]
Instance vector_hasEqDec {A : Type} {n : nat}
(A_hasEqDec : hasEqDec A)
: hasEqDec (Vector.t A n).
#[local]
Instance vec_isSetoid (n : nat) (A : Type) `(SETOID : isSetoid A) : isSetoid (vec n A) :=
{ eqProp (lhs : vec n A) (rhs : vec n A) := forall i : Fin.t n, lhs !! i == rhs !! i
; eqProp_Equivalence := relation_on_image_liftsEquivalence (pi_isSetoid (fun _ => SETOID)).(eqProp_Equivalence) nth
}.
#[local]
Instance vec_isSetoid1 {n : nat} : isSetoid1 (vec n) :=
vec_isSetoid n.
#[global]
Instance vec_satisfiesMonadLaws {n : nat}
: @MonadLaws (vec n) vec_isSetoid1 vec_isMonad.
End INSTANCES.
Fixpoint foldr {A : Type} {B : Type} {n : nat} (f : A -> B -> B) (z : B) (xs : Vector.t A n) : B :=
match xs with
| [] => z
| x :: xs => f x (foldr f z xs)
end.
Fixpoint from_list (xs : list A) {struct xs} : Vector.t A (L.length xs) :=
match xs with
| L.nil => []
| L.cons x xs => x :: from_list xs
end.

Lemma to_list_from_list (xs : list A)
: to_list (from_list xs) = xs.