Re: What is the "+/" operator?

"Bill Page" <[email protected]>
Newsgroups gmane.comp.mathematics.axiom.general
Message-ID <[email protected]>
> | > ... 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" <[email protected]> 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 :

> Why?

> 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,
f/(restl)))
    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'

http://wiki.axiom-developer.org/SandBoxMonoid

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
structures:

   )show Monoid
   )show AbelianMonoid

Note the defintions of:

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

and

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

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

Regards,
Bill Page.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.