mirror of
https://github.com/Z3Prover/z3
synced 2025-04-12 20:18:18 +00:00
z3str3: recognize two-argument re.loop
This commit is contained in:
parent
82c39f81a3
commit
b0bf2f1792
|
@ -1922,11 +1922,17 @@ namespace smt {
|
||||||
} else if (u.re.is_loop(a_regex)) {
|
} else if (u.re.is_loop(a_regex)) {
|
||||||
expr * body;
|
expr * body;
|
||||||
unsigned lo, hi;
|
unsigned lo, hi;
|
||||||
u.re.is_loop(a_regex, body, lo, hi);
|
// There are two variants of loop: a 2-argument version and a 3-argument version.
|
||||||
|
if (u.re.is_loop(a_regex, body, lo, hi)) {
|
||||||
rational rLo(lo);
|
rational rLo(lo);
|
||||||
rational rHi(hi);
|
rational rHi(hi);
|
||||||
zstring bodyStr = get_std_regex_str(body);
|
zstring bodyStr = get_std_regex_str(body);
|
||||||
return zstring("(") + bodyStr + zstring("{") + zstring(rLo.to_string().c_str()) + zstring(",") + zstring(rHi.to_string().c_str()) + zstring("})");
|
return zstring("(") + bodyStr + zstring("{") + zstring(rLo.to_string().c_str()) + zstring(",") + zstring(rHi.to_string().c_str()) + zstring("})");
|
||||||
|
} else if (u.re.is_loop(a_regex, body, lo)) {
|
||||||
|
rational rLo(lo);
|
||||||
|
zstring bodyStr = get_std_regex_str(body);
|
||||||
|
return zstring("(") + bodyStr + zstring("{") + zstring(rLo.to_string().c_str()) + zstring("+") + zstring("})");
|
||||||
|
}
|
||||||
} else if (u.re.is_full_seq(a_regex)) {
|
} else if (u.re.is_full_seq(a_regex)) {
|
||||||
return zstring("(.*)");
|
return zstring("(.*)");
|
||||||
} else if (u.re.is_full_char(a_regex)) {
|
} else if (u.re.is_full_char(a_regex)) {
|
||||||
|
@ -6732,7 +6738,7 @@ namespace smt {
|
||||||
} else if (u.re.is_star(re, sub1) || u.re.is_plus(re, sub1)) {
|
} else if (u.re.is_star(re, sub1) || u.re.is_plus(re, sub1)) {
|
||||||
unsigned cx = estimate_regex_complexity(sub1);
|
unsigned cx = estimate_regex_complexity(sub1);
|
||||||
return _qmul(2, cx);
|
return _qmul(2, cx);
|
||||||
} else if (u.re.is_loop(re, sub1, lo, hi)) {
|
} else if (u.re.is_loop(re, sub1, lo, hi) || u.re.is_loop(re, sub1, lo)) {
|
||||||
unsigned cx = estimate_regex_complexity(sub1);
|
unsigned cx = estimate_regex_complexity(sub1);
|
||||||
return _qadd(lo, cx);
|
return _qadd(lo, cx);
|
||||||
} else if (u.re.is_range(re, sub1, sub2)) {
|
} else if (u.re.is_range(re, sub1, sub2)) {
|
||||||
|
@ -6775,7 +6781,7 @@ namespace smt {
|
||||||
unsigned cx1 = estimate_regex_complexity_under_complement(sub1);
|
unsigned cx1 = estimate_regex_complexity_under_complement(sub1);
|
||||||
unsigned cx2 = estimate_regex_complexity_under_complement(sub2);
|
unsigned cx2 = estimate_regex_complexity_under_complement(sub2);
|
||||||
return _qmul(cx1, cx2);
|
return _qmul(cx1, cx2);
|
||||||
} else if (u.re.is_star(re, sub1) || u.re.is_plus(re, sub1) || u.re.is_loop(re, sub1, lo, hi)) {
|
} else if (u.re.is_star(re, sub1) || u.re.is_plus(re, sub1) || u.re.is_loop(re, sub1, lo, hi) || u.re.is_loop(re, sub1, lo)) {
|
||||||
unsigned cx = estimate_regex_complexity_under_complement(sub1);
|
unsigned cx = estimate_regex_complexity_under_complement(sub1);
|
||||||
return _qmul(2, cx);
|
return _qmul(2, cx);
|
||||||
} else if (u.re.is_range(re, sub1, sub2)) {
|
} else if (u.re.is_range(re, sub1, sub2)) {
|
||||||
|
@ -6831,7 +6837,7 @@ namespace smt {
|
||||||
} else if (u.re.is_complement(re)) {
|
} else if (u.re.is_complement(re)) {
|
||||||
// TODO can we do better?
|
// TODO can we do better?
|
||||||
return false;
|
return false;
|
||||||
} else if (u.re.is_loop(re, sub1, lo, hi)) {
|
} 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);
|
return check_regex_length_linearity_helper(sub1, already_star);
|
||||||
} else {
|
} else {
|
||||||
TRACE("str", tout << "WARNING: unknown regex term " << mk_pp(re, get_manager()) << std::endl;);
|
TRACE("str", tout << "WARNING: unknown regex term " << mk_pp(re, get_manager()) << std::endl;);
|
||||||
|
|
Loading…
Reference in a new issue