示例#1
0
 void mk_new_rule_tail(ast_manager & m, app * pred, var_idx_set const & non_local_vars, unsigned & next_idx, varidx2var_map & varidx2var, 
                       sort_ref_buffer & new_rule_domain, expr_ref_buffer & new_rule_args, app_ref & new_pred) {
     expr_ref_buffer new_args(m);
     unsigned n  = pred->get_num_args();
     for (unsigned i = 0; i < n; i++) {
         expr * arg = pred->get_arg(i);
         if (m.is_value(arg)) {
             new_args.push_back(arg);
         }
         else {
             SASSERT(is_var(arg));
             int vidx      = to_var(arg)->get_idx();
             var * new_var = 0;
             if (!varidx2var.find(vidx, new_var)) {
                 new_var = m.mk_var(next_idx, to_var(arg)->get_sort());
                 next_idx++;
                 varidx2var.insert(vidx, new_var);
                 if (non_local_vars.contains(vidx)) {
                     // other predicates used this variable... so it should be in the domain of the filter
                     new_rule_domain.push_back(to_var(arg)->get_sort());
                     new_rule_args.push_back(new_var);
                 }
             }
             SASSERT(new_var != 0);
             new_args.push_back(new_var);
         }
     }
     new_pred = m.mk_app(pred->get_decl(), new_args.size(), new_args.c_ptr());
 }
示例#2
0
 void mk_magic_sets::adornment::populate(app * lit, const var_idx_set & bound_vars) {
     SASSERT(empty());
     unsigned arity = lit->get_num_args();
     for (unsigned i = 0; i < arity; i++) {
         const expr * arg = lit->get_arg(i);
         bool bound = !is_var(arg) || bound_vars.contains(to_var(arg)->get_idx());
         push_back(bound ? AD_BOUND : AD_FREE);
     }
 }
示例#3
0
 float mk_magic_sets::get_unbound_cost(app * lit, const var_idx_set & bound_vars) {
     func_decl * pred = lit->get_decl();
     float res = 1;
     unsigned n = lit->get_num_args();
     for (unsigned i = 0; i < n; i++) {
         const expr * arg = lit->get_arg(i);
         if (is_var(arg) && !bound_vars.contains(to_var(arg)->get_idx())) {
             res *= m_context.get_sort_size_estimate(pred->get_domain(i));
         }
         //res-=1;
     }
     return res;
 }
示例#4
0
 unsigned get_bound_arg_count(app * lit, const var_idx_set & bound_vars) {
     unsigned res = 0;
     unsigned n = lit->get_num_args();
     for (unsigned i = 0; i < n; i++) {
         const expr * arg = lit->get_arg(i);
         if (!is_var(arg) || bound_vars.contains(to_var(arg)->get_idx())) {
             SASSERT(is_var(arg) || is_app(arg));
             SASSERT(!is_app(arg) || to_app(arg)->get_num_args()==0);
             res++;
         }
     }
     return res;
 }