Knights, normals and spies
Merlin's Book of Logic Puzzles p65#1
Knights tell the truth, spies lie, and normals do both.
Merlin interviews three people: A,B,C: one spy, one knight
and one normal but doesn't know who is which.
- A says C is not a spy.
- B says A is not a knight
- B says B is a knight.
Who is the spy, knight and normal in A, B, and C.
Notation
- K(x)::= x is a knight,
- S(x)::= x is a spy,
- N(x)::= x is normal.
- says(x,P)::=x says P.
Axioms
Knights tell the truth, spies lie, and normals do both:
- says(x,P)= (K(x) and P) or (S(x) and not P ) or N(x).
The above is not true of the real world, but fits the
world of the puzzle well.
Three people a,b,c, with one K , one S and one N .
Some observations
- |-if x=y then (N(x) and N(y)) = N(y) else (N(x) and N(y)) = false.
- |-if x=y then (S(x) and S(y)) = S(y) else (S(x) and S(y)) = false.
- |-if x=y then (K(x) and K(y)) = K(y) else (K(x) and K(y)) = false.
- |-if x<>z then (N(x) and not N(z)) = N(x).
- |-if x<>z then (S(x) and not S(z)) = S(x).
- |-if x<>z then (K(x) and not K(z)) = K(x).
The Three Statements
Net
- says(a, not S(c)).
- says(b, not K(a)).
- says(c, K(b)).
(End of Net)
Abreviations and Mapping to Boolean Algebra
|
|
|---|
| Leave out "(", ")"
|
| Use nothing for "and".
| PQ
| P and Q.
|
| Use prefix "-" for "not".
| -P
| not P.
|
| Use infix "-" as "and not"
| P-Q
| P*(-Q).
|
| Use "+" for "or".
| P+Q
| P or Q.
|
For example
- Kx = K(x) = x is a knight.
- says(x,P) = KxP + Sx-P + Nx.
- says(a, not Sc) = Ka-Sc + Sa-Sc + Na.
- Sa-Sc = Sa.
Consider
(A): Ka-Sc + SaSc + Na
- = Ka-Sc + 0 + Na
- = Ka-Sc + Na.
(B): Kb-Ka + SbKa + Nb
- =Kb + SbKa +Nb.
(C): KcKb + Sc-Kb + Nc
- = Sc-Kb + Nc.
- (A, C) |- (AC):
- (Ka-Sc + Na) (Sc-Kb + Nc)
- = Ka-ScScKb + NaSc-Kb + Ka-ScNc + NaNc
- = 0 + NaSc-Kb + 0 + NaNc
- = Na-KbSc + KaNc.
- (AC, B) |-
- (Na-KbSc + KaNc) (Kb + SbKa + Nb)
- = Na-KbSc(Kb + SbKa + Nb) + KaNc (Kb + SbKa + Nb)
- = NaNbSc + KaSbNc
- = 0 + KaSbNc
- = KaSbNc.
(Close Consider )
So
- A is a knight, B is a Spy, and C is Normal.
Check via Prolog
[ kns1.plg ]