mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 17:15:31 +00:00
allow copy within a user scope #6827
this will allow copying the solver state within a scope. The new solver state has its state at level 0. It is not possible to pop scopes from the new solver (you can still pop scopes from the original solver). The reason for this semantics is the relative difficulty of implementing (getting it right) of a state copy that preserves scopes.
This commit is contained in:
parent
403340498c
commit
adad468cd7
9 changed files with 23 additions and 24 deletions
|
@ -154,9 +154,8 @@ namespace smt {
|
|||
|
||||
src_af.get_macro_manager().copy_to(dst_af.get_macro_manager());
|
||||
|
||||
if (!src_ctx.m_setup.already_configured()) {
|
||||
if (!src_ctx.m_setup.already_configured())
|
||||
return;
|
||||
}
|
||||
|
||||
for (unsigned i = 0; !src_m.proofs_enabled() && i < src_ctx.m_assigned_literals.size(); ++i) {
|
||||
literal lit = src_ctx.m_assigned_literals[i];
|
||||
|
@ -3233,7 +3232,7 @@ namespace smt {
|
|||
}
|
||||
expr * f = m_asserted_formulas.get_formula(qhead);
|
||||
proof * pr = m_asserted_formulas.get_formula_proof(qhead);
|
||||
SASSERT(!pr || f == m.get_fact(pr));
|
||||
SASSERT(!pr || f == m.get_fact(pr));
|
||||
internalize_assertion(f, pr, 0);
|
||||
++qhead;
|
||||
}
|
||||
|
|
|
@ -297,9 +297,10 @@ namespace smt {
|
|||
void context::assert_default(expr * n, proof * pr) {
|
||||
internalize(n, true);
|
||||
literal l = get_literal(n);
|
||||
if (l == false_literal) {
|
||||
if (l == false_literal)
|
||||
set_conflict(mk_justification(justification_proof_wrapper(*this, pr)));
|
||||
}
|
||||
else if (l == true_literal)
|
||||
return;
|
||||
else {
|
||||
justification* j = mk_justification(justification_proof_wrapper(*this, pr));
|
||||
m_clause_proof.add(l, CLS_AUX, j);
|
||||
|
|
|
@ -63,8 +63,8 @@ namespace smt {
|
|||
return m_imp->m_kernel.get_manager();
|
||||
}
|
||||
|
||||
void kernel::copy(kernel& src, kernel& dst) {
|
||||
context::copy(src.m_imp->m_kernel, dst.m_imp->m_kernel);
|
||||
void kernel::copy(kernel& src, kernel& dst, bool override_base) {
|
||||
context::copy(src.m_imp->m_kernel, dst.m_imp->m_kernel, override_base);
|
||||
}
|
||||
|
||||
bool kernel::set_logic(symbol logic) {
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace smt {
|
|||
|
||||
~kernel();
|
||||
|
||||
static void copy(kernel& src, kernel& dst);
|
||||
static void copy(kernel& src, kernel& dst, bool override_base);
|
||||
|
||||
ast_manager & m() const;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ Notes:
|
|||
#include "util/dec_ref_util.h"
|
||||
#include "ast/reg_decl_plugins.h"
|
||||
#include "ast/for_each_expr.h"
|
||||
#include "ast/ast_smt2_pp.h"
|
||||
#include "ast/ast_pp.h"
|
||||
#include "ast/func_decl_dependencies.h"
|
||||
#include "smt/smt_kernel.h"
|
||||
#include "smt/params/smt_params.h"
|
||||
|
@ -88,14 +88,14 @@ namespace {
|
|||
ast_translation translator(get_manager(), m);
|
||||
|
||||
smt_solver * result = alloc(smt_solver, m, p, m_logic);
|
||||
smt::kernel::copy(m_context, result->m_context);
|
||||
smt::kernel::copy(m_context, result->m_context, true);
|
||||
|
||||
if (mc0())
|
||||
result->set_model_converter(mc0()->translate(translator));
|
||||
|
||||
for (auto & kv : m_name2assertion) {
|
||||
expr* val = translator(kv.m_value);
|
||||
expr* key = translator(kv.m_key);
|
||||
for (auto & [k, v] : m_name2assertion) {
|
||||
expr* val = translator(k);
|
||||
expr* key = translator(v);
|
||||
result->assert_expr(val, key);
|
||||
}
|
||||
|
||||
|
@ -104,9 +104,9 @@ namespace {
|
|||
|
||||
~smt_solver() override {
|
||||
dealloc(m_cuber);
|
||||
for (auto& kv : m_name2assertion) {
|
||||
get_manager().dec_ref(kv.m_key);
|
||||
get_manager().dec_ref(kv.m_value);
|
||||
for (auto& [k,v] : m_name2assertion) {
|
||||
get_manager().dec_ref(k);
|
||||
get_manager().dec_ref(v);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue