def test_action_to_steps(): aut = symbolic.Automaton() aut.declare_variables(x='bool', y=(0, 17)) aut.varlist['env'] = ['x'] aut.varlist['sys'] = ['y'] keys = ('x', 'y') aut.init['env'] = aut.add_expr('x /\ (y = 1)') aut.action['sys'] = aut.add_expr("y' /= y") aut.action['env'] = aut.true aut.qinit = '\A \A' aut.moore = True aut.build() g = enum.action_to_steps(aut, qinit=aut.qinit) # 36 states reachable, but should enumerate fewer assert len(g) == 4, g.nodes() # these are state projections (partial assignments) # a state assigns to all variable names # (infinitely many) states = { enum._node_tuple(d, keys) for u, d in g.nodes(data=True)} assert tuple([True, 1]) in states, states r = {p for p in states if p[0] is True} assert len(r) == 2 r = {p for p in states if p[0] is False} assert len(r) == 2
def test_action_to_steps(): aut = symbolic.Automaton() aut.declare_variables(x='bool', y=(0, 17)) env = 'env_foo' sys = 'sys_bar' aut.varlist[env] = ['x'] aut.varlist[sys] = ['y'] keys = ('x', 'y') aut.init[env] = aut.add_expr('x /\ (y = 1)') aut.init[sys] = aut.true aut.action[env] = aut.true aut.action[sys] = aut.add_expr("y' /= y") aut.win['<>[]'] = aut.bdds_from('x') aut.win['[]<>'] = aut.bdds_from('y != 1') aut.qinit = '\A \A' aut.moore = True aut.prime_varlists() g = enum.action_to_steps(aut, env=env, sys=sys, qinit=aut.qinit) # 36 states reachable, but should enumerate fewer assert len(g) == 4, g.nodes() # these are state projections (partial assignments) # a state assigns to all variable names # (infinitely many) states = {enum._node_tuple(d, keys) for u, d in g.nodes(data=True)} assert tuple([True, 1]) in states, states r = {p for p in states if p[0] is True} assert len(r) == 2 r = {p for p in states if p[0] is False} assert len(r) == 2
def test_node_tuple(): d = dict(a=10, b='g', gandalf=True) keys = ('b', 'gandalf', 'a') r = enum._node_tuple(d, keys) r_ = ('g', True, 10) assert r == r_, r