mirror of
https://github.com/Z3Prover/z3
synced 2025-06-07 06:33:23 +00:00
update regex membership to be slightly better tuned
This commit is contained in:
parent
f4ed432244
commit
c9cae77304
3 changed files with 19 additions and 18 deletions
|
@ -3790,6 +3790,7 @@ expr_ref seq_rewriter::simplify_path(expr* elem, expr* path) {
|
||||||
|
|
||||||
|
|
||||||
expr_ref seq_rewriter::mk_der_antimirov_union(expr* r1, expr* r2) {
|
expr_ref seq_rewriter::mk_der_antimirov_union(expr* r1, expr* r2) {
|
||||||
|
verbose_stream() << "union " << r1->get_id() << " " << r2->get_id() << "\n";
|
||||||
return mk_der_op(_OP_RE_ANTIMIROV_UNION, r1, r2);
|
return mk_der_op(_OP_RE_ANTIMIROV_UNION, r1, r2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,8 +96,6 @@ Equality solving using stochastic Nelson.
|
||||||
#include "ast/sls/sls_context.h"
|
#include "ast/sls/sls_context.h"
|
||||||
#include "ast/ast_pp.h"
|
#include "ast/ast_pp.h"
|
||||||
|
|
||||||
#include "ast/rewriter/th_rewriter.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace sls {
|
namespace sls {
|
||||||
|
|
||||||
|
@ -105,7 +103,8 @@ namespace sls {
|
||||||
plugin(c),
|
plugin(c),
|
||||||
seq(c.get_manager()),
|
seq(c.get_manager()),
|
||||||
a(c.get_manager()),
|
a(c.get_manager()),
|
||||||
rw(c.get_manager())
|
rw(c.get_manager()),
|
||||||
|
thrw(c.get_manager())
|
||||||
{
|
{
|
||||||
m_fid = seq.get_family_id();
|
m_fid = seq.get_family_id();
|
||||||
}
|
}
|
||||||
|
@ -1705,13 +1704,17 @@ namespace sls {
|
||||||
|
|
||||||
// Regular expressions
|
// Regular expressions
|
||||||
|
|
||||||
bool seq_plugin::is_in_re(zstring const& s, expr* r) {
|
bool seq_plugin::is_in_re(zstring const& s, expr* _r) {
|
||||||
expr_ref sval(seq.str.mk_string(s), m);
|
expr_ref r(_r, m);
|
||||||
th_rewriter rw(m);
|
for (unsigned i = 0; i < s.length(); ++i) {
|
||||||
expr_ref in_re(seq.re.mk_in_re(sval, r), m);
|
expr_ref ch(seq.str.mk_char(s[i]), m);
|
||||||
rw(in_re);
|
expr_ref r1 = rw.mk_derivative(ch, r);
|
||||||
SASSERT(m.limit().is_canceled() || m.is_true(in_re) || m.is_false(in_re));
|
if (seq.re.is_empty(r1))
|
||||||
return m.is_true(in_re);
|
return false;
|
||||||
|
r = r1;
|
||||||
|
}
|
||||||
|
auto info = seq.re.get_info(r);
|
||||||
|
return info.nullable == l_true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool seq_plugin::repair_down_in_re(app* e) {
|
bool seq_plugin::repair_down_in_re(app* e) {
|
||||||
|
@ -1721,12 +1724,8 @@ namespace sls {
|
||||||
if (!info.interpreted)
|
if (!info.interpreted)
|
||||||
return false;
|
return false;
|
||||||
auto s = strval0(x);
|
auto s = strval0(x);
|
||||||
expr_ref xval(seq.str.mk_string(s), m);
|
bool in_re = is_in_re(s, y);
|
||||||
expr_ref in_re(seq.re.mk_in_re(xval, y), m);
|
if (in_re == ctx.is_true(e))
|
||||||
th_rewriter thrw(m);
|
|
||||||
thrw(in_re);
|
|
||||||
SASSERT(m.limit().is_canceled() || m.is_true(in_re) || m.is_false(in_re));
|
|
||||||
if (m.is_true(in_re) == ctx.is_true(e))
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (is_value(x))
|
if (is_value(x))
|
||||||
|
|
|
@ -20,7 +20,7 @@ Author:
|
||||||
#include "ast/seq_decl_plugin.h"
|
#include "ast/seq_decl_plugin.h"
|
||||||
#include "ast/arith_decl_plugin.h"
|
#include "ast/arith_decl_plugin.h"
|
||||||
#include "ast/rewriter/seq_rewriter.h"
|
#include "ast/rewriter/seq_rewriter.h"
|
||||||
|
#include "ast/rewriter/th_rewriter.h"
|
||||||
|
|
||||||
namespace sls {
|
namespace sls {
|
||||||
|
|
||||||
|
@ -45,6 +45,7 @@ namespace sls {
|
||||||
seq_util seq;
|
seq_util seq;
|
||||||
arith_util a;
|
arith_util a;
|
||||||
seq_rewriter rw;
|
seq_rewriter rw;
|
||||||
|
th_rewriter thrw;
|
||||||
scoped_ptr_vector<eval> m_values;
|
scoped_ptr_vector<eval> m_values;
|
||||||
indexed_uint_set m_chars;
|
indexed_uint_set m_chars;
|
||||||
bool m_initialized = false;
|
bool m_initialized = false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue