Beispiel #1
0
def test_rabin_persistence_2():
    aut = trl.default_rabin_automaton()
    aut.declare_variables(x='bool')
    aut.varlist['sys'] = ['x']
    aut.init['sys'] = aut.true
    aut.win['<>[]'] = [aut.add_expr('x'), aut.add_expr(' ~ x')]
    # solve
    zk, yki, xkijr = gr1.solve_rabin_game(aut)
    win_set = zk[-1]
    assert win_set == aut.true, aut.bdd.to_expr(win_set)
    # transducer
    gr1.make_rabin_transducer(zk, yki, xkijr, aut)
    assert action_refined(aut)
    init = aut.init['impl_env']
    s = '(_goal = 0) /\ (_hold = 2)'
    init_ = aut.add_expr(s)
    assert init == init_, aut.bdd.to_expr(init)
    action = aut.action['impl']
    # enumeration.dump_relation(action, aut)
    s = (
        "(_goal = 0) /\ (_goal' = 0) /\ "
        "ite(_hold = 1,"
        "(_hold' = 1) /\ ~ x',"
        "ite(_hold = 0,"
        "(_hold' = 0) /\ x',"
        "(_hold = 2) /\ ("
        "( (_hold' = 0) /\ x' ) \/ "
        "( (_hold' = 1) /\ ~ x' )"
        ") ) )")
    action_ = aut.add_expr(s)
    assert action == action_, aut.bdd.to_expr(action)
Beispiel #2
0
def test_rabin_persistence():
    aut = trl.default_rabin_automaton()
    aut.declare_variables(x='bool')
    aut.varlist['sys'] = ['x']
    aut.init['env'] = aut.add_expr(' ~ x')
    aut.win['<>[]'] = [aut.add_expr('x')]
    # solve
    zk, yki, xkijr = gr1.solve_rabin_game(aut)
    win_set = zk[-1]
    assert win_set == aut.true, aut.bdd.to_expr(win_set)
    # tranducer
    gr1.make_rabin_transducer(zk, yki, xkijr, aut)
    assert action_refined(aut)
    init = aut.init['impl_env']
    s = '(_goal = 0) /\ (_hold = 1) /\ ~ x'
    init_ = aut.add_expr(s)
    assert init == init_, aut.bdd.to_expr(init)
    action = aut.action['impl']
    s = (
        "(_goal = 0) /\ (_goal' = 0) /\ "
        "ite(_hold' = 1, ~ x /\ x', x /\ x')")
    action_ = aut.add_expr(s)
    assert action == action_, aut.bdd.to_expr(action)
    #
    # unrealizable
    aut.win['[]<>'] = [aut.add_expr(' ~ x')]
    zk, _, _ = gr1.solve_rabin_game(aut)
    win_set = zk[-1]
    assert win_set == aut.false, aut.bdd.to_expr(win_set)
Beispiel #3
0
def test_rabin_with_safety_assumption():
    aut = trl.default_rabin_automaton()
    aut.declare_variables(x='bool')
    aut.varlist['env'] = ['x']
    aut.init['env'] = aut.add_expr('x')
    aut.action['env'] = aut.add_expr("x' ")
    aut.action['sys'] = aut.add_expr("x")
    # solve
    zk, yki, xkijr = gr1.solve_rabin_game(aut)
    win_set = zk[-1]
    assert win_set == aut.add_expr('x'), win_set
    # transducer
    gr1.make_rabin_transducer(zk, yki, xkijr, aut)
    assert action_refined(aut)
    init = aut.init['impl_env']
    s = 'x /\ (_goal = 0) /\ (_hold = 1)'
    init_ = aut.add_expr(s)
    assert init == init_, aut.bdd.to_expr(init)
    action = aut.action['impl']
    s = "((_goal = 0) /\ (_goal' = 0) /\ (_hold' = 0) /\ x)"
    action_ = aut.add_expr(s)
    assert action == action_, aut.bdd.to_expr(action)
    #
    # negate action to make unrealizable
    aut.action['sys'] = aut.add_expr(' ~ x')
    # solve
    zk, yki, xkijr = gr1.solve_rabin_game(aut)
    win_set = zk[-1]
    assert win_set == aut.false, aut.bdd.to_expr(win_set)
    with assert_raises(AssertionError):
        gr1.make_rabin_transducer(zk, yki, xkijr, aut)
Beispiel #4
0
def test_rabin_counter():
    aut = trl.default_rabin_automaton()
    aut.declare_variables(x='bool')
    aut.varlist['sys'] = ['x']
    aut.plus_one = False
    aut.qinit = '\A \A'
    aut.action['sys'] = aut.add_expr("x => ~ x' ")
    aut.win['[]<>'] = [aut.add_expr('x')]
    # solve
    zk, yki, xkijr = gr1.solve_rabin_game(aut)
    win_set = zk[-1]
    assert win_set == aut.bdd.true, aut.bdd.to_expr(win_set)
    # transducer
    gr1.make_rabin_transducer(zk, yki, xkijr, aut)
    assert action_refined(aut)
    init = aut.init['impl_env']
    s = '(_goal = 0) /\ (_hold = 1)'
    init_ = aut.add_expr(s)
    assert init == init_, aut.bdd.to_expr(init)
    action = aut.action['impl']
    # regression
    s = (
        "(_goal = 0) /\ (_goal' = 0) /\ "
        "(_hold' = 0) /\ "
        "ite(_hold = 0, x <=> ~ x', x => ~ x')")
    action_ = aut.add_expr(s)
    assert action == action_, aut.bdd.to_expr(action)
Beispiel #5
0
def trivial_winning_set(aut_streett):
    """Return set of trivially winning nodes for Streett(1).

    @return: `(trivial, aut_streett)` where:
        - `trivial`: node in `aut_streett.bdd`
        - `aut_streett`: `temporal.Automaton`
    """
    aut_rabin = trl.default_rabin_automaton()
    aut_rabin.bdd = aut_streett.bdd
    aut_rabin.vars = copy.deepcopy(aut_streett.vars)
    # swap vars and actions
    aut_rabin.varlist['env'] = list(aut_streett.varlist['sys'])
    aut_rabin.varlist['sys'] = list(aut_streett.varlist['env'])
    aut_rabin.action['env'] = aut_streett.action['sys']
    aut_rabin.action['sys'] = aut_streett.action['env']
    aut_rabin.init['env'] = aut_streett.init['sys']
    aut_rabin.init['sys'] = aut_streett.init['env']
    win = [~ w for w in aut_streett.win['<>[]']]
    aut_rabin.win['[]<>'] = win
    # needed because we changed bdd
    aut_rabin.win['<>[]'] = [aut_rabin.true]
    # solve
    win_streett, _, _ = solve_streett_game(aut_streett)
    zk, _, _ = solve_rabin_game(aut_rabin)
    win_rabin = zk[-1]
    # find trivial win set
    # win_rabin_ = _copy_bdd(win_rabin,
    #                        aut_rabin.bdd, aut_streett.bdd)
    trivial = win_streett & ~ win_rabin
    return trivial, aut_streett
Beispiel #6
0
def trivial_winning_set(aut_streett):
    """Return set of trivially winning nodes for Streett(1).

    @return: `(trivial, aut_streett)` where:
        - `trivial`: node in `aut_streett.bdd`
        - `aut_streett`: `temporal.Automaton`
    """
    aut_rabin = trl.default_rabin_automaton()
    aut_rabin.bdd = aut_streett.bdd
    aut_rabin.vars = copy.deepcopy(aut_streett.vars)
    # swap vars and actions
    aut_rabin.varlist['env'] = list(aut_streett.varlist['sys'])
    aut_rabin.varlist['sys'] = list(aut_streett.varlist['env'])
    aut_rabin.action['env'] = aut_streett.action['sys']
    aut_rabin.action['sys'] = aut_streett.action['env']
    aut_rabin.init['env'] = aut_streett.init['sys']
    aut_rabin.init['sys'] = aut_streett.init['env']
    win = [~ w for w in aut_streett.win['<>[]']]
    aut_rabin.win['[]<>'] = win
    # needed because we changed bdd
    aut_rabin.win['<>[]'] = [aut_rabin.true]
    # solve
    win_streett, _, _ = solve_streett_game(aut_streett)
    zk, _, _ = solve_rabin_game(aut_rabin)
    win_rabin = zk[-1]
    # find trivial win set
    # win_rabin_ = _copy_bdd(win_rabin,
    #                        aut_rabin.bdd, aut_streett.bdd)
    trivial = win_streett & ~ win_rabin
    return trivial, aut_streett
Beispiel #7
0
def test_rabin_2_goals():
    aut = trl.default_rabin_automaton()
    aut.declare_variables(x='bool', y='bool')
    aut.varlist = dict(env=['x'], sys=['y'])
    aut.win['[]<>'] = [aut.add_expr('x => y')]
    # solve
    zk, _, _ = gr1.solve_rabin_game(aut)
    win_set = zk[-1]
    assert win_set == aut.true, aut.bdd.to_expr(win_set)
    #
    # unrealizable
    aut.win['<>[]'] = [aut.add_expr(' ~ y')]
    zk, _, _ = gr1.solve_rabin_game(aut)
    win_set = zk[-1]
    assert win_set == aut.false, aut.bdd.to_expr(win_set)
    #
    # realizable again
    aut.win['<>[]'] = [aut.add_expr('y')]
    zk, _, _ = gr1.solve_rabin_game(aut)
    win_set = zk[-1]
    assert win_set == aut.true, aut.bdd.to_expr(win_set)
    #
    # unrealizable
    aut.win['[]<>'] = [aut.add_expr(s) for s in ['x => y', ' ~ y']]
    zk, _, _ = gr1.solve_rabin_game(aut)
    win_set = zk[-1]
    assert win_set == aut.false, aut.bdd.to_expr(win_set)
Beispiel #8
0
def test_rabin_trivial_loop():
    a = trl.default_rabin_automaton()
    a.acceptance = 'Rabin(1)'
    a.declare_variables(x='bool')
    a.varlist['sys'] = ['x']
    # solve
    assert len(a.win['<>[]']) == 1
    assert len(a.win['[]<>']) == 1
    zk, yki, xkijr = gr1.solve_rabin_game(a)
    assert zk[-1] == a.bdd.true, zk
    # transducer
    gr1.make_rabin_transducer(zk, yki, xkijr, a)
    # vars
    assert '_goal' in a.vars, a.vars
    vt = a.vars['_goal']['type']
    assert vt == 'int', vt
    dom = a.vars['_goal']['dom']
    assert dom == (0, 0), dom
    assert '_hold' in a.vars, a.vars
    vt = a.vars['_hold']['type']
    assert vt == 'int', vt
    dom = a.vars['_hold']['dom']
    assert dom == (0, 1), dom
    assert 'x' in a.vars, a.vars
    # init
    init = a.init['impl_env']
    init_ = a.add_expr('(_goal = 0) /\ (_hold = 1)')
    assert init == init_, a.bdd.to_expr(init)
    # action
    action = a.action['impl']
    s = ("(_goal = 0) /\ (_goal' = 0) /\ " "(_hold' = 0)")
    action_ = a.add_expr(s)
    assert action == action_, a.bdd.to_expr(action)
Beispiel #9
0
def test_rabin_persistence_2():
    aut = trl.default_rabin_automaton()
    aut.declare_variables(x='bool')
    aut.varlist['sys'] = ['x']
    aut.init['sys'] = aut.true
    aut.win['<>[]'] = [aut.add_expr('x'), aut.add_expr(' ~ x')]
    # solve
    zk, yki, xkijr = gr1.solve_rabin_game(aut)
    win_set = zk[-1]
    assert win_set == aut.true, aut.bdd.to_expr(win_set)
    # transducer
    gr1.make_rabin_transducer(zk, yki, xkijr, aut)
    assert action_refined(aut)
    init = aut.init['impl_env']
    s = '(_goal = 0) /\ (_hold = 2)'
    init_ = aut.add_expr(s)
    assert init == init_, aut.bdd.to_expr(init)
    action = aut.action['impl']
    # enumeration.dump_relation(action, aut)
    s = ("(_goal = 0) /\ (_goal' = 0) /\ "
         "ite(_hold = 1,"
         "(_hold' = 1) /\ ~ x',"
         "ite(_hold = 0,"
         "(_hold' = 0) /\ x',"
         "(_hold = 2) /\ ("
         "( (_hold' = 0) /\ x' ) \/ "
         "( (_hold' = 1) /\ ~ x' )"
         ") ) )")
    action_ = aut.add_expr(s)
    assert action == action_, aut.bdd.to_expr(action)
Beispiel #10
0
def test_rabin_with_safety_assumption():
    aut = trl.default_rabin_automaton()
    aut.declare_variables(x='bool')
    aut.varlist['env'] = ['x']
    aut.init['env'] = aut.add_expr('x')
    aut.action['env'] = aut.add_expr("x' ")
    aut.action['sys'] = aut.add_expr("x")
    # solve
    zk, yki, xkijr = gr1.solve_rabin_game(aut)
    win_set = zk[-1]
    assert win_set == aut.add_expr('x'), win_set
    # transducer
    gr1.make_rabin_transducer(zk, yki, xkijr, aut)
    assert action_refined(aut)
    init = aut.init['impl_env']
    s = 'x /\ (_goal = 0) /\ (_hold = 1)'
    init_ = aut.add_expr(s)
    assert init == init_, aut.bdd.to_expr(init)
    action = aut.action['impl']
    s = "((_goal = 0) /\ (_goal' = 0) /\ (_hold' = 0) /\ x)"
    action_ = aut.add_expr(s)
    assert action == action_, aut.bdd.to_expr(action)
    #
    # negate action to make unrealizable
    aut.action['sys'] = aut.add_expr(' ~ x')
    # solve
    zk, yki, xkijr = gr1.solve_rabin_game(aut)
    win_set = zk[-1]
    assert win_set == aut.false, aut.bdd.to_expr(win_set)
    with assert_raises(AssertionError):
        gr1.make_rabin_transducer(zk, yki, xkijr, aut)
Beispiel #11
0
def test_rabin_counter():
    aut = trl.default_rabin_automaton()
    aut.declare_variables(x='bool')
    aut.varlist['sys'] = ['x']
    aut.plus_one = False
    aut.qinit = '\A \A'
    aut.action['sys'] = aut.add_expr("x => ~ x' ")
    aut.win['[]<>'] = [aut.add_expr('x')]
    # solve
    zk, yki, xkijr = gr1.solve_rabin_game(aut)
    win_set = zk[-1]
    assert win_set == aut.bdd.true, aut.bdd.to_expr(win_set)
    # transducer
    gr1.make_rabin_transducer(zk, yki, xkijr, aut)
    assert action_refined(aut)
    init = aut.init['impl_env']
    s = '(_goal = 0) /\ (_hold = 1)'
    init_ = aut.add_expr(s)
    assert init == init_, aut.bdd.to_expr(init)
    action = aut.action['impl']
    # regression
    s = ("(_goal = 0) /\ (_goal' = 0) /\ "
         "(_hold' = 0) /\ "
         "ite(_hold = 0, x <=> ~ x', x => ~ x')")
    action_ = aut.add_expr(s)
    assert action == action_, aut.bdd.to_expr(action)
Beispiel #12
0
def test_rabin_persistence():
    aut = trl.default_rabin_automaton()
    aut.declare_variables(x='bool')
    aut.varlist['sys'] = ['x']
    aut.init['env'] = aut.add_expr(' ~ x')
    aut.win['<>[]'] = [aut.add_expr('x')]
    # solve
    zk, yki, xkijr = gr1.solve_rabin_game(aut)
    win_set = zk[-1]
    assert win_set == aut.true, aut.bdd.to_expr(win_set)
    # tranducer
    gr1.make_rabin_transducer(zk, yki, xkijr, aut)
    assert action_refined(aut)
    init = aut.init['impl_env']
    s = '(_goal = 0) /\ (_hold = 1) /\ ~ x'
    init_ = aut.add_expr(s)
    assert init == init_, aut.bdd.to_expr(init)
    action = aut.action['impl']
    s = ("(_goal = 0) /\ (_goal' = 0) /\ "
         "ite(_hold' = 1, ~ x /\ x', x /\ x')")
    action_ = aut.add_expr(s)
    assert action == action_, aut.bdd.to_expr(action)
    #
    # unrealizable
    aut.win['[]<>'] = [aut.add_expr(' ~ x')]
    zk, _, _ = gr1.solve_rabin_game(aut)
    win_set = zk[-1]
    assert win_set == aut.false, aut.bdd.to_expr(win_set)
Beispiel #13
0
def test_rabin_2_goals():
    aut = trl.default_rabin_automaton()
    aut.declare_variables(x='bool', y='bool')
    aut.varlist = dict(env=['x'], sys=['y'])
    aut.win['[]<>'] = [aut.add_expr('x => y')]
    # solve
    zk, _, _ = gr1.solve_rabin_game(aut)
    win_set = zk[-1]
    assert win_set == aut.true, aut.bdd.to_expr(win_set)
    #
    # unrealizable
    aut.win['<>[]'] = [aut.add_expr(' ~ y')]
    zk, _, _ = gr1.solve_rabin_game(aut)
    win_set = zk[-1]
    assert win_set == aut.false, aut.bdd.to_expr(win_set)
    #
    # realizable again
    aut.win['<>[]'] = [aut.add_expr('y')]
    zk, _, _ = gr1.solve_rabin_game(aut)
    win_set = zk[-1]
    assert win_set == aut.true, aut.bdd.to_expr(win_set)
    #
    # unrealizable
    aut.win['[]<>'] = [aut.add_expr(s) for s in ['x => y', ' ~ y']]
    zk, _, _ = gr1.solve_rabin_game(aut)
    win_set = zk[-1]
    assert win_set == aut.false, aut.bdd.to_expr(win_set)
Beispiel #14
0
def test_rabin_trivial_loop():
    a = trl.default_rabin_automaton()
    a.acceptance = 'Rabin(1)'
    a.declare_variables(x='bool')
    a.varlist['sys'] = ['x']
    # solve
    assert len(a.win['<>[]']) == 1
    assert len(a.win['[]<>']) == 1
    zk, yki, xkijr = gr1.solve_rabin_game(a)
    assert zk[-1] == a.bdd.true, zk
    # transducer
    gr1.make_rabin_transducer(zk, yki, xkijr, a)
    # vars
    assert '_goal' in a.vars, a.vars
    vt = a.vars['_goal']['type']
    assert vt == 'int', vt
    dom = a.vars['_goal']['dom']
    assert dom == (0, 0), dom
    assert '_hold' in a.vars, a.vars
    vt = a.vars['_hold']['type']
    assert vt == 'int', vt
    dom = a.vars['_hold']['dom']
    assert dom == (0, 1), dom
    assert 'x' in a.vars, a.vars
    # init
    init = a.init['impl_env']
    init_ = a.add_expr('(_goal = 0) /\ (_hold = 1)')
    assert init == init_, a.bdd.to_expr(init)
    # action
    action = a.action['impl']
    s = (
        "(_goal = 0) /\ (_goal' = 0) /\ "
        "(_hold' = 0)")
    action_ = a.add_expr(s)
    assert action == action_, a.bdd.to_expr(action)
Beispiel #15
0
def test_rabin_goal():
    aut = trl.default_rabin_automaton()
    aut.declare_variables(x='bool')
    aut.varlist = dict(env=['x'], sys=list())
    aut.win['[]<>'] = [aut.add_expr('x')]
    # solve
    zk, yki, xkijr = gr1.solve_rabin_game(aut)
    win_set = zk[-1]
    assert win_set == aut.false, aut.bdd.to_expr(win_set)
Beispiel #16
0
def test_rabin_goal():
    aut = trl.default_rabin_automaton()
    aut.declare_variables(x='bool')
    aut.varlist = dict(env=['x'], sys=list())
    aut.win['[]<>'] = [aut.add_expr('x')]
    # solve
    zk, yki, xkijr = gr1.solve_rabin_game(aut)
    win_set = zk[-1]
    assert win_set == aut.false, aut.bdd.to_expr(win_set)
Beispiel #17
0
def test_streett_with_liveness_assumption():
    aut = trl.default_streett_automaton()
    aut.declare_variables(x='bool', y=(0, 2))
    aut.varlist = dict(env=['x'], sys=['y'])
    aut.init['env'] = aut.add_expr('y < 2')
    aut.action['sys'] = aut.add_expr(
        """
        /\ ( ((y = 0) /\ ~ x) => (y' = 0) )
        /\ ((y = 0) => (y' < 2))
        /\ ((y = 1) => (y' = 0))
        /\ ((y = 2) => FALSE)
        /\ y \in 0..2
        """)
    aut.win['<>[]'] = [aut.add_expr(' ~ x')]
    aut.win['[]<>'] = [aut.add_expr('y = 1')]
    # solve
    z, yij, xijk = gr1.solve_streett_game(aut)
    z_ = aut.add_expr('y < 2')
    e = aut.bdd.to_expr(z)
    e_ = aut.bdd.to_expr(z_)
    assert z == z_, (e, e_)
    # transducer
    gr1.make_streett_transducer(z, yij, xijk, aut)
    assert action_refined(aut)
    init = aut.init['impl_env']
    assert init == aut.add_expr('(y < 2) /\ (_goal = 0)'), aut.bdd.to_expr(init)
    action = aut.action['impl']
    s = (
        "( (y = 0) => ite(x, (y' = 1), (y' = 0)) ) /\ "
        "( (y = 1) => (y' = 0) ) /\ "
        "( (_goal = 0) /\ (_goal' = 0) ) /\ "
        "( (y /= 2) /\ (y /= 3) )")
    action_ = aut.add_expr(s)
    sat = list(aut.bdd.pick_iter(action))
    sys_action = aut.action['sys']
    sys_action = gr1._copy_bdd(sys_action, aut.bdd, aut.bdd)
    u = aut.apply('=>', action, sys_action)
    assert u == aut.bdd.true, u
    assert action == action_, (action, action_, pprint.pprint(sat))
    #
    # test complement
    b = trl.default_rabin_automaton()
    b.acceptance = 'Rabin(1)'
    b.declare_variables(x='bool', y=(0, 2))
    b.varlist = dict(env=['y'], sys=['x'])
    b.action['env'] = gr1._copy_bdd(aut.action['sys'], aut.bdd, b.bdd)
    b.win['<>[]'] = [b.add_expr('y /= 1')]
    b.win['[]<>'] = [b.add_expr('x')]
    zk, yki, xkijr = gr1.solve_rabin_game(b)
    rabin_win_set = zk[-1]
    bdd = b.bdd
    streett_win_set = gr1._copy_bdd(z, aut.bdd, bdd)
    assert rabin_win_set == bdd.apply('not', streett_win_set)
    with assert_raises(AssertionError):
        gr1.make_rabin_transducer(zk, yki, xkijr, b)
Beispiel #18
0
def test_streett_with_liveness_assumption():
    aut = trl.default_streett_automaton()
    aut.declare_variables(x='bool', y=(0, 2))
    aut.varlist = dict(env=['x'], sys=['y'])
    aut.init['env'] = aut.add_expr('y < 2')
    aut.action['sys'] = aut.add_expr("""
        /\ ( ((y = 0) /\ ~ x) => (y' = 0) )
        /\ ((y = 0) => (y' < 2))
        /\ ((y = 1) => (y' = 0))
        /\ ((y = 2) => FALSE)
        /\ y \in 0..2
        """)
    aut.win['<>[]'] = [aut.add_expr(' ~ x')]
    aut.win['[]<>'] = [aut.add_expr('y = 1')]
    # solve
    z, yij, xijk = gr1.solve_streett_game(aut)
    z_ = aut.add_expr('y < 2')
    e = aut.bdd.to_expr(z)
    e_ = aut.bdd.to_expr(z_)
    assert z == z_, (e, e_)
    # transducer
    gr1.make_streett_transducer(z, yij, xijk, aut)
    assert action_refined(aut)
    init = aut.init['impl_env']
    assert init == aut.add_expr('(y < 2) /\ (_goal = 0)'), aut.bdd.to_expr(
        init)
    action = aut.action['impl']
    s = ("( (y = 0) => ite(x, (y' = 1), (y' = 0)) ) /\ "
         "( (y = 1) => (y' = 0) ) /\ "
         "( (_goal = 0) /\ (_goal' = 0) ) /\ "
         "( (y /= 2) /\ (y /= 3) )")
    action_ = aut.add_expr(s)
    sat = list(aut.bdd.pick_iter(action))
    sys_action = aut.action['sys']
    sys_action = gr1._copy_bdd(sys_action, aut.bdd, aut.bdd)
    u = aut.apply('=>', action, sys_action)
    assert u == aut.bdd.true, u
    assert action == action_, (action, action_, pprint.pprint(sat))
    #
    # test complement
    b = trl.default_rabin_automaton()
    b.acceptance = 'Rabin(1)'
    b.declare_variables(x='bool', y=(0, 2))
    b.varlist = dict(env=['y'], sys=['x'])
    b.action['env'] = gr1._copy_bdd(aut.action['sys'], aut.bdd, b.bdd)
    b.win['<>[]'] = [b.add_expr('y /= 1')]
    b.win['[]<>'] = [b.add_expr('x')]
    zk, yki, xkijr = gr1.solve_rabin_game(b)
    rabin_win_set = zk[-1]
    bdd = b.bdd
    streett_win_set = gr1._copy_bdd(z, aut.bdd, bdd)
    assert rabin_win_set == bdd.apply('not', streett_win_set)
    with assert_raises(AssertionError):
        gr1.make_rabin_transducer(zk, yki, xkijr, b)
Beispiel #19
0
def test_rabin_always_x():
    # always x
    aut = trl.default_rabin_automaton()
    aut.declare_variables(x='bool')
    aut.varlist['sys'] = ['x']
    aut.acceptance = 'Rabin(1)'
    aut.action['sys'] = aut.add_expr("x' ")
    # solve
    zk, yki, xkijr = gr1.solve_rabin_game(aut)
    win_set = zk[-1]
    assert win_set == aut.bdd.true, win_set
    # transducer
    gr1.make_rabin_transducer(zk, yki, xkijr, aut)
    # init
    init = aut.init['impl_env']
    s = '(_goal = 0) /\ (_hold = 1)'
    init_ = aut.add_expr(s)
    assert init == init_, aut.bdd.to_expr(init)
    # action
    action = aut.action['impl']
    s = (
        "(_goal = 0) /\ (_goal' = 0) /\ "
        "(_hold' = 0) /\ "
        "x' ")
    action_ = aut.add_expr(s)
    assert action == action_, aut.bdd.to_expr(action)
    #
    # always ~ x
    aut.init['env'] = aut.add_expr(' ~ x')
    aut.action['sys'] = aut.add_expr(' ~ x')
    # solve
    zk, yki, xkijr = gr1.solve_rabin_game(aut)
    win_set = zk[-1]
    win_set_ = aut.add_expr(' ~ x')
    assert win_set == win_set_, aut.bdd.to_expr(win_set)
    # transducer
    gr1.make_rabin_transducer(zk, yki, xkijr, aut)
    assert action_refined(aut)
    init = aut.init['impl_env']
    s = (
        '(_goal = 0) /\ (_hold = 1) /\ '
        ' ~ x')
    init_ = aut.add_expr(s)
    assert init == init_, aut.bdd.to_expr(init)
    action = aut.action['impl']
    s = (
        "(_goal = 0) /\ (_goal' = 0) /\ "
        "(_hold' = 0) /\ "
        " ~ x /\ ~ x'")
    action_ = aut.add_expr(s)
    assert action == action_, aut.bdd.to_expr(action)
Beispiel #20
0
def test_rabin_always_x():
    # always x
    aut = trl.default_rabin_automaton()
    aut.declare_variables(x='bool')
    aut.varlist['sys'] = ['x']
    aut.acceptance = 'Rabin(1)'
    aut.action['sys'] = aut.add_expr("x' ")
    # solve
    zk, yki, xkijr = gr1.solve_rabin_game(aut)
    win_set = zk[-1]
    assert win_set == aut.bdd.true, win_set
    # transducer
    gr1.make_rabin_transducer(zk, yki, xkijr, aut)
    # init
    init = aut.init['impl_env']
    s = '(_goal = 0) /\ (_hold = 1)'
    init_ = aut.add_expr(s)
    assert init == init_, aut.bdd.to_expr(init)
    # action
    action = aut.action['impl']
    s = ("(_goal = 0) /\ (_goal' = 0) /\ " "(_hold' = 0) /\ " "x' ")
    action_ = aut.add_expr(s)
    assert action == action_, aut.bdd.to_expr(action)
    #
    # always ~ x
    aut.init['env'] = aut.add_expr(' ~ x')
    aut.action['sys'] = aut.add_expr(' ~ x')
    # solve
    zk, yki, xkijr = gr1.solve_rabin_game(aut)
    win_set = zk[-1]
    win_set_ = aut.add_expr(' ~ x')
    assert win_set == win_set_, aut.bdd.to_expr(win_set)
    # transducer
    gr1.make_rabin_transducer(zk, yki, xkijr, aut)
    assert action_refined(aut)
    init = aut.init['impl_env']
    s = ('(_goal = 0) /\ (_hold = 1) /\ ' ' ~ x')
    init_ = aut.add_expr(s)
    assert init == init_, aut.bdd.to_expr(init)
    action = aut.action['impl']
    s = ("(_goal = 0) /\ (_goal' = 0) /\ " "(_hold' = 0) /\ " " ~ x /\ ~ x'")
    action_ = aut.add_expr(s)
    assert action == action_, aut.bdd.to_expr(action)