Hacker News new | past | comments | ask | show | jobs | submit login

If all marbles in a bag are black, and you take one marble out, are all marbles in the bag white?

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:

  marbles = ["black"]
  marbles.pop()
  all(m=="white" for m in marbles) # => True



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.

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.

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.


I don't think he was treating "all marbles are white" as the negation of "all marbles are black".

The comment he replied to was claiming that any question that is true for n = 1 should also be true for n = 0, but this comment shows that it is obvious nonsense.

The comment above basically claimed:

  marbles = ["black"]
  all(m=="black" for m in marbles) # => True
  marbles.pop()
  all(m=="black" for m in marbles) # => True
If that is the case then the following would also need to be true:

  all(m=="white" for m in marbles) # => True
  all(m=="green" for m in marbles) # => True
What color is the marble?

Just because the question “there is a marble in the bag such that…” is false does not mean you can just negate it and say “all marbles in the bag are…” if the actual answer is that the question is not applicable.


Its interesting that "for all <is true?>" seems to imply a non-empty set, whereas "for any <is false?>" seems to not make the same implication.

It's certainly misleading in every day speech. On the bright side, all my papers have been published and all of my research funding has been granted.


> "for any <is false?>"

What do you mean here?

"some element doesn't have the attribute" requires a non-empty set.

If you mean "it is false that some element has the attribute", then you need to write that very differently, which makes it much less of a surprise that it has different implications from the "all" statement.


Though it feels strange to write this, the fact that all the marbles are white doesn't change the fact that they're all black...and transparent, and not marbles at all, etc...


Right, my point was pointing out a weakness in the style of explanation—that the same structure can be applied with similar intuitive appeal to reject the behavior of all()—not to actually disagree with the correctness of all() in implementing universal quantification, or the correctness of the design that it should implement universal quantification.


> If all marbles in a bag are black, and you take one marble out, are all marbles in the bag white?

The logical answer is "maybe."


Yes, you took out the last marble that wasn't white, and now all marbles that remain are white.


my pragmatic view is that it should be false.

A common error would be a programming mistake in the selection of the list element return an empty list. The returned list would, unexpectedly, comes empty. Trying to check if everything is black would return True and the code would follow on. It would be very hard to debug


For the any predicate, you want to know if any element satisfies it, which of course, without any elements it can't be satisfied.

If you want the inverse behaviour, you have to verify that all elements do not satisfy it. And that necessarily results in the empty set being falsy on any, but truthy on all.

Also, its just easier to use .any to check if the set is empty or not, in many cases.


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 false if the bag is empty, the statement is true by material implication.


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.


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.

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

We can rewrite this as "For all x, x is not a marble or x is not in the bag or x is even". We can see that this is true if "x is not in the bag" is true for all x. It's not really nonsense because we can quantify over all objects, so some of them will be marbles, some of them will be even, etc.

Going back to the more general question we can look at the statement "For all x, F(x)" where F is any predicate. Call this statement P. The negation ~P is equivalent to "There exists some x such that ~F(x)". But if we are quantifying over the empty set, ~P is false, so P must be true in that case.


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".


>"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?"

They're the same, just quantifying over different sets. I can quantify over objects in the universe, in which case I need the clause about being in the bag. Or I can quantify over objects in the bag, in which case I'm quantifying over the empty set.

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 works differently, but good luck doing that while preserving all of our theorems in set theory and mathematics.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: