Re: SWI Prolog forgets identity of query variables in CHR ???
Henning Christiansen <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <[email protected]> |
Hello Uwe,
What I want is this:
> ?- c(X,Y).
> c(X,Y)
which is the corrct solution.
This one is wrong:
> ?- c(X,Y).
> c(_G30729,_G30730)
because it answers with a statement about two "local" variables fifferent from my "local", i.e. X and Y.
This is a minimalist example, of course, but when you want to derive more elaborate relationships among you query variables, it is a big problem.
I found a version of SICStus Prolog that uses the same CHR compiler as SWI, and it works the way I want, namely that my query variables X and Y are recognizable.
med venlig hilsen / best wishes
Henning
On 26 Feb 2014, at 14:56, Uwe Lesta <[email protected]> wrote:
> Hello Henning,
>
> What did you expect when queering ?- c(X,Y). ?
>
> Remember CHR select a constraint by matching the not by unification.
> If unification is needed the CHR constraint has to be
> c(X,Animal) <=> Animal = cow | d(X,pig).
>
> Hope this helps
>
> Uwe
>
>
>> -----Original Message-----
>> From: [email protected]
>> bonn.de [mailto:swi-prolog-bounces+lesta=sbs-
>> [email protected]] On Behalf Of Henning
>> Christiansen
>> Sent: Tuesday, February 25, 2014 12:43 PM
>> To: [email protected]
>> Subject: [SWIPL] SWI Prolog forgets identity of query variables in CHR
>> ???
>>
>> Hi SWIPL team,
>>
>> I observed strange problem that the identity of variables in CHR
>> queries are sometimes forgotten when the resylt is printed out.
>> I could isolate the problem into a one rule program.
>> For the two test queries, no rule is applied;
>> the first one behaves as you would expect, but in the second one, my
>> query variables gets renamed and thus the semantics of the answer is
>> wrong.
>>
>> If I have a program with no rules, no misbehaviour is observed
>>
>> (running on Mac OS 10.9.1)
>>
>> best wishes
>>
>> Henning
>>
>>
>> The program:
>>
>> :- use_module(library(chr)).
>> :- chr_constraint c/2, d/2.
>> c(X,cow) <=> d(X,pig).
>>
>> Queries:
>> $ swipl
>> Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 6.6.1-DIRTY)
>> ....
>>
>> ?- [program].
>> % library(chr) compiled into chr 0.51 sec, 6,504 clauses
>> % program compiled 0.51 sec, 6,551 clauses
>> true.
>>
>> ?- c(X,duck).
>> c(X,duck)
>> true .
>> c(X,duck)
>>
>> ?- c(X,Y).
>> c(_G30729,_G30730)
>> true .
>> c(_G30729,_G30730)
>>
>>
>>
>>
>>
>> Henning Christiansen
>> Professor of Computer Science, PhD
>> Leader of Research group PLIS: Programming, Logic and Intelligent
>> Systems
>> Department of Communication, Business and Information Technologies
>> Roskilde University
>> P.O.Box 260, DK-4000 Roskilde, DENMARK
>> http://www.ruc.dk/~henning
>>
>> -------------- next part --------------
>> HTML attachment scrubbed and removed
>> _______________________________________________
>> SWI-Prolog mailing list
>> [email protected]
>> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog