(lists of fixed length). It uses the definitions from the standard library, butrenames or changes their notations, so that it becomes more consistent with thenaming conventions in this development. *)FromstdppRequireExportfinlist.

OpenScopevector_scope.(** The type [vec n] represents lists of consisting of exactly [n] elements.Whereas the standard library declares exactly the same notations for vectors asused for lists, we use slightly different notations so it becomes easier to uselists and vectors together. *)Notationvec:=Vector.t.Notationvnil:=Vector.nil.Argumentsvnil{_}.Notationvcons:=Vector.cons.Notationvapp:=Vector.append.Argumentsvcons{_}_{_}_.Infix":::":=vcons(atlevel60,rightassociativity):vector_scope.

(** Notice that we cannot define [Vector.nth] as an instance of our [Lookup]type class, as it has a dependent type. *)ArgumentsVector.nth{__}!_!_%fin/.Infix"!!!":=Vector.nth(atlevel20):vector_scope.(** The tactic [vec_double_ind v1 v2] performs double induction on [v1] and [v2]provided that they have the same length. *)Notationvec_rect2:=Vector.rect2.Ltacvec_double_indv1v2:=matchtypeofv1with|vec_?n=>repeatmatchgoalwith

Proof.refine(vec_rect2(λn(vw:vecAn),{v=w}+{v≠w})(left_)(λ___Hxy,cast_if_and(decxy)H));f_equal;eautousingvcons_inj_1,vcons_inj_2.Defined.(** Similar to [fin], we provide an inversion principle that keeps the lengthfixed. We define a tactic [inv_vec v] to perform case analysis on [v], usingthis inversion principle. *)Notationvec_0_inv:=Vector.case0.Definitionvec_S_inv{An}(P:vecA(Sn)→Type)(Hcons:∀xv,P(x:::v))v:Pv.Proof.

(** We define a coercion from [vec] to [list] and show that it preserves theoperations on vectors. We also define a function to go in the other way, butdo not define it as a coercion, as it would otherwise introduce ambiguity. *)Fixpointvec_to_list{An}(v:vecAn):listA:=

(** Similar to vlookup, we cannot define [vinsert] as an instance of the[Insert] type class, as it has a dependent type. *)Fixpointvinsert{An}(i:finn)(x:A):vecAn→vecAn:=matchiwith|0%fin=>vec_S_inv_(λ_v,x:::v)