mirror of
https://github.com/Z3Prover/z3
synced 2025-04-24 01:25:31 +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:
parent
c0f1f33898
commit
f6d411d54b
21 changed files with 145 additions and 12 deletions
|
@ -213,6 +213,20 @@ namespace smt {
|
|||
return out;
|
||||
}
|
||||
|
||||
expr* kernel::congruence_root(expr * e) {
|
||||
smt::enode* n = m_imp->m_kernel.find_enode(e);
|
||||
if (!n)
|
||||
return e;
|
||||
return n->get_root()->get_expr();
|
||||
}
|
||||
|
||||
expr* kernel::congruence_next(expr * e) {
|
||||
smt::enode* n = m_imp->m_kernel.find_enode(e);
|
||||
if (!n)
|
||||
return e;
|
||||
return n->get_next()->get_expr();
|
||||
}
|
||||
|
||||
void kernel::collect_statistics(::statistics & st) const {
|
||||
m_imp->m_kernel.collect_statistics(st);
|
||||
}
|
||||
|
|
|
@ -239,6 +239,13 @@ namespace smt {
|
|||
*/
|
||||
expr_ref_vector cubes(unsigned depth);
|
||||
|
||||
/**
|
||||
\brief access congruence closure
|
||||
*/
|
||||
expr* congruence_next(expr* e);
|
||||
|
||||
expr* congruence_root(expr* e);
|
||||
|
||||
|
||||
/**
|
||||
\brief retrieve depth of variables from decision stack.
|
||||
|
|
|
@ -330,6 +330,10 @@ namespace {
|
|||
m_context.get_units(units);
|
||||
}
|
||||
|
||||
expr* congruence_next(expr* e) override { return m_context.congruence_next(e); }
|
||||
expr* congruence_root(expr* e) override { return m_context.congruence_root(e); }
|
||||
|
||||
|
||||
expr_ref_vector cube(expr_ref_vector& vars, unsigned cutoff) override {
|
||||
ast_manager& m = get_manager();
|
||||
if (!m_cuber) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue