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 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)"))
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 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)"))