diff --git a/src/math/polysat/slicing.cpp b/src/math/polysat/slicing.cpp index 2b10408d0..b7aa6aee1 100644 --- a/src/math/polysat/slicing.cpp +++ b/src/math/polysat/slicing.cpp @@ -16,54 +16,21 @@ Author: /* - (x=y) - x <=========== y - / \ / \ - x[7:4] x[3:0] y[3:0] - <========== - (by x=y) - -Try later: - Congruence closure with "virtual concat" terms - x = x[7:4] ++ x[3:0] - y = y[7:4] ++ y[3:0] - x[7:4] = y[7:4] - x[3:0] = y[3:0] - => x = y - -Recycle the z3 egraph? - - x = x[7:4] ++ x[3:0] - - Add instance euf_egraph.h - - What do we need from the egraph? - - backtracking trail to check for new equalities - - - - - - - - - +Example: (1) x = y (2) z = y[3:0] (3) explain(x[3:0] == z)? should be { (1), (2) } - (1) x ========================> y / \ / \ (2) x[7:4] x[3:0] y[7:4] y[3:0] ===========> z - - - - - - - - +TODO: +- track fixed bits along with enodes +- notify solver about equalities discovered by congruence +- implement query functions */ diff --git a/src/math/polysat/slicing.h b/src/math/polysat/slicing.h index 61f7f438c..c44725b85 100644 --- a/src/math/polysat/slicing.h +++ b/src/math/polysat/slicing.h @@ -253,9 +253,26 @@ namespace polysat { /** Extract reason for x == y */ void explain_equal(pvar x, pvar y, sat::literal_vector& out_lits, unsigned_vector& out_vars); - // TODO: - // Query for a given variable v: - // - set of variables that share at least one slice with v (need variable, offset/width relative to v) + /// Example: + /// - assume query_var has segments 11122233 and var has segments 2224 + /// - then the overlapping region "222" is given by width = 3, offset_var = 1, offset_query = 2. + /// (First version will probably only support offset 0.) + struct var_overlap { + pvar var; + /// number of overlapping bits + unsigned width; + /// offset of overlapping region in var + unsigned offset_var; + /// offset of overlapping region in query variable + unsigned offset_query; + }; + using var_overlap_vector = svector; + + /** For a given variable v, find the set of variables that share at least one slice with v. */ + void query_overlaps(pvar v, var_overlap_vector& out); + + /** Query fixed portions of the variable v */ + void query_fixed(pvar v, rational& mask, rational& value); std::ostream& display(std::ostream& out) const; std::ostream& display_tree(std::ostream& out) const;