News for hackers. Stuff that matters.
Re:A liar who always lies says "All my hats are green." by rawgabbit on Monday December 09, 2024 @11:46AM (#42367798)
I never liked this type of puzzle. It is not formal logic but more about the idiosyncrasies and conventions of the English language. I put this puzzle on par with Agatha Christie’s murder mysteries. It requires a suspension of disbelief and logic to be believable.

Someone who always lies means in the purest sense means you cannot trust anything they say. Even the word “hat” could mean they are talking about their pet cat that they like to carry on their head.

What the author would probably say is “All my hats are green” means the liar is either lying about All or Green. Either all their hats are some other color or only one hat is green. This means you have to assume the liar has a hat. How do we know that?

We only know that because of similar puzzles that came before. In other words this is not logic but more pattern recognition.

Re:A liar who always lies says "All my hats are green." by mjburgess on Monday December 09, 2024 @11:56AM (#42367899)
This is generally the case for the vast majority of puzzles, and it equally drives me mad in those areas where academics set "puzzles" and conclude that people's inabilty to "solve" them is some cognitive deficiency.

I've rarely encountered a case where it is isnt an extreme lack of self-awareness in the questioner -- eg., being extremely overfit to language/notation/etc. localised to their own area of expertise.

Re:A liar who always lies says "All my hats are green." by sillysaurusx on Monday December 09, 2024 @12:19PM (#42368085)
It’s not so much that an inability to solve them means you’re deficient, as it is that an ability to solve them means you’re capable in ways most people aren’t. My wife is great at puzzles, and it’s always humbling to watch her sail through them.

I agree that puzzles alone shouldn’t e.g. determine whether you’re a good fit for a job, though. That’s one of the more annoying parts of software interviewing.

Re:A liar who always lies says "All my hats are green." by mjburgess on Monday December 09, 2024 @12:26PM (#42368147)
I think it should be the duty of the person asking the question to find a isomorphism to another question that the majority of people can answer.

Eg., rather than asking about the risks of A,,B,C given various probabilities etc. ask them to make bets in a highly familiar environment with a resource that has uniform marginal utility to them... so eg., "suppose you were at home and your friend does..., how much of your time on a sunday would you bet to do... "

You find that when "the very same question" is asked in highly familiar terms people get it right.

Then this investigator-academic should ask: what features of their own puzzle induce the kind of mistakes they see?

In my experience its often that people are far less socially incompetent than questioners, so put "interpretation & trust" priors on terms/presentations of questions that mean they don't parse the presentation into the problem the investigator has in mind.

People who write puzzles tend to be the most bureaucratic sort of literalists who have profoundly eccentric modes of interpretation

The problem that most people are solving is: "what do i say to make this person/question go away"

Re:A liar who always lies says "All my hats are green." by hinkley on Monday December 09, 2024 @01:16PM (#42368797)
> The problem that most people are solving is: "what do i say to make this person/question go away" reply

This is it.

Never attribute to incompetence that which can be readily attributed to apathy.

Re:A liar who always lies says "All my hats are green." by crazygringo on Monday December 09, 2024 @12:27PM (#42368164)
> as it is that an ability to solve them means you’re capable in ways most people aren’t.

No, because the point is that they always hinge on an arbitrary distinction to give one answer. But if you made a different arbitrary distinction you'd get a different answer. And the arbitrary distinctions are, well, arbitrary. They reflect neither truth nor capability. Just whether you can read the questioner's mind as to what arbitrary and intentionally unstated assumptions they are making.

No thanks.

Re:A liar who always lies says "All my hats are green." by stevenAthompson on Monday December 09, 2024 @12:39PM (#42368309)
Logic itself is a relatively new invention, and is symbolic itself. That is to say, logic is a map not the territory.

That said, if someone can't fathom the most widely used symbolic languages humans use (math, logic, language, etc) they probably do have a cognitive deficit of some sort when compared to those who can.

Re:A liar who always lies says "All my hats are green." by lotharcable2 on Monday December 09, 2024 @03:14PM (#42370073)
It is less 'logic is new'... it more about abstract thinking is a skill that is more useful in societies that have complex social arrangements.

If you are a primitive farmer abstract thinking isn't really useful to you. Everything you deal with in your life, except religion, can almost entirely be dealt with absolutes with little in the way of abstractions.

If it rains at the right time then you can have a good harvest. If the weather is bad then it sucks. If there is animals threatening your crops or herd you need to take steps to deal with them.

There is a lot of logic in dealing with these things. You have to know the seasons, know the stars, know the dirt, etc. You have to understand the life cycle and manipulate the behavior and biology of plants and animals at the right stages in their lives. Things have a logical sequence and there are direct consequences that are predictable from events and your actions.

Where as in modern society you have been conditioned to think in terms of hypothetical and abstractions through being exposed to testing your entire life.

You first need to know how test questions work before you are able to answer them accurately.

For a person who isn't exposed to this then the whole affair of asking hypotheticals and assuming imaginary situations with specific rules that don't actually apply to the present reality is very confusing.

They don't even understand the question. So, of course, they are going to suck at answering them.

And ultimately that is all IQ testing measures.. your ability to take tests.

Re:A liar who always lies says "All my hats are green." by stevenAthompson on Monday December 09, 2024 @04:06PM (#42370551)
> They don't even understand the question. So, of course, they are going to suck at answering them.

I agree, but would also say that you should be capable of learning to understand those questions. For example, If you can't speak English, you'll be bad at reading books in English. If you were never taught math, you'll be bad at math. Similarly, If you never learned to reason you'll be bad at solving logic puzzles. It's almost tautological.

However, if a person is incapable of learning to do one of those things, despite the majority of the world being fully capable of doing it, they probably have a cognitive deficit.

> And ultimately that is all IQ testing measures.. your ability to take tests.

I disagree. I think it measures how well you've learned to reason, though I do agree that reasoning is a learned skill for most people.

Re:A liar who always lies says "All my hats are green." by blueflow on Monday December 09, 2024 @12:47PM (#42368425)
Languages were made up by mankind at some point. They are not backed by the rest of physical reality. They can only be learned by induction, and there is no guarantee that people will get the same "version" of it.

To speak in your analogy, people walk around with different maps of the same territory and realizing this is the self-awareness mjburgess is talking about.

Re:A liar who always lies says "All my hats are green." by bbor on Monday December 09, 2024 @12:41PM (#42368350)
I mean, 2400y at least… I guess you mean quantitative logical calculus notation?

- the local Russell hater

Re:A liar who always lies says "All my hats are green." by stevenAthompson on Monday December 09, 2024 @01:46PM (#42369142)
By "relatively recent" I meant in terms of human evolution. We've had it for around 2400 of the last 300,000 years or so. So less than 1% of our species existence.

I used that phrasing to drive home the idea that logic is not some inherent aspect of nature, or even fundamental to the way humans perceive the world.

Re:A liar who always lies says "All my hats are green." by hinkley on Monday December 09, 2024 @01:13PM (#42368758)
I guess sleeping through history class is also a mental deficit ;)
Re:A liar who always lies says "All my hats are green." by AtlasBarfed on Monday December 09, 2024 @01:05PM (#42368655)
The linguistics imo are pretty ill defined.

"All" bring a common colloquial term doesn't have a strict set theory definition here. It is reasonable many people think zero hats is means the lie is in this very first word.

A lot of people will consider "all" to implicitly mean 1 or more, while I think strict logicians will map colloquial all to 0 or more.

All mat imply colloquially 2 or more as well, as why bother say "all" if you had one hat in the truthful sense

"My hats" contrasts with the "has a hat" because having a hat in your possession that you could have borrowed does not confer ownership that the word "my" can imply.

So great, a three letter word and a two letter word and we are knee deep in ambiguity.

They could be wearing the hat to try to publicly locate the true owner who might say "hey I lost that hat at x".

"Are green"... Green as in vegetable? Green as in the specific wavelength defined as green and not lime or some other named shade? Completely green dyed being undermined by a black spot or a pattern on the hat?

Imo zero hats of ownership is a viable lie to the statement, as is having one red-green hat.

Re:A liar who always lies says "All my hats are green." by ewzimm on Monday December 09, 2024 @01:44PM (#42369114)
I like your way of phrasing this. Also, we can assume that this is not the only statement that the liar has ever told, so the context matters. If the preceding statement was "Every hat is my hat." Then we have a definition of "all" in the next sentence that works against the stated answer. So "we can't conclude anything" is really the answer because of undefined terms.
Re:A liar who always lies says "All my hats are green." by Suppafly on Monday December 09, 2024 @01:05PM (#42368664)
>and it equally drives me mad in those areas where academics set "puzzles" and conclude that people's inabilty to "solve" them is some cognitive deficiency.

Does that actually happen in academia? It seems to mostly be a social media thing.

Re:A liar who always lies says "All my hats are green." by mjburgess on Monday December 09, 2024 @01:16PM (#42368801)
So frequently I'd say its the main case. Researchers are extremely poor at controlling for competing explanations, in many cases, strongly incentivsed not to.

Suppose you're writing a paper what do you write: option A) Average People Cannot Understand Probaility!?!?!, option B) Inexperienced test takers with unfamiliar notation fail to grasp meaning of a novel question; option C) survey participants on technical questions often do not adopt a literal interpretation of question; D) etc. etc.

In general researchers are extremely loath to, or poor at, recognising there's 101 alternative explanations for any research result using human participants and 99.99% of the time just publish the paper that says the experiment evidences their preferred conclusion.

Re:A liar who always lies says "All my hats are green." by Suppafly on Monday December 09, 2024 @01:33PM (#42368986)
These sorts of puzzles aren't used by researchers though, so I'm not sure I follow the rest. They almost always seemed to be used by people trained in logical thinking to consider problems in different ways. They only seem get to the larger public when someone shares one on social media and people with no background in logic complain that they are poorly written or have no answer, since they don't realize that these sorts of puzzles presuppose some background in logic and familiarity with the setup.
Re:A liar who always lies says "All my hats are green." by whatshisface on Monday December 09, 2024 @01:25PM (#42368897)
"Democrats perform poorly on history tests designed by Republicans."
Re:A liar who always lies says "All my hats are green." by btilly on Monday December 09, 2024 @02:40PM (#42369689)
There is one notable example that I'm aware of, but it really is a cognitive deficiency.

The contrapositive is a rule that says that "A => B" is the same as "not B => not A". This is very confusing to people, and few can follow verbally why it works.

But here is a fun experiment. People are presented with a selection of envelopes, all face down, and are asked to verify the fact that, "All unstamped envelopes are small." They immediately begin turning over the large envelopes, then have trouble explaining their (correct) reasoning!

Here is a correct implication process for their actions.

"All unstamped envelopes are small." => "unstamped envelope => small envelope" => "not small envelope => not unstamped" => "large envelope => stamped"

At which point it is easier to just check the large envelopes!

Re:A liar who always lies says "All my hats are green." by hinkley on Monday December 09, 2024 @01:07PM (#42368683)
It works better for everybody when these puzzles are told as inside jokes instead.
Re:A liar who always lies says "All my hats are green." by raincole on Monday December 09, 2024 @01:28PM (#42368923)
My favorite example is Monty Hall problem. "Smart" people often use it as the evidence of how bad general people are at probability.

It really isn't. The problem is usually given in this form:

> Suppose you're on a game show, and you're given the choice of three doors: Behind one door is a car; behind the others, goats. You pick a door, say No. 1, and the host, who knows what's behind the doors, opens another door, say No. 3, which has a goat. He then says to you, "Do you want to pick door No. 2?" Is it to your advantage to switch your choice? [1]

The only correct ansewr to this question is "I don't know." People who answer yes are just taking way too many standardized tests.

[1]: https://en.wikipedia.org/wiki/Monty_Hall_problem

Re:A liar who always lies says "All my hats are green." by LargeWu on Monday December 09, 2024 @02:01PM (#42369291)
The difference here is that the Monty Hall problem has an explanation that while counterintuitive, is statistically sound. You should always switch, because the probability you picked the correct door is locked in at the time you made the choice between 3 doors. It is 1/3 that you picked correctly, and 2/3 that you picked incorrectly. The counterintuitive part is that if you switch, you are effectively selecting all the doors you did not pick originally. It's your original door, vs the field.

The green hat problem hinges on subjective interpretations of the meaning of both "liar" and the different ways in which the liar's sentence may be false. It may be false because the liar owns many hats, none of which are green. Or they own many hats, only some of which are green. Or they own no hats. These are all reasonable interpretations of how the sentence might be false, and the answers presented are not necessarily mutually exclusive.

Re:A liar who always lies says "All my hats are green." by btilly on Monday December 09, 2024 @02:32PM (#42369610)
The problem here is that the usual explanation sneaks in multiple rarely stated assumptions.

If Monty knows the door with the prize and is aiming for the game to continue, then you should switch. (This is the usual argument.)

If Monty doesn't know where the prize is, then you learned nothing. (Monty's result was luck, and he can't impart information that he doesn't have.)

If Monty knows where the prize is and wants you to lose, absolutely don't switch. (Monty will only drag the game out as a way to try to make you lose.)

The reasoning behind these statements is completely solid, and there are no hidden assumptions being snuck in.

Re:A liar who always lies says "All my hats are green." by LargeWu on Monday December 09, 2024 @02:43PM (#42369732)
I think, canonically, Monty always knows where the prize is, and will always eliminate all doors except for one, and will never eliminate a door with the prize, and will always give you a choice to switch. There's no room for Monty's motivation.
Re:A liar who always lies says "All my hats are green." by btilly on Monday December 09, 2024 @02:46PM (#42369762)
Those assumptions are required for the usual explanation. But they are very rarely stated. And so the usual explanation is not logically solid.

You can't just sneak in the assumptions. You have to state them somewhere.

Re:A liar who always lies says "All my hats are green." by LargeWu on Monday December 09, 2024 @04:11PM (#42370583)
well, they are part of the original, canonical problem. it's not the original problem's fault if re-tellers omit key information.
Re:A liar who always lies says "All my hats are green." by foxglacier on Monday December 09, 2024 @04:35PM (#42370772)
They're not. It says he "opens another door, say No. 3, which has a goat". That could mean he deliberately chose a door with a goat or he chose one by some unstated process and it happened to have a goat by chance. It says he "knows what's behind the doors" but that statement means nothing because it doesn't say how he uses that knowledge, if at all. It's full of language ambiguity.
Re:A liar who always lies says "All my hats are green." by 8note on Monday December 09, 2024 @02:53PM (#42369848)
the assumption is told to you in that the game is expected to continue after monty opens a door. if he could open the prize door, the game would describe what happens when he does that
Re:A liar who always lies says "All my hats are green." by btilly on Monday December 09, 2024 @03:12PM (#42370051)
No. That condition holds in all three of the scenarios that I stated. And yet you have 3 different answers. Switching 2/3 win, 1/2 win, and 0/1 win respectively.

You specifically need information that we haven't been given about the counterfactuals. What might Monty have done in other scenarios that we have not yet observed? We don't know. And we're not actually told. That makes that an implicit assumption that wasn't specified.

Re:A liar who always lies says "All my hats are green." by hulium on Monday December 09, 2024 @02:29PM (#42369585)
Last time I claimed this was the correct answer, I was linked to the Monty Crawl problem. https://www.probability.ca/jeff/writing/montyfall.pdf
Re:A liar who always lies says "All my hats are green." by LargeWu on Monday December 09, 2024 @02:45PM (#42369751)
That's fine, but given the parameters of the problem change with the Monty Crawl variant, it's not the same problem, and doesn't invalidate the answer of the base variant.
Re:A liar who always lies says "All my hats are green." by hulium on Monday December 09, 2024 @02:53PM (#42369837)
The problem is that the parameter was unspecified in the original problem. Your answer is equivalent to the shaky answer referred to in the paper. Without knowing that the host selects between 2 goats with 50/50 chance, you cannot give a general answer.
Re:A liar who always lies says "All my hats are green." by LargeWu on Monday December 09, 2024 @02:56PM (#42369881)
I don't follow, which parameter was unspecified in the original problem?
Re:A liar who always lies says "All my hats are green." by hulium on Monday December 09, 2024 @03:05PM (#42369977)
My last sentence. Or which parameter do you think was modified?
Re:A liar who always lies says "All my hats are green." by LargeWu on Monday December 09, 2024 @03:53PM (#42370454)
The host might be selecting between two goats, or might be selecting between a goat and a car. Either way, it doesn't matter because we don't get any additional information about whether our original choice was correct. (To clarify, this applies to the original problem, not the Crawl variant, where we either sometimes get definitive information, or sometimes get no information)

Edit: Furthermore, I don't think that author's solution to the Crawl problem is correct. When the host eliminates a door, either you will get information that says you should switch, and you'll win 100% of the time; or you won't get information, and you should still always switch and win 2/3 of the time.

Re:A liar who always lies says "All my hats are green." by hulium on Monday December 09, 2024 @05:00PM (#42371021)
> it doesn't matter because we don't get any additional information about whether our original choice was correct

That's the missing assumption. I would say assuming that people are perfectly random falls into the "standardized test" category.

> you won't get information, and you should still always switch and win 2/3 of the time.

You always get some information, the set of possible results becomes narrower, so saying the probabilities don't change is not sufficient. Not a good idea to discuss the problem in informal language though.

Re:A liar who always lies says "All my hats are green." by raincole on Monday December 09, 2024 @04:31PM (#42370727)
Years ago, the Monty Fall variation was mentioned on a local telnet forum I visited. The "consensus" of the thread was the solution of Monty Fall is the same as that of Monty Hall: switching gives you 2/3 chance to win.

That was when I realized many people just memorize the Monty Hall's solution without understanding it, a.k.a. "standardized tests".

Re:A liar who always lies says "All my hats are green." by karmakurtisaani on Monday December 09, 2024 @01:40PM (#42369057)
But it is in your advantage! Code a simulator and do some numerical experiments. The simulations where you switch end up winning more.

Edit: from your other reply I see your beef is more with the wording.

Edit edit: although I disagree with your point even then. But it seems to lead to rather fruitless argument, so let's leave it here.

Re:A liar who always lies says "All my hats are green." by naniwaduni on Monday December 09, 2024 @02:45PM (#42369753)
I think reasoning with the 100-door variation is likely to be more enlightening than encoding your assumptions into a simulation.
Re:A liar who always lies says "All my hats are green." by karmakurtisaani on Monday December 09, 2024 @03:03PM (#42369961)
I'm sure it depends on the person. Some people like to see raw numbers, others a more general problem.
Re:A liar who always lies says "All my hats are green." by hansvm on Monday December 09, 2024 @02:01PM (#42369296)
Perhaps there's another formulation you meant to write, but every time I've seen it, it's been equivalent to the thing you just asked, and the only potentially ambiguous part of the question is "to your advantage". If you stay then you have a 1/3 chance of getting a car, and if you switch you have a 2/3 chance.

Yes, it's also correct that you don't "know" the result, and you might prefer goats to cars (even then you should probably sell the car and buy several goats), but there's a reasonable enough interpretation of "advantage" that you shouldn't dismiss the problem outright.

Re:A liar who always lies says "All my hats are green." by raincole on Monday December 09, 2024 @02:28PM (#42369567)
I regret opening this can of worms called Monty Hall.

But anyway I'll link the relevant section from Wikipedia:

https://en.wikipedia.org/wiki/Monty_Hall_problem#Other_host_...

> The version of the Monty Hall problem published in Parade in 1990 did not specifically state that the host would always open another door, or always offer a choice to switch, or even never open the door revealing the car. However, Savant made it clear in her second follow-up column that the intended host's behavior could only be what led to the 2/3 probability she gave as her original answer. (emphasis mine)

My point was that when people ask this question, they often word it like the very 1990 version did, lefting out this critical statement (which Savant considered needed as well, therefore she clarified in the follow-up column), making the question ambiguous.

(Although Savant also said "Very few (out of people who said is 2/3 is wrong) raised questions about ambiguity"... so perhaps people are actually just bad at probablity...?)

Re:A liar who always lies says "All my hats are green." by btilly on Monday December 09, 2024 @02:45PM (#42369749)
Just be glad that you didn't go for the 2 envelopes problem which was her next. Vos Savant was wrong about that one, and few people like the real answer.

The problem is that you're presented with two envelopes with 2 real numbers inside. You randomly select one, then look, and try to guess if you got the larger number. It doesn't seem like you can do better than even, but you can!

Unfortunately everyone hates the answer. Which is that you make up a random number and pretend it is the other one. Your odds of being right are

50% + (probability of choosing between the numbers) / 2

Which can always be strictly bigger than 50%. (Though possibly by only a little amount.)

Special case. If those numbers and yours were all independently randomly chosen from the same distribution, you'll be right 2/3 of the time.

Re:A liar who always lies says "All my hats are green." by hansvm on Monday December 09, 2024 @03:55PM (#42370465)
The two reals are selected via some distribution, and the only way you can do better than chance is if you have some knowledge of that distribution.

The question leaves that distribution completely hidden, and your answer smuggles it back in. That feels less like a counter-intuitive math/stats question and more like a badly worded gotcha.

Re:A liar who always lies says "All my hats are green." by raincole on Monday December 09, 2024 @04:00PM (#42370514)
Yes, this two real numbers question suffers from hidden conditions as the original version of Monty Hall problem does, but even more explicitly.

We can't have an uniform distribution over all real numbers, so it's quite pointless to discuss if looking into the envelope gives any new information, cause we don't even know the distribution yet.

Re:A liar who always lies says "All my hats are green." by btilly on Monday December 09, 2024 @04:49PM (#42370901)
You don't need a uniform distribution to get guaranteed better than even odds. And many nonuniform distributions work just fine.

There are no hidden conditions. It is just a shocking result that we don't expect.

Re:A liar who always lies says "All my hats are green." by raincole on Monday December 09, 2024 @06:02PM (#42371544)
https://www.alexirpan.com/2015/09/09/the-other-two-envelope-...

If your solution is the same as this article's, it's plain wrong. Even the natural number case is plain strong.

It's very easy to demostrate as well: consider a trivia case where the distribution is just {P(1)=1/3, P(2)=1/3, P(3)=1/3} and you see 2 in the first envelope. There is no strategy to get a better chance than 50%. Therefore, any strategy that gives a better chance than 50% must implicitly make an assumption over the initial distribution (and therefore excludes a distribution like {P(1)=1/3, P(2)=1/3, P(3)=1/3})

Actually the article is even "wronger" than this, because "started A" and "switched" aren't independent and one can't simply use the product of their probability. The above example is a quick way to demonstrate it's not a general strategy without assumption to get >50% winning chance. Similarily, one can just use {P(1)=1/3, P(2)=1/3, P(3)=1/3} (this is a valid distribution over real numbers!) to demonstrate the real number strategy isn't general.

Again, for both natural number and real number case, the discussion over strategies is only meaningful is we know something about the distribution.

Interestingly, this article is wrong more or less in the same way as believing switching does give you more expected value in the original "twice money in another envelope" variation.

Edit: For people who are interested in the switching strategy, check Randomized Switching in the Two-Envelope Problem (2009). Spoiler: full of discussion over the initial distribution.

Re:A liar who always lies says "All my hats are green." by LudwigNagasena on Monday December 09, 2024 @08:00PM (#42372480)
> It's very easy to demostrate as well: consider a trivia case where the distribution is just {P(1)=1/3, P(2)=1/3, P(3)=1/3} and you see 2 in the first envelope.

Seeing 2 is only one of the many possible cases. You haven’t calculated the total probability.

Re:A liar who always lies says "All my hats are green." by btilly on Monday December 09, 2024 @06:52PM (#42371952)
Sorry, but you're simply wrong. You can read the answer I gave. You can read the answer Colin Wright gave. You can trust that we both have math degrees and know what we are talking about. Or, aw heck, you can try it with an actual program at https://www.perlmonks.org/?node_id=39630. (Yes, I wrote that piece of hackery about a decade ago.)

I don't actually care how you convince yourself. But the explanation is right. If your random number is outside of the range, you've got even odds. If it is inside of the range, you've got 100% odds. As long as there is a positive probability of being between, you've got strictly better than even, by half of the probability of being between.

Many, many distributions guarantee positive odds of being in between. The one I chose for my program was:

    (log(rand) * (flip_coin() ? 10 : -10 ))
Which is the log of a random number between 0 and 1, times 10 times + or - with even odds. The various factors were chosen to fit well with normal human choices that most seek to test it with.
Re:A liar who always lies says "All my hats are green." by hansvm on Monday December 09, 2024 @07:44PM (#42372369)
That code has the same problem that Colin Wright's explanation does. Your computation of the success rate explicitly uses the fact that you're between the two values, but till you've seen the second value you can't possibly know whether you are or are not and thus can't adjust your guess based on that fact.
Re:A liar who always lies says "All my hats are green." by LudwigNagasena on Monday December 09, 2024 @08:39PM (#42372748)
The success is checked after the decision is made to, well, verify the decision. The guess isn't adjusted on whether the number is between two values.

The strategy is straightforward and bulletproof (if you allow a random generator of real numbers, otherwise you may keep tossing coins indefinitely): keep tossing coins until you get tails. If the number you saw is less than the number of heads you got, you don't switch.

For the simplest case assume that one envelope always contains 1 and another always contains 2. You choose one envelope randomly, so in 50% of cases you get 1, which you switch in 50% of cases. And in 50% of cases you get 2, which you switch in 25% of cases. Hence, you pick the higher number in 62.5% of cases. The same works with any numbers N, M; or any complex distributions; or even real numbers with a bit more complicated strategy. You don't have to know whether you are between two values in advance, you just have to guess.

Re:A liar who always lies says "All my hats are green." by btilly on Tuesday December 10, 2024 @10:54AM (#42377989)
No, I'm not doing anything other than tracking it. I'm doing that to show the user, "How much of this success was chance 50% choices, how much was guaranteed?" And so people can see how much of a good or bad result was blind luck versus the strategy successfully sticking a thumb on the scales.

In other words, I'm merely trying to be informative.

Re:A liar who always lies says "All my hats are green." by raincole on Monday December 09, 2024 @08:47PM (#42372809)
You're correct. I realized that I completely misunderstoond the original problem after reading McDonnell's paper more carefully.

I thought you meant the strategy can make the winning chance always >50% even after the player opens the first envelope, which isn't possible.

However you actually meant the strategy can make the expected winning chance >50% before the player opens the first envelope, for any well-defined distribution of real number, even the distribution is not known to the player, which now I realize is true.

(I haven't thought through some edge case like Cantor distribution, but now I incline to it's true not just for "many distributions". Of course for a discrete distributions, we need to specifiy the two envelopes can't have the same number. Besides that, it seems to hold true for any distribution?)

Re:A liar who always lies says "All my hats are green." by btilly on Tuesday December 10, 2024 @10:51AM (#42377969)
Exactly right. After you've picked the envelope, you may be nearly guaranteed to be wrong. For example both numbers are large positives and you picked the smaller. Now you're almost guaranteed to guess larger, and be wrong.

But before you pick, your odds were still bigger than 50%. Just not by much.

Re:A liar who always lies says "All my hats are green." by raincole on Monday December 09, 2024 @08:48PM (#42372814)
Edit Edit: I was wrong. I completely misunderstood the problem. See my other comment below.
Re:A liar who always lies says "All my hats are green." by hansvm on Monday December 09, 2024 @05:25PM (#42371231)
You need some _known_ distribution though, and it's shocking because the distribution is ommitted from the question, and the presence of the same distribution is snuck into the answer.
Re:A liar who always lies says "All my hats are green." by ColinWright on Monday December 09, 2024 @06:05PM (#42371572)
I think you are wrong ... see my answer here:

https://news.ycombinator.com/item?id=42371563

Re:A liar who always lies says "All my hats are green." by hansvm on Monday December 09, 2024 @07:48PM (#42372396)
Not to be too dismissive, but the title text of this xkcd [0] seems relevant. No matter how nice the explanation is, the fact that the conclusion is wrong suggests that the reasoning has a flaw. I took a stab at what I think that flaw is when I responded to your rebuttal [1].

[0] https://xkcd.com/2217/

[1] https://news.ycombinator.com/item?id=42372285

Re:A liar who always lies says "All my hats are green." by raincole on Monday December 09, 2024 @09:11PM (#42372972)
I dimissed it at first (you can see I made some embarrassing comments above), but the strategy is correct. I'd argue it's even intuitively correct once the problem in question is clarified.

It's not saying that after the player see the number in the first envelope, the strategy guarantees a >50% outcome.

It's saying that give any distribution, over all possible outcomes, >50% times the strategy will end up pick the larger number. You can say this >50% is the expected winning chance before the player see the number in the first envelope.

I'd say this is "intuitve" because, if your strategy can guarantee "when the player see a large number in the first envelope, he's less likely to switch than if he saw a small number", it would be better than blindly switching by coin toss. So intuitively such a strategy exists.

The only "trick" here is that since the player doesn't know the initial distribution, they can't tell "how large counts as large?" therefore they needs something that preserves some property over the whole real number line. That's why the strategy involves sampling from a another distribution whose PDF is non-zero everywhere.

Re:A liar who always lies says "All my hats are green." by hansvm on Monday December 09, 2024 @09:38PM (#42373150)
Sorry, I was too dismissive. I'm not crazy about the explanation, but I think you're right.
Re:A liar who always lies says "All my hats are green." by ColinWright on Monday December 09, 2024 @06:03PM (#42371563)
This turns out not to be the case.

Let's play this game exactly once.

You choose two unequal real numbers. I don't know what they are, and I don't know the distribution from which you choose them. You write them down and put them in separate envelopes.

I'm allowed to choose one envelope and open it to see the number inside, and my job is then to say which envelope holds the larger number.

I claim I have a strategy now which lets me win strictly more than 50% of the time. My strategy is this.

I choose a real number R at random from a distribution that has dense support. In other words, for any two reals, L and U with L<U, P(L<R<U) > 0. This is easy to do ... one method is to list the rationals, positive and negative, then roll a die, discarding numbers until you get a 6.

Now I flip a coin and thereby choose an envelope at random. I proceed by assuming my chosen number is between your two numbers. There is a non-zero chance this is true ... call it e. So e>0.

If I'm wrong then my choice is 50% ... probability is 1-e.

If I'm right then my choice is 100%. ... probability is e.

Combined, my chance of being right is 0.5(1-e) + e = 0.5+e/2, which is strictly greater than 50%.

You can make it as small as you like, and if we play the game repeatedly then you can make it approach 50%. But as it stands, with a one-off game, I can win with a probability that depends on your chosen numbers, but which is strictly bigger than 50%.

Re:A liar who always lies says "All my hats are green." by hansvm on Monday December 09, 2024 @07:34PM (#42372285)
Why, exactly, are you allowed to know why some random guess is between the two numbers or not when computing your choice?
Re:A liar who always lies says "All my hats are green." by hansvm on Monday December 09, 2024 @09:57PM (#42373256)
Sorry, too late to edit, I see you're describing how you know your choice was good/bad (I thought you were describing a probabilistic choice).
Re:A liar who always lies says "All my hats are green." by ajnin on Tuesday December 10, 2024 @03:25AM (#42374924)
I'm not a mathematician so please bear with me here, but I think a problem stems from the fact that the set of reals is "infinite". So, whatever interval you choose, there are infinitely more reals outside the interval as inside (by that I mean that you can fit an infinite number of copies of that interval up to infinity). So the probability e is not >0, it is effectively 0. The second problem is, what does it mean to choose a real at random ? There is an implication that you can choose such number, but as a human living in the finite universe there are limitations to your choice. Any number you can write using all the atoms in the universe is infinitely outnumbered by all numbers that you can't. So effectively it is impossible to pick a random real number. You have to pick a real in some interval, implicitly the interval of reals you can write in an envelope. Which is a different problem than stated originally and for which your "e" can be >0.
Re:A liar who always lies says "All my hats are green." by ColinWright on Tuesday December 10, 2024 @04:58AM (#42375378)
I'm not a mathematician so please bear with me here

I am a mathematician, so please bear with me when I try to explain how this can work.

The rational numbers are countable, and that means that I can write a list of them. There are several ways of doing this, but personally I like the Calkin-Wilf tree[0]. That only gives the positive ones, but we can include zero and the negative ones by interleaving them.

So, whatever interval you choose, there are infinitely more reals outside the interval as inside (by that I mean that you can fit an infinite number of copies of that interval up to infinity). So the probability e is not >0, it is effectively 0.

One you have chosen the two numbers, L and U, I note that there are rational numbers in between. Choose one of those numbers, call it M.

M is in my list above. Now I roll a die, discarding numbers from the list until I get a 6. There is a non-zero probability that the number retained is M, so there is a non-zero probability that my chosen number is between L and U. So e is definitely non-zero.

The second problem is, what does it mean to choose a real at random?

It doesn't have to be uniformly at random -- that's the mistake nearly everyone makes -- and the above process does it perfectly well. It only ever chooses a rational number, but that's OK. It's still a real number, it's still a random number, and for any non-empty interval, there is a non-zero chance the chosen number is inside.

... as a human living in the finite universe there are limitations to your choice.

Yes, but that is accounted for in the explicit description of how to choose the number.

Any number you can write using all the atoms in the universe is infinitely outnumbered by all numbers that you can't.

Again, this is accounted for by the fact that we are not choosing uniformly at random.

[0] https://en.wikipedia.org/wiki/Calkin%E2%80%93Wilf_tree

Re:A liar who always lies says "All my hats are green." by vbarrielle on Tuesday December 10, 2024 @12:12PM (#42378795)
Am I right to assume one could also sample from a Gaussian distribution for the method to work? Of course, the probability e of sampling between the two real numbers would be very small, but it would be nonzero.
Re:A liar who always lies says "All my hats are green." by ColinWright on Wednesday December 11, 2024 @03:19PM (#42392439)
Yes, any distribution with dense support works. Your problem is to prove that your method of number selection really does have a non-zero probability of being between any two distinct reals.

So ... yes, choose from a Gaussian, but then you have to tell me exactly how.

That's tricky.

Re:A liar who always lies says "All my hats are green." by raincole on Tuesday December 10, 2024 @07:36AM (#42376269)
> The second problem is, what does it mean to choose a real at random ?... So effectively it is impossible to pick a random real number

Yes, it's established there isn't "uniform distribution over all real numbers" without violating axiom of probability. You're 100% correct on this.

But it doesn't make Colin's solution wrong, because e > 0 for any* well-defined distribution.

> Which is a different problem than stated originally

There are two ways to inteprete the original problem:

A. The numbers are truly randomly picked over all real numbers.

B. The numbers are picked from a well-defined distribution which is unknown to the player.

Since A. is invalid mathematically speaking (without changing the commonly accepted definition of probability), it's reasonable to only consider B., in which case, Colin's solution is correct.

I made a more intuitive explantion on why a strategy better than coin toss exists here: https://news.ycombinator.com/item?id=42372972

*: More strictly, any distribution that guarantees the probability that the two numbers in envelope are the same = 0.

Re:A liar who always lies says "All my hats are green." by btilly on Tuesday December 10, 2024 @10:49AM (#42377938)
How the numbers in the envelopes were picked doesn't matter. What's important is that they exist, and are specific numbers.
Re:A liar who always lies says "All my hats are green." by raincole on Monday December 09, 2024 @03:13PM (#42370072)
"Two Envelopes Problem" seems to be usaully referred to a very different problem: https://en.wikipedia.org/wiki/Two_envelopes_problem
Re:A liar who always lies says "All my hats are green." by btilly on Monday December 09, 2024 @03:22PM (#42370152)
I was dealing with a more general variant of the version that Vos Savant gave. Which is that you were able to look at the contents of the envelope that you got. She claimed you didn't gain useful information. Calling it "information" is problematic, but it certainly is useful, because the stated strategy then works!

This is one reason that probability theorists have learned to be more careful in stating the double money version to rule out the solution that I gave. But my version has been in the literature since, I believe the 1950s. Under, as I first encountered it, the same exact name. (I encountered it from Dr Laurie Snell at Dartmouth College in the mid 1990s.)

Re:A liar who always lies says "All my hats are green." by copypasterepeat on Monday December 09, 2024 @01:35PM (#42369001)
I guess I don't understand why you think "I don't know" is the only correct answer. It's clearly not, which is the point of the problem in the first place. It's a bit hard to grok, but once you do, it's clear what the right answer is.
Re:A liar who always lies says "All my hats are green." by raincole on Monday December 09, 2024 @01:39PM (#42369047)
"I don't know" is the only correct anwser because the original problem isn't properly worded.

You need to (at least) add this statement to the original question:

> The host must open a door in any situation, and you know this rule.

Because "host" in daily language is a human being with agency to choose whether to not open a door. Without this statement, the original problem is actually a game theory problem with two players. The host might be playing a strategy where he only opens the door when he knows you picked the car at the first place, or any other strategy.

The above statement removes the ambiguity and that's what the original author meant (but failed to put in words).

(If you're interesting in this, the wikipedia page linked above actually contains a quite extensive discussion in history over it)

Re:A liar who always lies says "All my hats are green." by copypasterepeat on Monday December 09, 2024 @02:57PM (#42369896)
Ah I see what you mean. Yeah, that makes sense. If the host behavior is not clearly stated then the right answer would indeed be "it can't be determined from available information".
Re:A liar who always lies says "All my hats are green." by dooglius on Monday December 09, 2024 @02:05PM (#42369332)
I don't think improper wording makes it an example of the type of puzzle GP is complaining about, because the counter-intuitive aspect holds up when everything is clarified.
Re:A liar who always lies says "All my hats are green." by drdec on Monday December 09, 2024 @01:41PM (#42369062)
It depends on if Monty has the option to show another door or do nothing.
Re:A liar who always lies says "All my hats are green." by suggestion on Monday December 09, 2024 @03:11PM (#42370046)
Perhaps it'll be more intuitive to you if you scale the number of doors up. If there are 100 doors, only one containing a car, you pick one, the host reveals 98/99 remaining doors as goats, it's obvious the correct choice is to switch. The correct answer is a mathematically provable probability. 1% chance you picked the right door, 99% chance the door was in the remaining pool, therefore 99% chance the last remaining door is the correct door.
Re:A liar who always lies says "All my hats are green." by oneshtein on Monday December 09, 2024 @03:21PM (#42370148)
If you will try to play this game in real life, with such logic it will be easy to trick you 100% of the time.
Re:A liar who always lies says "All my hats are green." by suggestion on Thursday December 12, 2024 @01:25PM (#42401804)
You can write a simulation that does this (as MIT and several others have) and Monte Carlo it. You will find that the logic is 100% correct. The prize MUST be either the door you picked initially or the one you can switch to. There is a 99% chance it's not the one you picked.

https://web.mit.edu/rsi/www/2013/files/MiniSamples/MontyHall...

Re:A liar who always lies says "All my hats are green." by quchen on Monday December 09, 2024 @02:40PM (#42369688)
Can you explain the mistake (of people taking the standardized tests)? I don't understand it from the message, and the Wikipedia article seems to detail exactly the "normal, smart" switching solution.
Re:A liar who always lies says "All my hats are green." by afiori on Tuesday December 10, 2024 @11:12AM (#42378201)
In my opinion a lot of these puzzles are about empathy toward the examiner as they generally ask variations of "what would I answer to this question?".

In the case of a logician and the properties of the elements of the empty set the frame of mind of the examiner is probaly going to be about using algebraic logical connectives.

For another nice example I can quote [0] via [1]

> Luria: All bears are white where there is always snow. In Novaya Zemlya there is always snow. What color are the bears there?

> Peasant: I have seen only black bears and I do not talk of what I have not seen.

> Luria: What what do my words imply?

> Peasant: If a person has not been there he can not say anything on the basis of words. If a man was 60 or 80 and had seen a white bear there and told me about it, he could be believed.

This is a more extreme case, but in my opinion it is the same phenomenon of being asked to take external things as true and work on them.

[0] https://languagelog.ldc.upenn.edu/nll/?p=481

[1] https://www.astralcodexten.com/p/somewhat-contra-marcus-on-a...

Re:A liar who always lies says "All my hats are green." by raincole on Monday December 09, 2024 @12:13PM (#42368033)
Puzzles like this are to make more people interested in formal logic. The "gateway drug" of formal logic.

Just like the barber paradox isn't literally Russell's paradox, but it made more people to look up the history of it and perhaps learned what Russell's paradox is. Hopefully 0.1% of them turn out to be mathematicians.

Re:A liar who always lies says "All my hats are green." by dleeftink on Monday December 09, 2024 @12:19PM (#42368084)
Why not hopefully more? Less? Is mathematics this inaccessible to the other 99.9%?
Re:A liar who always lies says "All my hats are green." by raincole on Monday December 09, 2024 @12:58PM (#42368555)
Maybe "hopefully" isn't the right word.

My point is that not everyone who understands barber paradox (in plain english) has to understand formal logic, and not everyone who understands formal logic has to become a mathematician. However I still believe the existing of the plain english puzzle is a net positive for humanity's collective mathematical comprehension.

Re:A liar who always lies says "All my hats are green." by SilasX on Monday December 09, 2024 @01:13PM (#42368760)
I think you want "optimistically".
Re:A liar who always lies says "All my hats are green." by Retric on Monday December 09, 2024 @12:39PM (#42368315)
Another way of considering that statement is diminishing returns on the utility of mathematicians.

Some is good, but more isn’t necessarily better.

Re:A liar who always lies says "All my hats are green." by dleeftink on Monday December 09, 2024 @01:14PM (#42368769)
And less isn't necessarily better either. But as we further mathematics, large cohorts are falling behind.

I welcome puzzles, but I also think we need to shed some of the exclusionary aspects of mathematics/compsci, the brunt of which are far too known: inaccesible formalisms, leetcode, competitive grants/hackathons, steep admission requirements, code bounties, interview puzzle rounds, etc.

Some necessary and organised in good faith I'm sure, but I hope we can move past the implicit assumption that 'maths/code isn't for everyone' and self-select based on that, as that doesn't further the cause.

Re:A liar who always lies says "All my hats are green." by JadeNB on Monday December 09, 2024 @01:09PM (#42368703)
> Why not hopefully more? Less? Is mathematics this inaccessible to the other 99.9%?

I think it meant "hopefully at least 0.1%." (I can imagine someone who feels that it's hopefully at most 0.1%, but probably that person wouldn't be kindly disposed towards efforts to fool people into being interested in complex mathematical topics, as your parent seems to be.)

Re:A liar who always lies says "All my hats are green." by gweinberg on Monday December 09, 2024 @12:13PM (#42368036)
Right. Some people will claim "all my hats are green" is equivalent to "I have no hats which are not green", so he ,must have one hat which is not green. But other people would argue that teh original statement also implies you have at least one hat, so the statement can still be a lie if he has no hats at all. Lewis Carrol explicitly endorses the second view in his book "The Game of Logic". Good luck trying to argue logic with Lewis Carrol.
Re:A liar who always lies says "All my hats are green." by copypasterepeat on Monday December 09, 2024 @12:04PM (#42367969)
Agreed.

Not to mention that a liar doesn't necessarily have to mean someone who tells a falsehood in every single statement. It could just mean someone who frequently tells falsehoods. Or, more deviously, someone who wants to cause maximum uncertainty in his listeners, in which case some mix of true and false statements would probably be the way to go.

Re:A liar who always lies says "All my hats are green." by fortran77 on Monday December 09, 2024 @12:07PM (#42367995)
In the world of logic puzzles, it is understood that a "liar" never makes a true statement, and that "vacuously true" statements are false.
Re:A liar who always lies says "All my hats are green." by dingaling on Monday December 09, 2024 @01:01PM (#42368590)
Which seems to be an untenable premise.

"I never make a true statement" says the liar.

Re:A liar who always lies says "All my hats are green." by latexr on Monday December 09, 2024 @01:23PM (#42368874)
> "I never make a true statement" says the liar.

I’ve never seen one of this puzzles phrasing it like that. With good reason, that would break the puzzle.

Re:A liar who always lies says "All my hats are green." by JadeNB on Monday December 09, 2024 @01:10PM (#42368714)
> In the world of logic puzzles, it is understood that a "liar" never makes a true statement, and that "vacuously true" statements are false.

I agree with the first stipulation, but, outside of Lewis Carroll's puzzles, I think that the second isn't true. For example, I believe you'll find just the opposite in Raymond Smullyan's books.

Re:A liar who always lies says "All my hats are green." by pleurotus on Monday December 09, 2024 @12:31PM (#42368207)
> Not to mention that a liar doesn't necessarily have to mean someone who tells a falsehood in every single statement.

FTA: >Note: this question was originally set in a maths exam, so the answer assumes some basic assumptions about formal logic. A liar is someone who only says false statements.

I think it's pretty clear how on definitions

Re:A liar who always lies says "All my hats are green." by copypasterepeat on Monday December 09, 2024 @12:59PM (#42368575)
Ah I see that now, thanks. It was under the ad banner so I missed it first time around.
Re:A liar who always lies says "All my hats are green." by dotancohen on Monday December 09, 2024 @12:03PM (#42367962)
Only people with formal training in logic, or those who work with formal definitions of logic, have trouble with this aspect of the puzzles.

Trying to return to your more naive understanding of logic not only helps understand the intent of the puzzle, it also makes the puzzle more fun.

Re:A liar who always lies says "All my hats are green." by garciasn on Monday December 09, 2024 @12:15PM (#42368052)
> it also makes the puzzle more fun.

No; it makes the puzzle illogical and thus about as much fun, for those who prefer logical outcomes, as discussing religion or politics.

Re:A liar who always lies says "All my hats are green." by dotancohen on Monday December 09, 2024 @01:28PM (#42368926)
That could be - in my country religion and politics is literally a matter of life or death. We discuss them to no end.
Re:A liar who always lies says "All my hats are green." by eblume on Monday December 09, 2024 @12:12PM (#42368027)
I'm genuinely perplexed by this, how is the puzzle even a puzzle if you don't judge it by formal logic?
Re:A liar who always lies says "All my hats are green." by gosub100 on Monday December 09, 2024 @12:22PM (#42368107)
It's still useful for young people or those who have never stopped to consider it. I think it's a good introduction to the warts of a context sensitive grammar
Re:A liar who always lies says "All my hats are green." by dotancohen on Monday December 09, 2024 @01:27PM (#42368918)
Because in everyday life we do not formally define ideas.

Just for example I play a game with my children where we tickle each other when we see a yellow vehicle. Is a yellow tractor a vehicle for purpose of the game? How about a yellow baby cart. How about a billboard with a photograph of a yellow baby's toy car?

We honestly have more fun discussing what is a vehicle for purpose of the game than we do tickling. Especially when it becomes clear that a yellow baby carriage is a vehicle only if it is daddy to be tickled... Honestly a good lesson to learn early that life is not fair and that rules are subjective.

Re:A liar who always lies says "All my hats are green." by LudwigNagasena on Monday December 09, 2024 @01:39PM (#42369049)
Reminds me of "The rule says, “No vehicles in the park”", https://news.ycombinator.com/item?id=36453856
Re:A liar who always lies says "All my hats are green." by Waterluvian on Monday December 09, 2024 @11:56AM (#42367901)
Agreed. I bin this with other “rules lawyering,” which usually feels unfair, uninteresting, and unsatisfying.

It’s why puzzlemaking a truly challenging and impressive skill. It must be fair, a challenge, and obvious in retrospect.

I think it’s why the twist in Bioshock worked so well for me: it was right there in plain sight numerous times, while other twists in mystery games/films elicit a groan.

Re:A liar who always lies says "All my hats are green." by paxys on Monday December 09, 2024 @12:03PM (#42367946)
These puzzles are entirely formal logic. Now you may not like or understand the intricacies of the logic/math and how it interacts with the English language, but the rules, and thus the solutions, are pretty objective and not open to interpretation.
Re:A liar who always lies says "All my hats are green." by 38 on Monday December 09, 2024 @12:08PM (#42367999)
You aren't reading the same article. It's obviously ambiguous
Re:A liar who always lies says "All my hats are green." by paxys on Monday December 09, 2024 @12:19PM (#42368082)
And yet everyone here has come up with the right answer.
Re:A liar who always lies says "All my hats are green." by SirMaster on Monday December 09, 2024 @01:19PM (#42368832)
Then the puzzle shouldn't use the word lie, because to lie can mean to be deceptive, and saying all your hats are green when you have no hats is clearly deceptive and thus can be considered a lie.
Re:A liar who always lies says "All my hats are green." by mr_mitm on Monday December 09, 2024 @01:30PM (#42368952)
It's not deceptive, it's simply true in formal logic. I've been thought in linear algebra 101: all statements about the elements of the empty set are true. That's the core of this puzzle, and contrary what OP claimed, it's a matter of logic, not language.
Re:A liar who always lies says "All my hats are green." by SirMaster on Monday December 09, 2024 @01:48PM (#42369166)
But the question is being presented to humans via language and without any formal logic training.

If it's a formal logic problem it should be presented in formal logic terms (presumably that only those with formal logic training would even understand) so then there is no possibility of language ambiguity.

I'm not trying to be argumentative, but this is just how this come across to me, and I am pretty confident most humans would consider it a lie which I think would count for something given the place and the way in which the question was presented.

Re:A liar who always lies says "All my hats are green." by jkaptur on Monday December 09, 2024 @12:20PM (#42368086)
The end of the article notes "A liar is someone who only says false statements." I agree that this is quite different from the colloquial definition of a liar, someone who mixes truth and lies in order to mislead.
Re:A liar who always lies says "All my hats are green." by efdee on Monday December 09, 2024 @12:35PM (#42368260)
The beginning of the article quite clearly states "A liar who always lies", though.
Re:A liar who always lies says "All my hats are green." by gosub100 on Monday December 09, 2024 @12:26PM (#42368152)
Any time I hear the Rick Roll song (Rick Astley - Never Gonna Give You Up) I always notice the ambiguity in the lyrics "Never Gonna run around AND desert you" and ponder how his proclamation would still be valid provided he only committed one of those transgressions individually.
Re:A liar who always lies says "All my hats are green." by GuB-42 on Monday December 09, 2024 @12:30PM (#42368200)
That's the reason natural languages are not very well suited to formal logic, and one of the reasons programmers use programming languages.

If we reframe it using C++ "std::all_of" function over an array of strings called "hats", and say that the following must be false (because he is a liar):

  std::all_of(hats.begin(), hats.end(), [](std::string hat) { return hat == "green"; })
Then we can answer the questions without ambiguity:

A) The liar has at least one hat. Yes, because std::all_of returns "true" on an empty list

B) The liar has only one green hat. Unsure, because { "green", "green", "red" } is false, and { "green", "red" } is also false

C) The liar has no hats. No, it is the opposite of A

D) The liar has at least one green hat. Unsure, because { "green", "red" } is false and { "red" } is also false

E) The liar has no green hats. Unsure, for the same reason as in D

Re:A liar who always lies says "All my hats are green." by gpderetta on Monday December 09, 2024 @12:46PM (#42368403)
The question becomes why all_of returns true for an empty list. A better example would use std::accumulate and an 'and' function argument. The original STL documentation [1] described the function argument as having to model the Monoid[2] concept and have an identity value. The identity value for the 'and' Monoid is 'true'.

[1] https://www.boost.org/sgi/stl/MonoidOperation.html

[2] note: Monoid, not Monad, and yes, category theory left its mark in C++ as well.

Re:A liar who always lies says "All my hats are green." by GuB-42 on Monday December 09, 2024 @01:06PM (#42368679)
And it is also what makes the most sense if you are using all_of, usually.

For example, you may want to use all_of to check if all the preconditions are met before running a command, is there are no preconditions, then you can run the command.

Or, in a test report, a test case is successful if it and all of its sub-cases are successful, if there are no sub-cases, then that part is considered successful.

Or, you are making a task runner, you exit if all the tasks are completed, if there are no tasks, then you can exit immediately.

Saying that all of nothing is true is the most appropriate behavior, both in theory and in practice.

Re:A liar who always lies says "All my hats are green." by SilasX on Monday December 09, 2024 @01:19PM (#42368841)
>The question becomes why all_of returns true for an empty list.

Yes! Before it became a programming problem, I considered the implications of this decision for common speech. In that case, it will generally be expected that when someone says "all my hats are green", they have at least one hat, probably because otherwise it doesn't hit the relevance threshold to make such a statement worth saying.[1]

Based on this, with my younger, hornier mind, I would joke that, "I have gone on a date with every female cheerleader at my university." (All the cheerleaders at my university are male.)

The idea being, an equally valid convention would be to read the statement as "there exists no element violating all the predicates" i.e. no one who is both a "female cheerleader at my university" and "someone I have not gone on a date with".

And this convention, it turns out, is what C's all_of (and Python's all()) uses.

But I'd still balk at someone using that trick in common speech -- it's at least an attempt to be misleading.

[1] See the "Maxim of Relevance": https://en.wikipedia.org/w/index.php?title=Cooperative_princ...

Re:A liar who always lies says "All my hats are green." by nuancebydefault on Monday December 09, 2024 @01:37PM (#42369018)
I make love to my wife almost every weekday. Almost monday, almost Tuesday, almost Wednesday,...
Re:A liar who always lies says "All my hats are green." by JadeNB on Monday December 09, 2024 @01:01PM (#42368587)
> The question becomes why all_of returns true for an empty list.

Because it is, if you'll forgive my Haskell-ese, the only implementation that means that `all_of $ l1 ++ l2 == (all_of l1) && (all_of l2)` for all lists `l1` and `l2`, including empty ones.

Re:A liar who always lies says "All my hats are green." by gpderetta on Monday December 09, 2024 @01:27PM (#42368919)
yes of course, I was trying (and failed?) to draw a connection from all_of to accumulate (i.e. fold).
Re:A liar who always lies says "All my hats are green." by JadeNB on Monday December 09, 2024 @04:21PM (#42370644)
Ah, my apologies. I don't know my way around C++, and, by reading your comment too quickly, misread it to be saying that `all_of` behaved badly, rather than that its behavior could be better understood by looking elsewhere.
Re:A liar who always lies says "All my hats are green." by crdrost on Monday December 09, 2024 @12:30PM (#42368202)
> What the author would probably say is “All my hats are green” means the liar is either lying about All or Green. Either all their hats are some other color or only one hat is green. This means you have to assume the liar has a hat. How do we know that?

This is almost certainly not what the author will say, and it does have some tangential connections to computing so it's worth expanding on briefly.

In computing you often reduce problems to smaller problems, this can be done with recursion but it doesn't have to be, dynamic programming kind of is the reverse of it; whatever. When you do that though, you get these questions about really small collections, sets, lists, data structures.

Just for a quick concrete example so that we're not an abstract theory land, is a one-element list sorted? Is a zero element list sorted? Is [5, 5, 5] sorted ascending, descending, both, or neither? If you choose the wrong answer, then it means that your algorithm needs to be more complex, you don't trust zero-element lists to be sorted so your quicksort HAS to pivot on a median of 3, you don't trust one-element lists to be sorted so your quicksort HAS to pivot on a median of 5, or maybe when you see that you would recurse into a list of size 1 you generate a new median-pivot or something.

In mathematics, there is a convention which attempts to generalize this idea that an empty list is always sorted. In fact, an empty list is also always randomly sorted. It is always sorted descending, too. If it's an empty array of ints, all of those ints are greater than 1000—and they are also less than 50.

The mathematical convention is, in lay speak, “if you are talking about nothing, pretty much anything you say is going to be true unless it's gibberish.” If I said every int is green, well, synesthesia excepted ints don't really have colors, that's crap.

Everything else is “trivially true.” More formally, any predicate of the form {for all elements in S, this is true of that element} is taken to be “trivially true” when S is an empty set. It is something like the code,

    let agg = true
    for (const element of mylist) {
      agg = agg || f(element)
    }
where no matter what f is, if mylist was empty, agg is true. (“Trivial” here is sometimes replaced with the word “vacuous” because “trivially” is also a common English word meaning “easily,” so something “trivially true” might also by normal English rules mean “is easily seen to be true, is easily proven to be true, we can debunk the opposite with a 5 second look at the Wikipedia page,” etc.)

So that's the convention and besides making base cases much easier, one reason to do this is that the negation of any “for all Xs in the set, Y” is always perfectly specified as “there exists an X in the set such that not-Y.” The other convention you'd have to negate as “Either the set is empty or (...)”.

So the claim is that the perfect Liar is lying according to mathematical rules of Truth and falsehood, and according to those rules, this statement “all of my hats are green” can only be false if there exists at least one hat belonging to the liar which is not green. If there are no hats then the statement was trivially true.

Re:A liar who always lies says "All my hats are green." by bingohbangoh on Monday December 09, 2024 @12:32PM (#42368234)
I agree.

It reminds me of the math "puzzles" on Twitter which go:

1 shoe + 1 shoe = 2

2 shoes + 2 shoes = 4

3 shoes + 2 shoes = ???

And the answer isn't 5 because a) we're not counting shoes and b) the shoe laces were different colors. There's nothing clever, it just teaches you to be hyper cynical and question every little detail which isn't relevant to either Math or the real world.

Re:A liar who always lies says "All my hats are green." by ninalanyon on Monday December 09, 2024 @01:06PM (#42368675)
I have a little monograph written many decades ago on Dimensional Analysis. Since reading it, not quite so many decades ago, I simply dismiss puzzles of this sort because the two sides of the equations are dimensionally incongruent. This means that I have to try to guess the state of mind of the questioner rather than solve a logic problem.

It's a handy stance because I'm no good at either solving logic problems or getting inside other people's heads!

Another on that really irritates me is the kind that presents a series of integers and asks which integer comes next. Any integer will do, you just have to fit the appropriate polynomial.

Re:A liar who always lies says "All my hats are green." by chromaton on Monday December 09, 2024 @02:34PM (#42369625)
> Another on that really irritates me is the kind that presents a series of integers and asks which integer comes next. Any integer will do, you just have to fit the appropriate polynomial.

This one bugs me to no end because it's part of the standard elementary school curriculum, for example here: https://byjus.com/maths/patterns-questions/

But surely someone with a strong imagination could come up with a pattern to fit any number as the next in the sequence. I doubt most elementary educators even grasp the issue.

Re:A liar who always lies says "All my hats are green." by bingohbangoh on Monday December 09, 2024 @03:08PM (#42370012)
> This means that I have to try to guess the state of mind of the questioner rather than solve a logic problem

That is an excellent way to put it!

It explains why it appeals to non-math people. They are (usually) better at these more verbal-based games ime.

Re:A liar who always lies says "All my hats are green." by hinkley on Monday December 09, 2024 @01:20PM (#42368850)
I expect people in different branches of statistics or physics would potentially come up with different answers based on what sorts of series appear in their realm of expertise.
Re:A liar who always lies says "All my hats are green." by grog454 on Monday December 09, 2024 @12:36PM (#42368271)
The article clearly defines someone who always lies to mean they only make false statements. It's not hard or ambiguous to determine various scenarios in which "all my hats are green" is false.

The solution article also discusses vacuous truths ("all my hats are green" is true if you have no hats, vacuously). Truth has a definition in formal logic too, but we've gotten far enough that this problem is already solvable and unambiguous.

Re:A liar who always lies says "All my hats are green." by gryn on Monday December 09, 2024 @12:40PM (#42368325)
yeah, you can add most "paradoxes" to that list.

the one I hate the most is the Monty Hall Problem.

Re:A liar who always lies says "All my hats are green." by fargle on Monday December 09, 2024 @01:18PM (#42368826)
monty hall is not a true paradox. it could be classed as "veridical" (truthful) paradox, or i've seen it called a pseudo-paradox.

but you realize that it's unambiguously mathematically true without gimicky word-play or puns or other logic puzzle trickery.

it's just simply an un-intuitive result. most statistics really is.

curious: why the hate for the monty-hall problem?

Re:A liar who always lies says "All my hats are green." by naniwaduni on Monday December 09, 2024 @02:02PM (#42369303)
The claimed Monty Hall result becomes untrue with very subtle changes to the premises. For example, if the host blindly chooses randomly between remaining doors, the resulting distribution is 1/3 contestant door choice correct (switch loses), 1/3 contestant and host both incorrect (switch wins), 1/3 contestant incorrect host correct (no switch can be offered).
Re:A liar who always lies says "All my hats are green." by gryn on Monday December 09, 2024 @04:22PM (#42370655)
Yes, I didn't mean it as it being a paradox just the problem I hate the most. I should've worded that better.

The reason I hate it is that it's a example of how to lie and mislead using statistics and that the only reason it exist is that a content creator in the print media wanted to give an edgy true answer to farm engagement, and now as a consequence many introductory statistics course make students suffer for the same reasons. The assumptions made to reach that answer are not made explicit and it changes the response. And teachers mess it up a lot of the time which lead to a lead of head-scratching (or sometime just leave under-specified on purpose).

It was the right answer to a question that wasn't asked. the host opens the door before giving the choice and the door he's choosing isn't random.

Wikipedia explains this better than I would be here's the part I'm talking about:

> In Morgan _et al four university professors published an article in _The American Statistician_ claiming that Savant gave the correct advice but the wrong argument. They believed the question asked for the chance of the car behind door 2 _given_ the player's initial choice of door 1 and the game host opening door 3, and they showed this chance was anything between 1/2 and 1 depending on the host's decision process given the choice. Only when the decision is completely randomized is the chance 2/3 .

[Monty Hall problem - Wikipedia](https://en.wikipedia.org/wiki/Monty_Hall_problem)

The game theoretic explanation (in the same page) as to why you should switch is more convincing and less click-baity though without needing to give a specific probability value or assume the host strategy.

Re:A liar who always lies says "All my hats are green." by fargle on Monday December 09, 2024 @06:59PM (#42372011)
very interesting. i love the reply; don't mistake my responses as arguments or disagreement - just ideas:

i think Savant was 100% correct and the original stating of the problem was clear enough. it's not really about torturing students or trying to be tricky or edgy - it's meant to be an important lesson about independence in statistics. it's more of an example of the kind of real problems that are torture. statistics is the torture, not the exposition of it...

> content creator in the print media wanted to give an edgy true answer to farm engagement

this was 1975 and the fight didn't break out until 1990. using terms like "content creator", "farm engagement", etc. gives a vibe that i guarantee was not the case at the time. yes, it was meant to be an engaging puzzle, but back then it didn't have those highly negative connotations.

from wiki: "Several critics of the paper by Morgan et al.,[38] whose contributions were published along with the original paper, criticized the authors for altering Savant's wording and misinterpreting her intention"

if anything people with an axe to grind like the Morgan et. al. analysis were the one twisting words around.

as far as instructors (and many other people) having a bad time explaining it, well... that's not a problem with the puzzle is it? bad teachers are a real thing.

for me the very best most direct way to understand the puzzle and the solution is to look at the decision tree diagram next to "Conditional probability by direct calculation" on the wikipedia page [1]. with only 3 doors and 3 possible first choices and a single 2nd chose (switch or not), you can easily fully directly compute every possible scenario. draw that picture 3 times (one for each initial door chosen) and count up the wins and losses for strategy switch vs no-switch.

[1] https://upload.wikimedia.org/wikipedia/commons/thumb/d/de/Mo...

Re:A liar who always lies says "All my hats are green." by shever73 on Monday December 09, 2024 @12:54PM (#42368517)
This is an Alex Bellos puzzle, which I’ve learned through experience to ignore. The terms are always so loosely defined that any solution you come up with is a gamble at best.
Re:A liar who always lies says "All my hats are green." by hinkley on Monday December 09, 2024 @01:06PM (#42368671)
> Either all their hats are some other color or only one hat is green. This means you have to assume the liar has a hat. How do we know that?

Which is another listener’s bias: is lying by omission a lie?

All my horses are unicorns. I don’t have any horses, nor unicorns. So it’s true but also not.

Re:A liar who always lies says "All my hats are green." by missinglugnut on Monday December 09, 2024 @01:11PM (#42368727)
There's an early xkcd for this sort of riddle: https://xkcd.com/169/

The article mentions a maths exam, and of course the answer to the hats puzzle is very straightforward if you convert to statements about sets and logic in the way the teacher expects.

But converting ambiguous language into logical statements by taking everything extremely literally is the opposite of a useful life lesson, so I think it's a terrible exam question.

Re:A liar who always lies says "All my hats are green." by whatshisface on Monday December 09, 2024 @01:23PM (#42368880)
The article said that the problem was based in formal logic and appeared on a "maths test." That means it isn't ambiguous question about the English language.
Re:A liar who always lies says "All my hats are green." by from-nibly on Monday December 09, 2024 @01:32PM (#42368977)
No that doesn't mean anything. Tests and books can be wrong.
Re:A liar who always lies says "All my hats are green." by jldugger on Monday December 09, 2024 @02:56PM (#42369880)
Well, part of the coursework, and probably the hardest part, is about translating natural language problems into formal logic statements, ie:

"The liar says All my hats are green" becomes "¬∀x|x∈hat,OWNS(x) (GREEN(x))" or similar.

And then from there you can also translate the five provided answers and try to find a contradiction.

Re:A liar who always lies says "All my hats are green." by seanhunter on Monday December 09, 2024 @01:35PM (#42369002)
Yes. It isn’t ambiguous and is entirely solvable using old school formal logic of the “All Cretans are liars” sort.

If the liar owns no hats the statement “All my hats are green” would be true. Under the parameters of the question it must be a lie and therefore cannot be true. So the liar owns at least one hat which is not green. They may own additional hats which can be of any colour.

People who are saying “if they are a liar they might not even be talking about hats” are somewhat missing the point:

1) Whether or not they are talking about hats they have made a statement about hats and under the “rules of the game” of formal logic it must be untrue because we are given they are a liar. That’s enough to answer the question.

2) The “rules of the game” are about predicates and properties and inference. The language is plenty precise enough to convey both the question and to deduce the solution.

Re:A liar who always lies says "All my hats are green." by stickfigure on Monday December 09, 2024 @01:47PM (#42369148)
I think there's a sort of divide-by-zero problem here. Does an empty set of hats have a color? You could arbitrarily define "all my hats are green" for the empty set as either true or false as part of a consistent logical system. There isn't enough information in the question to know whether we should pick one or the other, though there's probably a colloquial preference for true.
Re:A liar who always lies says "All my hats are green." by seanhunter on Monday December 09, 2024 @02:56PM (#42369885)
If set of his hats is the empty set then it contains no hat which is not green, which would make his statement true. As siblings have said, this is a “vacuous truth” in formal logic.

Edit to add: if you find this problematic consider that the statement “All my hats are green” in formal logic is identically equivalent to

For all hats h in my hats, h is green.

So for this statement to be false there needs to be a hat in the set “my hats” which does not have the property that it is green. If “my hats” is empty or indeed if somehow contrary to the rules of the game “my hats” only contains things which are not hats or all the hats it contains are green then the statement is true.

Since the speaker is a liar the statement cannot be true. Therefore there is at least one hat in “my hats” which does not have the property that it is green.

The maths students will be learning this in the context of negation and will have learned that the negation of a universal (“for all”) statement in predicate logic is an existential (“there exists”) statement. Since we have a liar we have to negate what the liar says so since the liar says

“For all hats h in my hats, h is green.”

We negate this and deduce

“There exists at least one hat h in my hats such that h is not green.”

In the context of old-fashioned predicate logic this is not ambiguous.

Re:A liar who always lies says "All my hats are green." by stickfigure on Monday December 09, 2024 @04:32PM (#42370735)
If you add "using old-fashioned predicate logic" or "using classical logic" to the question, I agree with you. Vacuous truth is generally useful, but it's still an arbitrary choice. It's not a thing you can test like gravity.

This is why the problem statement bothers me. If you're going to contrive a puzzle out of pure logic, you had better constrain the world (ie, what logic system the "liar" uses). It's like formulating a geometry problem (behavior of parallel lines, sum of angles of a triangle, etc) and just assuming Euclidian space.

Re:A liar who always lies says "All my hats are green." by lukas099 on Monday December 09, 2024 @01:56PM (#42369245)
Is there not a convention within formal logic defining this type of statement to be true or false?
Re:A liar who always lies says "All my hats are green." by gabrielhidasy on Monday December 09, 2024 @02:26PM (#42369554)
There is, it's the "Vacuous Truth", generally any affirmation about elements of the empty set is true. It's very useful as it allows you to convert any statement "All elements of x are Y" in "No element in x is Not Y".
Re:A liar who always lies says "All my hats are green." by scotty79 on Monday December 09, 2024 @02:06PM (#42369338)
There is.

  [].all(x => whatever(x)) == true
At least that's how math usually thinks about it.
Re:A liar who always lies says "All my hats are green." by oneshtein on Monday December 09, 2024 @03:33PM (#42370273)
> If the liar owns no hats the statement “All my hats are green” would be true.

Color of non existing object is undefined.

The correct solution is:

!(all && my && hats && are && green) == !all || !my || !hats || !are || !green.

Re:A liar who always lies says "All my hats are green." by seanhunter on Monday December 09, 2024 @03:51PM (#42370432)
If you want to allow undefined statements that’s actually fine from an inferential point of view even though in predicate logic statements are always either true or false.

He’s a liar so his statement has to be specifically false.

Re:A liar who always lies says "All my hats are green." by idrios on Monday December 09, 2024 @01:35PM (#42369004)
If a stranger told me "All of my cars are red" and then I learned that they didn't own a car, I wouldn't call them clever I'd call them a liar.
Re:A liar who always lies says "All my hats are green." by PittleyDunkin on Monday December 09, 2024 @01:37PM (#42369027)
> It is not formal logic but more about the idiosyncrasies and conventions of the English language

Well yea, that's the fun part! Logic puzzles without interaction with language are dull affairs indeed, basically just computation.

Re:A liar who always lies says "All my hats are green." by skybrian on Monday December 09, 2024 @01:43PM (#42369100)
Yes, this is an artificial example and it uses ambiguous language. But it doesn’t really matter whether you got it right or whether the puzzle is fair. Knowing about “vacuously true” statements is useful because that’s a corner case where a bug can happen. (Or it could be a loophole in a legal document.)

When you’re writing functions that work on lists or sets, you need to decide what to do about statements that are vacuously true. Call it out in the documentation? Put in a special case? Assert that the set is non-empty? Or maybe even create a new datatype to make the corner case unrepresentable. These design choices have side-effects, making a function easier or harder to use, more or less error-prone.

Recognizing vacuous statements is pattern recognition, but it’s sometimes useful pattern recognition, and for children, learning about it might even be fun.

Re:A liar who always lies says "All my hats are green." by dllthomas on Monday December 09, 2024 @01:49PM (#42369173)
I think the puzzle is better if the person "only speaks falsehoods" than if they "always lie" - depending on context, a true statement can be a lie.
Re:A liar who always lies says "All my hats are green." by aftbit on Monday December 09, 2024 @01:54PM (#42369224)
This is called out in the article:

>Note: this question was originally set in a maths exam, so the answer assumes some basic assumptions about formal logic. A liar is someone who only says false statements.

Re:A liar who always lies says "All my hats are green." by dllthomas on Monday December 09, 2024 @07:55PM (#42372437)
Yeah, my comment was just a suggestion that that wording be imported into the question, rather than living in a clarification.
Re:A liar who always lies says "All my hats are green." by torginus on Monday December 09, 2024 @02:12PM (#42369396)
if you look at it as a programmer, vacuously true makes sense.

In js if I write:

  const allHatsGreen = hats.every(hat => hat.color === 'green');
it will be true if hats is empty. Same thing for C# Linq. Imo this makes sense, because if I write:

  const matchAllConditions = conditions.every(condition => condition.matches(item))

In some condition matcher (lets say I want to check rules before an user is allowed to post), the correct behavior is the result to be true, when the array is empty.

I'm not well versed, in functional programming, but in Ocaml (of F#, hehe) it would be

  let rec all_hats_green = function
    | [] -> true
    | hat::rest -> hat.color = "green" && all_hats_green rest
so in a recursive implementation, this is the behavior that makes sense.
Re:A liar who always lies says "All my hats are green." by hansvm on Monday December 09, 2024 @02:15PM (#42369435)
I don't think it's that idiosyncratic? Everywhere I've lived:

1. A deceit is an attempt to make somebody believe something false.

2. A falsehood is a statement which is false.

3. A lie is a deceitful falsehood.

Regardless of whether they miscommunicated about hats vs cats, and regardless of whether they were being deceitful in the process, for the statement to be a lie it would also have to be a falsehood, implying they have at least one hat which is not green.

Yes, these problems require suspension of disbelief, especially given the shorthand "he's a liar" always meaning that the person is often deceitful (usually with other negative implications), but the problem statement being that the "person always lies" is pretty clear and doesn't require special pattern recognition or other mental gymnastics, and it's not that different from the suspension of disbelief you invoke when playing a game of chess and not literally sending a knight to murderously dethrone your opposition.

Re:A liar who always lies says "All my hats are green." by btilly on Monday December 09, 2024 @02:27PM (#42369563)
What you're saying can only be true to the extent that natural language doesn't look like formal logic.

Unfortunately, there are some obvious discrepancies. My favorite is that "can't" really means something closer to "not can".

This can be demonstrated with a close analysis of the statement, "I can't not do that." To get our usual understanding of the sentence we need to parse it as, "I (not can) (not do that)." And then turn that into, "I must not (not do that)." And now cancel the double negative to get, "I must do that."

Suppose that you try to parse it as, "I can not not do that." You quickly get, "I can do that." Which is not at all what that sentence actually means.

Re:A liar who always lies says "All my hats are green." by golly_ned on Monday December 09, 2024 @02:52PM (#42369835)
Most english sentences are semantically ambiguous and can often be parsed in hundreds of different ways. And it's true that there is an element of reading comprehension. But a reasonable reader won't assume the thing about the cat.

We know this is occurring on a math exam, so it must be a logic puzzle. The exam-taker would've probably known this refers to a first-order logic question, and have been taught a certain way of translating sentences like this into first-order logic.

This is true of all word puzzles that they need to be mapped to math in a way that assumes knowledge about the world and context.

Re:A liar who always lies says "All my hats are green." by Nifty3929 on Monday December 09, 2024 @05:05PM (#42371058)
Yes - the puzzle should not revolved around semantic ambiguities like this. Let's be clear about the terms of the puzzle, agree on definitions, and then argue from there.

In fact, I would extend this to arguments as well: Let's be clear up front what we mean by important words and go from there. Too often people ending up arguing about definitions, but in roundabout ways.