I'm new to Prolog and I'm trying to resolve this exercise:
Define a predicate
greater_than/2
that takes two numerals in the notation that we introduced in this lecture (i.e.0
,succ(0)
,succ(succ(0))
...) as arguments and decides whether the first one is greater than the second one. E.g:
?- greater_than( succ(succ(succ(0))), succ(0) ).
yes.
?- greater_than( succ(succ(0)), succ(succ(succ(0))) ).
no.
This is my answer so far:
greater_than(X, 0).
greater_than( succ(succ(X)), succ(Y) ).
but of course doesn't work properly, so I'm asking anyone for help. Thanks.