4 Oct 22:46
Re: 5.7.X : problem with attributed variables and memberchk ?
From: Victor NOEL <victor.noel <at> crazydwarves.org>
Subject: Re: 5.7.X : problem with attributed variables and memberchk ?
Newsgroups: gmane.comp.ai.prolog.swi
Date: 2008-10-04 20:46:13 GMT
Subject: Re: 5.7.X : problem with attributed variables and memberchk ?
Newsgroups: gmane.comp.ai.prolog.swi
Date: 2008-10-04 20:46:13 GMT
On Sat, Oct 04, 2008 at 10:08:59PM +0200, Bart Demoen wrote: > > > ?- A in 0..5, B in 6..7, memberchk(A, [B, C]). > > false. > > > > > > Shouldn't the last one return : > > A = C, > > C in 0..5, > > B in 6..7. > > > > ? > > First a look at: > > ?- help(memberchk). > memberchk(?Elem, +List) > Equivalent to member/2, but leaves no choice point. > > This is enough to answer your question: yes, you are correct about > your expectation. > > In fact, the implementation of pl_memberchk in pl-list.c cuts the > choicepoint before executing woken goals. It is a bit tricky to get > this correct (from within C), but currently it doesn't deliver what > the manual promises I think. If memchk/2 is written in Prolog, you get > what you expect. > > How did you find this bug ? It is complicated to explain, in simple : I have a big program using memberchk and it was not doing what it should be doing :> I tried for a long time understanding what happened, at first I thought it was the constraints on the variables that were not compatibles so the results would have been normal, but after a lot of test (now I know how to make attributes(portray) for write_term/2 works :) I reduced it to this little example. The program is a general argumentation framework that combines preference reasoning, abduction and constraint programming. I am working on the inclusion of constraint programming to it, you can take a look at if you want, there is a hg branch for it there : https://dev.crazydwarves.org/trac/Gorgias Regards, Victor
RSS Feed