# Is the definition of "predicate" correct in the Glossary of Terms?

**URL:** <https://swi-prolog.discourse.group/t/is-the-definition-of-predicate-correct-in-the-glossary-of-terms/2807>\
**Category:** General\
**Created:** [August 20, 2020, 12:14pm UTC](https://swi-prolog.discourse.group/t/is-the-definition-of-predicate-correct-in-the-glossary-of-terms/2807 "2020-08-20T12:14:40Z")\
**Posts on this page:** 15\
**Page:** 2

<div class="post-metadata">

**Author:** ![JCR](https://avatars.discourse-cdn.com/v4/letter/j/258eb7/32.png) [@JCR](https://swi-prolog.discourse.group/u/JCR)\
**Post date:** [August 24, 2020, 5:19pm UTC](https://swi-prolog.discourse.group/t/is-the-definition-of-predicate-correct-in-the-glossary-of-terms/2807/27 "2020-08-24T17:19:24Z")

</div>

> [@jan](#):
>
> I’m thinking along the line that _predicate_ is an ambiguous reference to either a _predicate indicator_ or a _predicate definition_ and the latter is a synonym for _procedure_ (in the context of Prolog). How correct/wrong is that?

If i read the room correctly, what it says in the current [glossary entry](https://www.swi-prolog.org/pldoc/man?section=glossary) (a collection of clauses with the same functor (name/arity)) actually captures the meaning conventionally attributed to “predicate” rather well. So maybe what needs to be changed is the ISO text, leaving the glossary entry untouched?

About the duality of “predicate” either meaning a predicate indicator or a collection of clauses with the same head (procedure), to me predicate indicator just seems to be a name or symbol (that refers to the collection of clauses with the same head). Is this really the meaning of predicate, that “predicate” refers to a _name_ for something? Do we not mean the thing that predicate indicator references when we say “predicate” (i.e. the collection of clauses with the same head)?

/JCR

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [August 24, 2020, 7:26pm UTC](https://swi-prolog.discourse.group/t/is-the-definition-of-predicate-correct-in-the-glossary-of-terms/2807/28 "2020-08-24T19:26:05Z")

</div>

I mostly agree. I do thnk we should address the confusion in the glossary though. That is easier than changing the ISO text 🙂

---

<div class="post-metadata">

**Author:** ![anniepoo](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/anniepoo/32/12_2.png) [@anniepoo](https://swi-prolog.discourse.group/u/anniepoo)\
**Post date:** [August 27, 2020, 12:56pm UTC](https://swi-prolog.discourse.group/t/is-the-definition-of-predicate-correct-in-the-glossary-of-terms/2807/31 "2020-08-27T12:56:04Z")

</div>

hmm… Prolog predicates succeed or fail. I tell students they return void

---

<div class="post-metadata">

**Author:** ![grossdan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/grossdan/32/23_2.png) [@grossdan](https://swi-prolog.discourse.group/u/grossdan)\
**Post date:** [September 26, 2021, 7:09am UTC](https://swi-prolog.discourse.group/t/is-the-definition-of-predicate-correct-in-the-glossary-of-terms/2807/32 "2021-09-26T07:09:15Z")

</div>

Intuitively, that is what i also thought that unlike functions predicates don’t return anything …

I guess strictly speaking one need to view the true or false returned by a call as part of a procedural mechanism of control flow …

I.e. “returning” true or false is part of the procedural reading of Prolog.

Dan

---

<div class="post-metadata">

**Author:** ![stassa.p](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/stassa.p/32/712_2.png) [@stassa.p](https://swi-prolog.discourse.group/u/stassa.p)\
**Post date:** [September 29, 2021, 1:10pm UTC](https://swi-prolog.discourse.group/t/is-the-definition-of-predicate-correct-in-the-glossary-of-terms/2807/33 "2021-09-29T13:10:30Z")

</div>

> [@joeblog](#):
>
> Back to predicates: The tendency of people in different fields to redefine commonly used words into “special cases” just strikes me as blunting language.

In this case it’s imperative languages that are redefining “predicate”, which is a term from First Order Logic (FOL) a.k.a. Predicate Logic, a.k.a. the First Order Predicate Calculus. Informally, in FOL a “predicate” is the name of a relation over entities in the domain of discourse. Still informally, the concept of relation is a generalisation of the concept of function, where in a relation any number of objects are mapped to any number of objects, rather than to a single object. For instance, `ƒ:X, Y → Z` is a function mapping elements of the sets X and Y to elements of the set Z, `ƒ(x,y)` is an instance of ƒ and ƒ(x,y) = z is the instance of ƒ that maps x ∈ X, y ∈ Y to z ∈ Z. Whereas p(x,y,z) is the relation p/3 that maps elements of X, Y and Z to each other.

Bottom line: functions have “return” values, relations don’t have return values, predicates are relations, not functions, and predicates don’t have return values.

> [@joeblog](#):
>
> A core idea of Prolog is it is built entirely out of predicates, with “answers” returned as parameters instead of something a function substitutes itself with, a convention I guess started with Fortran, from which nearly every commonly used pogramming language is descended.

This also comes from FOL which has no concept of replacing a term by its value. FOL also doesn’t have any concept of substituting variables, for example. FOL only has syntax, the rules that determine whether a formula is a well-formed formula (wff) or not, and the rules of the four logical connectives (∧, ∨, → and ¬) and the two quantifiers, ∀ and ∃.

Everything else belongs to something outside of FOL. The idea of replacing functions with their values comes from algebra, I reckon. The idea of substituting variables for terms (variables, functions or constants) is from proof theory.

Incidentally, FOL has functions, but again those are not the usual functions that are replaced by their values. Functions are defined recursively as follows: a constant, or a variable, is a term. If `ƒ` is a function symbol of arity `n` and `t₁, ..., tₙ` are terms, then `ƒ(t₁, ..., tₙ)` is a term, sometimes called a functional term, or simply function.

But those functions cannot be replaced by their values in FOL. For example, suppose `p(ƒ(x), y)` is an atom of the predicate p/2. FOL doesn’t tell you how you can replace ƒ(x) by its value, so there is no way to go from `p(ƒ(x), y)` to, say, `p(2, 1)`. Various proof procedures let you substitute variables for other terms, so for example under SLD resolution with unification you might end up with an atom `p(ƒ(ƒ(x)), y)` by substituting `x` for `ƒ(x)`, but note that again you are not replacing `ƒ(x)` with a value. You’re only creating a new term.

It’s a bit of a mindbend and it takes a lot time staring at it to get one’s head around. Most of this time is taken letting go of the idea that things are replaced by their values.

Edit: Let’s digest this first but it occurs to me you might be wondering about the value of predicates as true or false. The thing to remember is that FOL predicates _dont’ have truth values_. Instead, the _atoms_ of predicates are assigned true or false values by an interpretation (literally, an assignment of truth values to predicate atoms). Then the truth value of well-formed-formulae are determined according to the rules of the logical connectives and the two quantifiers, depending on the values of atoms under the current interpretation. Proof procedures are used to determine the truth of well-formed formulae. SLD-resolution is a proof procedure restricted to one kind of well-formed formulae, the Horn clauses.

---

<div class="post-metadata">

**Author:** ![stassa.p](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/stassa.p/32/712_2.png) [@stassa.p](https://swi-prolog.discourse.group/u/stassa.p)\
**Post date:** [September 29, 2021, 1:28pm UTC](https://swi-prolog.discourse.group/t/is-the-definition-of-predicate-correct-in-the-glossary-of-terms/2807/34 "2021-09-29T13:28:16Z")

</div>

> [@JCR](#):
>
> About the duality of “predicate” either meaning a predicate indicator or a collection of clauses with the same head (procedure), to me predicate indicator just seems to be a name or symbol (that refers to the collection of clauses with the same head). Is this really the meaning of predicate, that “predicate” refers to a _name_ for something? Do we not mean the thing that predicate indicator references when we say “predicate” (i.e. the collection of clauses with the same head)?

Oh right. I posted my informal definition of “predicate” earlier, replying to @joeblog having forgotten the discussion up to my reply. My informal definition is that “a predicate is the name of a relation between entities in the domain of discourse”.

But that’s no use in Prolog, where we want to have a name for the expressions we write in a source file. I think the way you explain it makes the most sense, in that (prorgamming) context: a predicate is a name attached to a set of clauses that have the same symbol and arity in their head literal. A “predicate indicator” is simply a short-hand for a predicate that also gives us its arity, so that we can distinguish between predicates with the same symbol but different arities (which are distinct sets of clauses in the source code). So I think it makes sense to say that a predicate indicator is a reference to a predicate with a specific symbol and arity.

To be honest, I’d prefer to separate “predicate” from “predicate definition” because you can have multiple definitions for the same predicate. For instance, I might have two Prolog module files and have a separate definition of the predicate `father/2` in each of them, each for a different family, for example. But this could cause even more confusion.

---

<div class="post-metadata">

**Author:** ![EricGT](https://avatars.discourse-cdn.com/v4/letter/e/f1d935/32.png) [@EricGT](https://swi-prolog.discourse.group/u/EricGT)\
**Post date:** [September 29, 2021, 1:34pm UTC](https://swi-prolog.discourse.group/t/is-the-definition-of-predicate-correct-in-the-glossary-of-terms/2807/35 "2021-09-29T13:34:32Z")

</div>

> [@stassa.p](#):
>
> you can have multiple definitions for the same predicate. For instance, I might have two Prolog module files and have a separate definition of the predicate father/2 in each of them, each for a different family, for example.

While many think of predicate indicator as `Name/Arity`, in reality one should use `Module:Name/Arity`. This is prevalent in [SWI-Prolog source code](https://github.com/SWI-Prolog/swipl-devel).

The reason I suppose predicate indicator does not include module in the definition is because Modules came in Part 2 of the standard. ([ref](https://www.iso.org/obp/ui/#iso:std:iso-iec:13211:-2:ed-1:v1:en))

> **Personal notes**
>
> Found this when using prolog\_frame\_attribute/3 with `goal`.
> 
> ```prolog
> '<meta-call>'(my_app:(family_tree:grandmother(_21310,_21312),fail,!;true)))
> 
> ```
> 
> I have known for some time that modules can be nested with SWI-Prolog. I don’t know all of the specifics at present thus this is in a personal note.

---

<div class="post-metadata">

**Author:** ![stassa.p](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/stassa.p/32/712_2.png) [@stassa.p](https://swi-prolog.discourse.group/u/stassa.p)\
**Post date:** [September 29, 2021, 1:44pm UTC](https://swi-prolog.discourse.group/t/is-the-definition-of-predicate-correct-in-the-glossary-of-terms/2807/36 "2021-09-29T13:44:17Z")

</div>

> [@Boris](#):
>
> I would like to emphasize that I strongly feel that “predicate” on its own can mean either the definition, or the indicator, or both at the same time.

It’s funny but if you go back to the foundational text on logic programming, J. W. Lloyd (“Foundations of logic programming” and note that this is about logic programming in general, not just Prolog, for which you probably want Clocksin & Mellish) he doesn’t use “predicate” or “definition”, much. Rather, he uses _program_: logic program, definite program, normal program, etc.

All those program’s are sets of clauses. In fact, that’s the definition of a logic program: a set of Horn clauses. Only, if you’re actually coding a logic program you end up creating a whole bunch of sub-programs, that each do different things and it make sense, pragmatically speaking, that you want to know how to refer to those things. In practice, we call them “predicates” so for example append/3 is one predicate, member/2 is another predicate and so on, and I wager that what we think of as a “predicate” also includes sub-predicates, which we often call “auxiliaries”. It’s sub-programs all the way down.

All this is very easy to understand when one is looking at source code where it’s very obvoius where one (sub-) program begins and another ends. But it gets hairy quickly when trying to explain this to newcomers or to speak formally of such things. See again my comment about being confused when I first started coding in Prolog. I think back then my confusion only started to clear up when I read “Prolog and Natural-Language Analysis” by Fernando Pereira and M. Shieber:

[http://www.mtome.com/Publications/PNLA/prolog-digital.pdf](http://www.mtome.com/Publications/PNLA/prolog-digital.pdf)

Although I had to read it many, many times carefully. Skimming through it again I can’t remember why or where it was that the lightbulb went off, but I remember it as being truly enlightening.

---

<div class="post-metadata">

**Author:** ![stassa.p](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/stassa.p/32/712_2.png) [@stassa.p](https://swi-prolog.discourse.group/u/stassa.p)\
**Post date:** [September 29, 2021, 1:46pm UTC](https://swi-prolog.discourse.group/t/is-the-definition-of-predicate-correct-in-the-glossary-of-terms/2807/37 "2021-09-29T13:46:43Z")

</div>

Well, I didn’t know that. Thanks for clarifying.

---

<div class="post-metadata">

**Author:** ![JCR](https://avatars.discourse-cdn.com/v4/letter/j/258eb7/32.png) [@JCR](https://swi-prolog.discourse.group/u/JCR)\
**Post date:** [September 29, 2021, 3:23pm UTC](https://swi-prolog.discourse.group/t/is-the-definition-of-predicate-correct-in-the-glossary-of-terms/2807/38 "2021-09-29T15:23:43Z")

</div>

Thanks for your insightful comments! I am learning a lot from them.

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [September 29, 2021, 3:59pm UTC](https://swi-prolog.discourse.group/t/is-the-definition-of-predicate-correct-in-the-glossary-of-terms/2807/39 "2021-09-29T15:59:23Z")

</div>

I think the glossary item (and maybe more) should be changed. It is still a bit unclear how. We clearly have a _predicate indicator_, which is in its full form module:name/arity (or //arity for DCG rules, but let us skip that for now) and in abbreviated form name/arity. Whatever you call it, _predicate indicator_ is the official name in the ISO standard and seems pretty much a _“reference to a set of clauses”_ Just a name (Prolog atom) doesn’t fulfill this role as predicates with the same name and different arities are unrelated. We can also refer to a predicate using _[module:]name(…arg…)_. For example predicate\_property/2 does this. That kind of suggests that such a term is a predicate … It is sometimes also called a _head_. And finally, of course we have the set of clauses that _X_ to a predicate. That is a clear entity you want to be able to talk about.

Somehow during all these years I thought a predicate is the set of clauses and a predicate indicator is the reference to it. That gives all terms a clear role, but it seems wrong ☹

Note that humans often don’t care too much about whether something is a reference or the thing itself. In “Bob is happy”, Bob is clearly a reference to an ever changing set of cells, but we tend to ignore that 🙂

As is, the best I can think of is to explain the mess ☹ and write that predicate can mean either a reference or the set of clauses. Better solutions are of course welcome.

---

<div class="post-metadata">

**Author:** ![stassa.p](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/stassa.p/32/712_2.png) [@stassa.p](https://swi-prolog.discourse.group/u/stassa.p)\
**Post date:** [September 29, 2021, 4:35pm UTC](https://swi-prolog.discourse.group/t/is-the-definition-of-predicate-correct-in-the-glossary-of-terms/2807/41 "2021-09-29T16:35:39Z")

</div>

I think that’s a more detailed and technical definition of a (logical) interpretation than the informal one I gave above: “an assignment of truth values to a predicate’s atoms”.

But note that an interpretation assigns truth values _to atoms_ not to a _predicate_ (in FOL). So in that sense, a predicate is still not a function that returns a boolean. A predicate doesn’t return anything and it doesn’t even have a value.

Another way to look at this is that a “predicate” is a set of atoms (facts) with the same symbol and arity. Atoms can be associated with a true or false value, which is the job of an interpretation, but not a property of the predicate itself.

This makes it harder to explain how and why Prolog “predicates” can be defined as both facts and rules, or a mix of two. I have seen (but I’m not sure where) an intensional definition of a predicate (one composed of a set of rules) referred to as a “name” for the predicate, but that would clearly sow the chaos of confusion far and wide- further and wider than what it already is.

---

<div class="post-metadata">

**Author:** ![stassa.p](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/stassa.p/32/712_2.png) [@stassa.p](https://swi-prolog.discourse.group/u/stassa.p)\
**Post date:** [September 29, 2021, 4:47pm UTC](https://swi-prolog.discourse.group/t/is-the-definition-of-predicate-correct-in-the-glossary-of-terms/2807/43 "2021-09-29T16:47:16Z")

</div>

> [@anon95304481](#):
>
> This is only true if your domain is the Herbrand domain or when you define truth as atom diagrams (you can have atom diagrams with or without Herbrand domain).

I’m not sure exactly about the “Herbrand domain”. Do you mean as in a Herbrand interpretation, mapping each constant to itself? Can you give an example?

---

<div class="post-metadata">

**Author:** ![stassa.p](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/stassa.p/32/712_2.png) [@stassa.p](https://swi-prolog.discourse.group/u/stassa.p)\
**Post date:** [September 29, 2021, 6:33pm UTC](https://swi-prolog.discourse.group/t/is-the-definition-of-predicate-correct-in-the-glossary-of-terms/2807/45 "2021-09-29T18:33:09Z")

</div>

Ah, with you. I know a “Herbrand domain” as “Herbrand universe” and “atom diagram” as “Herbrand base”. I think we’re just using slightly different terminologies, probably because we’ve studied different texts.

---

<div class="post-metadata">

**Author:** ![grossdan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/grossdan/32/23_2.png) [@grossdan](https://swi-prolog.discourse.group/u/grossdan)\
**Post date:** [September 30, 2021, 5:40am UTC](https://swi-prolog.discourse.group/t/is-the-definition-of-predicate-correct-in-the-glossary-of-terms/2807/47 "2021-09-30T05:40:55Z")

</div>

I wish there was an easy accessible resource for the theory behind logic programming - and Prolog in particular. A theory resource for the practicing programmer.

Does Prolog have a formal semantics?

[Previous page](https://swi-prolog.discourse.group/t/is-the-definition-of-predicate-correct-in-the-glossary-of-terms/2807.md?page=1)
