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

seq_monadic: replace model out-param with gen-model toggle + get_model()

Remove the obj_map<expr,expr*>* model out-parameter from solve/solve_and/
decide_dnf. Add an m_gen_model flag (default true) with set_gen_model(bool),
store the extracted model in m_model (reset at the top of decide_dnf), and
expose get_model(). Switch live_states out to expr_ref_vector and the
product_nonempty state vectors to ptr_vector<expr>. Simplify the concat case
of parse_term with all_of. Disable model generation in the sat-only unit
tests and the benchmark.

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 20:14:59 -07:00
parent 5650fb2460
commit 773c5496b9
4 changed files with 54 additions and 52 deletions

View file

@ -121,6 +121,7 @@ class seq_monadic_test {
}
void check(char const* name, expr* term, expr* R, lbool expected) {
m_mon.set_gen_model(false); // this check does not use the model
lbool got = m_mon.solve(term, R);
bool ok = (got == expected);
if (!ok) ++m_fail;
@ -141,7 +142,8 @@ class seq_monadic_test {
obj_map<expr, expr*> const& ve, lbool expected) {
vector<std::pair<expr*, expr*>> mems;
add_extra(mems, term, R, ve);
lbool got = m_mon.solve_and(mems, nullptr);
m_mon.set_gen_model(false); // this check does not use the model
lbool got = m_mon.solve_and(mems);
bool ok = (got == expected);
if (!ok) ++m_fail;
std::cout << (ok ? " OK " : " FAIL ") << name
@ -177,10 +179,11 @@ class seq_monadic_test {
// term a member of R (substitute var -> witness and re-decide by derivatives).
void check_witness(char const* name, expr* term, expr* R,
obj_map<expr, expr*> const& ve) {
obj_map<expr, expr*> model;
vector<std::pair<expr*, expr*>> mems;
add_extra(mems, term, R, ve);
lbool got = m_mon.solve_and(mems, &model);
m_mon.set_gen_model(true); // this check verifies the extracted model
lbool got = m_mon.solve_and(mems);
obj_map<expr, expr*> const& model = m_mon.get_model();
bool ok = (got == l_true) && !model.empty();
if (ok) {
expr_safe_replace rep(m);
@ -198,7 +201,8 @@ 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) {
lbool got = m_mon.solve_and(mems, nullptr);
m_mon.set_gen_model(false); // this check does not use the model
lbool got = m_mon.solve_and(mems);
bool ok = (got == expected);
if (!ok) ++m_fail;
std::cout << (ok ? " OK " : " FAIL ") << name

View file

@ -138,9 +138,10 @@ lbool run_file(
memberships.push_back(std::make_pair(entry.m_key, entry.m_value));
auto start = std::chrono::high_resolution_clock::now();
mon.set_gen_model(false); // benchmark only needs the verdict
lbool verdict = memberships.empty()
? l_undef
: mon.solve_and(memberships, nullptr);
: mon.solve_and(memberships);
solve_ms = std::chrono::duration<double, std::milli>(
std::chrono::high_resolution_clock::now() - start).count();
return verdict;