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 finds a lady he will marry her and if he opens a door and finds 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 [3] and [1]).
Modeling Steps
Let’s define two sets for the doors d = {12} (’1’ for door 1, ’2’ for door 2) and for the prices p = {TL} (’T’ for Tiger, ’L’ for Lady).

We introduce a binary variable (Boolean proposition) x_{d,p} for each (d,p)– combination. For example, x_{1,L} means that “behind door 1 there is the lady”. This statement can be true (x_{1,L} = 1) or false (x_{1,L} = 0).

Behind each door is exactly one price (a tiger or a lady). This can be formulated as a Boolean constraint. For each door d we have: _{p} x_{d,p}. Formulated as a mathematical equality, this is ∑ _{p}x_{d,p} = 1 for each door d.

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:
x_{1,L} ∧ x_{2,T }

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:
∨ _{d}x_{d,L} ∧∨ _{d}x_{d,T }

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 ( ):

We want to know whether a lady is behind door 1, for example. Hence, we minimize x_{1,L}. If the solution would be x_{1,L} = 1, we know for sure that behind door 1 there is a lady and we open it! Otherwise, we want to know if the lady is behind door 2 and therefore minimize x_{2,L}. If the solution of this second objective would be x_{2,L} = 1, we knew for sure that behind door 2 there is a lady. In all other cases we don’t know!
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.
Questions

How can we be sure that the solution is the only one? All we did was to minimize x_{1,L} then minimize x_{2,L}.

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!

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!

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!

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!

Modify the problem as follows: (1) The statement on door 1 says: “It makes no difference 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!
Answers

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.

We need to replace the second constraint by the following one:
∨ _{d} x_{d,L} ↔ x_{1,T }
The complete model is at: tiger1a.

We need to replace the second constraint by the following one:
(x_{1,T } x_{2,L}) ↔ x_{1,L}
The complete model is at: tiger1b.

We need to replace the second constraint by the following one:
(∧ _{d} x_{d,L} ↔ x_{1,L}) ∧ (∧ _{d} x_{d,L} x_{2,L})
The complete model is at: tiger1c.

We need to replace the second constraint by the following one:
(∨ _{d} x_{d,L} ↔ x_{1,L}) ∧ (x_{1,L} x_{2,L})
The complete model is at: tiger1d.

We need to replace the second constraint by the following one:
(∨ _{p} (∧ _{d} x_{d,p}) ↔ x_{1,L}) ∧ (x_{1,L} x_{2,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
endThe complete model is at: tiger1e.
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.