From 087cbb278ebf54b8c3b007f0440550f60e69f386 Mon Sep 17 00:00:00 2001 From: Brandon Rozek Date: Fri, 15 Nov 2024 15:38:20 -0500 Subject: [PATCH] Correctly find the top and bottom of the order lattice --- vsp.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/vsp.py b/vsp.py index 7420b68..6a50c63 100644 --- a/vsp.py +++ b/vsp.py @@ -48,9 +48,13 @@ def find_top(algebra: Set[ModelValue], mconjunction: Optional[ModelFunction], md return None for x in algebra: + is_top = True for y in algebra: - if mdisjunction(x, y) == x and mconjunction(x, y) == y: - return x + if mdisjunction(x, y) != x or mconjunction(x, y) != y: + is_top = False + break + if is_top: + return x print("[Warning] Failed to find the top of the lattice") return None @@ -64,9 +68,13 @@ def find_bottom(algebra: Set[ModelValue], mconjunction: Optional[ModelFunction], return None for x in algebra: + is_bottom = True for y in algebra: - if mdisjunction(x, y) == y and mconjunction(x, y) == x: - return x + if mdisjunction(x, y) != y or mconjunction(x, y) != x: + is_bottom = False + break + if is_bottom: + return x print("[Warning] Failed to find the bottom of the lattice") return None