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.
Inductive vec_heq (n : nat) (xs : Vector.t A n) : forall m : nat, Vector.t A m -> Prop :=
| vec_ext_heq_refl
: vec_heq n xs n xs.
#[local] Notation " xs =~= xs' " := (vec_heq _ xs _ xs') : type_scope.
#[local] Hint Constructors vec_heq : core.

Lemma nth_error_to_list (n : nat) (xs : Vector.t A n) (i : nat)
(LT : i < n)
: nth_error (to_list xs) i = Some (xs !! Fin.getFin i LT).