Exemplo n.º 1
0
static void sort_args(expr * & l1, expr * & l2, expr * & l3) {
    expr * args[3] = {l1, l2, l3};
    // ast_lt_proc is based on the AST ids. So, it is a total order on AST nodes.
    // No need for stable_sort
    std::sort(args, args+3, ast_lt_proc());
    l1 = args[0]; l2 = args[1]; l3 = args[2];
}
 br_status mk_app_core(func_decl * f, unsigned num_args, expr * const * args, expr_ref & result) {
     if ((f->is_associative() && f->is_commutative()) ||
         m_manager.is_distinct(f)) {
         ptr_buffer<expr> buffer;
         buffer.append(num_args, args);
         std::sort(buffer.begin(), buffer.end(), ast_lt_proc());
         bool change = false;
         for (unsigned i = 0; !change && i < num_args; ++i) {
             change = (args[i] != buffer[i]);
         }
         if (change) {
             result = m().mk_app(f, num_args, buffer.begin());
             return BR_DONE;
         }
     }
     else if (f->is_commutative() && num_args == 2 && args[0]->get_id() > args[1]->get_id()) {
         expr* args2[2] = { args[1], args[0] };
         result = m().mk_app(f, num_args, args2);
         return BR_DONE;
     }
     return BR_FAILED;
 }