[m-dev.] Assocative predicates

Peter Schachte pets at students.cs.mu.OZ.AU
Thu Apr 23 11:36:24 AEST 1998


On Thu, 16 Apr 1998, Fergus Henderson wrote:

> How about just `pragma assert(Goal)'?
> 
> 	:- pragma assert(all [A,B,C] (A+B)+C=A+(B+C)).
> 
> 	:- pragma assert(all [A,B,C,D,E,F,G,H] (
> 		foo(A, B, C, D, E), foo(D, E, F, G, H) <=> 
> 		foo(A, B, F, D, E), foo(D, E, C, G, H))).
> 
> This syntax seems to be nice, at least from the user's perspective.

The generality and straight-forwardness of your proposal is certainly
appealing.  I'd like to see implicit quantifiers, but your recent mail
cleans that up rather nicely.

However, I still think there is something to be said for using words people
recognize like "associative," "commutative," etc.  I suppose that can be
done in comments, but how about allowing users (and the standard library) to
define properties.  Maybe something like

:- pragma assertion(associative_function(F) = (F(A,F(B,C)) = F(F(A,B),C))).
:- pragma assertion(associative_predicate(P) = (
	P(A,B,C), P(C,D,E) <=> P(B,C,F), P(A,F,E)
).

and then

:- pragma assert(associative_function(+)).
:- pragma assert(associative_predicate(append)).

Better still, perhaps the overloading resolution mechanism could be used to
avoid the need for the `_function' and `_predicate' suffixes. 


-Peter Schachte               | The secret of being miserable is to have the
mailto:pets at cs.mu.OZ.AU       | leisure to bother about whether you are
http://www.cs.mu.oz.au/~pets/ | happy or not. The cure is occupation.
PGP: finger pets at 128.250.37.3 |     -- George Bernard Shaw 




More information about the developers mailing list