def test_recursive_replace_variable(): # BFP(x, Lx.x, x & y) tree = Call( Call( Call(Var("BFP"), Var("x")), Lambda("x", Var("x")), # This should not be replaced. ), And(Var("x"), Var("y")), ) assert tree.replace_variable("x", Var("j")) == Call( Call(Call(Var("BFP"), Var("j")), Lambda("x", Var("x"))), And(Var("j"), Var("y")) )
def test_replace_predicate(): tree = Call(Var("P"), Var("x")) assert tree.replace_variable("P", Var("Good")) == Call(Var("Good"), Var("x"))