Exemplo n.º 1
0
 def __convert_to_nuxmv(typeset: Typeset) -> List[str]:
     tuple_vars = []
     for k, v in typeset.items():
         if isinstance(v, Boolean):
             tuple_vars.append(f"{k}: boolean")
         elif isinstance(v, BoundedInteger):
             tuple_vars.append(f"{k}: {k.min}..{k.max}")
     return tuple_vars
Exemplo n.º 2
0
class World(dict):
    """"Instanciate atomic propositions (and their negation) for each Type"""
    def __init__(self,
                 actions: Set[Types] = None,
                 locations: Set[Types] = None,
                 sensors: Set[Types] = None,
                 contexts: Set[Types] = None):
        super().__init__()

        self.__typeset = Typeset(actions | locations | sensors | contexts
                                 | {Active()})

        for name, elem in self.__typeset.items():
            super(World, self).__setitem__(name, elem.to_atom())
            super(World, self).__setitem__(f"!{name}", ~elem.to_atom())

        self.__rules: Set[Rule] = set()

    @property
    def rules(self) -> Set[Rule]:
        return self.__rules

    @property
    def typeset(self) -> Typeset:
        return self.__typeset

    def add_rules(self, rules: Set[Rule]):
        self.__rules |= rules

    def adjacent_types(self, location: ReachLocation) -> Set[ReachLocation]:

        adjacent_types = set()
        for class_name in location.adjacency_set:
            for t in self.typeset.values():
                if type(t).__name__ == class_name:
                    adjacent_types.add(t)

        return adjacent_types