# Prolog Question

This topic is 3314 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am trying to formulate a simple dependency expression in Prolog after not having used it for a long time. I express two facts and a rule.
a( 1).
a( 2).
b( X) :- a( X), a( X + 1).
testing this gives no match
  ?- b( What).
no
My intention is that b( What) should match when What = 1 as the only case, since both a(1) and a(2) are satisfied. I am using Yap, and while the manual indicates that it supports arithmetic operators like '+' I suspect that I am doing something wrong conceptually.

##### Share on other sites
AFAIK prolog arithmetics are done through the 'is' operator, so you would have to do something like this:
b(X) :- a(X), Y is X + 1, a(Y).

##### Share on other sites
Thanks!! That works very well.