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
<Chapter Label="ExtendingOpenMath">
2
<Heading>Extending the &OpenMath; package</Heading>
3
4
<Section Label="Available">
5
<Heading>Exploring the range of supported symbols</Heading>
6
<Index Key="OMsymRecord"><C>OMsymRecord</C></Index>
7
8
The &OpenMath; package supports such basic &OpenMath; objects
9
as integers ( &lt;OMI> ), character strings ( &lt;OMSTR> ) and
10
variables ( &lt;OMVAR> ). Besides that, it supports a number
11
of &OpenMath; content dictionaries (some of them only partially,
12
dependently on their relevance to &GAP;).
13
14
To see which symbols from which content dictionaries are supported
15
for the conversion from &OpenMath; to &GAP;, explore the global record
16
<C>OMsymRecord</C>. Its components have names of appropriate CDs,
17
and subcomponents of each component have names of symbols from the
18
corresponding CD. If the value of the component is not equal to
19
<K>fail</K>, then it contains the function or the object which is used
20
for conversion. The following example of the entry for the <C>nums1</C> CD
21
demonstrates a combination of all possible cases:
22
23
<Example>
24
<![CDATA[
25
gap> Display( OMsymRecord.nums1 );
26
rec(
27
NaN := nan,
28
based_integer := fail,
29
e := 2.718281828459045,
30
gamma := fail,
31
i := E(4),
32
infinity := infinity,
33
pi := 3.141592653589793,
34
rational := function ( x )
35
return OMgapId( [ OMgap2ARGS( x ), x[1] / x[2] ] )[2];
36
end )
37
]]>
38
</Example>
39
40
<C>OMsymRecord</C> contains all symbols for which conversion from
41
&OpenMath; to &GAP; is supported except some special symbols related
42
with errors and special procedures from the &SCSCP; package which
43
are treated separately.
44
<P/>
45
46
To check quickly if &GAP; can parse a given &OpenMath; object,
47
copy the &OpenMath; code and paste it directly into standard input
48
after the following command:
49
50
<Log>
51
<![CDATA[
52
gap> s:= InputTextUser();; g := OMGetObject(s); CloseStream(s);
53
]]>
54
</Log>
55
56
The main tool for the conversion from &GAP; to &OpenMath; is
57
<C>OMPut( &lt;writer>, &lt;object> )</C>. A number of methods for
58
<C>OMPut</C> are installed in the file <File>openmath/gap/omput.gi</File>.
59
<P/>
60
61
To check quickly whether the object may be converted to &OpenMath;,
62
call <C>OMprint</C> for that object, for example:
63
64
<Example>
65
<![CDATA[
66
gap> OMPrint( [ [1..10], ZmodnZObj(2,6), (1,2) ] );
67
<OMOBJ xmlns="http://www.openmath.org/OpenMath" version="2.0">
68
<OMA>
69
<OMS cd="list1" name="list"/>
70
<OMA>
71
<OMS cd="interval1" name="integer_interval"/>
72
<OMI>1</OMI>
73
<OMI>10</OMI>
74
</OMA>
75
<OMA>
76
<OMS cd="integer2" name="class"/>
77
<OMI>2</OMI>
78
<OMI>6</OMI>
79
</OMA>
80
<OMA>
81
<OMS cd="permut1" name="permutation"/>
82
<OMI>2</OMI>
83
<OMI>1</OMI>
84
</OMA>
85
</OMA>
86
</OMOBJ>
87
]]>
88
</Example>
89
90
The package is in the continuous development and will support even more symbols in the future.
91
In the meantime, if you will have any requests for the support for particular symbols, please
92
contact Alexander Konovalov.
93
94
</Section>
95
96
<Section Label="Private">
97
<Heading>Adding support for private content dictionaries and symbols</Heading>
98
99
There is also a way for the user to extend the package adding support for private
100
and experimental CDs or separate symbols. We allocated the directory <File>openmath/private</File>
101
for this purposes, and currently it contain the file <File>private.g</File> for conversions
102
from &OpenMath; to &GAP; and the file <File>private.gi</File> for conversions from &GAP;
103
to &OpenMath; for some symbols from private CDs contained in the <File>openmath/cds</File> directory.
104
<P/>
105
106
In particular, we extended the package with the following private &OpenMath; symbols:
107
<List>
108
<Item>
109
<C>group1.group_by_generators</C> which allows us to input and output groups given by
110
their generators as this is a natural way to create groups in &GAP;;
111
</Item>
112
<Item>
113
<C>semigroup1.semigroup_by_generators</C> and <C>monoid1.monoid_by_generators</C>
114
following the same considerations for semigroups and monoids;
115
</Item>
116
<Item>
117
<C>pcgroup1.pcgroup_by_pcgscode</C> for PcGroups given by their pcgs code and order;
118
</Item>
119
<Item>
120
<C>record1.record</C> for records as they are important data structures which we want
121
to pass in a straightforward manner between different &GAP; instances;
122
</Item>
123
<Item>
124
<C>transform1.transformation</C> to support transformations, transformation semigroups
125
and their automorphism groups.
126
</Item>
127
</List>
128
129
The file <File>private.g</File> is loaded from <File>openmath/gap/new.g</File>,
130
and the <File>private.gi</File> is loaded from <File>openmath/gap/read.g</File>.
131
If the user would like to add own code, this may be done either by adding it
132
to these files or by placing additional files in <File>openmath/private</File>
133
directory and load them similarly to <File>private.g</File> and <File>private.gi</File>.
134
135
We will welcome user's contributions in the form of the code to support existing content
136
dictionaries from the &OpenMath; web site or private content dictionaries, if they may
137
be interesting for a wider community.
138
139
</Section>
140
141
</Chapter>
142