Exemplo n.º 1
0
def test_cyclic_core_with_care_set():
    aut = _fol.Context()
    aut.declare(x=(0, 17))
    # cover = {True}
    s = '(x < 15)'
    f = aut.add_expr(s)
    s = '(x < 15)'
    care_set = aut.add_expr(s)
    cov.cyclic_core(f, care_set, aut)
Exemplo n.º 2
0
def test_cyclic_core_using_robots_example():
    aut, _ = setup_aut(15, 15)
    f = robots_example(aut)
    care_set = aut.true
    xcore, ycore, essential = cov.cyclic_core(f, care_set, aut)
    assert xcore == aut.false, xcore
    n_essential = aut.count(essential)
    k = aut.count(essential)
    assert n_essential == k, (n_essential, k)
    assert n_essential == 7, n_essential
Exemplo n.º 3
0
def test_cyclic_core():
    aut = _fol.Context()
    aut.declare(x=(0, 4), y=(0, 4), z=(0, 4))
    # cover = single prime
    s = '(x < 3) /\ (y = 2)'
    f = aut.add_expr(s)
    care_set = aut.true
    cov.cyclic_core(f, care_set, aut)
    # cover = 2 primes
    s = '(x <= 2) \/ (y <= 2)'
    f = aut.add_expr(s)
    care_set = aut.true
    cov.cyclic_core(f, care_set, aut)
    # no cyclic core
    s = (
        '('
        '(0 <= x  /\  x <= 1) \/ '
        '(0 <= x  /\  x <= 1  /\  1 <= y  /\  y <= 3) \/ '
        '(3 <= x  /\  x <= 4) \/ '
        '(3 <= x  /\  x <= 4  /\  1 <= y  /\  y <= 3) \/ '
        '(0 <= y  /\  y <= 1) \/ '
        '(0 <= y  /\  y <= 1  /\  1 <= x  /\  x <= 3) \/ '
        '(3 <= y  /\  y <= 4) \/ '
        '(3 <= y  /\  y <= 4  /\  1 <= x  /\  x <= 3) '
        ') /\ (0 <= x) /\ (x <= 4) /\ '
        '(0 <= y) /\ (y <= 4) ')
    f = aut.add_expr(s)
    care_set = aut.true
    cov.cyclic_core(f, care_set, aut)
    # no cyclic core
    s = (
        '('
        '(0 <= x  /\  x <= 3  /\  0 <= y  /\  y <= 1) \/ '
        '(1 <= x  /\  x <= 4  /\  0 <= y  /\  y <= 1) \/ '
        '(0 <= x  /\  x <= 3  /\  3 <= y  /\  y <= 4) \/ '
        '(1 <= x  /\  x <= 4  /\  3 <= y  /\  y <= 4) \/ '
        '(0 <= x  /\  x <= 1  /\  0 <= y  /\  y <= 3) \/ '
        '(0 <= x  /\  x <= 1  /\  1 <= y  /\  y <= 4) \/ '
        '(3 <= x  /\  x <= 4  /\  0 <= y  /\  y <= 3) \/ '
        '(3 <= x  /\  x <= 4  /\  1 <= y  /\  y <= 4) '
        ') /\ (0 <= x) /\ (x <= 4) /\ '
        '(0 <= y) /\ (y <= 4) ')
    f = aut.add_expr(s)
    care_set = aut.true
    cov.cyclic_core(f, care_set, aut)
    # has cyclic core
    logger = logging.getLogger('omega.symbolic.cover')
    old_level = logger.getEffectiveLevel()
    # in order to test `_print_cyclic_core`
    logger.setLevel(logging.INFO)
    s = (
        '('
        '(z = 1  /\  y = 0)  \/ '
        '(x = 0  /\  z = 1)  \/ '
        '(y = 1  /\  x = 0)  \/ '
        '(y = 1  /\  z = 0)  \/ '
        '(x = 1  /\  z = 0)  \/ '
        '(x = 1  /\  y = 0) '
        ') /\ (0 <= x  /\  x <= 1  /\ '
        '0 <= y  /\  y <= 1  /\ '
        '0 <= z  /\  z <= 1) ')
    f = aut.add_expr(s)
    care_set = aut.true
    cov.cyclic_core(f, care_set, aut)
    logger.setLevel(old_level)