-
Notifications
You must be signed in to change notification settings - Fork 149
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
4425 node merging to reduce branching for cse #4521
4425 node merging to reduce branching for cse #4521
Conversation
@Stevengre you need to rebase your branch on Also, we can assume that the |
pyk/src/pyk/kcfg/kcfg.py
Outdated
def remove_node_safely( | ||
self, | ||
node_id: NodeIdLike, | ||
predecessors: dict[str, tuple[NodeIdLike, ...]] = None, | ||
successors: dict[str, tuple[NodeIdLike, ...]] = None, | ||
) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have this method? Don't we already have remove_node
? It should work fine, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although the current remove node operation does not cause dangling issues, it directly removes edges related to the node, leading to some unexpected situations. For example:
graph LR
A -->|Split| B
A -->|Split| C
Removing node B results in:
graph LR
A
C
However, what I expect is:
graph LR
A -->|Split| C
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually expected behavior, because Split
nodes must maintain that they are total and mutually exclusive. Mutually exclusive means that nodes B
and C
must not have any intersection of their states. Total means that node A
must represent the same set of states as the union of nodes B
and C
. So putting a split like A -> C
violates the totalness requirement, so the split must be removed.
@ehildenb If this is the case, i.e., (2,3), (2,4), (3,4), (3,5), (4,5) (2,5), then the current implementation will work as mentioned in #4425. I am just providing a more general solution to handle the special cases that might appear in the figure. I believe that the meaning of KCFGSemantics.mergable(CTerm, CTerm) is to specify that two CTerms are mergable, so this situation might arise. And this merging method aligns with the semantics of mergable. |
…to-reduce-branching-for-cse
@Stevengre please rebase your branch on |
Thank you for your suggestion. And sorry for my late reply. I will make sure to study the article thoroughly. I will try to rebase my branch, but please give me one day to focus on my paper. Some problems still need to be fixed for it. I will complete this work by next Monday. |
By the way, I have one more thing to confirm. Regarding this functionality: should we assume that 1. All branch targets of the split edge will be merged? 2. Is the mergable relationship transitive? |
Mergability should be an equivalence relation. So it should partition the nodes. Transitive, commutative, and reflexive. |
Thank you! I understand. This way, we won't have a situation where (2,4) and (4,5) are mergable but not (2,5). However, it is still possible that some split targets may be merged while others are not, right? |
Yes, it's still possible some split nodes are merge-able and others are not. But you can do that by refactoring the way the splits happen. See for example here: https://docs.google.com/drawings/d/1l8i_aUMcL8E7WyxHmk2cqRIY74fQ-yvMdhhdDNcOUp0/edit Between diagram 1 and 2, we determined that |
Thank you for sharing this article (https://runtimeverification.com/blog/github-guidelines-for-collaborative-coding)! I will do my best to make my PRs easy to review by following the correct, fast, simple, and complete guidelines. However, I apologize as I am still new to collaborative coding and might make some mistakes. If you see any areas that need improvement, please let me know. Thank you again! |
This is an implementation for #4425; the changes related to #4499 and #4502 will affect the
merge_node
functionality.Please note that while this implementation is consistent with the design of #4425, it is not identical. It takes into account some general cases of mergeable nodes.
With mergeable pairs (2,3), (2,4), (3,4), (3,5), and (4,5).
Based on the largest connected subgraph, we identify two mergeable groups: (2,3,4) and (3,4,5), as 2 and 5 cannot be merged. Thus, the merged result should be:
Open Issues:
__eq__
method to address this?