void grobner::extract_monomials(expr * lhs, ptr_buffer<expr> & monomials) { while (m_util.is_add(lhs)) { SASSERT(!m_util.is_add(to_app(lhs)->get_arg(0))); monomials.push_back(to_app(lhs)->get_arg(0)); lhs = to_app(lhs)->get_arg(1); } monomials.push_back(lhs); }
void clause::update_parents(ptr_buffer<clause> & parents) { ptr_buffer<clause>::iterator it = parents.begin(); ptr_buffer<clause>::iterator end = parents.end(); for (; it != end; ++it) { clause * parent = *it; parent->add_child(this); } }
unsigned get_max_len(ptr_buffer<char> & keys) { unsigned max = 0; for (unsigned i = 0; i < static_cast<unsigned>(keys.size()); i++) { char * k = keys.get(i); if (*k == ':') k++; unsigned curr = static_cast<unsigned>(strlen(k)); if (curr > max) max = curr; } return max; }
bool reduce_quantifier( quantifier * q, expr * old_body, expr * const * new_patterns, expr * const * new_no_patterns, expr_ref & result, proof_ref & result_pr) { if (q->get_kind() == lambda_k) return false; m_sorts.reset(); expr_ref_vector bounds(m); bool found = false; for (unsigned i = 0; i < q->get_num_decls(); ++i) { sort* s = q->get_decl_sort(i); if (m_imp.is_fd(s)) { unsigned bv_size = get_bv_size(s); m_sorts.push_back(m_bv.mk_sort(bv_size)); unsigned nc = m_dt.get_datatype_num_constructors(s); if (!is_power_of_two(nc) || nc == 1) { bounds.push_back(m_bv.mk_ule(m.mk_var(q->get_num_decls()-i-1, m_sorts[i]), m_bv.mk_numeral(nc-1, bv_size))); } found = true; } else { m_sorts.push_back(s); } } if (!found) { return false; } expr_ref new_body_ref(old_body, m), tmp(m); if (!bounds.empty()) { switch (q->get_kind()) { case forall_k: new_body_ref = m.mk_implies(mk_and(bounds), new_body_ref); break; case exists_k: bounds.push_back(new_body_ref); new_body_ref = mk_and(bounds); break; case lambda_k: UNREACHABLE(); break; } } result = m.mk_quantifier(q->get_kind(), q->get_num_decls(), m_sorts.c_ptr(), q->get_decl_names(), new_body_ref, q->get_weight(), q->get_qid(), q->get_skid(), q->get_num_patterns(), new_patterns, q->get_num_no_patterns(), new_no_patterns); result_pr = nullptr; return true; }
static void get_keys(M const & m, ptr_buffer<char> & keys) { typename M::iterator it = m.begin(); typename M::iterator end = m.end(); for (; it != end; ++it) { keys.push_back(const_cast<char*>(it->m_key)); } }
/** \brief Traverse args, and copy the non-numeral exprs to result, and accumulate the value of the numerals in k. */ void poly_simplifier_plugin::process_monomial(unsigned num_args, expr * const * args, numeral & k, ptr_buffer<expr> & result) { rational v; for (unsigned i = 0; i < num_args; i++) { expr * arg = args[i]; if (is_numeral(arg, v)) k *= v; else result.push_back(arg); } }
void sort_fun_decls(ast_manager & m, model_core const & md, ptr_buffer<func_decl> & result) { func_decl_set visited; ptr_vector<func_decl> todo; unsigned sz = md.get_num_functions(); for (unsigned i = 0; i < sz; i++) { func_decl * f = md.get_function(i); if (visited.contains(f)) continue; visited.insert(f); todo.push_back(f); while (!todo.empty()) { func_decl * curr = todo.back(); func_interp * curr_i = md.get_func_interp(curr); SASSERT(curr_i != 0); if (!curr_i->is_partial()) { func_decl_set deps; bool all_visited = true; collect_func_decls(m, curr_i->get_else(), deps); func_decl_set::iterator it2 = deps.begin(); func_decl_set::iterator end2 = deps.end(); for (; it2 != end2; ++it2) { func_decl * d = *it2; if (d->get_arity() > 0 && md.has_interpretation(d) && !visited.contains(d)) { todo.push_back(d); visited.insert(d); all_visited = false; } } if (!all_visited) continue; } todo.pop_back(); result.push_back(curr); } } }