/usr/share/gap/lib/algebra.gi is in gap-libs 4r7p9-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 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 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 | #############################################################################
##
#W algebra.gi GAP library Thomas Breuer
#W and Willem de Graaf
##
##
#Y Copyright (C) 1997, Lehrstuhl D für Mathematik, RWTH Aachen, Germany
#Y (C) 1998 School Math and Comp. Sci., University of St Andrews, Scotland
#Y Copyright (C) 2002 The GAP Group
##
## This file contains generic methods for algebras and algebras-with-one.
##
#############################################################################
##
#M Representative( <A> ) . . . . . . . . one element of a left operator ring
##
InstallMethod( Representative,
"for left operator ring with known generators",
[ IsLeftOperatorRing and HasGeneratorsOfLeftOperatorRing ],
RepresentativeFromGenerators( GeneratorsOfLeftOperatorRing ) );
#############################################################################
##
#M Representative( <A> ) . . . one element of a left operator ring-with-one
##
InstallMethod( Representative,
"for left operator ring-with-one with known generators",
[ IsLeftOperatorRingWithOne and HasGeneratorsOfLeftOperatorRingWithOne ],
RepresentativeFromGenerators( GeneratorsOfLeftOperatorRingWithOne ) );
#############################################################################
##
#M FLMLORByGenerators( <R>, <gens> ) . . . . <R>-FLMLOR generated by <gens>
#M FLMLORByGenerators( <R>, <gens>, <zero> )
##
InstallMethod( FLMLORByGenerators,
"for ring and collection",
[ IsRing, IsCollection ],
function( R, gens )
local A;
A:= Objectify( NewType( FamilyObj( gens ),
IsFLMLOR and IsAttributeStoringRep ),
rec() );
SetLeftActingDomain( A, R );
SetGeneratorsOfLeftOperatorRing( A, AsList( gens ) );
CheckForHandlingByNiceBasis( R, gens, A, false );
return A;
end );
InstallOtherMethod( FLMLORByGenerators,
"for ring, homogeneous list, and ring element",
[ IsRing, IsHomogeneousList, IsRingElement ],
function( R, gens, zero )
local A;
A:= Objectify( NewType( CollectionsFamily( FamilyObj( zero ) ),
IsFLMLOR and IsAttributeStoringRep ),
rec() );
SetLeftActingDomain( A, R );
SetGeneratorsOfLeftOperatorRing( A, gens );
SetZero( A, zero );
if IsEmpty( gens ) then
SetIsTrivial( A, true );
SetGeneratorsOfLeftModule( A, gens );
fi;
CheckForHandlingByNiceBasis( R, gens, A, zero );
return A;
end );
#############################################################################
##
#M FLMLORWithOneByGenerators( <R>, <gens> ) unit. <R>-FLMLOR gen. by <gens>
#M FLMLORWithOneByGenerators( <R>, <gens>, <zero> )
##
InstallMethod( FLMLORWithOneByGenerators,
"for ring and collection",
[ IsRing, IsCollection ],
function( R, gens )
local A;
A:= Objectify( NewType( FamilyObj( gens ),
IsFLMLORWithOne and IsAttributeStoringRep ),
rec() );
SetLeftActingDomain( A, R );
SetGeneratorsOfLeftOperatorRingWithOne( A, AsList( gens ) );
CheckForHandlingByNiceBasis( R, gens, A, false );
return A;
end );
InstallOtherMethod( FLMLORWithOneByGenerators,
"for ring, homogeneous list, and ring element",
[ IsRing, IsHomogeneousList, IsRingElement ],
function( R, gens, zero )
local A;
A:= Objectify( NewType( CollectionsFamily( FamilyObj( zero ) ),
IsFLMLORWithOne and IsAttributeStoringRep ),
rec() );
SetLeftActingDomain( A, R );
SetGeneratorsOfLeftOperatorRingWithOne( A, AsList( gens ) );
SetZero( A, zero );
CheckForHandlingByNiceBasis( R, gens, A, zero );
return A;
end );
#############################################################################
##
#F Algebra( <F>, <gens> )
#F Algebra( <F>, <gens>, <zero> )
#F Algebra( <F>, <gens>, "basis" )
#F Algebra( <F>, <gens>, <zero>, "basis" )
##
InstallGlobalFunction( FLMLOR, function( arg )
local A;
# ring and list of generators
if Length( arg ) = 2 and IsRing( arg[1] )
and IsList( arg[2] ) and 0 < Length( arg[2] ) then
A:= FLMLORByGenerators( arg[1], arg[2] );
# ring, list of generators plus zero
elif Length( arg ) = 3 and IsRing( arg[1] )
and IsList( arg[2] ) then
if arg[3] = "basis" then
A:= FLMLORByGenerators( arg[1], arg[2] );
UseBasis( A, arg[2] );
else
A:= FLMLORByGenerators( arg[1], arg[2], arg[3] );
fi;
# ring, list of generators plus zero
elif Length( arg ) = 4 and IsRing( arg[1] )
and IsList( arg[2] )
and arg[4] = "basis" then
A:= FLMLORByGenerators( arg[1], arg[2], arg[3] );
UseBasis( A, arg[2] );
# no argument given, error
else
Error( "usage: FLMLOR( <F>, <gens> ), ",
"FLMLOR( <F>, <gens>, <zero> )" );
fi;
# Return the result.
return A;
end );
#############################################################################
##
#F Subalgebra( <A>, <gens> ) . . . . . subalgebra of <A> generated by <gens>
#F Subalgebra( <A>, <gens>, "basis" )
##
InstallGlobalFunction( SubFLMLOR, function( arg )
local S;
if Length( arg ) <= 1
or not IsFLMLOR( arg[1] )
or not IsHomogeneousList( arg[2] ) then
Error( "first argument must be a FLMLOR,\n",
"second argument must be a list of generators" );
elif IsEmpty( arg[2] ) then
return SubFLMLORNC( arg[1], arg[2] );
elif IsIdenticalObj( FamilyObj( arg[1] ),
FamilyObj( arg[2] ) )
and ForAll( arg[2], v -> v in arg[1] ) then
S:= FLMLORByGenerators( LeftActingDomain( arg[1] ), arg[2] );
SetParent( S, arg[1] );
if Length( arg ) = 3 and arg[3] = "basis" then
UseBasis( S, arg[2] );
fi;
return S;
fi;
Error( "usage: SubFLMLOR( <V>, <gens> [, \"basis\"] )" );
end );
#############################################################################
##
#F SubalgebraNC( <A>, <gens>, "basis" )
#F SubalgebraNC( <A>, <gens> )
##
InstallGlobalFunction( SubFLMLORNC, function( arg )
local S;
if IsEmpty( arg[2] ) then
S:= Objectify( NewType( FamilyObj( arg[1] ),
IsFLMLOR
and IsTrivial
and IsTwoSidedIdealInParent
and IsAttributeStoringRep ),
rec() );
SetLeftActingDomain( S, LeftActingDomain( arg[1] ) );
SetGeneratorsOfLeftModule( S, AsList( arg[2] ) );
else
S:= FLMLORByGenerators( LeftActingDomain( arg[1] ), arg[2] );
fi;
if Length( arg ) = 3 and arg[3] = "basis" then
UseBasis( S, arg[2] );
fi;
SetParent( S, arg[1] );
return S;
end );
#############################################################################
##
#F AlgebraWithOne( <F>, <gens> )
#F AlgebraWithOne( <F>, <gens>, <zero> )
#F AlgebraWithOne( <F>, <gens>, "basis" )
#F AlgebraWithOne( <F>, <gens>, <zero>, "basis" )
##
InstallGlobalFunction( FLMLORWithOne, function( arg )
local A;
# ring and list of generators
if Length( arg ) = 2 and IsRing( arg[1] )
and IsList( arg[2] ) and 0 < Length( arg[2] ) then
A:= FLMLORWithOneByGenerators( arg[1], arg[2] );
# ring, list of generators plus zero
elif Length( arg ) = 3 and IsRing( arg[1] )
and IsList( arg[2] ) then
if arg[3] = "basis" then
A:= FLMLORWithOneByGenerators( arg[1], arg[2] );
UseBasis( A, arg[2] );
else
A:= FLMLORWithOneByGenerators( arg[1], arg[2], arg[3] );
fi;
# ring, list of generators plus zero
elif Length( arg ) = 4 and IsRing( arg[1] )
and IsList( arg[2] )
and arg[4] = "basis" then
A:= FLMLORWithOneByGenerators( arg[1], arg[2], arg[3] );
UseBasis( A, arg[2] );
# no argument given, error
else
Error( "usage: FLMLORWithOne( <F>, <gens> ), ",
"FLMLORWithOne( <F>, <gens>, <zero> )" );
fi;
# Return the result.
return A;
end );
#############################################################################
##
#F SubalgebraWithOne( <A>, <gens> ) subalg.-with-one of <A> gen. by <gens>
##
InstallGlobalFunction( SubFLMLORWithOne, function( arg )
local S;
if Length( arg ) <= 1 or not IsFLMLOR( arg[1] )
or not IsHomogeneousList( arg[2] ) then
Error( "first argument must be a FLMLOR,\n",
"second argument must be a list of generators" );
elif IsEmpty( arg[2] ) then
return SubFLMLORWithOneNC( arg[2], arg[2] );
elif IsIdenticalObj( FamilyObj( arg[1] ),
FamilyObj( arg[2] ) )
and ForAll( arg[2], v -> v in arg[1] )
and ( IsFLMLORWithOne( arg[1] ) or One( arg[1] ) <> fail ) then
S:= FLMLORWithOneByGenerators( LeftActingDomain( arg[1] ), arg[2] );
SetParent( S, arg[1] );
if Length( arg ) = 3 and arg[3] = "basis" then
UseBasis( S, arg[2] );
fi;
return S;
fi;
Error( "usage: SubFLMLORWithOne( <V>, <gens> [, \"basis\"] )" );
end );
#############################################################################
##
#F SubalgebraWithOneNC( <A>, <gens> )
##
InstallGlobalFunction( SubFLMLORWithOneNC, function( arg )
local S, gens;
if IsEmpty( arg[2] ) then
# Note that `S' is in general not trivial,
# and if we call `Objectify' here then `S' does not get a special
# representation (e.g., as a matrix algebra).
# So the argument that special methods would catch this case
# does not hold!
gens:= [ One( arg[1] ) ];
S:= FLMLORWithOneByGenerators( LeftActingDomain( arg[1] ), gens );
UseBasis( S, gens );
else
S:= FLMLORWithOneByGenerators( LeftActingDomain( arg[1] ), arg[2] );
if Length( arg ) = 3 and arg[3] = "basis" then
UseBasis( S, arg[2] );
fi;
fi;
SetParent( S, arg[1] );
return S;
end );
#############################################################################
##
#M LieAlgebraByDomain( <A> )
##
## The Lie algebra of the associative algebra <A>
##
InstallMethod( LieAlgebraByDomain,
"for an algebra",
[ IsAlgebra ],
function( A )
local T, n, zero, nullvec, S, i, j, k, m, cfs, cij, cji;
if not IsAssociative( A ) then TryNextMethod(); fi;
# We construct a structure constants table for the Lie algebra
# corresponding to <A>. If the structure constants of <A> are given by
# d_{ij}^k, then the structure constants of the Lie algebra will be given
# by d_{ij}^k - d_{ji}^k.
T:= StructureConstantsTable( Basis( A ) );
n:= Dimension( A );
zero:= Zero( LeftActingDomain( A ) );
nullvec:= List( [1..n], x -> zero );
S:= EmptySCTable( n, zero, "antisymmetric" );
for i in [1..n] do
for j in [i+1..n] do
cfs:= ShallowCopy( nullvec );
cij:= T[i][j]; cji:= T[j][i];
for m in [1..Length(cij[1])] do
k:= cij[1][m];
cfs[k]:= cfs[k] + cij[2][m];
od;
for m in [1..Length(cji[1])] do
k:= cji[1][m];
cfs[k]:= cfs[k] - cji[2][m];
od;
cij:= [ ];
for m in [1..n] do
if cfs[m] <> zero then
Add( cij, cfs[m] );
Add( cij, m );
fi;
od;
SetEntrySCTable( S, i, j, cij );
od;
od;
return LieAlgebraByStructureConstants( LeftActingDomain( A ), S );
end );
#############################################################################
##
#F LieAlgebra( <A> )
#F LieAlgebra( <F>, <gens> )
#F LieAlgebra( <F>, <gens>, <zero> )
#F LieAlgebra( <F>, <gens>, "basis" )
#F LieAlgebra( <F>, <gens>, <zero>, "basis" )
##
InstallGlobalFunction( LieAlgebra, function( arg )
#T check that the families have the same characteristic?
#T `CharacteristicFamily' ?
local A,gens;
# In the case of one domain argument,
# construct the isomorphic Lie algebra.
if Length( arg ) = 1 and IsDomain( arg[1] ) then
A:= LieAlgebraByDomain( arg[1] );
# division ring and list of generators
elif Length( arg ) >= 2 and IsList( arg[2] ) then
gens:= List( arg[2], x -> LieObject( x ) );
if Length( arg ) = 2 and IsDivisionRing( arg[1] )
and 0 < Length( arg[2] ) then
A:= AlgebraByGenerators( arg[1], gens );
# division ring, list of generators plus zero
elif Length( arg ) = 3 and IsDivisionRing( arg[1] ) then
if arg[3] = "basis" then
A:= AlgebraByGenerators( arg[1], gens );
UseBasis( A, gens );
else
A:= AlgebraByGenerators( arg[1], gens, arg[3] );
fi;
# division ring, list of generators plus zero
elif Length( arg ) = 4 and IsDivisionRing( arg[1] )
and arg[4] = "basis" then
A:= AlgebraByGenerators( arg[1], gens, arg[3] );
UseBasis( A, gens );
else
Error( "usage: LieAlgebra( <F>, <gens> ), ",
"LieAlgebra( <F>, <gens>, <zero> ), LieAlgebra( <D> )");
fi;
# no argument given, error
else
Error( "usage: LieAlgebra( <F>, <gens> ), ",
"LieAlgebra( <F>, <gens>, <zero> ), LieAlgebra( <D> )");
fi;
# Return the result.
return A;
end );
#############################################################################
##
#F EmptySCTable( <dim>, <zero> )
#F EmptySCTable( <dim>, <zero>, \"symmetric\" )
#F EmptySCTable( <dim>, <zero>, \"antisymmetric\" )
##
InstallGlobalFunction( EmptySCTable, function( arg )
local dim, T, entry, i;
if 2 <= Length( arg )
and IsInt( arg[1] ) and IsZero( arg[2] )
and ( Length( arg ) = 2 or IsString( arg[3] ) ) then
dim:= arg[1];
T:= [];
entry:= Immutable( [ [], [] ] );
for i in [ 1 .. dim ] do
T[i]:= List( [ 1 .. dim ], x -> entry );
od;
# Store the symmetry flag.
if Length( arg ) = 3 then
if arg[3] = "symmetric" then
Add( T, 1 );
elif arg[3] = "antisymmetric" then
Add( T, -1 );
else
Error("third argument must be \"symmetric\" or \"antisymmetric\"");
fi;
else
Add( T, 0 );
fi;
# Store the zero coefficient.
Add( T, arg[2] );
else
Error( "usage: EmptySCTable( <dim>, <zero> [,\"symmetric\"] )" );
fi;
return T;
end );
#############################################################################
##
#F SetEntrySCTable( <T>, <i>, <j>, <list> )
##
InstallGlobalFunction( SetEntrySCTable, function( T, i, j, list )
local range, zero, Fam, entry, k, val, pos;
# Check that `i' and `j' are admissible.
range:= [ 1 .. Length( T ) - 2 ];
if not i in range then
Error( "<i> must lie in ", range );
elif not j in range then
Error( "<j> must lie in ", range );
fi;
# Check `list', and construct the table entry.
zero:= T[ Length( T ) ];
Fam:= FamilyObj( zero );
entry:= [ [], [] ];
for k in [ 1, 3 .. Length( list ) -1 ] do
val:= list[k];
pos:= list[k+1];
# Check that `pos' is inside the table,
# and that its entry is assigned only once.
if not pos in range then
Error( "list entry ", list[k+1], " must lie in ", range );
elif pos in entry[1] then
Error( "position ", pos, " must occur at most once in <list>" );
fi;
# Check that the coefficients either fit to the zero element
# or are rationals (with suitable denominators).
if FamilyObj( val ) = Fam then
if val <> zero then
Add( entry[1], pos );
Add( entry[2], val );
fi;
elif IsRat( val ) then
if val <> 0 then
Add( entry[1], pos );
Add( entry[2], val * One( zero ) );
fi;
else
Error( "list entry ", list[k], " does not fit to zero element" );
fi;
od;
# Set the table entry.
SortParallel( entry[1], entry[2] );
T[i][j]:= Immutable( entry );
# Add the value `T[j][i]' in the case of (anti-)symmetric tables.
if T[ Length(T) - 1 ] = 1 then
T[j][i]:= T[i][j];
elif T[ Length(T) - 1 ] = -1 then
T[j][i]:= Immutable( [ entry[1], -entry[2] ] );
fi;
end );
#############################################################################
##
#F ReducedSCTable( <T>, <one> )
##
InstallGlobalFunction( ReducedSCTable, function( T, one )
local new, n, i, j, entry;
new:= [];
n:= Length( T ) - 2;
# Reduce the entries.
for i in [ 1 .. n ] do
new[i]:= [];
for j in [ 1 .. n ] do
entry:= T[i][j];
entry:= [ Immutable( entry[1] ), entry[2] * one ];
MakeImmutable( entry );
new[i][j]:= entry;
od;
od;
# Store zero coefficient and symmetry flag.
new[ n+1 ]:= T[ n+1 ];
new[ n+2 ]:= T[ n+2 ] * one;
# Return the immutable new table.
MakeImmutable( new );
return new;
end );
#############################################################################
##
#F GapInputSCTable( <T>, <varnam> )
##
InstallGlobalFunction( GapInputSCTable, function( T, varnam )
local dim, str, lower, i, j, entry, k;
# Initialize, and set the ranges for the loops.
dim:= Length( T ) - 2;
str:= Concatenation( varnam, ":= EmptySCTable( ",
String( dim ), ", ", String( T[ Length( T ) ] ) );
lower:= [ 1 .. dim ];
if T[ dim+1 ] = 1 then
Append( str, ", \"symmetric\"" );
elif T[ dim+1 ] = -1 then
Append( str, ", \"antisymmetric\"" );
else
lower:= ListWithIdenticalEntries( dim, 1 );
fi;
Append( str, " );\n" );
# Fill up the table.
for i in [ 1 .. dim ] do
for j in [ lower[i] .. dim ] do
entry:= T[i][j];
if not IsEmpty( entry[1] ) then
Append( str, "SetEntrySCTable( " );
Append( str, varnam );
Append( str, ", " );
Append( str, String(i) );
Append( str, ", " );
Append( str, String(j) );
Append( str, ", [" );
for k in [ 1 .. Length( entry[1] )-1 ] do
Append( str, String( entry[2][k] ) );
Add( str, ',' );
Append( str, String( entry[1][k] ) );
Add( str, ',' );
od;
k:= Length( entry[1] );
Append( str, String( entry[2][k] ) );
Add( str, ',' );
Append( str, String( entry[1][k] ) );
Append( str, "] );\n" );
fi;
od;
od;
ConvertToStringRep( str );
return str;
end );
#############################################################################
##
#F IdentityFromSCTable( <T> )
##
InstallGlobalFunction( IdentityFromSCTable, function( T )
local n, # dimension of the underlying algebra
equ, # equation system to solve
zero, # zero of the field
zerovec, # zero vector
vec, # right hand side of the equation system
one, # identity of the field
i, j, k, # loop over rows of `equ'
row, # one row of the equation system
Tpos, #
Tval, #
p, #
sol,
sum;
n:= Length( T ) - 2;
zero:= T[ n+2 ];
# If the table belongs to a trivial algebra,
# the identity is equal to the zero.
if n = 0 then
return EmptyRowVector( FamilyObj( zero ) );
fi;
# Set up the equation system,
# in row $i$ and column $(k-1)*n + j$ we have $c_{ijk}$.
equ:= [];
zerovec:= ListWithIdenticalEntries( n^2, zero );
vec:= ShallowCopy( zerovec );
one:= One( zero );
for i in [ 1 .. n ] do
row:= ShallowCopy( zerovec );
for j in [ 1 .. n ] do
Tpos:= T[i][j][1];
Tval:= T[i][j][2];
p:= (j-1)*n;
for k in [ 1 .. Length( Tpos ) ] do
row[ p + Tpos[k] ]:= Tval[k];
od;
od;
Add( equ, row );
vec[ (i-1)*n + i ]:= one;
od;
sol:= SolutionMat( equ, vec );
# If we have a candidate and if the algebra is not known
# to be commutative then check whether the candidate
# acts trivially also from the right.
if sol <> fail and T[ n+1 ] <> 1 then
for j in [ 1 .. n ] do
for k in [ 1 .. n ] do
sum:= zero;
for i in [ 1 .. n ] do
Tpos:= T[j][i];
p:= Position( Tpos[1], k );
#T cheaper !!!
if p <> fail then
sum:= sum + sol[i] * Tpos[2][p];
fi;
od;
if ( j = k and sum <> one ) or ( j <> k and sum <> zero ) then
return fail;
fi;
od;
od;
fi;
# Return the result.
return sol;
end );
#############################################################################
##
#F QuotientFromSCTable( <T>, <num>, <den> )
##
## We solve the equation system $<num> = x <den>$.
## If no solution exists, `fail' is returned.
##
## In terms of the basis $B$ with vectors $b_1, \ldots, b_n$ this means
## for $<num> = \sum_{i=1}^n a_i b_i$,
## $<den> = \sum_{i=1}^n c_i b_i$,
## $x = \sum_{i=1}^n x_i b_i$ that
## $a_k = \sum_{i,j} c_i x_j c_{ijk}$ for all $k$.
## Here $c_{ijk}$ denotes the structure constants w.r.t. $B$.
## This means $a = x M$ with $M_{ik} = \sum_{j=1}^n c_{ijk} c_j$.
##
InstallGlobalFunction( QuotientFromSCTable, function( T, x, c )
local M, # matrix of the equation system
n, # dimension of the algebra
zero, # zero vector
i, j, # loop variables
row, # one row of `M'
entry, #
val; #
M:= [];
n:= Length( c );
# If the algebra is zero dimensional,
# the zero is also the identity and thus also its inverse.
if n = 0 then
return c;
fi;
zero:= ListWithIdenticalEntries( n, T[ Length( T ) ] );
for i in [ 1 .. n ] do
row:= ShallowCopy( zero );
for j in [ 1 .. n ] do
entry:= T[i][j];
val:= c[j];
row{ entry[1] }:= row{ entry[1] } + val * entry[2];
#T better!
od;
Add( M, row );
od;
# Return the quotient, or `fail'.
return SolutionMat( M, x );
end );
#############################################################################
##
#F TestJacobi( <T> )
##
## We check whether for all $1 \leq m \leq n$ the equality
## $\sum_{l=1}^n c_{jkl} c_{ilm} + c_{kil} c_{jlm} + c_{ijl} c_{klm} = 0$
## holds.
##
InstallGlobalFunction( TestJacobi, function( T )
local zero, # the zero of the field
n, # dimension of the algebra
i, j, k, m, # loop variables
cij, cki, cjk, # structure constant vectors
sum,
t;
zero:= T[ Length( T ) ];
n:= Length( T ) - 2;
for i in [ 1 .. n ] do
for j in [ i+1 .. n ] do
cij:= T[i][j];
for k in [ j+1 .. n ] do
cki:= T[k][i];
cjk:= T[j][k];
for m in [ 1 .. n ] do
sum:= zero;
for t in [ 1 .. Length( cjk[1] ) ] do
sum:= sum + cjk[2][t] * SCTableEntry( T, i, cjk[1][t], m );
od;
for t in [ 1 .. Length( cki[1] ) ] do
sum:= sum + cki[2][t] * SCTableEntry( T, j, cki[1][t], m );
od;
for t in [ 1 .. Length( cij[1] ) ] do
sum:= sum + cij[2][t] * SCTableEntry( T, k, cij[1][t], m );
od;
if sum <> zero then
return [ i, j, k ];
fi;
od;
od;
od;
od;
return true;
end );
#############################################################################
##
#M MultiplicativeNeutralElement( <A> )
##
## is the multiplicative neutral element of <A> if this exists,
## otherwise is `fail'.
##
## Let $(b_1, b_2, \ldots, b_n)$ be a basis of $A$, and $e$ the result of
## `MultiplicativeNeutralElement( <A> )'.
## Then $e = \sum_{i=1}^n a_i b_i$, and for $1 \leq k \leq n$ we have
## $e \cdot b_j = b_j$, or equivalently
## $\sum_{i=1}^n a_i b_i \cdot b_j = b_j$.
## Define the structure constants by
## $b_i \cdot b_j = \sum_{k=1}^n c_{ijk} b_k$.
##
## Then $\sum_{i=1}^n a_i c_{ijk} = \delta_{jk}$ for $1 \leq k \leq n$.
##
## This yields $n^2$ linear equations for the $n$ indeterminates $a_i$,
## and a solution is a left identity.
## For this we have to test whether it is also a right identity.
##
InstallMethod( MultiplicativeNeutralElement,
[ IsFLMLOR and IsFiniteDimensional ],
function( A )
local B, # basis of `A'
one; # result
B:= Basis( A );
one:= IdentityFromSCTable( StructureConstantsTable( B ) );
if one <> fail then
one:= LinearCombination( B, one );
fi;
return one;
end );
#############################################################################
##
#M IsAssociative( <A> )
##
## We check whether the vectors of a basis satisfy the associativity law.
## (Bilinearity of the multiplication is of course assumed.)
##
## If $b_i \cdot b_j = \sum_{l=1}^n c_{ijl} b_l$ then we have
## $b_i \cdot ( b_j \cdot b_k ) = ( b_i \cdot b_j ) \cdot b_k$
## if and only if
## $\sum_{l=1}^n c_{jkl} c_{ilm} = \sum_{l=1}^n c_{ijl} c_{lkm}$ for all
## $1 \leq m \leq n$.
##
## We check this equality for all $1 \leq i, j, k \leq n$.
##
InstallMethod( IsAssociative,
"generic method for a (finite dimensional) FLMLOR",
[ IsFLMLOR ],
function( A )
local T, # structure constants table w.r.t. a basis of `A'
zero,
range,
i, j, k, l, m,
Ti,
Tj,
cijpos,
cijval,
cjkpos,
cjkval,
sum,
x,
pos;
if not IsFiniteDimensional( A ) then
TryNextMethod();
fi;
T:= StructureConstantsTable( Basis( A ) );
zero:= Zero( LeftActingDomain( A ) );
range:= [ 1 .. Length( T[1] ) ];
for i in range do
Ti:= T[i];
for j in range do
cijpos:= Ti[j][1];
cijval:= Ti[j][2];
Tj:= T[j];
for k in range do
cjkpos:= Tj[k][1];
cjkval:= Tj[k][2];
for m in range do
sum:= zero;
for l in [ 1 .. Length( cjkpos ) ] do
x:= Ti[ cjkpos[l] ];
pos:= Position( x[1], m );
if pos <> fail then
sum:= sum + cjkval[l] * x[2][ pos ];
fi;
od;
for l in [ 1 .. Length( cijpos ) ] do
x:= T[ cijpos[l] ][k];
pos:= Position( x[1], m );
if pos <> fail then
sum:= sum - cijval[l] * x[2][ pos ];
fi;
od;
if sum <> zero then
# $i, j, k$ fail
Info( InfoAlgebra, 2,
"IsAssociative fails for i = ", i, ", j = ", j,
", k = ", k );
return false;
fi;
od;
od;
od;
od;
return true;
end );
#############################################################################
##
#M IsAnticommutative( <A> ) . . . . . . . . . . . . .for a fin.-dim. FLMLOR
##
## is `true' if the multiplication in <A> is anticommutative,
## and `false' otherwise.
##
InstallMethod( IsAnticommutative,
"generic method for a (finite dimensional) FLMLOR",
[ IsFLMLOR ],
function( A )
local n, # dimension of `A'
T, # table of structure constants for `A'
zero, # zero coefficient
i, j; # loop over rows and columns ot `T'
if not IsFiniteDimensional( A ) then
TryNextMethod();
fi;
n:= Dimension( A );
T:= StructureConstantsTable( Basis( A ) );
zero:= T[ n+2 ];
for i in [ 2 .. n ] do
for j in [ 1 .. i-1 ] do
if T[i][j][1] <> T[j][i][1]
or ( not IsEmpty( T[i][j][1] )
and PositionNot( T[i][j][2] + T[j][i][2], zero )
<= Length( T[i][j][2] ) ) then
return false;
fi;
od;
od;
if Characteristic( A ) <> 2 then
# The values on the diagonal must be zero.
for i in [ 1 .. n ] do
if not IsEmpty( T[i][i][1] ) then
return false;
fi;
od;
fi;
return true;
end );
#############################################################################
##
#M IsCommutative( <A> ) . . . . . . . . . . . for finite dimensional FLMLOR
##
## Check whether every basis vector commutes with every basis vector.
##
InstallMethod( IsCommutative,
"generic method for a finite dimensional FLMLOR",
[ IsFLMLOR ],
IsCommutativeFromGenerators( GeneratorsOfVectorSpace ) );
#T use structure constants!
#############################################################################
##
#M IsCommutative( <A> ) . . . . . . . . . . . . . for an associative FLMLOR
##
## If <A> is associative then we can restrict the check to a smaller
## equation system than that for arbitrary algebras, since we have to check
## $x a = a x$ only for algebra generators $a$ and $x$, not for all vectors
## of a basis.
##
InstallMethod( IsCommutative,
"for an associative FLMLOR",
[ IsFLMLOR and IsAssociative ],
IsCommutativeFromGenerators( GeneratorsOfAlgebra ) );
InstallMethod( IsCommutative,
"for an associative FLMLOR-with-one",
[ IsFLMLORWithOne and IsAssociative ],
IsCommutativeFromGenerators( GeneratorsOfAlgebraWithOne ) );
#############################################################################
##
#M IsZeroSquaredRing( <A> ) . . . . . . . . for a finite dimensional FLMLOR
##
InstallMethod( IsZeroSquaredRing,
"for a finite dimensional FLMLOR",
[ IsFLMLOR ],
function( A )
if not IsAnticommutative( A ) then
# Every zero squared ring is anticommutative.
return false;
elif ForAny( BasisVectors( Basis( A ) ),
x -> not IsZero( x*x ) ) then
# If not all basis vectors are zero squared then we return `false'.
return false;
elif IsCommutative( LeftActingDomain( A ) ) then
# If otherwise the left acting domain is commutative then we return
# `true' because we know that <A> is anticommutative and the basis
# vectors are zero squared.
return true;
else
# Otherwise we give up.
TryNextMethod();
fi;
end );
#############################################################################
##
#M IsJacobianRing( <A> )
##
InstallMethod( IsJacobianRing,
"for a (finite dimensional) FLMLOR",
[ IsFLMLOR ],
function( A )
local n, # dimension of `A'
T, # table of structure constants for `A'
i; # loop over the diagonal of `T'
if not IsFiniteDimensional( A ) then
TryNextMethod();
fi;
# In characteristic 2 we have to make sure that $a \* a = 0$.
#T really?
T:= StructureConstantsTable( Basis( A ) );
if Characteristic( A ) = 2 then
n:= Dimension( A );
for i in [ 1 .. n ] do
if not IsEmpty( T[i][i][1] ) then
return false;
fi;
od;
fi;
# Check the Jacobi identity $[a,[b,c]] + [b,[c,a]] + [c,[a,b]] = 0$.
return TestJacobi( T ) = true;
end );
#############################################################################
##
#M Intersection2( <A1>, <A2> ) . . . . . . . . . intersection of two FLMLORs
##
InstallMethod( Intersection2,
"generic method for two FLMLORs",
IsIdenticalObj,
[ IsFLMLOR, IsFLMLOR ],
Intersection2Spaces( AsFLMLOR, SubFLMLORNC, FLMLOR ) );
#############################################################################
##
#M Intersection2( <A1>, <A2> ) . . . . intersection of two FLMLORs-with-one
##
InstallMethod( Intersection2,
"generic method for two FLMLORs-with-one",
IsIdenticalObj,
[ IsFLMLORWithOne, IsFLMLORWithOne ],
Intersection2Spaces( AsFLMLORWithOne, SubFLMLORWithOneNC,
FLMLORWithOne ) );
#############################################################################
##
#M \/( <A>, <I> ) . . . . . . . . . . . . factor of an algebra by an ideal
#M \/( <A>, <relators> ) . . . . . . . . . factor of an algebra by an ideal
##
## is the factor algebra of the finite dimensional algebra <A> modulo
## the ideal <I> or the ideal spanned by the collection <relators>.
##
InstallOtherMethod( \/,
"for FLMLOR and collection",
IsIdenticalObj,
[ IsFLMLOR, IsCollection ],
function( A, relators )
if IsFLMLOR( relators ) then
TryNextMethod();
else
return A / TwoSidedIdealByGenerators( A, relators );
fi;
end );
InstallOtherMethod( \/,
"for FLMLOR and empty list",
[ IsFLMLOR, IsList and IsEmpty ],
function( A, empty )
# `NaturalHomomorphismByIdeal( A, TrivialSubFLMLOR( A ) )' is the
# identity mapping on `A', and `ImagesSource' of it yields `A'.
return A;
end );
InstallOtherMethod( \/,
"generic method for two FLMLORs",
IsIdenticalObj,
[ IsFLMLOR, IsFLMLOR ],
function( A, I )
return ImagesSource( NaturalHomomorphismByIdeal( A, I ) );
end );
#############################################################################
##
#M TrivialSubadditiveMagmaWithZero( <A> ) . . . . . . . . . . for a FLMLOR
##
InstallMethod( TrivialSubadditiveMagmaWithZero,
"for a FLMLOR",
[ IsFLMLOR ],
A -> SubFLMLORNC( A, [] ) );
#############################################################################
##
#M AsFLMLOR( <R>, <D> ) . . view a collection as a FLMLOR over the ring <R>
##
InstallMethod( AsFLMLOR,
"for a ring and a collection",
[ IsRing, IsCollection ],
function( F, D )
local A, L;
D:= AsSSortedList( D );
L:= ShallowCopy( D );
A:= TrivialSubFLMLOR( AsFLMLOR( F, D ) );
SubtractSet( L, AsSSortedList( A ) );
while 0 < Length(L) do
A:= ClosureLeftOperatorRing( A, L[1] );
#T call explicit function that maintains an elements list?
SubtractSet( L, AsSSortedList( A ) );
od;
if Length( AsList( A ) ) <> Length( D ) then
return fail;
fi;
A:= FLMLOR( F, GeneratorsOfLeftOperatorRing( A ), Zero( D[1] ) );
SetAsSSortedList( A, D );
SetSize( A, Length( D ) );
SetIsFinite( A, true );
#T ?
# Return the FLMLOR.
return A;
end );
#############################################################################
##
#M AsFLMLOR( <F>, <V> ) . . view a left module as FLMLOR over the field <F>
##
## is an algebra over <F> that is equal (as set) to <V>.
## For that, perhaps the field of <A> has to be changed before
## getting the correct list of generators.
##
InstallMethod( AsFLMLOR,
"for a division ring and a free left module",
[ IsDivisionRing, IsFreeLeftModule ],
function( F, V )
local L, A;
if LeftActingDomain( V ) = F then
A:= FLMLOR( F, GeneratorsOfLeftModule( V ) );
if A <> V then
return fail;
fi;
if HasBasis( V ) then
SetBasis( A, Basis( V ) );
fi;
elif IsTrivial( V ) then
# We need the zero.
A:= FLMLOR( F, [], Zero( V ) );
elif IsSubset( LeftActingDomain( V ), F ) then
# Make sure that the field change does not change the elements.
L:= BasisVectors( Basis( AsField( F, LeftActingDomain(V) ) ) );
L:= Concatenation( List( L, x -> List( GeneratorsOfLeftModule( V ),
y -> x * y ) ) );
A:= FLMLOR( F, L );
if A <> V then
return fail;
fi;
elif IsSubset( F, LeftActingDomain( V ) ) then
# Make sure that the field change does not change the elements.
L:= BasisVectors( Basis( AsField( LeftActingDomain(V), F ) ) );
if ForAny( L, x -> ForAny( GeneratorsOfLeftModule( V ),
y -> not x * y in V ) ) then
return fail;
fi;
A:= FLMLOR( F, GeneratorsOfLeftModule( V ) );
if A <> V then
return fail;
fi;
else
V:= AsFLMLOR( Intersection( F, LeftActingDomain( V ) ), V );
return AsFLMLOR( F, V );
fi;
UseIsomorphismRelation( V, A );
UseSubsetRelation( V, A );
return A;
end );
#############################################################################
##
#M AsFLMLOR( <F>, <A> ) . . . view an algebra as algebra over the field <F>
##
## is an algebra over <F> that is equal (as set) to <D>.
## For that, perhaps the field of <A> has to be changed before
## getting the correct list of generators.
##
InstallMethod( AsFLMLOR,
"for a division ring and an algebra",
[ IsDivisionRing, IsFLMLOR ],
function( F, D )
local L, A;
if LeftActingDomain( D ) = F then
return D;
elif IsTrivial( D ) then
# We need the zero.
A:= FLMLOR( F, [], Zero( D ) );
elif IsSubset( LeftActingDomain( D ), F ) then
# Make sure that the field change does not change the elements.
L:= BasisVectors( Basis( AsField( F, LeftActingDomain(D) ) ) );
L:= Concatenation( List( L, x -> List( GeneratorsOfAlgebra( D ),
y -> x * y ) ) );
A:= FLMLOR( F, L );
elif IsSubset( F, LeftActingDomain( D ) ) then
# Make sure that the field change does not change the elements.
L:= BasisVectors( Basis( AsField( LeftActingDomain(D), F ) ) );
if ForAny( L, x -> ForAny( GeneratorsOfAlgebra( D ),
y -> not x * y in D ) ) then
return fail;
fi;
A:= FLMLOR( F, GeneratorsOfAlgebra( D ) );
else
D:= AsFLMLOR( Intersection( F, LeftActingDomain( D ) ), D );
return AsFLMLOR( F, D );
fi;
UseIsomorphismRelation( D, A );
UseSubsetRelation( D, A );
return A;
end );
#############################################################################
##
#M AsFLMLORWithOne( <R>, <D> ) . . . . . . view a coll. as a FLMLOR-with-one
##
InstallMethod( AsFLMLORWithOne,
"for a ring and a collection",
[ IsRing, IsCollection ],
function( F, D )
return AsFLMLORWithOne( AsFLMLOR( F, D ) );
end );
#############################################################################
##
#M AsFLMLORWithOne( <F>, <V> ) . . view a left module as a algebra-with-one
##
InstallMethod( AsFLMLORWithOne,
"for a division ring and a free left module",
[ IsDivisionRing, IsFreeLeftModule ],
function( F, V )
local L, A;
# Check that `V' contains the identity.
if One( V ) = fail then
return fail;
elif LeftActingDomain( V ) = F then
A:= FLMLORWithOne( F, GeneratorsOfLeftModule( V ) );
if A <> V then
return fail;
fi;
# Left module generators and basis are maintained.
if HasGeneratorsOfLeftModule( V ) then
SetGeneratorsOfLeftModule( A, GeneratorsOfLeftModule( V ) );
fi;
if HasBasis( V ) then
SetBasis( A, Basis( V ) );
fi;
elif IsSubset( LeftActingDomain( V ), F ) then
# Make sure that the field change does not change the elements.
L:= BasisVectors( Basis( AsField( F, LeftActingDomain(V) ) ) );
L:= Concatenation( List( L, x -> List( GeneratorsOfLeftModule( V ),
y -> x * y ) ) );
A:= FLMLORWithOne( F, L );
if A <> V then
return fail;
fi;
elif IsSubset( F, LeftActingDomain( V ) ) then
# Make sure that the field change does not change the elements.
L:= BasisVectors( Basis( AsField( LeftActingDomain(V), F ) ) );
if ForAny( L, x -> ForAny( GeneratorsOfLeftModule( V ),
y -> not x * y in V ) ) then
return fail;
fi;
A:= FLMLORWithOne( F, GeneratorsOfLeftModule( V ) );
if A <> V then
return fail;
fi;
else
# Note that we need not use the isomorphism and subset relations
# (see below) because this is the task of the calls to
# `AsAlgebraWithOne'.
A:= AsAlgebraWithOne( Intersection( F, LeftActingDomain( V ) ), V );
return AsAlgebraWithOne( F, A );
fi;
UseIsomorphismRelation( V, A );
UseSubsetRelation( V, A );
return A;
end );
#############################################################################
##
#M AsFLMLORWithOne( <F>, <D> ) . . . . view an algebra as a algebra-with-one
##
InstallMethod( AsFLMLORWithOne,
"for a division ring and an algebra",
[ IsDivisionRing, IsFLMLOR ],
function( F, D )
local L, A;
# Check that `D' contains the identity.
if One( D ) = fail then
return fail;
elif LeftActingDomain( D ) = F then
A:= FLMLORWithOne( F, GeneratorsOfLeftOperatorRing( D ) );
# Left module generators and basis are maintained.
if HasGeneratorsOfLeftModule( D ) then
SetGeneratorsOfLeftModule( A, GeneratorsOfLeftModule( D ) );
fi;
if HasBasis( D ) then
SetBasis( A, Basis( D ) );
fi;
elif IsSubset( LeftActingDomain( D ), F ) then
# Make sure that the field change does not change the elements.
L:= BasisVectors( Basis( AsField( F, LeftActingDomain(D) ) ) );
L:= Concatenation( List( L, x -> List( GeneratorsOfAlgebra( D ),
y -> x * y ) ) );
A:= FLMLORWithOne( F, L );
elif IsSubset( F, LeftActingDomain( D ) ) then
# Make sure that the field change does not change the elements.
L:= BasisVectors( Basis( AsField( LeftActingDomain(D), F ) ) );
if ForAny( L, x -> ForAny( GeneratorsOfAlgebra( D ),
y -> not x * y in D ) ) then
return fail;
fi;
A:= FLMLORWithOne( F, GeneratorsOfLeftOperatorRing( D ) );
else
# Note that we need not use the isomorphism and subset relations
# (see below) because this is the task of the calls to
# `AsAlgebraWithOne'.
D:= AsAlgebraWithOne( Intersection( F, LeftActingDomain( D ) ), D );
return AsAlgebraWithOne( F, D );
fi;
UseIsomorphismRelation( D, A );
UseSubsetRelation( D, A );
return A;
end );
#############################################################################
##
#M AsFLMLORWithOne( <F>, <D> ) . . view an alg.-with-one as an alg.-with-one
##
InstallMethod( AsFLMLORWithOne,
"for a division ring and a algebra-with-one",
[ IsDivisionRing, IsFLMLORWithOne ],
function( F, D )
local L, A;
if LeftActingDomain( D ) = F then
return D;
elif IsSubset( LeftActingDomain( D ), F ) then
# Make sure that the field change does not change the elements.
L:= BasisVectors( Basis( AsField( F, LeftActingDomain(D) ) ) );
L:= Concatenation( List( L, x -> List( GeneratorsOfAlgebra( D ),
y -> x * y ) ) );
A:= AlgebraWithOne( F, L );
elif IsSubset( F, LeftActingDomain( D ) ) then
# Make sure that the field change does not change the elements.
L:= BasisVectors( Basis( AsField( LeftActingDomain(D), F ) ) );
if ForAny( L, x -> ForAny( GeneratorsOfAlgebra( D ),
y -> not x * y in D ) ) then
return fail;
fi;
A:= AlgebraWithOne( F, GeneratorsOfAlgebra( D ) );
else
# Note that we need not use the isomorphism and subset relations
# (see below) because this is the task of the calls to
# `AsAlgebraWithOne'.
D:= AsAlgebraWithOne( Intersection( F, LeftActingDomain( D ) ), D );
return AsAlgebraWithOne( F, D );
fi;
UseIsomorphismRelation( D, A );
UseSubsetRelation( D, A );
return A;
end );
#############################################################################
##
#M ClosureLeftOperatorRing( <A>, <a> ) . . . . . . . closure with an element
##
InstallMethod( ClosureLeftOperatorRing,
"for a FLMLOR and a ring element",
#T why not a general function for any left operator ring?
#T (need `LeftOperatorRingByGenerators' ?)
IsCollsElms,
[ IsFLMLOR, IsRingElement ],
function( A, a )
# if possible test if the element lies in the ring already,
if HasGeneratorsOfLeftOperatorRing( A )
and a in GeneratorsOfLeftOperatorRing( A ) then
return A;
# otherwise make a new left operator ring
else
return FLMLOR( LeftActingDomain( A ),
Concatenation( GeneratorsOfLeftOperatorRing( A ), [ a ] ) );
fi;
end );
InstallMethod( ClosureLeftOperatorRing,
"for an FLMLOR with basis, and a ring element",
IsCollsElms,
[ IsFLMLOR and HasBasis, IsRingElement ],
function( A, a )
# test if the element lies in the FLMLOR already,
if a in A then
return A;
# otherwise make a new FLMLOR
else
return FLMLOR( LeftActingDomain( A ),
#T FLMLORByGenerators?
Concatenation( BasisVectors( Basis( A ) ), [ a ] ),
"basis" );
fi;
end );
InstallMethod( ClosureLeftOperatorRing,
"for a FLMLOR-with-one and a ring element",
IsCollsElms,
[ IsFLMLORWithOne, IsRingElement ],
function( A, a )
# if possible test if the element lies in the ring already,
if a in GeneratorsOfLeftOperatorRingWithOne( A ) then
return A;
# otherwise make a new left operator ring-with-one
else
return FLMLORWithOne( LeftActingDomain( A ),
Concatenation( GeneratorsOfLeftOperatorRingWithOne( A ),
[ a ] ) );
fi;
end );
InstallMethod( ClosureLeftOperatorRing,
"for a FLMLOR-with-one with basis, and a ring element",
IsCollsElms,
[ IsFLMLORWithOne and HasBasis, IsRingElement ],
function( A, a )
# test if the element lies in the FLMLOR already,
if a in A then
return A;
# otherwise make a new FLMLOR-with-one
else
return FLMLORWithOne( LeftActingDomain( A ),
Concatenation( BasisVectors( Basis( A ) ), [ a ] ),
"basis" );
fi;
end );
InstallMethod( ClosureLeftOperatorRing,
"for a FLMLOR containing the whole family, and a ring element",
IsCollsElms,
[ IsFLMLOR and IsWholeFamily, IsRingElement ],
SUM_FLAGS, # this is better than everything else
function( A, a )
return A;
end );
#############################################################################
##
#M ClosureLeftOperatorRing( <A>, <U> ) . closure of two left operator rings
##
InstallMethod( ClosureLeftOperatorRing,
"for two left operator rings",
IsIdenticalObj,
[ IsLeftOperatorRing, IsLeftOperatorRing ],
function( A, S )
local g; # one generator
for g in GeneratorsOfLeftOperatorRing( S ) do
A := ClosureLeftOperatorRing( A, g );
od;
return A;
end );
InstallMethod( ClosureLeftOperatorRing,
"for two left operator rings-with-one",
IsIdenticalObj,
[ IsLeftOperatorRingWithOne, IsLeftOperatorRingWithOne ],
function( A, S )
local g; # one generator
for g in GeneratorsOfLeftOperatorRingWithOne( S ) do
A := ClosureLeftOperatorRing( A, g );
od;
return A;
end );
InstallMethod( ClosureLeftOperatorRing,
"for a left op. ring cont. the whole family, and a collection",
IsIdenticalObj,
[ IsLeftOperatorRing and IsWholeFamily, IsCollection ],
SUM_FLAGS, # this is better than everything else
function( A, S )
return A;
end );
#############################################################################
##
#M ClosureLeftOperatorRing( <A>, <list> ) . . . . closure of left op. ring
##
InstallMethod( ClosureLeftOperatorRing,
"for left operator ring and list of elements",
IsIdenticalObj,
[ IsLeftOperatorRing, IsCollection ],
function( A, list )
local g; # one generator
for g in list do
A:= ClosureLeftOperatorRing( A, g );
od;
return A;
end );
#############################################################################
##
#F MutableBasisOfClosureUnderAction( <F>, <Agens>, <from>, <init>, <opr>,
#F <zero>, <maxdim> )
##
## This function is used to compute bases of finite dimensional ideals $I$
## in *associative* algebras that are given by ideal generators $J$ and
## (generators of) the acting algebra $A$.
## An important special case is that of the algebra $A$ itself, given by
## algebra generators.
##
## The algorithm assumes that it is possible to deal with mutable bases of
## vector spaces generated by elements of $A$.
## It proceeds as follows.
##
## Let $A$ be a finite dimensional algebra over the ring $F$,
## and $I$ a two-sided ideal in $A$ that is generated (as a two-sided ideal)
## by the set $J$.
## (For the cases of one-sided ideals, see below.)
##
## Let $S$ be a set of algebra generators of $A$.
## The identity of $A$, if exists, need not be contained in $S$.
##
## Each element $x$ in $I$ can be written as a linear combination of
## products $j a_1 a_2 \cdots a_n$, with $j \in J$ and $a_i \in S$ for
## $1 \leq i \leq n$.
## Let $l(x)$ denote the minimum of the largest $n$ for involved words
## $a_1 a_2 \cdots a_n$, taken over all possible expressions for $x$.
##
## Define $I_i = \{ x \in I \mid l(x) \leq i \}$.
## Then $I_i$ is an $F$-space, $A_0 = \langle J \rangle_F$,
## and $I_0 \< I_1 \< I_2 \< \cdots I_k \< I_{k+1} \< \ldots$
## is an ascending chain that eventually reaches $I$.
## For $i > 0$ we have
## $I_{i+1} = \langle I_i\cup\bigcup_{s\in S} ( I_i s\cup s I_i )\rangle_F$.
##
## (*Note* that the computation of the $I_i$ gives us the smallest value $k$
## such that every element is a linear combination of words in terms of the
## algebra generators, of maximal length $k$.)
##
InstallGlobalFunction( MutableBasisOfClosureUnderAction,
function( F, Agens, from, init, opr, zero, maxdim )
local MB, # mutable basis, result
gen, # loop over generators
v, #
dim, # dimension of the actual left module
right, # `true' if we have to multiply from the right
left; # `true' if we have to multiply from the left
# Get the side(s) from where to multiply.
left := true;
right := true;
if from = "left" then
right:= false;
elif from = "right" then
left:= false;
fi;
# $I_0$
MB := MutableBasis( F, init, zero );
dim := 0;
while dim < NrBasisVectors( MB ) and dim < maxdim do
# `MB' is a mutable basis of $I_i$.
dim:= NrBasisVectors( MB );
if right then
# Compute $I^{\prime}_i = I_i + \sum_{s \in S} I_i s$.
for gen in Agens do
for v in BasisVectors( MB ) do
CloseMutableBasis( MB, opr( v, gen ) );
od;
od;
fi;
if left then
# Compute $I_i + \sum_{s \in S} s I_i$
# resp. $I^{\prime}_i + \sum_{s \in S} s I_i$.
for gen in Agens do
for v in BasisVectors( MB ) do
CloseMutableBasis( MB, opr( gen, v ) );
od;
od;
fi;
od;
# Return the mutable basis.
return MB;
end );
#############################################################################
##
#F MutableBasisOfNonassociativeAlgebra( <F>, <Agens>, <zero>, <maxdim> )
##
InstallGlobalFunction( MutableBasisOfNonassociativeAlgebra,
function( F, Agens, zero, maxdim )
local MB, # mutable basis, result
dim, # dimension of the current left module
bv, # current basis vectors
v, w; # loop over basis vectors found already
MB := MutableBasis( F, Agens, zero );
dim := 0;
while dim < NrBasisVectors( MB ) and dim < maxdim do
dim := NrBasisVectors( MB );
bv := BasisVectors( MB );
for v in bv do
for w in bv do
CloseMutableBasis( MB, v * w );
CloseMutableBasis( MB, w * v );
od;
od;
od;
# Return the mutable basis.
return MB;
end );
#############################################################################
##
#F MutableBasisOfIdealInNonassociativeAlgebra( <F>, <Vgens>, <Igens>,
#F <zero>, <from>, <maxdim> )
##
InstallGlobalFunction( MutableBasisOfIdealInNonassociativeAlgebra,
function( F, Vgens, Igens, zero, from, maxdim )
local MB, # mutable basis, result
dim, # dimension of the current left module
bv, # current basis vectors
right, # `true' if we have to multiply from the right
left, # `true' if we have to multiply from the left
v, gen; # loop over basis vectors found already
# Get the side(s) from where to multiply.
left := true;
right := true;
if from = "left" then
right:= false;
elif from = "right" then
left:= false;
fi;
dim := 0;
MB := MutableBasis( F, Igens, zero );
while dim < NrBasisVectors( MB ) and dim < maxdim do
dim := NrBasisVectors( MB );
bv := BasisVectors( MB );
for v in bv do
for gen in Vgens do
if left then
CloseMutableBasis( MB, gen * v );
fi;
if right then
CloseMutableBasis( MB, v * gen );
fi;
od;
od;
od;
# Return the mutable basis.
return MB;
end );
#############################################################################
##
#M IsSubset( <A>, <B> ) . . . . . . . . . . . . test for subset of FLMLORs
##
## These methods are preferable to that for free left modules because they
## use algebra generators.
##
## We assume that generators of an extension of the left acting domains can
## be computed if they are fields; note that infinite field extensions do
## not (yet) occur in {\GAP} as `LeftActingDomain' values.
##
InstallMethod( IsSubset,
"for two FLMLORs",
IsIdenticalObj,
[ IsFLMLOR, IsFLMLOR ],
function( D1, D2 )
local F1, F2;
F1:= LeftActingDomain( D1 );
F2:= LeftActingDomain( D2 );
if not ( HasIsDivisionRing( F1 ) and IsDivisionRing( F1 ) and
HasIsDivisionRing( F2 ) and IsDivisionRing( F2 ) ) then
TryNextMethod();
fi;
# catch trivial case
if IsSubset(GeneratorsOfLeftOperatorRing(D1),
GeneratorsOfLeftOperatorRing(D2)) then
return true;
fi;
return IsSubset( D1, GeneratorsOverIntersection( D2,
GeneratorsOfLeftOperatorRing( D2 ),
F2, F1 ) );
end );
InstallMethod( IsSubset,
"for two FLMLORs-with-one",
IsIdenticalObj,
[ IsFLMLORWithOne, IsFLMLORWithOne ],
function( D1, D2 )
local F1, F2;
F1:= LeftActingDomain( D1 );
F2:= LeftActingDomain( D2 );
if not ( HasIsDivisionRing( F1 ) and IsDivisionRing( F1 ) and
HasIsDivisionRing( F2 ) and IsDivisionRing( F2 ) ) then
TryNextMethod();
fi;
return IsSubset( D1, GeneratorsOverIntersection( D2,
GeneratorsOfLeftOperatorRingWithOne( D2 ),
F2, F1 ) );
end );
#############################################################################
##
#M ViewObj( <A> ) . . . . . . . . . . . . . . . . . . . . . . view a FLMLOR
##
## print left acting domain, if known also dimension or no. of generators
##
InstallMethod( ViewObj,
"for a FLMLOR",
[ IsFLMLOR ],
function( A )
Print( "<free left module over ", LeftActingDomain( A ), ", and ring>" );
end );
InstallMethod( ViewObj,
"for a FLMLOR with known dimension",
[ IsFLMLOR and HasDimension ], 1, # override method requiring gens.
function( A )
Print( "<free left module of dimension ", Dimension( A ),
" over ", LeftActingDomain( A ), ", and ring>" );
end );
InstallMethod( ViewObj,
"for a FLMLOR with known generators",
[ IsFLMLOR and HasGeneratorsOfAlgebra ],
function( A )
Print( "<free left module over ", LeftActingDomain( A ),
", and ring, with ",
Length( GeneratorsOfFLMLOR( A ) ), " generators>" );
end );
#############################################################################
##
#M PrintObj( <A> ) . . . . . . . . . . . . . . . . . . . . . print a FLMLOR
##
InstallMethod( PrintObj,
"for a FLMLOR",
[ IsFLMLOR ],
function( A )
Print( "FLMLOR( ", LeftActingDomain( A ), ", ... )" );
end );
InstallMethod( PrintObj,
"for a FLMLOR with known generators",
[ IsFLMLOR and HasGeneratorsOfFLMLOR ],
function( A )
if IsEmpty( GeneratorsOfFLMLOR( A ) ) then
Print( "FLMLOR( ", LeftActingDomain( A ), ", [], ", Zero( A ), " )" );
else
Print( "FLMLOR( ", LeftActingDomain( A ), ", ",
GeneratorsOfFLMLOR( A ), " )" );
fi;
end );
#############################################################################
##
#M ViewObj( <A> ) . . . . . . . . . . . . . . . . . view a FLMLOR-with-one
##
## print left acting domain, if known also dimension or no. of generators
##
InstallMethod( ViewObj,
"for a FLMLOR-with-one",
[ IsFLMLORWithOne ],
function( A )
Print( "<free left module over ", LeftActingDomain( A ),
", and ring-with-one>" );
end );
InstallMethod( ViewObj,
"for a FLMLOR-with-one with known dimension",
[ IsFLMLORWithOne and HasDimension ], 1, # override method requ. gens.
function( A )
Print( "<free left module of dimension ", Dimension( A ),
" over ", LeftActingDomain( A ), ", and ring-with-one>" );
end );
InstallMethod( ViewObj,
"for a FLMLOR-with-one with known generators",
[ IsFLMLORWithOne and HasGeneratorsOfFLMLORWithOne ],
function( A )
Print( "<free left module over ", LeftActingDomain( A ),
", and ring-with-one, with ",
Length( GeneratorsOfAlgebraWithOne( A ) ), " generators>" );
end );
#############################################################################
##
#M PrintObj( <A> ) . . . . . . . . . . . . . . . . . print a FLMLOR-with-one
##
InstallMethod( PrintObj,
"for a FLMLOR-with-one",
[ IsFLMLORWithOne ],
function( A )
Print( "FLMLORWithOne( ", LeftActingDomain( A ), ", ... )" );
end );
InstallMethod( PrintObj,
"for a FLMLOR-with-one with known generators",
[ IsFLMLORWithOne and HasGeneratorsOfFLMLOR ],
function( A )
if IsEmpty( GeneratorsOfFLMLORWithOne( A ) ) then
Print( "FLMLORWithOne( ", LeftActingDomain( A ), ", [], ",
Zero( A ), " )" );
else
Print( "FLMLORWithOne( ", LeftActingDomain( A ), ", ",
GeneratorsOfFLMLORWithOne( A ), " )" );
fi;
end );
#############################################################################
##
#M ViewObj( <A> ) . . . . . . . . . . . . . . . . . . . . . view an algebra
##
## print left acting domain, if known also dimension or no. of generators
##
InstallMethod( ViewObj,
"for an algebra",
[ IsAlgebra ],
function( A )
Print( "<algebra over ", LeftActingDomain( A ), ">" );
end );
InstallMethod( ViewObj,
"for an algebra with known dimension",
[ IsAlgebra and HasDimension ], 1, # override method requiring gens.
function( A )
Print( "<algebra of dimension ", Dimension( A ),
" over ", LeftActingDomain( A ), ">" );
end );
InstallMethod( ViewObj,
"for an algebra with known generators",
[ IsAlgebra and HasGeneratorsOfAlgebra ],
function( A )
Print( "<algebra over ", LeftActingDomain( A ), ", with ",
Length( GeneratorsOfAlgebra( A ) ), " generators>" );
end );
#############################################################################
##
#M PrintObj( <A> ) . . . . . . . . . . . . . . . . . . . . print an algebra
##
InstallMethod( PrintObj,
"for an algebra",
[ IsAlgebra ],
function( A )
Print( "Algebra( ", LeftActingDomain( A ), ", ... )" );
end );
InstallMethod( PrintObj,
"for an algebra with known generators",
[ IsAlgebra and HasGeneratorsOfAlgebra ],
function( A )
if IsEmpty( GeneratorsOfAlgebra( A ) ) then
Print( "Algebra( ", LeftActingDomain( A ), ", [], ", Zero( A ), " )" );
else
Print( "Algebra( ", LeftActingDomain( A ), ", ",
GeneratorsOfAlgebra( A ), " )" );
fi;
end );
#############################################################################
##
#M ViewObj( <A> ) . . . . . . . . . . . . . . . . view an algebra-with-one
##
## print left acting domain, if known also dimension or no. of generators
##
InstallMethod( ViewObj, "for an algebra-with-one", [ IsAlgebraWithOne ],
function( A )
if IsIdenticalObj(A,LeftActingDomain(A)) then
Print( "<algebra-with-one over itself>" );
else
Print( "<algebra-with-one over ", LeftActingDomain( A ), ">" );
fi;
end );
InstallMethod( ViewObj,
"for an algebra-with-one with known dimension",
[ IsAlgebraWithOne and HasDimension ], 1, # override method requ. gens.
function( A )
Print( "<algebra-with-one of dimension ", Dimension( A ),
" over ", LeftActingDomain( A ), ">" );
end );
InstallMethod( ViewObj,
"for an algebra-with-one with known generators",
[ IsAlgebraWithOne and HasGeneratorsOfAlgebraWithOne ],
function( A )
Print( "<algebra-with-one over ", LeftActingDomain( A ), ", with ",
Length( GeneratorsOfAlgebraWithOne( A ) ), " generators>" );
end );
#############################################################################
##
#M PrintObj( <A> ) . . . . . . . . . . . . . . . . print an algebra-with-one
##
InstallMethod( PrintObj,
"for an algebra-with-one",
[ IsAlgebraWithOne ],
function( A )
Print( "AlgebraWithOne( ", LeftActingDomain( A ), ", ... )" );
end );
InstallMethod( PrintObj,
"for an algebra-with-one with known generators",
[ IsAlgebraWithOne and HasGeneratorsOfAlgebra ],
function( A )
if IsEmpty( GeneratorsOfAlgebraWithOne( A ) ) then
Print( "AlgebraWithOne( ", LeftActingDomain( A ), ", [], ",
Zero( A ), " )" );
else
Print( "AlgebraWithOne( ", LeftActingDomain( A ), ", ",
GeneratorsOfAlgebraWithOne( A ), " )" );
fi;
end );
#############################################################################
##
#M ViewObj( <A> ) . . . . . . . . . . . . . . . . . . view a Lie algebra
##
## print left acting domain, if known also dimension or no. of generators
##
InstallMethod( ViewObj,
"for a Lie algebra",
[ IsLieAlgebra ],
function( A )
Print( "<Lie algebra over ", LeftActingDomain( A ), ">" );
end );
InstallMethod( ViewObj,
"for a Lie algebra with known dimension",
[ IsLieAlgebra and HasDimension ], 1, # override method requ. gens.
function( A )
Print( "<Lie algebra of dimension ", Dimension( A ),
" over ", LeftActingDomain( A ), ">" );
end );
InstallMethod( ViewObj,
"for a Lie algebra with known generators",
[ IsLieAlgebra and HasGeneratorsOfAlgebra ],
function( A )
Print( "<Lie algebra over ", LeftActingDomain( A ), ", with ",
Length( GeneratorsOfAlgebra( A ) ), " generators>" );
end );
#############################################################################
##
#M AsSubalgebra(<A>, <U>) . view an algebra as subalgebra of another algebra
##
InstallMethod( AsSubalgebra,
"for two algebras",
IsIdenticalObj,
[ IsAlgebra, IsAlgebra ],
function( A, U )
local samecoeffs, S;
if not IsSubset( A, U ) then
return fail;
fi;
# Construct the generators list.
samecoeffs:= LeftActingDomain( A ) = LeftActingDomain( U );
if not samecoeffs then
U:= AsAlgebra( LeftActingDomain( A ), U );
fi;
# Construct the subalgebra.
S:= SubalgebraNC( A, GeneratorsOfAlgebra( U ) );
# Maintain useful information.
UseIsomorphismRelation( U, S );
UseSubsetRelation( U, S );
if samecoeffs and HasDimension( U ) then
SetDimension( S, Dimension( U ) );
fi;
# Return the subalgebra.
return S;
end );
InstallMethod( AsSubalgebra,
"for an algebra and an algebra-with-one",
IsIdenticalObj,
[ IsAlgebra, IsAlgebraWithOne ],
function( A, U )
local samecoeffs, S;
if not IsSubset( A, U ) then
return fail;
fi;
# Construct the generators list.
samecoeffs:= LeftActingDomain( A ) = LeftActingDomain( U );
if not samecoeffs then
U:= AsAlgebraWithOne( LeftActingDomain( A ), U );
fi;
# Construct the subalgebra.
S:= SubalgebraWithOneNC( A, GeneratorsOfAlgebraWithOne( U ) );
# Maintain useful information.
UseIsomorphismRelation( U, S );
UseSubsetRelation( U, S );
if samecoeffs and HasDimension( U ) then
SetDimension( S, Dimension( U ) );
fi;
# Return the subalgebra.
return S;
end );
#############################################################################
##
#M AsSubalgebraWithOne(<A>, <U>) . . . view algebra as subalgebra of another
##
InstallMethod( AsSubalgebraWithOne,
"for two algebras",
IsIdenticalObj,
[ IsAlgebra, IsAlgebra ],
function( A, U )
local S;
if not IsSubset( A, U ) or One( U ) = fail then
return fail;
fi;
if LeftActingDomain( A ) <> LeftActingDomain( U ) then
U:= AsAlgebraWithOne( LeftActingDomain( A ), U );
fi;
# Construct and return the subalgebra.
S:= SubalgebraWithOneNC( A, GeneratorsOfAlgebra( U ) );
UseIsomorphismRelation( U, S );
UseSubsetRelation( U, S );
return S;
end );
InstallMethod( AsSubalgebraWithOne,
"for an algebra and a algebra-with-one",
IsIdenticalObj,
[ IsAlgebra, IsAlgebraWithOne ],
function( A, U )
local S;
if not IsSubset( A, U ) then
return fail;
fi;
if LeftActingDomain( A ) <> LeftActingDomain( U ) then
U:= AsAlgebraWithOne( LeftActingDomain( A ), U );
fi;
# Construct and return the subalgebra.
S:= SubalgebraWithOneNC( A, GeneratorsOfAlgebraWithOne( U ) );
UseIsomorphismRelation( U, S );
UseSubsetRelation( U, S );
return S;
end );
#############################################################################
##
#F CentralizerInFiniteDimensionalAlgebra( <A>, <S>, <issubset> )
##
## Let $(b_1, \ldots, b_n)$ be a basis of <A>, and $(s_1, \ldots, s_m)$
## be a basis of <S>, with $s_j = \sum_{l=1}^n v_{jl} b_l$.
## The structure constants of <A> are $c_{ijk}$ with
## $b_i b_j = \sum_{k=1}^n c_{ijk} b_k$.
## Then we compute a basis of the solution space of the system
## $\sum_{i=1}^n a_i \sum_{l=1}^n v_{jl} ( c_{ilk} - c_{lik} )$ for
## $1 \leq j \leq m$ and $1 \leq k \leq n$.
##
## (left null space of an $n \times (nm)$ matrix)
##
## If the multiplication in <A> is known to be anticommutative this is used.
## (Note that the case of commutative multiplication is handled in a more
## general way.)
##
#T We will have problems with this approach if centralizers of algebras over
#T non-commutative coefficients domains are considered.
#T In this case, <S> might stand for generators w.r.t. a larger coefficients
#T domain that also must be centralized ...
##
InstallGlobalFunction( CentralizerInFiniteDimensionalAlgebra,
function( A, S, issubset )
local B, # basis of `A'
T, # structure constants table w. r. to `B'
n, # dimension of `A'
m, # length of `S'
M, # matrix of the equation system
v, # coefficients of basis vectors of `S' w.r. to `B'
zerovector, # initialize one row of `M'
row, # one row of `M'
i, j, k, l, # loop variables
cil, cli, #
offset,
pos;
# Handle the case that `S' may be not contained in `A'.
# (If `A' knows a basis and `S' is a subset of `A' then
# there are methods that return `A' itself as closure.)
if not issubset then
M:= ClosureAlgebra( A, S );
return Intersection2( A,
CentralizerInFiniteDimensionalAlgebra( M, S, true ) );
fi;
# Now `S' is known to be contained in `A'.
B:= Basis( A );
T:= StructureConstantsTable( B );
n:= Dimension( A );
m:= Length( S );
M:= [];
v:= List( S, x -> Coefficients( B, x ) );
zerovector:= [ 1 .. n*m ] * Zero( LeftActingDomain( A ) );
if HasIsAnticommutative( A ) and IsAnticommutative( A ) then
# Column $(j-1)*n + k$ contains in row $i$ the value
# $\sum_{l=1}^n v_{jl} c_{ilk}$
for i in [ 1 .. n ] do
row:= ShallowCopy( zerovector );
for l in [ 1 .. n ] do
cil:= T[i][l];
for j in [ 1 .. m ] do
offset:= (j-1)*n;
for k in [ 1 .. Length( cil[1] ) ] do
pos:= cil[1][k] + offset;
row[ pos ]:= row[ pos ] + v[j][l] * cil[2][k];
od;
od;
od;
Add( M, row );
od;
else
# Column $(j-1)*n + k$ contains in row $i$ the value
# $\sum_{l=1}^n v_{jl} ( c_{ilk} - c_{lik} )$
for i in [ 1 .. n ] do
row:= ShallowCopy( zerovector );
for l in [ 1 .. n ] do
cil:= T[i][l];
cli:= T[l][i];
for j in [ 1 .. m ] do
offset:= (j-1)*n;
for k in [ 1 .. Length( cil[1] ) ] do
pos:= cil[1][k] + offset;
row[ pos ]:= row[ pos ] + v[j][l] * cil[2][k];
od;
for k in [ 1 .. Length( cli[1] ) ] do
pos:= cli[1][k] + offset;
row[ pos ]:= row[ pos ] - v[j][l] * cli[2][k];
od;
od;
od;
Add( M, row );
od;
fi;
# Solve the equation system.
M:= NullspaceMat( M );
# Construct the generators from the coefficient vectors.
M:= List( M, x -> LinearCombination( B, x ) );
# Return the subalgebra.
if IsFLMLORWithOne( A ) then
return SubalgebraWithOneNC( A, M, "basis" );
else
return SubalgebraNC( A, M, "basis" );
fi;
end );
#############################################################################
##
#M CentralizerOp( <A>, <S> ) . . . . . cent. of a vector space in an algebra
##
InstallMethod( CentralizerOp,
"for a finite dimensional algebra and a vector space with parent",
IsIdenticalObj,
[ IsAlgebra, IsVectorSpace and HasParent ],
function( A, S )
if not IsIdenticalObj( A, Parent( S ) )
or not IsFiniteDimensional( A ) then
TryNextMethod();
fi;
return CentralizerInFiniteDimensionalAlgebra( A,
BasisVectors( Basis( S ) ),
true );
end );
#############################################################################
##
#M CentralizerOp( <A>, <S> ) . . . cent. of an algebra in an assoc. algebra
##
InstallMethod( CentralizerOp,
"for a fin. dim. assoc. algebra and an algebra with parent",
IsIdenticalObj,
[ IsAlgebra and IsAssociative, IsAlgebra and HasParent ],
function( A, S )
if not IsIdenticalObj( A, Parent( S ) )
or not IsFiniteDimensional( A ) then
TryNextMethod();
fi;
return CentralizerInFiniteDimensionalAlgebra( A,
GeneratorsOfAlgebra( S ),
true );
end );
#############################################################################
##
#M CentralizerOp( <A>, <S> ) . . . . . cent. of a vector space in an algebra
##
InstallMethod( CentralizerOp,
"for a finite dimensional algebra and a vector space",
IsIdenticalObj,
[ IsAlgebra, IsVectorSpace ],
function( A, S )
if not IsFiniteDimensional( A ) then
TryNextMethod();
fi;
return CentralizerInFiniteDimensionalAlgebra( A,
BasisVectors( Basis( S ) ),
false );
end );
#############################################################################
##
#M CentralizerOp( <A>, <S> ) . . . cent. of an algebra in an assoc. algebra
##
InstallMethod( CentralizerOp,
"for a fin. dim. assoc. algebra and an algebra",
IsIdenticalObj,
[ IsAlgebra and IsAssociative, IsAlgebra ],
function( A, S )
if not IsFiniteDimensional( A ) then
TryNextMethod();
fi;
return CentralizerInFiniteDimensionalAlgebra( A,
GeneratorsOfAlgebra( S ),
false );
end );
#############################################################################
##
#M CentralizerOp( <A>, <elm> ) . . . . . . cent. of an element in an algebra
##
InstallMethod( CentralizerOp,
"for an algebra and an element",
IsCollsElms,
[ IsAlgebra, IsObject ],
function( A, elm )
return Centralizer( A, Algebra( LeftActingDomain( A ), [ elm ] ) );
end );
#############################################################################
##
#F CentreFromSCTable( <T> )
##
## Given a structure constants table <T> w.r.t. a basis $B$, say,
## `CentreFromSCTable' returns a list of $B$-coefficients vectors
## of a basis for the centre of an $F$-algebra with s.c. table <T>,
## where $F$ is assumed to be commutative.
##
## We have to solve the system
## $\sum_{i=1}^n a_i ( c_{ijk} - c_{jik} ) = 0$ for $1 \leq j, k \leq n$.
##
BindGlobal( "CentreFromSCTable", function( T )
local n, # the dimension
M, # matrix of the equation system
i, j, k, # loop variables
row, # one row in `M'
offset, # offset between entry in `T' and column in `M'
pos, # nonzero positions in $c_{ij}$
val; # loop over structure constants in $c_{ij}$
n:= Length( T ) - 2;
M:= NullMat( n, n*n, T[ Length( T ) ] );
for i in [ 1 .. n ] do
row:= M[i];
for j in [ 1 .. n ] do
offset:= (j-1)*n;
row{ offset + T[i][j][1] }:= T[i][j][2];
pos:= T[j][i][1];
val:= T[j][i][2];
for k in [ 1 .. Length( pos ) ] do
row[ offset + pos[k] ]:= row[ offset + pos[k] ] - val[k];
#T cheaper!
od;
od;
od;
# Solve the equation system.
return NullspaceMat( M );
end );
#############################################################################
##
#M Centre( <A> )
##
InstallMethod( Centre,
"for a finite dimensional FLMLOR",
[ IsFLMLOR ],
function( A )
local C, # centre of `A', result
B, # a basis of `A'
M; # matrix of the equation system
if not IsFiniteDimensional( A ) then
TryNextMethod();
fi;
# If necessary convert `A' to a FLMLOR over a commutative ring.
if not IsCommutative( LeftActingDomain( A ) ) then
A:= AsFLMLOR( Centre( LeftActingDomain( A ) ), A );
fi;
# Solve the equation system.
# If a s.c. table is already known, we use it since this allows us to
# avoid multiplications.
# Only if no s.c. table is known and if the algebra is known to be
# associative and if the number of algebra generators is less than the
# number of basis vectors, we do not force the computation of a
# s.c. table.
# (Note that for associative algebras,
# we have to check $x a = a x$ only for algebra generators $a$,
# not for all vectors of a basis.)
B:= Basis( A );
if HasStructureConstantsTable( B )
or not ( HasIsAssociative( A ) and IsAssociative( A ) ) then
M:= CentreFromSCTable( StructureConstantsTable( B ) );
else
if HasGeneratorsOfAlgebraWithOne( A ) then
M:= GeneratorsOfAlgebraWithOne( A );
else
M:= GeneratorsOfAlgebra( A );
fi;
if Dimension( A ) <= 2 * Length( M ) then
M:= CentreFromSCTable( StructureConstantsTable( B ) );
else
M:= List( BasisVectors( B ), bi -> Concatenation( List( M,
a -> Coefficients( B, bi * a - a * bi ) ) ) );
M:= NullspaceMat( M );
fi;
fi;
# Construct the generators from the coefficient vectors.
M:= List( M, x -> LinearCombination( B, x ) );
# Construct the centre.
if IsFLMLORWithOne( A ) then
C:= SubalgebraWithOneNC( A, M, "basis" );
else
C:= SubalgebraNC( A, M, "basis" );
fi;
Assert( 1, IsAbelian( C ) );
SetIsAbelian( C, true );
# Return the centre.
return C;
end );
#############################################################################
##
#F MutableBasisOfProductSpace( <U>, <V> )
##
## Once we have the basis vectors for the product space,
## we only have to decide whether the result of `ProductSpace' is an ideal,
## an algebra, or just a vector space.
## This decision is left to the methods of `ProductSpace',
## the computation of basis vectors is done by `MutableBasisOfProductSpace'.
##
BindGlobal( "MutableBasisOfProductSpace", function( U, V )
local inter, # intersection of left acting domains
u, v, # loop over the bases
MB; # mutable basis of the commutator subspace, result
if LeftActingDomain( U ) = LeftActingDomain( V ) then
inter:= LeftActingDomain( U );
else
inter:= Intersection2( LeftActingDomain( U ), LeftActingDomain( V ) );
U:= AsVectorSpace( inter, U );
V:= AsVectorSpace( inter, V );
fi;
MB:= MutableBasis( inter, [], Zero( U ) );
V:= BasisVectors( Basis( V ) );
for u in BasisVectors( Basis( U ) ) do
for v in V do
CloseMutableBasis( MB, u * v );
od;
od;
# Return the result.
return [ MB, inter ];
end );
#############################################################################
##
#M ProductSpace( <U>, <V> ) . . . . . . . . . . . for two free left modules
##
InstallMethod( ProductSpace,
"for two free left modules",
IsIdenticalObj,
[ IsFreeLeftModule, IsFreeLeftModule ],
function( U, V )
local MB, vectors, C;
# Compute basis vectors.
MB:= MutableBasisOfProductSpace( U, V );
vectors:= BasisVectors( MB[1] );
if IsEmpty( vectors ) then
return TrivialSubspace( U );
fi;
# Create the appropriate domain.
if HasParent( U ) and HasParent( V )
and IsIdenticalObj( Parent( U ), Parent( V ) ) then
C:= SubmoduleNC( Parent( U ), vectors, "basis" );
else
C:= FreeLeftModule( MB[2], vectors, "basis" );
fi;
# Insert the basis.
SetBasis( C, ImmutableBasis( MB[1] ) );
# Return the result.
return C;
end );
#############################################################################
##
#M ProductSpace( <U>, <V> ) . . . . . . . . . . . . . . . for two algebras
##
## If $<U> = <V>$ is known to be an algebra then the product space is also
## an algebra, moreover it is an ideal in <U>.
## If <U> and <V> are known to be ideals in an algebra $A$
## then the product space is known to be an algebra and an ideal in $A$.
##
InstallMethod( ProductSpace,
"for two algebras",
IsIdenticalObj,
[ IsAlgebra, IsAlgebra ],
function( U, V )
local P, MB, C;
# Look for the ideal relation that allows one to construct an ideal.
if IsIdenticalObj( U, V ) then
P:= U;
elif HasParent( V ) and IsIdenticalObj( Parent( V ), U )
and HasIsTwoSidedIdealInParent( V )
and IsTwoSidedIdealInParent( V ) then
P:= U;
elif HasParent( U ) and IsIdenticalObj( Parent( U ), V )
and HasIsTwoSidedIdealInParent( U )
and IsTwoSidedIdealInParent( U ) then
P:= V;
else
TryNextMethod();
fi;
# Compute basis vectors for the result.
MB:= MutableBasisOfProductSpace( U, V )[1];
# The result is an ideal in `U'.
C:= SubalgebraNC( P, BasisVectors( MB ), "basis" );
SetIsTwoSidedIdealInParent( C, true );
SetBasis( C, ImmutableBasis( MB, C ) );
# Return the result.
return C;
end );
#############################################################################
##
#M ProductSpace( <U>, <V> ) . . . . . . . . for two ideals with same parent
##
InstallMethod( ProductSpace,
"for two ideals with same parent",
IsIdenticalObj,
[ IsAlgebra and HasParent and IsTwoSidedIdealInParent,
IsAlgebra and HasParent and IsTwoSidedIdealInParent ],
function( U, V )
local MB, C;
if not IsIdenticalObj( Parent( U ), Parent( V ) ) then
TryNextMethod();
fi;
# The result is an ideal in the parent of `U'.
MB:= MutableBasisOfProductSpace( U, V )[1];
C:= SubalgebraNC( Parent( U ), BasisVectors( MB ), "basis" );
SetIsTwoSidedIdealInParent( C, true );
SetBasis( C, ImmutableBasis( MB, C ) );
# Return the result.
return C;
end );
#############################################################################
##
#M RadicalOfAlgebra( <A> ) . . . . . . . . radical of an associative algebra
##
## `RadicalOfAlgebra' computes the radical (maximal nilpotent ideal)
## of an associative algebra <A> by first constructing a faithful
## matrix representation.
## (Note that there is a special implementation for associative matrix
## algebras.)
##
## If <A> contains an identity element then the adjoint representation is
## already faithful.
##
## Otherwise we add an identity element (Dorroh extension).
## More precisely we consider the space $B = \{ (x,t) | x\in A, t\in F }$.
## We let <A> act on this space via $a (x,t) = (ax+ta,0)$.
## Then it is easily seen that this representation is faithful.
##
InstallMethod( RadicalOfAlgebra,
"for an associative algebra",
[ IsAlgebra ],
function( A )
local bb, # list of matrices representing the basis elements of <A>
n, # dimension of <A>
BA, # basis of `A'
bv, # basis vectors of `BA'
F, # left acting domain of `A'
M, # (n+1) x (n+1) matrix
i,j, # loop variables
col, # a column of `M'
B, # the representation of <A>
R, # the radical of `B'
bas, # a basis of `B' (corresponding to the basis of <A>)
rad; # a basis of the radical of <A>
# Make sure that the algebra is associative and not a matrix algebra.
if not IsAssociative( A ) then
TryNextMethod();
fi;
n:= Dimension( A );
BA:= Basis( A );
bv:= BasisVectors( BA );
F:= LeftActingDomain( A );
if One( A ) <> fail then
bb:= List( bv, x -> AdjointMatrix( BA, x ) );
else
bb:= [];
for i in [1..n] do
M:=[];
for j in [1..n] do
col:= Coefficients( BA, bv[i] * bv[j] );
col[n+1]:= Zero( F );
Add( M, col );
od;
col:= [ 1 .. n+1 ] * Zero( F );
col[i]:= One( F );
Add( M, col );
Add( bb, M );
od;
fi;
# Compute the radical of the isomorphic matrix algebra.
B:= Algebra( F, bb, "basis" );
R:= RadicalOfAlgebra( B );
# Transfer the radical back to the original algebra.
bas:= BasisNC( B, bb );
rad:= List( BasisVectors( Basis( R ) ),
x -> LinearCombination( BA, Coefficients( bas, x ) ) );
return SubalgebraNC( A, rad, "basis" );
end );
#############################################################################
##
#M IsTrivial( <A> ) . . . . . . . . . . . . . . . . . . . . . for a FLMLOR
##
InstallMethod( IsTrivial,
"for a FLMLOR",
[ IsFLMLOR ],
A -> ForAll( GeneratorsOfLeftOperatorRing( A ), IsZero ) );
#############################################################################
##
#M IsTrivial( <A> ) . . . . . . . . . . . . . . . . . for a FLMLOR-with-one
##
## A FLMLOR-with-one is trivial if and only if its identity is equal to its
## zero.
##
InstallMethod( IsTrivial,
"for a FLMLOR-with-one",
[ IsFLMLORWithOne ],
A -> IsZero( One( A ) ) );
#############################################################################
##
#M GeneratorsOfLeftModule( <A> )
##
## We assume that it is possible to construct a basis for the algebra <A>.
## If <A> is finite dimensional and if we know algebra generators
## then the process of successive closure under the action of <A> on itself
## yields this.
##
InstallMethod( GeneratorsOfLeftModule,
"for a FLMLOR",
[ IsFLMLOR ],
A -> BasisVectors( Basis( A ) ) );
#############################################################################
##
#M Basis( <A> ) . . . . . . . . . . . . basis from FLMLOR gens. for FLMLOR
##
InstallMethod( Basis,
"for a FLMLOR",
[ IsFLMLOR ],
function( A )
# If generators as left module are known
# we do not need to multiply at all.
if HasGeneratorsOfLeftModule( A ) then
TryNextMethod();
fi;
return ImmutableBasis( MutableBasisOfNonassociativeAlgebra(
LeftActingDomain( A ),
GeneratorsOfLeftOperatorRing( A ),
Zero( A ),
infinity ), A );
end );
#############################################################################
##
#M Basis( <A> ) . . . . . . basis from FLMLOR gens. for associative FLMLOR
##
InstallMethod( Basis,
"for an associative FLMLOR",
[ IsFLMLOR and IsAssociative ],
function( A )
local mb;
# If generators as left module are known
# we do not need to multiply at all.
if HasGeneratorsOfLeftModule( A ) then
TryNextMethod();
fi;
mb:= MutableBasisOfClosureUnderAction(
LeftActingDomain( A ),
GeneratorsOfLeftOperatorRing( A ),
"left",
GeneratorsOfLeftOperatorRing( A ),
\*,
Zero( A ),
infinity );
return ImmutableBasis( mb, A );
end );
#############################################################################
##
#M Basis( <A> ) . basis from FLMLOR gens. for associative FLMLOR-with-one
##
InstallMethod( Basis,
"for an associative FLMLOR-with-one",
[ IsFLMLORWithOne and IsAssociative ],
function( A )
# If generators as left module are known
# we do not need to multiply at all.
if HasGeneratorsOfLeftModule( A ) then
TryNextMethod();
fi;
return ImmutableBasis( MutableBasisOfClosureUnderAction(
LeftActingDomain( A ),
GeneratorsOfLeftOperatorRing( A ),
"left",
[ One( A ) ],
\*,
Zero( A ),
infinity ), A );
end );
#############################################################################
##
#M Basis( <A> ) . . . . . . . . . . basis from FLMLOR gens. for Lie algebra
##
## In a Lie algebra, every word (with brackets) in terms of algebra
## generators is a linear combination of left-normed words;
## this means that it is sufficient to multiply with generators from one
## side.
##
InstallMethod( Basis,
"for a Lie algebra",
[ IsLieAlgebra ],
function( A )
local mb;
# If generators as left module are known
# we do not need to multiply at all.
if HasGeneratorsOfLeftModule( A ) then
TryNextMethod();
fi;
mb:= MutableBasisOfClosureUnderAction(
LeftActingDomain( A ),
GeneratorsOfLeftOperatorRing( A ),
"left",
GeneratorsOfLeftOperatorRing( A ),
\*,
Zero( A ),
infinity );
return ImmutableBasis( mb, A );
end );
#############################################################################
##
#M PowerSubalgebraSeries( <A> )
##
InstallOtherMethod( PowerSubalgebraSeries,
"for an algebra",
[ IsAlgebra ],
function ( A )
local S, # power subalgebra series of <A>, result
D; # power subalgebras
# Compute the series by repeated calling of `ProductSpace'.
S := [ A ];
D := ProductSpace( A, A );
while D <> S[ Length(S) ] do
Add( S, D );
D:= ProductSpace( D, D );
od;
# Return the series when it becomes stable.
return S;
end );
#############################################################################
##
#M IsNilpotentElement( <L>, <x> ) . . . . . . for an algebra and an element
##
## <x> is nilpotent if its adjoint matrix $A$ (i.e. the linear map coming
## from left multiplication by <x>) is nilpotent.
## To check this, we only need to check whether $A^n$ (or a smaller power)
## is zero, where $n$ denotes the dimension of <L>.
##
InstallMethod( IsNilpotentElement,
"for an algebra, and an element",
IsCollsElms,
[ IsAlgebra, IsRingElement ],
function( L, x )
local B, # a basis of `L'
A, # adjoint matrix of `x w.r. to `B'
n, # dimension of `L'
i, # loop variable
zero; # zero coefficient
B := Basis( L );
A := AdjointMatrix( B, x );
n := Dimension( L );
i := 1;
zero:= Zero( A[1][1] );
if ForAll( A, x -> n < PositionNot( x, zero ) ) then
return true;
fi;
while i < n do
i:= 2 * i;
A:= A * A;
if ForAll( A, x -> n < PositionNot( x, zero ) ) then
return true;
fi;
od;
return false;
end );
#############################################################################
##
#M GeneratorsOfLeftOperatorRing( <A> ) . . . . . . . . for a FLMLOR-with-one
##
InstallMethod( GeneratorsOfLeftOperatorRing,
"for a FLMLOR-with-one",
[ IsFLMLORWithOne ],
A -> Concatenation( [ One( A ) ],
GeneratorsOfLeftOperatorRingWithOne( A ) ) );
#############################################################################
##
#M GeneratorsOfLeftOperatorRing( <A> ) . . . . for FLMLOR with module gens.
##
InstallMethod( GeneratorsOfLeftOperatorRing,
"for a FLMLOR with known left module generators",
[ IsFLMLOR and HasGeneratorsOfLeftModule ],
GeneratorsOfLeftModule );
#############################################################################
##
#M GeneratorsOfLeftOperatorRingWithOne( <A> ) . for FLMLOR with module gens.
##
InstallMethod( GeneratorsOfLeftOperatorRingWithOne,
"for a FLMLOR-with-one with known left module generators",
[ IsFLMLORWithOne and HasGeneratorsOfLeftModule ],
GeneratorsOfLeftModule );
#############################################################################
##
#M DirectSumOfAlgebras( <A1>, <A2> )
##
## Construct a s.c. algebra.
## (There are special methods for the sum of appropriate matrix algebras.)
##
#T embeddings/projections should be provided!
##
InstallOtherMethod( DirectSumOfAlgebras,
"for two algebras",
[ IsAlgebra, IsAlgebra ],
function( A1, A2 )
local n, # The dimension of the resulting algebra.
i,j, # Loop variables.
T, # The table of structure constants of the direct sum.
scT, #
n1, # The dimension of A1.
n2, # The dimension of A2.
ll, # A list of structure constants.
L, # result.
sym, # if both products are (anti)symmetric, then the result
# will have the same property.
R1,R2, # Root systems of A1,A2.
f1,f2, # Embeddings of A1,A2 in L.
R, # Root system of L.
RV, # List of various things.
r,
pos; # List of positions.
if LeftActingDomain( A1 ) <> LeftActingDomain( A2 ) then
Error( "<A1> and <A2> must be written over the same field" );
fi;
n1:= Dimension( A1 );
n2:= Dimension( A2 );
n:= n1+n2;
T:= [];
# Initialize the s.c. table.
T:= EmptySCTable( n, Zero( LeftActingDomain( A1 ) ) );
# Enter the structure constants for the first algebra.
scT:= StructureConstantsTable( Basis( A1 ) );
sym:= scT[n1+1];
T{ [ 1 .. n1 ] }{ [ 1 .. n1 ] }:= scT{ [ 1 .. n1 ] };
scT:= StructureConstantsTable( Basis( A2 ) );
for i in [1..n2] do
for j in [1..n2] do
ll:= ShallowCopy( scT[i][j] );
ll[1]:= ll[1] + n1;
T[n1+i][n1+j]:= ll;
od;
od;
# Set the (anti)symmetric flag
if scT[n2 + 1] = sym then
T[n + 1] := sym;
fi;
if Characteristic( LeftActingDomain( A1 ) ) = 2 and sym in [ 1, -1 ]
and scT[n2 + 1] in [ 1, -1 ] then
T[n + 1] := 1;
fi;
L:= AlgebraByStructureConstants( LeftActingDomain( A1 ), T );
# Maintain useful information.
if HasIsLieAlgebra( A1 ) and HasIsLieAlgebra( A2 )
and IsLieAlgebra( A1 ) and IsLieAlgebra( A2 ) then
SetIsLieAlgebra( L, true );
if HasRootSystem( A1 ) and HasRootSystem( A2 ) then
# We can easily compute the root system of `L'.
R1:= RootSystem( A1 ); R2:= RootSystem( A2 );
f1:= LeftModuleGeneralMappingByImages( A1, L, CanonicalBasis(A1),
CanonicalBasis(L){[1..Dimension(A1)]} );
f2:= LeftModuleGeneralMappingByImages( A2, L, CanonicalBasis(A2),
CanonicalBasis(L){[Dimension(A1)+1..Dimension(L)]} );
R:= Objectify( NewType( NewFamily( "RootSystemFam", IsObject ),
IsAttributeStoringRep and IsRootSystemFromLieAlgebra ),
rec() );
RV:= List( PositiveRootVectors( R1 ), x -> Image( f1, x ) );
Append( RV, List( PositiveRootVectors( R2 ),
x -> Image( f2, x ) ) );
SetPositiveRootVectors( R, RV );
RV:= List( NegativeRootVectors( R1 ), x -> Image( f1, x ) );
Append( RV, List( NegativeRootVectors( R2 ),
x -> Image( f2, x ) ) );
SetNegativeRootVectors( R, RV );
RV:= List( PositiveRoots( R1 ), ShallowCopy );
for i in [1..Length(RV)] do
Append( RV[i], ListWithIdenticalEntries(
Length( CartanMatrix( R2 ) ),
Zero( LeftActingDomain( A2 ) ) ) );
od;
for i in PositiveRoots( R2 ) do
r:= ListWithIdenticalEntries( Length( CartanMatrix( R1 ) ),
Zero( LeftActingDomain( A1 ) ) );
Append( r, i );
Add( RV, r );
od;
SetPositiveRoots( R, RV );
RV:= List( NegativeRoots( R1 ), ShallowCopy );
for i in [1..Length(RV)] do
Append( RV[i], ListWithIdenticalEntries(
Length( CartanMatrix( R2 ) ),
Zero( LeftActingDomain( A2 ) ) ) );
od;
for i in NegativeRoots( R2 ) do
r:= ListWithIdenticalEntries( Length( CartanMatrix( R1 ) ),
Zero( LeftActingDomain( A1 ) ) );
Append( r, i );
Add( RV, r );
od;
SetNegativeRoots( R, RV );
pos:= List( SimpleSystem( R1 ), x -> Position(
PositiveRoots(R1), x ) );
RV:= PositiveRoots( R ){pos};
pos:= List( SimpleSystem( R2 ), x -> Position(
PositiveRoots(R2), x ) + Length( PositiveRoots(R1) ));
Append( RV, PositiveRoots( R ){pos} );
SetSimpleSystem( R, RV );
RV:= [ ];
for i in [1,2,3] do
RV[i]:= List( CanonicalGenerators( R1 )[i],
x -> Image( f1, x ) );
Append( RV[i], List( CanonicalGenerators( R2 )[i],
x -> Image( f2, x ) ) );
od;
SetCanonicalGenerators( R, RV );
SetCartanMatrix( R, DirectSumMat( CartanMatrix( R1 ),
CartanMatrix( R2 ) ) );
SetUnderlyingLieAlgebra( R, L );
SetRootSystem( L, R );
if HasChevalleyBasis( A1 ) and HasChevalleyBasis( A2 ) then
RV:= [ ];
for i in [1,2,3] do
RV[i]:= List( ChevalleyBasis( A1 )[i],
x -> Image( f1, x ) );
Append( RV[i], List( ChevalleyBasis( A2 )[i],
x -> Image( f2, x ) ) );
od;
SetChevalleyBasis( L, RV );
fi;
fi;
if HasSemiSimpleType( A1 ) and HasSemiSimpleType( A2 ) then
SetSemiSimpleType( L, Concatenation( SemiSimpleType(A1)," ",
SemiSimpleType( A2 ) ) );
fi;
if HasIsRestrictedLieAlgebra ( A1 ) and HasIsRestrictedLieAlgebra ( A2 )
and IsRestrictedLieAlgebra ( A1 ) and IsRestrictedLieAlgebra ( A2 )
then
SetIsRestrictedLieAlgebra( L, true );
if HasPthPowerImages( Basis ( A1 ) )
and HasPthPowerImages( Basis ( A2 ) ) then
if not IsBound (f1) then
f1:= LeftModuleGeneralMappingByImages( A1, L,
CanonicalBasis(A1),
CanonicalBasis(L){[1..Dimension(A1)]} );
f2:= LeftModuleGeneralMappingByImages( A2, L,
CanonicalBasis(A2),
CanonicalBasis(L){[Dimension(A1)+1..Dimension(L)]});
fi;
SetPthPowerImages( Basis ( L ),
Concatenation ( List (PthPowerImages( Basis ( A1 ) ), x->x^f1),
List (PthPowerImages( Basis ( A2 ) ), x->x^f2) ) );
fi;
fi;
fi;
if HasIsAssociative( A1 ) and HasIsAssociative( A2 )
and IsAssociative( A1 ) and IsAssociative( A2 ) then
SetIsAssociative( L, true );
fi;
# Return the result.
return L;
end );
#############################################################################
##
#M DirectSumOfAlgebras( <list> ) . . . . . . . for a dense list of algebras
##
InstallMethod( DirectSumOfAlgebras,
"for list of algebras",
[ IsDenseList ],
function( list )
local R, A, i;
if IsEmpty( list ) then
Error( "<list> must be nonempty" );
fi;
R:= LeftActingDomain( list[1] );
for A in list do
if not IsFLMLOR( A ) or LeftActingDomain( A ) <> R then
Error( "all entries in <list> must be FLMLORs over <R>" );
fi;
od;
A:= list[1];
for i in [ 2 .. Length( list ) ] do
A:= DirectSumOfAlgebras( A, list[i] );
od;
return A;
end );
#############################################################################
##
#O IsCentral( <A>, <U> ) . . . . . . . . test if <U> is centralized by <A>
##
## Check whether every basis vector of <A> commutes with every basis vector
## of the subset <U>.
##
## For associative algebras, we have to check $u a = a u$ only for algebra
## generators $a$ and $u$ of $A$ and $U$, respectively,
## not for all vectors of a basis.
##
InstallMethod( IsCentral,
"for two FLMLORs",
IsIdenticalObj,
[ IsFLMLOR, IsFLMLOR ],
IsCentralFromGenerators( GeneratorsOfLeftModule,
GeneratorsOfLeftModule ) );
InstallMethod( IsCentral,
"for two associative FLMLORs",
IsIdenticalObj,
[ IsFLMLOR and IsAssociative, IsFLMLOR and IsAssociative ],
IsCentralFromGenerators( GeneratorsOfAlgebra,
GeneratorsOfAlgebra ) );
InstallMethod( IsCentral,
"for two associative FLMLORs-with-one",
IsIdenticalObj,
[ IsFLMLORWithOne and IsAssociative,
IsFLMLORWithOne and IsAssociative ],
IsCentralFromGenerators( GeneratorsOfAlgebraWithOne,
GeneratorsOfAlgebraWithOne ) );
#############################################################################
##
#F FreeAlgebraConstructor( <name>, <magma> )
##
## is used for a uniform treatment of free (associative) algebras(-with-one)
##
BindGlobal( "FreeAlgebraConstructor", function( name, magma )
return function( arg )
local R, # coefficients ring
names, # names of the algebra generators
M, # magma
A, # algebra
F, # family
i;
# Check the argument list.
if Length( arg ) = 0 or not IsRing( arg[1] ) then
Error( "first argument must be a ring" );
fi;
R:= arg[1];
# Construct names of generators.
if Length( arg ) = 2 and IsInt( arg[2] ) then
names:= List( [ 1 .. arg[2] ],
i -> Concatenation( "x.", String(i) ) );
MakeImmutable( names );
elif Length( arg ) = 2
and IsList( arg[2] )
and ForAll( arg[2], IsString ) then
names:= arg[2];
elif Length( arg ) = 3 and IsInt( arg[2] ) and IsString( arg[3] ) then
names:= List( [ 1 .. arg[2] ],
x -> Concatenation( arg[3], ".", String(x) ) );
MakeImmutable( names );
elif ForAll( arg{ [ 2 .. Length( arg ) ] }, IsString ) then
names:= arg{ [ 2 .. Length( arg ) ] };
else
Error( "usage: ", name, "( <R>, <rank> )\n",
"or ", name, "( <R>, <name1>, ... )" );
fi;
M := magma( names );
# Construct the algebra as free magma algebra of a free magma over `R'.
A := FreeMagmaRing( R, M );
# Store the names.
F := ElementsFamily( FamilyObj( A ) );
F!.names:= names;
# Install grading
if HasOne(M) then i := 0; else i := 1; fi;
SetGrading( A, rec(min_degree := i,
max_degree := infinity,
source := Integers,
hom_components := function(degree)
local i, d, B, x, y;
if HasOne(M) then
B := [[One(M)],GeneratorsOfMagmaWithOne(M)];
else
B := [[],GeneratorsOfMagma(M)];
fi;
for d in [2..degree] do
Add(B,[]);
if IsAssociative(M) then
for x in B[2] do for y in B[d] do
Add(B[d+1],x*y);
od; od;
else
for i in [2..d] do
for x in B[i] do for y in B[d+2-i] do
Add(B[d+1],x*y);
od; od;
od;
fi;
od;
x := Zero(R);
y := [One(R)];
return VectorSpace(R, List(B[degree+1],
p->ElementOfMagmaRing( F, x, y, [p] )));
end));
# Return the result.
return A;
end;
end );
#############################################################################
##
#F FreeAlgebra( <R>, <rank> ) . . . . . . . . . . free algebra of given rank
#F FreeAlgebra( <R>, <rank>, <name> )
#F FreeAlgebra( <R>, <name1>, <name2>, ... )
##
InstallGlobalFunction( FreeAlgebra,
FreeAlgebraConstructor( "FreeAlgebra", FreeMagma ) );
#############################################################################
##
#F FreeAlgebraWithOne( <R>, <rank> ) . . free algebra-with-one of given rank
#F FreeAlgebraWithOne( <R>, <rank>, <name> )
#F FreeAlgebraWithOne( <R>, <name1>, <name2>, ... )
##
InstallGlobalFunction( FreeAlgebraWithOne,
FreeAlgebraConstructor( "FreeAlgebraWithOne", FreeMagmaWithOne ) );
#############################################################################
##
#F FreeAssociativeAlgebra( <R>, <rank> )
#F FreeAssociativeAlgebra( <R>, <rank>, <name> )
#F FreeAssociativeAlgebra( <R>, <name1>, <name2>, ... )
##
InstallGlobalFunction( FreeAssociativeAlgebra,
FreeAlgebraConstructor( "FreeAssociativeAlgebra", FreeSemigroup ) );
#############################################################################
##
#F FreeAssociativeAlgebraWithOne( <R>, <rank> )
#F FreeAssociativeAlgebraWithOne( <R>, <rank>, <name> )
#F FreeAssociativeAlgebraWithOne( <R>, <name1>, <name2>, ... )
##
InstallGlobalFunction( FreeAssociativeAlgebraWithOne,
FreeAlgebraConstructor( "FreeAssociativeAlgebraWithOne", FreeMonoid ) );
#############################################################################
##
#M \.( <F>, <n> ) . . . . . . . . . access to generators of a free algebra
##
InstallAccessToGenerators( IsMagmaRingModuloRelations,
"magma ring containing the whole family",
GeneratorsOfAlgebra );
InstallAccessToGenerators( IsMagmaRingModuloRelations and IsRingWithOne,
"magma ring-with-one containing the whole family",
GeneratorsOfAlgebraWithOne );
#############################################################################
##
#M CentralIdempotentsOfAlgebra( <A> )
##
## Let A be an associative algebra with one. We construct a maximal
## system of orthogonal primitive idemoptents in the centre of A.
## First we let B be the centre of A and Q the
## the semisimple commutative associative algebra A/Rad(A).
## We calculate a complete set of orthogonal idempotents in `Q'
## and then lift them to A.
## The orthogonal idempotents in `Q' correspond to the decomposition
## of `Q' as a direct sum of simple ideals. Now `ideals' will contain
## a list of ideals of `Q' such that the direct sum of these equals
## `Q'. The variable `ids' will contain the idempotents corresponding
## to the ideals in `ids'.
## The algorithms has two parts: one for small fields (of size less than
## `2*Dimension( Q )', and one for big fields.
## If the field is big, then using a Las Vegas algorithm we find a
## splitting element (this is an element that generates `Q'). By
## factoring the minimal polynomial of such element we can find a
## complete set of orthogonal idempotents in one step.
## However, if the field is small splitting elements might not exist.
## In this case we use decomposable elements (of which the minimum
## polynomial factors into two (or more) relatively prime factors.
## Then using the same procedure as for splitting elements we can
## find some idempotents. But in this case the corresponding ideals
## might split further. So we have to find decomposable elements in
## these and so on.
## Decomposable elements are found as follows: first we calculate
## the subalgebra of all elements x such that x^q=x
## (where `q=Size( F )').
## This subalgebra is a number of copies of the ground field. So any
## element independent from 1 of this subalgebra will have a minimum
## polynomial that splits completely. On the other hand, if 1 is the
## only basis vector of this subalgebra than the original algebra was
## simple.
## For a more elaborate description we refer to "W. Eberly and M.
## Giesbrecht, Efficient Decomposition of Associative Algebras,
## Proceedings of ISSAC 1996."
##
InstallMethod( CentralIdempotentsOfAlgebra,
"for an associative algebra",
[ IsAlgebra ],
function( A )
local F,B,Rad,Q,bQ,ids,ideals,id,i,j,k,l,set,cf,e,vv,sp,x,f,q,sol,
eq,facs,hlist,c,p,g,gcd,bb,E,ei,ni,hom,qq;
if One( A ) = fail then TryNextMethod(); fi;
F:=LeftActingDomain(A);
B:=Centre(A);
Rad:= RadicalOfAlgebra( B );
hom:= NaturalHomomorphismByIdeal( B, Rad );
Q:= ImagesSource( hom );
bQ:= BasisVectors( Basis( Q ) );
ids:= [ One( Q ) ];
ideals:= [ Q ];
# The variable `k' will point to the first element of `ideals' that
# still has to be decomposed.
k:=1;
if Size(F) > 2*Dimension( Q )^2 then
set:= [ 0 .. 2*Dimension(Q)^2 ]*One( F );
else
set:= [ ];
fi;
repeat
if Length( set ) > 1 then
# We are in the case of a big field.
repeat
# We try to find an element of `Q' that generates it.
# If we take the coefficients of such an element randomly
# from a set of `2*Dimension(Q)^2' elements,
# then this element generates `Q' with probability > 1/2
bQ:= BasisVectors( Basis( ideals[k] ) );
cf:= List( [ 1 .. Length(bQ) ], x -> Random( set ) );
e:= LinearCombination( bQ, cf );
# Now we calculate the minimum polynomial of `e'.
vv:= [ MultiplicativeNeutralElement( ideals[k] ) ];
sp:= MutableBasis( F, vv );
x:= ShallowCopy( e );
while not IsContainedInSpan( sp, x ) do
Add( vv, x );
CloseMutableBasis( sp, x );
x:= x*e;
od;
sp:= UnderlyingLeftModule( ImmutableBasis( sp ) );
cf:= ShallowCopy(
- Coefficients( BasisNC( sp, vv ), x )
);
Add( cf, One( F ) );
f:= ElementsFamily( FamilyObj( F ) );
f:= LaurentPolynomialByCoefficients( f, cf, 0 );
until DegreeOfLaurentPolynomial( f ) = Dimension( Q );
else
# Here the field is small.
q:= Size( F );
# `sol' will be a basis of the subalgebra of the k-th ideal
# consisting of all elements x such that x^q=x.
# If the length of this list is 1,
# then the ideal is simple and we proceed to the next one. If all
# ideals are simple then we quit the loop.
sol:= [ ];
while Length( sol ) < 2 and k <= Length( ideals ) do
bQ:= BasisVectors( Basis( ideals[k] ) );
eq:= [ ];
for i in [1..Dimension( ideals[k] )] do
Add( eq, Coefficients( Basis( ideals[k] ), bQ[i]^q-bQ[i] ) );
od;
sol:= List( NullspaceMat( eq ),
x -> LinearCombination( bQ, x ) );
if Length(sol) = 1 then k:=k+1; fi;
od;
if k>Length(ideals) then break; fi;
vv:= [ MultiplicativeNeutralElement( ideals[k] ) ];
sp:= MutableBasis( F, vv );
e:= sol[1];
if IsContainedInSpan( sp, e ) then e:=sol[2]; fi;
# We calculate the minimum polynomial of `e'.
x:= ShallowCopy( e );
while not IsContainedInSpan( sp, x ) do
Add( vv, x );
CloseMutableBasis( sp, x );
x:= x*e;
od;
sp:= UnderlyingLeftModule( ImmutableBasis( sp ) );
cf:= ShallowCopy(
- Coefficients( BasisNC( sp, vv ), x )
);
Add( cf, One( F ) );
f:= ElementsFamily( FamilyObj( F ) );
f:= LaurentPolynomialByCoefficients( f, cf, 0 );
fi;
facs:= Factors( PolynomialRing( F ), f );
# Now we find elements h1,...,hs such that `hi = 1 mod facs[i]' and
# `hi = 0 mod facs[j]' if `i<>j'.
# This is possible due to the Chinese remainder theorem.
hlist:= [ ];
for i in [1..Length( facs )] do
cf:= List( [ 1..Length( facs ) ], x -> Zero( F ) );
cf[i]:= One(F);
j:= 1;
c:= cf[1];
p:= facs[1];
while j < Length(facs) do
j:= j + 1;
g:= GcdRepresentation( p, facs[j] );
gcd:= g[1]*p+g[2]*facs[j];
qq:= g[1]*(cf[j]-c)/gcd;
if qq<>0*qq then
c:= p*EuclideanRemainder( qq, facs[j] )
+ c;
fi;
p:= p*facs[j] / gcd;
od;
Add( hlist, EuclideanRemainder( c*facs[i]^0 , p ) );
od;
# Now a set of orthogonal idempotents is given by `hi(e)'.
# We evaluate `hi(e)' in a rather strange way; this in order to make
# sure that the one is the one of `ideals[ k ]' ('e^0' will be the
# one of the big algebra `Q').
id:= List( hlist, x -> Value( x, e,
MultiplicativeNeutralElement( ideals[k] ) ) );
if Length(set) = 0 then
# We are in the case of a small field;
# so we append the new idempotents and ideals
# (and erase the old ones). (If `E' is an idempotent,
# then the corresponding ideal is given by `E*Q*E'.)
Append(ids,id);
for l in [1..Length(id)] do
bb:=List(BasisVectors(Basis(ideals[k])),x->id[l]*x*id[l]);
Add(ideals,Subalgebra(Q,bb));
od;
ideals:=Filtered(ideals,x->x<>ideals[k]);
ids:=Filtered(ids,x->x<>ids[k]);
else
# Here the field is big so we found the complete list of idempotents
# in one step.
ids:= id;
k:=Length(ideals)+1;
fi;
while k<=Length(ideals) and Dimension( ideals[k] ) = 1 do k:=k+1; od;
until k>Length(ideals);
id:= List( ids, e -> PreImagesRepresentative( hom, e ) );
# Now we lift the idempotents to the big algebra `A'. The
# first idempotent is lifted as follows:
# We have that `id[1]^2-id[1]' is an element of `Rad'.
# We construct the sequences e_{i+1} = e_i + n_i - 2e_in_i,
# and n_{i+1}=e_{i+1}^2-e_{i+1}, starting with e_0=id[1].
# It can be proved by induction that e_q is an idempotent in `A'
# because n_0^{2^q}=0.
# Now `E' will be the sum of all idempotents lifted so far.
# Then the next lifted idempotent is obtained by setting
# `ei:=id[i]-E*id[i]-id[i]*E+E*id[i]*E;'
# and lifting as above. It can be proved that in this manner we
# get an orthogonal system of primitive idempotents.
E:= Zero( F )*id[1];
for i in [1..Length(id)] do
ei:= id[i]-E*id[i]-id[i]*E+E*id[i]*E;
q:= 0;
while 2^q <= Dimension( Rad ) do
q:= q+1;
od;
ni:= ei*ei-ei;
for j in [1..q] do
ei:= ei+ni-2*ei*ni;
ni:= ei*ei-ei;
od;
id[i]:= ei;
E:= E+ei;
od;
return AsSSortedList(id);
end );
##############################################################################
##
#M IsSimpleAlgebra( <A> ) . . . . . . . . . . . .for an associative algebra
##
## A test whether <A> is simple.
##
InstallMethod( IsSimpleAlgebra,
"for an associative algebra",
[ IsAlgebra ],
function( A )
if not IsAssociative( A ) then
TryNextMethod();
fi;
if Dimension( RadicalOfAlgebra( A ) ) <> 0 then
return false;
else
return Length( CentralIdempotentsOfAlgebra( A ) ) = 1;
fi;
end );
###############################################################################
##
#M LeviMalcevDecomposition( <L> )
##
## A Levi-Malcev subalgebra of `L' is a semisimple subalgebra complementary to
## the radical `R'. We find a Levi-Malcev subalgebra of `L' by first
## computing a complementary subspace to `R'. This subspace is a Levi-Malcev
## subalgebra modulo `R'. Then we change the basis vectors such that they
## form a basis of a Levi-Malcev subalgebra modulo the second term of the
## derived series of `R' after that we consider the third term of the
## derived series, and so on.
##
InstallMethod( LeviMalcevDecomposition,
"for an associative or a Lie algebra",
[ IsAlgebra ],
function( L )
local R, # The solvable radical of `L'.
s, # The dimension of the Levi subalgebra.
F, # coefficients domain of `L'
bas,bb, # Lists of basiselements.
sp, # A vector space.
subalg, # Boolean.
a,i,j,k,l,m, # Loop variables.
x, # Element of `L'.
ser, # The derived series of `R'.
p, # The length of the derived series.
Rbas, # A special basis of `R'.
levi, # Basis of a Levi complement.
T, # Structure constants table of `L', w.r.t. a
# particular basis.
cf,cf1,cf2, # Coefficient vectors.
klist, # List of integers.
comp, # List of basis vectors of a complement.
dim, # The length of `comp'.
B, # A basis.
cij, # Entry of the table of structure constants.
eqs, # Matrix of equation set.
rl, # Right hand side of the equation system.
eqno, # Number of the equation.
sol, # Solution set to the equations.
r,offset; # Integers.
if IsLieAlgebra( L ) then
R:= LieSolvableRadical( L );
offset:= 1;
elif IsAssociative( L ) then
R:= RadicalOfAlgebra( L );
offset:=0;
fi;
if Dimension( R ) = 0 then
return [ L, R ];
elif Dimension( R ) = Dimension( L ) then
return [ TrivialSubalgebra( L ), R ];
fi;
s:= Dimension( L ) - Dimension( R );
# `bb' will be a basis of a complement to `R' in `L'.
bas:= ShallowCopy( BasisVectors( Basis( R ) ) );
F:= LeftActingDomain( L );
sp:= MutableBasis( F, bas );
bb:= [ ];
for k in BasisVectors( Basis( L ) ) do
if Length( bb ) = s then
break;
elif not IsContainedInSpan( sp, k ) then
Add( bb, k );
CloseMutableBasis( sp, k );
fi;
od;
sp:= MutableBasis( F, bb );
subalg:= true;
for i in [1..Length(bb)] do
for j in [offset*i+1..Length(bb)] do
if not IsContainedInSpan( sp, bb[i]*bb[j] ) then
subalg:= false;
break;
fi;
od;
od;
if subalg then
Info( InfoAlgebra, 1,
"LeviDecomposition: subalgebra test successful" );
return [ SubalgebraNC( L, bb, "basis" ), R ];
fi;
ser:= PowerSubalgebraSeries( R );
# We now calculate a basis of `R' such that the first k1 elements
# form a basis of the last nonzero term of the derived series `ser',
# the first k2 ( k2>k1 ) elements form a basis of the next to last
# element of the derived series, and so on.
p:= Length( ser );
i:= p-1;
Rbas:= ShallowCopy( BasisVectors( Basis( ser[p-1] ) ) );
sp:= MutableBasis( F, Rbas );
while Length(Rbas) < Dimension(R) do
if Length(Rbas) = Dimension(ser[i]) then
i:= i-1;
k:= 1;
else
x:= BasisVectors( Basis( ser[i] ) )[k];
if not IsContainedInSpan( sp, x ) then
Add( Rbas, x );
CloseMutableBasis( sp, x );
fi;
k:= k+1;
fi;
od;
levi:= ShallowCopy( bb );
Append(bb,Rbas);
# So now `bb' is a list of basis vectors of `L' such that
# the first elements form a basis of a complement to `R'
# and the remaining elements are a basis for `R' of the form
# described above.
# We now calculate a structure constants table of `L' w.r.t. this basis.
sp:= VectorSpace( F, bb );
B:= BasisNC( sp, bb );
T:= List([1..s],x->[]);
for i in [1..s] do
for j in [offset*i+1..s] do
cf:= Coefficients( B, levi[i]*levi[j] ){[1..s]};
klist:= Filtered([1..s],i->cf[i]<>0);
cf:= Filtered(cf,x->x<>0);
T[i][j]:= [klist,cf];
od;
od;
# Now `levi' is a Levi-Malcev subalgebra modulo `R'.
# The loop modifies this modulo statement.
# After the first round `levi' will be a Levi-Malcev subalgebra modulo
# the second element of the derived series.
# After the second step `levi' will be a Levi-Malcev subalgebra modulo
# the third element of the derived series.
# And so on.
for a in [1..p-1] do
# `comp' will be a basis of the complement of the `a+1'-th element
# of the derived series in the `a'-th element of the derived series.
# `B' will be a basis of the `a'-th term of the derived series,
# such that the basis elements of the complement come first.
# So if we have an element v of the `a'-th term of the derived series,
# then by taking the coefficients w.r.t. `B', we can easily find
# the part that belongs to `comp'.
# The equations we have are vector equations in the space `comp',
# i.e., in the quotient of two elements of the derived series.
# But we do not want to work with this quotient directly.
comp:= Rbas{ [ Dimension(ser[a+1])+1 .. Dimension(ser[a]) ] };
dim:= Length(comp);
bb:= ShallowCopy( comp );
for i in [1..Dimension(ser[a+1])] do
Add(bb,Rbas[i]);
od;
sp:= VectorSpace( F, bb );
B:= BasisNC( sp, bb );
cf:= List( comp, x -> Coefficients( B, x ){[1..dim]} );
eqs:= NullMat( s*dim, dim*s*(s-offset)/(offset+1), F );
rl:= [];
for i in [1..s] do
for j in [offset*i+1..s] do
cij:= T[i][j];
for k in [1..dim] do
cf1:= Coefficients(B,levi[i]*comp[k]){[1..dim]};
cf2:= Coefficients(B,comp[k]*levi[j]){[1..dim]};
for l in [1..dim] do
if IsAssociative( L ) then
eqno:= (i-1)*s*dim+(j-1)*dim+l;
else
eqno:= (i-1)*(2*s-i)*dim/2+(j-i-1)*dim+l;
fi;
eqs[(j-1)*dim+k][eqno]:= eqs[(j-1)*dim+k][eqno]+cf1[l];
eqs[(i-1)*dim+k][eqno]:= eqs[(i-1)*dim+k][eqno]+cf2[l];
for m in [1..Length(cij[1])] do
r:=cij[1][m];
if r <= s then
eqs[(r-1)*dim+k][eqno]:= eqs[(r-1)*dim+k][eqno]-
cij[2][m]*cf[k][l];
fi;
od;
od;
od;
x:= Zero(L);
for m in [1..Length(cij[1])] do
if cij[1][m] <= s then
x:= x+cij[2][m]*levi[cij[1][m]];
fi;
od;
x:= x-levi[i]*levi[j];
Append(rl,Coefficients(B,x){[1..dim]});
od;
od;
sol:= SolutionMat( eqs, rl );
if sol = fail then return sol; fi;
for i in [1..s] do
for j in [1..dim] do
levi[i]:=levi[i]+sol[(i-1)*dim+j]*comp[j];
od;
od;
od;
return [ SubalgebraNC( L, levi, "basis" ), R ];
end );
############################################################################
##
#M DirectSumDecomposition( <A> ) ........direct sum decomposition of <A>
##
InstallMethod( DirectSumDecomposition,
"for semisimple associative algebras",
[ IsAlgebra and IsAssociative ],
function( A )
local R;
R:= RadicalOfAlgebra( A );
if Dimension( R ) > 0 then
TryNextMethod();
fi;
return List( CentralIdempotentsOfAlgebra( A ), x -> Ideal( A, [ x ] ) );
end );
#############################################################################
##
#E
|