When Is Cheryl's Birthday?(nbviewer.ipython.org) |
When Is Cheryl's Birthday?(nbviewer.ipython.org) |
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
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.
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.
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.
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?"
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...
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
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"...
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.
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.
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.
so, no, arguing about the actual problem isn't bikeshedding :)
[1] http://en.wikipedia.org/wiki/Parkinson%27s_law_of_triviality
If we can deduce the answer from silence then there's no need for any of the information given in the question, it's not a logic puzzle it's bullshit.
I don't assume Albert and Bernard are anything, if you've made assumptions beyond what's stated in the question then you've done it wrong.
And yes, I understand timing oracles.
What, exactly, about vector spaces implies an order of operations?
(For those who don't get the reference, every so often some variant of "a + b * 0 + c = ?" will show up in the public's attention and receive very emotional arguments about how it must be 0, or must be a+c, or must be c, or it must be ambiguous and therefore undefined. Similarly to the logic puzzle programmers can just point to the problem expressed in Python for the correct answer...)
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.
Bernard: I don't know when Cheryl's birthday is.
Albert: I don't know when Cheryl's birthday is.
Bernard: I know when Cheryl's birthday is now.
Albert: Then I also know when Cheryl's birthday is.
I don't think it's really a good critique of a logic problem to say, "but if you remove this extremely important part, it doesn't work anymore"!
The conversation would need to be:
Bernard: I don't know when Cheryl's birthday is
Albert: I don't know when Cheryl's birthday is, and I knew that Bernard didn't know.
Bernard: Then I know when Cheryl's birthday is now.
Albert: Then I also know when Cheryl's birthday is.
Then it works. You only have to assume that the parties are logical and tell the truth.
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.
I am seeing this claim a lot, but I do not understand it. Why would readers assume that a riddle is a bunch of nonsense, rather than something with an objective answer?
> To borrow your Ode To Joy example, it's like trying to learn to play the piece after the sheet music had been torn and tattered, burned and stained with coffee.
I don't see the analogy, because I had no trouble understanding the wording of the puzzle. I thought it was extremely clear and precise. To use your analogy, I feel like I'm looking at a pristine professionally-notated piece of sheet music while everyone else is saying it's torn and tattered.
Different people carry different assumptions with them throughout their lives. Not everybody approaches a logic puzzle with the mental preparation of solving logic puzzles. They aren't looking to analyze the statements and they don't carry the assumption that the statements carry just enough information to solve it. Instead, they might expect some trick or play on words to give a "stupid" answer.
because I had no trouble understanding the wording of the puzzle
But you do have trouble understanding that other people might be different from you; with different experiences, assumptions, etc.
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.
The speed at which they come to their conclusions, and who speaks first is meaningless. I think perhaps if you are taking them into account then you are trying to come up with a completely different problem, or intentionally being disingenuous.
Given the context (that this is a question on a high school test), it is safe to assume that Albert and Bernard are only drawing logical conclusions from the information Cheryl provides and what each other say.
Given that the problem works with no problems under these assumptions, and that there is enough information to re-word it with Bernard speaking first that does not change the answer, it seems pointless to try and look for timing attacks or other outlandish ways to change the answer...
That's your own assumption. And that's a perfectly fine assumption to make, but not a universally chosen one.
Maybe my other comment was right and they should have been called Alice, Bob, and Carol.
The way I read the question, it's as though a moderator said: "Albert, tell me what's on your mind." "Bernard?" "Albert?"
I will add that #4 should certainly be in the past tense ("at first I didn't know") because this way Albert and Bernard are in on the fact that they're part of a logical puzzle!! They should not know that they are characters in a puzzle.
This is how I read the puzzle:
Moderator to Albert: tell the reader what you know.
Albert: I don't know when Cheryl's birthday is, but I know that Bernard does not know too.
Moderator to Bernard: And you, Bernard?
Bernard: At first in this puzzle I don't know when Cheryl's birthday is (before Albert spoke), but now that you have asked Albert, and I've heard his response, I've figured it out.
Moderator to Albert: And any thoughts from you, now that Bernard has figured it out?
Albert: Yes. Given the information Bernard has now stated, I would say I also know Cheryl's birthday now.
If you're even thinking about this then you have failed the question, it's a puzzle that asks you to derive a correct answer from the data provided, not from your conjectures about human behaviour.
Bernard: Cheryl told me it's the 17th.
Albert: Cheryl told me it's in August.
Because of this, solutions are often not logical.
In essence, this is the true test of the puzzle; not whether you can solve the intended puzzle, but whether or not you can muster sufficient social and analytical empathy to work with others when your assumptions turn out to be incongruent with the intended assumptions.
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.
People might very well be able to solve even fairly complex logic problems without having been exposed to this tradition of encoding such problems.
The problem is stated as three persons having an odd, but casual conversation. To outsider that's all they're doing and to those the problem is impenetrable. Insiders, however, immediately recognise the informal protocol of logic quizzes that this is not a random casual conversation, it is carefully written to encode just enough information to be solvable as a logic problem. These insiders know to carefully extract (decode) this information. Only then do they solve the logic problem.
The "dishonesty" of the problem, which is confusing to people expecting the problem to be stated honestly, is that the conversation in the problem is entirely contrived, there is no way is would ever happened as part of a real world exchange about birthdays. This is fine for the intendeded reader, school kids trained in this protocol, but in "going viral" it went to a lot of unintended recipients.
When Albert says I don't know when Cheryl's birthday is, but I know that Bernard does not know too, consider There are no unique days in the month I was told.
Informally, note the difference of order. If Albert said "I was told the Birthday is in July", that would be, say, first order. The plain version I provide is a logical statement about the months and dates, a second order statement. But the cryptic version is a statement about what (second-order) statements Bernard can make, so third order. Hence, cryptic.
Which is probably intended, as otherwise I would have thought he meant to say "before Cheryl had told me, I didn't know".
In the context of Albert's statement though, it couldn't mean that - Albert's statement is saying that Bernard does not have enough information to determine the date just based on what Cheryl told him, so in saying "at first I did not know, but now I know", the only difference between "at first" and "now" is Albert speaking.
So Bernard's comment could only mean, "Based on what Cheryl told me, I did not know what the birthday was, but given the extra information I have as a result of Albert's statement, now I know"
Incidentally, I get a similar feeling from these puzzles that I get from code questions or examples where every variable or function is named 'a' or 'b' or 'foo' or 'bar'.
(aaand I just had a mini-epiphany of sorts that when I see those types of programming puzzles I should probably write them out and substitute the variable names as I go....)
If you dont initially grasp the above then Albert's initial declaration "I don't know when Cheryl's birthday is" just seems to be a redundant statement that doesn't offer any information. And thats just the first hurdle of the puzzle.
A lot of people hate maths-questions-stated-as-stories, even simple ones ("There are several chickens and rabbits in a cage (with no other types of animals). There are 72 heads and 200 feet inside the cage. How many chickens are there, and how many rabbits?" etc etc) so to people like that, this Cheryl-birthday problem initialy presents as hopelessly cryptic.
If you can't piece everything together then... well you're not suited to logical analysis.
That started me thinking outside the confines of the problem and about the implicit assumptions that were in the problem statement itself. The 'inability to piece everything together' is entirely imaginary on your part.
That's certainly a reasonable thing to do.
What's not reasonable is to assume that the assumptions you make are going to match the assumptions of others. Likewise, when make assumptions there is a chance that the assumptions you make are incorrect.
That may or may not be the case here.
But the fact remains, you need to make some very strong assumptions for what you have said to be true.
>> Given that this question is about humans
Please note that nowhere in the questions does it say the participants are human. This is one of your many assumptions.