Goto Chapter: Top 1 2 3 Bib Ind
Top of Book Previous Chapter Next Chapter

3 Extending the OpenMath package
3.1 Exploring the range of supported symbols
3.2 Adding support for private content dictionaries and symbols

### 3 Extending the OpenMath package

#### 3.1 Exploring the range of supported symbols

The OpenMath package supports such basic OpenMath objects as integers ( <OMI> ), character strings ( <OMSTR> ) and variables ( <OMVAR> ). Besides that, it supports a number of OpenMath content dictionaries (some of them only partially, dependently on their relevance to GAP). To see which symbols from which content dictionaries are supported for the conversion from OpenMath to GAP, explore the global record `OMsymRecord`. Its components have names of appropriate CDs, and subcomponents of each component have names of symbols from the corresponding CD. If the value of the component is not equal to `fail`, then it contains the function or the object which is used for conversion. The following example of the entry for the nums1 CD demonstrates a combination of all possible cases:

    gap> Print(OMsymRecord.nums1,"\n");
    rec(
      e := fail,
      i := E(4),
      pi := fail,
      based_integer := fail,
      gamma := fail,
      infinity := infinity,
      NaN := fail,
      rational := function ( x )
            return OMgapId( [ OMgap2ARGS( x ), x[1] / x[2] ] )[2];
        end )

`OMsymRecord` contains all symbols for which conversion from OpenMath to GAP is supported except some special symbols related with errors and special procedures from the SCSCP package which are treated separately.

To check quickly if GAP can parse a given OpenMath object, copy the OpenMath code and paste it directly into standard input after the following commands:

    gap> stream := InputTextUser();;
    gap> g := OMGetObject(stream);CloseStream(stream);

The main tool for the conversion from GAP to OpenMath is `OMPut( <stream>, <object> )`. A number of methods for `OMPut` are installed in the file `openmath/gap/omput.gi`.

To check quickly whether the object may be converted to OpenMath, call `OMprint` for that object, for example:

    gap> OMPrint( [ [1..10], ZmodnZObj(2,6), (1,2) ] );
    <OMOBJ>
    	<OMA>
    		<OMS cd="list1" name="list"/>
    		<OMA>
    			<OMS cd="interval1" name="integer_interval"/>
    			<OMI> 1</OMI>
    			<OMI> 10</OMI>
    		</OMA>
    		<OMA>
    			<OMS cd="integer2" name="class"/>
    			<OMI> 2</OMI>
    			<OMI> 6</OMI>
    		</OMA>
    		<OMA>
    			<OMS cd="permut1" name="permutation"/>
    			<OMI> 2</OMI>
    			<OMI> 1</OMI>
    		</OMA>
    	</OMA>
    </OMOBJ>

The package is in the continuous development and will support even more symbols in the future. In the meantime, if you will have any requests for the support for particular symbols, please write to Alexander Konovalov who currently develops and maintains the package.

#### 3.2 Adding support for private content dictionaries and symbols

There is also a way for the user to extend the package adding support for private and experimental CDs or separate symbols. We allocated the directory `openmath/private` for this purposes, and currently it contain the file `private.g` for conversions from OpenMath to GAP and the file `private.gi` for conversions from GAP to OpenMath for some symbols from private CDs contained in the `openmath/cds` directory.

In particular, we extended the package with the following private OpenMath symbols:

- `group1.group_by_generators` which allows us to input and output groups given by their generators as this is a natural way to create groups in GAP;

- `semigroup1.semigroup_by_generators` and `monoid1.monoid_by_generators` following the same considerations for semigroups and monoids;

- `pcgroup1.pcgroup_by_pcgscode` for PcGroups given by their pcgs code and order;

- `record1.record` for records as they are important data structures which we want to pass in a straightforward manner between different GAP instances;

- `transform1.transformation` to support transformations, transformation semigroups and their automorphism groups.

The file `private.g` is loaded from `openmath/gap/new.g`, and the `private.gi` is loaded from `openmath/gap/read.g`. If the user would like to add own code, this may be done either by adding it to these files or by placing additional files in `openmath/private` directory and load them similarly to `private.g` and `private.gi`. We will welcome user's contributions in the form of the code to support existing content dictionaries from the OpenMath web site or private content dictionaries, if they may be interesting for a wider community.

Top of Book Previous Chapter Next Chapter
Goto Chapter: Top 1 2 3 Bib Ind

generated by GAPDoc2HTML