Data Format

OpenXM admits multiple mathematical encodings such as OpenMath, MP, CMO (Common Mathematical Object format). OpenXM itself does not exhibit a bias towards a particular encodings as a main mathematical data carrier and an OpenXM compliant system do not need to implement all possible data formats. However they should at least implement seven primitive data types of the CMO, which are necessary to carry several control informations such as a mathcap. Mathcap is a list of supported CMO's, OpenXM stack machine codes, and necessary extra informations. If a program sends an OX messages unknown to its peer, an unrecoverable error may occur. By exchanging mathcaps, a program knows its peer's capability and such an error can be avoided. Mathcap is also defined as a CMO. See [12] for the details.

Encoding types of OX data are distinguished with tags of OX messages. For example, an OX message with the tag OX_DATA is followed by a CMO packet. An OX message with the tag OX_DATA_OPENMATH_XML is followed by an OpenMath XML string.

Let us explain the data format of CMO. Any CMO packet consists of a header and a body. The size of the header is 4 bytes that tags the data type of the body. Data type tags are signed 32 bit integers which is called int32 in this paper. Following tags are registered in the OpenXM.

#define CMO_ERROR2                         0x7f000002
#define CMO_NULL                           1
#define CMO_INT32                          2
#define CMO_DATUM                          3
#define CMO_STRING                         4
#define CMO_MATHCAP                        5
#define CMO_LIST                           17

#define CMO_MONOMIAL32                     19
#define CMO_ZZ                             20
#define CMO_QQ                             21
#define CMO_ZERO                           22
#define CMO_DMS_GENERIC                    24
#define CMO_DMS_OF_N_VARIABLES             25
#define CMO_RING_BY_NAME                   26
#define CMO_RECURSIVE_POLYNOMIAL           27
#define CMO_LIST_R                         28
#define CMO_INT32COEFF                     30
#define CMO_DISTRIBUTED_POLYNOMIAL         31
#define CMO_POLYNOMIAL_IN_ONE_VARIABLE     33
#define CMO_RATIONAL                       34
#define CMO_64BIT_MACHINE_DOUBLE           40
#define CMO_ARRAY_OF_64BIT_MACHINE_DOUBLE  41
#define CMO_BIGFLOAT                       50
#define CMO_IEEE_DOUBLE_FLOAT              51
#define CMO_INDETERMINATE                  60
#define CMO_TREE                           61
#define CMO_LAMBDA                         62
The first seven primitive types should be implemented on all OpenXM compliant systems. The formats are as follows.
int32 CMO_ERROR2 CMObject ob

int32 CMO_NULL  

int32 CMO_INT32 int32 n

int32 CMO_DATUM int32 n byte data[0]
$\cdots$ byte data[n-1]  

int32 CMO_STRING int32 n byte data[0]
$\cdots$ byte data[n-1]  

int32 CMO_MATHCAP CMObject ob

int32 CMO_LIST int32 n CMObject ob[0]
$\cdots$ CMObject ob[n-1]  

CMO's can be expressed in terms of XML. For example, (CMO_INT32 $1234$) can be expressed by
<cmo>
 <cmo_int32>
   <int32> 1234 </int32>
 </cmo_int32>
</cmo>
As to the formats of other CMO's and XML, see [12].

When one wants to implement CMO on a server, the person proceeds as follows.

  1. Look for the list of CMO's at the web cite [15]. If there is a CMO that fits to one's requirement, then use this CMO.
  2. If there is no suitable CMO, design a new CMO and register the new CMO to [15] with a description and examples.

Nobuki Takayama 2017-03-30