This file is indexed.

/usr/share/gap/pkg/openmath/gap/omput.gd is in gap-openmath 11.3.1+ds-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
###########################################################################
##
#W  omput.gd                OpenMath Package                 Andrew Solomon
#W                                                         Marco Costantini
#W                                                      Alexander Konovalov
##
#Y    Copyright (C) 1999, 2000, 2001, 2006
#Y    School Math and Comp. Sci., University of St.  Andrews, Scotland
#Y    Copyright (C) 2004, 2005, 2006 Marco Costantini
##
##  Writes a GAP object to an output stream, as an OpenMath object
## 


###########################################################################

DeclareGlobalVariable("OpenMathRealRandomSource");

###########################################################################
##
##  Declarations for OpenMathWriter
##
##  <#GAPDoc Label="IsOpenMathWriter">
##  <ManSection>
##      <Filt Name="IsOpenMathWriter" Type="Category" />
##      <Filt Name="IsOpenMathXMLWriter" Type="Category" />
##      <Filt Name="IsOpenMathBinaryWriter" Type="Category" />
##  <Description>
##  <Ref Filt="IsOpenMathWriter"/>is a category for &OpenMath; writers. 
##  It has two subcategories: <Ref Filt="IsOpenMathXMLWriter"/> and  
##  <Ref Filt="IsOpenMathBinaryWriter"/>.
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
DeclareCategory( "IsOpenMathWriter", IsObject );
DeclareCategory( "IsOpenMathXMLWriter", IsOpenMathWriter );
DeclareCategory( "IsOpenMathBinaryWriter", IsOpenMathWriter );
OpenMathWritersFamily := NewFamily( "OpenMathWritersFamily" );


###########################################################################
##
##  <#GAPDoc Label="OpenMathBinaryWriter">
##  <ManSection>
##      <Func Name="OpenMathBinaryWriter" Arg="s" />
##  <Description>
##  for a stream <A>s</A>, returns an object in the category 
##  <Ref Filt="OpenMathBinaryWriter"/>.
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
DeclareGlobalFunction ( "OpenMathBinaryWriter" );


###########################################################################
##
##  <#GAPDoc Label="OpenMathXMLWriter">
##  <ManSection>
##      <Func Name="OpenMathXMLWriter" Arg="s" />
##  <Description>
##  for a stream <A>s</A>, returns an object in the category 
##  <Ref Filt="IsOpenMathXMLWriter"/>. 
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
DeclareGlobalFunction ( "OpenMathXMLWriter" );

DeclareRepresentation( "IsOpenMathWriterRep", IsPositionalObjectRep, [ ] );
OpenMathBinaryWriterType := NewType( OpenMathWritersFamily, 
                              IsOpenMathWriterRep and IsOpenMathBinaryWriter );
OpenMathXMLWriterType    := NewType( OpenMathWritersFamily, 
                              IsOpenMathWriterRep and IsOpenMathXMLWriter );                                
                            
                               
###########################################################################
##
#F  OMPutObject( <stream>, <obj> )  
#F  OMPutObjectNoOMOBJtags( <stream>, <obj> )  
## 
##  <#GAPDoc Label="OMPutObject">
##  
##  <ManSection>
##      <Func Name="OMPutObject" Arg="stream obj" />
##      <Func Name="OMPutObjectNoOMOBJtags" Arg="stream obj" />
##  <Description>
##  <Ref Func="OMPutObject" /> writes (appends) the XML &OpenMath; 
##  encoding of the &GAP; object <A>obj</A> to output stream <A>stream</A> 
##  (see <Ref BookName="ref" Oper="InputTextFile" />, 
##  <Ref BookName="ref" Oper="OutputTextUser" />, 
##  <Ref BookName="ref" Oper="OutputTextString" />, 
##  <Ref BookName="scscp" Oper="InputOutputTCPStream" Label="for client" />,
##  <Ref BookName="scscp" Oper="InputOutputTCPStream" Label="for server" />).
##  <P/>
##  The second version does the same but without &lt;OMOBJ> 
##  tags, what may be useful for assembling complex &OpenMath; objects.
##  <Example>
##  <![CDATA[
##  gap> g := [[1,2],[1,0]];;
##  gap> t := "";
##  ""
##  gap> s := OutputTextString(t, true);;
##  gap> w:=OpenMathXMLWriter( s );
##  <OpenMath XML writer to OutputTextString(0)>
##  gap> OMPutObject(w, g);
##  gap> CloseStream(s);
##  gap> Print(t);
##  <OMOBJ>
##  	<OMA>
##  		<OMS cd="linalg2" name="matrix"/>
##  		<OMA>
##  			<OMS cd="linalg2" name="matrixrow"/>
##  			<OMI>1</OMI>
##  			<OMI>2</OMI>
##  		</OMA>
##  		<OMA>
##  			<OMS cd="linalg2" name="matrixrow"/>
##  			<OMI>1</OMI>
##  			<OMI>0</OMI>
##  		</OMA>
##  	</OMA>
##  </OMOBJ>
##  ]]>
##  </Example>
##  
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
## 
DeclareGlobalFunction("OMPutObject");
DeclareGlobalFunction("OMPutObjectNoOMOBJtags");

DeclareOperation("OMPutOMOBJ",    [ IsOpenMathWriter ] );
DeclareOperation("OMPutEndOMOBJ", [ IsOpenMathWriter ] );


###########################################################################
##
#O  OMPut(<stream>,<obj> ) 
## 
##
DeclareOperation("OMPut", [IsOpenMathWriter, IsObject ]);


###########################################################################
##
#F  OMPrint( <obj> ) .................   Print <obj> as OpenMath object 
##
##  <#GAPDoc Label="OMPrint">
##  <ManSection>
##      <Func Name="OMPrint" Arg="obj" />
##  <Description>
##  OMPrint writes the default XML &OpenMath; encoding of &GAP; 
##  object <A>obj</A> to the standard output.
##  <P/>
##  One can try it with different &GAP; objects to see if they
##  can be converted to &OpenMath; and learn how their &OpenMath;
##  representation looks like. Here we show the encoding for lists 
##  of integers and rationals:
##  <Example>
##  <![CDATA[
##  gap> OMPrint( [ 1, 1/2 ] );     
##  <OMOBJ>
##  	<OMA>
##  		<OMS cd="list1" name="list"/>
##  		<OMI>1</OMI>
##  		<OMA>
##  			<OMS cd="nums1" name="rational"/>
##  			<OMI>1</OMI>
##  			<OMI>2</OMI>
##  		</OMA>
##  	</OMA>
##  </OMOBJ>
##  ]]>
##  </Example>
##  Strings are encoded using <C>&lt;OMSTR></C> tags:
##  <Example>
##  <![CDATA[
##  gap> OMPrint( "This is a string" );
##  <OMOBJ>
##  	<OMSTR>This is a string</OMSTR>
##  </OMOBJ>
##  ]]>
##  </Example>
##  Cyclotomics may be encoded in different ways dependently on their properties:
##  <Example>
##  <![CDATA[
##  gap> OMPrint( 1-2*E(4) );      
##  <OMOBJ>
##  	<OMA>
##  		<OMS cd="complex1" name="complex_cartesian"/>
##  		<OMI>1</OMI>
##  		<OMI>-2</OMI>
##  	</OMA>
##  </OMOBJ>
##  gap> OMPrint(E(3));       
##  <OMOBJ>
##  	<OMA>
##  		<OMS cd="arith1" name="plus"/>
##  		<OMA>
##  			<OMS cd="arith1" name="times"/>
##  			<OMI>1</OMI>
##  			<OMA>
##  				<OMS cd="algnums" name="NthRootOfUnity"/>
##  				<OMI>3</OMI>
##  				<OMI>1</OMI>
##  			</OMA>
##  		</OMA>
##  	</OMA>
##  </OMOBJ>
##  ]]>
##  </Example>
##  Various encodings may be used for various types of groups:
##  <Example>
##  <![CDATA[
##  gap> OMPrint( Group( (1,2) ) );
##  <OMOBJ>
##  	<OMA>
##  		<OMS cd="permgp1" name="group"/>
##  		<OMS cd="permutation1" name="right_compose"/>
##  		<OMA>
##  			<OMS cd="permut1" name="permutation"/>
##  			<OMI>2</OMI>
##  			<OMI>1</OMI>
##  		</OMA>
##  	</OMA>
##  </OMOBJ>
##  gap> OMPrint( Group( [ [ [ 1, 2 ],[ 0, 1 ] ] ] ) );
##  <OMOBJ>
##  	<OMA>
##  		<OMS cd="group1" name="group_by_generators"/>
##  		<OMA>
##  			<OMS cd="linalg2" name="matrix"/>
##  			<OMA>
##  				<OMS cd="linalg2" name="matrixrow"/>
##  				<OMI>1</OMI>
##  				<OMI>2</OMI>
##  			</OMA>
##  			<OMA>
##  				<OMS cd="linalg2" name="matrixrow"/>
##  				<OMI>0</OMI>
##  				<OMI>1</OMI>
##  			</OMA>
##  		</OMA>
##  	</OMA>
##  </OMOBJ>
##  gap> OMPrint( FreeGroup( 2 ) );                      
##  <OMOBJ>
##  	<OMA>
##  		<OMS cd="fpgroup1" name="free_groupn"/>
##  		<OMI>2</OMI>
##  	</OMA>
##  </OMOBJ>
##  ]]>
##  </Example>
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
##
DeclareGlobalFunction("OMPrint");


###########################################################################
## 
##  OMString( <obj> ) ........ returns string with <obj> as OpenMath object
##
##  <#GAPDoc Label="OMString">
##  <ManSection>
##      <Func Name="OMString" Arg="obj" />
##  <Description>
##  OMString returns a string with the default XML &OpenMath; 
##  encoding of &GAP; object <A>obj</A>.
##  If used with the <K>noomobj</K> option, then initial and 
##  final &lt;OMOBJ> tags will be omitted.
##  <Example>
##  <![CDATA[
##  gap> OMString(42);
##  "<OMOBJ> <OMI>42</OMI> </OMOBJ>"
##  gap> OMString([1,2]:noomobj);    
##  "<OMA> <OMS cd=\"list1\" name=\"list\"/> <OMI>1</OMI> <OMI>2</OMI> </OMA>"
##  ]]>
##  </Example>
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
##
DeclareGlobalFunction("OMString");


###########################################################################
##
#F  OMWriteLine( <stream>, <list> )
##
##  Auxiliary function for OMPut functions.
##  Takes a list of string arguments and outputs them
##  to a single line with the correct indentation.
##
##  Input : List of arguments to print
##  Output: \t ^ OMIndent, arguments
##
DeclareGlobalFunction("OMWriteLine");


###########################################################################
##
#F  OMPutSymbol( <stream>, <cd>, <name> )
##
##  Input : cd, name as strings
##  Output: <OMS cd="<cd>" name="<name>" />
##
DeclareOperation("OMPutSymbol", [ IsOpenMathWriter, IsString, IsString ] );


###########################################################################
##
#F  OMPutForeign( <stream>, <encoding>, <string> )
##
##  Input : encoding and string representing the foreighn object
##
DeclareOperation("OMPutForeign", [ IsOpenMathWriter, IsString, IsString ] );


###########################################################################
##
#F  OMPutVar( <stream>, <name> )
##
##  Input : name as string
##  Output: <OMV name="<name>" />
##
DeclareOperation("OMPutVar", [ IsOpenMathWriter, IsObject ] );


###########################################################################
##
#M  OMPutApplication( <stream>, <cd>, <name>, <list> )
##
##  Input : cd, name as strings, list as a list
##  Output:
##        <OMA>
##                <OMS cd=<cd> name=<name>/>
##                OMPut(<list>[1])
##                OMPut(<list>[2])
##                ...
##        </OMA>
##
DeclareGlobalFunction("OMPutApplication");
DeclareOperation("OMPutOMA",    [ IsOpenMathWriter ] );
DeclareOperation("OMPutOMAWithId", [ IsOpenMathWriter , IsString ] );
DeclareOperation("OMPutEndOMA", [ IsOpenMathWriter ] );


###########################################################################
##
## Tags for attributions and attribution pairs
##
DeclareOperation("OMPutOMATTR",    [ IsOpenMathWriter ] );
DeclareOperation("OMPutEndOMATTR",    [ IsOpenMathWriter ] );
DeclareOperation("OMPutOMATP", [ IsOpenMathWriter ] );
DeclareOperation("OMPutEndOMATP", [ IsOpenMathWriter ] );

###########################################################################
##
#M  OMPutBinding( <stream>, <cd>, <name>, <listbvars>, <object> )
##
##  Input : cd, name, list of bvars, object
##  Output:
##        <OMBIND>
##                <OMS cd=<cd> name=<name>/>
##                OMPut(<list>[1])
##                OMPut(<object)
##                ...
##        </OMBIND>
##
#DeclareGlobalFunction("OMPutBinding");
DeclareOperation("OMPutOMBIND",    [ IsOpenMathWriter ] );
DeclareOperation("OMPutOMBINDWithId", [ IsOpenMathWriter , IsString ] );
DeclareOperation("OMPutEndOMBIND", [ IsOpenMathWriter ] );


###########################################################################
##
## Tags for binding vars
##
DeclareOperation("OMPutOMBVAR",    [ IsOpenMathWriter ] );
DeclareOperation("OMPutEndOMBVAR",    [ IsOpenMathWriter ] );


###########################################################################
##
#M  OMPutError( <stream>, <cd>, <name>, <list> )
##
##  Input : cd, name as strings, list as a list
##  Output:
##        <OME>
##                <OMS cd=<cd> name=<name>/>
##                OMPut(<list>[1])
##                OMPut(<list>[2])
##                ...
##        </OME>
##
DeclareGlobalFunction("OMPutError");
DeclareOperation("OMPutOME",    [ IsOpenMathWriter ] );
DeclareOperation("OMPutEndOME", [ IsOpenMathWriter ] );

DeclareAttribute( "OMReference", IsObject );

DeclareOperation( "OMPutReference", [ IsOpenMathWriter, IsObject ] );


###########################################################################
##
#O  OMPutByteArray( <stream>, <bitlist> ) 
## 
##  Put bitlists into byte arrays
##
DeclareGlobalFunction("OMPutByteArray");


###########################################################################
##
#O  OMPutList(<stream>,<obj> ) 
## 
##  Tries to render this as an OpenMath list
##
DeclareOperation("OMPutList", [ IsOpenMathWriter, IsObject ]);


# Determines the indentation of the next line to be printed.
OMIndent := 0;


###########################################################################
#
# Declarations for OMPlainString objects
#
##  <#GAPDoc Label="OMPlainString">
##  <ManSection>
##      <Func Name="OMPlainString" Arg="string" />
##  <Description>
##  <Ref Func="OMPlainString" /> wraps the string into a &GAP; object of a
##  special kind called an &OpenMath; plain string. Internally such object is
##  represented as a string, but <Ref Func="OMPutObject" /> threat it in a
##  different way: instead of converting it into a &lt;OMSTR> object, an
##  &OpenMath; plain string will be plainly substituted into the output (this
##  explains its name) without decorating it with &lt;OMSTR> tags. 
##  <P/>
##  It is assumed that &OpenMath; plain string contains valid &OpenMath; code;
##  no actual validation is performed during its creation. Such functionality
##  may be useful to compose some &OpenMath; code at the &GAP; level to
##  communicate it to the other system, in particular, to send there symbols
##  which are not supported by &GAP;, for example:
##  <Example>
##  <![CDATA[
##  gap> s:=OMPlainString("<OMS cd=\"nums1\" name=\"pi\"/>");
##  <OMS cd="nums1" name="pi"/>
##  gap> OMPrint(s);                                       
##  <OMOBJ>
##  	<OMS cd="nums1" name="pi"/>
##  </OMOBJ>
##  ]]>
##  </Example>
##  
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
##
DeclareCategory( "IsOMPlainString", IsObject );
OMPlainStringsFamily := NewFamily( "OMPlainStringsFamily" );
DeclareGlobalFunction ( "OMPlainString" );
DeclareRepresentation( "IsOMPlainStringRep", IsPositionalObjectRep, [ ] );
OMPlainStringDefaultType := NewType( OMPlainStringsFamily, 
                                IsOMPlainStringRep and IsOMPlainString );                                

###########################################################################
#E