File: types.g

package info (click to toggle)
gap-atlasrep 2.1.9-1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,688 kB
  • sloc: xml: 20,993; javascript: 155; makefile: 113; sh: 1
file content (3955 lines) | stat: -rw-r--r-- 144,645 bytes parent folder | download
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
3949
3950
3951
3952
3953
3954
3955
#############################################################################
##
#W  types.g              GAP 4 package AtlasRep                 Thomas Breuer
##
##  This file contains implementations of the actual data types used in the
##  &ATLAS; of Group Representations.
##


#############################################################################
##
#V  AtlasOfGroupRepresentationsInfo
##
BindGlobal( "AtlasOfGroupRepresentationsInfo", rec(

    # user parameters
    accessFunctions := AtlasOfGroupRepresentationsAccessFunctionsDefault,

    # system parameters (filled automatically)
    GAPnames := [],

    ringinfo := [],

    permrepinfo := rec(),

    characterinfo := rec(),

    notified := [],

    filenames := [],
    newfilenames := [],

    TableOfContents := rec( core   := rec(),
                            types  := rec( rep   := [],
                                           prg   := [],
                                           cache := [] ),
                            merged := rec() ),

    TOC_Cache := rec(),
    ) );


#############################################################################
##
#D  Permutation representations
##
##  <#GAPDoc Label="type:perm:format">
##  <Mark><M>groupname</M><C>G</C><M>i</M><C>-p</C><M>n</M><M>id</M><C>B</C><M>m</M><C>.m</C><M>nr</M></Mark>
##  <Item>
##    a file in &MeatAxe; text file format
##    containing the <M>nr</M>-th generator of a permutation representation
##    on <M>n</M> points.
##    An example is <C>M11G1-p11B0.m1</C>.
##  </Item>
##  <#/GAPDoc>
##
AGR.DeclareDataType( "rep", "perm", rec(

    # `<groupname>G<i>-p<n><id>B<m>.m<nr>'
    FilenameFormat := [ [ [ IsChar, "G", IsDigitChar ],
                          [ "p", IsDigitChar, AGR.IsLowerAlphaOrDigitChar,
                            "B", IsDigitChar, ".m", IsDigitChar ] ],
                        [ ParseBackwards, ParseForwards ] ],

    AddDescribingComponents := function( record, type )
      local repid, parsed, comp, info, pos;

      repid:= record.identifier[2][1];
      if not IsString( repid ) then
        repid:= repid[2];
      fi;
      parsed:= AGR.ParseFilenameFormat( repid, type[2].FilenameFormat );
      record.p:= Int( parsed[5] );
      record.id:= parsed[6];
      repid:= repid{ [ 1 .. Position( repid, '.' ) - 1 ] };
      if IsBound( AtlasOfGroupRepresentationsInfo.characterinfo.(
                      record.groupname ) ) then
        info:= AtlasOfGroupRepresentationsInfo.characterinfo.(
                   record.groupname );
        if IsBound( info[1] ) then
          info:= info[1];
          pos:= Position( info[2], repid );
          if pos <> fail then
            record.constituents:= info[1][ pos ];
            if info[3][ pos ] <> fail then
              record.charactername:= info[3][ pos ];
            fi;
          fi;

        fi;
      fi;
      if IsBound( AtlasOfGroupRepresentationsInfo.permrepinfo.( repid ) ) then
        repid:= AtlasOfGroupRepresentationsInfo.permrepinfo.( repid );
        for comp in [ "isPrimitive", "orbits", "rankAction", "stabilizer",
                      "transitivity", "maxnr" ] do
          if IsBound( repid.( comp ) ) and repid.( comp ) <> "???" then
            record.( comp ):= repid.( comp );
          fi;
        od;
      fi;
    end,

    # `[ <i>, <n>, <id>, <m>, <filenames> ]'
    AddFileInfo := function( list, entry, name )
      local known;
      if 0 < entry[5] then
        known:= First( list, x -> x{ [ 1 .. 4 ] } = entry{ [3, 5, 6, 8 ] } );
        if known = fail then
          known:= entry{ [ 3, 5, 6, 8 ] };
          Add( known, [] );
          Add( list, known );
        fi;
        known[5][ entry[10] ]:= name;
        return true;
      fi;
      return false;
    end,

    DisplayOverviewInfo := [ "#", "r", function( conditions )
      # Put *all* types of representations together, in particular
      # assume that the functions for the other "rep" kind types are trivial!
      local info, no;

      conditions:= ShallowCopy( conditions );
      conditions[1]:= conditions[1][1];
      info:= CallFuncList( AllAtlasGeneratingSetInfos, conditions );
      no:= Length( info );
      if no = 0 then
        no:= "";
      fi;
      return [ String( no ),
               not ForAll( info,
                           x -> IsString( x.identifier[2] )
                                or ForAll( x.identifier[2], IsString ) ) ];
    end ],

    AccessGroupCondition := function( info, cond )
      return  AGR.CheckOneCondition( IsPermGroup, x -> x = true, cond )
          and AGR.CheckOneCondition( IsPermGroup, cond )
          and AGR.CheckOneCondition( IsMatrixGroup, x -> x = false, cond )
          and AGR.CheckOneCondition( NrMovedPoints,
                  x -> ( IsFunction( x ) and x( info.p ) = true )
                       or info.p = x, cond )
          and AGR.CheckOneCondition( IsTransitive,
                  x -> ( not IsBound( info.transitivity ) and x = fail ) or
                       ( IsBound( info.transitivity ) and
                         ( ( IsFunction( x ) and x( info.transitivity > 0 ) = true )
                           or ( info.transitivity > 0 ) = x ) ), cond )
          and AGR.CheckOneCondition( Transitivity,
                  x -> ( not IsBound( info.transitivity ) and x = fail ) or
                       ( IsBound( info.transitivity ) and
                         ( ( IsFunction( x ) and x( info.transitivity ) = true )
                           or info.transitivity = x ) ), cond )
          and AGR.CheckOneCondition( IsPrimitive,
                  x -> ( not IsBound( info.isPrimitive ) and x = fail ) or
                       ( IsBound( info.isPrimitive ) and
                         ( ( IsFunction( x ) and x( info.isPrimitive ) = true )
                           or info.isPrimitive = x ) ), cond )
          and AGR.CheckOneCondition( RankAction,
                  x -> ( not IsBound( info.rankAction ) and x = fail ) or
                       ( IsBound( info.rankAction ) and
                         ( ( IsFunction( x ) and x( info.rankAction ) = true )
                           or info.rankAction = x ) ), cond )
          and AGR.CheckOneCondition( Identifier,
                  x -> ( IsFunction( x ) and x( info.id ) = true )
                       or info.id = x, cond )
          and IsEmpty( cond );
    end,

    DisplayGroup := function( r )
      local disp, sep;

      if AGR.ShowOnlyASCII() then
        disp:= Concatenation( "G <= Sym(", String( r.p ), r.id, ")" );
      else
        disp:= Concatenation( "G ≤ Sym(", String( r.p ), r.id, ")" );
      fi;
      if IsBound( r.transitivity ) then
        disp:= [ disp ];
        if   r.transitivity = 0 then
          # For intransitive repres., show the orbit lengths.
          Add( disp, Concatenation( "orbit lengths ",
            JoinStringsWithSeparator( List( r.orbits, String ), ", " ) ) );
          sep:= ", ";
        elif r.transitivity = 1 then
          # For transitivity 1, show the rank (if known).
          if IsBound( r.rankAction ) and r.rankAction <> "???" then
            Add( disp, Concatenation( "rank ", String( r.rankAction ) ) );
            sep:= ", ";
          fi;
        elif IsInt( r.transitivity ) then
          # For transitivity at least 2, show the transitivity.
          Add( disp, Concatenation( String( r.transitivity ), "-trans." ) );
          sep:= ", ";
        else
          # The transitivity is not known.
          Add( disp, "" );
          sep:= "";
        fi;
        if 0 < r.transitivity then
          # For transitive representations, more info may be available.
          if IsBound( r.isPrimitive ) and r.isPrimitive then
            if IsBound( r.stabilizer ) and r.stabilizer <> "???" then
              Add( disp, Concatenation( sep, "on cosets of " ) );
              Add( disp, r.stabilizer );
              if IsBound( r.maxnr ) and r.maxnr <> "???" then
                Add( disp, Concatenation( " (",
                                          Ordinal( r.maxnr ), " max.)" ) );
              else
                Add( disp, "" );
              fi;
            elif IsBound( r.maxnr ) and r.maxnr <> "???" then
              Add( disp, Concatenation( sep, "on cosets of ",
                                        Ordinal( r.maxnr ), " max." ) );
            else
              Add( disp, Concatenation( sep, "primitive" ) );
            fi;
          elif IsBound( r.stabilizer ) and r.stabilizer <> "???" then
            Add( disp, Concatenation( sep, "on cosets of " ) );
            Add( disp, r.stabilizer );
          fi;
        fi;
      fi;
      return disp;
    end,

    TestFileHeaders := function( tocid, groupname, entry, type )
      local name, cand, filename, len, file, line;

      if tocid = "core" then
        tocid:= "datagens";
      fi;

      # Each generator is stored in a file of its own.
      for name in entry[ Length( entry ) ] do

        # Consider only local files, do not download them.
        cand:= AtlasOfGroupRepresentationsLocalFilename(
                   [ [ tocid, name ] ], type );
        if not ( Length( cand ) = 1 and ForAll( cand[1][2], x -> x[2] ) ) then
          return true;
        fi;
        filename:= cand[1][2][1][1];
        len:= Length( filename );
        if 3 < len and filename{ [ len-2 .. len ] } = ".gz" then
          filename:= filename{ [ 1 .. len-3 ] };
        fi;

        # Read the first line of the file.
        file:= InputTextFile( filename );
        if file = fail then
          return Concatenation( "cannot create input stream for file `",
                     filename,"'" );
        fi;
        AGR.InfoRead( "#I  reading `",filename,"' started\n" );
        line:= ReadLine( file );
        if line = fail then
          CloseStream( file );
          return Concatenation( "no first line in file `",filename,"'" );
        fi;
        while not '\n' in line do
          Append( line, ReadLine( file ) );
        od;
        CloseStream( file );
        AGR.InfoRead( "#I  reading `",filename,"' done\n" );

        # The header must consist of four nonnegative integers.
        line:= CMeatAxeFileHeaderInfo( line );
        if line = fail then
          return Concatenation( "illegal header of file `", filename,"'" );
        fi;

        # Start the specific tests for permutations.
        # Check mode, number of permutations, and degree.
        if   line[1] <> 12 then
          return Concatenation( "mode of file `", name,
                     "' differs from 12" );
        elif line[4] <> 1 then
          return Concatenation(
                "more than one permutation in file `", name, "'" );
        elif line[3] <> entry[2] then
          return Concatenation( "perm. degree in file `",
                     name, "' is ", String( line[3] ) );
        fi;

      od;
      return true;
    end,

    TestFiles := AGR.TestFilesMTX,

    # Permutation representations are sorted according to
    # degree and identification string.
    SortTOCEntries := entry -> entry{ [ 2, 3 ] },

    # Check whether the right number of files is available for each repres.
    PostprocessFileInfo := function( toc, record )
      local list, i;
      list:= record.perm;
      for i in [ 1 .. Length( list ) ] do
        if not IsDenseList( list[i][5] ) then
#T better check whether the number of generators equals the number of
#T standard generators
          Info( InfoAtlasRep, 1, "not all generators for ", list[i][5] );
          Unbind( list[i] );
        fi;
      od;
      if not IsDenseList( list ) then
        record.perm:= Compacted( list );
      fi;
    end,

    # We store the type, the full filename, and the list of CRC values.
    TOCEntryString := function( typename, entry )
      local list, pos, name, crc, info;

      list:= AtlasOfGroupRepresentationsInfo.filenames;
      pos:= List( entry[5], nam -> PositionSorted( list, [ nam ] ) );
      if ForAll( pos, x -> x <= Length( list ) ) and
         List( pos, x -> list[x][1] ) = entry[5] then
        name:= list[ pos[1] ][2];
        crc:= List( pos, i -> AGR_Checksum( list[i], typename ) );
        info:= Concatenation( "\"", typename, "\",\"",
            name{ [ 1 .. PositionSublist( name, ".m" ) + 1 ] }, "\"" );
        if not fail in crc then
          Append( info, Concatenation( ",[",
                            JoinStringsWithSeparator( crc, "," ), "]" ) );
        fi;
        return info;
      fi;
      return fail;
    end,

    # The default access reads the text format files.
    # Note that `ScanMeatAxeFile' returns a list of permutations.
    ReadAndInterpretDefault := paths -> Concatenation( List( paths,
                                            ScanMeatAxeFile ) ),

    InterpretDefault := strings -> Concatenation( List( strings,
                                 str -> ScanMeatAxeFile( str, "string" ) ) ),
    ) );


#############################################################################
##
#D  Matrix representations over finite fields
##
##  <#GAPDoc Label="type:matff:format">
##  <Mark><M>groupname</M><C>G</C><M>i</M><C>-f</C><M>q</M><C>r</C><M>dim</M><M>id</M><C>B</C><M>m</M><C>.m</C><M>nr</M></Mark>
##  <Item>
##    a file in &MeatAxe; text file format
##    containing the <M>nr</M>-th generator of a matrix representation
##    over the field with <M>q</M> elements, of dimension <M>dim</M>.
##    An example is <C>S5G1-f2r4aB0.m1</C>.
##  </Item>
##  <#/GAPDoc>
##
AGR.DeclareDataType( "rep", "matff",   rec(

    # `<groupname>G<i>-f<q>r<dim><id>B<m>.m<nr>'
    FilenameFormat := [ [ [ IsChar, "G", IsDigitChar ],
                          [ "f", IsDigitChar, "r", IsDigitChar,
                            AGR.IsLowerAlphaOrDigitChar,
                            "B", IsDigitChar, ".m", IsDigitChar ] ],
                        [ ParseBackwards, ParseForwards ] ],

    AddDescribingComponents := function( record, type )
      local repid, parsed, info, char, pos;

      repid:= record.identifier[2][1];
      if not IsString( repid ) then
        repid:= repid[2];
      fi;
      parsed:= AGR.ParseFilenameFormat( repid, type[2].FilenameFormat );
      record.dim:= Int( parsed[7] );
      record.id:= parsed[8];
      record.ring:= GF( parsed[5] );
      if IsBound( AtlasOfGroupRepresentationsInfo.characterinfo.(
                      record.groupname ) ) then
        info:= AtlasOfGroupRepresentationsInfo.characterinfo.(
                   record.groupname );
        char:= Characteristic( record.ring );
        if IsBound( info[ char ] ) then
          info:= info[ char ];
          pos:= Position( info[2], repid{ [ 1 .. Position( repid, '.' ) - 1 ] } );
          if pos <> fail then
            record.constituents:= info[1][ pos ];
            if IsInt( record.constituents ) then
              record.constituents:= [ record.constituents ];
            fi;
            if info[3][ pos ] <> fail then
              record.charactername:= info[3][ pos ];
            fi;
          fi;
        fi;
      fi;
    end,

    # `[ <i>, <q>, <dim>, <id>, <m>, <filenames> ]'
    AddFileInfo := function( list, entry, name )
      local known;
      if IsPrimePowerInt( entry[5] ) and 0 < entry[7] then
        known:= First( list, x -> x{ [ 1 .. 5 ] }
                                  = entry{ [ 3, 5, 7, 8, 10 ] } );
        if known = fail then
          known:= entry{ [ 3, 5, 7, 8, 10 ] };
          Add( known, [] );
          Add( list, known );
        fi;
        known[6][ entry[12] ]:= name;
        return true;
      fi;
      return false;
    end,

    AccessGroupCondition := function( info, cond )
      return  AGR.CheckOneCondition( IsMatrixGroup, x -> x = true, cond )
          and AGR.CheckOneCondition( IsMatrixGroup, cond )
          and AGR.CheckOneCondition( IsPermGroup, x -> x = false, cond )
          and AGR.CheckOneCondition( Characteristic,
                  function( p )
                    local char;
                    char:= SmallestRootInt( Size( info.ring ) );
                    return char = p or IsFunction( p ) and p( char ) = true;
                  end,
                  cond )
          and AGR.CheckOneCondition( Dimension,
                  x -> ( IsFunction( x ) and x( info.dim ) )
                       or info.dim = x, cond )
          and AGR.CheckOneCondition( Ring,
                  R -> ( IsFunction( R ) and R( info.ring ) ) or
                       ( IsField( R ) and IsFinite( R )
                         and Size( info.ring ) mod Characteristic( R ) = 0
                         and DegreeOverPrimeField( R )
                            mod LogInt( Size( info.ring ),
                                        Characteristic( R ) ) = 0 ),
                  cond )
          and AGR.CheckOneCondition( Identifier,
                  x -> ( IsFunction( x ) and x( info.id ) = true )
                       or info.id = x, cond )
          and IsEmpty( cond );
    end,

    DisplayGroup := function( r )
      local disp;

      if AGR.ShowOnlyASCII() then
        disp:= Concatenation( "G <= GL(", String( r.dim ), r.id,
                              ",", String( r.identifier[4] ), ")" );
        if IsBound( r.charactername ) then
          disp:= [ disp, Concatenation( "character ", r.charactername ) ];
        fi;
      else
        disp:= Concatenation( "G ≤ GL(", String( r.dim ), r.id,
                              ",", String( r.identifier[4] ), ")" );
        if IsBound( r.charactername ) then
          disp:= [ disp, Concatenation( "φ = ", r.charactername ) ];
        fi;
      fi;
      return disp;
    end,

    TestFileHeaders := function( tocid, groupname, entry, type )
      local name, cand, filename, len, file, line, errors;

      if tocid = "core" then
        tocid:= "datagens";
      fi;

      # Each generator is stored in a file of its own.
      for name in entry[ Length( entry ) ] do

        # Consider only local files, do not download them.
        cand:= AtlasOfGroupRepresentationsLocalFilename(
                   [ [ tocid, name ] ], type );
        if not ( Length( cand ) = 1 and ForAll( cand[1][2], x -> x[2] ) ) then
          return true;
        fi;
        filename:= cand[1][2][1][1];
        len:= Length( filename );
        if 3 < len and filename{ [ len-2 .. len ] } = ".gz" then
          filename:= filename{ [ 1 .. len-3 ] };
        fi;

        # Read the first line of the file.
        file:= InputTextFile( filename );
        if file = fail then
          return Concatenation( "cannot create input stream for file `",
                     filename,"'" );
        fi;
        AGR.InfoRead( "#I  reading `",filename,"' started\n" );
        line:= ReadLine( file );
        if line = fail then
          CloseStream( file );
          return Concatenation( "no first line in file `",filename,"'" );
        fi;
        while not '\n' in line do
          Append( line, ReadLine( file ) );
        od;
        CloseStream( file );
        AGR.InfoRead( "#I  reading `",filename,"' done\n" );

        # The header must consist of four nonnegative integers.
        line:= CMeatAxeFileHeaderInfo( line );
        if line = fail then
          return Concatenation( "illegal header of file `", filename,"'" );
        fi;

        # Start the specific tests for matrices over finite fields.
        # Check mode, field size, and dimension.
        errors:= "";
        if   6 < line[1] then
          Append( errors, Concatenation( "mode of file `", name,
                            "' is larger than 6" ) );
        elif line[2] <> entry[2] then
          Append( errors, Concatenation( "file `", name,
                            "': field is of size ", String( line[2] ) ) );
        elif line[3] <> entry[3] then
          Append( errors, Concatenation( "file `", name,
                            "': matrix dimension is ", String( line[3] ) ) );
        elif line[3] <> line[4] then
          Append( errors, Concatenation( "file `", name,
                            "': matrix is not square" ) );
        fi;
        if not IsEmpty( errors ) then
          return errors;
        fi;

      od;
      return true;
    end,

    TestFiles := AGR.TestFilesMTX,

    # Matrix representations over finite fields are sorted according to
    # field size, dimension, and identification string.
    SortTOCEntries := entry -> entry{ [ 2 .. 4 ] },

    # Check whether the right number of files is available for each repres.
    PostprocessFileInfo := function( toc, record )
      local list, i;
      list:= record.matff;
      for i in [ 1 .. Length( list ) ] do
        if not IsDenseList( list[i][6] ) then
#T better check whether the number of generators equals the number of
#T standard generators
          Info( InfoAtlasRep, 1, "not all generators for ", list[i][6] );
          Unbind( list[i] );
        fi;
      od;
      if not IsDenseList( list ) then
        record.matff:= Compacted( list );
      fi;
    end,

    # We store the type, the full filename, and the list of CRC values.
    TOCEntryString := function( typename, entry )
      local list, pos, name, crc, info;

      list:= AtlasOfGroupRepresentationsInfo.filenames;
      pos:= List( entry[6], nam -> PositionSorted( list, [ nam ] ) );
      if ForAll( pos, x -> x <= Length( list ) ) and
         List( pos, x -> list[x][1] ) = entry[6] then
        name:= list[ pos[1] ][2];
        crc:= List( pos, i -> AGR_Checksum( list[i], typename ) );
        info:= Concatenation( "\"", typename, "\",\"",
            name{ [ 1 .. PositionSublist( name, ".m" ) + 1 ] }, "\"" );
        if not fail in crc then
          Append( info, Concatenation( ",[",
                            JoinStringsWithSeparator( crc, "," ), "]" ) );
        fi;
        return info;
      fi;
      return fail;
    end,

    # The default access reads the text format files.
    ReadAndInterpretDefault := paths -> List( paths, ScanMeatAxeFile ),

    InterpretDefault := strings -> List( strings,
                                 str -> ScanMeatAxeFile( str, "string" ) ),
    ) );


#############################################################################
##
#D  Matrix representations over the integers
##
##  <#GAPDoc Label="type:matint:format">
##  <Mark><M>groupname</M><C>G</C><M>i</M><C>-Zr</C><M>dim</M><M>id</M><C>B</C><M>m</M>.g</Mark>
##  <Item>
##    a &GAP; readable file
##    containing all generators of a matrix representation
##    over the integers, of dimension <M>dim</M>.
##    An example is <C>A5G1-Zr4B0.g</C>.
##  </Item>
##  <#/GAPDoc>
##
AGR.DeclareDataType( "rep", "matint",  rec(

    # `<groupname>G<i>-Zr<dim><id>B<m>.g'
    FilenameFormat := [ [ [ IsChar, "G", IsDigitChar ],
                        [ "Zr", IsDigitChar, AGR.IsLowerAlphaOrDigitChar,
                          "B", IsDigitChar, ".g" ] ],
                        [ ParseBackwards, ParseForwards ] ],

    AddDescribingComponents := function( record, type )
      local repid, parsed, info, pos;

      repid:= record.identifier[2];
      if not IsString( repid ) then
        # one private file
        repid:= repid[1][2];
      fi;
      parsed:= AGR.ParseFilenameFormat( repid, type[2].FilenameFormat );
      record.dim:= Int( parsed[5] );
      record.id:= parsed[6];
      record.ring:= Integers;
      if IsBound( AtlasOfGroupRepresentationsInfo.characterinfo.(
                      record.groupname ) ) then
        info:= AtlasOfGroupRepresentationsInfo.characterinfo.(
                   record.groupname );
        if IsBound( info[1] ) then
          info:= info[1];
          pos:= Position( info[2], repid{ [ 1 .. Position( repid, '.' ) - 1 ] } );
          if pos <> fail then
            record.constituents:= info[1][ pos ];
            if IsInt( record.constituents ) then
              record.constituents:= [ record.constituents ];
            fi;
            if info[3][ pos ] <> fail then
              record.charactername:= info[3][ pos ];
            fi;
          fi;
        fi;
      fi;
    end,

    # `[ <i>, <dim>, <id>, <m>, <filename> ]'
    AddFileInfo := function( list, entry, name )
      if 0 < entry[5] then
        Add( list, Concatenation( entry{ [ 3, 5, 6, 8 ] }, [ name ] ) );
        return true;
      fi;
      return false;
    end,

    AccessGroupCondition := function( info, cond )
      return  AGR.CheckOneCondition( IsMatrixGroup, x -> x = true, cond )
          and AGR.CheckOneCondition( IsMatrixGroup, cond )
          and AGR.CheckOneCondition( IsPermGroup, x -> x = false, cond )
          and AGR.CheckOneCondition( Characteristic,
                  p -> p = 0 or ( IsFunction( p ) and p( 0 ) = true ),
                  cond )
          and AGR.CheckOneCondition( Dimension,
                  x -> ( IsFunction( x ) and x( info.dim ) )
                       or info.dim = x, cond )
          and AGR.CheckOneCondition( Ring,
                  R -> ( IsFunction( R ) and R( Integers ) ) or
                       ( IsRing( R ) and IsCyclotomicCollection( R ) ), cond )
          and AGR.CheckOneCondition( Identifier,
                  x -> ( IsFunction( x ) and x( info.id ) = true )
                       or info.id = x, cond )
          and IsEmpty( cond );
    end,

    TestFileHeaders := function( tocid, groupname, entry, type )
      return AGR.TestFileHeadersDefault( tocid, groupname, entry, type,
               entry[2],
               function( entry, mats, filename )
                 if not ForAll( mats, mat -> ForAll( mat,
                                 row -> ForAll( row, IsInt ) ) ) then
                   return Concatenation( "matrices in `", filename,
                              "' are not over the integers" );
                 fi;
                 return true;
               end );
    end,

    DisplayGroup := function( r )
      local disp;

      if AGR.ShowOnlyASCII() then
        disp:= Concatenation( "G <= GL(", String( r.dim ), r.id, ",Z)" );
        if IsBound( r.charactername ) then
          disp:= [ disp, Concatenation( "character ", r.charactername ) ];
        fi;
      else
        disp:= Concatenation( "G ≤ GL(", String( r.dim ), r.id, ",ℤ)" );
        if IsBound( r.charactername ) then
          disp:= [ disp, Concatenation( "χ = ", r.charactername ) ];
        fi;
      fi;
      return disp;
    end,

    # Matrix representations over the integers are sorted according to
    # dimension and identification string.
    SortTOCEntries := entry -> entry{ [ 2, 3 ] },

    # There is only one file.
    ReadAndInterpretDefault := function( paths )
      if EndsWith( paths[1], ".json" ) then
        return AtlasDataJsonFormatFile( paths[1] ).generators;
      else
        return AtlasDataGAPFormatFile( paths[1] ).generators;
      fi;
    end,

    InterpretDefault := function( strings )
      if strings[1][1] = '{' then
        return AtlasDataJsonFormatFile( strings[1], "string" ).generators;
      else
        return AtlasDataGAPFormatFile( strings[1], "string" ).generators;
      fi;
    end,
    ) );


#############################################################################
##
#D  Matrix representations over algebraic number fields
##
##  <#GAPDoc Label="type:matalg:format">
##  <Mark><M>groupname</M><C>G</C><M>i</M><C>-Ar</C><M>dim</M><M>id</M><C>B</C><M>m</M><C>.g</C></Mark>
##  <Item>
##    a &GAP; readable file
##    containing all generators of a matrix representation of dimension
##    <M>dim</M> over an algebraic number field not specified further.
##    An example is <C>A5G1-Ar3aB0.g</C>.
##  </Item>
##  <#/GAPDoc>
##
AGR.DeclareDataType( "rep", "matalg",  rec(

    # `<groupname>G<i>-Ar<dim><id>B<m>.g'
    FilenameFormat := [ [ [ IsChar, "G", IsDigitChar ],
                        [ "Ar", IsDigitChar, AGR.IsLowerAlphaOrDigitChar,
                          "B", IsDigitChar, ".g" ] ],
                        [ ParseBackwards, ParseForwards ] ],

    AddDescribingComponents := function( record, type )
      local repid, parsed, info, F, gens, pos;

      repid:= record.identifier[2];
      if not IsString( repid ) then
        # one private file
        repid:= repid[1][2];
      fi;
      parsed:= AGR.ParseFilenameFormat( repid, type[2].FilenameFormat );
      record.dim:= Int( parsed[5] );
      record.id:= parsed[6];
      info:= repid{ [ 1 .. Position( repid, '.' )-1 ] };
      info:= First( AtlasOfGroupRepresentationsInfo.ringinfo,
                    x -> x[1] = info );
      if info <> fail then
        F:= info[3];
        record.ring:= F;
        if IsField( F ) then
          gens:= GeneratorsOfField( F );
          if Length( gens ) = 1 then
            # is true for all currently available representations
            record.polynomial:= CoefficientsOfUnivariatePolynomial(
                                    MinimalPolynomial( Rationals, gens[1] ) );
          fi;
        fi;
      fi;
      if IsBound( AtlasOfGroupRepresentationsInfo.characterinfo.(
                      record.groupname ) ) then
        info:= AtlasOfGroupRepresentationsInfo.characterinfo.(
                   record.groupname );
        if IsBound( info[1] ) then
          info:= info[1];
          pos:= Position( info[2], repid{ [ 1 .. Position( repid, '.' ) - 1 ] } );
          if pos <> fail then
            record.constituents:= info[1][ pos ];
            if IsInt( record.constituents ) then
              record.constituents:= [ record.constituents ];
            fi;
            if info[3][ pos ] <> fail then
              record.charactername:= info[3][ pos ];
            fi;
          fi;
        fi;
      fi;
    end,

    # `[ <i>, <dim>, <id>, <m>, <filename> ]'
    AddFileInfo := function( list, entry, name )
      if 0 < entry[5] then
        Add( list, Concatenation( entry{ [ 3, 5, 6, 8 ] }, [ name ] ) );
        return true;
      fi;
      return false;
    end,

    AccessGroupCondition := function( info, cond )
      return  AGR.CheckOneCondition( IsMatrixGroup, x -> x = true, cond )
          and AGR.CheckOneCondition( IsMatrixGroup, cond )
          and AGR.CheckOneCondition( IsPermGroup, x -> x = false, cond )
          and AGR.CheckOneCondition( Characteristic,
                  p -> p = 0 or ( IsFunction( p ) and p( 0 ) = true ),
                  cond )
          and AGR.CheckOneCondition( Dimension,
                  x -> ( IsFunction( x ) and x( info.dim ) = true )
                       or info.dim = x, cond )
          and AGR.CheckOneCondition( Ring,
                  x -> IsIdenticalObj( x, Cyclotomics ) or
                       ( not IsBound( info.ring ) and x = fail ) or
                       # case of a field consisting of cyclotomics
                       ( IsBound( info.ring ) and
                         ( ( IsFunction( x ) and x( info.ring ) = true )
                           or ( IsRing( x ) and IsCyclotomicCollection( x )
#T problem with GAP:
#T 'IsSubset( Integers, CF(5) )' runs into an error
                                and ( not IsIdenticalObj( x, Integers ) and
                                      IsSubset( x, info.ring ) ) ) ) ) or
                       # case of a field not consisting of cyclotomics
                       ( IsBound( info.ring ) and
                         IsBound( info.polynomial ) and
                         IsField( x ) and Characteristic( x ) = 0 and
                         1 in List( Factors(
                                      UnivariatePolynomial( x,
                                        info.polynomial * One( x ), 1 ) ),
                                    Degree ) ), cond )
          and AGR.CheckOneCondition( Identifier,
                  x -> ( IsFunction( x ) and x( info.id ) = true )
                       or info.id = x, cond )
          and IsEmpty( cond );
    end,

    TestFileHeaders := function( tocid, groupname, entry, type )
      return AGR.TestFileHeadersDefault( tocid, groupname, entry, type,
               entry[2],
               function( entry, mats, filename )
                 local info;

                 if not IsCyclotomicCollCollColl( mats ) then
                   return Concatenation( "matrices in `",filename,
                              "' are not over cyclotomics" );
                 elif ForAll( Flat( mats ), IsInt ) then
                   return Concatenation( "matrices in `",filename,
                              "' are over the integers" );
                 fi;
                 filename:= filename{ [ 1 .. Position( filename, '.' )-1 ] };
                 info:= First( AtlasOfGroupRepresentationsInfo.ringinfo,
                               l -> l[1] = filename );
                 if info = fail then
                   return Concatenation( "field info for `",filename,
                              "' missing" );
                 elif Field( Rationals, Flat( mats ) ) <> info[3] then
                   return Concatenation( "field info for `",filename,
                              "' should be ",
                              String( Field( Rationals, Flat( mats ) ) ) );
                 fi;
                 return true;
               end );
    end,

    DisplayGroup := function( r )
      local fld, disp;

      fld:= r.identifier[2];
      if not IsString( fld ) then
        fld:= fld[1][2];
      fi;
      fld:= fld{ [ 1 .. Length( fld )-2 ] };
      fld:= First( AtlasOfGroupRepresentationsInfo.ringinfo,
                   p -> p[1] = fld );
      if AGR.ShowOnlyASCII() then
        if fld <> fail then
          fld:= fld[2];
        else
          fld:= "C";
        fi;
        disp:= Concatenation( "G <= GL(", String( r.dim ), r.id, ",",
                              fld, ")" );
        if IsBound( r.charactername ) then
          disp:= [ disp, Concatenation( "character ", r.charactername ) ];
        fi;
      else
        if fld <> fail then
          fld:= fld[2];
        else
          fld:= "â„‚";
        fi;
        disp:= Concatenation( "G ≤ GL(", String( r.dim ), r.id, ",",
                              fld, ")" );
        if IsBound( r.charactername ) then
          disp:= [ disp, Concatenation( "χ = ", r.charactername ) ];
        fi;
      fi;
      return disp;
    end,

    # Matrix representations over algebraic extension fields are sorted
    # according to dimension and identification string.
    SortTOCEntries := entry -> entry{ [ 2, 3 ] },

    # There is only one file.
    # It may be a GAP format file or a Json format file.
    ReadAndInterpretDefault := function( paths )
      if EndsWith( paths[1], ".json" ) then
        return AtlasDataJsonFormatFile( paths[1] ).generators;
      else
        return AtlasDataGAPFormatFile( paths[1] ).generators;
      fi;
    end,

    InterpretDefault := function( strings )
      if strings[1][1] = '{' then
        return AtlasDataJsonFormatFile( strings[1], "string" ).generators;
      else
        return AtlasDataGAPFormatFile( strings[1], "string" ).generators;
      fi;
    end,
    ) );


#############################################################################
##
#D  Matrix representations over residue class rings
##
##  <#GAPDoc Label="type:matmodn:format">
##  <Mark><M>groupname</M><C>G</C><M>i</M><C>-Z</C><M>n</M><C>r</C><M>dim</M><M>id</M><C>B</C><M>m</M><C>.g</C></Mark>
##  <Item>
##    a &GAP; readable file
##    containing all generators of a matrix representation of dimension
##    <M>dim</M> over the ring of integers mod <M>n</M>.
##    An example is <C>2A8G1-Z4r4aB0.g</C>.
##  </Item>
##  <#/GAPDoc>
##
AGR.DeclareDataType( "rep", "matmodn", rec(

    # `<groupname>G<i>-Z<n>r<dim><id>B<m>.g'
    FilenameFormat := [ [ [ IsChar, "G", IsDigitChar ],
                          [ "Z", IsDigitChar, "r", IsDigitChar,
                            AGR.IsLowerAlphaOrDigitChar,
                            "B", IsDigitChar, ".g" ] ],
                        [ ParseBackwards, ParseForwards ] ],

    AddDescribingComponents := function( record, type )
      local repid, parsed;

      repid:= record.identifier[2];
      if not IsString( repid ) then
        # one private file
        repid:= repid[1][2];
      fi;
      parsed:= AGR.ParseFilenameFormat( repid, type[2].FilenameFormat );
      record.dim:= Int( parsed[7] );
      record.id:= parsed[8];
      record.ring:= ZmodnZ( parsed[5] );
    end,

    # `[ <i>, <n>, <dim>, <id>, <m>, <filename> ]'
    AddFileInfo := function( list, entry, name )
      if 0 < entry[5] and 0 < entry[7] then
        Add( list, Concatenation( entry{ [ 3, 5, 7, 8, 10 ] }, [ name ] ) );
        return true;
      fi;
      return false;
    end,

    AccessGroupCondition := function( info, cond )
      return  AGR.CheckOneCondition( IsMatrixGroup, x -> x = true, cond )
          and AGR.CheckOneCondition( IsMatrixGroup, cond )
          and AGR.CheckOneCondition( IsPermGroup, x -> x = false, cond )
          and AGR.CheckOneCondition( Characteristic,
                  p -> p = fail or ( IsFunction( p ) and p( fail ) = true ),
                  cond )
          and AGR.CheckOneCondition( Dimension,
                  x -> ( IsFunction( x ) and x( info.dim ) )
                       or info.dim = x, cond )
          and AGR.CheckOneCondition( Ring,
                  R -> ( IsFunction( R ) and R( info.ring ) ) or
                       ( IsRing( R )
                  and IsZmodnZObjNonprimeCollection( R )
                  and Characteristic( One( R ) ) = Size( info.ring ) ),
                  cond )
          and AGR.CheckOneCondition( Identifier,
                  x -> ( IsFunction( x ) and x( info.id ) = true )
                       or info.id = x, cond )
          and IsEmpty( cond );
    end,

    DisplayGroup := function( r )
      if AGR.ShowOnlyASCII() then
        return Concatenation( "G <= GL(",String( r.dim ), r.id,
                              ",Z/", String( r.identifier[4] ),"Z)" );
      else
        return Concatenation( "G ≤ GL(",String( r.dim ), r.id,
                              ",ℤ/", String( r.identifier[4] ),"ℤ)" );
      fi;
    end,

    TestFileHeaders := function( tocid, groupname, entry, type )
      return AGR.TestFileHeadersDefault( tocid, groupname, entry, type,
               entry[3],
               function( entry, mats, filename )
                 if   not IsZmodnZObjNonprimeCollCollColl( mats ) then
                   return Concatenation( "matrices in `", filename,
                              "' are not over a residue class ring" );
                 elif Characteristic( mats[1][1,1] ) <> entry[2] then
                   return Concatenation( "matrices in `", filename,
                              "' are not over Z/", entry[2], "Z" );
                 fi;
                 return true;
               end );
    end,

    # Matrix representations over residue class rings are sorted according
    # to modulus, dimension, and identification string.
    SortTOCEntries := entry -> entry{ [ 2 .. 4 ] },

    # There is only one file.
    ReadAndInterpretDefault := paths -> AtlasDataGAPFormatFile(
                                            paths[1] ).generators,

    InterpretDefault := strings -> AtlasDataGAPFormatFile(
                                       strings[1], "string" ).generators,
    ) );


#############################################################################
##
#D  Quaternionic matrix representations
##
##  <#GAPDoc Label="type:quat:format">
##  <Mark><M>groupname</M><C>G</C><M>i</M><C>-Hr</C><M>dim</M><M>id</M><C>B</C><M>m</M><C>.g</C></Mark>
##  <Item>
##    a &GAP; readable file
##    containing all generators of a matrix representation
##    over a quaternion algebra over an algebraic number field,
##    of dimension <M>dim</M>.
##    An example is <C>2A6G1-Hr2aB0.g</C>.
##  </Item>
##  <#/GAPDoc>
##
AGR.DeclareDataType( "rep", "quat",  rec(

    # `<groupname>G<i>-Hr<dim><id>B<m>.g'
    FilenameFormat := [ [ [ IsChar, "G", IsDigitChar ],
                          [ "Hr", IsDigitChar, AGR.IsLowerAlphaOrDigitChar,
                            "B", IsDigitChar, ".g" ] ],
                        [ ParseBackwards, ParseForwards ] ],

    AddDescribingComponents := function( record, type )
      local repid, parsed, info;

      repid:= record.identifier[2];
      if not IsString( repid ) then
        # one private file
        repid:= repid[1][2];
      fi;
      parsed:= AGR.ParseFilenameFormat( repid, type[2].FilenameFormat );
      record.dim:= Int( parsed[5] );
      record.id:= parsed[6];
      info:= repid{ [ 1 .. Position( repid, '.' )-1 ] };
      info:= First( AtlasOfGroupRepresentationsInfo.ringinfo,
                    x -> x[1] = info );
      if info <> fail then
        record.ring:= info[3];
      fi;
    end,

    # `[ <i>, <dim>, <id>, <m>, <filename> ]'
    AddFileInfo := function( list, entry, name )
      if 0 < entry[5] then
        Add( list, Concatenation( entry{ [ 3, 5, 6, 8 ] }, [ name ] ) );
        return true;
      fi;
      return false;
    end,

    AccessGroupCondition := function( info, cond )
      return  AGR.CheckOneCondition( IsMatrixGroup, x -> x = true, cond )
          and AGR.CheckOneCondition( IsMatrixGroup, cond )
          and AGR.CheckOneCondition( IsPermGroup, x -> x = false, cond )
          and AGR.CheckOneCondition( Characteristic,
                  p -> p = 0 or ( IsFunction( p ) and p( 0 ) = true ),
                  cond )
          and AGR.CheckOneCondition( Dimension,
                  x -> ( IsFunction( x ) and x( info.dim ) = true )
                       or info.dim = x, cond )
          and AGR.CheckOneCondition( Ring,
                  x -> ( not IsBound( info.ring ) and x = fail ) or
                       ( IsBound( info.ring ) and
                         ( ( IsFunction( x ) and x( info.ring ) = true )
                           or ( IsRing( x ) and IsQuaternionCollection( x )
                                and IsSubset( x, info.ring ) ) ) ), cond )
          and AGR.CheckOneCondition( Identifier,
                  x -> ( IsFunction( x ) and x( info.id ) = true )
                       or info.id = x, cond )
          and IsEmpty( cond );
    end,

    TestFileHeaders := function( tocid, groupname, entry, type )
      return AGR.TestFileHeadersDefault( tocid, groupname, entry, type,
               entry[2],
               function( entry, mats, filename )
                 local info;

                 if not ForAll( mats, IsQuaternionCollColl ) then
                   return Concatenation( "matrices in `",filename,
                              "' are not over the quaternions" );
                 fi;
                 filename:= filename{ [ 1 .. Position( filename, '.' )-1 ] };
                 info:= First( AtlasOfGroupRepresentationsInfo.ringinfo,
                               l -> l[1] = filename );
                 if info = fail then
                   return Concatenation( "field info for `",filename,
                              "' missing" );
                 elif Field( Flat( List( Flat( mats ), ExtRepOfObj ) ) )
                      <> EvalString( Concatenation( "Field",
                             info[2]{ [ Position( info[2], '(' ) ..
                                      Length( info[2] ) ] } ) ) then
                   return Concatenation( "field info for `", filename,
                              "' should involve ",
                              Field( Flat( List( Flat( mats ),
                                                 ExtRepOfObj ) ) ) );
                 fi;
                 return true;
               end );
    end,

    DisplayGroup := function( r )
      local fld;

      fld:= r.identifier[2];
      if not IsString( fld ) then
        fld:= fld[1][2];
      fi;
      fld:= fld{ [ 1 .. Length( fld )-2 ] };
      fld:= First( AtlasOfGroupRepresentationsInfo.ringinfo,
                   p -> p[1] = fld );
      if AGR.ShowOnlyASCII() then
        if fld = fail then
          fld:= "QuaternionAlgebra(C)";
        else
          fld:= fld[2];
        fi;
        return Concatenation( "G <= GL(", String( r.dim ), r.id, ",", fld,
                              ")" );
      else
        if fld = fail then
          fld:= "QuaternionAlgebra(â„‚)";
        else
          fld:= fld[2];
        fi;
        return Concatenation( "G ≤ GL(", String( r.dim ), r.id, ",", fld,
                              ")" );
      fi;
    end,

    # Matrix representations over the quaternions are sorted according to
    # dimension and identification string.
    SortTOCEntries := entry -> entry{ [ 2, 3 ] },

    # There is only one file.
    ReadAndInterpretDefault := paths -> AtlasDataGAPFormatFile(
                                            paths[1] ).generators,

    InterpretDefault := strings -> AtlasDataGAPFormatFile(
                                       strings[1], "string" ).generators,
    ) );


#############################################################################
##
#D  Straight line programs for generators of maximal subgroups
##
##  <#GAPDoc Label="type:maxes:format">
##  <Mark><M>groupname</M><C>G</C><M>i</M><C>-max</C><M>k</M><C>W</C><M>n</M></Mark>
##  <Item>
##    In this case, the file contains a straight line program that takes
##    generators of <M>G</M> w.&nbsp;r.&nbsp;t.&nbsp;the <M>i</M>-th set
##    of standard generators,
##    and returns a list of generators
##    (in general <E>not</E> standard generators)
##    for a subgroup <M>U</M> in the <M>k</M>-th class of maximal subgroups
##    of <M>G</M>.
##    An example is <C>J1G1-max7W1</C>.
##  </Item>
##  <#/GAPDoc>
##
AGR.DeclareDataType( "prg", "maxes", rec(

    # `<groupname>G<i>-max<k>W<n>'
    FilenameFormat := [ [ [ IsChar, "G", IsDigitChar ],
                          [ "max", IsDigitChar, "W", IsDigitChar ] ],
                        [ ParseBackwards, ParseForwards ] ],

    # `[ <i>, <k>, <filename> ]'
    AddFileInfo := function( list, entry, name )
      if 0 < entry[5] then
        Add( list, Concatenation( entry{ [ 3, 5 ] }, [ name ] ) );
        return true;
      fi;
      return false;
    end,

    DisplayOverviewInfo := [ "maxes", "r", function( conditions )
      local groupname, tocs, std, info, factgroupinfo, maxext, value,
            private, toc, record, new, finfo, factgroupname;

      groupname:= conditions[1][2];
      tocs:= AGR.TablesOfContents( conditions );
      if Length( conditions ) = 1 or
         not ( IsInt( conditions[2] ) or IsList( conditions[2] ) ) then
        std:= true;
      else
        std:= conditions[2];
        if IsInt( std ) then
          std:= [ std ];
        fi;
      fi;

      info:= First( AtlasOfGroupRepresentationsInfo.GAPnames,
                    x -> x[2] = groupname );
      if info = fail or not IsBound( info[3].maxext )
                     or not IsBound( info[3].factorCompatibility ) then
        factgroupinfo:= [];
        maxext:= [];
      else
        factgroupinfo:= Filtered( info[3].factorCompatibility,
                                  x -> ( std = true or x[1] in std )
                                       and x[4] = true );
        maxext:= Filtered( info[3].maxext,
                            x -> std = true or x[1] in std );
      fi;

      value:= [];
      private:= false;
      for toc in tocs do
        # If a straight line program for the restriction is available
        # then take it.
        if IsBound( toc.( groupname ) ) then
          record:= toc.( groupname );
          if IsBound( record.maxes ) then
            new:= List( Filtered( record.maxes,
                                  x -> std = true or x[1] in std ),
                        x -> x[2] );
            if toc.TocID <> "core" and not IsEmpty( new ) then
              private:= true;
            fi;
            UniteSet( value, new );
          fi;
        fi;

        # If a straight line program is available for the restriction
        # to the maximal subgroup of a factor group,
        # and if this program can be used also here
        # then take it.
        for finfo in factgroupinfo do
          factgroupname:= finfo[2];
          info:= First( AtlasOfGroupRepresentationsInfo.GAPnames,
                        x -> x[1] = factgroupname );
          factgroupname:= info[2];
          if IsBound( toc.( factgroupname ) ) then
            record:= toc.( factgroupname );
            if IsBound( record.maxes ) then
              new:= List( Filtered( maxext,
                                    l -> ForAny( record.maxes,
                                                 fl -> fl[3] = l[3][1] ) ),
                          x -> x[2] );
              if toc.TocID <> "core" and not IsEmpty( new ) then
                private:= true;
              fi;
              UniteSet( value, new );
            fi;
          fi;
        od;
      od;
      if IsEmpty( value ) then
        value:= "";
      else
        value:= String( Length( value ) );
      fi;
      return [ value, private ];
    end ],

    DisplayPRG := function( tocs, names, std, stdavail )
      local data, sortkeys, alltocs, info,
            factgroupinfo, maxext, prvwidth, toc, record, i, private, mxstd,
            pos, finfo, factgroupname, facti, ker, kerid, pi, result, nrmaxes,
            title, entry, line, width, prvphantom, maxnr, j, line2;

      data:= [];
      sortkeys:= [];

      alltocs := AGR.TablesOfContents( "all" );
      info:= First( AtlasOfGroupRepresentationsInfo.GAPnames,
                    x -> x[2] = names[2] );
      if info = fail or not IsBound( info[3].maxext )
                     or not IsBound( info[3].factorCompatibility ) then
        factgroupinfo:= [];
        maxext:= [];
      else
        factgroupinfo:= Filtered( info[3].factorCompatibility,
                                  x -> ( std = true or x[1] in std )
                                       and x[4] = true );
        maxext:= Filtered( info[3].maxext,
                            x -> std = true or x[1] in std );
      fi;

      prvwidth:= 0;
      for toc in tocs do
        # If a straight line program for the restriction is available
        # then take it.
        if IsBound( toc.( names[2] ) ) then
          record:= toc.( names[2] );
          if IsBound( record.maxes ) then
            for i in record.maxes do
              if std = true or i[1] in std then
                if toc.TocID <> "core" then
                  private:= UserPreference( "AtlasRep",
                                "AtlasRepMarkNonCoreData" );
                  prvwidth:= Length( private );
                else
                  private := "";
                fi;

                entry:= [ ,
                          private,
                          String( i[1] ),
                          AGR.VersionOfSLP( i[3] ),
                          [ names[1], i[3], i[1] ] ];
                if toc.TocID <> "core" then
                  entry[5][2]:= [ [ toc.TocID, entry[5][2] ] ];
                fi;

                # If *standard* generators of the max. subgroup are available
                # (perhaps in another table of contents) then mention this,
                # in a line of its own;
                # note that Browse will allow one to click on the line.
                mxstd:= AGR.StandardizeMaximalSubgroup( names[2], i[3], true,
                                                        true );
                Add( data, entry );
                Add( sortkeys, [ i[2], i[1], Int( entry[4] ) ] );
                if mxstd <> fail then
                  entry:= ShallowCopy( entry );
                  entry[5]:= ShallowCopy( entry[5] );
                  if IsString( entry[5][2] ) then
                    entry[5][2]:= [ entry[5][2], mxstd[1] ];
                  else
                    Add( entry[5][2], mxstd[1] );
                  fi;
                  entry[6]:= Concatenation( "std. ", String( mxstd[2] ) );
                  Add( data, entry );
                  Add( sortkeys, [ i[2], i[1], Int( entry[4] ), mxstd[2] ] );
                fi;
              fi;
            od;
          fi;
        fi;

        # If a straight line program is available for the restriction
        # to the maximal subgroup of a factor group,
        # and if this program can be used also here
        # then take it.
        for finfo in factgroupinfo do
          factgroupname:= finfo[2];
          info:= First( AtlasOfGroupRepresentationsInfo.GAPnames,
                        x -> x[1] = factgroupname );
          factgroupname:= info[2];
          if IsBound( toc.( factgroupname ) ) then
            record:= toc.( factgroupname );
            if IsBound( record.maxes ) then
              for i in maxext do
                facti:= First( record.maxes, fl -> fl[3] = i[3][1] );
                if facti <> fail and ( std = true or i[1] in std ) then
                  if toc.TocID <> "core" then
                    private:= UserPreference( "AtlasRep",
                                  "AtlasRepMarkNonCoreData" );
                    prvwidth:= Length( private );
                  else
                    private := "";
                  fi;

                  entry:= [ ,
                            private,
                            String( i[1] ),
                            AGR.VersionOfSLP( facti[3] ),
                            [ names[1], i[3], i[1] ] ];
                  if Length( i[3] ) = 1 then
                    entry[5][2]:= i[3][1];
                    # No additional kernel generators are needed.
                    if toc.TocID <> "core" then
                      entry[5][2]:= [ [ toc.TocID, entry[5][2] ] ];
                    fi;
                  else
                    # We have to specify a program for computing the kernel.
                    ker:= AtlasProgramInfo( names[1], std, "kernel", finfo[2] );
                    if ker <> fail then
                      kerid:= ker.identifier[2];
                      if IsString( kerid ) then
                        entry[5][2]:= [ entry[5][2][1], kerid ];
                      else
                        entry[5][2]:= [ entry[5][2][1], kerid[1] ];
                      fi;
                      if toc.TocID <> "core" then
                        entry[5][2][1]:= [ toc.TocID, entry[5][2][1] ];
                      fi;
                    fi;
                  fi;
                  Add( data, entry );
                  Add( sortkeys, [ i[2], i[1], Int( entry[4] ) ] );
                fi;
              od;
            fi;
          fi;
        od;
      od;

      title:= "maxes";
      if not IsEmpty( data ) then
        entry:= First( AtlasOfGroupRepresentationsInfo.GAPnames,
                       x -> x[2] = names[2] );
        if IsBound( entry[3].nrMaxes ) then
          title:= "maxes (";
          nrmaxes:= Length( Set( List( sortkeys, x -> x[1] ) ) );
          if nrmaxes = entry[3].nrMaxes then
            Append( title, "all " );
          else
            Append( title, String( nrmaxes ) );
            Append( title, " out of " );
          fi;
          Append( title, String( entry[3].nrMaxes ) );
          Append( title, ")" );
        fi;

        SortParallel( sortkeys, data );

        width:= Length( String( sortkeys[ Length( sortkeys ) ][1] ) );
        prvphantom:= RepeatedString( " ", prvwidth );

        for i in [ 1 .. Length( data ) ] do
          # Compute the value for the first column (including privacy flag).
          maxnr:= sortkeys[i][1];
          line:= String( maxnr, width );
          Append( line, data[i][2] );
          if IsBound( entry[3].structureMaxes ) and
             IsBound( entry[3].structureMaxes[ maxnr ] ) then
            Append( line, ":  " );
            if data[i][2] = "" then
              Append( line, prvphantom );
            fi;
            Append( line, entry[3].structureMaxes[ maxnr ] );
          fi;
          data[i][1]:= line;
          data[i][2]:= "";
        od;
      fi;

      return AGR.CommonDisplayPRG( title, stdavail, data, false );
    end,

    # Create the program info from the identifier.
    AtlasProgramInfo := function( type, identifier, groupname )
      local filename, i, result, gapname;

      # We need only the information about the restriction part,
      # not a standardization or kernel generators.
      filename:= identifier[2];
      if not IsString( filename ) then
        if IsString( filename[1] ) then
          filename:= filename[1];
        else
          filename:= filename[1][2];
        fi;
      fi;

      i:= AGR.ParseFilenameFormat( filename, type[2].FilenameFormat );
      if i = fail then
        return fail;
      fi;
      i:= i[5];

      result:= rec( standardization := identifier[3],
                    identifier      := identifier );

      # Set the size if available.
      gapname:= First( AtlasOfGroupRepresentationsInfo.GAPnames,
                       pair -> pair[2] = groupname );
      if IsBound( gapname[3].sizesMaxes )
         and IsBound( gapname[3].sizesMaxes[i] ) then
        result.size:= gapname[3].sizesMaxes[i];
      fi;
      if IsBound( gapname[3].structureMaxes ) and
         IsBound( gapname[3].structureMaxes[i] ) then
        result.subgroupname:= gapname[3].structureMaxes[i];
      fi;

      return result;
    end,

    # Create the program from the identifier.
    AtlasProgram := function( type, identifier, groupname )
      local i, std, result, entry, prog, names, pos, maxstd, info, datadirs,
            name, kerprg, gapname;

      i:= identifier[2];
      if not IsString( i ) then
        i:= i[1];
        if not IsString( i ) then
          i:= i[2];
        fi;
      fi;
      i:= AGR.ParseFilenameFormat( i, type[2].FilenameFormat );
      if i = fail then
        return fail;
      fi;
      i:= i[5];
      std:= identifier[3];

      # The second entry is one of
      # - the filename of the program,
      # - this filename plus a filename for standardization
      #   (so we need the *composition* of two programs).
      # - this filename plus a filename for kernel generators
      #   (so we need the *union* of two sets of generators),
      if IsString( identifier[2] ) or Length( identifier[2] ) = 1 then
        # There is just one program.
        result:= AtlasProgramDefault( type, identifier, groupname );
      elif Length( identifier[2] ) = 2 then
        # The second entry describes two files.
        entry:= identifier[2][1];
        if IsString( entry ) then
          prog:= AGR.FileContents( [ [ "dataword", entry ] ], type );
          names:= [ entry ];
        else
          prog:= AGR.FileContents( [ entry ], type );
          names:= [ entry[2] ];
        fi;
        if prog = fail then
          return fail;
        fi;

        entry:= identifier[2][2];
        if IsString( entry ) then
          Add( names, entry );
        else
          Add( names, entry[2] );
          entry:= [ entry ];
        fi;

        # Decide in which situation we are.
        pos:= Position( names[2], '-' );
        if pos <> fail and names[2]{ [ 1 .. pos - 1 ] }
                           = ReplacedString( names[1], "-", "" ) then
          # One program for the restriction, one for the standardization.
          type:= First( AGR.DataTypes( "prg" ), x -> x[1] = "maxstd" );
          maxstd:= AtlasProgramDefault( type, [ groupname, entry, std ],
                       groupname );
          if maxstd = fail then
            return fail;
          fi;
          prog:= CompositionOfStraightLinePrograms( maxstd.program,
                                                    prog.program );
        else
          # One program for a factor group and some kernel generators
          # must be integrated.
          type:= First( AGR.DataTypes( "prg" ), x -> x[1] = "kernel" );
          kerprg:= AtlasProgramDefault( type, [ groupname, entry, std ],
                       groupname );
          if kerprg = fail then
            return fail;
          fi;
          prog:= [ prog.program, kerprg.program ];
          prog:= IntegratedStraightLineProgram( prog );
        fi;
        result:= rec( program         := prog,
                      standardization := std,
                      identifier      := identifier );
      else
        return fail;
      fi;

      # Set subgroup size and subgroup name if available.
      gapname:= First( AtlasOfGroupRepresentationsInfo.GAPnames,
                       pair -> pair[2] = groupname );
      if IsBound( gapname[3].sizesMaxes ) and
         IsBound( gapname[3].sizesMaxes[i] ) then
        result.size:= gapname[3].sizesMaxes[i];
      fi;
      if IsBound( gapname[3].structureMaxes ) and
         IsBound( gapname[3].structureMaxes[i] ) then
        result.subgroupname:= gapname[3].structureMaxes[i];
      fi;

      return result;
    end,

    # entry: `[ <std>, <maxnr>, <file> ]',
    # conditions: `[ "maxes", <maxnr> ]' or `[ "maxes", <maxnr>, <std2> ]'
    #             or together with `[ "version", <vers> ]'
    AccessPRG := function( toc, groupname, std, conditions )
      local std2, version, record, entry, mxstd, info, factgroupinfo, maxext,
            finfo, factgroupname, i, istd, ker;

      std2:= true;
      version:= true;
      if not ( Length( conditions ) in [ 2 .. 5 ] and conditions[1] = "maxes"
               and IsPosInt( conditions[2] ) ) then
        return fail;
      elif Length( conditions ) = 3 then
        std2:= conditions[3];
        if not IsPosInt( std2 ) then
          return fail;
        fi;
      elif Length( conditions ) = 4 then
        if conditions[3] <> "version" then
          return fail;
        fi;
        version:= String( conditions[4] );
      elif Length( conditions ) = 5 then
        std2:= conditions[3];
        if not ( IsPosInt( std2 ) and conditions[4] = "version" ) then
          return fail;
        fi;
        version:= String( conditions[5] );
      fi;

      if IsBound( toc.( groupname ) ) then
        record:= toc.( groupname );

        # If a straight line program for the restriction is available
        # then take it.
        if IsBound( record.maxes ) then
          for entry in record.maxes do
            if     ( std = true or entry[1] in std )
               and entry[2] = conditions[2] then
              if version = true or AGR.VersionOfSLP( entry[3] ) = version then
                # Note that the version number refers to the straight line
                # program for computing the restriction, not to the program
                # for standardizing the result of the restriction.
                # (This feature is needed by 'BrowseAtlasInfo'.)
                if std2 = true then
                  # We need not standardize the subgroup generators.
                  entry:= entry{ [ 3, 1 ] };
                  if toc.TocID <> "core" then
                    entry[1]:= [ [ toc.TocID, entry[1] ] ];
                  fi;
                  return entry;
                else
                  # We have to find a slp for computing *standard* generators
                  # of the max. subgp., perhaps in another table of contents.
                  mxstd:= AGR.StandardizeMaximalSubgroup( groupname,
                              entry[3], std2, true );
                  if mxstd <> fail then
                    entry:= [ [ entry[3], mxstd[1] ], entry[1] ];
                    if toc.TocID <> "core" then
                      entry[1][1]:= [ toc.TocID, entry[1][1] ];
                    fi;
                    return entry;
                  fi;
                fi;
              fi;
            fi;
          od;
        fi;
      fi;

      # If a straight line program is available for the restriction
      # to the maximal subgroup of a factor group,
      # and if this program can be used also here
      # then take it.
      # In this case, we cannot return *standard* generators.
      # We do not want to support version numbers,
      # they would depend on two programs.
      if Length( conditions ) <> 2 then
        return fail;
      fi;

      info:= First( AtlasOfGroupRepresentationsInfo.GAPnames,
                    x -> x[2] = groupname );
      if info = fail or not IsBound( info[3].maxext )
                     or not IsBound( info[3].factorCompatibility ) then
        return fail;
      fi;
      factgroupinfo:= Filtered( info[3].factorCompatibility,
                                x -> ( std = true or x[1] in std )
                                     and x[4] = true );
      maxext:= Filtered( info[3].maxext,
                          x -> ( std = true or x[1] in std )
                               and x[2] = conditions[2] );
      for finfo in factgroupinfo do
        factgroupname:= finfo[2];
        info:= First( AtlasOfGroupRepresentationsInfo.GAPnames,
                      x -> x[1] = factgroupname );
        factgroupname:= info[2];
        if IsBound( toc.( factgroupname ) ) then
          record:= toc.( factgroupname );
          if IsBound( record.maxes ) then
            for i in maxext do
              if ForAny( record.maxes, fl -> fl[3] = i[3][1] ) then
                entry:= i{ [ 3, 1 ] };
                if Length( entry[1] ) = 1 then
                  # No additional kernel generators are needed.
                  entry[1]:= entry[1][1];
                  if toc.TocID <> "core" then
                    entry[1]:= [ [ toc.TocID, entry[1] ] ];
                  fi;
                  return entry;
                else
                  # We have to specify a program for computing the kernel.
                  if std = true then
                    ker:= AtlasProgramInfo( AGR.GAPNameAtlasName( groupname ),
                                            "kernel", finfo[2] );
                  else
                    for istd in std do
                      ker:= AtlasProgramInfo( AGR.GAPNameAtlasName( groupname ),
                                              istd, "kernel", finfo[2] );
                      if ker <> fail then
                        break;
                      fi;
                    od;
                  fi;
                  if ker <> fail then
                    entry[1]:= ShallowCopy( entry[1] );
                    if IsString( ker.identifier[2] ) then
                      entry[1][2]:= ker.identifier[2];
                    else
                      entry[1][2]:= ker.identifier[2][1];
                    fi;
                    if toc.TocID <> "core" then
                      entry[1][1]:= [ toc.TocID, entry[1][1] ];
                    fi;
                    return entry;
                  fi;
                fi;
              fi;
            od;
          fi;
        fi;
      od;
      return fail;
    end,

    # Maxes are sorted according to their natural position.
    SortTOCEntries := entry -> entry[2],

    # In addition to the tests in `AGR.TestWordsSLPDefault',
    # compute the images in a representation if available,
    # and compare the group order with that stored in the
    # GAP Character Table Library (if available).
    TestWords:= function( tocid, name, file, type, verbose )
        local prog, prg, gens, pos, pos2, maxnr, gapname, storedsize, tbl,
              subname, subtbl, std, grp, size;

        # Read the program.
        if tocid = "core" then
          tocid:= "dataword";
        fi;
        prog:= AGR.FileContents( [ [ tocid, file ] ], type );
        if prog = fail then
          Print( "#E  file `", file, "' is corrupted\n" );
          return false;
        fi;

        # Check consistency.
        if prog = fail or not IsInternallyConsistent( prog.program ) then
          Print( "#E  program `", file, "' not internally consistent\n" );
          return false;
        fi;
        prg:= prog.program;

        # Create a list of trivial generators.
        gens:= ListWithIdenticalEntries(
                   NrInputsOfStraightLineProgram( prg ), () );

        # Run the program.
        gens:= ResultOfStraightLineProgram( prg, gens );

        # Compute the position in the `Maxes' list.
        pos:= PositionSublist( file, "-max" );
        pos2:= pos + 4;
        while file[ pos2 ] <> 'W' do
          pos2:= pos2 + 1;
        od;
        maxnr:= Int( file{ [ pos+4 .. pos2-1 ] } );

        # Fetch a perhaps stored value.
        gapname:= First( AtlasOfGroupRepresentationsInfo.GAPnames,
                         pair -> name = pair[2] );
        if gapname = fail then
          Print( "#E  problem: no GAP name for `", name, "'\n" );
          return false;
        fi;
        storedsize:= fail;
        if IsBound( gapname[3].sizesMaxes ) and
           IsBound( gapname[3].sizesMaxes[ maxnr ] ) then
          storedsize:= gapname[3].sizesMaxes[ maxnr ];
        fi;

        # Identify the group in the GAP Character Table Library.
        tbl:= CharacterTable( gapname[1] );
        if tbl = fail and storedsize = fail then
          if verbose then
            Print( "#I  no character table for `", gapname[1],
                   "', no check for `", file, "'\n" );
          fi;
          return true;
        fi;

        # Identify the subgroup in the GAP Character Table Library.
        if tbl <> fail then
          if HasMaxes( tbl ) then
            if Length( Maxes( tbl ) ) < maxnr then
              Print( "#E  program `", file,
                     "' contradicts `Maxes( ", tbl, " )'\n" );
              return false;
            fi;
            subname:= Maxes( tbl )[ maxnr ];
          else
            subname:= Concatenation( Identifier( tbl ), "M", String( maxnr ) );
          fi;
          subtbl:= CharacterTable( subname );
          if IsCharacterTable( subtbl ) then
            if storedsize <> fail and storedsize <> Size( subtbl ) then
              Print( "#E  program `", file,
                     "' contradicts stored subgroup order'\n" );
              return false;
            elif storedsize = fail then
              storedsize:= Size( subtbl );
            fi;
          elif storedsize = fail then
            if verbose then
              Print( "#I  no character table for `", subname,
                     "', no check for `", file, "'\n" );
            fi;
            return true;
          fi;
        fi;
        if storedsize = fail then
          return true;
        fi;

        # Compute the standardization.
        pos2:= pos - 1;
        while file[ pos2 ] <> 'G' do
          pos2:= pos2-1;
        od;
        std:= Int( file{ [ pos2+1 .. pos-1 ] } );

        # Get a representation if available, and map the generators.
        gapname:= gapname[1];
        gens:= OneAtlasGeneratingSetInfo( gapname, std,
                   NrMovedPoints, [ 2 .. AGR.Test.MaxTestDegree ],
                   "contents", [ tocid, "local" ] );
        if gens = fail then
          if verbose then
            Print( "#I  no perm. repres. for `", gapname,
                   "', no check for `", file, "'\n" );
          fi;
        else
          gens:= AtlasGenerators( gens );
          grp:= Group( gens.generators );
          if tbl <> fail then
            if IsBound( gens.size ) and gens.size <> Size( tbl ) then
              Print( "#E  wrong size for group`", gapname, "'\n" );
              return false;
            fi;
            SetSize( grp, Size( tbl ) );
          fi;
          gens:= ResultOfStraightLineProgram( prg, gens.generators );
          size:= Size( SubgroupNC( grp, gens ) );
          if size <> storedsize then
            Print( "#E  program `", file, "' for group of order ", size,
                   " not ", storedsize, "\n" );
            if subtbl <> fail then
              Print( "#E  (contradicts character table of `",
                     Identifier( subtbl ), "')\n" );
            fi;
            return false;
          fi;
        fi;

        # No more tests are available.
        return true;
    end,

    # There is only one file.
    ReadAndInterpretDefault := paths -> ScanStraightLineProgram( paths[1] ),

    InterpretDefault := strings -> ScanStraightLineProgram( strings[1],
                                       "string" ),
    ) );


#############################################################################
##
#D  Straight line programs for class representatives
##
##  <#GAPDoc Label="type:classes:format">
##  <Mark><M>groupname</M><C>G</C><M>i</M><C>-cclsW</C><M>n</M></Mark>
##  <Item>
##    In this case, the file contains a straight line program that returns
##    a list of conjugacy class representatives of <M>G</M>.
##    An example is <C>RuG1-cclsW1</C>.
##  </Item>
##  <#/GAPDoc>
##
AGR.DeclareDataType( "prg", "classes", rec(

    # `<groupname>G<i>-cclsW<n>'
    FilenameFormat := [ [ [ IsChar, "G", IsDigitChar ],
                          [ "cclsW", IsDigitChar ] ],
                        [ ParseBackwards, ParseForwards ] ],

    # `[ <i>, <filename> ]'
    AddFileInfo := function( list, entry, name )
      Add( list, Concatenation( entry{ [ 3 ] }, [ name ] ) );
      return true;
    end,

    DisplayOverviewInfo := [ "cl", "c", function( conditions )
      local groupname, tocs, std, value, private, toc, record, i, pos, rel;

      groupname:= conditions[1][2];
      tocs:= AGR.TablesOfContents( conditions );
      if Length( conditions ) = 1 or
         not ( IsInt( conditions[2] ) or IsList( conditions[2] ) ) then
        std:= true;
      else
        std:= conditions[2];
        if IsInt( std ) then
          std:= [ std ];
        fi;
      fi;

      value:= false;
      private:= false;
      for toc in tocs do
        if IsBound( toc.( groupname ) ) then
          record:= toc.( groupname );
          if IsBound( record.classes ) and
             ( ( std = true and not IsEmpty( record.classes ) ) or
               ForAny( record.classes, l -> l[1] in std ) ) then
            value:= true;
          elif IsBound( record.cyc2ccl ) and IsBound( record.cyclic ) then
            for i in record.cyc2ccl do
              # Check that for scripts of the form
              # `<groupname>G<i>cycW<n>-cclsW<m>',
              # a script of the form `<groupname>G<i>-cycW<n>' is available.
              pos:= PositionSublist( i[2], "cycW" );
              rel:= Concatenation( i[2]{ [ 1 .. pos-1 ] }, "-",
                        i[2]{ [ pos .. Position( i[2], '-' ) - 1 ] } );
              if ( std = true or i[1] in std ) and
                 ForAny( record.cyclic,
                     x -> x[2] = rel and ( std = true or x[1] in std ) ) then
                value:= true;
                break;
              fi;
            od;
          fi;
          if value then
            if toc.TocID <> "core" then
              private:= true;
            fi;
            break;
          fi;
        fi;
      od;
      if value then
        value:= "+";
      else
        value:= "";
      fi;
      return [ value, private ];
    end ],

    DisplayPRG := function( tocs, names, std, stdavail )
      local data, c2c, cyc, toc, record, private, i, filec2c, filecyc, pos,
            rel, match, entry;

      data:= [];

      # The information can be stored either directly or via two scripts
      # in `cyclic' and `cyc2ccl'.
      c2c:= [];
      cyc:= [];

      for toc in tocs do
        if IsBound( toc.( names[2] ) ) then
          record:= toc.( names[2] );
          if toc.TocID <> "core" then
            private:= UserPreference( "AtlasRep",
                          "AtlasRepMarkNonCoreData" );
          else
            private:= "";
          fi;
          if IsBound( record.classes ) then
            for i in record.classes do
              if std = true or i[1] in std then
                entry:= [ "",
                          private,
                          String( i[1] ),
                          AGR.VersionOfSLP( i[2] ),
                          [ names[1], i[2], i[1] ] ];
                if toc.TocID <> "core" then
                  entry[5][2]:= [ [ toc.TocID, entry[5][2] ] ];
                fi;
                Add( data, entry );
              fi;
            od;
          fi;

          if IsBound( record.cyc2ccl ) then
            for i in record.cyc2ccl do
              if std = true or i[1] in std then
                entry:= [ i, private ];
                if toc.TocID <> "core" then
                  entry[3]:= toc.TocID;
                fi;
                Add( c2c, entry );
              fi;
            od;
          fi;

          if IsBound( record.cyclic ) then
            for i in record.cyclic do
              if std = true or i[1] in std then
                entry:= [ i, private ];
                if toc.TocID <> "core" then
                  entry[3]:= toc.TocID;
                fi;
                Add( cyc, entry );
              fi;
            od;
          fi;
        fi;
      od;

      for i in c2c do

        # Check if for scripts of the form `<groupname>G<i>cycW<n>-cclsW<m>',
        # a script of the form `<groupname>G<i>-cycW<n>' is available.
        filec2c:= i[1][2];
        pos:= PositionSublist( filec2c, "cycW" );
        rel:= Concatenation( filec2c{ [ 1 .. pos-1 ] }, "-",
                  filec2c{ [ pos .. Position( filec2c, '-' ) - 1 ] } );
        match:= First( cyc, x -> x[1][2] = rel );
        if match <> fail then
          private:= "";
          if i[2] <> "" then
            private:= i[2];
          elif match[2] <> "" then
            private:= match[2];
          fi;
          if Length( i ) = 3 then
            filec2c:= [ i[3], filec2c ];
          fi;
          filecyc:= match[1][2];
          if Length( match ) = 3 then
            filecyc:= [ match[3], filecyc ];
          fi;
          entry:= [ "(composed)",
                    private,
                    String( match[1][1] ),
                    JoinStringsWithSeparator( AGR.VersionOfSLP( filec2c ),
                                              ", " ),
                    [ names[1], [ filec2c, filecyc ], match[1][1] ] ];
          Add( data, entry );
        fi;
      od;

      if ForAny( data, x -> x[1] = "(composed)" ) then
        for i in data do
          if i[1] = "" then
            i[1]:= "(direct)";
          fi;
        od;
      fi;

      return AGR.CommonDisplayPRG( "class repres.", stdavail, data, true );
    end,

    # entry: `[ <std>, <file> ]',
    # conditions: `[ "classes" ]'
    #             or together with `[ "version", <vers> ]'
    AccessPRG := function( toc, groupname, std, conditions )
      local version, record, entry, toc2, record2, pos, rel, entry2, file2;

      if not IsBound( toc.( groupname ) ) then
        return fail;
      elif Length( conditions ) = 1 and conditions[1] = "classes" then
        version:= true;
      elif Length( conditions ) = 3 and conditions[1] = "classes"
                                    and conditions[2] = "version" then
        version:= String( conditions[3] );
      else
        return fail;
      fi;

      # Check whether there is a program for computing class repres.
      record:= toc.( groupname );
      if IsBound( record.classes ) then
        for entry in record.classes do
          if ( std = true or entry[1] in std ) and
             ( version = true or AGR.VersionOfSLP( entry[2] ) = version ) then
            entry:= entry{ [ 2, 1 ] };
            if toc.TocID <> "core" then
              entry[1]:= [ [ toc.TocID, entry[1] ] ];
            fi;
            return entry;
          fi;
        od;
      fi;

      # Try to compose the program for computing classes
      # from a program for computing repres. of cyclic subgroups
      # (in the given table of contents)
      # and a program for computing class representatives from the outputs of
      # this program (in *any* table of contents).
      for toc2 in AGR.TablesOfContents( "all" ) do
        if IsBound( toc2.( groupname ) ) then
          record2:= toc2.( groupname );

          if IsBound( record.cyclic ) and IsBound( record2.cyc2ccl )
                                      and version = true then
            for entry2 in record2.cyc2ccl do
              if std = true or entry2[1] in std then

                # Check if for `<groupname>G<i>cycW<n>-cclsW<m>' scripts,
                # a script of the form `<groupname>G<i>-cycW<n>' exists.
                file2:= entry2[2];
                pos:= PositionSublist( file2, "cycW" );
                rel:= Concatenation( file2{ [ 1 .. pos-1 ] }, "-",
                        file2{ [ pos .. Position( file2, '-' ) - 1 ] } );
                for entry in record.cyclic do
                  if entry[2] = rel and ( std = true or entry[1] in std ) then
                    if toc.TocID <> "core" then
                      rel:= [ toc.TocID, rel ];
                    fi;
                    if toc.TocID <> "core" then
                      file2:= [ toc2.TocID, file2 ];
                    fi;
                    return [ [ file2, rel ], entry2[1] ];
                  fi;
                od;
              fi;
            od;
          fi;
        fi;
      od;

      return fail;
    end,

    # Create the program info from the identifier.
    AtlasProgramInfo := function( type, identifier, groupname )
      local filename;

      # If only one file is involved then use the default function.
      filename:= identifier[2];
      if IsString( filename ) or Length( filename ) = 1 then
        return AtlasProgramInfoDefault( type, identifier, groupname );
      fi;

      # Two files are involved.
      filename:= identifier[2][1];
      if not IsString( filename ) then
        filename:= filename[2];
      fi;
      type:= First( AGR.DataTypes( "prg" ), x -> x[1] = "cyc2ccl" );
      if AGR.ParseFilenameFormat( filename, type[2].FilenameFormat )
             = fail then
        return fail;
      fi;

      filename:= identifier[2][2];
      if not IsString( filename ) then
        filename:= filename[2];
      fi;
      type:= First( AGR.DataTypes( "prg" ), x -> x[1] = "cyclic" );
      if AGR.ParseFilenameFormat( filename, type[2].FilenameFormat )
             = fail then
        return fail;
      fi;

      return rec( standardization := identifier[3],
                  identifier      := identifier );
    end,

    # Create the program from the identifier.
    AtlasProgram := function( type, identifier, groupname )
      local type1, entry1, filename, type2, entry2, prog1, prog2, prog,
            result;

      if IsString( identifier[2] ) or Length( identifier[2] ) = 1 then
        # The second entry describes one file.
        return AtlasProgramDefault( type, identifier, groupname );
      elif Length( identifier[2] ) = 2 then
        # The second entry describes two files to be composed.
        type1:= First( AGR.DataTypes( "prg" ), x -> x[1] = "cyclic" );
        entry1:= identifier[2][2];
        if IsString( entry1 ) then
          filename:= entry1;
          entry1:= [ "dataword", entry1 ];
        else
          filename:= entry1[2];
        fi;
        if AGR.ParseFilenameFormat( filename, type1[2].FilenameFormat )
               = fail then
          return fail;
        fi;

        type2:= First( AGR.DataTypes( "prg" ), x -> x[1] = "cyc2ccl" );
        entry2:= identifier[2][1];
        if IsString( entry2 ) then
          filename:= entry2;
          entry2:= [ "dataword", entry2 ];
        else
          filename:= entry2[2];
        fi;
        if AGR.ParseFilenameFormat( filename, type2[2].FilenameFormat )
               = fail then
          return fail;
        fi;

        prog1:= AGR.FileContents( [ entry1 ], type1 );
        if prog1 = fail then
          return fail;
        fi;
        prog2:= AGR.FileContents( [ entry2 ], type2 );
        if prog2 = fail then
          return fail;
        fi;

        prog:= CompositionOfStraightLinePrograms( prog2.program,
                   prog1.program );
        if prog = fail then
          return fail;
        fi;

        result:= rec( program         := prog,
                      standardization := identifier[3],
                      identifier      := identifier );

        if IsBound( prog2.outputs ) then
          # Take the outputs of the last program in the composition.
          result.outputs:= prog2.outputs;
        fi;

        return result;
      fi;

      return fail;
    end,

    TestWords := function( tocid, name, file, type, verbose )
      return AGR.TestWordsSLPDefault( tocid, name, file, type, true, verbose );
    end,

    # There is only one file.
    ReadAndInterpretDefault := paths -> ScanStraightLineProgram( paths[1] ),

    InterpretDefault := strings -> ScanStraightLineProgram( strings[1],
                                       "string" ),
    ) );


#############################################################################
##
#D  Straight line programs for representatives of cyclic subgroups
##
##  <#GAPDoc Label="type:cyclic:format">
##  <Mark><M>groupname</M><C>G</C><M>i</M><C>-cycW</C><M>n</M></Mark>
##  <Item>
##    In this case, the file contains a straight line program that returns
##    a list of representatives of generators
##    of maximally cyclic subgroups of <M>G</M>.
##    An example is <C>Co1G1-cycW1</C>.
##  </Item>
##  <#/GAPDoc>
##
AGR.DeclareDataType( "prg", "cyclic", rec(
    # `<groupname>G<i>-cycW<n>'
    FilenameFormat := [ [ [ IsChar, "G", IsDigitChar ],
                          [ "cycW", IsDigitChar ] ],
                        [ ParseBackwards, ParseForwards ] ],

    # `[ <i>, <filename> ]'
    AddFileInfo := function( list, entry, name )
      Add( list, Concatenation( entry{ [ 3 ] }, [ name ] ) );
      return true;
    end,

    DisplayOverviewInfo := AGR.DisplayOverviewInfoDefault( "cyc", "c", "cyclic" ),

    DisplayPRG := function( tocs, names, std, stdavail )
      local data, toc, record, private, i, entry;

      data:= [];

      for toc in tocs do
        if IsBound( toc.( names[2] ) ) then
          record:= toc.( names[2] );
          if IsBound( record.cyclic ) then
            if toc.TocID <> "core" then
              private:= UserPreference( "AtlasRep",
                            "AtlasRepMarkNonCoreData" );
            else
              private := "";
            fi;
            for i in record.cyclic do
              if std = true or i[1] in std then
                entry:= [ "",
                          private,
                          String( i[1] ),
                          AGR.VersionOfSLP( i[2] ),
                          [ names[1], i[2], i[1] ] ];
                if toc.TocID <> "core" then
                  entry[5][2]:= [ [ toc.TocID, entry[5][2] ] ];
                fi;
                Add( data, entry );
              fi;
            od;
          fi;
        fi;
      od;

      return AGR.CommonDisplayPRG( "repr. cyc. subg.", stdavail, data, true );
    end,

    # entry: `[ <std>, <file> ]',
    # conditions: `[ "cyclic" ]'
    #             or together with `[ "version", <vers> ]'
    AccessPRG := function( toc, groupname, std, conditions )
      local version, record, entry;

      if not IsBound( toc.( groupname ) ) then
        return fail;
      elif Length( conditions ) = 1 and conditions[1] = "cyclic" then
        version:= true;
      elif Length( conditions ) = 3 and conditions[1] = "cyclic"
                                    and conditions[2] = "version" then
        version:= String( conditions[3] );
      else
        return fail;
      fi;

      record:= toc.( groupname );
      if IsBound( record.cyclic ) then
        for entry in record.cyclic do
          if ( std = true or entry[1] in std ) and
             ( version = true or AGR.VersionOfSLP( entry[2] ) = version ) then
            entry:= entry{ [ 2, 1 ] };
            if toc.TocID <> "core" then
              entry[1]:= [ [ toc.TocID, entry[1] ] ];
            fi;
            return entry;
          fi;
        od;
      fi;
      return fail;
    end,

    TestWords := function( tocid, name, file, type, verbose )
      return AGR.TestWordsSLPDefault( tocid, name, file, type, true, verbose );
    end,

    # There is only one file.
    ReadAndInterpretDefault := paths -> ScanStraightLineProgram( paths[1] ),

    InterpretDefault := strings -> ScanStraightLineProgram( strings[1],
                                       "string" ),
    ) );


#############################################################################
##
#D  Straight line programs for computing class representatives from
#D      representatives of cyclic subgroups
##
##  <#GAPDoc Label="type:cyc2ccls:format">
##  <Mark><M>groupname</M><C>G</C><M>i</M><C>cycW</C><M>n</M><C>-cclsW</C><M>m</M></Mark>
##  <Item>
##    In this case, the file contains a straight line program that takes
##    the return value of the program in the file
##    <M>groupname</M><C>G</C><M>i</M><C>-cycW</C><M>n</M>
##    (see above),
##    and returns a list of conjugacy class representatives of <M>G</M>.
##    An example is <C>M11G1cycW1-cclsW1</C>.
##  </Item>
##  <#/GAPDoc>
##
AGR.DeclareDataType( "prg", "cyc2ccl", rec(

    # `<groupname>G<i>cycW<n>-cclsW<m>'
    FilenameFormat := [ [ [ IsChar, "G", IsDigitChar, "cycW", IsDigitChar ],
                          [ "cclsW", IsDigitChar ] ],
                        [ ParseBackwards, ParseForwards ] ],

    # `[ <i>, <filename> ]'
    AddFileInfo := function( list, entry, name )
      Add( list, Concatenation( entry{ [ 3 ] }, [ name ] ) );
      return true;
    end,

    # entry: `[ <std>, <file> ]',
    # conditions: `[ "cyc2ccl" ]' or
    #             `[ "cyc2ccl", <vers> ]' or
    #             `[ "cyc2ccl", "version", <version> ]' or
    #             `[ "cyc2ccl", <vers>, "version", <version> ]'
    #             where <vers> is the version number of the 'cyc' script
    #             and <version> is the version number of the program itself
    AccessPRG := function( toc, groupname, std, conditions )
      local version, record, versions, entry;

      if not IsBound( toc.( groupname ) ) then
        return fail;
      elif Length( conditions ) = 1 and conditions[1] = "cyc2ccl" then
        version:= true;
      elif Length( conditions ) = 2 and conditions[1] = "cyc2ccl" then
        version:= [ conditions[2], true ];
      elif Length( conditions ) = 3 and conditions[1] = "cyc2ccl"
                                    and conditions[2] = "version" then
        version:= [ true, conditions[3] ];
      elif Length( conditions ) = 4 and conditions[1] = "cyc2ccl"
                                    and conditions[3] = "version" then
        version:= [ conditions[2], conditions[4] ];
      else
        return fail;
      fi;

      record:= toc.( groupname );
      if IsBound( record.cyc2ccl ) then
        for entry in record.cyc2ccl do
          if version <> true then
            # Note that 'AGR.VersionOfSLP' returns two strings in this case.
            versions:= AGR.VersionOfSLP( entry[2] );
          fi;
          if ( std = true or entry[1] in std ) and
             ( version = true or
               ( ( version[1] = true or
                   String( version[1] ) = versions[1] ) and
                 ( version[2] = true or
                   String( version[2] ) = versions[2] ) ) ) then
            entry:= entry{ [ 2, 1 ] };
            if toc.TocID <> "core" then
              entry[1]:= [ [ toc.TocID, entry[1] ] ];
            fi;
            return entry;
          fi;
        od;
      fi;
      return fail;
    end,

    TestWords := function( tocid, name, file, type, verbose )
      return AGR.TestWordsSLPDefault( tocid, name, file, type, true, verbose );
    end,

    # There is only one file.
    ReadAndInterpretDefault := paths -> ScanStraightLineProgram( paths[1] ),

    InterpretDefault := strings -> ScanStraightLineProgram( strings[1],
                                       "string" ),
    ) );


#############################################################################
##
#D  Straight line programs for computing kernel generators
##
##  <#GAPDoc Label="type:kernel:format">
##  <Mark><M>groupname</M><C>G</C><M>i</M><C>-ker</C><M>factgroupname</M><C>W</C><M>n</M></Mark>
##  <Item>
##    In this case, the file contains a straight line program that takes
##    generators of <M>G</M> w.&nbsp;r.&nbsp;t.&nbsp;the <M>i</M>-th set of
##    standard generators,
##    and returns generators of the kernel of an epimorphism
##    that maps <M>G</M> to a group with <Package>ATLAS</Package>-file name
##    <M>factgroupname</M>.
##    An example is <C>2A5G1-kerA5W1</C>.
##  </Item>
##  <#/GAPDoc>
##
AGR.DeclareDataType( "prg", "kernel", rec(

    # `<groupname>G<i>-ker<factgroupname>W<n>'
    FilenameFormat := [ [ [ IsChar, "G", IsDigitChar ],
                          [  "ker", IsChar, "W", IsDigitChar ] ],
                        [ ParseBackwards, ParseBackwardsWithPrefix ] ],

    # `[ <i>, <factgroupname>, <filename> ]'
    AddFileInfo := function( list, entry, name )
      Add( list, [ entry[3], entry[5], name ] );
      return true;
    end,

    # no DisplayOverviewInfo function
    DisplayPRG := function( tocs, names, std, stdavail )
      local data, gapname, toc, record, private, i, entry;

      data:= [];
      if AGR.ShowOnlyASCII() then
        gapname:= Concatenation( names[1], " -> " );
      else
        gapname:= Concatenation( names[1], " → " );
      fi;

      for toc in tocs do
        if IsBound( toc.( names[2] ) ) then
          record:= toc.( names[2] );
          if IsBound( record.kernel ) then
            if toc.TocID <> "core" then
              private:= UserPreference( "AtlasRep",
                            "AtlasRepMarkNonCoreData" );
            else
              private := "";
            fi;
            for i in record.kernel do
              if std = true or i[1] in std then
                entry:= [ Concatenation( gapname,
                                         AGR.GAPNameAtlasName( i[2] ) ),
                          private,
                          String( i[1] ),
                          AGR.VersionOfSLP( i[3] ),
                          [ names[1], i[3], i[1] ] ];
                if toc.TocID <> "core" then
                  entry[5][2]:= [ [ toc.TocID, entry[5][2] ] ];
                fi;
                Add( data, entry );
              fi;
            od;
          fi;
        fi;
      od;

      return AGR.CommonDisplayPRG( "kernels", stdavail, data, false );
    end,

    # entry: `[ <std>, <descr>, <file> ]',
    # conditions: `[ "kernel", <factgroupname> ]'
    #             or together with `[ "version", <vers> ]'
    AccessPRG := function( toc, groupname, std, conditions )
      local version, record, info, entry;

      if not IsBound( toc.( groupname ) ) then
        return fail;
      elif Length( conditions ) = 2 and conditions[1] = "kernel" then
        version:= true;
      elif Length( conditions ) = 4 and conditions[1] = "kernel"
                                    and conditions[3] = "version" then
        version:= String( conditions[4] );
      else
        return fail;
      fi;

      record:= toc.( groupname );
      if IsBound( record.kernel ) then
        info:= First( AtlasOfGroupRepresentationsInfo.GAPnames,
                      x -> x[1] = conditions[2] );
        if info = fail then
          return fail;
        fi;
        info:= info[2];

        for entry in record.kernel do
          if ( std = true or entry[1] in std ) and
             ( version = true or AGR.VersionOfSLP( entry[3] ) = version ) and
             info = entry[2] then
            entry:= entry{ [ 3, 1, 2 ] };
            if toc.TocID <> "core" then
              entry[1]:= [ [ toc.TocID, entry[1] ] ];
            fi;
            return entry;
          fi;
        od;
      fi;
      return fail;
    end,

    TestWords := function( tocid, name, file, type, verbose )
      return AGR.TestWordsSLPDefault( tocid, name, file, type, false, verbose );
    end,

    # There is only one file.
    ReadAndInterpretDefault := paths -> ScanStraightLineProgram( paths[1] ),

    InterpretDefault := strings -> ScanStraightLineProgram( strings[1],
                                       "string" ),
    ) );


#############################################################################
##
#D  Straight line programs for standardizing generators of maximal subgroups
##
##  <#GAPDoc Label="type:maxstd:format">
##  <Mark><M>groupname</M><C>G</C><M>i</M><C>max</C><M>k</M><C>W</C><M>n</M><C>-</C><M>subgroupname</M><C>G</C><M>j</M><C>W</C><M>m</M></Mark>
##  <Item>
##    In this case, the file contains a straight line program that takes
##    the return value of the program in the file
##    <M>groupname</M><C>G</C><M>i</M><C>-max</C><M>k</M><C>W</C><M>n</M>
##    (see above),
##    which are generators for a group <M>U</M>, say;
##    <M>subgroupname</M> is a name for <M>U</M>,
##    and the return value is a list of standard generators for <M>U</M>,
##    w.&nbsp;r.&nbsp;t.&nbsp;the <M>j</M>-th set of standard generators.
##    (Of course this implies that the groups in the <M>k</M>-th class of
##    maximal subgroups of <M>G</M> are isomorphic to the group with name
##    <M>subgroupname</M>.)
##    An example is <C>J1G1max1W1-L211G1W1</C>;
##    the first class of maximal subgroups of the Janko group <M>J_1</M>
##    consists of groups isomorphic to the linear group <M>L_2(11)</M>,
##    for which standard generators are defined.
##  </Item>
##  <#/GAPDoc>
##
AGR.DeclareDataType( "prg", "maxstd", rec(
    # `<groupname>G<i>max<k>W<n>-<subgroupname>G<j>W<m>'
    FilenameFormat := [ [ [ IsChar, "G", IsDigitChar, "max", IsDigitChar,
                            "W", IsDigitChar ],
                          [ IsChar, "G", IsDigitChar, "W", IsDigitChar ] ],
                        [ ParseBackwards, ParseBackwards ] ],

    # `[ <i>, <k>, <n>, <subgroupname>, <j>, <filename> ]'
    AddFileInfo := function( list, entry, name )
      Add( list, Concatenation( entry{ [ 3, 5, 7, 8, 10 ] }, [ name ] ) );
      return true;
    end,

    # no DisplayOverviewInfo function
    DisplayPRG := function( tocs, names, std, stdavail )
      local data, toc, record, private, i, entry;

      data:= [];

      for toc in tocs do
        if IsBound( toc.( names[2] ) ) then
          record:= toc.( names[2] );
          if IsBound( record.maxstd ) then
            if toc.TocID <> "core" then
              private:= UserPreference( "AtlasRep",
                            "AtlasRepMarkNonCoreData" );
            else
              private := "";
            fi;
            for i in record.maxstd do
              if std = true or i[1] in std then
                entry:= [ Concatenation( "from ", Ordinal( i[2] ),
                                         " max., version ", String( i[3] ),
                                         " to ",
                                         AGR.GAPNameAtlasName( i[4] ),
                                         ", std. ", String( i[5] ) ),
                          private,
                          String( i[1] ),
                          AGR.VersionOfSLP( i[6] ),
                          [ names[1], i[6], i[1] ] ];
                if toc.TocID <> "core" then
                  entry[5][2]:= [ [ toc.TocID, entry[5][2] ] ];
                fi;
                Add( data, entry );
              fi;
            od;
          fi;
        fi;
      od;

      return AGR.CommonDisplayPRG( "standardizations of maxes",
                                   stdavail, data, false );
    end,

    # Check whether ATLAS names are defined.
    PostprocessFileInfo := function( toc, record )
      local list, i;
      list:= record.maxstd;
      for i in [ 1 .. Length( list ) ] do
        if ForAll( AtlasOfGroupRepresentationsInfo.GAPnames,
                   pair -> pair[2] <> list[i][4] ) then
          Info( InfoAtlasRep, 3,
                "t.o.c. construction: ignoring name `", list[i][6], "'" );
          Unbind( list[i] );
        fi;
      od;
      if not IsDenseList( list ) then
        record.maxstd:= Compacted( list );
      fi;
    end,

    # entry: `[ <std>, <maxnr>, <vers>, <subgroupname>, <substd>, <file> ]',
    # conditions: `[ "maxstd", <maxnr>, <vers>, <substd> ]'
    #             or together with `[ "version", <vers> ]'
    AccessPRG := function( toc, groupname, std, conditions )
      local record, version, entry;

      if not IsBound( toc.( groupname ) ) then
        return fail;
      fi;
      record:= toc.( groupname );

      if Length( conditions ) in [ 4, 6 ] and conditions[1] = "maxstd"
                                          and IsBound( record.maxstd ) then
        version:= true;
        if Length( conditions ) = 6 then
          if conditions[5] <> "version" then
            return fail;
          fi;
          version:= String( conditions[6] );
        fi;
        for entry in record.maxstd do
          if     ( std = true or entry[1] in std )
             and conditions[2] = entry[2]
             and conditions[3] = entry[3]
             and conditions[4] = entry[5]
             and ( version = true or
                   version = Int( AGR.VersionOfSLP( entry[6] ) ) ) then
            entry:= entry{ [ 6, 1, 2, 3, 5 ] };
            if toc.TocID <> "core" then
              entry[1]:= [ [ toc.TocID, entry[1] ] ];
            fi;
            return entry;
          fi;
        od;
      fi;
      return fail;
    end,

    TestWords := function( tocid, name, file, type, verbose )
      return AGR.TestWordsSLPDefault( tocid, name, file, type, false, verbose );
    end,

    # There is only one file.
    ReadAndInterpretDefault := paths -> ScanStraightLineProgram( paths[1] ),

    InterpretDefault := strings -> ScanStraightLineProgram( strings[1],
                                       "string" ),
    ) );


#############################################################################
##
#D  Straight line programs for computing images of standard generators
#D      under outer automorphisms
##
##  <#GAPDoc Label="type:out:format">
##  <Mark><M>groupname</M><C>G</C><M>i</M><C>-a</C><M>outname</M><C>W</C><M>n</M></Mark>
##  <Item>
##    In this case, the file contains a straight line program that takes
##    generators of <M>G</M> w.&nbsp;r.&nbsp;t.&nbsp;the <M>i</M>-th set
##    of standard generators,
##    and returns the list of their images
##    under the outer automorphism <M>\alpha</M> of <M>G</M>
##    given by the name <M>outname</M>;
##    if this name is empty then <M>\alpha</M> is the unique nontrivial
##    outer automorphism of <M>G</M>;
##    if it is a positive integer <M>k</M> then <M>\alpha</M> is a
##    generator of the unique cyclic order <M>k</M> subgroup of the outer
##    automorphism group of <M>G</M>;
##    if it is of the form <C>2_1</C> or <C>2a</C>,
##    <C>4_2</C> or <C>4b</C>, <C>3_3</C> or <C>3c</C>
##    <M>\ldots</M> then <M>\alpha</M>
##    generates the cyclic group of automorphisms induced on <M>G</M> by
##    <M>G.2_1</M>, <M>G.4_2</M>, <M>G.3_3</M> <M>\ldots</M>;
##    finally, if it is of the form <M>k</M><C>p</C><M>d</M>,
##    with <M>k</M> one of the above forms and <M>d</M> an integer then
##    <M>d</M> denotes the number of dashes
##    appended to the automorphism described by <M>k</M>;
##    if <M>d = 1</M> then <M>d</M> can be omitted.
##    Examples are <C>A5G1-aW1</C>, <C>L34G1-a2_1W1</C>,
##    <C>U43G1-a2_3pW1</C>, and <C>O8p3G1-a2_2p5W1</C>;
##    these file names describe the outer order <M>2</M> automorphism of
##    <M>A_5</M> (induced by the action of <M>S_5</M>)
##    and the order <M>2</M> automorphisms of
##    <M>L_3(4)</M>, <M>U_4(3)</M>, and <M>O_8^+(3)</M>
##    induced by the actions of
##    <M>L_3(4).2_1</M>, <M>U_4(3).2_2^{\prime}</M>,
##    and <M>O_8^+(3).2_2^{{\prime\prime\prime\prime\prime}}</M>,
##    respectively.
##  </Item>
##  <#/GAPDoc>
##
AGR.DeclareDataType( "prg", "out", rec(
    # `<groupname>G<i>-a<outname>W<n>'
    FilenameFormat := [ [ [ IsChar, "G", IsDigitChar ],
                          [  "a", IsChar, "W", IsDigitChar ] ],
                        [ ParseBackwards, ParseBackwardsWithPrefix ] ],

    # `[ <i>, <nam>, <filename> ]'
    AddFileInfo := function( list, entry, name )
      local std, descr, pos, dashes, order, index;
      std:= entry[3];
      descr:= entry[5];
      pos:= Position( descr, 'p' );
      if pos = fail then
        dashes:= "";
        pos:= Length( descr ) + 1;
      elif pos = Length( descr ) then
        dashes:= "'";
      else
        dashes:= Int( descr{ [ pos+1 .. Length( descr ) ] } );
        if dashes = fail then
          return false;
        fi;
        dashes:= ListWithIdenticalEntries( dashes, '\'' );
      fi;
      descr:= descr{ [ 1 .. pos-1 ] };
      pos:= Position( descr, '_' );
      if pos = fail then
        order:= descr;
        index:= "";
      else
        order:= descr{ [ 1 .. pos-1 ] };
        index:= descr{ [ pos+1 .. Length( descr ) ] };
      fi;
      if Int( order ) = fail or Int( index ) = fail then
        return false;
      elif order = "" then
        order:= "2";
      fi;
      if index <> "" then
        order:= Concatenation( order, "_", index );
      fi;
      order:= Concatenation( order, dashes );
      Add( list, [ std, order, name ] );
      return true;
    end,

    DisplayOverviewInfo := [ "out", "r", function( conditions )
      local groupname, tocs, std, value, private, toc, record, new;

      groupname:= conditions[1][2];
      tocs:= AGR.TablesOfContents( conditions );
      if Length( conditions ) = 1 or
         not ( IsInt( conditions[2] ) or IsList( conditions[2] ) ) then
        std:= true;
      else
        std:= conditions[2];
        if IsInt( std ) then
          std:= [ std ];
        fi;
      fi;

      value:= [];;
      private:= false;
      for toc in tocs do
        if IsBound( toc.( groupname ) ) then
          record:= toc.( groupname );
          if IsBound( record.out ) then
            new:= Set( List( Filtered( record.out,
                                       x -> std = true or x[1] in std ),
                             x -> x[2] ) );
            if toc.TocID <> "core" and not IsEmpty( new ) then
              private:= true;
            fi;
            UniteSet( value, new );
          fi;
        fi;
      od;
      value:= JoinStringsWithSeparator( value, "," );
      return [ value, private ];
    end ],

    DisplayPRG := function( tocs, names, std, stdavail )
      local data, toc, record, private, i, entry;

      data:= [];

      for toc in tocs do
        if IsBound( toc.( names[2] ) ) then
          record:= toc.( names[2] );
          if IsBound( record.out ) then
            if toc.TocID <> "core" then
              private:= UserPreference( "AtlasRep",
                            "AtlasRepMarkNonCoreData" );
            else
              private:= "";
            fi;
            for i in record.out do
              if std = true or i[1] in std then
                entry:= [ i[2],
                          private,
                          String( i[1] ),
                          AGR.VersionOfSLP( i[3] ),
                          [ names[1], i[3], i[1] ] ];
                if toc.TocID <> "core" then
                  entry[5][2]:= [ [ toc.TocID, entry[5][2] ] ];
                fi;
                Add( data, entry );
              fi;
            od;
          fi;
        fi;
      od;

      return AGR.CommonDisplayPRG( "automorphisms", stdavail, data, false );
    end,

    # entry: `[ <std>, <autname>, <file> ]',
    # conditions: `[ "automorphism", <autname> ]'
    #             or together with `[ "version", <vers> ]'
    AccessPRG := function( toc, groupname, std, conditions )
      local version, record, entry;

      if not IsBound( toc.( groupname ) ) then
        return fail;
      elif Length( conditions ) = 2 and conditions[1] = "automorphism" then
        version:= true;
      elif Length( conditions ) = 4 and conditions[1] = "automorphism"
                                    and conditions[3] = "version" then
        version:= String( conditions[4] );
      else
        return fail;
      fi;

      record:= toc.( groupname );
      if IsBound( record.out ) then
        for entry in record.out do
          if ( std = true or entry[1] in std ) and
             ( version = true or AGR.VersionOfSLP( entry[3] ) = version ) and
             entry[2] = conditions[2] then
            entry:= entry{ [ 3, 1 ] };
            if toc.TocID <> "core" then
              entry[1]:= [ [ toc.TocID, entry[1] ] ];
            fi;
            return entry;
          fi;
        od;
      fi;
      return fail;
    end,

    # Create the program info from the identifier.
    AtlasProgramInfo := function( type, identifier, groupname )
    local filename, parsed;

    filename:= identifier[2];
    if not IsString( filename ) then
      filename:= filename[1][2];
    fi;

    if IsString( filename ) then
      parsed:= AGR.ParseFilenameFormat( filename, type[2].FilenameFormat );
      if parsed <> fail then
        return rec( standardization := identifier[3],
                    identifier      := identifier,
                    autname         := parsed[5] );
      fi;
    fi;

    return fail;
    end,

    # It would be good to check whether the order of the automorphism
    # fits to the name of the script, but the scripts do not describe
    # automorphisms of minimal possible order.
    # (So the power given by the name of the script is an inner
    # automorphism; how could we check this with reasonable effort?)
    # Thus we check just whether the name fits to the structure of the
    # outer automorphism group and to the order of the automorphism.
    # (We copy the relevant part of the code of `AGR.TestWordsSLPDefault'
    # into this function.)
    TestWords := function( tocid, name, file, type, verbose )
      local filename, prog, prg, gens, gapname, pos, claimedorder, tbl,
            outinfo, bound, imgs, order;

      # Read the program.
      if tocid = "core" then
        tocid:= "dataword";
      fi;
      prog:= AGR.FileContents( [ [ tocid, file ] ], type );
      if prog = fail then
        Print( "#E  file `", file, "' is corrupted\n" );
        return false;
      fi;

      # Check consistency.
      if prog = fail or not IsInternallyConsistent( prog.program ) then
        Print( "#E  program `", file, "' not internally consistent\n" );
        return false;
      fi;
      prg:= prog.program;

      # Create the list of (trivial) generators.
      gens:= ListWithIdenticalEntries( NrInputsOfStraightLineProgram( prg ),
                                       () );

      # Run the program.
      gens:= ResultOfStraightLineProgram( prg, gens );

      # Get the GAP name of `name'.
      gapname:= First( AtlasOfGroupRepresentationsInfo.GAPnames,
                       pair -> name = pair[2] );
      if gapname = fail then
        Print( "#E  problem: no GAP name for `", name, "'\n" );
        return false;
      fi;
      gapname:= gapname[1];

      # Get the order of the automorphism from the filename.
      pos:= PositionSublist( file, "-a" );
      claimedorder:= file{ [ pos+2 .. Length( file ) ] };
      pos:= Position( claimedorder, 'W' );
      claimedorder:= claimedorder{ [ 1 .. pos-1 ] };
      pos:= Position( claimedorder, 'p' );
      if pos <> fail then
	if not ForAll( claimedorder{ [ pos+1 .. Length( claimedorder ) ] },
	               IsDigitChar ) then
	  Print( "#E  wrong number of dashes in `", file, "'\n" );
	  return false;
	elif claimedorder{ [ pos+1 .. Length( claimedorder ) ] } = "0" then
          Print( "#E  wrong name `", file, "'\n" );
	  return false;
	fi;
        claimedorder:= claimedorder{ [ 1 .. pos-1 ] };
      fi;
      pos:= Position( claimedorder, '_' );
      if pos <> fail then
        claimedorder:= claimedorder{ [ 1 .. pos-1 ] };
      fi;
      if not ForAll( claimedorder, IsDigitChar ) then
        Print( "#E  wrong name `", file, "'\n" );
	return false;
      fi;
      claimedorder:= Int( claimedorder );

      # Get the structure of the automorphism group.
      # If this group is cyclic then we compare orders.
      tbl:= CharacterTable( gapname );
      if tbl <> fail and IsBound( AGR.HasExtensionInfoCharacterTable )
                     and AGR.HasExtensionInfoCharacterTable( tbl ) then
        outinfo:= AGR.ExtensionInfoCharacterTable( tbl )[2];
        if    outinfo = "" then
          Print( "#E  automorphism `", file,
                 "' for group without outer automorphisms\n" );
          return false;
        elif outinfo <> "2" and claimedorder = 0 then
          Print( "#E  automorphism `", file,
                 "' but the outer automorphism is not unique\n" );
          return false;
        elif Int( outinfo ) <> fail and claimedorder <> 0
             and Int( outinfo ) mod claimedorder <> 0 then
          Print( "#E  automorphism `", file,
                 "' for outer automorphism group ", outinfo, "\n" );
          return false;
        fi;
      fi;

      if claimedorder = 0 then
        claimedorder:= 2;
      fi;

      # Get generators of the group in question.
      gens:= OneAtlasGeneratingSetInfo( gapname,
                 "contents", [ tocid, "local" ] );
      if gens <> fail and tbl <> fail then
        gens:= AtlasGenerators( gens );
        if gens <> fail then
          gens:= gens.generators;
          bound:= Exponent( tbl ) * claimedorder;

          # Compute the order of the automorphism.
          imgs:= ResultOfStraightLineProgram( prg, gens );
          order:= 1;
          while order < bound and imgs <> gens do
            imgs:= ResultOfStraightLineProgram( prg, imgs );
            order:= order + 1;
          od;

          if   imgs <> gens then
            Print( "#E  order ", order, " of automorphism `", file,
                   "' is larger than ", bound, "\n" );
            return false;
          elif order mod claimedorder <> 0 then
            Print( "#E  order ", order, " of automorphism `", file,
                   "' not divisible by ", claimedorder, "\n" );
            return false;
          fi;
        fi;
      fi;

      return true;
    end,

    # There is only one file.
    ReadAndInterpretDefault := paths -> ScanStraightLineProgram( paths[1] ),

    InterpretDefault := strings -> ScanStraightLineProgram( strings[1],
                                       "string" ),
    ) );


#############################################################################
##
#D  Straight line programs for switching between different standardizations
##
##  <#GAPDoc Label="type:switch:format">
##  <Mark><M>groupname</M><C>G</C><M>i</M><C>-G</C><M>j</M><C>W</C><M>n</M></Mark>
##  <Item>
##    In this case, the file contains a straight line program that takes
##    generators of <M>G</M> w.&nbsp;r.&nbsp;t.&nbsp;the <M>i</M>-th set
##    of standard generators, and returns standard generators of <M>G</M>
##    w.&nbsp;r.&nbsp;t.&nbsp;the <M>j</M>-th set of standard generators.
##    An example is <C>L35G1-G2W1</C>.
##  </Item>
##  <#/GAPDoc>
##
AGR.DeclareDataType( "prg", "switch", rec(
    # `<groupname>G<i>-G<j>W<n>'
    FilenameFormat := [ [ [ IsChar, "G", IsDigitChar ],
                          [  "G", IsDigitChar, "W", IsDigitChar ] ],
                        [ ParseBackwards, ParseForwards ] ],

    # `[ <i>, <j>, <filename> ]'
    AddFileInfo := function( list, entry, name )
      Add( list, [ entry[3], entry[5], name ] );
      return true;
    end,

    DisplayPRG := function( tocs, names, std, stdavail )
      local data, toc, record, private, i, entry;

      data:= [];

      for toc in tocs do
        if IsBound( toc.( names[2] ) ) then
          record:= toc.( names[2] );
          if IsBound( record.switch ) then
            if toc.TocID <> "core" then
              private:= UserPreference( "AtlasRep",
                            "AtlasRepMarkNonCoreData" );
            else
              private:= "";
            fi;
            for i in record.switch do
              if std = true or i[1] in std then
                entry:= [ Concatenation( String( i[1] ), " -> ",
                                         String( i[2] ) ),
                          private,
                          String( i[1] ),
                          AGR.VersionOfSLP( i[3] ),
                          [ names[1], i[3], i[1] ] ];
                if toc.TocID <> "core" then
                  entry[5][2]:= [ [ toc.TocID, entry[5][2] ] ];
                fi;
                Add( data, entry );
              fi;
            od;
          fi;
        fi;
      od;

      return AGR.CommonDisplayPRG( "restandardizations", stdavail, data, false );
    end,

    # entry: `[ <std>, <descr>, <file> ]',
    # conditions: `[ "restandardize", <std2> ]'
    #             or together with `[ "version", <vers> ]'
    AccessPRG := function( toc, groupname, std, conditions )
      local version, record, entry;

      if not IsBound( toc.( groupname ) ) then
        return fail;
      elif Length( conditions ) = 2 and conditions[1] = "restandardize" then
        version:= true;
      elif Length( conditions ) = 4 and conditions[1] = "restandardize"
                                    and conditions[3] = "version" then
        version:= String( conditions[4] );
      else
        return fail;
      fi;
      record:= toc.( groupname );

      if IsBound( record.switch ) then
        for entry in record.switch do
          if ( std = true or entry[1] in std ) and
             ( version = true or AGR.VersionOfSLP( entry[3] ) = version ) and
             conditions[2] = entry[2] then
            entry:= entry{ [ 3, 1, 2 ] };
            if toc.TocID <> "core" then
              entry[1]:= [ [ toc.TocID, entry[1] ] ];
            fi;
            return entry;
          fi;
        od;
      fi;
      return fail;
    end,

    TestWords := function( tocid, name, file, type, verbose )
      return AGR.TestWordsSLPDefault( tocid, name, file, type, false, verbose );
    end,

    # There is only one file.
    ReadAndInterpretDefault := paths -> ScanStraightLineProgram( paths[1] ),

    InterpretDefault := strings -> ScanStraightLineProgram( strings[1],
                                       "string" ),
    ) );


#############################################################################
##
#D  Black box programs for finding standard generators
##
##  <#GAPDoc Label="type:find:format">
##  <Mark><M>groupname</M><C>G</C><M>i</M><C>-find</C><M>n</M></Mark>
##  <Item>
##    <Index Subkey="for finding standard generators">black box program
##    </Index>
##    In this case, the file contains a black box program that takes
##    a group, and returns (if it is successful) a set of standard generators
##    for <M>G</M>, w.&nbsp;r.&nbsp;t.&nbsp;the <M>i</M>-th standardization.
##  </Item>
##  <#/GAPDoc>
##
AGR.DeclareDataType( "prg", "find", rec(
    # `<groupname>G<i>-find<j>'
    FilenameFormat := [ [ [ IsChar, "G", IsDigitChar ],
                          [ "find", IsDigitChar ] ],
                        [ ParseBackwards, ParseBackwardsWithPrefix ] ],

    # `[ <i>, <j>, <filename> ]'
    AddFileInfo := function( list, entry, name )
      Add( list, [ entry[3], entry[5], name ] );
      return true;
    end,

    DisplayOverviewInfo := AGR.DisplayOverviewInfoDefault( "fnd", "c", "find" ),

    DisplayPRG := function( tocs, names, std, stdavail )
      local data, toc, record, private, i, entry;

      data:= [];

      for toc in tocs do
        if IsBound( toc.( names[2] ) ) then
          record:= toc.( names[2] );
          if IsBound( record.find ) then
            if toc.TocID <> "core" then
              private:= UserPreference( "AtlasRep",
                            "AtlasRepMarkNonCoreData" );
            else
              private:= "";
            fi;
            for i in record.find do
              if std = true or i[1] in std then
                entry:= [ "",
                          private,
                          String( i[1] ),
                          String( i[2] ),
                          [ names[1], i[3], i[1] ] ];
                if toc.TocID <> "core" then
                  entry[5][2]:= [ [ toc.TocID, entry[5][2] ] ];
                fi;
                Add( data, entry );
              fi;
            od;
          fi;
        fi;
      od;

      return AGR.CommonDisplayPRG( "std. gen. finder", stdavail, data, true );
    end,

    # entry: `[ <std>, <version>, <file> ]',
    # conditions: `[ "find" ]'
    #             or together with `[ "version", <vers> ]'
    AccessPRG := function( toc, groupname, std, conditions )
      local version, record, entry;

      if not IsBound( toc.( groupname ) ) then
        return fail;
      elif Length( conditions ) = 1 and conditions[1] = "find" then
        version:= true;
      elif Length( conditions ) = 3 and conditions[1] = "find"
                                    and conditions[2] = "version" then
        version:= String( conditions[3] );
      else
        return fail;
      fi;

      record:= toc.( groupname );
      if IsBound( record.find ) then
        for entry in record.find do
          if ( std = true or entry[1] in std ) and
             ( version = true or AGR.VersionOfSLP( entry[3] ) = version ) then
            # the part of the identifier
            entry:= entry{ [ 3, 1, 2 ] };
            if toc.TocID <> "core" then
              entry[1]:= [ [ toc.TocID, entry[1] ] ];
            fi;
            return entry;
          fi;
        od;
      fi;
      return fail;
    end,

    # There is only one file.
    ReadAndInterpretDefault := paths -> ScanBBoxProgram( AGR.StringFile(
                                                             paths[1] ) ),

    InterpretDefault := strings -> ScanBBoxProgram( strings[1] ),

    # If there is a representation for this group (independent of the
    # standardization) then we apply the script, and check whether at least
    # the whole group is generated by the result; if also a `check' script
    # is available for this standardization then we run it on the result.
    TestWords := function( tocid, name, file, type, verbose )
      local prog, prg, gapname, gens, G, res, pos, pos2, std, check;

      # Read the program.
      if tocid = "core" then
        tocid:= "dataword";
      fi;
      prog:= AGR.FileContents( [ [ tocid, file ] ], type );
      if prog = fail then
        Print( "#E  file `", file, "' is corrupted\n" );
        return false;
      fi;
      prg:= prog.program;

      # Get the GAP name of `name'.
      gapname:= First( AtlasOfGroupRepresentationsInfo.GAPnames,
                       pair -> name = pair[2] );
      if gapname = fail then
        Print( "#E  problem: no GAP name for `", name, "'\n" );
        return false;
      fi;

      # Get generators of the group in question.
      gens:= OneAtlasGeneratingSetInfo( gapname[1], "contents", "local" );
      if gens <> fail then
        gens:= AtlasGenerators( gens );
        if gens <> fail then
          gens:= gens.generators;
          G:= Group( gens );
          if IsBound( gapname[3].size ) then
            SetSize( G, gapname[3].size );
          fi;
          res:= ResultOfBBoxProgram( prg, G );
          if IsList( res ) and not IsString( res ) then
            # Compute the standardization.
            pos:= Position( file, '-' );
            pos2:= pos - 1;
            while file[ pos2 ] <> 'G' do
              pos2:= pos2-1;
            od;
            std:= Int( file{ [ pos2+1 .. pos-1 ] } );
            check:= AtlasProgram( gapname[1], std, "check" );
            if check <> fail then
              if not ResultOfStraightLineDecision( check.program, res ) then
                Print( "#E  return values of `", file,
                       "' do not fit to the check file\n" );
                return false;
              fi;
            fi;
            # Check the group order only for permutation groups.
            if IsPermGroup( G ) then
              if not IsSubset( G, res ) then
                Print( "#E  return values of `", file,
                       "' do not lie in the group\n" );
                return false;
              elif Size( SubgroupNC( G, res ) ) <> Size( G ) then
                Print( "#E  return values of `", file,
                       "' do not generate the group\n" );
                return false;
              fi;
            fi;
          fi;
        fi;
      fi;

      return true;
    end,

    ) );


#############################################################################
##
#D  Straight line programs for checking standard generators
##
##  <#GAPDoc Label="type:check:format">
##  <Mark><M>groupname</M><C>G</C><M>i</M><C>-check</C><M>n</M></Mark>
##  <Item>
##    <Index>semi-presentation</Index>
##    In this case, the file contains a straight line decision that takes
##    generators of <M>G</M>, and returns <K>true</K> if these generators are
##    standard generators w.&nbsp;r.&nbsp;t.&nbsp;the <M>i</M>-th
##    standardization, and <K>false</K> otherwise.
##  </Item>
##  <#/GAPDoc>
##
AGR.DeclareDataType( "prg", "check", rec(
    # `<groupname>G<i>-check<j>'
    FilenameFormat := [ [ [ IsChar, "G", IsDigitChar ],
                          [ "check", IsDigitChar ] ],
                        [ ParseBackwards, ParseBackwardsWithPrefix ] ],

    # `[ <i>, <j>, <filename> ]'
    AddFileInfo := function( list, entry, name )
      Add( list, [ entry[3], entry[5], name ] );
      return true;
    end,

    DisplayOverviewInfo := [ "chk", "c", function( conditions )
      local groupname, tocs, std, value, private, toc, record;

      groupname:= conditions[1][2];
      tocs:= AGR.TablesOfContents( conditions );
      if Length( conditions ) = 1 or
         not ( IsInt( conditions[2] ) or IsList( conditions[2] ) ) then
        std:= true;
      else
        std:= conditions[2];
        if IsInt( std ) then
          std:= [ std ];
        fi;
      fi;

      value:= "";
      private:= false;
      for toc in tocs do
        if IsBound( toc.( groupname ) ) then
          record:= toc.( groupname );
          if ( IsBound( record.check ) and
               ForAny( record.check, x -> std = true or x[1] in std ) ) or
             ( IsBound( record.pres ) and
               ForAny( record.pres, x -> std = true or x[1] in std ) ) then
            value:= "+";
            if toc.TocID <> "core" then
              private:= true;
            fi;
            break;
          fi;
        fi;
      od;
      return [ value, private ];
    end ],

    DisplayPRG := function( tocs, names, std, stdavail )
      local data, toc, record, private, comp, i, entry;

      data:= [];

      for toc in tocs do
        if IsBound( toc.( names[2] ) ) then
          record:= toc.( names[2] );
          if toc.TocID <> "core" then
            private:= UserPreference( "AtlasRep",
                          "AtlasRepMarkNonCoreData" );
          else
            private:= "";
          fi;
          for comp in [ "check", "pres" ] do
            if IsBound( record.( comp ) ) then
              for i in record.( comp ) do
                if std = true or i[1] in std then
                  entry:= [ Concatenation( "(", comp, ")" ),
                            private,
                            String( i[1] ),
                            String( i[2] ),
                            [ names[1], i[3], i[1] ] ];
                  if toc.TocID <> "core" then
                    entry[5][2]:= [ [ toc.TocID, entry[5][2] ] ];
                  fi;
                  Add( data, entry );
                fi;
              od;
            fi;
          od;
        fi;
      od;

      return AGR.CommonDisplayPRG( "std. gen. checker", stdavail, data, true );
    end,

    # entry: `[ <std>, <version>, <file> ]',
    # conditions: `[ "check" ]'
    #             or together with `[ "version", <vers> ]'
    AccessPRG := function( toc, groupname, std, conditions )
      local version, record, entry, comp;

      if not IsBound( toc.( groupname ) ) then
        return fail;
      elif Length( conditions ) = 1 and conditions[1] = "check" then
        version:= true;
      elif Length( conditions ) = 3 and conditions[1] = "check"
                                    and conditions[2] = "version" then
        version:= String( conditions[3] );
      else
        return fail;
      fi;
      record:= toc.( groupname );

      for comp in [ "check", "pres" ] do
        if IsBound( record.( comp ) ) then
          for entry in record.( comp ) do
            if ( std = true or entry[1] in std ) and
               ( version = true or AGR.VersionOfSLP( entry[3] ) = version ) then
              # the part of the identifier
              entry:= entry{ [ 3, 1, 2 ] };
              if toc.TocID <> "core" then
                entry[1]:= [ [ toc.TocID, entry[1] ] ];
              fi;
              return entry;
            fi;
          od;
        fi;
      od;
      return fail;
    end,

    TestWords := function( tocid, name, file, type, verbose )
        return AGR.TestWordsSLDDefault( tocid, name, file, type,
                 [ IsChar, "G", IsDigitChar, "-check", IsDigitChar ],
                 verbose ); end,

    # There is only one file.
    ReadAndInterpretDefault := paths -> ScanStraightLineDecision(
                                            AGR.StringFile( paths[1] ) ),

    InterpretDefault := strings -> ScanStraightLineDecision( strings[1] ),
    ) );


#############################################################################
##
#D  Straight line decisions representing presentations
##
##  <#GAPDoc Label="type:pres:format">
##  <Mark><M>groupname</M><C>G</C><M>i</M><C>-P</C><M>n</M></Mark>
##  <Item>
##    <Index>presentation</Index>
##    In this case, the file contains a straight line decision that takes
##    some group elements, and returns <K>true</K> if these elements are
##    standard generators for <M>G</M>,
##    w.&nbsp;r.&nbsp;t.&nbsp;the <M>i</M>-th standardization,
##    and <K>false</K> otherwise.
##  </Item>
##  <#/GAPDoc>
##
AGR.DeclareDataType( "prg", "pres", rec(
    # `<groupname>G<i>-P<j>'
    FilenameFormat := [ [ [ IsChar, "G", IsDigitChar ],
                          [ "P", IsDigitChar ] ],
                        [ ParseBackwards, ParseBackwardsWithPrefix ] ],

    # `[ <i>, <j>, <filename> ]'
    AddFileInfo := function( list, entry, name )
      Add( list, [ entry[3], entry[5], name ] );
      return true;
    end,

    DisplayOverviewInfo := AGR.DisplayOverviewInfoDefault( "prs", "c", "pres" ),

    DisplayPRG := function( tocs, names, std, stdavail )
      local data, toc, record, private, i, entry;

      data:= [];

      for toc in tocs do
        if IsBound( toc.( names[2] ) ) then
          record:= toc.( names[2] );
          if IsBound( record.pres ) then
            if toc.TocID <> "core" then
              private:= UserPreference( "AtlasRep",
                            "AtlasRepMarkNonCoreData" );
            else
              private:= "";
            fi;
            for i in record.pres do
              if std = true or i[1] in std then
                entry:= [ "",
                          private,
                          String( i[1] ),
                          String( i[2] ),
                          [ names[1], i[3], i[1] ] ];
                if toc.TocID <> "core" then
                  entry[5][2]:= [ [ toc.TocID, entry[5][2] ] ];
                fi;
                Add( data, entry );
              fi;
            od;
          fi;
        fi;
      od;

#T better add rows for pres. obtained by restandardization,
#T in analogy to the maxes scripts plus "std." info
      return AGR.CommonDisplayPRG( "presentation", stdavail, data, true );
    end,

    # entry: `[ <std>, <version>, <file> ]',
    # conditions: `[ "presentation" ]'
    #             or together with `[ "version", <vers> ]'
    AccessPRG := function( toc, groupname, std, conditions )
      local version, record, entry, tocs, toc2, record2, entry2, switch, pres;

      if not IsBound( toc.( groupname ) ) then
        return fail;
      elif Length( conditions ) = 1 and conditions[1] = "presentation" then
        version:= true;
      elif Length( conditions ) = 3 and conditions[1] = "presentation"
                                    and conditions[2] = "version" then
        version:= String( conditions[3] );
      else
        return fail;
      fi;
      record:= toc.( groupname );

      if IsBound( record.pres ) then
        # Look for a presentation in the required standardization.
        for entry in record.pres do
          if ( std = true or entry[1] in std ) and
             ( version = true or AGR.VersionOfSLP( entry[3] ) = version ) then
            # the part of the identifier
            entry:= entry{ [ 3, 1, 2 ] };
            if toc.TocID <> "core" then
              entry[1]:= [ [ toc.TocID, entry[1] ] ];
            fi;
            return entry;
          fi;
        od;
        if std <> true then
          # Look for a presentation in another standardization
          # such that we have a restandardization program
          # (in *any* table of contents).
          tocs:= AGR.TablesOfContents( "all" );
          for entry in record.pres do
            if version = true or AGR.VersionOfSLP( entry[3] ) = version then
              for toc2 in tocs do
                if IsBound( toc2.( groupname ) ) then
                  record2:= toc2.( groupname );
                  if IsBound( record2.switch ) then
                    for entry2 in record2.switch do
                      if entry2[1] in std and entry2[2] = entry[1] then
                        pres:= entry[3];
                        if toc.TocID <> "core" then
                          pres:= [ toc.TocID, pres ];
                        fi;
                        switch:= entry2[3];
                        if toc2.TocID <> "core" then
                          switch:= [ toc2.TocID, switch ];
                        fi;
                        return [ [ pres, switch ], entry2[1], entry[1] ];
                      fi;
                    od;
                  fi;
                fi;
              od;
            fi;
          od;
        fi;
      fi;
      return fail;
    end,

    # Create the program info from the identifier.
    AtlasProgramInfo := function( type, identifier, groupname )
      local filename;

      # If only one file is involved then use the default function.
      filename:= identifier[2];
      if IsString( filename ) or Length( filename ) = 1 then
        return AtlasProgramInfoDefault( type, identifier, groupname );
      fi;

      # Two files are involved.
      filename:= identifier[2][1];
      if not IsString( filename ) then
        filename:= filename[2];
      fi;
      type:= First( AGR.DataTypes( "prg" ), x -> x[1] = "pres" );
      if AGR.ParseFilenameFormat( filename, type[2].FilenameFormat )
             = fail then
        return fail;
      fi;

      filename:= identifier[2][2];
      if not IsString( filename ) then
        filename:= filename[2];
      fi;
      type:= First( AGR.DataTypes( "prg" ), x -> x[1] = "switch" );
      if AGR.ParseFilenameFormat( filename, type[2].FilenameFormat )
             = fail then
        return fail;
      fi;

      return rec( standardization := identifier[3],
                  identifier      := identifier );
    end,

    # Create the program from the identifier.
    AtlasProgram := function( type, identifier, groupname )
      local type1, entry1, filename, type2, entry2, prog1, prog2, prog,
            result;

      if IsString( identifier[2] ) or Length( identifier[2] ) = 1 then
        # The second entry describes one file.
        return AtlasProgramDefault( type, identifier, groupname );
      elif Length( identifier[2] ) = 2 then
        # The second entry describes two files to be composed.
        type1:= First( AGR.DataTypes( "prg" ), x -> x[1] = "switch" );
        entry1:= identifier[2][2];
        if IsString( entry1 ) then
          filename:= entry1;
          entry1:= [ "dataword", entry1 ];
        else
          filename:= entry1[2];
        fi;
        if AGR.ParseFilenameFormat( filename, type1[2].FilenameFormat )
               = fail then
          return fail;
        fi;

        type2:= First( AGR.DataTypes( "prg" ), x -> x[1] = "pres" );
        entry2:= identifier[2][1];
        if IsString( entry2 ) then
          filename:= entry2;
          entry2:= [ "dataword", entry2 ];
        else
          filename:= entry2[2];
        fi;
        if AGR.ParseFilenameFormat( filename, type2[2].FilenameFormat )
               = fail then
          return fail;
        fi;

        prog1:= AGR.FileContents( [ entry1 ], type1 );
        if prog1 = fail then
          return fail;
        fi;
        prog2:= AGR.FileContents( [ entry2 ], type2 );
        if prog2 = fail then
          return fail;
        fi;

        prog:= CompositionOfSLDAndSLP( prog2.program, prog1.program );
        if prog <> fail then
          return rec( program         := prog,
                      standardization := identifier[3],
                      identifier      := identifier );
        fi;
      fi;

      return fail;
    end,

    TestWords := function( tocid, name, file, type, verbose )
        return AGR.TestWordsSLDDefault( tocid, name, file, type,
                 [ IsChar, "G", IsDigitChar, "-P", IsDigitChar ],
                 verbose ); end,

    # There is only one file.
    ReadAndInterpretDefault := paths -> ScanStraightLineDecision(
                                            AGR.StringFile( paths[1] ) ),

    InterpretDefault := strings -> ScanStraightLineDecision( strings[1] ),
    ) );


#############################################################################
##
#D  Other straight line programs
##
##  <#GAPDoc Label="type:otherscripts:format">
##  <Mark><M>groupname</M><C>G</C><M>i</M><C>-X</C><M>descr</M><C>W</C><M>n</M></Mark>
##  <Item>
##    In this case, the file contains a straight line program that takes
##    generators of <M>G</M> w.&nbsp;r.&nbsp;t.&nbsp;the <M>i</M>-th set
##    of standard generators,
##    and whose return value corresponds to <M>descr</M>.
##    This format is used only in private extensions
##    (see Chapter&nbsp;<Ref Chap="chap:Private Extensions"/>),
##    such a script can be accessed with <M>descr</M> as the third argument
##    of <Ref Func="AtlasProgram"/>.
##  </Item>
##  <#/GAPDoc>
##
AGR.DeclareDataType( "prg", "otherscripts", rec(

    # `<groupname>G<i>-X<descr>W<n>'
    FilenameFormat := [ [ [ IsChar, "G", IsDigitChar ],
                          [ "X", IsChar, "W", IsDigitChar ] ],
                        [ ParseBackwards, ParseBackwardsWithPrefix ] ],

    # `[ <i>, <descr>, <filename> ]'
    AddFileInfo := function( list, entry, name )
      Add( list, Concatenation( entry{ [ 3, 5 ] }, [ name ] ) );
      return true;
    end,

    DisplayPRG := function( tocs, names, std, stdavail )
      local data, toc, record, private, i, entry;

      data:= [];

      for toc in tocs do
        if IsBound( toc.( names[2] ) ) then
          record:= toc.( names[2] );
          if IsBound( record.otherscripts ) then
            if toc.TocID <> "core" then
              private:= UserPreference( "AtlasRep",
                            "AtlasRepMarkNonCoreData" );
            else
              private:= "";
            fi;
            for i in record.otherscripts do
              if std = true or i[1] in std then
                entry:= [ Concatenation( "\"", i[2], "\"" ),
                          private,
                          String( i[1] ),
                          AGR.VersionOfSLP( i[3] ),
                          [ names[1], i[3], i[1] ] ];
                if toc.TocID <> "core" then
                  entry[5][2]:= [ [ toc.TocID, entry[5][2] ] ];
                fi;
                Add( data, entry );
              fi;
            od;
          fi;
        fi;
      od;

      return AGR.CommonDisplayPRG( "other scripts", stdavail, data, false );
    end,

    # entry: `[ <std>, <descr>, <file> ]',
    # conditions: `[ "other", <descr> ]'
    #             or together with `[ "version", <vers> ]'
    AccessPRG := function( toc, groupname, std, conditions )
      local version, record, entry;

      if not IsBound( toc.( groupname ) ) then
        return fail;
      elif Length( conditions ) = 2 and conditions[1] = "other" then
        version:= true;
      elif Length( conditions ) = 4 and conditions[1] = "other"
                                    and conditions[3] = "version" then
        version:= String( conditions[4] );
      else
        return fail;
      fi;

      record:= toc.( groupname );
      if IsBound( record.otherscripts ) then
        for entry in record.otherscripts do
          if ( std = true or entry[1] in std ) and
             ( version = true or AGR.VersionOfSLP( entry[3] ) = version ) and
             entry[2] = conditions[2] then
            entry:= entry{ [ 3, 1 ] };
            if toc.TocID <> "core" then
              entry[1]:= [ [ toc.TocID, entry[1] ] ];
            fi;
            return entry;
          fi;
        od;
      fi;
      return fail;
    end,

    TestWords := function( tocid, name, file, type, verbose )
      return AGR.TestWordsSLPDefault( tocid, name, file, type, false, verbose );
    end,

    # There is only one file.
    ReadAndInterpretDefault := paths -> ScanStraightLineProgram( paths[1] ),

    InterpretDefault := strings -> ScanStraightLineProgram( strings[1],
                                       "string" ),
    ) );


#############################################################################
##
##  Read the known tables of contents,
##  as given by the user preference "AtlasRepTOCData".
##
##  Note that the current file gets notified via
##  'DeclareAutoreadableVariables',
##  because we want to delay the evaluation of the data.
##
##  We cannot read the tables of contents in 'read.g' because this would
##  trigger that 'gap/types.g' and then 'atlasprm.json' etc. are read.
##  This would not work because some functions are not yet available in this
##  situation.
##
##  (A notification of the "internal" extension in test mode is contained
##  in the test file 'tst/atlasrep.tst'.)
##
AGR.EvaluateTOC:= function()
    local entry, pos, id, filename;

    for entry in UserPreference( "AtlasRep", "AtlasRepTOCData" ) do
      pos:= Position( entry, '|' );
      if pos <> fail then
        id:= entry{ [ 1 .. pos-1 ] };
        filename:= entry{ [ pos+1 .. Length( entry ) ] };
        AtlasOfGroupRepresentationsNotifyData( filename, id );
      fi;
    od;
end;

AGR.EvaluateTOC();


#############################################################################
##
##  For backwards compatibility, we set the components of the global record
##  'AtlasOfGroupRepresentationsInfo' that were used up to version 1.5.1
##  of the package, for specifying user preferences.
##  Note that the values of the "real" user preferences
##  are relevant for setting the record components,
##  modifying the record components does *not* affect these user preferences.
##
##  (We cannot move the code to 'obsolete.gi' because then 'types.g' would
##  be read too early.)
##
if UserPreference( "gap", "ReadObsolete" ) <> false then
  AtlasOfGroupRepresentationsInfo.SetComponentsOfUserParameters:= function()
    local url, pos;

    AtlasOfGroupRepresentationsInfo.remote:= UserPreference( "AtlasRep",
        "AtlasRepAccessRemoteFiles" );

    url:= First( AtlasOfGroupRepresentationsInfo.notified,
                 r -> r.ID = "core" ).DataURL;
    if 7 < Length( url ) and
       LowercaseString( url{ [ 1 .. 7 ] } ) = "http://" then
      url:= url{ [ 8 .. Length( url ) ] };
    fi;
    pos:= Position( url, '/' );
    AtlasOfGroupRepresentationsInfo.servers:= [
        [ url{ [ 1 .. pos - 1 ] }, url{ [ pos+1 .. Length( url ) ] } ] ];

    AtlasOfGroupRepresentationsInfo.wget:= false;

    AtlasOfGroupRepresentationsInfo.compress:= UserPreference( "AtlasRep",
        "CompressDownloadedMeatAxeFiles" );

    AtlasOfGroupRepresentationsInfo.displayFunction:= EvalString(
        UserPreference( "AtlasRep", "DisplayFunction" ) );

    AtlasOfGroupRepresentationsInfo.markprivate:= UserPreference( "AtlasRep",
        "AtlasRepMarkNonCoreData" );

    end;

  AtlasOfGroupRepresentationsInfo.SetComponentsOfUserParameters();
fi;


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