CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

| Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

Views: 418346
1
2
3 Extending the OpenMath package
3
4
5
3.1 Exploring the range of supported symbols
6
7
The OpenMath package supports such basic OpenMath objects as integers (
8
<OMI> ), character strings ( <OMSTR> ) and variables ( <OMVAR> ). Besides
9
that, it supports a number of OpenMath content dictionaries (some of them
10
only partially, dependently on their relevance to GAP). To see which symbols
11
from which content dictionaries are supported for the conversion from
12
OpenMath to GAP, explore the global record OMsymRecord. Its components have
13
names of appropriate CDs, and subcomponents of each component have names of
14
symbols from the corresponding CD. If the value of the component is not
15
equal to fail, then it contains the function or the object which is used for
16
conversion. The following example of the entry for the nums1 CD demonstrates
17
a combination of all possible cases:
18
19
 Example 
20

21
gap> Display( OMsymRecord.nums1 ); 
22
rec(
23
 NaN := nan,
24
 based_integer := fail,
25
 e := 2.718281828459045,
26
 gamma := fail,
27
 i := E(4),
28
 infinity := infinity,
29
 pi := 3.141592653589793,
30
 rational := function ( x )
31
 return OMgapId( [ OMgap2ARGS( x ), x[1] / x[2] ] )[2];
32
 end )
33

34

35
36
OMsymRecord contains all symbols for which conversion from OpenMath to GAP
37
is supported except some special symbols related with errors and special
38
procedures from the SCSCP package which are treated separately.
39
40
To check quickly if GAP can parse a given OpenMath object, copy the OpenMath
41
code and paste it directly into standard input after the following command:
42
43
 Example 
44

45
gap> s:= InputTextUser();; g := OMGetObject(s); CloseStream(s);
46

47

48
49
The main tool for the conversion from GAP to OpenMath is OMPut( <writer>,
50
<object> ). A number of methods for OMPut are installed in the file
51
openmath/gap/omput.gi.
52
53
To check quickly whether the object may be converted to OpenMath, call
54
OMprint for that object, for example:
55
56
 Example 
57

58
gap> OMPrint( [ [1..10], ZmodnZObj(2,6), (1,2) ] ); 
59
<OMOBJ xmlns="http://www.openmath.org/OpenMath" version="2.0">
60
 <OMA>
61
 <OMS cd="list1" name="list"/>
62
 <OMA>
63
 <OMS cd="interval1" name="integer_interval"/>
64
 <OMI>1</OMI>
65
 <OMI>10</OMI>
66
 </OMA>
67
 <OMA>
68
 <OMS cd="integer2" name="class"/>
69
 <OMI>2</OMI>
70
 <OMI>6</OMI>
71
 </OMA>
72
 <OMA>
73
 <OMS cd="permut1" name="permutation"/>
74
 <OMI>2</OMI>
75
 <OMI>1</OMI>
76
 </OMA>
77
 </OMA>
78
</OMOBJ>
79

80

81
82
The package is in the continuous development and will support even more
83
symbols in the future. In the meantime, if you will have any requests for
84
the support for particular symbols, please contact Alexander Konovalov.
85
86
87
3.2 Adding support for private content dictionaries and symbols
88
89
There is also a way for the user to extend the package adding support for
90
private and experimental CDs or separate symbols. We allocated the directory
91
openmath/private for this purposes, and currently it contain the file
92
private.g for conversions from OpenMath to GAP and the file private.gi for
93
conversions from GAP to OpenMath for some symbols from private CDs contained
94
in the openmath/cds directory.
95
96
In particular, we extended the package with the following private OpenMath
97
symbols:
98
99
 group1.group_by_generators which allows us to input and output groups
100
given by their generators as this is a natural way to create groups in
101
GAP;
102
103
 semigroup1.semigroup_by_generators and monoid1.monoid_by_generators
104
following the same considerations for semigroups and monoids;
105
106
 pcgroup1.pcgroup_by_pcgscode for PcGroups given by their pcgs code and
107
order;
108
109
 record1.record for records as they are important data structures which
110
we want to pass in a straightforward manner between different GAP
111
instances;
112
113
 transform1.transformation to support transformations, transformation
114
semigroups and their automorphism groups.
115
116
The file private.g is loaded from openmath/gap/new.g, and the private.gi is
117
loaded from openmath/gap/read.g. If the user would like to add own code,
118
this may be done either by adding it to these files or by placing additional
119
files in openmath/private directory and load them similarly to private.g and
120
private.gi. We will welcome user's contributions in the form of the code to
121
support existing content dictionaries from the OpenMath web site or private
122
content dictionaries, if they may be interesting for a wider community.
123
124
125