Proof using.
intros.
simpl in *.
find_eapply_lem_hyp before_middle_insert.
- find_eapply_lem_hyp in_middle_insert.
eapply_prop_hyp In (O k1); eauto.
intuition; try congruence.
- intro. find_inversion. eauto using NoDup_get_op_input_keys_In_I.
Qed.

Lemma in_before_before_preserved :
forall xs ys zs k ir,
NoDup (get_op_input_keys (xs ++ I k :: ys ++ O k :: zs)) ->
NoDup (get_op_output_keys (xs ++ I k :: ys ++ O k :: zs)) ->
(forall k1 k2,
In (I k2) (xs ++ I k :: ys ++ O k :: zs) ->
before (O k1) (I k2) (xs ++ I k :: ys ++ O k :: zs) ->
before (IRO k1) (IRI k2) (IRI k :: IRO k :: ir)) ->
forall k1 k2,
In (I k2) (xs ++ ys ++ zs) ->
before (O k1) (I k2) (xs ++ ys ++ zs) ->
before (IRO k1) (IRI k2) ir.