let compare_literals x y =
  let cmp =
    compare
      (Symbol.name (top_symbol_literal x))
      (Symbol.name (top_symbol_literal y))
  in
    if cmp <> 0 then
      cmp
    else if x.sign == y.sign then
      compare_terms x.atom y.atom
    else if x.sign then
      -1
    else
      1