Skip to content

Commit

Permalink
Avoid using merge_nodes by default (#4647)
Browse files Browse the repository at this point in the history
Default: Avoid using merge_nodes, as they offer a more abstract rule
instead of the original ones.
  • Loading branch information
Stevengre authored Oct 7, 2024
1 parent 64b0260 commit d40018b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pyk/src/pyk/kcfg/exploration.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,5 @@ def to_dict(self) -> dict[str, Any]:
#

# Minimizing the KCFG
def minimize_kcfg(self) -> None:
KCFGMinimizer(self.kcfg).minimize()
def minimize_kcfg(self, merge: bool = False) -> None:
KCFGMinimizer(self.kcfg).minimize(merge=merge)
4 changes: 2 additions & 2 deletions pyk/src/pyk/kcfg/minimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def _is_mergeable(x: KCFG.Edge | KCFG.MergedEdge, y: KCFG.Edge | KCFG.MergedEdge

return True

def minimize(self) -> None:
def minimize(self, merge: bool = False) -> None:
"""Minimize KCFG by repeatedly performing the lifting transformations.
The KCFG is transformed to an equivalent in which no further lifting transformations are possible.
Expand All @@ -300,5 +300,5 @@ def minimize(self) -> None:
repeat = self.lift_splits() or repeat

repeat = True
while repeat:
while repeat and merge:
repeat = self.merge_nodes()
4 changes: 2 additions & 2 deletions pyk/src/tests/unit/kcfg/merge_node_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,12 @@ def util_check_constraint(constraint: KInner, merged_var: KVariable, under_check


def check_merge_no(minimizer: KCFGMinimizer) -> None:
minimizer.minimize()
minimizer.minimize(merge=True)
assert minimizer.kcfg.to_dict() == merge_node_test_kcfg().to_dict()


def check_merged_one(minimizer: KCFGMinimizer) -> None:
minimizer.minimize()
minimizer.minimize(merge=True)
# 1 --> merged bi: Merged Edge
merged_edge = single(minimizer.kcfg.merged_edges(source_id=1))
edges = {2: 9, 3: 10, 16: 20, 17: 21, 18: 22, 19: 23, 6: 13, 7: 14, 8: 15}
Expand Down

0 comments on commit d40018b

Please sign in to comment.