News for hackers. Stuff that matters.
Re:The 2,500 year old history of why Python’s all([]) return... by fasterik on Friday August 25, 2023 @04:34PM (#37266687)
I think your proposal would break all of logic and mathematics.

"All marbles in the bag are white" is equivalent to "For all x, if x is a marble and x is in the bag, then x is white". Since the antecedent is trivially false if the bag is empty, the statement is trivially true by material implication.

Re:The 2,500 year old history of why Python’s all([]) return... by VonGallifrey on Friday August 25, 2023 @05:17PM (#37267168)
Are those statements really the same?

"For all x, if x is a marble and x is in the bag, then x is white"

I would question if nothingness is a marble. Or would you say that the following statement is also true? I would say that x is a marble and therefore can be neither even or odd because it is not a number?

"For all x, if x is a marble and x is in the bag, then x is even"

That is just a nonsense question same as asking if all the non-existing marbles are of a particular color.

Re:The 2,500 year old history of why Python’s all([]) return... by fasterik on Friday August 25, 2023 @06:35PM (#37267873)
According to the rules of logic, we can always replace (P -> Q) with (~P v Q). In other words, if P is false then (P -> Q) is always true. This is known as a vacuous truth.

https://en.wikipedia.org/wiki/Vacuous_truth

Agreed, sometimes this leads to true statements that sound like nonsense. One example from the article is "if Tokyo is in France, then the Eiffel Tower is in Bolivia". This is a true statement because Tokyo is not in France.

Re:The 2,500 year old history of why Python’s all([]) return... by VonGallifrey on Saturday August 26, 2023 @08:06AM (#37272053)
I think my problem here is that everyone just assumes an extra condition. The question "if Tokyo is in France, then the Eiffel Tower is in Bolivia" is not the same as "is the Eiffel Tower in Bolivia" and the statement of

  all(m=="white" for m in marbles)
is not the same as "For all x, if x is a marble and x is in the bag, then x is white". The statement is more "For all x in the bag, is x white?" and the answer to that is either "No, nothing is not white" or "Question is not applicable".
Re:The 2,500 year old history of why Python’s all([]) return... by fasterik on Saturday August 26, 2023 @02:20PM (#37275426)
all(m=="white" for m in marbles)

By De Morgan's laws, this is equivalent to

not any(m != "white" for m in marbles)

If you want all(m=="white" for m in marbles) to evaluate to False for the empty set, then any(m != "white" for m in marbles) has to evaluate to True for the empty set, or you have to give up on De Morgan's laws.

This is how standard first-order logic works. Again, you're welcome to try to make your own system of logic that's different, but good luck doing that while preserving all of our theorems in set theory and mathematics.