diff --git a/pyk/src/pyk/kore/internal.py b/pyk/src/pyk/kore/internal.py index 95eb918bc7..588bcf35b3 100644 --- a/pyk/src/pyk/kore/internal.py +++ b/pyk/src/pyk/kore/internal.py @@ -11,6 +11,8 @@ from .syntax import App, Axiom, SortApp, SortDecl, String, Symbol, SymbolDecl if TYPE_CHECKING: + from collections.abc import Iterable + from .syntax import Definition @@ -140,6 +142,11 @@ def let( functions=self.functions if functions is None else functions, ) + def filter_rewrites(self, labels: Iterable[str]) -> KoreDefn: + """Keep only rewrite rules with certain labels in the definition.""" + should_keep = set(labels) + return self.let(rewrites=tuple(rewrite for rewrite in self.rewrites if rewrite.label in should_keep)) + def project_to_symbols(self) -> KoreDefn: """Project definition to symbols present in the definition.""" symbol_sorts = {sort for symbol in self.symbols for sort in self._symbol_sorts(symbol)}