Proof using.
intros h h' l1 l2 f m H_in.
apply functional_extensionality; intro from.
apply functional_extensionality; intro to.
case (A_eq_dec h' from); intro H_dec; case (A_eq_dec h to); intro H_dec'.
- rewrite <- H_dec.
rewrite <- H_dec'.
rewrite collate_ls_not_in; auto.
rewrite collate_ls_app; simpl.
set (f' := collate_ls _ l1 _ _ _).
rewrite collate_ls_not_in.
* unfold update2 at 2.
break_if.
+ unfold f'.
rewrite collate_ls_not_in.
-- unfold update2.
break_if; auto.
break_or_hyp; intuition.
-- intro.
contradict H_in.
apply in_or_app.
left.
assumption.
+ break_or_hyp; intuition.
* intro.
contradict H_in.
apply in_or_app.
right.
assumption.
- rewrite collate_ls_neq_to; auto.
rewrite collate_ls_neq_to; auto.
unfold update2.
break_if; auto.
break_and; subst.
intuition.
- rewrite H_dec'.
rewrite collate_ls_neq_update2; auto.
rewrite collate_ls_split_eq; auto.
- rewrite collate_ls_neq_to; auto.
rewrite collate_ls_neq_to; auto.
unfold update2.
break_if; auto.
break_and; subst.
intuition.
Qed.

Lemma NoDup_Permutation_collate_ls_eq :
forall l (f : A -> A -> list B) h m l',
NoDup l ->
Permutation l l' ->
collate_ls A_eq_dec l f h m = collate_ls A_eq_dec l' f h m.