Correctly find the top and bottom of the order lattice

This commit is contained in:
Brandon Rozek 2024-11-15 15:38:20 -05:00
parent 6317dc054f
commit 087cbb278e

16
vsp.py
View file

@ -48,9 +48,13 @@ def find_top(algebra: Set[ModelValue], mconjunction: Optional[ModelFunction], md
return None return None
for x in algebra: for x in algebra:
is_top = True
for y in algebra: for y in algebra:
if mdisjunction(x, y) == x and mconjunction(x, y) == y: if mdisjunction(x, y) != x or mconjunction(x, y) != y:
return x is_top = False
break
if is_top:
return x
print("[Warning] Failed to find the top of the lattice") print("[Warning] Failed to find the top of the lattice")
return None return None
@ -64,9 +68,13 @@ def find_bottom(algebra: Set[ModelValue], mconjunction: Optional[ModelFunction],
return None return None
for x in algebra: for x in algebra:
is_bottom = True
for y in algebra: for y in algebra:
if mdisjunction(x, y) == y and mconjunction(x, y) == x: if mdisjunction(x, y) != y or mconjunction(x, y) != x:
return x is_bottom = False
break
if is_bottom:
return x
print("[Warning] Failed to find the bottom of the lattice") print("[Warning] Failed to find the bottom of the lattice")
return None return None