logoalt Hacker News

skybrian12/09/20240 repliesview on HN

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.