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)