(* 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 in_remove (T: Set) x n (i: natBelow (S n)) (v: Vector.t T (S n)): List.In x v -> x <> nth v i -> List.In x (remove v i).