[m-dev.] Assocative predicates
pets at cs.mu.OZ.AU
Thu Apr 16 18:15:39 AEST 1998
On 16-Apr-98, Peter David ROSS wrote:
>My preferred solution is that the user annotates the predicates the
>user knows to be associative by some method. The issues that arise are that
>- these annotations need to be accessible by modules which import the
I'll let the people who understand transopt files address this...
>- the assocativity of a predicate depends on the mode of the
I think it's clearer to say that associativity is directional. Given a
predicate, say foo/5, you'd like to be able to say, for example, that
foo(A, B, C, D, E), foo(D, E, F, G, H)
is always equivalent to
foo(A, B, F, D, E), foo(D, E, C, G, H)
The statement is basically independent of the modes.
To say this, you have to say which arguments are "associated" with which
(that's a *really* bad choice of word there). In this example, the first and
fourth are associated, and so are the second and fifth. So maybe some syntax
:- pragma associative(foo(A, B, _, A, B)).
would give you what you need. For +, you might write
:- pragma associative(A+_ = A).
:- pragma associative(_+A = A).
Also keep in mind that in the future we may wish to allow declarations of
other interesting algebraic properties which the compiler might be able to
capitalize on. Commutativity is probably not too interesting, but
distributativity is. Having identities could be useful, maybe knowing if
there is a zero might be helpful.
And don't forget to check out my .sig of the day...
-Peter Schachte | Bill Gates is only a white persian cat and
mailto:pets at cs.mu.OZ.AU | a monocle away from being the villain in a
http://www.cs.mu.oz.au/~pets/ | James Bond movie.
PGP: finger pets at 184.108.40.206 | -- Dennis Miller
More information about the developers