コード例 #1
0
ファイル: contracts.py プロジェクト: johnyf/contract_maker
def test_post():
    aut = Automaton()
    aut.players = dict(alice=0, bob=1)
    aut.vars = dict(x=dict(type='bool', owner='alice'),
                    _i=dict(type='saturating', dom=(0, 1), owner='alice'))
    aut.action['alice'] = ["x <-> !x'"]
    fill_blanks(aut)
    print(aut)
    aut = aut.build()
    u = aut.add_expr('x & (_i = 0)')
    v = image(u, aut, pre=False)
    enum.print_nodes(v, aut.vars, aut.bdd)
コード例 #2
0
def test_post():
    aut = Automaton()
    aut.players = dict(alice=0, bob=1)
    aut.vars = dict(x=dict(type='bool', owner='alice'),
                    _i=dict(type='saturating', dom=(0, 1), owner='alice'))
    aut.action['alice'] = ["x <-> !x'"]
    fill_blanks(aut)
    print(aut)
    aut = aut.build()
    u = aut.add_expr('x & (_i = 0)')
    v = image(u, aut, pre=False)
    enum.print_nodes(v, aut.vars, aut.bdd)
コード例 #3
0
ファイル: contracts.py プロジェクト: johnyf/contract_maker
def make_assumptions(original_aut):
    aut = copy.copy(original_aut)
    z = closure(aut)
    # print('Cooperative winning set:')
    # enum.print_nodes(z, aut.vars, aut.bdd)
    assert z != aut.bdd.false, 'unsatisfiable'
    require_closure(z, aut)
    specs = nested_specs(z, aut)
    pprint.pprint(specs)
    bdd = aut.bdd
    #
    # uncomment to enumerate constructed assumptions
    #
    return
    print('------------------')
    for c in specs['car_a'][1]:
        j = c[0]
        print('nested spec for player {j}:'.format(j=j))
        print(c)
        print('P_m:')
        u = c[1]
        enum.print_nodes(u, aut.vars, bdd)
        print('Q_m:')
        v = c[2]
        enum.print_nodes(v, aut.vars, bdd)
        print('P_m & ! Q_m:')
        u = aut.bdd.apply('diff', u, v)
        enum.print_nodes(u, aut.vars, bdd)
        print('assumptions: eta = xi')
        assumptions = c[3]
        if not assumptions:
            continue
        for j, k, u in assumptions:
            enum.print_nodes(u, aut.vars, bdd)
コード例 #4
0
def make_assumptions(original_aut):
    aut = copy.copy(original_aut)
    z = closure(aut)
    # print('Cooperative winning set:')
    # enum.print_nodes(z, aut.vars, aut.bdd)
    assert z != aut.bdd.false, 'unsatisfiable'
    require_closure(z, aut)
    specs = nested_specs(z, aut)
    pprint.pprint(specs)
    bdd = aut.bdd
    #
    # uncomment to enumerate constructed assumptions
    #
    return
    print('------------------')
    for c in specs['car_a'][1]:
        j = c[0]
        print('nested spec for player {j}:'.format(j=j))
        print(c)
        print('P_m:')
        u = c[1]
        enum.print_nodes(u, aut.vars, bdd)
        print('Q_m:')
        v = c[2]
        enum.print_nodes(v, aut.vars, bdd)
        print('P_m & ! Q_m:')
        u = aut.bdd.apply('diff', u, v)
        enum.print_nodes(u, aut.vars, bdd)
        print('assumptions: eta = xi')
        assumptions = c[3]
        if not assumptions:
            continue
        for j, k, u in assumptions:
            enum.print_nodes(u, aut.vars, bdd)