3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-04-04 18:59:02 +00:00

seq_model: address NSB review comments (#8995)

* Initial plan

* Address NSB review comments in seq_model.cpp

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

* Address code review feedback: improve null-sort handling in seq_model and some_seq_in_re

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
This commit is contained in:
Copilot 2026-03-14 21:55:32 -07:00 committed by GitHub
parent 6947698d65
commit 2212f59704
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 53 additions and 91 deletions

View file

@ -6014,6 +6014,27 @@ void seq_rewriter::op_cache::cleanup() {
}
}
lbool seq_rewriter::some_seq_in_re(expr* r, expr_ref& result) {
sort* seq_sort = nullptr;
if (!u().is_re(r, seq_sort))
return l_undef;
if (u().is_string(seq_sort)) {
zstring s;
lbool res = some_string_in_re(r, s);
if (res == l_true)
result = str().mk_string(s);
return res;
}
// For non-string sequences: check if the regex accepts the empty sequence.
SASSERT(seq_sort);
expr_ref is_null = is_nullable(r);
if (m().is_true(is_null)) {
result = str().mk_empty(seq_sort);
return l_true;
}
return l_undef;
}
lbool seq_rewriter::some_string_in_re(expr* r, zstring& s) {
sort* rs;
(void)rs;

View file

@ -417,6 +417,16 @@ public:
/* Apply simplifications to the intersection to keep it normalized (r1 and r2 are not normalized)*/
expr_ref mk_regex_inter_normalize(expr* r1, expr* r2);
/*
* Extract some sequence that is a member of r.
* result is set to a concrete sequence expression if l_true is returned.
* For string-typed regexes, delegates to some_string_in_re.
* For other sequence types, checks nullability and returns the empty
* sequence if the regex accepts it; otherwise returns l_undef.
* Returns l_false if the regex is known to be empty.
*/
lbool some_seq_in_re(expr* r, expr_ref& result);
/*
* Extract some string that is a member of r.
* Return true if a valid string was extracted.