Re: [eclipse-clp-users] Simple problem - strange effect

From: Philipp Marcus <marcus_at_...247...>
Date: Thu, 22 Apr 2010 19:28:00 +0200
Hi,

thanks for your hints. I've changed to IC and added the constraint  
X#=2. But now I still have too less propagation in my example:

    :-lib(ic).
    :-lib(propia).

    con1(1,1,0).
    con1(1,2,0).
    con1(1,3,0).

    cons(X,Y,B) :-
         con1(X,Y,B) infers most.

    execute(X) :-
         X#::[1,2,3],    cons(1,X)    or    X#=1 or X#=2.

Why is it not possible for IC to infer that the domain of X only 
consists of the elements [1,2]? Instead I get the output:

    ?- execute(X).
    X = X{1 .. 3}
    There are 4 delayed goals.
    Yes (0.00s cpu)

Best regards,
Philipp


Am 22.04.2010 15:48, schrieb Thorsten Winterer:
> Am 22.04.2010 15:19, schrieb Philipp Marcus:
>> Hi,
>>
>> given the following simple program:
>>
>>     :-lib(fd).
>>     :-lib(propia).
>>
>>     con1(1,1,0).
>>     con1(1,2,0).
>>     con1(1,3,0).
>>
>>     cons(X,Y,B) :-
>>         con1(X,Y,B) infers most.
>>
>>     execute(X) :-
>>         X#::[1,2,3],    cons(1,X)    #\/     X#=1.
>>
>>
>> I'd expect that the domain of X is reduced to the value 1 as the 
>> first term cons(1,X)  can never be true. But i only get the answer
>>
>>     ?- execute(X).
>>     No (0.00s cpu)
>>
>> I am wondering as (false \/ X=1 ) should imply that X has to be 1 to 
>> be true.
>
> The problem is that your are using fd instead of ic. fd's #\/ only 
> works with arithmetic constraints (see the documentation), whereas 
> ic's 'or' works with reified constraints:
>
>     :-lib(ic).
>     :-lib(propia).
>
>     con1(1,1,0).
>     con1(1,2,0).
>     con1(1,3,0).
>
>     cons(X,Y,B) :-
>         con1(X,Y,B) infers most.
>
>     execute(X) :-
>         X#::[1,2,3],    cons(1,X)    or     X#=1.
>
>
> ?- execute(X).
> X = 1
> Yes (0.00s cpu)
>
>
> Cheers,
> Thorsten
>
>
>
>
>>
>> Thanks in advance and best regards,
>> Philipp
>>
>>
>>
>> ------------------------------------------------------------------------------
>>    
>>
>>
>> _______________________________________________
>> ECLiPSe-CLP-Users mailing list
>> ECLiPSe-CLP-Users_at_lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/eclipse-clp-users
>>    
>
>
> ------------------------------------------------------------------------------
>    
>
>
> _______________________________________________
> ECLiPSe-CLP-Users mailing list
> ECLiPSe-CLP-Users_at_lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/eclipse-clp-users
>    
Received on Thu Apr 22 2010 - 17:28:05 CEST

This archive was generated by hypermail 2.2.0 : Mon Jul 09 2018 - 02:05:29 CEST