logoalt Hacker News

rawgabbit12/09/202429 repliesview on HN

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.


Replies

mjburgess12/09/2024

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.

show 8 replies
GuB-4212/09/2024

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

show 1 reply
btilly12/09/2024

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.

raincole12/09/2024

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.

show 1 reply
bingohbangoh12/09/2024

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.

show 1 reply
grog45412/09/2024

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.

paxys12/09/2024

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.

show 2 replies
whatshisface12/09/2024

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.

show 2 replies
skybrian12/09/2024

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.

gosub10012/09/2024

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.

PittleyDunkin12/09/2024

> 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.

Nifty392912/09/2024

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.

hinkley12/09/2024

> 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.

jkaptur12/09/2024

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.

show 1 reply
shever7312/09/2024

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.

idrios12/09/2024

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.

Waterluvian12/09/2024

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.

copypasterepeat12/09/2024

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.

show 2 replies
torginus12/09/2024

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.
gweinberg12/09/2024

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.

dllthomas12/09/2024

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.

show 1 reply
hansvm12/09/2024

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.

missinglugnut12/09/2024

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.

dotancohen12/09/2024

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.

show 2 replies
golly_ned12/09/2024

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.

crdrost12/09/2024

> 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.

gryn12/09/2024

yeah, you can add most "paradoxes" to that list.

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

show 1 reply
smohare12/09/2024

[dead]