On Sun, 14 Jun 2009 19:14:10 -0400, Terry Reedy wrote: > Steven D'Aprano wrote: >> >> So-called "vacuous truth". It's often useful to have all([]) return >> true, but it's not *always* useful -- there are reasonable cases where >> the opposite behaviour would be useful: [...] > It seems to me that the absurd conclusion implied by the theorem > invalidates the theorem rather than supporting your point.
I wouldn't go so far as to say the vacuous truth theorem ("empty statements are true") is invalidated. The Wikipedia article discusses various reasons why it's more correct (or at least more useful) to treat vacuous statements as true: http://en.wikipedia.org/wiki/Vacuous_truth But it's not without difficulties -- however those difficulties are smaller than those if you take vacuous statements as false in general. [...] > Try finding another 'reasonable case'. Any time you do something like: if not x and all(x): process(x) instead of just: if all(x): process(x) I can't think of a real world example off the top of my head, but here's a contrived example demonstrating that vacuous truths imply both a fact and it's opposite: def startswith(s, chars): """Return True if s starts with any of chars.""" for c in chars: if s.startswith(c): return True return False if all([startswith(w, "aeiou") for w in words]): print "All the words start with vowels." if all([startswith(w, "bcdfghjklmnpqrstvwxyz") for w in words]): print "All of the words start with consonants." If words is empty, this code claims that all of the words start with vowels as well as starting with consonants. There are, of course, ways to work around that other than rejecting vacuous truths. One is to simply use an "elif" for the second test. -- Steven -- http://mail.python.org/mailman/listinfo/python-list