From 81a2d17965483cbb681bc2dc18b471e356df4195 Mon Sep 17 00:00:00 2001 From: Brandon Rozek Date: Tue, 28 May 2024 13:51:29 -0400 Subject: [PATCH] Temporary debugging --- parse_magic.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/parse_magic.py b/parse_magic.py index 4b95ba4..d0ea945 100644 --- a/parse_magic.py +++ b/parse_magic.py @@ -60,6 +60,7 @@ def parse_matrices(infile: TextIO) -> List[Tuple[Model, Dict]]: Implication: mimplication } solutions.append((model, interpretation)) + print(f"Parsed Matrix {len(solutions)}") return solutions @@ -102,6 +103,7 @@ def parse_mvalue(x: str) -> ModelValue: def determine_cresult(size: int, ordering: Dict[ModelValue, ModelValue], a: ModelValue, b: ModelValue) -> ModelValue: for i in range(size + 1): c = mvalue_from_index(i) + if not ordering[(c, a)]: continue if not ordering[(c, b)]: @@ -141,6 +143,7 @@ def determine_dresult(size: int, ordering: Dict[ModelValue, ModelValue], a: Mode if not invalid: return c + print(a, "|", b, "is not defined") def parse_order(infile: TextIO, size: int) -> Optional[Tuple[ModelFunction, ModelFunction]]: line = next(infile).strip() @@ -161,6 +164,11 @@ def parse_order(infile: TextIO, size: int) -> Optional[Tuple[ModelFunction, Mode omapping[(x, y)] = table[table_i] == '1' table_i += 1 + + # NOTE: Print omapping for debugging + for (x, y) in omapping.keys(): + print(x, y, "maps to", omapping[(x, y)]) + cmapping = {} dmapping = {} @@ -233,6 +241,10 @@ if __name__ == "__main__": solutions: List[Model] = parse_matrices(sys.stdin) print(f"Parsed {len(solutions)} matrices") for i, (model, interpretation) in enumerate(solutions): + # TODO: Check if conjunction and disjunction are well defined while parsing + model.logical_operations -= {interpretation[Conjunction], interpretation[Disjunction]} + del interpretation[Conjunction] + del interpretation[Disjunction] # print(model) if has_vsp(model, interpretation): print(model)