<story><title>Why does all() return True if the iterable is empty?</title><url>https://blog.carlmjohnson.net/post/2020/python-square-of-opposition/</url></story><parent_chain><item><author>dragonwriter</author><text>If all marbles in a bag are black, and you take one marble out, are all marbles in the bag white?&lt;p&gt;The only logical answer is no. It would be rather absurd to make an exception for the case where you start with one marble in the bag... and yet:&lt;p&gt;&lt;pre&gt;&lt;code&gt;  marbles = [&amp;quot;black&amp;quot;]
  marbles.pop()
  all(m==&amp;quot;white&amp;quot; for m in marbles) # =&amp;gt; True&lt;/code&gt;&lt;/pre&gt;</text></item><item><author>tromp</author><text>If all marbles in a bag are black, and you take one marble out, are all marbles in the bag still black?&lt;p&gt;The only logical answer is yes.
It would be rather absurd to make an exception for the case where you start with one marble in the bag. That would make logical reasoning extremely cumbersome, for no benefit whatsoever.</text></item></parent_chain><comment><author>chongli</author><text>The mistake you’re making here is by treating the statement “all marbles are white” as the negation of “all marbles are black” and claiming that this violates the law of the excluded middle.&lt;p&gt;But we are operating under predicate logic. The negation of “all marbles in the bag are black” is “there is a marble in the bag which is not black”. Then, clearly the latter statement is false in the case of an empty bag.&lt;p&gt;In fact, we can confidently claim falsity for any given statement of the form “there is a marble in the bag such that…” when the bag is empty. Therefore, by the law of the excluded middle, its negation is true, so statements of the form “all marbles in the bag are…” are vacuously true when the bag is empty.</text></comment>
<story><title>Why does all() return True if the iterable is empty?</title><url>https://blog.carlmjohnson.net/post/2020/python-square-of-opposition/</url></story><parent_chain><item><author>dragonwriter</author><text>If all marbles in a bag are black, and you take one marble out, are all marbles in the bag white?&lt;p&gt;The only logical answer is no. It would be rather absurd to make an exception for the case where you start with one marble in the bag... and yet:&lt;p&gt;&lt;pre&gt;&lt;code&gt;  marbles = [&amp;quot;black&amp;quot;]
  marbles.pop()
  all(m==&amp;quot;white&amp;quot; for m in marbles) # =&amp;gt; True&lt;/code&gt;&lt;/pre&gt;</text></item><item><author>tromp</author><text>If all marbles in a bag are black, and you take one marble out, are all marbles in the bag still black?&lt;p&gt;The only logical answer is yes.
It would be rather absurd to make an exception for the case where you start with one marble in the bag. That would make logical reasoning extremely cumbersome, for no benefit whatsoever.</text></item></parent_chain><comment><author>bandyaboot</author><text>Though it feels strange to write this, the fact that all the marbles are white doesn&amp;#x27;t change the fact that they&amp;#x27;re all black...and transparent, and not marbles at all, etc...</text></comment>