Monty Hall Puzzle

From [1]:

the Monty Hall puzzle ... gets its name from the TV game show hosted by Monty Hall... A player is given the opportunity to select one of three closed doors, behind one of which there is a prize. Behind the other two doors are empty rooms. Once the player has made a selection, Monty is obligated to open one of the remaining closed doors which does not contain the prize, showing that the room behind it is empty. He then asks the player if he would like to switch his selection to the other unopened door, or stay with his original choice. Here is the problem: Does it matter if he switches?

Code

We use the predicates:

This is generalized version of monty.swinb because the player can here select any door.

:- use_module(library(pita)). :- if(current_predicate(use_rendering/1)). :- use_rendering(c3). :- endif. :- pita. :- begin_lpad. prize(1):1/3; prize(2):1/3; prize(3):1/3. % the prize is behind each door with probability 1/3 selected(1). % the player selected door 1 open_door(A):0.5; open_door(B):0.5:- member(A,[1,2,3]), member(B,[1,2,3]), A < B, \+ prize(A), \+ prize(B), \+ selected(A), \+ selected(B). % Monty opens door A with probability 0.5 and door B with probability 0.5 if % A and B are different doors, the prize is not behind any of them and the % player did not select any of them open_door(A):- member(A,[1,2,3]), \+ prize(A), \+ selected(A), member(B,[1,2,3]), prize(B), \+ selected(B). % Monty opens door A with probability 1 if the prize is not behind it, it is % not selected by the player and the prize is behind another door A that is % not selected win_keep:- selected(A), prize(A). % the player keeps his choice and wins if he has selected a door with the prize win_switch:- member(A,[1,2,3]), \+ selected(A), prize(A), \+ open_door(A). % the player switches and wins if the prize is behind the door that he has % not selected and that Monty did not open :- end_lpad.

What is the probability that the player wins if he keeps his choice?

prob(win_keep,Prob).

What is the probability that the player wins if he switches door?

prob(win_switch,Prob).

The probability if the player switches grows from 1/3 to 2/3.

Note that if you change the probability distribution of Monty selecting a door to open when the prize is behind the door selected by the player, then the probability of winning by switching remains the same. You can try it by modifying the third clause and rerunning the queries.

You can also visualize these values with:

prob(win_keep,Prob),bar(Prob,C).
prob(win_switch,Prob),bar(Prob,C).

References

[1] Chitta Baral, Michael Gelfond, and Nelson Rushton. "Probabilistic reasoning with answer sets." Theory and Practice of Logic Programming 9.01 (2009): 57-144. http://www.public.asu.edu/~cbaral/papers/plogJune20-08.pdf