From dmiles@teknowledge.com Sun Jun 10 13:43:37 2001
Received: from helium.teknowledge.com (promethium.teknowledge.com [128.136.192.50])
	by swi.psy.uva.nl (8.11.2/8.11.2) with ESMTP id f5ABhZ301476
	for <prolog@swi.psy.uva.nl>; Sun, 10 Jun 2001 13:43:36 +0200 (MET DST)
Received: by helium.teknowledge.com with Internet Mail Service (5.5.2653.19)
	id <MJN6VJB8>; Sun, 10 Jun 2001 04:37:45 -0700
Message-ID: <EE25484266A64A47AE06CFC47C64232B4039A1@helium.teknowledge.com>
From: "Douglas R. Miles" <dmiles@teknowledge.com>
To: "'Sebastian Sardina'" <ssardina@cs.toronto.edu>
Cc: Jay Halcomb <jhalcomb@teknowledge.com>,
   "'prolog@swi.psy.uva.nl'"
	 <prolog@swi.psy.uva.nl>
Subject: RE: [SWIPL] constraint library?
Date: Sun, 10 Jun 2001 04:37:15 -0700
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2653.19)
Content-Type: text/plain;
	charset="iso-8859-1"

Sebastian,

There are not any prologs that I am aware of that supports argument type
checking on predicates (as part of it's kernel).  This is ussually something
we must do ourselves gladly.  If an implementor was to make this part of the
prolog kernel it would potentually create overhead for non typed problems.
Or potentually would not give ususers enough control on how it is done.


Its not too hard to implement as you can see in this simple example bellow:


% nth_domain(+Predicate,+Argument,+Collection)
nth_domain(loves,1,agent).
nth_domain(loves,2,entity).
nth_domain(covets,1,agent).
nth_domain(covets,2,entity).
nth_domain(friends,1,agent).
nth_domain(friends,2,agent).
nth_domain(enemy,1,agent).
nth_domain(enemy,2,agent).

nth_domain(instance_of,1,entity).
nth_domain(instance_of,2,collection).

instance_of(mark,agent).
instance_of(jake,agent).
instance_of(sue,agent).
instance_of(car,entity).
instance_of(X,Class):-subclass_of(Subclass,Class),instance_of(X,Subclass).

subclass_of(agent,entity).

loves(john,car).
enemy(john,jake).

covets(Who,What):-enemy(Who,Someone),loves(Someone,What).

my_call((X,Y)):-my_call(X),my_call(Y).
my_call((X;Y)):-my_call(X);my_call(Y).
my_call(G):-constrained_call(G)

constrained_call(G):-possible(G),chain(G).
constrained_call(not(G)):-possible(G),not(chain(G)).

chain(G):- clause(G,Ants),my_call(Ants).
chain(G):- G.

possible(X):-X=..[F|ARGS],nth_dom_check(F,0,ARGS).

nth_dom_check(_,_,[]).
nth_dom_check(F,N,[A|RGS]):-
		nth_domain(F,N,Class),
		instance_of(A,Class),
		NN is N +1 ,nth_dom_check(F,NN,RGS).

|?- loves(X,Y).

X = john
Y = car

|?- my_call(covets(X,Y)).
...
|?- my_call(non(covets(X,Y))).
...
etc


Douglas


> -----Original Message-----
> From: Sebastian Sardina [mailto:ssardina@cs.toronto.edu]
> Sent: Friday, June 08, 2001 5:54 AM
> To: Douglas R. Miles
> Subject: Re: [SWIPL] constraint library?
> 
> 
> YES! that's what I want..
> does SWI have something like that? mmm I think it does not right?
> 
> thanks
> 
> sebastian
> 
> "Douglas R. Miles" wrote:
> > 
> > Sebastian,
> > 
> > Are you refering to argument type constraints for 
> predicates?  So one can
> > use a therotical type ontology to define limited 
> possiblities for unbound
> > prolog varibles?
> > 
> > Douglas
> > 
> > > -----Original Message-----
> > > From: Sebastian Sardina [mailto:ssardina@cs.toronto.edu]
> > > Sent: Thursday, June 07, 2001 1:29 PM
> > > To: prolog@swi.psy.uva.nl
> > > Subject: [SWIPL] constraint library?
> > >
> > >
> > > I have asked this question before.
> > >
> > > Does SWI have any constraint library or module?
> > >
> > > Thanks
> > >
> > > Sebastian
> > >
> > >
> > > ----------------
> > > * To UNSUBSCRIBE, please use the HTML form at
> > >
> > >
> > > 
> http://www.swi.psy.uva.nl/projects/SWI-Prolog/index.html#mailinglist
> > >
> > > or send mail to prolog-request@swi.psy.uva.nl using the
> > > Subject: "unsubscribe"
> > > (without the quotes) and *no* message body.
> > >
> > > ** An ARCHIVE of this list is maintained at
> > >
> > >     
> http://www.swi.psy.uva.nl/projects/SWI-Prolog/mailinglist/archive/
> > >
> > >
> > >
> 
> 

