Exemple #1
0
def build_T7(F, G):
    # (F->G)->((!F->G)->G)

    nF = notFormula(F)
    nG = notFormula(G)

    F1 = Node(F, G)
    F1.msg = "t7 hypoth"
    F2 = Node(nF, G)
    F2.msg = "t7 hypoth"

    f3 = build_T5(F, G)
    F3 = f3[-1]
    F4 = axiom.A3(F, G)

    f5 = syl_1(F3, F4)
    F5 = f5[-1]

    F6 = MP(F1, F5)

    f7 = build_T4(nG, F)
    F7 = f7[-1]

    # (!F->G)->(!F->!!G)
    F8 = nF
    F9 = Node(nF, G)
    F10 = MP(F8, F9)
    f11 = build_T2(G)
    F11 = f11[-1]

    F12 = MP(F10, F11)

    f13 = build_deduction([F1, F2, F9], F8, F12, [F8, F9, F10] + f11 + [F12])
    F13 = f13[-1]
    f14 = build_deduction([], F9, F13, f13)
    F14 = f14[-1]

    #...
    f15 = syl_1(F14, F7)
    F15 = f15[-1]
    f16 = syl_1(F15, F6)
    F16 = f16[-1]

    proof = [F1, F2] + f14 + [F4] + f5

    f17 = build_deduction([], F1, F16, proof)

    proof = f17

    return proof
Exemple #2
0
def A1(F, G):
    """
        F -> (G -> F)   axiom (1)
    """

    if F is None or G is None:
        return None

    tree = Node(G, F)
    tree = Node(F, tree)

    tree.msg = "A1 for " + str(F) + ", " + str(G)

    return tree
Exemple #3
0
def build_T6(F, G):
    fg = Node(F, G)
    fg.msg = "hypoth t6"

    t5 = build_T5(fg, G)
    T5 = t5[-1]

    ng = notFormula(G)
    ng.msg = "hypoth t6"
    F1 = F
    F1.msg = "hypoth t6"
    # we need (F->G)->G
    F2 = MP(F1, fg)
    ded = build_deduction([F1, ng], fg, G, [F1, F2])
    F3 = ded[-1]

    F4 = MP(F3, T5)

    proof = [F1, ng, F2] + ded + [F4]

    proof = build_deduction([], F, F4, proof)

    return proof
Exemple #4
0
def Calmar_Theorem(F, values):
    '''
        Calmar's Theorem implementation

    :param F: Propositional calculus formula: Variable or Node
    :return:
    '''

    if type(F) == Variable:
        v = Variable(F.symbol, _not=True if values[F.symbol] == 1 else 0)

        return [v]

    if F._not:  # F = !G
        G = Node(None, None)
        G.left = F.left  # Copy G, but F = !G
        G.right = F.right

        if F.calculate(values) == 1:
            G.msg = "Calmar's theorem, 1.a) F^(alpha) = G^(alpha) => hypoth |- G^() = F^()"

            return [G]

        else:
            # !f = !!g
            t2 = build_T2(G)
            T2 = t2[-1]

            nng = MP(G, T2)

            res = t2
            res.append(nng)
            return res

    else:  # F = G->H

        res = []

        G = F.left
        H = F.right

        if G.calculate(values) == 0:

            nG = notFormula(G)
            t3 = build_T3(G, H)

            T = t3[-1]
            mp = MP(nG, T)

            res = t3
            res.append(mp)

        elif H.calculate(values) == 1:

            # h->(g->h)
            h = H
            hgh = axiom.A1(H, G)

            gh = MP(h, hgh)

            return [hgh, gh]

        else:
            # F = !(G->H)
            # have G, !H. proof !(G->H)

            nH = notFormula(H)

            t6 = build_T6(G, H)
            T6 = t6[-1]

            f1 = MP(G, T6)
            f2 = MP(nH, f1)

            res = t6
            res.extend([f1, f2])

        return res