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 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777
|
<Chapter Label="Partial permutations">
<Heading>Partial permutations</Heading>
This chapter describes the functions in &GAP; for partial permutations.
<P/>
A <E>partial permutation</E> in &GAP; is simply an injective function from any
finite set of positive integers to any other finite set of positive integers.
The largest point on which a partial permutation can be defined, and the
largest value that the image of such a point can have, are defined by certain
architecture dependent limits. <P/>
Every inverse semigroup is isomorphic to an inverse semigroup of partial
permutations and, as such, partial permutations are to inverse semigroup theory
what permutations are to group theory and transformations are to semigroup
theory. In this way, partial permutations are the
elements of inverse partial permutation semigroups. <P/>
A partial permutations in &GAP; acts on a finite set of positive integers on
the right. The image of a point <C>i</C> under a partial permutation <C>f</C>
is expressed as <C>i^f</C> in &GAP;. This action is also implemented by the
function <Ref Func="OnPoints"/>. The preimage of a point <C>i</C> under the
partial permutation <C>f</C> can be computed using <C>i/f</C> without
constructing the inverse of <C>f</C>. Partial permutations in &GAP; are
created using the operations described in Section <Ref
Sect="sect:CreatingPartialPerms"/>.
Partial permutations are, by default, displayed
in component notation, which is described in Section
<Ref Sect="sect:DisplayingPartialPerms"/>. <P/>
The fundamental attributes of a partial permutation are:
<List>
<Mark>Domain</Mark>
<Item>The <E>domain</E> of a partial permutation is just the set of positive
integers where it is defined; see <Ref Attr="DomainOfPartialPerm"/>. We
will denote the domain of a partial permutation <C>f</C> by dom(<C>f</C>).
</Item>
<Mark>Degree</Mark>
<Item> The <E>degree</E> of a partial permutation <C>f</C> is just the largest
positive integer where <C>f</C> is defined. In other words, the degree of
<C>f</C> is the largest element in the domain of <C>f</C>;
see <Ref Func="DegreeOfPartialPerm"/>.
</Item>
<Mark>Image list</Mark>
<Item>
The <E>image list</E> of a partial permutation <C>f</C> is the list
<C>[i_1^f, i_2^f, .. , i_n^f]</C>
where the domain of <C>f</C> is
<C>[i_1, i_2, .., i_n]</C>
see <Ref Attr="ImageListOfPartialPerm"/>. For example, the partial perm
sending <C>1</C> to <C>5</C> and <C>2</C> to <C>4</C> has image list
<C>[ 5, 4 ]</C>.
</Item>
<Mark>Image set</Mark>
<Item>
The <E>image set</E> of a partial permutation <C>f</C> is just the set of
points in the image list (i.e. the image list after it has been sorted into
increasing order);
see <Ref Attr="ImageSetOfPartialPerm"/>. We will denote the image set of a
partial permutation <C>f</C> by im(<C>f</C>).
</Item>
<Mark>Codegree</Mark>
<Item> The <E>codegree</E> of a partial permutation <C>f</C> is just the
largest positive integer of the form <C>i^f</C> for any <C>i</C>
in the domain of <C>f</C>. In other words, the codegree of <C>f</C> is
the largest element in the image of <C>f</C>; see
<Ref Func="CodegreeOfPartialPerm"/>.
</Item>
<Mark>Rank</Mark>
<Item>The <E>rank</E> of a partial permutation <C>f</C> is the size of its
domain, or equivalently the size of its image set or image list; see
<Ref Func="RankOfPartialPerm"/>.
</Item>
</List>
A <E>functional digraph</E> is a directed graph where every vertex has
out-degree <C>1</C>. A partial permutation <A>f</A> can be thought of as a
functional digraph with vertices <C>[1..DegreeOfPartialPerm(f)]</C> and
edges from <C>i</C> to <C>i^f</C> for every <C>i</C>. A <E>component</E>
of a partial permutation 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 <C>k</C>. <P/>
If <C>S</C> is a semigroup and <C>s</C> is an element of <C>S</C>, then an
element <C>t</C> in <C>S</C> is a <E>semigroup inverse</E> for <C>s</C> if
<C>s*t*s=s</C> and <C>t*s*t=t</C>; see, for example,
<Ref Func="InverseOfTransformation"/>. A semigroup in which every element has
a unique semigroup inverse is called an <E>inverse semigroup</E>.<P/>
Every partial permutation belongs to a symmetric inverse monoid; see
<Ref Oper="SymmetricInverseSemigroup"/>. Inverse semigroups of partial
permutations are hence inverse subsemigroups of the symmetric inverse
monoids. <P/>
The inverse <C>f^-1</C> of a partial permutation <C>f</C> is simply the
partial permutation that maps <C>i^f</C> to <C>i</C> for all <C>i</C> in the
image of <C>f</C>. It follows that the domain of <C>f^-1</C> equals the
image of <C>f</C> and that the image of <C>f^-1</C> equals the domain of
<C>f</C>. The inverse <C>f^-1</C> is the
unique partial permutation with the property that <C>f*f^-1*f=f</C>
and <C>f^-1*f*f^-1=f^-1</C>. In other words, <C>f^-1</C> is the unique
semigroup inverse of <C>f</C> in the symmetric inverse monoid. <P/>
If <C>f</C> and <C>g</C> are partial permutations, then the domain and image
of the product are:
<Alt Only='Text'>
<Display>
dom(fg)=(im(f)\cap dom(g))f^-1 and
im(fg)=(im(f)\cap dom(g))g
</Display>
</Alt>
<Alt Not='Text'>
<Display>
\textrm{dom}(fg)=(\textrm{im}(f)\cap \textrm{dom}(g))f^{-1}\textrm{ and }
\textrm{im}(fg)=(\textrm{im}(f)\cap \textrm{dom}(g))g
</Display>
</Alt>
A partial permutation is an idempotent if and only if it is the identity
function on its domain.
The products <C>f*f^-1</C> and <C>f^-1*f</C> are just the identity
functions on the domain and image of <C>f</C>, respectively. It follows that
<C>f*f^-1</C> is a left identity for <C>f</C> and <C>f^-1*f</C> is a right
identity. These products will be referred to here
as the <E>left one</E> and <E>right one</E> of the partial permutation
<C>f</C>; see <Ref Attr="LeftOne" Label="for a partial perm"/>. The
<E>one</E> of a partial permutation is just the identity on the
union of its domain and its image, and the <E>zero</E> of a partial
permutation is just the empty partial permutation; see
<Ref Meth="One" Label="for a partial perm"/> and
<Ref Meth="MultiplicativeZero" Label="for a partial perm"/>.
<P/>
If <C>S</C> is an arbitrary inverse semigroup, the <E>natural partial
order</E> on <C>S</C> is defined as follows: for elements <C>x</C> and
<C>y</C> of <C>S</C> we say <C>x</C><M>\leq</M><C>y</C> if there exists an
idempotent element <C>e</C> in <C>S</C> such that <C>x=ey</C>.
In the context of the symmetric inverse monoid, a partial permutation
<C>f</C> is less than or equal to a partial permutation <C>g</C> in the
natural partial order if and only
if <C>f</C> is a restriction of <C>g</C>. The natural partial order is a meet
semilattice, in other words, every pair of elements has a greatest lower
bound; see <Ref Func="MeetOfPartialPerms"/>.<P/>
Note that unlike permutations, partial permutations do not fix unspecified
points but are simply undefined on such points; see Chapter
<Ref Chap="Permutations"/>. Similar to permutations, and unlike
transformations, it is possible to multiply any two partial permutations in
&GAP;.<P/>
Internally, &GAP; stores a partial permutation <C>f</C> as a list consisting
of the codegree of <C>f</C> and the images <C>i^f</C> of the points
<C>i</C> that are less than or equal to the degree of <C>f</C>; the value
<C>0</C> is stored where <C>i^f</C> is undefined. The domain and image set
of <C>f</C> are also stored after either of these values is computed. When
the codegree of a partial permutation <C>f</C> is less than 65536, the
codegree and images <C>i^f</C> are stored as 16-bit integers, the domain and
image set are subobjects of <C>f</C> which are immutable plain lists of
&GAP; integers. When the codegree of <C>f</C> is greater than or equal to
65536, the codegree and images are stored as 32-bit integers; the domain and
image set are stored in the same way as before. A partial permutation belongs
to <C>IsPPerm2Rep</C> if it is stored using 16-bit integers and to
<C>IsPPerm4Rep</C> otherwise.
<P/>
In the names of the &GAP; functions that deal with partial permutations, the word <Q>Permutation</Q> is usually abbreviated to <Q>Perm</Q>, to save typing.
For example, the category test function for partial permutations is
<Ref Filt="IsPartialPerm"/>.
<Section>
<Heading>The family and categories of partial permutations</Heading>
<ManSection>
<Filt Name="IsPartialPerm" Arg='obj' Type='Category'/>
<Returns><K>true</K> or <K>false</K>.</Returns>
<Description>
Every partial permutation in &GAP; belongs to the category
<C>IsPartialPerm</C>. Basic operations for partial permutations are
<Ref Attr="DomainOfPartialPerm"/>, <Ref Attr="ImageListOfPartialPerm"/>,
<Ref Attr="ImageSetOfPartialPerm"/>, <Ref Func="RankOfPartialPerm"/>,
<Ref Func="DegreeOfPartialPerm"/>, multiplication of two partial
permutations is via <K>*</K>, and exponentiation with the first argument
a positive integer <C>i</C> and second argument a partial permutation
<C>f</C> where the result is the image <C>i^f</C> of the point <C>i</C>
under <C>f</C>. The inverse of a partial permutation <C>f</C> can be
obtains using <C>f^-1</C>.
</Description>
</ManSection>
<ManSection>
<Filt Name="IsPartialPermCollection" Arg='obj' Type='Category'/>
<Description>
Every collection of partial permutations belongs to the category
<C>IsPartialPermCollection</C>.
For example, a semigroup of partial permutations belongs
in <C>IsPartialPermCollection</C>.
</Description>
</ManSection>
<ManSection>
<Fam Name="PartialPermFamily"/>
<Description>
The family of all partial permutations is <C>PartialPermFamily</C>
</Description>
</ManSection>
</Section>
<!-- *************************************************************** -->
<!-- *************************************************************** -->
<Section Label="sect:CreatingPartialPerms">
<Heading>Creating partial permutations</Heading>
There are several ways of creating partial permutations in &GAP;, which are
described in this section.
<!-- *************************************************************** -->
<ManSection>
<Func Name="PartialPerm" Arg="dom, img" Label="for a domain and image"/>
<Func Name="PartialPerm" Arg="list" Label="for a dense image"/>
<Returns>A partial permutation.</Returns>
<Description>
Partial permutations can be created in two ways: by giving the domain
and the image, or the dense image list.<P/>
<List>
<Mark>Domain and image</Mark>
<Item>
The partial permutation defined by a domain <A>dom</A> and image
<A>img</A>, where <A>dom</A> is a set of positive integers and
<A>img</A> is a duplicate free list of positive integers, maps
<A>dom</A><C>[i]</C> to <A>img</A><C>[i]</C>. For example,
the partial permutation mapping <C>1</C> and <C>5</C> to <C>20</C> and
<C>2</C> can be created using:
<Log>PartialPerm([1,5],[20,2]); </Log>
In this setting, <C>PartialPerm</C> is the analogue in the context of
partial permutations of <Ref Func="MappingPermListList"/>.
</Item>
<Mark>Dense image list</Mark>
<Item>
The partial permutation defined by a dense image list <A>list</A>,
maps the positive integer <C>i</C> to <A>list</A><C>[i]</C> if
<A>list</A><C>[i]<>0</C> and is undefined at <C>i</C> if
<A>list</A><C>[i]=0</C>. For example, the partial permutation
mapping <C>1</C> and <C>5</C> to <C>20</C> and <C>2</C> can be
created using: <Log>PartialPerm([20,0,0,0,2]);</Log>
In this setting, <C>PartialPerm</C> is the analogue in the context of
partial permutations of <Ref Func="PermList"/>.
</Item>
</List>
Regardless of which of these two methods are used to create a partial
permutation in &GAP; the internal representation is the same. <P/>
If the largest point in the domain is larger than the
rank of the partial permutation, then using the dense image list to
define the partial permutation will require less typing; otherwise
using the domain and the image will require less typing. For example,
the partial permutation mapping <C>10000</C> to <C>1</C> can be defined
using:
<Log>PartialPerm([10000], [1]);</Log>
but using the dense image list would require a list with <C>9999</C>
entries equal to <C>0</C> and the final entry equal to <C>1</C>.
On the other hand, the identity on <C>[1,2,3,4,6]</C> can be defined
using:
<Log>PartialPerm([1,2,3,4,0,6]);</Log>
<P/>
Please note that a partial permutation in &GAP; is never a permutation
nor is a permutation ever a partial permutation. For example, the
permutation <C>(1,4,2)</C> fixes <C>3</C> but the partial permutation
<C>PartialPerm([4,1,0,2]);</C> is not defined on <C>3</C>.
</Description>
</ManSection>
<!-- *************************************************************** -->
<ManSection>
<Oper Name="PartialPermOp" Arg='obj, list[, func]'/>
<Oper Name="PartialPermOpNC" Arg='obj, list[, func]'/>
<Returns>A partial permutation or <K>fail</K>.</Returns>
<Description>
<Ref Oper="PartialPermOp"/> returns the partial permutation 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 partial permutation
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
partial permutations of <Ref Func="Permutation"
Label="for a group, an action domain, etc."/> or
<Ref Oper="TransformationOp"/>.<P/>
If <A>obj</A> does not map the elements of <A>list</A> injectively,
then <K>fail</K> is returned.<P/>
<Ref Oper="PartialPermOpNC"/> does not check that <A>obj</A> maps
elements of <A>list</A> injectively or that a partial permutation 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, in situations where it is
guaranteed that the arguments have the required properties.
<Example>
gap> f:=Transformation( [ 9, 10, 4, 2, 10, 5, 9, 10, 9, 6 ] );;
gap> PartialPermOp(f, [ 6 .. 8 ], OnPoints);
[1,4][2,5][3,6]</Example>
</Description>
</ManSection>
<!-- *************************************************************** -->
<ManSection>
<Oper Name="RestrictedPartialPerm" Arg="f, set"/>
<Returns>A partial permutation.</Returns>
<Description>
<C>RestrictedPartialPerm</C> returns a new partial permutation that acts
on the points in the set of positive integers <A>set</A> in the same
way as the partial permutation <A>f</A>, and that is undefined on those
points that are not in <A>set</A>.
<Example>
gap> f:=PartialPerm( [ 1, 3, 4, 7, 8, 9 ], [ 9, 4, 1, 6, 2, 8 ] );;
gap> RestrictedPartialPerm(f, [ 2, 3, 6, 10 ] );
[3,4]</Example>
</Description>
</ManSection>
<!-- *************************************************************** -->
<ManSection>
<Func Name="JoinOfPartialPerms" Arg="arg"/>
<Func Name="JoinOfIdempotentPartialPermsNC" Arg="arg"/>
<Returns>A partial permutation or <K>fail</K>.</Returns>
<Description>
The join of partial permutations <A>f</A> and <A>g</A> is just the join,
or supremum, of <A>f</A> and <A>g</A> under the natural partial
ordering of partial permutations. <P/>
<C>JoinOfPartialPerms</C> returns the union of the partial permutations
in its argument if this defines a partial permutation, and <K>fail</K>
if it is not. The argument <A>arg</A> can be a partial permutation
collection or a number of partial permutations.
<P/>
The function <C>JoinOfIdempotentPartialPermsNC</C> returns the join of
its argument which is assumed to be a collection of idempotent partial
permutations or a number of idempotent partial permutations. It is not
checked that the arguments are idempotents. The performance of this
function is higher than <C>JoinOfPartialPerms</C> when it is known
<E>a priori</E> that the argument consists of idempotents.<P/>
The union of <A>f</A> and <A>g</A> is a partial
permutation if and only if <A>f</A> and <A>g</A> agree on the
intersection dom(<A>f</A>)<M>\cap</M> dom(<A>g</A>) of their domains and
the images of dom(<A>f</A>)<M>\setminus</M> dom(<A>g</A>)
and dom(<A>g</A>)<M>\setminus</M> dom(<A>f</A>) under
<A>f</A> and <A>g</A>, respectively, are disjoint.
<Example>
gap> f:=PartialPerm( [ 1, 2, 3, 6, 8, 10 ], [ 2, 6, 7, 9, 1, 5 ] );
[3,7][8,1,2,6,9][10,5]
gap> g:=PartialPerm( [ 11, 12, 14, 16, 18, 19 ],
> [ 17, 20, 11, 19, 14, 12 ] );
[16,19,12,20][18,14,11,17]
gap> JoinOfPartialPerms(f, g);
[3,7][8,1,2,6,9][10,5][16,19,12,20][18,14,11,17]
gap> f:=PartialPerm( [ 1, 4, 5, 6, 7 ], [ 5, 7, 3, 1, 4 ] );
[6,1,5,3](4,7)
gap> g:=PartialPerm( [ 100 ], [ 1 ] );
[100,1]
gap> JoinOfPartialPerms(f, g);
fail
gap> f:=PartialPerm( [ 1, 3, 4 ], [ 3, 2, 4 ] );
[1,3,2](4)
gap> g:=PartialPerm( [ 1, 2, 4 ], [ 2, 3, 4 ] );
[1,2,3](4)
gap> JoinOfPartialPerms(f, g);
fail
gap> f:=PartialPerm( [ 1 ], [ 2 ] );
[1,2]
gap> JoinOfPartialPerms(f, f^-1);
(1,2)</Example>
</Description>
</ManSection>
<!-- *************************************************************** -->
<ManSection>
<Func Name="MeetOfPartialPerms" Arg="arg"/>
<Returns>A partial permutation.</Returns>
<Description>
The meet of partial permutations <A>f</A> and <A>g</A> is just the meet,
or infimum, of <A>f</A> and <A>g</A> under the natural partial
ordering of partial permutations. In other words, the meet is the
greatest partial permutation which is a restriction of both <A>f</A> and
<A>g</A>. <P/>
Note that unlike the join of partial permutations, the meet always
exists. <P/>
<Ref Func="MeetOfPartialPerms"/> returns the meet of the partial permutations
in its argument. The argument <A>arg</A> can be a partial permutation
collection or a number of partial permutations.
<Example>
gap> f:=PartialPerm( [ 1, 2, 3, 6, 100000 ], [ 2, 6, 7, 1, 5 ] );
[3,7][100000,5](1,2,6)
gap> g:=PartialPerm( [ 1, 2, 3, 4, 6 ], [ 2, 4, 6, 1, 5 ] );
[3,6,5](1,2,4)
gap> MeetOfPartialPerms(f, g);
[1,2]
gap> g:=PartialPerm( [ 1, 2, 3, 5, 6, 7, 9, 10 ],
> [ 4, 10, 5, 6, 7, 1, 3, 2 ] );
[9,3,5,6,7,1,4](2,10)
gap> MeetOfPartialPerms(f, g);
<empty partial perm></Example>
</Description>
</ManSection>
<!-- *************************************************************** -->
<ManSection>
<Func Name="EmptyPartialPerm" Arg=""/>
<Returns>The empty partial permutation.</Returns>
<Description>
The empty partial permutation is returned by this function when it is
called with no arguments. This is just short hand for
<C>PartialPerm([]);</C>.
<Example>
gap> EmptyPartialPerm();
<empty partial perm></Example>
</Description>
</ManSection>
<!-- *************************************************************** -->
<ManSection><Heading>RandomPartialPerm</Heading>
<Func Name="RandomPartialPerm" Arg="n" Label="for a positive integer"/>
<Func Name="RandomPartialPerm" Arg="set" Label="for a set of positive
integers"/>
<Func Name="RandomPartialPerm" Arg="dom, img" Label="for domain and image"/>
<Returns>A random partial permutation.</Returns>
<Description>
In its first form,
<C>RandomPartialPerm</C> returns a randomly chosen partial permutation
where points in the domain and image are bounded above by the
positive integer <A>n</A>.
<Log>gap> RandomPartialPerm(10);
[2,9][4,1,6,5][7,3](8)</Log>
In its second form, <C>RandomPartialPerm</C> returns a randomly chosen
partial permutation with points in the domain and image contained in the
set of positive integers <A>set</A>.
<Log>gap> RandomPartialPerm([1,2,3,1000]);
[2,3,1000](1)</Log>
In its third form, <C>RandomPartialPerm</C> creates a randomly chosen
partial permutation with domain contained in the set of positive integers
<A>dom</A> and image contained in the set of positive integers
<A>img</A>. The arguments <A>dom</A> and <A>img</A> do not have to have
equal length.<P/>
Note that it is not guaranteed in either of these cases that partial
permutations are chosen with a uniform distribution.
</Description>
</ManSection>
</Section>
<!-- *************************************************************** -->
<Section Label="sect:AttributesPartialPerms">
<Heading>Attributes for partial permutations</Heading>
In this section we describe the functions available in &GAP; for
finding various attributes of partial permutations. <P/>
<ManSection>
<Func Name="DegreeOfPartialPerm" Arg="f"/>
<Attr Name="DegreeOfPartialPermCollection" Arg="coll"/>
<Returns>A non-negative integer.</Returns>
<Description>
The <E>degree</E> of a partial permutation <A>f</A> is the largest
positive integer where it is defined, i.e. the maximum element in the
domain of <A>f</A>. <P/>
The degree a collection of partial permutations <A>coll</A> is the
largest degree of any partial permutation in <A>coll</A>.
<Example>
gap> f:=PartialPerm( [ 1, 2, 3, 6, 8, 10 ], [ 2, 6, 7, 9, 1, 5 ] );
[3,7][8,1,2,6,9][10,5]
gap> DegreeOfPartialPerm(f);
10</Example>
</Description>
</ManSection>
<!-- *************************************************************** -->
<ManSection>
<Func Name="CodegreeOfPartialPerm" Arg="f"/>
<Attr Name="CodegreeOfPartialPermCollection" Arg="coll"/>
<Returns>A non-negative integer.</Returns>
<Description>
The <E>codegree</E> of a partial permutation <A>f</A> is the largest
positive integer in its image. <P/>
The codegree a collection of partial permutations <A>coll</A> is the
largest codegree of any partial permutation in <A>coll</A>.
<Example>
gap> f:=PartialPerm( [ 1, 2, 3, 4, 5, 8, 10 ], [ 7, 1, 4, 3, 2, 6, 5 ] );
[8,6][10,5,2,1,7](3,4)
gap> CodegreeOfPartialPerm(f);
7</Example>
</Description>
</ManSection>
<!-- *************************************************************** -->
<ManSection>
<Func Name="RankOfPartialPerm" Arg="f"/>
<Attr Name="RankOfPartialPermCollection" Arg="coll"/>
<Returns>A non-negative integer.</Returns>
<Description>
The <E>rank</E> of a partial permutation <A>f</A> is the size of its
domain, or equivalently the size of its image set or image list.<P/>
The rank of a partial permutation collection <A>coll</A> is the size of the
union of the domains of the elements of <A>coll</A>, or
equivalently, the total number of points on which the elements of <A>coll</A>
act. Note that this is value may not the same as the size of the union of
the images of the elements in <A>coll</A>.
<Example>
gap> f:=PartialPerm( [ 1, 2, 4, 6, 8, 9 ], [ 7, 10, 1, 9, 4, 2 ] );
[6,9,2,10][8,4,1,7]
gap> RankOfPartialPerm(f);
6</Example>
</Description>
</ManSection>
<!-- *************************************************************** -->
<ManSection>
<Attr Name="DomainOfPartialPerm" Arg="f"/>
<Attr Name="DomainOfPartialPermCollection" Arg="f"/>
<Returns>A set of positive integers (maybe empty).</Returns>
<Description>
The <E>domain</E> of a partial permutation <A>f</A> is the set of
positive integers where <A>f</A> is defined. <P/>
The domain of a partial permutation collection <A>coll</A> is the union of
the domains of its elements.
<Example>
gap> f:=PartialPerm( [ 1, 2, 3, 6, 8, 10 ], [ 2, 6, 7, 9, 1, 5 ] );
[3,7][8,1,2,6,9][10,5]
gap> DomainOfPartialPerm(f);
[ 1, 2, 3, 6, 8, 10 ]</Example>
</Description>
</ManSection>
<!-- *************************************************************** -->
<ManSection>
<Attr Name="ImageOfPartialPermCollection" Arg="coll"/>
<Returns>A set of positive integers (maybe empty).</Returns>
<Description>
The <E>image</E> of a partial permutation collection <A>coll</A> is the
union of the images of its elements.
<Example><![CDATA[
gap> S := SymmetricInverseSemigroup(5);
<symmetric inverse monoid of degree 5>
gap> ImageOfPartialPermCollection(GeneratorsOfInverseSemigroup(S));
[ 1 .. 5 ]]]></Example>
</Description>
</ManSection>
<!-- *************************************************************** -->
<ManSection>
<Attr Name="ImageListOfPartialPerm" Arg="f"/>
<Returns>The list of images of a partial permutation.</Returns>
<Description>
The <E>image list</E> of a partial permutation <A>f</A> is the list of
images of the elements of the domain <A>f</A> where
<C>ImageListOfPartialPerm(<A>f</A>)[i]=DomainOfPartialPerm(<A>f</A>)[i]^<A>f</A></C>
for any <C>i</C> in the range from <C>1</C> to the rank of <A>f</A>.
<Example>
gap> f:=PartialPerm( [ 1, 2, 3, 4, 5, 8, 10 ], [ 7, 1, 4, 3, 2, 6, 5 ] );
[8,6][10,5,2,1,7](3,4)
gap> ImageListOfPartialPerm(f);
[ 7, 1, 4, 3, 2, 6, 5 ]</Example>
</Description>
</ManSection>
<!-- *************************************************************** -->
<ManSection>
<Attr Name="ImageSetOfPartialPerm" Arg='f'/>
<Returns>The image set of a partial permutation.</Returns>
<Description>
The <E>image set</E> of a partial permutation <C>f</C> is just the set of
points in the image list (i.e. the image list after it has been sorted
into increasing order).
<Example>
gap> f:=PartialPerm( [ 1, 2, 3, 5, 7, 10 ], [ 10, 2, 3, 5, 7, 6 ] );
[1,10,6](2)(3)(5)(7)
gap> ImageSetOfPartialPerm(f);
[ 2, 3, 5, 6, 7, 10 ]</Example>
</Description>
</ManSection>
<!-- *************************************************************** -->
<ManSection>
<Attr Name="FixedPointsOfPartialPerm" Arg="f" Label="for a partial perm"/>
<Meth Name="FixedPointsOfPartialPerm" Arg="coll" Label="for a partial perm coll"/>
<Returns>A set of positive integers.</Returns>
<Description>
<C>FixedPointsOfPartialPerm</C> returns the set of points <C>i</C> in the
domain of the partial permutation <A>f</A> such that <C>i^<A>f</A>=i</C>.
<P/>
When the argument is a collection of partial permutations <A>coll</A>,
<C>FixedPointsOfPartialPerm</C> returns the set of points fixed by every
element of the collection of partial permutations <A>coll</A>.
<Example>
gap> f := PartialPerm( [ 1, 2, 3, 6, 7 ], [ 1, 3, 4, 7, 5 ] );
[2,3,4][6,7,5](1)
gap> FixedPointsOfPartialPerm(f);
[ 1 ]
gap> f := PartialPerm([1 .. 10]);;
gap> FixedPointsOfPartialPerm(f);
[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]</Example>
</Description>
</ManSection>
<ManSection>
<Attr Name="MovedPoints" Arg="f" Label="for a partial perm"/>
<Meth Name="MovedPoints" Arg="coll" Label="for a partial perm coll"/>
<Returns>A set of positive integers.</Returns>
<Description>
<C>MovedPoints</C> returns the set of points <C>i</C> in the domain of
the partial permutation <A>f</A> such that <C>i^<A>f</A><>i</C>. <P/>
When the argument is a collection of partial permutations
<A>coll</A>, <C>MovedPoints</C> returns the set of points moved by some
element of the collection of partial permutations <A>coll</A>.
<Example>
gap> f := PartialPerm( [ 1, 2, 3, 4 ], [ 5, 7, 1, 6 ] );
[2,7][3,1,5][4,6]
gap> MovedPoints(f);
[ 1, 2, 3, 4 ]
gap> FixedPointsOfPartialPerm(f);
[ ]
gap> FixedPointsOfPartialPerm(PartialPerm([1 .. 4]));
[ 1, 2, 3, 4 ]</Example>
</Description>
</ManSection>
<!-- *************************************************************** -->
<ManSection>
<Attr Name="NrFixedPoints" Arg="f" Label="for a partial perm"/>
<Meth Name="NrFixedPoints" Arg="coll" Label="for a partial perm coll"/>
<Returns>A positive integer.</Returns>
<Description>
<C>NrFixedPoints</C> returns the number of points <C>i</C> in the domain
of the partial permutation <A>f</A> such that <C>i^<A>f</A>=i</C>. <P/>
When the argument is a collection of partial permutations
<A>coll</A>, <C>NrFixedPoints</C> returns the number of points fixed by
every element of the collection of partial permutations <A>coll</A>.
<Example>
gap> f := PartialPerm( [ 1, 2, 3, 4, 5 ], [ 3, 2, 4, 6, 1 ] );
[5,1,3,4,6](2)
gap> NrFixedPoints(f);
1
gap> NrFixedPoints(PartialPerm([1 .. 10]));
10</Example>
</Description>
</ManSection>
<ManSection>
<Attr Name="NrMovedPoints" Arg="f" Label="for a partial perm"/>
<Meth Name="NrMovedPoints" Arg="coll" Label="for a partial perm coll"/>
<Returns>A positive integer.</Returns>
<Description>
<C>NrMovedPoints</C> returns the number of points <C>i</C> in the domain
of the partial permutation <A>f</A> such that <C>i^<A>f</A><>i</C>.
<P/>
When the argument is a collection of partial permutations
<A>coll</A>, <C>NrMovedPoints</C> returns the number of points moved by
some element of the collection of partial permutations <A>coll</A>.
<Example>
gap> f := PartialPerm( [ 1, 2, 3, 4, 5, 7, 8 ], [ 4, 5, 6, 7, 1, 3, 2 ] );
[8,2,5,1,4,7,3,6]
gap> NrMovedPoints(f);
7
gap> NrMovedPoints(PartialPerm([1 .. 4]));
0</Example>
</Description>
</ManSection>
<!-- *************************************************************** -->
<ManSection>
<Attr Name="SmallestMovedPoint" Arg="f" Label="for a partial perm"/>
<Meth Name="SmallestMovedPoint" Arg="coll" Label="for a partial perm 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><>i</C> if such an <C>i</C> exists. If <A>f</A>
is an identity partial permutation, then <K>infinity</K> is returned.<P/>
If the argument is a collection of partial permutations
<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 partial permutations, then <C>SmallestMovedPoint</C>
returns <K>infinity</K>.
<Example>
gap> f := PartialPerm( [ 1, 3 ], [ 4, 3 ] );
[1,4](3)
gap> SmallestMovedPoint(f);
1
gap> SmallestMovedPoint(PartialPerm([1 .. 10]));
infinity</Example>
</Description>
</ManSection>
<ManSection>
<Attr Name="LargestMovedPoint" Arg="f" Label="for a partial perm"/>
<Meth Name="LargestMovedPoint" Arg="coll" Label="for a partial perm coll"/>
<Returns>A positive integer or <K>infinity</K>.</Returns>
<Description>
<C>LargestMovedPoint</C> returns the largest positive integers <C>i</C>
such that <C>i^<A>f</A><>i</C> if such an <C>i</C> exists. If <A>f</A>
is the identity partial permutation, then <C>0</C> is returned.<P/>
If the argument is a collection of partial permutations <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
partial permutations, then <C>LargestMovedPoint</C> returns <C>0</C>.
<Example>
gap> f := PartialPerm( [ 1, 3, 4, 5 ], [ 5, 1, 6, 4 ] );
[3,1,5,4,6]
gap> LargestMovedPoint(f);
5
gap> LargestMovedPoint(PartialPerm([1 .. 10]));
0</Example>
</Description>
</ManSection>
<ManSection>
<Attr Name="SmallestImageOfMovedPoint" Arg="f" Label="for a partial permutation"/>
<Meth Name="SmallestImageOfMovedPoint" Arg="coll"
Label="for a partial permutation 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><>i</C> if such an <C>i</C>
exists. If <A>f</A> is the identity partial permutation, then
<K>infinity</K> is returned.<P/>
If the argument is a collection of partial permutations <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 partial permutations, then
<C>SmallestImageOfMovedPoint</C> returns <K>infinity</K>.
<Example><![CDATA[
gap> S := SymmetricInverseSemigroup(5);
<symmetric inverse monoid of degree 5>
gap> SmallestImageOfMovedPoint(S);
1
gap> S := Semigroup(PartialPerm([10 .. 100], [10 .. 100]));;
gap> SmallestImageOfMovedPoint(S);
infinity
gap> f := PartialPerm( [ 1, 2, 3, 6 ] );
[4,6](1)(2)(3)
gap> SmallestImageOfMovedPoint(f);
6]]></Example>
</Description>
</ManSection>
<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<ManSection>
<Attr Name="LargestImageOfMovedPoint" Arg="f"
Label="for a partial permutation"/>
<Meth Name="LargestImageOfMovedPoint" Arg="coll"
Label="for a partial permutation 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><>i</C> if such an <C>i</C>
exists. If <A>f</A> is an identity partial permutation, then <C>0</C> is
returned.<P/>
If the argument is a collection of partial permutations <A>coll</A>, then
the largest integer which is the image of 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 partial permutations, then
<C>LargestImageOfMovedPoint</C> returns <C>0</C>.
<Example><![CDATA[
gap> S := SymmetricInverseSemigroup(5);
<symmetric inverse monoid of degree 5>
gap> LargestImageOfMovedPoint(S);
5
gap> S := Semigroup(PartialPerm([10 .. 100], [10 .. 100]));;
gap> LargestImageOfMovedPoint(S);
0
gap> f := PartialPerm( [ 1, 2, 3, 6 ] );;
gap> LargestImageOfMovedPoint(f);
6]]></Example>
</Description>
</ManSection>
<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<ManSection>
<Attr Name="IndexPeriodOfPartialPerm" Arg="f"/>
<Returns>A pair of positive integers.</Returns>
<Description>
Returns the least positive integers <C>m, 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 partial permutation
<A>f</A>.
<Example>
gap> f:=PartialPerm( [ 1, 2, 3, 5, 6, 7, 8, 11, 12, 16, 19 ],
> [ 9, 18, 20, 11, 5, 16, 8, 19, 14, 13, 1 ] );
[2,18][3,20][6,5,11,19,1,9][7,16,13][12,14](8)
gap> IndexPeriodOfPartialPerm(f);
[ 6, 1 ]
gap> f^6=f^7;
true</Example>
</Description>
</ManSection>
<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<ManSection>
<Attr Name="SmallestIdempotentPower" Arg="f" Label="for a partial perm"/>
<Returns>A positive integer.</Returns>
<Description>
This function returns the least positive integer <C>n</C> such that the
partial permutation <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 Attr="IndexPeriodOfPartialPerm"/>.
<Example>
gap> f:=PartialPerm( [ 1, 2, 3, 4, 5, 7, 8, 10, 11, 13, 18, 19, 20 ],
> [ 5, 1, 7, 3, 10, 2, 12, 14, 11, 16, 6, 9, 15 ] );
[4,3,7,2,1,5,10,14][8,12][13,16][18,6][19,9][20,15](11)
gap> SmallestIdempotentPower(f);
8
gap> f^8;
<identity partial perm on [ 11 ]></Example>
</Description>
</ManSection>
<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<ManSection>
<Attr Name="ComponentsOfPartialPerm" Arg="f" />
<Returns>A list of lists of positive integer.</Returns>
<Description>
<C>ComponentsOfPartialPerm</C> returns a list of the components of the
partial permutation <A>f</A>. Each component is a subset of the domain of
<A>f</A>, and the union of the components equals the domain.
<Example>
gap> f:=PartialPerm( [ 1, 2, 3, 4, 5, 7, 8, 10, 11, 12, 13, 19 ],
> [ 20, 4, 6, 19, 9, 14, 3, 12, 17, 5, 15, 13 ] );
[1,20][2,4,19,13,15][7,14][8,3,6][10,12,5,9][11,17]
gap> ComponentsOfPartialPerm(f);
[ [ 1, 20 ], [ 2, 4, 19, 13, 15 ], [ 7, 14 ], [ 8, 3, 6 ],
[ 10, 12, 5, 9 ], [ 11, 17 ] ]</Example>
</Description>
</ManSection>
<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<ManSection>
<Attr Name="NrComponentsOfPartialPerm" Arg="f" />
<Returns>A positive integer.</Returns>
<Description>
<C>NrComponentsOfPartialPerm</C>
returns the number of components of the partial permutation
<A>f</A> on its domain.
<Example>
gap> f:=PartialPerm( [ 1, 2, 3, 4, 5, 7, 8, 10, 11, 12, 13, 19 ],
> [ 20, 4, 6, 19, 9, 14, 3, 12, 17, 5, 15, 13 ] );
[1,20][2,4,19,13,15][7,14][8,3,6][10,12,5,9][11,17]
gap> NrComponentsOfPartialPerm(f);
6</Example>
</Description>
</ManSection>
<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<ManSection>
<Attr Name="ComponentRepsOfPartialPerm" Arg="f" />
<Returns>A list of positive integers.</Returns>
<Description>
<C>ComponentRepsOfPartialPerm</C> returns the representatives, in the
following sense, of the components of the partial permutation <A>f</A>.
Every component of <A>f</A> contains a unique element in the domain but
not the image of <A>f</A>; this element is called the
<E>representative</E> of the component. If <C>i</C> is a representative
of a component of <A>f</A>, then for every <C>j</C><M>\not=</M><C>i</C>
in the component of <C>i</C>, there exists a positive integer <C>k</C>
such that <C>i ^ (<A>f</A> ^ k) = j</C>. Unlike transformations, there is
exactly one representative for every component of <A>f</A>.
<C>ComponentRepsOfPartialPerm</C> returns the least number of
representatives.
<Example>
gap> f:=PartialPerm( [ 1, 2, 3, 4, 5, 7, 8, 10, 11, 12, 13, 19 ],
> [ 20, 4, 6, 19, 9, 14, 3, 12, 17, 5, 15, 13 ] );
[1,20][2,4,19,13,15][7,14][8,3,6][10,12,5,9][11,17]
gap> ComponentRepsOfPartialPerm(f);
[ 1, 2, 7, 8, 10, 11 ]</Example>
</Description>
</ManSection>
<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<ManSection>
<Attr Name="LeftOne" Arg="f" Label="for a partial perm"/>
<Attr Name="RightOne" Arg="f" Label="for a partial perm"/>
<Returns>A partial permutation.</Returns>
<Description>
<C>LeftOne</C> returns the identity partial permutation
<C>e</C> such that the domain and image of <C>e</C> equal the domain of
the partial permutation <A>f</A> and such that <C>e*<A>f</A>=f</C>. <P/>
<C>RightOne</C> returns the identity partial permutation
<C>e</C> such that the domain and image of <C>e</C> equal the image of
<A>f</A> and such that <C><A>f</A>*e=f</C>.
<Example>
gap> f:=PartialPerm( [ 1, 2, 4, 5, 6, 7 ], [ 10, 1, 6, 5, 8, 7 ] );
[2,1,10][4,6,8](5)(7)
gap> RightOne(f);
<identity partial perm on [ 1, 5, 6, 7, 8, 10 ]>
gap> LeftOne(f);
<identity partial perm on [ 1, 2, 4, 5, 6, 7 ]></Example>
</Description>
</ManSection>
<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<ManSection>
<Meth Name="One" Arg="f" Label="for a partial perm"/>
<Returns>A partial permutation.</Returns>
<Description>
As described in <Ref Attr="OneImmutable"/>,
<C>One</C> returns the multiplicative neutral element of the partial
permutation <A>f</A>, which is the identity partial permutation on the
union of the domain and image of <A>f</A>. Equivalently, the one of
<A>f</A> is the join of the right one and left one of <A>f</A>.
<Example>
gap> f:=PartialPerm([ 1, 2, 3, 4, 5, 7, 10 ], [ 3, 7, 9, 6, 1, 10, 2 ]);;
gap> One(f);
<identity partial perm on [ 1, 2, 3, 4, 5, 6, 7, 9, 10 ]></Example>
</Description>
</ManSection>
<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<ManSection>
<Meth Name="MultiplicativeZero" Arg="f" Label="for a partial perm"/>
<Returns>The empty partial permutation.</Returns>
<Description>
As described in <Ref Attr="MultiplicativeZero"/>,
<C>Zero</C> returns the multiplicative zero element of the partial
permutation <A>f</A>, which is the empty partial permutation.
<Example>
gap> f := PartialPerm([ 1, 2, 3, 4, 5, 7, 10 ], [ 3, 7, 9, 6, 1, 10, 2 ]);;
gap> MultiplicativeZero(f);
<empty partial perm></Example>
</Description>
</ManSection>
<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
</Section>
<!-- *************************************************************** -->
<Section Label="sect:ChangingRepPartialPerms">
<Heading>Changing the representation of a partial permutation</Heading>
It is possible that a partial permutation in &GAP; can be represented by other
types of objects, or that other types of &GAP; objects can be represented by
partial permutations. Partial permutations which are
mathematically permutations can be converted into permutations in &GAP; using
the function <Ref Attr="AsPermutation"/>. Similarly, a partial permutation
can be converted into a transformation using <Ref Attr="AsTransformation"/>.
<P/>
In this section we describe functions for converting other types of objects
in &GAP; into partial permutations.
<ManSection>
<Oper Name="AsPartialPerm" Arg="f, set" Label="for a permutation and a set of
positive integers"/>
<Meth Name="AsPartialPerm" Arg="f" Label="for a permutation"/>
<Meth Name="AsPartialPerm" Arg="f, n" Label="for a permutation and a positive integer"/>
<Returns>A partial permutation.</Returns>
<Description>
A permutation <A>f</A> defines a partial permutation when it is restricted
to any finite set of positive integers. <C>AsPartialPerm</C> can be used to
obtain this partial permutation.<P/>
There are several possible arguments for <C>AsPartialPerm</C>:
<List>
<Mark>for a permutation and set of positive integers</Mark>
<Item><C>AsPartialPerm</C> returns the
partial permutation that equals <A>f</A> on the set of positive
integers <A>set</A> and that is undefined on every other positive integer.
<P/>
Note that as explained in
<Ref Func="PartialPerm" Label="for a domain and image"/>
<E>a permutation is never a partial permutation</E> in &GAP;, please
keep this in mind when using <C>AsPartialPerm</C>.
</Item>
<Mark>for a permutation</Mark>
<Item><C>AsPartialPerm</C> returns the partial permutation that agrees
with <A>f</A> on <C>[1..LargestMovedPoint(<A>f</A>)]</C> and that is
not defined on any other positive integer.
</Item>
<Mark>for a permutation and a positive integer</Mark>
<Item><C>AsPartialPerm</C> returns the partial permutation that agrees
with <A>f</A> on <C>[1..<A>n</A>]</C>, when <A>n</A> is a positive
integer, and that is not defined on any other positive integer.
</Item>
</List>
The operation <Ref Oper="PartialPermOp"/> can also be used to convert
permutations into partial permutations.
<Example>
gap> f:=(2,8,19,9,14,10,20,17,4,13,12,3,5,7,18,16);;
gap> AsPartialPerm(f);
(1)(2,8,19,9,14,10,20,17,4,13,12,3,5,7,18,16)(6)(11)(15)
gap> AsPartialPerm(f, [ 1, 2, 3 ] );
[2,8][3,5](1)</Example>
</Description>
</ManSection>
<!-- *************************************************************** -->
<ManSection>
<Oper Name="AsPartialPerm" Arg="f, set"
Label="for a transformation and a set of positive integer"/>
<Meth Name="AsPartialPerm" Arg="f, n"
Label="for a transformation and a positive integer"/>
<Returns>A partial permutation or <K>fail</K>.</Returns>
<Description>
A transformation <A>f</A> defines a partial permutation when it is
restricted to a set of positive integers where it is injective.
<C>AsPartialPerm</C> can be used to obtain this partial permutation. <P/>
There are several possible arguments for <C>AsPartialPerm</C>:
<List>
<Mark>for a transformation and set of positive integers</Mark>
<Item>
<C>AsPartialPerm</C> returns the partial permutation obtained by
restricting <A>f</A> to the set of positive integers <A>set</A> when:
<List>
<Item><A>set</A> contains no elements exceeding the degree of
<A>f</A>;
</Item>
<Item><A>f</A> is injective on <A>set</A>.
</Item>
</List>
</Item>
<Mark>for a transformation and a positive integer</Mark>
<Item><C>AsPartialPerm</C> returns the partial permutation that agrees
with <A>f</A> on <C>[1..<A>n</A>]</C> when <A>A</A> is a positive
integer and this set satisfies the
conditions given above.
</Item>
</List>
The operation <Ref Oper="PartialPermOp"/> can also be used to convert
transformations into partial permutations.
<Example>
gap> f:=Transformation( [ 8, 3, 5, 9, 6, 2, 9, 7, 9 ] );;
gap> AsPartialPerm(f, [1, 2, 3, 5, 8]);
[1,8,7][2,3,5,6]
gap> AsPartialPerm(f, 3);
[1,8][2,3,5]
gap> AsPartialPerm(f, [ 2 .. 4 ] );
[2,3,5][4,9]</Example>
</Description>
</ManSection>
</Section>
<!-- *************************************************************** -->
<!-- *************************************************************** -->
<Section Label="sect:OperatorsPartialPerms">
<Heading>Operators and operations for partial permutations</Heading>
<ManSection>
<Meth Name="Inverse" Arg="f" Label="for a partial permutation"/>
<Description>
returns the inverse of the partial permutation <A>f</A>.
</Description>
</ManSection>
<ManSection>
<Meth Name="\^" Arg="i, f" Label="for a positive integer and a partial permutation"/>
<Description>
returns the image of the positive integer <A>i</A> under the
partial permutation <A>f</A> if it is defined and <C>0</C> if it is not.
</Description>
</ManSection>
<ManSection>
<Meth Name="\/" Arg="i, f" Label="for a positive integer and a partial permutation"/>
<Description>
returns the preimage of the positive integer <A>i</A> under the
partial permutation <A>f</A> if it is defined and <C>0</C> if it is not.
Note that the inverse of <A>f</A> is not calculated to find the
preimage of <A>i</A>.
</Description>
</ManSection>
<ManSection>
<Meth Name="\^" Arg="f, g" Label="for a partial permutation and a permutation or partial 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 partial permutation and <A>g</A> is a permutation or partial
permutation; see <Ref Oper="\^"/>. This operation requires
essentially the same number of steps as multiplying partial permutations,
which is around one third as many as inverting and multiplying twice.
</Description>
</ManSection>
<ManSection>
<Meth Name="\*" Arg="f, g" Label="for permutations and partial permutations"/>
<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 partial permutations or permutations. The product of a
permutation and a partial permutation is returned as a partial
permutation.
</Description>
</ManSection>
<ManSection>
<Meth Name="\/" Arg="f, g" Label="for a partial permutation and permutation or partial 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 partial
permutation and
<A>g</A> is a permutation or partial permutation.
This operation requires essentially the same number of steps
as multiplying partial permutations, which is
approximately half that 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 or partial permutation
and a partial permutation"/>
<Description>
returns <C><A>g</A>^-1*<A>f</A></C>
when <A>f</A> is a partial permutation and
<A>g</A> is a permutation or partial permutation.
This operation requires essentially the same number of steps
as multiplying partial permutations, which is
approximately half that required to first invert <A>g</A> and then take
the product with <A>f</A>.
</Description>
</ManSection>
<ManSection>
<Meth Name="\<" Arg="f, g" Label="for partial permutations"/>
<Description>
<C><A>f</A> < <A>g</A></C>
returns <K>true</K> if the image of <A>f</A> on the range from 1 to the
degree of <A>f</A>
is lexicographically less than the corresponding image for <A>g</A>
and <K>false</K> if it is not. See <Ref Func="NaturalLeqPartialPerm"/>
and <Ref Func="ShortLexLeqPartialPerm"/> for additional orders for
partial permutations.
</Description>
</ManSection>
<ManSection>
<Meth Name="\=" Arg="f, g" Label="for partial permutations"/>
<Description>
<C><A>f</A> = <A>g</A></C>
returns <K>true</K> if the partial permutation <A>f</A> equals the
partial permutation <A>g</A> and returns <K>false</K> if it does not.
</Description>
</ManSection>
<!-- *************************************************************** -->
<ManSection>
<Oper Name="PermLeftQuoPartialPerm" Arg='f, g'/>
<Oper Name="PermLeftQuoPartialPermNC" 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 partial permutations <A>f</A> and
<A>g</A> have equal domain and image set. <P/>
<C>PermLeftQuoPartialPerm</C> verifies that <A>f</A> and <A>g</A> have
equal domains and image sets, and returns an error if they do not.
<C>PermLeftQuoPartialPermNC</C> does no checks.
<Example>
gap> f:=PartialPerm( [ 1, 2, 3, 4, 5, 7 ], [ 7, 9, 10, 4, 2, 5 ] );
[1,7,5,2,9][3,10](4)
gap> g:=PartialPerm( [ 1, 2, 3, 4, 5, 7 ], [ 7, 4, 9, 2, 5, 10 ] );
[1,7,10][3,9](2,4)(5)
gap> PermLeftQuoPartialPerm(f, g);
(2,5,10,9,4)</Example>
</Description>
</ManSection>
<!-- *************************************************************** -->
<ManSection>
<Oper Name="PreImagePartialPerm" Arg='f, i'/>
<Returns>A positive integer or <K>fail</K>.</Returns>
<Description>
<C>PreImagePartialPerm</C> returns the preimage of the positive
integer <A>i</A> under the partial permutation <A>f</A> if
<A>i</A> belongs to the image of <A>f</A>. If <A>i</A> does not belong to
the image of <A>f</A>, then <K>fail</K> is returned. <P/>
The same result can be obtained by using <C><A>i</A>/<A>f</A></C> as
described in Section <Ref Sect="sect:OperatorsPartialPerms"/>.
<Example>
gap> f:=PartialPerm( [ 1, 2, 3, 5, 9, 10 ], [ 5, 10, 7, 8, 9, 1 ] );
[2,10,1,5,8][3,7](9)
gap> PreImagePartialPerm(f, 8);
5
gap> PreImagePartialPerm(f, 5);
1
gap> PreImagePartialPerm(f, 1);
10
gap> PreImagePartialPerm(f, 10);
2
gap> PreImagePartialPerm(f, 2);
fail</Example>
</Description>
</ManSection>
<!-- *************************************************************** -->
<ManSection>
<Oper Name="ComponentPartialPermInt" Arg='f, i'/>
<Returns>A set of positive integers.</Returns>
<Description>
<C>ComponentPartialPermInt</C> returns the elements of the component of
<A>f</A> containing <A>i</A> that can be obtained by repeatedly applying
<A>f</A> to <A>i</A>.
<Example>
gap> f:=PartialPerm( [ 1, 2, 4, 5, 6, 7, 8, 10, 14, 15, 16, 17, 18 ],
> [ 11, 4, 14, 16, 15, 3, 20, 8, 17, 19, 1, 6, 12 ] );
[2,4,14,17,6,15,19][5,16,1,11][7,3][10,8,20][18,12]
gap> ComponentPartialPermInt(f, 4);
[ 4, 14, 17, 6, 15, 19 ]
gap> ComponentPartialPermInt(f, 3);
[ ]
gap> ComponentPartialPermInt(f, 10);
[ 10, 8, 20 ]
gap> ComponentPartialPermInt(f, 100);
[ ]</Example>
</Description>
</ManSection>
<!-- *************************************************************** -->
<ManSection>
<Func Name="NaturalLeqPartialPerm" Arg="f, g"/>
<Returns><K>true</K> or <K>false</K>.</Returns>
<Description>
The <E>natural partial order</E> <M>\leq</M> on an inverse semigroup
<C>S</C> is defined by <C>s</C><M>\leq</M><C>t</C> if there exists an
idempotent
<C>e</C> in <C>S</C> such that <C>s=et</C>. Hence if <A>f</A> and
<A>g</A> are partial permutations, then <A>f</A><M>\leq</M><A>g</A> if
and only if <A>f</A> is a restriction of <A>g</A>;
see <Ref Oper="RestrictedPartialPerm"/>. <P/>
<C>NaturalLeqPartialPerm</C>
returns <K>true</K> if <A>f</A> is a restriction of <A>g</A> and
<K>false</K> if it is not. Note that since this is a partial order and
not a total order, it is possible that <A>f</A> and <A>g</A> are
incomparable with respect to the natural partial order.
<Example>
gap> f:=PartialPerm(
> [ 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 16, 17, 18, 19 ],
> [ 3, 12, 14, 4, 11, 18, 17, 2, 9, 5, 15, 8, 20, 10, 19 ] );;
gap> g:=RestrictedPartialPerm(f, [ 1, 2, 3, 9, 13, 20 ] );
[1,3,14][2,12]
gap> NaturalLeqPartialPerm(g,f);
true
gap> NaturalLeqPartialPerm(f,g);
false
gap> g:=PartialPerm( [ 1, 2, 3, 4, 5, 8, 10 ],
> [ 7, 1, 4, 3, 2, 6, 5 ] );;
gap> NaturalLeqPartialPerm(f, g);
false
gap> NaturalLeqPartialPerm(g, f);
false</Example>
</Description>
</ManSection>
<!-- *************************************************************** -->
<ManSection>
<Func Name="ShortLexLeqPartialPerm" Arg="f, g"/>
<Returns><K>true</K> or <K>false</K>.</Returns>
<Description>
<C>ShortLexLeqPartialPerm</C> returns <K>true</K> if
the concatenation of the domain and image list of <A>f</A> is short-lex
less than the corresponding concatenation for <A>g</A> and <K>false</K>
otherwise.<P/>
Note that this is not the natural partial order
on partial permutation or the same as comparing <A>f</A> and <A>g</A>
using <C>\<</C>.
<Example>
gap> f:=PartialPerm( [ 1, 2, 3, 4, 6, 7, 8, 10 ],
> [ 3, 8, 1, 9, 4, 10, 5, 6 ] );
[2,8,5][7,10,6,4,9](1,3)
gap> g:=PartialPerm( [ 1, 2, 3, 4, 5, 8, 10 ],
> [ 7, 1, 4, 3, 2, 6, 5 ] );
[8,6][10,5,2,1,7](3,4)
gap> f<g;
true
gap> g<f;
false
gap> ShortLexLeqPartialPerm(f, g);
false
gap> ShortLexLeqPartialPerm(g, f);
true
gap> NaturalLeqPartialPerm(f, g);
false
gap> NaturalLeqPartialPerm(g, f);
false</Example>
</Description>
</ManSection>
<ManSection>
<Oper Name="TrimPartialPerm" Arg="f"/>
<Returns>Nothing.</Returns>
<Description>
It can happen that the internal representation of a partial permutation
uses more memory than necessary. For example, by composing a partial
permutation with codegree less than 65536 with a partial permutation with
codegree greater than 65535. It is possible that the resulting partial
permutation <A>f</A> has its codegree and images stored as
32-bit integers, while none of its image points exceeds 65536. The
purpose of this function is to change the internal representation of
such an <A>f</A> from using 32-bit to using 16-bit integers. <P/>
Note that the partial permutation <A>f</A> is changed in-place, and
nothing is returned by this function.
<Example>
gap> f:=PartialPerm( [ 1, 2 ], [ 3, 4 ] )
> *PartialPerm( [ 3, 5 ], [ 3, 100000 ] );
[1,3]
gap> IsPPerm4Rep(f);
true
gap> TrimPartialPerm(f); f;
[1,3]
gap> IsPPerm4Rep(f);
false</Example>
</Description>
</ManSection>
<!-- *************************************************************** -->
</Section>
<!-- *************************************************************** -->
<Section Label="sect:DisplayingPartialPerms">
<Heading>Displaying partial permutations</Heading>
It is possible to change the way that &GAP; displays partial permutations
using the user preferences <C>PartialPermDisplayLimit</C>
and <C>NotationForPartialPerms</C>; see Section
<Ref Func="UserPreference"/> for more information about user preferences.
<P/>
If <C>f</C> is a partial permutation of rank <C>r</C> exceeding the value
of the user preference <C>PartialPermDisplayLimit</C>, then <C>f</C> is
displayed as:
<Log><partial perm on r pts with degree m, codegree n></Log>
where the degree and codegree are <C>m</C> and <C>n</C>, respectively.
The idea is to abbreviate the display of partial permutations defined on
many points. The default value for the <C>PartialPermDisplayLimit</C> is
<C>100</C>. <P/>
If the rank of <C>f</C> does not exceed the value of
<C>PartialPermDisplayLimit</C>, then how <C>f</C> is displayed depends on
the value of the user preference <C>NotationForPartialPerms</C> except in
the case that <C>f</C> is the empty partial permutation or an identity
partial permutation. <P/>
There are three possible values for <C>NotationForPartialPerms</C> user
preference, which are described below.
<List>
<Mark>component</Mark>
<Item> Similar to permutations, and unlike transformations, partial
permutations can be expressed as products of disjoint permutations and
chains.
A <E>chain</E> is a list <C>c</C> of some length <C>n</C> such
that:
<List>
<Item>
<C>c[1]</C> is an element of the domain of <A>f</A> but not the
image
</Item>
<Item><C>c[i]^<A>f</A>=c[i+1]</C> for all <C>i</C> in the range from
<C>1</C> to <C>n-1</C>.
</Item>
<Item><C>c[n]</C> is in the image of <A>f</A> but not the
domain.</Item>
</List>
In the display, permutations are displayed as they usually are in &GAP;,
except that fixed points are displayed enclosed in round brackets, and
chains are displayed enclosed in square brackets.
<Log>
gap> f := PartialPerm([ 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 16, 17, 18, 19 ],
> [ 3, 12, 14, 4, 11, 18, 17, 2, 9, 5, 15, 8, 20, 10, 19 ]);
[1,3,14][16,8,2,12,15](4)(5,11)[6,18,10,9][7,17,20](19)</Log>
This option is the most compact way to display a partial permutation and
is the default value of the user preference
<C>NotationForPartialPerms</C>.
</Item>
<Mark>domainimage</Mark>
<Item>
With this option a partial permutation <C>f</C> is displayed
in the format: <C>DomainOfPartialPerm(<A>f</A>)->
ImageListOfPartialPerm(<A>f</A>)</C>.
<Log>gap> f:=PartialPerm( [ 1, 2, 4, 5, 6, 7 ], [ 10, 1, 6, 5, 8, 7 ]);
[ 1, 2, 4, 5, 6, 7 ] -> [ 10, 1, 6, 5, 8, 7 ]</Log>
</Item>
<Mark>input</Mark>
<Item>
With this option a partial permutation <A>f</A> is displayed as:
<C>PartialPerm(DomainOfPartialPerm(<A>f</A>),
ImageListOfPartialPerm(<A>f</A>))</C>
which corresponds to the input (of the first type described in
<Ref Func="PartialPerm" Label="for a domain and image"/>).
<Log>gap> f:=PartialPerm( [ 1, 2, 3, 5, 6, 9, 10 ],
> [ 4, 7, 3, 8, 2, 1, 6 ] );
PartialPerm( [ 1, 2, 3, 5, 6, 9, 10 ], [ 4, 7, 3, 8, 2, 1, 6 ] )</Log>
</Item>
</List>
<Log>
gap> SetUserPreference("PartialPermDisplayLimit", 12);
gap> UserPreference("PartialPermDisplayLimit");
12
gap> f:=PartialPerm([1,2,3,4,5,6], [6,7,1,4,3,2]);
[5,3,1,6,2,7](4)
gap> f:=PartialPerm(
> [ 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 16, 17, 18, 19 ],
> [ 3, 12, 14, 4, 11, 18, 17, 2, 9, 5, 15, 8, 20, 10, 19 ] );
<partial perm on 15 pts with degree 19, codegree 20>
gap> SetUserPreference("PartialPermDisplayLimit", 100);
gap> f;
[1,3,14][6,18,10,9][7,17,20][16,8,2,12,15](4)(5,11)(19)
gap> UserPreference("NotationForPartialPerms");
"component"
gap> SetUserPreference("NotationForPartialPerms", "domainimage");
gap> f;
[ 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 16, 17, 18, 19 ] ->
[ 3, 12, 14, 4, 11, 18, 17, 2, 9, 5, 15, 8, 20, 10, 19 ]
gap> SetUserPreference("NotationForPartialPerms", "input");
gap> f;
PartialPerm(
[ 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 16, 17, 18, 19 ],
[ 3, 12, 14, 4, 11, 18, 17, 2, 9, 5, 15, 8, 20, 10, 19 ] )</Log>
</Section>
<Section Label="Partial perm semigroups">
<Heading>Semigroups and inverse semigroups of partial permutations</Heading>
As mentioned at the start of the chapter, every inverse semigroup is isomorphic
to a semigroup of partial permutations, and in this section we describe the
functions in &GAP; specific to partial permutation semigroups. For more information
about semigroups and inverse semigroups see Chapter <Ref Chap="Semigroups"/>. <P/>
The <Package>Semigroups</Package> package contains
many additional functions and methods for computing with semigroups of
partial permutations. 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. <P/>
Since a partial permutation semigroup is also a partial permutation collection, there are special methods for <Ref Attr="DomainOfPartialPermCollection"/>,
<Ref Attr="ImageOfPartialPermCollection"/>,
<Ref Meth="FixedPointsOfPartialPerm" Label="for a partial perm coll"/>,
<Ref Meth="MovedPoints" Label="for a partial perm coll"/>,
<Ref Meth="NrFixedPoints" Label="for a partial perm coll"/>,
<Ref Meth="NrMovedPoints" Label="for a partial perm coll"/>,
<Ref Meth="LargestMovedPoint" Label="for a partial perm coll"/>, and
<Ref Meth="SmallestMovedPoint" Label="for a partial perm coll"/>
when applied to a partial permutation semigroup.
<ManSection>
<Filt Name="IsPartialPermSemigroup" Arg="obj"/>
<Filt Name="IsPartialPermMonoid" Arg="obj"/>
<Returns><K>true</K> or <K>false</K>.</Returns>
<Description>
A <E>partial perm semigroup</E> is simply a semigroup consisting of partial
permutations, which may or may not be an inverse semigroup. An object
<A>obj</A> in &GAP; is a partial perm semigroup if and only if it satisfies
<Ref Filt="IsSemigroup"/> and <Ref Filt="IsPartialPermCollection"/>.<P/>
A <E>partial perm monoid</E> is a monoid consisting of partial
permutations. An object in &GAP; is a partial perm monoid if it satisfies
<Ref Filt="IsMonoid"/> and <Ref Filt="IsPartialPermCollection"/>.<P/>
Note that it is possible for a partial perm semigroup to have a
multiplicative neutral element (i.e. an identity element) but not to satisfy
<C>IsPartialPermMonoid</C>. For example,
<Example><![CDATA[
gap> f := PartialPerm( [ 1, 2, 3, 6, 8, 10 ], [ 2, 6, 7, 9, 1, 5 ] );;
gap> S := Semigroup(f, One(f));
<commutative partial perm monoid of rank 9 with 1 generator>
gap> IsMonoid(S);
true
gap> IsPartialPermMonoid(S);
true]]></Example>
Note that unlike transformation semigroups, the <Ref Attr="One"/> of a partial permutation semigroup must coincide with the multiplicative neutral element, if either exists.<P/>
For more details see <Ref Filt="IsMagmaWithOne"/>.
</Description>
</ManSection>
<ManSection>
<Attr Name="DegreeOfPartialPermSemigroup" Arg="S"/>
<Attr Name="CodegreeOfPartialPermSemigroup" Arg="S"/>
<Attr Name="RankOfPartialPermSemigroup" Arg="S"/>
<Returns>A non-negative integer.</Returns>
<Description>
The <E>degree</E> of a partial permutation semigroup <A>S</A> is the
largest degree of any partial permutation in <A>S</A>. <P/>
The <E>codegree</E> of a partial permutation semigroup <A>S</A> is the
largest positive integer in its image.<P/>
The <E>rank</E> of a partial permutation semigroup <A>S</A> is the number
of points on which it acts.
<Example><![CDATA[
gap> S := Semigroup( PartialPerm( [ 1, 5 ], [ 10000, 3 ] ) );
<commutative partial perm semigroup of rank 2 with 1 generator>
gap> DegreeOfPartialPermSemigroup(S);
5
gap> CodegreeOfPartialPermSemigroup(S);
10000
gap> RankOfPartialPermSemigroup(S);
2]]></Example>
</Description>
</ManSection>
<ManSection>
<Oper Name="SymmetricInverseSemigroup" Arg="n"/>
<Oper Name="SymmetricInverseMonoid" Arg="n"/>
<Returns>The symmetric inverse semigroup of degree <A>n</A>.</Returns>
<Description>
If <A>n</A> is a non-negative integer, then
<C>SymmetricInverseSemigroup</C> returns the inverse semigroup consisting
of all partial permutations with degree and codegree at most <A>n</A>.
Note that <A>n</A> must be non-negative, but in particular, can equal
<C>0</C>. <P/>
The symmetric inverse semigroup
<Alt Not="Text">
has <M>\sum_{r=0}^n{n\choose r}^2\cdot r!</M>
elements and </Alt>
is generated by any set that of partial permutations that
generate the symmetric group on <A>n</A> points and any partial permutation
of rank <C><A>n</A>-1</C>.<P/>
<C>SymmetricInverseMonoid</C> is a synonym for
<C>SymmetricInverseSemigroup</C>.
<Example><![CDATA[
gap> S := SymmetricInverseSemigroup(5);
<symmetric inverse monoid of degree 5>
gap> Size(S);
1546
gap> GeneratorsOfInverseMonoid(S);
[ (1,2,3,4,5), (1,2)(3)(4)(5), [5,4,3,2,1] ]]]></Example>
</Description>
</ManSection>
<ManSection>
<Prop Name="IsSymmetricInverseSemigroup" Arg='S'/>
<Prop Name="IsSymmetricInverseMonoid" Arg='S'/>
<Returns><K>true</K> or <K>false</K>.</Returns>
<Description>
If the partial perm semigroup <A>S</A> of degree and codegree <A>n</A>
equals the symmetric inverse semigroup on <A>n</A> points, then
<C>IsSymmetricInverseSemigroup</C> return <K>true</K> and otherwise it
returns <K>false</K>.<P/>
<C>IsSymmetricInverseMonoid</C> is a synonym of
<C>IsSymmetricInverseSemigroup</C>. It is common in the literature
for the symmetric inverse monoid to be referred to as the symmetric inverse
semigroup.
<Example><![CDATA[
gap> S := Semigroup(AsPartialPerm((1, 3, 4, 2), 5), AsPartialPerm((1, 3, 5), 5),
> PartialPerm( [ 1, 2, 3, 4 ] ) );
<partial perm semigroup of rank 5 with 3 generators>
gap> IsSymmetricInverseSemigroup(S);
true
gap> S;
<symmetric inverse monoid of degree 5>]]></Example>
</Description>
</ManSection>
<ManSection>
<Attr Name="NaturalPartialOrder" Arg="S"/>
<Attr Name="ReverseNaturalPartialOrder" Arg="S"/>
<Returns>The natural partial order on an inverse semigroup.</Returns>
<Description>
The <E>natural partial order</E> <M>\leq</M> on an inverse semigroup
<A>S</A> is defined by <C>s</C><M>\leq</M><C>t</C> if there exists an
idempotent
<C>e</C> in <A>S</A> such that <C>s=et</C>. Hence if <C>f</C> and
<C>g</C> are partial permutations, then <C>f</C><M>\leq</M><C>g</C> if
and only if <C>f</C> is a restriction of <C>g</C>;
see <Ref Oper="RestrictedPartialPerm"/>.<P/>
<C>NaturalPartialOrder</C> returns the natural partial order on the inverse
semigroup of partial permutations <A>S</A> as a list of sets of positive
integers where entry <C>i</C> in <C>NaturalPartialOrder(<A>S</A>)</C> is
the set of positions in <C>Elements(<A>S</A>)</C> of elements which are
less than <C>Elements(<A>S</A>)[i]</C>. See also
<Ref Func="NaturalLeqPartialPerm"/>.<P/>
<C>ReverseNaturalPartialOrder</C> returns the reverse of the natural
partial order on the inverse semigroup of partial permutations <A>S</A> as
a list of sets of
positive integers where entry <C>i</C> in
<C>ReverseNaturalPartialOrder(<A>S</A>)</C> is the set of positions in
<C>Elements(<A>S</A>)</C> of elements which are greater than
<C>Elements(<A>S</A>)[i]</C>. See also
<Ref Func="NaturalLeqPartialPerm"/>.
<Example><![CDATA[
gap> S := InverseSemigroup([ PartialPerm( [ 1, 3 ], [ 1, 3 ] ),
> PartialPerm( [ 1, 2 ], [ 3, 2 ] ) ] );
<inverse partial perm semigroup of rank 3 with 2 generators>
gap> Size(S);
11
gap> NaturalPartialOrder(S);
[ [ ], [ 1 ], [ 1 ], [ 1 ], [ 1, 2, 4 ], [ 1, 3, 4 ], [ 1 ], [ 1 ],
[ 1, 4, 7 ], [ 1, 4, 8 ], [ 1, 2, 8 ] ]
gap> NaturalLeqPartialPerm(Elements(S)[4], Elements(S)[10]);
true
gap> NaturalLeqPartialPerm(Elements(S)[4], Elements(S)[1]);
false]]></Example>
</Description>
</ManSection>
<ManSection>
<Attr Name="IsomorphismPartialPermSemigroup" Arg="S"/>
<Attr Name="IsomorphismPartialPermMonoid" Arg="S"/>
<Returns>An isomorphism.</Returns>
<Description>
<C>IsomorphismPartialPermSemigroup(<A>S</A>)</C>
returns an isomorphism from the inverse semigroup <A>S</A> to an
inverse semigroup of partial permutations.<P/>
<C>IsomorphismPartialPermMonoid(<A>S</A>)</C> returns an isomorphism from
the inverse semigroup <A>S</A> to an inverse monoid of partial
permutations, if possible.<P/>
We only describe <C>IsomorphismPartialPermMonoid</C>,
the corresponding statements for <C>IsomorphismPartialPermSemigroup</C>
also hold.
<List>
<Mark>Partial permutation semigroups</Mark>
<Item>
If <A>S</A> is a partial permutation semigroup that does not satisfy
<Ref Filt="IsMonoid"/> but where
<C>MultiplicativeNeutralElement(<A>S</A>)<>fail</C>, then
<C>IsomorphismPartialPermMonoid(<A>S</A>)</C> returns an isomorphism
from <A>S</A> to an inverse monoid of partial permutations.
</Item>
<Mark>Permutation groups</Mark>
<Item>
If <A>S</A> is a permutation group, then
<C>IsomorphismPartialPermMonoid</C> returns an isomorphism from
<A>S</A> to an inverse monoid of partial permutations on the set
<C>MovedPoints(<A>S</A>)</C> obtained using
<Ref Meth="AsPartialPerm" Label="for a permutation"/>.
The inverse of this isomorphism is obtained using
<Ref Attr="AsPermutation"/>.
</Item>
<Mark>Transformation semigroups</Mark>
<Item>
If <A>S</A> is a transformation semigroup which is mathematically a
monoid but which does not necessarily belong to the category <Ref Filt
= "IsMonoid"/>, then
<C>IsomorphismPartialPermMonoid</C> returns an isomorphism from
<A>S</A> to an inverse monoid of partial permutations.
</Item>
</List>
<Example><![CDATA[
gap> S := InverseSemigroup(
> PartialPerm( [ 1, 2, 3, 4, 5 ], [ 4, 2, 3, 1, 5 ] ),
> PartialPerm( [ 1, 2, 4, 5 ], [ 3, 1, 4, 2 ] ) );;
gap> IsMonoid(S);
false
gap> Size(S);
508
gap> iso := IsomorphismPartialPermMonoid(S);
MappingByFunction( <inverse partial perm semigroup of size 508,
rank 5 with 2 generators>, <inverse partial perm monoid of size 508,
rank 5 with 2 generators>
, function( object ) ... end, function( object ) ... end )
gap> Size(S);
508
gap> Size(Range(iso));
508
gap> G := Group((1,2)(3,8)(4,6)(5,7), (1,3,4,7)(2,5,6,8), (1,4)(2,6)(3,7)(5,8));;
gap> IsomorphismPartialPermSemigroup(G);
MappingByFunction( Group([ (1,2)(3,8)(4,6)(5,7), (1,3,4,7)
(2,5,6,8), (1,4)(2,6)(3,7)
(5,8) ]), <partial perm group of rank 8 with 3 generators>
, function( p ) ... end, <Attribute "AsPermutation"> )
gap> S := Semigroup(Transformation( [ 2, 5, 1, 7, 3, 7, 7 ] ),
> Transformation( [ 3, 6, 5, 7, 2, 1, 7 ] ) );;
gap> iso := IsomorphismPartialPermMonoid(S);;
gap> MultiplicativeNeutralElement(S) ^ iso;
<identity partial perm on [ 1, 2, 3, 4, 5, 6 ]>
gap> One(Range(iso));
<identity partial perm on [ 1, 2, 3, 4, 5, 6 ]>
gap> MovedPoints(Range(iso));
[ 1 .. 5 ]]]></Example>
</Description>
</ManSection>
</Section>
</Chapter>
|