Section Accessories.
Context {A : Type}.
#[local] Notation vec := (Vector.t A).
Fixpoint map {A : Type} {B : Type} {n : nat} (f : A -> B) (xs : Vector.t A n) {struct xs} : Vector.t B n :=
match xs with
| [] => []
| x :: xs' => f x :: map f xs'
end.
Fixpoint replicate {A : Type} {n : nat} {struct n} : A -> Vector.t A n :=
match n with
| O => fun x => []
| S n' => fun x => x :: replicate (n := n') x
end.
Fixpoint diagonal {A : Type} {n : nat} {struct n} : Vector.t (Vector.t A n) n -> Vector.t A n :=
match n with
| O => fun xss => []
| S n' => fun xss => head (head xss) :: diagonal (n := n') (map tail (tail xss))
end.

Lemma diagonal_spec {A : Type} {n : nat} (xss : Vector.t (Vector.t A n) n)
: forall i : Fin.t n, xss !! i !! i = diagonal xss !! i.