0
votes

Prolog newbie here;

I'm trying to define multiple facts at once, but I keep getting the error below:

?- assert(robin(damian, dick)).
true.

?- robin(damian).

ERROR: Undefined procedure: robin/1
ERROR:     However, there are definitions for:
ERROR:         robin/2
false.

The statements individually seem to work fine:

?- assert(robin(damian)).
true.

?- assert(robin(dick)).
true.

?- robin(damian).
true.

I'm not sure what the syntax error with the first line is, and I've tried changing it in many ways.

Thanks!

1
Well you define a predicate with two arguments, and you call a predicate with one argument. If you want to obtain dick. You should call it with robin(damian,X).Willem Van Onsem
@WillemVanOnsem Thanks you! You really cleared that up for me!Decipherer

1 Answers

1
votes

The first line you give is not defining multiple predicates at once, but is defining a single predicate with two arguments. When you then try to call it you are using a single argument, which is undefined as it says in the error message. This is also why it suggests robin/2. Calling it like robin(damian, X) will get rid of the syntax error by unifying the second argument with X, but based on your question it sounds like this is not what you want. You should probably just define the predicates one at a time if you would like to use them like you show in your second code sample.