【演習問題5:パズル``正直者と嘘つき'' (TPTP/PUZ025-1)】

true-->native(a),native(b),native(c).
true-->a_truth(says(a,equal_type(b,c))).
true-->ask_1_if_2(c,equal_type(a,b)).
native(A)-->a_truth(truthteller(A));a_truth(liar(A)).

native(A),native(B),a_truth(liar(A)),a_truth(liar(B))
    -->a_truth(equal_type(A,B)).
native(A),native(B),a_truth(truthteller(A)),a_truth(truthteller(B))
    -->a_truth(equal_type(A,B)).

a_truth(truthteller(A)),a_truth(says(A,B))-->a_truth(B).
a_truth(A),a_truth(says(B,A))-->a_truth(truthteller(B)).
a_truth(says(A,B))-->a_truth(B);a_truth(liar(A)).
a_truth(equal_type(A,B)),a_truth(truthteller(A))
    -->a_truth(truthteller(B)).
a_truth(equal_type(A,B)),a_truth(liar(A))
    -->a_truth(liar(B)).
a_truth(truthteller(A)),native(B)
    -->a_truth(equal_type(A,B));a_truth(liar(B)).
a_truth(liar(A)),native(B)
    -->a_truth(equal_type(A,B));a_truth(truthteller(B)).
a_truth(equal_type(A,B))
    -->a_truth(equal_type(B,A)).

ask_1_if_2(A,B),a_truth(truthteller(A)),a_truth(B)
    -->answer(yes).
ask_1_if_2(A,B),a_truth(truthteller(A))
    -->a_truth(B);answer(no).
ask_1_if_2(A,B),a_truth(liar(A)),a_truth(B)-->answer(no).
ask_1_if_2(A,B),a_truth(liar(A))-->a_truth(B);answer(yes).

a_truth(truthteller(A)),a_truth(liar(A))-->false.
a_truth(liar(A)),a_truth(says(A,B)),a_truth(B)-->false.
answer(A)-->false.