For years I've been using Prolog, this is the first time I come across dif/2 predicate ! (Edited) Anyway I just tried dif/2 in swi-prolog and found it is readily available as a *constraint* in clpfd. But it is not recognised by eclipse-clp.
In eclipse-clp, sound disequality is available as (~=)/2: www.eclipseclp.org/doc/bips/kernel/termcomp/TE-2.html You can easily make this an alias for dif/2. dif/2 is also available in SICStus Prolog. Enjoy!
= is a predefined infix operator, and an operator cannot be a direct operand of an operator (such as /). Therefore, I am writing (=)/2, so that the predicate indicator is itself also a valid Prolog term. For example, using Scryer Prolog, we get: ?- write_canonical((=)/2). /(=,2) On the other hand, =/2 is not a valid Prolog term: ?- write_canonical(=/2). error(syntax_error(incomplete_reduction),read_term/3:1).
@@ThePowerOfProlog Thanks for the clarification. With SWI-Prolog, if I write write_canonical(=/2) I obtain an error message, but if I enter write_canonical(;/2) then I obtain /(;,2). Isn't ; an operator also ?
@@bertrandduguesclin826 SWI-Prolog cannot be used to tell what is Prolog syntax and what is not, because SWI-Prolog is not conforming to the Prolog ISO standard. For learning Prolog syntax, I recommend to use a conforming Prolog system. For example, with Scryer Prolog, we get: ?- write_canonical(;/2). error(syntax_error(incomplete_reduction),read_term/3:1). ?- write_canonical((;)/2). /(;,2) true. This is because ';' is an infix operator, and therefore cannot be used as a direct operand of another operator (such as '/').
if I have a problem like gossip(X) : X loves to gossip friend (X,Y) : X is a friend of Y knows(X,S) : X knows the secret S X knows the secret and blurt it out to his friend so what is we want to find the predicate for gets-to-know(X,S) :-
For years I've been using Prolog, this is the first time I come across dif/2 predicate !
(Edited) Anyway I just tried dif/2 in swi-prolog and found it is readily available as a *constraint* in clpfd. But it is not recognised by eclipse-clp.
In eclipse-clp, sound disequality is available as (~=)/2:
www.eclipseclp.org/doc/bips/kernel/termcomp/TE-2.html
You can easily make this an alias for dif/2. dif/2 is also available in SICStus Prolog. Enjoy!
Saved a life
Why do you define the unification predicate as (=)/2 and not =/2 ?
= is a predefined infix operator, and an operator cannot be a direct operand of an operator (such as /). Therefore, I am writing (=)/2, so that the predicate indicator is itself also a valid Prolog term. For example, using Scryer Prolog, we get:
?- write_canonical((=)/2).
/(=,2)
On the other hand, =/2 is not a valid Prolog term:
?- write_canonical(=/2).
error(syntax_error(incomplete_reduction),read_term/3:1).
@@ThePowerOfProlog Thanks for the clarification. With SWI-Prolog, if I write write_canonical(=/2) I obtain an error message, but if I enter write_canonical(;/2) then I obtain /(;,2). Isn't ; an operator also ?
@@bertrandduguesclin826 SWI-Prolog cannot be used to tell what is Prolog syntax and what is not, because SWI-Prolog is not conforming to the Prolog ISO standard. For learning Prolog syntax, I recommend to use a conforming Prolog system. For example, with Scryer Prolog, we get:
?- write_canonical(;/2).
error(syntax_error(incomplete_reduction),read_term/3:1).
?- write_canonical((;)/2).
/(;,2) true.
This is because ';' is an infix operator, and therefore cannot be used as a direct operand of another operator (such as '/').
@@ThePowerOfProlog ok Thank you
Danke! Thank You
if I have a problem like
gossip(X) : X loves to gossip
friend (X,Y) : X is a friend of Y
knows(X,S) : X knows the secret S
X knows the secret and blurt it out to his friend so what is
we want to find the predicate for gets-to-know(X,S) :-
you can define false, by not defining false xD