mirror of
https://github.com/Z3Prover/z3
synced 2025-04-22 16:45:31 +00:00
Special case regex membership with constant string
This commit is contained in:
parent
73062fc892
commit
78b77b9d1e
1 changed files with 21 additions and 0 deletions
|
@ -4545,6 +4545,27 @@ br_status seq_rewriter::mk_str_in_regexp(expr* a, expr* b, expr_ref& result) {
|
|||
result = m().mk_true();
|
||||
return BR_DONE;
|
||||
}
|
||||
|
||||
zstring s;
|
||||
if (str().is_string(a, s) && re().is_ground(b)) {
|
||||
// Just check membership and replace by true/false
|
||||
expr_ref r(b, m());
|
||||
for (unsigned i = 0; i < s.length(); i++) {
|
||||
if (re().is_empty(r)) {
|
||||
result = m().mk_false();
|
||||
return BR_DONE;
|
||||
}
|
||||
unsigned ch = s[i];
|
||||
expr_ref new_r = mk_derivative(m_util.mk_char(ch), r);
|
||||
r = new_r;
|
||||
}
|
||||
if (re().get_info(r).nullable)
|
||||
result = m().mk_true();
|
||||
else
|
||||
result = m().mk_false();
|
||||
return BR_DONE;
|
||||
}
|
||||
|
||||
expr_ref b_s(m());
|
||||
if (lift_str_from_to_re(b, b_s)) {
|
||||
result = m_br.mk_eq_rw(a, b_s);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue