% The Famous Barber's paradox % In a certain village, there is a barber who shaves % those residents who do not shave themselves, % and all residents who don't shave themselves % are shaved by the barber. :-op(600, xfx, shaves). resident(X):-(X=jim ; X=john ; X=barber). shaving(X):- barber shaves X ; X shaves X. barber shaves X:-!,resident(X), X\=barber, print(X), write(' can be shaved by the barber'), nl. X shaves X:-!, resident(X), X\=barber, print(X), write(' can shave himself'), nl. X shaves Y:-print(X), write(' shaves '), print(Y), write('............NOT!'), nl, fail. go:-resident(X),shaving(X),fail. paradox:-trace, resident(Who), Who shaves barber.