intuition.
eapply to_list_nil_inv.
eapply app_second_eq.
eapply shiftOut_correct_inv.
eauto.
trivial.
Qed.

Lemma filter_Permutation : forall (A : Set)(ls1 ls2 : list A)(P : A -> bool),
Permutation ls1 ls2 ->
Permutation (filter P ls1) (filter P ls2).