예제 #1
0
def test_synthesis_mealy_all_init():
    sp = grspec_3()
    h = omega_int.synthesize_enumerated_streett(sp)
    assert h is None, 'should be unrealizable'
    sp.env_init = ['y = x']
    h = omega_int.synthesize_enumerated_streett(sp)
    g = synth.strategy2mealy(h, sp)
    # g.save('moore.pdf')
    assert g is not None
    n = len(g)
    assert n == 6, n
예제 #2
0
def test_synthesis_mealy_all_init():
    sp = grspec_3()
    h = omega_int.synthesize_enumerated_streett(sp)
    assert h is None, 'should be unrealizable'
    sp.env_init = ['y = x']
    h = omega_int.synthesize_enumerated_streett(sp)
    g = synth.strategy2mealy(h, sp)
    # g.save('moore.pdf')
    assert g is not None
    n = len(g)
    assert n == 6, n
예제 #3
0
def test_synthesis_moore():
    sp = grspec_2()
    h = omega_int.synthesize_enumerated_streett(sp)
    g = synth.strategy2mealy(h, sp)
    # g.save('moore.pdf')
    assert g is not None
    n = len(g)
    assert n == 26, n
예제 #4
0
def test_synthesis_moore():
    sp = grspec_2()
    h = omega_int.synthesize_enumerated_streett(sp)
    g = synth.strategy2mealy(h, sp)
    # g.save('moore.pdf')
    assert g is not None
    n = len(g)
    assert n == 26, n
예제 #5
0
def test_synthesis_fol():
    sp = grspec_1()
    h = omega_int.synthesize_enumerated_streett(sp)
    g = synth.strategy2mealy(h, sp)
    assert g is not None
    assert len(g.inputs) == 1, g.inputs
    assert 'x' in g.inputs, g.inputs
    dom = g.inputs['x']
    dom_ = set(xrange(5))
    assert dom == dom_, (dom, dom_)
    assert len(g.outputs) == 1, g.outputs
    assert 'y' in g.outputs, g.outputs
    dom = g.outputs['y']
    dom_ = set(xrange(5))
    assert dom == dom_, (dom, dom_)
예제 #6
0
def test_synthesis_fol():
    sp = grspec_1()
    h = omega_int.synthesize_enumerated_streett(sp)
    g = synth.strategy2mealy(h, sp)
    assert g is not None
    assert len(g.inputs) == 1, g.inputs
    assert 'x' in g.inputs, g.inputs
    dom = g.inputs['x']
    dom_ = set(xrange(5))
    assert dom == dom_, (dom, dom_)
    assert len(g.outputs) == 1, g.outputs
    assert 'y' in g.outputs, g.outputs
    dom = g.outputs['y']
    dom_ = set(xrange(5))
    assert dom == dom_, (dom, dom_)
예제 #7
0
def test_synthesis_bool():
    sp = grspec_0()
    h = omega_int.synthesize_enumerated_streett(sp)
    g = synth.strategy2mealy(h, sp)
    # fname = 'mealy.pdf'
    # g.save(fname)
    # pd = nx.drawing.nx_pydot.to_pydot(g)
    # pd.write_pdf(fname)
    assert g is not None
    assert len(g.inputs) == 1, g.inputs
    assert 'x' in g.inputs, g.inputs
    dom = g.inputs['x']
    dom_ = {False, True}
    assert dom == dom_, (dom, dom_)
    assert len(g.outputs) == 1, g.outputs
    assert 'y' in g.outputs, g.outputs
    dom = g.outputs['y']
    dom_ = {False, True}
    assert dom == dom_, (dom, dom_)
    assert len(g) == 5, [g.nodes(data=True), g.edges(data=True)]
예제 #8
0
def test_synthesis_bool():
    sp = grspec_0()
    h = omega_int.synthesize_enumerated_streett(sp)
    g = synth.strategy2mealy(h, sp)
    # fname = 'mealy.pdf'
    # g.save(fname)
    # pd = nx.drawing.nx_pydot.to_pydot(g)
    # pd.write_pdf(fname)
    assert g is not None
    assert len(g.inputs) == 1, g.inputs
    assert 'x' in g.inputs, g.inputs
    dom = g.inputs['x']
    dom_ = {False, True}
    assert dom == dom_, (dom, dom_)
    assert len(g.outputs) == 1, g.outputs
    assert 'y' in g.outputs, g.outputs
    dom = g.outputs['y']
    dom_ = {False, True}
    assert dom == dom_, (dom, dom_)
    assert len(g) == 5, [
        g.nodes(data=True), g.edges(data=True)]
예제 #9
0
def test_synthesis_strings():
    sp = grspec_2()
    h = omega_int.synthesize_enumerated_streett(sp)
    g = synth.strategy2mealy(h, sp)
    assert g is not None
    # outputs
    assert len(g.outputs) == 1, g.outputs
    assert 'y' in g.outputs, g.outputs
    dom = g.outputs['y']
    dom_ = {'a', 'b'}
    assert dom == dom_, (dom, dom_)
    # check simulation
    n = len(g)
    assert n == 4, n
    u = 'Sinit'
    u, r = g.reaction(u, dict(x=0))
    assert r == dict(y='a'), r
    u, r = g.reaction(u, dict(x=2))
    assert r == dict(y='b'), r
    u, r = g.reaction(u, dict(x=1))
    assert r == dict(y='b'), r
    u, r = g.reaction(u, dict(x=0))
    assert r == dict(y='a'), r
예제 #10
0
def test_synthesis_strings():
    sp = grspec_4()
    h = omega_int.synthesize_enumerated_streett(sp)
    g = synth.strategy2mealy(h, sp)
    assert g is not None
    # outputs
    assert len(g.outputs) == 1, g.outputs
    assert 'y' in g.outputs, g.outputs
    dom = g.outputs['y']
    dom_ = {'a', 'b'}
    assert dom == dom_, (dom, dom_)
    # check simulation
    n = len(g)
    assert n == 4, n
    u = 'Sinit'
    u, r = g.reaction(u, dict(x=0))
    assert r == dict(y='a'), r
    u, r = g.reaction(u, dict(x=2))
    assert r == dict(y='b'), r
    u, r = g.reaction(u, dict(x=1))
    assert r == dict(y='b'), r
    u, r = g.reaction(u, dict(x=0))
    assert r == dict(y='a'), r
예제 #11
0
def test_synthesis_cudd():
    sp = grspec_1()
    h = omega_int.synthesize_enumerated_streett(sp)
    assert h is not None
    n = len(h)
    assert n == 16, n
예제 #12
0
def test_synthesis_unrealizable():
    sp = grspec_0()
    sp.sys_prog = ['False']
    h = omega_int.synthesize_enumerated_streett(sp)
    assert h is None, h
예제 #13
0
def test_synthesis_cudd():
    sp = grspec_1()
    h = omega_int.synthesize_enumerated_streett(sp, use_cudd=True)
    n = len(h)
    assert n == 25, n
예제 #14
0
def test_synthesis_unrealizable():
    sp = grspec_0()
    sp.sys_prog = ['False']
    h = omega_int.synthesize_enumerated_streett(sp)
    assert h is None, h
예제 #15
0
def test_synthesis_cudd():
    sp = grspec_1()
    h = omega_int.synthesize_enumerated_streett(sp, use_cudd=True)
    n = len(h)
    assert n == 25, n
예제 #16
0
# we require that the lift eventually satisfies every request
#  (i.e. button being turned on)
psi = spec.GRSpec(env_vars, sys_vars, env_init, sys_init,
                  env_safe, sys_safe, env_prog, sys_prog)
#for i in range(n):
#    psi |= DSL.response(trig=b[i], react=f[i], owner='sys', aux='aux' + str(i+1))
#print(psi.pretty())


psi.qinit = '\A \E'
psi.moore = False
psi.plus_one = False

#ctrl=synth.synthesize(psi, ignore_sys_init=False, solver='gr1c')

strategy = omega_int.synthesize_enumerated_streett(psi)
use_cudd=False

spec=psi
aut = omega_int._grspec_to_automaton(spec)
sym.fill_blanks(aut)
bdd = omega_int._init_bdd(use_cudd)
aut.bdd = bdd
a = aut.build()
bdd.dump("file_a.pdf")

# what has been generated#
print(aut.init['env'])
print(aut.init['sys'])
print(aut.action['sys'])