mirror of
https://github.com/Z3Prover/z3
synced 2026-06-03 15:47:55 +00:00
fix crashes
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
7d2c84465c
commit
7d5d6a2b38
2 changed files with 10 additions and 29 deletions
|
|
@ -577,6 +577,8 @@ namespace smt {
|
||||||
continue;
|
continue;
|
||||||
auto r = n->get_root();
|
auto r = n->get_root();
|
||||||
// Create a union expression that is canonical (sorted)
|
// Create a union expression that is canonical (sorted)
|
||||||
|
if (!m_set_members.contains(r))
|
||||||
|
continue;
|
||||||
auto& set = *m_set_members[r];
|
auto& set = *m_set_members[r];
|
||||||
ptr_vector<expr> elems;
|
ptr_vector<expr> elems;
|
||||||
for (auto [e,b] : set)
|
for (auto [e,b] : set)
|
||||||
|
|
@ -587,7 +589,7 @@ namespace smt {
|
||||||
trail.push_back(s);
|
trail.push_back(s);
|
||||||
enode *n2 = nullptr;
|
enode *n2 = nullptr;
|
||||||
if (!set_reprs.find(s, n2)) {
|
if (!set_reprs.find(s, n2)) {
|
||||||
set_reprs.insert(s, n2);
|
set_reprs.insert(s, r);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (n2->get_root() == r)
|
if (n2->get_root() == r)
|
||||||
|
|
|
||||||
|
|
@ -294,38 +294,16 @@ namespace smt {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base implementation:
|
* 1. Base implementation:
|
||||||
* Enumerate all satisfying assignments to m_solver for atoms based on |s|
|
* Enumerate all satisfying assignments to m_solver for atoms based on |s|
|
||||||
* Extract Core from enumeration
|
* Extract Core from enumeration
|
||||||
* Assert Core => |s_i| = sum_ij n_ij for each |s_i| cardinality expression
|
* Assert Core => |s_i| = sum_ij n_ij for each |s_i| cardinality expression
|
||||||
* NB. Soundness of using Core has not been rigorously established.
|
* NB. Soundness of using Core has not been rigorously established.
|
||||||
* Incremental algorithm:
|
* 2. We can check with theory_lra if slack_sums constraints are linear
|
||||||
* Enumerate N assignments at a time.
|
* feasible. If they are we can possibly terminate by extracting a model
|
||||||
* Associate tracking literal C_i with current assignment.
|
* If they are infeasible, temporarily strengthen m_solver using the negation of unsat core
|
||||||
* Assume C_i
|
* that comes from infeasible slack propositions. Then the next model releaxes at least one
|
||||||
* Assert !C_0, .. , !C_{i-1}, C_i => /\_i |s_i| = sum_j n_ij and /\ n_j >= 0
|
* slack variable that is part of the infeasible subset.
|
||||||
* Incremental algorithm with blocking clauses
|
|
||||||
* Enumerate N assignments at a time.
|
|
||||||
* use smt_arith_value::check_lp_feasiable to check if current assignment is feasible.
|
|
||||||
* if it is, then yield the current assignment. Assume there is a filter that avoids future
|
|
||||||
* calls to find more models if the current model satisfies all cardinality terms.
|
|
||||||
* In other words, for every |s| the model produces a set with |s| elements,
|
|
||||||
* where |s| is the value assigned by the arithmetic solver.
|
|
||||||
* if it is not feasible, extract the infeasible core from call:
|
|
||||||
* - card_core: a set of cardinality atoms
|
|
||||||
* - lit_core: a set of literals asserted into the arithmetic solver
|
|
||||||
* - eq_core: a set of equations asserte into the arithmetic solver
|
|
||||||
* First take the card_core atoms and enumerate Boolean models for m_solver that
|
|
||||||
* satisfy the disjunction of those atoms.
|
|
||||||
* - Infeasibility of the current model meant that there was no linear assignment to
|
|
||||||
* the subset in card_core that satisfied lit_core & eq_core. So the query to extend the
|
|
||||||
* set of assignments is to fix this.
|
|
||||||
* If there is some model for the disjunction of card_core atoms, then
|
|
||||||
* add new slacks for the models an continue, possibly querying the arithmetic solver if the new set of
|
|
||||||
* linear relaxation to the subset is feasible.
|
|
||||||
* If there is no model to the disjunction of card_core atoms, then
|
|
||||||
* it means that size_core & lit_core & eq_core is unsat.
|
|
||||||
* where size_core is the unsat core for m_solver.
|
|
||||||
*/
|
*/
|
||||||
lbool theory_finite_set_size::run_solver() {
|
lbool theory_finite_set_size::run_solver() {
|
||||||
expr_ref_vector asms(m);
|
expr_ref_vector asms(m);
|
||||||
|
|
@ -418,6 +396,7 @@ namespace smt {
|
||||||
if (!m_solver_ran)
|
if (!m_solver_ran)
|
||||||
return run_solver();
|
return run_solver();
|
||||||
|
|
||||||
|
//
|
||||||
// at this point we assume that
|
// at this point we assume that
|
||||||
// cardinality constraints are satisfied
|
// cardinality constraints are satisfied
|
||||||
// by arithmetic solver.
|
// by arithmetic solver.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue