Skip to content

Fix collectEmptyEqs() in string utils#6562

Merged
ajreynol merged 2 commits intocvc5:masterfrom
4tXJ7f:issue6483
May 18, 2021
Merged

Fix collectEmptyEqs() in string utils#6562
ajreynol merged 2 commits intocvc5:masterfrom
4tXJ7f:issue6483

Conversation

@4tXJ7f
Copy link
Copy Markdown
Member

@4tXJ7f 4tXJ7f commented May 18, 2021

Fixes #6483. The benchmark in the issue was performing the following
incorrect rewrite:

 Rewrite (str.replace "B" (str.replace (str.++ (str.replace "B" a "B") a) "B" "") "B") to (str.replace "B" a "B") by RPL_X_Y_X_SIMP.

The rewrite RPL_X_Y_X_SIMP rewrites terms of the form (str.replace x y x), where x is of length one and (= y "") rewrites to a
conjunction of equalities of the form (= y_i "") where y_i is some
term. The function responsible for collecting the terms y_i from this
conjunction, collectEmptyEqs(), returns a bool and a vector of
Nodes. The bool indicates whether all equalities in the conjunction
were of the form (= y_i ""). The rewrite RPL_X_Y_X_SIMP only applies
if this is true. However, collectEmptyEqs() had a bug where it would
not return false when all of the conjuncts were equalities but not all
of them were equalities with the empty string. This commit fixes
collectEmptyEqs() and adds tests.

Fixes cvc5#6483. The benchmark in the issue was performing the following
incorrect rewrite:

```
 Rewrite (str.replace "B" (str.replace (str.++ (str.replace "B" a "B") a) "B" "") "B") to (str.replace "B" a "B") by RPL_X_Y_X_SIMP.
```

The rewrite `RPL_X_Y_X_SIMP` rewrites terms of the form `(str.replace x
y x)`, where `x` is of length one and `(= y "")` rewrites to a
conjunction of equalities of the form `(= y_i "")` where `y_i` is some
term. The function responsible for collecting the terms `y_i` from this
conjunction, `collectEmptyEqs()`, returns a `bool` and a vector of
`Node`s. The `bool` indicates whether all equalities in the conjunction
were of the form `(= y_i "")`. The rewrite `RPL_X_Y_X_SIMP` only applies
if this is true. However, `collectEmptyEqs()` had a bug where it would
not return false when all of the conjuncts were equalities but not all
of them were equalities with the empty string. This commit fixes
`collectEmptyEqs()` and adds tests.
@4tXJ7f 4tXJ7f added normal Priority major Priority labels May 18, 2021
@4tXJ7f 4tXJ7f requested a review from ajreynol May 18, 2021 20:54
@ajreynol ajreynol added moderate Complexity and removed normal Priority labels May 18, 2021
@ajreynol
Copy link
Copy Markdown
Member

Does this PR also fix #6101 ?

Copy link
Copy Markdown
Member

@ajreynol ajreynol left a comment

Choose a reason for hiding this comment

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

LGTM, great find.

@ajreynol ajreynol enabled auto-merge (squash) May 18, 2021 21:11
@4tXJ7f
Copy link
Copy Markdown
Member Author

4tXJ7f commented May 18, 2021

Does this PR also fix #6101 ?

Unfortunately, it does not look like it. The rewrite fixed in this PR does not apply very often.

@ajreynol ajreynol merged commit c214051 into cvc5:master May 18, 2021
@4tXJ7f 4tXJ7f deleted the issue6483 branch May 28, 2021 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

major Priority moderate Complexity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

solution unsoundness on a string formula

2 participants