mirror of
https://github.com/Z3Prover/z3
synced 2025-08-24 03:57:51 +00:00
moving out viable functionality
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
19099244c4
commit
6f93ed8dc2
9 changed files with 242 additions and 121 deletions
91
src/math/polysat/viable.h
Normal file
91
src/math/polysat/viable.h
Normal file
|
@ -0,0 +1,91 @@
|
|||
/*++
|
||||
Copyright (c) 2021 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
maintain viable domains
|
||||
|
||||
|
||||
Author:
|
||||
|
||||
Nikolaj Bjorner (nbjorner) 2021-03-19
|
||||
Jakob Rath 2021-04-6
|
||||
|
||||
--*/
|
||||
#pragma once
|
||||
|
||||
#include <limits>
|
||||
#include "math/dd/dd_bdd.h"
|
||||
#include "math/polysat/types.h"
|
||||
|
||||
namespace polysat {
|
||||
|
||||
class solver;
|
||||
|
||||
class viable {
|
||||
typedef dd::bdd bdd;
|
||||
solver& s;
|
||||
dd::bdd_manager m_bdd;
|
||||
scoped_ptr_vector<dd::fdd> m_bits;
|
||||
vector<bdd> m_viable; // set of viable values.
|
||||
vector<std::pair<pvar, bdd>> m_viable_trail;
|
||||
|
||||
public:
|
||||
viable(solver& s);
|
||||
|
||||
void push() { m_viable.push_back(m_bdd.mk_true()); }
|
||||
void pop() { m_viable.pop_back(); }
|
||||
|
||||
void push_viable(pvar v);
|
||||
|
||||
void pop_viable();
|
||||
|
||||
void intersect_eq(rational const& a, pvar v, rational const& b, bool is_positive);
|
||||
|
||||
/**
|
||||
* Check whether variable v has any viable values left according to m_viable.
|
||||
*/
|
||||
bool has_viable(pvar v);
|
||||
|
||||
bool is_false(pvar v) { return m_viable[v].is_false(); }
|
||||
|
||||
/**
|
||||
* check if value is viable according to m_viable.
|
||||
*/
|
||||
bool is_viable(pvar v, rational const& val);
|
||||
|
||||
/**
|
||||
* register that val is non-viable for var.
|
||||
*/
|
||||
void add_non_viable(pvar v, rational const& val);
|
||||
|
||||
/**
|
||||
* Register all values that are not contained in vals as non-viable.
|
||||
*/
|
||||
void intersect_viable(pvar v, bdd vals);
|
||||
|
||||
/**
|
||||
* Add dependency for variable viable range.
|
||||
*/
|
||||
void add_viable_dep(pvar v, p_dependency* dep);
|
||||
|
||||
/**
|
||||
* Find a next viable value for variable.
|
||||
*/
|
||||
dd::find_t find_viable(pvar v, rational & val);
|
||||
|
||||
/** Log all viable values for the given variable.
|
||||
* (Inefficient, but useful for debugging small instances.)
|
||||
*/
|
||||
void log(pvar v);
|
||||
/** Like log_viable but for all variables */
|
||||
void log();
|
||||
|
||||
dd::bdd_manager& get_bdd() { return m_bdd; }
|
||||
dd::fdd const& sz2bits(unsigned sz);
|
||||
dd::fdd const& var2bits(pvar v);
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue