Пример #1
0
def test_clarks_completion():
    comparator = TermComparator()

    input1 = Parser.create_term('Impl(Not(a),b)')
    output1 = Parser.create_clarks_completion(input1)
    expected_output1 = Term('And', [
        Term('BiImpl',
             [Term('Not', [Term('a')]), Term('b')]),
        Term('BiImpl', [Term('a', []), Term('BOT')])
    ])
    assert comparator.terms_are_equal(output1, expected_output1)

    input1 = Parser.create_term('And(Impl(And(a,b),p),Impl(c,p))')
    expected_output_string = 'And(And(And(BiImpl(Or(And(a,b),c),p),BiImpl(a,BOT)),BiImpl(b,BOT)),BiImpl(c,BOT))'
    expected_output1 = Parser.create_term(expected_output_string)
    output1 = Parser.create_clarks_completion(input1)
    assert comparator.terms_are_equal(output1, expected_output1)

    input1 = Parser.create_term(
        'And(And(Impl(And(a,b),p),Impl(c,p)),And(Impl(And(b,c),x),Impl(a,x)))')
    expected_output_string = 'And(And(And(And(BiImpl(Or(And(a,b),c),p),BiImpl(Or(And(b,c),a),x)),BiImpl(a,BOT)),BiImpl(b,BOT)),BiImpl(c,BOT))'
    expected_output1 = Parser.create_term(expected_output_string)
    output1 = Parser.create_clarks_completion(input1)
    assert comparator.terms_are_equal(output1, expected_output1)

    # Not in header-atom -> not allowed
    # input1 = Parser.create_term('And(And(Impl(And(a,b),Not(p)),Impl(c,Not(p))),And(Impl(And(b,c),x),Impl(a,x)))')
    # expected_output_string = 'And(And(And(And(BiImpl(Or(And(a,b),c),Not(p)),BiImpl(Or(And(b,c),a),x)),BiImpl(a,BOT)),BiImpl(b,BOT)),BiImpl(c,BOT))'
    # expected_output1 = Parser.create_term(expected_output_string)
    # output1 = Parser.create_clarks_completion(input1)
    # assert comparator.terms_are_equal(output1, expected_output1)

    input1 = Parser.create_term(
        'And(And(Impl(And(a,Not(b)),p),Impl(c,p)),And(Impl(And(Not(b),c),x),Impl(a,x)))'
    )
    expected_output_string = 'And(And(And(And(BiImpl(Or(And(a,Not(b)),c),p),BiImpl(Or(And(Not(b),c),a),x)),BiImpl(a,BOT)),BiImpl(b,BOT)),BiImpl(c,BOT))'
    expected_output1 = Parser.create_term(expected_output_string)
    output1 = Parser.create_clarks_completion(input1)
    assert comparator.terms_are_equal(output1, expected_output1)

    input1 = Parser.create_term('And(Impl(TOP,p),Impl(And(a,b),BOT))')
    expected_output_string = "And(And(And(BiImpl(TOP,p),BiImpl(And(a,b),BOT)),BiImpl(a,BOT)),BiImpl(b,BOT))"
    expected_output1 = Parser.create_term(expected_output_string)
    output1 = Parser.create_clarks_completion(input1)
    assert comparator.terms_are_equal(output1, expected_output1)
Пример #2
0
def test_cc_2():
    input1 = und(impl('a', 'b'), impl('b', 'a'))
    output1 = Parser.create_clarks_completion(input1)
    input1 = impl(nicht('b'), 'a')
    output1 = Parser.create_clarks_completion(input1)
    x = 0