Пример #1
0
def Q3_2():
	clear()
	A = Var("A")
	B = Var("B")
	p1 = premise(Or(A, B))
	p2 = premise(Not(B))

	return orE(p1, Arrow(A,A), arrowI(assume(B), FE(notE(assumed(B), p2, false()), A), Arrow(B, A)), A)
Пример #2
0
def disSyl():
    A = Var("a")
    B = Var("b")
    p1 = premise(Or(A, B))
    p2 = premise(Not(B))

    return orE(
        p1, arrowI(assume(A), assumed(A), Arrow(A, A)),
        arrowI(assume(B), FE(notE(assumed(B), p2, false()), A), Arrow(B, A)),
        A)
Пример #3
0
def DM2():
    a = Var("a")
    b = Var("b")
    prem = premise(Not(And(a, b)))  #The original premise, ~(A && B)
    d1 = premise(
        Not(Or(Not(a), Not(b)))
    )  #d1 is the phrase required to run DL1 and DL2. I ran it as a premise, but it is assumed, NOT a premise

    return doubleNeg(
        notI(
            arrowI(assume(Not(Or(Not(a), Not(b)))),
                   notE(andI(DL1(d1), DL2(d1), And(a, b)), prem, false()),
                   Arrow(Not(Or(Not(a), Not(b))), false())),
            Not(Not(Or(Not(a), Not(b))))), Or(Not(a), Not(b)))
Пример #4
0
def ren_forall():
    return forallI(assume(Var("x")),
                   forallE(
                       premise(parse("FA x. P(x)")),
                       "x",
                       parse("P(x)"),
                   ), parse("FA z. P(z)"))
Пример #5
0
def contra():
    return arrowI(
        assume(parse("EX x.P(x)")),
        existsE(
            assumed(parse("EX x.P(x)")), "c",
            forallE(premise(parse("FA x.P(x) -> Q")), "c", parse("P(c) -> Q")),
            parse("Q")), parse("(EX x.P(x)) -> Q"))
Пример #6
0
def Q3_1():
	clear()
	A = Var("A")
	B = Var("B")
	p1 = premise(Or(A, B))

	return orE(p1, arrowI(assume(A), orIR(assumed(A), Or(B, A)), Arrow(A, Or(B, A))), arrowI(assume(B), orIL(assumed(B), Or(B, A)), Arrow(B, Or(B, A))), Or(B, A))
Пример #7
0
def arrTrans():
    a = Var("A")
    b = Var("B")
    c = Var("C")

    p1 = premise(Arrow(a, b))
    p2 = premise(Arrow(b, c))

    a1 = assume(a)

    return arrowI(a1, \
                  arrowE(arrowE(assumed(a), \
                                p1, \
                                b), \
                         p2, \
                         c), \
                  Arrow(a,c))
Пример #8
0
def forall_comm():
    return forallI(
        assume(Var("a")),
        forallI(
            assume(Var("b")),
            forallE(
                forallE(premise(parse("FA x. FA y. P(x, y)")), "b",
                        parse("FA y. P(b, y)")), "a", parse("P(b, a)")),
            parse("FA x. P(x, a)")), parse("FA y. FA x. P(x, y)"))
Пример #9
0
def Q3_3():
	clear()
	A = Var("A")
	B = Var("B")
	p1 = premise(Or(Not(A), Not(B)))
	end = Not(And(A,B))
	A_B = And(A,B)
	
	return orE(p1, arrowI(assume(Not(A)), notI(arrowI(assume(A_B), notE(andEL(assumed(A_B), A), assumed(Not(A)), false()), Arrow(A_B, false())), Not(A_B)), Arrow(Not(A), Not(A_B))), arrowI(assume(Not(B)), notI(arrowI(assume(A_B), notE(andER(assumed(A_B), B), assumed(Not(B)), false()), Arrow(A_B, false())), Not(A_B)), Arrow(Not(B), Not(A_B))), end)
Пример #10
0
def orComm():
    A = Var("a")
    B = Var("b")
    p1 = premise(Or(A, B))

    return orE(
        p1, arrowI(assume(A), orIR(assumed(A), Or(B, A)), Arrow(A, Or(B, A))),
        arrowI(assume(B), orIL(assumed(B), Or(B, A)), Arrow(B, Or(B, A))),
        Or(B, A))
Пример #11
0
def contra():
    return arrowI(
        assume(parse("EX x. P(x)")),
        arrowE(
            existsE(
                assumed(parse("EX x. P(x)")), "a",
                arrowI(assume(parse("P(a)")), assumed(parse("P(a)")),
                       Arrow(parse("P(a)"), parse("P(a)"))), parse("P(a)")),
            forallE(premise(parse("FA x. (P(x)->Q)")), "a", parse("P(a)->Q")),
            Var("Q")), Arrow(parse("EX x. P(x)"), Var("Q")))
Пример #12
0
def DM3():
    return forallI(
        assume(Var("a")),
        notI(
            arrowI(
                assume(parse("P(a)")),
                notE(existsI(assumed(parse("P(a)")), "a", parse("EX x. P(x)")),
                     premise(Not(parse("EX x. P(x)"))), false()),
                Arrow(parse("P(a)"), false())), Not(parse("P(a)"))),
        parse("FA x. ~P(x)"))
Пример #13
0
def DM1():
    return notI(
        arrowI(
            assume(parse("EX x. P(x)")),
            notE(
                existsE(
                    assumed(parse("EX x. P(x)")), "d",
                    arrowI(
                        assume(parse("P(d)")),
                        FE(
                            notE(
                                assumed(parse("P(d)")),
                                forallE(premise(parse("FA x. ~P(x)")), "d",
                                        parse("~P(d)")), false()),
                            parse("P(c)")), parse("P(d) -> P(c)")),
                    parse("P(c)")),
                forallE(premise(parse("FA x. ~P(x)")), "c", parse("~P(c)")),
                false()), Arrow(parse("EX x. P(x)"), false())),
        parse("~EX x. P(x)"))
Пример #14
0
def main():
    try:
        clear()
        orComm().print_proof()
        clear()
        disSyl().print_proof()
        clear()
        DM1().print_proof()
        clear()
        a = Var("a")
        b = Var("b")
        dlPrem = premise(Not(Or(Not(a), Not(b))))
        DL1(dlPrem).print_proof()
        clear()
        dlPrem = premise(Not(Or(Not(a), Not(b))))
        DL2(dlPrem).print_proof()
        clear()
        DM2().print_proof()
    except (ProofException) as e:
        e.print()
Пример #15
0
def DM2():
    return notI(
        arrowI(
            assume(parse("FA x. P(x)")),
            notE(
                forallE(assumed(parse("FA x. P(x)")), "a", parse("P(a)")),
                existsE(
                    premise(parse("EX x. ~P(x)")), "a",
                    arrowI(assume(Not(parse("P(a)"))),
                           assumed(Not(parse("P(a)"))),
                           Arrow(Not(parse("P(a)")), Not(parse("P(a)")))),
                    Not(parse("P(a)"))), false()),
            (Arrow(parse("FA x. P(x)"), false()))), Not(parse("FA x. P(x)")))
Пример #16
0
def forall_comm():
    return forallI(
        assume(Var("c")),
        forallI(
            assume(Var("d")),
            forallE(
                forallE(
                    premise(parse("FA x. FA y. P(x, y)")),
                    "d",
                    parse("FA y. P(d, y)"),
                ),
                "c",
                parse("P(d, c)"),
            ), parse("FA x. P(x, c)")), parse("FA y. FA x. P(x, y)"))
Пример #17
0
def example():
    clear()
    p1 = premise(parse("EX x. FA y. P(x,y)"))
    a1 = assume(parse("FA y. P(u,y)"))

    a2 = assume(Var("v"))
    l1 = assumed(parse("FA y. P(u,y)"))
    l2 = forallE(l1, "v", parse("P(u,v)"))
    l3 = existsI(l2, "u", parse("EX x. P(x,v)"))
    l4 = forallI(a2, l3, parse("FA y. EX x. P(x,y)"))

    l5 = arrowI(a1, l4, parse("(FA y. P(u,y)) -> (FA y. EX x. P(x,y))"))
    l6 = existsE(p1, "u", l5, parse("FA y. EX x. P(x,y)"))
    return l6
Пример #18
0
def andComm():
    clear()
    a = Var("A")
    b = Var("B")
    p1 = premise(And(a, b))

    # The proof itself looks different, but it's really just on it's side.
    #
    # each proof rule is written as rule(support, expression)
    # since the andI rule B && A needs two pieces (B and A), we need the two proofs
    # the proof for B is andER, and the proof of A is andEL
    return andI(andER(p1, b), \
                andEL(p1, a), \
                And(b,a))
Пример #19
0
def exists_comm():
    return existsE(
        premise(parse("EX x. EX y. P(x,y)")), "c",
        arrowI(
            assume(parse("EX y. P(c,y)")),
            existsE(
                assumed(parse("EX y. P(c,y)")), "d",
                arrowI(
                    assume(parse("P(c,d)")),
                    existsI(
                        existsI(assumed(parse("P(c,d)")), "c",
                                parse("EX x. P(x,d)")), "d",
                        parse("EX y. EX x. P(x,y)")),
                    parse("P(c,d) -> EX y. EX x. P(x,y)")),
                parse("EX y. EX x. P(x,y)")),
            parse("(EX y. P(c,y)) -> EX y. EX x. P(x,y)")),
        parse("EX y. EX x. P(x,y)"))
Пример #20
0
def DM1():
    A = Var("a")
    B = Var("b")
    p1 = premise(Or(Not(A), Not(B)))
    end = Not(And(A, B))
    A_B = And(A, B)
    #I condensed parts of the proofs so I could substitute in things that made sense to me, otherwise I was going nuts

    return orE(
        p1,
        arrowI(
            assume(Not(A)),
            notI(
                arrowI(assume(A_B),
                       notE(andEL(assumed(A_B), A), assumed(Not(A)), false()),
                       Arrow(A_B, false())), Not(A_B)),
            Arrow(Not(A), Not(A_B))),
        arrowI(
            assume(Not(B)),
            notI(
                arrowI(assume(A_B),
                       notE(andER(assumed(A_B), B), assumed(Not(B)), false()),
                       Arrow(A_B, false())), Not(A_B)),
            Arrow(Not(B), Not(A_B))), end)
Пример #21
0
def ren_exists():
    return existsE(
        premise(parse("EX x. P(x)")), "c",
        arrowI(assume(parse("P(c)")),
               existsI(assumed(parse("P(c)")), "c", parse("EX z. P(z)")),
               parse("P(c) -> EX z. P(z)")), parse("EX z. P(z)"))