Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
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
Project: cocalc-sagemath-dev-slelievre
Views: 418346<Chapter Label="ExtendingOpenMath">1<Heading>Extending the &OpenMath; package</Heading>23<Section Label="Available">4<Heading>Exploring the range of supported symbols</Heading>5<Index Key="OMsymRecord"><C>OMsymRecord</C></Index>67The &OpenMath; package supports such basic &OpenMath; objects8as integers ( <OMI> ), character strings ( <OMSTR> ) and9variables ( <OMVAR> ). Besides that, it supports a number10of &OpenMath; content dictionaries (some of them only partially,11dependently on their relevance to &GAP;).1213To see which symbols from which content dictionaries are supported14for the conversion from &OpenMath; to &GAP;, explore the global record15<C>OMsymRecord</C>. Its components have names of appropriate CDs,16and subcomponents of each component have names of symbols from the17corresponding CD. If the value of the component is not equal to18<K>fail</K>, then it contains the function or the object which is used19for conversion. The following example of the entry for the <C>nums1</C> CD20demonstrates a combination of all possible cases:2122<Example>23<![CDATA[24gap> Display( OMsymRecord.nums1 );25rec(26NaN := nan,27based_integer := fail,28e := 2.718281828459045,29gamma := fail,30i := E(4),31infinity := infinity,32pi := 3.141592653589793,33rational := function ( x )34return OMgapId( [ OMgap2ARGS( x ), x[1] / x[2] ] )[2];35end )36]]>37</Example>3839<C>OMsymRecord</C> contains all symbols for which conversion from40&OpenMath; to &GAP; is supported except some special symbols related41with errors and special procedures from the &SCSCP; package which42are treated separately.43<P/>4445To check quickly if &GAP; can parse a given &OpenMath; object,46copy the &OpenMath; code and paste it directly into standard input47after the following command:4849<Log>50<![CDATA[51gap> s:= InputTextUser();; g := OMGetObject(s); CloseStream(s);52]]>53</Log>5455The main tool for the conversion from &GAP; to &OpenMath; is56<C>OMPut( <writer>, <object> )</C>. A number of methods for57<C>OMPut</C> are installed in the file <File>openmath/gap/omput.gi</File>.58<P/>5960To check quickly whether the object may be converted to &OpenMath;,61call <C>OMprint</C> for that object, for example:6263<Example>64<![CDATA[65gap> OMPrint( [ [1..10], ZmodnZObj(2,6), (1,2) ] );66<OMOBJ xmlns="http://www.openmath.org/OpenMath" version="2.0">67<OMA>68<OMS cd="list1" name="list"/>69<OMA>70<OMS cd="interval1" name="integer_interval"/>71<OMI>1</OMI>72<OMI>10</OMI>73</OMA>74<OMA>75<OMS cd="integer2" name="class"/>76<OMI>2</OMI>77<OMI>6</OMI>78</OMA>79<OMA>80<OMS cd="permut1" name="permutation"/>81<OMI>2</OMI>82<OMI>1</OMI>83</OMA>84</OMA>85</OMOBJ>86]]>87</Example>8889The package is in the continuous development and will support even more symbols in the future.90In the meantime, if you will have any requests for the support for particular symbols, please91contact Alexander Konovalov.9293</Section>9495<Section Label="Private">96<Heading>Adding support for private content dictionaries and symbols</Heading>9798There is also a way for the user to extend the package adding support for private99and experimental CDs or separate symbols. We allocated the directory <File>openmath/private</File>100for this purposes, and currently it contain the file <File>private.g</File> for conversions101from &OpenMath; to &GAP; and the file <File>private.gi</File> for conversions from &GAP;102to &OpenMath; for some symbols from private CDs contained in the <File>openmath/cds</File> directory.103<P/>104105In particular, we extended the package with the following private &OpenMath; symbols:106<List>107<Item>108<C>group1.group_by_generators</C> which allows us to input and output groups given by109their generators as this is a natural way to create groups in &GAP;;110</Item>111<Item>112<C>semigroup1.semigroup_by_generators</C> and <C>monoid1.monoid_by_generators</C>113following the same considerations for semigroups and monoids;114</Item>115<Item>116<C>pcgroup1.pcgroup_by_pcgscode</C> for PcGroups given by their pcgs code and order;117</Item>118<Item>119<C>record1.record</C> for records as they are important data structures which we want120to pass in a straightforward manner between different &GAP; instances;121</Item>122<Item>123<C>transform1.transformation</C> to support transformations, transformation semigroups124and their automorphism groups.125</Item>126</List>127128The file <File>private.g</File> is loaded from <File>openmath/gap/new.g</File>,129and the <File>private.gi</File> is loaded from <File>openmath/gap/read.g</File>.130If the user would like to add own code, this may be done either by adding it131to these files or by placing additional files in <File>openmath/private</File>132directory and load them similarly to <File>private.g</File> and <File>private.gi</File>.133134We will welcome user's contributions in the form of the code to support existing content135dictionaries from the &OpenMath; web site or private content dictionaries, if they may136be interesting for a wider community.137138</Section>139140</Chapter>141142