Section Update2Rel.
Variables A B : Type.
Variable R : relation A.
Hypothesis A_eq_dec : forall x y : A, {x = y} + {x <> y}.
Hypothesis R_dec : forall x y : A, {R x y} + {~ R x y}.
Proof using.
intros.
induction ns; simpl in *; [ intuition | idtac ].
break_if; simpl in *.
- break_or_hyp; auto.
concludes.
break_and.
auto.
- concludes.
break_and.
auto.
Qed.
Proof using.
intros.
induction ns; simpl in *; [ intuition | idtac ].
break_if.
- break_or_hyp.
* left; auto.
* concludes.
right; auto.
- break_or_hyp.
* intuition.
* concludes.
assumption.
Qed.
Proof using.
induction ns; intros; auto.
assert (H_neq: a <> n).
intro.
subst.
auto with datatypes.
assert (H_not_in: ~ In n ns).
intro.
intuition.
simpl.
break_if; auto.
simpl.
intro.
break_or_hyp; auto.
intuition eauto.
Qed.
Proof using.
intros.
induction ns; auto.
invc_NoDup.
concludes.
simpl in *.
break_if; auto.
apply NoDup_cons; auto.
apply not_in_not_in_filter_rel.
assumption.
Qed.
Proof using.
induction ns0; intros; simpl in *.
- break_if; auto.
find_apply_lem_hyp irreflexive_R.
intuition.
- break_if; auto.
find_higher_order_rewrite.
trivial.
Qed.
Proof using.
intros f g h n n' l.
generalize f g; clear f g.
induction l; auto.
intros.
simpl in *.
break_let.
destruct a.
find_injection.
set (f' := update2 _ _ _ _ _).
set (g' := update2 _ _ _ _ _).
rewrite (IHl f' g'); auto.
unfold f', g', update2.
break_if; auto.
break_and.
subst.
find_rewrite.
trivial.
Qed.

Lemma collate_in_in :
forall l h n n' (f : A -> A -> list B) a,
In a (f n' n) ->
In a ((collate A_eq_dec h f l) n' n).