mirror of
https://github.com/Z3Prover/z3
synced 2026-02-23 00:37:36 +00:00
enable optional failure in levelwise
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
This commit is contained in:
parent
aff0a82914
commit
1e985ea96e
6 changed files with 29 additions and 2 deletions
|
|
@ -32,6 +32,8 @@ static void vec_setx(std_vector<T>& v, unsigned idx, T val, T def) {
|
|||
|
||||
namespace nlsat {
|
||||
|
||||
struct nullified_poly_exception {};
|
||||
|
||||
// The three projection modes for a level:
|
||||
// 1. section_biggest_cell: Sample is on a root. All disc/lc added.
|
||||
// 2. sector_biggest_cell: Sample between roots. noLdcf optimization only.
|
||||
|
|
@ -55,6 +57,8 @@ namespace nlsat {
|
|||
|
||||
unsigned m_level = 0; // current level being processed
|
||||
unsigned m_spanning_tree_threshold = 3; // minimum both-side count for spanning tree
|
||||
bool m_null_fail = false;
|
||||
bool m_fail = false;
|
||||
unsigned m_l_rf = UINT_MAX; // position of lower bound in m_rel.m_rfunc
|
||||
unsigned m_u_rf = UINT_MAX; // position of upper bound in m_rel.m_rfunc, UINT_MAX in section case
|
||||
|
||||
|
|
@ -260,6 +264,7 @@ namespace nlsat {
|
|||
m_I.emplace_back(m_pm);
|
||||
|
||||
m_spanning_tree_threshold = m_solver.lws_spt_threshold();
|
||||
m_null_fail = m_solver.lws_null_fail();
|
||||
}
|
||||
|
||||
// Handle a polynomial whose every coefficient evaluates to zero at the sample.
|
||||
|
|
@ -267,6 +272,8 @@ namespace nlsat {
|
|||
// request_factorized each of them and continue to the next level.
|
||||
// When a non-vanishing derivative is found, request_factorized it and stop.
|
||||
void handle_nullified_poly(polynomial_ref const& p) {
|
||||
if (m_null_fail)
|
||||
throw nullified_poly_exception();
|
||||
// Add all coefficients of p (w.r.t. m_level) to m_todo.
|
||||
unsigned deg = m_pm.degree(p, m_level);
|
||||
for (unsigned j = 0; j <= deg; ++j) {
|
||||
|
|
@ -1295,7 +1302,7 @@ namespace nlsat {
|
|||
}
|
||||
}
|
||||
|
||||
std_vector<root_function_interval> single_cell() {
|
||||
std_vector<root_function_interval> single_cell_work() {
|
||||
TRACE(lws,
|
||||
tout << "Input polynomials (" << m_P.size() << "):\n";
|
||||
for (unsigned i = 0; i < m_P.size(); ++i)
|
||||
|
|
@ -1342,6 +1349,16 @@ namespace nlsat {
|
|||
|
||||
return m_I;
|
||||
}
|
||||
|
||||
std_vector<root_function_interval> single_cell() {
|
||||
try {
|
||||
return single_cell_work();
|
||||
}
|
||||
catch (nullified_poly_exception&) {
|
||||
m_fail = true;
|
||||
return m_I;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
levelwise::levelwise(
|
||||
|
|
@ -1360,6 +1377,7 @@ namespace nlsat {
|
|||
return m_impl->single_cell();
|
||||
}
|
||||
|
||||
bool levelwise::failed() const { return m_impl->m_fail; }
|
||||
|
||||
} // namespace nlsat
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue