Programming Content
Dictionary for OpenMath




by


Gaston H. Gonnet

Presented at the 8th OpenMath Workshop,
Nice, May 23-24, 1997.



An HTML version of this paper is available at:
http://www.inf.ethz.ch/personal/gonnet/ContDict/Progr.html




The Programming Content Dictionary, provides a mechanism to exchange programs, functions and procedures between OpenMath (OM) complaint applications. All the principles of OpenMath communications apply. This Content Dictionary (CD) defines the most common programming constructs, and allows the encoding of most scientific computation programs. For those who prefer, a BNF grammar version of the programming CD is available.



Principles:
  1. Provide portability to several popular programming languages (for scientific computation).

  2. Steal successful constructs from existing languages.

  3. As with all of OpenMath, what is defined should be correctly implemented/translated, what is outside the definition is up to the user.

  4. Conceptually, a greatest common denominator of several languages.

  5. Special handling of objects is done by a library (e.g. string manipulation, input/output, etc.).



Advantages:
  1. Automatic (simpler) generation of code is possible. In most cases this means increasing the reliability of the code.

  2. Increased portability. This is one of the main goals.

  3. Possibility of optimization at various levels, some of these completely beyond the reach of compilers.

  4. Execution in different languages provides better testing (tighter compilers, run time checkings, etc.).

  5. Symbolic execution (partial or complete) provides proofs or correctness.

  6. Automatic generation of debugging versions, profiling versions, etc.

  7. Library of Metafunctions



Tour of the definition through an example

We will use as an example, the computation of a Moving Parabolic approximation.

The input for this computation is a vector x of dimension n. We will compute a parabolic approximation (polynomial approximation of degree 2) for each consecutive set of m points ending at position i. That is, for each position i

  x[i-j] ~ a0[i] + a1[i]*j + a2[i]*j^2
for j between 0 and m-1. The following graph shows an example of two such approximations from a set of 21 points.

We will call this procedure MovingParabApprox and we will code it in OpenMath. A maple session is used to compute the crucial equations and to optimize this code. This function can be converted to C or to Maple.

To test this function we write a Main program. This is also written in OpenMath. This program can be converted to C or to Maple. The output of both programs is, fortunately, identical. The code for Maple can also be executed symbolically, this provides some level of program verification.