Re: Getting different results than Schrijvers
Michael Richter <[email protected]> Fri, 4 Apr 2014 07:43:01 +0800
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <CAGKutLsZrcWy6GWOmSHpwTA-EaXT5VC6oRXSrEMwcPrghv5EOQ@mail.gmail.com> |
I took this to the CHR mailing list and found the answer. First, the weird choice points thing is a result of, for some reason, having chr_option(debug, on) be the default in SWI-Prolog. This is not true for YAP (the only other Prolog I have installed which had CHR baked in). There was also some surprise expressed in the CHR mailing list that this was the default. That being said, adding this line of code to the neq.pl file solved that particular issue: :- chr_option(debug,off). The other one is a case of bad code. neq(X,Y) <=> X \= Y | true. This breaks one of the requirements of CHR: variables cannot be bound in the guard. Since X \= Y is \+ X = Y, the runtime is screwing up because there is an attempt to unify. The solution is to either use unifiable/3 like this: neq(X, Y) <=> unifiable(X, Y, _) | true. Or to explicitly check for instantiation: neq(X, Y) <=> ground(X), ground(Y) | X \= Y. On 31 March 2014 01:01, Anne Ogborn <[email protected]> wrote: > This example by Schrijvers (slide 94 of his presentation online) :- > chr_constraint neq/2. neq(X,X) <=> fail. > neq(X,Y) <=> X \= Y | true. ?- neq(a,a). > No > ?- neq(a,b). > Yes > ?- neq(A,B). > neq(A,B) However in SWI-Prolog (Multi-threaded, 64 bits, Version > 7.1.9-11-g3c17aed) 2 ?- neq(A,B). > false. > > Anybody know whats going on? > _______________________________________________ > SWI-Prolog mailing list > [email protected] > https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog > -- "Perhaps people don't believe this, but throughout all of the discussions of entering China our focus has really been what's best for the Chinese people. It's not been about our revenue or profit or whatnot." --Sergey Brin, demonstrating the emptiness of the "don't be evil" mantra. -------------- next part -------------- HTML attachment scrubbed and removed