Implementing optimization #14

Discard subalgebras which are order-dependent
This commit is contained in:
Brandon Rozek 2025-01-31 17:16:25 -05:00
parent 9f80fb8bba
commit 4b907281a5
3 changed files with 43 additions and 6 deletions

View file

@ -103,18 +103,34 @@ def binary_function_str(f: ModelFunction) -> str:
Interpretation = Dict[Operation, ModelFunction]
class OrderTable:
def __init__(self):
self.ordering = set()
def add(self, x, y):
"""
Add x <= y
"""
self.ordering.add((x, y))
def is_lt(self, x, y):
return (x, y) in self.ordering
class Model:
def __init__(
self,
carrier_set: Set[ModelValue],
logical_operations: Set[ModelFunction],
designated_values: Set[ModelValue],
ordering: Optional[OrderTable] = None,
name: Optional[str] = None
):
assert designated_values <= carrier_set
self.carrier_set = carrier_set
self.logical_operations = logical_operations
self.designated_values = designated_values
self.ordering = ordering
self.name = str(abs(hash((
frozenset(carrier_set),
frozenset(logical_operations),