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 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532
|
\documentclass[dvipdfmx]{book}
\newcommand{\VolumeName}{Volume 4: Axiom Developers Guide}
\input{bookheader.tex}
\mainmatter
\setcounter{chapter}{0} % Chapter 1
\begin{quote}
Confronting every new programmer learning a new language are
\begin{itemize}
\item The Cave of Artifacts
\item The Forest of Tooling
\item The Mountain of Language
\item The Cloud Castle of Mindset
\end{itemize}
-- Daniel Higginbotham in Clojure for the Brave and True
\end{quote}
\section{What is the purpose of the HACKPI domain?}
HACKPI is a hack provided for the benefit of the axiom interpreter.
As a mathematical type, it is the simple transcendental extension
\verb|Q(\pi)| of the rational numbers. This type allows interactive
users to use the name \verb|'%pi'| without a type both where a numerical
value is expected [ as in \verb|draw(sin x,x=-%pi..%pi)| ] or when the
exact symbolic value is meant. The interpreter defaults a typeless
\verb|%pi| to HACKPI and then uses the various conversions to cast it
further as required by the context.
One could argue that it is unfair to single \verb|%pi| out from other
constants, but it occurs frequently enough in school examples
(specially for graphs) so it was worth a special hack. In a
non-interactive environment (library), HACKPI would not exist.
(Manuel Bronstein)
\section{How Axiom Builds}
\subsection{The environment variables}
Axiom uses a tree of Makefiles to build the system. Each Makefile
is created from the literate file (Makefile.pamphlet) and then executed.
In order to have a complete set of variables we create an ``environment''
that contains all of the shell variables (except the AXIOM variable).
These can be changed on the command line at the time of the top level
``make'' command. One common usage pattern is to override the NOISE
variable. This variable controls whether we see the full output or just
the echo of each individual step. Sometimes a build fails at a step and
we would like to know the details. By default they are written to
\verb|$TMP/trace| but we can watch every detail with the command line:
\begin{verbatim}
make NOISE=
\end{verbatim}
This overrides the output file and writes everything to the console.
Another common usage pattern is to override the tests that are run.
By default, all tests are run. This can be very time consuming.
A particular subset can be run or, using the option ``notests'', none
will be run:
\begin{verbatim}
make TESTSET=notests
\end{verbatim}
\begin{verbatim}
AWK=gawk
BOOKS=/research/test/books
BYE=bye
CC=gcc
CCF=-O2 -fno-strength-reduce -Wall -D_GNU_SOURCE -DLINUXplatform
-I/usr/X11/include
COMMAND=/usr/local/axiom/mnt/ubuntu/bin/axiom
DAASE=/research/test/src/share
DESTDIR=/usr/local/axiom
DOCUMENT=/research/test/mnt/ubuntu/bin/document
GCLDIR=/research/test/lsp/gcl-2.6.8pre4
GCLOPTS=--enable-vssize=65536*2 --enable-locbfd --disable-dynsysbfd
--disable-statsysbfd --enable-maxpage=512*1024 --disable-xgcl
--disable-tkconfig
GCLVERSION=gcl-2.6.8pre4
INC=/research/test/src/include
INT=/research/test/int
LDF= -L/usr/X11R6/lib -L/usr/lib -lXpm
LISP=lsp
LSP=/research/test/lsp
MNT=/research/test/mnt
NOISE=-o /research/test/obj/tmp/trace
O=o
OBJ=/research/test/obj
PART=cprogs
PATCH=patch
PLF=LINUXplatform
RANLIB=ranlib
RUNTYPE=serial
SPAD=/research/test/mnt/
SPADBIN=/research/test/mnt/ubuntu/bin
SPD=/research/test
SRC=/research/test/src
SRCDIRS=interpdir sharedir algebradir etcdir clefdir docdir graphdir
smandir hyperdir browserdir inputdir
SUBPART=everything
SYS=ubuntu
TANGLE=/research/test/mnt/ubuntu/bin/lib/notangle
TAR=tar
TESTSET=none
TMP=/research/test/obj/tmp
TOUCH=touch
UNCOMPRESS=gunzip
VERSION=Axiom (May 2010)
WEAVE=/research/test/mnt/ubuntu/bin/lib/noweave
XLIB=/usr/X11R6/lib
ZIPS=/research/test/zips
\end{verbatim}
\section{The runtime structure of Axiom}
\begin{center}
\includegraphics[scale=0.5]{ps/v4architecture.eps}\\
{\bf Runtime Structure \cite{Bake14}}
\end{center}
\subsection{The build step}
This shows the steps taken to build Axiom in the sequence they happen.
Each level of indentation is another level of Makefile being executed.
\begin{verbatim}
Makefile
1 noweb
2 copy SRC/scripts to AXIOM/bin
3 extract Makefile.SYS from Makefile.pamphlet
4 latex SRC/input/*.input.pamphlet
5 extract SRC/algebra/Makefile.help from SRC/algebra/Makefile.pamphlet
5a make SRC/algebra/Makefile.help parallelhelp
5a1 extract syntax help from BOOKS/bookvol5
5a2 extract help files from BOOKS/bookvol10.*
6 extract BOOKS/Makefile from BOOKS/Makefile.pamphlet
6a make BOOKS/Makefile
6a1 copy SRC/scripts/tex/axiom.sty to AXIOM/doc
6a2 create AXIOM/doc/*.pdf
6a2a copy book*.pamphlet to AXIOM/doc
6a2b extract latex for each book
6a2c latex each book
6a2d dvipdfm each dvi file
6a3 make AXIOM/doc/toc.pdf
7 extract AXIOM/doc/hypertex/Makefile1 from BOOKS/bookvol11
7a make AXIOM/doc/hypertex/Makefile1
7a1 extract all xhtml pages to AXIOM/doc/hypertex
7a2 extract axiom1.bitmap from BOOK/bookvol11
7a3 extract rcm3720.input from BOOK/bookvol11
7a4 extract strang.input from BOOK/bookvol11
7a5 extract signatures.txt from BOOK/bookvol11
7a6 copy BOOKS/ps/doctitle.png to AXIOM/doc/hypertex
7a7 copy BOOKS/ps/lightbayou.png to AXIOM/doc/hypertex
8 make Makefile.SYS
8a create the root directories
8b create noweb if needed
8c extract SRC/Makefile from SRC/Makefile.pamphlet
8d make SRC/Makefile setup
8d1 extract SRC/scripts/Makefile from SRC/scripts/Makefile.pamphlet
8d2 make SRC/scripts/Makefile
8d1a copy all scripts to AXIOM/bin
8d3 extract SRC/lib/Makefile from SRC/lib/Makefile.pamphlet
8d4 make SRC/lib/Makefile
8d4a compile INT/lib/bsdsignal.c
8d4b compile INT/lib/cursor.c
8d4c compile INT/lib/edin.c
8d4d compile INT/lib/fnct-key.c
8d4e compile INT/lib/halloc.c
8d4f compile INT/lib/openpty.c
8d4g compile INT/lib/pixmap.c
8d4h compile INT/lib/prt.c
8d4i compile INT/lib/sockio-c.c
8d4j compile INT/lib/spadcolors.c
8d4k compile INT/lib/util.c
8d4l compile INT/lib/wct.c
8d4m compile INT/lib/xdither.c
8d4n compile INT/lib/xshade.c
8d4o compile INT/lib/xspadfill.c
8d4p create libspad.a
8d4q compile INT/lib/cfuns-c.c
8d4r compile INT/lib/hash.c
8d4s latex all files to INT/doc/src/lib
8e extract LSP/Makefile from LSP/Makefile.pamphlet
8f make LSP/Makefile gcldir
8f1 untar ZIPS/gcl
8f2 apply Axiom patches to gcl
8f3 copy gcl_collectfn.lsp to OBJ/SYS/lsp
8f4 copy sys-proclaim.lisp to OBJ/SYS/lsp
8f5 make LSP/GCLVERSION/Makefile
8f6 add BOOKS/tangle.lsp to gcl to create INT/SYS/lisp
8g make SRC/Makefile
8g1 make stanzas from SRCDIRS
8g1a interpdir
8g1a1 copy bookvol5 to src/interp
8g1a2 copy bookvol9 to src/interp
8g1a3 copy bookvol10.5 to src/interp
8g1a4 extract util.ht from BOOKS/bookvol7.1 to AXIOM/doc
8g1a5 make SRC/interp/Makefile
8g1a5a build SAVESYS=OBJ/SYS/bin/interpsys
8g1a5a1 build DEPSYS=OBJ/SYS/bin/depsys
8g1a5a2 compile all interp files
8g1a5a3 call build-interpsys to make SAVESYS
8g1a5a4 build warm.data
8g1a5a5 build SAVESYS
8g1a5a6 copy SAVESYS to AXIOMSYS=AXIOM/bin/AXIOMsys
8g1b sharedir
8g1b1 make share/Makefile
8g1b1a copy SRC/share/algebra/command.list to AXIOM/lib
8g1c algebradir
8g1c1 extract algebra/Makefile from SRC/algebra/Makefile.pamphlet
8g1c2 copy bookvol10.2 to SRC/algebra
8g1c3 copy bookvol10.3 to SRC/algebra
8g1c4 copy bookvol10.4 to SRC/algebra
8g1c5 copy bookvol10.5 to SRC/algebra
8g1c6 extract 'findAlgebraFiles'
from SRC/algebra/Makefile.pamphlet
8g1c7 execute findAlgebraFiles and append output
to SRC/algebra/Makefile
8g1c8 make SRC/algebra/Makefile
8g1c8a build INT/algebra nrlibs
8g1c8b copy SRC/algebra/libdb.text to AXIOM/algebra
8g1c8c construct AXIOM/bin/index.html
8g1c8d copy SRC/share/algebra/gloss.text AXIOM/algebra
8g1c8e copy SRC/share/algebra/glossdef.text AXIOM/algebra
8g1c8f copy SRC/share/algebra/glosskey.text AXIOM/algebra
8g1d etcdir
8g1d1 extract SRC/etc/Makefile from SRC/etc/Makefile.pamphlet
8g1d2 make etc/Makefile
8g1d2a copy SRC/doc/gloss.text INT/algebra
8g1d2b copy SRC/doc/topics.data INT/algebra
8g1d2c call make-databases
8g1d2b copy INT/algebra/*.daase AXIOM/algebra
8g1d2e compile asq.c
8g1d2f copy OBJ/SYS/etc/asq AXIOM/bin
8g1d2g copy SRC/etc/summary AXIOM/lib
8g1d2h copy SRC/etc/copyright AXIOM/lib
8g1e clefdir
8g1e1 extract SRC/clef/Makefile from SRC/clef/Makefile.pamphlet
8g1e2 make clef/Makefile
8g1e2a extract edible.c to OBJ/SYS/clef
8g1e2b compile OBJ/SYS/clef/edible.c
8g1e2c link edible, fnct-key, edin, bsdsignal, prt, wct,
openpty, cursor into AXIOM/bin/clef
8g1f docdir
8g1f1 extract SRC/doc/Makefile from SRC/doc/Makefile.pamphlet
8g1f2 make SRC/doc/Makefile
8g1f2a extract SRC/doc/axiom.bib to INT/doc
8g1f2b extract SRC/doc/axiom.sty to AXIOM/bin/tex
8g1f2c extract SRC/doc/refcard.dvi to AXIOM/doc
8g1f2d extract SRC/doc/endpaper.dvi to AXIOM/doc
8g1f2e copy SRC/doc/ps/* to AXIOM/doc/ps
8g1f2f extract SRC/doc/rosetta.dvi to AXIOM/doc
8g1f2g extract SRC/doc/booklet.c to INT
8g1f2h compile booklet.c
8g1f2i copy booklet to AXIOM/bin
8g1g graphdir
8g1g1 extract SRC/graph/Makefile from BOOKS/bookvol8.pamphlet
8g1g2 make graph/Makefile
8g1g2a compile and link AXIOM/lib/viewman
8g1g2b compile and link AXIOM/lib/view2d
8g1g2c compile and link AXIOM/lib/view3d
8g1g2d compile and link AXIOM/lib/viewalone
8g1g2e extract AXIOM/graph/parabola.view from bookvol8
8g1g2f extract psfiles from bookvol8 to AXIOM/lib/graph
8g1h smandir
8g1h1 extract SRC/sman/Makefile from BOOKS/bookvol6.pamphlet
8g1h2 make sman/Makefile
8g1h2a extract INT/sman/session.c from bookvol6
8g1h2b compile INT/sman/session.c to OBJ/SYS/sman/session.o
8g1h2c link OBJ/SYS/sman/session.o to AXIOM/lib/session
8g1h2d extract INT/sman/spadclient.c from bookvol6
8g1h2e compile INT/sman/spadclient.c
to OBJ/SYS/sman/spadclient.o
8g1h2f link OBJ/SYS/sman/spadclient.o to AXIOM/lib/spadclient
8g1h2g extract INT/sman/sman.c from bookvol6
8g1h2h compile INT/sman/sman.c to OBJ/SYS/sman/sman.o
8g1h2i link OBJ/SYS/sman/sman.o to AXIOM/lib/sman
8g1h2j extract axiom shell script from bookvol6 to AXIOM/bin
8g1h2k chmod axiom shell script to be executable
8g1h2l create AXIOM/doc/bookvol6.dvi
8g1i hyperdir
8g1i1 extract INT/hyper/Makefile from BOOKS/bookvol7.pamphlet
8gli2 make INT/hyper/Makefile (to make hyperdoc)
8g1i2a extract and compile AXIOM/lib/spadbuf
8g1i2b extract and compile AXIOM/lib/ex2ht
8g1i2c extract and compile AXIOM/bin/htadd
8g1i2d extract and compile AXIOM/lib/hthits
8g1i2e extract and compile AXIOM/bin/htsearch
8g1i2f extract and compile AXIOM/lib/presea
8g1i2g extract and compile AXIOM/bin/hypertex
8g1i2h untar SPD/books/axbook.tgz to AXIOM/doc
8g1i2j copy SPD/books/bigbayou.png to AXIOM/doc
8g1i2k copy SPD/books/doctitle.png to AXIOM/doc
8g1i3 extract INT/hyper/Makefile from BOOKS/bookvol7.1.pamphlet
8g1i4 make INT/hyper/Makefile (to make hyperdoc pages)
8g1i4a copy SPD/books/bookvol7.1 to AXIOM/doc
8g1i4b htadd pages from AXIOM/doc/bookvol7.1
8g1i4c copy SPD/books/bitmaps AXIOM/doc/bitmaps
8g1i4d copy SPD/books/viewports AXIOM/doc/viewports
8g1i4e untar AXIOM/doc/viewports .Z files
8g1j browserdir
8g1j1 build of hyperdoc browser commented out
8g1k inputdir
8g1k1 extract SRC/input/Makefile from SRC/input/Makefile.pamphlet
8g1k2 make SRC/input/Makefile
8g1k2a copy SRC/input/*.input INT/input
8g1k2b lisp tangle input files from SRC/input/*.input.pamphlet
8g1k2c extract INT/input/Makefile
from SRC/input/Makefile.pamphlet
8g1k2d make INT/input/Makefile TESTSET
8g1k2d1 run regresstests
8g1k2d2 run catstests
8g1k2d3 run richtests
8g1k2d4 run regression tests
8g1k2d5 extract INT/input/Makefile.algebra
from SRC/algebra/Makefile.pamphlet
8g1k2d6 make INT/input/Makefile.algebra
\end{verbatim}
\subsection{Where each output file is created}
Here we show which step in the above set of actions creates the file
that ends up in the final ship directory. We break it down by subdirectory
in the final image.
\subsubsection{AXIOM/algebra}
\begin{verbatim}
in AXIOM/algebra:
*.o
browse.daase
category.daase
compress.daase
dependents.daase
interp.daase
operation.daase
users.daase
\end{verbatim}
\subsubsection{AXIOM/autoload}
\begin{verbatim}
in AXIOM/autoload:
ax.o
bc-matrix.o
br-con.o
ht-util.o
mark.fn
mark.o
nag-c02.o
nag-c05.o
nag-c06.o
nag-d01.o
nag-d02.o
nag-d03.o
nag-e01.o
nag-e02.o
nag-e04.o
nag-f01.o
nag-f02.o
nag-f04.o
nag-f07.o
nag-s.o
nspadaux.o
pspad1.fn
pspad1.o
pspad2.fn
pspad2.o
topics.o
wi1.fn
wi1.o
wi2.fn
wi2.o
\end{verbatim}
\subsubsection{AXIOM/bin}
\begin{verbatim}
in AXIOM/bin:
asq 8g1d2f copy OBJ/SYS/etc/asq AXIOM/bin
axiom 8g1h2k chmod axiom shell script to be executable
axiom.sty 6a1 copy SRC/scripts/tex/axiom.sty to AXIOM/doc
AXIOMsys 8g1a5a6 copy SAVESYS to AXIOMSYS=AXIOM/bin/AXIOMsys
booklet 8g1f2i copy booklet to AXIOM/bin
boxhead 2 copy SRC/scripts to AXIOM/bin
boxtail 2 copy SRC/scripts to AXIOM/bin
boxup 2 copy SRC/scripts to AXIOM/bin
clef 8g1e2c link edible, fnct-key, edin, bsdsignal, prt, wct,
openpty, cursor into AXIOM/bin/clef
document 2 copy SRC/scripts to AXIOM/bin
htadd 8g1i2c extract and compile AXIOM/bin/htadd
htsearch 8g1i2e extract and compile AXIOM/bin/htsearch
hypertex 8g1i2g extract and compile AXIOM/bin/hypertex
index.html 8g1c8c construct AXIOM/bin/index.html
lib 1 noweb
btdefn
cpif
emptydefn
finduses
h2a
htmldoc
markup
mnt
nodefs
noidx
noindex
noroff
noroots
notangle
nountangle
noweave
noweb
nt
nuweb2noweb
numtime
pipedocs
tmac.w
toascii
tohtml
toroff
totex
unmarkup
Makefile.pamphlet
man
man1
cpif.1
htmltoc.1
nodefs.1
noindex.1
noroff.1
noroots.1
notangle.1
nountangle.1
noweave.1
noweb.1
nuweb2noweb.1
sl2h.1
man7
nowebfilters.7
nowebstyle.7
showdvi 2 copy SRC/scripts to AXIOM/bin
? sman 8g1h2i link OBJ/SYS/sman/sman.o to AXIOM/lib/sman
SPADEDIT 2 copy SRC/scripts to AXIOM/bin
tex 2 copy SRC/scripts to AXIOM/bin
axiom.sty 8g1f2b extract SRC/doc/axiom.sty to AXIOM/bin/tex
2 copy SRC/scripts to AXIOM/bin
noweb.sty 1 noweb
nwmac.tex 1 noweb
? viewalone 8g1g2d compile and link AXIOM/lib/viewalone
\end{verbatim}
\subsubsection{AXIOM/doc}
\begin{verbatim}
AXIOM/doc:
axbook
*.xhtml
axiom.sty
bigbayou.png
bitmaps
*.bitmap
bookvol0.out
bookvol0.pdf
bookvol0.toc
bookvol10.1.out
bookvol10.1.pdf
bookvol10.1.toc
bookvol10.2.out
bookvol10.2.pdf
bookvol10.2.toc
bookvol10.3.out
bookvol10.3.pdf
bookvol10.3.toc
bookvol10.4.out
bookvol10.4.pdf
bookvol10.4.toc
bookvol10.5.out
bookvol10.5.pdf
bookvol10.5.toc
bookvol10.out
bookvol10.pdf
bookvol10.toc
bookvol11.out
bookvol11.pdf
bookvol11.toc
bookvol12.out
bookvol12.pdf
bookvol12.toc
bookvol1.out
bookvol1.pdf
bookvol1.toc
bookvol2.out
bookvol2.pdf
bookvol2.toc
bookvol3.out
bookvol3.pdf
bookvol3.toc
bookvol4.out
bookvol4.pdf
bookvol4.toc
bookvol5.out
bookvol5.pdf
bookvol5.toc
bookvol6.out
bookvol6.pdf
bookvol6.toc
bookvol7.out
bookvol7.pdf
bookvol7.toc
bookvol7.1.out
bookvol7.1.pamphlet
bookvol7.1.pdf
bookvol7.1.toc
bookvol8.out
bookvol8.pdf
bookvol8.toc
bookvol9.out
bookvol9.pdf
bookvol9.toc
bookvolbib.pdf
doctitle.png
endpaper.dvi
ht.db
hypertex
*.xhtml
msgs
s2-us.msgs
ps
*.ps
refcard.dvi
rosetta.dvi
spadhelp
*.help
src
? algebra
algebra.Makefile.dvi
books.Makefile.dvi
clef
axiom.sty
edible.c.dvi
clef.Makefile.dvi
doc.Makefile.dvi
etc.Makefile.dvi
? hyper
input
*.input.dvi
input.Makefile.dvi
? interp
interp.Makefile.dvi
lib
*.c.dvi
lib.Makefile.dvi
Makefile.dvi
root.Makefile.dvi
scripts.Makefile.dvi
share.Makefile.dvi
? sman
src.Makefile.dvi
toc.pdf
util.ht
viewports
*.view
data
graph0
image.bm
image.xpm
\end{verbatim}
\subsubsection{AXIOM/graph}
\begin{verbatim}
AXIOM/graph
parabola.view: 8g1g2e extract AXIOM/graph/parabola.view from bookvol8
data
graph0
\end{verbatim}
\subsubsection{AXIOM/input}
\begin{verbatim}
AXIOM/input:
*.input files
\end{verbatim}
\subsubsection{AXIOM/lib}
\begin{verbatim}
AXIOM/lib:
command.list 8g1b1a copy SRC/share/algebra/command.list to AXIOM/lib
copyright 8g1d2h copy SRC/etc/copyright AXIOM/lib
ex2ht 8g1i2b extract and compile AXIOM/lib/ex2ht
graph 8g1g2f extract psfiles from bookvol8 to AXIOM/lib/graph
colorpoly.ps
colorwol.ps
drawarc.ps
drawcolor.ps
drawIstr.ps
drawline.ps
drawlines.ps
drawpoint.ps
draw.ps
drawrect.ps
drawstr.ps
drwfilled.ps
end.ps
fillarc.ps
fillpoly.ps
fillwol.ps
header.ps
setup.ps
hthits 8g1i2d extract and compile AXIOM/lib/hthits
presea 8g1i2f extract and compile AXIOM/lib/presea
session 8g1h2c link OBJ/SYS/sman/session.o to AXIOM/lib/session
spadbuf 8g1i2a extract and compile AXIOM/lib/spadbuf
spadclient 8g1h2f link OBJ/SYS/sman/spadclient.o AXIOM/lib/spadclient
SPADEDIT
summary 8g1d2g copy SRC/etc/summary AXIOM/lib
view2d 8g1g2b compile and link AXIOM/lib/view2d
view3d 8g1g2c compile and link AXIOM/lib/view3d
viewman 8g1g2a compile and link AXIOM/lib/viewman
\end{verbatim}
\subsubsection{AXIOM/src}
\begin{verbatim}
AXIOM/src:
? algebra
\end{verbatim}
\subsubsection{AXIOM/timestamp}
\begin{verbatim}
AXIOM/timestamp
\end{verbatim}
\section{How Axiom Works}
\subsection{Input and Type Selection}
First we change the default setting for autoload messages to
turn off the noise of file loading from the library:
\begin{verbatim}
(1) -> )set mes auto off
\end{verbatim}
Next we tell the interpreter to show us the modemaps used to
classify input and select types. This is known as ``bottomup''
messages. We can watch the interpreter ponder the input.
\begin{verbatim}
(1) -> )set mes bot on
\end{verbatim}
Now we give it something nontrivial to ponder.
\begin{verbatim}
(1) -> f:=1/(a*x+b)
\end{verbatim}
After parsing the input Axiom begins to figure out the type
of the expression. In this case it starts with the multiply
operator in the denominator.
Axiom has determined that ``a'' is of type VARIABLE and ``x''
is of type VARIABLE. It is looking for function of the form
\begin{verbatim}
VARIABLE * VARIABLE
\end{verbatim}
so it looks in the domain of the left argument ``a'' which is
VARIABLE and does not find the required function. Similarly
it looks in the domain of the right argument ``x'' which is
VARIABLE and, not surprisingly, does not find the required function.
It tried to promote each VARIABLE to SYMBOL and looks for a way
to mulitply VARIABLES and SYMBOLS or SYMBOLS and SYMBOLS. Neither
succeeds.
\begin{verbatim}
Function Selection for *
Arguments: (VARIABLE a,VARIABLE x)
-> no appropriate * found in Variable a
-> no appropriate * found in Variable x
-> no appropriate * found in Symbol
-> no appropriate * found in Variable a
-> no appropriate * found in Variable x
-> no appropriate * found in Symbol
Modemaps from Associated Packages
no modemaps
\end{verbatim}
Since it cannot find a specific modemap that uses the exact types
it now expands the search to look for the general modemaps. It
searches these modemaps in order to try to find one that fits.
\begin{verbatim}
Remaining General Modemaps
[1] (D,D1) -> D from D
if D has XFALG(D2,D1) and D2 has ORDSET and D1 has RING
\end{verbatim}
The first match will fail because Symbol does not have RING. We can
determine this by asking the interpreter:
\begin{verbatim}
SYMBOL has RING
(1) false
Type: Boolean
\end{verbatim}
The following modemaps will fail for various similar reasons:
\begin{verbatim}
[2] (D1,D) -> D from D
if D has XFALG(D1,D2) and D1 has ORDSET and D2 has RING
[3] (Integer,D) -> D from D
if D has VECTCAT D2 and D2 has TYPE and D2 has ABELGRP
[4] (D1,D) -> D from D
if D has VECTCAT D1 and D1 has TYPE and D1 has MONOID
[5] (D,D1) -> D from D
if D has VECTCAT D1 and D1 has TYPE and D1 has MONOID
[6] (D,D1) -> D1 from D
if D has SMATCAT(D2,D3,D4,D1) and D3 has RING and D4 has
DIRPCAT(D2,D3) and D1 has DIRPCAT(D2,D3)
[7] (D1,D) -> D1 from D
if D has SMATCAT(D2,D3,D1,D4) and D3 has RING and D1 has
DIRPCAT(D2,D3) and D4 has DIRPCAT(D2,D3)
[8] (D,D) -> D from D if D has SGROUP
[9] (D,D1) -> D from D if D has RMODULE D1 and D1 has RNG
[10] (D,D) -> D from D if D has MONAD
[11] (D,D) -> D from D
if D has MATCAT(D1,D2,D3) and D1 has RING and D2 has FLAGG
D1 and D3 has FLAGG D1
[12] (D1,D) -> D from D
if D has MATCAT(D1,D2,D3) and D1 has RING and D2 has FLAGG
D1 and D3 has FLAGG D1
[13] (D,D1) -> D from D
if D has MATCAT(D1,D2,D3) and D1 has RING and D2 has FLAGG
D1 and D3 has FLAGG D1
[14] (Integer,D) -> D from D
if D has MATCAT(D2,D3,D4) and D2 has RING and D3 has FLAGG
D2 and D4 has FLAGG D2
[15] (D,D1) -> D1 from D
if D has MATCAT(D2,D3,D1) and D2 has RING and D3 has FLAGG
D2 and D1 has FLAGG D2
[16] (D1,D) -> D1 from D
if D has MATCAT(D2,D1,D3) and D2 has RING and D1 has FLAGG
D2 and D3 has FLAGG D2
[17] ((D5 -> D6),(D4 -> D5)) -> (D4 -> D6) from MappingPackage3(D4,
D5,D6)
if D4 has SETCAT and D5 has SETCAT and D6 has SETCAT
[18] (D1,D) -> D from D if D has LMODULE D1 and D1 has RNG
[19] (PolynomialIdeals(D1,D2,D3,D4),PolynomialIdeals(D1,D2,D3,D4))
-> PolynomialIdeals(D1,D2,D3,D4)
from PolynomialIdeals(D1,D2,D3,D4)
if D1 has FIELD and D2 has OAMONS and D3 has ORDSET and D4
has POLYCAT(D1,D2,D3)
[20] (D1,D) -> D from D
if D has GRMOD(D1,D2) and D1 has COMRING and D2 has ABELMON
[21] (D,D1) -> D from D
if D has GRMOD(D1,D2) and D1 has COMRING and D2 has ABELMON
[22] (D1,D2) -> D from D
if D has FMCAT(D1,D2) and D1 has RING and D2 has SETCAT
[23] (D1,D2) -> D from D
if D has FAMONC(D2,D1) and D2 has SETCAT and D1 has CABMON
[24] (Equation D1,D1) -> Equation D1 from Equation D1
if D1 has SGROUP and D1 has TYPE
[25] (D1,Equation D1) -> Equation D1 from Equation D1
if D1 has SGROUP and D1 has TYPE
[26] (D,D1) -> D from D
if D has DIRPCAT(D2,D1) and D1 has TYPE and D1 has MONOID
[27] (D1,D) -> D from D
if D has DIRPCAT(D2,D1) and D1 has TYPE and D1 has MONOID
[28] (DenavitHartenbergMatrix D2,Point D2) -> Point D2
from DenavitHartenbergMatrix D2
if D2 has Join(Field,TranscendentalFunctionCategory)
[29] (PositiveInteger,Color) -> Color from Color
[30] (DoubleFloat,Color) -> Color from Color
[31] (CartesianTensor(D1,D2,D3),CartesianTensor(D1,D2,D3)) ->
CartesianTensor(D1,D2,D3)
from CartesianTensor(D1,D2,D3)
if D1: INT and D2: NNI and D3 has COMRING
[32] (PositiveInteger,D) -> D from D if D has ABELSG
[33] (NonNegativeInteger,D) -> D from D if D has ABELMON
[34] (Integer,D) -> D from D if D has ABELGRP
\end{verbatim}
Eventually the interpreter decides that it can coerce Symbol to
Polynomial(Integer). We can do this in the interpreter also:
\begin{verbatim}
a::Symbol::POLY(INT)
(1) a
Type: Polynomial Integer
\end{verbatim}
And the interpreter can find multiply in POLY(INT):
\begin{verbatim}
[1] signature: (POLY INT,POLY INT) -> POLY INT
implemented: slot $$$ from POLY INT
[2] signature: (POLY INT,POLY INT) -> POLY INT
implemented: slot $$$ from POLY INT
\end{verbatim}
We can see this signature exists by asking the interpreter to show
us the domain POLY(INT) (truncated here for brevity):
\begin{verbatim}
)show POLY(INT)
Polynomial Integer is a domain constructor.
Abbreviation for Polynomial is POLY
This constructor is exposed in this frame.
Issue )edit src/algebra/POLY.spad to see algebra source code for POLY
------------------------------- Operations --------------------------------
?*? : (Fraction Integer,%) -> % ?*? : (Integer,%) -> %
?*? : (PositiveInteger,%) -> % ?*? : (%,Fraction Integer) -> %
?*? : (%,Integer) -> % ?*? : (%,%) -> %
\end{verbatim}
Having found multipy the interpreter now starts a search for the operation
\begin{verbatim}
(POLY(INT)) + (VARIABLE)
\end{verbatim}
It cannot find this modemap
\begin{verbatim}
Function Selection for +
Arguments: (POLY INT,VARIABLE b)
-> no appropriate + found in Polynomial Integer
-> no appropriate + found in Variable b
-> no appropriate + found in Variable b
\end{verbatim}
so it promotes VARIABLE to POLY(INT) and finds the operation:
\begin{verbatim}
(POLY(INT)) + (POLY(INT))
\end{verbatim}
\begin{verbatim}
[1] signature: (POLY INT,POLY INT) -> POLY INT
implemented: slot $$$ from POLY INT
\end{verbatim}
Next it tackles the division operation where the numerator is
PI (PositiveInteger) and the denominator is POLY(INT). It tries
to find
\begin{verbatim}
(PI) / (POLY(INT))
\end{verbatim}
in PositiveInteger, Polynomial Integer and Integer. All attempts fail.
\begin{verbatim}
Function Selection for /
Arguments: (PI,POLY INT)
-> no appropriate / found in PositiveInteger
-> no appropriate / found in Polynomial Integer
-> no appropriate / found in Integer
-> no appropriate / found in PositiveInteger
-> no appropriate / found in Polynomial Integer
-> no appropriate / found in Integer
Modemaps from Associated Packages
no modemaps
\end{verbatim}
So now it turns to the general modemaps:
\begin{verbatim}
Remaining General Modemaps
[1] (D,D1) -> D from D if D has VSPACE D1 and D1 has FIELD
[2] (D,D1) -> D from D
if D has RMATCAT(D2,D3,D1,D4,D5) and D1 has RING and D4 has
DIRPCAT(D3,D1) and D5 has DIRPCAT(D2,D1) and D1 has FIELD
[3] (D1,D1) -> D from D if D has QFCAT D1 and D1 has INTDOM
[4] (D,D1) -> D from D
if D has MATCAT(D1,D2,D3) and D1 has RING and D2 has FLAGG
D1 and D3 has FLAGG D1 and D1 has FIELD
[5] (D,D1) -> D from D
if D has LIECAT D1 and D1 has COMRING and D1 has FIELD
[6] (D,D) -> D from D if D has GROUP
[7] (SparseMultivariatePolynomial(D2,Kernel D),
SparseMultivariatePolynomial(D2,Kernel D)) -> D
from D if D2 has INTDOM and D2 has ORDSET and D has FS D2
[8] (Float,Integer) -> Float from Float
[9] (D,D) -> D from D if D has FIELD
[10] (D,D) -> D from D
if D = EQ D1 and D1 has FIELD and D1 has TYPE or D = EQ D1
and D1 has GROUP and D1 has TYPE
[11] (DoubleFloat,Integer) -> DoubleFloat from DoubleFloat
[12] (D,D1) -> D from D
if D has AMR(D1,D2) and D1 has RING and D2 has OAMON and D1
has FIELD
\end{verbatim}
it eventually promotes PI to FRAC(POLY(INT)) and
POLY(INT) to FRAC(POLY(INT)) and finds the match:
\begin{verbatim}
(FRAC(POLY(INT))) / (FRAC(POLY(INT)))
\end{verbatim}
We can ask the intepreter to show us this operation (again, the
output is truncated for brevity):
\begin{verbatim}
)show FRAC(POLY(INT))
Fraction Polynomial Integer is a domain constructor.
Abbreviation for Fraction is FRAC
This constructor is exposed in this frame.
Issue )edit src/algebra/FRAC.spad to see algebra source code for FRAC
------------------------------- Operations --------------------------------
?*? : (Fraction Integer,%) -> % ?*? : (Integer,%) -> %
?*? : (PositiveInteger,%) -> % ?*? : (%,Fraction Integer) -> %
?*? : (%,%) -> % ?**? : (%,Integer) -> %
?**? : (%,PositiveInteger) -> % ?+? : (%,%) -> %
?-? : (%,%) -> % -? : % -> %
?/? : (%,%) -> % ?<? : (%,%) -> Boolean
\end{verbatim}
\begin{verbatim}
[1] signature: (FRAC POLY INT,FRAC POLY INT) -> FRAC POLY INT
implemented: slot $$$ from FRAC POLY INT
\end{verbatim}
At this point the interpreter has succeeded in finding a type for
the expression and eventually returns the result badged with the
appropriate type:
\begin{verbatim}
1
(1) -------
a x + b
Type: Fraction Polynomial Integer
\end{verbatim}
\subsection{A simple integral}
Now we will show an integration with successive levels of expansion
of explanation. We will use the expression above:
\begin{verbatim}
(1) -> f:=1/(a*x+b)
1
(1) -------
a x + b
Type: Fraction Polynomial Integer
(2) -> integrate(f,x)
log(a x + b)
(2) ------------
a
Type: Union(Expression Integer,...)
\end{verbatim}
\subsection{A simple integral, expansion 1 interpreter}
\begin{verbatim}
(2) -> integrate(f,x)
\end{verbatim}
Here we assume the previous discussion of modemap handling for the
expression f and we only look at the modemap handling for the integrate
function. We are looking for a modemap of the form:
\begin{verbatim}
integrate(FRAC(POLY(INT)),VARIABLE x)
\end{verbatim}
So first we look in the domains of the arguments, that is, in
Fraction Polynomial Integer, and Variable. Neither one succeeds:
\begin{verbatim}
Function Selection for integrate
Arguments: (FRAC POLY INT,VARIABLE x)
-> no appropriate integrate found in Fraction Polynomial Integer
-> no appropriate integrate found in Variable x
-> no appropriate integrate found in Fraction Polynomial Integer
-> no appropriate integrate found in Variable x
Modemaps from Associated Packages
no modemaps
\end{verbatim}
Next we look at the general modemaps to find one that might work:
\begin{verbatim}
Remaining General Modemaps
[1] (D,D1) -> D from D
if D1 = SYMBOL and D has UTSCAT D2 and D2 has RING and D2
has ACFS INT and D2 has PRIMCAT and D2 has TRANFUN and D2
has ALGEBRA FRAC INT or D1 = SYMBOL and D has UTSCAT D2 and
D2 has RING and D2 has variables: D2 -> List D1 and D2 has
integrate: (D2,D1) -> D2 and D2 has ALGEBRA FRAC INT
[2] (D,D1) -> D from D
if D1 = SYMBOL and D has UPXSCAT D2 and D2 has RING and D2
has ACFS INT and D2 has PRIMCAT and D2 has TRANFUN and D2
has ALGEBRA FRAC INT or D1 = SYMBOL and D has UPXSCAT D2
and D2 has RING and D2 has variables: D2 -> List D1 and D2
has integrate: (D2,D1) -> D2 and D2 has ALGEBRA FRAC INT
[3] (D,D1) -> D from D
if D1 = SYMBOL and D has ULSCAT D2 and D2 has RING and D2
has ACFS INT and D2 has PRIMCAT and D2 has TRANFUN and D2
has ALGEBRA FRAC INT or D1 = SYMBOL and D has ULSCAT D2 and
D2 has RING and D2 has variables: D2 -> List D1 and D2 has
integrate: (D2,D1) -> D2 and D2 has ALGEBRA FRAC INT
[4] (Polynomial D2,Symbol) -> Polynomial D2 from Polynomial D2
if D2 has ALGEBRA FRAC INT and D2 has RING
[5] (D,D1) -> D from D
if D has MTSCAT(D2,D1) and D2 has RING and D1 has ORDSET
and D2 has ALGEBRA FRAC INT
[6] (Fraction Polynomial D4,Symbol) -> Union(Expression D4,List
Expression D4)
from IntegrationResultRFToFunction D4
if D4 has CHARZ and D4 has Join(GcdDomain,RetractableTo
Integer,OrderedSet,LinearlyExplicitRingOver Integer)
[7] (Expression Float,List Segment OrderedCompletion Float) ->
Result
from AnnaNumericalIntegrationPackage
[8] (Expression Float,Segment OrderedCompletion Float) -> Result
from AnnaNumericalIntegrationPackage
[9] (GeneralUnivariatePowerSeries(D2,D3,D4),Variable D3) ->
GeneralUnivariatePowerSeries(D2,D3,D4)
from GeneralUnivariatePowerSeries(D2,D3,D4)
if D3: SYMBOL and D2 has ALGEBRA FRAC INT and D2 has RING
and D4: D2
[10] (D2,Symbol) -> Union(D2,List D2) from FunctionSpaceIntegration(
D4,D2)
if D4 has Join(EuclideanDomain,OrderedSet,
CharacteristicZero,RetractableTo Integer,
LinearlyExplicitRingOver Integer) and D2 has Join(
TranscendentalFunctionCategory,PrimitiveFunctionCategory,
AlgebraicallyClosedFunctionSpace D4)
[11] (Fraction Polynomial D4,SegmentBinding OrderedCompletion
Fraction Polynomial D4) -> Union(f1: OrderedCompletion Expression
D4,f2: List OrderedCompletion Expression D4,fail: failed,
pole: potentialPole)
from RationalFunctionDefiniteIntegration D4
if D4 has Join(EuclideanDomain,OrderedSet,
CharacteristicZero,RetractableTo Integer,
LinearlyExplicitRingOver Integer)
[12] (Fraction Polynomial D4,SegmentBinding OrderedCompletion
Expression D4) -> Union(f1: OrderedCompletion Expression D4,f2:
List OrderedCompletion Expression D4,fail: failed,pole:
potentialPole)
from RationalFunctionDefiniteIntegration D4
if D4 has Join(EuclideanDomain,OrderedSet,
CharacteristicZero,RetractableTo Integer,
LinearlyExplicitRingOver Integer)
[13] (D2,SegmentBinding OrderedCompletion D2) -> Union(f1:
OrderedCompletion D2,f2: List OrderedCompletion D2,fail: failed,
pole: potentialPole)
from ElementaryFunctionDefiniteIntegration(D4,D2)
if D2 has Join(TranscendentalFunctionCategory,
PrimitiveFunctionCategory,AlgebraicallyClosedFunctionSpace
D4) and D4 has Join(EuclideanDomain,OrderedSet,
CharacteristicZero,RetractableTo Integer,
LinearlyExplicitRingOver Integer)
\end{verbatim}
Modemap [6] wins because we can construct the first argument
by matching
\begin{verbatim}
Fraction Polynomial Integer
\end{verbatim}
to
\begin{verbatim}
Fraction Polynomial D4
\end{verbatim}
so we can infer that D4 == Integer
\begin{verbatim}
[6] (Fraction Polynomial D4,Symbol) -> Union(Expression D4,List
Expression D4)
from IntegrationResultRFToFunction D4
if D4 has CHARZ and D4 has Join(GcdDomain,RetractableTo
Integer,OrderedSet,LinearlyExplicitRingOver Integer)
\end{verbatim}
Given that match we have two requirements on Integer, both of which
we can check with the interpreter:
\begin{verbatim}
INT has CHARZ
(3) true
Type: Boolean
(4) -> INT has Join(GcdDomain,RetractableTo Integer,OrderedSet,_
LinearlyExplicitRingOver Integer)
(4) true
Type: Boolean
\end{verbatim}
So we have a match
\begin{verbatim}
[1] signature: (FRAC POLY INT,SYMBOL) -> Union(EXPR INT,LIST EXPR INT)
implemented: slot (Union (Expression (Integer))
(List (Expression (Integer))))
(Fraction (Polynomial (Integer)))(Symbol)
from IRRF2F INT
[2] signature: (EXPR INT,SYMBOL) -> Union(EXPR INT,LIST EXPR INT)
implemented: slot (Union (Expression (Integer))
(List (Expression (Integer))))
(Expression (Integer))(Symbol)
from FSINT(INT,EXPR INT)
\end{verbatim}
Now we invoke
\begin{verbatim}
integrate(FRAC(POLY(INT)),SYMBOL) -> Union(EXPR INT,LIST EXPR INT)
from IRRF2F(INT)
integrate(1/(a*x+b),x)
\end{verbatim}
can print the result:
\begin{verbatim}
log(a x + b)
(2) ------------
a
Type: Union(Expression Integer,...)
\end{verbatim}
\subsection{A simple integral, expansion 2 integrate}
Now that we know how the interpreter has matched the input and called
the function we need to follow the first level call into the function.
Axiom provides a trace tool that will allow us to walk into the function
invocation and watch what happens. We will follow this same invocation
path many times, each time we will descend another layer, repeating the
information as we do.
For now, we look at the domain IRRF2F from irexpand.spad.
The categorical definition of this domain reads (we remove parts
of the definition for brevity):
\begin{verbatim}
IntegrationResultRFToFunction(R): Exports == Implementation where
R: Join(GcdDomain, RetractableTo Integer, OrderedSet,
LinearlyExplicitRingOver Integer)
RF ==> Fraction Polynomial R
F ==> Expression R
IR ==> IntegrationResult RF
OF ==> OutputForm
Exports ==> with
expand : IR -> List F
++ expand(i) returns the list of possible real functions
++ corresponding to i.
if R has CharacteristicZero then
integrate : (RF, Symbol) -> Union(F, List F)
++ integrate(f, x) returns the integral of \spad{f(x)dx}
++ where x is viewed as a real variable..
Implementation ==> add
import IntegrationTools(R, F)
import TrigonometricManipulations(R, F)
import IntegrationResultToFunction(R, F)
toEF: IR -> IntegrationResult F
toEF i == map(#1::F, i)$IntegrationResultFunctions2(RF, F)
expand i == expand toEF i
complexExpand i == complexExpand toEF i
if R has CharacteristicZero then
import RationalFunctionIntegration(R)
if R has imaginary: () -> R then
integrate(f, x) == complexIntegrate(f, x)
else
integrate(f, x) ==
l := [mkPrim(real g, x) for g in expand internalIntegrate(f, x)]
empty? rest l => first l
l
@
\end{verbatim}
We can see that this domain constructor takes one argument which, in
this case, is Integer. We've already determined that Integer has the
required Joins:
\begin{verbatim}
(4) -> INT has Join(GcdDomain,RetractableTo Integer,OrderedSet,_
LinearlyExplicitRingOver Integer)
(4) true
Type: Boolean
\end{verbatim}
and we can see that:
\begin{verbatim}
(5) -> INT has CharacteristicZero
(5) true
Type: Boolean
\end{verbatim}
so we can match the signature of integrate:
\begin{verbatim}
integrate(Fraction Polynomial Integer, Symbol) ->
Union(Expression Integer, List Expression Integer)
\end{verbatim}
We can trace this domain and ask to see the output in math form:
\begin{verbatim}
(6) -> )trace IRRF2F )math
Packages traced:
IntegrationResultRFToFunction Integer
Parameterized constructors traced:
IRRF2F
\end{verbatim}
and now, when we do the integration, we see the output of the trace:
\begin{verbatim}
integrate(1/(a*x+b),x)
1<enter IntegrationResultRFToFunction.integrate,32 :
1
arg1= -------
a x + b
arg2= x
1<enter IntegrationResultRFToFunction.expand,18 :
1 a x + b
arg1= - log(-------)
a a
1>exit IntegrationResultRFToFunction.expand,18 :
a x + b
log(-------)
a
[------------]
a
1>exit IntegrationResultRFToFunction.integrate,32 :
log(a x + b)
------------
a
log(a x + b)
(6) ------------
a
Type: Union(Expression Integer,...)
\end{verbatim}
From this we learn that the arguments to integrate are exactly the
arguments we supplied and we know the exact types of the arguments
because they have to match the signature of the function:
\begin{verbatim}
1<enter IntegrationResultRFToFunction.integrate,32 :
integrate(, Symbol) ->
1
arg1= ------- <== Fraction Polynomial Integer
a x + b
arg2= x <== Symbol
\end{verbatim}
and returns the result
\begin{verbatim}
1>exit IntegrationResultRFToFunction.integrate,32 :
log(a x + b)
------------ <== Union(Expression Integer, List Expression Integer)
a
\end{verbatim}
\subsection{A simple integral, expansion 2 internalIntegrate}
If we look at the function definition for integrate:
\begin{verbatim}
integrate(f, x) ==
l := [mkPrim(real g, x) for g in expand internalIntegrate(f, x)]
empty? rest l => first l
l
\end{verbatim}
we can see that there is a call to the function
\begin{verbatim}
internalIntegrate(f, x)
\end{verbatim}
and we can compute the types of the arguments since they are exactly
the types of the integrate function itself:
\begin{verbatim}
internalIntegrate(Fraction Polynomial Integer, Symbol)
\end{verbatim}
and since the return value will be fed to the expand function we
can look at the signature of expand:
\begin{verbatim}
expand: IntegrationResult Fraction Polynomial Integer ->
List Expression Integer
\end{verbatim}
and we can get the full signature for internalIntegrate:
\begin{verbatim}
internalIntegrate(Fraction Polynomial Integer, Symbol) ->
IntegrationResult Fraction Polynomial Integer
\end{verbatim}
This comes from the domain
\begin{verbatim}
RationalFunctionIntegration(F): Exports == Implementation where
F: Join(IntegralDomain, RetractableTo Integer, CharacteristicZero)
\end{verbatim}
where F is Integer.
\begin{verbatim}
SE ==> Symbol
P ==> Polynomial F
Q ==> Fraction P
UP ==> SparseUnivariatePolynomial Q
QF ==> Fraction UP
LGQ ==> List Record(coeff:Q, logand:Q)
UQ ==> Union(Record(ratpart:Q, coeff:Q), "failed")
ULQ ==> Union(Record(mainpart:Q, limitedlogs:LGQ), "failed")
Exports ==> with
internalIntegrate: (Q, SE) -> IntegrationResult Q
++ internalIntegrate(f, x) returns g such that \spad{dg/dx = f}.
Implementation ==> add
import RationalIntegration(Q, UP)
import IntegrationResultFunctions2(QF, Q)
import PolynomialCategoryQuotientFunctions(IndexedExponents SE,
SE, F, P, Q)
internalIntegrate(f, x) ==
map(multivariate(#1, x), integrate univariate(f, x))
\end{verbatim}
If we look the signature for internalIntegrate and expand it we see:
\begin{verbatim}
internalIntegrate: (Q, SE) -> IntegrationResult Q
internalIntegrate: ( Fraction Polynomial Integer, Symbol) ->
IntegrationResult Fraction Polynomial Integer
\end{verbatim}
which is exactly what we need. When we look at the function we see:
\begin{verbatim}
internalIntegrate(f, x) ==
map(multivariate(#1, x), integrate univariate(f, x))
\end{verbatim}
We can watch the function call by tracing INTRF:
\begin{verbatim}
(7) -> )trace INTRF )math
Packages traced:
IntegrationResultRFToFunction Integer,
RationalFunctionIntegration Integer
Parameterized constructors traced:
IRRF2F, INTRF
\end{verbatim}
and we see:
\begin{verbatim}
(7) -> integrate(1/(a*x+b),x)
1<enter IntegrationResultRFToFunction.integrate,32 :
1
arg1= -------
a x + b
arg2= x
1<enter RationalFunctionIntegration.internalIntegrate,25 :
1
arg1= -------
a x + b
arg2= x
1>exit RationalFunctionIntegration.internalIntegrate,25 :
1 a x + b
- log(-------)
a a
1<enter IntegrationResultRFToFunction.expand,18 :
1 a x + b
arg1= - log(-------)
a a
1>exit IntegrationResultRFToFunction.expand,18 :
a x + b
log(-------)
a
[------------]
a
1>exit IntegrationResultRFToFunction.integrate,32 :
log(a x + b)
------------
a
log(a x + b)
(7) ------------
a
Type: Union(Expression Integer,...)
\end{verbatim}
Now we see that internalIntegrate was called with the arguments
\begin{verbatim}
1<enter RationalFunctionIntegration.internalIntegrate,25 :
1
arg1= ------- <== Fraction Polynomial Integer
a x + b
arg2= x <== Symbol
\end{verbatim}
and returned the values:
\begin{verbatim}
1>exit RationalFunctionIntegration.internalIntegrate,25 :
1 a x + b
- log(-------) <== IntegrationResult Fraction Polynomial Integer
a a
\end{verbatim}
\subsection{A simple integral, expansion 3 univariate}
But the internalIntegrate function does its work by calling yet
other functions, the deepest of which is univariate:
\begin{verbatim}
internalIntegrate(f, x) ==
map(multivariate(#1, x), integrate univariate(f, x))
\end{verbatim}
Since univariate uses the arguments to the internalIntegrate function
which has the signature:
\begin{verbatim}
internalIntegrate: ( Fraction Polynomial Integer, Symbol) ->
\end{verbatim}
we can determine that we need a univariate function with the signature:
\begin{verbatim}
univariate: ( Fraction Polynomial Integer, Symbol) ->
\end{verbatim}
This function is found in PolynomialCategoryQuotientFunctions, POLYCATQ
which has the form:
\begin{verbatim}
PolynomialCategoryQuotientFunctions(E, V, R, P, F):
Exports == Implementation where
E: OrderedAbelianMonoidSup
V: OrderedSet
R: Ring
P: PolynomialCategory(R, E, V)
F: Field with
coerce: P -> %
numer : % -> P
denom : % -> P
UP ==> SparseUnivariatePolynomial F
RF ==> Fraction UP
Exports ==> with
variables : F -> List V
++ variables(f) returns the list of variables appearing
++ in the numerator or the denominator of f.
mainVariable: F -> Union(V, "failed")
++ mainVariable(f) returns the highest variable appearing
++ in the numerator or the denominator of f, "failed" if
++ f has no variables.
univariate : (F, V) -> RF
++ univariate(f, v) returns f viewed as a univariate
++ rational function in v.
Implementation ==> add
P2UP: (P, V) -> UP
univariate(f, x) == P2UP(numer f, x) / P2UP(denom f, x)
P2UP(p, x) ==
map(#1::F,
univariate(p, x))$SparseUnivariatePolynomialFunctions2(P, F)
\end{verbatim}
So we are calling the function:
\begin{verbatim}
univariate: ( Fraction Polynomial Integer, Symbol) ->
Fraction SparseUnivariatePolynomial Field with
coerce: PolynomialCategory(Ring, OrderedAbelianMonoidSup, OrderedSet) -> %
numer: % -> PolynomialCategory(Ring, OrderedAbelianMonoidSup, OrderedSet)
denom: % -> PolynomialCategory(Ring, OrderedAbelianMonoidSup, OrderedSet)
\end{verbatim}
which we can see by tracing that domain:
\begin{verbatim}
(8) -> )trace POLYCATQ )math
Packages traced:
IntegrationResultRFToFunction Integer,
RationalFunctionIntegration Integer,
PolynomialCategoryQuotientFunctions(IndexedExponents
Kernel Expression Integer,Kernel Expression Integer,
Integer,SparseMultivariatePolynomial(Integer,Kernel
Expression Integer),Expression Integer),
PolynomialCategoryQuotientFunctions(IndexedExponents
Symbol,Symbol,Integer,Polynomial Integer,Fraction
Polynomial Integer)
Parameterized constructors traced:
IRRF2F, INTRF, POLYCATQ
\end{verbatim}
which gives the input:
\begin{verbatim}
1<enter PolynomialCategoryQuotientFunctions.univariate,16 :
1
arg1= ------- <== Fraction Polynomial Integer
a x + b
arg2= x <== Symbol
\end{verbatim}
and the output
\begin{verbatim}
1>exit PolynomialCategoryQuotientFunctions.univariate,16 :
1
-
a
----- <== Fraction SparseUnivariatePolynomial Field with
b coerce: P -> %
? + - numer: % -> P
a denom: % -> P
\end{verbatim}
It should be clear that univariate divided the numerator and
denominator by the leading coefficient of the polynomial in
the denominator. It also replaced ``x'' with the variable ``?''.
\subsection{A simple integral, expansion 4 integrate}
When univariate returns, the results are fed to another integrate,
this time from RationalIntegration (INTRAT). This domain looks like:
\begin{verbatim}
RationalIntegration(F, UP): Exports == Implementation where
F : Join(Field, CharacteristicZero, RetractableTo Integer)
UP: UnivariatePolynomialCategory F
RF ==> Fraction UP
IR ==> IntegrationResult RF
LLG ==> List Record(coeff:RF, logand:RF)
URF ==> Union(Record(ratpart:RF, coeff:RF), "failed")
U ==> Union(Record(mainpart:RF, limitedlogs:LLG), "failed")
OF ==> OutputForm
Exports ==> with
integrate : RF -> IR
++ integrate(f) returns g such that \spad{g' = f}.
Implementation ==> add
import TranscendentalIntegration(F, UP)
integrate f ==
rec := monomialIntegrate(f, differentiate)
integrate(rec.polypart)::RF::IR + rec.ir
\end{verbatim}
This domain was constructed and ``brought into scope'' in
RationalFunctionIntegration(F) with the statement
\begin{verbatim}
import RationalIntegration(Fraction Polynomial Integer,
SparseUnivariatePolynomial Fraction Polynomial Integer)
\end{verbatim}
and the function has the signature
\begin{verbatim}
integrate:
Fraction SparseUnivariatePolynomial Fraction Polynomial Integer ->
IntegrationResult Fraction
Fraction Polynomial Integer
\end{verbatim}
\begin{verbatim}
1<enter RationalIntegration.integrate,32 :
1
-
a
arg1= ----- <== Fraction SparseUnivariatePolynomial
b Fraction Polynomial Integer
? + -
a
1>exit RationalIntegration.integrate,32 :
1 b
- log(? + -) <== IntegrationResult Fraction SparseUnivariatePolynomial
a a Fraction Polynomial Integer
\end{verbatim}
\subsection{A simple integral, expansion 5 monomialIntegrate}
The integrate function is defined as:
\begin{verbatim}
integrate f ==
print(outputForm("tpdhere INTRAT 1")@OF)$OF
rec := monomialIntegrate(f, differentiate)
integrate(rec.polypart)::RF::IR + rec.ir
\end{verbatim}
Notice that while ``f'' is an argument to integrate, the ``differentiate''
function is a free variable. The Axiom compiler will look at all of the
symbols ``in scope'' to find its meaning. This code does an import:
\begin{verbatim}
import TranscendentalIntegration(Fraction Polynomial Integer,
SparseUnivariatePolynomial Fraction Polynomial Integer)
\end{verbatim}
which exports monomialIntegrate
\begin{verbatim}
TranscendentalIntegration(F, UP): Exports == Implementation where
F : Field
UP : UnivariatePolynomialCategory F
RF ==> Fraction UP
FF ==> Record(ratpart:F, coeff:F)
UF ==> Union(FF, "failed")
IR ==> IntegrationResult RF
REC ==> Record(ir:IR, specpart:RF, polypart:UP)
Exports ==> with
monomialIntegrate : (RF, UP -> UP) -> REC
++ monomialIntegrate(f, ') returns \spad{[ir, s, p]} such that
++ \spad{f = ir' + s + p} and all the squarefree factors of the
++ denominator of s are special w.r.t the derivation '.
Implementation ==> add
import SubResultantPackage(UP, UP2)
import MonomialExtensionTools(F, UP)
import TranscendentalHermiteIntegration(F, UP)
import CommuteUnivariatePolynomialCategory(F, UP, UP2)
monomialIntegrate(f, derivation) ==
zero? f => [0, 0, 0]
r := HermiteIntegrate(f, derivation)
zero?(inum := numer(r.logpart)) =>
[r.answer::IR, r.specpart, r.polypart]
iden := denom(r.logpart)
x := monomial(1, 1)$UP
resultvec := subresultantVector(UP2UP2 inum -
(x::UP2) * UP2UP2 derivation iden, UP2UP2 iden)
respoly := primitivePart leadingCoefficient resultvec 0
rec := splitSquarefree(respoly, kappa(#1, derivation))
logs:List(LOG) := [
[1, UP2UPR(term.factor),
UP22UPR swap primitivePart(resultvec(term.exponent),term.factor)]
for term in factors(rec.special)]
dlog :=
((derivation x) = 1) => r.logpart
differentiate(mkAnswer(0, logs, empty()),
differentiate(#1, derivation))
(u := retractIfCan(p := r.logpart - dlog)@Union(UP, "failed")) case UP =>
[mkAnswer(r.answer, logs, empty), r.specpart, r.polypart + u::UP]
[mkAnswer(r.answer, logs, [[p, dummy]]), r.specpart, r.polypart]
\end{verbatim}
which expands into the type signature:
\begin{verbatim}
monomialIntegrate:
(Fraction SparseUnivariatePolynomial Fraction Polynomial Integer,
SparseUnivariatePolynomial Fraction Polynomial Integer ->
SparseUnivariatePolynomial Fraction Polynomial Integer) ->
Record(ir: IntegrationResult Fraction
SparseUnivariatePolynomial Fraction Polynomial Integer,
specpart: Fraction
SparseUnivariatePolynomial Fraction Polynomial Integer,
polypart: SparseUnivariatePolynomial Fraction Polynomial Integer)
++ monomialIntegrate(f, ') returns \spad{[ir, s, p]} such that
++ \spad{f = ir' + s + p} and all the squarefree factors of the
++ denominator of s are special w.r.t the derivation '.
\end{verbatim}
we can watch this happen:
\begin{verbatim}
)trace INTTR )math
Function traced: UnivariatePolynomialCategory
Packages traced:
IntegrationResultRFToFunction Integer,
RationalFunctionIntegration Integer,
RationalIntegration(Fraction Polynomial Integer,
SparseUnivariatePolynomial Fraction Polynomial
Integer), PolynomialCategoryQuotientFunctions(
IndexedExponents Kernel Expression Integer,Kernel
Expression Integer,Integer,
SparseMultivariatePolynomial(Integer,Kernel
Expression Integer),Expression Integer),
PolynomialCategoryQuotientFunctions(IndexedExponents
Symbol,Symbol,Integer,Polynomial Integer,Fraction
Polynomial Integer), TranscendentalIntegration(
Fraction Polynomial Integer,
SparseUnivariatePolynomial Fraction Polynomial
Integer)
Parameterized constructors traced:
IRRF2F, INTRF, INTRAT, POLYCATQ, INTTR
\end{verbatim}
and we can watch the monomialIntegrate function call
\begin{verbatim}
(34) -> integrate(1/(a*x+b),x)
1<enter IntegrationResultRFToFunction.integrate,32 :
1
arg1= -------
a x + b
arg2= x
"tpdhere IRRF2F 1"
1<enter RationalFunctionIntegration.internalIntegrate,25 :
1
arg1= -------
a x + b
arg2= x
1<enter PolynomialCategoryQuotientFunctions.univariate,16 :
1
arg1= -------
a x + b
arg2= x
1>exit PolynomialCategoryQuotientFunctions.univariate,16 :
1
-
a
-----
b
? + -
a
1<enter RationalIntegration.integrate,32 :
1
-
a
arg1= ----- <== Fraction SparseUnivariatePolynomial
b Fraction Polynomial Integer
? + -
a
1<enter TranscendentalIntegration.monomialIntegrate,81 :
1
-
a
arg1= ----- <== Fraction SparseUnivariatePolynomial
b Fraction Polynomial Integer
? + -
a
arg2= theMap(UPOLYC-;differentiate;2S;37,873)
1>exit TranscendentalIntegration.monomialIntegrate,81 :
1 b
[ir= - log(? + -),specpart= 0,polypart= 0]
a a
1>exit RationalIntegration.integrate,32 :
1 b
- log(? + -)
a a
1>exit RationalFunctionIntegration.internalIntegrate,25 :
1 a x + b
- log(-------)
a a
1>exit IntegrationResultRFToFunction.integrate,32 :
log(a x + b)
------------
a
log(a x + b)
(34) ------------
a
Type: Union(Expression Integer,...)
(35) ->
\end{verbatim}
\subsection{A simple integral, expansion 6 HermiteIntegrate}
Since ``f'' is not zero we invoke HermiteIntegrate from the domain
TranscendentalHermiteIntegration which looks like:
\begin{verbatim}
TranscendentalHermiteIntegration(F, UP): Exports == Implementation where
F : Field
UP : UnivariatePolynomialCategory F
N ==> NonNegativeInteger
RF ==> Fraction UP
REC ==> Record(answer:RF, lognum:UP, logden:UP)
HER ==> Record(answer:RF, logpart:RF, specpart:RF, polypart:UP)
Exports ==> with
HermiteIntegrate: (RF, UP -> UP) -> HER
++ HermiteIntegrate(f, D) returns \spad{[g, h, s, p]}
++ such that \spad{f = Dg + h + s + p},
++ h has a squarefree denominator normal w.r.t. D,
++ and all the squarefree factors of the denominator of s are
++ special w.r.t. D. Furthermore, h and s have no polynomial parts.
++ D is the derivation to use on \spadtype{UP}.
Implementation ==> add
import MonomialExtensionTools(F, UP)
HermiteIntegrate(f, derivation) ==
rec := decompose(f, derivation)
hi := normalHermiteIntegrate(rec.normal, derivation)
qr := divide(hi.lognum, hi.logden)
[hi.answer, qr.remainder / hi.logden, rec.special, qr.quotient + rec.poly]
\end{verbatim}
The function has the same input signature as monomialIntegrate but a
different return signature.
\begin{verbatim}
HermiteIntegrate:
(Fraction SparseUnivariatePolynomial Fraction Polynomial Integer,
SparseUnivariatePolynomial Fraction Polynomial Integer ->
SparseUnivariatePolynomial Fraction Polynomial Integer) ->
Record(answer:Fraction SparseUnivariatePolynomial
Fraction Polynomial Integer,
logpart:Fraction SparseUnivariatePolynomial
Fraction Polynomial Integer,
specpart:Fraction SparseUnivariatePolynomial
Fraction Polynomial Integer,
polypart:SparseUnivariatePolynomial Fraction Polynomial Integer)
\end{verbatim}
so we trace this domain
\begin{verbatim}
(37) -> )trace INTHERTR )math
Function traced: UnivariatePolynomialCategory
Packages traced:
IntegrationResultRFToFunction Integer,
RationalFunctionIntegration Integer,
RationalIntegration(Fraction Polynomial Integer,
SparseUnivariatePolynomial Fraction Polynomial
Integer), PolynomialCategoryQuotientFunctions(
IndexedExponents Kernel Expression Integer,Kernel
Expression Integer,Integer,
SparseMultivariatePolynomial(Integer,Kernel
Expression Integer),Expression Integer),
PolynomialCategoryQuotientFunctions(IndexedExponents
Symbol,Symbol,Integer,Polynomial Integer,Fraction
Polynomial Integer), TranscendentalIntegration(
Fraction Polynomial Integer,
SparseUnivariatePolynomial Fraction Polynomial
Integer), TranscendentalHermiteIntegration(Fraction
Polynomial Integer,SparseUnivariatePolynomial
Fraction Polynomial Integer)
Parameterized constructors traced:
IRRF2F, INTRF, INTRAT, POLYCATQ, INTTR, INTHERTR
\end{verbatim}
and now we see
\begin{verbatim}
(38) -> integrate(1/(a*x+b),x)
1<enter IntegrationResultRFToFunction.integrate,32 :
1
arg1= -------
a x + b
arg2= x
"tpdhere IRRF2F 1"
1<enter RationalFunctionIntegration.internalIntegrate,25 :
1
arg1= -------
a x + b
arg2= x
1<enter RationalIntegration.integrate,32 :
1
-
a
arg1= -----
b
? + -
a
"tpdhere INTRAT 1"
1<enter TranscendentalIntegration.monomialIntegrate,81 :
1
-
a
arg1= -----
b
? + -
a
arg2= theMap(UPOLYC-;differentiate;2S;37,873)
1<enter TranscendentalHermiteIntegration.HermiteIntegrate,18 :
1
-
a
arg1= -----
b
? + -
a
arg2= theMap(UPOLYC-;differentiate;2S;37,873)
1>exit TranscendentalHermiteIntegration.HermiteIntegrate,18 :
1
-
a
[answer= 0,logpart= -----,specpart= 0,polypart= 0]
b
? + -
a
1>exit TranscendentalIntegration.monomialIntegrate,81 :
1 b
[ir= - log(? + -),specpart= 0,polypart= 0]
a a
"tpdhere UPOLYC 1"
1>exit RationalIntegration.integrate,32 :
1 b
- log(? + -)
a a
1>exit RationalFunctionIntegration.internalIntegrate,25 :
1 a x + b
- log(-------)
a a
1<enter IntegrationResultRFToFunction.expand,18 :
1 a x + b
arg1= - log(-------)
a a
1>exit IntegrationResultRFToFunction.expand,18 :
a x + b
log(-------)
a
[------------]
a
1>exit IntegrationResultRFToFunction.integrate,32 :
log(a x + b)
------------
a
log(a x + b)
(38) ------------
a
Type: Union(Expression Integer,...)
\end{verbatim}
so HermiteIntegrate did nothing to the input.
Next we call normalHermiteIntegrate which is a local function
\section{Tools}
\subsection{svn}
SVN is a source control system on all platforms. Axiom 'silver' is
maintained in an SVN archive on sourceforge. This can be pulled from:
\begin{verbatim}
svn co https://axiom.svn.sf.net/svnroot/axiom/trunk/axiom axiom
\end{verbatim}
\subsection{git}
Git is a unix-based source code control system. Axiom 'silver' is
maintained in a git archive. This can be pulled from:
\begin{verbatim}
git-clone ssh://git@axiom-developer.org/home/git/silver
\end{verbatim}
the password for the userid git is linus.
\subsection{cvs}
This assumes that you have set up ssh on the Savannah site.
CVS does not use a password. You have to log onto the Savannah
site and set up a public key. This requires you to:
\begin{itemize}
\item set up a local public key:
ssh-keygen -b 1024 -t rsa1
\item open a browser
\item nagivate to the savannah page that has your personal keys
\item open .ssh/identity.pub
\item cut .ssh/identity.pub
\item paste it into your personal key list on savannah
\item go have a beer (the page takes an hour or two to update)
\end{itemize}
Once you have a working key you can do the cvs login.
If it prompts you for a password then the key is not working.
If it prompts you to ``Enter the passphrase for RSA key'' then
cvs login will work.
I maintain a directory where I work (call this WORK)
\begin{verbatim}
/home/axiomgnu/new
\end{verbatim}
and a directory for CVS (call this GOLD)
\begin{verbatim}
/axiom
\end{verbatim}
When I want to export a set of changes I do the following steps:
\noindent
0) MAKE SURE THE ~/.ssh/config FILE IS CORRECT:
\begin{verbatim}
(you should only need to do this once.
you need to change the User= field)
Host *.gnu.org
Protocol=1
Compression=yes
CompressionLevel=3
User=axiom
StrictHostKeyChecking=no
PreferredAuthentications=publickey,password
NumberOfPasswordPrompts=2
\end{verbatim}
\noindent
1) MAKE SURE THE SHELL VARIABLES ARE OK:
\begin{verbatim}
(normally set in .bashrc)
export CVS_RSH=ssh
export CVSROOT=:pserver:axiom@subversions.gnu.org:/cvsroot/axiom
^^^^^
change this to your id
\end{verbatim}
\noindent
2) MAKE SURE YOU'RE LOGGED IN:
\begin{verbatim}
(I keep a session open all the time but it doesn't seem to care
if you login again. i'm not sure what login does, actually)
cvs login
\end{verbatim}
\noindent
3) GET A FRESH COPY FOR THE FIRST TIME OR AT ANY TIME:
\begin{verbatim}
(you only need to do this the first time but you can erase
your whole axiom subtree and refresh it again doing this.
note that i work as root so i can update /. Most rational
people are smarter than me and work as a regular user so
you have to change the instructions for cd. But you knew that)
cd /
cvs co axiom
\end{verbatim}
\noindent
4) MAKE SURE THAT GOLD, MY LOCAL CVS COPY, IS UP TO DATE:
\begin{verbatim}
(I maintain an exact copy of the CVS repository and only make
changes to it when i want to export the changes. that way I
won't export my working tree by accident. my working tree is
normally badly broken.
The update command makes sure that you have all of the changes
other people might have made and checked in. you have to merge
your changes so you don't step on other people's work.
So be sure to run update BEFORE you copy files to GOLD)
cd /axiom
cvs update
\end{verbatim}
\noindent
5) COPY CHANGED FILES FROM WORK TO THE GOLD TREE:
\begin{verbatim}
(This is an example for updating the *.daase files.
You basically are changing your GOLD tree to reflect the
way you want CVS to look once you check in all of the files.)
cd /home/axiomgnu/new
cp src/share/algebra/*.daase /axiom/src/share/algebra
\end{verbatim}
\noindent
6) IF A FILE IS NEW (e.g. src/interp/foo.lisp.pamphlet) THEN:
\begin{verbatim}
(If you create a file you need to "put it under CVS control"
CVS only cares about files you explicitly add or delete.
If you make a new file and copy it to GOLD you need to do this.
Don't do the "cvs add" in your WORK directory. The cvs add
command updates the files in the CVS directory and you won't
have them in your WORK directory.
Notice that you do the "cvs add" in the directory where the
file was added (hence, the cd commands).
cd /axiom/src/interp
cvs add -m"some pithy comment" foo.lisp.pamphlet
cd /axiom
\end{verbatim}
\noindent
7) IF A FILE IS DELETED (e.g. src/interp/foo.lisp.pamphlet) THEN:
\begin{verbatim}
(you have to delete the file from the GOLD directory BEFORE you
do a "cvs remove". The "cvs remove" will update the files in
the CVS directory
Notice that you do the "cvs remove" in the directory where the
file was deleted (hence, the cd commands).
cd /axiom/src/interp
rm foo.lisp.pamphlet
cvs remove foo.lisp.pamphlet
cd /axiom
\end{verbatim}
\noindent
8) IF A DIRECTORY IS NEW (e.g. foodir) THEN:
\begin{verbatim}
(this will put "foodir" under CVS control. It will also create
foodir/CVS as a directory with a bunch of control files in the
foodir/CVS directory. Don't mess with the control files.
(there are a bunch of special rules about directories.
empty directories are not downloaded by update.)
(NOTE: THERE IS NO WAY TO DELETE A DIRECTORY)
cd /axiom/src
mkdir foodir
cvs add -m "pithy comment" foodir
cd /axiom
\end{verbatim}
\noindent
9) EDIT CHANGELOG:
\begin{verbatim}
changelog is already under CVS control so it will get uploaded
when you do the checkin.)
cd /axiom
emacs -nw changelog
(add a date, initials, and pithy comment, save it, and exit)
\end{verbatim}
\noindent
10) CHECK IN THE CHANGES
\begin{verbatim}
(This will actually change the savannah CVS repository.
The "cvs ci" command will recurse thru all of the lower
subdirectories and look for changed files. It will change
the host versions of those files to agree with your copy.
If somebody else has changed a file while you were busy
developing code then the checkin MAY complain (if it can't
merge the changes)
cd /axiom
cvs ci -m"pithy comment"
\end{verbatim}
Congrats. You've now done your first change to the production
image. Please be very careful as this is a world readable copy.
We don't want to ship nonsense. Test everything. Even trivial
changes before you upload.
\section{Common Lisps}
\subsection{GCL}
Axiom was ported to run under AKCL which was a common lisp
developed by Bill Schelter. He started with KCL (Kyoto Common
Lisp) and, since he lived and worked in Austin, Texas, named
his version AKCL (Austin-Kyoto Common Lisp). Bill worked under
contract to the Scratchpad group at IBM Research. I was the
primary developer for system internals so Bill and I worked
closely together on a lot of issues. After Axiom was sold to
NAG Bill continued to develop AKCL and it eventually became
GCL (Gnu Common Lisp).
In order to port Axiom to run on GCL we need to do several things.
First, we need to apply a few patches. These patches enlarge the
default stack size, remove the startup banner, link with Axiom's
socket library, and rename collectfn.
The issue with the stack size is probably bogus. At one point the
system was running out of stack space but the problem was due to
a recursive expansion of a macro and no amount of stack space
would be sufficient. This patch remains at the moment but should
probably be removed and tested.
The startup banner is an issue because we plan to run under
various frontend programs like Texmacs and the Magnus ZLC.
We need to just output a single prompt.
Axiom has a socket library because at the time it was developed under
AKCL there was no socket code in Lisp. There is still not a standard
common lisp socket library but I believe all common lisps have a way
to manipulate sockets. This code should be rewritten in lisp
and \verb|#+| for each common lisp.
The collectfn file is a major optimization under GCL. When collectfn
is loaded and the lisp compiler is run then collectfn will output
a .fn file. The second time the compiler is invoked the .fn
file is consulted to determine the actual types of arguments used.
Function calling is highly optimized using this type information
so that fast function calling occurs. Axiom should be built one
time to create the int/*/*.fn files. It should then be rebuilt
using the cached .fn files. I will automate this process into
the Makefiles in the future.
GCL implementation will have a major porting problem to brand new
platforms. The compiler strategy is to output C code, compile it
using GCC, and dynamically link the machine code to the running
image. This requires deep knowledge of the symbol tables used
by the native linker for each system. In general this is a hard
problem that requires a lot of expertise. Bill Schelter and I
spent a lot of time and effort making this work for each port.
The magic knowledge is not written down anywhere and I no longer
remember the details.
\subsection{CCL}
When Axiom was sold to NAG it was ported to CCL (Codemist Common
Lisp) which is not, strictly speaking, a common lisp implementation.
It contains just enough common lisp to support Axiom and, as I'm
a great believer in simple code, it only needed a small subset of
a full common lisp.
CCL can be considered the best way to get Axiom running on a new
architecture as the porting issues are minimal.
CCL is a byte-interpreter implementation and has both the
positive and negative aspects of that design choice. The positive
aspect is that porting the code to run on new architectures is
very simple. Once the CCL byte-code interpreter is running
then Axiom is running. The saved-system image is pure byte-codes
and is completely system independent.
The negative aspects are that it is slow and the garbage collector
appears broken. Compiling the Axiom library files on an file-by-file
basis takes about 1 hour on GCL and about 12 hours on CCL. Compiling
all of the Axiom library files in the same image (as opposed to
starting a new image per file) still takes about 1 hour on GCL.
It never finishes in CCL. Indeed it stops doing useful work after
about the 40th file (out of several hundred).
When Axiom became open source I moved the system back to GCL
because I could not understand how to build a CCL system. I plan
to revisit this in the future and document the process so others
can follow it as well as build Makefiles to automate it.
\subsection{CMU CL}
CMU CL grew out of the Carnegie-Mellon University SPICE project.
That project studied the issues involved in building an optimizing
compiler for common lisp. Axiom, back when it was Scratchpad at IBM,
ran on CMU CL. Indeed, a lot of the lisp-level optimizations are
due to use of the CMU CL compiler and the disassemble function.
\subsection{Franz Lisp}
Axiom, as Scratchpad, ran on Franz Lisp.
\subsection{Lucid Common Lisp}
Axiom, as Scratchpad, ran on Lucid Common Lisp.
\subsection{Symbolics Common Lisp}
Axiom, as Scratchpad, ran on Symbolics Common Lisp.
\subsection{Golden Common Lisp}
Axiom, as Scratchpad, ran on Golden Common Lisp.
This was a PC version of Common Lisp which appears to have died.
\subsection{VM/LISP 370}
Axiom, as Scratchpad, ran on VM/Lisp 370. This was an IBM version
of lisp and was not a common lisp. The .daase random access
file format is an artifact of running on this lisp.
\subsection{Maclisp}
Axiom, as Scratchpad, ran on Maclisp. This was an early MIT version
of lisp and is not common lisp. Many of the funny function names
that have slightly different semantics than their common lisp
counterparts still exist in the system as macros due to this
lisp.
\section{Changing GCL versions}
Axiom lives on GNU Common Lisp. Axiom adds C code to the lisp image.
Axiom caches versions to ensure that nothing breaks. Changing GCL
versions has introduced subtle bugs at various times. The steps
necessary to introduce a new version are
\begin{enumerate}
\item Add the latest GCL sources to Axiom
\item Update the patches to the new version
\item create diff -Naur patches to the gcl sources
\item update lsp/Makefile.pamphlet to apply the patch at build
\item add a new chunk to lsp/Makefile.pamphlet to build gcl-2.6.10
\item Change the GCLVERSION to point at the new sources
\item change the Makefile to match Makefile.pamphlet
\end{enumerate}
We assume in the following that \verb|$AXHOME| is the home directory and that
Axiom lives in the silver subdirectory.
In more detail these steps are:
\begin{enumerate}
\item Add the lateset GCL sources to Axiom
\begin{enumerate}
\item Download the latest GCL from gnu.org\\
For these instructions assume the file is
\begin{verbatim}
gcl-Version_2_6_10.tar.gz
\end{verbatim}
\item move the tar file into /tmp\\
We are going to make changes to the distribution via patches
\item untar the file
\begin{verbatim}
tar -zxf gcl-Version_2_6_10.tar.gz
\end{verbatim}
\item cd to the untarred directory
\begin{verbatim}
cd gcl-Version_2_6_10
\end{verbatim}
\item rename the gcl directory\\
Camm follows a convention that the top level directory in the
tar file is called gcl. Since we maintain several past versions
we need to rename this and re-tar it
\begin{verbatim}
mv gcl gcl-2.6.10
\end{verbatim}
\item rename gcl to use our naming convention
\begin{verbatim}
tar -zcf gcl-2.6.10.tgz gcl-2.6.10
\end{verbatim}
\item We move the original, renamed, retarred file to the zip directory
\begin{verbatim}
mv gcl-2.6.10.tgz $AXHOME/silver/zips
\end{verbatim}
\item We have to make sure to include the new file in the git commit
\begin{verbatim}
cd $AXHOME/silver
\end{verbatim}
\item Tell git we care about the file
\begin{verbatim}
git add zips/gcl-2.6.10.tgz
\end{verbatim}
\end{enumerate}
\item Update the patches to the new version
\begin{enumerate}
\item find the previous patches
\begin{verbatim}
ls $AXHOME/silver/zips/gcl-2.6.8pre7*patch
\end{verbatim}
\item for each patch do ( Step 3 ; Step 4 )
\end{enumerate}
\item create diff -Naur patches to the gcl sources
\begin{enumerate}
\item assume we are looking at gcl-2.6.8pre7.h.linux.defs.patch\\
The name tells us what file to patch. From the above we can see
that when Axiom builds GCL it will
\begin{verbatim}
cd lsp/gcl-2.6.8pre7
\end{verbatim}
because GCL is built by the lsp/Makefile.pamphlet. That Makefile
will do a
\begin{verbatim}
cd h
patch <gcl-2.6.8pre7.h.linux.defs.patch
\end{verbatim}
which will apply the patch .... So we need to make a patch
\item move to the subdirectory containing the file
\begin{verbatim}
cd /tmp/gcl-Version_2_6_10/gcl-2.6.10/h
\end{verbatim}
\item edit the 'linux.defs' file to create the proper patch
\item save the changed file as linux.defs.tpd
\item in a shell, create a diff -Naur patch by
\begin{verbatim}
diff -Naur linux.defs linux.defs.tpd >gcl-2.6.10.h.linux.defs.patch
\end{verbatim}
\item move it to the zips directory
\begin{verbatim}
mv gcl-2.6.10.h.linux.defs.patch $AXHOME/silver/zips
cd $AXHOME/silver
git add zips/gcl-2.6.10.h.linux.defs.patch
\end{verbatim}
\end{enumerate}
\item update lsp/Makefile.pamphlet to apply the patch at build
\begin{enumerate}
\item edit lsp/Makefile.pamphlet
\item search for chunk \verb|gcl-2.6.8pre7.h.linux.defs.patch|
\item copy the chunk and name the new chunk
\verb|gcl-2.6.10.h.linux.defs.patch|
\end{enumerate}
\item add a new chunk to lsp/Makefile.pamphlet to build gcl-2.6.10
\begin{enumerate}
\item find the subsection ``The GCL-2.6.8pre7 stanza''
\item make a copy named ``The GCL-2.6.10 stanza''
\item add the new patches
\item tell git we care
\begin{verbatim}
cd $AXHOME/silver
git add lsp/Makefile.pamphlet
\end{verbatim}
\end{enumerate}
\item Change the GCLVERSION to point at the new sources
\begin{enumerate}
\item emacs \verb|$AXHOME/silver/Makefile.pamphlet|
\item search for \verb|#GCLVERSION|, a Makefile comment line
\item the last line is uncommented. Assume it reads GCLVERSION=gcl-2.6.8pre7\\
gcl-2.6.8pre7 was is the name of the current version we are
replacing. We will use this name in the next step
\item put a \# in front of the GCLVERSION variable to comment it out\\
We maintain the list of old, working patches. We also remember the
names of the prior GCLVERSIONS in case we have to back up
\item Add a new line reading:
\begin{verbatim}
GCLVERSION=gcl-2.6.10
\end{verbatim}
This will cause Axiom to untar this tgz file to get the sources
and apply the corresponding patches
\end{enumerate}
\item change the Makefile to match Makefile.pamphlet
\begin{itemize}
\item compile the tangle program
\begin{verbatim}
( cd books ; gcc -o tangle tangle.c )
\end{verbatim}
\item use books/tangle to extract the new Makefile
\begin{verbatim}
books/tangle Makefile.pamphlet >Makefile
\end{verbatim}
\end{itemize}
\end{enumerate}
\section{Literate Programming}
The Axiom source code was originally developed at IBM Research.
It was sold to The Numerical Algorithms Group (NAG) and was on
the market as a commercial competitor to Mathematica and Maple.
Axiom was withdrawn from the market in 2000 and released as free
and open source software in 2001. When the Axiom project was
started on savannah, the GNU Free Software Foundation site the
source code had been rewritten into ``pamphlet'' files. The reasons
for this are twofold.
\subsection{Pamphlet files}
When the Axiom code was released it contained few comments. That made
it very difficult to understand what the code actually did. Unlike
commercial software there would be no group of individuals who would
work on the project for its lifetime. Thus there needed to be a way to
capture the expertise and understanding underlying ongoing
development.
Unlike any other piece of free and open source software Axiom will
still give useful answers 30 years from now. Thus it is important,
and worthwhile, to invest a large amount of effort into documenting
how these answers are arrived at and why the algorithms are written
the way they are.
The pamphlet file format follows Knuth's idea of literate
programming. Knuth made the observation that a program should be a
work designed to be read by humans. Making the program readable by
machine was a secondary consideration. Making documentation primary
and code secondary was a dramatic shift for a programmer.
Knuth created a file format that combined documentation and code. He
created a tool called ``Web'' which had two basic command, tangle and
weave. The tangle command would be run against a literate document and
extract the source code, the weave command would be run against the
literate document and extract the TeX.
\subsection{noweb}
Knuth's Web tool was specifically designed to use Pascal code. The
``tangle'' operation would prettyprint the output according to the
style rules of Pascal.
Axiom was written in a variety of languages, such as C and Lisp,
and used tools such as Makefiles which have their own syntax. Thus
Web could not be used directly.
Axiom defines a new latex environment called chunk.
This chunk environment makes the pamphlet file a pure latex file.
This eliminates the need for the weave operation. The tangle
operation only needs to occur while manipulating code, either during
system build or end user interaction. At both of these times the
tangle operation can be built into the system and hidden.
To support extracting chunks from pamphlet files Axiom now has a
new top level command. At the top level one can write:
\begin{verbatim}
)tangle filename
\end{verbatim}
This will look for ``filename.pamphlet'' and extract the top level
chunk which has the name ``*''.
The latest changeset introduces two related changes, gclweb and
axiom.sty. Together these changes allow optional syntactic changes to
pamphlets. These changes will completely eliminate the need to weave
files since now a pamphlet file can be a valid latex file. Tangle is
the only remaining command and it will eventually be an option on
)compile, etc.
The src/interp/gclweb.lisp file introduces the ability to extract code
from pamphlet files while inside Axiom. The short description is that
gclweb will now automatically distinguish the type of chunk style
(latex or noweb) based on the chunk name. It is a first step to a native
understanding of pamphlet files. Future work involves integrating it
into commands like )compile and adding commands like )tangle.
Tangle can also be called directly from lisp on a file from within Axiom:
\begin{verbatim}
)lisp (tangle "filename.pamphlet" "chunkname")
)lisp (tangle "filename.pamphlet" "chunkname" "filename.spad")
\end{verbatim}
gclweb distinguishes the input syntax by looking at the first character
of the chunkname. If it is a '$<$' then noweb is used, otherwise latex.
The src/doc/axiom.sty.pamphlet introduces the new chunk environment.
This is a completely compatible change and has no impact on existing
pamphlets. The new syntax makes pamphlet files = tex files so there is
no need to use weave. The gclweb change has a compatible tangle
function which can be invoked from inside Axiom.
\begin{verbatim}
\begin{chunk}{chunkname}
your code goes here
\end{chunk}
\end{verbatim}
One feature of the latex chunk style is that latex commands
work within the chunk. To get typeset mathematics use
\verb|\(| and \verb|\)|
\begin{verbatim}
-- This will typeset in a chunk \( x^2+\epsilon \)
-- And you can format things {\bf bold}
\end{verbatim}
\section{Databases}
\subsection{libcheck}
The databases are built from the .kaf files in the .nrlib directories.
(.kaf files are random access files).
interp.exposed is a file that names all of the CDPs (Category, Domain,
and Packages) and classifies them. Only some CDPs are exposed because
most are used to implement algebra and are not intended to be user level
functions. Exposing all of the functions causes much ambiguity.
There is a function called libcheck (see src/interp/util.lisp.pamphlet)
that will check nrlibs vs interp.exposed. This is only partially
functional as I see that changes were made to the system which broke
this function.
The libcheck function requires an absolute pathname to the int directory
so call it thus:
\begin{verbatim}
--> )lisp (libcheck "/axiom/int/algebra")
\end{verbatim}
The main reason this function is broken is that the system now gets
exposure information from src/algebra/exposed.lsp.pamphlet. It appears
that interp.exposed.pamphlet is no longer used (although I made sure
that both files have the same information). I'm going to modify libcheck
to use exposed.lsp in the future and eliminate all references in the
system to interp.exposed.
For the moment, however, the libcheck function is quite useful.
It used to be run during system build because I frequently ran into
database problems and this function would alert me to that fact.
I'll add it back into the Makefile once I elide interp.exposed.
\subsection{asq}
Axiom has several databases which contain information about domains,
categories, and packages. The databases are in a compressed format and
are organized as random-access files using numeric index values so it
is hard to get at the stored information. However, there is a
command-line query function called asq (pronounced ask) that knows the
format of the files and can be used for stand-alone queries. For
instance, if you know the abbreviation for a domain but want to know
what source file generated that domain you can say:
\begin{verbatim}
asq -so FOOBAR
\end{verbatim}
and it will tell you the name of the algebra source file that
defines FOOBAR.
\section{Axiom internal representations}
\begin{verbatim}
PRIMITIVE REPRESENTATIONS OF AXIOM OBJECTS
There are several primitive representations in axiom. These are:
boolean
this is represented as a lisp boolean
integer
this is represented as a lisp integer
small integer
this is represented as a lisp integer
small float
this is represented as a lisp float
list
this is represented as a lisp list
vector
this is represented as a lisp vector
record
there are 3 cases:
records of 1 element are a pair (element . nil)
records of 2 element are a pair (element1 . element2)
records of 3 or more are a vectors #<a b c...>
mapping
mappings are a spadcall objects. they are represented as a pair
(lispfn . env)
where the env is usually a type object. A spadcall rips this
pair open and applies the lispfn to its args with env as the
last arg.
union
there are 2 cases
if the object can be determined by a lisp predicate
(eg integer) then the union is just the object (eg 3)
itself since we can use lisp to decide which branch of
the union the object belongs to. that is, 3 is of the
integer branch in union(list,integer)
if the object cannot be determined then the object is
wrapped into a pair where the car of the pair is the
union branch name and the cdr of the pair is the object.
that is, given union(a:SUP,b:POLY(INT)) x might be (a . x)
note: if no tags are given in the union the system uses
consecutive integers, thus union(SUP,POLY(INT)) will give
a pair of (1 . x) or (2 . x) depending on the type of x
other types are built up of compositions of these primitive
types. a sparse univariate polynomial (SUP) over the integers
x**2+1
is represented as
Term := Record(k:NonNegativeInteger,c:R)
Rep := List Term
that is, the representation is a list of terms where each term
is a record whose first field is a nonnegative integer (the
exponent) and the second field is a member of the coefficient
ring. since this is a record of length 2 it is represented as
a pair. thus, the internal form of this polynomial is:
((2 . 1) (0 . 1))
a more complex object (recursively defined) is POLY(INT). given
x**2+1
as a POLY(INT) we look at its representation and see:
D := SparseUnivariatePolynomial($)
VPoly := Record(v:VarSet,ts:D)
Rep := Union(R,VPoly)
so first we find that we are a member of the second form of the
union and since this is an untagged union the system uses 2 as
the tag. thus the first level of internal representation is:
( 2 . <a VPoly object> )
next we need to define the VPoly object. VPolys are records of
length 2 so we know they are represented by a pair. the car of
the pair is a VarSet. the cdr is a D which is a
SparseUnivariatePolynomial. Thus we consider this to be a poly
in x (at the top level) and we get:
( 2 . ( x . <an SUP>))
the SUP is over the SparseMultivariatePolynomials (SMP) so the
representation is recursive. Since an SUP is represented as a
list of
(non-negative int . coefficient)
one per term and we have 2 terms we know the next level of
structure is:
( 2 . ( x . (( 2 . <an SMP> ) ( 0 . <an SMP> ))))
the SMP is just the integers so it fits into the first branch
of the union and each SMP looks like:
( uniontag . value )
in this case, being the first branch we get
( 2 . ( x . (( 2 . ( 1 . 1 )) ( 0 . ( 1 . 1 )))))
as the internal representation of
x**2 + 1
what could be easier?
\end{verbatim}
\section{Spad to internal function calling}
\subsection{getdatabse output}
\begin{verbatim}
GETDATABASE('Permutation, 'OPERATIONALIST)$Lisp
\end{verbatim}
generates the output
\begin{verbatim}
(($unique)
(~= (((Boolean) $ $) () T ELT))
(sort (((List $) (List $)) 76 T ELT))
(sign (((Integer) $) 59 T ELT))
(sample (($) () T CONST))
(recip (((Union $ "failed") $) () T ELT))
(order (((NonNegativeInteger) $) 57 T ELT))
(orbit (((Set #1) $ #1) 48 T ELT))
(one? (((Boolean) $) () T ELT))
(odd? (((Boolean) $) 62 T ELT))
(numberOfCycles (((NonNegativeInteger) $) 60 T ELT))
(movedPoints (((Set #1) $) 41 T ELT))
(min (($ $ $) () (OR (has #1 (Finite)) (has #1 (OrderedSet))) ELT))
(max (($ $ $) () (OR (has #1 (Finite)) (has #1 (OrderedSet))) ELT))
(listRepresentation
(((Record (: preimage (List #1)) (: image (List #1))) $) 35 T ELT))
(latex (((String) $) () T ELT))
(inv (($ $) 92 T ELT))
(hash (((SingleInteger) $) () T ELT))
(fixedPoints (((Set #1) $) 98 (has #1 (Finite)) ELT))
(even? (((Boolean) $) 58 T ELT))
(eval ((#1 $ #1) 46 T ELT))
(elt ((#1 $ #1) 93 T ELT))
(degree (((NonNegativeInteger) $) 43 T ELT))
(cycles (($ (List (List #1))) 84 T ELT))
(cyclePartition (((Partition) $) 52 T ELT))
(cycle (($ (List #1)) 21 T ELT))
(conjugate (($ $ $) () T ELT))
(commutator (($ $ $) () T ELT))
(coercePreimagesImages (($ (List (List #1))) 38 T ELT))
(coerceListOfPairs (($ (List (List #1))) 87 T ELT))
(coerceImages (($ (List #1)) 95 T ELT))
(coerce (((OutputForm) $) 83 T ELT) (($ (List (List #1))) 65 T ELT)
(($ (List #1)) 66 T ELT))
(^ (($ $ (PositiveInteger)) () T ELT)
(($ $ (NonNegativeInteger)) () T ELT) (($ $ (Integer)) () T ELT))
(One (($) 16 T CONST))
(>= (((Boolean) $ $) () (OR (has #1 (Finite)) (has #1 (OrderedSet))) ELT))
(> (((Boolean) $ $) () (OR (has #1 (Finite)) (has #1 (OrderedSet))) ELT))
(= (((Boolean) $ $) 44 T ELT))
(<= (((Boolean) $ $) () (OR (has #1 (Finite)) (has #1 (OrderedSet))) ELT))
(< (((Boolean) $ $) 64 T ELT))
(/ (($ $ $) () T ELT))
(** (($ $ (PositiveInteger)) () T ELT)
(($ $ (NonNegativeInteger)) () T ELT) (($ $ (Integer)) () T ELT))
(* (($ $ $) 22 T ELT)))
\end{verbatim}
Sometimes in a getdatabase expression you will see:
\begin{verbatim}
(~= (((Boolean) $ $) () T ELT))
---------------------^^
\end{verbatim}
and in other places there is a number
\begin{verbatim}
(sign (((Integer) $) 59 T ELT))
---------------------------^^
\end{verbatim}
In general, when a large number appears it is a byte index into
the compress.daase file.
Axiom would not fit on a laptop. We needed smaller databases.
The solution to the problem was to scan the datatases for
common substrings, write the substring to compress.daase,
and replace the substring by the byte offset.
When reading the database these numbers would be replaced
by the substring from compress.daase using random access
seeks based on the byte offset.
See book volume 5
for an explanation of the database file formats.
HOWEVER, in this case, the number has a different meaning
which I will talk about below.
In summary, this shows what the following incantation means:
\begin{verbatim}
(sign (((Integer) $) () (has #1 (OrderedIntegralDomain))))
\end{verbatim}
\begin{verbatim}
INTEGER inherits sign from OINTDOM (OrderedIntegralDomain)
OINTDOM inherits sign from ORDRING (OrderedRing)
ORDRING implements sign
since ORDRING is a category, the actual code lives in
ORDRING-.nrlib/code.lsp
\end{verbatim}
The code for sign in ORDRING-.nrlib/code.lsp has the signature:
\begin{verbatim}
(DEFUN |ORDRING-;sign;SI;3| (|x| $) ....)
\end{verbatim}
We can "decode" the meaning of the function name as
\begin{itemize}
\item {\bf ORDRING-} the implementing file
\item {\bf sign} the function name
\item {\bf SI} returns SingleInteger (an old domain name)
\item {\bf 3} the third function in the file
(unique, to distinguish multiple functions with the same name)
\end{itemize}
It takes 2 arguments,
\begin{itemize}
\item {\bf \verb?|x|?} which should be a SingleInteger
\item {\bf \verb?$?} which is the current domain (ORDRING-)
\end{itemize}
So it looks like I have the following structure
\begin{verbatim}
(NAME ((TARGETTYPE SOURCETYPE) ?1 CONDITION ?2))
\end{verbatim}
but we are looking up 'sign' in INTEGER so there is
a condition on sign
\begin{verbatim}
Integer has OrderedRing ==> true
\end{verbatim}
so that explains the condition field.
Here we show how Axiom finds the function implementation, looks up the
function ``in the domain'', and calls it.
\begin{verbatim}
(sign (((Integer) $) 59 T ELT))
\end{verbatim}
Now you've asked for 'sign' from domain Permutation
\begin{verbatim}
(sign (((Integer) $) 59 T ELT))
\end{verbatim}
The implementation for 'sign' is in PERM.nrlib/code.lsp. It reads:
\begin{verbatim}
(defun |PERM;sign;$I;17| (|p| $)
(cond
((spadcall |p| (qrefelt $ 58)) 1)
('t -1)))
\end{verbatim}
which you would read as
\begin{verbatim}
if (calling function in position 58 of myself) is true
then return 1
else return -1
\end{verbatim}
How does Axiom find the function? It is in the infovec which
is the ``information vector'' containing information about the
domain.
First we must make sure that PERM has the necessary domain
information loaded (the 'infovec').
\begin{verbatim}
-> [1,2,3]::PERM(INT)
\end{verbatim}
Now, back to the 'sign' function. You saw this:
\begin{verbatim}
(sign (((Integer) $) 59 T ELT)) (sample (($) () T CONST))
\end{verbatim}
which is asking you to look up element 59 from the domain (\verb|$|)
Note that \verb|$| {\sl actually} means the infovec. So we are asking:
\begin{verbatim}
(elt (elt (getf (symbol-plist '|Permutation|) '|infovec|) 0) 59)
\end{verbatim}
which results in:
\begin{verbatim}
|PERM;sign;$I;17|
\end{verbatim}
so we ``looked up'' the function sign in the domain PERM.
Explaining in more detail, from the inside out by walking the
runtime data structures we see
\begin{verbatim}
(symbol-plist '|Permutation|)
\end{verbatim}
returns the property list on the symbol {\bf Permutation} which is where
Axiom caches domain information. Almost everything of interest about a
domain resides on the property list, shown here in all its glory.
\begin{verbatim}
(LOADED "/research/test/mnt/ubuntu/algebra/PERM.o"
SYSTEM:DEBUG (#:G1567 #:G1568)
|infovec| (
#(NIL NIL NIL NIL NIL NIL
(|local| |#1|) (QUOTE |Rep|) (|Boolean|)
(0 . <) (|PositiveInteger|) (6 . |lookup|)
(|Integer|) (|List| 6) (11 . |maxIndex|)
(16 . |elt|)
(CONS IDENTITY (FUNCALL (|dispatchFunction| |PERM;One;$;29|) $))
(|NonNegativeInteger|) (22 . |last|) (28 . |first|)
(34 . |concat|) |PERM;cycle;L$;26| |PERM;*;3$;28|
(40 . =) (46 . =) (52 . |elt|)
(58 . |list|) (63 . |position|) (69 . |delete|)
(|Mapping| 8 13 13) (|List| 13) (75 . |sort|)
(81 . |copy|) (86 . |member?|)
(|Record| (|:| |preimage| 13) (|:| |image| 13))
|PERM;listRepresentation;$R;9| (92 . |elt|)
(98 . ~=) |PERM;coercePreimagesImages;L$;10|
(|Set| 6) (104 . |construct|) |PERM;movedPoints;$S;11|
(109 . |#|) |PERM;degree;$Nni;12| |PERM;=;2$B;13|
(114 . |brace|) |PERM;eval;$2S;31| (119 . |insert!|)
|PERM;orbit;$SS;14| (|List| 12) (|Partition|)
(125 . |partition|) |PERM;cyclePartition;$P;15|
(130 . |convert|) (135 . |removeDuplicates|)
(|List| $) (140 . |lcm|) |PERM;order;$Nni;16|
|PERM;even?;$B;18| |PERM;sign;$I;17| |PERM;numberOfCycles;$Nni;33|
(145 . |even?|) |PERM;odd?;$B;19| (150 . |maxIndex|)
|PERM;<;2$B;20| |PERM;coerce;L$;21| |PERM;coerce;L$;22|
(|Record| (|:| |cycl| 30) (|:| |permut| $$))
(|List| 67) (155 . |cons|) (|Mapping| 8 67 67)
(161 . |sort|) (|List| $$) (167 . |nil|)
(171 . |cons|) (177 . |reverse|) |PERM;sort;2L;23|
(|OutputForm|) (182 . |coerce|) (187 . |blankSeparate|)
(192 . |paren|) (197 . |outputForm|) (202 . |hconcat|)
|PERM;coerce;$Of;24| |PERM;cycles;L$;25| (207 . |second|)
(212 . =) |PERM;coerceListOfPairs;L$;27|
(|Vector| 6) (218 . |construct|) (223 . |elt|)
(229 . |new|) |PERM;inv;2$;30| |PERM;elt;$2S;32|
(235 . |coerce|) (240 . |coerceImages|) (245 . |index|)
(250 . |complement|) (255 . |fixedPoints|) (260 . |conjugate|)
(265 . +) (|Union| $ (QUOTE "failed"))
(|SingleInteger|) (|String|))
#(~= 271 |sort| 277 |sign| 282
|sample| 287 |recip| 291 |order| 296
|orbit| 301 |one?| 307 |odd?| 312
|numberOfCycles| 317 |movedPoints| 322 |min| 327
|max| 333 |listRepresentation| 339 |latex| 344
|inv| 349 |hash| 354 |fixedPoints| 359
|even?| 364 |eval| 369 |elt| 375
|degree| 381 |cycles| 386 |cyclePartition| 391
|cycle| 396 |conjugate| 401 |commutator| 407
|coercePreimagesImages| 413 |coerceListOfPairs| 418 |coerceImages| 423
|coerce| 428 ^ 443 |One| 461
>= 465 > 471 = 477
<= 483 < 489 / 495
** 501 * 519)
((|unitsKnown| . 0))
(#(0 0 0 0 3 0 0 0)
#(NIL
|Group&|
|Monoid&|
|SemiGroup&|
|OrderedSet&|
|SetCategory&|
|BasicType&|
NIL)
#((|PermutationCategory| 6)
(|Group|)
(|Monoid|)
(|SemiGroup|)
(|OrderedSet|)
(|SetCategory|)
(|BasicType|)
(|CoercibleTo| 77))
.
#( 2 6 8 0 0 9 1 6 10 0 11 1 13 12 0 14 2 13 6 0 12
15 2 13 0 0 17 18 2 13 0 0 17 19 2 13 0 0 0 20 2 6
8 0 0 23 2 13 8 0 0 24 2 7 13 0 12 25 1 13 0 6 26
2 13 12 6 0 27 2 13 0 0 12 28 2 30 0 29 0 31 1 13 0
0 32 2 13 8 6 0 33 2 30 13 0 12 36 2 6 8 0 0 37 1
39 0 13 40 1 39 17 0 42 1 39 0 13 45 2 39 0 6 0 47 1
50 0 49 51 1 50 49 0 53 1 49 0 0 54 1 12 0 55 56 1 12
8 0 61 1 30 12 0 63 2 68 0 67 0 69 2 68 0 70 0 71 0
72 0 73 2 72 0 2 0 74 1 72 0 0 75 1 6 77 0 78 1 77
0 55 79 1 77 0 0 80 1 77 0 12 81 1 77 0 55 82 1 13 6
0 85 2 39 8 0 0 86 1 88 0 13 89 2 88 6 0 12 90 2 7
0 17 13 91 1 6 0 12 94 1 0 0 13 95 1 6 0 10 96 1 39
0 0 97 1 0 39 0 98 1 50 0 0 99 2 50 0 0 0 100 2 0
8 0 0 1 1 0 55 55 76 1 0 12 0 59 0 0 0 1 1 0 101
0 1 1 0 17 0 57 2 0 39 0 6 48 1 0 8 0 1 1 0 8
0 62 1 0 17 0 60 1 0 39 0 41 2 3 0 0 0 1 2 3 0
0 0 1 1 0 34 0 35 1 0 103 0 1 1 0 0 0 92 1 0 102
0 1 1 1 39 0 98 1 0 8 0 58 2 0 6 0 6 46 2 0 6
0 6 93 1 0 17 0 43 1 0 0 30 84 1 0 50 0 52 1 0 0
13 21 2 0 0 0 0 1 2 0 0 0 0 1 1 0 0 30 38 1 0
0 30 87 1 0 0 13 95 1 0 0 13 66 1 0 0 30 65 1 0 77
0 83 2 0 0 0 12 1 2 0 0 0 17 1 2 0 0 0 10 1 0
0 0 16 2 3 8 0 0 1 2 3 8 0 0 1 2 0 8 0 0 44
2 3 8 0 0 1 2 0 8 0 0 64 2 0 0 0 0 1 2 0 0
0 12 1 2 0 0 0 17 1 2 0 0 0 10 1 2 0 0 0 0 22))
|lookupComplete|)
PNAME "Permutation"
DATABASE
#S(DATABASE
ABBREVIATION PERM
ANCESTORS NIL
CONSTRUCTOR NIL
CONSTRUCTORCATEGORY 2444459
CONSTRUCTORKIND |domain|
CONSTRUCTORMODEMAP
(((|Permutation| |#1|)
(|Join|
(|PermutationCategory| |#1|)
(CATEGORY |domain|
(SIGNATURE |listRepresentation|
((|Record| (|:| |preimage| #) (|:| |image| #)) $))
(SIGNATURE |coercePreimagesImages| ($ (|List| (|List| |#1|))))
(SIGNATURE |coerce| ($ (|List| (|List| |#1|))))
(SIGNATURE |coerce| ($ (|List| |#1|)))
(SIGNATURE |coerceListOfPairs| ($ (|List| (|List| |#1|))))
(SIGNATURE |degree| ((|NonNegativeInteger|) $))
(SIGNATURE |movedPoints| ((|Set| |#1|) $))
(SIGNATURE |cyclePartition| ((|Partition|) $))
(SIGNATURE |order| ((|NonNegativeInteger|) $))
(SIGNATURE |numberOfCycles| ((|NonNegativeInteger|) $))
(SIGNATURE |sign| ((|Integer|) $))
(SIGNATURE |even?| ((|Boolean|) $))
(SIGNATURE |odd?| ((|Boolean|) $))
(SIGNATURE |sort| ((|List| $) (|List| $)))
(IF (|has| |#1| (|Finite|))
(SIGNATURE |fixedPoints| ((|Set| |#1|) $)) |noBranch|)
(IF (|has| |#1| (|IntegerNumberSystem|))
(SIGNATURE |coerceImages| ($ (|List| |#1|)))
(IF (|has| |#1| (|Finite|))
(SIGNATURE |coerceImages| ($ #)) |noBranch|))))
(|SetCategory|))
(T |Permutation|))
COSIG (NIL T)
DEFAULTDOMAIN NIL
MODEMAPS 2443154
NILADIC NIL
OBJECT "PERM"
OPERATIONALIST
((|$unique|)
(~= (((|Boolean|) $ $) NIL . #0=(T . #1=(ELT))))
(|sort| (((|List| $) (|List| $)) 76 . #0#))
(|sign| (((|Integer|) $) 59 . #0#))
(|sample| (($) NIL T CONST))
(|recip| (((|Union| $ "failed") $) NIL . #0#))
(|order| (((|NonNegativeInteger|) $) 57 . #0#))
(|orbit| (((|Set| |#1|) $ |#1|) 48 . #0#))
(|one?| (((|Boolean|) $) NIL . #0#))
(|odd?| (((|Boolean|) $) 62 . #0#))
(|numberOfCycles| (((|NonNegativeInteger|) $) 60 . #0#))
(|movedPoints| (((|Set| |#1|) $) 41 . #0#))
(|min| (($ $ $) NIL
(OR (|has| |#1| (|Finite|)) (|has| |#1| (|OrderedSet|))) . #1#))
(|max| (($ $ $) NIL
(OR (|has| |#1| (|Finite|)) (|has| |#1| (|OrderedSet|))) . #1#))
(|listRepresentation|
(((|Record| (|:| |preimage| (|List| |#1|))
(|:| |image| (|List| |#1|))) $) 35 . #0#))
(|latex| (((|String|) $) NIL . #0#))
(|inv| (($ $) 92 . #0#))
(|hash| (((|SingleInteger|) $) NIL . #0#))
(|fixedPoints| (((|Set| |#1|) $) 98 (|has| |#1| (|Finite|)) . #1#))
(|even?| (((|Boolean|) $) 58 . #0#))
(|eval| ((|#1| $ |#1|) 46 . #0#))
(|elt| ((|#1| $ |#1|) 93 . #0#))
(|degree| (((|NonNegativeInteger|) $) 43 . #0#))
(|cycles| (($ (|List| (|List| |#1|))) 84 . #0#))
(|cyclePartition| (((|Partition|) $) 52 . #0#))
(|cycle| (($ (|List| |#1|)) 21 . #0#))
(|conjugate| (($ $ $) NIL . #0#))
(|commutator| (($ $ $) NIL . #0#))
(|coercePreimagesImages| (($ (|List| (|List| |#1|))) 38 . #0#))
(|coerceListOfPairs| (($ (|List| (|List| |#1|))) 87 . #0#))
(|coerceImages| (($ (|List| |#1|)) 95 . #0#))
(|coerce|
(((|OutputForm|) $) 83 . #0#)
(($ (|List| (|List| |#1|))) 65 . #0#)
(($ (|List| |#1|)) 66 . #0#))
(^ (($ $ (|PositiveInteger|)) NIL . #0#)
(($ $ (|NonNegativeInteger|)) NIL . #0#)
(($ $ (|Integer|)) NIL . #0#))
(|One| (($) 16 T CONST))
(>= (((|Boolean|) $ $) NIL
(OR (|has| |#1| (|Finite|)) (|has| |#1| (|OrderedSet|))) . #1#))
(> (((|Boolean|) $ $) NIL
(OR (|has| |#1| (|Finite|)) (|has| |#1| (|OrderedSet|))) . #1#))
(= (((|Boolean|) $ $) 44 . #0#))
(<= (((|Boolean|) $ $) NIL
(OR (|has| |#1| (|Finite|)) (|has| |#1| (|OrderedSet|))) . #1#))
(< (((|Boolean|) $ $) 64 . #0#))
(/ (($ $ $) NIL . #0#))
(** (($ $ (|PositiveInteger|)) NIL . #0#)
(($ $ (|NonNegativeInteger|)) NIL . #0#)
(($ $ (|Integer|)) NIL . #0#))
(* (($ $ $) 22 . #0#)))
DOCUMENTATION 1609893
CONSTRUCTORFORM 1609883
ATTRIBUTES 1614391
PREDICATES 1614406
SOURCEFILE "bookvol10.3.pamphlet"
PARENTS NIL
USERS NIL
DEPENDENTS NIL
SPARE NIL))
\end{verbatim}
There are many things on the property list which looks like
\begin{verbatim}
(symbol1 thing1 symbol2 thing2 ... symboln thingn)
\end{verbatim}
In the PERM case we see
\begin{verbatim}
(LOADED "/research/silver/mnt/algebra/PERM.o"
|infovec| (#<vector> #<vector>...)
....)
\end{verbatim}
We can get the \verb?|infovec|? off the property list with the call
(getf (symbol-plist '|Permutation|) '|infovec|)
is a request to search the property list for the symbol |infovec|
and return the value, which is the domain "information vector".
You can see this vector if you look in PERM.nrlib/code.lsp.
At the bottom of that file you'll see:
\begin{verbatim}
(SETF (GET (QUOTE |Permutation|) (QUOTE |infovec|) ....)
\end{verbatim}
which uses SETF to put the infovec on the property list of PERM.
This information vector contains information for function lookup.
This vector gets created when we "instantiate" PERM.
The {\bf infovec} is a list with the structure
\begin{verbatim}
(#<vector 08ea516c>
#<vector 08ea5150>
((|unitsKnown| . 0))
(#<vector 08ea50fc>
#<vector 08ea5134>
#<vector 08ea5118> . #<vector 08ea50e0>)
|lookupComplete|)
\end{verbatim}
So, now that we have the infovec, back to the game...
\begin{verbatim}
(elt (getf (symbol-plist '|Permutation|) '|infovec|) 0)
\end{verbatim}
This gets the 0th element out of the infovec list which is a
vector of the name of every function Permutation implements.
We look up function names in this list, in particular, 59:
\begin{verbatim}
(elt (elt (getf (symbol-plist '|Permutation|) '|infovec|) 0) 59)
\end{verbatim}
looks into this vector of names at the 59th element which returns
\begin{verbatim}
|PERM;sign;$I;17|
\end{verbatim}
The SPAD form of this function reads:
\begin{verbatim}
sign(p) ==
even? p => 1
-1
\end{verbatim}
The lisp form (see PERM.nrlib/code.lsp) reads:
\begin{verbatim}
(defun |PERM;sign;$I;17| (|p| $)
(cond
((spadcall |p| (qrefelt $ 58)) 1)
('t -1)))
\end{verbatim}
We call the \verb?|PERM;sign;$I;17|? which takes 2 arguments
The first of which is the permutation and the second is the infovec
for the PERM domain.
The \verb|(qrefelt $ 58)| uses the above dance to look up a function
in the infovec at the 58th position... which returns
\begin{verbatim}
|PERM;even?;$B;18|
\end{verbatim}
The spadcall calls \verb'|PERM;even?;$B;18|' with the value of \verb?|p|?.
If we look in the domain Permutation for the implementation of even?
\begin{verbatim}
even?(p) == even?(#(p.1) - numberOfCycles p)
\end{verbatim}
which in PERM.nrlib/code.lsp we see
\begin{verbatim}
(defun |PERM;even?;$b;18|
(spadcall
(- (length (spadcall |p| 1 (qrefelt $ 25)))
(spadcall |p| (qrefelt $ 60)))
(qrefelt % 61)))
\end{verbatim}
where
\begin{verbatim}
(qrefelt $ 25) ==> (52 . |elt|)
(qrefelt $ 60) ==> |PERM;numberOfCycles;$Nni;33|
(qrefelt $ 61) ==> (145. |even?|)
\end{verbatim}
So, to summarize, the small magic numbers you see in the results
are indexes into the infovec, which is where Axiom stores things
it needs to look up at runtime, usually function references.
If there is () rather than a number than there is no need to do
a function lookup.
Axiom execution is an alternating series of function lookups in
the infovec followed by a call of that function which results in
a function lookup in the infovec followed by a call of that
function which results in .....
spadcall is a wrapper macro which takes the arguments and a
function to call. qrefelt does the infovec lookup.
\section{axiom command}
The axiom command will eventually be a shell script. At the moment
it is just a copy of the interpsys image. However the whole Axiom
system consists of several processes and the axiom command starts
these processes. The shell script will transparently replace the
axiom executable image which will be renamed to spadsys.
\section{help command documentation}
Axiom supports a )help command that takes a single argument.
This argument is interpreted as the name of a flat ascii file
which should live in \$AXIOM/doc/src/spadhelp.
\subsection{help documentation for algebra}
The help documentation for algebra files lives within the algebra
pamphlet. The help chunk contains the name of the domain, thus:
\begin{verbatim}
\begin{chunk}{thisdomain.help}
====================================================================
thisdomain examples
====================================================================
(documentation for this domain)
examplefunction foo
output
Type: thetype
See Also:
o )show thisdomain
o $AXIOM/bin/src/doc/algebra/thisfile.spad.dvi
\end{chunk}
\end{verbatim}
The documentation starts off with the domain enclosed in two lines
of equal signs. The documentation is free format. Generally the
functions are indented two spaces, the output is indented 3 spaces,
and the Type field has been moved toward the center of the line.
The ``See Also:'' section lists the domain with the ``show'' command
and the path to the source file in dvi format.
\subsection{Adding help documentation in Makefile}
There is a section in the src/algebra/Makefile.pamphlet that reads:
\begin{verbatim}
SPADHELP=\
${HELP}/AssociationList.help ${HELP}/BalancedBinaryTree.help \
\end{verbatim}
which is essentially a list of all of the algebra help files. Each item
in this list refers to a stanza that looks like:
\begin{verbatim}
${HELP}/AssociationList.help: ${BOOKS}/bookvol10.3.pamphlet
@echo 7000 create AssociationList.help from \
${BOOKS}/bookvol10.3.pamphlet
@${TANGLE} -R"AssociationList.help" ${BOOKS}/bookvol10.3.pamphlet \
>${HELP}/AssociationList.help
@cp ${HELP}/AssociationList.help ${HELP}/ALIST.help
@${TANGLE} -R"AssociationList.input" ${BOOKS}/bookvol10.3.pamphlet \
>${INPUT}/AssociationList.input
@echo "AssociationList (ALIST)" >>${HELPFILE}
\end{verbatim}
Notice that the first line has an connection between the help file and
the spad file that contains it.
The second line gives debugging output containing a unique number for
console debugging purposes of failed builds.
The third line extracts the help file. Help files are part of
the algebra books (bookvol10.2, bookvol10.3, and bookvol10.4). The
chunkname is the same as the Category, Domain, or Package.
The fourth line copies the file with the long name of the domain to a file
with the abbreviation of the domain so the user can query the domain
with either form using help.
The fifth line creates a regression test file for the help file. In the
algebra each help file has an associated regression test file to test
all of the function calls shown in the help page. These files are
copied to the intermediate directory for regression testing.
The sixth line adds a line to the HELPFILE (see the variable in
the src/algebra/Makefile). This HELPFILE is concatenated onto the
final help.help file in the MNT/doc/spadhelp directory. Thus, when
a user types )help with no argument they see a list of domains which
contain help information.
\subsection{Using help documentation for regression testing}
The fifth line extracts an input test file for the algebra. In general
each help file is used to create an input test file for regression testing.
There is a Makefile variable called REGRESS in the algebra Makefile:
\begin{verbatim}
REGRESS=\
AssociationList.regress BalancedBinaryTree.regress \
\end{verbatim}
This is part of a Makefile that structure within the algebra Makefile.
This Makefile gets extracted by the Makefile in the input subdirectory.
Thus there is a connection between the two Makefiles (algebra and input).
This algebra regression Makefile goes by the chunk name
{\bf algebra.regress}. It contains a list of regression files and a
single stanza:
\begin{verbatim}
%.regress: %.input
@ echo algebra regression testing $*
@ rm -f $*.output
@ echo ')read $*.input' | ${TESTSYS}
@ echo ')lisp (regress "$*.output")' | ${TESTSYS} \
| egrep -v '(Timestamp|Version)' | tee $*.regress
\end{verbatim}
The input Makefile extracts {\bf algebra.regress} and then calls
make to process this file.
This keeps the regression test list in the algebra Makefile.
\subsection{help documentation as algebra test files}
\section{debugsys}
The ``debugsys'' executable is the ``interpsys'' image but it is
built using the interpreted lisp code rather than using compiled
lisp code. This will make it slower but may, in certain cases,
give much better feedback in case of errors. If you find you need
to use debugsys you're really doing deep debugging. It isn't useful
for much else. It can be started by typing:
\begin{verbatim}
export AXIOM=/home/axiomgnu/new/mnt/linux
/home/axiomgnu/new/obj/linux/bin/debugpsys
\end{verbatim}
Notice that this image lives in the ``obj'' subtree. It is not
shipped with the ``final'' system image as only developers could
find it useful.
\subsection{debugging hyperdoc}
Hyperdoc will sometimes exit and also kill the AXIOMsys image with
no error message. One way to get around this is to replace the
AXIOMsys image with the debugsys image:
\begin{enumerate}
\item mv \$AXIOM/bin/AXIOMsys \$AXIOM/bin/AXIOMsys.backup\\
This keeps the failing axiomsys image around for later restoration.
\item cp obj/sys/bin/debugsys \$AXIOM/bin/AXIOMsys\\
This puts an interpreted version of axiom in place of the compiled form
\item axiom\\
Now we are running a fully interpreted form and the error messages are
much more informative.
\end{enumerate}
\section{Understanding a compiled function}
Suppose we stop a program at a function call to some low level lisp function,
say ONEP. We can do that by entering
\begin{verbatim}
)trace ONEP )break
\end{verbatim}
at the Axiom command prompt. Or at the lisp prompt:
\begin{verbatim}
(trace (ONEP :entry (break)))
\end{verbatim}
Next we execute some function that will
eventually call ONEP thus:
\begin{verbatim}
p := numeric %pi
Break: onep
Broken at ONEP. Type :H for Help.
BOOT>>
\end{verbatim}
We have stopped and entered a lisp command prompt. We can enter any
lisp expression here and there are commands that begin with a ``:''
character. ``:b'' requests a backtrace of the call stack, thus:
\begin{verbatim}
BOOT>>:b
Backtrace: funcall > system:top-level > restart > /read >
|upLET| > eval > |Pi| > |newGoGet| > |newGoGet| > ONEP
\end{verbatim}
Here we see that the function ONEP was called by the function newGoGet.
Notice that the name is surrounded by vertical bars. Vertical bars are
a common lisp escape sequence used to allow non-standard characters to
occur in symbol names. Common lisp is not case sensitive. Boot code is
case sensitive. Thus symbol names that were written in Boot tend to have
escape sequence characters around the name.
Now that we see the simple backtrace we can ask for a more complex one.
The command is ``:bt''. It shows more detail about each level of call
on the invocation history stack (ihs) including the function name, its
arguments and the depth of the invocation history stack ([ihs=13]):
\begin{verbatim}
BOOT>>:bt
#0 ONEP {1=nil,} [ihs=13]
#1 newGoGet {g3629=("0" (#<vector 08b34bb4> 45 . |char|)),
loc1=#<compiled-function |CHAR;cha...} [ihs=12]
#2 newGoGet {g3629=("%pi" (#<vector 08b34bec> 0 . |coerce|)),
loc1=(#<vector 08b34bec> 0 . |c...} [ihs=11]
#3 Pi {g109299=nil,loc1=nil,loc2=#<hash-table 082992f4>,
loc3=|Pi|,loc4=15,loc5=#<vecto...} [ihs=10]
#4 EVAL {loc0=nil,loc1=nil,loc2=nil,
loc3=#<compiled-function |Pi|>} [ihs=9]
#5 upLET {t=(#<vector 08b34d04> #<vector 08b34ce8>
(#<vector 08b34ccc> (#<vector 08b34c08...} [ihs=8]
#6 /READ {loc0=#p"/home/axiomgnu/new/src/input/algbrbf.input",
loc1=nil,loc2=nil,loc3=nil,...} [ihs=7]
#7 RESTART {loc0=((|read|
|/home/axiomgnu/new/src/input/algbrbf.input|)),
loc1=|/home/axiomg...} [ihs=6]
#8 TOP-LEVEL {loc0=nil,loc1=0,loc2=0,loc3=nil,loc4=nil,
loc5=nil,loc6=nil,loc7=nil,loc8=nil,lo...} [ihs=5]
#9 FUNCALL {loc0=#<compiled-function system:top-level>} [ihs=4]
BOOT>>:bl
>> (LAMBDA-BLOCK ONEP (&REST X) ...)():
X : (1)
NIL
\end{verbatim}
We can ask to see the local variables that are used at the current
level of the invocation history stack. The command is ``:bl'' thus:
\begin{verbatim}
BOOT>>:bl
>> (LAMBDA-BLOCK ONEP (&REST X) ...)():
X : (1)
NIL
\end{verbatim}
We can move up the stack one level at a time looking at the function
that called the current function (the previous function) using ``:p'' thus:
\begin{verbatim}
BOOT>>:p
Broken at |NEWGOGET|.
\end{verbatim}
And again, we can look at the variables that can be accessed locally:
\begin{verbatim}
BOOT>>:bl
>> newGoGet():
Local0(G3629): (0 (#<vector 08b34bb4> 45 . char))
Local(1): #<compiled-function CHAR;char;S$;20>
Local(2): 0
Local(3): #<vector 08b233f0>
Local(4): 1
NIL
\end{verbatim}
Here we see that the function newGoGet is calling
CHAR;char;S\$;20 which is a mangled form of
the name of the original spad function. To decode this name
we can see that the CHAR portion is used to identify the
domain where the function lives. This domain, CHAR, comes
from the source file ``string.spad'' which lives in
``src/algebra/string.spad.pamphlet''. To discover this we use
the Axiom ``asq'' command with the ``-so'' (sourcefile) option
at a standard shell prompt (NOT in the lisp prompt) thus:
\begin{verbatim}
asq -so CHAR
string.spad
\end{verbatim}
If we look at the code in the string.spad.pamphlet file we find
the following code signature:
\begin{verbatim}
char: String -> %
++ char(s) provides a character from a string s of length one.
\end{verbatim}
and it's implementation code:
\begin{verbatim}
char(s:String) ==
(#s) = 1 => s(minIndex s) pretend %
error "String is not a single character"
\end{verbatim}
The string.spad file can be compiled at the command prompt.
In particular, we can compile only the CHAR domain out of this
file thus:
\begin{verbatim}
)co string.spad )con CHAR
\end{verbatim}
This will produce a directory called CHAR.NRLIB containing 3 files:
\begin{verbatim}
ls CHAR.NRLIB
code.lsp index.kaf info
\end{verbatim}
The info file contains information used by the spad compiler. We can
ignore it for now.
The index.kaf file contains information that will go into the various
Axiom database (.daase) files. The kaf file format is a random access
file. The first entry is an integer that will be an index into the
file that can be used in an operating system call to seek. In this
case it will be an index which is the last used byte in the file.
Go to the last expression in the file and we find:
\begin{verbatim}
(
("slot1Info" 0 11302)
("documentation" 0 9179)
("ancestors" 0 9036)
("parents" 0 9010)
("abbreviation" 0 9005)
("predicates" 0 NIL)
("attributes" 0 NIL)
("signaturesAndLocals" 0 8156)
("superDomain" 0 NIL)
("operationAlist" 0 7207)
("modemaps" 0 6037)
("sourceFile" 0 5994)
("constructorCategory" 0 5434)
("constructorModemap" 0 4840)
("constructorKind" 0 4831)
("constructorForm" 0 4817)
("NILADIC" 0 4768)
("compilerInfo" 0 2093)
("loadTimeStuff" 0 20))
\end{verbatim}
This is a list of triples. Each triple has two interesting parts, the
name of the data and the seek index of the data in the index.kaf file.
So, for instance, if you want to know what source file contains this
domain you can start at the top of the index.kaf file, move ahead 5994
bytes and you will be at the start of the string:
\begin{verbatim}
"/usr/local/axiom/src/algebra/string.spad"
\end{verbatim}
The information in the index.kaf files are collected into the
special databases (the .daase files). The stand-alone ``asq'' function
can query these databases and answer questions. The kind of questions
you can ask are the names in the list above.
The third file in the CHAR.NRLIB directory is the code.lsp file. This
is the actual common lisp code that will be executed as a result of
calling the various spad functions. The spad code from the char command
was:
\begin{verbatim}
char(s:String) ==
(#s) = 1 => s(minIndex s) pretend %
error "String is not a single character"
\end{verbatim}
which got compiled into the common lisp code:
\begin{verbatim}
(DEFUN |CHAR;char;S$;20| (|s| |$|)
(COND
((EQL (QCSIZE |s|) 1)
(SPADCALL |s|
(SPADCALL |s| (QREFELT |$| 47))
(QREFELT |$| 48)))
((QUOTE T)
(|error| "String is not a single character"))))
\end{verbatim}
To understand what is going on here we need to understand the low level
details of Axiom's interface to Common Lisp. The ``Q'' functions are
strongly typed (Quick) versions of standard common lisp functions.
QCSIZE is defined in src/interp/vmlisp.lisp.pamphlet thus:
\begin{verbatim}
(defmacro qcsize (x)
`(the fixnum (length (the simple-string ,x))))
\end{verbatim}
This macro will compute the length of a string.
QREFELT is defined in the same file as:
\begin{verbatim}
(defmacro qrefelt (vec ind)
`(svref ,vec ,ind))
\end{verbatim}
This macro will return the element of a vector.
SPADCALL is defined in src/interp/macros.lisp.pamphlet as:
\begin{verbatim}
(defmacro SPADCALL (&rest L)
(let ((args (butlast l)) (fn (car (last l))) (gi (gensym)))
`(let ((,gi ,fn))
(the (values t) (funcall (car ,gi) ,@args (cdr ,gi))))
))
\end{verbatim}
This macro will call the last value of the argument list as a function
and give it everything but the last argument as arguments to the function.
There are confusing historical reasons for this I won't go into here.
So you can see that these are simply macros that will expand into
highly optimizable (the optimizations depend on the abilities of the
common lisp compiler) common lisp code.
The common lisp code computes the length of the string s. If the length
is 1 then we call the minIndex function from string on s. The minIndex
function is found by looking ``in the domain''. The compiler changes the
minIndex function call into a reference into a vector. The 47th element
of the vector contains the function minIndex.
\begin{verbatim}
(SPADCALL |s| (QREFELT |$| 47))
\end{verbatim}
This code is equivalent (ignoring the gensyms) to the call
\begin{verbatim}
(minIndex s)
\end{verbatim}
The \$ symbol refers to the domain. At runtime this amounts to a lookup
of the ``infovec''. The compile-time infovec shown here:
\begin{verbatim}
(setf (get
(QUOTE |Character|)
(QUOTE |infovec|))
(LIST
(QUOTE
#(NIL
NIL
NIL
NIL
NIL
NIL
(QUOTE |Rep|)
(|List| 28)
(|PrimitiveArray| 28)
(0 . |construct|)
(QUOTE |OutChars|)
(QUOTE |minChar|)
(|Boolean|)
|CHAR;=;2$B;1|
|CHAR;<;2$B;2|
(|NonNegativeInteger|)
|CHAR;size;Nni;3|
(|Integer|)
|CHAR;char;I$;6|
(|PositiveInteger|)
|CHAR;index;Pi$;4|
|CHAR;ord;$I;7|
|CHAR;lookup;$Pi;5|
(5 . |coerce|)
|CHAR;random;$;8|
|CHAR;space;$;9|
|CHAR;quote;$;10|
|CHAR;escape;$;11|
(|OutputForm|)
|CHAR;coerce;$Of;12|
(|CharacterClass|)
(10 . |digit|)
(|Character|)
(14 . |member?|)
|CHAR;digit?;$B;13|
(20 . |hexDigit|)
|CHAR;hexDigit?;$B;14|
(24 . |upperCase|)
|CHAR;upperCase?;$B;15|
(28 . |lowerCase|)
|CHAR;lowerCase?;$B;16|
(32 . |alphabetic|)
|CHAR;alphabetic?;$B;17|
(36 . |alphanumeric|)
|CHAR;alphanumeric?;$B;18|
(|String|)
|CHAR;latex;$S;19|
(40 . |minIndex|)
(45 . |elt|)
|CHAR;char;S$;20|
|CHAR;upperCase;2$;21|
|CHAR;lowerCase;2$;22|
(|SingleInteger|)))
(QUOTE
#(|~=| 51 |upperCase?| 57 |upperCase| 62 |space| 67
|size| 71 |random| 75 |quote| 79 |ord| 83 |min| 88
|max| 94 |lowerCase?| 100 |lowerCase| 105 |lookup| 110
|latex| 115 |index| 120 |hexDigit?| 125 |hash| 130
|escape| 135 |digit?| 139 |coerce| 144 |char| 149
|alphanumeric?| 159 |alphabetic?| 164 |>=| 169 |>| 175
|=| 181 |<=| 187 |<| 193))
(QUOTE NIL)
(CONS
(|makeByteWordVec2| 1 (QUOTE (0 0 0 0 0 0)))
(CONS
(QUOTE #(NIL |OrderedSet&| NIL |SetCategory&|
|BasicType&| NIL))
(CONS
(QUOTE
#((|OrderedFinite|)
(|OrderedSet|)
(|Finite|)
(|SetCategory|)
(|BasicType|)
(|CoercibleTo| 28)))
(|makeByteWordVec2| 52
(QUOTE
(1 8 0 7 9 1 6 0 17 23 0 30 0 31 2 30 12 32 0 33
0 30 0 35 0 30 0 37 0 30 0 39 0 30 0 41 0 30 0
43 1 45 17 0 47 2 45 32 0 17 48 2 0 12 0 0 1 1
0 12 0 38 1 0 0 0 50 0 0 0 25 0 0 15 16 0 0 0 24
0 0 0 26 1 0 17 0 21 2 0 0 0 0 1 2 0 0 0 0 1 1 0
12 0 40 1 0 0 0 51 1 0 19 0 22 1 0 45 0 46 1 0 0
19 20 1 0 12 0 36 1 0 52 0 1 0 0 0 27 1 0 12 0 34
1 0 28 0 29 1 0 0 45 49 1 0 0 17 18 1 0 12 0 44 1
0 12 0 42 2 0 12 0 0 1 2 0 12 0 0 1 2 0 12 0 0 13
2 0 12 0 0 1 2 0 12 0 0 14))))))
(QUOTE |lookupComplete|)))
\end{verbatim}
Which is a 5 element list. This contains all kinds of information used at
runtime by the compiled routines. In particular, functions are looked up
at runtime in the first element of the infovec list. This first element
contains 53 items (in this domain). Item 47 is
\begin{verbatim}
(40 . |minIndex|)
\end{verbatim}
which is the minIndex function we seek.
At runtime this infovec lives on the property list of the domain name.
The domain name of CHAR is Character. So we look on the property list
(a lisp a-list) thus:
\begin{verbatim}
BOOT>>(symbol-plist '|Character|)
(SYSTEM:DEBUG (#:G85875)
|infovec| (#<vector 08b34380>
#<vector 08b34364>
NIL
(#<bit-vector 08b34310>
#<vector 08b34348>
#<vector 08b3432c> . #<vector 08b342f4>)
|lookupComplete|)
LOADED "/home/axiomgnu/new/mnt/linux/algebra/CHAR.o"
NILADIC T
PNAME "Character"
DATABASE #S(DATABASE
ABBREVIATION CHAR
ANCESTORS NIL
CONSTRUCTOR NIL
CONSTRUCTORCATEGORY 228064
CONSTRUCTORKIND |domain|
CONSTRUCTORMODEMAP 227069
COSIG (NIL)
DEFAULTDOMAIN NIL
MODEMAPS 227404
NILADIC T
OBJECT "CHAR"
OPERATIONALIST 226402
DOCUMENTATION 152634
CONSTRUCTORFORM 152626
ATTRIBUTES 154726
PREDICATES 154731
SOURCEFILE "string.spad"
PARENTS NIL
USERS NIL
DEPENDENTS NIL
SPARE NIL))
\end{verbatim}
This list is organized contains many runtime lookup items (notice the
PNAME entry is ``Character'', the LOADED entry says where the file came
from, the DATABASE structure entry has database indicies
(see daase.lisp.pamphlet for the structure definition), etc).
Lets get the property list
\begin{verbatim}
BOOT>>(setq a (symbol-plist '|Character|))
(SYSTEM:DEBUG (#:G85875)
|infovec| (#<vector 08b34380>
#<vector 08b34364>
NIL
(#<bit-vector 08b34310>
#<vector 08b34348>
#<vector 08b3432c> . #<vector 08b342f4>)
|lookupComplete|)
LOADED "/home/axiomgnu/new/mnt/linux/algebra/CHAR.o"
NILADIC T
PNAME "Character"
DATABASE #S(DATABASE
ABBREVIATION CHAR
ANCESTORS NIL
CONSTRUCTOR NIL
CONSTRUCTORCATEGORY 228064
CONSTRUCTORKIND |domain|
CONSTRUCTORMODEMAP 227069
COSIG (NIL)
DEFAULTDOMAIN NIL
MODEMAPS 227404
NILADIC T
OBJECT "CHAR"
OPERATIONALIST 226402
DOCUMENTATION 152634
CONSTRUCTORFORM 152626
ATTRIBUTES 154726
PREDICATES 154731
SOURCEFILE "string.spad"
PARENTS NIL
USERS NIL
DEPENDENTS NIL
SPARE NIL))
\end{verbatim}
Next we get the infovec value
\begin{verbatim}
BOOT>>(setq b (fourth a))
(#<vector 08b34380>
#<vector 08b34364>
NIL
(#<bit-vector 08b34310>
#<vector 08b34348>
#<vector 08b3432c> . #<vector 08b342f4>)
|lookupComplete|)
\end{verbatim}
Then we get the function table
\begin{verbatim}
BOOT>>(setq c (car b))
#<vector 08b34380>
\end{verbatim}
In this common lisp (GCL) the array is identified by it's memory address.
Notice that it has the right number of entries:
\begin{verbatim}
BOOT>>(length c)
53
\end{verbatim}
And we can ask for the 47th entry thus:
\begin{verbatim}
BOOT>>(elt c 47)
(40 . |minIndex|)
\end{verbatim}
Later we end up calling the 48th function (which is elt and
returns the actual character in the string). We ask for it:
\begin{verbatim}
BOOT>>(elt c 48)
(45 . |elt|)
\end{verbatim}
At this point we've reached the metal. Common lisp will evaluate
the macro-expanded functions and execute the proper code. Essentially
the compiler has changed all of our spad code into runtime table lookups.
\section{The axiom.input startup file}
If you add a file in your home directory called ``.axiom.input'' it will
be read and executed when Axiom starts. This is useful for various
reasons including setting various switches. Mine reads:
\begin{verbatim}
)lisp (pprint ``running /root/.axiom.input'')
)set quit unprotected
)set message autoload off
)set message startup off
\end{verbatim}
You can execute any command in .axiom.input. Be aware that this will
ALSO be run while you are doing a ``make'' so be careful what you ask to do.
\section{Where are Axiom symbols stored?}
You'd think that your question about where the symbol is interned
would be easy to answer but it is not. The top level loop uses Bill
Burge's dreaded zipper parser. You can see it in action by executing
the following sequence:
\begin{verbatim}
)lisp (setq $DALYMODE t)
; this is a special mode of the top level interpreter. If
; $DALYMODE is true then any top-level form that begins
; with an open-paren is considered a lisp expression.
; For almost everything I ever do I end up peeking at the
; lisp so this bit of magic helps.
(trace |intloopProcessString|)
; from int-top.boot.pamphlet
(trace |intloopProcess|)
; the third argument is the "zippered" input
(trace |intloopSpadProcess|)
; now it is all clear, no? sigh.
(trace |phInterpret|)
; from int-top.boot.pamphlet
(trace |intInterpretPform|)
; from intint.lisp.pamphlet
(trace |processInteractive|)
; from i-toplev.boot.pamphlet
(setq |$reportInstantiations| t)
; shows what domains were created
(setq |$monitorNewWorld| t)
; watch the interpreter resolve operations
(trace |processInteractive1|)
; from i-toplev.boot.pamphlet
\end{verbatim}
ah HA! I remember now. There is the notion of a ``frame'' which is
basically a namespace in Axiom or an alist in Common Lisp. It is
possible to maintain different ``frames'' and move among them. There
is the notion of the current frame and it contains all the defined
variables. At any given time the current frame is available as
\$InteractiveFrame. This variable is used in processInteractive1.
If you do:
\begin{verbatim}
a:=7
(pprint |$InteractiveFrame|)
\end{verbatim}
you'll see |a| show up on the alist. When you do the
\begin{verbatim}
pgr:=MonoidRing(Polynomial PrimeField 5, Permutation Integer)
p:pgr:=1
\end{verbatim}
you'll see |p| show up with 2 other things: (|p| mode value)
where mode is the ``type'' of the variable. The value is the
internal value. In this case MonoidRing has an internal
representation. You can find out what the internal representation
of a MonoidRing is by first asking where the source file is:
\begin{verbatim}
(do this at a shell prompt, not in axiom)
asq -so MonoidRing ==> mring.spad
-- or -- in Axiom type:
)show MonoidRing
\end{verbatim}
and you'll see a line that reads:
\begin{verbatim}
Issue )edit (yourpath)/../../src/algebra/mring.spad
\end{verbatim}
If you look in mring.spad.pamphlet you'll see line 91 that reads:
\begin{verbatim}
Rep := List Term
\end{verbatim}
which says that we will store elements of type MonoidRing as a list
of Term objects. Term is defined in the same file (as a macro, which
is what '$==>$' means in spad files) on line 43:
\begin{verbatim}
Term ==> Record(coef: R, monom: M)
\end{verbatim}
which means that elements of a MonoidRing are Lists of Records.
The 'R' is defined on line 42 as the first argument to MonoidRing
which in this case is ``Polynomial PrimeField 5''. The ``M'' is also
defined on line 42 as the second argument to MonoidRing and in this
case is ``Permutation Integer''. So the real representation is
\begin{verbatim}
List Record(coef: Polynomial PrimeField 5,
monom: Permutation Integer)
\end{verbatim}
In the \$InteractiveFrame we printed out you can see in the value
field that the value is:
\begin{verbatim}
(|value|
(|MonoidRing| (|Polynomial| (|PrimeField| 5))
(|Permutation| (|Integer|)))
WRAPPED ((0 . 1) . #<vector 08af33d4>))
\end{verbatim}
which basically means that we know how the MonoidRing was constructed and
what it's current value is. The (0 . 1) likely means that this is the
zeroth (constant) term with a leading coefficient of 1. This is just a
guess as I haven't decoded the representation of either Polynomial PrimeField
or Permutation Integer. You can do the same deconstruction of these two
domains by setting
\begin{verbatim}
pi:=Permutation Integer
z:pi:=1
pp5:=Polynomial PrimeField 5
w:pp5:=1
and following the same steps as above:
(pprint |$InteractiveFrame|)
)show pi
(find the source file)
(find the representation and decode it)
(pprint |$InteractiveFrame|)
)show pp5
(find the source file)
(find the representation and decode it)
\end{verbatim}
Be sure to set \$DALYMODE to nil if you plan to use Axiom for any
real computation. Otherwise every expression that begins with an
open-paren will go directly to lisp.
\section{Translating individual boot files to common lisp}
If you are making changes to boot code it is sometimes helpful to
check the generated lisp code to ensure it does what you want.
You can convert an individual boot file to common lisp using the
boottran::boottocl function:
\begin{verbatim}
)fin -- drop into common lisp
(boottran::boottocl "foo.boot")
\end{verbatim}
when you do this it creates a foo.clisp file in ../../int/interp
Alternatively if you work from the pamphlet file the process is
more painful as you have to do
\begin{verbatim}
)cd (yourpath)/int/interp
)sys tangle ../../src/interp/foo.boot.pamphlet >foo.boot
)fin
(boottran::boottocl "foo.boot")
(restart)
\end{verbatim}
The )cd step tells axiom to cd to the int/interp subdirectory.
The )sys tangle... extracts the boot file from the pamphlet file
The )fin step drops into common lisp
The (bootran... converts the foo.boot file to foo.clisp
The (restart) re-enters the top level loop
\section{Directories}
For this discussion I assume that you have your system rooted
at /spad and was build to run on linux. These directories
may not yet be in the CVS tree but are documented here so they
make sense when the show up.
\vskip .25in
\noindent
The AXIOM variable
The usual setting of the AXIOM variable is /spad/mnt/linux. The
name is composed of three parts, the rooted path, in this case
/spad, ``mnt'', and the system you are running, in this case
linux. Builds for other systems will have other system names.
\vskip .25in
\noindent
/spad
This is the usual root directory of the Axiom system. The name is
historical, a contraction of Scratchpad. This name can be anything
provided the shell variable AXIOM contains the new prefix.
\vskip .25in
\noindent
/spad/mnt
This is a directory which contains files which are specific to a
given platform. At a site that contains multiple platforms this
directory will contain a subdirectory for each type of platform
(e.g. linux, rios, ps2, rt, sun, etc).
\vskip .25in
\noindent
/spad/mnt/linux
This directory contains the complete copy of the Axiom system for
the linux system. This is the 'mount point' of the system.
Executable systems (for RedHat) are shipped relative to this
point. In what follows, the ./ refers to /spad/mnt/linux.
\begin{verbatim}
********************************************************
There are several directories explained below. They are:
./bin -- user executables
./doc -- system documentation
./algebra -- algebra libraries
./lib -- system executables
./etc -- I haven't a clue....
********************************************************
\end{verbatim}
\subsection{The mnt/linux/bin directory}
\vskip .25in
\noindent
./bin
This is a directory of user executable commands, either at the top
level or thru certain Axiom system calls. Support executables live
in ./lib
\vskip .25in
\noindent
./bin/htadd
This adds pages to the Hyperdoc database (ht.db, which lives
in ./doc/hypertex/pages; hypertex, since we have a penchant for these
things, is an historical name for Hyperdoc. The single word 'lawyers'
will probably explain away a lot of name changes.)
\vskip .25in
\noindent
./bin/spadsys
This is the Axiom interpreter. It is one of the functions started when
the user invokes the system using the spadsys command. Normally this
command is run under the control of sman (./lib/sman) and the console
is under the control of clef (./bin/clef), the wonderous command-line
editor. It is possible to start spadsys standalone but it will not
talk to Hyperdoc or graphics. Users who rlogin or use an ascii-only
terminal (for historical reasons, no doubt) can profit by invoking
spadsys directly rather than using ./bin/axiom
\vskip .25in
\noindent
./bin/axiom
This is a shell script that spins the world. It kicks off a whole tree
of processes necessary to perform the X-related magic we do. It expects
the shell variable AXIOM to be set to the 'mount point' (usually to
/spad/mnt/linux).
\vskip .25in
\noindent
./bin/clef
This is the wonderous command-line editor used by Axiom. It can be used
in a stand-alone fashion if you wish.
\vskip .25in
\noindent
./bin/SPADEDFN
This script is invoked by the spad )fe command. It can be changed to
invoke your favorite editor. While you may invoke your editor, it may
not run (as in, yes, I can invoke the devil but will he come when I
call?)
\vskip .25in
\noindent
./bin/viewalone
This is a function to run the graphics in a stand-alone fashion. The
Graphics package (an amazing contribution by several very talented
people, most notably Jim Wen and Jon Steinbach) is a C program that
communicates with Axiom thru sockets. It will, however, perform its
miracles unaided if invoked by the sufficiently chaste...
\vskip .25in
\noindent
./bin/hypertex
This is a function to run Hyperdoc (remember the penchant!) stand-alone.
The Hyperdoc package owes its existence to the efforts of J.M. Wiley and
Scott Morrison. This function works off 'pages' that live in
hypertex pages directory and are referenced in the ``hyperdoc database''
called ht.db (for historical reasons, but you
knew that). It is possible for creative plagerists to figure out how
to write their own pages and add them to the database (see htadd above),
thus gaining fame far and wide...
\vskip .25in
\noindent
./bin/sys-init.lsp
This is a file of lisp code that gets loaded
before Axiom starts. Thus, we distribute patches by adding lisp
(load ...) commands to this file. The sufficiently clever should
have a field day with this one. (All others should worship the
sufficiently clever and send them money, eh?)
\vskip .25in
\noindent
./bin/init.lsp
This is a file of lisp code loaded if and only if
you start spadsys in this directory. The user can put a file of this
name in her home directory and it will get loaded at startup with
the probable effect of injecting luser errors into the running system.
sigh.
\subsection{The mnt/linux/doc directory}
\vskip .25in
\noindent
./doc
The doc subdirectory contains system documentation.
\vskip .25in
\noindent
./doc/command.list
This is a file of command completions used by clef when you hit the
tab key. This is a little known feature that will surprise someone
someday (hopefully pleasantly).
\vskip .25in
\noindent
./doc/book
This is an attempt at a book describing Axiom. It represents a
combination of fantasy, describing what never will be and history
(remember the penchant?) describing what was. Any description matching
what is may be regarded as failure of the imagination and ignored.
\vskip .25in
\noindent
./doc/compguide
This is an attempt to describe a compiler that doesn't exist, never
did exist, and never will exist. It makes for entertaining reading
so we included it.
\vskip .25in
\noindent
./doc/hypertex
This is the fabled Hyperdoc subdirectory where all of the pages and
the database live, along with several other obscure files needed to
make the wizards look good.
\vskip .25in
\noindent
./doc/hypertex/pages
This is where the 'pages' live. Each file ending in .ht contains
several pages related, if only by chance, to the same topic. You
may find it instructive to try to read some of these files. Hyperdoc
was learned by the 'campfire' method (sitting around the fire
passing along historical facts by word of mouth) and will probably
continue to propagate by the same method. Ye may become th' local
scribe and soothsayer if ye study the writings here below....
\vskip .25in
\noindent
./doc/hypertex/pages/rootpage.ht
This file is the magic 'first page' that gets displayed when
Hyperdoc starts. There is a macro (see ./doc/hypertex/pages/util.ht)
called /localinfo which is intended to allow the luser to add
her own pages without modifying the system copies. How this is
done was lost when the campfire got rained out.
\vskip .25in
\noindent
./doc/hypertex/pages/util.ht
This file contains the macros used to extend the system commands.
The syntax is hard to learn (it was hard to write, it ought to
be hard to learn, eh?).
\vskip .25in
\noindent
./doc/hypertex/pages/ht.db
This is the Hyperdoc database. It is updated using ./bin/htadd
which must be run whenever a page in this directory gets changed.
The necessary arguments to htadd are obvious to those in the know.
\vskip .25in
\noindent
./doc/hypertex/bitmaps
There are several pretty bitmaps used as cursors, buttons and
general decorations that hide in this directory.
\vskip .25in
\noindent
./doc/hypertex/ht.files
This is a list of some Hyperdoc files. It seems to have no
purpose in life but it is useful as a koan, as in, What is
the length of half a list?
\vskip .25in
\noindent
./doc/hypertex/ht.db
Another copy of the Hyperdoc database. It isn't clear which
one is the real one so I guess we keep both. Maybe we'll
figure it out at the friday night campfire provided we don't
get too lit.
\vskip .25in
\noindent
./doc/hypertex/gloss.text
The text used in the glossary. Many magic words lie herein.
Some are spoken only by campfire gurus.
\vskip .25in
\noindent
./doc/library
This is a directory of Hyperdoc pages that can be freely smashed,
trashed and generally played with. It uses the /localinfo connection
to set up a 'library' containing Hyperdoc pages keyed to your
favorite textbook. It is interesting to set the shell variable\\
HTPATH=/spad/mnt/linux/doc/library:\\
/spad/mnt/linux/doc/hypertex/pages\\
and then start Hyperdoc. See the file ./doc/library/macros.ht
\vskip .25in
\noindent
./doc/msgs
This directory contains several 'message databases'; the only one
of which we seem to care about being s2-us.msgs but I can't swear
to it.
\vskip .25in
\noindent
./doc/spadhelp
This is a directory containing help information for a copy of the
system that once ran long ago and far away. It is kept for
historical reasons (programmers NEVER throw anything away).
\vskip .25in
\noindent
./doc/viewports
There are several dozen truly fine pictures in Axiom. We have
created them and hidden them here. Hyperdoc will insert them
at various places (where the text gets too boring, hopefully)
and you can click on them there. They get snarfed from here.
It is possible to view them with stand-alone graphics but don't
ask me how. I missed that campfire due to poisoned marshmellows.
\vskip .25in
\noindent
./doc/complang
This directory contains fantasy from the past as opposed to facts
from the future. Ignore it.
\vskip .25in
\noindent
./doc/ug
This directory left intentionally blank :-) (an old IBM joke).
\vskip .25in
\noindent
./doc/tex
These are the files necessary to create the famous goertler document.
If you figure out how to use these please send us the instructions
and we will add a log to the campfire with your name on it (a rare
honor indeed as luser's names rarely reach the inner circle).
\vskip .25in
\noindent
./doc/htex
This directory contains the original tex-like source for the luser's
guide. There are many functions that munch on these between here and
paper but this is approximately where they start. If you do your own
algebra perchance you might document it like this. Figuring out the
syntax will also get your name into the inner circle (probably
connnected with a smirk :-) )
\vskip .25in
\noindent
./doc/newug
Please don't ask me. I couldn't begin to guess. You wouldn't believe
how many 'new' things there are that really aren't. We have more NEW
things than Madison Avenue has NEW laundry soap.
\vskip .25in
\noindent
./doc/gloss.text
This one is here because it is here. Existentially speaking, of course.
\vskip .25in
\noindent
./doc/submitted
This was what the htex files said before history was rewritten...
(and renamed?)
\subsection{The mnt/linux/algebra directory}
\vskip .25in
\noindent
./algebra
This is where all of the interesting action lives.
Each .NRLIB directory contains 2 files, a code.o and an index.kaf*
file. The code.o contains the executable algebra that gets loaded
into the system. The index.kaf* file contains all kinds of things
like signatures, source paths, properties and dried bat droppings.
The documentation for each of these can be reached by using the
BROWSE feature of Hyperdoc.
\vskip .25in
\noindent
./algebra/MODEMAP.daase
This is an inverted database that contains information gleaned from
the index.kaf* files. Without this there is no way to figure out
which .NRLIB file to load. This database is opened on startup
and kept open.
\vskip .25in
\noindent
./algebra/interp.exposed
This is a control file for the interpeter that limits the number
of places to search for function names.
*********************************************
\subsection{The mnt/linux/etc directory}
\vskip .25in
\noindent
./lib
This directory contains functions that get loaded by the system.
Nothing in here is executable by the user but the system needs
these functions to run.
\vskip .25in
\noindent
./lib/htrefs\\
./lib/htsearch\\
./lib/hthits
These three functions are used to search the Hyperdoc pages.
There is no way in the current system to request a search of
those pages so these files are fascinating examples of history
in the making...
\vskip .25in
\noindent
./lib/hypertex
This is Hyperdoc. What is in a name?
\vskip .25in
\noindent
./lib/sman
This is sman, which comes before all. Methinks the name originated
as a contraction of superman, the name of a stack frame in a system
long ago and far away (VMLisp) chosen because a certain programmer had a
penchant for comic books when he was young.
\vskip .25in
\noindent
./lib/session\\
./lib/spadclient
These two files are processes started by sman for some reason or other.
I can never remember what they do or why. However, the campfire fails
to smoke if they don't work.
\vskip .25in
\noindent
./lib/viewman
This is the controlling function for the graphics.
\vskip .25in
\noindent
./lib/view2d
This is invoked when a 2 dimensional window is requested.
This is provided mostly for those math majors who never got over
the insights from flatland.
\vskip .25in
\noindent
./lib/view3d
This is invoked when a 3 dimensional window is requested.
Option IBM3634-A is required to convert your 2 dimensional
screen to 3 dimensions for realistic viewing. A mathematically
accurate, if somewhat more achievable, rendering can be had
on a color or monochrome crt without this upgrade.
\vskip .25in
\noindent
./lib/gloss.text\\
./lib/glosskey.text\\
./lib/glossdef.text
These are three files related to the glossary. The first (gloss.text)
is the original glossary text. The second (glosskey.text) is a list
of terms and pointers into glossdef.text. The third (glossdef.text for
those math majors who can't count) is a list of definitions and pointers
back into the second (guess). These files are used by Hyperdoc.
\vskip .25in
\noindent
./lib/browsedb.lisp
This is the original file that creates an in-memory hash table used by
browse. It is used during system build time. We keep it here to ensure
that the bytes on this section of the disk have a well-defined orientation,
allowing us to compute the spin vectors of the individual magnetic domains.
This allows us to give Heisenburg a sense of direction (at least over the
long run).
\vskip .25in
\noindent
./lib/comdb.text\\
./lib/libdb.text
The first file (comdb.text) contains the so-called $++$ (plus
plus) comments from the algebra files. It contains pointers into
the second file. The second file (libdb.text) contains flags
(constructor, operation, attribute) and pointers into the first file.
These files are used by browse in Hyperdoc.
\vskip .25in
\noindent
./lib/loadmprotect\\
./lib/mprotect
This set of two files has been mercifully de-installed from the system.
They will, if used and despite the meaning behind the name, cause
random system reboots (yeah, HARDWARE reboots. don't ask me how, I'm
just the historian).
\vskip .25in
\noindent
./lib/SPADEDIT\\
./lib/fc\\
./lib/spadbuf\\
./lib/SPADEDFN\\
./lib/obey\\
./lib/ex2ht
I've drawn a blank; intentionally.
\subsection{The mnt/linux/lib directory}
\vskip .25in
\noindent
./etc
This directory intentionally left blank.
We just can't figure out WHY we intended to leave it blank.
Historical reasons, no doubt.
\section{The )set command}
The {\bf )set} command contains many possible options such as:
\begin{verbatim}
Current Values of )set Variables
Variable Description Current Value
----------------------------------------------------------------
breakmode execute break processing on error break
compiler Library compiler options ...
expose control interpreter constructor exposure ...
functions some interpreter function options ...
fortran view and set options for FORTRAN output ...
kernel library functions built into the kernel for
efficiency ...
hyperdoc options in using HyperDoc ...
help view and set some help options ...
history save workspace values in a history file on
messages show messages for various system features ...
naglink options for NAGLink ...
output view and set some output options ...
quit protected or unprotected quit unprotected
streams set some options for working with streams ...
system set some system development variables ...
userlevel operation access level of system user development
Variables with current values of ... have further
sub-options. For example,
issue )set system to see what the options are for system .
For more information, issue )help set .
\end{verbatim}
The table that contains these options lives in setvart.boot.pamphlet.
The actual code that implements these options is sprinkled around
but most of the first-level calls resolve to functions in
setvars.boot.pamphlet. Thus if you plan to add a new output
style to the system, or figure out where a current style is
broken, these two files are the place to start.
A new )set breakmode command has been implemented to handle the
case that you might want an error message or an error return code
from AXIOMsys. You can set this option with
\begin{verbatim}
)set breakmode quit
\end{verbatim}
This will cause AXIOMsys to exit with the return code of 1.
Note that if you invoke the ``axiom'' shell script to start
AXIOMsys you will not see this return code (sman swallows it).
\section{Special Output Formats}
The first level of special output formatting is handled by
functions in setvart.boot.pamphlet. This handles the options
given to the )set command.
\section{Low Level Debugging Techniques}
It should be observed that Axiom is basically Common Lisp and
some very low level techniques can be used to find where problems
occur in algebra code. This section walks thru a small problem and
illustrates some techniques that can be used to find bugs. The
point of this exercise is to show a few techniques, not to show a
general method.
\subsection{Finding Anonymous Function Signatures}
This is a technique, adapted from Waldek Hebisch,
for asking the interpreter to reveal the actual
function that will be called in a given circumstance. Here we have a
function tanint from the domain ElementaryIntegration.
\begin{verbatim}
tanint(f, x, k) ==
eta' := differentiate(eta := first argument k, x)
r1 := tanintegrate(univariate(f, k), differentiate(#1,
differentiate(#1, x), monomial(eta', 2) + eta'::UP),
rischDEsys(#1, 2 * eta, #2, #3, x, lflimitedint(#1, x, #2),
lfextendedint(#1, x, #2)))
map(multivariate(#1, k), r1.answer) + lfintegrate(r1.a0, x)
\end{verbatim}
We would like to know the type signature of the first argument to the
inner call to the differentiate function:
\begin{verbatim}
differentiate(#1, x), monomial(eta', 2) + eta'::UP),
\end{verbatim}
We see that differentiate is called with \verb|#1|, which is Axiom's
notation for an anonymous function. How can we determine the signature?
Axiom has a second notation for anonymous functions using the
\verb|+->| notation. This notation allows you to explicitly specify
type information. In the above code, we would like to replace the
\verb|#1| variable with the \verb|+->| and explicit type information.
The first step is to look at the output of the Spad compiler.
The abbreviation for ElementaryIntegration can be found from the
interpreter by:
\begin{verbatim}
)show ElementaryIntegration
Abbreviation for ElementaryIntegration is INTEF
\end{verbatim}
So the compiler output is in the int/algebra/INTEF.nrlib/code.lsp file.
There we see the definition of the lisp tanint function. Notice that the
\verb|$| is a hidden, internal fourth argument to an Axiom three argument
function. This is the vector of the current domain containing slots where
we can look up information, called the domain vector.
\begin{verbatim}
(DEFUN |INTEF;tanint| (|f| |x| |k| $)
(PROG (|eta| |eta'| |r1|)
(RETURN
(SEQ
(LETT |eta'|
(SPADCALL
(LETT |eta|
(|SPADfirst|
(SPADCALL |k| (QREFELT $ 18)))
|INTEF;tanint|)
|x|
(QREFELT $ 19))
|INTEF;tanint|)
(LETT |r1|
(SPADCALL
(SPADCALL |f| |k| (QREFELT $ 22))
(CONS (FUNCTION |INTEF;tanint!1|) (VECTOR |eta'| |x| $))
(CONS (FUNCTION |INTEF;tanint!4|) (VECTOR |x| $ |eta|))
(QREFELT $ 50))
|INTEF;tanint|)
(EXIT
(SPADCALL
(SPADCALL
(CONS
(FUNCTION |INTEF;tanint!5|)
(VECTOR $ |k|))
(QCAR |r1|)
(QREFELT $ 57))
(SPADCALL (QCDR |r1|) |x| (QREFELT $ 58))
(QREFELT $ 59)))))))
\end{verbatim}
The assignment line for \verb|eta'| is:
\begin{verbatim}
eta' := differentiate(eta := first argument k, x)
\end{verbatim}
which is implemented by the code:
\begin{verbatim}
(LETT |eta'|
(SPADCALL
(LETT |eta|
(|SPADfirst|
(SPADCALL |k| (QREFELT $ 18)))
|INTEF;tanint|)
|x|
(QREFELT $ 19))
|INTEF;tanint|)
\end{verbatim}
from which we see that the inner differentiate is slot 19 in
the domain vector. Every domain has an associated domain vector
which contains references to other functions from other domains,
among other things. The QREFELT function takes the domain vector
\verb|$| and slot number and does a ``quick array reference''. The
return value is a pair, the car of which is a function to call.
The SPADCALL macro uses the last argument, in this case the result
of \verb|(QREFELT $ 19)| to find the function to call.
The function from slot 19 can be found with:
\begin{verbatim}
)lisp (setq $dalymode t)
(setf *print-circle* t)
(setf *print-array* nil)
(setf dv (|ElementaryIntegration| (|Integer|) (|Expression| (|Integer|))))
(|replaceGoGetSlot| (cdr (aref dv 19)))
Value = (#<compiled-function |FS-;differentiate;SSS;99|> . #<vector 090cbccc>)
\end{verbatim}
The call of \verb|(setq $dalymode t)| changes the Axiom top level
loop to interpret any input that begins with an open parenthesis to
be interpreted as a lisp s-expression rather than Axiom input. This
saves typing \verb|)lisp| in front of every lisp expression. Be sure
to do a \verb|(setq $dalymode nil)| when you are finished.
The *print-circle* needs to be true because the domain vector contains
circular references to itself and we need to make sure that we check for
this during printing so the print is not infinite.
The *print-array* needs to be nil so that the arrays just print some
identifying information rather than the detailed array contents.
The \verb|(setf dv ...| uses the Lisp internal names for the domains.
In Axiom, the names of types are case-sensitive symbols. These are
represented in lisp surrounded by vertical bars because lisp is not
case sensitive. The dv variable is essentially being set to the Axiom
equivalent of:
\begin{verbatim}
dv:=ElementaryIntegration(Integer,Expression(Integer))
\end{verbatim}
except we do this in lisp. The end result is that dv will contain the
domain vector for the newly constructed domain. From the lisp code
Consider the call of the form:
\begin{verbatim}
(SPADCALL A B '(C . D))
\end{verbatim}
The SPADCALL macro takes a set of arguments, the last of which is
a pair where C is the function to call and D is the domain vector.
So if we do:
\begin{verbatim}
(macroexpand-1 '(spadcall a b '(c . d)))
Value =
(LET ((#0=#:G1417 (QUOTE (C . D))))
(THE (VALUES T) (FUNCALL (CAR #0#) A B (CDR #0#))))
\end{verbatim}
Note that \verb|#0| is a ``pointer'', in this case to the list '(c)
and \verb|#0#| is a use of that pointer. This is done to make sure that
you reference the exact cons cell of the argument.
In Axiom compiler output
\begin{verbatim}
(SPADCALL eta k (QREFELT $ 19))
\end{verbatim}
approximately translates to
\begin{verbatim}
(FUNCALL (CAR (QREFELT $ 19)) eta k (CDR (QREFELT $ 19)))
\end{verbatim}
which calls the function from the domain slot 19 on the value
assigned to eta and the variable k and the domain.
Thus, the full expansion becomes
\begin{verbatim}
(FUNCALL #<compiled-function |FS-;differentiate;SSS;99|>
eta k #<vector 090cbccc>)
\end{verbatim}
From this we can see a reference to \verb|FS-;differentiate;SSS;99|
which is the internal name of the differentiate function from the
\verb|FS-| category.
Note that FunctionSpace is a category. When categories contain
implementation code the compiler generates 2 nrlibs. The Axiom convention for
categorical implementation of code using a trailing ``-'' so the actual
code for \verb|FS-;differentiate;SSS;99| lives in
int/algebra/FS-.nrlib/code.lsp
We can see that the differentiate function is coming from the category
\begin{verbatim}
)show FS
FunctionSpace R: OrderedSet is a category constructor
Abbreviation for FunctionSpace is FS
....
differentiate : (%,Symbol) -> % if R has RING
differentiate : (%,List Symbol) -> % if R has RING
differentiate : (%,Symbol,NonNegativeInteger) -> % if R has RING
differentiate : (%,List Symbol,List NonNegativeInteger) -> % if R has RING
\end{verbatim}
From the above signatures we know there is only one differentiate that
is a two argument form so the call
\begin{verbatim}
differentiate(#1, x), monomial(eta', 2) + eta'::UP),
\end{verbatim}
must be the first instance.
From the sources (bookvol10.4) we see that the tanint function has
the signature:
\begin{verbatim}
tanint : (F, SE, K) -> IR
\end{verbatim}
and that
\begin{verbatim}
SE ==> Symbol
F : Join(AlgebraicallyClosedField, TranscendentalFunctionCategory,
FunctionSpace R)
K ==> Kernel F
\end{verbatim}
The differentiate function takes something of type F and a Symbol
and returns something of type F. If we write this as an anonymous
function it becomes:
\begin{verbatim}
(x2 : F) : F +-> differentiate(x2, x)
\end{verbatim}
Thus, we can rewrite the differentiate call as:
\begin{verbatim}
differentiate(#1, x), monomial(eta', 2) + eta'::UP),
\end{verbatim}
as
\begin{verbatim}
(x2 : F) : F +-> differentiate(x2, x),
monomial(eta', 2) + eta'::UP),
\end{verbatim}
Continuing in this way we can fully rewrite the assignments as:
\begin{verbatim}
r1 := tanintegrate(univariate(f, k),
(x1 : UP) : UP +-> differentiate(x1,
(x2 : F) : F +-> differentiate(x2, x),
monomial(eta', 2) + eta'::UP),
(x6 : Integer, x2 : F, x3 : F) : Union(List F, "failed") +->
rischDEsys(x6, 2 * eta, x2, x3, x,
(x4 : F, x5 : List F) : U3 +-> lflimitedint(x4, x, x5),
(x4 : F, x5 : F) : U2 +-> lfextendedint(x4, x, x5)))
map((x1 : RF) : F +-> multivariate(x1, k), r1.answer) + _
lfintegrate(r1.a0, x)
\end{verbatim}
Note that rischDEsys is tricky, because rischDEsys returns only List F,
but tanintegrate expects union.
\subsection{The example bug}
Axiom can generate TeX output by typing:
\begin{verbatim}
)set output tex on
\end{verbatim}
Here we give an example of TeX output that contains a bug:
\begin{verbatim}
(1) -> )set output tex on
(1) -> radix(10**10,32)
Loading /axiom/mnt/linux/algebra/RADUTIL.o for package
RadixUtilities
Loading /axiom/mnt/linux/algebra/RADIX.o
for domain RadixExpansion
Loading /axiom/mnt/linux/algebra/ANY1.o
for package AnyFunctions1
Loading /axiom/mnt/linux/algebra/NONE1.o
for package NoneFunctions1
Loading /axiom/mnt/linux/algebra/ANY.o
for domain Any
Loading /axiom/mnt/linux/algebra/SEX.o
for domain SExpression
(1) 9A0NP00
Loading /axiom/mnt/linux/algebra/TEX.o
for domain TexFormat
Loading /axiom/mnt/linux/algebra/CCLASS.o
for domain CharacterClass
Loading /axiom/mnt/linux/algebra/IBITS.o
for domain IndexedBits
Loading /axiom/mnt/linux/algebra/UNISEG.o
for domain UniversalSegment
$$
9#\A0#\N#\P00
\leqno(1)
$$
Loading /axiom/mnt/linux/algebra/VOID.o for domain Void
Type: RadixExpansion 32
\end{verbatim}
The correct output should be:
\begin{verbatim}
$$
9A0NP00
\leqno(1)
$$
\end{verbatim}
So we need to figure out where the \# prefixes are being generated.
In the above code we can see various domains being loaded. These domains
are lisp code. Each domain lives in a subdirectory of its own. For example,
the ANY domain lives in ANY.NRLIB. The ANY.NRLIB directory contains a
common lisp file named code.lsp. The compiled form of this code ANY.o
is loaded whenever the domain Any is referenced. We can look at the lisp
code:
\begin{verbatim}
(/VERSIONCHECK 2)
(PUT (QUOTE |ANY;obj;$N;1|)
(QUOTE |SPADreplace|)
(QUOTE QCDR))
(DEFUN |ANY;obj;$N;1| (|x| $) (QCDR |x|))
(PUT (QUOTE |ANY;dom;$Se;2|)
(QUOTE |SPADreplace|)
(QUOTE QCAR))
(DEFUN |ANY;dom;$Se;2| (|x| $) (QCAR |x|))
(PUT (QUOTE |ANY;domainOf;$Of;3|)
(QUOTE |SPADreplace|)
(QUOTE QCAR))
(DEFUN |ANY;domainOf;$Of;3| (|x| $) (QCAR |x|))
(DEFUN |ANY;=;2$B;4| (|x| |y| $)
(COND
((SPADCALL (QCAR |x|) (QCAR |y|) (QREFELT $ 17))
(EQ (QCDR |x|) (QCDR |y|)))
((QUOTE T) (QUOTE NIL))))
(DEFUN |ANY;objectOf;$Of;5| (|x| $)
(|spad2BootCoerce|
(QCDR |x|)
(QCAR |x|)
(SPADCALL
(SPADCALL "OutputForm" (QREFELT $ 21))
(QREFELT $ 23))))
(DEFUN |ANY;showTypeInOutput;BS;6| (|b| $)
(SEQ
(SETELT $ 10 (SPADCALL |b| (QREFELT $ 9)))
(EXIT
(COND
(|b| "Type of object will be displayed in
output of a member of Any")
((QUOTE T) "Type of object will not be displayed in
output of a member of Any")))))
(DEFUN |ANY;coerce;$Of;7| (|x| $)
(PROG (|obj1| |p| |dom1| #0=#:G1426 |a| #1=#:G1427)
(RETURN
(SEQ
(LETT |obj1|
(SPADCALL |x| (QREFELT $ 24))
|ANY;coerce;$Of;7|)
(COND
((NULL (SPADCALL (QREFELT $ 10) (QREFELT $ 26)))
(EXIT |obj1|)))
(LETT |dom1|
(SEQ
(LETT |p|
(|prefix2String| (|devaluate| (QCAR |x|)))
|ANY;coerce;$Of;7|)
(EXIT
(COND
((SPADCALL |p| (QREFELT $ 27))
(SPADCALL |p| (QREFELT $ 23)))
((QUOTE T) (SPADCALL |p| (QREFELT $ 29))))))
|ANY;coerce;$Of;7|)
(EXIT
(SPADCALL
(CONS |obj1|
(CONS ":"
(PROGN
(LETT #0# NIL |ANY;coerce;$Of;7|)
(SEQ
(LETT |a| NIL |ANY;coerce;$Of;7|)
(LETT #1# |dom1| |ANY;coerce;$Of;7|)
G190
(COND
((OR (ATOM #1#)
(PROGN
(LETT |a| (CAR #1#) |ANY;coerce;$Of;7|)
NIL))
(GO G191)))
(SEQ
(EXIT
(LETT #0#
(CONS
(SPADCALL |a| (QREFELT $ 30))
#0#)
|ANY;coerce;$Of;7|)))
(LETT #1# (CDR #1#) |ANY;coerce;$Of;7|)
(GO G190)
G191
(EXIT (NREVERSE0 #0#))))))
(QREFELT $ 31)))))))
(DEFUN |ANY;any;SeN$;8| (|domain| |object| $)
(SEQ
(COND
((|isValidType| |domain|) (CONS |domain| |object|))
((QUOTE T)
(SEQ
(LETT |domain| (|devaluate| |domain|) |ANY;any;SeN$;8|)
(EXIT
(COND
((|isValidType| |domain|) (CONS |domain| |object|))
((QUOTE T)
(|error|
"function any must have a domain as first argument")))))))))
(DEFUN |Any| NIL
(PROG NIL
(RETURN
(PROG (#0=#:G1432)
(RETURN
(COND
((LETT #0#
(HGET |$ConstructorCache| (QUOTE |Any|))
|Any|)
(|CDRwithIncrement| (CDAR #0#)))
((QUOTE T)
(UNWIND-PROTECT
(PROG1
(CDDAR
(HPUT |$ConstructorCache|
(QUOTE |Any|)
(LIST (CONS NIL (CONS 1 (|Any;|))))))
(LETT #0# T |Any|))
(COND
((NOT #0#)
(HREM |$ConstructorCache| (QUOTE |Any|))))))))))))
(DEFUN |Any;| NIL
(PROG (|dv$| $ |pv$|)
(RETURN
(PROGN
(LETT |dv$| (QUOTE (|Any|)) . #0=(|Any|))
(LETT $ (make-array 35) . #0#)
(QSETREFV $ 0 |dv$|)
(QSETREFV $ 3 (LETT |pv$| (|buildPredVector| 0 0 NIL) . #0#))
(|haddProp| |$ConstructorCache| (QUOTE |Any|) NIL (CONS 1 $))
(|stuffDomainSlots| $)
(QSETREFV $ 6
(|Record| (|:| |dm| (|SExpression|)) (|:| |ob| (|None|))))
(QSETREFV $ 10 (SPADCALL (QUOTE NIL) (QREFELT $ 9)))
$))))
(setf (get (QUOTE |Any|) (QUOTE |infovec|))
(LIST
(QUOTE
#(NIL NIL NIL NIL NIL NIL (QUOTE |Rep|)
(|Boolean|) (|Reference| 7) (0 . |ref|)
(QUOTE |printTypeInOutputP|) (|None|)
|ANY;obj;$N;1| (|SExpression|) |ANY;dom;$Se;2|
(|OutputForm|) |ANY;domainOf;$Of;3| (5 . =)
|ANY;=;2$B;4| (|String|) (|Symbol|) (11 . |coerce|)
(|List| 20) (16 . |list|) |ANY;objectOf;$Of;5|
|ANY;showTypeInOutput;BS;6| (21 . |deref|)
(26 . |atom?|) (|List| $) (31 . |list|)
(36 . |coerce|) (41 . |hconcat|) |ANY;coerce;$Of;7|
|ANY;any;SeN$;8| (|SingleInteger|)))
(QUOTE #(~= 46 |showTypeInOutput| 52 |objectOf| 57 |obj|
62 |latex| 67 |hash| 72 |domainOf| 77 |dom| 82
|coerce| 87 |any| 92 = 98))
(QUOTE NIL)
(CONS (|makeByteWordVec2| 1 (QUOTE (0 0 0)))
(CONS (QUOTE #(|SetCategory&| |BasicType&| NIL))
(CONS
(QUOTE #((|SetCategory|) (|BasicType|) (|CoercibleTo| 15)))
(|makeByteWordVec2| 34
(QUOTE (1 8 0 7 9 2 13 7 0 0 17 1 20 0 19 21 1 22 0 20
23 1 8 7 0 26 1 13 7 0 27 1 20 28 0 29 1 20 15
0 30 1 15 0 28 31 2 0 7 0 0 1 1 0 19 7 25 1 0
15 0 24 1 0 11 0 12 1 0 19 0 1 1 0 34 0 1 1 0
15 0 16 1 0 13 0 14 1 0 15 0 32 2 0 0 13 11 33
2 0 7 0 0 18))))))
(QUOTE |lookupComplete|)))
(setf (get (QUOTE |Any|) (QUOTE NILADIC)) T)
\end{verbatim}
We can ignore this information and focus on the functions that are
defined in this file. These functions can be traced with the usual
common lisp tracing facility. So lets create a file /tmp/debug.lisp
that contains a trace statement for each DEFUN in ANY.NRLIB/code.lsp.
It looks like:
\begin{verbatim}
(trace |ANY1;retractable?;AB;1|)
(trace |ANY1;coerce;SA;2|)
(trace |ANY1;retractIfCan;AU;3|)
(trace |ANY1;retract;AS;4|)
(trace |AnyFunctions1|)
(trace |AnyFunctions1;|)
\end{verbatim}
We can now restart the axiom system, rerun the failing expression
(this will autoload ANY.o; alternatively we could hand-load the
ANY.NRLIB/code.lsp file), and then load our /tmp/debug.lisp file.
Now all of the functions in the ANY domain are traced and we can
watch the trace occur while the expression is evaluated. In this example
I've created a larger file that traces all of the loaded domains:
\begin{verbatim}
(trace |RADUTIL;radix;FIA;1|)
(trace |RadixUtilities|)
(trace |RadixUtilities;|)
(trace |RADIX;characteristic;Nni;1|)
(trace |RADIX;differentiate;2$;2|)
(trace |RADIX;Zero;$;3|)
(trace |RADIX;One;$;4|)
(trace |RADIX;-;2$;5|)
(trace |RADIX;+;3$;6|)
(trace |RADIX;-;3$;7|)
(trace |RADIX;*;I2$;8|)
(trace |RADIX;*;3$;9|)
(trace |RADIX;/;3$;10|)
(trace |RADIX;/;2I$;11|)
(trace |RADIX;<;2$B;12|)
(trace |RADIX;=;2$B;13|)
(trace |RADIX;numer;$I;14|)
(trace |RADIX;denom;$I;15|)
(trace |RADIX;coerce;$F;16|)
(trace |RADIX;coerce;I$;17|)
(trace |RADIX;coerce;F$;18|)
(trace |RADIX;retractIfCan;$U;19|)
(trace |RADIX;retractIfCan;$U;20|)
(trace |RADIX;ceiling;$I;21|)
(trace |RADIX;floor;$I;22|)
(trace |RADIX;wholePart;$I;23|)
(trace |RADIX;fractionPart;$F;24|)
(trace |RADIX;wholeRagits;$L;25|)
(trace |RADIX;fractRagits;$S;26|)
(trace |RADIX;prefixRagits;$L;27|)
(trace |RADIX;cycleRagits;$L;28|)
(trace |RADIX;wholeRadix;L$;29|)
(trace |RADIX;fractRadix;2L$;30|)
(trace |RADIX;intToExpr|)
(trace |RADIX;exprgroup|)
(trace |RADIX;intgroup|)
(trace |RADIX;overBar|)
(trace |RADIX;coerce;$Of;35|)
(trace |RADIX;checkRagits|)
(trace |RADIX;radixInt|)
(trace |RADIX;radixFrac|)
(trace |RadixExpansion|)
(trace |RadixExpansion;|)
(trace |ANY1;retractable?;AB;1|)
(trace |ANY1;coerce;SA;2|)
(trace |ANY1;retractIfCan;AU;3|)
(trace |ANY1;retract;AS;4|)
(trace |AnyFunctions1|)
(trace |AnyFunctions1;|)
(trace |NONE1;coerce;SN;1|)
(trace |NoneFunctions1|)
(trace |NoneFunctions1;|)
(trace |ANY;obj;$N;1|)
(trace |ANY;dom;$Se;2|)
(trace |ANY;domainOf;$Of;3|)
(trace |ANY;=;2$B;4|)
(trace |ANY;objectOf;$Of;5|)
(trace |ANY;showTypeInOutput;BS;6|)
(trace |ANY;coerce;$Of;7|)
(trace |ANY;any;SeN$;8|)
(trace |Any|)
(trace |Any;|)
(trace |SExpression|)
(trace |SExpression;|)
(trace |TEX;new;$;1|)
(trace |TEX;newWithNum|)
(trace |TEX;coerce;Of$;3|)
(trace |TEX;convert;OfI$;4|)
(trace |TEX;display;$IV;5|)
(trace |TEX;display;$V;6|)
(trace |TEX;prologue;$L;7|)
(trace |TEX;tex;$L;8|)
(trace |TEX;epilogue;$L;9|)
(trace |TEX;setPrologue!;$2L;10|)
(trace |TEX;setTex!;$2L;11|)
(trace |TEX;setEpilogue!;$2L;12|)
(trace |TEX;coerce;$Of;13|)
(trace |TEX;ungroup|)
(trace |TEX;postcondition|)
(trace |TEX;stringify|)
(trace |TEX;lineConcat|)
(trace |TEX;splitLong|)
(trace |TEX;splitLong1|)
(trace |TEX;group|)
(trace |TEX;addBraces|)
(trace |TEX;addBrackets|)
(trace |TEX;parenthesize|)
(trace |TEX;precondition|)
(trace |TEX;formatSpecial|)
(trace |TEX;formatPlex|)
(trace |TEX;formatMatrix|)
(trace |TEX;formatFunction|)
(trace |TEX;formatNullary|)
(trace |TEX;formatUnary|)
(trace |TEX;formatBinary|)
(trace |TEX;formatNary|)
(trace |TEX;formatNaryNoGroup|)
(trace |TEX;formatTex|)
(trace |TexFormat|)
(trace |TexFormat;|)
(trace |CCLASS;digit;$;1|)
(trace |CCLASS;hexDigit;$;2|)
(trace |CCLASS;upperCase;$;3|)
(trace |CCLASS;lowerCase;$;4|)
(trace |CCLASS;alphabetic;$;5|)
(trace |CCLASS;alphanumeric;$;6|)
(trace |CCLASS;=;2$B;7|)
(trace |CCLASS;member?;C$B;8|)
(trace |CCLASS;union;3$;9|)
(trace |CCLASS;intersect;3$;10|)
(trace |CCLASS;difference;3$;11|)
(trace |CCLASS;complement;2$;12|)
(trace |CCLASS;convert;$S;13|)
(trace |CCLASS;convert;$L;14|)
(trace |CCLASS;charClass;S$;15|)
(trace |CCLASS;charClass;L$;16|)
(trace |CCLASS;coerce;$Of;17|)
(trace |CCLASS;#;$Nni;18|)
(trace |CCLASS;empty;$;19|)
(trace |CCLASS;brace;$;20|)
(trace |CCLASS;insert!;C2$;21|)
(trace |CCLASS;remove!;C2$;22|)
(trace |CCLASS;inspect;$C;23|)
(trace |CCLASS;extract!;$C;24|)
(trace |CCLASS;map;M2$;25|)
(trace |CCLASS;map!;M2$;26|)
(trace |CCLASS;parts;$L;27|)
(trace |CharacterClass|)
(trace |CharacterClass;|)
(trace |IBITS;minIndex;$I;1|)
(trace |IBITS;range|)
(trace |IBITS;coerce;$Of;3|)
(trace |IBITS;new;NniB$;4|)
(trace |IBITS;empty;$;5|)
(trace |IBITS;copy;2$;6|)
(trace |IBITS;#;$Nni;7|)
(trace |IBITS;=;2$B;8|)
(trace |IBITS;<;2$B;9|)
(trace |IBITS;and;3$;10|)
(trace |IBITS;or;3$;11|)
(trace |IBITS;xor;3$;12|)
(trace |IBITS;setelt;$I2B;13|)
(trace |IBITS;elt;$IB;14|)
(trace |IBITS;Not;2$;15|)
(trace |IBITS;And;3$;16|)
(trace |IBITS;Or;3$;17|)
(trace |IndexedBits|)
(trace |IndexedBits;|)
(trace |UNISEG;segment;S$;1|)
(trace |UNISEG;segment;2S$;2|)
(trace |UNISEG;BY;$I$;3|)
(trace |UNISEG;lo;$S;4|)
(trace |UNISEG;low;$S;5|)
(trace |UNISEG;hasHi;$B;6|)
(trace |UNISEG;hi;$S;7|)
(trace |UNISEG;high;$S;8|)
(trace |UNISEG;incr;$I;9|)
(trace |UNISEG;SEGMENT;S$;10|)
(trace |UNISEG;SEGMENT;2S$;11|)
(trace |UNISEG;coerce;S$;12|)
(trace |UNISEG;convert;S$;13|)
(trace |UNISEG;=;2$B;14|)
(trace |UNISEG;coerce;$Of;15|)
(trace |UNISEG;expand;$S;16|)
(trace |UNISEG;map;M$S;17|)
(trace |UNISEG;plusInc|)
(trace |UNISEG;expand;LS;19|)
(trace |UNISEG;expand;LS;19!0|)
(trace |UniversalSegment|)
(trace |UniversalSegment;|)
\end{verbatim}
Now we rerun the function and get the trace output
\begin{verbatim}
(2) -> )lisp (load "/axiom/debug.lisp")
Value = T
(2) -> radix(10**10,32)
1> (|RadixUtilities|)
<1 (|RadixUtilities| #<vector 08b565cc>)
1> (|RadixExpansion| 32)
<1 (|RadixExpansion| #<vector 08b8cc94>)
1> (|AnyFunctions1| #<vector 08b8cc94>)
<1 (|AnyFunctions1| #<vector 08b5647c>)
1> (|RadixExpansion| 32)
<1 (|RadixExpansion| #<vector 08b8cc94>)
1> (|RADIX;radixInt| 10000000000 32 #<vector 08b8cc94>)
<1 (|RADIX;radixInt| (9 10 0 23 25 0 0))
1> (|RADIX;radixFrac| 0 1 32 #<vector 08b8cc94>)
<1 (|RADIX;radixFrac| (NIL 0))
1> (|RadixExpansion| 32)
<1 (|RadixExpansion| #<vector 08b8cc94>)
1> (|RADIX;intgroup| (9 10 0 23 25 0 0) #<vector 08b8cc94>)
2> (|RADIX;intToExpr| 9 #<vector 08b8cc94>)
<2 (|RADIX;intToExpr| 9)
2> (|RADIX;intToExpr| 10 #<vector 08b8cc94>)
<2 (|RADIX;intToExpr| #\A)
2> (|RADIX;intToExpr| 0 #<vector 08b8cc94>)
<2 (|RADIX;intToExpr| 0)
2> (|RADIX;intToExpr| 23 #<vector 08b8cc94>)
<2 (|RADIX;intToExpr| #\N)
2> (|RADIX;intToExpr| 25 #<vector 08b8cc94>)
<2 (|RADIX;intToExpr| #\P)
2> (|RADIX;intToExpr| 0 #<vector 08b8cc94>)
<2 (|RADIX;intToExpr| 0)
2> (|RADIX;intToExpr| 0 #<vector 08b8cc94>)
<2 (|RADIX;intToExpr| 0)
<1 (|RADIX;intgroup| (CONCAT 9 #\A 0 #\N #\P 0 0))
1> (|RADIX;exprgroup|
((CONCAT 9 #\A 0 #\N #\P 0 0)) #<vector 08b8cc94>)
<1 (|RADIX;exprgroup| (CONCAT 9 #\A 0 #\N #\P 0 0))
(2) 9A0NP00
1> (|TexFormat|)
<1 (|TexFormat| #<vector 08b24000>)
1> (|TexFormat|)
<1 (|TexFormat| #<vector 08b24000>)
1> (|TEX;newWithNum| 2 #<vector 08b24000>)
<1 (|TEX;newWithNum| #<vector 08b8c284>)
1> (|TEX;precondition|
(CONCAT 9 #\A 0 #\N #\P 0 0) #<vector 08b24000>)
<1 (|TEX;precondition| (CONCAT 9 #\A 0 #\N #\P 0 0))
1> (|TEX;formatTex|
(CONCAT 9 #\A 0 #\N #\P 0 0) 0 #<vector 08b24000>)
2> (|TEX;stringify| CONCAT #<vector 08b24000>)
<2 (|TEX;stringify| "CONCAT")
2> (|TEX;formatSpecial| "CONCAT"
(9 #\A 0 #\N #\P 0 0) 0 #<vector 08b24000>)
3> (|TEX;formatNary| ""
(9 #\A 0 #\N #\P 0 0) 0 #<vector 08b24000>)
4> (|TEX;formatNaryNoGroup| ""
(9 #\A 0 #\N #\P 0 0) 0 #<vector 08b24000>)
5> (|TEX;formatTex| 9 0 #<vector 08b24000>)
6> (|TEX;stringify| 9 #<vector 08b24000>)
<6 (|TEX;stringify| "9")
<5 (|TEX;formatTex| "9")
5> (|TEX;formatTex| #\A 0 #<vector 08b24000>)
6> (|TEX;stringify| #\A #<vector 08b24000>)
<6 (|TEX;stringify| "#\\A")
6> (|IBITS;range|
#<bit-vector 0831d930> 35 #<vector 085da658>)
<6 (|IBITS;range| 35)
<5 (|TEX;formatTex| "#\\A")
5> (|TEX;formatTex| 0 0 #<vector 08b24000>)
6> (|TEX;stringify| 0 #<vector 08b24000>)
<6 (|TEX;stringify| "0")
<5 (|TEX;formatTex| "0")
5> (|TEX;formatTex| #\N 0 #<vector 08b24000>)
6> (|TEX;stringify| #\N #<vector 08b24000>)
<6 (|TEX;stringify| "#\\N")
6> (|IBITS;range|
#<bit-vector 0831d930> 35 #<vector 085da658>)
<6 (|IBITS;range| 35)
<5 (|TEX;formatTex| "#\\N")
5> (|TEX;formatTex| #\P 0 #<vector 08b24000>)
6> (|TEX;stringify| #\P #<vector 08b24000>)
<6 (|TEX;stringify| "#\\P")
6> (|IBITS;range|
#<bit-vector 0831d930> 35 #<vector 085da658>)
<6 (|IBITS;range| 35)
<5 (|TEX;formatTex| "#\\P")
5> (|TEX;formatTex| 0 0 #<vector 08b24000>)
6> (|TEX;stringify| 0 #<vector 08b24000>)
<6 (|TEX;stringify| "0")
<5 (|TEX;formatTex| "0")
5> (|TEX;formatTex| 0 0 #<vector 08b24000>)
6> (|TEX;stringify| 0 #<vector 08b24000>)
<6 (|TEX;stringify| "0")
<5 (|TEX;formatTex| "0")
<4 (|TEX;formatNaryNoGroup| "9#\\A0#\\N#\\P00")
4> (|TEX;group| "9#\\A0#\\N#\\P00" #<vector 08b24000>)
<4 (|TEX;group| "{9#\\A0#\\N#\\P00}")
<3 (|TEX;formatNary| "{9#\\A0#\\N#\\P00}")
<2 (|TEX;formatSpecial| "{9#\\A0#\\N#\\P00}")
<1 (|TEX;formatTex| "{9#\\A0#\\N#\\P00}")
1> (|TEX;postcondition|
"{9#\\A0#\\N#\\P00}" #<vector 08b24000>)
2> (|TEX;ungroup| "{9#\\A0#\\N#\\P00}" #<vector 08b24000>)
<2 (|TEX;ungroup| "9#\\A0#\\N#\\P00")
<1 (|TEX;postcondition| "9#\\A0#\\N#\\P00")
$$
1> (|TEX;splitLong|
"9#\\A0#\\N#\\P00" 77 #<vector 08b24000>)
2> (|TEX;splitLong1|
"9#\\A0#\\N#\\P00" 77 #<vector 08b24000>)
3> (|TEX;lineConcat|
"9#\\A0#\\N#\\P00 " NIL #<vector 08b24000>)
<3 (|TEX;lineConcat| ("9#\\A0#\\N#\\P00 "))
<2 (|TEX;splitLong1| ("9#\\A0#\\N#\\P00 "))
<1 (|TEX;splitLong| ("9#\\A0#\\N#\\P00 "))
9#\A0#\N#\P00
\leqno(2)
$$
Type: RadixExpansion 32
\end{verbatim}
Notice the call that reads:
\begin{verbatim}
2> (|RADIX;intToExpr| 10 #<vector 08b8cc94>)
<2 (|RADIX;intToExpr| #\A)
\end{verbatim}
This means that calling |RADIX;intToExpr| with the number 10
and ``the domain vector'' generates the character \#\\A which fails.
If we had the domain vector in a variable we could hand-execute this
algebra function directly and watch it fail. So we go to the file
RADIX.NRLIB/code.lsp which contains the definition of RADIX;intToExpr.
The definition is:
\begin{verbatim}
(DEFUN |RADIX;intToExpr| (|i| $)
(COND
((< |i| 10)
(SPADCALL |i| (QREFELT $ 66)))
((QUOTE T)
(SPADCALL
(SPADCALL
(QREFELT $ 64)
(+ (- |i| 10) (SPADCALL (QREFELT $ 64) (QREFELT $ 68)))
(QREFELT $ 70))
(QREFELT $ 71)))))
\end{verbatim}
We can put this definition into our /tmp/debug.lisp file and modify
it to capture the domain vector passed in the \$ variable thus:
\begin{verbatim}
(DEFUN |RADIX;intToExpr| (|i| $)
(setq tpd $)
(COND
((< |i| 10)
(SPADCALL |i| (QREFELT $ 66)))
((QUOTE T)
(SPADCALL
(SPADCALL
(QREFELT $ 64)
(+ (- |i| 10) (SPADCALL (QREFELT $ 64) (QREFELT $ 68)))
(QREFELT $ 70))
(QREFELT $ 71)))))
\end{verbatim}
Now when this function is executed the tpd variable will contain the
value of \$, the domain vector. So we load debug.lisp again
to redefine RADIX;intToExpr and re-execute the function. The trace
results will be the same but now the global variable tpd will have
the domain vector:
\begin{verbatim}
(4) -> (identity tpd)
Value = #<vector 08b8cc94>
\end{verbatim}
Now we can use common lisp to step the RADIX;intToExpr function:
\begin{verbatim}
(4) -> (step (|RADIX;intToExpr| 10 tpd))
Type ? and a newline for help.
(|RADIX;intToExpr| 10 ...) ?
Stepper commands:
n (or N or Newline): advances to the next form.
s (or S): skips the form.
p (or P): pretty-prints the form.
f (or F) FUNCTION: skips until the FUNCTION is called.
q (or Q): quits.
u (or U): goes up to the enclosing form.
e (or E) FORM: evaluates the FORM and prints the value(s).
r (or R) FORM: evaluates the FORM and returns the value(s).
b (or B): prints backtrace.
?: prints this.
(|RADIX;intToExpr| 10 ...)
10
TPD
= #<vector 08b8cc94>
(SYSTEM::TRACE-CALL (QUOTE #:G1624) ...)
(QUOTE #:G1624)
SYSTEM::ARGS
= (10 #<vector 08b8cc94>)
(QUOTE T)
(QUOTE T)
(QUOTE (CONS # ...))
(QUOTE T)
(QUOTE (CONS # ...))
(LET (#) ...)
(QUOTE (10 #<vector 08b8cc94>))
T
= T
1> (LET (#) ...)
(QUOTE (10 #<vector 08b8cc94>))
(CONS (QUOTE |RADIX;intToExpr|) ...)
(QUOTE |RADIX;intToExpr|)
SYSTEM::ARGLIST
= (10 #<vector 08b8cc94>)
= (|RADIX;intToExpr| 10 ...)
= (|RADIX;intToExpr| 10 ...)
(|RADIX;intToExpr| 10 ...)
(SETQ TPD ...)
$
= #<vector 08b8cc94>
= #<vector 08b8cc94>
(COND (# #) ...)
(< |i| ...)
|i|
= 10
10
= NIL
(QUOTE T)
(SPADCALL (SPADCALL # ...) ...)
(LET (#) ...)
(QREFELT $ ...)
(SVREF $ ...)
$
= #<vector 08b8cc94>
71
= (#<compiled-function |CHAR;coerce;$Of;12|> .
#<vector 08b3901c>)
= (#<compiled-function |CHAR;coerce;$Of;12|> .
#<vector 08b3901c>)
(THE (VALUES T) ...)
(FUNCALL (CAR #:G1776) ...)
(CAR #:G1776)
#:G1776
= (#<compiled-function |CHAR;coerce;$Of;12|> .
#<vector 08b3901c>)
= #<compiled-function |CHAR;coerce;$Of;12|>
(SPADCALL (QREFELT $ ...) ...)
(LET (#) ...)
(QREFELT $ ...)
(SVREF $ ...)
$
= #<vector 08b8cc94>
70
= (#<compiled-function
|ISTRING;elt;$IC;30|> .
#<vector 08b26850>)
= (#<compiled-function
|ISTRING;elt;$IC;30|> .
#<vector 08b26850>)
(THE (VALUES T) ...)
(FUNCALL (CAR #:G1777) ...)
(CAR #:G1777)
#:G1777
= (#<compiled-function
|ISTRING;elt;$IC;30|> .
#<vector 08b26850>)
= #<compiled-function |ISTRING;elt;$IC;30|>
(QREFELT $ ...)
(SVREF $ ...)
$
= #<vector 08b8cc94>
64
= "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
= "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
(+ (- |i| ...) ...)
(- |i| ...)
|i|
= 10
10
= 0
(SPADCALL (QREFELT $ ...) ...)
(LET (#) ...)
(QREFELT $ ...)
(SVREF $ ...)
$
= #<vector 08b8cc94>
68
= (#<compiled-function
|ISTRING;minIndex;$I;11|> .
#<vector 08b26850>)
= (#<compiled-function
|ISTRING;minIndex;$I;11|> .
#<vector 08b26850>)
(THE (VALUES T) ...)
(FUNCALL (CAR #:G1778) ...)
(CAR #:G1778)
#:G1778
= (#<compiled-function
|ISTRING;minIndex;$I;11|> .
#<vector 08b26850>)
= #<compiled-function
|ISTRING;minIndex;$I;11|>
(QREFELT $ ...)
(SVREF $ ...)
$
= #<vector 08b8cc94>
64
= "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
= "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
(CDR #:G1778)
#:G1778
= (#<compiled-function
|ISTRING;minIndex;$I;11|> .
#<vector 08b26850>)
= #<vector 08b26850>
= 1
= 1
= 1
= 1
= 1
(CDR #:G1777)
#:G1777
= (#<compiled-function
|ISTRING;elt;$IC;30|> .
#<vector 08b26850>)
= #<vector 08b26850>
= 65
= 65
= 65
= 65
(CDR #:G1776)
#:G1776
= (#<compiled-function
|CHAR;coerce;$Of;12|> .
#<vector 08b3901c>)
= #<vector 08b3901c>
= #\A
= #\A
= #\A
= #\A
= #\A
<1 (LET (# #) ...)
(QUOTE (10 #<vector 08b8cc94>))
(QUOTE (#\A))
(CONS (QUOTE |RADIX;intToExpr|) ...)
(QUOTE |RADIX;intToExpr|)
VALUES
= (#\A)
= (|RADIX;intToExpr| #\A)
= (|RADIX;intToExpr| #\A)
(|RADIX;intToExpr| #\A)
= #\A
= #\A
Value = #\A
(4) ->
\end{verbatim}
If we examine the source code for this function in int/algebra/radix.spad
we find:
\begin{verbatim}
ALPHAS : String := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
intToExpr(i:I): OUT ==
-- computes a digit for bases between 11 and 36
i < 10 => i :: OUT
elt(ALPHAS,(i-10) + minIndex(ALPHAS)) :: OUT
\end{verbatim}
We do some lookups by hand to find out what functions are being called
from the domain vectors thus:
\begin{verbatim}
(4) -> )lisp (qrefelt tpd 68)
Value = (#<compiled-function
|ISTRING;minIndex;$I;11|> . #<vector 08b26850>)
\end{verbatim}
The \#\\A value appears from a call to
CHAR;coerce;\$Of;12. We can look in CHAR.NRLIB/code.lsp
for this function and continue our descent into the code. The
function looks like:
\begin{verbatim}
(DEFUN |CHAR;coerce;$Of;12| (|c| $)
(ELT (QREFELT $ 10)
(+ (QREFELT $ 11) (SPADCALL |c| (QREFELT $ 21)))))
\end{verbatim}
Again we need to get the domain vector, this time from the CHAR domain.
The domain vector has all of the information about a domain including
what functions are referenced and what data values are used. The
QREFELT is a ``quick elt'' function which resolved to a highly
type optimized function call. The SPADCALL function funcalls the
second argument to SPADCALL with the first argument to SPADCALL
effectively giving:
\begin{verbatim}
(funcall (qrefelt $ 21) |c|)
\end{verbatim}
So we modify the CHAR;coerce;\$Of;12 function to capture the domain
vector thus:
\begin{verbatim}
(DEFUN |CHAR;coerce;$Of;12| (|c| $)
(format t "|CHAR;coerce;$Of;12| called")
(setq tpd1 $)
(ELT (QREFELT $ 10)
(+ (QREFELT $ 11) (SPADCALL |c| (QREFELT $ 21)))))
\end{verbatim}
Again we rerun the failing function and now tpd1 contains the
domain vector for the domain CHAR:
\subsection{Operating system level I/O trace (strace)}
If the bug seems to happen during startup the only method of
debugging might be to use strace. To do this, replace the
\$AXIOM/bin/AXIOMsys binary with a shell script. You should:
\begin{enumerate}
\item rename \$AXIOM/bin/AXIOMsys to \$AXIOM/bin/AXIOMsys.bin
\item create the shell script shown below
\item copy the shell script to the file \$AXIOM/bin/AXIOMsys so it will
execute in place of the normal Axiom image
\item chmod +x \$AXIOM/bin/AXIOMsys to make the script executable
\item start axiom normally
\end{enumerate}
The script reads:
\begin{verbatim}
#!/bin/sh
exec strace -o /tmp/str.$$ /research/test/mnt/ubuntu/bin/AXIOMsys.bin "$@"
| tee /tmp/tee.$$
\end{verbatim}
The script will create 2 files in the tmp directory, ``str.NNNNN'' and
``tee.NNNNN'' where NNNNN is the process id assigned to axiom at runtime.
The tee.NNNNN file contains the console output you saw.
The str.NNNNN contains the output of strace which is a list of all of
the system calls and their result.
\section{How to make graphs in algebra books}
dot -Tps <pic >books/ps/domain.ps
where file pic contains something like:
\begin{verbatim}
digraph pic {
fontsize=10;
bgcolor="#ECEA81";
node [shape=box, color=white, style=filled];
"OrderlyDifferentialVariable"
[color=lightblue,href="bookvol10.3.pdf#nameddest=ODVAR"];
}
\end{verbatim}
In book Volume 10.3 there are .ps files generated for each domain.
These pictures show the category, domain, or package that is the highest
in the algebra tower. That means that the parent domain has to be compiled
before this domain. Since the parent is the highest in the tower then all
of the other domains will already have been compiled.
We derive the dependency information from the algebra Makefile.
In order to insert algebra into the tower we derive its parents
and then create a table of all of the parents. However, the table is
mostly comments except for the highest parent. So if the highest parent
is compiled in layer 12 then the new domain is inserted into layer 13.
The graph information at the end of a domain (e.g. UTSZ) contains only
the uncommented information. It is used to generate the picture. So
for UTSZ we see:
\begin{verbatim}
"UTSZ" [color="#88FF44",href="bookvol10.3.pdf#nameddest=UTSZ"]
"ACFS" [color="#4488FF",href="bookvol10.2.pdf#nameddest=ACFS"]
"UTSZ" -> "ACFS"
\end{verbatim}
This tells us several pieces of information. UTSZ depends on ACFS
as the highest parent. ACFS is in layer 17 so is in layer 18.
ACFS is a category (color 4488FF) and lives in bookvol10.2.
UTSZ is a domain (color 88FF44, note the rotation of hex codes,
a package is color FF4488) and lives in bookvol10.3.
The necessary stanzas exist after each algebra domain.
Copy the stanza into a digraph block and run the dot function.
So for the UTSZ domain we would create a file (e.g. called 'pic')
that contains a block that reads:
\begin{verbatim}
digraph pic {
fontsize=10;
bgcolor="#ECEA81";
node [shape=box, color=white, style=filled];
"UTSZ" [color="#88FF44",href="bookvol10.3.pdf#nameddest=UTSZ"]
"ACFS" [color="#4488FF",href="bookvol10.2.pdf#nameddest=ACFS"]
"UTSZ" -> "ACFS"
}
\end{verbatim}
and then run the command:
\begin{verbatim}
dot -Tps <pic >pic.ps
cp pic.ps ps/v103univariatetaylorseriesczero.ps
\end{verbatim}
The output file ``ps/v103univariatetaylorseriesczero.ps'' is included
after the pagepic of each domain in the book.
\section{Adding or Editing pages in Hyperdoc}
In Axiom it is easy to develop new pages in hyperdoc.
All of the hyperdoc pages live in bookvol7.1.pamphlet.
The structure of each page, say for the Fantastic domain, consists
of a few lines of latex followed by a literate chunk. All of the
hyperdoc page information goes into the literate chunk and will
be extracted as a hyperdoc page.
\begin{verbatim}
\section{fantastic.ht} <-- ordinary latex
\pagehead{FantasticPage}{fantastic.ht}{Fantastic} <-- special latex
\pageto{..... <-- for latex (not hyperdoc) links to other pages
<<fantastic.ht>>= <-- this is what htadd looks for
all the documentation for domain Fantastic
@ <-- this is the end of the page for htadd
\end{verbatim}
When you add new pages to bookvol7.1.pamphlet you need to tell the
system about the changes. The ``htadd'' function will search the
bookvol7.1.pamphlet file for chunks with the name ``*.ht'' and build the
file ht.db.
The ht.db file is used by hyperdoc to find pages.
Each line in ht.db contains a line that
\begin{verbatim}
FantasticPage (byteIndex) (lineIndex)
\end{verbatim}
So the two critical files, bookvol7.1.pamphlet and ht.db live in \$AXIOM/doc
There is a very fast cycle for editing.
\begin{verbatim}
cd $AXIOM/doc
while (1) do
axiom <-- at the shell prompt
(navigate to page in hyperdoc) <-- to check your work
)lisp (bye) <-- at the axiom prompt
(modify bookvol7.1.pamphlet) <-- change the page
rm ht.db <-- remove the old database
htadd bookvol7.1.pamphlet <-- remake the database
\end{verbatim}
\section{Graphviz file creation}
The graphviz output used on the website is a scaled vector graphics
file (SVG). The dot command to output this file is:
\begin{verbatim}
dot -Tsvg:cg <pic >pic.svg
\end{verbatim}
The SVG file that gets generated has the following preamble.
\begin{verbatim}
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd" [
<!ATTLIST svg xmlns:xlink CDATA #FIXED "http://www.w3.org/1999/xlink">
]>
<!-- Generated by dot version 2.8 (Thu Sep 14 20:34:11 UTC 2006)
For user: (root) root -->
<!-- Title: AxiomSept2008 Pages: 1 -->
<svg width="3960pt" height="2312pt"
viewBox = "0 0 3960 2312"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
\end{verbatim}
There are two pieces of information that are important. First,
we need to add the following text by removing the trailing
$>$ character from the svg tag and replacing it with the
following block. This block exports some javascript functions
that we use to scale the graphics.
\begin{verbatim}
onload="RunScript(evt)">
<script type="text/ecmascript">
<![CDATA[
var g_element;
var SVGDoc;
var SVGRoot;
function setDimension(w,h) {
SVGDoc.documentElement.setAttribute("width",w);
SVGDoc.documentElement.setAttribute("height",h);
}
function setScale(sw,sh) {
g_element.setAttribute("transform","scale("+sw+" "+sh+")");
}
function RunScript(LoadEvent) {
top.SVGsetDimension=setDimension;
top.SVGsetScale=setScale;
SVGDoc=LoadEvent.target.ownerDocument;
g_element=SVGDoc.getElementById("graph0");
}
]]>
</script>
\end{verbatim}
A second item of interest is the viewbox line which gives us the
width and height information. We use this information to place
the graph on the web page. A simple example of the web page
looks follows. We need to replace the X and Y sizes with the
sizes from the viewbox above.
\begin{verbatim}
<html>
<head>
<title>Axiom Abbreviated Category and Domain graph</title>
<script type="text/javascript">
var W3CDOM = (document.createElement && document.getElementsByTagName);
window.onload = init;
function init(evt) {
SVGscale(0.5);
}
function SVGscale(scale) {
window.SVGsetDimension(8162*scale, 3068*scale);
window.SVGsetScale(scale,scale);
var box = document.getElementById('svgid');
box.width = 8162*scale;
box.height = 3068*scale;
}
</script>
</head>
<body>
<h1>Axiom Abbreviated Category and Domain graph</h1>
<div>
choose here:
<a href="#" onclick="SVGscale(0.1);">0.1</a> or
<a href="#" onclick="SVGscale(0.25);">0.25</a> or
<a href="#" onclick="SVGscale(0.5);">0.5</a> or
<a href="#" onclick="SVGscale(1);">1.0</a> or
<a href="#" onclick="SVGscale(1.5);">1.5</a> or ...
</div>
<div>
<object id='svgid' data="dotabb.svg" type="image/svg+xml"
width="8162" height="3068" wmode="transparent" style="overflow:hidden;" />
</object>
</div>
</body>
</html>
\end{verbatim}
\section{Adding Algebra}
\subsection{Adding algebra to the books}
Assume you have a piece of algebra code that you want to permanently add
to Axiom. This is a fairly complex process since the system automatically
runs regression tests, creates help files, etc. and has other standard
features you need to support. Lets assume your algebra looks like this:
\begin{verbatim}
)abbreviation package INTERGB InterfaceGroebnerPackage
InterfaceGroebnerPackage(K,symb,E,OV,R):Exports == Implementation where
K : FIELD
symb : List Symbol
E : OrderedAbelianMonoidSup
OV : OrderedSet
R : PolynomialCategory(K,E,OV)
LIST ==> List
Exports ==> with
groebner: LIST R -> LIST R
Implementation ==> add
PF ==> PrimeField(q)
DPF ==> DistributedMultivariatePolynomial(symb,PF)
D ==> DistributedMultivariatePolynomial(symb,K)
JCFGBPack ==> GroebnerPackage(PF,E,OV,DPF)
GBPack ==> GroebnerPackage(K,E,OV,D)
coerceDtoR: D->R
coerceDtoR(pol) == map(#1,pol)$MPolyCatFunctions2(OV,E,E,K,K,D,R)
groebner(l)==
ldmp:List D:= [coerceRtoD(pol) for pol in l]
gg:=groebner(ldmp)$GBPack
[coerceDtoR(pol) for pol in gg]
\end{verbatim}
There are some things to check and things to change.
\begin{itemize}
\item remove all tabs. Spad is a language that assigns meaning to
indentation and tabs are not going to survive the build process intact.
\item try to stay within 80 characters. Spad code is printed in the books
so it should try to limit line lengths everywhere.
\item change ``)abbreviation'' to ``)abbrev''. The Makefile will search
for the abbrev line and expect this exact text.
\begin{verbatim}
)abbrev package INTERGB InterfaceGroebnerPackage
\end{verbatim}
\item make sure there is only a single space between the items in the
abbrev line. The Makefile assumes this.
\item Add the comment header block. The author information is used to
check that all authors are included in the credits. The description
tag is used as output by the ``)describe'' command. For example:
\begin{verbatim}
++ Author: Gaetan Hache
++ Date Created: September 1996
++ Date Last Updated: April, 2010, by Tim Daly
++ Description:
++ Part of the Package for Algebraic Function Fields in one variable PAFF
\end{verbatim}
Other tags can be included but are not used. Do not assume that any
format information will be correctly translated or preserved. Make the
description section be simple text with a single character between the
``++'' and the first word of the text.
\end{itemize}
\begin{enumerate}
\item Choose the right book:
\begin{itemize}
\item Category goes into book bookvol10.2.pamphlet
\item Domain goes into book bookvol10.3.pamphlet
\item Package goes into book bookvol10.4.pamphlet
\item Numerics goes into book bookvol10.5.pamphlet
\end{itemize}
\item Find the right chapter. Chapter ordered by name, not abbreviation
\item Create a new section. The easiest way to do this is to copy another
section and change the names. In any case, your new section will need
\item Create a dividiing line consisting of all \% signs.
Note that this character is the comment character for TeX.
\item Create the \verb|\section| tag. This tag should contain the exact text of
the )abbrev line from your algebra code. It reads:
\verb|)section{package INTERGB InterfaceGroebnerPackage}|
\item Create a regression test chunk. This chunk derives its name from the
algebra name as in ``InterfaceGroebnerPackage.input''. This chunk will
be automatically extracted and run during regression testing. For the
moment the chunk should be a simple empty input file as in:
\begin{verbatim}
)set break resume
)sys rm -f InterfaceGroebnerPackage.output
)spool InterfaceGroebnerPackage.output
)set message test on
)set message auto off
)clear all
--S 1 of 1
)show InterfaceGroebnerPackage
--E 1
)spool
)lisp (bye)
\end{verbatim}
\item Create a help text chunk. This chunk dervies its name from the
algebra name as in ``InterfaceGroebnerPackage.help''. This chunk will
be automatically extracted and used to build help text during build.
For the moment the chunck should be a simple empty help text file as in:
\begin{verbatim}
====================================================================
examples InterfaceGroebnerPackage
====================================================================
See Also:
o )show InterfaceGroebnerPackage
\end{verbatim}
\end{enumerate}
At this point we need information from the Axiom interpreter to continue.
Start Axiom and compile your program with ``autoload'' on. For example:
\begin{verbatim}
axiom -nox
)set message autoload on
)co InterfaceGroebnerPackage.spad
\end{verbatim}
You will see output containing lines which detail the category, domains,
and packages needed by your code, for example:
\begin{verbatim}
Loading /research/test/mnt/ubuntu/algebra/FIELD.o for category Field
Loading /research/test/mnt/ubuntu/algebra/EUCDOM.o for category
EuclideanDomain
Loading /research/test/mnt/ubuntu/algebra/PID.o for category
PrincipalIdealDomain
Loading /research/test/mnt/ubuntu/algebra/GCDDOM.o for category
GcdDomain
Loading /research/test/mnt/ubuntu/algebra/INTDOM.o for category
IntegralDomain
Loading /research/test/mnt/ubuntu/algebra/COMRING.o for category
CommutativeRing
Loading /research/test/mnt/ubuntu/algebra/RING.o for category Ring
Loading /research/test/mnt/ubuntu/algebra/RNG.o for category Rng
Loading /research/test/mnt/ubuntu/algebra/ABELGRP.o for category
AbelianGroup
Loading /research/test/mnt/ubuntu/algebra/CABMON.o for category
CancellationAbelianMonoid
Loading /research/test/mnt/ubuntu/algebra/ABELMON.o for category
AbelianMonoid
Loading /research/test/mnt/ubuntu/algebra/ABELSG.o for category
AbelianSemiGroup
Loading /research/test/mnt/ubuntu/algebra/SETCAT.o for category
SetCategory
Loading /research/test/mnt/ubuntu/algebra/BASTYPE.o for category
BasicType
Loading /research/test/mnt/ubuntu/algebra/KOERCE.o for category
CoercibleTo
Loading /research/test/mnt/ubuntu/algebra/SGROUP.o for category
SemiGroup
Loading /research/test/mnt/ubuntu/algebra/MONOID.o for category
Monoid
Loading /research/test/mnt/ubuntu/algebra/LMODULE.o for category
LeftModule
Loading /research/test/mnt/ubuntu/algebra/BMODULE.o for category
BiModule
Loading /research/test/mnt/ubuntu/algebra/RMODULE.o for category
RightModule
Loading /research/test/mnt/ubuntu/algebra/ALGEBRA.o for category
Algebra
Loading /research/test/mnt/ubuntu/algebra/MODULE.o for category
Module
Loading /research/test/mnt/ubuntu/algebra/ENTIRER.o for category
EntireRing
Loading /research/test/mnt/ubuntu/algebra/UFD.o for category
UniqueFactorizationDomain
Loading /research/test/mnt/ubuntu/algebra/DIVRING.o for category
DivisionRing
Loading /research/test/mnt/ubuntu/algebra/OAMONS.o for category
OrderedAbelianMonoidSup
Loading /research/test/mnt/ubuntu/algebra/OCAMON.o for category
OrderedCancellationAbelianMonoid
Loading /research/test/mnt/ubuntu/algebra/OAMON.o for category
OrderedAbelianMonoid
Loading /research/test/mnt/ubuntu/algebra/OASGP.o for category
OrderedAbelianSemiGroup
Loading /research/test/mnt/ubuntu/algebra/ORDSET.o for category
OrderedSet
Loading /research/test/mnt/ubuntu/algebra/POLYCAT.o for category
PolynomialCategory
Loading /research/test/mnt/ubuntu/algebra/PDRING.o for category
PartialDifferentialRing
Loading /research/test/mnt/ubuntu/algebra/FAMR.o for category
FiniteAbelianMonoidRing
Loading /research/test/mnt/ubuntu/algebra/AMR.o for category
AbelianMonoidRing
Loading /research/test/mnt/ubuntu/algebra/CHARZ.o for category
CharacteristicZero
Loading /research/test/mnt/ubuntu/algebra/CHARNZ.o for category
CharacteristicNonZero
Loading /research/test/mnt/ubuntu/algebra/FRETRCT.o for category
FullyRetractableTo
Loading /research/test/mnt/ubuntu/algebra/RETRACT.o for category
RetractableTo
Loading /research/test/mnt/ubuntu/algebra/EVALAB.o for category
Evalable
Loading /research/test/mnt/ubuntu/algebra/IEVALAB.o for category
InnerEvalable
Loading /research/test/mnt/ubuntu/algebra/FLINEXP.o for category
FullyLinearlyExplicitRingOver
Loading /research/test/mnt/ubuntu/algebra/LINEXP.o for category
LinearlyExplicitRingOver
Loading /research/test/mnt/ubuntu/algebra/KONVERT.o for category
ConvertibleTo
Loading /research/test/mnt/ubuntu/algebra/PATMAB.o for category
PatternMatchable
Loading /research/test/mnt/ubuntu/algebra/PFECAT.o for category
PolynomialFactorizationExplicit
Loading /research/test/mnt/ubuntu/algebra/FFIELDC.o for category
FiniteFieldCategory
Loading /research/test/mnt/ubuntu/algebra/FPC.o for category
FieldOfPrimeCharacteristic
Loading /research/test/mnt/ubuntu/algebra/FINITE.o for category
Finite
Loading /research/test/mnt/ubuntu/algebra/STEP.o for category
StepThrough
Loading /research/test/mnt/ubuntu/algebra/DIFRING.o for category
DifferentialRing
Loading /research/test/mnt/ubuntu/algebra/NNI.o for domain
NonNegativeInteger
Loading /research/test/mnt/ubuntu/algebra/INT.o for domain Integer
\end{verbatim}
These are all of the algebra files on which your algebra depends.
Collect all of these names into a list:
\begin{verbatim}
FIELD.o EUCDOM.o PID.o GCDDOM.o INTDOM.o
COMRING.o RING.o RNG.o ABELGRP.o CABMON.o
ABELMON.o ABELSG.o SETCAT.o BASTYPE.o KOERCE.o
SGROUP.o MONOID.o LMODULE.o BMODULE.o RMODULE.o
ALGEBRA.o MODULE.o ENTIRER.o UFD.o DIVRING.o
OAMONS.o OCAMON.o OAMON.o OASGP.o ORDSET.o
POLYCAT.o PDRING.o FAMR.o AMR.o CHARZ.o
CHARNZ.o FRETRCT.o RETRACT.o EVALAB.o IEVALAB.o
FLINEXP.o LINEXP.o KONVERT.o PATMAB.o PFECAT.o
FFIELDC.o FPC.o FINITE.o STEP.o DIFRING.o
NNI.o INT.o
\end{verbatim}
The algebra files are arranged into layers. Algebra in a given layer can
only depend on algebra in lower layers. So algebra in layer 4 can only
depend on algebra in layers 0 through 3.
Your algebra depends on all of the above algebra so we first need to
answer the question ``What is the highest layer of algebra my code
depends upon''.
To answer that question we need to know the layer of each of the above files.
This can be determined by searching the Makefile and finding the layer.
We do this here and annotate the above list, rearranged by layers:
\begin{verbatim}
FIELD.o EUCDOM.o PID.o GCDDOM.o INTDOM.o
COMRING.o RING.o RNG.o ABELGRP.o CABMON.o
ABELMON.o ABELSG.o SETCAT.o BASTYPE.o KOERCE.o
SGROUP.o MONOID.o LMODULE.o BMODULE.o RMODULE.o
ALGEBRA.o MODULE.o ENTIRER.o UFD.o DIVRING.o
OAMONS.o OCAMON.o OAMON.o OASGP.o ORDSET.o
POLYCAT.o PDRING.o FAMR.o AMR.o CHARZ.o
CHARNZ.o FRETRCT.o RETRACT.o EVALAB.o IEVALAB.o
FLINEXP.o LINEXP.o KONVERT.o PATMAB.o PFECAT.o
FFIELDC.o FPC.o FINITE.o STEP.o DIFRING.o
NNI.o INT.o
\end{verbatim}
We find that
\begin{verbatim}
layer 0
EUCDOM.o GCDDOM.o INTDOM.o COMRING.o RING.o RNG.o ABELGRP.o CABMON.o ABELMON.o
ABELSG.o SETCAT.o BASTYPE.o KOERCE.o MONOID.o ENTIRER.o UFD.o DIVRING.o
POLYCAT.o KONVERT.o FFIELDC.o DIFRING.o NNI.o INT.o
layer 1
SGROUP.o LMODULE.o RMODULE.o ORDSET.o RETRACT.o IEVALAB.o FINITE.o STEP.o
PATMAB.o
layer 2
BMODULE.o OASGP.o PDRING.o CHARZ.o CHARNZ.o EVALAB.o LINEXP.o
layer 3
MODULE.o OAMON.o
layer 4
ALGEBRA.o OCAMON.o
layer 5
PID.o OAMONS.o
layer 6
FIELD.o AMR.o FRETRCT.o FLINEXP.o
layer 7
FAMR.o FPC.o
layer 10
PFECAT.o
\end{verbatim}
So we know that our algebra belongs in layer 11 since it depends on
PFECAT which lives in layer 10.
Now we have all of the information needed to add the algebra to the book.
We create a new section that contains the following parts:
\begin{itemize}
\item the \verb|\section{...}| header
\item the input file
\item the help file
\item the page head markup
\item the pagepic markup
\item the Exports section
\item the theory and discussion section
\item the algebra
\item the dot picture file information
\end{itemize}
We've already explained most of the sections. Now we insert a chunk
for our algebra. The name of this chunk is important because the Makefile
will look for this exact chunk name. In our example case it looks like:
\begin{verbatim}
\begin{chunk}{package INTERGB InterfaceGroebnerPackage}
\end{verbatim}
which is followed immediately by the algebra starting with the ``abbrev''
command.
Make sure that the section names, input file names, help file names,
and chunk names all reflect the new algebra names.
Next we copy the chunkname to the bottom of the file as part of the
algebra chunk.
The next piece to be handled is the ``pagepic'' tag. This inserts a
picture into the book which shows what files our algebra depends upon.
We do this using the graphviz dot program.
We create a file that shows the graph relationship. Since our code
INTERGB depends on PFECAT we show that here. We create a line for our
code that looks like:
\begin{verbatim}
"INTERGB" [color="#FF4488",href="bookvol10.4.pdf#nameddest=INTERGB"]
\end{verbatim}
This tells us the name of the node, the background color where
\begin{itemize}
\item \#4488FF is a category
\item \#88FF44 is a domain
\item \#FF4488 is a package
\item \#FF8844 is a numeric
\end{itemize}
(note the rotation of bytes) and the html link from the graph to
the position in the document so the user can click on the picture
and go to the source code. It names the book and the offset.
We have the same information for PFECAT:
\begin{verbatim}
"PFECAT" [color="#4488FF",href="bookvol10.2.pdf#nameddest=PFECAT"]
\end{verbatim}
We combine this information to create a picture file for the graphviz dot
program:
\begin{verbatim}
digraph pic {
fontsize=10;
bgcolor="#ECEA81";
node [shape=box, color=white, style=filled];
"INTERGB" [color="#FF4488",href="bookvol10.4.pdf#nameddest=INTERGB"]
"PFECAT" [color="#4488FF",href="bookvol10.2.pdf#nameddest=PFECAT"]
"INTERGB" -> "PFECAT"
}
\end{verbatim}
Save this file into \verb|$AXIOM/books/pic|. Then run:
\begin{verbatim}
dot -Tps <pic >ps/v104interfacegroebnerpackage.ps
\end{verbatim}
This will generate a postscript file
\verb|$AXIOM/books/ps/v104interfacegroebnerpackage.ps|
Note that the pagepic name should be lower case as this is the name of
a file in the file system. Axiom uses only lower case names as files
to avoid the problem of mixed-case or ambiguous case file systems.
The pagepic file is saved into a subdirectory (ps) under the books
directory. The file contains the name of the book (v104 is volume 10.4),
the name of the algebra in lowercase, and the extension of ps.
Now we modify the pagepic tag in book volume 10.4 to read:
\verb|\pagepic{ps/v104interfacegroebnerpackage.ps}{INTERGB}{1.00}|
This tells us where to find the file, what the abbreviation for the
file will be, and the scale factor to use to display the file (1.00).
We copy the body of the pic file to the book so we can easily
recreate the graphs:
\begin{verbatim}
\begin{chunk}{INTERGB.dotabb}
"INTERGB" [color="#FF4488",href="bookvol10.4.pdf#nameddest=INTERGB"]
"PFECAT" [color="#4488FF",href="bookvol10.2.pdf#nameddest=PFECAT"]
"INTERGB" -> "PFECAT"
\end{chunk}
\end{verbatim}
Next we return to the command line and get explicit information about
our new domain:
\begin{verbatim}
(1) -> )show INTERGB
InterfaceGroebnerPackage(K: Field,
symb: List Symbol,
E: OrderedAbelianMonoidSup,
OV: OrderedSet,
R: PolynomialCategory(K,E,OV))
is a package constructor
Abbreviation for InterfaceGroebnerPackage is INTERGB
This constructor is exposed in this frame.
Issue )edit /research/silver/PAFF/PAFF/spad/interGBwoGB.spad to see
algebra source code for INTERGB
------------------------------- Operations --------------------------------
groebner : List R -> List R
\end{verbatim}
We need to insert the results of this command into the trivial input file
we have created. The trivial input file will be run during build time and
the results of the command at build time will be compared with the results
we provide. The results we provide are actually comments so they begin with
two dashes, the Axiom comment character.
The regression programm (``regress'') compares each line generated by the
program with the line stored in the input file. It only compares lines that
start with ``--R''. Each test is surrounded by the comment pair ``--S m of n''
and ``--E m'' which indicates the start and end of test ``m'' respectively.
Since we will eventually compile this domain from the book the final
output line for the )edit location will be the book. Thus we need to
change the line:
\begin{verbatim}
Issue )edit /PAFF/interGBwoGB.spad to see algebra source code for INTERGB
\end{verbatim}
to read:
\begin{verbatim}
Issue )edit bookvol10.4.pamphlet to see algebra source code for INTERGB
\end{verbatim}
So we update our input file section to read:
\begin{verbatim}
)set break resume
)sys rm -f InterfaceGroebnerPackage.output
)spool InterfaceGroebnerPackage.output
)set message test on
)set message auto off
)clear all
--S 1 of 1
)show InterfaceGroebnerPackage
--R InterfaceGroebnerPackage(K: Field,
--R symb: List Symbol,
--R E: OrderedAbelianMonoidSup,
--R OV: OrderedSet,
--R R: PolynomialCategory(K,E,OV))
--R is a package constructor
--R Abbreviation for InterfaceGroebnerPackage is INTERGB
--R This constructor is exposed in this frame.
--R Issue )edit bookvol10.4.pamphlet to see algebra source code for INTERGB
--R
--R------------------------------- Operations --------------------------------
--R groebner : List R -> List R
--R
--E 1
)spool
)lisp (bye)
\end{verbatim}
There is another section, Exports, which lists all of the unique function
names exported by this algebra. Note that this list is longer than just
the functions locally defined because the algebra inherits functions.
We make a tabular environment with the number of columns specified by
the ``l'' characters (``l'' means left-justify, ``c'' would be center, and
``r'' would be right justify). We include just enough columns to keep from
overflowing the 80 column limit.
For this domain we see generate we only have a single export.
\begin{verbatim}
{\bf Exports:}\\
\cross{INTERGB}{groebner}
\end{verbatim}
The cross function creates a cross-reference entry in the index so you
can look up the function and find the domain or look up the domain and
find the function.
Now we have finished setting up the algebra.
We have to add the algebra, regression, and help information to the Makefile.
We know from above that the algebra belongs in layer 11 so we find layer 11
and add this abbreviation in alphabetical order. We can use this order since
none of the files depend on each other in this layer.
The new line looks like:
\begin{verbatim}
${OUT}/INMODGCD.o ${OUT}/INNMFACT.o ${OUT}/INPSIGN.o ${OUT}/INTERGB.o \
\end{verbatim}
Note that the trailing slash is required by the Makefile in order to continue
the input line.
Take note of the prior algebra abbreviation INPSIGN. We search for that
lower down and find the block reading:
\begin{verbatim}
"INPSIGN" [color="#FF4488",href="bookvol10.4.pdf#nameddest=INPSIGN"]
/*"INPSIGN" -> {"RING"; "RNG"; "ABELGRP"; "CABMON"; "ABELMON"; "ABELSG"}*/
/*"INPSIGN" -> {"SETCAT"; "BASTYPE"; "KOERCE"; "SGROUP"; "MONOID"}*/
/*"INPSIGN" -> {"LMODULE"; "UPOLYC"; "POLYCAT"; "PDRING"; "FAMR"; "AMR"}*/
/*"INPSIGN" -> {"BMODULE"; "RMODULE"; "COMRING"; "ALGEBRA"; "MODULE"}*/
/*"INPSIGN" -> {"CHARZ"; "CHARNZ"; "INTDOM"; "ENTIRER"; "FRETRCT"}*/
/*"INPSIGN" -> {"RETRACT"; "EVALAB"; "IEVALAB"; "FLINEXP"; "LINEXP"}*/
/*"INPSIGN" -> {"ORDSET"; "KONVERT"; "PATMAB"; "GCDDOM"}*/
"INPSIGN" -> "PFECAT"
/*"INPSIGN" -> {"UFD"; "ELTAB"; "DIFRING"; "DIFEXT"; "STEP"; "EUCDOM"}*/
/*"INPSIGN" -> {"PID"; "FIELD"; "DIVRING"; "INT"; "INS-"}*/
\end{verbatim}
This information is used to create the total graph of the algebra.
Most of this information is kept for future graph use but commented out.
We only uncomment lines that are direct dependence relationships. As you
can see from the above INPSIGN depends only on PFECAT.
First we create the signature line which is the same one used above for
the pagepic graph.
We also need to create a similar block for our code. We use the list generated
above, replacing the ``.o'' with semicolons.
The total result is:
\begin{verbatim}
"INTERGB" [color="#FF4488",href="bookvol10.4.pdf#nameddest=INTERGB"]
/*"INTERGB" -> {
/*"INTERGB" -> {"FIELD"; "EUCDOM"; "PID"; "GCDDOM"; "INTDOM"; "COMRING"}*/
/*"INTERGB" -> {"RING"; "RNG"; "ABELGRP"; "CABMON"; "ABELMON"; "ABELSG"}*/
/*"INTERGB" -> {"SETCAT"; "BASTYPE"; "KOERCE"; "SGROUP"; "MONOID"}*/
/*"INTERGB" -> {"LMODULE"; "BMODULE"; "RMODULE"; "ALGEBRA"; "MODULE"}*/
/*"INTERGB" -> {"ENTIRER"; "UFD"; "DIVRING"; "OAMONS"; "OCAMON"; "OAMON"}*/
/*"INTERGB" -> {"OASGP"; "ORDSET"; "POLYCAT"; "PDRING"; "FAMR"; "AMR"}*/
/*"INTERGB" -> {"CHARZ"; "CHARNZ"; "FRETRCT"; "RETRACT"; "EVALAB"}*/
/*"INTERGB" -> {"IEVALAB"; "FLINEXP"; "LINEXP"; "KONVERT"; "PATMAB"}*/
"INTERGB" -> "PFECAT"
/*"INTERGB" -> {"FFIELDC"; "FPC"; "FINITE"; "STEP"; "DIFRING"; "NNI"; "INT"}*/
\end{verbatim}
Help files are automatically extracted from the books using the
lisp function ``makeHelpFiles'' which lives in books/tangle.lisp.
This will find all of the .help chunks in books of interest
and write each chunk to the target directory in its own filename.
So if a chunk name is somedomain.help we create the help file
somedomain.help containing the chunk value.
Now we create the regression hook. Look for the list REGRESS and add the
line containing the algebra thus:
\begin{verbatim}
InterfaceGroebnerPackage.regress \
\end{verbatim}
This will cause regression to be run on the InterfaceGroebnerPackage.input
file.
We need to modify book volume 5 (the interpreter) to add this algebra
to the list of exposed algebra. To do this, add the line:
\begin{verbatim}
(|InterfaceGroebnerPackage| . INTERGB)
\end{verbatim}
to the variable \verb|$globalExposureGroupAlist| under the ``basic''
sublist.
Now the algebra should build and have the new algebra available.
There are ways this can fail which we will cover in more detail.
Once the code compiles cleanly there are a few ways to check that it works.
First, check that the file int/input/InterfaceGroebnerPackage.regress shows
no failures. Second, run the command
\begin{verbatim}
)show InterfaceGroebnerPackage
\end{verbatim}
to see if the domain exists. Run the command
\begin{verbatim}
)help InterfaceGroebnerPackage
\end{verbatim}
to see that the help file exists. Run the command
\begin{verbatim}
)describe InterfaceGroebnerPackage
\end{verbatim}
to see that the description paragraph exists.
\subsection{Creating a stand-alone pamphlet file}
Suppose we want to add a new algebra file from a new pamphlet.
For example, we want to add BLAS1.spad in books/newbook.pamphlet.
The explanation for the steps follow. The steps are:
\begin{enumerate}
\item write the algebra code
\item create the pamphlet file called newbook.pamphlet
\item create a new section in newbook.pamphlet
\item create the chunk name stanza in newbook.pamphlet
\item insert BLAS1.spad into the new stanza
\item create the dotabb stanza in newbook.pamphlet
\item update src/algebra/Makefile.pamphlet to insert BLAS1.spad
\item update src/algebra/Makefile.pamphlet to insert BLAS1 into graph
\item update the dotabb stanza in newbook.pamphlet
\item update src/Makefile.pamphlet to copy the newbook file to src/algebra
\item update \$globalExposureGroupAlist in bookvol5 to add BLAS1 to basic
\end{enumerate}
\section{Makefile}
This book is actually a literate program\cite{Knut92} and can contain
executable source code. In particular, the Makefile for this book
is part of the source of the book and is included below.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\cleardoublepage
\phantomsection
\addcontentsline{toc}{chapter}{Bibliography}
\bibliographystyle{axiom}
\bibliography{axiom}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\cleardoublepage
\phantomsection
\addcontentsline{toc}{chapter}{Index}
\printindex
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}
|