Example #1
0
def test12():
    print "-- START TEST 12 --"

    #kb1 = PDKB(3, [1,2,3], map(Literal, ['p', 'q', 'r']))
    kb2 = IndexedPDKB(3, [1,2,3], map(Literal, ['p', 'q', 'r']))
    kb3 = IndexedPDKB(3, [1,2,3], map(Literal, ['p', 'q', 'r']))

    l1 = Belief(1, Belief(2, Literal('p')))
    l2 = Possible(1, Belief(2, Literal('p')))
    kb2.expand(set([l1]))
    kb3.expand(set([l2]))

    assert kb2.query_t(Literal('p'))
    assert not kb3.query_t(Literal('p'))

    l1_closed = kt_closure(l1)
    assert l1 in l1_closed
    assert Belief(1, Literal('p')) in l1_closed
    assert Belief(2, Literal('p')) in l1_closed
    assert Literal('p') in l1_closed

    l2_closed = kt_closure(l2)
    fully_closed = []
    for rml in l2_closed:
        fully_closed += kd_closure(rml)
    assert l2 in fully_closed
    assert Possible(1, Possible(2, Literal('p'))) in fully_closed
    assert Possible(1, Literal('p')) in fully_closed

    print "-- END TEST 12 --\n"
Example #2
0
def test6():
    print "-- START TEST 6 --"

    for axiom_system in [KD, KT]:
        AxiomSystem.SYSTEM = axiom_system
        kb1 = PDKB(1, [1,2], map(Literal, ['p', 'q']))
        kb2 = PDKB(1, [1,2], map(Literal, ['p', 'q']))
        test_expand(kb1, kb2)

        # Test that adding an RML already implied does nothing
        kb1 = IndexedPDKB(1, [1,2], map(Literal, ['p', 'q']))
        kb1.expand(set([Belief(1, Literal('p'))]))
        kb2 = kb1.copy()
        kb1.expand(set([Possible(1, Literal('p'))]))
        assert kb1 == kb2

        # Test that adding an RML that implies an existing RML removes that RML
        kb1 = IndexedPDKB(1, [1,2], map(Literal, ['p', 'q']))
        kb1.expand(set([Possible(1, Literal('p'))]))
        old_size = kb1.size()
        kb1.expand(set([Belief(1, Literal('p'))]))
        assert kb1.size() == old_size, "kb1 = %s, old = %s" % (kb1.size(), old_size)

        l1 = Belief(1, Literal('p'))
        l2 = Belief(2, Literal('p'))
        assert not l1.entails_rml(l2)

    for axiom_system in [KD, KT]:
        AxiomSystem.SYSTEM = axiom_system
        kb1 = IndexedPDKB(1, [1,2], map(Literal, ['p', 'q']))
        kb2 = IndexedPDKB(1, [1,2], map(Literal, ['p', 'q']))
        test_expand(kb1, kb2)       

    print "-- END TEST 6 --\n"
Example #3
0
def test7():

    print "-- START TEST 7 --"
    AxiomSystem.SYSTEM = KD
    kb = PDKB(1, [1,2,3], map(Literal, ['p', 'q']))
    test_remove(kb)
        
    kb = IndexedPDKB(1, [1,2,3], map(Literal, ['p', 'q']))
    test_remove(kb)

    AxiomSystem.SYSTEM = KT
    kb = PDKB(1, [1,2,3], map(Literal, ['p', 'q']))
    test_remove_kt(kb)
        
    kb = IndexedPDKB(1, [1,2,3], map(Literal, ['p', 'q']))
    test_remove_kt(kb)
    
    print "-- END TEST 7 --\n"
Example #4
0
def test10():
    print "-- START TEST 10 --"

    for axiom_system in [KD, KT]:
        AxiomSystem.SYSTEM = axiom_system
        kb1 = PDKB(3, [1,2,3,4], map(Literal, ['p', 'q', 'r']))
        kb2 = IndexedPDKB(3, [1,2,3,4], map(Literal, ['p', 'q', 'r']))

        test_consistency_random_kb(kb1, kb2)

    print "-- END TEST 10 --\n"
Example #5
0
def test9():
    print("-- START TEST 9 --")

    for axiom_system in [KD, KT]:
        AxiomSystem.SYSTEM = axiom_system
        kb1 = PDKB(3, [1,2,3], list(map(Literal, ['p', 'q', 'r'])))
        kb2 = IndexedPDKB(3, [1,2,3], list(map(Literal, ['p', 'q', 'r'])))

        test_consistency(kb1, kb2)

    print("-- END TEST 9 --\n")
Example #6
0
def test8():

    print "-- START TEST 8 --"

    for axiom_system in [KD, KT]:
        AxiomSystem.SYSTEM = axiom_system
        kb = PDKB(1, [1,2], map(Literal, ['p', 'q']))
        test_update(kb)

        indexed_kb = IndexedPDKB(1, [1,2], map(Literal, ['p', 'q']))
        test_update(indexed_kb)

    print "-- END TEST 8 --\n"