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

12
vsp.py
View file

@ -48,8 +48,12 @@ 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:
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")
@ -64,8 +68,12 @@ 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:
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")