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
(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.
- 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
we need to say
while not zero? b repeat
(a,b):= (b,a rem b)
- 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:
is a field then the ring
is an Euclidean domain.
- Conditional implementation
- The implementation of an operation defined
in several univariate polynomial rings like
may depend on the properties of the coefficient RING.
be a ring and
be a univariate polynomial in
is a non-commutative ring then
is any commutative ring then
- 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
while a ~= b repeat
if a < b then b := b-a else a := a-b
Marc Moreno Maza