That lets you discover the answer for the empty set.
To bridge the gap with programming, make a map f: S -> bool which represents our predicate.
all(f, S) => either S is empty or for all elements s in S, f(s) = True.
Now make f work on sets as well as individual values. f({x, y}) means True if f(x) and f(y) are True, False otherwise.
all(f, S) => all(f, P(S))
If we take the opposite and define all(f, {}) = False then this doesn't work and in addition all(f, P(S)) = False for all sets S.
I agree it's only logical in engineering contexts like that though, not in everyday language.
> liar.hats.every((hat) => hat.color === "green")
will throw a TypeError: Cannot read properties of undefined. That’s definitely not `true`.
liar.hats.push("red")
This only works if hats is an empty array. If hats is just not a property people have (undefined in the example), then you can't represent adding them.Now you might argue hats can be null when a user doesn't have them, or a non-empty array, but that's clearly not a great way to represent that. Now you have owning no hats represented two different ways as an empty array or null, and must build special casing around the null case (unless you are using a language where nil and the empty array are one and the same)
const liar = { hats: [] };
liar.hats.every(hat => hat.color === "green")
true