-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixing issue #4651 #4666
fixing issue #4651 #4666
Changes from 2 commits
bc6c81d
13259bf
872fd5e
6706b0d
9b201c5
6d408fd
7f0b5bc
6989ff7
4244ce4
0440cfe
ba21ffa
b03d1c8
86c11b9
93ee2a6
739b537
b8fb744
60f8884
4e6476c
b9cbb08
79fc3f2
e2bdf54
455d53e
f6b242e
7c592d4
98084d7
4983805
507b4c7
11c90cc
35e3d84
996905a
a35d00e
e9a4e48
86310a1
4682b48
e8826bb
dbe2c9b
b992f59
9b5dc0c
727ea43
9f0b303
2510686
bbe027f
a003af4
bee3077
314bd92
4d41db3
ed7d969
fa9cf0f
d4e92d4
03e92f3
74a2bf1
ecddaea
527bf72
141edef
1163908
daf7e9e
7c2fe46
54a75d6
4b22434
95493f7
e4b7b7b
d83d0a8
aa66be9
fe43f8d
65bc77d
7fbaf71
f370d8d
687a16a
3a6bd33
3e9d270
4886967
530ac5a
bd11419
c0ccf85
ca23365
0628f6c
05f27b7
2627721
07d4511
bab0823
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -728,9 +728,11 @@ br_status seq_rewriter::mk_app_core(func_decl * f, unsigned num_args, expr * con | |
case _OP_STRING_STRIDOF: | ||
UNREACHABLE(); | ||
} | ||
#if 0 | ||
if (st == BR_FAILED) { | ||
st = lift_ites_throttled(f, num_args, args, result); | ||
} | ||
#endif | ||
CTRACE("seq_verbose", st != BR_FAILED, tout << expr_ref(m().mk_app(f, num_args, args), m()) << " -> " << result << "\n";); | ||
SASSERT(st == BR_FAILED || m().get_sort(result) == f->get_range()); | ||
return st; | ||
|
@@ -3246,11 +3248,12 @@ br_status seq_rewriter::mk_str_in_regexp(expr* a, expr* b, expr_ref& result) { | |
result = m().mk_true(); | ||
return BR_DONE; | ||
} | ||
expr* b1 = nullptr; | ||
if (re().is_to_re(b, b1)) { | ||
result = m_br.mk_eq_rw(a, b1); | ||
return BR_REWRITE1; | ||
expr_ref b_s(m()); | ||
if (lift_str_from_to_re(b, b_s)) { | ||
result = m_br.mk_eq_rw(a, b_s); | ||
return BR_REWRITE_FULL; | ||
} | ||
expr* b1 = nullptr; | ||
expr* eps = nullptr; | ||
if (re().is_opt(b, b1) || | ||
(re().is_union(b, b1, eps) && re().is_epsilon(eps)) || | ||
|
@@ -3337,6 +3340,30 @@ bool seq_rewriter::has_fixed_length_constraint(expr* a, unsigned& len) { | |
return minl == maxl; | ||
} | ||
|
||
bool seq_rewriter::lift_str_from_to_re_ite(expr* r, expr_ref& result) | ||
{ | ||
expr* cond = nullptr, * then_r = nullptr, * else_r = nullptr; | ||
expr_ref then_s(m()); | ||
expr_ref else_s(m()); | ||
if (m().is_ite(r, cond, then_r, else_r) && | ||
lift_str_from_to_re(then_r, then_s) && | ||
lift_str_from_to_re(else_r, else_s)) { | ||
result = m().mk_ite(cond, then_s, else_s); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
bool seq_rewriter::lift_str_from_to_re(expr* r, expr_ref& result) | ||
{ | ||
expr* s = nullptr; | ||
if (re().is_to_re(r, s)) { | ||
result = s; | ||
return true; | ||
} | ||
return lift_str_from_to_re_ite(r, result); | ||
} | ||
|
||
br_status seq_rewriter::mk_str_to_regexp(expr* a, expr_ref& result) { | ||
return BR_FAILED; | ||
} | ||
|
@@ -3375,11 +3402,13 @@ br_status seq_rewriter::mk_re_concat(expr* a, expr* b, expr_ref& result) { | |
result = a; | ||
return BR_DONE; | ||
} | ||
expr* a1 = nullptr, *b1 = nullptr; | ||
if (re().is_to_re(a, a1) && re().is_to_re(b, b1)) { | ||
result = re().mk_to_re(str().mk_concat(a1, b1)); | ||
expr_ref a_str(m()); | ||
expr_ref b_str(m()); | ||
if (lift_str_from_to_re(a, a_str) && lift_str_from_to_re(b, b_str)) { | ||
result = re().mk_to_re(str().mk_concat(a_str, b_str)); | ||
return BR_REWRITE2; | ||
} | ||
expr* a1 = nullptr, *b1 = nullptr; | ||
if (re().is_star(a, a1) && re().is_star(b, b1) && a1 == b1) { | ||
result = a; | ||
return BR_DONE; | ||
|
@@ -3811,7 +3840,15 @@ br_status seq_rewriter::mk_re_star(expr* a, expr_ref& result) { | |
result = re().mk_star(re().mk_union(b1, c1)); | ||
return BR_REWRITE2; | ||
} | ||
if (m().is_ite(a, c, b1, c1)) | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. move { to after ), not on a new line as in C# |
||
if ((re().is_full_char(b1) || re().is_full_seq(b1)) && | ||
(re().is_full_char(c1) || re().is_full_seq(c1))) { | ||
result = re().mk_full_seq(m().get_sort(b1)); | ||
return BR_REWRITE2; | ||
} | ||
|
||
} | ||
return BR_FAILED; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1452,20 +1452,24 @@ app* seq_util::rex::mk_epsilon(sort* seq_sort) { | |
*/ | ||
std::ostream& seq_util::rex::pp::compact_helper_seq(std::ostream& out, expr* s) const { | ||
SASSERT(re.u.is_seq(s)); | ||
if (re.u.str.is_concat(s)) { | ||
expr_ref_vector es(re.m); | ||
re.u.str.get_concat(s, es); | ||
for (expr* e : es) { | ||
if (re.u.str.is_unit(e)) | ||
seq_unit(out, e); | ||
else | ||
out << mk_pp(e, re.m); | ||
if (re.m.is_value(s)) { | ||
if (re.u.str.is_concat(s)) { | ||
expr_ref_vector es(re.m); | ||
re.u.str.get_concat(s, es); | ||
for (expr* e : es) { | ||
if (re.u.str.is_unit(e)) | ||
seq_unit(out, e); | ||
else | ||
out << mk_pp(e, re.m); | ||
} | ||
} | ||
else if (re.u.str.is_empty(s)) | ||
out << "()"; | ||
else | ||
seq_unit(out, s); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this makes a "long distance" assumption about values. So instead
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I updated it similarly, but essentially I wanted to distinguish between 'A' vs uninterpreted const A, the latter is now printed as {A} |
||
} | ||
else if (re.u.str.is_empty(s)) | ||
out << "()"; | ||
else | ||
seq_unit(out, s); | ||
else | ||
out << "(to_re " << mk_pp(s, re.m) << ")"; | ||
return out; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will create a perf regression for strings, where lifting ites is very useful.
So it could look at the type of the expression. If it is a seq, then lift, otherwise don't.
That can be accomplished inside lift_ites_throttled, not here.