my-hats is not empty
for every hat in my-hats, is-green(hat) is true
We know that the speaker always lies, so both statements must be false: my-hats must be empty, and it must be that it exists at least one hat in my-hat that is not green. This is a contradiction. So either the speaker or the puzzle is not consistent (and uninteresting), or the 'my-hats is not empty' is not a valid assumption.> We know that the speaker always lies, so both statements must be false: my-hats must be empty, and it must be that it exists at least one hat in my-hat that is not green.
No. Since it is one statement as written, and the rules of common logic are not created by the liar, as I said up in the thread, either possibility is true. The person may have no hats or have one hat that is not green.
For me, the evaluation of the empty set should have separate semantics than that for how a non-empty set's elements are logically combined to produce a value.
This is the result of doing stats programming for grad students, doing lots of database design and programming, and lots of regular programming in imperative and functional languages.
The key is that we are always working within a context, and this problem's context involves both formal logic and regular old language. And, whew!, is there a disconnect and interference pattern.
What a delightfully unserious discussion!
function areAllTheirHatsGreen(someone) {
return someone.getHats().every(hat => hat.color === 'green')
}
I wonder if there's a language or programming paradigm where this function wouldn't be determined simlarly.I think best you could do is make a validation check that throws an error if there's no hats at all, but would that make sense?
What if you have a function that has to return a boolean and not throw an error.
As to paradigms, I've not seen anything yet, but I haven't seen it all, and corporate America has their legacy systems that limit their explorations.