3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-07-23 20:58:54 +00:00

fix bug in seq rewriter op_cache::find (#4509)

* remove unneeded reverse case in derivative; placeholder for generalized lifted derivative

* experimental tweaks to RE rewriter to improve performance

* if-then-else lifting
(broken code -- preserving this commit in case this idea is useful later)

* if-then-else derivative optimizations: new approach templates

* implement if-then-else BDD normal form for derivatives
(code compiles but is still buggy)

* remove std::cout debugging for PR

* Revert "remove std::cout debugging for PR"

This reverts commit c7bdc44d31.

* debugging

* fix derivative interaction with reverse; add flags for left/right derivative and lifting over union/intersection

* remove debugging statements for PR

* Revert "remove debugging statements for PR"

This reverts commit 38e85a7288.

* revert some purely cosmetic changes from upstream; fix a bug

* revert unnecessary changes

* remove some redundant rewrites and add a new one for str.in_re(s, comp(r))

* add disabled rewrite for complement

* fix bug in op cache find (result was not saved)

* remove debugging std::cout for PR
This commit is contained in:
calebstanford-msr 2020-06-09 14:36:31 -04:00 committed by GitHub
parent ec1e733ef2
commit 1fd567d1e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 99 additions and 28 deletions

View file

@ -171,23 +171,26 @@ class seq_rewriter {
length_comparison compare_lengths(unsigned sza, expr* const* as, unsigned szb, expr* const* bs);
// Support for regular expression derivatives
bool get_head_tail(expr* e, expr_ref& head, expr_ref& tail);
bool get_head_tail_reversed(expr* e, expr_ref& head, expr_ref& tail);
bool get_re_head_tail(expr* e, expr_ref& head, expr_ref& tail);
bool get_re_head_tail_reversed(expr* e, expr_ref& head, expr_ref& tail);
expr_ref re_and(expr* cond, expr* r);
expr_ref re_predicate(expr* cond, sort* seq_sort);
expr_ref mk_seq_concat(expr* a, expr* b);
// Calculate derivative, memoized and enforcing a normal form
expr_ref mk_derivative(expr* ele, expr* r);
expr_ref mk_derivative_rec(expr* ele, expr* r);
expr_ref mk_der_op(decl_kind k, expr* a, expr* b);
expr_ref mk_der_op_rec(decl_kind k, expr* a, expr* b);
expr_ref mk_der_concat(expr* a, expr* b);
expr_ref mk_der_union(expr* a, expr* b);
expr_ref mk_der_inter(expr* a, expr* b);
expr_ref mk_der_compl(expr* a);
expr_ref mk_derivative(expr* ele, expr* r);
expr_ref mk_derivative_rec(expr* ele, expr* r);
expr_ref mk_der_reverse(expr* a);
bool are_complements(expr* r1, expr* r2) const;
bool is_subset(expr* r1, expr* r2) const;
@ -231,11 +234,12 @@ class seq_rewriter {
br_status mk_re_range(expr* lo, expr* hi, expr_ref& result);
br_status mk_re_reverse(expr* r, expr_ref& result);
br_status mk_re_derivative(expr* ele, expr* r, expr_ref& result);
br_status lift_ite(func_decl* f, unsigned n, expr* const* args, expr_ref& result);
br_status lift_ites_throttled(func_decl* f, unsigned n, expr* const* args, expr_ref& result);
br_status reduce_re_eq(expr* a, expr* b, expr_ref& result);
br_status reduce_re_is_empty(expr* r, expr_ref& result);
bool non_overlap(expr_ref_vector const& p1, expr_ref_vector const& p2) const;
bool non_overlap(zstring const& p1, zstring const& p2) const;
bool rewrite_contains_pattern(expr* a, expr* b, expr_ref& result);
@ -324,9 +328,9 @@ public:
void add_seqs(expr_ref_vector const& ls, expr_ref_vector const& rs, expr_ref_pair_vector& new_eqs);
// Check for acceptance of the empty string
expr_ref is_nullable(expr* r);
// heuristic elimination of element from condition that comes form a derivative.
// special case optimization for conjunctions of equalities, disequalities and ranges.
void elim_condition(expr* elem, expr_ref& cond);