Re: forall implementation
- From: "Carlo Capelli" <carlo.capelli@xxxxxxxx>
- Date: Fri, 15 Sep 2006 08:19:39 +0200
"bart demoen" <bmd@xxxxxxxxxxxxxx> ha scritto nel messaggio
news:pan.2006.09.14.21.10.21.516318@xxxxxxxxxxxxxxxxx
On Thu, 14 Sep 2006 19:26:24 +0200, Carlo Capelli wrote:it (I
I found the following code in SWI-Prolog:
forall(A, B) :-
\+((
A,
\+B
)).
Very nice, and the predicate is worth to use, but PSharp can't compile
inthink it goes into loop, having seen the memory footprint...).
I renamed the predicate in the following way, because PSharp use forall
LLP context,
runall(A, B) :-
\+((
call(A),
\+B
)).
but it doesn't work.
It is not clear what you are asking: there seems to be a bug in PSharp
and you want us to find a way around it ? You should ask Jon Cook directly
about bugs in P#.
My simple minded replacement obviously doesn't work:
runall(A, B) :-
repeat,
runall_(A, B).
runall_(A, B) :-
call(A),
call(B),
fail.
runall_(_, _).
Sure, your replacement obviously does not work. What do you expect ?
Prolog code that circumvents the P# bug ?
Maybe the following will work: since we know that \+ can be implemented
by
\+(G) :- call(G), !, fail.
\+(_).
try expanding (or inlining, or unfolding) this definition in the original
def of forall.
Show us what you get :-)
Cheers
Bart Demoen
Many thanks Bart, I will try...
In the meanwhile, I think a possible solution could be
runall(A,B) :- findall((A,B), call((A,B)), _).
that seems to work.
Bye Carlo
.
- References:
- forall implementation
- From: Carlo Capelli
- Re: forall implementation
- From: bart demoen
- forall implementation
- Prev by Date: Re: The n-knights problem
- Next by Date: Re: forall implementation
- Previous by thread: Re: forall implementation
- Next by thread: Re: forall implementation
- Index(es):
Relevant Pages
|
|