Subject: Re: [SWIPL] indexing clarification

From: "Richard A. O'Keefe" <[email-masked]>
Date: Fri, 25 May 2001 10:53:48 +1200 (NZST)

I would like some clarification on indexing.  Below I have quoted a 
	sentence from the documentation for 'index':
	
	"Only atoms, integers and functors (e.g. name and arity of a term) are 
	considered."
	
	What is meant by a 'functor'?  I assume this means that during indexing 
	grocery/6 is treated as a 'functor' and not as a term with functor '/' and 
	arity 2.  ie.  /(grocery,6)
	
No, what this means is simply this:

    for indexing, the only information about any term that is considered
    is its functor, that is, its name (which might be a number) and arity
    (number of arguments, 0 for any constant).

The functor of 42 is 42/0.
The functor of fred is fred/0.
The functor of grocery(banana, 6, kg, 500, dollar, cash) is grocery/6.

	So does that mean that the following can be indexed on the first
	argument?

	tables(grocery/6, A, B, tables(A, C, D), tables(B, C, D)).

ALL predicates are indexed on the (functor of the) first argument.
In this case, the index key is (/)/2.

	Also, do other prolog implementations do the same?
	
Mostly, ever since DEC-10 Prolog.  EMAS Prolog, C Prolog, and PDP-11 Prolog
didn't do any indexing at all, but I imagine they're pretty well dead now.
Some Prolog offer even more indexing, indexing-on-functor-of-first-argument
is pretty much the least indexing tolerable in a Prolog system.