sine-patre/fol/tests/test_subst.py

33 lines
790 B
Python
Raw Normal View History

2024-04-25 16:47:45 +00:00
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)