Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added derivative support for (str.to_re (str.from_int ...)) #5431

Merged
merged 1 commit into from
Jul 25, 2021

Conversation

veanes
Copy link
Collaborator

@veanes veanes commented Jul 25, 2021

This fixes an unsound unsat result in one case discussed in issue #5140
involving the use of (str.to_re (str.from_int (str.len x))) where x is uninterpreted.

@@ -3339,6 +3339,26 @@ expr_ref seq_rewriter::mk_derivative_rec(expr* ele, expr* r) {
//while mk_empty() = [], because deriv(epsilon) = [] = nothing
return mk_empty();
}
else if (str().is_itos(r1, r2))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how it fixes the underlying issue. The default behavior is to return a derivative expression. It should be sound no matter what it is applied to. Adding this code just bypasses the default case so it seems to mask the bug, not outright address it for other scenarios. Suppose I introduce an uninterpreted function that has the same effect as itos. This code would go to the default case.


tl = str().mk_substr(r1, m_autil.mk_int(1), m_autil.mk_sub(str().mk_length(r1), m_autil.mk_int(1)));
//if ((isdigit ele) and (ele = (hd r1))) then (to_re (tl r1)) else []
result = re_and(result, re().mk_to_re(tl));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re_and already performs constant folding when the condition is true/false. So having the caller perform constant folding is at best a micro-optimization with the effect of making the code more elaborate.
I

@NikolajBjorner NikolajBjorner merged commit 4fd1e6d into Z3Prover:master Jul 25, 2021
NikolajBjorner added a commit that referenced this pull request Jul 25, 2021
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
NikolajBjorner added a commit that referenced this pull request Jul 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants