3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-24 01:25:31 +00:00

working on cardinality tactic

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2013-11-06 12:33:09 -08:00
parent e84c5e7e90
commit 2f04918c39
4 changed files with 488 additions and 11 deletions

View file

@ -54,18 +54,16 @@ namespace smt {
TRACE("card", tout << "internalize: " << mk_pp(atom, m) << "\n";);
if (k >= atom->get_num_args()) {
NOT_IMPLEMENTED_YET();
}
if (k == 0) {
NOT_IMPLEMENTED_YET();
}
SASSERT(0 < k && k < atom->get_num_args());
SASSERT(!ctx.b_internalized(atom));
bool_var bv = ctx.mk_bool_var(atom);
if (k >= atom->get_num_args()) {
literal lit(bv);
ctx.mk_th_axiom(get_id(), 1, &lit);
return true;
}
card* c = alloc(card, bv, k);
add_card(c);
for (unsigned i = 0; i < num_args; ++i) {
expr* arg = atom->get_arg(i);
if (!ctx.b_internalized(arg)) {
@ -100,7 +98,22 @@ namespace smt {
ctx.mark_as_relevant(tmp);
}
c->m_args.push_back(bv);
add_watch(bv, c);
if (0 < k) {
add_watch(bv, c);
}
}
if (0 < k) {
add_card(c);
}
else {
// bv <=> (and (not bv1) ... (not bv_n))
literal_vector& lits = get_lits();
lits.push_back(literal(bv));
for (unsigned i = 0; i < c->m_args.size(); ++i) {
ctx.mk_th_axiom(get_id(), ~literal(bv), ~literal(c->m_args[i]));
lits.push_back(literal(c->m_args[i]));
}
ctx.mk_th_axiom(get_id(), lits.size(), lits.c_ptr());
}
return true;
}