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

z3str3: fix support for re.complement and re.intersection #4092

Merged
merged 1 commit into from
Apr 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions src/smt/theory_str.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2069,6 +2069,18 @@ namespace smt {
return zstring("(.*)");
} else if (u.re.is_full_char(a_regex)) {
return zstring("str.allchar");
} else if (u.re.is_intersection(a_regex)) {
expr * a0;
expr * a1;
u.re.is_intersection(a_regex, a0, a1);
zstring a0str = get_std_regex_str(a0);
zstring a1str = get_std_regex_str(a1);
return zstring("(") + a0str + zstring("&&") + a1str + zstring(")");
} else if (u.re.is_complement(a_regex)) {
expr * body;
u.re.is_complement(a_regex, body);
zstring bodyStr = get_std_regex_str(body);
return zstring("(^") + bodyStr + zstring(")");
} else {
TRACE("str", tout << "BUG: unrecognized regex term " << mk_pp(regex, get_manager()) << std::endl;);
UNREACHABLE(); return zstring("");
Expand Down
6 changes: 5 additions & 1 deletion src/smt/theory_str_regex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,11 @@ namespace smt {
return true;
} else if (u.re.is_complement(re)) {
// TODO can we do better?
return false;
return false;
} else if (u.re.is_intersection(re)) {
return false;
} else if (u.re.is_complement(re)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this one is redundant given the one right above isn't it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're right, but eventually, these will have two different heuristics for length, and I wanted to capture that by separating them out.

return false;
} else if (u.re.is_loop(re, sub1, lo, hi) || u.re.is_loop(re, sub1, lo)) {
return check_regex_length_linearity_helper(sub1, already_star);
} else {
Expand Down