Fixpoint all_but (i : nat) {A} (l : list A) : list A :=
match i with
O => tl l
| S i =>
match l with
nil => nil
| x :: l => x :: all_but i l
end
end.

(* Specifications: *)
Lemma all_but_app {A} i (l l' : list A) :
lt i (List.length l) ->
all_but i (l ++ l') = all_but i l ++ l'.
Lemma all_but_map {A B} (f : A -> B) i l :
all_but i (map f l) = map f (all_but i l).
Lemma permutation_all_but {A} i (l : list A) x :
nth_error l i = Some x ->
Permutation l (x :: all_but i l).