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.

Lemma len_eq_from_vec_heq (n : nat) (m : nat) (xs : Vector.t A n) (xs' : Vector.t A m)
(HEQ : xs =~= xs')
: n = m.