dining-philosophers-le.le · output · proof · check · playground
The question
Five diners share five chopsticks around a table. Each diner picks up their left chopstick first and needs their right one to eat. Given a sequence of actions, how many diners finish, and can anyone still move?
Historical background
Dijkstra used five philosophers sharing forks to illustrate synchronization. He showed how each philosopher can take their left fork and end up waiting for their neighbor. James S. Plank’s operating-systems lecture presents the same problem with chopsticks. This example represents the scheduling choices as action lists that the reasoner can replay and check. Edsger W. Dijkstra, EWD 310 · James S. Plank, Dining Philosophers
What we tell eyemind
A state records the diners holding their first chopstick and the diners who have finished. A diner who has done neither can take their first chopstick if it is free. A diner who holds their first can take their second if it is free, eat, and release both in a single action.
The rules replay the listed actions with all chopsticks initially free. A schedule ends in deadlock if some diners still need to eat and there is no legal next action. Another rule reports that the schedule can continue whenever a next action is available.
What eyemind concludes
| Schedule | Diners served | Verdict |
|---|---|---|
| Taking turns | 5 | Everyone served |
| Everyone takes first | 0 | Deadlock |
| One pickup | 0 | Can continue |
When all five pick up their left chopsticks, each required right chopstick is already held, so the checker reports this answer.
struct('le:answer', 'verdicts', 'dinner', 'everyone takes first', 'deadlock')
What the proof establishes
The saved proof is checked. Each listed action is legal at its point in the schedule, and the deadlock verdict accounts for every possible next action in the final state.
Try it
node bin/eyemind.js examples/dining-philosophers-le.le
node bin/eyemind.js --check-proof examples/proof/dining-philosophers-le.js examples/dining-philosophers-le.le
Remove Eve’s pickup from the everyone takes first schedule. Chopstick
5 stays free, Alice can eat, and the verdict becomes can continue.
