(* remove *)

Definition remove (T: Set) (n: nat) (v: Vector.t T (S n)) (nb: natBelow (S n)): Vector.t T n :=
  natBelow_rect_S
    (fun (n0: nat) (_: natBelow (S n0)) => Vector.t T (S n0) -> Vector.t T n0)
    (fun p => @tail p _)
    (fun v p H v0 => Vector.cons (head v0) (H (tail v0))) nb v.(* permutations *)

Inductive Permutation (A: Type): forall n, Vector.t A n -> Vector.t A n -> Prop :=
  | perm_nil: Permutation Vector.nil Vector.nil
  | perm_skip (x: A) n (v v': Vector.t A n): Permutation v v' -> Permutation (Vector.cons x v) (Vector.cons x v')
  | perm_swap (x y: A) n (l: Vector.t A n): Permutation (Vector.cons y (Vector.cons x l)) (Vector.cons x (Vector.cons y l))
  | perm_trans n (l l' l'': Vector.t A n): Permutation l l' -> Permutation l' l'' -> Permutation l l''.(* permutations *)

Inductive Permutation (A: Type): forall n, Vector.t A n -> Vector.t A n -> Prop :=
  | perm_nil: Permutation Vector.nil Vector.nil
  | perm_skip (x: A) n (v v': Vector.t A n): Permutation v v' -> Permutation (Vector.cons x v) (Vector.cons x v')
  | perm_swap (x y: A) n (l: Vector.t A n): Permutation (Vector.cons y (Vector.cons x l)) (Vector.cons x (Vector.cons y l))
  | perm_trans n (l l' l'': Vector.t A n): Permutation l l' -> Permutation l' l'' -> Permutation l l''.(* permutations *)

Inductive Permutation (A: Type): forall n, Vector.t A n -> Vector.t A n -> Prop :=
  | perm_nil: Permutation Vector.nil Vector.nil
  | perm_skip (x: A) n (v v': Vector.t A n): Permutation v v' -> Permutation (Vector.cons x v) (Vector.cons x v')
  | perm_swap (x y: A) n (l: Vector.t A n): Permutation (Vector.cons y (Vector.cons x l)) (Vector.cons x (Vector.cons y l))
  | perm_trans n (l l' l'': Vector.t A n): Permutation l l' -> Permutation l' l'' -> Permutation l l''.(* permutations *)

Inductive Permutation (A: Type): forall n, Vector.t A n -> Vector.t A n -> Prop :=
  | perm_nil: Permutation Vector.nil Vector.nil
  | perm_skip (x: A) n (v v': Vector.t A n): Permutation v v' -> Permutation (Vector.cons x v) (Vector.cons x v')
  | perm_swap (x y: A) n (l: Vector.t A n): Permutation (Vector.cons y (Vector.cons x l)) (Vector.cons x (Vector.cons y l))
  | perm_trans n (l l' l'': Vector.t A n): Permutation l l' -> Permutation l' l'' -> Permutation l l''.(* permutations *)

Inductive Permutation (A: Type): forall n, Vector.t A n -> Vector.t A n -> Prop :=
  | perm_nil: Permutation Vector.nil Vector.nil
  | perm_skip (x: A) n (v v': Vector.t A n): Permutation v v' -> Permutation (Vector.cons x v) (Vector.cons x v')
  | perm_swap (x y: A) n (l: Vector.t A n): Permutation (Vector.cons y (Vector.cons x l)) (Vector.cons x (Vector.cons y l))
  | perm_trans n (l l' l'': Vector.t A n): Permutation l l' -> Permutation l' l'' -> Permutation l l''.

Lemma remove_map (A B: Set) (f: A -> B) n (i: natBelow (S n)) (v: Vector.t A (S n)): remove (map f v) i = map f (remove v i).