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.

Lemma head_unfold {A : Type} (n : nat) (x : A) (xs : Vector.t A n)
: head (x :: xs) = x.