axiom-math
[Top][All Lists]
Advanced

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

[Axiom-math] missing exports in Finite DirectProduct and Product


From: Bill Page
Subject: [Axiom-math] missing exports in Finite DirectProduct and Product
Date: Wed, 17 Oct 2007 23:19:27 -0400

Axiom Developers;

If the components of the cartesian product Product or DirectProduct
are domains in the category Finite then the product domain has Finite.
Unfortunately the current Axiom library code does not define all of
the required exports of Finite. For example:

(1) -> index(1)$DirectProduct(2,IntegerMod(3))
   Internal Error
   The function index with signature hashcode is missing from domain
      DirectProduct2(IntegerMod 3)

(1) -> index(1)$Product(OVAR [a,b],IntegerMod(3))
   Internal Error
   The function index with signature hashcode is missing from domain
      Product(OrderedVariableList (a b))(IntegerMod 3)

(1) -> DirectProduct(2,IntegerMod(3)) has Finite

   (1)  true
                                                                Type: Boolean

The attached file contains a patch against FriCAS Revision: 112 that
adds the missing operations 'index', 'lookup', and 'hash'.  The
operation 'size' is already available as a default.

Having 'index' available for products allows one to iterate over the
elements of a cross product like this:

  X:=Product(OVAR [a,b],IntegerMod(3))
  [index(i::PI)$X for i in 1..size()$X]

Note: Coercion to PositiveInteger (PI) is required because 'size'
returns an NonNegativeInteger (NNI) so i is of type NNI but index
expects an argument >= 1. Since the products export operations allow
acces to the components it is easy to write functions that map over
such lists.

Writing this made me think that it was also desirable the domains in
Finite also enumerate there members in a more functional manner so
because FriCAS now allows us to easily make fairly deep changes in the
algebra code, as an exercise I decided to define the following new
export of Finite

  expand: () -> List %

  expand() == [index(i::PositiveInteger) for i in 1..size()]

So with this patch one can write for example:

(1) -> map(x+->(selectsecond(x)::Symbol)^(selectfirst(x)::Integer), _
         expand()$Product(ZMOD(3),OVAR [a,b]))

              2  2
   (1)  [a,b,a ,b ,1,1]
                                                Type: List Expression Integer

------

I would be interested in your opinions about this approach to
providing Cartesian products for the Axiom library.

I think it is interesting to see how domains in the category Finite
able to participate like "sets" in the language. Of course it is also
possible to represent countably infinite sets in Axiom via the Stream
domain. This suggests the that the category constructor StepThrough
could also usefully be provided with an export that expands to such
Stream. Perhaps the underlying Spad language should support this sort
of expansion of Finite and countably infinite domains as a standard
form of iterator in the [ ... for i in ... ] construction?

Of course Aldor already has implemented some basic abstractions of
this kind but it is not entirely obvious to me how best to extend
Axiom's library and still stay within the limitations of the current
Spad language.

Regards,
Bill Page.

Attachment: missing-finite-exports.patch
Description: Binary data


reply via email to

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