3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-05-08 00:05:46 +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

@ -62,7 +62,8 @@ bool elim_unconstrained::is_var_lt(int v1, int v2) const {
void elim_unconstrained::eliminate() {
while (!m_heap.empty()) {
expr_ref r(m), side_cond(m);
expr_ref r(m);
proof_ref pr(m);
int v = m_heap.erase_min();
node& n = get_node(v);
if (n.m_refcount == 0)
@ -84,7 +85,7 @@ void elim_unconstrained::eliminate() {
unsigned sz = m_args.size();
for (expr* arg : *to_app(t))
m_args.push_back(reconstruct_term(get_node(arg)));
bool inverted = m_inverter(t->get_decl(), to_app(t)->get_num_args(), m_args.data() + sz, r, side_cond);
bool inverted = m_inverter(t->get_decl(), to_app(t)->get_num_args(), m_args.data() + sz, r, pr);
n.m_refcount = 0;
m_args.shrink(sz);
if (!inverted) {
@ -113,7 +114,7 @@ void elim_unconstrained::eliminate() {
IF_VERBOSE(11, verbose_stream() << mk_bounded_pp(get_node(v).m_orig, m) << " " << mk_bounded_pp(t, m) << " -> " << r << " " << get_node(e).m_refcount << "\n";);
SASSERT(!side_cond && "not implemented to add side conditions\n");
SASSERT(!pr && "not implemented to add proofs\n");
}
}