Sie sind auf Seite 1von 4

Logical Puzzle about lady and tiger (tiger2)

Problem: A prisoner is faced with a decision where he must open one of


nine doors. The rooms behind each door may be empty or contain either a
lady or a tiger. If the prisoner opens a door and finds a lady he will marry
her and if he opens a door and finds a tiger he will be eaten alive.
The prisoner would prefer to be married than either be eaten alive or
to face emptiness. Each door has a sign bearing a statement which may be
either true or false.
The statements on the nine doors are:

1. The lady is in an odd-numbered room

2. This room is empty

3. Sign 5 is right or sign 7 is wrong

4. Sign 1 is wrong

5. Sign 2 or sign 4 is right

6. Sign 3 is wrong

7. The lady is not in room 1

8. This room contains a tiger and room 9 is empty

9. This room contains a tiger and sign 6 is wrong

In addition, the prisoner is informed that only one room contains a lady;
each of the others either contain a tiger or are empty. The sign on the door
of the room containing the lady is true, the signs on all the doors containing
tigers are false, and the signs on the doors of empty rooms can be either true
or false.
The prisoner is told whether or not room eight is empty and this know-
ledge helps him to find the only solution (see [3] and [2]).

Modeling Steps
In the same way as in model tiger1.lpl we introduce two sets for the doors
(d) and the prices (p). Now we have 9 doors and three prices.

1. The binary variables are then x{d,p}, giving 27 binary variables (9


doors times 3 prices).

1
2. Furthermore, 9 binary variables (t{d}) are introduces, saying whether
the statement on door d is true or false.

3. The logical formulation of the constraints is now straightforward.

The complete model code in LPL for this model is as follows (see [1]):

MODEL tiger2 "Logical Puzzle about lady and tiger";


SET d := /1:9/ "The 9 doors";
p := /Lady Tiger ’Empty’/ "The prices";
BINARY VARIABLE x{d,p} "Behind door d is price p";
t{d} "The statement on the doors";
CONSTRAINT
D1: t[1] <-> OR{d|d%2} x[d,’Lady’];
D2: t[2] <-> x[2,’Empty’];
D3: t[3] <-> (t[5] OR x[1,’Lady’]);
D4: t[4] <-> ~t[1];
D5: t[5] <-> (t[2] OR t[4]);
D6: t[6] <-> ~t[3];
D7: t[7] <-> ~x[1,’Lady’];
D8: t[8] <-> (x[8,’Tiger’] AND x[9,’Empty’]);
D9: t[9] <-> (x[9,’Tiger’] AND t[3]);
A{d}: XOR{p} x "Each door hides exactly one prize";
B: XOR{d} x[d,’Lady’] "Only one room contains a lady";
C{d}: x[d,’Lady’] -> t "Sign on lady’s door is true";
D{d}: x[d,’Tiger’] -> ~t "Sign on tigers’ doors false";
--E1: x[8,’Empty’]=1 "Door 8 is empty";
E: x[8,’Empty’]=0 "Door 8 is not empty";

FOR{d} DO
MINIMIZE any: x[d,’Lady’];
WRITE ’Behind door %1s is a %5s\n’:
d , if(x[d,’Lady’],’Lady’,’???’);
END
END

We minimize 9 times, for each door once (in the FOR-loop. Each time, the Solution
variable x[d,’Lady’] is minimized. If the result (the optimum) is 1 then
a lady is behind the door, otherwise we do not know. Clearly, the lady is

2
behind door 7. However, when the constraint E is replaced by constraint E1
(’door 8 is empty’), nothing can be deduced about the lady.

Question 1 (Answer to 1)

1. Can you tell where the tigers are?

2. What is the solution, if we replace the statement on door 1 by: ’The


lady is in an even-numbered room’.

3. Suppose we add the statement “there are exactly 3 tigers in three doors”
to the original problem. What is the solution?

Answer 1 (Question of 1)

1. We replace the two statements within the FOR loop by the following:

MINIMIZE any: x[d,’Tiger’];


WRITE ’Behind door %1s is a %5s\n’:
d , if(x[d,’Tiger’],’Tiger’,’???’);

Using E, nothing can be said. However, if behind the door 8 the room
is empty then there are at least three tigers (in doors 2, 8, and 9).

2. In this case, we cannot deduce where the lady is, whether behind door
8 the room is empty or not. The constraint D1 must be changed to the
following:

D1: t[1] <-> OR{d|d%1} x[d,’Lady’];

(The expression d%1 returns true, if (d mod 1) 6= 0.)

3. The constraint to be added is as follows:

F: SUM{d} x[d,’Tiger’] = 3;

3
This problem has a unique solution (Empty, Tiger, Empty, Empty, Em-
pty, Empty, Lady, Tiger, Tiger). To check this we use the following loop
(27 optimizations):

FOR{d,p} DO
MINIMIZE any: x[d,p];
IF x THEN WRITE ’Behind door %1s is a %5s\n’: d,p; END
END

Literatur
[1] T. Hürlimann. Reference Manual for the LPL Modelling Language. http:
//www.virtual-optima.com.

[2] Clare Nolan. http://www.chlond.demon.co.uk/academic/puzzles.


html.

[3] R. Smullyan. The Lady or The Tiger. Oxford University Press, 1991.

Das könnte Ihnen auch gefallen