Skip to content

Commit 13c098f

Browse files
better equality solving pre-processing with bv
1 parent d980ac9 commit 13c098f

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

src/ast/simplifiers/extract_eqs.cpp

+23-4
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ namespace euf {
9292
if (!bv.is_bv_add(x))
9393
return;
9494
expr_ref term(m);
95-
unsigned i = 0;
9695
auto mk_term = [&](unsigned i) {
9796
term = y;
9897
unsigned j = 0;
@@ -102,17 +101,40 @@ namespace euf {
102101
++j;
103102
}
104103
};
104+
expr* u = nullptr, *z = nullptr;
105+
rational r;
106+
unsigned i = 0;
105107
for (expr* arg : *to_app(x)) {
106108
if (is_uninterp_const(arg)) {
107109
mk_term(i);
108110
eqs.push_back(dependent_eq(orig, to_app(arg), term, d));
109111
}
112+
else if (bv.is_bv_mul(arg, u, z) && bv.is_numeral(u, r) && is_uninterp_const(z) && r.is_odd()) {
113+
mk_term(i);
114+
unsigned sz = bv.get_bv_size(z);
115+
rational inv_r;
116+
VERIFY(r.mult_inverse(sz, inv_r));
117+
term = bv.mk_bv_mul(bv.mk_numeral(inv_r, sz), term);
118+
eqs.push_back(dependent_eq(orig, to_app(z), term, d));
119+
}
110120
++i;
111121
}
112122
}
113123

124+
void solve_mul(expr* orig, expr* x, expr* y, expr_dependency* d, dep_eq_vector& eqs) {
125+
expr* u = nullptr, *z = nullptr;
126+
rational r, inv_r;
127+
if (bv.is_bv_mul(x, u, z) && bv.is_numeral(u, r) && is_uninterp_const(z) && r.is_odd()) {
128+
unsigned sz = bv.get_bv_size(z);
129+
VERIFY(r.mult_inverse(sz, inv_r));
130+
auto term = expr_ref(bv.mk_bv_mul(bv.mk_numeral(inv_r, sz), y), m);
131+
eqs.push_back(dependent_eq(orig, to_app(z), term, d));
132+
}
133+
}
134+
114135
void solve_eq(expr* orig, expr* x, expr* y, expr_dependency* d, dep_eq_vector& eqs) {
115136
solve_add(orig, x, y, d, eqs);
137+
solve_mul(orig, x, y, d, eqs);
116138
}
117139

118140

@@ -132,12 +154,9 @@ namespace euf {
132154
}
133155

134156
void pre_process(dependent_expr_state& fmls) override {
135-
if (!m_enabled)
136-
return;
137157
}
138158

139159
void updt_params(params_ref const& p) override {
140-
141160
}
142161

143162
};

0 commit comments

Comments
 (0)