Exemplo n.º 1
0
    def pow(self) -> 'BSet':
        this_map = self.map
        this_domain = this_map.keys()

        start = BRelation()
        queue = [start]
        result = BSet(start)
        while not len(queue) == 0:
            current_set = queue.pop(0)

            for e1 in this_domain:
                domain_element = e1
                _range = this_map[domain_element]
                for e2 in _range:
                    range_element = e2
                    next_relation = current_set.union(
                        BRelation.fromSet(
                            BSet(BTuple(domain_element, range_element))))
                    previous_size = result.size()
                    result = result.union(BSet(next_relation))
                    if previous_size < result.size():
                        queue.append(next_relation)

        return result
Exemplo n.º 2
0
 def front(self) -> 'BRelation':
     return self.domainSubstraction(BSet(self.card()))
Exemplo n.º 3
0
 def _range(self) -> 'BSet':
     _set = reduce(lambda a, b: a.union(b), self.map.values(), set())
     return BSet(*list(_set))
Exemplo n.º 4
0
 def pow1(self) -> 'BSet':
     return self.pow().difference(BSet(BRelation()))
Exemplo n.º 5
0
 def _range(self) -> 'BSet':
     _range = reduce(lambda a, b: a.update(b), self.map.values(),
                     immutables.Map())
     return BSet(_range)
Exemplo n.º 6
0
class BUtils:
    BOOL = BSet(BBoolean(True), BBoolean(False))