[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Strange difference in FD between E*E and E**2
From: |
Fred Bapst |
Subject: |
Strange difference in FD between E*E and E**2 |
Date: |
Fri, 16 Dec 2011 15:17:25 +0100 |
User-agent: |
Mozilla/5.0 (Windows NT 5.1; rv:8.0) Gecko/20111105 Thunderbird/8.0 |
Hello,
With the following code, strangePower1(A,B) gives one solution, where the other
versions give two:
strangePower1(A,B) :-
fd_domain([A,B],0,5),
(A-B)**2 #> 16, % <-------
fd_labeling([A,B]).
strangePower2(A,B) :-
fd_domain([A,B],0,5),
(A-B)*(A-B) #> 16, % <-------
fd_labeling([A,B]).
strangePower3(A,B) :-
fd_domain([A,B],0,5),
A**2 -2*A*B +B**2 #> 16, % <-------
fd_labeling([A,B]).
| ?- strangePower2(A,B).
A = 0 B = 5 ? a
A = 5 B = 0
(15 ms) no
| ?- strangePower1(A,B).
A = 5 B = 0
yes
Can you explain why? Do you think this difference is reasonable from the
programmer's point of view?
Observed in gprolog-1.4.0, both in Win32 and Linux32.
Best regards.
- Strange difference in FD between E*E and E**2,
Fred Bapst <=