1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
from typing import Any, List, Optional, overload, TypeVar
from itertools import product
from functools import cmp_to_key
from .posets_representation import MyFinitePoset
import act4e_interfaces as I
E = TypeVar("E")
X = TypeVar("X")
class SolFinitePosetMeasurement(I.FinitePosetMeasurement):
def height(self, fp: I.FinitePoset[Any]) -> int:
raise NotImplementedError()
def width(self, fp: I.FinitePoset[Any]) -> int:
raise NotImplementedError()
class SolFinitePosetConstructionOpposite(I.FinitePosetConstructionOpposite):
def opposite(self, p: I.FinitePoset[X]) -> I.FinitePoset[X]:
e = p.carrier().elements()
values = []
for a, b in product(e, e):
if p.holds(a, b):
# then the opposite holds(b, a)
values.append((b, a))
return MyFinitePoset(p.carrier(), values)
class SolFinitePosetSubsetProperties(I.FinitePosetSubsetProperties):
def is_chain(self, fp: I.FinitePoset[X], s: List[X]) -> bool:
try:
def cmp(a, b):
return fp._cmp(a, b)
s_sorted = sorted(s, key=cmp_to_key(cmp))
except RuntimeError as e:
return False
return True
def is_antichain(self, fp: I.FinitePoset[X], s: List[X]) -> bool:
# Comparison with itself should be ignored, since there is always a
# relation to itself by antisymmetry
not_the_same = lambda pair: not fp.carrier().equal(pair[0], pair[1])
# Check that no elements are comparable
for a, b in filter(not_the_same, product(s, s)):
assert fp.carrier().contains(a) and fp.carrier().contains(b)
if fp.holds(a, b):
return False
return True
class SolFinitePosetSubsetProperties2(I.FinitePosetSubsetProperties2):
def is_lower_set(self, fp: I.FinitePoset[X], s: List[X]) -> bool:
raise NotImplementedError()
def is_upper_set(self, fp: I.FinitePoset[X], s: List[X]) -> bool:
raise NotImplementedError()
class SolFinitePosetClosures(I.FinitePosetClosures):
def upper_closure(self, fp: I.FinitePoset[X], s: List[X]) -> List[X]:
raise NotImplementedError()
def lower_closure(self, fp: I.FinitePoset[X], s: List[X]) -> List[X]:
raise NotImplementedError()
class SolFinitePosetInfSup(I.FinitePosetInfSup):
def lower_bounds(self, fp: I.FinitePoset[E], s: List[E]) -> List[E]:
raise NotImplementedError()
def upper_bounds(self, fp: I.FinitePoset[E], s: List[E]) -> List[E]:
raise NotImplementedError()
def infimum(self, fp: I.FinitePoset[E], s: List[E]) -> Optional[E]:
raise NotImplementedError()
def supremum(self, fp: I.FinitePoset[E], s: List[E]) -> Optional[E]:
raise NotImplementedError()
class SolFinitePosetMinMax(I.FinitePosetMinMax):
def minimal(self, fp: I.FinitePoset[E], S: List[E]) -> List[E]:
raise NotImplementedError()
def maximal(self, fp: I.FinitePoset[E], S: List[E]) -> List[E]:
raise NotImplementedError()
|