Section Permutation_alt.
Variable A:Type.
Implicit Type a : A.
Implicit Type l : list A.
(** Alternative characterization of permutation via [nth_error] and [nth] *)
Let adapt f n :=
let m := f (S n) in if le_lt_dec m (f 0) then m else pred m.
Local Definition adapt_injective f : Injective f -> Injective (adapt f).

(* Specifications: *)
Lemma Permutation_nth_error_bis l l' :
Permutation l l' <->
exists f:nat->nat,
Injective f /\
bFun (length l) f /\
(forall n, nth_error l' n = nth_error l (f n)).
Lemma Permutation_nth l l' d :
Permutation l l' <->
(let n := length l in
length l' = n /\
exists f:nat->nat,
bFun n f /\
bInjective n f /\
(forall x, x < n -> nth x l' d = nth (f x) l d)).