mirror of
https://github.com/Z3Prover/z3
synced 2025-04-24 01:25:31 +00:00
updated notes, fixes to dual solver
This commit is contained in:
parent
ef6542823b
commit
a216bee647
5 changed files with 142 additions and 54 deletions
|
@ -24,22 +24,19 @@ namespace sat {
|
|||
|
||||
void dual_solver::push() {
|
||||
m_solver.user_push();
|
||||
m_roots_lim.push_back(m_roots.size());
|
||||
m_tracked_lim.push_back(m_tracked_stack.size());
|
||||
m_units_lim.push_back(m_units.size());
|
||||
m_roots.push_scope();
|
||||
m_tracked_vars.push_scope();
|
||||
m_units.push_scope();
|
||||
}
|
||||
|
||||
void dual_solver::pop(unsigned num_scopes) {
|
||||
m_solver.user_pop(num_scopes);
|
||||
unsigned old_sz = m_roots_lim.size() - num_scopes;
|
||||
for (unsigned v = m_tracked_stack.size(); v-- > m_tracked_lim[old_sz]; )
|
||||
m_is_tracked[v] = false;
|
||||
m_roots.shrink(m_roots_lim[old_sz]);
|
||||
m_tracked_stack.shrink(m_tracked_lim[old_sz]);
|
||||
m_units.shrink(m_units_lim[old_sz]);
|
||||
m_roots_lim.shrink(old_sz);
|
||||
m_tracked_lim.shrink(old_sz);
|
||||
m_units_lim.shrink(old_sz);
|
||||
unsigned old_sz = m_tracked_vars.old_size(num_scopes);
|
||||
for (unsigned i = m_tracked_vars.size(); i-- > old_sz; )
|
||||
m_is_tracked[m_tracked_vars[i]] = false;
|
||||
m_units.pop_scope(num_scopes);
|
||||
m_roots.pop_scope(num_scopes);
|
||||
m_tracked_vars.pop_scope(num_scopes);
|
||||
}
|
||||
|
||||
bool_var dual_solver::ext2var(bool_var v) {
|
||||
|
@ -56,7 +53,7 @@ namespace sat {
|
|||
v = ext2var(v);
|
||||
if (!m_is_tracked.get(v, false)) {
|
||||
m_is_tracked.setx(v, true, false);
|
||||
m_tracked_stack.push_back(v);
|
||||
m_tracked_vars.push_back(v);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,6 +66,10 @@ namespace sat {
|
|||
}
|
||||
|
||||
void dual_solver::add_root(unsigned sz, literal const* clause) {
|
||||
if (sz == 1) {
|
||||
m_units.push_back(clause[0]);
|
||||
return;
|
||||
}
|
||||
literal root(m_solver.mk_var(), false);
|
||||
for (unsigned i = 0; i < sz; ++i)
|
||||
m_solver.mk_clause(root, ~ext2lit(clause[i]), status::input());
|
||||
|
@ -86,7 +87,7 @@ namespace sat {
|
|||
m_solver.user_push();
|
||||
m_solver.add_clause(m_roots.size(), m_roots.c_ptr(), status::input());
|
||||
m_lits.reset();
|
||||
for (bool_var v : m_tracked_stack)
|
||||
for (bool_var v : m_tracked_vars)
|
||||
m_lits.push_back(literal(v, l_false == s.value(m_var2ext[v])));
|
||||
lbool is_sat = m_solver.check(m_lits.size(), m_lits.c_ptr());
|
||||
m_core.reset();
|
||||
|
|
|
@ -8,6 +8,8 @@ Module Name:
|
|||
Abstract:
|
||||
|
||||
Solver for obtaining implicant.
|
||||
Based on an idea by Armin Biere to use dual propagation
|
||||
for representation of negated goal.
|
||||
|
||||
Author:
|
||||
|
||||
|
@ -15,18 +17,19 @@ Author:
|
|||
|
||||
--*/
|
||||
#pragma once
|
||||
#include "util/lim_vector.h"
|
||||
#include "sat/sat_solver.h"
|
||||
|
||||
namespace sat {
|
||||
|
||||
class dual_solver {
|
||||
solver m_solver;
|
||||
literal_vector m_roots, m_lits, m_core, m_units;
|
||||
lim_svector<literal> m_units, m_roots;
|
||||
lim_svector<bool_var> m_tracked_vars;
|
||||
literal_vector m_lits, m_core;
|
||||
bool_var_vector m_is_tracked;
|
||||
unsigned_vector m_tracked_stack;
|
||||
unsigned_vector m_ext2var;
|
||||
unsigned_vector m_var2ext;
|
||||
unsigned_vector m_roots_lim, m_tracked_lim, m_units_lim;
|
||||
void add_literal(literal lit);
|
||||
|
||||
bool_var ext2var(bool_var v);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue