mirror of
https://github.com/Z3Prover/z3
synced 2025-05-05 23:05:46 +00:00
Polysat disjunctive lemmas (WIP) (#5275)
* Extend search state by boolean literals * Only resolve against positive equality * mk_dep_ref * Make clause non-owning * scoped_clause * Use scoped_clause * minor * scoped_ptr move assignment * WIP: internal handling of disjunctive constraints * leaf_value * disjunctive constraints continued * Fix bool_lit * Actually add constraints to storage * Some fixes * more fixes * constraint should have a bool_lit instead of a bool_var * propagate(bool_lit) * updates * interface changes * small fixes * Make sat::dimacs_lit's constructor explicit (otherwise, calling operator<< with sat::literal is ambiguous) * Use sat::literal * Print test name at the beginning * Convention: constraint corresponds to the positive boolean literal * Make constraint ownership more explicit * clause stores literals
This commit is contained in:
parent
49e9782238
commit
28996429df
24 changed files with 1196 additions and 360 deletions
78
src/math/polysat/boolean.cpp
Normal file
78
src/math/polysat/boolean.cpp
Normal file
|
@ -0,0 +1,78 @@
|
|||
/*++
|
||||
Copyright (c) 2021 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
polysat boolean variables
|
||||
|
||||
Author:
|
||||
|
||||
Nikolaj Bjorner (nbjorner) 2021-03-19
|
||||
Jakob Rath 2021-04-6
|
||||
|
||||
--*/
|
||||
#include "math/polysat/boolean.h"
|
||||
#include "math/polysat/log.h"
|
||||
|
||||
namespace polysat {
|
||||
|
||||
sat::bool_var bool_var_manager::new_var() {
|
||||
if (m_unused.empty()) {
|
||||
sat::bool_var var = size();
|
||||
m_value.push_back(l_undef);
|
||||
m_value.push_back(l_undef);
|
||||
m_level.push_back(UINT_MAX);
|
||||
m_reason.push_back(nullptr);
|
||||
m_lemma.push_back(nullptr);
|
||||
return var;
|
||||
} else {
|
||||
sat::bool_var var = m_unused.back();
|
||||
m_unused.pop_back();
|
||||
SASSERT_EQ(m_level[var], UINT_MAX);
|
||||
return var;
|
||||
}
|
||||
}
|
||||
|
||||
void bool_var_manager::del_var(sat::bool_var var) {
|
||||
SASSERT(std::all_of(m_unused.begin(), m_unused.end(), [var](unsigned unused_var) { return var != unused_var; }));
|
||||
auto lit = sat::literal(var);
|
||||
m_value[lit.index()] = l_undef;
|
||||
m_value[(~lit).index()] = l_undef;
|
||||
m_level[var] = UINT_MAX;
|
||||
m_reason[var] = nullptr;
|
||||
m_lemma[var] = nullptr;
|
||||
m_unused.push_back(var);
|
||||
}
|
||||
|
||||
void bool_var_manager::assign(sat::literal lit, unsigned lvl, clause* reason, clause* lemma) {
|
||||
SASSERT(!is_assigned(lit));
|
||||
m_value[lit.index()] = l_true;
|
||||
m_value[(~lit).index()] = l_false;
|
||||
m_level[lit.var()] = lvl;
|
||||
m_reason[lit.var()] = reason;
|
||||
m_lemma[lit.var()] = lemma;
|
||||
}
|
||||
|
||||
void bool_var_manager::unassign(sat::literal lit) {
|
||||
SASSERT(is_assigned(lit));
|
||||
m_value[lit.index()] = l_undef;
|
||||
m_value[(~lit).index()] = l_undef;
|
||||
m_level[lit.var()] = UINT_MAX;
|
||||
m_reason[lit.var()] = nullptr;
|
||||
m_lemma[lit.var()] = nullptr;
|
||||
}
|
||||
|
||||
void bool_var_manager::reset_marks() {
|
||||
m_marks.reserve(size());
|
||||
m_clock++;
|
||||
if (m_clock != 0)
|
||||
return;
|
||||
m_clock++;
|
||||
m_marks.fill(0);
|
||||
}
|
||||
|
||||
void bool_var_manager::set_mark(sat::bool_var var) {
|
||||
SASSERT(var != sat::null_bool_var);
|
||||
m_marks[var] = m_clock;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue