I use GNU Prolog to solve a problem. I have defined the following predicate :
% P is the product of X and Y
produit(X,Y,P) :-
between(2,200,X),
between(2,200,Y),
X #<# Y,
X*Y #=# P.
% S is the sum of X and Y
somme(X,Y,S) :-
between(2,200,X),
between(2,200,Y),
X #<# Y,
X+Y #=# S.
%je ne peux pas deviner
clue_one(X,Y) :-
produit(X,Y,P),
XX*YY #=# P,
XX #\=# X,
XX #\=# 1,
YY #\=# 1,
XX #\=# Y.
%je le savais
clue_two(S) :-
forall(somme(X,Y,S), clue_one(X,Y)).
Prolog says that clue_two(17)
is true but when I try findall(S, clue_two(S), L)
, GNU Prolog returns the empty list. Why?
The
forall/2
de facto standard predicate is equivalent to:Due to the use of negation, no bindings resulting from the calls to either
Generator
orTest
are returned.