Ejemplo n.º 1
0
def test_realizable():
    for f, expected in [(LTL('([]<>a) -> ([]<>(a && b))',
                             input_variables={'a': 'boolean'},
                             output_variables={'b': 'boolean'}), True),
                        (LTL('[]<>(a && b)',
                             input_variables={'a': 'boolean'},
                             output_variables={'b': 'boolean'}), False)]:
        yield check_realizable, f, expected
Ejemplo n.º 2
0
class LTL_test:
    def setUp(self):
        self.f = LTL("[](p -> <>q)", input_variables={"p": "boolean"},
                     output_variables={"q": "boolean"})

    def tearDown(self):
        self.f = None

    def test_loads_dumps_id(self):
        # Dump/load identity test: Dumping the result from loading a
        # dump should be identical to the original dump.
        assert self.f.dumps() == LTL.loads(self.f.dumps()).dumps()
Ejemplo n.º 3
0
class LTL_test(object):
    def setUp(self):
        self.f = LTL("[](p -> <>q)",
                     input_variables={"p": "boolean"},
                     output_variables={"q": "boolean"})

    def tearDown(self):
        self.f = None

    def test_loads_dumps_id(self):
        # Dump/load identity test: Dumping the result from loading a
        # dump should be identical to the original dump.
        assert self.f.dumps() == LTL.loads(self.f.dumps()).dumps()
Ejemplo n.º 4
0
 def test_loads_dumps_id(self):
     # Dump/load identity test: Dumping the result from loading a
     # dump should be identical to the original dump.
     assert self.f.dumps() == LTL.loads(self.f.dumps()).dumps()
Ejemplo n.º 5
0
 def setUp(self):
     self.f = LTL("[](p -> <>q)", input_variables={"p": "boolean"},
                  output_variables={"q": "boolean"})
Ejemplo n.º 6
0
#!/usr/bin/env python
from __future__ import print_function
from tulip.spec.form import LTL
from tulip.interfaces import lily

f = LTL('([]<>(!a)) -> ([](a -> <> b) && [](a -> !X b))',
        input_variables={'a': 'boolean'},
        output_variables={'b': 'boolean'})
# Try appending
#
#     && [](!b -> !X b)
#
# to the above LTL formula. The result will not be realizable.

M = lily.synthesize(f)
if M is not None:
    print(M)
else:
    print('Not realizable.')
Ejemplo n.º 7
0
 def test_loads_dumps_id(self):
     # Dump/load identity test: Dumping the result from loading a
     # dump should be identical to the original dump.
     assert self.f.dumps() == LTL.loads(self.f.dumps()).dumps()
Ejemplo n.º 8
0
 def setUp(self):
     self.f = LTL("[](p -> <>q)",
                  input_variables={"p": "boolean"},
                  output_variables={"q": "boolean"})
Ejemplo n.º 9
0
def test_nonbool():
    f = LTL('[](a -> <>b)',
            input_variables={'a': (0, 1)},
            output_variables={'b': 'boolean'})
    M = lily.synthesize(f)
Ejemplo n.º 10
0
#!/usr/bin/env python
"""
Tests for the interface with Lily.
"""
import pytest
from tulip.spec.form import LTL, GRSpec
from tulip.interfaces import lily


@pytest.mark.parametrize('f,expected',
                         [(LTL('([]<>a) -> ([]<>(a && b))',
                               input_variables={'a': 'boolean'},
                               output_variables={'b': 'boolean'}), True),
                          (LTL('[]<>(a && b)',
                               input_variables={'a': 'boolean'},
                               output_variables={'b': 'boolean'}), False)])
def test_realizable(f, expected):
    M = lily.synthesize(f)
    if expected:
        assert M is not None
    else:
        assert M is None


def test_GRSpec():
    f = GRSpec(env_vars={'a'},
               sys_vars={'b'},
               env_init=['!a'],
               sys_init=['!b'],
               env_safety=['a -> X !a', '!a -> X a'],
               sys_prog=['a && b'])