Skip to content
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

Merged
merged 80 commits into from
Sep 8, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
bc6c81d
fixing issue #4651
veanes Aug 27, 2020
13259bf
regression fix
veanes Aug 27, 2020
872fd5e
fix #4662
NikolajBjorner Aug 27, 2020
6706b0d
na
NikolajBjorner Aug 27, 2020
9b201c5
reenabled lift_ites_throttled with an additional filter, without the …
veanes Aug 28, 2020
6d408fd
removing temp testing variable
veanes Aug 28, 2020
7f0b5bc
Allow to skip System.loadLibrary() calls from Java Native class (#4667)
vlsergey Aug 28, 2020
6989ff7
using intended utility methods for sort detection
veanes Aug 28, 2020
4244ce4
adding ack/model
NikolajBjorner Aug 28, 2020
0440cfe
add smt params dependency
NikolajBjorner Aug 28, 2020
ba21ffa
missing file
NikolajBjorner Aug 28, 2020
b03d1c8
deps
NikolajBjorner Aug 28, 2020
86c11b9
order
NikolajBjorner Aug 28, 2020
93ee2a6
persist fields
NikolajBjorner Aug 28, 2020
739b537
dbg build
NikolajBjorner Aug 28, 2020
b8fb744
reset caches
NikolajBjorner Aug 28, 2020
60f8884
sr
NikolajBjorner Aug 28, 2020
4e6476c
fix cmake build
NikolajBjorner Aug 29, 2020
b9cbb08
shuffle dependencies
NikolajBjorner Aug 29, 2020
79fc3f2
warnings /errors
NikolajBjorner Aug 29, 2020
e2bdf54
update include
NikolajBjorner Aug 29, 2020
455d53e
missing cmakelists
NikolajBjorner Aug 29, 2020
f6b242e
update cmake
NikolajBjorner Aug 29, 2020
7c592d4
add depend
NikolajBjorner Aug 29, 2020
98084d7
add depend
NikolajBjorner Aug 29, 2020
4983805
virtual method
NikolajBjorner Aug 29, 2020
507b4c7
path
NikolajBjorner Aug 29, 2020
11c90cc
move parameters from ast/rewriter to params
NikolajBjorner Aug 29, 2020
35e3d84
move fpa
NikolajBjorner Aug 29, 2020
996905a
fix warnings
NikolajBjorner Aug 29, 2020
a35d00e
remove pragma
NikolajBjorner Aug 29, 2020
e9a4e48
dbg
NikolajBjorner Aug 29, 2020
86310a1
updated sat_smt
NikolajBjorner Aug 30, 2020
4682b48
na
NikolajBjorner Aug 30, 2020
e8826bb
fix #4651
NikolajBjorner Aug 30, 2020
dbe2c9b
encoding options #4665
NikolajBjorner Aug 30, 2020
b992f59
expose name inclusion as optional
NikolajBjorner Aug 30, 2020
9b5dc0c
fix misc issues around #4661 introduced when adding lazy push/pop to …
NikolajBjorner Aug 30, 2020
727ea43
remove lazy push from theory_lra
NikolajBjorner Aug 30, 2020
9f0b303
na
NikolajBjorner Aug 30, 2020
2510686
fix dotnet build
NikolajBjorner Aug 30, 2020
bbe027f
na
NikolajBjorner Aug 30, 2020
a003af4
release nodes
NikolajBjorner Aug 31, 2020
bee3077
free memory in egraph
NikolajBjorner Aug 31, 2020
314bd92
avoid duplicate class names frame in sat_scc and sat_smt
NikolajBjorner Aug 31, 2020
4d41db3
adding euf
NikolajBjorner Aug 31, 2020
ed7d969
elaborate on smt/drat format outline, expose euf mode as config
NikolajBjorner Sep 1, 2020
fa9cf0f
mk-var during copy
NikolajBjorner Sep 1, 2020
d4e92d4
move theory_var_list into id_var_list and utilities from smt-enode in…
NikolajBjorner Sep 1, 2020
03e92f3
with bounded
NikolajBjorner Sep 1, 2020
74a2bf1
Merge branch 'master' of https://github.com/z3prover/z3
NikolajBjorner Sep 1, 2020
ecddaea
na
NikolajBjorner Sep 1, 2020
527bf72
Remove duplicate binary condition. Fixes #4668.
wintersteiger Sep 1, 2020
141edef
butterfly effect on fp?
NikolajBjorner Sep 1, 2020
1163908
prepare for theory plugins
NikolajBjorner Sep 2, 2020
daf7e9e
file
NikolajBjorner Sep 2, 2020
7c2fe46
build fix
NikolajBjorner Sep 2, 2020
54a75d6
remove SMTFD
NikolajBjorner Sep 2, 2020
4b22434
na
NikolajBjorner Sep 2, 2020
95493f7
na
NikolajBjorner Sep 2, 2020
e4b7b7b
na
NikolajBjorner Sep 2, 2020
d83d0a8
na
NikolajBjorner Sep 2, 2020
aa66be9
na
NikolajBjorner Sep 3, 2020
fe43f8d
na
NikolajBjorner Sep 3, 2020
65bc77d
na
NikolajBjorner Sep 3, 2020
7fbaf71
na
NikolajBjorner Sep 3, 2020
f370d8d
na
NikolajBjorner Sep 3, 2020
687a16a
SMTFD is back (#4676)
agurfinkel Sep 4, 2020
3a6bd33
fixing issue #4651
veanes Aug 27, 2020
3e9d270
regression fix
veanes Aug 27, 2020
4886967
reenabled lift_ites_throttled with an additional filter, without the …
veanes Aug 28, 2020
530ac5a
removing temp testing variable
veanes Aug 28, 2020
bd11419
using intended utility methods for sort detection
veanes Aug 28, 2020
c0ccf85
misc edits related to nonground regexes
veanes Sep 2, 2020
ca23365
bug fix of state id off by 1 calculation error and improved pretty pr…
veanes Sep 4, 2020
0628f6c
Merge branch 'fix4651' of https://github.com/veanes/z3 into fix4651
veanes Sep 5, 2020
05f27b7
removed unused method declaration
veanes Sep 5, 2020
2627721
improved id to regex value map info in generated dgml
veanes Sep 5, 2020
07d4511
reorgd callback function for state pretty printer
veanes Sep 5, 2020
bab0823
updated some comments
veanes Sep 6, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 44 additions & 7 deletions src/ast/rewriter/seq_rewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

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.

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;
Expand Down Expand Up @@ -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)) ||
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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))
{
Copy link
Contributor

Choose a reason for hiding this comment

The 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;
}

Expand Down
4 changes: 4 additions & 0 deletions src/ast/rewriter/seq_rewriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ class seq_rewriter {
bool non_overlap(zstring const& p1, zstring const& p2) const;
bool rewrite_contains_pattern(expr* a, expr* b, expr_ref& result);
bool has_fixed_length_constraint(expr* a, unsigned& len);
/* r = ite(c1,ite(c2,to_re(s),to_re(t)),to_re(u)) ==> returns true, result = ite(c1,ite(c2,s,t),u)*/
bool lift_str_from_to_re_ite(expr * r, expr_ref & result);
/* same as lift_to_re_from_ite and also: r = to_re(u) ==> returns true, result = u */
bool lift_str_from_to_re(expr * r, expr_ref & result);

br_status mk_bool_app_helper(bool is_and, unsigned n, expr* const* args, expr_ref& result);
br_status mk_eq_helper(expr* a, expr* b, expr_ref& result);
Expand Down
28 changes: 16 additions & 12 deletions src/ast/seq_decl_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this makes a "long distance" assumption about values.
Better to not make such assumptions deeply buried in code and have the routine more self-contained.
You can simply check for is_concat(s) regardless of whether it is a value, and you can check for unit, and empty as 3 separate cases. The is_value check only filters cases of concatenations of non-constants and constants, where the conventions in this routine are not uniform: in the default case you use (to_re ...), in the non-default case it doesn't use (to_re ..) around the expression.

So instead

if (is_empty(s))
    out << "();
else if is_unit(s))
      seq_unit(s, s);
else if (is_concat(s)) 
    for (expr* e : concats(s))
          concat_helper_sec(out, s);
else out << "(to_re " << pp(s) << ")";

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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}
Another thing I wanted to distinguish is (in some cases) pp(to_re S) from pp(S), but in most cases the distiction is not needed or desired and just adds noise, so I did not do it in the end. e.g. pp(tore("ab") ++ tore("cd") ) and
pp(tore("ab" ++ "cd")) are printed the same way

}
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;
}

Expand Down