1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
from typing import TypeVar
from itertools import product
from .posets_bounds import SolFinitePosetConstructionOpposite
import act4e_interfaces as I
A = TypeVar("A")
B = TypeVar("B")
X = TypeVar("X")
class SolFiniteMonotoneMapProperties(I.FiniteMonotoneMapProperties):
def is_monotone(self, p1: I.FinitePoset[A], p2: I.FinitePoset[B], m: I.FiniteMap[A, B]) -> bool:
A = p1.carrier().elements()
for x, y in product(A, A):
if p1.holds(x, y):
if not p2.holds(m(x), m(y)):
return False
return True
def is_antitone(self, p1: I.FinitePoset[A], p2: I.FinitePoset[B], m: I.FiniteMap[A, B]) -> bool:
opp = SolFinitePosetConstructionOpposite()
return self.is_monotone(opp.opposite(p1), p2, m)
|