Definition get_IR_output_keys (l : list IR) : list K :=
    filterMap (fun x => match x with
                          | IRO k => Some k
                          | IRU k => Some k
                          | _ => None
                        end) l.

Lemma before_head_op : forall l h ir, (forall k1 k2, In (I k2) l -> before (O k1) (I k2) l -> before (IRO k1) (IRI k2) (IRI h :: ir)) -> forall x, In (I h) l -> before x (I h) l -> exists k, x = I k.