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:

The lady is in an oddnumbered room

This room is empty

Sign 5 is right or sign 7 is wrong

Sign 1 is wrong

Sign 2 or sign 4 is right

Sign 3 is wrong

The lady is not in room 1

This room contains a tiger and room 9 is empty

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 find the only solution (see [3] and [1]).
Modeling Steps
In the same way as in model tiger1, we introduce two sets for the doors (d ∈{1…9}) and the prices (p ∈{Lady, Tiger, Empty}). We have 9 doors and three prices.

The binary variables are x_{d,p}, giving 27 binary variables (9 doors times 3 prices).

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

The logical formulation of the constraints is now straightforward.
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{dd%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'] "Door 8 is empty";
E: ~x[8,'Empty'] "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 forloop. Each time, the variable x_{d,L} 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 behind door 7. However, when the constraint E 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”.
Questions

Can you tell where the tigers are?

What is the solution, if we replace the statement on door 1 by: “The lady is in an evennumbered room”.

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

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).

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{dd%1} x[d,’Lady’];
(The expression d%1 returns true, if (d mod 1) ⁄= 0.)

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] Nolan Clare. http://www.chlond.demon.co.uk/academic/puzzles.html.
[2] MatMod. Homepage for Learning Mathematical Modeling : https://matmod.ch.
[3] Smullyan R. The Lady or The Tiger. Oxford University Press, 1991.
[4] Hürlimann T. Reference Manual for the LPL Modeling Language, most recent version. https://matmod.ch/lpl/doc/manual.pdf.