3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-02-15 05:11:49 +00:00

update wcnf front-end and add new wcnf strategy

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2026-01-01 17:50:17 -08:00
parent 17dffc67c9
commit 5c4a3128c4
6 changed files with 168 additions and 5 deletions

View file

@ -137,6 +137,25 @@ class wcnf {
result = to_app(mk_or(m, ors.size(), ors.data()));
return result;
}
app_ref read_hard_clause() {
int parsed_lit;
int var;
app_ref result(m), p(m);
expr_ref_vector ors(m);
while (true) {
parsed_lit = in.parse_int();
if (parsed_lit == 0)
break;
var = abs(parsed_lit);
p = m.mk_const(symbol((unsigned)var), m.mk_bool_sort());
if (parsed_lit < 0)
p = m.mk_not(p);
ors.push_back(p);
}
result = to_app(mk_or(m, ors.size(), ors.data()));
return result;
}
void parse_spec(unsigned& num_vars, unsigned& num_clauses, unsigned& max_weight) {
in.parse_token("wcnf");
@ -152,7 +171,7 @@ public:
}
void parse() {
unsigned num_vars = 0, num_clauses = 0, max_weight = 0;
unsigned num_vars = 0, num_clauses = 0, max_weight = UINT_MAX;
while (true) {
in.skip_whitespace();
if (in.eof()) {
@ -165,6 +184,11 @@ public:
++in;
parse_spec(num_vars, num_clauses, max_weight);
}
else if (*in == 'h') {
in.next();
app_ref cls = read_hard_clause();
opt.add_hard_constraint(cls);
}
else {
unsigned weight = 0;
app_ref cls = read_clause(weight);