240 points · by jonp · 11y ago · 128 comments
For example, can a version of the code be used to solve the 'hardest puzzle' -
https://xkcd.com/blue_eyes.html
(solution: https://xkcd.com/solution.html) ?
If you know someone else doesn't know, that just gives you more knowledge you yourself can use.
For the "hardest puzzle", on each day everyone learns that no one was able to figure out the solution the day before. Because of this, a person knows that for a possible number of blue-eyed people to be valid, a person who sees one less blue eyed person than that, must have been unable to figure it out on the previous day.
An Arc/Common Lisp solution I just wrote up: https://gist.github.com/malisper/80625bcda75c66780f81
I get your point. Still, it's hard to define the puzzle in terms of not-people. Maybe you could call them intelligent robots -- people might find it easier to picture mute robots with hats.
If you properly understand those rules and convert them to code (as in the OP) then searching the possible answers for a match is trivial.
The Singaporean government doesn't think Singapore English is a valid thing and wants everyone to learn "good" English. The Singaporean upper class is, as usual, on the government's side, and will complain about the poor English education in their country. That's fine for them, but please be aware that when you say "this is bad English" you are making a cultural and class-based judgment. What you really mean is the math question uses a way of expressing time that is familiar to them but not familiar to you.
def statement3(date):
possible_dates = tell(Month(date))
return (not know(possible_dates)
and not know(filter(lambda x : not know(x),
[tell(Day(d)) for d in possible_dates])))The Python solution proposed is really great, in that it captures both the expressive and functional spirit of the language.
You are overestimating how simple it is.There are more than 1200 comments on the solution on the NYTimes[1] almost all of them arguing that other dates are correct.
[1] http://www.nytimes.com/2015/04/15/science/answer-to-the-sing...
The original version of the puzzle (in the Singapore Math Olympiad) presented the dates in a sparse table format. This little bit of symbolic communication makes it much clearer that the answerer is supposed to cross off the dates by a process of deduction, making the puzzle simple to solve.
After eliminating May and June because they have unique days, which is obvious, I got stuck trying to figure out how Albert would be able to figure out the date after knowing that Bernard now knows the date. So I got stuck on July 16, Aug. 15 and Aug. 17 for a while, because I could not figure out how Albert would know the date if he was told August as the month. It took me a few minutes (ok, like 5 or so, more then I care to admit to my self I suppose :) ) to figure out that my job wasn't to figure out how Albert new, but rather to figure out what the answer was IF Albert now knew the answer.
From that it's pretty easy, but it's the perspective that trips most people up.
The trick is in figuring out what additional information is actually being added by whatever subsequent statements are being made.
It's weird. I usually have a lot of trouble with mathematical word puzzles. Particularly probability. But logic puzzles almost always seem to be pretty easy for me.
Now if you want a really fucking hard one, try your hand at this: http://en.wikipedia.org/wiki/The_Hardest_Logic_Puzzle_Ever
What, exactly, about vector spaces implies an order of operations?
so, no, arguing about the actual problem isn't bikeshedding :)
[1] http://en.wikipedia.org/wiki/Parkinson%27s_law_of_triviality
return (not know(possible_dates)
and all(not know(tell(Day(d)))
for d in possible_dates))
feels almost zen to me; or at least like Mr. Norvig likes himself some lisp at times.Write your specifications clearly, and then it does not become an internationally shared 'problem' to solve.
[I work with insanely documented specifications just like this, year after year. Not putting a problem clearly is not something to aspire to.]
Heck, it's not even clear that Albert and Bernard are communicating with one another and not merely with the answerer. If you assume they do not communicate at all then the puzzle becomes impossible.
I'm not clear on what the difference between a riddle and a logic puzzle would be in this context.
> If you assume they do not communicate at all then the puzzle becomes impossible.
Why would someone make an assumption that renders the puzzle impossible? I suppose the questioner could just be a troll or something.
Getting back to the article: the problem is worded so badly it should be sent back to the author to more coherently express what they think. Specifications, etc...
I don't really think it's especially obfuscated though. You just have to think about why people are saying what they say, which is a fairly useful thing to be able to do...
http://jdh.hamkins.org/transfinite-epistemic-logic-puzzle-ch...
When I did this a while back, my approach was to construct a 5x4 matrix with blanks (5 unique dates x 4 unique months). This allowed the clues to cross off entire rows and or columns until only 1 pair stood standing. Personally, I find the construction of the solution much more interesting than the problem itself given how many people participated.
There is no inference from silence. There is no humanity in such a question, there is simply the information you're given and the application of logic to narrow down the answers. The Singaporean kids that took the exam knew this and anyone that's ever taken a maths or logic exam should know this.
You don't guess what might have happened from human behaviour because you don't know, you don't look for a 'trick' to give away the answer, you simply use the data in the question to narrow down the possibilities until you can arrive at an answer.
The moment you think "but what if this action could have taken place because if he knew he would have said" you have failed.
And you probably suck at debugging.
the python solution is neat, but i have a feeling that there are tools that are more native to these kind of problems than general purpose programming language.
Translating roughly from the problem statement (x being the variable holding Cheryl's birthday):
Not(Know_Albert(x)) and Know_Albert(Not(Know_Bernard(x) etc.
Semantically, the possible birthdays correspond to the possible worlds. A reasoner would be able to solve this by process of elimination, somewhat similarly to a constraint-solver.
Resources:
Wikipedia entry on Epistemic Logic: http://en.wikipedia.org/wiki/Epistemic_modal_logic
Fagin, Ronald; Halpern, Joseph; Moses, Yoram; Vardi, Moshe (2003). Reasoning about Knowledge: http://www.amazon.com/Reasoning-About-Knowledge-Ronald-Fagin...
I haven't read the entire book, but the first couple of chapters give you an idea and some great examples not too different from this puzzle.
"iPython" already supports Haskell and Julia kernels too. A iPython Javascript kernel would also make sense given its popularity and its functional inspired syntax.
The real puzzles are:
1. "Why did Albert speak first?"
2. "Why did he speak in such cryptic language?"
He says, "At first I didn't know", so all he could have said if he had spoken first would have been "I don't know when the birthday is". Then Albert would have said, "I don't know when the birthday is, and I knew that Bernard couldn't have".
So the problem is unchanged regardless of who speaks first.
It also doesn't seem that cryptic to me... It doesn't take that much reading between the lines to understand the statement "at first I didn't know, but I know now" to mean "the information that Albert just provided gives me enough information to determine the birthday"...
Simply reordering the questions does not make sense, so I can't see it happening any way other than what I posted, which shows that it wouldn't change anything.
The suggestion that Albert's first statement necessarily eliminates all dates in May is false, and the answer is indeterminable, as can be readily verified with a Venn diagram. It took me some time to spot the flaw in the problem construction; I initially found the official solution persuasive, but when you think more carefully about it you realize it's actually wholly illogical.
Albert knows the month, and his statement, which translates directly to "given the month I know, it is not possible for Albert to independently determine the date" certainly does rule out the two months.
The whole ruckus surrounding this problem seems to be more a reflection of the sad state of the intelligence in our population, rather than anything to do with Asia.
Bernard: Silence (he doesn't know the answer)
Albert: Silence (he doesn't either)
Bernard: I know it!
Interestingly it then becomes relevant who was silent first.Basically it's nonsense.
1. "Why did Albert speak first?"
Before we answer this, we need to develop a set of assumptions to operate under. Given the synthetic nature of the problem, we might assume that both Albert and Bernard are of equal ability, and able to make logical inferences based on reasonable assumptions. We'll also assume that both Albert and Bernard are only going to announce the binary state of each others certainty of the answer. Lastly, we'll assume that whoever can deduce the binary state of certainty first, will speak first.
These assumptions, while a bit presumptuous, seem on the surface to adhere to the spirit of the puzzle.
Given those assumptions, what does it mean when Albert speaks first? It means that he's figured out the binary state of certainty before Bernard. How could that be?
If Bernard has the dates 18 or 19, then he knows that he knows, and he also knows that Albert does not know. If Bernard has any other date, he'll know that they both don't know. How does Bernard make this determination? He checks if his date is repeated anywhere.
Compare that to the logic that Albert must perform to rule out Bernard's certainty. He must check that all of the dates in his month are in fact repeated.
If they both perform these mental operations at the same speed, then Bernard should speak first in the case where he knows a unique date. The only reason why Bernard might not speak first is that he must also reason through whether or not Albert might know the date at this point. If Bernard holds an unrepeated date, the complexity of reasoning through Alberts situation boils down to considering only one month. But if Bernard holds a repeated date, he must consider Albert's situation for two months.
So, there exists a time past which Albert must know that Bernard is considering the more difficult situation, and thus he can infer that Bernard does not know.
If one assumes precise knowledge of the timing of logical operations, one can make even stronger inferences. To the point of even solving the entire problem without anyone every saying anything, for specific birthdays.
I will be the first to admit that this line of reasoning may require certain assumptions which are strained. Thus the question may still remain:
1. "Why did Albert speak first?"
Does anyone have a different set of logical assumptions which leads to Albert speaking first?
----
What this exposes really, is the more subtle assumption that the "correct" solution makes:
"There is only one way to make inferences in this puzzle."
The truth of that statement depends very much on the assumptions one makes about the puzzle. Most problematic is that most assumptions which makes that true, make it impossible for Albert to be the first speaker.
It's a kind of logical paradox brought on by the fact that synthetic logic problems do not map very well to real world situations.