I hope my comment won’t just add noise to the conversation but the meaning of “predicate” in the context of Prolog has been a huge source of confusion for me ever since I started learning Prolog and up to the first year and a half of my PhD (I study Inductive Logic Programming).
I remember, when I was first starting out, wondering “OK, so facts and rules are predicates. So what are queries?” because I had been taught the “facts, rules and queries” terminology and I had also been told that rules and facts make up predicates. So I was lost until a light bulb went on in my head, I decided that queries are also predicates and told all about it to anyone who couldn’t run away, with the exuberance of a novice mystic having an epiphany. Lesson number one: don’t trust epiphanies.
Later, in the first year of my PhD I was forced to re-do my early stage report and I had one of my submitted papers cruelly savaged in both cases by reviewers infuriated by my use of “predicate” to mean, well, everything and anything. parent(homer,bart)
? A predicate (or worse, a term). parent/2
? A predicate. parent(X,Y):- mother(X,Y). parent(X,Y):- father(X,Y).
? A predicate. This time, there were no lightbulbs. I sat down and re-read carefully both J. W. Lloyd and the first half of Foundations of Inductive Logic Programming (which first half is basically a retell of most of the material in Lloyd). So now, if you ask me the difference between a predicate definition, a predicate symbol (and arity) and a predicate indicator in Prolog, I’ll know what to say (“Read Lloyd”).
Unfortunately, none of these foundational sources of knowledge for my field and Logic Programming include a definition of “predicate”. That’s right. “predicate” is not defined formally in the main Logic Programming (and ILP) source. What is semi-defined is “predicate symbol”, but “predicate” itself, is not.
So what the hell is a predicate?
I guess I’ll have to read a mathematical logic sourcebook to know for sure, because it seems to me that Logic Programming borrowed the terminology from mathematical logic -and nobody bothered to re-establish it since, well, duh, predicate, everyone knows what that is; I guess. On the other hand, “function” and even “constant” are formally defined in both Lloyd and Foundations of ILP (a constant is a 0-arity function). So why is predicate left hanging?
How about “a predicate is a function that returns a boolean”, that joeblog likes?
I hate it (sorry @joeblog)! I hate it from the point of view of the novice logic programmer I was all those years ago, confused, cold and alone, trying to figure out what this or that formal definition means and what are its implications.
For example, if “a predicate is a function that returns a boolean”- then where is that boolean? I’m a novice, trying to understand Prolog now, eh? Can I do this?
?- parent(_,bart) = true.
If the answer to that is “false”, does it mean that bart has no parent? Does it mean that _
is not bart’s parent? What does it mean? It sure doesn’t mean that parent(_,bart)
is true! Because it’s not equal to true
! So I’m hopelessly lost again, right when I thought that I’m finally going to understand what those “predicates” are, now that someone has taken the trouble to explain them to me in “nice and simple and clear” terminology that I already intuitively understand (why, I built my own web app in javascript at high school, I understand functions, I’ve written lots of them!).
And wait 'till I decide to dig a little deeper and get my hands on some ancient textbook, like Lloyd, and find out that:
Definition A term is defined inductively as follows:
(a) A variable is a term.
(b) A constant is a term.
(c ) If f is an n-ary function symbol and t_1,…,t_n are terms, then f(t_1,…,t_n) is a term.
Wait. So functions are terms? Aha! That’s why eveything in Prolog is occasionally described as a “term”! It’s because predicates are functions (that return booleans) and functions are terms! Light bulb!
To be fair, Prolog has made a meal of logic programming terminology and there’s no salvaging that with a mere glossary. So I have no suggestsions. I think Jan’s proposal is the most practical one (as usual): point out the confusion (“Teach the controversy!”). A predicate means different things in different contexts and you have to try to understand the context. After that, you’re on your own.
P.S. Lloyd has this to say about “procedures” in logic programming:
"However, what [Kowalski in “Predicate Logic as a Programming Language”] shows is that logic has a procedural interpretation, which makes it very effective as a programming language. Briefly, a program clause A ← B_1,…,B_n is regarded as a procedure definition. If ←C_1,…,C_k is a goal, then each C_j is regarded as a procedure call. A program is run by giving it an initial goal. If the current goal is ←C_1,…,C_k, a step in the computation involves unifying some C_j with the head A of a program clause A←B_1,…,B_n and thus reducing the current goal to the goal ←(C_1,…,C_{j-1},B_1,…,B_n, C_{j+1},…,C_k)θ where θ is the unifying substitution. Unification thus becomes a uniform mechanism for parameter passing, data selection and data construction. The computation terminates when the emtpy goal is produced.
So it is a program clause, not a predicate definition, that is a procedure definition. More confusion, this time with the ISO standard.