I have a very simple program using library(clpfd) but I am confused as to why a possible answer is not being reported. The program is as follows:
:- use_module(library(clpfd)). solution1(A, D, B) :- B #= A + (A // D), D #> 0, D #< 101, A mod D #= 0, A #> 99, A #< 1000, A #< B, label([A, D, B]). solution2(A, N, D, B) :- B #= A + (A * N) // D, N #> 0, N #< 100, D #> 0, D #< 101, N #< D, (A * N) mod D #= 0, A #> 99, A #< 1000, A #< B, label([A, N, D, B]).
When I set B to a specific value, I get the following answers:
2 ?- solution1(A, D, 749). A = 642, D = 6 ; false. 3 ?- solution2(A, N, D, 749). A = 378, N = 53, D = 54 ; A = 385, N = 52, D = 55 .
As you can see… solution2 is where the constraint has the numerator (N) and denominator (D) specified, but solution1 is where N = 1 and so the constraints are simplified.
What I don’t understand is why doesn’t solution2 report a solution for N = 1 and D = 6? I have probably done something very silly but I can’t see it.