# What is the difference between head and predication

**URL:** <https://swi-prolog.discourse.group/t/what-is-the-difference-between-head-and-predication/4471>\
**Category:** Help!\
**Tags:** on-topic-only\
**Created:** [September 22, 2021, 1:20pm UTC](https://swi-prolog.discourse.group/t/what-is-the-difference-between-head-and-predication/4471 "2021-09-22T13:20:51Z")\
**Posts on this page:** 2\
**Page:** 1

<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 22, 2021, 1:20pm UTC](https://swi-prolog.discourse.group/t/what-is-the-difference-between-head-and-predication/4471/1 "2021-09-22T13:20:51Z")

</div>

The ISO Prolog standard notes

> `head` (of a rule): A predication, distinguished by its context.

> `predication`: A predicate with arity N and a sequence of N arguments.

> `predicate`: An identifier together with an arity.

> `clause`: A fact or a rule. It has two parts: a head, and a body.

clause noted because a clause is not just a head and this relates to just the head of a clause.

* * *

So my take is that there can be many heads for one predication, e.g.

`predication`

```prolog
append(_,_,_)

```

`head`

```prolog
append([], A, A)
append([A|B], C, [A|D])

```

Is this correct?

* * *

The distinction is usually just ignored but for my problem the distinction is needed, so it needs to be correct.

* * *

Demonstration with code

```prolog
?- use_module(library(lists)).
true.

?- compound_name_arity(Predication,append,3),nth_clause(lists:Predication,Index,Ref),clause(Module:Head,_,Ref),numbervars(Predication,0,_,[singletons(true)]),numbervars(Head).
Predication = append(_, _, _),
Index = 1,
Ref = <clause>(0000000006240B20),
Module = lists,
Head = append([], A, A) ;
Predication = append(_, _, _),
Index = 2,
Ref = <clause>(00000000067ACAA0),
Module = lists,
Head = append([A|B], C, [A|D]).

```

* * *

> **Personal notes**
>
> SWI-Prolog has a few predicates for looking at properties of internal structures, in particular  
> clause\_property/2 - `clause_property(+ClauseRef, -Property)`  
> predicate\_property/2 - `predicate_property(:Head, ?Property)`
> 
> clause/3 `clause(:Head, ?Body, ?Reference)` can convert a head to a clause reference or a clause reference to a head, thus it would seem there is a one to one correspondence between clause reference and head. If so then why two different property predicates?
> 
> If one looks at the properties returned by predicate\_property/2 for predicates with many different clauses, facts with many clauses are a good example, then it becomes apparent that properties are not unique per head but unique per predication, thus `head` makes more sense as `predication` and the predicate name makes more sense as predication\_property.
> 
> So think of `predicate_property(:Head, ?Property)` as `predication_property(:Predication, ?Property)`
> 
> * * *
> 
> Likewise
> 
> predicate\_name/2 - `predicate_name(:Head, -PredName:string)` as  
> `predicatation_name(:Predication, -Predicate_name)` where Predicate\_name is a string.
> 
> current\_predicate/2 - `current_predicate(?Name, :Head)` as  
> `current_predicate(?Name, :Predication)`
> 
> rule/2 - `rule(:Head, -Rule)` as  
> `rule(:Predication, -Rule)`
> 
> rule/3 - `rule(:Head, -Rule, -Ref)` as  
> `rule(:Predication, -Rule, - Ref)`
> 
> current\_arithmetic\_function/1 - `current_arithmetic_function(?Head)` as  
> `current_arithmetic_function(?Predication)`
> 
> current\_format\_predicate/2 - Need to understand this one first.
> 
> retractall/1 - `retractal(+Head)` as  
> `retractall(+Predication)`
> 
> pi\_head/2 - `pi_head(?PredicateIndicator, ?Goal)` as  
> `pi_head(?PredicateIndicator, ?Predication)`
> 
> head\_name\_arity/3 - `head_name_arity(?Goal, ?Name, ?Arity)` as  
> `head_name_arity(?Predication, ?Name, ?Arity)`
> 
> current\_predicate\_wrapper/4 - Need to understand this one first.  
> wrap\_predicate/4 - Need to understand this one first.
> 
> inferred\_meta\_predicate/2 - Need to understand this one first.  
> infer\_meta\_predicate/2 - Need to understand this one first.
> 
> iso\_builtin\_predicate/1 - `iso_builtin_predicate(?Head:callable)` as  
> `iso_builtin_predicate(?Predication)` where Predication is a callable term.
> 
> * * *
> 
> Predicates that use head
> 
> clause/2 - `clause(:Head, ?Body)`
> 
> * * *
> 
> When converting compiled code back into human readable code it is nice to have variable names like `A,B,C`. It is also nice to have the variable names correlate between the head and the body, the following code sample does this.
> 
> ```prolog
> ?- use_module(library(lists)).
> true.
> 
> ?- ?- current_predicate(append,Predication),rule(Predication,Rule),numbervars(Rule),numbervars(Predication,0,_,[singletons(true)]).
> Predication = append(_, _, _),
> Rule = append([], A, A) ;
> Predication = append(_, _, _),
> Rule = (append([A|B], C, [A|D]):-append(B, C, D)) ;
> Predication = append(_, _),
> Rule = (append(A, B):-must_be(list, A), append_(A, B)) ;
> false.
> 
> ```
> 
> * * *
> 
> How to check if a predicate uses a predication or head? Use the `append` predicates to check the results.
> 
> clause/2 uses a head and so returns multiple answers while predicate\_name/2 uses a predication and returns a single answer.
> 
> ```prolog
> ?- clause(append(_,_,_),Body).
> Body = true ;
> Body = append(_28534, _27022, _28540).
> 
> ?- predicate_name(append(_,_,_),Name).
> Name = "append/3".
> 
> ```
> 
> * * *
> 
> > [@Is the definition of "predicate" correct in the Glossary of Terms?](https://swi-prolog.discourse.group/t/is-the-definition-of-predicate-correct-in-the-glossary-of-terms/2807/3):
> >
> > I never understood the difference between _predicate_ and _procedure_ . ISO says
> > 
> > > 3.21 built-in predicate: A procedure whose execution is implemented by the processor (see 8).
> > 
> > This (to me) indicate _predicate_ and _procedure_ are synonyms. Before ISO I think the term _procedure_ was rarely used in the context of Prolog.
> > 
> > Does anyone know the history of this terminology?
> 
> In trying to understand what frame is with regards to [Environment Stack](https://www.swi-prolog.org/pldoc/man?section=manipstack) bumped into  
> [Frame (artificial intelligence)](https://en.wikipedia.org/wiki/Frame_(artificial_intelligence)) which notes
> 
> > Each piece of information about a particular frame is held in a slot. The information can contain:
> > 
> > - Facts or Data
> > - Values (called facets)
> > 
> > - Procedures (also called procedural attachments)
> > - IF-NEEDED : deferred evaluation
> > - IF-ADDED : updates linked information
> > 
> > - Default Values
> > - For Data
> > - For Procedures
> > 
> > - Other Frames or Subframes
> 
> At present don’t know if all of this is related to Prolog but it is the first time I have seen all of the terminology used in one place based on a historical perspective.
> 
> Ref: “A Framework for Representing Knowledge” by Marvin Minsky ([PDF](https://courses.media.mit.edu/2004spring/mas966/Minsky%201974%20Framework%20for%20knowledge.pdf))

---

<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 24, 2021, 6:47pm UTC](https://swi-prolog.discourse.group/t/what-is-the-difference-between-head-and-predication/4471/2 "2021-09-24T18:47:45Z")

</div>

I also find this confusing. Reminds me of [this](https://swi-prolog.discourse.group/t/is-the-definition-of-predicate-correct-in-the-glossary-of-terms/2807) discussion.
