Lady and Tiger Puzzle II (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 nds a lady he will marry her and if he opens a door and nds 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 knowledge helps him
to nd the only solution (see [3] and [2]).
Modeling Steps
In the same way as in model tiger1, we introduce two sets for the doors (d
and the prices (p
∈{
∈ {1 . . . 9})
Lady Tiger Empty}). We have 9 doors and three prices.
1. The binary variables are
xd,p ,
giving 27 binary variables (9 doors times 3 prices).
2. Furthermore, 9 binary variables (td ) 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]):
1
Listing 1: The Model
model tiger2 "Lady and Tiger Puzzle II";
set d := [1..9]
"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 tiger’s 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,1],’Lady’,’???’));
end
end
Solution
: We minimize 9 times, for each door once (in the
variable
xd,L
is minimized.
for-loop.
Each time, the
If the result (the optimum) is 1 then a lady is behind the
door, otherwise we do not know. Clearly, the lady is behind door 7. However, when the
E
constraint
is replaced by constraint
E1
(door 8 is empty), nothing can be deduced
about the lady. We deduce that we were told that door 8 is not empty.
Question
(Answer see )
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
(Question see )
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 door 8 the room is empty then
there are at least three tigers (in doors 2, 8, and 9).
2
2. In this case, we cannot deduce where the lady is, and whether the room behind door
8 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;
This problem has a unique solution (Empty, Tiger, Empty, Empty, Empty, 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
References
[1] T. Hürlimann. Reference Manual for the LPL Modelling Language, most recent version.
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.
3
© Copyright 2026 Paperzz