(************************************************************************)
(*         *      The Rocq Prover / The Rocq Development Team           *)
(*  v      *         Copyright INRIA, CNRS and contributors             *)
(* <O___,, * (see version control and CREDITS file for authors & dates) *)
(*   \VV/  **************************************************************)
(*    //   *    This file is distributed under the terms of the         *)
(*         *     GNU Lesser General Public License Version 2.1          *)
(*         *     (see LICENSE file for the text of the license)         *)
(************************************************************************)
(** N.B.: Using this encoding of vectors is discouraged. See <https://github.com/coq/coq/blob/master/stdlib/theories/Vectors/Vector.v>. *)
Attributes warn(cats="stdlib vector", note="Using Vector.t is known to be technically difficult, see <https://github.com/coq/coq/blob/master/stdlib/theories/Vectors/Vector.v>.").
(** Proofs of specification for functions defined over Vector  Initial Author: Pierre Boutillier Institution: PPS, INRIA 12/2010 *)
#[local] Set Warnings "-stdlib-vector".
Require Fin List.
Definition cons_inj {A} {a1 a2} {n} {v1 v2 : t A n}
(eq : a1 :: v1 = a2 :: v2) : a1 = a2 /\ v1 = v2 :=
match eq in _ = x return caseS _ (fun a2' _ v2' => fun v1' => a1 = a2' /\ v1' = v2') x v1
with | eq_refl => conj eq_refl eq_refl
end.

(* Specifications: *)
Lemma nil_spec {A} (v : t A 0) : v = [].
Lemma nth_order_hd A: forall n (v : t A (S n)) (H : 0 < S n),
nth_order v H = hd v.
Lemma nth_order_last A: forall n (v: t A (S n)) (H: n < S n),
nth_order v H = last v.
Lemma nth_order_ext A: forall n k (v : t A n) (H1 H2 : k < n),
nth_order v H1 = nth_order v H2.
Lemma nth_append_L A: forall n m (v : t A n) (w : t A m) p,
(v ++ w) [@ Fin.L m p] = v [@ p].
Lemma nth_append_R A: forall n m (v : t A n) (w : t A m) p,
(v ++ w) [@ Fin.R n p] = w [@ p].
Lemma In_nth A: forall n (v : t A n) p,
In (nth v p) v.