:-dlib_require(clp).
go:-
    write('% Show all pair of A,B,C<honest,liar>'),nl,
    write('% A says [ I am honest ]'),nl,
    write('% B says [ A is not honest,I am honest ]'),nl,
    write('% C says [ B is liar,I am honest ]'),nl,nl,

    TL =[honest,liar],
    Person = [A,B,C],
    Person in TL,
    who_say(A, A==honest ),    % A: I am honest
    who_say(B, A\==honest),    % B: A is not honest
    who_say(B, B==honest ),    % B: I am honest
    who_say(C, B== liar  ),    % C: B is liar
    who_say(C, C==honest ),    % C: I am honest
    labeling(Person),
        write(['A' is A,' B'  is B,' C' is C]),nl,
    fail.

who_say(Who,Say):- 
    arg(1,Say,One),
    freeze(Who,(Who==honest->freeze(One,Say);freeze(One,\+Say))).
