3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-13 01:16:15 +00:00

start porting grobner basis functionality

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
This commit is contained in:
Lev Nachmanson 2019-09-05 17:12:44 -07:00
parent 7386b7d68d
commit 35efdc9852
2 changed files with 13 additions and 19 deletions

View file

@ -1039,10 +1039,11 @@ namespace smt {
bool internalize_gb_eq(grobner::equation const * eq); bool internalize_gb_eq(grobner::equation const * eq);
enum gb_result { GB_PROGRESS, GB_NEW_EQ, GB_FAIL }; enum gb_result { GB_PROGRESS, GB_NEW_EQ, GB_FAIL };
gb_result compute_grobner(svector<theory_var> const & nl_cluster); gb_result compute_grobner(svector<theory_var> const & nl_cluster);
bool compute_basis_loop(grobner & gb);
void update_statistics(grobner&); void update_statistics(grobner&);
void set_gb_exhausted(bool r); void set_gb_exhausted();
bool pass_over_gb_eqs_for_conflict(ptr_vector<grobner::equation>& eqs, grobner&); bool pass_over_gb_eqs_for_conflict(ptr_vector<grobner::equation>& eqs, grobner&);
gb_result scan_for_linear(ptr_vector<grobner::equation>& eqs, grobner&); bool scan_for_linear(ptr_vector<grobner::equation>& eqs, grobner&);
bool try_to_modify_eqs(ptr_vector<grobner::equation>& eqs, grobner&, unsigned &); bool try_to_modify_eqs(ptr_vector<grobner::equation>& eqs, grobner&, unsigned &);
bool max_min_nl_vars(); bool max_min_nl_vars();
final_check_status process_non_linear(); final_check_status process_non_linear();

View file

@ -2290,15 +2290,15 @@ bool theory_arith<Ext>::try_to_modify_eqs(ptr_vector<grobner::equation>& eqs, gr
// Scan the grobner basis eqs for equations of the form x - k = 0 or x = 0 is found, and x is not fixed, // Scan the grobner basis eqs for equations of the form x - k = 0 or x = 0 is found, and x is not fixed,
// then assert bounds for x, and continue // then assert bounds for x, and continue
template<typename Ext> template<typename Ext>
typename theory_arith<Ext>::gb_result theory_arith<Ext>::scan_for_linear(ptr_vector<grobner::equation>& eqs, grobner& gb) { bool theory_arith<Ext>::scan_for_linear(ptr_vector<grobner::equation>& eqs, grobner& gb) {
gb_result result = GB_FAIL; bool result = false;
if (m_params.m_nl_arith_gb_eqs) { if (m_params.m_nl_arith_gb_eqs) {
for (grobner::equation* eq : eqs) { for (grobner::equation* eq : eqs) {
if (!eq->is_linear_combination()) { if (!eq->is_linear_combination()) {
TRACE("non_linear", tout << "processing new equality:\n"; gb.display_equation(tout, *eq);); TRACE("non_linear", tout << "processing new equality:\n"; gb.display_equation(tout, *eq););
TRACE("non_linear_bug", tout << "processing new equality:\n"; gb.display_equation(tout, *eq);); TRACE("non_linear_bug", tout << "processing new equality:\n"; gb.display_equation(tout, *eq););
if (internalize_gb_eq(eq)) if (internalize_gb_eq(eq))
result = GB_NEW_EQ; result = true;
} }
} }
} }
@ -2332,31 +2332,24 @@ typename theory_arith<Ext>::gb_result theory_arith<Ext>::compute_grobner(svector
unsigned next_weight = MAX_DEFAULT_WEIGHT + 1; // next weight using during perturbation phase. unsigned next_weight = MAX_DEFAULT_WEIGHT + 1; // next weight using during perturbation phase.
ptr_vector<grobner::equation> eqs; ptr_vector<grobner::equation> eqs;
while (true) { do {
TRACE("non_linear_gb", tout << "before:\n"; gb.display(tout);); TRACE("non_linear_gb", tout << "before:\n"; gb.display(tout););
gb.compute_basis_init(); gb.compute_basis_init();
bool r = compute_basis_loop(gb); if (!compute_basis_loop(gb) && !warn) {
update_statistics(gb);
if (!r && !warn) {
set_gb_exhausted(); set_gb_exhausted();
warn = true; warn = true;
} }
update_statistics(gb);
if (get_context().get_cancel_flag()) { if (get_context().get_cancel_flag()) {
return GB_FAIL; return GB_FAIL;
} }
TRACE("non_linear_gb", tout << "after:\n"; gb.display(tout);); TRACE("non_linear_gb", tout << "after:\n"; gb.display(tout););
if (pass_over_gb_eqs_for_conflict(eqs, gb)) if (pass_over_gb_eqs_for_conflict(eqs, gb))
return GB_PROGRESS; return GB_PROGRESS;
gb_result result = scan_for_linear(eqs, gb);
if ( result != GB_FAIL ||
(!m_params.m_nl_arith_gb_perturbate) ||
m_nl_gb_exhausted ||
(!try_to_modify_eqs(eqs, gb, next_weight))
) {
return result;
}
} }
while(scan_for_linear(eqs, gb) && m_params.m_nl_arith_gb_perturbate &&
(!m_nl_gb_exhausted) && try_to_modify_eqs(eqs, gb, next_weight));
return GB_FAIL;
} }
/** /**