6
$\begingroup$

If there are only truth teller and liar, I used to solve with BooleanConvert or SatisfiabilityInstances. However for this one, how could I use Mathematica to solve?

Mr. Lee is a senior programmer, but there is something wrong with the three robots he recently designed: the one always tells the truth, the one always lies, and the other sometimes tells the truth, sometimes lies. Mr. Lee asked Dr. Gao for help to distinguish them. Dr. Gao took a look and asked 3 questions with them. The questions are shown below:

For the robot on the left side, Dr. Gao: Who is sitting next to you? Robot replied: A truth teller.

For the robot in the middle, Dr. Gao: Who are you? Robot replied: The guy always hesitant.

For the robot on the right side, Dr. Gao: Who is sitting next to you? Robot replied: A liar.

According to the above three question and answers to distinguish these robots.

I also tried BooleanTable, since I marked both liar and joker as false. But it seems this way is not general and succinct.

input and output of BooleanTable

$\endgroup$
1
  • 1
    $\begingroup$ Is "The guy always hesitant" the same as the joker the same as "sometimes truthful, sometimes not"? $\endgroup$ Sep 22, 2022 at 14:14

2 Answers 2

7
$\begingroup$

I use l, m, r for the left, middle, right robots respectively. Each can take the values $-1,0,1$ with the following interpretation:

truthteller[x_]:=(x==1);
joker[x_]:=(x==0);
liar[x_]:=(x==-1);

Using

claim[who_,what_]:=And[Implies[truthteller[who],what],
                       Implies[liar[who],Not[what]]];

the answers of the three robots are:

claims=And[
  claim[l,truthteller[m]],
  claim[m,joker[m]],
  claim[r,liar[m]]
];

Our general assumptions are

assumptions=And[l!=m!=r, (* no two robots are of same kind *)
                l*(l^2-1)==0,m*(m^2-1)==0,r*(r^2-1)==0 (* only -1,0,1 *) ];

We solve using:

Reduce[And[claims,assumptions],{l,m,r}]
(* l==0&&m==-1&&r==1 *)

From left to right: joker, liar, truthteller.

$\endgroup$
0
$\begingroup$

Thanks for the solution from user293787. It is very helpful to me.

After a lot of effort, I also worked out a way myself to solve this.

I define l, m, r as Roberts at left, middle, and right. t as truth-teller, i as liar, and h as hesitater. So, for example, "lt" means the proposition that "left Robert is a truth-teller", "mi" means the proposition that "middle Robert is a liar"

(1) l, m, r each take one role:

a = (lt \[And] mh \[And] ri) \[Or] (lt \[And] mi \[And] 
     rh) \[Or] (lh \[And] mt \[And] ri) \[Or] (li \[And] mt \[And] 
     rh) \[Or] ( 
    li \[And] mh \[And] rt) \[Or] (lh \[And] mi \[And] rt);

(2) the answers from three roberts:

b =  lt \[Implies] mt;
c = mt \[Implies] mh;
d = rt \[Implies] mi;

(3) l, m, r each can be only one of the role (no dual roles):

e = (lt \[And] \[Not] li \[And] \[Not] lh) \[Or] (\[Not] lt \[And] 
     li \[And] \[Not] lh) \[Or] (\[Not] lt \[And] \[Not] li \[And] lh);
f = (mt \[And] \[Not] mi \[And] \[Not] mh) \[Or] (\[Not] mt \[And] 
     mi \[And] \[Not] mh) \[Or] (\[Not] mt \[And] \[Not] mi \[And] mh);
g = (rt \[And] \[Not] ri \[And] \[Not] rh) \[Or] (\[Not] rt \[And] 
     ri \[And] \[Not] rh) \[Or] (\[Not] rt \[And] \[Not] ri \[And] 
     rh);

(4) Use BooleanConvert

a && b && c && d && e && f && g // BooleanConvert

or SatisfiabilityInstances

SatisfiabilityInstances[
 a && b && c && d && e && f && g, {lt, li, lh, mt, mi, mh, rt, ri, 
  rh}]

enter image description here

To sum up, with BooleanConvert or SatisifiabilityInstances or BooleanTable, it seems every logic problem like this can be solved.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.