Sie sind auf Seite 1von 4

Lady and Tiger Puzzle I (tiger1[1])

Problem : In this puzzle a prisoner is faced with a decision where he must open one of two
doors. Behind each door there either is a lady or a tiger. There might be two tigers, two
ladies or one of each. 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. Of course, the prisoner would
prefer to be married than eaten alive. Each of the doors has a sign bearing a statement
that may be either true or false.
The statement on door 1 says, In this room there is a lady, and in the other room is
a tiger. The statement on door 2 says, In one of these rooms there is a lady, and in one
of these rooms there is a tiger. The prisoner is informed that one of the two statements
is true and one is false. Which door should he open? (see [4] and [3]).

Modeling Steps
Let's dene two sets for the doors d={ 1 2 } ('1' for door 1, '2' for door 2) and for the
prices p={ T L } ('T' for Tiger, 'L' for Lady).

1. We introduce a binary variable (Boolean proposition) xd,p for each (d, p)- combina-
tion. For example, x1,L means that behind door 1 there is the lady. This statement
can be true (x1,L = 1) or false (x1,L = 0).

2. There is exactly one price behind each door is exactly one price (the tiger or the
lady), that is, for each door we have either a lady or a tiger. This can be formu-

lated as a Boolean constraint. For each door d we have: ˙ xd,p 1


W
Formulated as a
P p
mathematical equality, this is p xd,p = 1 for each door d.

3. The statement on door 1 is equivalent to saying There is a lady behind door 1 and
a tiger behind door 2. The straightforward implementation is:

x1,L ∧ x2,T 2

4. The statement on door 2 is equivalent to saying A lady is behind one door and a
tiger is behind one door. The formulation is:

xd,T 3
W W
d xd,L ∧ d

5. Exactly one of the two statements on the two doors is true which means that we
˙ ):
must connect the two statements with an exclusive or operator ( ∨

_ _
x1,L ∧ x2,T ∨˙ ( xd,L ∧ xd,T )
d d

6. We want to know whether a lady is behind door 1, for example. Hence, we minimize
x1,L . If the solution would be x1,L = 1, we know for sure that behind door 1 there is
1 We use p ∨˙ q to express the Boolean exclusive or: exactly one of both p and q is true. The indexed
˙
W
version is: i∈I xi meaning that exactly one of all xi with i ∈ I is true.
2 The operator ∧ is used for the Boolean and: p ∧ q is true if and only if both p and q are true. The
V
indexed version is i∈I xi which is true if and only if all xi with i ∈ I are true.
3 The operator ∨ is used to express the Boolean or: p ∨ q is true if and only if at least one of p and q
W
is true. The indexed version is i∈I xi which is true if and only if at least one xi with i ∈ I is true.

1
a lady and we open it! Otherwise, we want to know if the lady is behind door 2 and
therefore minimize x2,L . If the solution of this second objective would be x2,L = 1,
we knew for sure that behind door 2 there is a lady. In all other cases we don't
know!

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

Listing 1: The Model


 
model tiger1 "Lady and Tiger Puzzle I";
set d:= [1 2] "The two doors";
p:= [Lady Tiger] "The prices";
binary variable x{d,p} "Behind door d is price p";
constraint
A{d}: xor{p} x "Each door hides exactly one prize";
B: x[1,’Lady’] and x[2,’Tiger’] xor
or{d} x[d,’Lady’] and or{d} x[d,’Tiger’]
"Exactly one statement written on the doors is true";
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 : Behind door 1 there is a tiger and behind door 2 there is a lady. Further
investigations show that this is the unique solution.

Question (Answer see )

1. How can we be sure that the solution is the only one? All we did was to minimize
x1,L then minimize x2,L .

2. Modify the problem as follows: (1) The statement on door 1 says: At least one of
these rooms contains a lady. (2) The statement on door 2 says: A tiger is in the
other room. (3) We are told that these two statements are either both true or both
false. Build the model and solve it!

3. Modify the problem as follows: (1) The statement on door 1 says: Either a tiger
is in this room or a lady is in the other room. (2) The statement on door 2 says:
A lady is in the other room. (3) We are told that these two statements are either
both true or both false. Build the model and solve it!

4. Modify the problem as follows: (1) The statement on door 1 says: Both rooms
contain a lady. (2) The statement on door 2 says: Both rooms contain a lady. (3)
We are also told that if a lady is in room 1 then the statement (1) is true otherwise
it is false, and if a lady is in room 2 then the statement (2) is false otherwise it is
true. Build the model and solve it!

5. Modify the problem as follows: (1) The statement on door 1 says: At least one
room contains a lady. (2) The statement on door 2 says: The other room contains
a lady. (3) We are told that if a lady is in room 1 then the statement (1) is
true otherwise it is false, and if a lady is in room 2 then the statement (2) is false
otherwise it is true. Build the model and solve it!

2
6. Modify the problem as follows: (1) The statement on door 1 says: It makes no
dierence which room you pick. (2) The statement on door 2 says: There is a lady
in the other room. (3) We are told that if a lady is in room 1 then the statement
(1) is true otherwise it is false, and if a lady is in room 2 then the statement (2) is
false otherwise it is true. Where are the ladies and where are the tigers? Build the
model and solve it!

Answer (Question see )

1. We are not sure! All we know after the two optimizations is where the ladies are
(there might be two), if there are any. If both optimizations yield zero then we do
not know where they are. We can then repeat the optimizations for the tigers to be
sure where they are. But again, if this optimization gives zero, then we still know
nothing and we cannot derive any knowledge from the logical statements concerning
the location of the prices.

2. We need to replace the second constraint by the following one:

xd,L ↔ x1,T 4
W
d
The complete model is at: tiger1a[1].

3. We need to replace the second constraint by the following one:

(x1,T ∨˙ x2,L ) ↔ x1,L


The complete model is at: tiger1b[1].

4. We need to replace the second constraint by the following one:


V
( xd,L ↔ x1,L )∧
d
( d xd,L ∨˙ x2,L )
V

The complete model is at: tiger1c[1].

5. We need to replace the second constraint by the following one:

xd,L ↔ x1,L ) ∧ (x1,L ∨˙ x2,L )


W
( d
The complete model is at: tiger1d[1].

6. We need to replace the second constraint by the following one:

˙
W V
( p ( d xd,p ) ↔ x1,L ) ∧ (x1,L ∨ x2,L )
We want to have the complete knowledge about where each price is hidden. Hence,
we optimize 4 times (loop over d, p). Hence, we replace the loop by the following
instructions:

for{d,p} do
minimize any: x[d,p];
if x then write ’Behind door %1s is a %5s\n’: d, p; end
end

The complete model is at: tiger1e[1].

4 We use the Boolean operation ↔ for the equivalence: p↔q means  p is true if and only if q is true.

3
References
[1] T. Hürlimann. Model Library. lpl.unifr.ch/lpl/mainmodel.html.

[2] T. Hürlimann. Reference Manual for the LPL Modelling Language, most recent ver-
sion. www.virtual-optima.com.

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


html.

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