File: trans.xml

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 (1766 lines) | stat: -rw-r--r-- 68,514 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
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
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
<Chapter Label="Transformations">
<Heading>Transformations</Heading>

This chapter describes the functions in &GAP; for transformations.
<P/>

A <E>transformation</E> in &GAP; is simply a function from the positive
integers to the positive integers.  Transformations are to semigroup
theory what permutations are to group theory, in the sense that every
semigroup can be realised as a semigroup of transformations. In &GAP;
transformation semigroups are always finite, and so only finite
semigroups can be realised in this way.
<P/>

A transformation in &GAP; acts on the positive integers (up to some
architecture dependent limit) on the right. The image of a point
<C>i</C> under a transformation <C>f</C> is expressed as <C>i ^ f</C> in
&GAP;.  This action is also implemented by the function <Ref
  Func="OnPoints"/>.  If <C>i ^ f</C> is different from <C>i</C>, then
<C>i</C> is <E>moved</E> by <E>f</E> and otherwise it is <E>fixed</E> by
<C>f</C>.  Transformations in &GAP; are created using the operations
described in Section <Ref Sect="sect:CreatingTransformations"/>.
<P/>

The <E>degree</E> of a transformation <C>f</C> is usually defined as the
largest positive integer where <C>f</C> is defined.  In previous
versions of &GAP;, transformations were only defined on positive
integers less than their degree, it was only possible to multiply
transformations of equal degree, and a transformation did not act on any
point exceeding its degree.  Starting with version 4.7 of &GAP;,
transformations behave more like permutations, in that they fix
unspecified points and it is possible to multiply arbitrary
transformations; see Chapter <Ref Chap="Permutations"/>.  The definition
of the degree of a transformation <C>f</C> in the current version of
&GAP; is the largest value <C>n</C> such that <C>n ^ f &lt;> n</C> or
<C>i ^ f = n</C> for some <C>i &lt;> n</C>. Equivalently, the degree of
a transformation is the least value <C>n</C> such that
<C>[ n + 1, n + 2, ... ]</C> is fixed pointwise by <C>f</C>.
<P/>

The transformations of a given degree belong to the full transformation
semigroup of that degree; see <Ref Func="FullTransformationSemigroup"/>.
Transformation semigroups are hence subsemigroups of the full
transformation semigroup.
<P/>

It is possible to use transformations in &GAP; without reference to the
degree, much as it is possible to use permutations in this way.
However, for backwards compatibility, and because it is sometimes
useful, it is possible to access the degree of a transformation using
<Ref Func="DegreeOfTransformation"/>. Certain attributes of
transformations are also calculated with respect to the degree, such as
the rank, image set, or kernel (these values can also be calculated with
respect to any positive integer). So, it is possible to ignore the
degree of a transformation if you prefer to think of transformations as
acting on the positive integers in a similar way to permutations. For
example, this approach is used in the <Package>FR</Package> package. It
is also possible to think of transformations as only acting on the
positive integers not exceeding their degree. For example, this was the
approach formerly used in &GAP; and it is also useful in the
<Package>Semigroups</Package> package.
<P/>

Transformations are displayed, by default, using the list
<C>[ 1 ^ f .. n ^ f ]</C> where <C>n</C> is the degree of <C>f</C>.
This behaviour differs from that of versions of &GAP; earlier than 4.7.
See Section <Ref Sect="sect:DisplayingTransformations"/> for more information.
<P/>

The <E>rank</E> of a transformation on the positive integers up to
<C>n</C> is the number of distinct points in <C>[ 1 ^ f .. n ^ f ]</C>.
The <E>kernel</E> of a transformation <C>f</C> on <C>[ 1 .. n ]</C> is
the equivalence relation on <C>[ 1 .. n ]</C> consisting of those pairs
<C>(i, j)</C> of positive integers such that  <C>i ^ f = j ^ f</C>.  The
kernel of a transformation is represented in two ways: as a partition of
<C>[ 1 .. n ]</C> or as the image list of a transformation <C>g</C> such
that the kernel of <C>g</C> on <C>[ 1 .. n ]</C> equals the kernel of
<C>f</C> and <C>j ^ g = i</C> for all <C>j</C> in <C>i</C>th class. The
latter is referred to as the <E>flat kernel</E> of <C>f</C>. For any
given transformation <C>f</C> and value <C>n</C>, there is a unique
transformation <C>g</C> with this property.
<P/>

A <E>functional digraph</E> is a directed graph where every vertex has
out-degree <M>1</M>.  A transformation <A>f</A> can be thought of as a
functional digraph with vertices the positive integers and edges from
<C>i</C> to <C>i ^ f</C> for every <C>i</C>. A <E>component</E> of a
transformation is defined as a component of the corresponding functional
digraph.  More specifically, <C>i</C> and <C>j</C> are in the same
component if and only if there are <M>i = v_0, v_1, \ldots, v_n = j</M>
such that either <M>v_{k+1}=v_{k}^f</M> or <M>v_{k}=v_{k+1}^f</M> for
all <M>k</M>.  A <E>cycle</E> of a transformation is defined as a cycle
(or strongly connected component) of the corresponding functional
digraph.  More specifically, <C>i</C> belongs to a cycle of <A>f</A> if
there are <M>i=v_0, v_1, \ldots, v_n=i</M> such that either
<M>v_{k+1}=v_{k}^f</M> or <M>v_{k}=v_{k+1}^f</M> for all <M>k</M>.
<P/>

Internally, &GAP; stores a transformation <C>f</C> as a list consisting
of the images <C>i ^ f</C> for all values of <C>i</C> less than a value
which is at least the degree of <C>f</C> and which is determined at the
time of the creation of <C>f</C>. When the degree of a transformation
<C>f</C> is at most 65536, the images of points under <C>f</C> are
stored as 16-bit integers, the kernel and image set are subobjects of
<C>f</C> which are plain lists of &GAP; integers.  When the degree of
<C>f</C> is greater than 65536, the images of points under <C>f</C> are
stored as 32-bit integers; the kernel and image set are stored in the
same way as before.  A transformation belongs to <C>IsTrans2Rep</C> if
it is stored using 16-bit integers and to <C>IsTrans4Rep</C> if it is
stored using 32-bit integers.
<P/>

<Section>
    <Heading>The family and categories of transformations</Heading>
  <ManSection>
    <Filt Name="IsTransformation" Arg="obj" Type="Category"/>
    <Description>
    Every transformation in &GAP; belongs to the category
    <C>IsTransformation</C>. Basic operations for transformations are
    <Ref Oper="ImageListOfTransformation"/>,
    <Ref Attr="ImageSetOfTransformation"/>,
    <Ref Attr="KernelOfTransformation"/>,
    <Ref Attr="FlatKernelOfTransformation"/>,
    <Ref Attr="RankOfTransformation"
      Label="for a transformation and a list"/>,
    <Ref Func="DegreeOfTransformation"/>,
    multiplication of two transformations via <K>*</K>, and
    exponentiation with the first argument a positive integer <C>i</C>
    and second argument a transformation <C>f</C> where the result is
    the image <C>i ^ f</C> of the point <C>i</C> under <C>f</C>.
    </Description>
  </ManSection>

  <ManSection>
    <Filt Name="IsTransformationCollection" Arg="obj" Type="Category"/>
    <Description>
     Every collection of transformations belongs to the category
     <C>IsTransformationCollection</C>. For example, transformation
     semigroups belong to <C>IsTransformationCollection</C>.
    </Description>
  </ManSection>

  <ManSection>
    <Fam Name="TransformationFamily"/>
    <Description>
      The family of all transformations is <C>TransformationFamily</C>.
    </Description>
  </ManSection>
</Section>

<!-- *************************************************************** -->

<Section Label="sect:CreatingTransformations">
  <Heading>Creating transformations</Heading>

  There are several ways of creating transformations in &GAP;, which are
  described in this section.

  <!-- *************************************************************** -->

  <ManSection>
    <Oper Name="Transformation" Arg="list" Label="for an image list"/>
    <Oper Name="Transformation" Arg="list, func"
      Label="for a list and function"/>
    <Oper Name="TransformationList" Arg="list" Label="for an image list"/>
    <Returns>A transformation.</Returns>
    <Description>
      <C>TransformationList</C> returns the transformation <C>f</C> such
      that <C>i ^ <A>f</A> = <A>list</A>[i]</C> if <C>i</C> is between
      <C>1</C> and the length of <A>list</A> and <C>i ^ <A>f</A> = i</C>
      if <C>i</C> is larger than the length of <A>list</A>. An error will
      occur in <C>TransformationList</C> if <A>list</A> is not dense, if
      <A>list</A> contains an element which is not a positive integer,
      or if <A>list</A> contains an integer not in
      <C>[ 1 .. Length( <A>list</A> ) ]</C>.
      <P/>

      <C>TransformationList</C> is the analogue in the context of
      transformations of <Ref Func="PermList"/>. <C>Transformation</C>
      is a synonym of <C>TransformationList</C> when the argument is a
      list.
      <P/>

      When the arguments are a list of positive integers <A>list</A> and
      a function <A>func</A>, <C>Transformation</C> returns the
      transformation <C>f</C> such that
      <C><A>list</A>[i] ^ f = <A>func</A>( <A>list</A>[i] )</C> if
      <C>i</C> is in the range <C>[ 1 .. Length( <A>list</A> ) ]</C> and
      <C>f</C> fixes all other points.

      <Example><![CDATA[
gap> SetUserPreference( "NotationForTransformations", "input" );
gap> f := Transformation( [ 11, 10, 2, 11, 4, 4, 7, 6, 9, 10, 1, 11 ] );
Transformation( [ 11, 10, 2, 11, 4, 4, 7, 6, 9, 10, 1, 11 ] )
gap> f := TransformationList( [ 2, 3, 3, 1 ] );
Transformation( [ 2, 3, 3, 1 ] )
gap> SetUserPreference( "NotationForTransformations", "fr" );
gap> f := Transformation( [ 10, 11 ], x -> x ^ 2 );
<transformation: 1,2,3,4,5,6,7,8,9,100,121>
gap> SetUserPreference( "NotationForTransformations", "input" );
]]></Example>
    </Description>
  </ManSection>

  <!-- *************************************************************** -->

  <ManSection>
    <Oper Name="Transformation" Arg="src, dst"
      Label="for a source and destination"/>
    <Oper Name="TransformationListList" Arg="src, dst"
      Label="for a source and destination"/>
    <Returns>A transformation.</Returns>
    <Description>
      If <A>src</A> and <A>dst</A> are lists of positive integers of the
      same length, such that <A>src</A> contains no  element  twice,
      then <C>TransformationListList( <A>src</A>, <A>dst</A> )</C> returns
      a transformation  <C>f</C>  such  that
      <C>src[i] ^ <A>f</A> = dst[i]</C>. The transformation <A>f</A>
      fixes all points larger than the maximum of the entries in
      <A>src</A> and <A>dst</A>.
      <P/>

      <C>TransformationListList</C> is the analogue in the context of
      transformations of <Ref Func="MappingPermListList"/>.
      <C>Transformation</C> is a synonym of
      <C>TransformationListList</C> when its arguments are two lists of
      positive integers.
    <Example><![CDATA[
gap> Transformation( [ 10, 11 ],[ 11, 12 ] );
Transformation( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 12 ] )
gap> TransformationListList( [ 1, 2, 3 ], [ 4, 5, 6 ] );
Transformation( [ 4, 5, 6, 4, 5, 6 ] )
]]></Example>
    </Description>
  </ManSection>

  <!-- *************************************************************** -->

  <ManSection>
    <Oper Name="TransformationByImageAndKernel" Arg="im, ker"
      Label="for an image and kernel"/>
    <Returns>A transformation or <K>fail</K>.</Returns>
    <Description>
      This operation returns the transformation <C>f</C> where <C>i ^ f
        = <A>im</A>[<A>ker</A>[i]]</C> for <C>i</C> in the range
      <C>[ 1 .. Length( <A>ker</A> ) ]</C>. This transformation has flat
      kernel equal to <A>ker</A> and image set equal to
      <C>Set( <A>im</A> )</C>.
      <P/>

      The argument <A>im</A> should be a duplicate free list of
      positive integers and <A>ker</A> should be the flat kernel of a
      transformation with rank equal to the length of <A>im</A>. If the
      arguments do not fulfil these conditions, then <K>fail</K> is
      returned.

      <Example><![CDATA[
gap> TransformationByImageAndKernel( [ 8, 1, 3, 4 ],
>                                    [ 1, 2, 3, 1, 2, 1, 2, 4 ] );
Transformation( [ 8, 1, 3, 8, 1, 8, 1, 4 ] )
gap> TransformationByImageAndKernel( [ 1, 3, 8, 4 ],
>                                    [ 1, 2, 3, 1, 2, 1, 2, 4 ] );
Transformation( [ 1, 3, 8, 1, 3, 1, 3, 4 ] )
]]></Example>
    </Description>
  </ManSection>

<!-- *************************************************************** -->

  <ManSection>
    <Oper Name="Idempotent" Arg="im, ker"/>
    <Returns>A transformation or <K>fail</K>.</Returns>
    <Description>
      <Ref Oper="Idempotent"/> returns the idempotent transformation
      with image set <A>im</A> and flat kernel <A>ker</A> if such a
      transformation exists and <K>fail</K> if it does not.
      More specifically, a transformation is returned when the argument
      <A>im</A> is a set of positive integers and <A>ker</A> is the flat
      kernel of a transformation with rank equal to the length of
      <A>im</A> and where <A>im</A> has one element in every class of
      the kernel corresponding to <A>ker</A>.
      <P/>

      Note that this is function does not always return the same
      transformation as <C>TransformationByImageAndKernel</C> with the
      same arguments.

      <Example><![CDATA[
gap> Idempotent( [ 2, 4, 6, 7, 8, 10, 11 ],
>                [ 1, 2, 1, 3, 3, 4, 5, 1, 6, 6, 7, 5 ] );
Transformation( [ 8, 2, 8, 4, 4, 6, 7, 8, 10, 10, 11, 7 ] )
gap> TransformationByImageAndKernel( [ 2, 4, 6, 7, 8, 10, 11 ],
>                      [ 1, 2, 1, 3, 3, 4, 5, 1, 6, 6, 7, 5 ] );
Transformation( [ 2, 4, 2, 6, 6, 7, 8, 2, 10, 10, 11, 8 ] )
]]></Example>
    </Description>
  </ManSection>

<!-- *************************************************************** -->

  <ManSection>
    <Oper Name="TransformationOp" Arg="obj, list[, func]"/>
    <Oper Name="TransformationOpNC" Arg="obj, list[, func]"/>
    <Returns>A transformation or <K>fail</K>.</Returns>
    <Description>
      <Ref Oper="TransformationOp"/> returns the transformation that
      corresponds to the action of the object <A>obj</A> on the domain
      or list <A>list</A> via the function <A>func</A>. If the optional
      third argument <A>func</A> is not specified, then the action <Ref
        Func="OnPoints"/> is used by default.  Note that the returned
      transformation refers to the positions in <A>list</A> even if
      <A>list</A> itself consists of integers.
      <P/>

      This function is the analogue in the context of transformations of
      <Ref Func="Permutation"
        Label = "for a group, an action domain, etc."/>.
      <P/>

      If <A>obj</A> does not map elements of <A>list</A> into
      <A>list</A>, then <K>fail</K> is returned.
      <P/>

      <Ref Oper="TransformationOpNC"/> does not check that <A>obj</A>
      maps elements of <A>list</A> to elements of <A>list</A> or that a
      transformation is defined by the action of <A>obj</A> on
      <A>list</A> via <A>func</A>.  This function should be used only
      with caution, and in situations where it is guaranteed that the
      arguments have the required properties.

      <Example><![CDATA[
gap> f := Transformation( [ 10, 2, 3, 10, 5, 10, 7, 2, 5, 6 ] );;
gap> TransformationOp( f, [ 2, 3 ] );
IdentityTransformation
gap> TransformationOp( f, [ 1, 2, 3 ] );
fail
gap> S := SemigroupByMultiplicationTable( [ [ 1, 1, 1 ],
>                                           [ 1, 1, 1 ],
>                                           [ 1, 1, 2 ] ] );;
gap> TransformationOp( Elements( S )[1], S, OnRight );
Transformation( [ 1, 1, 1 ] )
gap> TransformationOp( Elements( S )[3], S, OnRight );
Transformation( [ 1, 1, 2 ] )
]]></Example>
    </Description>
  </ManSection>

  <ManSection>
    <Oper Name="TransformationNumber" Arg="m, n"/>
    <Oper Name="NumberTransformation" Arg="f[, n]"/>
    <Returns>A transformation or a number.</Returns>
    <Description>
      These functions implement a bijection from the transformations with
      degree at most <A>n</A> to the numbers
      <C>[ 1 .. <A>n</A> ^ <A>n</A> ]</C>.
      <P/>

      More precisely, if <A>m</A> and <A>n</A> are positive integers
      such that <A>m</A> is at most <C><A>n</A> ^ <A>n</A></C>, then
      <C>TransformationNumber</C> returns the <A>m</A>th transformation
      with degree at most <A>n</A>.
      <P/>

      If <A>f</A> is a transformation and <A>n</A> is a positive
      integer, which is greater than or equal to the degree of <A>f</A>,
      then <C>NumberTransformation</C> returns the number in <C>[ 1 ..
        <A>n</A> ^ <A>n</A> ]</C> that corresponds to <A>f</A>. If the
      optional second argument <A>n</A> is not specified, then the
      degree of <A>f</A> is used by default.
      <Example><![CDATA[
gap> f := Transformation( [ 3, 3, 5, 3, 3 ] );;
gap> NumberTransformation( f, 5 );
1613
gap> NumberTransformation( f, 10 );
2242256790
gap> TransformationNumber( 2242256790, 10 );
Transformation( [ 3, 3, 5, 3, 3 ] )
gap> TransformationNumber( 1613, 5 );
Transformation( [ 3, 3, 5, 3, 3 ] )]]></Example>
    </Description>
  </ManSection>


<!-- *************************************************************** -->

  <ManSection><Heading>RandomTransformation</Heading>
    <Oper Name="RandomTransformation" Arg="n"/>
    <Returns>A random transformation.</Returns>
    <Description>
      If <A>n</A> is a positive integer, then
      <C>RandomTransformation</C> returns a random transformation with
      degree at most <A>n</A>.
      <Log>
gap> RandomTransformation( 6 );
Transformation( [ 2, 1, 2, 1, 1, 2 ] )</Log>
    </Description>
  </ManSection>

<!-- *************************************************************** -->

 <ManSection>
   <Var Name="IdentityTransformation"/>
   <Description>
     This variable is bound to the identity transformation,
     which has degree <C>0</C>.
     <Example><![CDATA[
gap> IdentityTransformation;
IdentityTransformation
]]></Example>
   </Description>
  </ManSection>

<!-- *************************************************************** -->

  <ManSection>
    <Oper Name="ConstantTransformation" Arg="m, n"/>
    <Returns>A transformation.</Returns>
    <Description>
      This function returns a constant transformation <C>f</C> such that
      <C>i ^ f = <A>n</A></C> for all <C>i</C> less than or equal to
      <A>m</A>, when <A>n</A> and <A>m</A> are positive integers.
    <Example><![CDATA[
gap> ConstantTransformation( 5, 1 );
Transformation( [ 1, 1, 1, 1, 1 ] )
gap> ConstantTransformation( 6, 4 );
Transformation( [ 4, 4, 4, 4, 4, 4 ] )
]]></Example>
    </Description>
  </ManSection>
</Section>

<!-- *************************************************************** -->

<Section Label="sect:ChangingRepTransformations">
  <Heading>Changing the representation of a transformation</Heading>
  It is possible that a transformation in &GAP; can be represented as
  another type of object, or that another type of &GAP; object can be
  represented as a transformation.
  <P/>

  The operations <Ref Attr="AsPermutation"/> and <Ref Meth="AsPartialPerm"
  Label="for a transformation and a positive integer"/> can be used to
  convert transformations into permutations or partial permutations,
  where appropriate.  In this section we describe functions for
  converting other types of objects into transformations.

  <ManSection>
  <Attr Name="AsTransformation" Arg="f[, n]"/>
  <Returns>A transformation.</Returns>
  <Description>
  <C>AsTransformation</C>
  returns the permutation, transformation, partial permutation or binary
  relation <A>f</A> as a transformation.

  <List>

    <Mark>for permutations</Mark>
    <Item>
      If <A>f</A> is a permutation and <A>n</A> is a non-negative
      integer, then <C>AsTransformation( <A>f</A>, <A>n</A> )</C>
      returns the transformation <C>g</C> such that <C>i ^ g = i ^ f</C>
      for all <C>i</C> in the range <C>[ 1 .. <A>n</A> ]</C>.
      <P/>

      If no non-negative integer <A>n</A> is specified, then the largest
      moved point of <A>f</A> is used as the value for <A>n</A>; see
      <Ref Attr="LargestMovedPoint" Label="for a permutation"/>.
    </Item>

    <Mark>for transformations</Mark>
    <Item>
      If <A>f</A> is a transformation and <A>n</A> is a non-negative
      integer less than the degree of <A>f</A> such that <A>f</A> is a
      transformation of <C>[ 1 .. <A>n</A> ]</C>, then
      <C>AsTransformation</C> returns the restriction of <A>f</A> to
      <C>[ 1 .. <A>n</A> ]</C>.
      <P/>

      If <A>f</A> is a transformation and <A>n</A> is not specified or
      is greater than or equal to the degree of <A>f</A>, then
      <A>f</A> is returned.
    </Item>

    <Mark>for partial permutations</Mark>
    <Item>
      A partial permutation <A>f</A> can be converted into a
      transformation <C>g</C> as follows. The degree <C>m</C> of
      <C>g</C> is equal to the maximum of <A>n</A>, the largest moved
      point of <A>f</A> plus <C>1</C>, and the largest image of a moved
      point plus <C>1</C>.  The transformation <C>g</C> agrees with
      <A>f</A> on the domain of <A>f</A> and maps the points in
      <C>[ 1 .. m ]</C>, which are not in the domain of <A>f</A> to
      <C>n</C>, i.e.  <C>i ^ g = i ^ <A>f</A></C> for all <C>i</C> in the
      domain of <A>f</A>, <C>i ^ g = n</C> for all <C>i</C> in
      <C>[ 1 .. n ]</C>, and <C>i ^ g = i</C> for all <C>i</C> greater
      than <A>n</A>.  <C>AsTransformation( <A>f</A> )</C> returns the
      transformation <C>g</C> defined in the previous sentences. <P/>

      If the optional argument <A>n</A> is not present, then the default
      value of the maximum of the largest moved point and the largest
      image of a moved point of <A>f</A> plus <C>1</C> is used.
    </Item>

    <Mark>for binary relations</Mark>
    <Item>
      In the case that <A>f</A> is a binary relation, which defines
      a transformation, <C>AsTransformation</C> returns that
      transformation.
    </Item>
  </List>
  <Example><![CDATA[
gap> f := Transformation( [ 3, 5, 3, 4, 1, 2 ] );;
gap> AsTransformation( f, 5 );
Transformation( [ 3, 5, 3, 4, 1 ] )
gap> AsTransformation( f, 10 );
Transformation( [ 3, 5, 3, 4, 1, 2 ] )
gap> AsTransformation( (1,3)(2,4) );
Transformation( [ 3, 4, 1, 2 ] )
gap> AsTransformation( (1,3)(2,4), 10 );
Transformation( [ 3, 4, 1, 2 ] )
gap> f := PartialPerm( [ 1, 2, 3, 4, 5, 6 ], [ 6, 7, 1, 4, 3, 2 ] );
[5,3,1,6,2,7](4)
gap> AsTransformation( f, 11 );
Transformation( [ 6, 7, 1, 4, 3, 2, 11, 11, 11, 11, 11 ] )
gap> AsPartialPerm( last, DomainOfPartialPerm( f ) );
[5,3,1,6,2,7](4)
gap> AsTransformation( f, 14 );
Transformation( [ 6, 7, 1, 4, 3, 2, 14, 14, 14, 14, 14, 14, 14, 14 ] )
gap> AsPartialPerm( last, DomainOfPartialPerm( f ) );
[5,3,1,6,2,7](4)
gap> AsTransformation( f );
Transformation( [ 6, 7, 1, 4, 3, 2, 8, 8 ] )
gap> AsTransformation( Transformation( [ 1, 1, 2 ] ), 0 );
IdentityTransformation
]]></Example>
  </Description>
  </ManSection>

  <ManSection>
  <Func Name="RestrictedTransformation" Arg="f, list"/>
  <Returns>A transformation.</Returns>
  <Description>
    <C>RestrictedTransformation</C> returns the new transformation
    <C>g</C> such that <C> i ^ g = i ^ <A>f</A></C> for all <C>i</C> in
    <A>list</A> and such that <C>i ^ g = i</C> for all <C>i</C> not in
    <A>list</A>.
    <P/>

    <Example><![CDATA[
gap> f := Transformation( [ 2, 10, 5, 9, 10, 9, 6, 3, 8, 4, 6, 5 ] );;
gap> RestrictedTransformation( f, [ 1, 2, 3, 10, 11, 12 ] );
Transformation( [ 2, 10, 5, 4, 5, 6, 7, 8, 9, 4, 6, 5 ] )]]></Example>
  </Description>
</ManSection>

  <ManSection>
  <Func Name="PermutationOfImage" Arg="f"/>
  <Returns>A permutation or <K>fail</K>.</Returns>
  <Description>
    If the transformation <A>f</A> is a permutation of the points in its
    image, then <C>PermutationOfImage</C> returns this permutation. If
    <A>f</A> does not permute its image, then <K>fail</K> is returned.
    <P/>

    If <A>f</A> happens to be a permutation, then
    <C>PermutationOfImage</C> with argument <A>f</A> returns the same
    value as <C>AsPermutation</C> with argument <A>f</A>.

  <Example><![CDATA[
gap> f := Transformation( [ 5, 8, 3, 5, 8, 6, 2, 2, 7, 8 ] );;
gap> PermutationOfImage( f );
fail
gap> f := Transformation( [ 8, 2, 10, 2, 4, 4, 7, 6, 9, 10 ] );;
gap> PermutationOfImage( f );
fail
gap> f := Transformation( [ 1, 3, 6, 6, 2, 10, 2, 3, 10, 5 ] );;
gap> PermutationOfImage( f );
(2,3,6,10,5)
gap> f := Transformation( [ 5, 2, 8, 4, 1, 8, 10, 3, 5, 7 ] );;
gap> PermutationOfImage( f );
(1,5)(3,8)(7,10)
]]></Example>
  </Description>
  </ManSection>
</Section>

<!-- *************************************************************** -->
<!-- *************************************************************** -->

<Section Label="sect:OperatorsTransformations">
  <Heading>Operators for transformations</Heading>

<ManSection>
  <Meth Name="\^" Arg="i, f" Label="for a positive integer and a transformation"/>
  <Description>
      <C><A>i</A> ^ <A>f</A></C>
      returns the image of the positive integer <A>i</A> under the
      transformation <A>f</A>.
  </Description>
</ManSection>

<ManSection>
  <Meth Name="\^" Arg="f, g" Label="for a transformation and a permutation"/>
  <Description>
      <C><A>f</A> ^ <A>g</A></C>
      returns <C><A>g</A> ^ -1 * <A>f</A> * <A>g</A></C> when
      <A>f</A> is a transformation and <A>g</A> is a permutation
      <Ref Oper="\^"/>.
      This operation requires essentially the same number of steps as
      multiplying a transformation by a permutation, which is
      approximately one third of the number required to first invert
      <A>g</A>, take the product with <A>f</A>, and then the product
      with <A>g</A>.
  </Description>
</ManSection>

<ManSection>
  <Meth Name="\*" Arg="f, g" Label="for transformations"/>
  <Description>
      <C><A>f</A> * <A>g</A></C>
      returns the composition of <A>f</A> and <A>g</A> when <A>f</A> and
      <A>g</A> are transformations or permutations. The product of a
      permutation and a transformation is returned as a transformation.
  </Description>
</ManSection>

<ManSection>
  <Meth Name="\/" Arg="f, g" Label="for a transformation and a permutation"/>
  <Description>
      <C><A>f</A> / <A>g</A></C>
      returns <C><A>f</A> * <A>g</A> ^ -1</C> when <A>f</A> is a
      transformation and <A>g</A> is a permutation.  This operation
      requires essentially the same number of steps as multiplying a
      transformation by a permutation, which is approximately half the
      number required to first invert <A>g</A> and then take the product
      with <A>f</A>.
  </Description>
</ManSection>

<ManSection>
  <Meth Name="LeftQuotient" Arg="g, f" Label="for a permutation and transformation"/>
  <Description>
      returns <C><A>g</A> ^ -1 * <A>f</A></C> when <A>f</A> is a
      transformation and <A>g</A> is a permutation. This operation uses
      essentially the same number of steps as multiplying a
      transformation by a permutation, which is approximately half the
      number required to first invert <A>g</A> and then take the product
      with <A>f</A>.
  </Description>
</ManSection>

<ManSection>
  <Meth Name="\&lt;" Arg="i, f" Label="for transformations"/>
  <Description>
      <Index Subkey="for transformations">smaller</Index>
      <C><A>f</A> &lt; <A>g</A></C>
      returns <K>true</K> if the image list of <A>f</A> is
      lexicographically less than the image list of <A>g</A> and
      <K>false</K> if it is not.
  </Description>
</ManSection>

<ManSection>
  <Meth Name="\=" Arg="f, g" Label="for transformations"/>
  <Description>
      <Index Subkey="for transformations">equality</Index>
      <C><A>f</A> = <A>g</A></C>
      returns <K>true</K> if the transformation <A>f</A> equals the
      transformation <A>g</A> and returns <K>false</K> if it does not.
  </Description>
</ManSection>

<!-- *************************************************************** -->

  <ManSection>
    <Oper Name="PermLeftQuoTransformation" Arg="f, g"/>
    <Func Name="PermLeftQuoTransformationNC" Arg="f, g"/>
    <Returns>A permutation.</Returns>
    <Description>
      Returns the permutation on the image set of <A>f</A> induced by
      <C><A>f</A> ^ -1 * <A>g</A></C> when the transformations <A>f</A>
      and <A>g</A> have equal kernel and image set.
      <P/>

      <C>PermLeftQuoTransformation</C> verifies that <A>f</A> and
      <A>g</A> have equal kernels and image sets, and returns an error
      if they do not.  <C>PermLeftQuoTransformationNC</C> does no
      checks.
      <Example><![CDATA[
gap> f := Transformation( [ 5, 6, 7, 1, 4, 3, 2, 7 ] );;
gap> g := Transformation( [ 5, 7, 1, 6, 4, 3, 2, 1 ] );;
gap> PermLeftQuoTransformation( f, g );
(1,6,7)
gap> PermLeftQuoTransformation( g, f );
(1,7,6)
]]></Example>
    </Description>
  </ManSection>

<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->

  <ManSection>
    <Func Name="IsInjectiveListTrans" Arg="list, obj"/>
    <Returns><K>true</K> or <K>false</K>.</Returns>
    <Description>
      The argument <A>obj</A> should be a transformation or the list of
      images of a transformation and <A>list</A> should be a list of
      positive integers. <C>IsInjectiveListTrans</C> checks if
      <A>obj</A> is injective on <A>list</A>.
      <P/>

      More precisely, if <A>obj</A> is a transformation, then we define
      <C>f := <A>obj</A></C> and if <A>obj</A> is the image list of a
      transformation we define <C>f := Transformation( <A>obj</A> )</C>.
      <C>IsInjectiveListTrans</C> returns <K>true</K> if <C>f</C> is
      injective on <A>list</A> and <K>false</K> if it is not. If
      <A>list</A> is not duplicate free, then <K>false</K> is returned.
      <P/>
      <Example><![CDATA[
gap> f := Transformation( [ 2, 6, 7, 2, 6, 9, 9, 1, 1, 5 ] );;
gap> IsInjectiveListTrans( [ 1, 5 ], f );
true
gap> IsInjectiveListTrans( [ 5, 1 ], f );
true
gap> IsInjectiveListTrans( [ 5, 1, 5, 1, 1, ], f );
false
gap> IsInjectiveListTrans( [ 5, 1, 2, 3 ], [ 1, 2, 3, 4, 5 ] );
true
]]></Example>
    </Description>
  </ManSection>

<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->

<ManSection>
  <Oper Name="ComponentTransformationInt" Arg="f, n" />
  <Returns>A list of positive integers.</Returns>
  <Description>
    If <A>f</A> is a transformation and <A>n</A> is a positive integer,
    then <C>ComponentTransformationInt</C> returns those elements
    <C>i</C> such that <C><A>n</A> ^ <A>f</A> ^ j = i</C> for some
    positive integer <C>j</C>, i.e. the elements of the component of
    <A>f</A> containing <A>n</A> that can be obtained by applying powers
    of <A>f</A> to <A>n</A>.
<Example><![CDATA[
gap> f := Transformation( [ 6, 2, 8, 4, 7, 5, 8, 3, 5, 8 ] );;
gap> ComponentTransformationInt( f, 1 );
[ 1, 6, 5, 7, 8, 3 ]
gap> ComponentTransformationInt( f, 12 );
[ 12 ]
gap> ComponentTransformationInt( f, 5 );
[ 5, 7, 8, 3 ]
]]></Example>
  </Description>
</ManSection>

<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->

  <ManSection>
    <Oper Name="PreImagesOfTransformation" Arg="f, n"/>
    <Returns>A set of positive integers.</Returns>
    <Description>
      Returns the preimages of the positive integer <A>n</A> under the
      transformation <A>f</A>, i.e. the positive integers <C>i</C> such
      that <C>i ^ <A>f</A> = n</C>.

      <Example><![CDATA[
gap> f := Transformation( [ 2, 6, 7, 2, 6, 9, 9, 1, 1, 5 ] );;
gap> PreImagesOfTransformation( f, 1 );
[ 8, 9 ]
gap> PreImagesOfTransformation( f, 3 );
[  ]
gap> PreImagesOfTransformation( f, 100 );
[ 100 ]
]]></Example>
</Description>
</ManSection>

</Section>

<!-- *************************************************************** -->

<Section Label="sect:AttributesTransformations">
  <Heading>Attributes for transformations</Heading>
  In this section we describe the functions available in &GAP; for finding
  various properties and attributes of transformations.

  <ManSection>
    <Func Name="DegreeOfTransformation" Arg="f"/>
    <Attr Name="DegreeOfTransformationCollection" Arg="coll"/>
    <Returns>A positive integer.</Returns>
    <Description>
      The <E>degree</E> of a transformation <A>f</A> is the largest
      value such that <C>n ^ <A>f</A> &lt;> n</C> or
      <C>i ^ <A>f</A> = n</C> for some <C>i &lt;> n</C>.  Equivalently,
      the degree of a transformation is the least value <C>n</C> such
      that <C>[ n + 1, n + 2, ... ]</C> is fixed pointwise by <A>f</A>.
      <P/>

      The degree of a collection of transformations <A>coll</A> is
      the maximum degree of any transformation in <A>coll</A>.
      <Example><![CDATA[
gap> DegreeOfTransformation( IdentityTransformation );
0
gap> DegreeOfTransformationCollection(
> [ Transformation( [ 1, 3, 4, 1 ] ),
>   Transformation( [ 3, 1, 1, 3, 4 ] ),
>   Transformation( [ 2, 4, 1, 2 ] ) ] );
5
]]></Example>
    </Description>
  </ManSection>

<!-- *************************************************************** -->

  <ManSection>
    <Oper Name="ImageListOfTransformation" Arg="f[, n]"/>
    <Oper Name="ListTransformation" Arg="f[, n]"/>
    <Returns>The list of images of a transformation.</Returns>
    <Description>
      Returns the list of images of <C>[ 1 .. <A>n</A> ]</C> under the
      transformation <A>f</A>, which is
      <C>[ 1 ^ <A>f</A> .. <A>n</A> ^ <A>f</A> ]</C>.  If the optional
      second argument <A>n</A> is not present, then the degree of
      <A>f</A> is used by default.
      <P/>

      This is the analogue for transformations of <Ref Func="ListPerm"/>
      for permutations.
      <Example><![CDATA[
gap> f := Transformation( [ 2 ,3, 4, 2, 4 ] );;
gap> ImageListOfTransformation( f );
[ 2, 3, 4, 2, 4 ]
gap> ImageListOfTransformation( f, 10 );
[ 2, 3, 4, 2, 4, 6, 7, 8, 9, 10 ]
]]></Example>
    </Description>
  </ManSection>

<!-- *************************************************************** -->

  <ManSection>
    <Attr Name="ImageSetOfTransformation" Arg="f[, n]"/>
    <Returns>The set of images of the transformation.</Returns>
    <Description>
      Returns the set of points in the list of images of
      <C>[ 1 .. <A>n</A> ]</C> under <A>f</A>, i.e. the sorted list of
      images with duplicates removed.  If the optional second argument
      <A>n</A> is not given, then the degree of <A>f</A> is used.
      <P/>

      <Example><![CDATA[
gap> f := Transformation( [ 5, 6, 7, 1, 4, 3, 2, 7 ] );;
gap> ImageSetOfTransformation( f );
[ 1, 2, 3, 4, 5, 6, 7 ]
gap> ImageSetOfTransformation( f, 10 );
[ 1, 2, 3, 4, 5, 6, 7, 9, 10 ]
]]></Example>
</Description>
</ManSection>

<!-- *************************************************************** -->

  <ManSection>
    <Attr Name="RankOfTransformation" Arg="f[, n]"
      Label="for a transformation and a positive integer"/>
    <Attr Name="RankOfTransformation" Arg="f[, list]"
      Label="for a transformation and a list"/>
    <Returns>The rank of a transformation.</Returns>
    <Description>
      When the arguments are a transformation <A>f</A> and a positive
      integer <A>n</A>, <C>RankOfTransformation</C> returns the size of
      the set of images of the transformation <A>f</A> in the range
      <C>[ 1 .. <A>n</A> ]</C>.  If the optional second argument
      <A>n</A> is not specified, then the degree of <A>f</A> is used.
      <P/>

      When the arguments are a transformation <A>f</A> and a list
      <A>list</A> of positive integers, this function returns the size
      of the set of images of the transformation <A>f</A> on
      <A>list</A>.

      <Example><![CDATA[
gap> f := Transformation( [ 8, 5, 8, 2, 2, 8, 4, 7, 3, 1 ] );;
gap> ImageSetOfTransformation( f );
[ 1, 2, 3, 4, 5, 7, 8 ]
gap> RankOfTransformation( f );
7
gap> RankOfTransformation( f, 100 );
97
gap> RankOfTransformation( f, [ 2, 5, 8 ] );
3
]]></Example>
    </Description>
  </ManSection>

<!-- *************************************************************** -->

  <ManSection>
    <Attr Name="MovedPoints" Arg="f" Label="for a transformation"/>
    <Attr Name="MovedPoints" Arg="coll"
      Label="for a transformation coll"/>
    <Returns>A set of positive integers.</Returns>
    <Description>
      When the argument is a transformation, <C>MovedPoints</C> returns
      the set of positive integers <C>i</C> such that
      <C>i ^ <A>f</A> &lt;> i</C>.
      <P/>

      <C>MovedPoints</C> returns the set of points moved by some element of
      the collection of transformations <A>coll</A>.
      <Example><![CDATA[
gap> f := Transformation( [ 6, 10, 1, 4, 6, 5, 1, 2, 3, 3 ] );;
gap> MovedPoints( f );
[ 1, 2, 3, 5, 6, 7, 8, 9, 10 ]
gap> f := IdentityTransformation;
IdentityTransformation
gap> MovedPoints( f );
[  ]
]]></Example>
    </Description>
  </ManSection>

<!-- *************************************************************** -->

  <ManSection>
    <Attr Name="NrMovedPoints" Arg="f" Label="for a transformation"/>
    <Attr Name="NrMovedPoints" Arg="coll"
      Label="for a transformation coll"/>
    <Returns>A positive integer.</Returns>
    <Description>
      When the argument is a transformation,<C>NrMovedPoints</C> returns
      the number of positive integers <C>i</C> such that
      <C>i ^ <A>f</A> &lt;> i</C>.
      <P/>

      <C>MovedPoints</C> returns the number of points which are moved by at
      least one element of the collection of transformations <A>coll</A>.
      <Example><![CDATA[
gap> f := Transformation( [ 7, 1, 4, 3, 2, 7, 7, 6, 6, 5 ] );;
gap> NrMovedPoints( f );
9
gap> NrMovedPoints( IdentityTransformation );
0
]]></Example>
    </Description>
  </ManSection>

<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->

<ManSection>
  <Attr Name="SmallestMovedPoint" Arg="f" Label="for a transformation"/>
  <Meth Name="SmallestMovedPoint" Arg="coll" Label="for a transformation coll"/>
  <Returns>A positive integer or <K>infinity</K>.</Returns>
  <Description>
    <C>SmallestMovedPoint</C> returns the smallest  positive integer
    <C>i</C> such that <C>i ^ <A>f</A> &lt;> i</C> if such an <C>i</C>
    exists.  If <A>f</A> is the identity transformation, then
    <K>infinity</K> is returned.
    <P/>

    If the argument is a collection of transformations <A>coll</A>, then
    the smallest point which is moved by at least one element of
    <A>coll</A> is returned, if such a point exists.  If <A>coll</A>
    only contains identity transformations, then
    <C>SmallestMovedPoint</C> returns <K>infinity</K>.
    <Example><![CDATA[
gap> S := FullTransformationSemigroup( 5 );
<full transformation monoid of degree 5>
gap> SmallestMovedPoint( S );
1
gap> S := Semigroup( IdentityTransformation );
<trivial transformation group of degree 0 with 1 generator>
gap> SmallestMovedPoint( S );
infinity
gap> f := Transformation( [ 1, 2, 3, 6, 6, 6 ] );;
gap> SmallestMovedPoint( f );
4
]]></Example>
  </Description>
</ManSection>

<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->

<ManSection>
  <Attr Name="LargestMovedPoint" Arg="f"
    Label="for a transformation"/>
  <Meth Name="LargestMovedPoint" Arg="coll"
    Label="for a transformation coll"/>
  <Returns>A positive integer.</Returns>
  <Description>
    <C>LargestMovedPoint</C> returns the largest positive integers
    <C>i</C> such that <C>i ^ <A>f</A> &lt;> i</C> if such an <C>i</C>
    exists.  If <A>f</A> is the identity transformation, then <C>0</C>
    is returned.
    <P/>

    If the argument is a collection of transformations <A>coll</A>, then the
    largest point which is moved by at least one element of <A>coll</A> is
    returned, if such a point exists.  If <A>coll</A> only contains identity
    transformations, then <C>LargestMovedPoint</C> returns <C>0</C>.

    <Example><![CDATA[
gap> S := FullTransformationSemigroup( 5 );
<full transformation monoid of degree 5>
gap> LargestMovedPoint( S );
5
gap> S := Semigroup( IdentityTransformation );
<trivial transformation group of degree 0 with 1 generator>
gap> LargestMovedPoint( S );
0
gap> f := Transformation( [ 1, 2, 3, 6, 6, 6 ] );;
gap> LargestMovedPoint( f );
5
]]></Example>
  </Description>
</ManSection>

<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->

<ManSection>
  <Attr Name="SmallestImageOfMovedPoint" Arg="f"
    Label="for a transformation"/>
  <Meth Name="SmallestImageOfMovedPoint" Arg="coll"
    Label="for a transformation coll"/>
  <Returns>A positive integer or <K>infinity</K>.</Returns>
  <Description>
    <C>SmallestImageOfMovedPoint</C> returns the smallest positive
    integer <C>i ^ <A>f</A></C> such that <C>i ^ <A>f</A> &lt;> i</C> if
    such an <C>i</C> exists.  If <A>f</A> is the identity
    transformation, then <K>infinity</K> is returned.<P/>

    If the argument is a collection of transformations <A>coll</A>, then
    the smallest integer which is the image a point moved by at least
    one element of <A>coll</A> is returned, if such a point exists.  If
    <A>coll</A> only contains identity transformations, then
    <C>SmallestImageOfMovedPoint</C> returns <K>infinity</K>.

    <Example><![CDATA[
gap> S := FullTransformationSemigroup( 5 );
<full transformation monoid of degree 5>
gap> SmallestImageOfMovedPoint( S );
1
gap> S := Semigroup( IdentityTransformation );
<trivial transformation group of degree 0 with 1 generator>
gap> SmallestImageOfMovedPoint( S );
infinity
gap> f := Transformation( [ 1, 2, 3, 6, 6, 6 ] );;
gap> SmallestImageOfMovedPoint( f );
6
]]></Example>
  </Description>
</ManSection>

<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->

<ManSection>
  <Attr Name="LargestImageOfMovedPoint" Arg="f"
    Label="for a transformation"/>
  <Meth Name="LargestImageOfMovedPoint" Arg="coll"
    Label="for a transformation coll"/>
  <Returns>A positive integer.</Returns>
  <Description>
    <C>LargestImageOfMovedPoint</C> returns the largest positive integer
    <C>i ^ <A>f</A></C> such that <C>i ^ <A>f</A> &lt;> i</C> if such an
    <C>i</C> exists.  If <A>f</A> is the identity transformation, then
    <C>0</C> is returned.
    <P/>

    If the argument is a collection of transformations <A>coll</A>, then
    the largest integer which is the image a point moved by at least one
    element of <A>coll</A> is returned, if such a point exists.  If
    <A>coll</A> only contains identity transformations, then
    <C>LargestImageOfMovedPoint</C> returns <C>0</C>.
    <Example><![CDATA[
gap> S := FullTransformationSemigroup( 5 );
<full transformation monoid of degree 5>
gap> LargestImageOfMovedPoint( S );
5
gap> S := Semigroup( IdentityTransformation );;
gap> LargestImageOfMovedPoint( S );
0
gap> f := Transformation( [ 1, 2, 3, 6, 6, 6 ] );;
gap> LargestImageOfMovedPoint( f );
6
]]></Example>
  </Description>
</ManSection>

<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->

  <ManSection>
    <Attr Name="FlatKernelOfTransformation" Arg="f[, n]"/>
    <Returns>The flat kernel of a transformation.</Returns>
    <Description>
      If the kernel classes of the transformation <A>f</A> on
      <C>[ 1 .. <A>n</A> ]</C> are <M>K_1, \dots, K_r</M>, then
      <C>FlatKernelOfTransformation</C> returns a list <C>L</C> such
      that <C>L[i] = j</C> for all <C>i</C> in <M>K_j</M>.  For a given
      transformation and positive integer <A>n</A>, there is a unique
      such list.
      <P/>

      If the optional second argument <A>n</A> is not present, then the
      degree of <A>f</A> is used by default.
      <Example><![CDATA[
gap> f := Transformation( [ 10, 3, 7, 10, 1, 5, 9, 2, 6, 10 ] );;
gap> FlatKernelOfTransformation( f );
[ 1, 2, 3, 1, 4, 5, 6, 7, 8, 1 ]
]]></Example>
    </Description>
  </ManSection>

<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->

  <ManSection>
    <Attr Name="KernelOfTransformation" Arg="f[, n, bool]"/>
    <Returns>The kernel of a transformation.</Returns>
    <Description>
      When the arguments are a transformation <A>f</A>, a positive
      integer <A>n</A>, and <K>true</K>, <C>KernelOfTransformation</C>
      returns the kernel of the transformation <A>f</A> on
      <C>[ 1 .. <A>n</A> ]</C> as a set of sets of positive integers. If
      the argument <A>bool</A> is <K>false</K>, then only the
      non-singleton classes are returned. <P/>

      The second and third arguments are optional, the default values
      are the degree of <A>f</A> and <K>true</K>.
      <Example><![CDATA[
gap> f := Transformation( [ 2, 6, 7, 2, 6, 9, 9, 1, 11, 1, 12, 5 ] );;
gap> KernelOfTransformation( f );
[ [ 1, 4 ], [ 2, 5 ], [ 3 ], [ 6, 7 ], [ 8, 10 ], [ 9 ], [ 11 ],
  [ 12 ] ]
gap> KernelOfTransformation( f, 5 );
[ [ 1, 4 ], [ 2, 5 ], [ 3 ] ]
gap> KernelOfTransformation( f, 5, false );
[ [ 1, 4 ], [ 2, 5 ] ]
gap> KernelOfTransformation( f, 15 );
[ [ 1, 4 ], [ 2, 5 ], [ 3 ], [ 6, 7 ], [ 8, 10 ], [ 9 ], [ 11 ],
  [ 12 ], [ 13 ], [ 14 ], [ 15 ] ]
gap> KernelOfTransformation( f, false );
[ [ 1, 4 ], [ 2, 5 ], [ 6, 7 ], [ 8, 10 ] ]
]]></Example>
  </Description>
  </ManSection>

<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->

<ManSection>
  <Func Name="InverseOfTransformation" Arg="f"/>
  <Returns>A transformation.</Returns>
  <Description>
    <C>InverseOfTransformation</C> returns a semigroup inverse of the
    transformation <A>f</A> in the full transformation semigroup. An
    <E>inverse</E> of <A>f</A> is any transformation <C>g</C> such that
    <C><A>f</A> * g * <A>f</A> = <A>f</A></C> and
    <C>g * <A>f</A> * g = g</C>.  Every transformation has at least one
    inverse.
    <Example><![CDATA[
gap> f := Transformation( [ 2, 6, 7, 2, 6, 9, 9, 1, 1, 5 ] );;
gap> g := InverseOfTransformation( f );
Transformation( [ 8, 1, 1, 1, 10, 2, 3, 1, 6, 1 ] )
gap> f * g * f;
Transformation( [ 2, 6, 7, 2, 6, 9, 9, 1, 1, 5 ] )
gap> g * f * g;
Transformation( [ 8, 1, 1, 1, 10, 2, 3, 1, 6, 1 ] )
]]></Example>
  </Description>
</ManSection>

<ManSection>
  <Attr Name="Inverse" Arg="f" Label="for a transformation"/>
  <Returns>A transformation.</Returns>
  <Description>
    If the transformation <A>f</A> is a bijection, then <C>Inverse</C> or
    <C><A>f</A> ^ -1</C> returns the inverse of <A>f</A>.
    If <A>f</A> is not a bijection, then <K>fail</K> is returned.
    <Example><![CDATA[
gap> Transformation( [ 3, 8, 12, 1, 11, 9, 9, 4, 10, 5, 10, 6 ] ) ^ -1;
fail
gap> Transformation( [ 2, 3, 1 ] ) ^ -1;
Transformation( [ 3, 1, 2 ] )
]]></Example>
  </Description>
</ManSection>

<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->

  <ManSection>
    <Func Name="IndexPeriodOfTransformation" Arg="f"/>
    <Returns>A pair of positive integers.</Returns>
    <Description>
      Returns the least positive integers <C>m</C> and <C>r</C> such
      that <C><A>f</A> ^ (m + r) = <A>f</A> ^ m</C>, which are  known as
      the <E>index</E> and <E>period</E> of the transformation <A>f</A>.
      <Example><![CDATA[
gap> f := Transformation( [ 3, 4, 4, 6, 1, 3, 3, 7, 1 ] );;
gap> IndexPeriodOfTransformation( f );
[ 2, 3 ]
gap> f ^ 2 = f ^ 5;
true
gap> IndexPeriodOfTransformation( IdentityTransformation );
[ 1, 1 ]
gap> IndexPeriodOfTransformation( Transformation( [ 1, 2, 1 ] ) );
[ 1, 1 ]
gap> IndexPeriodOfTransformation( Transformation( [ 1, 2, 3 ] ) );
[ 1, 1 ]
gap> IndexPeriodOfTransformation( Transformation( [ 1, 3, 2 ] ) );
[ 1, 2 ]
]]></Example>
    </Description>
  </ManSection>

<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->

<ManSection>
  <Attr Name="SmallestIdempotentPower" Arg="f"
    Label="for a transformation"/>
  <Returns>A positive integer.</Returns>
  <Description>
      This function returns the least positive integer <C>n</C> such
      that the transformation <C><A>f</A> ^ n</C> is an idempotent.  The
      smallest idempotent power of <A>f</A> is the least multiple of the
      period of <A>f</A> that is greater than or equal to the index of
      <A>f</A>; see <Ref Func="IndexPeriodOfTransformation"/>.

      <Example><![CDATA[
gap> f := Transformation( [ 6, 7, 4, 1, 7, 4, 6, 1, 3, 4 ] );;
gap> SmallestIdempotentPower( f );
3
gap> f := Transformation( [ 6, 6, 6, 2, 7, 1, 5, 3, 10, 6 ] );;
gap> SmallestIdempotentPower( f );
2
]]></Example>
    </Description>
  </ManSection>

<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->

<ManSection>
  <Attr Name="ComponentsOfTransformation" Arg="f" />
  <Returns>A list of lists of positive integers.</Returns>
  <Description>
    <C>ComponentsOfTransformation</C> returns a list of the components
    of the transformation <A>f</A>.  Each component is a subset of
    <C>[ 1 .. DegreeOfTransformation( f ) ]</C>, and the union of the
    components is <C>[ 1 .. DegreeOfTransformation( f ) ]</C>.

    <Example><![CDATA[
gap> f := Transformation( [ 6, 12, 11, 1, 7, 6, 2, 8, 4, 7, 5, 12 ] );
Transformation( [ 6, 12, 11, 1, 7, 6, 2, 8, 4, 7, 5, 12 ] )
gap> ComponentsOfTransformation( f );
[ [ 1, 6, 4, 9 ], [ 2, 12, 3, 11, 5, 7, 10 ], [ 8 ] ]
gap> f := AsTransformation( (1,8,2,4,11,5,10)(3,7)(9,12) );
Transformation( [ 8, 4, 7, 11, 10, 6, 3, 2, 12, 1, 5, 9 ] )
gap> ComponentsOfTransformation( f );
[ [ 1, 8, 2, 4, 11, 5, 10 ], [ 3, 7 ], [ 6 ], [ 9, 12 ] ]]]></Example>
  </Description>
</ManSection>

<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->

<ManSection>
  <Attr Name="NrComponentsOfTransformation" Arg="f" />
  <Returns>A positive integer.</Returns>
  <Description>
    <C>NrComponentsOfTransformation</C> returns the number of components
    of the transformation <A>f</A> on the range
    <C>[ 1 .. DegreeOfTransformation( <A>f</A> ) ]</C>.

    <Example><![CDATA[
gap> f := Transformation( [ 6, 12, 11, 1, 7, 6, 2, 8, 4, 7, 5, 12 ] );
Transformation( [ 6, 12, 11, 1, 7, 6, 2, 8, 4, 7, 5, 12 ] )
gap> NrComponentsOfTransformation( f );
3
gap> f := AsTransformation( (1,8,2,4,11,5,10)(3,7)(9,12) );
Transformation( [ 8, 4, 7, 11, 10, 6, 3, 2, 12, 1, 5, 9 ] )
gap> NrComponentsOfTransformation( f );
4
]]></Example>
  </Description>
</ManSection>

<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->

<ManSection>
  <Attr Name="ComponentRepsOfTransformation" Arg="f" />
  <Returns>A list of lists of positive integers.</Returns>
  <Description>
    <C>ComponentRepsOfTransformation</C> returns the representatives, in
    the following sense, of the components of the transformation
    <A>f</A>.  For every <C>i</C> in
    <C>[ 1 .. DegreeOfTransformation( f ) ]</C> there exists a
    representative <C>j</C> and a positive integer <C>k</C> such that
    <C>i ^ (<A>f</A> ^ k) = j</C>. The representatives returned by
    <C>ComponentRepsOfTransformation</C> are partitioned according to
    the component they belong to.  <C>ComponentRepsOfTransformation</C>
    returns the least number of representatives.
    <Example><![CDATA[
gap> f := Transformation( [ 6, 12, 11, 1, 7, 6, 2, 8, 4, 7, 5, 12 ] );
Transformation( [ 6, 12, 11, 1, 7, 6, 2, 8, 4, 7, 5, 12 ] )
gap> ComponentRepsOfTransformation( f );
[ [ 3, 10 ], [ 9 ], [ 8 ] ]
gap> f := AsTransformation( (1,8,2,4,11,5,10)(3,7)(9,12) );
Transformation( [ 8, 4, 7, 11, 10, 6, 3, 2, 12, 1, 5, 9 ] )
gap> ComponentRepsOfTransformation( f );
[ [ 1 ], [ 3 ], [ 6 ], [ 9 ] ]
]]></Example>
  </Description>
</ManSection>


<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->

<ManSection>
  <Attr Name="CyclesOfTransformation" Arg="f[, list]" />
  <Returns>A list of lists of positive integers.</Returns>
  <Description>
    When the arguments of this function are a transformation <A>f</A>
    and a list <A>list</A>, it returns a list of the cycles of the
    components of <A>f</A> containing any element of <A>list</A>.<P/>

    If the optional second argument is not present, then the range
    <C>[ 1 .. DegreeOfTransformation( <A>f</A> ) ]</C> is used as the
    default value for <A>list</A>.
    <Example><![CDATA[
gap> f := Transformation( [ 6, 12, 11, 1, 7, 6, 2, 8, 4, 7, 5, 12 ] );
Transformation( [ 6, 12, 11, 1, 7, 6, 2, 8, 4, 7, 5, 12 ] )
gap> CyclesOfTransformation( f );
[ [ 6 ], [ 12 ], [ 8 ] ]
gap> CyclesOfTransformation( f, [ 1, 2, 4 ] );
[ [ 6 ], [ 12 ] ]
gap> CyclesOfTransformation( f, [ 1 .. 17 ] );
[ [ 6 ], [ 12 ], [ 8 ], [ 13 ], [ 14 ], [ 15 ], [ 16 ], [ 17 ] ]
]]></Example>
  </Description>
</ManSection>

<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->

<ManSection>
  <Oper Name="CycleTransformationInt" Arg="f, n" />
  <Returns>A list of positive integers.</Returns>
  <Description>
    If <A>f</A> is a transformation and <A>n</A> is a positive
    integer, then <C>CycleTransformationInt</C> returns the cycle of the
    component of <A>f</A> containing <A>n</A>.
    <Example><![CDATA[
gap> f := Transformation( [ 6, 2, 8, 4, 7, 5, 8, 3, 5, 8 ] );;
gap> CycleTransformationInt( f, 1 );
[ 8, 3 ]
gap> CycleTransformationInt( f, 12 );
[ 12 ]
gap> CycleTransformationInt( f, 5 );
[ 8, 3 ]
]]></Example>
  </Description>
</ManSection>

<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->

<ManSection>
  <Attr Name="LeftOne" Arg="f" Label="for a transformation"/>
  <Attr Name="RightOne" Arg="f" Label="for a transformation"/>
  <Returns>A transformation.</Returns>
  <Description>
    <C>LeftOne</C> returns an idempotent transformation <C>e</C> such that
    the kernel (with respect to the degree of <A>f</A>) of <C>e</C>
    equals the kernel of the transformation <A>f</A> and
    <C>e * <A>f</A> = f</C>.
    <P/>

    <C>RightOne</C> returns an idempotent transformation <C>e</C> such
    that the image set (with respect to the degree of <A>f</A>) of
    <C>e</C> equals the image set of <A>f</A> and
    <C><A>f</A> * e = f</C>.

    <Example><![CDATA[
gap> f := Transformation( [ 11, 10, 2, 11, 4, 4, 7, 6, 9, 10, 1, 11 ] );;
gap> e := RightOne( f );
Transformation( [ 1, 2, 2, 4, 4, 6, 7, 7, 9, 10, 11, 11 ] )
gap> IsIdempotent( e );
true
gap> f * e = f;
true
gap> e := LeftOne( f );
Transformation( [ 1, 2, 3, 1, 5, 5, 7, 8, 9, 2, 11, 1 ] )
gap> e * f = f;
true
gap> IsIdempotent( e );
true
]]></Example>
  </Description>
</ManSection>

  <ManSection>
    <Oper Name="TrimTransformation" Arg="f[, n]"/>
    <Returns>Nothing.</Returns>
    <Description>
      It can happen that the internal representation of a transformation
      uses more memory than necessary. For example, this can happen when
      composing transformations where it is possible that the resulting
      transformation <A>f</A> belongs to <C>IsTrans4Rep</C> and
      stores its images as 32-bit integers, while none of its moved
      points exceeds 65536. The purpose of <C>TrimTransformation</C> is
      to change the internal representation of such an <A>f</A> to
      remove the trailing fixed points in the internal representation of
      <A>f</A>.
      <P/>

      If the optional second argument <A>n</A> is provided, then the
      internal representation of <A>f</A> is reduced to the images of
      the first <A>n</A> positive integers. Please note that it must be
      the case that <C>i ^ <A>f</A> &lt;= n</C> for all <C>i</C> in the
      range <C>[ 1 .. <A>n</A> ]</C> otherwise the resulting object will
      not define a transformation.
      <P/>

      If the optional second argument is not included, then the
      degree of <A>f</A> is used by default.
      <P/>

      The transformation <A>f</A> is changed in-place, and
      nothing is returned by this function.

      <Log><![CDATA[
gap> f := Transformation( [ 1 .. 2 ^ 16 ], x -> x + 1 );
<transformation on 65537 pts with rank 65536>
gap> g := Transformation( [ 1 .. 2 ^ 16 + 1 ],
> function( x )
>   if x = 1 or x = 65537 then
>     return x;
>   else
>     return x - 1;
>   fi;
> end );
<transformation on 65536 pts with rank 65535>
gap> h := g * f;
Transformation( [ 2, 2 ] )
gap> DegreeOfTransformation( h ); IsTrans4Rep( h ); MemoryUsage( h );
65537
true
262188
gap> TrimTransformation( h ); h;
Transformation( [ 2, 2 ] )
gap> DegreeOfTransformation( h ); IsTrans4Rep( h ); MemoryUsage( h );
2
false
44
]]></Log>
    </Description>
  </ManSection>
</Section>

<!-- *************************************************************** -->

<Section Label="sect:DisplayingTransformations">
  <Heading>Displaying transformations</Heading>
    It is possible to change the way that &GAP; displays transformations
    using the user preferences <C>TransformationDisplayLimit</C> and
    <C>NotationForTransformations</C>; see Section <Ref
      Func="UserPreference"/> for more information about user
    preferences.
    <P/>

    If <C>f</C> is a transformation where the degree <C>n</C> of
    <C>f</C> exceeds the value of the user preference
    <C>TransformationDisplayLimit</C>, then <C>f</C> is displayed as:
    <Log>&lt;transformation on n pts with rank r></Log> where <C>r</C>
    is the rank of <C>f</C> relative to <C>n</C>.  The idea is to
    abbreviate the display of transformations defined on many points.
    The default value for the <C>TransformationDisplayLimit</C> is
    <C>100</C>.
    <P/>

    If the degree of <C>f</C> does not exceed the value of
    <C>TransformationDisplayLimit</C>, then how <C>f</C> is displayed
    depends on the value of the user preference
    <C>NotationForTransformations</C>.
    <P/>

    There are two possible values for <C>NotationForTransformations</C>:

    <List>

      <Mark>input</Mark>
      <Item>
        With this option a transformation <A>f</A> is displayed in as:
        <C>Transformation( ImageListOfTransformation( <A>f</A>, n ) )</C>
        where <C>n</C> is the degree of <A>f</A>. The only exception is
        the identity transformation, which is displayed as:
        <C>IdentityTransformation</C>.
      </Item>

      <Mark>fr</Mark>
      <Item>With this option a transformation <A>f</A> is displayed in as:
        <C>&lt;transformation: ImageListOfTransformation( <A>f</A>, n )></C>
        where <C>n</C> is the largest moved point of <A>f</A>. The only
        exception is the identity transformation, which is displayed as:
        <C>&lt;identity transformation></C>.
      </Item>

    </List>
    <Log><![CDATA[
gap> SetUserPreference( "TransformationDisplayLimit", 12 );
gap> f := Transformation( [ 3, 8, 12, 1, 11, 9, 9, 4, 10, 5, 10, 6 ] );
<transformation on 12 pts with rank 10>
gap> SetUserPreference( "TransformationDisplayLimit", 100 );
gap> f;
Transformation( [ 3, 8, 12, 1, 11, 9, 9, 4, 10, 5, 10, 6 ] )
gap> SetUserPreference( "NotationForTransformations", "fr" );
gap> f;
<transformation: 3,8,12,1,11,9,9,4,10,5,10,6>
]]></Log>
</Section>

<!-- *************************************************************** -->

<Section Label="Making transformation semigroups">
<Heading>Semigroups of transformations</Heading>

As mentioned at the start of the chapter, every semigroup is isomorphic
to a semigroup of transformations, and in this section we describe the
functions in &GAP; specific to transformation semigroups. For more
information about semigroups in general see Chapter <Ref
  Chap="Semigroups"/>.
<P/>

The <Package>Semigroups</Package> package contains many additional
functions and methods for computing with semigroups of transformations.
In particular, <Package>Semigroups</Package> contains more efficient
methods than those available in the &GAP; library (and in many cases
more efficient than any other software) for creating semigroups of
transformations, calculating their Green's classes, size, elements,
group of units, minimal ideal, small generating sets, testing
membership, finding the inverses of a regular element, factorizing
elements over the generators, and more.

Since a transformation semigroup is also a transformation collection,
there are special methods for
<Ref Attr="MovedPoints" Label="for a transformation coll"/>,
<Ref Attr="NrMovedPoints" Label="for a transformation coll"/>,
<Ref Meth="LargestMovedPoint" Label="for a transformation coll"/>,
<Ref Meth="SmallestMovedPoint" Label="for a transformation coll"/>,
<Ref Meth="LargestImageOfMovedPoint" Label="for a transformation coll"/>,
and
<Ref Meth="SmallestImageOfMovedPoint" Label="for a transformation coll"/>,
when applied to a transformation semigroup.

<!-- *************************************************************** -->

<ManSection>
<Filt Name="IsTransformationSemigroup" Arg="obj" Type="Synonym"/>
<Filt Name="IsTransformationMonoid" Arg="obj" Type="Synonym"/>
<Returns><K>true</K> or <K>false</K>.</Returns>
<Description>
A <E>transformation semigroup</E> is simply a semigroup consisting of
transformations. An object <A>obj</A> is a transformation semigroup in
&GAP; if it satisfies <Ref Filt="IsSemigroup"/> and <Ref
  Filt="IsTransformationCollection"/>.
<P/>

A  <E>transformation monoid</E> is a monoid consisting of
transformations.  An object <A>obj</A> is a transformation monoid in
&GAP; if it satisfies <Ref Filt="IsMonoid"/> and <Ref
  Filt="IsTransformationCollection"/>.
<P/>

Note that it is possible for a transformation semigroup to have a
multiplicative neutral element (i.e. an identity element) but not to
satisfy <C>IsTransformationMonoid</C>. For example,
    <Example><![CDATA[
gap> f := Transformation( [ 2, 6, 7, 2, 6, 9, 9, 1, 1, 5 ] );;
gap> S := Semigroup( f, One( f ) );
<commutative transformation monoid of degree 10 with 1 generator>
gap> IsMonoid( S );
true
gap> IsTransformationMonoid( S );
true
gap> S := Semigroup(
> Transformation( [ 3, 8, 1, 4, 5, 6, 7, 1, 10, 10 ] ),
> Transformation( [ 1, 2, 3, 4, 5, 6, 7, 8, 10, 10 ] ) );
<transformation semigroup of degree 10 with 2 generators>
gap> One( S );
fail
gap> MultiplicativeNeutralElement( S );
Transformation( [ 1, 2, 3, 4, 5, 6, 7, 8, 10, 10 ] )
gap> IsMonoid( S );
false
]]></Example>
In this example <C>S</C> cannot be converted into a monoid using
<Ref Oper="AsMonoid"/> since the <Ref Attr="One"/> of any element in
<C>S</C> differs from the multiplicative neutral element.
<P/>

For more details see <Ref Filt="IsMagmaWithOne"/>.
</Description>
</ManSection>

<ManSection>
<Attr Name="DegreeOfTransformationSemigroup" Arg="S"/>
<Returns>A non-negative integer.</Returns>
<Description>
  The <E>degree</E> of a transformation semigroup <A>S</A> is just the
  maximum of the degrees of the elements of <A>S</A>.

  <Example><![CDATA[
gap> S := Semigroup(
> Transformation( [ 3, 8, 1, 4, 5, 6, 7, 1, 10, 10, 11 ] ),
> Transformation( [ 1, 2, 3, 4, 5, 6, 7, 8, 1, 1, 11 ] ) );
<transformation semigroup of degree 10 with 2 generators>
gap> DegreeOfTransformationSemigroup( S );
10
]]></Example>
</Description>
</ManSection>

<!-- *************************************************************** -->

<ManSection>
<Func Name="FullTransformationSemigroup" Arg="n"/>
<Func Name="FullTransformationMonoid" Arg="n"/>
<Returns>The full transformation semigroup of degree <A>n</A>.</Returns>
<Description>
  If <A>n</A> is a positive integer, then
  <C>FullTransformationSemigroup</C> returns the monoid consisting of
  all transformations with degree at most <A>n</A>, called the
  <E>full transformation semigroup</E>.
  <P/>

  The full transformation semigroup is regular, has
  <C><A>n</A> ^ <A>n</A></C> elements, and is generated by any set
  containing transformations that generate the symmetric group on
  <A>n</A> points and any transformation of rank <C><A>n</A> - 1</C>.
  <P/>

  <C>FulTransformationMonoid</C> is a synonym for
  <C>FullTransformationSemigroup</C>.

  <Example><![CDATA[
gap> FullTransformationSemigroup( 1234 );
<full transformation monoid of degree 1234>
]]></Example>
</Description>
</ManSection>

<!-- *************************************************************** -->

<ManSection>
<Prop Name="IsFullTransformationSemigroup" Arg="S"/>
<Prop Name="IsFullTransformationMonoid" Arg="S"/>
<Returns><K>true</K> or <K>false</K>.</Returns>
<Description>
  If the transformation semigroup <A>S</A> of degree <C>n</C> contains
  every transformation of degree at most <C>n</C>, then
  <C>IsFullTransformationSemigroup</C> returns <K>true</K> and otherwise
  it returns <K>false</K>.
  <P/>

  <C>IsFullTransformationMonoid</C> is a synonym of
  <C>IsFullTransformationSemigroup</C>. It is common in the literature
  for the full transformation monoid to be referred to as the full
  transformation semigroup.

  <Example><![CDATA[
gap> S := Semigroup( AsTransformation( (1,3,4,2), 5 ),
>                    AsTransformation( (1,3,5), 5 ),
>                    Transformation( [ 1, 1, 2, 3, 4 ] ) );
<transformation semigroup of degree 5 with 3 generators>
gap> IsFullTransformationSemigroup( S );
true
gap> S;
<full transformation monoid of degree 5>
gap> IsFullTransformationMonoid( S );
true
gap> S := FullTransformationSemigroup( 5 );;
gap> IsFullTransformationSemigroup( S );
true
]]></Example>
</Description>
</ManSection>

<!-- *************************************************************** -->

<ManSection>
<Attr Name="IsomorphismTransformationSemigroup" Arg="S"/>
<Attr Name="IsomorphismTransformationMonoid" Arg="S"/>
<Returns>An isomorphism to a transformation semigroup or monoid.</Returns>
<Description>
  Returns an isomorphism from the finite semigroup <A>S</A> to a
  transformation semigroup. For most types of objects in &GAP; the
  degree of this transformation semigroup will be equal to the size of
  <A>S</A> plus <C>1</C>.
  <P/>

  Let <C><A>S</A> ^ 1</C> denote the monoid obtained from <A>S</A> by
  adjoining an identity element. Then  <A>S</A> acts faithfully on
  <C><A>S</A> ^ 1</C> by right multiplication, i.e.  every element of
  <A>S</A> describes a transformation on <C>1, .. , |S| + 1</C>. The
  isomorphism from <A>S</A> to the transformation semigroup described in
  this way is called the <E>right regular representation</E> of
  <A>S</A>.  In most cases, <C>IsomorphismTransformationSemigroup</C>
  will return the right regular representation of <A>S</A>.
  <P/>

  As exceptions, if <A>S</A> is a permutation group or a partial perm
  semigroup, then the elements of <A>S</A> act naturally and faithfully
  by transformations on the values from <C>1</C> to the largest moved
  point of <A>S</A>.
  <P/>

  If <A>S</A> is a finitely presented semigroup, then the Todd-Coxeter
  approach will be attempted.<P/>

  <C>IsomorphismTransformationMonoid</C> differs from
  <C>IsomorphismTransformationSemigroup</C>
  only in that its range is a transformation monoid, and not only a
  semigroup, when the semigroup <A>S</A> is a monoid.

  <Log><![CDATA[
gap> S := Semigroup( [ [ [ Z(3), 0*Z(3) ], [ 0*Z(3), Z(3) ^ 0 ] ],
>  [ [ Z(3), Z(3)^0 ], [ Z(3), 0*Z(3) ] ],
>  [ [ Z(3)^0, 0*Z(3) ], [ 0*Z(3), 0*Z(3) ] ] ] );;
gap> Size( S );
81
gap> IsomorphismTransformationSemigroup( S );;
gap> S := SymmetricInverseSemigroup( 4 );
<symmetric inverse monoid of degree 4>
gap> IsomorphismTransformationMonoid( S );
MappingByFunction( <symmetric inverse monoid of degree 4>,
<transformation monoid of degree 5 with 4 generators>
 , function( x ) ... end, <Operation "AsPartialPerm"> )
gap> G := Group( (1,2,3) );
Group([ (1,2,3) ])
gap> IsomorphismTransformationMonoid( G );
MappingByFunction( Group([ (1,2,3) ]), <commutative transformation
 monoid of degree 3 with 1 generator>
 , function( x ) ... end, function( x ) ... end )]]></Log>
</Description>
</ManSection>

<ManSection>
<Attr Name="AntiIsomorphismTransformationSemigroup" Arg="S"/>
<Returns>An anti-isomorphism.</Returns>
<Description>
  If <A>S</A> is a semigroup, then
  <C>AntiIsomorphismTransformationSemigroup</C> returns an anti-isomorphism
  from <A>S</A> to a transformation semigroup. At present, the degree of the
  resulting transformation semigroup equals the size of <A>S</A> plus
  <M>1</M>, and, consequently, this function is of limited use. <P/>

    <Example><![CDATA[
gap> S := Semigroup( Transformation( [ 5, 5, 1, 1, 3 ] ),
>                    Transformation( [ 2, 4, 1, 5, 5 ] ) );
<transformation semigroup of degree 5 with 2 generators>
gap> Size( S );
172
gap> AntiIsomorphismTransformationSemigroup( S );
MappingByFunction( <transformation semigroup of size 172, degree 5
 with 2 generators>, <transformation semigroup of degree 173 with 2
 generators>, function( x ) ... end, function( x ) ... end )
]]></Example>
    </Description>
  </ManSection>
</Section>
</Chapter>