# Universal Object Oriented Languages and Computer Algebra

## 1 Introduction

Despite of existence of many interactive algebra–numerical systems (MatLAB or MathCAD<sup>1</sup><sup>1</sup>1Either can use MAPLE library) and systems of computer algebra (MACSYMA, REDUCE, MATHEMATICA, MAPLE, etc.), some kind of algebraic problems related with numerous difficult and formal manipulation could not be simply rewritten for computer. The systems of computer algebra very useful if the class of problems under consideration is already has standard implementation. It is symbolic integration and differentiation, rational and integer number arithmetic with arbitrary precision, etc. .

For implementation of new classes of problems the most of systems of computer algebra (CA) have his own programming languages. Sometime it can be very universal and powerful languages like LISP. For example, many new packages was implemented in REDUCE/RLISP by users.

On the other hand the programming of the new methods in a system of CA can be even more difficult, than using universal modern languages like Pascal, C++, etc. with new powerful techniques like data types or object oriented programming (OOP).

In the paper are considered possible extensions of the OOP to make possible of simple implementations to systems of CA. The paper is continue a theme presented earlier at .

## 2 Object Oriented Programming and Computer Algebra

The development of big and difficult pieces of software is often related with proliferation of errors and lost of clarity. The problem of effectiveness of programming was one of central point for creation structural languages like Pascal and new generation of object oriented languages like Java. The LISP, traditional for CA, is very universal, but the structure of programs is too complicated.

The OOP has possibility of understanding representation of structures in CA . For example it is possible to define Module <sup>2</sup><sup>2</sup>2Here it is additive Abelian group, unit is called “zero”:   
Module = Object;   
operation $`+`$ (A,B : Module) : Module;   
operation $``$ (A,B : Module) : Module;   
operation $``$ (A : Module) : Module;   
const Zero : Module;   
end; { Module }   
Then definition of Ring can exploit inheritance in OOP:   
Ring = Object(Module)   
operation $``$ (A,B : Ring) : Ring;   
operation $`/`$ (A,B : Ring) : Ring;   
function Inversion(A : Ring) : Ring;   
const Unit : Ring;   
end; { Ring }   
It is conception of an abstract basic type. They are algebra, module, group, field, ring etc.. The abstract types do not contain a data. Other objects contain data. It is integer, real or complex numbers, quaternions, $`n\times n`$ matrices, etc.:   
Quaternion = Object(Algebra)   
Data : array \[0..3\] of Number;   
function Norm : Number;   
operation $`+`$ (A,B : Quaternion) : Quaternion;   
operation $``$ (A,B : Quaternion) : Quaternion;   
$`\mathrm{}`$   
end; { Quaternion }   

There is a difficulty because in CA it is necessary to work with analytical expressions associated with each of the object. We can have possibility to write either $`z:=2i`$, or $`z:=x+iy`$. In the work  already was discussed some kind of extensions to the model of an object. It is some synthesis of functional and object oriented programming.

Comments to attached copy of slide presentation

## Slide 1

A scientific problem could be resolved with using variety of different ways. Here is represented using: Standard systems of computer algebra, Universal programming languages and traditional work with pen and piece of paper.

$$$$

An application of universal programming languages like C++, Pascal, etc. is still widely used not only for numerical calculation but for any scientific data manipulation, including computer algebra. Here is represented an approach with using Object oriented programming for computer algebra.

$$$$

An object oriented program for computer algebra consists of Specific structures and algorithms of computer algebra together with Standard structures of the object oriented language.

$$$$

It is convenient to merge both types of structures in some Extension of object oriented language for computer algebra.

$$$$

Practical realization of such idea could be either standalone translator for the language or Translator CA $``$ OOP, i.e. convertor of a program for computer algebra to a program on one of widespread object oriented languages (C++, JAVA, Delphi, etc.). The code generator produces program on the OO language, standard algorithms of computer algebra also can be included in Libraries in a standard format accessible for the language. Next, the produced C++ program can be translated to executable module; if it is JAVA program it can be converted to bytecode for using in WWW applets; etc.. It is the possibility to make computer algebra more effective, universal, fast, “light” and to include it as parts in other software projects.

## Slide 2

Here is represented good agreement of principles of object oriented programming with structures of standard algebraic models in mathematics, i.e. inheritance of methods and properties between such abstract objects as Semigroup, Group, Module, Ring, Division ring, Field, Algebra and such descendant “actual” objects as Real and Complex numbers or Polynomials.

## Slide 3

Here is emphasized one of specific property of mathematical language that requires some extension of model of an object in object oriented programming. As a simple example is considered meaning of same variable $`x`$ in different contexts:

What does ‘x’ mean?   
First meaning is traditional for standard programming language there ‘x’ means value of variable $`x`$ and nothing else. But another meanings also are essential and used in mathematics and computer algebra. The second meaning is ‘x’ as some variable $`x`$ of given type with value unknown or not essential. The last, most difficult case is ‘x’ as value of some function with (maybe partially) unknown arguments or expression like $`x=ay+2`$.

\- 

All three meaning are also used in Pure functional programming languages there the functions with partially defined arguments are used and could be described formally as some tree represented on the slide.

\- 

The trees are simply described by using usual Structures in object oriented languages produced by formal inversion of all arrows in diagram above.

\- 

But principles of type checking of an object oriented language should be extended for such a case to make the new structure (an object with pointers to argument and to method of evaluation of the function) compatible with initial type of variable $`x`$. It require an Extension of object programming: compatibility of 3 subtypes mentioned above.