[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-core
Subject:    [ruby-core:74028] [Ruby trunk Feature#12110] Create a method to avoid vacuous truth?
From:       sawadatsuyoshi () gmail ! com
Date:       2016-02-28 1:32:47
Message-ID: redmine.journal-57179.20160228013246.ea9f1c1a209d6d48 () ruby-lang ! org
[Download RAW message or body]

Issue #12110 has been updated by Tsuyoshi Sawada.


Martin Dürst wrote:
> Andrew Vit wrote:
> 
> > This is still surprising to me, it looks like a contradiction:
> > 
> > ```
> > [].any? #=> false
> > [].all? #=> true
> > ```
> > 
> > I would expect "all" to be a superset of "any": both should mean "at least one".
> > Is there a reason for the existing behavior, or is it just history now?
> 
> It's the way it works in Mathematics.

In natural language, universal quantification carries a presupposition that the \
domain is non empty; the meaning of "for all x in A, p(x)" is undefined when A is \
empty, just like "the king of the United States" is undefined. And whenever universal \
quantification is defined, the entailment holds: "for all x in A, p(x) → for some x \
in A, p(x)". That is probably what Andrew Vit was mentioning. And that is where \
natural language and formal systems differ, which makes the latter a bit \
counter-intuitive.

----------------------------------------
Feature #12110: Create a method to avoid vacuous truth?
https://bugs.ruby-lang.org/issues/12110#change-57179

* Author: Waldyr de Souza
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
I often find myself running into unexpected results when using #all? for example

[].all? { |e| false } # => true

Even though it's logically correct could we have a method that express the following?

foo.any? && foo.all?(&:bar)



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic