blob: bba5b62c5078145a76ee25042a19dca4fd35b9c9 (
plain)
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
|
from typing import Any, TypeVar
from .sets_properties import SolFiniteSetProperties
from .sets_power import MyFiniteSetOfFiniteSubsets, SolFiniteMakePowerSet
from .posets_representation import MyFinitePoset
import act4e_interfaces as I
X = TypeVar("X")
C = TypeVar("C") # Type of elements of set
E = TypeVar("E")
class MyFinitePosetOfFiniteSubsets(I.FinitePosetOfFiniteSubsets[C, E]):
_subsets: I.FiniteSetOfFiniteSubsets[C, E]
def __init__(self, subsets):
self._subsets = subsets
self._prop = SolFiniteSetProperties()
def carrier(self) -> I.FiniteSetOfFiniteSubsets[C, E]:
return self._subsets
def holds(self, a: I.FiniteSet[C], b: I.FiniteSet[C]):
if self._prop.equal(a, b):
return True
if self._subsets.contains(a) and self._subsets.contains(b):
if self._prop.is_subset(a, b):
return True
return False
class SolFinitePosetConstructionPower(I.FinitePosetConstructionPower):
def powerposet(self, s: I.FiniteSet[X]) -> I.FinitePosetOfFiniteSubsets[X, Any]:
setpow = SolFiniteMakePowerSet()
subsets = setpow.powerset(s)
return MyFinitePosetOfFiniteSubsets(subsets)
|