void process(expr * f) { if (fvisited.is_marked(f)) return; fvisited.mark(f); todo.push_back(f); while (!todo.empty()) { expr * t = todo.back(); todo.pop_back(); if (is_uninterp_const(t)) continue; if (is_app(t) && to_app(t)->get_family_id() == m.get_basic_family_id() && to_app(t)->get_num_args() > 0) { decl_kind k = to_app(t)->get_decl_kind(); if (k == OP_OR || k == OP_NOT || k == OP_IFF || ((k == OP_EQ || k == OP_ITE) && m.is_bool(to_app(t)->get_arg(1)))) { unsigned num = to_app(t)->get_num_args(); for (unsigned i = 0; i < num; i++) { expr * arg = to_app(t)->get_arg(i); if (fvisited.is_marked(arg)) continue; fvisited.mark(arg); todo.push_back(arg); } } } else { quick_for_each_expr(proc, tvisited, t); } } }
/** \brief Auxiliary method for local_ctx_simp. Replace args[i] by true if marked in neg_lits. Replace args[i] by false if marked in pos_lits. */ bool bool_rewriter::simp_nested_not_or(unsigned num_args, expr * const * args, expr_fast_mark1 & neg_lits, expr_fast_mark2 & pos_lits, expr_ref & result) { ptr_buffer<expr> new_args; bool simp = false; m_local_ctx_cost += num_args; for (unsigned i = 0; i < num_args; i++) { expr * arg = args[i]; if (neg_lits.is_marked(arg)) { result = m().mk_false(); return true; } if (pos_lits.is_marked(arg)) { simp = true; continue; } if (m().is_not(arg)) { expr * atom = to_app(arg)->get_arg(0); if (neg_lits.is_marked(atom)) { simp = true; continue; } if (pos_lits.is_marked(atom)) { result = m().mk_false(); return true; } } new_args.push_back(arg); } if (simp) { switch(new_args.size()) { case 0: result = m().mk_true(); return true; case 1: mk_not(new_args[0], result); return true; default: result = m().mk_not(m().mk_or(new_args.size(), new_args.c_ptr())); return true; } } return false; }
/** \brief Unmark atoms that occur in the boolean structure. */ void formula_compiler::unmark_nested_atoms(assertion_set const & s, expr_fast_mark2 & axioms) { ast_manager & m = s.m(); expr_fast_mark1 visited; unmark_axioms_proc proc(axioms); unsigned sz = s.size(); for (unsigned i = 0; i < sz; i++) { expr * f = s.form(i); while (m.is_not(f, f)); if (axioms.is_marked(f)) continue; quick_for_each_expr(proc, visited, f); } }