Obviously we need to implement the various usual sets of numbers:

- the ring of
__INTEGER NUMBERS__, - the field of
__RATIONAL NUMBERS__, - the rings of
__MODULAR INTEGERS__/*n*(and especially those which are prime fields), - the different sets of
__FLOATING POINT NUMBERS__(with fixed or arbitrary precision), - the ordered ring of
__REAL ALGEBRAIC NUMBERS__, - and many others that we will discover later.

Clearly we need also:

__UNIVARIATE OR MULTIVARIATE POLYNOMIALS__over each of these sets of numbers,__MATRICES__over the same sets,- and also polynomial or matrix rings over any ring we can consider, including polynomial or matrix rings themselves.

So we need infinitely many algebraic types. Let us call these types RINGS.

Moreover we need __ALGEBRAIC STRUCTURES__
(ring, commutative ring, Euclidean domain,
field, finite field, prime field, univariate polynomial ring, ...)
for the following reasons.

**Genericity**- We can organize our infinitely many RINGS
in a finite number of RING types.
Then, for instance, we can define the
*Euclidean algorithm*once for all for every Euclidean domain. For instance, for any Euclidean domain*R*we need to saygcd(a,b) == while not zero? b repeat (a,b):= (b,a rem b) return a

**Conditional declaration**- A matrix ring (or polynomial ring) may possess
an operation (inverse, gcd, ...) that another does not
and this fact depends on its coefficient ring.
So our MATRIX RINGS and POLYNOMIAL RINGS
should depend on the properties of their coefficient RING.
For instance we need to say:
*if**R*is a field then the ring*R*[*x*] of univariate polynomials over*R*is an Euclidean domain. **Conditional implementation**- The implementation of an operation defined
in several univariate polynomial rings like
( *p*,*n*)*p*^{n}(28)

may depend on the properties of the coefficient RING. Let*R*be a ring and*p*(*X*) =*aX*+*b*be a univariate polynomial in*X*with coefficient*a*,*b*in*R*. If*R*is a non-commutative ring then( *aX*+*b*)^{3}=*a*^{3}*X*^{3}+ (*a*^{2}*b*+*aba*+*ba*^{2})*X*^{2}+ (*abb*+*bba*+*bab*)*X*+*b*^{3}.(29)

If*R*is any commutative ring then( *aX*+*b*)^{3}=*a*^{3}*X*^{3}+ 3*a*^{2}*bX*^{2}+ 3*ab*^{2}*X*+*b*^{3}.(30)

If*R*is /3 then( *aX*+*b*)^{3}=*a*^{3}*X*^{3}+*b*^{3}.(31)

**Specialization**- Among all RINGS of a given type one
may have a much better algorithm for a given RING.
So for this particular one, we may wish to replace
the
*generic definition*of an operation. For instance for the Euclidean domain of the integers we may wish to say (with some optimizations ...)gcd(a,b) == while a ~= b repeat if a < b then b := b-a else a := a-b return a

2003-06-06