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"))
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)"))
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")))
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)")))
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
def DM2(): return notI( arrowI( assume(parse("FA x. P(x)")), notE( forallE(assumed(parse("FA x. P(x)")), "c", parse("P(c)")), existsE( premise(parse("EX x. ~P(x)")), "d", arrowI( assume(parse("~P(d)")), FE( notE( forallE(assumed(parse("FA x. P(x)")), "d", parse("P(d)")), assumed(parse("~P(d)")), false()), parse("~P(c)")), parse("~P(d) -> ~P(c)")), parse("~P(c)")), false()), Arrow(parse("FA x. P(x)"), false())), parse("~FA x. P(x)"))
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)"))