From ok@atlas.otago.ac.nz Fri May 25 00:54:02 2001
Received: from atlas.otago.ac.nz (atlas.otago.ac.nz [139.80.32.250])
	by swi.psy.uva.nl (8.11.2/8.11.2) with ESMTP id f4OMs0304207
	for <prolog@swi.psy.uva.nl>; Fri, 25 May 2001 00:54:00 +0200 (MET DST)
Received: (from ok@localhost)
	by atlas.otago.ac.nz (8.9.3/8.9.3) id KAA413674;
	Fri, 25 May 2001 10:53:48 +1200 (NZST)
Date: Fri, 25 May 2001 10:53:48 +1200 (NZST)
From: "Richard A. O'Keefe" <ok@atlas.otago.ac.nz>
Message-Id: <200105242253.KAA413674@atlas.otago.ac.nz>
To: lcmason@attcanada.ca, prolog@swi.psy.uva.nl
Subject: Re:  [SWIPL] indexing clarification

	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.

