Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Set Theory (Was: Do junctions support determining interesections of lists)

7 views
Skip to first unread message

Jonathan Lang

unread,
Apr 4, 2006, 2:02:55 PM4/4/06
to perl6-l...@perl.org
Will perl6 Sets include set negation and/or a universal set? In
effect, an internal flag that says, "this set contains every possible
element _except_ the ones listed"?

--
Jonathan "Dataweaver" Lang

Larry Wall

unread,
Apr 4, 2006, 2:16:12 PM4/4/06
to perl6-l...@perl.org
On Tue, Apr 04, 2006 at 11:02:55AM -0700, Jonathan Lang wrote:
: Will perl6 Sets include set negation and/or a universal set? In

: effect, an internal flag that says, "this set contains every possible
: element _except_ the ones listed"?

Arguably, that's what none() is. And all() is the only junction that
is also a "normal" enumerated set. The any() junction is the set of
sets that would intersect with the corresponding all() set without
producing the null set. And the one() junction is the set of sets
corresponding to the enumeration of all().

But this is all based on enumerated sets. Oddly missing are any
Sets that are defined by rule. That would presumably take closures,
though I suppose one can attempt to enumerate the closures that have
to hold true and autothread through the calls to those closures...

Can Russel be far behind? :-)

Larry

Yuval Kogman

unread,
Apr 4, 2006, 2:16:00 PM4/4/06
to Jonathan Lang, perl6-l...@perl.org
On Tue, Apr 04, 2006 at 12:02:55 -0700, Jonathan Lang wrote:
> Will perl6 Sets include set negation and/or a universal set? In
> effect, an internal flag that says, "this set contains every possible
> element _except_ the ones listed"?

Sure! How else will we implement the garbage collector?

;-)

--
Yuval Kogman <nothi...@woobling.org>
http://nothingmuch.woobling.org 0xEBD27418

Jonathan Lang

unread,
Apr 4, 2006, 2:23:14 PM4/4/06
to perl6-l...@perl.org
Larry Wall wrote:
> On Tue, Apr 04, 2006 at 11:02:55AM -0700, Jonathan Lang wrote:
> : Will perl6 Sets include set negation and/or a universal set? In
> : effect, an internal flag that says, "this set contains every possible
> : element _except_ the ones listed"?
>
> Arguably, that's what none() is.

...except that none() is a Junction, not a Set. As such, the same
arguments that say that any() and all() aren't suitable for use as
Sets apply to none(), don't they?

--
Jonathan "Dataweaver" Lang

Larry Wall

unread,
Apr 4, 2006, 2:39:04 PM4/4/06
to perl6-l...@perl.org

You're confusing the map with the territory. We're trying to decide
*how* Junctions are like Sets, not defining them into two different
universes. I'm saying that all() is the Junction tha is most like
a Set. A none() Junction can be viewed as the specification for an
infinite set of sets that do not intersect with the corresponding all()
junction. Infinite sets are a bit hard to compute with directly.

A one() junction is the spec for a number of sets corresponding to the
values of the corresponding all() junction, each of which contains only
one element from that set. An any() Junction is all possible subsets
not counting the null set.

So junctional logic could be defined in terms of set theory, but not
in a necessarily computable way.

Larry

Flavio S. Glock

unread,
Apr 4, 2006, 3:02:04 PM4/4/06
to perl6-l...@perl.org
2006/4/4, Larry Wall <la...@wall.org>:

> But this is all based on enumerated sets. Oddly missing are any
> Sets that are defined by rule. That would presumably take closures,
> though I suppose one can attempt to enumerate the closures that have
> to hold true and autothread through the calls to those closures...
>
> Can Russel be far behind? :-)

This is in ext/Recurrence:

use Recurrence;

# all integer numbers
$universe = Recurrence.new(
closure_next => sub { $_ + 1 },
closure_previous => sub { $_ - 1 },
:is_universe(1) );

# all even integers
$even_numbers = Recurrence.new(
closure_next => sub { 2 * int( $_ / 2 ) + 2 },
closure_previous => sub { 2 * int( ( $_ - 1 ) / 2 ) },
universe => $universe );

# all odd integers
$odd_numbers = $even_numbers.complement;

# all non-zero integers
$non_zero = Recurrence.new(
closure_next => sub ($x) { $x == -1 ?? 1 !! $x + 1 },
closure_previous => sub ($x) { $x == 1 ?? -1 !! $x - 1 },
complement_next => sub ($x) { $x < 0 ?? 0 !! Inf },
complement_previous => sub ($x) { $x > 0 ?? 0 !! -Inf },
universe => $universe );

- Flavio S. Glock

Jonathan Lang

unread,
Apr 4, 2006, 3:10:48 PM4/4/06
to perl6-l...@perl.org
Larry Wall wrote:
> You're confusing the map with the territory. We're trying to decide
> *how* Junctions are like Sets, not defining them into two different
> universes. I'm saying that all() is the Junction tha is most like
> a Set. A none() Junction can be viewed as the specification for an
> infinite set of sets that do not intersect with the corresponding all()
> junction. Infinite sets are a bit hard to compute with directly.

OK, then; what would be the specification for a _single_ set that
contains everything that doesn't intersect with a corresponding all()
Junction (the sort of thing that I'd use if I wanted to find the
largest subset of A that doesn't intersect with B)?

> A one() junction is the spec for a number of sets corresponding to the
> values of the corresponding all() junction, each of which contains only
> one element from that set. An any() Junction is all possible subsets
> not counting the null set.

Yeah; I got that.

--
Jonathan "Dataweaver" Lang

Luke Palmer

unread,
Apr 4, 2006, 4:11:34 PM4/4/06
to perl6-l...@perl.org
On 4/4/06, Jonathan Lang <dataw...@gmail.com> wrote:
> OK, then; what would be the specification for a _single_ set that
> contains everything that doesn't intersect with a corresponding all()
> Junction (the sort of thing that I'd use if I wanted to find the
> largest subset of A that doesn't intersect with B)?

Can't do it. Here's a proof.

Suppose you could find a _single_ set that contains everything that
doesn't intersect some other set (the complement). Let S be the
complement of the empty set. S is not an element of the empty set, so
it must be a member of S, which is impossible.

Finding the complement of a set assuming some other set is not hard
though, simply by using the set difference operator.

Luke

0 new messages