3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-08-02 20:23:27 +00:00

Remove var_extra from seq_monadic API

Per-variable extra constraints are now expressed as additional (var in R')
memberships passed to solve_and, so the var_extra parameter is dropped from
solve/solve_and and the internal decide_dnf. Tests updated to route extra
constraints through solve_and.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 57b9b87e-950a-49ea-bbb3-ed585646a5a9
This commit is contained in:
Nikolaj Bjorner 2026-07-31 14:31:35 -07:00
parent 656d1e6bcb
commit 168b51d332
4 changed files with 32 additions and 34 deletions

View file

@ -128,9 +128,20 @@ class seq_monadic_test {
<< " got=" << s(got) << " expected=" << s(expected) << "\n";
}
// build the membership list: the primary (term in R) plus one (var in R') per extra
// constraint, decided jointly by solve_and.
void add_extra(vector<std::pair<expr*, expr*>>& mems, expr* term, expr* R,
obj_map<expr, expr*> const& ve) {
mems.push_back(std::make_pair(term, R));
for (auto const& kv : ve)
mems.push_back(std::make_pair(kv.m_key, kv.m_value));
}
void check_extra(char const* name, expr* term, expr* R,
obj_map<expr, expr*> const& ve, lbool expected) {
lbool got = m_mon.solve(term, R, ve);
vector<std::pair<expr*, expr*>> mems;
add_extra(mems, term, R, ve);
lbool got = m_mon.solve_and(mems, nullptr);
bool ok = (got == expected);
if (!ok) ++m_fail;
std::cout << (ok ? " OK " : " FAIL ") << name
@ -167,7 +178,9 @@ class seq_monadic_test {
void check_witness(char const* name, expr* term, expr* R,
obj_map<expr, expr*> const& ve) {
obj_map<expr, expr*> model;
lbool got = m_mon.solve(term, R, ve, &model);
vector<std::pair<expr*, expr*>> mems;
add_extra(mems, term, R, ve);
lbool got = m_mon.solve_and(mems, &model);
bool ok = (got == l_true) && !model.empty();
if (ok) {
expr_safe_replace rep(m);
@ -185,8 +198,7 @@ class seq_monadic_test {
// decide a conjunction of memberships jointly (shared variables constrained together).
void check_and(char const* name, vector<std::pair<expr*, expr*>> const& mems, lbool expected) {
obj_map<expr, expr*> nove;
lbool got = m_mon.solve_and(mems, nove, nullptr);
lbool got = m_mon.solve_and(mems, nullptr);
bool ok = (got == expected);
if (!ok) ++m_fail;
std::cout << (ok ? " OK " : " FAIL ") << name

View file

@ -137,11 +137,10 @@ lbool run_file(
for (auto const& entry : var_re)
memberships.push_back(std::make_pair(entry.m_key, entry.m_value));
obj_map<expr, expr*> no_extra;
auto start = std::chrono::high_resolution_clock::now();
lbool verdict = memberships.empty()
? l_undef
: mon.solve_and(memberships, no_extra, nullptr);
: mon.solve_and(memberships, nullptr);
solve_ms = std::chrono::duration<double, std::milli>(
std::chrono::high_resolution_clock::now() - start).count();
return verdict;