Exemplo n.º 1
0
def test_exhaustive_consistent():
    # check basic consistency
    assert consistent(var('a'), var('b'), sequential('a', 'b'))

    # see how long a causal loop can be before transitivity stops working
    for i in range(1, 5):
        clauses = [sequential(to_char(i), 'a')] + chain(i)
        assert not consistent(and_(*clauses), exhaustive=True)
Exemplo n.º 2
0
def test_timeline():
    statements = [simultaneous('a', 'b'), sequential('b', 'a')]
    t = timeline(relationships(statements))
    print('timeline: ', t)
    formula = and_(var('a'), var('b'), *(t + statements))
    print('formula: ', formula)
    s = formula.sat()[1]
    if s:
        print('solution: ', [k for k, v in s.items() if v])
    assert not s
Exemplo n.º 3
0
def test_transitivity():
    def trans(s):
        return transitivity(triples(relationships(s)))

    statements = [sequential('a', 'b'),
                  sequential('b', 'c'),
                  sequential('d', 'e')]
    assert len(trans(statements)) == 1

    statements += sequential('a', 'c')
    assert trans(statements)[0].equiv(
        impl(and_(var("a<b"), var("b<c")), var("a<c")))
Exemplo n.º 4
0
def test_occurrence():
    occ = occurrence(relationships([simultaneous('a', 'b')]))
    print('occurrence: ', occ)
    formula = and_(simultaneous('a', 'b'), not_(var('a')), *occ)
    print('formula: ', formula)
    s = formula.sat()[1]
    if s:
        print('solution: ', [k for k, v in s.items() if v])
    assert not s
Exemplo n.º 5
0
def observe(role, event):
    return var(role + ":" + event)
Exemplo n.º 6
0
def test_ordered():
    assert not (ordered('a', 'b')
                & var('a')
                & var('b')
                & ~sequential('a', 'b')
                & ~sequential('b', 'a')).sat()[1]
Exemplo n.º 7
0
def test_consistent():
    # check basic consistency
    assert consistent(var('a'), var('b'), sequential('a', 'b'))