likes/2, as in
likes(jane, pizza), is 2, as it takes two arguments,
Arity Example Could Mean … 0
a bit like
#define LINUXin* C
Fido is happy. 2
gave(mary, john, book).
Mary gave John a book.
* hard to use in practice in Prolog: if the code contains
linux. then you could
test for this, but if it doesn't, then testing
linux in your code will trigger an
"Undefined procedure: linux/0" error. You can work around this by declaring
to be dynamic - i.e. putting the line
:- dynamic linux/0.in your code (usually at the start).
Every fact and rule in a Prolog program, and every
built-in predicate has an
arity. Often this is referred to in descriptions of
these facts and rules, by appending
and the arity to the name of the rule or fact.
For example, the built-in predicate
member/2 has arity 2.
A fact or rule can have more than one arity. For example, you might
want to have two versions of
% make(X, Y, Z): X makes Y for Z make(fred, chest_of_drawers, paul). make(ken, folding_bicycle, graham). % make(X, Y): X makes Y make(steve, fortune). make(kevin, mistake).What we have here are