File: monoid.gd

package info (click to toggle)
gap 4.15.1-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 110,212 kB
  • sloc: ansic: 97,261; xml: 48,343; cpp: 13,946; sh: 4,900; perl: 1,650; javascript: 255; makefile: 252; ruby: 9
file content (341 lines) | stat: -rw-r--r-- 12,104 bytes parent folder | download | duplicates (2)
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
#############################################################################
##
##  This file is part of GAP, a system for computational discrete algebra.
##  This file's authors include Thomas Breuer.
##
##  Copyright of GAP belongs to its developers, whose names are too numerous
##  to list here. Please refer to the COPYRIGHT file for details.
##
##  SPDX-License-Identifier: GPL-2.0-or-later
##
##  This file contains the declaration of operations for monoids.
##


#############################################################################
##
#P  IsMonoid( <D> )
##
##  <#GAPDoc Label="IsMonoid">
##  <ManSection>
##  <Filt Name="IsMonoid" Arg='D' Type='Synonym'/>
##
##  <Description>
##  A <E>monoid</E> is a magma-with-one (see&nbsp;<Ref Chap="Magmas"/>)
##  with associative multiplication.
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
##
DeclareSynonymAttr( "IsMonoid", IsMagmaWithOne and IsAssociative );


#############################################################################
##
#F  Monoid( <gen1>, <gen2> ... )
#F  Monoid( <gens> )
#F  Monoid( <gens>, <id> )
##
##  <#GAPDoc Label="Monoid">
##  <ManSection>
##  <Heading>Monoid</Heading>
##  <Func Name="Monoid" Arg='gen1, gen2 ...'
##   Label="for various generators"/>
##  <Func Name="Monoid" Arg='gens[, id]' Label="for a list"/>
##
##  <Description>
##  In the first form, <Ref Func="Monoid" Label="for various generators"/>
##  returns the monoid generated by the arguments <A>gen1</A>, <A>gen2</A>,
##  <M>\ldots</M>,
##  that is, the closure of these elements under multiplication and taking
##  the 0-th power.
##  In the second form, <Ref Func="Monoid" Label="for a list"/> returns
##  the monoid generated by the elements in the homogeneous list <A>gens</A>;
##  a square matrix as only argument is treated as one generator,
##  not as a list of generators.
##  In the second form, the identity element <A>id</A> may be given as the
##  second argument.
##  <P/>
##  It is <E>not</E> checked whether the underlying multiplication is
##  associative, use <Ref Func="MagmaWithOne"/> and
##  <Ref Prop="IsAssociative"/>
##  if you want to check whether a magma-with-one is in fact a monoid.
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
##
DeclareGlobalFunction( "Monoid" );


#############################################################################
##
#F  Submonoid( <M>, <gens> ) . . . . . . submonoid of <M> generated by <gens>
#F  SubmonoidNC( <M>, <gens> )
##
##  <#GAPDoc Label="Submonoid">
##  <ManSection>
##  <Func Name="Submonoid" Arg='M, gens'/>
##  <Func Name="SubmonoidNC" Arg='M, gens'/>
##
##  <Description>
##  are just synonyms of <Ref Func="SubmagmaWithOne"/>
##  and <Ref Func="SubmagmaWithOneNC"/>, respectively.
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
##
DeclareSynonym( "Submonoid", SubmagmaWithOne );

DeclareSynonym( "SubmonoidNC", SubmagmaWithOneNC );


#############################################################################
##
#O  MonoidByGenerators( <gens>[, <one>] )  . . . . monoid generated by <gens>
##
##  <#GAPDoc Label="MonoidByGenerators">
##  <ManSection>
##  <Oper Name="MonoidByGenerators" Arg='gens[, one]'/>
##
##  <Description>
##  is the underlying operation of <Ref Func="Monoid" Label="for a list"/>.
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
##
DeclareOperation( "MonoidByGenerators", [ IsCollection ] );


#############################################################################
##
#A  AsMonoid( <C> ) . . . . . . . . . . . . collection <C> regarded as monoid
##
##  <#GAPDoc Label="AsMonoid">
##  <ManSection>
##  <Oper Name="AsMonoid" Arg='C'/>
##
##  <Description>
##  If <A>C</A> is a collection whose elements form a monoid,
##  then <Ref Oper="AsMonoid"/> returns this monoid.
##  Otherwise <K>fail</K> is returned.
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
##
DeclareOperation( "AsMonoid", [IsCollection] );


#############################################################################
##
#O  AsSubmonoid( <D>, <C> )
##
##  <#GAPDoc Label="AsSubmonoid">
##  <ManSection>
##  <Oper Name="AsSubmonoid" Arg='D, C'/>
##
##  <Description>
##  Let <A>D</A> be a domain and <A>C</A> a collection.
##  If <A>C</A> is a subset of <A>D</A> that forms a monoid then
##  <Ref Oper="AsSubmonoid"/>
##  returns this monoid, with parent <A>D</A>.
##  Otherwise <K>fail</K> is returned.
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
##
DeclareOperation( "AsSubmonoid", [ IsDomain, IsCollection ] );


#############################################################################
##
#A  GeneratorsOfMonoid( <M> )  . . . . . . .  monoid generators of monoid <M>
##
##  <#GAPDoc Label="GeneratorsOfMonoid">
##  <ManSection>
##  <Attr Name="GeneratorsOfMonoid" Arg='M'/>
##
##  <Description>
##  Monoid generators of a monoid <A>M</A> are the same as
##  magma-with-one generators
##  (see&nbsp;<Ref Attr="GeneratorsOfMagmaWithOne"/>).
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
##
DeclareSynonymAttr( "GeneratorsOfMonoid", GeneratorsOfMagmaWithOne );


#############################################################################
##
#A  TrivialSubmonoid( <M> ) . . . . . . . . . trivial submonoid of monoid <M>
##
##  <#GAPDoc Label="TrivialSubmonoid">
##  <ManSection>
##  <Attr Name="TrivialSubmonoid" Arg='M'/>
##
##  <Description>
##  is just a synonym for <Ref Attr="TrivialSubmagmaWithOne"/>.
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
##
DeclareSynonymAttr( "TrivialSubmonoid", TrivialSubmagmaWithOne );


#############################################################################
##
#F  FreeMonoid( [<wfilt>,]<rank>[, <name>] )
#F  FreeMonoid( [<wfilt>,][<name1>[, <name2>[, ...]]] )
#F  FreeMonoid( [<wfilt>,]<names> )
#F  FreeMonoid( [<wfilt>,]infinity[, <name>][, <init>] )
##
##  <#GAPDoc Label="FreeMonoid">
##  <ManSection>
##  <Heading>FreeMonoid</Heading>
##  <Func Name="FreeMonoid" Arg='[wfilt, ]rank[, name]'
##   Label="for given rank"/>
##  <Func Name="FreeMonoid" Arg='[wfilt, ][name1[, name2[, ...]]]'
##   Label="for various names"/>
##  <Func Name="FreeMonoid" Arg='[wfilt, ]names'
##   Label="for a list of names"/>
##  <Func Name="FreeMonoid" Arg='[wfilt, ]infinity[, name][, init]'
##   Label="for infinitely many generators"/>
##
##  <Description>
##  <C>FreeMonoid</C> returns a free monoid. The number of
##  generators, and the labels given to the generators, can be specified in
##  several different ways.
##  Warning: the labels of generators are only an aid for printing,
##  and do not necessarily distinguish generators;
##  see the examples at the end of
##  <Ref Func="FreeSemigroup" Label="for given rank"/>
##  for more information.
##  <List>
##    <Mark>
##      1: For a given rank, and an optional generator name prefix
##    </Mark>
##    <Item>
##      Called with a nonnegative integer <A>rank</A>,
##      <Ref Func="FreeMonoid" Label="for given rank"/> returns
##      a free monoid on <A>rank</A> generators.
##      The optional argument <A>name</A> must be a string;
##      its default value is <C>"m"</C>. <P/>
##
##      If <A>name</A> is not given but the <C>generatorNames</C> option is,
##      then this option is respected as described in
##      Section&nbsp;<Ref Sect="Generator Names"/>. <P/>
##
##      Otherwise, the generators of the returned free monoid are labelled
##      <A>name</A><C>1</C>, ..., <A>name</A><C>k</C>,
##      where <C>k</C> is the value of <A>rank</A>. <P/>
##    </Item>
##    <Mark>2: For given generator names</Mark>
##    <Item>
##      Called with various nonempty strings,
##      <Ref Func="FreeMonoid" Label="for various names"/> returns
##      a free monoid on as many generators as arguments, which are labelled
##      <A>name1</A>, <A>name2</A>, etc.
##    </Item>
##    <Mark>3: For a given list of generator names</Mark>
##    <Item>
##      Called with a finite list <A>names</A> of
##      nonempty strings,
##      <Ref Func="FreeMonoid" Label="for a list of names"/> returns
##      a free monoid on <C>Length(<A>names</A>)</C> generators, whose
##      <C>i</C>-th generator is labelled <A>names</A><C>[i]</C>.
##    </Item>
##    <Mark>
##      4: For the rank <K>infinity</K>,
##         an optional default generator name prefix,
##         and an optional finite list of generator names
##    </Mark>
##    <Item>
##      Called in the fourth form,
##      <Ref Func="FreeMonoid" Label="for infinitely many generators"/>
##      returns a free monoid on infinitely many generators.
##      The optional argument <A>name</A> must be a string; its default value is
##      <C>"m"</C>,
##      and the optional argument <A>init</A> must be a finite list of
##      nonempty strings; its default value is an empty list.
##      The generators are initially labelled according to the list <A>init</A>,
##      followed by
##      <A>name</A><C>i</C> for each <C>i</C> in the range from
##      <C>Length(<A>init</A>)+1</C> to <K>infinity</K>.
##    </Item>
##  </List>
##
##  If the optional first argument <A>wfilt</A> is given, then it must be either
##  <C>IsSyllableWordsFamily</C>, <C>IsLetterWordsFamily</C>,
##  <C>IsWLetterWordsFamily</C>, or <C>IsBLetterWordsFamily</C>.
##  This filter specifies the representation used for the elements of
##  the free monoid
##  (see&nbsp;<Ref Sect="Representations for Associative Words"/>).
##  If no such filter is given, a letter representation is used.
##  <P/>
##  For more on associative words see
##  Chapter&nbsp;<Ref Chap="Associative Words"/>.
##
##  <Example><![CDATA[
##  gap> FreeMonoid(5);
##  <free monoid on the generators [ m1, m2, m3, m4, m5 ]>
##  gap> FreeMonoid(4, "gen");
##  <free monoid on the generators [ gen1, gen2, gen3, gen4 ]>
##  gap> FreeMonoid(3 : generatorNames := "turbo");
##  <free monoid on the generators [ turbo1, turbo2, turbo3 ]>
##  gap> FreeMonoid(2 : generatorNames := ["u", "v", "w"]);
##  <free monoid on the generators [ u, v ]>
##  gap> FreeMonoid(); FreeMonoid(0); FreeMonoid([]);
##  <free monoid of rank zero>
##  <free monoid of rank zero>
##  <free monoid of rank zero>
##  gap> FreeMonoid("a", "b", "c");
##  <free monoid on the generators [ a, b, c ]>
##  gap> FreeMonoid(["x", "y"]);
##  <free monoid on the generators [ x, y ]>
##  gap> FreeMonoid(infinity);
##  <free monoid with infinity generators>
##  gap> F := FreeMonoid(infinity, "g", ["a", "b"]);
##  <free monoid with infinity generators>
##  gap> GeneratorsOfMonoid(F){[1..4]};
##  [ a, b, g3, g4 ]
##  gap> GeneratorsOfMonoid(FreeMonoid(infinity, "gen")){[1..3]};
##  [ gen1, gen2, gen3 ]
##  gap> GeneratorsOfMonoid(FreeMonoid(infinity, [ "f", "g" ])){[1..3]};
##  [ f, g, m3 ]
##  gap> FreeMonoid(IsSyllableWordsFamily, 50);
##  <free monoid with 50 generators>
##  ]]></Example>
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
##
DeclareGlobalFunction( "FreeMonoid" );

#############################################################################
##
#P  IsFinitelyGeneratedMonoid( <M> )
##
##  <#GAPDoc Label="IsFinitelyGeneratedMonoid">
##  <ManSection>
##  <Prop Name="IsFinitelyGeneratedMonoid" Arg='M'/>
##
##  <Description>
##  tests whether the monoid <A>M</A> can be generated by a finite number of
##  generators. (This property is mainly used to obtain finiteness
##  conditions.)
##  <P/>
##  Note that this is a pure existence statement. Even if a monoid is known
##  to be generated by a finite number of elements, it can be very hard or
##  even impossible to obtain such a generating set if it is not known.
##  </Description>
##  </ManSection>
##  <#/GAPDoc>
##
DeclareProperty( "IsFinitelyGeneratedMonoid", IsMonoid );
InstallTrueMethod( IsMonoid, IsFinitelyGeneratedMonoid );

# make IsFinitelyGeneratedMonoid equivalent to IsMonoid and IsFinitelyGeneratedMagma
InstallTrueMethod( IsFinitelyGeneratedMonoid, IsMonoid and IsFinitelyGeneratedMagma );
InstallTrueMethod( HasIsFinitelyGeneratedMonoid, IsMonoid and HasIsFinitelyGeneratedMagma );
InstallTrueMethod( IsFinitelyGeneratedMagma, IsFinitelyGeneratedMonoid );
InstallTrueMethod( HasIsFinitelyGeneratedMagma, HasIsFinitelyGeneratedMonoid );