Re: [eclipse-clp-users] testing NOT existence

From: Alexandre Saidi <Alexandre.Saidi_at_ec-lyon.fr>
Date: Mon, 26 Apr 2010 10:53:02 +0200
Hi all,
another way is to test :
	not (not (foo(X)).

since "not not P = P" and that WITHOUT variable binding.

Please adapt « not » (eg. use « \+" if necessary).

Alex

Le 15 avr. 2010 à 15:58, Matthew Skala a écrit :

> On Thu, 15 Apr 2010, david wrote:
>> For example, assume foo/1 is a dynamic predicate, and that there are
>> rules such as:
>> 
>>   foo(X) :- goo(X).
>> 
>> Is there a way to test if there are any assertions of foo/1? One would
>> want to avoid any "false positives" due to, say, goo/1 being satisfied.
> 
> If you don't care about side effects of goo/1 and just want to know
> whether foo(X) succeeds with a specific, not general, value of X, then you
> could do this:
> 
> specific_foo(X):-
>   foo(Y),Y==X.
> 
> Note that specific_foo(bar) will succeed with foo(X):-goo(X). goo(bar).
> 
> If you want to test for the existence of a clause with exactly foo(bar) as
> its head, not any variable, you could do this:
> 
> head_foo(X):-
>   clause(foo(Y):-_),Y==X.
> 
> Note that head_foo(bar) will succeed with foo(bar):-fail.  It *only* looks
> at the head.
> 
> If you want to test explicitly for a fact with no body, you could do this:
> 
> fact_foo(X):-
>   clause(foo(Y):-true),Y==X.
> 
> That succeeds with foo(bar) but not with foo(bar):-goo(bar).
> 
> It should be easy to imagine other variations of using clause/1 and ==/2
> depending on just what you want to query for.  Note that all of these
> break the logic programming model and you probably should think hard about
> whether what you're attempting to do is *really* a good idea.
> -- 
> Matthew Skala, postdoctoral researcher, Universities of Toronto and Waterloo
> mskala_at_cs.toronto.edu    mskala_at_cs.uwaterloo.ca    mskala_at_ansuz.sooke.bc.ca
> 
> ------------------------------------------------------------------------------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> ECLiPSe-CLP-Users mailing list
> ECLiPSe-CLP-Users_at_lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/eclipse-clp-users

 -------------------------------
Alexandre Saidi
Maitre de Conférences
Ecole Centrale de Lyon-Dép. MI
LIRIS-CNRS UMR 5205
Tél : 0472186530, Fax : 0472186443
Received on Mon Apr 26 2010 - 08:53:11 CEST

This archive was generated by hypermail 2.2.0 : Thu Feb 02 2012 - 02:31:58 CET