[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

From: Bill Page
Subject: Re: [Axiom-math] What is the "+/" operator?
Date: Wed, 23 May 2007 20:48:09 -0400
User-agent: Webmail 4.0

| > ... Igor Khavkine writes:
| >
| >> Can someone explain this syntax? Looking at the Axiom.spad
| >> files, I see that it has general usage +/[...list construction...]. | >
| Quoting Martin Rubey:
| > It is old syntax for reduce and should go away. ... "Bill Page" <address@hidden> writes:

| But I agree that it should not appear directly in SPAD
| files.

Ralf Hemmecke writes:

| I very much agree. The reason is that one should give an initial value
| ...
Quoting Gabriel Dos Reis :


Reduction through "/" is a functional on monoid operations,
so one should expect to give a unit element.

Ok, as Ralf showed it is possible in Axiom to write / as
such a functional:

1) -> Z ==> Integer

(2) -> /: ((Z, Z) -> Z, List Z) -> Z

(3) -> _/(f: (Z, Z) -> Z,l: List Z): Z == ( empty? l => 0; f(first l,
   Function declaration ?/? : (((Integer,Integer) -> Integer),List
Integer) -> Integer has been added to workspace.
(4) -> (+)/[1,2,3]
   Compiling function / with type (((Integer,Integer) -> Integer),List
      Integer) -> Integer

Based on this I tentatively withdraw my object. However as you
point out:

   empty? l => 0

 is bogus. What we want is something like:

   empty? l => Unit(f)

where f(x,Unit f) = x.
Unfortunately this returns to the old problem that Axiom's library
does not fully abstract 'Moniod'

It defines another peculiar and parallel construct 'AbelianMonoid'
(that does not inherit from Monoid) in order to avoid the conflict of
names of operation associated with these separate monoid

  )show Monoid
  )show AbelianMonoid

Note the defintions of:

   ?*? : (%,%) -> %


   ?+? : (%,%) -> %

respectively, but:

(12) -> AbelianMonoid has Monoid

   (12)  false
                                      Type: Boolean

Anyway we might write:

  Unit(f) ==
     f=(+)$Integer => 0
     f=(*)$Integer => 1

So but maybe we could at least abstract the monoid 'Unit' by
overloading such functionals as 'Unit' and '/' defined in Monoid
and AbelianMonoid? Not perfect but ...
reduce on the other hand would want an initial value, or a value
to return when the list of operand is empty.

Indeed there are such variants of the 'reduce' operator in
Axiom, e.g.
   )show FiniteLinearAggregate

Bill Page.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]