Re: [eclipse-clp-users] Boolean value behaviour

From: Joachim Schimpf <jschimpf_at_coninfer.com>
Date: Mon, 8 Feb 2016 11:51:27 +0000
On 08/02/16 04:01, Edgaonkar, Shrirang wrote:
> Dear clp users,
>
>   Following is the script that executes:-

Maybe it would help if you stopped thinking of your programs as "scripts",
and understand them as logical statements that the system interprets.


>
> Script 1:
>
> :- lib(ic).
> solveNull(A,B):-
>
> A #:: 0..1,
> B #:: 0..1,
>
> A #\= B,
> B #= 1.
>
> It provides the solution of A as 0 and B as 1 but I do not wish to have A as 0.

The beauty of Logic Programming is that it can make logical inferences
for you *automatically*.  If you say that A is 0 or 1, and it isn't 1,
then the system can infer that A is 0, and it can do this *at any time*.


> I wish to restrict A to be var(See the script 2 below. It should pass.).

Being "var" is not a logical restriction/constraint.  It is a
temporary state during computation, and the constraint system
may replace the variable with a value *at any time*.
Try not to fight the system, work with it!


> ...  but I wanted my search subroutine to decide the value of A.

Fix your search routine.  It cannot expect all variables still to be
uninstantiated ("var").  Search routines usually can simply ignore
variables that are already instantiated (because there is no need
to "search" for their value any more).


-- Joachim
Received on Mon Feb 08 2016 - 11:51:23 CET

This archive was generated by hypermail 2.2.0 : Sat Feb 13 2016 - 00:13:14 CET