axiom-math
[Top][All Lists]

## Re: [Axiom-math] What is the "+/" operator?

 From: Gabriel Dos Reis Subject: Re: [Axiom-math] What is the "+/" operator? Date: Wed, 23 May 2007 19:40:26 -0500 (CDT)

```On Thu, 24 May 2007, Ralf Hemmecke wrote:

| On 05/24/2007 01:23 AM, Gabriel Dos Reis wrote:
| > Ralf Hemmecke <address@hidden> writes:
| >
| > | On 05/23/2007 06:50 PM, Bill Page wrote:
| > | > Quoting Martin Rubey <address@hidden>:
| > | >
| > | > > ... Igor Khavkine writes:
| > | > >
| > | > > > Can someone explain this syntax? Looking at the Axiom .spad files,
| > | > > > I see that it has general usage +/[...some list construction...].
| > | > >
| > | > > It is old syntax for reduce and should go away.
| > |
| > | I very much agree. The reason is that one should give an initial value
| > | otherwise you might be surprised.
| >
| > I don't see why there should be a surprise.
| >
| > Reduction through "/" is a functional on monoid operations, so one
| > should expect to give a unit element.
|
| Sure. So whoever (which means a program) deals with "/" should first check
| whether the second argument is a List over a monoid and that the first
| argument is exactly *the* corresponding binary operation of that particular
| monoid.

Or, since we're in the realm of algebraic computation, make sure that the
functional "/" is declared to have the "right" type.

This somehow brings us back to my beef with the way Axiom currently handle
mathematical structures (the old Monoid debate).

| If I look at it that way, then "/" should be a unary operation since what one
| currently writes as its first argument in
|
|   (+)/[1,2,3]
|
| is redundant information.

You know, any n-ary operator can be thought of as a unary operator :-)

| The monoid is specified by the argument of List.
| (The problem arises if a set has two (or more) monoid structures implemented,
| like Integer.)

Yes, and we are back to the old "monoid debate".

When it is "clear from context" which monoid structure is meant, then there
should be no need to explicitly specify the structure.  Of course, deduction
does not always work, and in the case where there are ambiguities one should
be given a mean to disambiguate (using the current System F style notation).

| Or are you saying that you have a domain (like Integer) and the first argument
| then selects the monoid structure? What if I give a binary function as the
| first argument which doesn't make the underlying set into a monoid? That error
| cannot even be caught at runtime.

Think of it this way:  What does reduction "/" need to work with?
A sequence of values and operation that happens to be a monoid operation
over the element type of the list.  So, assume that from the context of use,
the compiler or interpreter (it does not matter which one) can deduce that the
operation + in

"+"/[1, 2, 3]

is a monoid operation integers -- because it has seen a prior statement to
that effect.  What will be wrong?

-- Gaby

```