示例#1
0
    def test_body(self):
        """Test that the HOA body is correct."""
        state_edges_dict = OrderedDict({})
        state_edges_dict[State(0, name=string("a U b"), acc_sig=frozenset({0}))] = [
            Edge([2]),
            Edge([0]),
            Edge([1]),
            Edge([1]),
        ]

        state_edges_dict[State(1, acc_sig=frozenset({1}))] = [
            Edge([1]),
            Edge([1]),
            Edge([1]),
            Edge([1]),
        ]
        state_edges_dict[
            State(2, name=string("sink state"), acc_sig=frozenset({0}))
        ] = [
            Edge([2]),
            Edge([2]),
            Edge([2]),
            Edge([2]),
        ]

        assert self.hoa_body.state2edges == state_edges_dict
示例#2
0
    def test_hoa(self):
        """Test that the HOA automaton is correct."""
        hoa_header = HOAHeader(
            identifier("v1"),
            Acceptance(Fin(0), identifier("co-Buchi")),
            nb_states=4,
            start_states={frozenset([0, 2]), frozenset([3])},
            propositions=(string("a"), string("b"), string("c")),
            name=string("(Fa & G(b&Xc)) | c"),
        )

        state_edges_dict = OrderedDict({})
        state_edges_dict[State(0, name=string("Fa"))] = [
            Edge([0], label=TRUE, acc_sig=frozenset({0})),
            Edge([1], label=LabelAtom(0)),
        ]
        state_edges_dict[State(1, name=string("true"))] = [Edge([1], label=TRUE)]
        state_edges_dict[State(2, name=string("G(b&Xc)"))] = [
            Edge([2, 3], label=LabelAtom(1))
        ]
        state_edges_dict[State(3, name=string("c"))] = [Edge([1], label=LabelAtom(2))]
        hoa_body = HOABody(state_edges_dict)

        hoa_obj = HOA(hoa_header, hoa_body)
        assert self.hoa_obj == hoa_obj
示例#3
0
    def test_hoa(self):
        """Test that the HOA automaton is correct."""
        hoa_header = HOAHeader(
            identifier("v1"),
            Acceptance(Inf(0), identifier("Buchi")),
            nb_states=3,
            start_states={frozenset([0])},
            propositions=(string("a"),),
        )

        state_edges_dict = OrderedDict({})
        state_edges_dict[State(0)] = [
            Edge([1], label=LabelAtom(0)),
            Edge([2], label=~(LabelAtom(0))),
        ]
        state_edges_dict[State(1)] = [
            Edge([1], label=LabelAtom(0), acc_sig=frozenset({0})),
            Edge(
                [2],
                label=~(LabelAtom(0)),
                acc_sig=frozenset({0}),
            ),
        ]
        state_edges_dict[State(2)] = [
            Edge([1], label=LabelAtom(0)),
            Edge([2], label=~LabelAtom(0)),
        ]
        hoa_body = HOABody(state_edges_dict)

        hoa_obj = HOA(hoa_header, hoa_body)
        assert self.hoa_obj == hoa_obj
示例#4
0
    def test_hoa(self):
        """Test that the HOA automaton is correct."""
        hoa_header = HOAHeader(
            identifier("v1"),
            Acceptance(Inf(0), identifier("Buchi")),
            start_states={frozenset([0])},
            propositions=(string("a"), string("b")),
            name=string("GFa | G(b <-> Xa)"),
            properties=[
                identifier("explicit-labels"),
                identifier("trans-labels"),
                identifier("trans-acc"),
            ],
        )

        state_edges_dict = OrderedDict({})
        state_edges_dict[State(0)] = [
            Edge([1], label=TRUE),
            Edge([2], label=LabelAtom(1)),
            Edge([3], label=~(LabelAtom(1))),
        ]
        state_edges_dict[State(1, name=string("GFa"))] = [
            Edge([1], label=LabelAtom(0), acc_sig=frozenset({0})),
            Edge([1], label=~(LabelAtom(0))),
        ]
        state_edges_dict[State(2, name=string("a & G(b <-> Xa)"))] = [
            Edge(
                [2],
                label=LabelAtom(0) & LabelAtom(1),
                acc_sig=frozenset({0}),
            ),
            Edge(
                [3],
                label=LabelAtom(0) & ~LabelAtom(1),
                acc_sig=frozenset({0}),
            ),
        ]
        state_edges_dict[State(3, name=string("!a & G(b <-> Xa)"))] = [
            Edge(
                [2],
                label=~LabelAtom(0) & LabelAtom(1),
                acc_sig=frozenset({0}),
            ),
            Edge(
                [3],
                label=~LabelAtom(0) & ~LabelAtom(1),
                acc_sig=frozenset({0}),
            ),
        ]
        hoa_body = HOABody(state_edges_dict)

        hoa_obj = HOA(hoa_header, hoa_body)
        assert self.hoa_obj == hoa_obj
示例#5
0
 def test_body(self):
     """Test that the HOA body is correct."""
     state_edges_dict = OrderedDict({})
     state_edges_dict[State(0, name=string("a U b"))] = [
         Edge(
             [0],
             LabelAtom(0) & ~LabelAtom(1),
             {0},
         ),
         Edge([1], LabelAtom(1), {0}),
     ]
     state_edges_dict[State(1)] = [Edge([1], TRUE, {1})]
     assert self.hoa_body.state2edges == state_edges_dict
示例#6
0
 def test_hoa_body(self):
     """Test that the HOA body is correct."""
     state_edges_dict = OrderedDict({})
     state_edges_dict[State(0, label=LabelAtom(0), acc_sig=frozenset({0}))] = [
         Edge([0]),
         Edge([1]),
     ]
     state_edges_dict[State(1, label=~LabelAtom(0))] = [
         Edge([0]),
         Edge([1]),
     ]
     hoa_body = HOABody(state_edges_dict)
     assert self.hoa_body == hoa_body
示例#7
0
 def test_hoa_body(self):
     """Test that the HOA body is correct."""
     state_edges_dict = OrderedDict({})
     hoa_body = HOABody(state_edges_dict)
     state_edges_dict[State(0)] = [
         Edge(
             [0],
             label=~self.alias_a & ~self.alias_b,
         ),
         Edge(
             [0],
             label=self.alias_a & ~self.alias_b,
             acc_sig={0},
         ),
         Edge(
             [0],
             label=~self.alias_a & self.alias_b,
             acc_sig={1},
         ),
         Edge(
             [0],
             label=self.alias_a & self.alias_b,
             acc_sig={0, 1},
         ),
     ]
     assert self.hoa_body == hoa_body
示例#8
0
 def test_hoa_body(self):
     """Test that the HOA body is correct."""
     a0, a1 = LabelAtom(0), LabelAtom(1)
     state_edges_dict = OrderedDict({})
     state_edges_dict[State(0)] = [
         Edge(
             [0],
             label=~a0 & ~a1,
         ),
         Edge(
             [0],
             label=a0 & ~a1,
             acc_sig={0},
         ),
         Edge(
             [0],
             label=~a0 & a1,
             acc_sig={1},
         ),
         Edge(
             [0],
             label=a0 & a1,
             acc_sig={0, 1},
         ),
     ]
     hoa_body = HOABody(state_edges_dict)
     assert self.hoa_body == hoa_body
示例#9
0
    def state_name(self, args):
        """Parse the 'state_name' node."""
        non_trees = [arg for arg in args if not isinstance(arg, Tree)]
        kwargs = {
            arg.data: arg.children[0]
            for arg in args if isinstance(arg, Tree)
        }

        if "acc_sig" in kwargs.keys():
            kwargs["acc_sig"] = frozenset({kwargs["acc_sig"]})

        if len(non_trees) == 1:
            return State(index=non_trees[0], **kwargs)
        elif len(non_trees) == 2:
            return State(index=non_trees[0],
                         name=non_trees[1].strip('"'),
                         **kwargs)
        else:
            raise ValueError("Should not be here.")
示例#10
0
 def test_hoa_body(self):
     """Test that the HOA body is correct."""
     state_edges_dict = OrderedDict({})
     state_edges_dict[State(0)] = [
         Edge([0]),
         Edge([0], acc_sig=frozenset({0})),
         Edge([0], acc_sig=frozenset({1})),
         Edge([0], acc_sig=frozenset({0, 1})),
     ]
     hoa_body = HOABody(state_edges_dict)
     assert self.hoa_body == hoa_body