Re: forall implementation




"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:

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
it (I
think it goes into loop, having seen the memory footprint...).
I renamed the predicate in the following way, because PSharp use forall
in
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


.



Relevant Pages

  • Re: forall implementation
    ... I renamed the predicate in the following way, because PSharp use forall ... It is not clear what you are asking: there seems to be a bug in PSharp ... \+:- call,!, fail. ...
    (comp.lang.prolog)
  • Re: forall implementation
    ... Very nice, and the predicate is worth to use, but PSharp can't compile it (I ... It is not clear what you are asking: there seems to be a bug in PSharp ... \+:- call,!, fail. ...
    (comp.lang.prolog)
  • forall implementation
    ... Very nice, and the predicate is worth to use, but PSharp can't compile it (I ...
    (comp.lang.prolog)