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

[Civl] Enhance quantifier elimination #829

Merged
merged 2 commits into from
Jan 2, 2024
Merged

[Civl] Enhance quantifier elimination #829

merged 2 commits into from
Jan 2, 2024

Conversation

shazqadeer
Copy link
Contributor

TryElimination looks for a substitution for the lhs of single-static assignments on a path-by-path basis through an atomic action. If an assignment is of the form x := v where both x and v are variables, it is possible that x is defined but v is not. In such a case, the code change interprets the assignment as an equality and infers a definition v <-- x.

Copy link
Member

@bkragl bkragl left a comment

Choose a reason for hiding this comment

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

This change looks logically correct to me.

Just wondering: I believe we had a heuristic like this (and also something with arrays) in the old transition relation computation that we wanted to eliminate in the rewrite. But I don't remember any details. Do you have any recollection?

Do you have a simple example that illustrates the practical needed for this change? I'm wondering if the changes to the TryElimination calls here are related.

@shazqadeer
Copy link
Contributor Author

I have added a test this PR. If you comment out my code change, this example does not verify.

@shazqadeer
Copy link
Contributor Author

Just wondering: I believe we had a heuristic like this (and also something with arrays) in the old transition relation computation that we wanted to eliminate in the rewrite. But I don't remember any details. Do you have any recollection?

I do remember that in the initial approach, all assignments were treated as bidirectional equalities. So the optimization I introduced would be automatically considered. Clearly, we dropped this approach in the new implementation. But I don't remember the rationale.

@shazqadeer
Copy link
Contributor Author

I'm wondering if the changes to the TryElimination calls here are related.

I think you are referring to the changes that attempt TryElimination multiple times in an attempt to minimize the number of bound variables. The change I am proposing in this PR seems independent.

@bkragl
Copy link
Member

bkragl commented Jan 2, 2024

I was specifically wondering about the removed TryElimination(trc.allLocVars.Select(v => varCopies[v][0]));, but I think it is indeed unrelated.

The added example is somewhat contrived, because a procedure and action with just an empty body would be equivalent. I guess I was unsure whether such assignments (where the expr is a variable) are useful in loop-free actions to express something in the most natural way. But I can imagine that it is the case if you have branching.

I'll approve the PR.

@shazqadeer shazqadeer merged commit 9494987 into master Jan 2, 2024
4 checks passed
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