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

Allow merging branches back after a split #1931

Closed
lucasmt opened this issue Jun 28, 2023 · 6 comments · Fixed by #1934
Closed

Allow merging branches back after a split #1931

lucasmt opened this issue Jun 28, 2023 · 6 comments · Fixed by #1934
Assignees

Comments

@lucasmt
Copy link
Contributor

lucasmt commented Jun 28, 2023

We need a way to merge branches back after they have been split. For example, if we have code like

if (condition) {
    x = 10;
} else {
    x = 12;
}

// rest of the program

KEVM will split into two branches, one where x contains 10 and another where it contains 12, and the rest of the program will be executed twice, once in each branch. Instead, in some cases it would be better if we could merge these branches back into a single branch where the contents of x are replaced with a symbolic variable X with the constraint X ==Int 10 orBool X ==Int 12, and then execute the rest of the program only once.

This could be implemented by a command like (just a suggestion, feel free to use a different syntax) kevm foundry-merge-nodes ContractName.testName --node N1 --node N2 ... --node Nk, which would create a new node N subsuming nodes N1...Nk. According to @ehildenb, this node can be computed automatically as a convex anti-unifier of N1...Nk.

@lucasmt
Copy link
Contributor Author

lucasmt commented Jun 28, 2023

@ehildenb suggested @nwatson22, @palinatolmach or @iFrostizz for this

@ehildenb
Copy link
Member

Here is an anti-unification routine that can be used: https://github.com/runtimeverification/pyk/blob/49d861944bad260be137f68f4adc37b360e25771/src/pyk/kast/manip.py#L585

And here is the variant that can also handle constraints, though it does not do a good job: https://github.com/runtimeverification/pyk/blob/49d861944bad260be137f68f4adc37b360e25771/src/pyk/kast/manip.py#L600

You may need to fix this issue at the same time: runtimeverification/k#4219

@nwatson22 nwatson22 linked a pull request Jun 30, 2023 that will close this issue
@nwatson22
Copy link
Member

What is meant by convex here?

@ehildenb
Copy link
Member

Convex here means that no disjuncts (orBool) should show up in the resulting term, or matching logic disjuncts (#Or).

@nwatson22
Copy link
Member

So when we abstract a cell, we should not do the thing suggested where we include an orBool of the concrete values?

@ehildenb
Copy link
Member

That's right, that would make the anti-unifier concave instead of convex.

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 a pull request may close this issue.

3 participants