Re: cross operator and empty list

2008-04-16 Thread TSa

HaloO,

Larry Wall wrote:

Then [X]() also is ()? How about (0,1) X ([]) === (0,1)?


No, that's (0,[]), (1,[1]).  [] *doesn't* flatten in list context.


I guess you meant (0,[]), (1,[]). And you didn't answer what
[X]() returns. Following your arguments this would be undef.



I am genuinely curious as to why anyone who is not a mathematician
would want this?


Well, as an alternate default list. Especially if you are unsure
if a list will be subject to X. This would also be true and still
neutral for concatenation. So we would end up with two identity
elements unless they are equal as far as listhood is concerned.
Hmm, I agree that's all a bit constructed.


Rather than bend the current practical meanings of ()
and [], we possibly have the symbolic concept expressible as none(*).

 We don't define junctions as special in lists, which means it would
 be up to the implementation of infix:X to do something with it.

Would '() but .elems(1)' do the trick, too? With overloading X in
mind any type distinct from List would do. E.g. a UnitList singleton
type. But I don't get how none(*) expresses the unit list concept.
Why is none(*).elems == 1 and why (1,2,none(*)) === (1,2)? Would
other junctions behave the same?



But let me reiterate that lists are just lists, not sets.  In fact,
they're closer to bags than sets.  But lists are as much about
ordering as they are about membership.  Please don't take the use
of mathematical language to metaphorically describe the behavior of
infix:X as an attempt to confuse you.  :)


I just wondered what mathematical structure (List,infix:X) has.
Without an identity element it's just a semigroup. Whereas (List,
infix:,) is a monoid with () as identity element. So e.g. I wonder
if there's an isomorphism between that and (Str,infix~). But I
agree that I shouldn't bother the list with such things unless I
hope it could be useful for Perl 6 which I hoped for the identity
of X. But seemingly that was a false hope.


Regards, TSa.
--

The unavoidable price of reliability is simplicity
  -- C.A.R. Hoare


Re: cross operator and empty list

2008-04-14 Thread Xavier Noria

On Apr 12, 2008, at 17:37 , Moritz Lenz wrote:


[EMAIL PROTECTED] wrote:
Technically the Cartesian cross operator doesn't have an identity  
value.


It has.
The set which contains only the emty set, or in perl terms ([]);


If (a, b) denotes an ordered pair you get

   {0, 1} X {{}} = {(0, {}), (1, {})}

which, you see, is different from {0, 1}. They have different  
elements. The fact that there's a clear mapping that sort of  
identifies them has nothing to do with set equality.


-- fxn



RE: cross operator and empty list

2008-04-14 Thread Miller, Hugh
 

-Original Message-
From: Mark A. Biggar [mailto:[EMAIL PROTECTED] 
Sent: Sunday, April 13, 2008 11:22 PM
To: Miller, Hugh
Cc: Moritz Lenz; p6l
Subject: Re: cross operator and empty list

Miller, Hugh wrote:
 From: Moritz Lenz [mailto:[EMAIL PROTECTED]
 [EMAIL PROTECTED] wrote:
 Technically the Cartesian cross operator doesn't have an
 identity value.
 It has.
 The set which contains only the emty set, or in perl terms ([]); Or 
 am I missing something?
 Should be a (any) 1 point set for the identity.
 How about considering models from category theory, rather than set 
 theory ? Seems much more fruitful for computer issues than 
set theory.

No an identity would be a set E such that for any set A: A x E 
= A, but no such set exists.  A singleton set get close, but 
the result is only isomorphic (there is a natural bijection) 
not equal. Even in category theory you only get isomorphism.


--
[EMAIL PROTECTED]
[EMAIL PROTECTED]


Just so! Been looking at category theory so much lately that equality
has become just a special case of isomorphism without my noticing it.
-
Hugh Miller
e-mail: [EMAIL PROTECTED]


Re: cross operator and empty list

2008-04-14 Thread Xavier Noria

On Apr 14, 2008, at 12:05 , TSa wrote:


HaloO,

Xavier Noria wrote:

  {0, 1} X {{}} = {(0, {}), (1, {})}
which, you see, is different from {0, 1}. They have different  
elements. The fact that there's a clear mapping that sort of  
identifies them has nothing to do with set equality.


But X is cooperating with , in Perl 6:

 (0,1) X (()) === ((0,()),(1,())) === (0,1)

That is, X strips the outer list and comma concatenates the
inner empty list away.

With your definition X is not even associative because @a X @b X @c  
does

not produce a list of triples but either
   (@a X @b) X @c  === ( ((@a[0],@b[0]), @c[0]), ...)
or
@a X (@b X @c) === ( ( @a[0], (@b[0],@c[0])), ...).
That is two lists of differently  structured pairs.


Oh yes thank you. There was a subthread about the Cartesian product in  
Set Theory itself. I didn't mean that applied to the Perl operator.


-- fxn



Re: cross operator and empty list

2008-04-14 Thread TSa

HaloO,

Xavier Noria wrote:

   {0, 1} X {{}} = {(0, {}), (1, {})}

which, you see, is different from {0, 1}. They have different elements. 
The fact that there's a clear mapping that sort of identifies them has 
nothing to do with set equality.


But X is cooperating with , in Perl 6:

  (0,1) X (()) === ((0,()),(1,())) === (0,1)

That is, X strips the outer list and comma concatenates the
inner empty list away.

With your definition X is not even associative because @a X @b X @c does
not produce a list of triples but either
(@a X @b) X @c  === ( ((@a[0],@b[0]), @c[0]), ...)
or
 @a X (@b X @c) === ( ( @a[0], (@b[0],@c[0])), ...).
That is two lists of differently  structured pairs.


Regards, TSa.
--

The Angel of Geometry and the Devil of Algebra fight for the soul
of any mathematical being.   -- Attributed to Hermann Weyl


Re: cross operator and empty list

2008-04-14 Thread Larry Wall
On Mon, Apr 14, 2008 at 12:05:15PM +0200, TSa wrote:
 But X is cooperating with , in Perl 6:

   (0,1) X (()) === ((0,()),(1,())) === (0,1)

 That is, X strips the outer list and comma concatenates the
 inner empty list away.

No, the inner () is also in list context, and () in list context
always just disappears.

And 0,1 X () is going to be ().  Perl 6's infix:X is defined over
lists, not sets.  If you want to overload X for set types, you may.

Larry


Re: cross operator and empty list

2008-04-14 Thread TSa

HaloO,

Larry Wall wrote:

No, the inner () is also in list context, and () in list context
always just disappears.

And 0,1 X () is going to be ().  Perl 6's infix:X is defined over
lists, not sets.  If you want to overload X for set types, you may.


Then [X]() also is ()? How about (0,1) X ([]) === (0,1)?
The original question was sort of about how to write a list
that has .elems == 1 but no content.


Regards, TSa.
--

The Angel of Geometry and the Devil of Algebra fight for the soul
of any mathematical being.   -- Attributed to Hermann Weyl


Re: cross operator and empty list

2008-04-14 Thread TSa

HaloO,

I wrote:

Then [X]() also is ()? How about (0,1) X ([]) === (0,1)?
The original question was sort of about how to write a list
that has .elems == 1 but no content.


Other ideas are: [[]] and @@() with the latter not very likely
because it implies any multidimensional array somehow having
at least one element.

Regards, TSa.
--

The Angel of Geometry and the Devil of Algebra fight for the soul
of any mathematical being.   -- Attributed to Hermann Weyl


Re: cross operator and empty list

2008-04-14 Thread Larry Wall
On Mon, Apr 14, 2008 at 06:28:06PM +0200, TSa wrote:
 HaloO,

 Larry Wall wrote:
 No, the inner () is also in list context, and () in list context
 always just disappears.

 And 0,1 X () is going to be ().  Perl 6's infix:X is defined over
 lists, not sets.  If you want to overload X for set types, you may.

 Then [X]() also is ()? How about (0,1) X ([]) === (0,1)?

No, that's (0,[]), (1,[1]).  [] *doesn't* flatten in list context.

 The original question was sort of about how to write a list
 that has .elems == 1 but no content.

I am genuinely curious as to why anyone who is not a mathematician
would want this?  Rather than bend the current practical meanings of ()
and [], we possibly have the symbolic concept expressible as none(*).
We don't define junctions as special in lists, which means it would
be up to the implementation of infix:X to do something with it.

But let me reiterate that lists are just lists, not sets.  In fact,
they're closer to bags than sets.  But lists are as much about
ordering as they are about membership.  Please don't take the use
of mathematical language to metaphorically describe the behavior of
infix:X as an attempt to confuse you.  :)

By the way, you don't need to put parens around the arguments to X.
It takes a list on either side.  We made it tall so that it would
stand out visually anyway:

$a,$b,$c X $x,$y,$z

Larry


Re: cross operator and empty list

2008-04-14 Thread Mark J. Reed
On Mon, Apr 14, 2008 at 06:28:06PM +0200, TSa wrote:
 The original question was sort of about how to write a list
 that has .elems == 1 but no content.

Wouldn't that just be [[]] ?

Mark J. Reed [EMAIL PROTECTED]


Re: cross operator and empty list

2008-04-14 Thread Doug McNutt
At 09:58 -0700 4/14/08, Larry Wall wrote:
By the way, you don't need to put parens around the arguments to X. It takes a 
list on either side.  We made it tall so that it would stand out visually 
anyway:

$a,$b,$c X $x,$y,$z

How long before some engineer or 3D graphic artist gets really frustrated when 
he doesn't get what he expects?

($a,$b,$c) X ($x,$y,$z) --- ($b*$z - $c*$y, $c*$x - $a*$z, $a*$y - $b*$x)

use classic_vectors; # perhaps.


-- 
-- If you are presented a number as a percentage, and you do not clearly 
understand the numerator and the denominator involved, you are surely being 
lied to. --


Re: cross operator and empty list

2008-04-14 Thread Larry Wall
On Mon, Apr 14, 2008 at 11:47:04AM -0600, Doug McNutt wrote:
: At 09:58 -0700 4/14/08, Larry Wall wrote:
: By the way, you don't need to put parens around the arguments to X. It takes 
a list on either side.  We made it tall so that it would stand out visually 
anyway:
: 
: $a,$b,$c X $x,$y,$z
: 
: How long before some engineer or 3D graphic artist gets really frustrated 
when he doesn't get what he expects?
: 
: ($a,$b,$c) X ($x,$y,$z) --- ($b*$z - $c*$y, $c*$x - $a*$z, $a*$y - $b*$x)
: 
: use classic_vectors; # perhaps.

Which darn well better leave X alone and use

тип   2A2FVECTOR OR CROSS PRODUCT

instead.

Larry


Re: cross operator and empty list

2008-04-14 Thread John M. Dlugosz

Doug McNutt douglist-at-macnauchtan.com |Perl 6| wrote:

At 09:58 -0700 4/14/08, Larry Wall wrote:
  

By the way, you don't need to put parens around the arguments to X. It takes a 
list on either side.  We made it tall so that it would stand out visually 
anyway:

   $a,$b,$c X $x,$y,$z



How long before some engineer or 3D graphic artist gets really frustrated when 
he doesn't get what he expects?

($a,$b,$c) X ($x,$y,$z) --- ($b*$z - $c*$y, $c*$x - $a*$z, $a*$y - $b*$x)

use classic_vectors; # perhaps.


  
I think the ability to use mathematical vectors should be in a library.  
Perhaps more than one, with different aims.


So I'm more interested in making sure the core language supports writing 
such a library, that works with existing types and operators more 
seamlessly then in other languages, than about the actual semantics of a 
mathematical vector.


RE: cross operator and empty list

2008-04-13 Thread Miller, Hugh
 

-Original Message-
From: Moritz Lenz [mailto:[EMAIL PROTECTED] 
Sent: Saturday, April 12, 2008 10:37 AM
To: [EMAIL PROTECTED]
Cc: p6l
Subject: Re: cross operator and empty list

[EMAIL PROTECTED] wrote:
 Technically the Cartesian cross operator doesn't have an 
identity value.

It has.
The set which contains only the emty set, or in perl terms ([]);

Or am I missing something?

Cheers,
Moritz
--
Moritz Lenz
http://moritz.faui2k3.org/ |  http://perl-6.de/



Should be a (any) 1 point set for the identity.

How about considering models from category theory, rather than set
theory ? Seems much more fruitful for computer issues than set theory.

-
Hugh Miller
e-mail: [EMAIL PROTECTED]


Re: cross operator and empty list

2008-04-13 Thread Mark A. Biggar

Miller, Hugh wrote:
From: Moritz Lenz [mailto:[EMAIL PROTECTED] 
[EMAIL PROTECTED] wrote:
Technically the Cartesian cross operator doesn't have an 

identity value.
It has.
The set which contains only the emty set, or in perl terms ([]);
Or am I missing something?

Should be a (any) 1 point set for the identity.
How about considering models from category theory, rather than set
theory ? Seems much more fruitful for computer issues than set theory.


No an identity would be a set E such that for any set A: A x E = A, but 
no such set exists.  A singleton set get close, but the result is only 
isomorphic (there is a natural bijection) not equal. Even in category 
theory you only get isomorphism.



--
[EMAIL PROTECTED]
[EMAIL PROTECTED]


Re: cross operator and empty list

2008-04-12 Thread Moritz Lenz
[EMAIL PROTECTED] wrote:
 Technically the Cartesian cross operator doesn't have an identity value.

It has.
The set which contains only the emty set, or in perl terms ([]);

Or am I missing something?

Cheers,
Moritz
-- 
Moritz Lenz
http://moritz.faui2k3.org/ |  http://perl-6.de/



signature.asc
Description: OpenPGP digital signature


Re: cross operator and empty list

2008-04-07 Thread TSa

HaloO,

Larry Wall wrote:

(@a X @b X @c).elems == @a.elems * @b.elems * @c.elems


Sorry, I was aiming at defining a neutral element of the X
operator. In cartesian products of sets this is achieved
by having a set that contains as sole member the empty tuple.
So how would that be written? (()) perhaps? Or (;)? This
would have (;).elems == 1 but (;),1,2 === (1,2). And it
would be considered true in boolean context I guess. A more
explicit notation might be () but .elems = 1. For anonymous
arrays we already have [()].elems == 1, or not?

The above might be a bit subtle, though. OTOH, it could save
some surprises.


Regards, TSa.
--

The Angel of Geometry and the Devil of Algebra fight for the soul
of any mathematical being.   -- Attributed to Hermann Weyl


Re: cross operator and empty list

2008-04-07 Thread Adriano Ferreira
On Mon, Apr 7, 2008 at 4:50 AM, TSa [EMAIL PROTECTED] wrote:
 HaloO,


  Larry Wall wrote:

 (@a X @b X @c).elems == @a.elems * @b.elems * @c.elems
 

  Sorry, I was aiming at defining a neutral element of the X
  operator.

A neutral element for the cross operator seems weird if that is to be
compared with

0 for addition
1 for multiplication

because the basic assumption would be an element N such that

X op N = X

This would require that the operator with a neutral element should be
a mapping like:

op : D x D - D

which is not the case for the X operator

X : Seq(D1) x Seq(D2) - Seq( D1 x D2 )

At the other hand, any sequence with one only member would define a
result @a x ($any) that would be kind of isomorphically equivalent to
@a itself. But, apart from that, I don't get the value of defining
such a neutral element for the cross operator.

Adriano

 In cartesian products of sets this is achieved
  by having a set that contains as sole member the empty tuple.
  So how would that be written? (()) perhaps? Or (;)? This
  would have (;).elems == 1 but (;),1,2 === (1,2). And it
  would be considered true in boolean context I guess. A more
  explicit notation might be () but .elems = 1. For anonymous
  arrays we already have [()].elems == 1, or not?

  The above might be a bit subtle, though. OTOH, it could save
  some surprises.




  Regards, TSa.
  --

  The Angel of Geometry and the Devil of Algebra fight for the soul
  of any mathematical being.   -- Attributed to Hermann Weyl



Re: cross operator and empty list

2008-04-07 Thread Darren Duncan
Adriano, I think perhaps what Tsa is trying to get at is the identity value 
for the X operator, and I believe I know what it is.


In the relational model of data, both the version of the model where tuples 
have unordered named attributes/elements (which I prefer), and the version 
where tuples have ordered attributes/elements (which Perl 6 seems to be 
using in its X operator), the relational cross product operator is 
analogous to numeric multiplication or logical 'and' in its properties 
(except that the ordered version isn't commutative).


With respect to relational join being like multiplication, the special 
values 0 and 1 are represented by the nilary (zero attribute) relation with 
either 0 or 1 tuples respectively, which in common Perl array-of-hash (or 
array-of-array) notation for rowsets is


  []

and

  [ {} ] or [ [] ]

respectively; I'll call them R0 and R1 for now.  Joining any relation R 
with R0 gives R0 (or alternately a relation with the same attributes as R 
but zero tuples; its zero tuples either way), and joining any relation R 
with R1 gives R.


So R1 is the identity value for cross product, meaning the identity value 
for X, in Perl 6 would be a one-element array|seq whose element is the 
empty array|seq.  That is,


  [X] ()

equals this:

  ( () )

Larry et al, on a related note, the list of identity values for reduce in 
S03 should be updated to account for this; [X] wasn't on the list last I 
looked.


-- Darren Duncan


Re: cross operator and empty list

2008-04-07 Thread mark . a . biggar
Technically the Cartesian cross operator doesn't have an identity value.  There 
is no set X such that 
A x X = A.  Now any singleton set gives a result that is naturally isomorphic 
to the original set, I.e, there is a obvious bijection between the two sets, 
but they are not equal sets.

--
Mark Biggar
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]

 -- Original message --
From: Darren Duncan [EMAIL PROTECTED]
 Adriano, I think perhaps what Tsa is trying to get at is the identity value 
 for the X operator, and I believe I know what it is.
 
 In the relational model of data, both the version of the model where tuples 
 have unordered named attributes/elements (which I prefer), and the version 
 where tuples have ordered attributes/elements (which Perl 6 seems to be 
 using in its X operator), the relational cross product operator is 
 analogous to numeric multiplication or logical 'and' in its properties 
 (except that the ordered version isn't commutative).
 
 With respect to relational join being like multiplication, the special 
 values 0 and 1 are represented by the nilary (zero attribute) relation with 
 either 0 or 1 tuples respectively, which in common Perl array-of-hash (or 
 array-of-array) notation for rowsets is
 
[]
 
 and
 
[ {} ] or [ [] ]
 
 respectively; I'll call them R0 and R1 for now.  Joining any relation R 
 with R0 gives R0 (or alternately a relation with the same attributes as R 
 but zero tuples; its zero tuples either way), and joining any relation R 
 with R1 gives R.
 
 So R1 is the identity value for cross product, meaning the identity value 
 for X, in Perl 6 would be a one-element array|seq whose element is the 
 empty array|seq.  That is,
 
[X] ()
 
 equals this:
 
( () )
 
 Larry et al, on a related note, the list of identity values for reduce in 
 S03 should be updated to account for this; [X] wasn't on the list last I 
 looked.
 
 -- Darren Duncan



Re: cross operator and empty list

2008-04-07 Thread Darren Duncan

[EMAIL PROTECTED] wrote:
Technically the Cartesian cross operator doesn't have an identity value.  There is no set X such that 
A x X = A.  Now any singleton set gives a result that is naturally isomorphic to the original set, I.e, there is a obvious bijection between the two sets, but they are not equal sets.


If you were talking about ordinary set operators, then what you say is 
probably true.  However, my solution was specific to the relational model 
of data, whose operators correspond to a superset of plain set operators.


In this context, when I say plain set operators, I mean things like:

  union (or|add)
  intersection (and|multiply)
  difference
  symmetric difference (xor)

and in the relational model, each of those operators requires their input 
relations to have the same headings, that is their tuples are all of the 
same degree and have the same attribute names, and so the headings of the 
results match both of the inputs.


Extra operators in the relational model that aren't in the plain set include:

  natural join (and|multiply)
cartesian product is a special case
intersection is a special case
semijoin is a special case
  semidifference
  divide (divide)

These extra operators are effectively working in 2 dimensions, where one 
dimension is the set of tuples, and the other is the elements per tuple.


Also, every tuple element can itself be any type, either scalar or tuple or 
relation.  And that feature is orthogonal to the 2 dimensions I mentioned.


Given this context, the identity value of relational join or cross product 
was specifically a 2-dimensional value.


This said, the identity value of joining 2 tuples still goes under the same 
principle, even though that is a 1-dimensional operation.  Joining any 
tuple T with a tuple having zero elements is the first tuple T.


Since the normal output of X is 2-dimensional, it stands to reason that

  ( () )

should be a reasonable identity value for X, I think.

-- Darren Duncan


cross operator and empty list

2008-04-04 Thread TSa

HaloO,

why is (1,2,3) X () defined to be the empty list
and not (1,2,3) as is the case with the cartesian
product of sets which X basically is with preserved
order.

Regards, TSa.
--

The Angel of Geometry and the Devil of Algebra fight for the soul
of any mathematical being.   -- Attributed to Hermann Weyl


Re: cross operator and empty list

2008-04-04 Thread mark . a . biggar
Cartesain product with the empty set is empty.  A x B is the set of all pairs 
(a,b) where a is in A and b is in B. If either is empty then there are no such 
pairs and the result is also empty.

--
Mark Biggar
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]

 -- Original message --
From: TSa [EMAIL PROTECTED]
 HaloO,
 
 why is (1,2,3) X () defined to be the empty list
 and not (1,2,3) as is the case with the cartesian
 product of sets which X basically is with preserved
 order.
 
 Regards, TSa.
 -- 
 
 The Angel of Geometry and the Devil of Algebra fight for the soul
 of any mathematical being.   -- Attributed to Hermann Weyl



Re: cross operator and empty list

2008-04-04 Thread Larry Wall
On Fri, Apr 04, 2008 at 06:51:20PM +0200, TSa wrote:
 HaloO,

 why is (1,2,3) X () defined to be the empty list
 and not (1,2,3) as is the case with the cartesian
 product of sets which X basically is with preserved
 order.

(@a X @b X @c).elems == @a.elems * @b.elems * @c.elems

Larry


Re: cross operator and empty list

2008-04-04 Thread Mark J. Reed
Cartesian product of anything with the empty set is empty. Which is
why SQL has outer joins.



On 4/4/08, TSa [EMAIL PROTECTED] wrote:
 HaloO,

 why is (1,2,3) X () defined to be the empty list
 and not (1,2,3) as is the case with the cartesian
 product of sets which X basically is with preserved
 order.

 Regards, TSa.
 --

 The Angel of Geometry and the Devil of Algebra fight for the soul
 of any mathematical being.   -- Attributed to Hermann Weyl


-- 
Sent from Gmail for mobile | mobile.google.com

Mark J. Reed [EMAIL PROTECTED]