import fol def test_empty_subst(): root = fol.parse('Happy(x)').subst({}) assert 'PRED[Happy](VAR[x])' == str(root) def test_one_var_subst(): root = fol.parse('Happy(x)').subst({'x': fol.term('z')}) assert 'PRED[Happy](VAR[z])' == str(root) def test_one_function_subst(): root = fol.parse('Happy(x)').subst({'x': fol.term('f(z)')}) assert 'PRED[Happy](FUN[f](VAR[z]))' == str(root) def test_ambiguous_subst(): root = fol.parse('Happy(x)').subst({ 'x': fol.term('y'), 'y': fol.term('z'), }) assert 'PRED[Happy](VAR[y])' == str(root) def test_ambiguous_reverse_subst(): root = fol.parse('Happy(x, y)').subst({ 'y': fol.term('z'), 'x': fol.term('y'), }) assert 'PRED[Happy](VAR[y],VAR[z])' == str(root)