Пример #1
0
def resolutionKB():
    nP = Arguments("P", negative=True)

    nQ = Arguments("Q", negative=True)

    Sentence1 = CnfSentence([nP, Q_symbol])
    Sentence2 = CnfSentence([P_symbol])

    return [Sentence1, Sentence2]
Пример #2
0
def createCnfSentence(people, isLiar=False):
    argument1 = literals[people[0]].getNegativeArg()
    sentences = []
    for p in people[1:]:
        lit = literals[p]
        sentences.append(CnfSentence([argument1, lit if not isLiar else lit.getNegativeArg()]))
    sourcePeople = literals[people[0]]
    if not isLiar:
        p2, p3 = literals[people[1]].getNegativeArg(), literals[people[2]].getNegativeArg()
        sentences.append(CnfSentence([sourcePeople, p2, p3]))
    else:
        p2, p3 = literals[people[1]], literals[people[2]]
        sentences.append(CnfSentence([sourcePeople, p2, p3]))
    return sentences
Пример #3
0
def resolutionKB():
    sentences = []
    sentences.append(CnfSentence([P_1_1.getNegativeArg()]))

    sentences.append(CnfSentence([B_1_1.getNegativeArg(), P_1_2, P_2_1]))

    sentences.append(CnfSentence([P_1_2.getNegativeArg(), B_1_1]))

    sentences.append(CnfSentence([P_2_1.getNegativeArg(), B_1_1]))

    sentences.append(CnfSentence([B_2_1.getNegativeArg(), P_1_1, P_2_2, P_3_1]))

    sentences.append(CnfSentence([B_2_1, P_1_1.getNegativeArg()]))

    sentences.append(CnfSentence([B_2_1, P_2_2.getNegativeArg()]))

    sentences.append(CnfSentence([B_2_1, P_3_1.getNegativeArg()]))

    sentences.append(CnfSentence([B_1_1.getNegativeArg()]))

    sentences.append(CnfSentence([B_2_1]))

    return sentences
Пример #4
0
def resolutionKBPartb():
    """
    :return: CNF sentences knowledge base of part b
    """
    cnfsentences = list()
    cnfsentences.append(
        CnfSentence([Amy.getNegativeArg(),
                     Cal.getNegativeArg()]))
    cnfsentences.append(CnfSentence([Cal, Amy]))
    cnfsentences.append(CnfSentence([Bob.getNegativeArg(), Amy]))
    cnfsentences.append(CnfSentence([Bob.getNegativeArg(), Cal]))
    cnfsentences.append(
        CnfSentence([Amy.getNegativeArg(), Bob,
                     Cal.getNegativeArg()]))
    cnfsentences.append(CnfSentence([Cal.getNegativeArg(), Bob]))
    cnfsentences.append(CnfSentence([Cal, Bob.getNegativeArg()]))
    return cnfsentences
Пример #5
0
def resolutionKB():
    # The resolution cnfsentences knowledge base
    cnfsentences = []

    cnfsentences.append(CnfSentence([mythical.getNegativeArg(), immortal]))

    cnfsentences.append(CnfSentence([mythical, mammal]))

    cnfsentences.append(CnfSentence([mythical, immortal.getNegativeArg()]))

    cnfsentences.append(CnfSentence([horned, immortal.getNegativeArg()]))

    cnfsentences.append(CnfSentence([horned, mammal.getNegativeArg()]))

    cnfsentences.append(CnfSentence([horned.getNegativeArg(), magical]))
    return cnfsentences
Пример #6
0
def resolutionKBParta():
    """
    :return: Cnf sentences knowledge base for part a
    """
    cnfsentences = []

    cnfsentences.append(CnfSentence([Cal, Amy.getNegativeArg()]))

    cnfsentences.append(
        CnfSentence([Bob.getNegativeArg(),
                     Cal.getNegativeArg()]))

    cnfsentences.append(CnfSentence([Bob, Cal]))

    cnfsentences.append(
        CnfSentence([Cal.getNegativeArg(), Bob,
                     Amy.getNegativeArg()]))

    cnfsentences.append(CnfSentence([Cal, Bob.getNegativeArg()]))

    cnfsentences.append(CnfSentence([Cal, Amy]))

    return cnfsentences
Пример #7
0
def resolutionKBParta():
    KB = []

    # sentence0
    KB.append(CnfSentence(Door.values()))

    # sentence1
    KB.append(CnfSentence([priest["A"].getNegativeArg(), Door["X"]]))
    KB.append(CnfSentence([priest["A"], Door["X"].getNegativeArg()]))

    # sentence2
    KB.append(CnfSentence([priest["B"].getNegativeArg(), Door["Y"], Door["Z"]]))
    KB.append(CnfSentence([priest["B"], Door["Y"].getNegativeArg()]))
    KB.append(CnfSentence([priest["B"], Door["Z"].getNegativeArg()]))

    # sentence3
    C = priest["C"]
    A = priest["A"]
    B = priest["B"]
    KB.append(CnfSentence([C.getNegativeArg(), A]))
    KB.append(CnfSentence([C.getNegativeArg(), B]))
    KB.append(CnfSentence([A.getNegativeArg(), B.getNegativeArg(), C]))

    # sentence4
    D = priest["D"]
    X = Door["X"]
    Y = Door["Y"]
    KB.append(CnfSentence([D.getNegativeArg(), X]))
    KB.append(CnfSentence([D.getNegativeArg(), Y]))
    KB.append(CnfSentence([D, X.getNegativeArg(), Y.getNegativeArg()]))

    # sentence5
    Z = Door["Z"]
    E = priest["E"]
    KB.append(CnfSentence([E.getNegativeArg(), X]))
    KB.append(CnfSentence([E.getNegativeArg(), Z]))
    KB.append(CnfSentence([E, X.getNegativeArg(), Z.getNegativeArg()]))

    # sentence6
    F = priest["F"]
    KB.append(CnfSentence([F.getNegativeArg(), D, E]))
    KB.append(CnfSentence([F, D.getNegativeArg()]))
    KB.append(CnfSentence([F, E.getNegativeArg()]))

    # sentence7
    G = priest["G"]
    KB.append(CnfSentence([G.getNegativeArg(), C.getNegativeArg(), F]))
    KB.append(CnfSentence([G, C]))
    KB.append(CnfSentence([G, F.getNegativeArg()]))

    # sentence8
    H = priest["H"]
    KB.append(CnfSentence([G.getNegativeArg(), H.getNegativeArg(), A]))
    KB.append(CnfSentence([H, G]))
    KB.append(CnfSentence([H]))
    KB.append(CnfSentence([H, A.getNegativeArg()]))

    return KB
Пример #8
0
def resolutionKBPartb():
    KB = []

    # sentence0
    KB.append(CnfSentence(Door.values()))

    # sentence1
    A = priest["A"]
    G = priest["G"]
    KB.append(CnfSentence([priest["A"].getNegativeArg(), Door["X"]]))
    KB.append(CnfSentence([priest["A"], Door["X"].getNegativeArg()]))

    # sentence8
    H = priest["H"]
    KB.append(CnfSentence([G.getNegativeArg(), H.getNegativeArg(), A]))
    KB.append(CnfSentence([H, G]))
    KB.append(CnfSentence([H]))
    KB.append(CnfSentence([H, A.getNegativeArg()]))

    # fragment1
    C = priest["C"]
    KB.append(CnfSentence([C.getNegativeArg(), A]))
    KB.append(CnfSentence([C.getNegativeArg(), T]))
    KB.append(CnfSentence([A.getNegativeArg(), T.getNegativeArg(), C]))

    # fragment2
    KB.append(CnfSentence([G.getNegativeArg(), C.getNegativeArg(), Q]))
    KB.append(CnfSentence([C, G]))
    KB.append(CnfSentence([Q.getNegativeArg(), G]))
    return KB