File: semiring.gd

package info (click to toggle)
gap 4r4p10-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 29,224 kB
  • ctags: 7,084
  • sloc: ansic: 98,591; sh: 3,284; perl: 2,263; makefile: 467; awk: 6
file content (357 lines) | stat: -rw-r--r-- 11,541 bytes parent folder | download | duplicates (4)
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
#############################################################################
##
#W  semiring.gd                 GAP library                     Thomas Breuer
##
#H  @(#)$Id: semiring.gd,v 4.5 2002/04/15 10:05:22 sal Exp $
##
#Y  Copyright (C)  1999,  Lehrstuhl D fuer Mathematik,  RWTH Aachen,  Germany
#Y  (C) 1999 School Math and Comp. Sci., University of St.  Andrews, Scotland
#Y  Copyright (C) 2002 The GAP Group
##
##  This file declares the operations for semirings.
##
Revision.semiring_gd :=
    "@(#)$Id: semiring.gd,v 4.5 2002/04/15 10:05:22 sal Exp $";


#############################################################################
##
#P  IsLDistributive( <C> )
##
##  is `true' if the relation $a * ( b + c ) = ( a * b ) + ( a * c )$
##  holds for all elements $a$, $b$, $c$ in the collection <C>,
##  and `false' otherwise.
##
DeclareProperty( "IsLDistributive", IsRingElementCollection );

InstallSubsetMaintenance( IsLDistributive,
    IsRingElementCollection and IsLDistributive,
    IsRingElementCollection );

InstallFactorMaintenance( IsLDistributive,
    IsRingElementCollection and IsLDistributive,
    IsObject,
    IsRingElementCollection );


#############################################################################
##
#P  IsRDistributive( <C> )
##
##  is `true' if the relation $( a + b ) * c = ( a * c ) + ( b * c )$
##  holds for all elements $a$, $b$, $c$ in the collection <C>,
##  and `false' otherwise.
##
DeclareProperty( "IsRDistributive", IsRingElementCollection );

InstallSubsetMaintenance( IsRDistributive,
    IsRingElementCollection and IsRDistributive,
    IsRingElementCollection );

InstallFactorMaintenance( IsRDistributive,
    IsRingElementCollection and IsRDistributive,
    IsObject,
    IsRingElementCollection );


#############################################################################
##
#P  IsDistributive( <C> )
##
##  is `true' if the collection <C> is both left and right distributive,
##  and `false' otherwise.
##
DeclareSynonymAttr( "IsDistributive", IsLDistributive and IsRDistributive );


#############################################################################
##
#P  IsSemiring( <S> )
##
##  A *semiring* in {\GAP} is an additive magma (see~"IsAdditiveMagma")
##  that is also a magma (see~"IsMagma"),
##  such that addition `+' and multiplication `\*' are distributive.
##
##  The multiplication need *not* be associative (see~"IsAssociative").
##  For example, a Lie algebra (see~"Lie Algebras") is regarded as a
##  semiring in {\GAP}.
##  A semiring need not have an identity and a zero element,
##  see~"IsSemiringWithOne" and "IsSemiringWithZero".
##
DeclareSynonymAttr( "IsSemiring",
    IsAdditiveMagma and IsMagma and IsDistributive );


#############################################################################
##
#P  IsSemiringWithOne( <S> )
##
##  A *semiring-with-one* in {\GAP} is a semiring (see~"IsSemiring")
##  that is also a magma-with-one (see~"IsMagmaWithOne").
##
##  Note that a semiring-with-one need not contain a zero element
##  (see~"IsSemiringWithZero").
##
DeclareSynonymAttr( "IsSemiringWithOne",
    IsAdditiveMagma and IsMagmaWithOne and IsDistributive );


#############################################################################
##
#P  IsSemiringWithZero( <S> )
##
##  A *semiring-with-zero* in {\GAP} is a semiring (see~"IsSemiring")
##  that is also an additive magma-with-zero (see~"IsAdditiveMagmaWithZero").
##
##  Note that a semiring-with-zero need not contain an identity element
##  (see~"IsSemiringWithOne").
##
DeclareSynonymAttr( "IsSemiringWithZero",
    IsAdditiveMagmaWithZero and IsMagma and IsDistributive );


#############################################################################
##
#P  IsSemiringWithOneAndZero( <S> )
##
DeclareSynonymAttr( "IsSemiringWithOneAndZero",
    IsAdditiveMagmaWithZero and IsMagmaWithOne and IsDistributive );


#############################################################################
##
#A  GeneratorsOfSemiring( <S> )
##
##  `GeneratorsOfSemiring' returns a list of elements such that
##  the semiring <S> is the closure of these elements
##  under addition and multiplication.
##
DeclareAttribute( "GeneratorsOfSemiring", IsSemiring );


#############################################################################
##
#A  GeneratorsOfSemiringWithOne( <S> )
##
##  `GeneratorsOfSemiringWithOne' returns a list of elements such that
##  the semiring <R> is the closure of these elements
##  under addition, multiplication, and taking the identity element
##  `One( <S> )'.
##
##  <S> itself need *not* be known to be a semiring-with-one.
##
DeclareAttribute( "GeneratorsOfSemiringWithOne", IsSemiringWithOne );


#############################################################################
##
#A  GeneratorsOfSemiringWithZero( <S> )
##
##  `GeneratorsOfSemiringWithZero' returns a list of elements such that
##  the semiring <S> is the closure of these elements
##  under addition, multiplication, and taking the zero element
##  `Zero( <S> )'.
##
##  <S> itself need *not* be known to be a semiring-with-zero.
##
DeclareAttribute( "GeneratorsOfSemiringWithZero", IsSemiringWithZero );


#############################################################################
##
#A  GeneratorsOfSemiringWithOneAndZero( <S> )
##
DeclareAttribute( "GeneratorsOfSemiringWithOneAndZero",
    IsSemiringWithOneAndZero );


#############################################################################
##
#A  AsSemiring( <C> )
##
##  If the elements in the collection <C> form a semiring
##  then `AsSemiring' returns this semiring,
##  otherwise `fail' is returned.
##
DeclareAttribute( "AsSemiring", IsRingElementCollection );


#############################################################################
##
#A  AsSemiringWithOne( <C> )
##
##  If the elements in the collection <C> form a semiring-with-one
##  then `AsSemiringWithOne' returns this semiring-with-one,
##  otherwise `fail' is returned.
##
DeclareAttribute( "AsSemiringWithOne", IsRingElementCollection );


#############################################################################
##
#A  AsSemiringWithZero( <C> )
##
##  If the elements in the collection <C> form a semiring-with-zero
##  then `AsSemiringWithZero' returns this semiring-with-zero,
##  otherwise `fail' is returned.
##
DeclareAttribute( "AsSemiringWithZero", IsRingElementCollection );


#############################################################################
##
#A  AsSemiringWithOneAndZero( <C> )
##
##  If the elements in the collection <C> form a semiring-with-one-and-zero
##  then `AsSemiringWithOneAndZero' returns this semiring-with-one-and-zero,
##  otherwise `fail' is returned.
##
DeclareAttribute( "AsSemiringWithOneAndZero", IsRingElementCollection );


#############################################################################
##
#O  ClosureSemiring( <S>, <s> )
#O  ClosureSemiring( <S>, <T> )
##
##  For a semiring <S> and either an element <s> of its elements family
##  or a semiring <T>,
##  `ClosureSemiring' returns the semiring generated by both arguments.
##
DeclareOperation( "ClosureSemiring", [ IsSemiring, IsObject ] );


#############################################################################
##
#O  SemiringByGenerators( <C> ) . . .  semiring gener. by elements in a coll.
##
##  `SemiringByGenerators' returns the semiring generated by the elements
##  in the collection <C>,
##  i.~e., the closure of <C> under addition and multiplication.
##
DeclareOperation( "SemiringByGenerators", [ IsCollection ] );


#############################################################################
##
#O  SemiringWithOneByGenerators( <C> )
##
##  `SemiringWithOneByGenerators' returns the semiring-with-one generated by
##  the elements in the collection <C>, i.~e., the closure of <C> under
##  addition, multiplication, and taking the identity of an element.
##
DeclareOperation( "SemiringWithOneByGenerators", [ IsCollection ] );


#############################################################################
##
#O  SemiringWithZeroByGenerators( <C> )
##
DeclareOperation( "SemiringWithZeroByGenerators", [ IsCollection ] );


#############################################################################
##
#O  SemiringWithOneAndZeroByGenerators( <C> )
##
DeclareOperation( "SemiringWithOneAndZeroByGenerators", [ IsCollection ] );


#############################################################################
##
#F  Semiring( <r> ,<s>, ... )  . . . . . . semiring generated by a collection
#F  Semiring( <C> )  . . . . . . . . . . . semiring generated by a collection
##
##  In the first form `Semiring' returns the smallest semiring that
##  contains all the elements <r>, <s>... etc.
##  In the second form `Semiring' returns the smallest semiring that
##  contains all the elements in the collection <C>.
##  If any element is not an element of a semiring or if the elements lie in
##  no common semiring an error is raised.
##
DeclareGlobalFunction( "Semiring" );


#############################################################################
##
#F  SemiringWithOne( <r>, <s>, ... )
#F  SemiringWithOne( <C> )
##
##  In the first form `SemiringWithOne' returns the smallest
##  semiring-with-one that contains all the elements <r>, <s>... etc.
##  In the second form `SemiringWithOne' returns the smallest
##  semiring-with-one that contains all the elements in the collection <C>.
##  If any element is not an element of a semiring or if the elements lie in
##  no common semiring an error is raised.
##
DeclareGlobalFunction( "SemiringWithOne" );


#############################################################################
##
#F  SemiringWithZero( <r>, <s>, ... )
#F  SemiringWithZero( <C> )
##
DeclareGlobalFunction( "SemiringWithZero" );


#############################################################################
##
#F  SemiringWithOneAndZero( <r>, <s>, ... )
#F  SemiringWithOneAndZero( <C> )
##
DeclareGlobalFunction( "SemiringWithOneAndZero" );


#############################################################################
##
#F  Subsemiring( <S>, <gens> )
#F  SubsemiringNC( <S>, <gens> )
##
DeclareGlobalFunction( "Subsemiring" );
DeclareGlobalFunction( "SubsemiringNC" );


#############################################################################
##
#F  SubsemiringWithOne( <S>, <gens> )
#F  SubsemiringWithOneNC( <S>, <gens> )
##
DeclareGlobalFunction( "SubsemiringWithOne" );
DeclareGlobalFunction( "SubsemiringWithOneNC" );


#############################################################################
##
#F  SubsemiringWithZero( <S>, <gens> )
#F  SubsemiringWithZeroNC( <S>, <gens> )
##
DeclareGlobalFunction( "SubsemiringWithZero" );
DeclareGlobalFunction( "SubsemiringWithZeroNC" );


#############################################################################
##
#F  SubsemiringWithOneAndZero( <S>, <gens> )
#F  SubsemiringWithOneAndZeroNC( <S>, <gens> )
##
DeclareGlobalFunction( "SubsemiringWithOneAndZero" );
DeclareGlobalFunction( "SubsemiringWithOneAndZeroNC" );


#############################################################################
##
#A  CentralIdempotentsOfSemiring( <S> )
##
##  For a semiring <S>, this function returns
##  a list of central primitive idempotents such that their sum is
##  the identity element of <S>.
##  Therefore <S> is required to have an identity.
##
DeclareAttribute( "CentralIdempotentsOfSemiring", IsSemiring );


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