3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-25 01:55:32 +00:00

experimental feature to access congruence closure of SimpleSolver

This update includes an experimental feature to access a congruence closure data-structure after search.
It comes with several caveats as pre-processing is free to eliminate terms. It is therefore necessary to use a solver that does not eliminate the terms you want to track for congruence of. This is partially addressed by using SimpleSolver or incremental mode solving.

```python
from z3 import *
s = SimpleSolver()
x, y, z = Ints('x y z')
s.add(x == y)
s.add(y == z)
s.check()
print(s.root(x), s.root(y), s.root(z))
print(s.next(x), s.next(y), s.next(z))
```
This commit is contained in:
Nikolaj Bjorner 2022-12-30 21:41:27 -08:00
parent c0f1f33898
commit f6d411d54b
21 changed files with 145 additions and 12 deletions

View file

@ -275,6 +275,10 @@ public:
return m_solver2->cube(vars, backtrack_level);
}
expr* congruence_next(expr* e) override { switch_inc_mode(); return m_solver2->congruence_next(e); }
expr* congruence_root(expr* e) override { switch_inc_mode(); return m_solver2->congruence_root(e); }
expr * get_assumption(unsigned idx) const override {
unsigned c1 = m_solver1->get_num_assumptions();
if (idx < c1) return m_solver1->get_assumption(idx);

View file

@ -238,6 +238,15 @@ public:
virtual expr_ref_vector cube(expr_ref_vector& vars, unsigned backtrack_level) = 0;
/**
\brief retrieve congruence closure root.
*/
virtual expr* congruence_root(expr* e) = 0;
/**
\brief retrieve congruence closure sibling
*/
virtual expr* congruence_next(expr* e) = 0;
/**
\brief Display the content of this solver.

View file

@ -262,6 +262,9 @@ public:
expr_ref_vector cube(expr_ref_vector& vars, unsigned ) override { return expr_ref_vector(m); }
expr* congruence_next(expr* e) override { return e; }
expr* congruence_root(expr* e) override { return e; }
ast_manager& get_manager() const override { return m_base->get_manager(); }
void refresh(solver* new_base) {

View file

@ -136,6 +136,9 @@ public:
return expr_ref_vector(get_manager());
}
expr* congruence_next(expr* e) override { return e; }
expr* congruence_root(expr* e) override { return e; }
model_converter_ref get_model_converter() const override { return m_mc; }
void get_levels(ptr_vector<expr> const& vars, unsigned_vector& depth) override {