« Return to Thread: maplist and friends

Re: maplist and friends

by Ulrich Neumerkel :: Rate this Message:

Reply to Author | View in Thread

On Monday 21 Apr 2008 16:06:27 Samer Abdallah wrote:

> On 21 Apr 2008, at 14:33, Ulrich Neumerkel wrote:
> > On Monday 21 Apr 2008 12:48:13 Samer Abdallah wrote:
> >> ...   However, the body can include an explicit existential
> >> quantification so that, eg
> >>         ?- maplist( \(A):- B^(A=B), [a,b,c,d]).
> >> succeeds leaving B unbound.
> >
> > What about
> >
> > ?- B = a, maplist( \(A):- B^(A=B), [a,b,c,d]).
> ...
> > which should succeed (or produce an error), since the B at the top is
> I'm not sure why you would expect it to succeed - perhaps
> you are reading the existential quantification differently from
> me? My interpretation is that the existential quantification
> is to make it behave exactly like an auxiliary predicate defined
> in the usual way:
>         aux(A) :- A=B
> which has the implicit quantification, ie, it means
>         (exists B . A=B)  => aux(A)

Yes, so the B outside in B = a must be something different, entirely
unrelated to the quantified B.  It is the same as renaming the
internal B to B1.

Remark that you will succed for

?- maplist( \(A):- B^(A=B), [a,b,c,d]), B = a

as well, which would be consistent with the success of

?- B = a, maplist( \(A):- B^(A=B), [a,b,c,d]).

As we have here a pure program the conjunction G, H should be the same
as H, G.  You might have issues about termination and similar to
settle, but otherwise there cannot be any differences.

The most sensible would be some static checking, but there the
difficulties start...

Note that ensuring B being a variable is not sufficient, as it may share
with other variables in conflicting scope.

------------
For further info, please visit http://www.swi-prolog.org/

To unsubscribe, send a plaintext mail with "unsubscribe prolog <e-mail>"
in its body to majordomo@...

 « Return to Thread: maplist and friends

LightInTheBox - Buy quality products at wholesale price