mirror of
https://github.com/Z3Prover/z3
synced 2025-07-18 02:16:40 +00:00
add regex support for reverse and left/right derivative rewriting (#4477)
* partial work on adding 'reverse' (broken code) * new op codes for derivative and reverse + associated rewrite rules * incorporate reverses and derivatives in rewriter + some fixes * enable rewriting str.in_re constraints with right derivative
This commit is contained in:
parent
3d9d52f742
commit
c939195c10
5 changed files with 254 additions and 110 deletions
|
@ -216,10 +216,9 @@ namespace smt {
|
|||
return false;
|
||||
|
||||
// (accept s i R) & len(s) > i => (accept s (+ i 1) D(nth(s, i), R)) or conds
|
||||
expr_ref head = th.mk_nth(s, i);
|
||||
d = seq_rw().derivative(head, d);
|
||||
if (!d)
|
||||
throw default_exception("unable to expand derivative");
|
||||
expr_ref head = th.mk_nth(s, i);
|
||||
d = re().mk_derivative(head, r);
|
||||
rewrite(d);
|
||||
|
||||
literal acc_next = th.mk_literal(sk().mk_accept(s, a().mk_int(idx + 1), d));
|
||||
conds.push_back(~lit);
|
||||
|
@ -339,9 +338,9 @@ namespace smt {
|
|||
return;
|
||||
literal null_lit = th.mk_literal(is_nullable);
|
||||
expr_ref hd = mk_first(r);
|
||||
expr_ref d = seq_rw().derivative(hd, r);
|
||||
if (!d)
|
||||
throw default_exception("derivative was not defined");
|
||||
expr_ref d(m);
|
||||
d = re().mk_derivative(hd, r);
|
||||
rewrite(d);
|
||||
literal_vector lits;
|
||||
lits.push_back(~lit);
|
||||
if (null_lit != false_literal)
|
||||
|
@ -382,9 +381,9 @@ namespace smt {
|
|||
}
|
||||
th.add_axiom(~lit, ~th.mk_literal(is_nullable));
|
||||
expr_ref hd = mk_first(r);
|
||||
expr_ref d = seq_rw().derivative(hd, r);
|
||||
if (!d)
|
||||
throw default_exception("derivative was not defined");
|
||||
expr_ref d(m);
|
||||
d = re().mk_derivative(hd, r);
|
||||
rewrite(d);
|
||||
literal_vector lits;
|
||||
expr_ref_pair_vector cofactors(m);
|
||||
seq_rw().get_cofactors(d, cofactors);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue