Beispiel #1
0
def test_simplify_every_child(lexicon):
    # (LP.LQ.Ax.P(x) -> Q(x))(Lx.Child(x)) -> LQ.Ax.Child(x) -> Q(x)
    tree = Call(lexicon["every"][0].formula, lexicon["child"][0].formula)
    assert tree.simplify() == Lambda(
        "Q",
        ForAll("x",
               IfThen(Call(Var("Child"), Var("x")), Call(Var("Q"), Var("x")))))
Beispiel #2
0
def test_simplify_super_nested_call():
    # (LP.P(a, b))(Lx.Ly.x & y) -> a & b
    tree = Call(
        Lambda("P", Call(Call(Var("P"), Var("a")), Var("b"))),
        Lambda("x", Lambda("y", And(Var("x"), Var("y")))),
    )
    assert tree.simplify() == And(Var("a"), Var("b"))
Beispiel #3
0
def test_simplify_nested_call():
    # (Lx.Ly.x & y)(a)(b) -> a & b
    tree = Call(
        Call(Lambda("x", Lambda("y", And(Var("x"), Var("y")))), Var("a")),
        Var("b"))
    assert tree.simplify() == And(Var("a"), Var("b"))
Beispiel #4
0
def test_simplify_call_with_lambda_arg():
    # (LP.P(x))(Lx.x | a) -> x | a
    tree = Call(Lambda("P", Call(Var("P"), Var("x"))),
                Lambda("x", Or(Var("x"), Var("a"))))
    assert tree.simplify() == Or(Var("x"), Var("a"))
Beispiel #5
0
def test_simplify_call():
    tree = Call(Lambda("x", Var("x")), Var("j"))
    assert tree.simplify() == Var("j")