Skip to content

Commit

Permalink
add missing simplification; handle nit #6952
Browse files Browse the repository at this point in the history
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
  • Loading branch information
NikolajBjorner committed Oct 25, 2023
1 parent 0859be5 commit 7b49054
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
9 changes: 9 additions & 0 deletions src/ast/rewriter/seq_rewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1245,6 +1245,15 @@ br_status seq_rewriter::mk_seq_extract(expr* a, expr* b, expr* c, expr_ref& resu
result = str().mk_substr(a1, m_autil.mk_add(b1, b), m_autil.mk_sub(c1, b));
return BR_REWRITE3;
}
rational r1, r2;
if (str().is_extract(a, a1, b1, c1) &&
m_autil.is_numeral(b1, r1) && r1.is_unsigned() &&
m_autil.is_numeral(c1, r2) && r2.is_unsigned() &&
constantPos && constantLen &&
r1 == 0 && r2 >= pos + len) {
result = str().mk_substr(a1, b, c);
return BR_REWRITE1;
}

if (str().is_extract(a, a1, b1, c1) &&
is_prefix(a1, b1, c1) && is_prefix(a, b, c)) {
Expand Down
24 changes: 9 additions & 15 deletions src/math/polynomial/rpolynomial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -658,9 +658,7 @@ namespace rpolynomial {
void display(std::ostream & out, polynomial const * p, display_var_proc const & proc, bool use_star) {
var x = p->max_var();
bool first = true;
unsigned i = p->size();
while (i > 0) {
--i;
for (unsigned i = p->size(); i-- > 0; ) {
poly_or_num * pn = p->arg(i);
if (pn == nullptr)
continue;
Expand Down Expand Up @@ -697,23 +695,19 @@ namespace rpolynomial {
display(out, to_poly(pn), proc, use_star);
}
else {
bool add_paren = false;
if (i > 0)
add_paren = !is_monomial(to_poly(pn));
bool add_paren = !is_monomial(to_poly(pn));
if (add_paren)
out << "(";
display(out, to_poly(pn), proc, use_star);
if (add_paren)
out << ")";
if (i > 0) {
if (use_star)
out << "*";
else
out << " ";
proc(out, x);
if (i > 1)
out << "^" << i;
}
if (use_star)
out << "*";
else
out << " ";
proc(out, x);
if (i > 1)
out << "^" << i;
}
}
}
Expand Down

0 comments on commit 7b49054

Please sign in to comment.