void expr_context_simplifier::reduce_fix(expr * m, expr_ref & result) { expr_ref tmp(m_manager); result = m; do { tmp = result.get(); reduce(tmp.get(), result); } while (tmp.get() != result.get()); }
bool expr_delta::delta_dfs(unsigned& n, expr* e, expr_ref& result) { ast_manager& m = m_manager; if (m.is_true(e) || m.is_false(e)) { return false; } if (n == 0 && m.is_bool(e)) { result = m.mk_true(); return true; } else if (n == 1 && m.is_bool(e)) { result = m.mk_false(); return true; } else if (is_app(e)) { if (m.is_bool(e)) { SASSERT(n >= 2); n -= 2; } return delta_dfs(n, to_app(e), result); } else if (is_quantifier(e)) { SASSERT(n >= 2); n -= 2; quantifier* q = to_quantifier(e); if (delta_dfs(n, q->get_expr(), result)) { result = m.update_quantifier(q, result.get()); return true; } else { return false; } } return false; }
void mk_interp_tail_simplifier::simplify_expr(app * a, expr_ref& res) { expr_ref simp1_res(m); m_simp(a, simp1_res); (*m_rw)(simp1_res.get(), res); m_simp(res.get(), res); }
br_status pull_ite(expr_ref & result) { expr * t = result.get(); if (is_app(t)) { br_status st = pull_ite(to_app(t)->get_decl(), to_app(t)->get_num_args(), to_app(t)->get_args(), result); if (st != BR_FAILED) return st; } return BR_DONE; }
void mk_interp_tail_simplifier::simplify_expr(app * a, expr_ref& res) { expr_ref simp1_res(m); m_simp(a, simp1_res); (*m_rw)(simp1_res.get(), res); /*if (simp1_res.get()!=res.get()) { std::cout<<"pre norm:\n"<<mk_pp(simp1_res.get(),m)<<"post norm:\n"<<mk_pp(res.get(),m)<<"\n"; }*/ m_simp(res.get(), res); }
void bit2int::operator()(expr * m, expr_ref & result, proof_ref& p) { flush_cache(); expr_reduce emap(*this); for_each_ast(emap, m); result = get_cached(m); if (m_manager.proofs_enabled() && m != result.get()) { // TBD: rough p = m_manager.mk_rewrite(m, result); } TRACE("bit2int", tout << mk_pp(m, m_manager) << "======>\n" << mk_pp(result, m_manager) << "\n";);
bool simple_parser::parse(std::istream & in, expr_ref & result) { scanner s(in, std::cerr, false); try { result = parse_expr(s); if (!result) throw parser_error(); } catch (parser_error) { warning_msg("parser error"); return false; } m_exprs.reset(); return result.get() != 0; }
expr* get_literal() { return m_literal.get(); }
// Return true if t1 and t2 are of the form: // t + a1*x1 + ... + an*xn // t' + a1*x1 + ... + an*xn // Store t in new_t1, t' in new_t2 and (a1*x1 + ... + an*xn) in c. bool unify_add(app * t1, expr * t2, expr_ref & new_t1, expr_ref & new_t2, expr_ref & c) { unsigned num1 = t1->get_num_args(); expr * const * ms1 = t1->get_args(); if (num1 < 2) return false; unsigned num2; expr * const * ms2; if (m_a_util.is_add(t2)) { num2 = to_app(t2)->get_num_args(); ms2 = to_app(t2)->get_args(); } else { num2 = 1; ms2 = &t2; } if (num1 != num2 && num1 != num2 + 1 && num1 != num2 - 1) return false; new_t1 = 0; new_t2 = 0; expr_fast_mark1 visited1; expr_fast_mark2 visited2; for (unsigned i = 0; i < num1; i++) { expr * arg = ms1[i]; visited1.mark(arg); } for (unsigned i = 0; i < num2; i++) { expr * arg = ms2[i]; visited2.mark(arg); if (visited1.is_marked(arg)) continue; if (new_t2) return false; // more than one missing term new_t2 = arg; } for (unsigned i = 0; i < num1; i++) { expr * arg = ms1[i]; if (visited2.is_marked(arg)) continue; if (new_t1) return false; // more than one missing term new_t1 = arg; } // terms matched... bool is_int = m_a_util.is_int(t1); if (!new_t1) new_t1 = m_a_util.mk_numeral(rational(0), is_int); if (!new_t2) new_t2 = m_a_util.mk_numeral(rational(0), is_int); // mk common part ptr_buffer<expr> args; for (unsigned i = 0; i < num1; i++) { expr * arg = ms1[i]; if (arg == new_t1.get()) continue; args.push_back(arg); } SASSERT(!args.empty()); if (args.size() == 1) c = args[0]; else c = m_a_util.mk_add(args.size(), args.c_ptr()); return true; }