|
The lady is in Room Seven.
Note: If room 8 was empty then there is not enough information to identify a unique location for the lady. Therefore, the king must have informed the prisoner that room 8 was not empty. This may be verified by experimentation with the following model.
Xpress-Mosel Model
model 'trial12'
! Description : The Logical Labyrinth
! Source : Smullyan, R., (1991), The Lady or The Tiger, Oxford University Press
! Date written : Xpress-MP 21/12/99, Mosel 19/4/03
! Written by : M J Chlond
uses 'mmxprs'
parameters
door = 9
prize = 3 ! 1 = Lady, 2 = Tiger, 3 = Empty
end-parameters
declarations
x: array(1..door,1..prize) of mpvar ! x(i,j) = 1 if door i hides prize j, else 0
t: array(1..door) of mpvar ! t(i) = 1 if statement on door i is true, else 0
end-declarations
any:= x(1,1)
! if statement on door 1 is true (i.e. x(1,1)+x(3,1)+x(5,1)+x(7,1)+x(9,1) = 1 )
! then t(1) = 1, else t(1) = 0
lca:= t(1) = x(1,1)+x(3,1)+x(5,1)+x(7,1)+x(9,1)
! if statement on door 2 is true (i.e. x(2,3)=1) then t(2) = 1, else t(2) = 0
lcb:= t(2) = x(2,3)
! if statement on door 3 is true (i.e. t(5)+x(1,1) > 1 ) then t(3) = 1, else t(3) = 0
lcc1:= t(5)+x(1,1)-2*t(3) <= 0
lcc2:= t(5)+x(1,1)-t(3) >= 0
! if statement on door 4 is true (i.e. t(1) = 0) then t(4) = 1, else t(4) = 0
lcd:= t(4) = 1-t(1)
! if statement on door 5 is true (i.e. t(2)+t(4) > 1) then t(5) = 1, else t(5) = 0
lce1:= t(2)+t(4)-2*t(5) <= 0
lce2:= t(2)+t(4)-t(5) >= 0
! if statement on door 6 is true (i.e. t(3) = 0 ) then t(6) = 1, else t(6) = 0
lcf:= t(6) = 1-t(3)
! if statement on door 7 is true (i.e. x(1,1) = 0) then t(7) = 1, else t(7) = 0
lcg:= t(7) = 1-x(1,1)
! if statement on door 8 is true (i.e. x(8,2)+x(9,3) = 2 ) then t(8) = 1, else t(8) = 0
lch1:= x(8,2)+x(9,3)-2*t(8) <= 1
lch2:= x(8,2)+x(9,3)-2*t(8) >= 0
! if statement on door 9 is true (i.e. x(9,2)+t(3) = 2) then t(9) = 1, else t(9) = 0
lci1:= x(9,2)+t(3)-2*t(9) <= 1
lci2:= x(9,2)+t(3)-2*t(9) >= 0
! each door hides 1 prize
forall(i in 1..door)
pca(i):= sum(j in 1..prize) x(i,j) = 1
! only one room contains lady
pcb:= sum(i in 1..door) x(i,1) = 1
! sign on lady's door is true
forall(i in 1..door)
lck(i):= t(i) >= x(i,1)
! sign on tigers' doors are false
forall(i in 1..door)
lcl(i):= t(i) <= 1 - x(i,2)
! if room 8 is empty then not enough information to pinpoint lady
! min and max x(7,1) give different results
! room 8 is empty
!pcc:= x(8,3) = 1
! if room 8 is not empty then enough information
! min and max x(7,1) gives same results
! if the prisoner was able to deduce where the lady was then
! room 8 must not have been empty
! room 8 is not empty
pcc:= x(8,3) = 0
forall(i in 1..door,j in 1..prize)
x(i,j) is_binary
forall(i in 1..door)
t(i) is_binary
minimise(any)
! display results
write('x =')
writeln
forall(i in 1..door) do
forall(j in 1..prize) do
write(getsol(x(i,j)),' ')
end-do
writeln
end-do
writeln
write('t =')
writeln
forall(i in 1..door) do
write(getsol(t(i)),' ')
writeln
end-do
end-model
|