summaryrefslogtreecommitdiffstats
path: root/src/act4e_solutions/sets_properties.py
blob: 0d6b3fcfc8a82471812d47e2919de4cca19e7ed4 (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
from typing import Any, overload, Sequence, TypeVar

import act4e_interfaces as I

X = TypeVar("X")


class SolFiniteSetProperties(I.FiniteSetProperties):
    def is_subset(self, a: I.FiniteSet[X], b: I.FiniteSet[X]) -> bool:
        """ is a a subset of b ? """
        return all([b.contains(e) for e in a.elements()])

    def equal(self, a: I.FiniteSet[X], b: I.FiniteSet[X]) -> bool:
        return self.is_subset(a, b) and self.is_subset(b, a)

    def is_strict_subset(self, a: I.FiniteSet[X], b: I.FiniteSet[X]) -> bool:
        return self.is_subset(a, b) and not self.is_subset(b, a)


class SolFiniteMakeSetUnion(I.FiniteMakeSetUnion):
    def union(self, components: Sequence[I.FiniteSet[X]]) -> I.FiniteSetUnion[X, Any]:
        raise NotImplementedError() # implement here


class SolFiniteMakeSetIntersection(I.FiniteMakeSetIntersection):
    def intersection(self, components: Sequence[I.FiniteSet[X]]) -> I.FiniteSet[X]:
        raise NotImplementedError()