%data
love(zhangxueyou, wanfei).
love(zhangxueyou, zouhuimin).
love(wanfei, xietinfen).
love(zouhuimin, zhangxueyou).
love(xietinfen, wanfei).
love(xietinfen, zouhuimin).
love(liudehua, zouhuimin).
%rules
lovers(X,Y) :- love(X,Y),love(Y,X).
%rival_in_love(X,Y) :- love(X,Z),not(love(Z,X)),love(Z,Y).
rival_in_love(X,Y) :- love(X,Z),love(Z,Y),X/=Y.
The above is a example in prolog programming language. I found that the "not" is ineffective in GNU Prolog. So, I have to
modify the rule "rival_in_love" by using "/=". Although, during developing I am aware that if we have "not" predicator we have
to adopt a non-natural or inconveniently way to slove our problem.
I re-debuged the prolog example command_loop. The following coding is also effective. I changed the "X == 'end'" to "X = 'end'".
Yes, unification will resulte in success.
cmd_loop :-
repeat,
write('Enter command (end to exit): '),
read(X),
write(X),
nl,
X = 'end', !.
love(zhangxueyou, wanfei).
love(zhangxueyou, zouhuimin).
love(wanfei, xietinfen).
love(zouhuimin, zhangxueyou).
love(xietinfen, wanfei).
love(xietinfen, zouhuimin).
love(liudehua, zouhuimin).
%rules
lovers(X,Y) :- love(X,Y),love(Y,X).
%rival_in_love(X,Y) :- love(X,Z),not(love(Z,X)),love(Z,Y).
rival_in_love(X,Y) :- love(X,Z),love(Z,Y),X/=Y.
The above is a example in prolog programming language. I found that the "not" is ineffective in GNU Prolog. So, I have to
modify the rule "rival_in_love" by using "/=". Although, during developing I am aware that if we have "not" predicator we have
to adopt a non-natural or inconveniently way to slove our problem.
I re-debuged the prolog example command_loop. The following coding is also effective. I changed the "X == 'end'" to "X = 'end'".
Yes, unification will resulte in success.
cmd_loop :-
repeat,
write('Enter command (end to exit): '),
read(X),
write(X),
nl,
X = 'end', !.