let rec merge goals1 goals2 =
    (* List.merge sort_obligs opl1 opl2 : no, because keeps duplicates *)
    match goals1, goals2 with
      | _, [] -> goals1
      | [], _ -> goals2
      | g1::tl1, g2::tl2 ->
          let cmp = WpAnnot.compare_prop_id g1.g_id g2.g_id in
            if cmp < 0 then g1::(merge tl1 goals2)
            else if cmp > 0 then g2::(merge goals1 tl2)
            else
              let g = make_goal g1.g_id
                        (fun () -> W.merge g1.g_prop g2.g_prop)
                        [g1.g_descr; g2.g_descr]
              in g::(merge tl1 tl2)