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 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 8728 8729 8730 8731 8732 8733 8734 8735 8736 8737 8738 8739 8740 8741 8742 8743 8744 8745 8746 8747 8748 8749 8750 8751 8752 8753 8754 8755 8756 8757 8758 8759 8760 8761 8762 8763 8764 8765 8766 8767 8768 8769 8770 8771 8772 8773 8774 8775 8776 8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 8824 8825 8826 8827 8828 8829 8830 8831 8832 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 8847 8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 8860 8861 8862 8863 8864 8865 8866 8867 8868 8869 8870 8871 8872 8873 8874 8875 8876 8877 8878 8879 8880 8881 8882 8883 8884 8885 8886 8887 8888 8889 8890 8891 8892 8893 8894 8895 8896 8897 8898 8899 8900 8901 8902 8903 8904 8905 8906 8907 8908 8909 8910 8911 8912 8913 8914 8915 8916 8917 8918 8919 8920 8921 8922 8923 8924 8925 8926 8927 8928 8929 8930 8931 8932 8933 8934 8935 8936 8937 8938 8939 8940 8941 8942 8943 8944 8945 8946 8947 8948 8949 8950 8951 8952 8953 8954 8955 8956 8957 8958 8959 8960 8961 8962 8963 8964 8965 8966 8967 8968 8969 8970 8971 8972 8973 8974 8975 8976 8977 8978 8979 8980 8981 8982 8983 8984 8985 8986 8987 8988 8989 8990 8991 8992 8993 8994 8995 8996 8997 8998 8999 9000 9001 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 9188 9189 9190 9191 9192 9193 9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 9224 9225 9226 9227 9228 9229 9230 9231 9232 9233 9234 9235 9236 9237 9238 9239 9240 9241 9242 9243 9244 9245 9246 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 9257 9258 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 9272 9273 9274 9275 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 9304 9305 9306 9307 9308 9309 9310 9311 9312 9313 9314 9315 9316 9317 9318 9319 9320 9321 9322 9323 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344 9345 9346 9347 9348 9349 9350 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 9385 9386 9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 9442 9443 9444 9445 9446 9447 9448 9449 9450 9451 9452 9453 9454 9455 9456 9457 9458 9459 9460 9461 9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 9472 9473 9474 9475 9476 9477 9478 9479 9480 9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 9500 9501 9502 9503 9504 9505 9506 9507 9508 9509 9510 9511 9512 9513 9514 9515 9516 9517 9518 9519 9520 9521 9522 9523 9524 9525 9526 9527 9528 9529 9530 9531 9532 9533 9534 9535 9536 9537 9538 9539 9540 9541 9542 9543 9544 9545 9546 9547 9548 9549 9550 9551 9552 9553 9554 9555 9556 9557 9558 9559 9560 9561 9562 9563 9564 9565 9566 9567 9568 9569 9570 9571 9572 9573 9574 9575 9576 9577 9578 9579 9580 9581 9582 9583 9584 9585 9586 9587 9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 9602 9603 9604 9605 9606 9607 9608 9609 9610 9611 9612 9613 9614 9615 9616 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 9638 9639 9640 9641 9642 9643 9644 9645 9646 9647 9648 9649 9650 9651 9652 9653 9654 9655 9656 9657 9658 9659 9660 9661 9662 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 9674 9675 9676 9677 9678 9679 9680 9681 9682 9683 9684 9685 9686 9687 9688 9689 9690 9691 9692 9693 9694 9695 9696 9697 9698 9699 9700 9701 9702 9703 9704 9705 9706 9707 9708 9709 9710 9711 9712 9713 9714 9715 9716 9717 9718 9719 9720 9721 9722 9723 9724 9725 9726 9727 9728 9729 9730 9731 9732 9733 9734 9735 9736 9737 9738 9739 9740 9741 9742 9743 9744 9745 9746 9747 9748 9749 9750 9751 9752 9753 9754 9755 9756 9757 9758 9759 9760 9761 9762 9763 9764 9765 9766 9767 9768 9769 9770 9771 9772 9773 9774 9775 9776 9777 9778 9779 9780 9781 9782 9783 9784 9785 9786 9787 9788 9789 9790 9791 9792 9793 9794 9795 9796 9797 9798 9799 9800 9801 9802 9803 9804 9805 9806 9807 9808 9809 9810 9811 9812 9813 9814 9815 9816 9817 9818 9819 9820 9821 9822 9823 9824 9825 9826 9827 9828 9829 9830 9831 9832 9833 9834 9835 9836 9837 9838 9839 9840 9841 9842 9843 9844 9845 9846 9847 9848 9849 9850 9851 9852 9853 9854 9855 9856 9857 9858 9859 9860 9861 9862 9863 9864 9865 9866 9867 9868 9869 9870 9871 9872 9873 9874 9875 9876 9877 9878 9879 9880 9881 9882 9883 9884 9885 9886 9887 9888 9889 9890 9891 9892 9893 9894 9895 9896 9897 9898 9899 9900 9901 9902 9903 9904 9905 9906 9907 9908 9909 9910 9911 9912 9913 9914 9915 9916 9917 9918 9919 9920 9921 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9954 9955 9956 9957 9958 9959 9960 9961 9962 9963 9964 9965 9966 9967 9968 9969 9970 9971 9972 9973 9974 9975 9976 9977 9978 9979 9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 9993 9994 9995 9996 9997 9998 9999 10000 10001 10002 10003 10004 10005 10006 10007 10008 10009 10010 10011 10012 10013 10014 10015 10016 10017 10018 10019 10020 10021 10022 10023 10024 10025 10026 10027 10028 10029 10030 10031 10032 10033 10034 10035 10036 10037 10038 10039 10040 10041 10042 10043 10044 10045 10046 10047 10048 10049 10050 10051 10052 10053 10054 10055 10056 10057 10058 10059 10060 10061 10062 10063 10064 10065 10066 10067 10068 10069 10070 10071 10072 10073 10074 10075 10076 10077 10078 10079 10080 10081 10082 10083 10084 10085 10086 10087 10088 10089 10090 10091 10092 10093 10094 10095 10096 10097 10098 10099 10100 10101 10102 10103 10104 10105 10106 10107 10108 10109 10110 10111 10112 10113 10114 10115 10116 10117 10118 10119 10120 10121 10122 10123 10124 10125 10126 10127 10128 10129 10130 10131 10132 10133 10134 10135 10136 10137 10138 10139 10140 10141 10142 10143 10144 10145 10146 10147 10148 10149 10150 10151 10152 10153 10154 10155 10156 10157 10158 10159 10160 10161 10162 10163 10164 10165 10166 10167 10168 10169 10170 10171 10172 10173 10174 10175 10176 10177 10178 10179 10180 10181 10182 10183 10184 10185 10186 10187 10188 10189 10190 10191 10192 10193 10194 10195 10196 10197 10198 10199 10200 10201 10202 10203 10204 10205 10206 10207 10208 10209 10210 10211 10212 10213 10214 10215 10216 10217 10218 10219 10220 10221 10222 10223 10224 10225 10226 10227 10228 10229 10230 10231 10232 10233 10234 10235 10236 10237 10238 10239 10240 10241 10242 10243 10244 10245 10246 10247 10248 10249 10250 10251 10252 10253 10254 10255 10256 10257 10258 10259 10260 10261 10262 10263 10264 10265 10266 10267 10268 10269 10270 10271 10272 10273 10274 10275 10276 10277 10278 10279 10280 10281 10282 10283 10284 10285 10286 10287 10288 10289 10290 10291 10292 10293 10294 10295 10296 10297 10298 10299 10300 10301 10302 10303 10304 10305 10306 10307 10308 10309 10310 10311 10312 10313 10314 10315 10316 10317 10318 10319 10320 10321 10322 10323 10324 10325 10326 10327 10328 10329 10330 10331 10332 10333 10334 10335 10336 10337 10338 10339 10340 10341 10342 10343 10344 10345 10346 10347 10348 10349 10350 10351 10352 10353 10354 10355 10356 10357 10358 10359 10360 10361 10362 10363 10364 10365 10366 10367 10368 10369 10370 10371 10372 10373 10374 10375 10376 10377 10378 10379 10380 10381 10382 10383 10384 10385 10386 10387 10388 10389 10390 10391 10392 10393 10394 10395 10396 10397 10398 10399 10400 10401 10402 10403 10404 10405 10406 10407 10408 10409 10410 10411 10412 10413 10414 10415 10416 10417 10418 10419 10420 10421 10422 10423 10424 10425 10426 10427 10428 10429 10430 10431 10432 10433 10434 10435 10436 10437 10438 10439 10440 10441 10442 10443 10444 10445 10446 10447 10448 10449 10450 10451 10452 10453 10454 10455 10456 10457 10458 10459 10460 10461 10462 10463 10464 10465 10466 10467 10468 10469 10470 10471 10472 10473 10474 10475 10476 10477 10478 10479 10480 10481 10482 10483 10484 10485 10486 10487 10488 10489 10490 10491 10492 10493 10494 10495 10496 10497 10498 10499 10500 10501 10502 10503 10504 10505 10506 10507 10508 10509 10510 10511 10512 10513 10514 10515 10516 10517 10518 10519 10520 10521 10522 10523 10524 10525 10526 10527 10528 10529 10530 10531 10532 10533 10534 10535 10536 10537 10538 10539 10540 10541 10542 10543 10544 10545 10546 10547 10548 10549 10550 10551 10552 10553 10554 10555 10556 10557 10558 10559 10560 10561 10562 10563 10564 10565 10566 10567 10568 10569 10570 10571 10572 10573 10574 10575 10576 10577 10578 10579 10580 10581 10582 10583 10584 10585 10586 10587 10588 10589 10590 10591 10592 10593 10594 10595 10596 10597 10598 10599 10600 10601 10602 10603 10604 10605 10606 10607 10608 10609 10610 10611 10612 10613 10614 10615 10616 10617 10618 10619 10620 10621 10622 10623 10624 10625 10626 10627 10628 10629 10630 10631 10632 10633 10634 10635 10636 10637 10638 10639 10640 10641 10642 10643 10644 10645 10646 10647 10648 10649 10650 10651 10652 10653 10654 10655 10656 10657 10658 10659 10660 10661 10662 10663 10664 10665 10666 10667 10668 10669 10670 10671 10672 10673 10674 10675 10676 10677 10678 10679 10680 10681 10682 10683 10684 10685 10686 10687 10688 10689 10690 10691 10692 10693 10694 10695 10696 10697 10698 10699 10700 10701 10702 10703 10704 10705 10706 10707 10708 10709 10710 10711 10712 10713 10714 10715 10716 10717 10718 10719 10720 10721 10722 10723 10724 10725 10726 10727 10728 10729 10730 10731 10732 10733 10734 10735 10736 10737 10738 10739 10740 10741 10742 10743 10744 10745 10746 10747 10748 10749 10750 10751 10752 10753 10754 10755 10756 10757 10758 10759 10760 10761 10762 10763 10764 10765 10766 10767 10768 10769 10770 10771 10772 10773 10774 10775 10776 10777 10778 10779 10780 10781 10782 10783 10784 10785 10786 10787 10788 10789 10790 10791 10792 10793 10794 10795 10796 10797 10798 10799 10800 10801 10802 10803 10804 10805 10806 10807 10808 10809 10810 10811 10812 10813 10814 10815 10816 10817 10818 10819 10820 10821 10822 10823 10824 10825 10826 10827 10828 10829 10830 10831 10832 10833 10834 10835 10836 10837 10838 10839 10840 10841 10842 10843 10844 10845 10846 10847 10848 10849 10850 10851 10852 10853 10854 10855 10856 10857 10858 10859 10860 10861 10862 10863 10864 10865 10866 10867 10868 10869 10870 10871 10872 10873 10874 10875 10876 10877 10878 10879 10880 10881 10882 10883 10884 10885 10886 10887 10888 10889 10890 10891 10892 10893 10894 10895 10896 10897 10898 10899 10900 10901 10902 10903 10904 10905 10906 10907 10908 10909 10910 10911 10912 10913 10914 10915 10916 10917 10918 10919 10920 10921 10922 10923 10924 10925 10926 10927 10928 10929 10930 10931 10932 10933 10934 10935 10936 10937 10938 10939 10940 10941 10942 10943 10944 10945 10946 10947 10948 10949 10950 10951 10952 10953 10954 10955 10956 10957 10958 10959 10960 10961 10962 10963 10964 10965 10966 10967 10968 10969 10970 10971 10972 10973 10974 10975 10976 10977 10978 10979 10980 10981 10982 10983 10984 10985 10986 10987 10988 10989 10990 10991 10992 10993 10994 10995 10996 10997 10998 10999 11000 11001 11002 11003 11004 11005 11006 11007 11008 11009 11010 11011 11012 11013 11014 11015 11016 11017 11018 11019 11020 11021 11022 11023 11024 11025 11026 11027 11028 11029 11030 11031 11032 11033 11034 11035 11036 11037 11038 11039 11040 11041 11042 11043 11044 11045 11046 11047 11048 11049 11050 11051 11052 11053 11054 11055 11056 11057 11058 11059 11060 11061 11062 11063 11064 11065 11066 11067 11068 11069 11070 11071 11072 11073 11074 11075 11076 11077 11078 11079 11080 11081 11082 11083 11084 11085 11086 11087 11088 11089 11090 11091 11092 11093 11094 11095 11096 11097 11098 11099 11100 11101 11102 11103 11104 11105 11106 11107 11108 11109 11110 11111 11112 11113 11114 11115 11116 11117 11118 11119 11120 11121 11122 11123 11124 11125 11126 11127 11128 11129 11130 11131 11132 11133 11134 11135 11136 11137 11138 11139 11140 11141 11142 11143 11144 11145 11146 11147 11148 11149 11150 11151 11152 11153 11154 11155 11156 11157 11158 11159 11160 11161 11162 11163 11164 11165 11166 11167 11168 11169 11170 11171 11172 11173 11174 11175 11176 11177 11178 11179 11180 11181 11182 11183 11184 11185 11186 11187 11188 11189 11190 11191 11192 11193 11194 11195 11196 11197 11198 11199 11200 11201 11202 11203 11204 11205 11206 11207 11208 11209 11210 11211 11212 11213 11214 11215 11216 11217 11218 11219 11220 11221 11222 11223 11224 11225 11226 11227 11228 11229 11230 11231 11232 11233 11234 11235 11236 11237 11238 11239 11240 11241 11242 11243 11244 11245 11246 11247 11248 11249 11250 11251 11252 11253 11254 11255 11256 11257 11258 11259 11260 11261 11262 11263 11264 11265 11266 11267 11268 11269 11270 11271 11272 11273 11274 11275 11276 11277 11278 11279 11280 11281 11282 11283 11284 11285 11286 11287 11288 11289 11290 11291 11292 11293 11294 11295 11296 11297 11298 11299 11300 11301 11302 11303 11304 11305 11306 11307 11308 11309 11310 11311 11312 11313 11314 11315 11316 11317 11318 11319 11320 11321 11322 11323 11324 11325 11326 11327 11328 11329 11330 11331 11332 11333 11334 11335 11336 11337 11338 11339 11340 11341 11342 11343 11344 11345 11346 11347 11348 11349 11350 11351 11352 11353 11354 11355 11356 11357 11358 11359 11360 11361 11362 11363 11364 11365 11366 11367 11368 11369 11370 11371 11372 11373 11374 11375 11376 11377 11378 11379 11380 11381 11382 11383 11384 11385 11386 11387 11388 11389 11390 11391 11392 11393 11394 11395 11396 11397 11398 11399 11400 11401 11402 11403 11404 11405 11406 11407 11408 11409 11410 11411 11412 11413 11414 11415 11416 11417 11418 11419 11420 11421 11422 11423 11424 11425 11426 11427 11428 11429 11430 11431 11432 11433 11434 11435 11436 11437 11438 11439 11440 11441 11442 11443 11444 11445 11446 11447 11448 11449 11450 11451 11452 11453 11454 11455 11456 11457 11458 11459 11460 11461 11462 11463 11464 11465 11466 11467 11468 11469 11470 11471 11472 11473 11474 11475 11476 11477 11478 11479 11480 11481 11482 11483 11484 11485 11486 11487 11488 11489 11490 11491 11492 11493 11494 11495 11496 11497 11498 11499 11500 11501 11502 11503 11504 11505 11506 11507 11508 11509 11510 11511 11512 11513 11514 11515 11516 11517 11518 11519 11520 11521 11522 11523 11524 11525 11526 11527 11528 11529 11530 11531 11532 11533 11534 11535 11536 11537 11538 11539 11540 11541 11542 11543 11544 11545 11546 11547 11548 11549 11550 11551 11552 11553 11554 11555 11556 11557 11558 11559 11560 11561 11562 11563 11564 11565 11566 11567 11568 11569 11570 11571 11572 11573 11574 11575 11576 11577 11578 11579 11580 11581 11582 11583 11584 11585 11586 11587 11588 11589 11590 11591 11592 11593 11594 11595 11596 11597 11598 11599 11600 11601 11602 11603 11604 11605 11606 11607 11608 11609 11610 11611 11612 11613 11614 11615 11616 11617 11618 11619 11620 11621 11622 11623 11624 11625 11626 11627 11628 11629 11630 11631 11632 11633 11634 11635 11636 11637 11638 11639 11640 11641 11642 11643 11644 11645 11646 11647 11648 11649 11650 11651 11652 11653 11654 11655 11656 11657 11658 11659 11660 11661 11662 11663 11664 11665 11666 11667 11668 11669 11670 11671 11672 11673 11674 11675 11676 11677 11678 11679 11680 11681 11682 11683 11684 11685 11686 11687 11688 11689 11690 11691 11692 11693 11694 11695 11696 11697 11698 11699 11700 11701 11702 11703 11704 11705 11706 11707 11708 11709 11710 11711 11712 11713 11714 11715 11716 11717 11718 11719 11720 11721 11722 11723 11724 11725 11726 11727 11728 11729 11730 11731 11732 11733 11734 11735 11736 11737 11738 11739 11740 11741 11742 11743 11744 11745 11746 11747 11748 11749 11750 11751 11752 11753 11754 11755 11756 11757 11758 11759 11760 11761 11762 11763 11764 11765 11766 11767 11768 11769 11770 11771 11772 11773 11774 11775 11776 11777 11778 11779 11780 11781 11782 11783 11784 11785 11786 11787 11788 11789 11790 11791 11792 11793 11794 11795 11796 11797 11798 11799 11800 11801 11802 11803 11804 11805 11806 11807 11808 11809 11810 11811 11812 11813 11814 11815 11816 11817 11818 11819 11820 11821 11822 11823 11824 11825 11826 11827 11828 11829 11830 11831 11832 11833 11834 11835 11836 11837 11838 11839 11840 11841 11842 11843 11844 11845 11846 11847 11848 11849 11850 11851 11852 11853 11854 11855 11856 11857 11858 11859 11860 11861 11862 11863 11864 11865 11866 11867 11868 11869 11870 11871 11872 11873 11874 11875 11876 11877 11878 11879 11880 11881 11882 11883 11884 11885 11886 11887 11888 11889 11890 11891 11892 11893 11894 11895 11896 11897 11898 11899 11900 11901 11902 11903 11904 11905 11906 11907 11908 11909 11910 11911 11912 11913 11914 11915 11916 11917 11918 11919 11920 11921 11922 11923 11924 11925 11926 11927 11928 11929 11930 11931 11932 11933 11934 11935 11936 11937 11938 11939 11940 11941 11942 11943 11944 11945 11946 11947 11948 11949 11950 11951 11952 11953 11954 11955 11956 11957 11958 11959 11960 11961 11962 11963 11964 11965 11966 11967 11968 11969 11970 11971 11972 11973 11974 11975 11976 11977 11978 11979 11980 11981 11982 11983 11984 11985 11986 11987 11988 11989 11990 11991 11992 11993 11994 11995 11996 11997 11998 11999 12000 12001 12002 12003 12004 12005 12006 12007 12008 12009 12010 12011 12012 12013 12014 12015 12016 12017 12018 12019 12020 12021 12022 12023 12024 12025 12026 12027 12028 12029 12030 12031 12032 12033 12034 12035 12036 12037 12038 12039 12040 12041 12042 12043 12044 12045 12046 12047 12048 12049 12050 12051 12052 12053 12054 12055 12056 12057 12058 12059 12060 12061 12062 12063 12064 12065 12066 12067 12068 12069 12070 12071 12072 12073 12074 12075 12076 12077 12078 12079 12080 12081 12082 12083 12084 12085 12086 12087 12088 12089 12090 12091 12092 12093 12094 12095 12096 12097 12098 12099 12100 12101 12102 12103 12104 12105 12106 12107 12108 12109 12110 12111 12112 12113 12114 12115 12116 12117 12118 12119 12120 12121 12122 12123 12124 12125 12126 12127 12128 12129 12130 12131 12132 12133 12134 12135 12136 12137 12138 12139 12140 12141 12142 12143 12144 12145 12146 12147 12148 12149 12150 12151 12152 12153 12154 12155 12156 12157 12158 12159 12160 12161 12162 12163 12164 12165 12166 12167 12168 12169 12170 12171 12172 12173 12174 12175 12176 12177 12178 12179 12180 12181 12182 12183 12184 12185 12186 12187 12188 12189 12190 12191 12192 12193 12194 12195 12196 12197 12198 12199 12200 12201 12202 12203 12204 12205 12206 12207 12208 12209 12210 12211 12212 12213 12214 12215 12216 12217 12218 12219 12220 12221 12222 12223 12224 12225 12226 12227 12228 12229 12230 12231 12232 12233 12234 12235 12236 12237 12238 12239 12240 12241 12242 12243 12244 12245 12246 12247 12248 12249 12250 12251 12252 12253 12254 12255 12256 12257 12258 12259 12260 12261 12262 12263 12264 12265 12266 12267 12268 12269 12270 12271 12272 12273 12274 12275 12276 12277 12278 12279 12280 12281 12282 12283 12284 12285 12286 12287 12288 12289 12290 12291 12292 12293 12294 12295 12296 12297 12298 12299 12300 12301 12302 12303 12304 12305 12306 12307 12308 12309 12310 12311 12312 12313 12314 12315 12316 12317 12318 12319 12320 12321 12322 12323 12324 12325 12326 12327 12328 12329 12330 12331 12332 12333 12334 12335 12336 12337 12338 12339 12340 12341 12342 12343 12344 12345 12346 12347 12348 12349 12350 12351 12352 12353 12354 12355 12356 12357 12358 12359 12360 12361 12362 12363 12364 12365 12366 12367 12368 12369 12370 12371 12372 12373 12374 12375 12376 12377 12378 12379 12380 12381 12382 12383 12384 12385 12386 12387 12388 12389 12390 12391 12392 12393 12394 12395 12396 12397 12398 12399 12400 12401 12402 12403 12404 12405 12406 12407 12408 12409 12410 12411 12412 12413 12414 12415 12416 12417 12418 12419 12420 12421 12422 12423 12424 12425 12426 12427 12428 12429 12430 12431 12432 12433 12434 12435 12436 12437 12438 12439 12440 12441 12442 12443 12444 12445 12446 12447 12448 12449 12450 12451 12452 12453 12454 12455 12456 12457 12458 12459 12460 12461 12462 12463 12464 12465 12466 12467 12468 12469 12470 12471 12472 12473 12474 12475 12476 12477 12478 12479 12480 12481 12482 12483 12484 12485 12486 12487 12488 12489 12490 12491 12492 12493 12494 12495 12496 12497 12498 12499 12500 12501 12502 12503 12504 12505 12506 12507 12508 12509 12510 12511 12512 12513 12514 12515 12516 12517 12518 12519 12520 12521 12522 12523 12524 12525 12526 12527 12528 12529 12530 12531 12532 12533 12534 12535 12536 12537 12538 12539 12540 12541 12542 12543 12544 12545 12546 12547 12548 12549 12550 12551 12552 12553 12554 12555 12556 12557 12558 12559 12560 12561 12562 12563 12564 12565 12566 12567 12568 12569 12570 12571 12572 12573 12574 12575 12576 12577 12578 12579 12580 12581 12582 12583 12584 12585 12586 12587 12588 12589 12590 12591 12592 12593 12594 12595 12596 12597 12598 12599 12600 12601 12602 12603 12604 12605 12606 12607 12608 12609 12610 12611 12612 12613 12614 12615 12616 12617 12618 12619 12620 12621 12622 12623 12624 12625 12626 12627 12628 12629 12630 12631 12632 12633 12634 12635 12636 12637 12638 12639 12640 12641 12642 12643 12644 12645 12646 12647 12648 12649 12650 12651 12652 12653 12654 12655 12656 12657 12658 12659 12660 12661 12662 12663 12664 12665 12666 12667 12668 12669 12670 12671 12672 12673 12674 12675 12676 12677 12678 12679 12680 12681 12682 12683 12684 12685 12686 12687 12688 12689 12690 12691 12692 12693 12694 12695 12696 12697 12698 12699 12700 12701 12702 12703 12704 12705 12706 12707 12708 12709 12710 12711 12712 12713 12714 12715 12716 12717 12718 12719 12720 12721 12722 12723 12724 12725 12726 12727 12728 12729 12730 12731 12732 12733 12734 12735 12736 12737 12738 12739 12740 12741 12742 12743 12744 12745 12746 12747 12748 12749 12750 12751 12752 12753 12754 12755 12756 12757 12758 12759 12760 12761 12762 12763 12764 12765 12766 12767 12768 12769 12770 12771 12772 12773 12774 12775 12776 12777 12778 12779 12780 12781 12782 12783 12784 12785 12786 12787 12788 12789 12790 12791 12792 12793 12794 12795 12796 12797 12798 12799 12800 12801 12802 12803 12804 12805 12806 12807 12808 12809 12810 12811 12812 12813 12814 12815 12816 12817 12818 12819 12820 12821 12822 12823 12824 12825 12826 12827 12828 12829 12830 12831 12832 12833 12834 12835 12836 12837 12838 12839 12840 12841 12842 12843 12844 12845 12846 12847 12848 12849 12850 12851 12852 12853 12854 12855 12856 12857 12858 12859 12860 12861 12862 12863 12864 12865 12866 12867 12868 12869 12870 12871 12872 12873 12874 12875 12876 12877 12878 12879 12880 12881 12882 12883 12884 12885 12886 12887 12888 12889 12890 12891 12892 12893 12894 12895 12896 12897 12898 12899 12900 12901 12902 12903 12904 12905 12906 12907 12908 12909 12910 12911 12912 12913 12914 12915 12916 12917 12918 12919 12920 12921 12922 12923 12924 12925 12926 12927 12928 12929 12930 12931 12932 12933 12934 12935 12936 12937 12938 12939 12940 12941 12942 12943 12944 12945 12946 12947 12948 12949 12950 12951 12952 12953 12954 12955 12956 12957 12958 12959 12960 12961 12962 12963 12964 12965 12966 12967 12968 12969 12970 12971 12972 12973 12974 12975 12976 12977 12978 12979 12980 12981 12982 12983 12984 12985 12986 12987 12988 12989 12990 12991 12992 12993 12994 12995 12996 12997 12998 12999 13000 13001 13002 13003 13004 13005 13006 13007 13008 13009 13010 13011 13012 13013 13014 13015 13016 13017 13018 13019 13020 13021 13022 13023 13024 13025 13026 13027 13028 13029 13030 13031 13032 13033 13034 13035 13036 13037 13038 13039 13040 13041 13042 13043 13044 13045 13046 13047 13048 13049 13050 13051 13052 13053 13054 13055 13056 13057 13058 13059 13060 13061 13062 13063 13064 13065 13066 13067 13068 13069 13070 13071 13072 13073 13074 13075 13076 13077 13078 13079 13080 13081 13082 13083 13084 13085 13086 13087 13088 13089 13090 13091 13092 13093 13094 13095 13096 13097 13098 13099 13100 13101 13102 13103 13104 13105 13106 13107 13108 13109 13110 13111 13112 13113 13114 13115 13116 13117 13118 13119 13120 13121 13122 13123 13124 13125 13126 13127 13128 13129 13130 13131 13132 13133 13134 13135 13136 13137 13138 13139 13140 13141 13142 13143 13144 13145 13146 13147 13148 13149 13150 13151 13152 13153 13154 13155 13156 13157 13158 13159 13160 13161 13162 13163 13164 13165 13166 13167 13168 13169 13170 13171 13172 13173 13174 13175 13176 13177 13178 13179 13180 13181 13182 13183 13184 13185 13186 13187 13188 13189 13190 13191 13192 13193 13194 13195 13196 13197 13198 13199 13200 13201 13202 13203 13204 13205 13206 13207 13208 13209 13210 13211 13212 13213 13214 13215 13216 13217 13218 13219 13220 13221 13222 13223 13224 13225 13226 13227 13228 13229 13230 13231 13232 13233 13234 13235 13236 13237 13238 13239 13240 13241 13242 13243 13244 13245 13246 13247 13248 13249 13250 13251 13252 13253 13254 13255 13256 13257 13258 13259 13260 13261 13262 13263 13264 13265 13266 13267 13268 13269 13270 13271 13272 13273 13274 13275 13276 13277 13278 13279 13280 13281 13282 13283 13284 13285 13286 13287 13288 13289 13290 13291 13292 13293 13294 13295 13296 13297 13298 13299 13300 13301 13302 13303 13304 13305 13306 13307 13308 13309 13310 13311 13312 13313 13314 13315 13316 13317 13318 13319 13320 13321 13322 13323 13324 13325 13326 13327 13328 13329 13330 13331 13332 13333 13334 13335 13336 13337 13338 13339 13340 13341 13342 13343 13344 13345 13346 13347 13348 13349 13350 13351 13352 13353 13354 13355 13356 13357 13358 13359 13360 13361 13362 13363 13364 13365 13366 13367 13368 13369 13370 13371 13372 13373 13374 13375 13376 13377 13378 13379 13380 13381 13382 13383 13384 13385 13386 13387 13388 13389 13390 13391 13392 13393 13394 13395 13396 13397 13398 13399 13400 13401 13402 13403 13404 13405 13406 13407 13408 13409 13410 13411 13412 13413 13414 13415 13416 13417 13418 13419 13420 13421 13422 13423 13424 13425 13426 13427 13428 13429 13430 13431 13432 13433 13434 13435 13436 13437 13438 13439 13440 13441 13442 13443 13444 13445 13446 13447 13448 13449 13450 13451 13452 13453 13454 13455 13456 13457 13458 13459 13460 13461 13462 13463 13464 13465 13466 13467 13468 13469 13470 13471 13472 13473 13474 13475 13476 13477 13478 13479 13480 13481 13482 13483 13484 13485 13486 13487 13488 13489 13490 13491 13492 13493 13494 13495 13496 13497 13498 13499 13500 13501 13502 13503 13504 13505 13506 13507 13508 13509 13510 13511 13512 13513 13514 13515 13516 13517 13518 13519 13520 13521 13522 13523 13524 13525 13526 13527 13528 13529 13530 13531 13532 13533 13534 13535 13536 13537 13538 13539 13540 13541 13542 13543 13544 13545 13546 13547 13548 13549 13550 13551 13552 13553 13554 13555 13556 13557 13558 13559 13560 13561 13562 13563 13564 13565 13566 13567 13568 13569 13570 13571 13572 13573 13574 13575 13576 13577 13578 13579 13580 13581 13582 13583 13584 13585 13586 13587 13588 13589 13590 13591 13592 13593 13594 13595 13596 13597 13598 13599 13600 13601 13602 13603 13604 13605 13606 13607 13608 13609 13610 13611 13612 13613 13614 13615 13616 13617 13618 13619 13620 13621 13622 13623 13624 13625 13626 13627 13628 13629 13630 13631 13632 13633 13634 13635 13636 13637 13638 13639 13640 13641 13642 13643 13644 13645 13646 13647 13648 13649 13650 13651 13652 13653 13654 13655 13656 13657 13658 13659 13660 13661 13662 13663 13664 13665 13666 13667 13668 13669 13670 13671 13672 13673 13674 13675 13676 13677 13678 13679 13680 13681 13682 13683 13684 13685 13686 13687 13688 13689 13690 13691 13692 13693 13694 13695 13696 13697 13698 13699 13700 13701 13702 13703 13704 13705 13706 13707 13708 13709 13710 13711 13712 13713 13714 13715 13716 13717 13718 13719 13720 13721 13722 13723 13724 13725 13726 13727 13728 13729 13730 13731 13732 13733 13734 13735 13736 13737 13738 13739 13740 13741 13742 13743 13744 13745 13746 13747 13748 13749 13750 13751 13752 13753 13754 13755 13756 13757 13758 13759 13760 13761 13762 13763 13764 13765 13766 13767 13768 13769 13770 13771 13772 13773 13774 13775 13776 13777 13778 13779 13780 13781 13782 13783 13784 13785 13786 13787 13788 13789 13790 13791 13792 13793 13794 13795 13796 13797 13798 13799 13800 13801 13802 13803 13804 13805 13806 13807 13808 13809 13810 13811 13812 13813 13814 13815 13816 13817 13818 13819 13820 13821 13822 13823 13824 13825 13826 13827 13828 13829 13830 13831 13832 13833 13834 13835 13836 13837 13838 13839 13840 13841 13842 13843 13844 13845 13846 13847 13848 13849 13850 13851 13852 13853 13854 13855 13856 13857 13858 13859 13860 13861 13862 13863 13864 13865 13866 13867 13868 13869 13870 13871 13872 13873 13874 13875 13876 13877 13878 13879 13880 13881 13882 13883 13884 13885 13886 13887 13888 13889 13890 13891 13892 13893 13894 13895 13896 13897 13898 13899 13900 13901 13902 13903 13904 13905 13906 13907 13908 13909 13910 13911 13912 13913 13914 13915 13916 13917 13918 13919 13920 13921 13922 13923 13924 13925 13926 13927 13928 13929 13930 13931 13932 13933 13934 13935 13936 13937 13938 13939 13940 13941 13942 13943 13944 13945 13946 13947 13948 13949 13950 13951 13952 13953 13954 13955 13956 13957 13958 13959 13960 13961 13962 13963 13964 13965 13966 13967 13968 13969 13970 13971 13972 13973 13974 13975 13976 13977 13978 13979 13980 13981 13982 13983 13984 13985 13986 13987 13988 13989 13990 13991 13992 13993 13994 13995 13996 13997 13998 13999 14000 14001 14002 14003 14004 14005 14006 14007 14008 14009 14010 14011 14012 14013 14014 14015 14016 14017 14018 14019 14020 14021 14022 14023 14024 14025 14026 14027 14028 14029 14030 14031 14032 14033 14034 14035 14036 14037 14038 14039 14040 14041 14042 14043 14044 14045 14046 14047 14048 14049 14050 14051 14052 14053 14054 14055 14056 14057 14058 14059 14060 14061 14062 14063 14064 14065 14066 14067 14068 14069 14070 14071 14072 14073 14074 14075 14076 14077 14078 14079 14080 14081 14082 14083 14084 14085 14086 14087 14088 14089 14090 14091 14092 14093 14094 14095 14096 14097 14098 14099 14100 14101 14102 14103 14104 14105 14106 14107 14108 14109 14110 14111 14112 14113 14114 14115 14116 14117 14118 14119 14120 14121 14122 14123 14124 14125 14126 14127 14128 14129 14130 14131 14132 14133 14134 14135 14136 14137 14138 14139 14140 14141 14142 14143 14144 14145 14146 14147 14148 14149 14150 14151 14152 14153 14154 14155 14156 14157 14158 14159 14160 14161 14162 14163 14164 14165 14166 14167 14168 14169 14170 14171 14172 14173 14174 14175 14176 14177 14178 14179 14180 14181 14182 14183 14184 14185 14186 14187 14188 14189 14190 14191 14192 14193 14194 14195 14196 14197 14198 14199 14200 14201 14202 14203 14204 14205 14206 14207 14208 14209 14210 14211 14212 14213 14214 14215 14216 14217 14218 14219 14220 14221 14222 14223 14224 14225 14226 14227 14228 14229 14230 14231 14232 14233 14234 14235 14236 14237 14238 14239 14240 14241 14242 14243 14244 14245 14246 14247 14248 14249 14250 14251 14252 14253 14254 14255 14256 14257 14258 14259 14260 14261 14262 14263 14264 14265 14266 14267 14268 14269 14270 14271 14272 14273 14274 14275 14276 14277 14278 14279 14280 14281 14282 14283 14284 14285 14286 14287 14288 14289 14290 14291 14292 14293 14294 14295 14296 14297 14298 14299 14300 14301 14302 14303 14304 14305 14306 14307 14308 14309 14310 14311 14312 14313 14314 14315 14316 14317 14318 14319 14320 14321 14322 14323 14324 14325 14326 14327 14328 14329 14330 14331 14332 14333 14334 14335 14336 14337 14338 14339 14340 14341 14342 14343 14344 14345 14346 14347 14348 14349 14350 14351 14352 14353 14354 14355 14356 14357 14358 14359 14360 14361 14362 14363 14364 14365 14366 14367 14368 14369 14370 14371 14372 14373 14374 14375 14376 14377 14378 14379 14380 14381 14382 14383 14384 14385 14386 14387 14388 14389 14390 14391 14392 14393 14394 14395 14396 14397 14398 14399 14400 14401 14402 14403 14404 14405 14406 14407 14408 14409 14410 14411 14412 14413 14414 14415 14416 14417 14418 14419 14420 14421 14422 14423 14424 14425 14426 14427 14428 14429 14430 14431 14432 14433 14434 14435 14436 14437 14438 14439 14440 14441 14442 14443 14444 14445 14446 14447 14448 14449 14450 14451 14452 14453 14454 14455 14456 14457 14458 14459 14460 14461 14462 14463 14464 14465 14466 14467 14468 14469 14470 14471 14472 14473 14474 14475 14476 14477 14478 14479 14480 14481 14482 14483 14484 14485 14486 14487 14488 14489 14490 14491 14492 14493 14494 14495 14496 14497 14498 14499 14500 14501 14502 14503 14504 14505 14506 14507 14508 14509 14510 14511 14512 14513 14514 14515 14516 14517 14518 14519 14520 14521 14522 14523 14524 14525 14526 14527 14528 14529 14530 14531 14532 14533 14534 14535 14536 14537 14538 14539 14540 14541 14542 14543 14544 14545 14546 14547 14548 14549 14550 14551 14552 14553 14554 14555 14556 14557 14558 14559 14560 14561 14562 14563 14564 14565 14566 14567 14568 14569 14570 14571 14572 14573 14574 14575 14576 14577 14578 14579 14580 14581 14582 14583 14584 14585 14586 14587 14588 14589 14590 14591 14592 14593 14594 14595 14596 14597 14598 14599 14600 14601 14602 14603 14604 14605 14606 14607 14608 14609 14610 14611 14612 14613 14614 14615 14616 14617 14618 14619 14620 14621 14622 14623 14624 14625 14626 14627 14628 14629 14630 14631 14632 14633 14634 14635 14636 14637 14638 14639 14640 14641 14642 14643 14644 14645 14646 14647 14648 14649 14650 14651 14652 14653 14654 14655 14656 14657 14658 14659 14660 14661 14662 14663 14664 14665 14666 14667 14668 14669 14670 14671 14672 14673 14674 14675 14676 14677 14678 14679 14680 14681 14682 14683 14684 14685 14686 14687 14688 14689 14690 14691 14692 14693 14694 14695 14696 14697 14698 14699 14700 14701 14702 14703 14704 14705 14706 14707 14708 14709 14710 14711 14712 14713 14714 14715 14716 14717 14718 14719 14720 14721 14722 14723 14724 14725 14726 14727 14728 14729 14730 14731 14732 14733 14734 14735 14736 14737 14738 14739 14740 14741 14742 14743 14744 14745 14746 14747 14748 14749 14750 14751 14752 14753 14754 14755 14756 14757 14758 14759 14760 14761 14762 14763 14764 14765 14766 14767 14768 14769 14770 14771 14772 14773 14774 14775 14776 14777 14778 14779 14780 14781 14782 14783 14784 14785 14786 14787 14788 14789 14790 14791 14792 14793 14794 14795 14796 14797 14798 14799 14800 14801 14802 14803 14804 14805 14806 14807 14808 14809 14810 14811 14812 14813 14814 14815 14816 14817 14818 14819 14820 14821 14822 14823 14824 14825 14826 14827 14828 14829 14830 14831 14832 14833 14834 14835 14836 14837 14838 14839 14840 14841 14842 14843 14844 14845 14846 14847 14848 14849 14850 14851 14852 14853 14854 14855 14856 14857 14858 14859 14860 14861 14862 14863 14864 14865 14866 14867 14868 14869 14870 14871 14872 14873 14874 14875 14876 14877 14878 14879 14880 14881 14882 14883 14884 14885 14886 14887 14888 14889 14890 14891 14892 14893 14894 14895 14896 14897 14898 14899 14900 14901 14902 14903 14904 14905 14906 14907 14908 14909 14910 14911 14912 14913 14914 14915 14916 14917 14918 14919 14920 14921 14922 14923 14924 14925 14926 14927 14928 14929 14930 14931 14932 14933 14934 14935 14936 14937 14938 14939 14940 14941 14942 14943 14944 14945 14946 14947 14948 14949 14950 14951 14952 14953 14954 14955 14956 14957 14958 14959 14960 14961 14962 14963 14964 14965 14966 14967 14968 14969 14970 14971 14972 14973 14974 14975 14976 14977 14978 14979 14980 14981 14982 14983 14984 14985 14986 14987 14988 14989 14990 14991 14992 14993 14994 14995 14996 14997 14998 14999 15000 15001 15002 15003 15004 15005 15006 15007 15008 15009 15010 15011 15012 15013 15014 15015 15016 15017 15018 15019 15020 15021 15022 15023 15024 15025 15026 15027 15028 15029 15030 15031 15032 15033 15034 15035 15036 15037 15038 15039 15040 15041 15042 15043 15044 15045 15046 15047 15048 15049 15050 15051 15052 15053 15054 15055 15056 15057 15058 15059 15060 15061 15062 15063 15064 15065 15066 15067 15068 15069 15070 15071 15072 15073 15074 15075 15076 15077 15078 15079 15080 15081 15082 15083 15084 15085 15086 15087 15088 15089 15090 15091 15092 15093 15094 15095 15096 15097 15098 15099 15100 15101 15102 15103 15104 15105 15106 15107 15108 15109 15110 15111 15112 15113 15114 15115 15116 15117 15118 15119 15120 15121 15122 15123 15124 15125 15126 15127 15128 15129 15130 15131 15132 15133 15134 15135 15136 15137 15138 15139 15140 15141 15142 15143 15144 15145 15146 15147 15148 15149 15150 15151 15152 15153 15154 15155 15156 15157 15158 15159 15160 15161 15162 15163 15164 15165 15166 15167 15168 15169 15170 15171 15172 15173 15174 15175 15176 15177 15178 15179 15180 15181 15182 15183 15184 15185 15186 15187 15188 15189 15190 15191 15192 15193 15194 15195 15196 15197 15198 15199 15200 15201 15202 15203 15204 15205 15206 15207 15208 15209 15210 15211 15212 15213 15214 15215 15216 15217 15218 15219 15220 15221 15222 15223 15224 15225 15226 15227 15228 15229 15230 15231 15232 15233 15234 15235 15236 15237 15238 15239 15240 15241 15242 15243 15244 15245 15246 15247 15248 15249 15250 15251 15252 15253 15254 15255 15256 15257 15258 15259 15260 15261 15262 15263 15264 15265 15266 15267 15268 15269 15270 15271 15272 15273 15274 15275 15276 15277 15278 15279 15280 15281 15282 15283 15284 15285 15286 15287 15288 15289 15290 15291 15292 15293 15294 15295 15296 15297 15298 15299 15300 15301 15302 15303 15304 15305 15306 15307 15308 15309 15310 15311 15312 15313 15314 15315 15316 15317 15318 15319 15320 15321 15322 15323 15324 15325 15326 15327 15328 15329 15330 15331 15332 15333 15334 15335 15336 15337 15338 15339 15340 15341 15342 15343 15344 15345 15346 15347 15348 15349 15350 15351 15352 15353 15354 15355 15356 15357 15358 15359 15360 15361 15362 15363 15364 15365 15366 15367 15368 15369 15370 15371 15372 15373 15374 15375 15376 15377 15378 15379 15380 15381 15382 15383 15384 15385 15386 15387 15388 15389 15390 15391 15392 15393 15394 15395 15396 15397 15398 15399 15400 15401 15402 15403 15404 15405 15406 15407 15408 15409 15410 15411 15412 15413 15414 15415 15416 15417 15418 15419 15420 15421 15422 15423 15424 15425 15426 15427 15428 15429 15430 15431 15432 15433 15434 15435 15436 15437 15438 15439 15440 15441 15442 15443 15444 15445 15446 15447 15448 15449 15450 15451 15452 15453 15454 15455 15456 15457 15458 15459 15460 15461 15462 15463 15464 15465 15466 15467 15468 15469 15470 15471 15472 15473 15474 15475 15476 15477 15478 15479 15480 15481 15482 15483 15484 15485 15486 15487 15488 15489 15490 15491 15492 15493 15494 15495 15496 15497 15498 15499 15500 15501 15502 15503 15504 15505 15506 15507 15508 15509 15510 15511 15512 15513 15514 15515 15516 15517 15518 15519 15520 15521 15522 15523 15524 15525 15526 15527 15528 15529 15530 15531 15532 15533 15534 15535 15536 15537 15538 15539 15540 15541 15542 15543 15544 15545 15546 15547 15548 15549 15550 15551 15552 15553 15554 15555 15556 15557 15558 15559 15560 15561 15562 15563 15564 15565 15566 15567 15568 15569 15570 15571 15572 15573 15574 15575 15576 15577 15578 15579 15580 15581 15582 15583 15584 15585 15586 15587 15588 15589 15590 15591 15592 15593 15594 15595 15596 15597 15598 15599 15600 15601 15602 15603 15604 15605 15606 15607 15608 15609 15610 15611 15612 15613 15614 15615 15616 15617 15618 15619 15620 15621 15622 15623 15624 15625 15626 15627 15628 15629 15630 15631 15632 15633 15634 15635 15636 15637 15638 15639 15640 15641 15642 15643 15644 15645 15646 15647 15648 15649 15650 15651 15652 15653 15654 15655 15656 15657 15658 15659 15660 15661 15662 15663 15664 15665 15666 15667 15668 15669 15670 15671 15672 15673 15674 15675 15676 15677 15678 15679 15680 15681 15682 15683 15684 15685 15686 15687 15688 15689 15690 15691 15692 15693 15694 15695 15696 15697 15698 15699 15700 15701 15702 15703 15704 15705 15706 15707 15708 15709 15710 15711 15712 15713 15714 15715 15716 15717 15718 15719 15720 15721 15722 15723 15724 15725 15726 15727 15728 15729 15730 15731 15732 15733 15734 15735 15736 15737 15738 15739 15740 15741 15742 15743 15744 15745 15746 15747 15748 15749 15750 15751 15752 15753 15754 15755 15756 15757 15758 15759 15760 15761 15762 15763 15764 15765 15766 15767 15768 15769 15770 15771 15772 15773 15774 15775 15776 15777 15778 15779 15780 15781 15782 15783 15784 15785 15786 15787 15788 15789 15790 15791 15792 15793 15794 15795 15796 15797 15798 15799 15800 15801 15802 15803 15804 15805 15806 15807 15808 15809 15810 15811 15812 15813 15814 15815 15816 15817 15818 15819 15820 15821 15822 15823 15824 15825 15826 15827 15828 15829 15830 15831 15832 15833 15834 15835 15836 15837 15838 15839 15840 15841 15842 15843 15844 15845 15846 15847 15848 15849 15850 15851 15852 15853 15854 15855 15856 15857 15858 15859 15860 15861 15862 15863 15864 15865 15866 15867 15868 15869 15870 15871 15872 15873 15874 15875 15876 15877 15878 15879 15880 15881 15882 15883 15884 15885 15886 15887 15888 15889 15890 15891 15892 15893 15894 15895 15896 15897 15898 15899 15900 15901 15902 15903 15904 15905 15906 15907 15908 15909 15910 15911 15912 15913 15914 15915 15916 15917 15918 15919 15920 15921 15922 15923 15924 15925 15926 15927 15928 15929 15930 15931 15932 15933 15934 15935 15936 15937 15938 15939 15940 15941 15942 15943 15944 15945 15946 15947 15948 15949 15950 15951 15952 15953 15954 15955 15956 15957 15958 15959 15960 15961 15962 15963 15964 15965 15966 15967 15968 15969 15970 15971 15972 15973 15974 15975 15976 15977 15978 15979 15980 15981 15982 15983 15984 15985 15986 15987 15988 15989 15990 15991 15992 15993 15994 15995 15996 15997 15998 15999 16000 16001 16002 16003 16004 16005 16006 16007 16008 16009 16010 16011 16012 16013 16014 16015 16016 16017 16018 16019 16020 16021 16022 16023 16024 16025 16026 16027 16028 16029 16030 16031 16032 16033 16034 16035 16036 16037 16038 16039 16040 16041 16042 16043 16044 16045 16046 16047 16048 16049 16050 16051 16052 16053 16054 16055 16056 16057 16058 16059 16060 16061 16062 16063 16064 16065 16066 16067 16068 16069 16070 16071 16072 16073 16074 16075 16076 16077 16078 16079 16080 16081 16082 16083 16084 16085 16086 16087 16088 16089 16090 16091 16092 16093 16094 16095 16096 16097 16098 16099 16100 16101 16102 16103 16104 16105 16106 16107 16108 16109 16110 16111 16112 16113 16114 16115 16116 16117 16118 16119 16120 16121 16122 16123 16124 16125 16126 16127 16128 16129 16130 16131 16132 16133 16134 16135 16136 16137 16138 16139 16140 16141 16142 16143 16144 16145 16146 16147 16148 16149 16150 16151 16152 16153 16154 16155 16156 16157 16158 16159 16160 16161 16162 16163 16164 16165 16166 16167 16168 16169 16170 16171 16172 16173 16174 16175 16176 16177 16178 16179 16180 16181 16182 16183 16184 16185 16186 16187 16188 16189 16190 16191 16192 16193 16194 16195 16196 16197 16198 16199 16200 16201 16202 16203 16204 16205 16206 16207 16208 16209 16210 16211 16212 16213 16214 16215 16216 16217 16218 16219 16220 16221 16222 16223 16224 16225 16226 16227 16228 16229 16230 16231 16232 16233 16234 16235 16236 16237 16238 16239 16240 16241 16242 16243 16244 16245 16246 16247 16248 16249 16250 16251 16252 16253 16254 16255 16256 16257 16258 16259 16260 16261 16262 16263 16264 16265 16266 16267 16268 16269 16270 16271 16272 16273 16274 16275 16276 16277 16278 16279 16280 16281 16282 16283 16284 16285 16286 16287 16288 16289 16290 16291 16292 16293 16294 16295 16296 16297 16298 16299 16300 16301 16302 16303 16304 16305 16306 16307 16308 16309 16310 16311 16312 16313 16314 16315 16316 16317 16318 16319 16320 16321 16322 16323 16324 16325 16326 16327 16328 16329 16330 16331 16332 16333 16334 16335 16336 16337 16338 16339 16340 16341 16342 16343 16344 16345 16346 16347 16348 16349 16350 16351 16352 16353 16354 16355 16356 16357 16358 16359 16360 16361 16362 16363 16364 16365 16366 16367 16368 16369 16370 16371 16372 16373 16374 16375 16376 16377 16378 16379 16380 16381 16382 16383 16384 16385 16386 16387 16388 16389 16390 16391 16392 16393 16394 16395 16396 16397 16398 16399 16400 16401 16402 16403 16404 16405 16406 16407 16408 16409 16410 16411 16412 16413 16414 16415 16416 16417 16418 16419 16420 16421 16422 16423 16424 16425 16426 16427 16428 16429 16430 16431 16432 16433 16434 16435 16436 16437 16438 16439 16440 16441 16442 16443 16444 16445 16446 16447 16448 16449 16450 16451 16452 16453 16454 16455 16456 16457 16458 16459 16460 16461 16462 16463 16464 16465 16466 16467 16468 16469 16470 16471 16472 16473 16474 16475 16476 16477 16478 16479 16480 16481 16482 16483 16484 16485 16486 16487 16488 16489 16490 16491 16492 16493 16494 16495 16496 16497 16498 16499 16500 16501 16502 16503 16504 16505 16506 16507 16508 16509 16510 16511 16512 16513 16514 16515 16516 16517 16518 16519 16520 16521 16522 16523 16524 16525 16526 16527 16528 16529 16530 16531 16532 16533 16534 16535 16536 16537 16538 16539 16540 16541 16542 16543 16544 16545 16546 16547 16548 16549 16550 16551 16552 16553 16554 16555 16556 16557 16558 16559 16560 16561 16562 16563 16564 16565 16566 16567 16568 16569 16570 16571 16572 16573 16574 16575 16576 16577 16578 16579 16580 16581 16582 16583 16584 16585 16586 16587 16588 16589 16590 16591 16592 16593 16594 16595 16596 16597 16598 16599 16600 16601 16602 16603 16604 16605 16606 16607 16608 16609 16610 16611 16612 16613 16614 16615 16616 16617 16618 16619 16620 16621 16622 16623 16624 16625 16626 16627 16628 16629 16630 16631 16632 16633 16634 16635 16636 16637 16638 16639 16640 16641 16642 16643 16644 16645 16646 16647 16648 16649 16650 16651 16652 16653 16654 16655 16656 16657 16658 16659 16660 16661 16662 16663 16664 16665 16666 16667 16668 16669 16670 16671 16672 16673 16674 16675 16676 16677 16678 16679 16680 16681 16682 16683 16684 16685 16686 16687 16688 16689 16690 16691 16692 16693 16694 16695 16696 16697 16698 16699 16700 16701 16702 16703 16704 16705 16706 16707 16708 16709 16710 16711 16712 16713 16714 16715 16716 16717 16718 16719 16720 16721 16722 16723 16724 16725 16726 16727 16728 16729 16730 16731 16732 16733 16734 16735 16736 16737 16738 16739 16740 16741 16742 16743 16744 16745 16746 16747 16748 16749 16750 16751 16752 16753 16754 16755 16756 16757 16758 16759 16760 16761 16762 16763 16764 16765 16766 16767 16768 16769 16770 16771 16772 16773 16774 16775 16776 16777 16778 16779 16780 16781 16782 16783 16784 16785 16786 16787 16788 16789 16790 16791 16792 16793 16794 16795 16796 16797 16798 16799 16800 16801 16802 16803 16804 16805 16806 16807 16808 16809 16810 16811 16812 16813 16814 16815 16816 16817 16818 16819 16820 16821 16822 16823 16824 16825 16826 16827 16828 16829 16830 16831 16832 16833 16834 16835 16836 16837 16838 16839 16840 16841 16842 16843 16844 16845 16846 16847 16848 16849 16850 16851 16852 16853 16854 16855 16856 16857 16858 16859 16860 16861 16862 16863 16864 16865 16866 16867 16868 16869 16870 16871 16872 16873 16874 16875 16876 16877 16878 16879 16880 16881 16882 16883 16884 16885 16886 16887 16888 16889 16890 16891 16892 16893 16894 16895 16896 16897 16898 16899 16900 16901 16902 16903 16904 16905 16906 16907 16908 16909 16910 16911 16912 16913 16914 16915 16916 16917 16918 16919 16920 16921 16922 16923 16924 16925 16926 16927 16928 16929 16930 16931 16932 16933 16934 16935 16936 16937 16938 16939 16940 16941 16942 16943 16944 16945 16946 16947 16948 16949 16950 16951 16952 16953 16954 16955 16956 16957 16958 16959 16960 16961 16962 16963 16964 16965 16966 16967 16968 16969 16970 16971 16972 16973 16974 16975 16976 16977 16978 16979 16980 16981 16982 16983 16984 16985 16986 16987 16988 16989 16990 16991 16992 16993 16994 16995 16996 16997 16998 16999 17000 17001 17002 17003 17004 17005 17006 17007 17008 17009 17010 17011 17012 17013 17014 17015 17016 17017 17018 17019 17020 17021 17022 17023 17024 17025 17026 17027 17028 17029 17030 17031 17032 17033 17034 17035 17036 17037 17038 17039 17040 17041 17042 17043 17044 17045 17046 17047 17048 17049 17050 17051 17052 17053 17054 17055 17056 17057 17058 17059 17060 17061 17062 17063 17064 17065 17066 17067 17068 17069 17070 17071 17072 17073 17074 17075 17076 17077 17078 17079 17080 17081 17082 17083 17084 17085 17086 17087 17088 17089 17090 17091 17092 17093 17094 17095 17096 17097 17098 17099 17100 17101 17102 17103 17104 17105 17106 17107 17108 17109 17110 17111 17112 17113 17114 17115 17116 17117 17118 17119 17120 17121 17122 17123 17124 17125 17126 17127 17128 17129 17130 17131 17132 17133 17134 17135 17136 17137 17138 17139 17140 17141 17142 17143 17144 17145 17146 17147 17148 17149 17150 17151 17152 17153 17154 17155 17156 17157 17158 17159 17160 17161 17162 17163 17164 17165 17166 17167 17168 17169 17170 17171 17172 17173 17174 17175 17176 17177 17178 17179 17180 17181 17182 17183 17184 17185 17186 17187 17188 17189 17190 17191 17192 17193 17194 17195 17196 17197 17198 17199 17200 17201 17202 17203 17204 17205 17206 17207 17208 17209 17210 17211 17212 17213 17214 17215 17216 17217 17218 17219 17220 17221 17222 17223 17224 17225 17226 17227 17228 17229 17230 17231 17232 17233 17234 17235 17236 17237 17238 17239 17240 17241 17242 17243 17244 17245 17246 17247 17248 17249 17250 17251 17252 17253 17254 17255 17256 17257 17258 17259 17260 17261 17262 17263 17264 17265 17266 17267 17268 17269 17270 17271 17272 17273 17274 17275 17276 17277 17278 17279 17280 17281 17282 17283 17284 17285 17286 17287 17288 17289 17290 17291 17292 17293 17294 17295 17296 17297 17298 17299 17300 17301 17302 17303 17304 17305 17306 17307 17308 17309 17310 17311 17312 17313 17314 17315 17316 17317 17318 17319 17320 17321 17322 17323 17324 17325 17326 17327 17328 17329 17330 17331 17332 17333 17334 17335 17336 17337 17338 17339 17340 17341 17342 17343 17344 17345 17346 17347 17348 17349 17350 17351 17352 17353 17354 17355 17356 17357 17358 17359 17360 17361 17362 17363 17364 17365 17366 17367 17368 17369 17370 17371 17372 17373 17374 17375 17376 17377 17378 17379 17380 17381 17382 17383 17384 17385 17386 17387 17388 17389 17390 17391 17392 17393 17394 17395 17396 17397 17398 17399 17400 17401 17402 17403 17404 17405 17406 17407 17408 17409 17410 17411 17412 17413 17414 17415 17416 17417 17418 17419 17420 17421 17422 17423 17424 17425 17426 17427 17428 17429 17430 17431 17432 17433 17434 17435 17436 17437 17438 17439 17440 17441 17442 17443 17444 17445 17446 17447 17448 17449 17450 17451 17452 17453 17454 17455 17456 17457 17458 17459 17460 17461 17462 17463 17464 17465 17466 17467 17468 17469 17470 17471 17472 17473 17474 17475 17476 17477 17478 17479 17480 17481 17482 17483 17484 17485 17486 17487 17488 17489 17490 17491 17492 17493 17494 17495 17496 17497 17498 17499 17500 17501 17502 17503 17504 17505 17506 17507 17508 17509 17510 17511 17512 17513 17514 17515 17516 17517 17518 17519 17520 17521 17522 17523 17524 17525 17526 17527 17528 17529 17530 17531 17532 17533 17534 17535 17536 17537 17538 17539 17540 17541 17542 17543 17544 17545 17546 17547 17548 17549 17550 17551 17552 17553 17554 17555 17556 17557 17558 17559 17560 17561 17562 17563 17564 17565 17566 17567 17568 17569 17570 17571 17572 17573 17574 17575 17576 17577 17578 17579 17580 17581 17582 17583 17584 17585 17586 17587 17588 17589 17590 17591 17592 17593 17594 17595 17596 17597 17598 17599 17600 17601 17602 17603 17604 17605 17606 17607 17608 17609 17610 17611 17612 17613 17614 17615 17616 17617 17618 17619 17620 17621 17622 17623 17624 17625 17626 17627 17628 17629 17630 17631 17632 17633 17634 17635 17636 17637 17638 17639 17640 17641 17642 17643 17644 17645 17646 17647 17648 17649 17650 17651 17652 17653 17654 17655 17656 17657 17658 17659 17660 17661 17662 17663 17664 17665 17666 17667 17668 17669 17670 17671 17672 17673 17674 17675 17676 17677 17678 17679 17680 17681 17682 17683 17684 17685 17686 17687 17688 17689 17690 17691 17692 17693 17694 17695 17696 17697 17698 17699 17700 17701 17702 17703 17704 17705 17706 17707 17708 17709 17710 17711 17712 17713 17714 17715 17716 17717 17718 17719 17720 17721 17722 17723 17724 17725 17726 17727 17728 17729 17730 17731 17732 17733 17734 17735 17736 17737 17738 17739 17740 17741 17742 17743 17744 17745 17746 17747 17748 17749 17750 17751 17752 17753 17754 17755 17756 17757 17758 17759 17760 17761 17762 17763 17764 17765 17766 17767 17768 17769 17770 17771 17772 17773 17774 17775 17776 17777 17778 17779 17780 17781 17782 17783 17784 17785 17786 17787 17788 17789 17790 17791 17792 17793 17794 17795 17796 17797 17798 17799 17800 17801 17802 17803 17804 17805 17806 17807 17808 17809 17810 17811 17812 17813 17814 17815 17816 17817 17818 17819 17820 17821 17822 17823 17824 17825 17826 17827 17828 17829 17830 17831 17832 17833 17834 17835 17836 17837 17838 17839 17840 17841 17842 17843 17844 17845 17846 17847 17848 17849 17850 17851 17852 17853 17854 17855 17856 17857 17858 17859 17860 17861 17862 17863 17864 17865 17866 17867 17868 17869 17870 17871 17872 17873 17874 17875 17876 17877 17878 17879 17880 17881 17882 17883 17884 17885 17886 17887 17888 17889 17890 17891 17892 17893 17894 17895 17896 17897 17898 17899 17900 17901 17902 17903 17904 17905 17906 17907 17908 17909 17910 17911 17912 17913 17914 17915 17916 17917 17918 17919 17920 17921 17922 17923 17924 17925 17926 17927 17928 17929 17930 17931 17932 17933 17934 17935 17936 17937 17938 17939 17940 17941 17942 17943 17944 17945 17946 17947 17948 17949 17950 17951 17952 17953 17954 17955 17956 17957 17958 17959 17960 17961 17962 17963 17964 17965 17966 17967 17968 17969 17970 17971 17972 17973 17974 17975 17976 17977 17978 17979 17980 17981 17982 17983 17984 17985 17986 17987 17988 17989 17990 17991 17992 17993 17994 17995 17996 17997 17998 17999 18000 18001 18002 18003 18004 18005 18006 18007 18008 18009 18010 18011 18012 18013 18014 18015 18016 18017 18018 18019 18020 18021 18022 18023 18024 18025 18026 18027 18028 18029 18030 18031 18032 18033 18034 18035 18036 18037 18038 18039 18040 18041 18042 18043 18044 18045 18046 18047 18048 18049 18050 18051 18052 18053 18054 18055 18056 18057 18058 18059 18060 18061 18062 18063 18064 18065 18066 18067 18068 18069 18070 18071 18072 18073 18074 18075 18076 18077 18078 18079 18080 18081 18082 18083 18084 18085 18086 18087 18088 18089 18090 18091 18092 18093 18094 18095 18096 18097 18098 18099 18100 18101 18102 18103 18104 18105 18106 18107 18108 18109 18110 18111 18112 18113 18114 18115 18116 18117 18118 18119 18120 18121 18122 18123 18124 18125 18126 18127 18128 18129 18130 18131 18132 18133 18134 18135 18136 18137 18138 18139 18140 18141 18142 18143 18144 18145 18146 18147 18148 18149 18150 18151 18152 18153 18154 18155 18156 18157 18158 18159 18160 18161 18162 18163 18164 18165 18166 18167 18168 18169 18170 18171 18172 18173 18174 18175 18176 18177 18178 18179 18180 18181 18182 18183 18184 18185 18186 18187 18188 18189 18190 18191 18192 18193 18194 18195 18196 18197 18198 18199 18200 18201 18202 18203 18204 18205 18206 18207 18208 18209 18210 18211 18212 18213 18214 18215 18216 18217 18218 18219 18220 18221 18222 18223 18224 18225 18226 18227 18228 18229 18230 18231 18232 18233 18234 18235 18236 18237 18238 18239 18240 18241 18242 18243 18244 18245 18246 18247 18248 18249 18250 18251 18252 18253 18254 18255 18256 18257 18258 18259 18260 18261 18262 18263 18264 18265 18266 18267 18268 18269 18270 18271 18272 18273 18274 18275 18276 18277 18278 18279 18280 18281 18282 18283 18284 18285 18286 18287 18288 18289 18290 18291 18292 18293 18294 18295 18296 18297 18298 18299 18300 18301 18302 18303 18304 18305 18306 18307 18308 18309 18310 18311 18312 18313 18314 18315 18316 18317 18318 18319 18320 18321 18322 18323 18324 18325 18326 18327 18328 18329 18330 18331 18332 18333 18334 18335 18336 18337 18338 18339 18340 18341 18342 18343 18344 18345 18346 18347 18348 18349 18350 18351 18352 18353 18354 18355 18356 18357 18358 18359 18360 18361 18362 18363 18364 18365 18366 18367 18368 18369 18370 18371 18372 18373 18374 18375 18376 18377 18378 18379 18380 18381 18382 18383 18384 18385 18386 18387 18388 18389 18390 18391 18392 18393 18394 18395 18396 18397 18398 18399 18400 18401 18402 18403 18404 18405 18406 18407 18408 18409 18410 18411 18412 18413 18414 18415 18416 18417 18418 18419 18420 18421 18422 18423 18424 18425 18426 18427 18428 18429 18430 18431 18432 18433 18434 18435 18436 18437 18438 18439 18440 18441 18442 18443 18444 18445 18446 18447 18448 18449 18450 18451 18452 18453 18454 18455 18456 18457 18458 18459 18460 18461 18462 18463 18464 18465 18466 18467 18468 18469 18470 18471 18472 18473 18474 18475 18476 18477 18478 18479 18480 18481 18482 18483 18484 18485 18486 18487 18488 18489 18490 18491 18492 18493 18494 18495 18496 18497 18498 18499 18500 18501 18502 18503 18504 18505 18506 18507 18508 18509 18510 18511 18512 18513 18514 18515 18516 18517 18518 18519 18520 18521 18522 18523 18524 18525 18526 18527 18528 18529 18530 18531 18532 18533 18534 18535 18536 18537 18538 18539 18540 18541 18542 18543 18544 18545 18546 18547 18548 18549 18550 18551 18552 18553 18554 18555 18556 18557 18558 18559 18560 18561 18562 18563 18564 18565 18566 18567 18568 18569 18570 18571 18572 18573 18574 18575 18576 18577 18578 18579 18580 18581 18582 18583 18584 18585 18586 18587 18588 18589 18590 18591 18592 18593 18594 18595 18596 18597 18598 18599 18600 18601 18602 18603 18604 18605 18606 18607 18608 18609 18610 18611 18612 18613 18614 18615 18616 18617 18618 18619 18620 18621 18622 18623 18624 18625 18626 18627 18628 18629 18630 18631 18632 18633 18634 18635 18636 18637 18638 18639 18640 18641 18642 18643 18644 18645 18646 18647 18648 18649 18650 18651 18652 18653 18654 18655 18656 18657 18658 18659 18660 18661 18662 18663 18664 18665 18666 18667 18668 18669 18670 18671 18672 18673 18674 18675 18676 18677 18678 18679 18680 18681 18682 18683 18684 18685 18686 18687 18688 18689 18690 18691 18692 18693 18694 18695 18696 18697 18698 18699 18700 18701 18702 18703 18704 18705 18706 18707 18708 18709 18710 18711 18712 18713 18714 18715 18716 18717 18718 18719 18720 18721 18722 18723 18724 18725 18726 18727 18728 18729 18730 18731 18732 18733 18734 18735 18736 18737 18738 18739 18740 18741 18742 18743 18744 18745 18746 18747 18748 18749 18750 18751 18752 18753 18754 18755 18756 18757 18758 18759 18760 18761 18762 18763 18764 18765 18766 18767 18768 18769 18770 18771 18772 18773 18774 18775 18776 18777 18778 18779 18780 18781 18782 18783 18784 18785 18786 18787 18788 18789 18790 18791 18792 18793 18794 18795 18796 18797 18798 18799 18800 18801 18802 18803 18804 18805 18806 18807 18808 18809 18810 18811 18812 18813 18814 18815 18816 18817 18818 18819 18820 18821 18822 18823 18824 18825 18826 18827 18828 18829 18830 18831 18832 18833 18834 18835 18836 18837 18838 18839 18840 18841 18842 18843 18844 18845 18846 18847 18848 18849 18850 18851 18852 18853 18854 18855 18856 18857 18858 18859 18860 18861 18862 18863 18864 18865 18866 18867 18868 18869 18870 18871 18872 18873 18874 18875 18876 18877 18878 18879 18880 18881 18882 18883 18884 18885 18886 18887 18888 18889 18890 18891 18892 18893 18894 18895 18896 18897 18898 18899 18900 18901 18902 18903 18904 18905 18906 18907 18908 18909 18910 18911 18912 18913 18914 18915 18916 18917 18918 18919 18920 18921 18922 18923 18924 18925 18926 18927 18928 18929 18930 18931 18932 18933 18934 18935 18936 18937 18938 18939 18940 18941 18942 18943 18944 18945 18946 18947 18948 18949 18950 18951 18952 18953 18954 18955 18956 18957 18958 18959 18960 18961 18962 18963 18964 18965 18966 18967 18968 18969 18970 18971 18972 18973 18974 18975 18976 18977 18978 18979 18980 18981 18982 18983 18984 18985 18986 18987 18988 18989 18990 18991 18992 18993 18994 18995 18996 18997 18998 18999 19000 19001 19002 19003 19004 19005 19006 19007 19008 19009 19010 19011 19012 19013 19014 19015 19016 19017 19018 19019 19020 19021 19022 19023 19024 19025 19026 19027 19028 19029 19030 19031 19032 19033 19034 19035 19036 19037 19038 19039 19040 19041 19042 19043 19044 19045 19046 19047 19048 19049 19050 19051 19052 19053 19054 19055 19056 19057 19058 19059 19060 19061 19062 19063 19064 19065 19066 19067 19068 19069 19070 19071 19072 19073 19074 19075 19076 19077 19078 19079 19080 19081 19082 19083 19084 19085 19086 19087 19088 19089 19090 19091 19092 19093 19094 19095 19096 19097 19098 19099 19100 19101 19102 19103 19104 19105 19106 19107 19108 19109 19110 19111 19112 19113 19114 19115 19116 19117 19118 19119 19120 19121 19122 19123 19124 19125 19126 19127 19128 19129 19130 19131 19132 19133 19134 19135 19136 19137 19138 19139 19140 19141 19142 19143 19144 19145 19146 19147 19148 19149 19150 19151 19152 19153 19154 19155 19156 19157 19158 19159 19160 19161 19162 19163 19164 19165 19166 19167 19168 19169 19170 19171 19172 19173 19174 19175 19176 19177 19178 19179 19180 19181 19182 19183 19184 19185 19186 19187 19188 19189 19190 19191 19192 19193 19194 19195 19196 19197 19198 19199 19200 19201 19202 19203 19204 19205 19206 19207 19208 19209 19210 19211 19212 19213 19214 19215 19216 19217 19218 19219 19220 19221 19222 19223 19224 19225 19226 19227 19228 19229 19230 19231 19232 19233 19234 19235 19236 19237 19238 19239 19240 19241 19242 19243 19244 19245 19246 19247 19248 19249 19250 19251 19252 19253 19254 19255 19256 19257 19258 19259 19260 19261 19262 19263 19264 19265 19266 19267 19268 19269 19270 19271 19272 19273 19274 19275 19276 19277 19278 19279 19280 19281 19282 19283 19284 19285 19286 19287 19288 19289 19290 19291 19292 19293 19294 19295 19296 19297 19298 19299 19300 19301 19302 19303 19304 19305 19306 19307 19308 19309 19310 19311 19312 19313 19314 19315 19316 19317 19318 19319 19320 19321 19322 19323 19324 19325 19326 19327 19328 19329 19330 19331 19332 19333 19334 19335 19336 19337 19338 19339 19340 19341 19342 19343 19344 19345 19346 19347 19348 19349 19350 19351 19352 19353 19354 19355 19356 19357 19358 19359 19360 19361 19362 19363 19364 19365 19366 19367 19368 19369 19370 19371 19372 19373 19374 19375 19376 19377 19378 19379 19380 19381 19382 19383 19384 19385 19386 19387 19388 19389 19390 19391 19392 19393 19394 19395 19396 19397 19398 19399 19400 19401 19402 19403 19404 19405 19406 19407 19408 19409 19410 19411 19412 19413 19414 19415 19416 19417 19418 19419 19420 19421 19422 19423 19424 19425 19426 19427 19428 19429 19430 19431 19432 19433 19434 19435 19436 19437 19438 19439 19440 19441 19442 19443 19444 19445 19446 19447 19448 19449 19450 19451 19452 19453 19454 19455 19456 19457 19458 19459 19460 19461 19462 19463 19464 19465 19466 19467 19468 19469 19470 19471 19472 19473 19474 19475 19476 19477 19478 19479 19480 19481 19482 19483 19484 19485 19486 19487 19488 19489 19490 19491 19492 19493 19494 19495 19496 19497 19498 19499 19500 19501 19502 19503 19504 19505 19506 19507 19508 19509 19510 19511 19512 19513 19514 19515 19516 19517 19518 19519 19520 19521 19522 19523 19524 19525 19526 19527 19528 19529 19530 19531 19532 19533 19534 19535 19536 19537 19538 19539 19540 19541 19542 19543 19544 19545 19546 19547 19548 19549 19550 19551 19552 19553 19554 19555 19556 19557 19558 19559 19560 19561 19562 19563 19564 19565 19566 19567 19568 19569 19570 19571 19572 19573 19574 19575 19576 19577 19578 19579 19580 19581 19582 19583 19584 19585 19586 19587 19588 19589 19590 19591 19592 19593 19594 19595 19596 19597 19598 19599 19600 19601 19602 19603 19604 19605 19606 19607 19608 19609 19610 19611 19612 19613 19614 19615 19616 19617 19618 19619 19620 19621 19622 19623 19624 19625 19626 19627 19628 19629 19630 19631 19632 19633 19634 19635 19636 19637 19638 19639 19640 19641 19642 19643 19644 19645 19646 19647 19648 19649 19650 19651 19652 19653 19654 19655 19656 19657 19658 19659 19660 19661 19662 19663 19664 19665 19666 19667 19668 19669 19670 19671 19672 19673 19674 19675 19676 19677 19678 19679 19680 19681 19682 19683 19684 19685 19686 19687 19688 19689 19690 19691 19692 19693 19694 19695 19696 19697 19698 19699 19700 19701 19702 19703 19704 19705 19706 19707 19708 19709 19710 19711 19712 19713 19714 19715 19716 19717 19718 19719 19720 19721 19722 19723 19724 19725 19726 19727 19728 19729 19730 19731 19732 19733 19734 19735 19736 19737 19738 19739 19740 19741 19742 19743 19744 19745 19746 19747 19748 19749 19750 19751 19752 19753 19754 19755 19756 19757 19758 19759 19760 19761 19762 19763 19764 19765 19766 19767 19768 19769 19770 19771 19772 19773 19774 19775 19776 19777 19778 19779 19780 19781 19782 19783 19784 19785 19786 19787 19788 19789 19790 19791 19792 19793 19794 19795 19796 19797 19798 19799 19800 19801 19802 19803 19804 19805 19806 19807 19808 19809 19810 19811 19812 19813 19814 19815 19816 19817 19818 19819 19820 19821 19822 19823 19824 19825 19826 19827 19828 19829 19830 19831 19832 19833 19834 19835 19836 19837 19838 19839 19840 19841 19842 19843 19844 19845 19846 19847 19848 19849 19850 19851 19852 19853 19854 19855 19856 19857 19858 19859 19860 19861 19862 19863 19864 19865 19866 19867 19868 19869 19870 19871 19872 19873 19874 19875 19876 19877 19878 19879 19880 19881 19882 19883 19884 19885 19886 19887 19888 19889 19890 19891 19892 19893 19894 19895 19896 19897 19898 19899 19900 19901 19902 19903 19904 19905 19906 19907 19908 19909 19910 19911 19912 19913 19914 19915 19916 19917 19918 19919 19920 19921 19922 19923 19924 19925 19926 19927 19928 19929 19930 19931 19932 19933 19934 19935 19936 19937 19938 19939 19940 19941 19942 19943 19944 19945 19946 19947 19948 19949 19950 19951 19952 19953 19954 19955 19956 19957 19958 19959 19960 19961 19962 19963 19964 19965 19966 19967 19968 19969 19970 19971 19972 19973 19974 19975 19976 19977 19978 19979 19980 19981 19982 19983 19984 19985 19986 19987 19988 19989 19990 19991 19992 19993 19994 19995 19996 19997 19998 19999 20000 20001 20002 20003 20004 20005 20006 20007 20008 20009 20010 20011 20012 20013 20014 20015 20016 20017 20018 20019 20020 20021 20022 20023 20024 20025 20026 20027 20028 20029 20030 20031 20032 20033 20034 20035 20036 20037 20038 20039 20040 20041 20042 20043 20044 20045 20046 20047 20048 20049 20050 20051 20052 20053 20054 20055 20056 20057 20058 20059 20060 20061 20062 20063 20064 20065 20066 20067 20068 20069 20070 20071 20072 20073 20074 20075 20076 20077 20078 20079 20080 20081 20082 20083 20084 20085 20086 20087 20088 20089 20090 20091 20092 20093 20094 20095 20096 20097 20098 20099 20100 20101 20102 20103 20104 20105 20106 20107 20108 20109 20110 20111 20112 20113 20114 20115 20116 20117 20118 20119 20120 20121 20122 20123 20124 20125 20126 20127 20128 20129 20130 20131 20132 20133 20134 20135 20136 20137 20138 20139 20140 20141 20142 20143 20144 20145 20146 20147 20148 20149 20150 20151 20152 20153 20154 20155 20156 20157 20158 20159 20160 20161 20162 20163 20164 20165 20166 20167 20168 20169 20170 20171 20172 20173 20174 20175 20176 20177 20178 20179 20180 20181 20182 20183 20184 20185 20186 20187 20188 20189 20190 20191 20192 20193 20194 20195 20196 20197 20198 20199 20200 20201 20202 20203 20204 20205 20206 20207 20208 20209 20210 20211 20212 20213 20214 20215 20216 20217 20218 20219 20220 20221 20222 20223 20224 20225 20226 20227 20228 20229 20230 20231 20232 20233 20234 20235 20236 20237 20238 20239 20240 20241 20242 20243 20244 20245 20246 20247 20248 20249 20250 20251 20252 20253 20254 20255 20256 20257 20258 20259 20260 20261 20262 20263 20264 20265 20266 20267 20268 20269 20270 20271 20272 20273 20274 20275 20276 20277 20278 20279 20280 20281 20282 20283 20284 20285 20286 20287 20288 20289 20290 20291 20292 20293 20294 20295 20296 20297 20298 20299 20300 20301 20302 20303 20304 20305 20306 20307 20308 20309 20310 20311 20312 20313 20314 20315 20316 20317 20318 20319 20320 20321 20322 20323 20324 20325 20326 20327 20328 20329 20330 20331 20332 20333 20334 20335 20336 20337 20338 20339 20340 20341 20342 20343 20344 20345 20346 20347 20348 20349 20350 20351 20352 20353 20354 20355 20356 20357 20358 20359 20360 20361 20362 20363 20364 20365 20366 20367 20368 20369 20370 20371 20372 20373 20374 20375 20376 20377 20378 20379 20380 20381 20382 20383 20384 20385 20386 20387 20388 20389 20390 20391 20392 20393 20394 20395 20396 20397 20398 20399 20400 20401 20402 20403 20404 20405 20406 20407 20408 20409 20410 20411 20412 20413 20414 20415 20416 20417 20418 20419 20420 20421 20422 20423 20424 20425 20426 20427 20428 20429 20430 20431 20432 20433 20434 20435 20436 20437 20438 20439 20440 20441 20442 20443 20444 20445 20446 20447 20448 20449 20450 20451 20452 20453 20454 20455 20456 20457 20458 20459 20460 20461 20462 20463 20464 20465 20466 20467 20468 20469 20470 20471 20472 20473 20474 20475 20476 20477 20478 20479 20480 20481 20482 20483 20484 20485 20486 20487 20488 20489 20490 20491 20492 20493 20494 20495 20496 20497 20498 20499 20500 20501 20502 20503 20504 20505 20506 20507 20508 20509 20510 20511 20512 20513 20514 20515 20516 20517 20518 20519 20520 20521 20522 20523 20524 20525 20526 20527 20528 20529 20530 20531 20532 20533 20534 20535 20536 20537 20538 20539 20540 20541 20542 20543 20544 20545 20546 20547 20548 20549 20550 20551 20552 20553 20554 20555 20556 20557 20558 20559 20560 20561 20562 20563 20564 20565 20566 20567 20568 20569 20570 20571 20572 20573 20574 20575 20576 20577 20578 20579 20580 20581 20582 20583 20584 20585 20586 20587 20588 20589 20590 20591 20592 20593 20594 20595 20596 20597 20598 20599 20600 20601 20602 20603 20604 20605 20606 20607 20608 20609 20610 20611 20612 20613 20614 20615 20616 20617 20618 20619 20620 20621 20622 20623 20624 20625 20626 20627 20628 20629 20630 20631 20632 20633 20634 20635 20636 20637 20638 20639 20640 20641 20642 20643 20644 20645 20646 20647 20648 20649 20650 20651 20652 20653 20654 20655 20656 20657 20658 20659 20660 20661 20662 20663 20664 20665 20666 20667 20668 20669 20670 20671 20672 20673 20674 20675 20676 20677 20678 20679 20680 20681 20682 20683 20684 20685 20686 20687 20688 20689 20690 20691 20692 20693 20694 20695 20696 20697 20698 20699 20700 20701 20702 20703 20704 20705 20706 20707 20708 20709 20710 20711 20712 20713 20714 20715 20716 20717 20718 20719 20720 20721 20722 20723 20724 20725 20726 20727 20728 20729 20730 20731 20732 20733 20734 20735 20736 20737 20738 20739 20740 20741 20742 20743 20744 20745 20746 20747 20748 20749 20750 20751 20752 20753
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created on April, 17 2006 by texi2html 1.76 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
Karl Berry <karl@freefriends.org>
Olaf Bachmann <obachman@mathematik.uni-kl.de>
and many others.
Maintained by: Many creative people <dev@texi2html.cvshome.org>
Send bugs and suggestions to <users@texi2html.cvshome.org>
-->
<head>
<title>YAP Prolog User's Manual: YAP Prolog</title>
<meta name="description" content="YAP Prolog User's Manual: YAP Prolog">
<meta name="keywords" content="YAP Prolog User's Manual: YAP Prolog">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.76">
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="settitle">YAP Prolog</h1>
<p>@setcontentsaftertitlepage
</p>
@set VERSION: 5.1.1
<a name="Top"></a>
<a name="SEC_Top"></a>
<p>This file documents the YAP Prolog System version No value for VERSION, a
high-performance Prolog compiler developed at LIACC, Universidade do
Porto. YAP is based on David H. D. Warren's WAM (Warren Abstract
Machine), with several optimizations for better performance. YAP follows
the Edinburgh tradition, and is largely compatible with DEC-10 Prolog,
Quintus Prolog, and especially with C-Prolog.
</p>
<p>This file contains extracts of the SWI-Prolog manual, as written by Jan
Wielemaker. Our thanks to the author for his kind permission in allowing
us to include his text in this document.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC1">Introduction</a></td><td> </td><td align="left" valign="top"></td></tr>
<tr><td align="left" valign="top"><a href="#SEC2">1. Installing YAP</a></td><td> </td><td align="left" valign="top"> Installation
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC8">2. Running YAP</a></td><td> </td><td align="left" valign="top"></td></tr>
<tr><td align="left" valign="top"><a href="#SEC11">3. Syntax</a></td><td> </td><td align="left" valign="top"> The syntax of YAP
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC22">4. Loading Programs</a></td><td> </td><td align="left" valign="top"> Loading Prolog programs
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC26">5. The Module System</a></td><td> </td><td align="left" valign="top"> Using Modules in YAP
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC31">6. Built-In Predicates</a></td><td> </td><td align="left" valign="top"></td></tr>
<tr><td align="left" valign="top"><a href="#SEC61">7. Library Predicates</a></td><td> </td><td align="left" valign="top"></td></tr>
<tr><td align="left" valign="top"><a href="#SEC83">8. SWI-Prolog Emulation</a></td><td> </td><td align="left" valign="top"> SWI-Prolog emulation
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC90">9. Extensions to Prolog</a></td><td> </td><td align="left" valign="top"> Extensions to Standard YAP
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC91">9.1 Rational Trees</a></td><td> </td><td align="left" valign="top"> Working with Rational Trees
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC92">9.2 Coroutining</a></td><td> </td><td align="left" valign="top"> Changing the Execution of Goals
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC93">10. Attributed Variables</a></td><td> </td><td align="left" valign="top"> Using attributed Variables
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC100">11. Constraint Logic Programming over Reals</a></td><td> </td><td align="left" valign="top"> The CLP(R) System
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC105">12. CHR: Constraint Handling Rules</a></td><td> </td><td align="left" valign="top"> The CHR System
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC125">13. Logtalk</a></td><td> </td><td align="left" valign="top"> The Logtalk Object-Oriented System
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC126">14. Threads</a></td><td> </td><td align="left" valign="top"> Thread Library
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC134">15. Parallelism</a></td><td> </td><td align="left" valign="top"> Running in Or-Parallel
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC135">16. Tabling</a></td><td> </td><td align="left" valign="top"> Storing Intermediate Solutions of programs
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC137">18. Profiling the Abstract Machine</a></td><td> </td><td align="left" valign="top"> Profiling Abstract Machine Instructions
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC136">17. Tracing at Low Level</a></td><td> </td><td align="left" valign="top"> Tracing at Abstract Machine Level
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC138">19. Debugging</a></td><td> </td><td align="left" valign="top"> Using the Debugger
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC141">20. Indexing</a></td><td> </td><td align="left" valign="top"> Efficiency Considerations
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC142">21. C Language interface to YAP</a></td><td> </td><td align="left" valign="top"> Interfacing predicates written in C
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC153">22. Using YAP as a Library</a></td><td> </td><td align="left" valign="top"> Using YAP as a library in other programs
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC154">23. Compatibility with Other Prolog systems</a></td><td> </td><td align="left" valign="top"> Compatibility with other Prolog systems
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC168">Predicate Index</a></td><td> </td><td align="left" valign="top"> An item for each predicate
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC169">Concept Index</a></td><td> </td><td align="left" valign="top"> An item for each concept
</td></tr>
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
Built In Predicates
</pre></th></tr><tr><td align="left" valign="top"><a href="#SEC32">6.1 Control Predicates</a></td><td> </td><td align="left" valign="top"> Controlling the execution of Prolog programs
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC33">6.2 Handling Undefined Procedures</a></td><td> </td><td align="left" valign="top"> Handling calls to Undefined Procedures
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td><td> </td><td align="left" valign="top"> Predicates on Terms
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC35">6.4 Comparing Terms</a></td><td> </td><td align="left" valign="top"> Comparison of Terms
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC36">6.5 Arithmetic</a></td><td> </td><td align="left" valign="top"> Arithmetic in YAP
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC37">6.6 I/O Predicates</a></td><td> </td><td align="left" valign="top"> Input/Output with YAP
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC46">6.7 Using the Clausal Data Base</a></td><td> </td><td align="left" valign="top"> Modifying Prolog's Database
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC52">6.10 Collecting Solutions to a Goal</a></td><td> </td><td align="left" valign="top"> Finding All Possible Solutions
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC53">6.11 Grammar Rules</a></td><td> </td><td align="left" valign="top"></td></tr>
<tr><td align="left" valign="top"><a href="#SEC59">6.17 Predicate Information</a></td><td> </td><td align="left" valign="top"></td></tr>
<tr><td align="left" valign="top"><a href="#SEC54">6.12 Access to Operating System Functionality</a></td><td> </td><td align="left" valign="top"></td></tr>
<tr><td align="left" valign="top"><a href="#SEC55">6.13 Term Modification</a></td><td> </td><td align="left" valign="top"> Updating Prolog Terms
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC56">6.14 Profiling Prolog Programs</a></td><td> </td><td align="left" valign="top"> Profiling Prolog Execution
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC57">6.15 Counting Calls</a></td><td> </td><td align="left" valign="top"> Limiting the Maximum Number of Reductions
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC58">6.16 Arrays</a></td><td> </td><td align="left" valign="top"> Supporting Global and Local Arrays
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC59">6.17 Predicate Information</a></td><td> </td><td align="left" valign="top"> Information on Predicates
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td><td> </td><td align="left" valign="top"> Miscellaneous Predicates
</td></tr>
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
Subnodes of Running
</pre></th></tr><tr><td align="left" valign="top"><a href="#SEC9">2.1 Running Yap Interactively</a></td><td> </td><td align="left" valign="top"> Interacting with Yap
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC10">2.2 Running Prolog Files</a></td><td> </td><td align="left" valign="top"> Running Prolog files as scripts
</td></tr>
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
Subnodes of Syntax
</pre></th></tr><tr><td align="left" valign="top"><a href="#SEC12">3.1 Syntax of Terms</a></td><td> </td><td align="left" valign="top"></td></tr>
<tr><td align="left" valign="top"><a href="#SEC13">3.2 Prolog Tokens</a></td><td> </td><td align="left" valign="top"> Syntax of Prolog tokens
</td></tr>
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
Subnodes of Tokens
</pre></th></tr><tr><td align="left" valign="top"><a href="#SEC14">3.2.1 Numbers</a></td><td> </td><td align="left" valign="top"> Integer and Floating-Point Numbers
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC17">3.2.2 Character Strings</a></td><td> </td><td align="left" valign="top"> Sequences of Characters
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC18">3.2.3 Atoms</a></td><td> </td><td align="left" valign="top"> Atomic Constants
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC19">3.2.4 Variables</a></td><td> </td><td align="left" valign="top"> Logical Variables
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC20">3.2.5 Punctuation Tokens</a></td><td> </td><td align="left" valign="top"> Tokens that separate other tokens
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC21">3.2.6 Layout</a></td><td> </td><td align="left" valign="top"> Comments and Other Layout Rules
</td></tr>
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
Subnodes of Numbers
</pre></th></tr><tr><td align="left" valign="top"><a href="#SEC15">3.2.1.1 Integers</a></td><td> </td><td align="left" valign="top"> How Integers are read and represented
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC16">3.2.1.2 Floating-point Numbers</a></td><td> </td><td align="left" valign="top"> Floating Point Numbers
</td></tr>
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
Subnodes of Loading Programs
</pre></th></tr><tr><td align="left" valign="top"><a href="#SEC23">4.1 Program loading and updating</a></td><td> </td><td align="left" valign="top"> Program Loading and Updating
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td><td> </td><td align="left" valign="top"> Changing the compiler's parameters
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC25">4.3 Saving and Loading Prolog States</a></td><td> </td><td align="left" valign="top"> Saving and Restoring Programs
</td></tr>
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
Subnodes of Modules
</pre></th></tr><tr><td align="left" valign="top"><a href="#SEC27">5.1 Module Concepts</a></td><td> </td><td align="left" valign="top"> The Key Ideas in Modules
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC28">5.2 Defining a New Module</a></td><td> </td><td align="left" valign="top"> How To Define a New Module
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC29">5.3 Using Modules</a></td><td> </td><td align="left" valign="top"> How to Use a Module
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC30">5.4 Meta-Predicates in Modules</a></td><td> </td><td align="left" valign="top"> How to Handle New Meta-Predicates
</td></tr>
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
Subnodes of Input/Output
</pre></th></tr><tr><td align="left" valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td><td> </td><td align="left" valign="top"></td></tr>
<tr><td align="left" valign="top"><a href="#SEC39">6.6.2 Handling Streams and Files</a></td><td> </td><td align="left" valign="top"> C-Prolog Compatible File Handling
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td><td> </td><td align="left" valign="top"> Input/Output of terms
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td><td> </td><td align="left" valign="top"> Input/Output of Characters
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td><td> </td><td align="left" valign="top"> Input/Output using Streams
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC43">6.6.6 Compatible C-Prolog predicates for Terminal I/O</a></td><td> </td><td align="left" valign="top"> C-Prolog compatible Character I/O to terminal
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC44">6.6.7 Controlling Input/Output</a></td><td> </td><td align="left" valign="top"> Controlling your Input/Output
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC45">6.6.8 Using Sockets From Yap</a></td><td> </td><td align="left" valign="top"> Using Sockets from YAP
</td></tr>
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
Subnodes of Database
</pre></th></tr><tr><td align="left" valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td><td> </td><td align="left" valign="top"> Asserting and Retracting
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC48">6.7.2 Looking at the Data Base</a></td><td> </td><td align="left" valign="top"> Finding out what is in the Data Base
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC49">6.7.3 Using Data Base References</a></td><td> </td><td align="left" valign="top"></td></tr>
<tr><td align="left" valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td><td> </td><td align="left" valign="top"> YAP's Internal Database
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC51">6.9 The Blackboard</a></td><td> </td><td align="left" valign="top"> Storing and Fetching Terms in the BlackBoard
</td></tr>
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
Subnodes of Library
</pre></th></tr><tr><td align="left" valign="top"><a href="#SEC62">7.1 Apply Macros</a></td><td> </td><td align="left" valign="top"> Apply a Predicate to a list or to sub-terms.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC63">7.2 Association Lists</a></td><td> </td><td align="left" valign="top"> Binary Tree Implementation of Association Lists.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC64">7.3 AVL Trees</a></td><td> </td><td align="left" valign="top"> Predicates to add and lookup balanced binary trees.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC65">7.4 Heaps</a></td><td> </td><td align="left" valign="top"> Labelled binary tree where the key of each node is less
than or equal to the keys of its children.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC66">7.5 List Manipulation</a></td><td> </td><td align="left" valign="top"></td></tr>
<tr><td align="left" valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td><td> </td><td align="left" valign="top"> Ordered Set Manipulation
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC68">7.7 Pseudo Random Number Integer Generator</a></td><td> </td><td align="left" valign="top"> Pseudo Random Numbers
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC69">7.8 Queues</a></td><td> </td><td align="left" valign="top"> Queue Manipulation
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC70">7.9 Random Number Generator</a></td><td> </td><td align="left" valign="top"> Random Numbers
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td><td> </td><td align="left" valign="top"> Predicates to add, lookup and delete in red-black binary trees.
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC72">7.11 Regular Expressions</a></td><td> </td><td align="left" valign="top"> Regular Expression Manipulation
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC73">7.12 Splay Trees</a></td><td> </td><td align="left" valign="top"></td></tr>
<tr><td align="left" valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td><td> </td><td align="left" valign="top"> Writing To and Reading From Strings
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td><td> </td><td align="left" valign="top"> System Utilities
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC76">7.15 Utilities On Terms</a></td><td> </td><td align="left" valign="top"> Utilities on Terms
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC77">7.16 Call Cleanup</a></td><td> </td><td align="left" valign="top"> Call With registered Cleanup Calls
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC78">7.17 Calls With Timeout</a></td><td> </td><td align="left" valign="top"> Call With Timeout
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC79">7.18 Updatable Binary Trees</a></td><td> </td><td align="left" valign="top"></td></tr>
<tr><td align="left" valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td><td> </td><td align="left" valign="top"></td></tr>
<tr><td align="left" valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td><td> </td><td align="left" valign="top"> Directed Graphs Implemented With Red-Black Trees
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC82">7.21 Undirected Graphs</a></td><td> </td><td align="left" valign="top"> Undirected Graphs Using DGraphs
</td></tr>
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
Subnodes of Debugging
</pre></th></tr><tr><td align="left" valign="top"><a href="#SEC139">19.1 Debugging Predicates</a></td><td> </td><td align="left" valign="top"></td></tr>
<tr><td align="left" valign="top"><a href="#SEC140">19.2 Interacting with the debugger</a></td><td> </td><td align="left" valign="top"></td></tr>
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
Subnodes of Compatibility
</pre></th></tr><tr><td align="left" valign="top"><a href="#SEC155">23.1 Compatibility with the C-Prolog interpreter</a></td><td> </td><td align="left" valign="top"></td></tr>
<tr><td align="left" valign="top"><a href="#SEC161">23.2 Compatibility with the Quintus and SICStus Prolog systems</a></td><td> </td><td align="left" valign="top"></td></tr>
<tr><td align="left" valign="top"><a href="#SEC166">23.3 Compatibility with the ISO Prolog standard</a></td><td> </td><td align="left" valign="top"></td></tr>
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
Subnodes of Attributes
</pre></th></tr><tr><td align="left" valign="top"><a href="#SEC94">10.1 Attribute Declarations</a></td><td> </td><td align="left" valign="top"> Declaring New Attributes
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC95">10.2 Attribute Manipulation</a></td><td> </td><td align="left" valign="top"> Setting and Reading Attributes
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC96">10.3 Attributed Unification</a></td><td> </td><td align="left" valign="top"> Tuning the Unification Algorithm
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC97">10.4 Displaying Attributes</a></td><td> </td><td align="left" valign="top"> Displaying Attributes in User-Readable Form
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC98">10.5 Projecting Attributes</a></td><td> </td><td align="left" valign="top"> Obtaining the Attributes of Interest
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC99">10.6 Attribute Examples</a></td><td> </td><td align="left" valign="top"> Two Simple Examples of how to use Attributes.
</td></tr>
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
Subnodes of SWI-Prolog
</pre></th></tr><tr><td align="left" valign="top"><a href="#SEC84">8.1 Invoking Predicates on all Members of a List</a></td><td> </td><td align="left" valign="top"> maplist and friends
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC85">8.2 Forall</a></td><td> </td><td align="left" valign="top"> forall built-in
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC86">8.3 hProlog and SWI-Prolog Attributed Variables</a></td><td> </td><td align="left" valign="top"> Emulating SWI-like attributed variables
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC88">8.4 SWI Global variables</a></td><td> </td><td align="left" valign="top"> Emulating SWI-like attributed variables
</td></tr>
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
Subnodes of CLPR
</pre></th></tr><tr><td align="left" valign="top"><a href="#SEC101">11.1 Solver Predicates</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC102">11.2 Syntax of the predicate arguments</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC103">11.3 Use of unification</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC104">11.4 Non-Linear Constraints</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
Subnodes of CHR
</pre></th></tr><tr><td align="left" valign="top"><a href="#SEC106">12.1 Introduction</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC107">12.2 Syntax and Semantics</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC114">12.3 CHR in YAP Programs</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC118">12.4 Debugging</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC122">12.5 Examples</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC123">12.6 Compatibility with SICStus CHR</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC124">12.7 Guidelines</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
Subnodes of C-Interface
</pre></th></tr><tr><td align="left" valign="top"><a href="#SEC143">21.1 Terms</a></td><td> </td><td align="left" valign="top"> Primitives available to the C programmer
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC144">21.2 Unification</a></td><td> </td><td align="left" valign="top"> How to Unify Two Prolog Terms
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC145">21.3 Strings</a></td><td> </td><td align="left" valign="top"> From character arrays to Lists of codes and back
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC146">21.4 Memory Allocation</a></td><td> </td><td align="left" valign="top"> Stealing Memory From Yap
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC147">21.5 Controlling Yap Streams from <code>C</code></a></td><td> </td><td align="left" valign="top"> Control How Yap sees Streams
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC148">21.6 From <code>C</code> back to Prolog</a></td><td> </td><td align="left" valign="top"> From C to Yap to C to Yap
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC149">21.7 Writing predicates in C</a></td><td> </td><td align="left" valign="top"> Writing Predicates in C
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC150">21.8 Loading Object Files</a></td><td> </td><td align="left" valign="top"></td></tr>
<tr><td align="left" valign="top"><a href="#SEC151">21.9 Saving and Restoring</a></td><td> </td><td align="left" valign="top"></td></tr>
<tr><td align="left" valign="top"><a href="#SEC152">21.10 Changes to the C-Interface in Yap4</a></td><td> </td><td align="left" valign="top"> Changes in Foreign Predicates Interface
</td></tr>
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
Subnodes of C-Prolog
</pre></th></tr><tr><td align="left" valign="top"><a href="#SEC156">23.1.1 Major Differences between YAP and C-Prolog.</a></td><td> </td><td align="left" valign="top"></td></tr>
<tr><td align="left" valign="top"><a href="#SEC157">23.1.2 Yap predicates fully compatible with C-Prolog</a></td><td> </td><td align="left" valign="top"> Yap predicates fully compatible with
</td></tr>
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">C-Prolog
</pre></th></tr><tr><td align="left" valign="top"><a href="#SEC158">23.1.3 Yap predicates not strictly compatible with C-Prolog</a></td><td> </td><td align="left" valign="top"> Yap predicates not strictly as C-Prolog
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC159">23.1.4 Yap predicates not available in C-Prolog</a></td><td> </td><td align="left" valign="top"></td></tr>
<tr><td align="left" valign="top"><a href="#SEC160">23.1.5 Yap predicates not available in C-Prolog</a></td><td> </td><td align="left" valign="top"> C-Prolog predicates not available in YAP
</td></tr>
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
Subnodes of SICStus Prolog
</pre></th></tr><tr><td align="left" valign="top"><a href="#SEC162">23.2.1 Major Differences between YAP and SICStus Prolog.</a></td><td> </td><td align="left" valign="top"></td></tr>
<tr><td align="left" valign="top"><a href="#SEC163">23.2.2 Yap predicates fully compatible with SICStus Prolog</a></td><td> </td><td align="left" valign="top"> Yap predicates fully compatible with
</td></tr>
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">SICStus Prolog
</pre></th></tr><tr><td align="left" valign="top"><a href="#SEC164">23.2.3 Yap predicates not strictly compatible with SICStus Prolog</a></td><td> </td><td align="left" valign="top"> Yap predicates not strictly as
</td></tr>
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">SICStus Prolog
</pre></th></tr><tr><td align="left" valign="top"><a href="#SEC165">23.2.4 Yap predicates not available in SICStus Prolog</a></td><td> </td><td align="left" valign="top"></td></tr>
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
Tables
</pre></th></tr><tr><td align="left" valign="top"><a href="#SEC167">A. Summary of Yap Predefined Operators</a></td><td> </td><td align="left" valign="top"> Predefined operators
</td></tr>
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
</pre></th></tr></table>
<hr size="1">
<a name="Intro"></a>
<a name="SEC1"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC_Top" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC2" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[ << ]</td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC2" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="unnumbered"> Introduction </h1>
<p>This document provides User information on version No value for VERSION of
YAP (<em>yet another prolog</em>). The YAP Prolog System is a
high-performance Prolog compiler developed at LIACC, Universidade do
Porto. YAP provides several important features:
</p>
<ul>
<li> Speed: YAP is widely considered one of the fastest available Prolog
systems.
</li><li> Functionality: it supports stream I/O, sockets, modules,
exceptions, Prolog debugger, C-interface, dynamic code, internal
database, DCGs, saved states, co-routining, arrays.
</li><li> We explicitly allow both commercial and non-commercial use of YAP.
</li></ul>
<p>YAP is based on the David H. D. Warren's WAM (Warren Abstract Machine),
with several optimizations for better performance. YAP follows the
Edinburgh tradition, and was originally designed to be largely
compatible with DEC-10 Prolog, Quintus Prolog, and especially with
C-Prolog.
</p>
<p>YAP implements most of the ISO-Prolog standard. We are striving at
full compatibility, and the manual describes what is still
missing. The manual also includes a (largely incomplete) comparison
with SICStus Prolog.
</p>
<p>The document is intended neither as an introduction to Prolog nor to the
implementation aspects of the compiler. A good introduction to
programming in Prolog is the book <cite>The Art of Prolog</cite>, by
L. Sterling and E. Shapiro, published by "The MIT Press, Cambridge
MA". Other references should include the classical <cite>Programming in
Prolog</cite>, by W.F. Clocksin and C.S. Mellish, published by
Springer-Verlag.
</p>
<p>YAP 4.3 is known to build with many versions of gcc (<= gcc-2.7.2, >=
gcc-2.8.1, >= egcs-1.0.1, gcc-2.95.*) and on a variety of Unixen:
SunOS 4.1, Solaris 2.*, Irix 5.2, HP-UX 10, Dec Alpha Unix, Linux 1.2
and Linux 2.* (RedHat 4.0 thru 5.2, Debian 2.*) in both the x86 and
alpha platforms. It has been built on Windows NT 4.0 using Cygwin from
Cygnus Solutions (see README.nt) and using Visual C++ 6.0.
</p>
<p>The overall copyright and permission notice for YAP4.3 can be found in
the Artistic file in this directory. YAP follows the Perl Artistic
license, and it is thus non-copylefted freeware.
</p>
<p>If you have a question about this software, desire to add code, found a
bug, want to request a feature, or wonder how to get further assistance,
please send e-mail to <a href="mailto:yappers@ncc.up.pt">yappers@ncc.up.pt</a>. To subscribe to the
mailing list, send a request to <a href="mailto:majordomo@ncc.up.pt">majordomo@ncc.up.pt</a> with body
"subscribe yappers".
</p>
<p>Online documentation is available for YAP at:
</p>
<p> <a href="http://www.ncc.up.pt/~vsc/Yap/">http://www.ncc.up.pt/~vsc/Yap/</a>
</p>
<p>Recent versions of Yap, including both source and selected binaries,
can be found from this same URL.
</p>
<p>This manual was written by Vítor Santos Costa,
Luís Damas, Rogério Reis, and Rúben Azevedo. The
manual is largely based on the DECsystem-10 Prolog User's Manual by
D.L. Bowen, L. Byrd, F. C. N. Pereira, L. M. Pereira, and
D. H. D. Warren. We have also used comments from the Edinburgh Prolog
library written by R. O'Keefe. We would also like to gratefully
acknowledge the contributions from Ashwin Srinivasian.
</p>
<p>We are happy to include in YAP several excellent packages developed
under separate licenses. Our thanks to the authors for their kind
authorization to include these packages.
</p>
<p>The packages are, in alphabetical order:
</p>
<ul>
<li> The CHR package developed by Tom Schrijvers,
Christian Holzbaur, and Jan Wielemaker.
</li><li> The CLP(R) package developed Leslie De Koninck, Bart Demoen, Tom
Schrijvers and Jan Wielemaker and based on the CLP(Q,R) implementation
by Christian Holzbauer.
</li><li> The Logtalk Object-Oriented system is developed at the University
of Beira Interior, Portugal, by Paulo Moura.
The package is distributed under the Perl Artistic License.
Instructions about loading this package are included in this document.
The documentation on this package (including full installation instructions)
is distributed separately from yap.tex.
<p>Copyright © 1998-2006 Paulo Moura
</p>
</li><li> The Pillow WEB library developed at Universidad Politecnica de
Madrid by the CLIP group. This package is distributed under the FSF's
LGPL. Documentation on this package is distributed separately from
yap.tex.
</li><li> The yap2swi library implements some of the functionality of
SWI's PL interface. Please do refer to the SWI-Prolog home page:
<p><a href="http://www.swi-prolog.org">http://www.swi-prolog.org</a>
</p>
<p>for more information on SWI-Prolog and for a detailed description of its
foreign interface.
</p>
</li></ul>
<hr size="6">
<a name="Install"></a>
<a name="SEC2"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC1" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC3" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC1" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC8" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 1. Installing YAP </h1>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC3">1.1 Tuning the Functionality of YAP</a></td><td> </td><td align="left" valign="top"> Tuning the Functionality of YAP Machine
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC4">1.2 Tuning YAP for a Particular Machine and Compiler</a></td><td> </td><td align="left" valign="top"></td></tr>
</table>
<p>To compile YAP it should be sufficient to:
</p>
<ol>
<li> <code>mkdir ARCH</code>.
</li><li> <code>cd ARCH</code>.
</li><li> <code>../configure ...options...</code>.
<p>Notice that by default <code>configure</code> gives you a vanilla
configuration. For instance, in order to use coroutining and/or CLP
you need to do
</p>
<table><tr><td> </td><td><pre class="example">../configure --enable-coroutining ...options...
</pre></td></tr></table><p>Please see section <a href="#SEC3">Tuning the Functionality of YAP</a> for extra options.
</p>
</li><li> check the Makefile for any extensions or changes you want to
make.
<p>YAP uses <code>autoconf</code>. Recent versions of Yap try to follow GNU
conventions on where to place software.
</p>
<ul>
<li> The main executable is placed at <code>BINDIR</code>. This executable is
actually a script that calls the Prolog engine, stored at <code>LIBDIR</code>.
</li><li> <code>LIBDIR</code> is the directory where libraries are stored. YAPLIBDIR is a
subdirectory that contains the Prolog engine and a Prolog library.
</li><li> <code>INCLUDEDIR</code> is used if you want to use Yap as a library.
</li><li> <code>INFODIR</code> is where to store <code>info</code> files. Usually
<code>/usr/local/info</code>, <code>/usr/info</code>, or <code>/usr/share/info</code>.
</li></ul>
</li><li> <code>make</code>.
</li><li> If the compilation succeeds, try <code>./yap</code>.
</li><li> If you feel satisfied with the result, do <code>make install</code>.
</li><li> <code>make install-info</code> will create the info files in the
standard info directory.
</li><li> <code>make html</code> will create documentation in html format in the
predefined directory.
<p>In most systems you will need to be superuser in order to do <code>make
install</code> and <code>make info</code> on the standard directories.
</p></li></ol>
<hr size="6">
<a name="Configuration-Options"></a>
<a name="SEC3"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC2" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC4" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC2" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC2" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC8" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 1.1 Tuning the Functionality of YAP </h2>
<p>Compiling Yap with the standard options give you a plain vanilla
Prolog. You can tune Yap to include extra functionality by calling
<code>configure</code> with the appropriate options:
</p>
<ul>
<li> <code>--enable-rational-trees=yes</code> gives you support for infinite
rational trees.
</li><li> <code>--enable-coroutining=yes</code> gives you support for coroutining,
including freezing of goals, attributed variables, and
constraints. This will also enable support for infinite rational
trees.
</li><li> <code>--enable-depth-limit=yes</code> allows depth limited evaluation, say for
implementing iterative deepening.
</li><li> <code>--enable-low-level-tracer=yes</code> allows support for tracing all calls,
retries, and backtracks in the system. This can help in debugging your
application, but results in performance loss.
</li><li> <code>--enable-wam-profile=yes</code> allows profiling of abstract machine
instructions. This is useful when developing YAP, should not be so
useful for normal users.
</li><li> <code>--enable-condor=yes</code> allows using the Condor system that
support High Throughput Computing (HTC) on large collections of
distributively owned computing resources.
</li><li> <code>--enable-tabling=yes</code> allows tabling support. This option
is still experimental.
</li><li> <code>--enable-parallelism={env-copy,sba,a-cow}</code> allows
or-parallelism supported by one of these three forms. This option is
still highly experimental.
</li><li> <code>--with-gmp[=DIR]</code> give a path to where one can find the
<code>GMP</code> library if not installed in the default path.
</li></ul>
<p>Next follow machine dependent details:
</p>
<hr size="6">
<a name="Machine-Options"></a>
<a name="SEC4"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC3" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC5" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC2" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC2" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC8" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 1.2 Tuning YAP for a Particular Machine and Compiler </h2>
<p>The default options should give you best performance under
<code>GCC</code>. Although the system is tuned for this compiler
we have been able to compile versions of Yap under lcc in Linux,
Sun's cc compiler, IBM's xlc, SGI's cc, and Microsoft's Visual C++
6.0.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC5">1.3 Tuning YAP for <code>GCC</code>.</a></td><td> </td><td align="left" valign="top"> Using the GNUCC compiler
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC6">1.3.1 Compiling Under Visual C++</a></td><td> </td><td align="left" valign="top"> Using Microsoft's Visual C++ environment
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC7">1.3.2 Compiling Under SGI's cc</a></td><td> </td><td align="left" valign="top"> Compiling Under SGI's <code>cc</code>
</td></tr>
</table>
<hr size="6">
<a name="Tuning-for-GCC"></a>
<a name="SEC5"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC4" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC6" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC2" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC2" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC8" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 1.3 Tuning YAP for <code>GCC</code>. </h2>
<p>Yap has been developed to take advantage of <code>GCC</code> (but not to
depend on it). The major advantage of <code>GCC</code> is threaded code and
explicit register reservation.
</p>
<p>YAP is set by default to compile with the best compilation flags we
know. Even so, a few specific options reduce portability. The option
</p><ul>
<li> <code>--enable-max-performance=yes</code> will try to support the best
available flags for a specific architectural model. Currently, the option
assumes a recent version of <code>GCC</code>.
</li><li> <code>--enable-debug-yap</code> compiles Yap so that it can be debugged
by tools such as <code>dbx</code> or <code>gdb</code>.
</li></ul>
<p>Here follow a few hints:
</p>
<p>On x86 machines the flags:
</p>
<table><tr><td> </td><td><pre class="example">YAP_EXTRAS= ... -DBP_FREE=1
</pre></td></tr></table>
<p>tells us to use the <code>%bp</code> register (frame-pointer) as the emulator's
program counter. This seems to be stable and is now default.
</p>
<p>On Sparc/Solaris2 use:
</p>
<table><tr><td> </td><td><pre class="example">YAP_EXTRAS= ... -mno-app-regs -DOPTIMISE_ALL_REGS_FOR_SPARC=1
</pre></td></tr></table>
<p>and YAP will get two extra registers! This trick does not work on
SunOS 4 machines.
</p>
<p>Note that versions of GCC can be tweaked to recognize different
processors within the same instruction set, e.g. 486, Pentium, and
PentiumPro for the x86; or Ultrasparc, and Supersparc for
Sparc. Unfortunately, some of these tweaks do may make Yap run slower or
not at all in other machines with the same instruction set, so they
cannot be made default.
</p>
<p>Last, the best options also depends on the version of GCC you are using, and
it is a good idea to consult the GCC manual under the menus "Invoking
GCC"/"Submodel Options". Specifically, you should check
<code>-march=XXX</code> for recent versions of GCC/EGCS. In the case of
<code>GCC2.7</code> and other recent versions of <code>GCC</code> you can check:
</p>
<dl compact="compact">
<dt> <code>486:</code></dt>
<dd><p>In order to take advantage of 486 specific optimizations in GCC 2.7.*:
</p>
<table><tr><td> </td><td><pre class="example">YAP_EXTRAS= ... -m486 -DBP_FREE=1
</pre></td></tr></table>
</dd>
<dt> <code>Pentium:</code></dt>
<dd><table><tr><td> </td><td><pre class="example">YAP_EXTRAS= ... -m486 -malign-loops=2 -malign-jumps=2 \
-malign-functions=2
</pre></td></tr></table>
</dd>
<dt> <code>PentiumPro and other recent Intel and AMD machines:</code></dt>
<dd><p>PentiumPros are known not to require alignment. Check your version of
<code>GCC</code> for the best <code>-march</code> option.
</p>
</dd>
<dt> <code>Super and UltraSparcs:</code></dt>
<dd><table><tr><td> </td><td><pre class="example">YAP_EXTRAS= ... -msupersparc
</pre></td></tr></table>
</dd>
<dt> <code>MIPS: if have a recent machine and you need a 64 bit wide address</code></dt>
<dd><p>space you can use the abi 64 bits or eabi option, as in:
</p><table><tr><td> </td><td><pre class="example">CC="gcc -mabi=64" ./configure --...
</pre></td></tr></table><p>Be careful. At least for some versions of <code>GCC</code>, compiling with
<code>-g</code> seems to result in broken code.
</p>
</dd>
<dt> <code>WIN32: GCC is distributed in the MINGW32 and CYGWIN packages.</code></dt>
<dd>
<p>The Mingw32 environment is available from the URL:
</p>
<p><code>http://www.mingw.org</code>
</p>
<p>You will need to install the <code>msys</code> and <code>mingw</code>
packages. You should be able to do configure, make and make install.
</p>
<p>If you use mingw32 you may want to search the contributed packages for
the <code>gmp</code> multi-precision arithmetic library. If you do setup Yap
with <code>gmp</code> note that <code>libgmp.dll</code> must be in the path,
otherwise Yap will not be able to execute.
</p>
<p>CygWin environment is available from the URL:
</p>
<p><code>http://www.cygwin.com</code>
</p>
<p>and mirrors. We suggest using recent versions of the cygwin shell. The
compilation steps under the cygwin shell are as follows:
</p>
<table><tr><td> </td><td><pre class="example">mkdir cyg
$YAPSRC/configure --enable-coroutining \\
--enable-depth-limit \\
--enable-max-performance
make
make install
</pre></td></tr></table>
<p>By default, Yap will use the <code>--enable-cygwin=no</code> option to
disable the use of the cygwin dll and to enable the mingw32 subsystem
instead. Yap thus will not need the cygwin dll. It instead accesses
the system's <code>CRTDLL.DLL</code> <code>C</code> run time library supplied with
Win32 platforms through the mingw32 interface. Note that some older
WIN95 systems may not have <code>CRTDLL.DLL</code>, in this case it should
be sufficient to import the file from a newer WIN95 or WIN98 machine.
</p>
<p>You should check the default installation path which is set to
<code>/Yap</code> in the standard Makefile. This string will usually
be expanded into <code>c:\Yap</code> by Windows.
</p>
<p>The cygwin environment does not provide <tt>gmp</tt>. You can fetch a dll for
the <tt>gmp</tt> library from <a href="http://www.sf.net/projects/mingwrep">http://www.sf.net/projects/mingwrep</a>.
</p>
<p>It is also possible to configure Yap to be a part of the cygwin
environment. In this case you should use:
</p><table><tr><td> </td><td><pre class="example">mkdir cyg
$YAPSRC/configure --enable-coroutining \\
--enable-max-performance \\
--enable-cygwin=yes
make
make install
</pre></td></tr></table><p>Yap will then compile using the cygwin library and will be installed
in cygwin's <code>/usr/local</code>. You can use Yap from a cygwin console,
or as a standalone application as long as it can find
<code>cygwin1.dll</code> in its path.
</p>
</dd>
</dl>
<hr size="6">
<a name="Compiling-Under-Visual-C_002b_002b"></a>
<a name="SEC6"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC5" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC7" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC2" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC5" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC8" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 1.3.1 Compiling Under Visual C++ </h3>
<p>Yap compiles cleanly under Microsoft's Visual C++ release 6.0. We next
give a step-by-step tutorial on how to compile Yap manually using this
environment.
</p>
<p>First, it is a good idea to build Yap as a DLL:
</p>
<ol>
<li> create a project named yapdll using File.New. The project will be a
DLL project, initially empty.
<p>Notice that either the project is named yapdll or you must replace the
preprocessors variable <var>YAPDLL_EXPORTS</var> to match your project names
in the files <code>YapInterface.h</code> and <code>c_interface.c</code>.
</p>
</li><li> add all .c files in the <var>$YAPSRC/C</var> directory and in the
<var>$YAPSRC\OPTYap</var> directory to the Project's <code>Source Files</code> (use
FileView).
</li><li> add all .h files in the <var>$YAPSRC/H</var> directory,
<var>$YAPSRC\include</var> directory and in the <var>$YAPSRC\OPTYap</var>
subdirectory to the Project's <code>Header Files</code>.
</li><li> Ideally, you should now use <code>m4</code> to generate extra .h from .m4 files and use
<code>configure</code> to create a <code>config.h</code>. Or, you can be lazy, and
fetch these files from <var>$YAPSRC\VC\include</var>.
</li><li> You may want to go to <code>Build.Set Active Configuration</code> and set <code>Project
Type</code> to <code>Release</code>
</li><li> To use Yap's own include directories you have to set the Project
option <code>Project.Project Settings.C/C++.Preprocessor.Additional
Include Directories</code> to include the directories <var>$YAPSRC\H</var>,
<var>$YAPSRC\VC\include</var>, <var>$YAPSRC\OPTYap</var> and
<var>$YAPSRC\include</var>. The syntax is:
<table><tr><td> </td><td><pre class="example">$YAPSRC\H, $YAPSRC\VC\include, $YAPSRC\OPTYap, $YAPSRC\include
</pre></td></tr></table>
</li><li> Build: the system should generate an <code>yapdll.dll</code> and an <code>yapdll.lib</code>.
</li><li> Copy the file <code>yapdll.dll</code> to your path. The file
<code>yapdll.lib</code> should also be copied to a location where the linker can find it.
</li></ol>
<p>Now you are ready to create a console interface for Yap:
</p><ol>
<li> create a second project say <code>wyap</code> with <code>File.New</code>. The project will be a
WIN32 console project, initially empty.
</li><li> add <var>$YAPSRC\console\yap.c</var> to the <code>Source Files</code>.
</li><li> add <var>$YAPSRC\VC\include\config.h</var> and the files in <var>$YAPSRC\include</var> to
the <code>Header Files</code>.
</li><li> You may want to go to <code>Build.Set Active Configuration</code> and set
<code>Project Type</code> to <code>Release</code>.
</li><li> you will eventually need to bootstrap the system by booting from
<code>boot.yap</code>, so write:
<table><tr><td> </td><td><pre class="example"> -b $YAPSRC\pl\boot.yap
</pre></td></tr></table>
<p> in <code>Project.Project Settings.Debug.Program Arguments</code>.
</p>
</li><li> You need the sockets and yap libraries. Add
<table><tr><td> </td><td><pre class="example">ws2_32.lib yapdll.lib to
</pre></td></tr></table>
<p>to
</p>
<p>to <code>Project.Project Settings.Link.Object/Library Modules</code>
</p>
<p>You may also need to set the <code>Link Path</code> so that VC++ will find <code>yapdll.lib</code>.
</p>
</li><li> set <code>Project.Project Settings.C/C++.Preprocessor.Additional
Include Directories</code> to include the <var>$YAPSRC/VC/include</var> and
<var>$YAPSRC/include</var>.
<p>The syntax is:
</p>
<table><tr><td> </td><td><pre class="example">$YAPSRC\VC\include, $YAPSRC\include
</pre></td></tr></table>
</li><li> Build the system.
</li><li> Use <code>Build.Start Debug</code> to boot the system, and then create the saved state with
<table><tr><td> </td><td><pre class="example">['$YAPSRC\\pl\\init'].
save_program(startup).
^Z
</pre></td></tr></table>
<p>That's it, you've got Yap and the saved state!
</p></li></ol>
<p>The $YAPSRC\VC directory has the make files to build Yap4.3.17 under VC++ 6.0.
</p>
<hr size="6">
<a name="Tuning-for-SGI-cc"></a>
<a name="SEC7"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC6" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC8" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC2" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC5" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC8" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 1.3.2 Compiling Under SGI's cc </h3>
<p>YAP should compile under the Silicon Graphic's <code>cc</code> compiler,
although we advise using the GNUCC compiler, if available.
</p>
<dl compact="compact">
<dt> <code>64 bit</code></dt>
<dd><p>Support for 64 bits should work by using (under Bourne shell syntax):
</p><table><tr><td> </td><td><pre class="example">CC="cc -64" $YAP_SRC_PATH/configure --...
</pre></td></tr></table></dd>
</dl>
<hr size="6">
<a name="Run"></a>
<a name="SEC8"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC7" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC9" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC2" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC11" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 2. Running YAP </h1>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC9">2.1 Running Yap Interactively</a></td><td> </td><td align="left" valign="top"> Interacting with Yap
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC10">2.2 Running Prolog Files</a></td><td> </td><td align="left" valign="top"> Running Prolog files as scripts
</td></tr>
</table>
<a name="IDX1"></a>
<p>We next describe how to invoke Yap in Unix systems.
</p>
<hr size="6">
<a name="Running-Yap-Interactively"></a>
<a name="SEC9"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC8" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC10" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC8" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC8" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC11" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 2.1 Running Yap Interactively </h2>
<p>Most often you will want to use Yap in interactive mode. Assuming that
YAP is in the user's search path, the top-level can be invoked under
Unix with the following command:
</p>
<table><tr><td> </td><td><pre class="example">yap [-s n] [-h n] [-a n] [-c IP_HOST port ] [filename]
</pre></td></tr></table>
<p>All the arguments and flags are optional and have the following meaning:
</p><dl compact="compact">
<dt> <code>-?</code></dt>
<dd><p>print a short error message.
</p></dd>
<dt> <code>-s <var>n</var></code></dt>
<dd><p>allocate <var>n</var> K bytes for local and global stacks
</p></dd>
<dt> <code>-h <var>n</var></code></dt>
<dd><p>allocate <var>n</var> K bytes for heap and auxiliary stacks
</p></dd>
<dt> <code>-t <var>n</var></code></dt>
<dd><p>allocate <var>n</var> K bytes for the trail stack
</p></dd>
<dt> <code>-l <var>YAP_FILE</var></code></dt>
<dd><p>compile the Prolog file <var>YAP_FILE</var> before entering the top-level.
</p></dd>
<dt> <code>-L <var>YAP_FILE</var></code></dt>
<dd><p>compile the Prolog file <var>YAP_FILE</var> and then halt. This option is
useful for implementing scripts.
</p></dd>
<dt> <code>-g <var>Goal</var></code></dt>
<dd><p>run the goal <var>Goal</var> before top-level. The goal is converted from
an atom to a Prolog term.
</p></dd>
<dt> <code>-z <var>Goal</var></code></dt>
<dd><p>run the goal <var>Goal</var> as top-level. The goal is converted from
an atom to a Prolog term.
</p></dd>
<dt> <code>-b <var>BOOT_FILE</var></code></dt>
<dd><p>boot code is in Prolog file <var>BOOT_FILE</var>. The filename must define
the predicate '$live'/0.
</p></dd>
<dt> <code>-c <tt>IP_HOST</tt> <tt>port</tt></code></dt>
<dd><p>connect standard streams to host <tt>IP_HOST</tt> at port <tt>port</tt>
</p></dd>
<dt> <code>filename</code></dt>
<dd><p>restore state saved in the given file
</p></dd>
<dt> <code>--</code></dt>
<dd><p>separator for arguments to Prolog code. These arguments are visible
through the unix/1 built-in.
</p></dd>
</dl>
<p>Note that YAP will output an error message on the following conditions:
</p>
<ul>
<li>
a file name was given but the file does not exist or is not a saved
YAP state;
</li><li>
the necessary amount of memory could not be allocated;
</li><li>
the allocated memory is not enough to restore the state.
</li></ul>
<p>When restoring a saved state, YAP will allocate the
same amount of memory as that in use when the state was saved, unless a
different amount is specified by flags in the command line. By default,
YAP restores the file <samp>`startup'</samp> from the current directory or from
the YAP library.
<a name="IDX2"></a>
</p>
<a name="IDX3"></a>
<ul>
<li>
YAP usually boots from a saved state. The saved state will use the default
installation directory to search for the YAP binary unless you define
the environment variable YAPBINDIR.
<a name="IDX4"></a>
</li><li>
YAP always tries to find saved states from the current directory
first. If it cannot it will use the environment variable YAPLIBDIR, if
defined, or search the default library directory.
<a name="IDX5"></a>
</li><li>
YAP will try to find library files from the YAPSHAREDIR/library
directory.
</li></ul>
<hr size="6">
<a name="Running-Prolog-Files"></a>
<a name="SEC10"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC9" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC11" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC8" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC8" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC11" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 2.2 Running Prolog Files </h2>
<p>YAP can also be used to run Prolog files as scripts, at least in
Unix-like environments. A simple example is shown next:
</p>
<table><tr><td> </td><td><table class="cartouche" border="1"><tr><td>
<pre class="example">#!/usr/local/bin/yap -L --
#
# Hello World script file using Yap
#
# put a dot because of syntax errors .
:- write('Hello World'), nl.
</pre></td></tr></table>
</td></tr></table>
<p>The <code>#!</code> characters specify that the script should call the binary
file Yap. Notice that many systems will require the complete path to the
Yap binary. The <code>-L</code> flag indicates that YAP should consult the
current file when booting and then halt. The remaining arguments are
then passed to YAP. Note that YAP will skip the first lines if they
start with <code>#</code> (the comment sign for Unix's shell). YAP will
consult the file and execute any commands.
</p>
<p>A slightly more sophisticated example is:
</p>
<table><tr><td> </td><td><table class="cartouche" border="1"><tr><td>
<pre class="example">#!/usr/bin/yap -L --
#
# Hello World script file using Yap
# .
:- initialization(main).
main :- write('Hello World'), nl.
</pre></td></tr></table>
</td></tr></table>
<p>The <code>initialization</code> directive tells Yap to execute the goal main
after consulting the file. Source code is thus compiled and <code>main</code>
executed at the end. The <code>.</code> is useful while debugging the script
as a Prolog program: it guarantees that the syntax error will not
propagate to the Prolog code.
</p>
<p>Notice that the <code>--</code> is required so that the shell passes the extra
arguments to YAP. As an example, consider the following script
<code>dump_args</code>:
</p>
<table><tr><td> </td><td><table class="cartouche" border="1"><tr><td>
<pre class="example">#!/usr/bin/yap -L --
#.
main( [] ).
main( [H|T] ) :-
write( H ), nl,
main( T ).
:- unix( argv(AllArgs) ), main( AllArgs ).
</pre></td></tr></table>
</td></tr></table>
<p>If you this run this script with the arguments:
</p><table><tr><td> </td><td><pre class="example">./dump_args -s 10000
</pre></td></tr></table>
<p>the script will start an YAP process with stack size <code>10MB</code>, and
the list of arguments to the process will be empty.
</p>
<p>Often one wants to run the script as any other program, and for this it
is convenient to ignore arguments to YAP. This is possible by using
<code>L --</code> as in the next version of <code>dump_args</code>:
</p>
<table><tr><td> </td><td><table class="cartouche" border="1"><tr><td>
<pre class="example">#!/usr/bin/yap -L --
main( [] ).
main( [H|T] ) :-
write( H ), nl,
main( T ).
:- unix( argv(AllArgs) ), main( AllArgs ).
</pre></td></tr></table>
</td></tr></table>
<p>The <code>--</code> indicates the next arguments are not for YAP. Instead,
they must be sent directly to the <code>argv</code> built-in. Hence, running
</p><table><tr><td> </td><td><pre class="example">./dump_args test
</pre></td></tr></table>
<p>will write <code>test</code> on the standard output.
</p>
<hr size="6">
<a name="Syntax"></a>
<a name="SEC11"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC10" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC12" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC8" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC22" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 3. Syntax </h1>
<p>We will describe the syntax of YAP at two levels. We first will
describe the syntax for Prolog terms. In a second level we describe
the <i>tokens</i> from which Prolog <i>terms</i> are
built.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC12">3.1 Syntax of Terms</a></td><td> </td><td align="left" valign="top"> Syntax of terms
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC13">3.2 Prolog Tokens</a></td><td> </td><td align="left" valign="top"> Syntax of Prolog tokens
</td></tr>
</table>
<hr size="6">
<a name="Formal-Syntax"></a>
<a name="SEC12"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC11" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC13" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC11" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC11" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC22" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 3.1 Syntax of Terms </h2>
<p>Below, we describe the syntax of YAP terms from the different
classes of tokens defined above. The formalism used will be <em>BNF</em>,
extended where necessary with attributes denoting integer precedence or
operator type.
</p>
<table><tr><td> </td><td><pre class="example">
<code>
term ----> subterm(1200) end_of_term_marker
subterm(N) ----> term(M) [M <= N]
term(N) ----> op(N, fx) subterm(N-1)
| op(N, fy) subterm(N)
| subterm(N-1) op(N, xfx) subterm(N-1)
| subterm(N-1) op(N, xfy) subterm(N)
| subterm(N) op(N, yfx) subterm(N-1)
| subterm(N-1) op(N, xf)
| subterm(N) op(N, yf)
term(0) ----> atom '(' arguments ')'
| '(' subterm(1200) ')'
| '{' subterm(1200) '}'
| list
| string
| number
| atom
| variable
arguments ----> subterm(999)
| subterm(999) ',' arguments
list ----> '[]'
| '[' list_expr ']'
list_expr ----> subterm(999)
| subterm(999) list_tail
list_tail ----> ',' list_expr
| ',..' subterm(999)
| '|' subterm(999)
</code>
</pre></td></tr></table>
<p>Notes:
</p>
<ul>
<li>
<i>op(N,T)</i> denotes an atom which has been previously declared with type
<i>T</i> and base precedence <i>N</i>.
</li><li>
Since ',' is itself a pre-declared operator with type <i>xfy</i> and
precedence 1000, is <i>subterm</i> starts with a '(', <i>op</i> must be
followed by a space to avoid ambiguity with the case of a functor
followed by arguments, e.g.:
<table><tr><td> </td><td><pre class="example"><code> + (a,b) [the same as '+'(','(a,b)) of arity one]</code>
</pre></td></tr></table><p>versus
</p><table><tr><td> </td><td><pre class="example"><code> +(a,b) [the same as '+'(a,b) of arity two]</code>
</pre></td></tr></table>
</li><li>
In the first rule for term(0) no blank space should exist between
<i>atom</i> and '('.
</li><li>
<a name="IDX6"></a>
Each term to be read by the YAP parser must end with a single
dot, followed by a blank (in the sense mentioned in the previous
paragraph). When a name consisting of a single dot could be taken for
the end of term marker, the ambiguity should be avoided by surrounding the
dot with single quotes.
</li></ul>
<hr size="6">
<a name="Tokens"></a>
<a name="SEC13"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC12" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC14" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC11" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC11" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC22" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 3.2 Prolog Tokens </h2>
<p>Prolog tokens are grouped into the following categories:
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC14">3.2.1 Numbers</a></td><td> </td><td align="left" valign="top"> Integer and Floating-Point Numbers
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC17">3.2.2 Character Strings</a></td><td> </td><td align="left" valign="top"> Sequences of Characters
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC18">3.2.3 Atoms</a></td><td> </td><td align="left" valign="top"> Atomic Constants
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC19">3.2.4 Variables</a></td><td> </td><td align="left" valign="top"> Logical Variables
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC20">3.2.5 Punctuation Tokens</a></td><td> </td><td align="left" valign="top"> Tokens that separate other tokens
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC21">3.2.6 Layout</a></td><td> </td><td align="left" valign="top"> Comments and Other Layout Rules
</td></tr>
</table>
<hr size="6">
<a name="Numbers"></a>
<a name="SEC14"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC13" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC15" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC11" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC13" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC22" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 3.2.1 Numbers </h3>
<p>Numbers can be further subdivided into integer and floating-point numbers.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC15">3.2.1.1 Integers</a></td><td> </td><td align="left" valign="top"> How Integers are read and represented
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC16">3.2.1.2 Floating-point Numbers</a></td><td> </td><td align="left" valign="top"> Floating Point Numbers
</td></tr>
</table>
<hr size="6">
<a name="Integers"></a>
<a name="SEC15"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC14" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC16" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC11" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC14" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC22" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h4 class="subsubsection"> 3.2.1.1 Integers </h4>
<p>Integer numbers
are described by the following regular expression:
</p>
<table><tr><td> </td><td><pre class="example"><code>
<integer> := {<digit>+<single-quote>|0{xXo}}<alpha_numeric_char>+
</code>
</pre></td></tr></table>
<p>where {...} stands for optionality, <i>+</i> optional repetition (one or
more times), <i><digit></i> denotes one of the characters 0 ... 9, <i>|</i>
denotes or, and <i><single-quote></i> denotes the character "'". The digits
before the <i><single-quote></i> character, when present, form the number
basis, that can go from 0, 1 and up to 36. Letters from <code>A</code> to
<code>Z</code> are used when the basis is larger than 10.
</p>
<p>Note that if no basis is specified then base 10 is assumed. Note also
that the last digit of an integer token can not be immediately followed
by one of the characters 'e', 'E', or '.'.
</p>
<p>Following the ISO standard, YAP also accepts directives of the
form <code>0x</code> to represent numbers in hexadecimal base and of the form
<code>0o</code> to represent numbers in octal base. For usefulness,
YAP also accepts directives of the form <code>0X</code> to represent
numbers in hexadecimal base.
</p>
<p>Example:
the following tokens all denote the same integer
</p><table><tr><td> </td><td><pre class="example"><code>10 2'1010 3'101 8'12 16'a 36'a 0xa 0o12</code>
</pre></td></tr></table>
<p>Numbers of the form <code>0'a</code> are used to represent character
constants. So, the following tokens denote the same integer:
</p><table><tr><td> </td><td><pre class="example"><code>0'd 100</code>
</pre></td></tr></table>
<p>YAP (version No value for VERSION) supports integers that can fit
the word size of the machine. This is 32 bits in most current machines,
but 64 in some others, such as the Alpha running Linux or Digital
Unix. The scanner will read larger or smaller integers erroneously.
</p>
<hr size="6">
<a name="Floats"></a>
<a name="SEC16"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC15" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC17" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC11" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC14" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC22" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h4 class="subsubsection"> 3.2.1.2 Floating-point Numbers </h4>
<p>Floating-point numbers are described by:
</p>
<table><tr><td> </td><td><pre class="example"><code>
<float> := <digit>+{<dot><digit>+}
<exponent-marker>{<sign>}<digit>+
|<digit>+<dot><digit>+
{<exponent-marker>{<sign>}<digit>+}
</code>
</pre></td></tr></table>
<p>where <i><dot></i> denotes the decimal-point character '.',
<i><exponent-marker></i> denotes one of 'e' or 'E', and <i><sign></i> denotes
one of '+' or '-'.
</p>
<p>Examples:
</p><table><tr><td> </td><td><pre class="example"><code>10.0 10e3 10e-3 3.1415e+3</code>
</pre></td></tr></table>
<p>Floating-point numbers are represented as a double in the target
machine. This is usually a 64-bit number.
</p>
<hr size="6">
<a name="Strings"></a>
<a name="SEC17"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC16" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC18" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC11" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC13" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC22" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 3.2.2 Character Strings </h3>
<p>Strings are described by the following rules:
</p><table><tr><td> </td><td><pre class="example"> string --> '"' string_quoted_characters '"'
string_quoted_characters --> '"' '"' string_quoted_characters
string_quoted_characters --> '\'
escape_sequence string_quoted_characters
string_quoted_characters -->
string_character string_quoted_characters
escape_sequence --> 'a' | 'b' | 'r' | 'f' | 't' | 'n' | 'v'
escape_sequence --> '\' | '"' | ''' | '`'
escape_sequence --> at_most_3_octal_digit_seq_char '\'
escape_sequence --> 'x' at_most_2_hexa_digit_seq_char '\'
</pre></td></tr></table><p>where <code>string_character</code> in any character except the double quote
and escape characters.
</p>
<p>Examples:
</p><table><tr><td> </td><td><pre class="example"><code>"" "a string" "a double-quote:""" </code>
</pre></td></tr></table>
<p>The first string is an empty string, the last string shows the use of
double-quoting. The implementation of YAP represents strings as
lists of integers. Since Yap4.3.0 there is no static limit on string
size.
</p>
<p>Escape sequences can be used to include the non-printable characters
<code>a</code> (alert), <code>b</code> (backspace), <code>r</code> (carriage return),
<code>f</code> (form feed), <code>t</code> (horizontal tabulation), <code>n</code> (new
line), and <code>v</code> (vertical tabulation). Escape sequences also be
include the meta-characters <code>\</code>, <code>"</code>, <code>'</code>, and
<code>`</code>. Last, one can use escape sequences to include the characters
either as an octal or hexadecimal number.
</p>
<p>The next examples demonstrates the use of escape sequences in YAP:
</p>
<table><tr><td> </td><td><pre class="example"><code>"\x0c\" "\01\" "\f" "\\" </code>
</pre></td></tr></table>
<p>The first three examples return a list including only character 12 (form
feed). The last example escapes the escape character.
</p>
<p>Escape sequences were not available in C-Prolog and in original
versions of YAP up to 4.2.0. Escape sequences can be disable by using:
</p><table><tr><td> </td><td><pre class="example"><code>:- yap_flag(character_escapes,off).</code>
</pre></td></tr></table>
<hr size="6">
<a name="Atoms"></a>
<a name="SEC18"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC17" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC19" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC11" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC13" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC22" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 3.2.3 Atoms </h3>
<p>Atoms are defined by one of the following rules:
</p><table><tr><td> </td><td><pre class="example"> atom --> solo-character
atom --> lower-case-letter name-character*
atom --> symbol-character+
atom --> single-quote single-quote
atom --> ''' atom_quoted_characters '''
atom_quoted_characters --> ''' ''' atom_quoted_characters
atom_quoted_characters --> '\' atom_sequence string_quoted_characters
atom_quoted_characters --> character string_quoted_characters
</pre></td></tr></table>
<p>where:
</p><table><tr><td> </td><td><pre class="example"> <solo-character> denotes one of: ! ;
<symbol-character> denotes one of: # & * + - . / : <
= > ? @ \ ^ ` ~
<lower-case-letter> denotes one of: a...z
<name-character> denotes one of: _ a...z A...Z 0....9
<single-quote> denotes: '
</pre></td></tr></table>
<p>and <code>string_character</code> denotes any character except the double quote
and escape characters. Note that escape sequences in strings and atoms
follow the same rules.
</p>
<p>Examples:
</p><table><tr><td> </td><td><pre class="example"><code>a a12x '$a' ! => '1 2'</code>
</pre></td></tr></table>
<p>Version <code>4.2.0</code> of YAP removed the previous limit of 256
characters on an atom. Size of an atom is now only limited by the space
available in the system.
</p>
<hr size="6">
<a name="Variables"></a>
<a name="SEC19"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC18" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC20" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC11" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC13" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC22" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 3.2.4 Variables </h3>
<p>Variables are described by:
</p><table><tr><td> </td><td><pre class="example"> <variable-starter><variable-character>+
</pre></td></tr></table><p>where
</p><table><tr><td> </td><td><pre class="example"> <variable-starter> denotes one of: _ A...Z
<variable-character> denotes one of: _ a...z A...Z
</pre></td></tr></table>
<a name="IDX7"></a>
<p>If a variable is referred only once in a term, it needs not to be named
and one can use the character <code>_</code> to represent the variable. These
variables are known as anonymous variables. Note that different
occurrences of <code>_</code> on the same term represent <em>different</em>
anonymous variables.
</p>
<hr size="6">
<a name="Punctuation-Tokens"></a>
<a name="SEC20"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC19" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC21" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC11" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC13" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC22" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 3.2.5 Punctuation Tokens </h3>
<p>Punctuation tokens consist of one of the following characters:
</p><table><tr><td> </td><td><pre class="example"> ( ) , [ ] { } |
</pre></td></tr></table>
<p>These characters are used to group terms.
</p>
<hr size="6">
<a name="Layout"></a>
<a name="SEC21"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC20" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC22" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC11" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC13" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC22" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 3.2.6 Layout </h3>
<p>Any characters with ASCII code less than or equal to 32 appearing before
a token are ignored.
</p>
<p>All the text appearing in a line after the character <i>%</i> is taken to
be a comment and ignored (including <i>%</i>). Comments can also be
inserted by using the sequence <code>/*</code> to start the comment and
<code>*/</code> to finish it. In the presence of any sequence of comments or
layout characters, the YAP parser behaves as if it had found a
single blank character. The end of a file also counts as a blank
character for this purpose.
</p>
<hr size="6">
<a name="Loading-Programs"></a>
<a name="SEC22"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC21" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC23" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC11" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC26" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 4. Loading Programs </h1>
<table class="menu" border="0" cellspacing="0">
<p>Loading Programs
<a href="#SEC23">4.1 Program loading and updating</a> Program Loading and Updating
<a href="#SEC24">4.2 Changing the Compiler's Behavior</a> Changing the compiler's parameters
<a href="#SEC25">4.3 Saving and Loading Prolog States</a> Saving and Restoring Programs
</p>
</table>
<hr size="6">
<a name="Compiling"></a>
<a name="SEC23"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC22" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC24" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC22" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC22" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC26" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 4.1 Program loading and updating </h2>
<dl compact="compact">
<dt> <code>consult(<var>+F</var>)</code></dt>
<dd><a name="IDX8"></a>
<a name="IDX9"></a>
<a name="IDX10"></a>
<p>Adds the clauses written in file <var>F</var> or in the list of files <var>F</var>
to the program.
</p>
<p>In YAP <code>consult/1</code> does not remove previous clauses for
the procedures defined in <var>F</var>. Moreover, note that all code in YAP
is compiled.
</p>
</dd>
<dt> <code>reconsult(<var>+F</var>)</code></dt>
<dd><a name="IDX11"></a>
<a name="IDX12"></a>
<a name="IDX13"></a>
<p>Updates the program replacing the
previous definitions for the predicates defined in <var>F</var>.
</p>
</dd>
<dt> <code>[<var>+F</var>]</code></dt>
<dd><a name="IDX14"></a>
<a name="IDX15"></a>
<a name="IDX16"></a>
<p>The same as <code>consult(F)</code>.
</p>
</dd>
<dt> <code>[-<var>+F</var>]</code></dt>
<dd><a name="IDX17"></a>
<a name="IDX18"></a>
<a name="IDX19"></a>
<p>The same as <code>reconsult(F)</code>
</p>
<p>Example:
</p>
<table><tr><td> </td><td><pre class="example">?- [file1, -file2, -file3, file4].
</pre></td></tr></table>
<p>will consult <code>file1</code> <code>file4</code> and reconsult <code>file2</code> and
<code>file3</code>.
</p>
</dd>
<dt> <code>compile(<var>+F</var>)</code></dt>
<dd><a name="IDX20"></a>
<a name="IDX21"></a>
<a name="IDX22"></a>
<p>In YAP, the same as <code>reconsult/1</code>.
</p>
</dd>
<dt> <code>ensure_loaded(<var>+F</var>) [ISO]</code></dt>
<dd><a name="IDX23"></a>
<a name="IDX24"></a>
<a name="IDX25"></a>
<p>When the files specified by <var>F</var> are module files,
<code>ensure_loaded/1</code> loads them if they have note been previously
loaded, otherwise advertises the user about the existing name clashes
and prompts about importing or not those predicates. Predicates which
are not public remain invisible.
</p>
<p>When the files are not module files, <code>ensure_loaded/1</code> loads them
if they have not been loaded before, does nothing otherwise.
</p>
<p><var>F</var> must be a list containing the names of the files to load.
</p>
</dd>
<dt> <code>include(<var>+F</var>) [ISO]</code></dt>
<dd><a name="IDX26"></a>
<a name="IDX27"></a>
<a name="IDX28"></a>
<p>The <code>include</code> directive includes the text files or sequence of text
files specified by <var>F</var> into the file being currently consulted.
</p>
</dd>
</dl>
<hr size="6">
<a name="Setting-the-Compiler"></a>
<a name="SEC24"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC23" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC25" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC22" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC22" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC26" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 4.2 Changing the Compiler's Behavior </h2>
<p>This section presents a set of built-ins predicates designed to set the
environment for the compiler.
</p>
<dl compact="compact">
<dt> <code>source_mode(-<var>O</var>,+<var>N</var>)</code></dt>
<dd><a name="IDX29"></a>
<a name="IDX30"></a>
<a name="IDX31"></a>
<p>The state of source mode can either be on or off. When the source mode
is on, all clauses are kept both as compiled code and in a "hidden"
database. <var>O</var> is unified with the previous state and the mode is set
according to <var>N</var>.
</p>
</dd>
<dt> <code>source</code></dt>
<dd><a name="IDX32"></a>
<a name="IDX33"></a>
<a name="IDX34"></a>
<p>After executing this goal, YAP keeps information on the source
of the predicates that will be consulted. This enables the use of
<code>listing/0</code>, <code>listing/1</code> and <code>clause/2</code> for those
clauses.
</p>
<p>The same as <code>source_mode(_,on)</code> or as declaring all newly defined
static procedures as <code>public</code>.
</p>
</dd>
<dt> <code>no_source</code></dt>
<dd><a name="IDX35"></a>
<a name="IDX36"></a>
<a name="IDX37"></a>
<p>The opposite to <code>source</code>.
</p>
<p>The same as <code>source_mode(_,off)</code>.
</p>
</dd>
<dt> <code>compile_expressions</code></dt>
<dd><a name="IDX38"></a>
<a name="IDX39"></a>
<a name="IDX40"></a>
<p>After a call to this predicate, arithmetical expressions will be compiled.
(see example below). This is the default behavior.
</p>
</dd>
<dt> <code>do_not_compile_expressions</code></dt>
<dd><a name="IDX41"></a>
<a name="IDX42"></a>
<a name="IDX43"></a>
<p>After a call to this predicate, arithmetical expressions will not be compiled.
</p><table><tr><td> </td><td><pre class="example">?- source, do_not_compile_expressions.
yes
?- [user].
| p(X) :- X is 2 * (3 + 8).
| :- end_of_file.
?- compile_expressions.
yes
?- [user].
| q(X) :- X is 2 * (3 + 8).
| :- end_of_file.
:- listing.
p(A):-
A is 2 * (3 + 8).
q(A):-
A is 22.
</pre></td></tr></table>
</dd>
<dt> <code>hide(+<var>Atom</var>)</code></dt>
<dd><a name="IDX44"></a>
<a name="IDX45"></a>
<a name="IDX46"></a>
<p>Make atom <var>Atom</var> invisible.
</p>
</dd>
<dt> <code>unhide(+<var>Atom</var>)</code></dt>
<dd><a name="IDX47"></a>
<a name="IDX48"></a>
<a name="IDX49"></a>
<p>Make hidden atom <var>Atom</var> visible.
</p>
</dd>
<dt> <code>hide_predicate(+<var>Pred</var>)</code></dt>
<dd><a name="IDX50"></a>
<a name="IDX51"></a>
<a name="IDX52"></a>
<p>Make predicate <var>Pred</var> invisible to <code>current_predicate/2</code>,
<code>listing</code>, and friends.
</p>
</dd>
<dt> <code>expand_exprs(-<var>O</var>,+<var>N</var>)</code></dt>
<dd><a name="IDX53"></a>
<a name="IDX54"></a>
<a name="IDX55"></a>
<p>Puts YAP in state <var>N</var> (<code>on</code> or <code>off</code>) and unify
<var>O</var> with the previous state, where <var>On</var> is equivalent to
<code>compile_expressions</code> and <code>off</code> is equivalent to
<code>do_not_compile_expressions</code>. This predicate was kept to maintain
compatibility with C-Prolog.
</p>
</dd>
<dt> <code>path(-<var>D</var>)</code></dt>
<dd><a name="IDX56"></a>
<a name="IDX57"></a>
<a name="IDX58"></a>
<p>Unifies <var>D</var> with the current directory search-path of YAP.
Note that this search-path is only used by YAP to find the
files for <code>consult/1</code>, <code>reconsult/1</code> and <code>restore/1</code> and
should not be taken for the system search path.
</p>
</dd>
<dt> <code>add_to_path(+<var>D</var>)</code></dt>
<dd><a name="IDX59"></a>
<a name="IDX60"></a>
<a name="IDX61"></a>
<p>Adds <var>D</var> to the end of YAP's directory search path.
</p>
</dd>
<dt> <code>add_to_path(+<var>D</var>,+<var>N</var>)</code></dt>
<dd><a name="IDX62"></a>
<a name="IDX63"></a>
<a name="IDX64"></a>
<p>Inserts <var>D</var> in the position, of the directory search path of
YAP, specified by <var>N</var>. <var>N</var> must be either of
<code>first</code> or <code>last</code>.
</p>
</dd>
<dt> <code>remove_from_path(+<var>D</var>)</code></dt>
<dd><a name="IDX65"></a>
<a name="IDX66"></a>
<a name="IDX67"></a>
<p>Remove <var>D</var> from YAP's directory search path.
</p>
</dd>
<dt> <code>style_check(+<var>X</var>)</code></dt>
<dd><a name="IDX68"></a>
<a name="IDX69"></a>
<a name="IDX70"></a>
<p>Turns on style checking according to the attribute specified by <var>X</var>,
which must be one of the following:
</p><dl compact="compact">
<dt> <code>single_var</code></dt>
<dd><p>Checks single occurrences of named variables in a clause.
</p></dd>
<dt> <code>discontiguous</code></dt>
<dd><p>Checks non-contiguous clauses for the same predicate in a file.
</p></dd>
<dt> <code>multiple</code></dt>
<dd><p>Checks the presence of clauses for the same predicate in more than one
file when the predicate has not been declared as <code>multifile</code>
</p></dd>
<dt> <code>all</code></dt>
<dd><p>Performs style checking for all the cases mentioned above.
</p></dd>
</dl>
<p>By default, style checking is disabled in YAP unless we are in
<code>sicstus</code> or <code>iso</code> language mode.
</p>
<p>The <code>style_check/1</code> built-in is now deprecated. Please use the
<code>set_prolog_flag/1</code> instead.
</p>
</dd>
<dt> <code>no_style_check(+<var>X</var>)</code></dt>
<dd><a name="IDX71"></a>
<a name="IDX72"></a>
<a name="IDX73"></a>
<p>Turns off style checking according to the attribute specified by
<var>X</var>, which has the same meaning as in <code>style_check/1</code>.
</p>
<p>The <code>no_style_check/1</code> built-in is now deprecated. Please use the
<code>set_prolog_flag/1</code> instead.
</p>
</dd>
<dt> <code>multifile <var>P</var> [ISO]</code></dt>
<dd><a name="IDX74"></a>
<a name="IDX75"></a>
<a name="IDX76"></a>
<p>Instructs the compiler about the declaration of a predicate <var>P</var> in
more than one file. It must appear in the first of the loaded files
where the predicate is declared, and before declaration of any of its
clauses.
</p>
<p>Multifile declarations affect <code>reconsult/1</code> and <code>compile/1</code>:
when a multifile predicate is reconsulted, only the clauses from the
same file are removed.
</p>
<p>Since Yap4.3.0 multifile procedures can be static or dynamic.
</p>
</dd>
<dt> <code>discontiguous(+<var>G</var>) [ISO]</code></dt>
<dd><a name="IDX77"></a>
<a name="IDX78"></a>
<a name="IDX79"></a>
<p>Declare that the arguments are discontiguous procedures, that is,
clauses for discontigous procedures may be separated by clauses from
other procedures.
</p>
</dd>
<dt> <code>initialization(+<var>G</var>) [ISO]</code></dt>
<dd><a name="IDX80"></a>
<a name="IDX81"></a>
<a name="IDX82"></a>
<p>The compiler will execute goals <var>G</var> after consulting the current
file.
</p>
</dd>
<dt> <code>library_directory(+<var>D</var>)</code></dt>
<dd><a name="IDX83"></a>
<a name="IDX84"></a>
<a name="IDX85"></a>
<p>Succeeds when <var>D</var> is a current library directory name. Library
directories are the places where files specified in the form
<code>library(<var>File</var>)</code> are searched by the predicates
<code>consult/1</code>, <code>reconsult/1</code>, <code>use_module/1</code> or
<code>ensure_loaded/1</code>.
</p>
</dd>
<dt> <code>file_search_path(+<var>NAME</var>,-<var>DIRECTORY</var>)</code></dt>
<dd><a name="IDX86"></a>
<a name="IDX87"></a>
<a name="IDX88"></a>
<p>Allows writing file names as compound terms. The <var>NAME</var> and
<var>DIRECTORY</var> must be atoms. The predicate may generate multiple
solutions. The predicate is originally defined as follows:
</p>
<table><tr><td> </td><td><pre class="example">file_search_path(library,A) :-
library_directory(A).
file_search_path(system,A) :-
prolog_flag(host_type,A).
</pre></td></tr></table>
<p>Thus, [library(A)] will search for a file using
<var>library_directory</var>/1 to obtain the prefix.
</p>
</dd>
<dt> <code>library_directory(+<var>D</var>)</code></dt>
<dd><a name="IDX89"></a>
<a name="IDX90"></a>
<a name="IDX91"></a>
<p>Succeeds when <var>D</var> is a current library directory name. Library
directories are the places where files specified in the form
<code>library(<var>File</var>)</code> are searched by the predicates
<code>consult/1</code>, <code>reconsult/1</code>, <code>use_module/1</code> or
<code>ensure_loaded/1</code>.
</p>
</dd>
<dt> <code>prolog_file_name(+<var>Name</var>,-<var>FullPath</var>)</code></dt>
<dd><a name="IDX92"></a>
<a name="IDX93"></a>
<a name="IDX94"></a>
<p>Unify <var>FullPath</var> with the absolute path YAP would use to consult
file <var>Name</var>.
</p>
</dd>
<dt> <code>public <var>P</var> [ISO]</code></dt>
<dd><a name="IDX95"></a>
<a name="IDX96"></a>
<a name="IDX97"></a>
<p>Instructs the compiler that the source of a predicate of a list of
predicates <var>P</var> must be kept. This source is then accessible through
the <code>clause/2</code> procedure and through the <code>listing</code> family of
built-ins.
</p>
<p>Note that all dynamic procedures are public. The <code>source</code> directive
defines all new or redefined predicates to be public.
</p>
<p>Since Yap4.3.0 multifile procedures can be static or dynamic.
</p>
</dd>
</dl>
<hr size="6">
<a name="Saving"></a>
<a name="SEC25"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC24" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC26" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC22" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC22" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC26" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 4.3 Saving and Loading Prolog States </h2>
<dl compact="compact">
<dt> <code>save(+<var>F</var>)</code></dt>
<dd><a name="IDX98"></a>
<a name="IDX99"></a>
<a name="IDX100"></a>
<p>Saves an image of the current state of YAP in file <var>F</var>. From
<strong>Yap4.1.3</strong> onwards, YAP saved states are executable
files in the Unix ports.
</p>
</dd>
<dt> <code>save(+<var>F</var>,-<var>OUT</var>)</code></dt>
<dd><a name="IDX101"></a>
<a name="IDX102"></a>
<a name="IDX103"></a>
<p>Saves an image of the current state of YAP in file <var>F</var>. From
<strong>Yap4.1.3</strong> onwards, YAP saved states are executable
files in the Unix ports.
</p>
<p>Unify <var>OUT</var> with 1 when saving the file and <var>OUT</var> with 0 when
restoring the saved state.
</p>
</dd>
<dt> <code>save_program(+<var>F</var>)</code></dt>
<dd><a name="IDX104"></a>
<a name="IDX105"></a>
<a name="IDX106"></a>
<p>Saves an image of the current state of the YAP database in file
<var>F</var>.
</p>
</dd>
<dt> <code>save_program(+<var>F</var>, :<var>G</var>)</code></dt>
<dd><a name="IDX107"></a>
<a name="IDX108"></a>
<a name="IDX109"></a>
<p>Saves an image of the current state of the YAP database in file
<var>F</var>, and guarantee that execution of the restored code will start by
trying goal <var>G</var>.
</p>
</dd>
<dt> <code>restore(+<var>F</var>)</code></dt>
<dd><a name="IDX110"></a>
<a name="IDX111"></a>
<a name="IDX112"></a>
<p>Restores a previously saved state of YAP from file <var>F</var>.
</p>
<p>YAP always tries to find saved states from the current directory
first. If it cannot it will use the environment variable YAPLIBDIR, if
defined, or search the default library directory.
</p></dd>
</dl>
<hr size="6">
<a name="Modules"></a>
<a name="SEC26"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC25" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC27" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC22" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC31" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 5. The Module System </h1>
<p>Module systems are quite important for the development of large
applications. YAP implements a module system compatible with the Quintus
Prolog module system.
</p>
<p>The YAP module system is predicate-based. This means a module consists
of a set of predicates (or procedures), such that some predicates are
public and the others are local to a module. Atoms and terms in general
are global to the system. Moreover, the module system is flat, meaning
that we do not support an hierarchy of modules. Modules can
automatically import other modules, though. For compatibility with other
module systems the YAP module system is non-strict, meaning both that
there is both a way to access predicates private to a module and that is
possible to declare predicates for a module from some other module.
</p>
<p>YAP allows one to ignore the module system if one does not want to use
it. Last note that using the module system does not introduce any
significant overheads: only meta-calls that cross module boundaries are
slowed down by the presence of modules.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC27">5.1 Module Concepts</a></td><td> </td><td align="left" valign="top"> The Key Ideas in Modules
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC28">5.2 Defining a New Module</a></td><td> </td><td align="left" valign="top"> How To Define a New Module
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC29">5.3 Using Modules</a></td><td> </td><td align="left" valign="top"> How to Use a Module
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC30">5.4 Meta-Predicates in Modules</a></td><td> </td><td align="left" valign="top"> How to Handle New Meta-Predicates
</td></tr>
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
</pre></th></tr></table>
<hr size="6">
<a name="Module-Concepts"></a>
<a name="SEC27"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC26" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC28" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC26" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC26" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC31" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 5.1 Module Concepts </h2>
<p>The YAP module system applies to predicates. All predicates belong to a
module. System predicates belong to the module <code>primitives</code>, and by
default new predicates belong to the module <code>user</code>. Predicates from
the module <code>primitives</code> are automatically visible to every module.
</p>
<p>Every predicate must belong to a module. This module is called its
<em>source module</em>.
</p>
<p>By default, the source module for a clause occurring in a source file
with a module declaration is the declared module. For goals typed in
a source file without module declarations, their module is the module
the file is being loaded into. If no module declarations exist, this is
the current <em>type-in module</em>. The default type-in module is
<code>user</code>, but one can set the current module by using the built-in
<code>module/1</code>.
</p>
<p>Note that in this module system one can explicitly specify the source
mode for a clause by prefixing a clause with its module, say:
</p><table><tr><td> </td><td><pre class="example">user:(a :- b).
</pre></td></tr></table>
<p>In fact, to specify the source module for a clause it is sufficient to
specify the source mode for the clause's head:
</p><table><tr><td> </td><td><pre class="example">user:a :- b.
</pre></td></tr></table>
<p>The rules for goals are similar. If a goal appears in a text file with a
module declaration, the goal's source module is the declared
module. Otherwise, it is the module the file is being loaded into or the
type-in module.
</p>
<p>One can override this rule by prefixing a goal with the module it is
supposed to be executed into, say:
</p><table><tr><td> </td><td><pre class="example">nasa:launch(apollo,13).
</pre></td></tr></table><p>will execute the goal <code>launch(apollo,13)</code> as if the current source
module was <code>nasa</code>.
</p>
<p>Note that this rule breaks encapsulation and should be used with care.
</p>
<hr size="6">
<a name="Defining-Modules"></a>
<a name="SEC28"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC27" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC29" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC26" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC26" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC31" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 5.2 Defining a New Module </h2>
<p>A new module is defined by a <code>module</code> declaration:
</p>
<dl compact="compact">
<dt> <code>module(+<var>M</var>,+<var>L</var>)</code></dt>
<dd><a name="IDX113"></a>
<a name="IDX114"></a>
<a name="IDX115"></a>
<p>This predicate defines the file where it appears as a module file; it
must be the first declaration in the file.
<var>M</var> must be an atom specifying the module name; <var>L</var> must be a list
containing the module's public predicates specification, in the form
<code>[predicate_name/arity,...]</code>.
</p>
<p>The public predicates of a module file can be made accessible by other
files through the predicates <code>consult/1</code>, <code>reconsult/1</code>,
<code>ensure_loaded/1</code> or <code>use_module/2</code>. The non-public predicates
of a module file are not visible by other files; they can, however, be
accessed if the module name is prefixed to the file name through the
<code>:/2</code> operator.
</p>
</dd>
</dl>
<p>The built-in <code>module/1</code> sets the current source module:
</p><dl compact="compact">
<dt> <code>module(+<var>M</var>,+<var>L</var>, +<var>Options</var>)</code></dt>
<dd><a name="IDX116"></a>
<a name="IDX117"></a>
<a name="IDX118"></a>
<p>Similar to <code>module/2</code>, this predicate defines the file where it
appears as a module file; it must be the first declaration in the file.
<var>M</var> must be an atom specifying the module name; <var>L</var> must be a
list containing the module's public predicates specification, in the
form <code>[predicate_name/arity,...]</code>.
</p>
<p>The last argument <var>Options</var> must be a list of options, which can be:
</p>
<dl compact="compact">
<dt> <code>filename</code></dt>
<dd><p> the filename for a module to import into the current module.
</p>
</dd>
<dt> <code>library(file)</code></dt>
<dd><p> a library file to import into the current module.
</p>
</dd>
<dt> <code>hide(<var>Opt</var>)</code></dt>
<dd><p> if <var>Opt</var> is <code>false</code>, keep source code for current module, if
<code>true</code>, disable.
</p></dd>
</dl>
</dd>
<dt> <code>module(+<var>M</var>)</code></dt>
<dd><a name="IDX119"></a>
<a name="IDX120"></a>
<a name="IDX121"></a>
<p>Defines <var>M</var> to be the current working or type-in module. All files
which are not binded to a module are assumed to belong to the working
module (also referred to as type-in module). To compile a non-module
file into a module which is not the working one, prefix the file name
with the module name, in the form <code><var>Module</var>:<var>File</var></code>, when
loading the file.
</p>
</dd>
</dl>
<hr size="6">
<a name="Using-Modules"></a>
<a name="SEC29"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC28" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC30" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC26" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC26" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC31" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 5.3 Using Modules </h2>
<p>By default, all procedures to consult a file will load the modules
defined therein. The two following declarations allow one to import a
module explicitly. They differ on whether one imports all predicate
declared in the module or not.
</p>
<dl compact="compact">
<dt> <code>use_module(+<var>F</var>)</code></dt>
<dd><a name="IDX122"></a>
<a name="IDX123"></a>
<a name="IDX124"></a>
<p>Loads the files specified by <var>F</var>, importing all their public
predicates. Predicate name clashes are resolved by asking the user about
importing or not the predicate. A warning is displayed when <var>F</var> is
not a module file.
</p>
</dd>
<dt> <code>use_module(+<var>F</var>,+<var>L</var>)</code></dt>
<dd><a name="IDX125"></a>
<a name="IDX126"></a>
<a name="IDX127"></a>
<p>Loads the files specified by <var>F</var>, importing the predicates specified
in the list <var>L</var>. Predicate name clashes are resolved by asking the
user about importing or not the predicate. A warning is displayed when
<var>F</var> is not a module file.
</p>
</dd>
<dt> <code>use_module(?<var>M</var>,?<var>F</var>,+<var>L</var>)</code></dt>
<dd><a name="IDX128"></a>
<a name="IDX129"></a>
<a name="IDX130"></a>
<p>If module <var>M</var> has been defined, import the procedures in <var>L</var> to
the current module. Otherwise, load the files specified by <var>F</var>,
importing the predicates specified in the list <var>L</var>.
</p></dd>
</dl>
<hr size="6">
<a name="Meta_002dPredicates-in-Modules"></a>
<a name="SEC30"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC29" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC31" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC26" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC26" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC31" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 5.4 Meta-Predicates in Modules </h2>
<p>The module system must know whether predicates operate on goals or
clauses. Otherwise, such predicates would call a goal in the module they
were defined, instead of calling it in the module they are currently
executing. So, for instance:
</p><table><tr><td> </td><td><pre class="example">:- module(example,[a/1]).
...
a(G) :- call(G)
...
</pre></td></tr></table><p>The expected behavior for this procedure is to execute goal <var>G</var>
within the current module, that is, within <code>example</code>.
On the other hand, when executing <code>call/1</code> the system only knows
where <code>call/1</code> was defined, that is, it only knows of
<code>primitives</code>. A similar problem arises for <code>assert/1</code> and
friends.
</p>
<p>The <code>meta_predicate/1</code> declaration informs the system that some
arguments of a procedure are goals, clauses or clauses heads, and that
these arguments must be expanded to receive the current source module:
</p>
<dl compact="compact">
<dt> <code>meta_predicate <var>G1</var>,....,<var>Gn</var></code></dt>
<dd><a name="IDX131"></a>
<a name="IDX132"></a>
<a name="IDX133"></a>
<p>Each <var>Gi</var> is a mode specification. For example, a declaration for
<code>call/1</code> and <code>setof/3</code> would be of the form:
</p>
<table><tr><td> </td><td><pre class="example">:- meta_predicate call(:), setof(?,:,?).
</pre></td></tr></table>
<p>If the argument is <code>:</code> or an integer, the argument is a call and
must be expanded. Otherwise, the argument should not be expanded. Note
that the system already includes declarations for all built-ins.
</p>
</dd>
</dl>
<p>In the previous example, the only argument to <code>call/1</code> must be
expanded, resulting in the following code:
</p>
<table><tr><td> </td><td><pre class="example">:- module(example,[a/1]).
...
a(G) :- call(example:G)
...
</pre></td></tr></table>
<hr size="6">
<a name="Builtins"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC30" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC32" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC26" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="SEC31"></a>
<h1 class="chapter"> 6. Built-In Predicates </h1>
<table class="menu" border="0" cellspacing="0">
<p>Builtins, Debugging, Syntax, Top
<a href="#SEC32">6.1 Control Predicates</a> Controlling the Execution of Prolog Programs
<a href="#SEC33">6.2 Handling Undefined Procedures</a> Handling calls to Undefined Procedures
<a href="#SEC34">6.3 Predicates on terms</a> Predicates on Terms
<a href="#SEC35">6.4 Comparing Terms</a> Comparison of Terms
<a href="#SEC36">6.5 Arithmetic</a> Arithmetic in Yap
<a href="#SEC37">6.6 I/O Predicates</a> Input/Output with Yap
<a href="#SEC46">6.7 Using the Clausal Data Base</a> Modifying Prolog's Database
<a href="#SEC52">6.10 Collecting Solutions to a Goal</a> Finding All Possible Solutions
<a href="#SEC53">6.11 Grammar Rules</a> Grammar Rules
<a href="#SEC59">6.17 Predicate Information</a> Predicate Information
<a href="#SEC54">6.12 Access to Operating System Functionality</a> Access to Operating System Functionality
<a href="#SEC55">6.13 Term Modification</a> Updating Prolog Terms
<a href="#SEC56">6.14 Profiling Prolog Programs</a> Profiling Prolog Execution
<a href="#SEC57">6.15 Counting Calls</a> Limiting the Maximum Number of Reductions
<a href="#SEC58">6.16 Arrays</a> Supporting Global and Local Arrays
<a href="#SEC59">6.17 Predicate Information</a> Information on Predicates
<a href="#SEC60">6.18 Miscellaneous</a> Miscellaneous Predicates
</p>
</table>
<hr size="6">
<a name="Control"></a>
<a name="SEC32"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC31" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC33" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC31" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC31" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 6.1 Control Predicates </h2>
<p>This chapter describes the predicates for controlling the execution of
Prolog programs.
</p>
<p>In the description of the arguments of functors the following notation
will be used:
</p>
<ul>
<li>
a preceding plus sign will denote an argument as an "input argument" -
it cannot be a free variable at the time of the call;
</li><li>
a preceding minus sign will denote an "output argument";
</li><li>
an argument with no preceding symbol can be used in both ways.
</li></ul>
<dl compact="compact">
<dt> <code>+<var>P</var>, +<var>Q</var> [ISO]</code></dt>
<dd><a name="IDX134"></a>
<a name="IDX135"></a>
<a name="IDX136"></a>
<p>Conjunction of goals (and).
</p>
<p>Example:
</p><table><tr><td> </td><td><pre class="example"> p(X) :- q(X), r(X).
</pre></td></tr></table>
<p>should be read as "p(<var>X</var>) if q(<var>X</var>) and r(<var>X</var>)".
</p>
</dd>
<dt> <code>+<var>P</var> ; +<var>Q</var> [ISO]</code></dt>
<dd><a name="IDX137"></a>
<a name="IDX138"></a>
<a name="IDX139"></a>
<p>Disjunction of goals (or).
</p>
<p>Example:
</p><table><tr><td> </td><td><pre class="example"> p(X) :- q(X); r(X).
</pre></td></tr></table>
<p>should be read as "p(<var>X</var>) if q(<var>X</var>) or r(<var>X</var>)".
</p>
</dd>
<dt> <code>true [ISO]</code></dt>
<dd><a name="IDX140"></a>
<a name="IDX141"></a>
<a name="IDX142"></a>
<p>Succeeds once.
</p>
</dd>
<dt> <code>fail [ISO]</code></dt>
<dd><a name="IDX143"></a>
<a name="IDX144"></a>
<a name="IDX145"></a>
<p>Fails always.
</p>
</dd>
<dt> <code>false</code></dt>
<dd><a name="IDX146"></a>
<a name="IDX147"></a>
<a name="IDX148"></a>
<p>The same as fail
</p>
</dd>
<dt> <code>! [ISO]</code></dt>
<dd><a name="IDX149"></a>
<a name="IDX150"></a>
<a name="IDX151"></a>
<p> Read as "cut". Cuts any choices taken in the current procedure.
When first found "cut" succeeds as a goal, but if backtracking should
later return to it, the parent goal (the one which matches the head of
the clause containing the "cut", causing the clause activation) will
fail. This is an extra-logical predicate and cannot be explained in
terms of the declarative semantics of Prolog.
</p>
<p>example:
</p>
<table><tr><td> </td><td><pre class="example"> member(X,[X|_]).
member(X,[_|L]) :- member(X,L).
</pre></td></tr></table>
<p>With the above definition
</p>
<table><tr><td> </td><td><pre class="example"> ?- member(X,[1,2,3]).
</pre></td></tr></table>
<p>will return each element of the list by backtracking. With the following
definition:
</p>
<table><tr><td> </td><td><pre class="example"> member(X,[X|_]) :- !.
member(X,[_|L]) :- member(X,L).
</pre></td></tr></table>
<p>the same query would return only the first element of the
list, since backtracking could not "pass through" the cut.
</p>
</dd>
<dt> <code>\+ +<var>P</var> [ISO]</code></dt>
<dd><a name="IDX152"></a>
<a name="IDX153"></a>
<a name="IDX154"></a>
<p>Goal <var>P</var> is not provable. The execution of this predicate fails if
and only if the goal <var>P</var> finitely succeeds. It is not a true logical
negation, which is impossible in standard Prolog, but
"negation-by-failure".
</p>
<p>This predicate might be defined as:
</p><table><tr><td> </td><td><pre class="example"> \+(P) :- P, !, fail.
\+(_).
</pre></td></tr></table>
<p>if <var>P</var> did not include "cuts".
</p>
</dd>
<dt> <code>not +<var>P</var></code></dt>
<dd><a name="IDX155"></a>
<a name="IDX156"></a>
<a name="IDX157"></a>
<p>Goal <var>P</var> is not provable. The same as <code>'\+ <var>P</var>'</code>.
</p>
<p>This predicate is kept for compatibility with C-Prolog and previous
versions of YAP. Uses of <code>not/1</code> should be replace by
<code>(\+)/1</code>, as YAP does not implement true negation.
</p>
</dd>
<dt> <code>+<var>P</var> -> +<var>Q</var> [ISO]</code></dt>
<dd><a name="IDX158"></a>
<a name="IDX159"></a>
<a name="IDX160"></a>
<p>Read as "if-then-else" or "commit". This operator is similar to the
conditional operator of imperative languages and can be used alone or
with an else part as follows:
</p>
<dl compact="compact">
<dt> <code>+P -> +Q</code></dt>
<dd><p>"if P then Q".
</p></dd>
<dt> <code>+P -> +Q; +R</code></dt>
<dd><p>"if P then Q else R".
</p></dd>
</dl>
<p>These two predicates could be defined respectively in Prolog as:
</p><table><tr><td> </td><td><pre class="example"> (P -> Q) :- P, !, Q.
</pre></td></tr></table>
<p>and
</p><table><tr><td> </td><td><pre class="example"> (P -> Q; R) :- P, !, Q.
(P -> Q; R) :- R.
</pre></td></tr></table>
<p>if there were no "cuts" in <var>P</var>, <var>Q</var> and <var>R</var>.
</p>
<p>Note that the commit operator works by "cutting" any alternative
solutions of <var>P</var>.
</p>
<p>Note also that you can use chains of commit operators like:
</p><table><tr><td> </td><td><pre class="example"> P -> Q ; R -> S ; T.
</pre></td></tr></table>
<p>Note that <code>(->)/2</code> does not affect the scope of cuts in its
arguments.
</p>
</dd>
<dt> <code>repeat [ISO]</code></dt>
<dd><a name="IDX161"></a>
<a name="IDX162"></a>
<a name="IDX163"></a>
<p>Succeeds repeatedly.
</p>
<p>In the next example, <code>repeat</code> is used as an efficient way to implement
a loop. The next example reads all terms in a file:
</p>
<table><tr><td> </td><td><pre class="example"> a :- repeat, read(X), write(X), nl, X=end_of_file, !.
</pre></td></tr></table>
<p>the loop is effectively terminated by the cut-goal, when the test-goal
<code>X=end</code> succeeds. While the test fails, the goals <code>read(X)</code>,
<code>write(X)</code>, and <code>nl</code> are executed repeatedly, because
backtracking is caught by the <code>repeat</code> goal.
</p>
<p>The built-in <code>repeat/1</code> could be defined in Prolog by:
</p><table><tr><td> </td><td><pre class="example"> repeat.
repeat :- repeat.
</pre></td></tr></table>
</dd>
<dt> <code>call(+<var>P</var>) [IS0]</code></dt>
<dd><a name="IDX164"></a>
<a name="IDX165"></a>
<a name="IDX166"></a>
<p> If <var>P</var> is instantiated to an atom or a compound term, the goal
<code>call(<var>P</var>)</code> is executed as if the value of <code>P</code> was found
instead of the call to <code>call/1</code>, except that any "cut" occurring in
<var>P</var> only cuts alternatives in the execution of <var>P</var>.
</p>
</dd>
<dt> <code>incore(+<var>P</var>)</code></dt>
<dd><a name="IDX167"></a>
<a name="IDX168"></a>
<a name="IDX169"></a>
<p>The same as <code>call/1</code>.
</p>
</dd>
<dt> <code>call_with_args(+<var>Name</var>,...,?<var>Ai</var>,...)</code></dt>
<dd><a name="IDX170"></a>
<a name="IDX171"></a>
<a name="IDX172"></a>
<p>Meta-call where <var>Name</var> is the name of the procedure to be called and
the <var>Ai</var> are the arguments. The number of arguments varies between 0
and 10.
</p>
<p>If <var>Name</var> is a complex term, then <code>call_with_args/n</code> behaves as
<code>call/n</code>:
</p>
<table><tr><td> </td><td><pre class="example">call(p(X1,...,Xm), Y1,...,Yn) :- p(X1,...,Xm,Y1,...,Yn).
</pre></td></tr></table>
</dd>
<dt> <code>+<var>P</var></code></dt>
<dd><p> The same as <code>call(<var>P</var>)</code>. This feature has been kept to provide
compatibility with C-Prolog. When compiling a goal, YAP
generates a <code>call(<var>X</var>)</code> whenever a variable <var>X</var> is found as
a goal.
</p>
<table><tr><td> </td><td><pre class="example"> a(X) :- X.
</pre></td></tr></table>
<p>is converted to:
</p><table><tr><td> </td><td><pre class="example"> a(X) :- call(X).
</pre></td></tr></table>
</dd>
<dt> <code>if(?<var>G</var>,?<var>H</var>,?<var>I</var>) [IS0]</code></dt>
<dd><a name="IDX173"></a>
<a name="IDX174"></a>
<a name="IDX175"></a>
<p>Call goal <var>H</var> once per each solution of goal <var>H</var>. If goal
<var>H</var> has no solutions, call goal <var>I</var>.
</p>
<p>The built-in <code>if/3</code> is similar to <code>->/3</code>, with the difference
that it will backtrack over the test goal. Consider the following
small data-base:
</p>
<table><tr><td> </td><td><pre class="example">a(1). b(a). c(x).
a(2). b(b). c(y).
</pre></td></tr></table>
<p>Execution of an <code>if/3</code> query will proceed as follows:
</p>
<table><tr><td> </td><td><pre class="example"> ?- if(a(X),b(Y),c(Z)).
X = 1,
Y = a ? ;
X = 1,
Y = b ? ;
X = 2,
Y = a ? ;
X = 2,
Y = b ? ;
no
</pre></td></tr></table>
<p>The system will backtrack over the two solutions for <code>a/1</code> and the
two solutions for <code>b/1</code>, generating four solutions.
</p>
<p>Cuts are allowed inside the first goal <var>G</var>, but they will only prune
over <var>G</var>.
</p>
<p>If you want <var>G</var> to be deterministic you should use if-then-else, as
it is both more efficient and more portable.
</p>
</dd>
<dt> <code>once(:<var>G</var>) [IS0]</code></dt>
<dd><a name="IDX176"></a>
<a name="IDX177"></a>
<a name="IDX178"></a>
<p>Execute the goal <var>G</var> only once. The predicate is defined by:
</p>
<table><tr><td> </td><td><pre class="example"> once(G) :- call(G), !.
</pre></td></tr></table>
<p>Note that cuts inside <code>once/1</code> can only cut the other goals inside
<code>once/1</code>.
</p>
</dd>
<dt> <code>abort</code></dt>
<dd><a name="IDX179"></a>
<a name="IDX180"></a>
<a name="IDX181"></a>
<p>Abandons the execution of the current goal and returns to top level. All
break levels (see <code>break/0</code> below) are terminated. It is mainly
used during debugging or after a serious execution error, to return to
the top-level.
</p>
</dd>
<dt> <code>break</code></dt>
<dd><a name="IDX182"></a>
<a name="IDX183"></a>
<a name="IDX184"></a>
<p>Suspends the execution of the current goal and creates a new execution
level similar to the top level, displaying the following message:
</p>
<table><tr><td> </td><td><pre class="example"> [ Break (level <number>) ]
</pre></td></tr></table>
<p>telling the depth of the break level just entered. To return to the
previous level just type the end-of-file character or call the
end_of_file predicate. This predicate is especially useful during
debugging.
</p>
</dd>
<dt> <code>halt [ISO]</code></dt>
<dd><a name="IDX185"></a>
<a name="IDX186"></a>
<a name="IDX187"></a>
<p>Halts Prolog, and exits to the calling application. In YAP,
<code>halt/0</code> returns the exit code <code>0</code>.
</p>
</dd>
<dt> <code>halt(+ <var>I</var>) [ISO]</code></dt>
<dd><a name="IDX188"></a>
<a name="IDX189"></a>
<a name="IDX190"></a>
<p>Halts Prolog, and exits to the calling application returning the code
given by the integer <var>I</var>.
</p>
</dd>
<dt> <code>catch(+<var>Goal</var>,+<var>Exception</var>,+<var>Action</var>) [IS0]</code></dt>
<dd><a name="IDX191"></a>
<a name="IDX192"></a>
<a name="IDX193"></a>
<p>The goal <code>catch(<var>Goal</var>,<var>Exception</var>,<var>Action</var>)</code> tries to
execute goal <var>Goal</var>. If during its execution, <var>Goal</var> throws an
exception <var>E'</var> and this exception unifies with <var>Exception</var>, the
exception is considered to be caught and <var>Action</var> is executed. If
the exception <var>E'</var> does not unify with <var>Exception</var>, control
again throws the exception.
</p>
<p>The top-level of YAP maintains a default exception handler that
is responsible to capture uncaught exceptions.
</p>
</dd>
<dt> <code>throw(+<var>Ball</var>) [ISO]</code></dt>
<dd><a name="IDX194"></a>
<a name="IDX195"></a>
<a name="IDX196"></a>
<p>The goal <code>throw(<var>Ball</var>)</code> throws an exception. Execution is
stopped, and the exception is sent to the ancestor goals until reaching
a matching <code>catch/3</code>, or until reaching top-level.
</p>
</dd>
<dt> <code>garbage_collect</code></dt>
<dd><a name="IDX197"></a>
<a name="IDX198"></a>
<a name="IDX199"></a>
<p>The goal <code>garbage_collect</code> forces a garbage collection.
</p>
</dd>
<dt> <code>garbage_collect_atoms</code></dt>
<dd><a name="IDX200"></a>
<a name="IDX201"></a>
<a name="IDX202"></a>
<p>The goal <code>garbage_collect</code> forces a garbage collection of the atoms
in the data-base. Currently, only atoms are recovered.
</p>
</dd>
<dt> <code>gc</code></dt>
<dd><a name="IDX203"></a>
<a name="IDX204"></a>
<a name="IDX205"></a>
<p>The goal <code>gc</code> enables garbage collection. The same as
<code>yap_flag(gc,on)</code>.
</p>
</dd>
<dt> <code>nogc</code></dt>
<dd><a name="IDX206"></a>
<a name="IDX207"></a>
<a name="IDX208"></a>
<p>The goal <code>nogc</code> disables garbage collection. The same as
<code>yap_flag(gc,off)</code>.
</p>
</dd>
<dt> <code>grow_heap(+<var>Size</var>)</code></dt>
<dd><a name="IDX209"></a>
<a name="IDX210"></a>
<p>Increase heap size <var>Size</var> kilobytes.
</p>
</dd>
<dt> <code>grow_stack(+<var>Size</var>)</code></dt>
<dd><a name="IDX211"></a>
<a name="IDX212"></a>
<a name="IDX213"></a>
<p>Increase stack size <var>Size</var> kilobytes.
</p>
</dd>
</dl>
<hr size="6">
<a name="Undefined-Procedures"></a>
<a name="SEC33"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC32" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC34" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC31" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC31" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 6.2 Handling Undefined Procedures </h2>
<p>A predicate in a module is said to be undefined if there are no clauses
defining the predicate, and if the predicate has not been declared to be
dynamic. What YAP does when trying to execute undefined predicates can
be specified through three different ways:
</p><ul>
<li> By setting an YAP flag, through the <code>yap_flag/2</code> or
<code>set_prolog_flag/2</code> built-ins. This solution generalizes the
ISO standard.
</li><li> By using the <code>unknown/2</code> built-in (this solution is
compatible with previous releases of YAP).
</li><li> By defining clauses for the hook predicate
<code>user:unknown_predicate_handler/3</code>. This solution is compatible
with SICStus Prolog.
</li></ul>
<p>In more detail:
</p><dl compact="compact">
<dt> <code>unknown(-<var>O</var>,+<var>N</var>)</code></dt>
<dd><a name="IDX214"></a>
<a name="IDX215"></a>
<a name="IDX216"></a>
<p>Specifies an handler to be called is a program tries to call an
undefined static procedure <var>P</var>.
</p>
<p>The arity of <var>N</var> may be zero or one. If the arity is <code>0</code>, the
new action must be one of <code>fail</code>, <code>warning</code>, or
<code>error</code>. If the arity is <code>1</code>, <var>P</var> is an user-defined
handler and at run-time, the argument to the handler <var>P</var> will be
unified with the undefined goal. Note that <var>N</var> must be defined prior
to calling <code>unknown/2</code>, and that the single argument to <var>N</var> must
be unbound.
</p>
<p>In YAP, the default action is to <code>fail</code> (note that in the ISO
Prolog standard the default action is <code>error</code>).
</p>
<p>After defining <code>undefined/1</code> by:
</p><table><tr><td> </td><td><pre class="example">undefined(A) :- format('Undefined predicate: ~w~n',[A]), fail.
</pre></td></tr></table>
<p>and executing the goal:
</p><table><tr><td> </td><td><pre class="example">unknown(U,undefined(X)).
</pre></td></tr></table>
<p>a call to a predicate for which no clauses were defined will result in
the output of a message of the form:
</p><table><tr><td> </td><td><pre class="example">Undefined predicate: user:xyz(A1,A2)
</pre></td></tr></table>
<p>followed by the failure of that call.
</p>
</dd>
<dt> <code>yap_flag(unknown,+<var>SPEC</var>)</code></dt>
<dd><p>Alternatively, one can use <code>yap_flag/2</code>,
<code>current_prolog_flag/2</code>, or <code>set_prolog_flag/2</code>, to set this
functionality. In this case, the first argument for the built-ins should
be <code>unknown</code>, and the second argument should be either
<code>error</code>, <code>warning</code>, <code>fail</code>, or a goal.
</p>
</dd>
<dt> <code>user:unknown_predicate_handler(+G,+M,?NG)</code></dt>
<dd><a name="IDX217"></a>
<a name="IDX218"></a>
<a name="IDX219"></a>
<p>The user may also define clauses for
<code>user:unknown_predicate_handler/3</code> hook predicate. This
user-defined procedure is called before any system processing for the
undefined procedure, with the first argument <var>G</var> set to the current
goal, and the second <var>M</var> set to the current module. The predicate
<var>G</var> will be called from within the user module.
</p>
<p>If <code>user:unknown_predicate_handler/3</code> succeeds, the system will
execute <var>NG</var>. If <code>user:unknown_predicate_handler/3</code> fails, the
system will execute default action as specified by <code>unknown/2</code>.
</p></dd>
</dl>
<hr size="6">
<a name="Testing-Terms"></a>
<a name="SEC34"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC33" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC35" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC31" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC31" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 6.3 Predicates on terms </h2>
<dl compact="compact">
<dt> <code>var(<var>T</var>) [ISO]</code></dt>
<dd><a name="IDX220"></a>
<a name="IDX221"></a>
<a name="IDX222"></a>
<p>Succeeds if <var>T</var> is currently a free variable, otherwise fails.
</p>
</dd>
<dt> <code>atom(<var>T</var>) [ISO]</code></dt>
<dd><a name="IDX223"></a>
<a name="IDX224"></a>
<a name="IDX225"></a>
<p>Succeeds if and only if <var>T</var> is currently instantiated to an atom.
</p>
</dd>
<dt> <code>atomic(T) [ISO]</code></dt>
<dd><a name="IDX226"></a>
<a name="IDX227"></a>
<a name="IDX228"></a>
<p>Checks whether <var>T</var> is an atomic symbol (atom or number).
</p>
</dd>
<dt> <code>compound(<var>T</var>) [ISO]</code></dt>
<dd><a name="IDX229"></a>
<a name="IDX230"></a>
<a name="IDX231"></a>
<p>Checks whether <var>T</var> is a compound term.
</p>
</dd>
<dt> <code>db_reference(<var>T</var>)</code></dt>
<dd><a name="IDX232"></a>
<a name="IDX233"></a>
<a name="IDX234"></a>
<p>Checks whether <var>T</var> is a database reference.
</p>
</dd>
<dt> <code>float(<var>T</var>) [ISO]</code></dt>
<dd><a name="IDX235"></a>
<a name="IDX236"></a>
<a name="IDX237"></a>
<p>Checks whether <var>T</var> is a floating point number.
</p>
</dd>
<dt> <code>integer(<var>T</var>) [ISO]</code></dt>
<dd><a name="IDX238"></a>
<a name="IDX239"></a>
<a name="IDX240"></a>
<p>Succeeds if and only if <var>T</var> is currently instantiated to an integer.
</p>
</dd>
<dt> <code>nonvar(<var>T</var>) [ISO]</code></dt>
<dd><a name="IDX241"></a>
<a name="IDX242"></a>
<a name="IDX243"></a>
<p>The opposite of <code>var(<var>T</var>)</code>.
</p>
</dd>
<dt> <code>number(<var>T</var>) [ISO]</code></dt>
<dd><a name="IDX244"></a>
<a name="IDX245"></a>
<a name="IDX246"></a>
<p>Checks whether <code>T</code> is an integer or a float.
</p>
</dd>
<dt> <code>primitive(<var>T</var>)</code></dt>
<dd><a name="IDX247"></a>
<a name="IDX248"></a>
<a name="IDX249"></a>
<p>Checks whether <var>T</var> is an atomic term or a database reference.
</p>
</dd>
<dt> <code>simple(<var>T</var>)</code></dt>
<dd><a name="IDX250"></a>
<a name="IDX251"></a>
<a name="IDX252"></a>
<p>Checks whether <var>T</var> is unbound, an atom, or a number.
</p>
</dd>
<dt> <code>callable(<var>T</var>)</code></dt>
<dd><a name="IDX253"></a>
<a name="IDX254"></a>
<a name="IDX255"></a>
<p>Checks whether <var>T</var> is a callable term, that is, an atom or a
compound term.
</p>
</dd>
<dt> <code>name(<var>A</var>,<var>L</var>)</code></dt>
<dd><a name="IDX256"></a>
<a name="IDX257"></a>
<a name="IDX258"></a>
<p>The predicate holds when at least one of the arguments is ground
(otherwise, an error message will be displayed). The argument <var>A</var> will
be unified with an atomic symbol and <var>L</var> with the list of the ASCII
codes for the characters of the external representation of <var>A</var>.
</p>
<table><tr><td> </td><td><pre class="example"> name(yap,L).
</pre></td></tr></table>
<p>will return:
</p><table><tr><td> </td><td><pre class="example"> L = [121,97,112].
</pre></td></tr></table>
<p>and
</p><table><tr><td> </td><td><pre class="example"> name(3,L).
</pre></td></tr></table>
<p>will return:
</p><table><tr><td> </td><td><pre class="example"> L = [51].
</pre></td></tr></table>
</dd>
<dt> <code>atom_chars(?<var>A</var>,?<var>L</var>) [ISO]</code></dt>
<dd><a name="IDX259"></a>
<a name="IDX260"></a>
<a name="IDX261"></a>
<p>The predicate holds when at least one of the arguments is ground
(otherwise, an error message will be displayed). The argument <var>A</var> must
be unifiable with an atom, and the argument <var>L</var> with the list of the
ASCII codes for the characters of the external representation of <var>A</var>.
</p>
<p>The ISO-Prolog standard dictates that <code>atom_chars/2</code> should unify
the second argument with a list of one-char atoms, and not the character
codes. For compatibility with previous versions of YAP, and
with other Prolog implementations, YAP unifies the second
argument with the character codes, as in <code>atom_codes/2</code>. Use the
<code>set_prolog_flag(to_chars_mode,iso)</code> to obtain ISO standard
compatibility.
</p>
</dd>
<dt> <code>atom_codes(?<var>A</var>,?<var>L</var>) [ISO]</code></dt>
<dd><a name="IDX262"></a>
<a name="IDX263"></a>
<a name="IDX264"></a>
<p>The predicate holds when at least one of the arguments is ground
(otherwise, an error message will be displayed). The argument <var>A</var> will
be unified with an atom and <var>L</var> with the list of the ASCII
codes for the characters of the external representation of <var>A</var>.
</p>
</dd>
<dt> <code>atom_concat(+<var>As</var>,?<var>A</var>)</code></dt>
<dd><a name="IDX265"></a>
<a name="IDX266"></a>
<a name="IDX267"></a>
<p>The predicate holds when the first argument is a list of atoms, and the
second unifies with the atom obtained by concatenating all the atoms in
the first list.
</p>
</dd>
<dt> <code>atomic_concat(+<var>As</var>,?<var>A</var>)</code></dt>
<dd><a name="IDX268"></a>
<a name="IDX269"></a>
<a name="IDX270"></a>
<p>The predicate holds when the first argument is a list of atoms, and
the second unifies with the atom obtained by concatenating all the
atomic terms in the first list. The first argument thus may contain
atoms or numbers.
</p>
</dd>
<dt> <code>atom_concat(+<var>A1</var>,+<var>A2</var>,?<var>A</var>)</code></dt>
<dd><a name="IDX271"></a>
<a name="IDX272"></a>
<a name="IDX273"></a>
<p>The predicate holds when the first argument and second argument are
atoms, and the third unifies with the atom obtained by concatenating
the first two arguments.
</p>
</dd>
<dt> <code>atom_length(+<var>A</var>,?<var>I</var>) [ISO]</code></dt>
<dd><a name="IDX274"></a>
<a name="IDX275"></a>
<a name="IDX276"></a>
<p>The predicate holds when the first argument is an atom, and the second
unifies with the number of characters forming that atom.
</p>
</dd>
<dt> <code>atom_concat(?<var>A1</var>,?<var>A2</var>,?<var>A12</var>) [ISO]</code></dt>
<dd><a name="IDX277"></a>
<a name="IDX278"></a>
<a name="IDX279"></a>
<p>The predicate holds when the third argument unifies with an atom, and
the first and second unify with atoms such that their representations
concatenated are the representation for <var>A12</var>.
</p>
<p>If <var>A1</var> and <var>A2</var> are unbound, the built-in will find all the atoms
that concatenated give <var>A12</var>.
</p>
</dd>
<dt> <code>number_chars(?<var>I</var>,?<var>L</var>)</code></dt>
<dd><a name="IDX280"></a>
<a name="IDX281"></a>
<a name="IDX282"></a>
<p>The predicate holds when at least one of the arguments is ground
(otherwise, an error message will be displayed). The argument <var>I</var> must
be unifiable with a number, and the argument <var>L</var> with the list of the
ASCII codes for the characters of the external representation of <var>I</var>.
</p>
<p>The ISO-Prolog standard dictates that <code>number_chars/2</code> should unify
the second argument with a list of one-char atoms, and not the character
codes. For compatibility with previous versions of YAP, and
with other Prolog implementations, YAP unifies the second
argument with the character codes, as in <code>number_codes/2</code>. Use the
<code>set_prolog_flag(to_chars_mode,iso)</code> to obtain ISO standard
compatibility.
</p>
</dd>
<dt> <code>number_codes(?<var>A</var>,?<var>L</var>) [ISO]</code></dt>
<dd><a name="IDX283"></a>
<a name="IDX284"></a>
<a name="IDX285"></a>
<p>The predicate holds when at least one of the arguments is ground
(otherwise, an error message will be displayed). The argument <var>A</var>
will be unified with a number and <var>L</var> with the list of the ASCII
codes for the characters of the external representation of <var>A</var>.
</p>
</dd>
<dt> <code>number_atom(?<var>I</var>,?<var>L</var>)</code></dt>
<dd><a name="IDX286"></a>
<a name="IDX287"></a>
<a name="IDX288"></a>
<p>The predicate holds when at least one of the arguments is ground
(otherwise, an error message will be displayed). The argument <var>I</var> must
be unifiable with a number, and the argument <var>L</var> must be unifiable
with an atom representing the number.
</p>
</dd>
<dt> <code>char_code(?<var>A</var>,?<var>I</var>) [ISO]</code></dt>
<dd><a name="IDX289"></a>
<a name="IDX290"></a>
<a name="IDX291"></a>
<p>The built-in succeeds with <var>A</var> bound to character represented as an
atom, and <var>I</var> bound to the character code represented as an
integer. At least, one of either <var>A</var> or <var>I</var> must be bound before
the call.
</p>
</dd>
<dt> <code>sub_atom(+<var>A</var>,?<var>Bef</var>, ?<var>Size</var>, ?<var>After</var>, ?<var>At_out</var>) [ISO]</code></dt>
<dd><a name="IDX292"></a>
<a name="IDX293"></a>
<a name="IDX294"></a>
<p>True when <var>A</var> and <var>At_out</var> are atoms such that the name of
<var>At_out</var> has size <var>Size</var> and is a substring of the name of
<var>A</var>, such that <var>Bef</var> is the number of characters before and
<var>After</var> the number of characters afterwards.
</p>
<p>Note that <var>A</var> must always be known, but <var>At_out</var> can be unbound when
calling this built-in. If all the arguments for <code>sub_atom/5</code> but <var>A</var>
are unbound, the built-in will backtrack through all possible
substrings of <var>A</var>.
</p>
</dd>
<dt> <code>numbervars(<var>T</var>,+<var>N1</var>,-<var>Nn</var>)</code></dt>
<dd><a name="IDX295"></a>
<a name="IDX296"></a>
<a name="IDX297"></a>
<p>Instantiates each variable in term <var>T</var> to a term of the form:
<code>'$VAR'(<var>I</var>)</code>, with <var>I</var> increasing from <var>N1</var> to <var>Nn</var>.
</p>
</dd>
<dt> <code>ground(<var>T</var>)</code></dt>
<dd><a name="IDX298"></a>
<a name="IDX299"></a>
<a name="IDX300"></a>
<p>Succeeds if there are no free variables in the term <var>T</var>.
</p>
</dd>
<dt> <code>arg(+<var>N</var>,+<var>T</var>,<var>A</var>) [ISO]</code></dt>
<dd><a name="IDX301"></a>
<a name="IDX302"></a>
<a name="IDX303"></a>
<p>Succeeds if the argument <var>N</var> of the term <var>T</var> unifies with
<var>A</var>. The arguments are numbered from 1 to the arity of the term.
</p>
<p>The current version will generate an error if <var>T</var> or <var>N</var> are
unbound, if <var>T</var> is not a compound term, of if <var>N</var> is not a positive
integer. Note that previous versions of YAP would fail silently
under these errors.
</p>
</dd>
<dt> <code>functor(<var>T</var>,<var>F</var>,<var>N</var>)</code></dt>
<dd><a name="IDX304"></a>
<a name="IDX305"></a>
<a name="IDX306"></a>
<p>The top functor of term <var>T</var> is named <var>F</var> and has arity <var>N</var>.
</p>
<p>When <var>T</var> is not instantiated, <var>F</var> and <var>N</var> must be. If
<var>N</var> is 0, <var>F</var> must be an atomic symbol, which will be unified
with <var>T</var>. If <var>N</var> is not 0, then <var>F</var> must be an atom and
<var>T</var> becomes instantiated to the most general term having functor
<var>F</var> and arity <var>N</var>. If <var>T</var> is instantiated to a term then
<var>F</var> and <var>N</var> are respectively unified with its top functor name
and arity.
</p>
<p>In the current version of YAP the arity <var>N</var> must be an
integer. Previous versions allowed evaluable expressions, as long as the
expression would evaluate to an integer. This feature is not available
in the ISO Prolog standard.
</p>
</dd>
<dt> <code><var>T</var> =.. <var>L</var> [ISO]</code></dt>
<dd><a name="IDX307"></a>
<a name="IDX308"></a>
<a name="IDX309"></a>
<p>The list <var>L</var> is built with the functor and arguments of the term
<var>T</var>. If <var>T</var> is instantiated to a variable, then <var>L</var> must be
instantiated either to a list whose head is an atom, or to a list
consisting of just a number.
</p>
</dd>
<dt> <code><var>X</var> = <var>Y</var> [ISO]</code></dt>
<dd><a name="IDX310"></a>
<a name="IDX311"></a>
<a name="IDX312"></a>
<p>Tries to unify terms <var>X</var> and <var>Y</var>.
</p>
</dd>
<dt> <code><var>X</var> \= <var>Y</var> [ISO]</code></dt>
<dd><a name="IDX313"></a>
<a name="IDX314"></a>
<a name="IDX315"></a>
<p>Succeeds if terms <var>X</var> and <var>Y</var> are not unifiable.
</p>
</dd>
<dt> <code>unify_with_occurs_check(?T1,?T2) [ISO]</code></dt>
<dd><a name="IDX316"></a>
<a name="IDX317"></a>
<a name="IDX318"></a>
<p>Obtain the most general unifier of terms <var>T1</var> and <var>T2</var>, if there
is one.
</p>
<p>This predicate implements the full unification algorithm. An example:n
</p><table><tr><td> </td><td><pre class="example">unify_with_occurs_check(a(X,b,Z),a(X,A,f(B)).
</pre></td></tr></table>
<p>will succeed with the bindings <code>A = b</code> and <code>Z = f(B)</code>. On the
other hand:
</p><table><tr><td> </td><td><pre class="example">unify_with_occurs_check(a(X,b,Z),a(X,A,f(Z)).
</pre></td></tr></table>
<p>would fail, because <code>Z</code> is not unifiable with <code>f(Z)</code>. Note that
<code>(=)/2</code> would succeed for the previous examples, giving the following
bindings <code>A = b</code> and <code>Z = f(Z)</code>.
</p>
</dd>
<dt> <code>copy_term(?<var>TI</var>,-<var>TF</var>) [ISO]</code></dt>
<dd><a name="IDX319"></a>
<a name="IDX320"></a>
<a name="IDX321"></a>
<p>Term <var>TF</var> is a variant of the original term <var>TI</var>, such that for
each variable <var>V</var> in the term <var>TI</var> there is a new variable <var>V'</var>
in term <var>TF</var>.
</p>
</dd>
</dl>
<hr size="6">
<a name="Comparing-Terms"></a>
<a name="SEC35"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC34" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC36" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC31" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC31" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 6.4 Comparing Terms </h2>
<p>The following predicates are used to compare and order terms, using the
standard ordering:
</p>
<ul>
<li>
variables come before numbers, numbers come before atoms which in turn
come before compound terms, i.e.: variables @< numbers @< atoms @<
compound terms.
</li><li>
variables are roughly ordered by "age" (the "oldest" variable is put
first);
</li><li>
floating point numbers are sorted in increasing order;
</li><li>
Integers are sorted in increasing order;
</li><li>
atoms are sorted in lexicographic order;
</li><li>
compound terms are ordered first by name, then by arity of the main
functor, and finally by their arguments in left-to-right order.
</li></ul>
<dl compact="compact">
<dt> <code>compare(<var>C</var>,<var>X</var>,<var>Y</var>)</code></dt>
<dd><a name="IDX322"></a>
<a name="IDX323"></a>
<a name="IDX324"></a>
<p>As a result of comparing <var>X</var> and <var>Y</var>, <var>C</var> may take one of
the following values:
</p>
<ul>
<li>
<code>=</code> if <var>X</var> and <var>Y</var> are identical;
</li><li>
<code><</code> if <var>X</var> precedes <var>Y</var> in the defined order;
</li><li>
<code>></code> if <var>Y</var> precedes <var>X</var> in the defined order;
</li></ul>
</dd>
<dt> <code><var>X</var> == <var>Y</var> [ISO]</code></dt>
<dd><a name="IDX325"></a>
<a name="IDX326"></a>
<a name="IDX327"></a>
<p>Succeeds if terms <var>X</var> and <var>Y</var> are strictly identical. The
difference between this predicate and <code>=/2</code> is that, if one of the
arguments is a free variable, it only succeeds when they have already
been unified.
</p>
<table><tr><td> </td><td><pre class="example">?- X == Y.
</pre></td></tr></table>
<p>fails, but,
</p><table><tr><td> </td><td><pre class="example">?- X = Y, X == Y.
</pre></td></tr></table>
<p>succeeds.
</p><table><tr><td> </td><td><pre class="example">?- X == 2.
</pre></td></tr></table>
<p>fails, but,
</p><table><tr><td> </td><td><pre class="example">?- X = 2, X == 2.
</pre></td></tr></table>
<p>succeeds.
</p>
</dd>
<dt> <code><var>X</var> \== <var>Y</var> [ISO]</code></dt>
<dd><a name="IDX328"></a>
<a name="IDX329"></a>
<a name="IDX330"></a>
<p>Terms <var>X</var> and <var>Y</var> are not strictly identical.
</p>
</dd>
<dt> <code><var>X</var> @< <var>Y</var> [ISO]</code></dt>
<dd><a name="IDX331"></a>
<a name="IDX332"></a>
<a name="IDX333"></a>
<p>Term <var>X</var> precedes term <var>Y</var> in the standard order.
</p>
</dd>
<dt> <code><var>X</var> @=< <var>Y</var> [ISO]</code></dt>
<dd><a name="IDX334"></a>
<a name="IDX335"></a>
<a name="IDX336"></a>
<p>Term <var>X</var> does not follow term <var>Y</var> in the standard order.
</p>
</dd>
<dt> <code><var>X</var> @> <var>Y</var> [ISO]</code></dt>
<dd><a name="IDX337"></a>
<a name="IDX338"></a>
<a name="IDX339"></a>
<p>Term <var>X</var> follows term <var>Y</var> in the standard order.
</p>
</dd>
<dt> <code><var>X</var> @>= <var>Y</var> [ISO]</code></dt>
<dd><a name="IDX340"></a>
<a name="IDX341"></a>
<a name="IDX342"></a>
<p>Term <var>X</var> does not precede term <var>Y</var> in the standard order.
</p>
</dd>
<dt> <code>sort(+<var>L</var>,-<var>S</var>)</code></dt>
<dd><a name="IDX343"></a>
<a name="IDX344"></a>
<a name="IDX345"></a>
<p>Unifies <var>S</var> with the list obtained by sorting <var>L</var> and merging
identical (in the sense of <code>==</code>) elements.
</p>
</dd>
<dt> <code>keysort(+<var>L</var>,<var>S</var>)</code></dt>
<dd><a name="IDX346"></a>
<a name="IDX347"></a>
<a name="IDX348"></a>
<p>Assuming L is a list of the form <code><var>Key</var>-<var>Value</var></code>,
<code>keysort(+<var>L</var>,<var>S</var>)</code> unifies <var>S</var> with the list obtained
from <var>L</var>, by sorting its elements according to the value of
<var>Key</var>.
</p><table><tr><td> </td><td><pre class="example">?- keysort([3-a,1-b,2-c,1-a,1-b],S).
</pre></td></tr></table>
<p>would return:
</p><table><tr><td> </td><td><pre class="example">S = [1-b,1-a,1-b,2-c,3-a]
</pre></td></tr></table>
</dd>
<dt> <code>length(?<var>L</var>,?<var>S</var>)</code></dt>
<dd><a name="IDX349"></a>
<a name="IDX350"></a>
<a name="IDX351"></a>
<p>Unify the well-defined list <var>L</var> with its length. The procedure can
be used to find the length of a pre-defined list, or to build a list
of length <var>S</var>.
</p>
</dd>
</dl>
<hr size="6">
<a name="Arithmetic"></a>
<a name="SEC36"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC35" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC37" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC31" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC31" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 6.5 Arithmetic </h2>
<p>Arithmetic expressions in YAP may use the following operators
or <i>evaluable predicates</i>:
</p>
<dl compact="compact">
<dt> <code>+<var>X</var></code></dt>
<dd><p>The value of <var>X</var> itself.
</p>
</dd>
<dt> <code>-<var>X</var> [ISO]</code></dt>
<dd><p>Symmetric value.
</p>
</dd>
<dt> <code><var>X</var>+<var>Y</var> [ISO]</code></dt>
<dd><p>Sum.
</p>
</dd>
<dt> <code><var>X</var>-<var>Y</var> [ISO]</code></dt>
<dd><p>Difference.
</p>
</dd>
<dt> <code><var>X</var>*<var>Y</var> [ISO]</code></dt>
<dd><p>Product.
</p>
</dd>
<dt> <code><var>X</var>/<var>Y</var> [ISO]</code></dt>
<dd><p>Quotient.
</p>
</dd>
<dt> <code><var>X</var>//<var>Y</var> [ISO]</code></dt>
<dd><p>Integer quotient.
</p>
</dd>
<dt> <code><var>X</var> mod <var>Y</var> [ISO]</code></dt>
<dd><p>Integer remainder.
</p>
</dd>
<dt> <code><var>X</var> rem <var>Y</var></code></dt>
<dd><p>Integer remainder, the same as <code>mod</code>.
</p>
</dd>
<dt> <code>exp(<var>X</var>) [ISO]</code></dt>
<dd><p>Natural exponential.
</p>
</dd>
<dt> <code>log(<var>X</var>) [ISO]</code></dt>
<dd><p>Natural logarithm.
</p>
</dd>
<dt> <code>log10(<var>X</var>)</code></dt>
<dd><p>Decimal logarithm.
</p>
</dd>
<dt> <code>sqrt(<var>X</var>) [ISO]</code></dt>
<dd><p>Square root.
</p>
</dd>
<dt> <code>sin(<var>X</var>) [ISO]</code></dt>
<dd><p>Sine.
</p>
</dd>
<dt> <code>cos(<var>X</var>) [ISO]</code></dt>
<dd><p>Cosine.
</p>
</dd>
<dt> <code>tan(<var>X</var>)</code></dt>
<dd><p>Tangent.
</p>
</dd>
<dt> <code>asin(<var>X</var>)</code></dt>
<dd><p>Arc sine.
</p>
</dd>
<dt> <code>acos(<var>X</var>)</code></dt>
<dd><p>Arc cosine.
</p>
</dd>
<dt> <code>atan(<var>X</var>) [ISO]</code></dt>
<dd><p>Arc tangent.
</p>
</dd>
<dt> <code>atan2(<var>X</var>)</code></dt>
<dd><p>Four-quadrant arc tangent.
</p>
</dd>
<dt> <code>sinh(<var>X</var>)</code></dt>
<dd><p>Hyperbolic sine.
</p>
</dd>
<dt> <code>cosh(<var>X</var>)</code></dt>
<dd><p>Hyperbolic cosine.
</p>
</dd>
<dt> <code>tanh(<var>X</var>)</code></dt>
<dd><p>Hyperbolic tangent.
</p>
</dd>
<dt> <code>asinh(<var>X</var>)</code></dt>
<dd><p>Hyperbolic arc sine.
</p>
</dd>
<dt> <code>acosh(<var>X</var>)</code></dt>
<dd><p>Hyperbolic arc cosine.
</p>
</dd>
<dt> <code>atanh(<var>X</var>)</code></dt>
<dd><p>Hyperbolic arc tangent.
</p>
</dd>
<dt> <code>integer(<var>X</var>) [ISO]</code></dt>
<dd><p>If <var>X</var> evaluates to a float, the integer between the value of <var>X</var>
and 0 closest to the value of <var>X</var>, else if <var>X</var> evaluates to an
integer, the value of <var>X</var>.
</p>
</dd>
<dt> <code>float(<var>X</var>) [ISO]</code></dt>
<dd><p>If <var>X</var> evaluates to an integer, the corresponding float, else the float
itself.
</p>
</dd>
<dt> <code>float_fractional_part(<var>X</var>) [ISO]</code></dt>
<dd><p>The fractional part of the floating point number <var>X</var>, or <code>0.0</code>
if <var>X</var> is an integer. In the <code>iso</code> language mode,
<var>X</var> must be an integer.
</p>
</dd>
<dt> <code>float_integer_part(<var>X</var>) [ISO]</code></dt>
<dd><p>The float giving the integer part of the floating point number <var>X</var>,
or <var>X</var> if <var>X</var> is an integer. In the <code>iso</code> language mode,
<var>X</var> must be an integer.
</p>
</dd>
<dt> <code>abs(<var>X</var>) [ISO]</code></dt>
<dd><p>The absolute value of <var>X</var>.
</p>
</dd>
<dt> <code>ceiling(<var>X</var>) [ISO]</code></dt>
<dd><p>The float that is the smallest integral value not smaller than <var>X</var>.
</p>
<p>In <code>iso</code> language mode the argument must be a floating
point-number and the result is an integer.
</p>
</dd>
<dt> <code>floor(<var>X</var>) [ISO]</code></dt>
<dd><p>The float that is the greatest integral value not greater than <var>X</var>.
</p>
<p>In <code>iso</code> language mode the argument must be a floating
point-number and the result is an integer.
</p>
</dd>
<dt> <code>round(<var>X</var>) [ISO]</code></dt>
<dd><p>The nearest integral value to <var>X</var>. If <var>X</var> is
equidistant to two integers, it will be rounded to the closest even
integral value.
</p>
<p>In <code>iso</code> language mode the argument must be a floating
point-number, the result is an integer and it the float is equidistant
it is rounded up, that is, to the least integer greater than <var>X</var>.
</p>
</dd>
<dt> <code>sign(<var>X</var>) [ISO]</code></dt>
<dd><p>Return 1 if the <var>X</var> evaluates to a positive integer, 0 it if
evaluates to 0, and -1 if it evaluates to a negative integer. If <var>X</var>
evaluates to a floating-point number return 1.0 for a positive <var>X</var>,
0.0 for 0.0, and -1.0 otherwise.
</p>
</dd>
<dt> <code>truncate(<var>X</var>)</code></dt>
<dd><p>The float that is the integral value between <var>X</var> and 0 closest to
<var>X</var>.
</p>
</dd>
<dt> <code>max(<var>X</var>,<var>Y</var>)</code></dt>
<dd><p>The greater value of <var>X</var> and <var>Y</var>.
</p>
</dd>
<dt> <code>min(<var>X</var>,<var>Y</var>)</code></dt>
<dd><p>The lesser value of <var>X</var> and <var>Y</var>.
</p>
</dd>
<dt> <code><var>X</var> ^ <var>Y</var></code></dt>
<dd><p><var>X</var> raised to the power of <var>Y</var>, (from the C-Prolog syntax).
</p>
</dd>
<dt> <code>exp(<var>X</var>,<var>Y</var>)</code></dt>
<dd><p><var>X</var> raised to the power of <var>Y</var>, (from the Quintus Prolog syntax).
</p>
</dd>
<dt> <code><var>X</var> ** <var>Y</var> [ISO]</code></dt>
<dd><p><var>X</var> raised to the power of <var>Y</var> (from ISO).
</p>
</dd>
<dt> <code><var>X</var> /\ <var>Y</var> [ISO]</code></dt>
<dd><p>Integer bitwise conjunction.
</p>
</dd>
<dt> <code><var>X</var> \/ <var>Y</var> [ISO]</code></dt>
<dd><p>Integer bitwise disjunction.
</p>
</dd>
<dt> <code><var>X</var> # <var>Y</var> [ISO]</code></dt>
<dd><p>Integer bitwise exclusive disjunction.
</p>
</dd>
<dt> <code><var>X</var> << <var>Y</var></code></dt>
<dd><p>Integer bitwise left logical shift of <var>X</var> by <var>Y</var> places.
</p>
</dd>
<dt> <code><var>X</var> >> <var>Y</var> [ISO]</code></dt>
<dd><p>Integer bitwise right logical shift of <var>X</var> by <var>Y</var> places.
</p>
</dd>
<dt> <code>\ <var>X</var> [ISO]</code></dt>
<dd><p>Integer bitwise negation.
</p>
</dd>
<dt> <code>gcd(<var>X</var>,<var>Y</var>)</code></dt>
<dd><p>The greatest common divisor of the two integers <var>X</var> and <var>Y</var>.
</p>
</dd>
<dt> <code>msb(<var>X</var>)</code></dt>
<dd><p>The most significant bit of the integer <var>X</var>.
</p>
</dd>
<dt> <code>[<var>X</var>]</code></dt>
<dd><p>Evaluates to <var>X</var> for expression <var>X</var>. Useful because character
strings in Prolog are lists of character codes.
</p>
<table><tr><td> </td><td><pre class="example">X is Y*10+C-"0"
</pre></td></tr></table>
<p>is the same as
</p><table><tr><td> </td><td><pre class="example">X is Y*10+C-[48].
</pre></td></tr></table>
<p>which would be evaluated as:
</p><table><tr><td> </td><td><pre class="example">X is Y*10+C-48.
</pre></td></tr></table>
</dd>
</dl>
<p>Besides numbers and the arithmetic operators described above, certain
atoms have a special meaning when present in arithmetic expressions:
</p>
<dl compact="compact">
<dt> <code>pi</code></dt>
<dd><p>The value of <em>pi</em>, the ratio of a circle's circumference to its
diameter.
</p>
</dd>
<dt> <code>e</code></dt>
<dd><p>The base of the natural logarithms.
</p>
</dd>
<dt> <code>inf</code></dt>
<dd><p>Infinity according to the IEEE Floating-Point standard. Note that
evaluating this term will generate a domain error in the <code>iso</code>
language mode.
</p>
</dd>
<dt> <code>nan</code></dt>
<dd><p>Not-a-number according to the IEEE Floating-Point standard. Note that
evaluating this term will generate a domain error in the <code>iso</code>
language mode.
</p>
</dd>
<dt> <code>cputime</code></dt>
<dd><p>CPU time in seconds, since YAP was invoked.
</p>
</dd>
<dt> <code>heapused</code></dt>
<dd><p>Heap space used, in bytes.
</p>
</dd>
<dt> <code>local</code></dt>
<dd><p>Local stack in use, in bytes.
</p>
</dd>
<dt> <code>global</code></dt>
<dd><p>Global stack in use, in bytes.
</p>
</dd>
<dt> <code>random</code></dt>
<dd><p>A "random" floating point number between 0 and 1.
</p>
</dd>
</dl>
<p>The primitive YAP predicates involving arithmetic expressions are:
</p>
<dl compact="compact">
<dt> <code><var>X</var> is +<var>Y</var> [2]</code></dt>
<dd><a name="IDX352"></a>
<a name="IDX353"></a>
<a name="IDX354"></a>
<p>This predicate succeeds iff the result of evaluating the expression
<var>Y</var> unifies with <var>X</var>. This is the predicate normally used to
perform evaluation of arithmetic expressions:
</p>
<table><tr><td> </td><td><pre class="example">X is 2+3*4
</pre></td></tr></table>
<p>succeeds with <code>X = 14</code>.
</p>
</dd>
<dt> <code>+<var>X</var> < +<var>Y</var> [ISO]</code></dt>
<dd><a name="IDX355"></a>
<a name="IDX356"></a>
<a name="IDX357"></a>
<p>The value of the expression <var>X</var> is less than the value of expression
<var>Y</var>.
</p>
</dd>
<dt> <code>+<var>X</var> =< +<var>Y</var> [ISO]</code></dt>
<dd><a name="IDX358"></a>
<a name="IDX359"></a>
<a name="IDX360"></a>
<p>The value of the expression <var>X</var> is less than or equal to the value
of expression <var>Y</var>.
</p>
</dd>
<dt> <code>+<var>X</var> > +<var>Y</var> [ISO]</code></dt>
<dd><a name="IDX361"></a>
<a name="IDX362"></a>
<a name="IDX363"></a>
<p>The value of the expression <var>X</var> is greater than the value of
expression <var>Y</var>.
</p>
</dd>
<dt> <code>+<var>X</var> >= +<var>Y</var> [ISO]</code></dt>
<dd><a name="IDX364"></a>
<a name="IDX365"></a>
<a name="IDX366"></a>
<p>The value of the expression <var>X</var> is greater than or equal to the
value of expression <var>Y</var>.
</p>
</dd>
<dt> <code>+<var>X</var> =:= +<var>Y</var> [ISO]</code></dt>
<dd><a name="IDX367"></a>
<a name="IDX368"></a>
<a name="IDX369"></a>
<p>The value of the expression <var>X</var> is equal to the value of expression
<var>Y</var>.
</p>
</dd>
<dt> <code>+<var>X</var> =\= +<var>Y</var> [ISO]</code></dt>
<dd><a name="IDX370"></a>
<a name="IDX371"></a>
<a name="IDX372"></a>
<p>The value of the expression <var>X</var> is different from the value of
expression <var>Y</var>.
</p>
</dd>
<dt> <code>srandom(+<var>X</var>)</code></dt>
<dd><a name="IDX373"></a>
<a name="IDX374"></a>
<a name="IDX375"></a>
<p>Use the argument <var>X</var> as a new seed for YAP's random number
generator. The argument should be an integer, but floats are acceptable.
</p></dd>
</dl>
<p><strong>Notes:</strong>
</p>
<ul>
<li>
In contrast to previous versions of Yap, Yap4 <em>does not</em> convert
automatically between integers and floats.
</li><li>
arguments to trigonometric functions are expressed in radians.
</li><li>
if a (non-instantiated) variable occurs in an arithmetic expression
YAP will generate an exception. If no error handler is
available, execution will be thrown back to the top-level.
</li></ul>
<hr size="6">
<a name="I_002fO"></a>
<a name="SEC37"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC36" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC38" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC31" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC31" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 6.6 I/O Predicates </h2>
<p>Some of the I/O predicates described below will in certain conditions
provide error messages and abort only if the file_errors flag is set.
If this flag is cleared the same predicates will just fail. Details on
setting and clearing this flag are given under 7.7.
</p>
<table class="menu" border="0" cellspacing="0">
<p>Subnodes of Input/Output
<a href="#SEC38">6.6.1 Handling Streams and Files</a> Handling Streams and Files
<a href="#SEC39">6.6.2 Handling Streams and Files</a> C-Prolog Compatible File Handling
<a href="#SEC40">6.6.3 Handling Input/Output of Terms</a> Input/Output of terms
<a href="#SEC41">6.6.4 Handling Input/Output of Characters</a> Input/Output of Characters
<a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a> Input/Output using Streams
<a href="#SEC43">6.6.6 Compatible C-Prolog predicates for Terminal I/O</a> C-Prolog compatible Character I/O to terminal
<a href="#SEC44">6.6.7 Controlling Input/Output</a> Controlling your Input/Output
<a href="#SEC45">6.6.8 Using Sockets From Yap</a> Using Sockets from Yap
</p>
</table>
<hr size="6">
<a name="Streams-and-Files"></a>
<a name="SEC38"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC37" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC39" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC31" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC37" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 6.6.1 Handling Streams and Files </h3>
<dl compact="compact">
<dt> <code>open(+<var>F</var>,+<var>M</var>,-<var>S</var>) [ISO]</code></dt>
<dd><a name="IDX376"></a>
<a name="IDX377"></a>
<a name="IDX378"></a>
<p>Opens the file with name <var>F</var> in mode <var>M</var> ('read', 'write' or
'append'), returning <var>S</var> unified with the stream name.
</p>
<p>At most, there are 17 streams opened at the same time. Each stream is
either an input or an output stream but not both. There are always 3
open streams: <code>user_input</code> for reading, <code>user_output</code> for writing
and <code>user_error</code> for writing. If there is no ambiguity, the atoms
<code>user_input</code> and <code>user_output</code> may be referred to as <code>user</code>.
</p>
<p>The <code>file_errors</code> flag controls whether errors are reported when in
mode 'read' or 'append' the file <var>F</var> does not exist or is not
readable, and whether in mode 'write' or 'append' the file is not
writable.
</p>
</dd>
<dt> <code>open(+<var>F</var>,+<var>M</var>,-<var>S</var>,+<var>Opts</var>) [ISO]</code></dt>
<dd><a name="IDX379"></a>
<a name="IDX380"></a>
<a name="IDX381"></a>
<p>Opens the file with name <var>F</var> in mode <var>M</var> ('read', 'write' or
'append'), returning <var>S</var> unified with the stream name, and following
these options:
</p>
<dl compact="compact">
<dt> <code>type(+<var>T</var>)</code></dt>
<dd><p>Specify whether the stream is a <code>text</code> stream (default), or a
<code>binary</code> stream.
</p>
</dd>
<dt> <code>reposition(+<var>Bool</var>)</code></dt>
<dd><p>Specify whether it is possible to reposition the stream (<code>true</code>), or
not (<code>false</code>). By default, YAP enables repositioning for all
files, except terminal files and sockets.
</p>
</dd>
<dt> <code>eof_action(+<var>Action</var>)</code></dt>
<dd><p>Specify the action to take if attempting to input characters from a
stream where we have previously found an <code>end-of-file</code>. The possible
actions are <code>error</code>, that raises an error, <code>reset</code>, that tries to
reset the stream and is used for <code>tty</code> type files, and <code>eof_code</code>,
which generates a new <code>end-of-file</code> (default for non-tty files).
</p>
</dd>
<dt> <code>alias(+<var>Name</var>)</code></dt>
<dd><p>Specify an alias to the stream. The alias <tt>Name</tt> must be an atom. The
alias can be used instead of the stream descriptor for every operation
concerning the stream.
</p>
<p>The operation will fail and give an error if the alias name is already
in use. YAP allows several aliases for the same file, but only
one is returned by <code>stream_property/2</code>
</p></dd>
</dl>
</dd>
<dt> <code>close(+<var>S</var>) [ISO]</code></dt>
<dd><a name="IDX382"></a>
<a name="IDX383"></a>
<a name="IDX384"></a>
<p>Closes the stream <var>S</var>. If <var>S</var> does not stand for a stream
currently opened an error is reported. The streams <code>user_input</code>,
<code>user_output</code>, and <code>user_error</code> can never be closed.
</p>
<p>By default, give a file name, <code>close/1</code> will also try to close a
corresponding open stream. This feature is not available in ISO or
SICStus languages mode and is deprecated.
</p>
</dd>
<dt> <code>close(+<var>S</var>,+<var>O</var>) [ISO]</code></dt>
<dd><a name="IDX385"></a>
<a name="IDX386"></a>
<a name="IDX387"></a>
<p>Closes the stream <var>S</var>, following options <var>O</var>.
</p>
<p>The only valid options are <code>force(true)</code> and <code>force(false)</code>.
YAP currently ignores these options.
</p>
</dd>
<dt> <code>absolute_file_name(+<var>Name</var>,-<var>FullPath</var>)</code></dt>
<dd><a name="IDX388"></a>
<a name="IDX389"></a>
<a name="IDX390"></a>
<p>Give the path a full path <var>FullPath</var> Yap would use to consult a file
named <var>Name</var>. Unify <var>FullPath</var> with <code>user</code> if the file
name is <code>user</code>.
</p>
</dd>
<dt> <code>current_stream(<var>F</var>,<var>M</var>,<var>S</var>)</code></dt>
<dd><a name="IDX391"></a>
<a name="IDX392"></a>
<a name="IDX393"></a>
<p>Defines the relation: The stream <var>S</var> is opened on the file <var>F</var>
in mode <var>M</var>. It might be used to obtain all open streams (by
backtracking) or to access the stream for a file <var>F</var> in mode
<var>M</var>, or to find properties for a stream <var>S</var>.
</p>
</dd>
<dt> <code>flush_output [ISO]</code></dt>
<dd><a name="IDX394"></a>
<a name="IDX395"></a>
<a name="IDX396"></a>
<p>Send all data in the output buffer to current output stream.
</p>
</dd>
<dt> <code>flush_output(+<var>S</var>) [ISO]</code></dt>
<dd><a name="IDX397"></a>
<a name="IDX398"></a>
<a name="IDX399"></a>
<p>Send all data in the output buffer to stream <var>S</var>.
</p>
</dd>
<dt> <code>set_input(+<var>S</var>)</code></dt>
<dd><a name="IDX400"></a>
<a name="IDX401"></a>
<a name="IDX402"></a>
<p>Set stream <var>S</var> as the current input stream. Predicates like <code>read/1</code>
and <code>get/1</code> will start using stream <var>S</var>.
</p>
</dd>
<dt> <code>set_output(+<var>S</var>)</code></dt>
<dd><a name="IDX403"></a>
<a name="IDX404"></a>
<a name="IDX405"></a>
<p>Set stream <var>S</var> as the current output stream. Predicates like
<code>write/1</code> and <code>put/1</code> will start using stream <var>S</var>.
</p>
</dd>
<dt> <code>stream_select(+<var>STREAMS</var>,+<var>TIMEOUT</var>,-<var>READSTREAMS</var>)</code></dt>
<dd><a name="IDX406"></a>
<a name="IDX407"></a>
<a name="IDX408"></a>
<p>Given a list of open <var>STREAMS</var> openeded in read mode and a <var>TIMEOUT</var>
return a list of streams who are now available for reading.
</p>
<p>If the <var>TIMEOUT</var> is instantiated to <code>off</code>,
<code>stream_select/3</code> will wait indefinitely for a stream to become
open. Otherwise the timeout must be of the form <code>SECS:USECS</code> where
<code>SECS</code> is an integer gives the number of seconds to wait for a timeout
and <code>USECS</code> adds the number of micro-seconds.
</p>
<p>This built-in is only defined if the system call <code>select</code> is
available in the system.
</p>
</dd>
<dt> <code>current_input(-<var>S</var>) [ISO]</code></dt>
<dd><a name="IDX409"></a>
<a name="IDX410"></a>
<a name="IDX411"></a>
<p>Unify <var>S</var> with the current input stream.
</p>
</dd>
<dt> <code>current_output(-<var>S</var>) [ISO]</code></dt>
<dd><a name="IDX412"></a>
<a name="IDX413"></a>
<a name="IDX414"></a>
<p>Unify <var>S</var> with the current output stream.
</p>
</dd>
<dt> <code>at_end_of_stream [ISO]</code></dt>
<dd><a name="IDX415"></a>
<a name="IDX416"></a>
<a name="IDX417"></a>
<p>Succeed if the current stream has stream position end-of-stream or
past-end-of-stream.
</p>
</dd>
<dt> <code>at_end_of_stream(+<var>S</var>) [ISO]</code></dt>
<dd><a name="IDX418"></a>
<a name="IDX419"></a>
<a name="IDX420"></a>
<p>Succeed if the stream <var>S</var> has stream position end-of-stream or
past-end-of-stream. Note that <var>S</var> must be a readable stream.
</p>
</dd>
<dt> <code>set_stream_position(+<var>S</var>, +<var>POS</var>) [ISO]</code></dt>
<dd><a name="IDX421"></a>
<a name="IDX422"></a>
<a name="IDX423"></a>
<p>Given a stream position <var>POS</var> for a stream <var>S</var>, set the current
stream position for <var>S</var> to be <var>POS</var>.
</p>
</dd>
<dt> <code>stream_property(?<var>Stream</var>,?<var>Prop</var>) [ISO]</code></dt>
<dd><a name="IDX424"></a>
<a name="IDX425"></a>
<a name="IDX426"></a>
<p>Obtain the properties for the open streams. If the first argument is
unbound, the procedure will backtrack through all open
streams. Otherwise, the first argument must be a stream term (you may
use <code>current_stream</code> to obtain a current stream given a file name).
</p>
<p>The following properties are recognized:
</p>
<dl compact="compact">
<dt> <code>file_name(<var>P</var>)</code></dt>
<dd><p>An atom giving the file name for the current stream. The file names are
<code>user_input</code>, <code>user_output</code>, and <code>user_error</code> for the
standard streams.
</p>
</dd>
<dt> <code>mode(<var>P</var>)</code></dt>
<dd><p>The mode used to open the file. It may be one of <code>append</code>,
<code>read</code>, or <code>write</code>.
</p>
</dd>
<dt> <code>input</code></dt>
<dd><p>The stream is readable.
</p>
</dd>
<dt> <code>output</code></dt>
<dd><p>The stream is writable.
</p>
</dd>
<dt> <code>alias(<var>A</var>)</code></dt>
<dd><p>ISO-Prolog primitive for stream aliases. <tt>Yap</tt> returns one of the
existing aliases for the stream.
</p>
</dd>
<dt> <code>position(<var>P</var>)</code></dt>
<dd><p>A term describing the position in the stream.
</p>
</dd>
<dt> <code>end_of_stream(<var>E</var>)</code></dt>
<dd><p>Whether the stream is <code>at</code> the end of stream, or it has found the
end of stream and is <code>past</code>, or whether it has <code>not</code> yet
reached the end of stream.
</p>
</dd>
<dt> <code>eof_action(<var>A</var>)</code></dt>
<dd><p>The action to take when trying to read after reaching the end of
stream. The action may be one of <code>error</code>, generate an error,
<code>eof_code</code>, return character code <code>-1</code>, or <code>reset</code> the
stream.
</p>
</dd>
<dt> <code>reposition(<var>B</var>)</code></dt>
<dd><p>Whether the stream can be repositioned or not, that is, whether it is
seekable.
</p>
</dd>
<dt> <code>type(<var>T</var>)</code></dt>
<dd><p>Whether the stream is a <code>text</code> stream or a <code>binary</code> stream.
</p>
</dd>
</dl>
</dd>
</dl>
<hr size="6">
<a name="C_002dProlog-File-Handling"></a>
<a name="SEC39"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC38" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC40" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC31" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC37" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 6.6.2 Handling Streams and Files </h3>
<dl compact="compact">
<dt> <code>tell(+<var>S</var>)</code></dt>
<dd><a name="IDX427"></a>
<a name="IDX428"></a>
<a name="IDX429"></a>
<p>If <var>S</var> is a currently opened stream for output, it becomes the
current output stream. If <var>S</var> is an atom it is taken to be a
filename. If there is no output stream currently associated with it,
then it is opened for output, and the new output stream created becomes
the current output stream. If it is not possible to open the file, an
error occurs. If there is a single opened output stream currently
associated with the file, then it becomes the current output stream; if
there are more than one in that condition, one of them is chosen.
</p>
<p>Whenever <var>S</var> is a stream not currently opened for output, an error
may be reported, depending on the state of the file_errors flag. The
predicate just fails, if <var>S</var> is neither a stream nor an atom.
</p>
</dd>
<dt> <code>telling(-<var>S</var>)</code></dt>
<dd><a name="IDX430"></a>
<a name="IDX431"></a>
<a name="IDX432"></a>
<p>The current output stream is unified with <var>S</var>.
</p>
</dd>
<dt> <code>told</code></dt>
<dd><a name="IDX433"></a>
<a name="IDX434"></a>
<a name="IDX435"></a>
<p>Closes the current output stream, and the user's terminal becomes again
the current output stream. It is important to remember to close streams
after having finished using them, as the maximum number of
simultaneously opened streams is 17.
</p>
</dd>
<dt> <code>see(+<var>S</var>)</code></dt>
<dd><a name="IDX436"></a>
<a name="IDX437"></a>
<a name="IDX438"></a>
<p>If <var>S</var> is a currently opened input stream then it is assumed to be
the current input stream. If <var>S</var> is an atom it is taken as a
filename. If there is no input stream currently associated with it, then
it is opened for input, and the new input stream thus created becomes
the current input stream. If it is not possible to open the file, an
error occurs. If there is a single opened input stream currently
associated with the file, it becomes the current input stream; if there
are more than one in that condition, then one of them is chosen.
</p>
<p>When <var>S</var> is a stream not currently opened for input, an error may be
reported, depending on the state of the <code>file_errors</code> flag. If
<var>S</var> is neither a stream nor an atom the predicates just fails.
</p>
</dd>
<dt> <code>seeing(-<var>S</var>)</code></dt>
<dd><a name="IDX439"></a>
<a name="IDX440"></a>
<a name="IDX441"></a>
<p>The current input stream is unified with <var>S</var>.
</p>
</dd>
<dt> <code>seen</code></dt>
<dd><a name="IDX442"></a>
<a name="IDX443"></a>
<a name="IDX444"></a>
<p>Closes the current input stream (see 6.7.).
</p>
</dd>
</dl>
<hr size="6">
<a name="I_002fO-of-Terms"></a>
<a name="SEC40"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC39" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC41" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC31" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC37" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 6.6.3 Handling Input/Output of Terms </h3>
<dl compact="compact">
<dt> <code>read(-<var>T</var>) [ISO]</code></dt>
<dd><a name="IDX445"></a>
<a name="IDX446"></a>
<a name="IDX447"></a>
<p>Reads the next term from the current input stream, and unifies it with
<var>T</var>. The term must be followed by a dot ('.') and any blank-character
as previously defined. The syntax of the term must match the current
declarations for operators (see op). If the end-of-stream is reached,
<var>T</var> is unified with the atom <code>end_of_file</code>. Further reads from of
the same stream may cause an error failure (see <code>open/3</code>).
</p>
</dd>
<dt> <code>read_term(-<var>T</var>,+<var>Options</var>) [ISO]</code></dt>
<dd><a name="IDX448"></a>
<a name="IDX449"></a>
<a name="IDX450"></a>
<p>Reads term <var>T</var> from the current input stream with execution
controlled by the following options:
</p>
<dl compact="compact">
<dt> <code>singletons(-<var>Names</var>)</code></dt>
<dd><a name="IDX451"></a>
<p>Unify <var>Names</var> with a list of the form <var>Name=Var</var>, where
<var>Name</var> is the name of a non-anonymous singleton variable in the
original term, and <code>Var</code> is the variable's representation in
YAP.
</p>
</dd>
<dt> <code>syntax_errors(+<var>Val</var>)</code></dt>
<dd><a name="IDX452"></a>
<p>Control action to be taken after syntax errors. See <code>yap_flag/2</code>
for detailed information.
</p>
</dd>
<dt> <code>variable_names(-<var>Names</var>)</code></dt>
<dd><a name="IDX453"></a>
<p>Unify <var>Names</var> with a list of the form <var>Name=Var</var>, where <var>Name</var> is
the name of a non-anonymous variable in the original term, and <var>Var</var>
is the variable's representation in YAP.
</p>
</dd>
<dt> <code>variables(-<var>Names</var>)</code></dt>
<dd><a name="IDX454"></a>
<p>Unify <var>Names</var> with a list of the variables in term <var>T</var>.
</p>
</dd>
</dl>
</dd>
<dt> <code>char_conversion(+<var>IN</var>,+<var>OUT</var>) [ISO]</code></dt>
<dd><a name="IDX455"></a>
<a name="IDX456"></a>
<a name="IDX457"></a>
<p>While reading terms convert unquoted occurrences of the character
<var>IN</var> to the character <var>OUT</var>. Both <var>IN</var> and <var>OUT</var> must be
bound to single characters atoms.
</p>
<p>Character conversion only works if the flag <code>char_conversion</code> is
on. This is default in the <code>iso</code> and <code>sicstus</code> language
modes. As an example, character conversion can be used for instance to
convert characters from the ISO-LATIN-1 character set to ASCII.
</p>
<p>If <var>IN</var> is the same character as <var>OUT</var>, <code>char_conversion/2</code>
will remove this conversion from the table.
</p>
</dd>
<dt> <code>current_char_conversion(?<var>IN</var>,?<var>OUT</var>) [ISO]</code></dt>
<dd><a name="IDX458"></a>
<a name="IDX459"></a>
<a name="IDX460"></a>
<p>If <var>IN</var> is unbound give all current character
translations. Otherwise, give the translation for <var>IN</var>, if one
exists.
</p>
</dd>
<dt> <code>write(<var>T</var>) [ISO]</code></dt>
<dd><a name="IDX461"></a>
<a name="IDX462"></a>
<a name="IDX463"></a>
<p>The term <var>T</var> is written to the current output stream according to
the operator declarations in force.
</p>
</dd>
<dt> <code>display(+<var>T</var>)</code></dt>
<dd><a name="IDX464"></a>
<a name="IDX465"></a>
<a name="IDX466"></a>
<p>Displays term <var>T</var> on the current output stream. All Prolog terms are
written in standard parenthesized prefix notation.
</p>
</dd>
<dt> <code>write_canonical(+<var>T</var>) [ISO]</code></dt>
<dd><a name="IDX467"></a>
<a name="IDX468"></a>
<a name="IDX469"></a>
<p>Displays term <var>T</var> on the current output stream. Atoms are quoted
when necessary, and operators are ignored, that is, the term is written
in standard parenthesized prefix notation.
</p>
</dd>
<dt> <code>write_term(+<var>T</var>, +<var>Opts</var>) [ISO]</code></dt>
<dd><a name="IDX470"></a>
<a name="IDX471"></a>
<a name="IDX472"></a>
<p>Displays term <var>T</var> on the current output stream, according to the
following options:
</p>
<dl compact="compact">
<dt> <code>quoted(+<var>Bool</var>)</code></dt>
<dd><p>If <code>true</code>, quote atoms if this would be necessary for the atom to
be recognized as an atom by YAP's parser. The default value is
<code>false</code>.
</p>
</dd>
<dt> <code>ignore_ops(+<var>Bool</var>)</code></dt>
<dd><p>If <code>true</code>, ignore operator declarations when writing the term. The
default value is <code>false</code>.
</p>
</dd>
<dt> <code>numbervars(+<var>Bool</var>)</code></dt>
<dd><p>If <code>true</code>, output terms of the form
<code>'$VAR'(N)</code>, where <var>N</var> is an integer, as a sequence of capital
letters. The default value is <code>false</code>.
</p>
</dd>
<dt> <code>portrayed(+<var>Bool</var>)</code></dt>
<dd><p>If <code>true</code>, use <tt>portray/1</tt> to portray bound terms. The default
value is <code>false</code>.
</p>
</dd>
<dt> <code>max_depth(+<var>Depth</var>)</code></dt>
<dd><p>If <code>Depth</code> is a positive integer, use <tt>Depth</tt> as
the maximum depth to portray a term. The default is <code>0</code>, that is,
unlimited depth.
</p>
</dd>
</dl>
</dd>
<dt> <code>writeq(<var>T</var>) [ISO]</code></dt>
<dd><a name="IDX473"></a>
<a name="IDX474"></a>
<a name="IDX475"></a>
<p> Writes the term <var>T</var>, quoting names to make the result acceptable to
the predicate 'read' whenever necessary.
</p>
</dd>
<dt> <code>print(<var>T</var>)</code></dt>
<dd><a name="IDX476"></a>
<a name="IDX477"></a>
<a name="IDX478"></a>
<p>Prints the term <var>T</var> to the current output stream using <code>write/1</code>
unless T is bound and a call to the user-defined predicate
<code>portray/1</code> succeeds. To do pretty printing of terms the user should
define suitable clauses for <code>portray/1</code> and use <code>print/1</code>.
</p>
</dd>
<dt> <code>format(+<var>T</var>,+<var>L</var>)</code></dt>
<dd><a name="IDX479"></a>
<a name="IDX480"></a>
<a name="IDX481"></a>
<p>Print formatted output to the current output stream. The arguments in
list <var>L</var> are output according to the string or atom <var>T</var>.
</p>
<p>A control sequence is introduced by a <code>w</code>. The following control
sequences are available in YAP:
</p>
<dl compact="compact">
<dt> <code>'~~'</code></dt>
<dd><p>Print a single tilde.
</p>
</dd>
<dt> <code>'~a'</code></dt>
<dd><p>The next argument must be an atom, that will be printed as if by <code>write</code>.
</p>
</dd>
<dt> <code>'~Nc'</code></dt>
<dd><p>The next argument must be an integer, that will be printed as a
character code. The number <var>N</var> is the number of times to print the
character (default 1).
</p>
</dd>
<dt> <code>'~Ne'</code></dt>
<dt> <code>'~NE'</code></dt>
<dt> <code>'~Nf'</code></dt>
<dt> <code>'~Ng'</code></dt>
<dt> <code>'~NG'</code></dt>
<dd><p>The next argument must be a floating point number. The float <var>F</var>, the number
<var>N</var> and the control code <code>c</code> will be passed to <code>printf</code> as:
</p>
<table><tr><td> </td><td><pre class="example"> printf("%s.Nc", F)
</pre></td></tr></table>
<p>As an example:
</p>
<table><tr><td> </td><td><pre class="example">?- format("~8e, ~8E, ~8f, ~8g, ~8G~w",
[3.14,3.14,3.14,3.14,3.14,3.14]).
3.140000e+00, 3.140000E+00, 3.140000, 3.14, 3.143.14
</pre></td></tr></table>
</dd>
<dt> <code>'~Nd'</code></dt>
<dd><p>The next argument must be an integer, and <var>N</var> is the number of digits
after the decimal point. If <var>N</var> is <code>0</code> no decimal points will be
printed. The default is <var>N = 0</var>.
</p>
<table><tr><td> </td><td><pre class="example">?- format("~2d, ~d",[15000, 15000]).
150.00, 15000
</pre></td></tr></table>
</dd>
<dt> <code>'~ND'</code></dt>
<dd><p>Identical to <code>'~Nd'</code>, except that commas are used to separate groups
of three digits.
</p>
<table><tr><td> </td><td><pre class="example">?- format("~2D, ~D",[150000, 150000]).
1,500.00, 150,000
</pre></td></tr></table>
</dd>
<dt> <code>'~i'</code></dt>
<dd><p>Ignore the next argument in the list of arguments:
</p>
<table><tr><td> </td><td><pre class="example">?- format('The ~i met the boregrove',[mimsy]).
The met the boregrove
</pre></td></tr></table>
</dd>
<dt> <code>'~k'</code></dt>
<dd><p>Print the next argument with <code>write_canonical</code>:
</p>
<table><tr><td> </td><td><pre class="example">?- format("Good night ~k",a+[1,2]).
Good night +(a,[1,2])
</pre></td></tr></table>
</dd>
<dt> <code>'~Nn'</code></dt>
<dd><p>Print <var>N</var> newlines (where <var>N</var> defaults to 1).
</p>
</dd>
<dt> <code>'~NN'</code></dt>
<dd><p>Print <var>N</var> newlines if at the beginning of the line (where <var>N</var>
defaults to 1).
</p>
</dd>
<dt> <code>'~Nr'</code></dt>
<dd><p>The next argument must be an integer, and <var>N</var> is interpreted as a
radix, such that <code>2 <= N <= 36</code> (the default is 8).
</p>
<table><tr><td> </td><td><pre class="example">?- format("~2r, 0x~16r, ~r",
[150000, 150000, 150000]).
100100100111110000, 0x249f0, 444760
</pre></td></tr></table>
<p>Note that the letters <code>a-z</code> denote digits larger than 9.
</p>
</dd>
<dt> <code>'~NR'</code></dt>
<dd><p>Similar to '~NR'. The next argument must be an integer, and <var>N</var> is
interpreted as a radix, such that <code>2 <= N <= 36</code> (the default is 8).
</p>
<table><tr><td> </td><td><pre class="example">?- format("~2r, 0x~16r, ~r",
[150000, 150000, 150000]).
100100100111110000, 0x249F0, 444760
</pre></td></tr></table>
<p>The only difference is that letters <code>A-Z</code> denote digits larger than 9.
</p>
</dd>
<dt> <code>'~p'</code></dt>
<dd><p>Print the next argument with <code>print/1</code>:
</p>
<table><tr><td> </td><td><pre class="example">?- format("Good night ~p",a+[1,2]).
Good night a+[1,2]
</pre></td></tr></table>
</dd>
<dt> <code>'~q'</code></dt>
<dd><p>Print the next argument with <code>writeq/1</code>:
</p>
<table><tr><td> </td><td><pre class="example">?- format("Good night ~q",'Hello'+[1,2]).
Good night 'Hello'+[1,2]
</pre></td></tr></table>
</dd>
<dt> <code>'~Ns'</code></dt>
<dd><p>The next argument must be a list of character codes. The system then
outputs their representation as a string, where <var>N</var> is the maximum
number of characters for the string (<var>N</var> defaults to the length of the
string).
</p>
<table><tr><td> </td><td><pre class="example">?- format("The ~s are ~4s",["woods","lovely"]).
The woods are love
</pre></td></tr></table>
</dd>
<dt> <code>'~w'</code></dt>
<dd><p>Print the next argument with <code>write/1</code>:
</p>
<table><tr><td> </td><td><pre class="example">?- format("Good night ~w",'Hello'+[1,2]).
Good night Hello+[1,2]
</pre></td></tr></table>
</dd>
</dl>
<p>The number of arguments, <code>N</code>, may be given as an integer, or it
may be given as an extra argument. The next example shows a small
procedure to write a variable number of <code>a</code> characters:
</p>
<table><tr><td> </td><td><pre class="example">write_many_as(N) :-
format("~*c",[N,0'a]).
</pre></td></tr></table>
<p>The <code>format/2</code> built-in also allows for formatted output. One can
specify column boundaries and fill the intermediate space by a padding
character:
</p>
<dl compact="compact">
<dt> <code>'~N|'</code></dt>
<dd><p>Set a column boundary at position <var>N</var>, where <var>N</var> defaults to the
current position.
</p>
</dd>
<dt> <code>'~N+'</code></dt>
<dd><p>Set a column boundary at <var>N</var> characters past the current position, where
<var>N</var> defaults to <code>8</code>.
</p>
</dd>
<dt> <code>'~Nt'</code></dt>
<dd><p>Set padding for a column, where <var>N</var> is the fill code (default is
<kbd>SPC</kbd>).
</p>
</dd>
</dl>
<p>The next example shows how to align columns and padding. We first show
left-alignment:
</p>
<table><tr><td> </td><td><pre class="example">
<code>
?- format("~n*Hello~16+*~n",[]).
*Hello *
</code>
</pre></td></tr></table>
<p>Note that we reserve 16 characters for the column.
</p>
<p>The following example shows how to do right-alignment:
</p>
<table><tr><td> </td><td><pre class="example"><code>
?- format("*~tHello~16+*~n",[]).
* Hello*
</code>
</pre></td></tr></table>
<p>The <code>~t</code> escape sequence forces filling before <code>Hello</code>.
</p>
<p>We next show how to do centering:
</p>
<table><tr><td> </td><td><pre class="example"><code>
?- format("*~tHello~t~16+*~n",[]).
* Hello *
</code>
</pre></td></tr></table>
<p>The two <code>~t</code> escape sequence force filling both before and after
<code>Hello</code>. Space is then evenly divided between the right and the
left sides.
</p>
</dd>
<dt> <code>format(+<var>S</var>,+<var>T</var>,+<var>L</var>)</code></dt>
<dd><a name="IDX482"></a>
<a name="IDX483"></a>
<a name="IDX484"></a>
<p>Print formatted output to stream <var>S</var>.
</p>
</dd>
</dl>
<hr size="6">
<a name="I_002fO-of-Characters"></a>
<a name="SEC41"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC40" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC42" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC31" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC37" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 6.6.4 Handling Input/Output of Characters </h3>
<dl compact="compact">
<dt> <code>put(+<var>N</var>)</code></dt>
<dd><a name="IDX485"></a>
<a name="IDX486"></a>
<a name="IDX487"></a>
<p>Outputs to the current output stream the character whose ASCII code is
<var>N</var>. The character <var>N</var> must be a legal ASCII character code, an
expression yielding such a code, or a list in which case only the first
element is used.
</p>
</dd>
<dt> <code>put_byte(+<var>N</var>) [ISO]</code></dt>
<dd><a name="IDX488"></a>
<a name="IDX489"></a>
<a name="IDX490"></a>
<p>Outputs to the current output stream the character whose code is
<var>N</var>. The current output stream must be a binary stream.
</p>
</dd>
<dt> <code>put_char(+<var>N</var>) [ISO]</code></dt>
<dd><a name="IDX491"></a>
<a name="IDX492"></a>
<a name="IDX493"></a>
<p>Outputs to the current output stream the character who is used to build
the representation of atom <code>A</code>. The current output stream must be a
text stream.
</p>
</dd>
<dt> <code>put_code(+<var>N</var>) [ISO]</code></dt>
<dd><a name="IDX494"></a>
<a name="IDX495"></a>
<a name="IDX496"></a>
<p>Outputs to the current output stream the character whose ASCII code is
<var>N</var>. The current output stream must be a text stream. The character
<var>N</var> must be a legal ASCII character code, an expression yielding such
a code, or a list in which case only the first element is used.
</p>
</dd>
<dt> <code>get(-<var>C</var>)</code></dt>
<dd><a name="IDX497"></a>
<a name="IDX498"></a>
<a name="IDX499"></a>
<p>The next non-blank character from the current input stream is unified
with <var>C</var>. Blank characters are the ones whose ASCII codes are not
greater than 32. If there are no more non-blank characters in the
stream, <var>C</var> is unified with -1. If <code>end_of_stream</code> has already
been reached in the previous reading, this call will give an error message.
</p>
</dd>
<dt> <code>get0(-<var>C</var>)</code></dt>
<dd><a name="IDX500"></a>
<a name="IDX501"></a>
<a name="IDX502"></a>
<p>The next character from the current input stream is consumed, and then
unified with <var>C</var>. There are no restrictions on the possible
values of the ASCII code for the character, but the character will be
internally converted by YAP.
</p>
</dd>
<dt> <code>get_byte(-<var>C</var>) [ISO]</code></dt>
<dd><a name="IDX503"></a>
<a name="IDX504"></a>
<a name="IDX505"></a>
<p>If <var>C</var> is unbound, or is a character code, and the current stream is a
binary stream, read the next byte from the current stream and unify its
code with <var>C</var>.
</p>
</dd>
<dt> <code>get_char(-<var>C</var>) [ISO]</code></dt>
<dd><a name="IDX506"></a>
<a name="IDX507"></a>
<a name="IDX508"></a>
<p>If <var>C</var> is unbound, or is an atom representation of a character, and
the current stream is a text stream, read the next character from the
current stream and unify its atom representation with <var>C</var>.
</p>
</dd>
<dt> <code>get_code(-<var>C</var>) [ISO]</code></dt>
<dd><a name="IDX509"></a>
<a name="IDX510"></a>
<a name="IDX511"></a>
<p>If <var>C</var> is unbound, or is the code for a character, and
the current stream is a text stream, read the next character from the
current stream and unify its code with <var>C</var>.
</p>
</dd>
<dt> <code>peek_byte(-<var>C</var>) [ISO]</code></dt>
<dd><a name="IDX512"></a>
<a name="IDX513"></a>
<a name="IDX514"></a>
<p>If <var>C</var> is unbound, or is a character code, and the current stream is a
binary stream, read the next byte from the current stream and unify its
code with <var>C</var>, while leaving the current stream position unaltered.
</p>
</dd>
<dt> <code>peek_char(-<var>C</var>) [ISO]</code></dt>
<dd><a name="IDX515"></a>
<a name="IDX516"></a>
<a name="IDX517"></a>
<p>If <var>C</var> is unbound, or is an atom representation of a character, and
the current stream is a text stream, read the next character from the
current stream and unify its atom representation with <var>C</var>, while
leaving the current stream position unaltered.
</p>
</dd>
<dt> <code>peek_code(-<var>C</var>) [ISO]</code></dt>
<dd><a name="IDX518"></a>
<a name="IDX519"></a>
<a name="IDX520"></a>
<p>If <var>C</var> is unbound, or is the code for a character, and
the current stream is a text stream, read the next character from the
current stream and unify its code with <var>C</var>, while
leaving the current stream position unaltered.
</p>
</dd>
<dt> <code>skip(+<var>N</var>)</code></dt>
<dd><a name="IDX521"></a>
<a name="IDX522"></a>
<a name="IDX523"></a>
<p>Skips input characters until the next occurrence of the character with
ASCII code <var>N</var>. The argument to this predicate can take the same forms
as those for <code>put</code> (see 6.11).
</p>
</dd>
<dt> <code>tab(+<var>N</var>)</code></dt>
<dd><a name="IDX524"></a>
<a name="IDX525"></a>
<a name="IDX526"></a>
<p>Outputs <var>N</var> spaces to the current output stream.
</p>
</dd>
<dt> <code>nl [ISO]</code></dt>
<dd><a name="IDX527"></a>
<a name="IDX528"></a>
<a name="IDX529"></a>
<p>Outputs a new line to the current output stream.
</p>
</dd>
</dl>
<hr size="6">
<a name="I_002fO-for-Streams"></a>
<a name="SEC42"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC41" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC43" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC31" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC37" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 6.6.5 Input/Output Predicates applied to Streams </h3>
<dl compact="compact">
<dt> <code>read(+<var>S</var>,-<var>T</var>) [ISO]</code></dt>
<dd><a name="IDX530"></a>
<a name="IDX531"></a>
<a name="IDX532"></a>
<p>Reads term <var>T</var> from the stream <var>S</var> instead of from the current input
stream.
</p>
</dd>
<dt> <code>read_term(+<var>S</var>,-<var>T</var>,+<var>Options</var>) [ISO]</code></dt>
<dd><a name="IDX533"></a>
<a name="IDX534"></a>
<a name="IDX535"></a>
<p>Reads term <var>T</var> from stream <var>S</var> with execution controlled by the
same options as <code>read_term/2</code>.
</p>
</dd>
<dt> <code>write(+<var>S</var>,<var>T</var>) [ISO]</code></dt>
<dd><a name="IDX536"></a>
<a name="IDX537"></a>
<a name="IDX538"></a>
<p>Writes term <var>T</var> to stream <var>S</var> instead of to the current output
stream.
</p>
</dd>
<dt> <code>write_canonical(+<var>S</var>,+<var>T</var>) [ISO]</code></dt>
<dd><a name="IDX539"></a>
<a name="IDX540"></a>
<a name="IDX541"></a>
<p>Displays term <var>T</var> on the stream <var>S</var>. Atoms are quoted when
necessary, and operators are ignored.
</p>
</dd>
<dt> <code>write_term(+<var>S</var>, +<var>T</var>, +<var>Opts</var>) [ISO]</code></dt>
<dd><a name="IDX542"></a>
<a name="IDX543"></a>
<a name="IDX544"></a>
<p>Displays term <var>T</var> on the current output stream, according to the same
options used by <code>write_term/3</code>.
</p>
</dd>
<dt> <code>writeq(+<var>S</var>,<var>T</var>) [ISO]</code></dt>
<dd><a name="IDX545"></a>
<a name="IDX546"></a>
<a name="IDX547"></a>
<p>As <code>writeq/1</code>, but the output is sent to the stream <var>S</var>.
</p>
</dd>
<dt> <code>display(+<var>S</var>,<var>T</var>)</code></dt>
<dd><a name="IDX548"></a>
<a name="IDX549"></a>
<a name="IDX550"></a>
<p>Like <code>display/1</code>, but using stream <var>S</var> to display the term.
</p>
</dd>
<dt> <code>print(+<var>S</var>,<var>T</var>)</code></dt>
<dd><a name="IDX551"></a>
<a name="IDX552"></a>
<a name="IDX553"></a>
<p>Prints term <var>T</var> to the stream <var>S</var> instead of to the current output
stream.
</p>
</dd>
<dt> <code>put(+<var>S</var>,+<var>N</var>)</code></dt>
<dd><a name="IDX554"></a>
<a name="IDX555"></a>
<a name="IDX556"></a>
<p>As <code>put(N)</code>, but to stream <var>S</var>.
</p>
</dd>
<dt> <code>put_byte(+<var>S</var>,+<var>N</var>) [ISO]</code></dt>
<dd><a name="IDX557"></a>
<a name="IDX558"></a>
<a name="IDX559"></a>
<p>As <code>put_byte(N)</code>, but to binary stream <var>S</var>.
</p>
</dd>
<dt> <code>put_char(+<var>S</var>,+<var>A</var>) [ISO]</code></dt>
<dd><a name="IDX560"></a>
<a name="IDX561"></a>
<a name="IDX562"></a>
<p>As <code>put_char(A)</code>, but to text stream <var>S</var>.
</p>
</dd>
<dt> <code>put_code(+<var>S</var>,+<var>N</var>) [ISO]</code></dt>
<dd><a name="IDX563"></a>
<a name="IDX564"></a>
<a name="IDX565"></a>
<p>As <code>put_code(N)</code>, but to text stream <var>S</var>.
</p>
</dd>
<dt> <code>get(+<var>S</var>,-<var>C</var>)</code></dt>
<dd><a name="IDX566"></a>
<a name="IDX567"></a>
<a name="IDX568"></a>
<p>The same as <code>get(C)</code>, but from stream <var>S</var>.
</p>
</dd>
<dt> <code>get0(+<var>S</var>,-<var>C</var>)</code></dt>
<dd><a name="IDX569"></a>
<a name="IDX570"></a>
<a name="IDX571"></a>
<p>The same as <code>get0(C)</code>, but from stream <var>S</var>.
</p>
</dd>
<dt> <code>get_byte(+<var>S</var>,-<var>C</var>) [ISO]</code></dt>
<dd><a name="IDX572"></a>
<a name="IDX573"></a>
<a name="IDX574"></a>
<p>If <var>C</var> is unbound, or is a character code, and the stream <var>S</var> is a
binary stream, read the next byte from that stream and unify its
code with <var>C</var>.
</p>
</dd>
<dt> <code>get_char(+<var>S</var>,-<var>C</var>) [ISO]</code></dt>
<dd><a name="IDX575"></a>
<a name="IDX576"></a>
<a name="IDX577"></a>
<p>If <var>C</var> is unbound, or is an atom representation of a character, and
the stream <var>S</var> is a text stream, read the next character from that
stream and unify its representation as an atom with <var>C</var>.
</p>
</dd>
<dt> <code>get_code(+<var>S</var>,-<var>C</var>) [ISO]</code></dt>
<dd><a name="IDX578"></a>
<a name="IDX579"></a>
<a name="IDX580"></a>
<p>If <var>C</var> is unbound, or is a character code, and the stream <var>S</var> is a
text stream, read the next character from that stream and unify its
code with <var>C</var>.
</p>
</dd>
<dt> <code>peek_byte(+<var>S</var>,-<var>C</var>) [ISO]</code></dt>
<dd><a name="IDX581"></a>
<a name="IDX582"></a>
<a name="IDX583"></a>
<p>If <var>C</var> is unbound, or is a character code, and <var>S</var> is a binary
stream, read the next byte from the current stream and unify its code
with <var>C</var>, while leaving the current stream position unaltered.
</p>
</dd>
<dt> <code>peek_char(+<var>S</var>,-<var>C</var>) [ISO]</code></dt>
<dd><a name="IDX584"></a>
<a name="IDX585"></a>
<a name="IDX586"></a>
<p>If <var>C</var> is unbound, or is an atom representation of a character, and
the stream <var>S</var> is a text stream, read the next character from that
stream and unify its representation as an atom with <var>C</var>, while leaving
the current stream position unaltered.
</p>
</dd>
<dt> <code>peek_code(+<var>S</var>,-<var>C</var>) [ISO]</code></dt>
<dd><a name="IDX587"></a>
<a name="IDX588"></a>
<a name="IDX589"></a>
<p>If <var>C</var> is unbound, or is an atom representation of a character, and
the stream <var>S</var> is a text stream, read the next character from that
stream and unify its representation as an atom with <var>C</var>, while leaving
the current stream position unaltered.
</p>
</dd>
<dt> <code>skip(+<var>S</var>,-<var>C</var>)</code></dt>
<dd><a name="IDX590"></a>
<a name="IDX591"></a>
<a name="IDX592"></a>
<p>Like <code>skip/1</code>, but using stream <var>S</var> instead of the current
input stream.
</p>
</dd>
<dt> <code>tab(+<var>S</var>,+<var>N</var>)</code></dt>
<dd><a name="IDX593"></a>
<a name="IDX594"></a>
<a name="IDX595"></a>
<p>The same as <code>tab/1</code>, but using stream <var>S</var>.
</p>
</dd>
<dt> <code>nl(+<var>S</var>)</code></dt>
<dd><a name="IDX596"></a>
<a name="IDX597"></a>
<a name="IDX598"></a>
<p>Outputs a new line to stream <var>S</var>.
</p>
</dd>
</dl>
<hr size="6">
<a name="C_002dProlog-to-Terminal"></a>
<a name="SEC43"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC42" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC44" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC31" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC37" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 6.6.6 Compatible C-Prolog predicates for Terminal I/O </h3>
<dl compact="compact">
<dt> <code>ttyput(+<var>N</var>)</code></dt>
<dd><a name="IDX599"></a>
<a name="IDX600"></a>
<a name="IDX601"></a>
<p>As <code>put(N)</code> but always to <code>user_output</code>.
</p>
</dd>
<dt> <code>ttyget(-<var>C</var>)</code></dt>
<dd><a name="IDX602"></a>
<a name="IDX603"></a>
<a name="IDX604"></a>
<p>The same as <code>get(C)</code>, but from stream <code>user_input</code>.
</p>
</dd>
<dt> <code>ttyget0(-<var>C</var>)</code></dt>
<dd><a name="IDX605"></a>
<a name="IDX606"></a>
<a name="IDX607"></a>
<p>The same as <code>get0(C)</code>, but from stream <code>user_input</code>.
</p>
</dd>
<dt> <code>ttyskip(-<var>C</var>)</code></dt>
<dd><a name="IDX608"></a>
<a name="IDX609"></a>
<a name="IDX610"></a>
<p>Like <code>skip/1</code>, but always using stream <code>user_input</code>.
stream.
</p>
</dd>
<dt> <code>ttytab(+<var>N</var>)</code></dt>
<dd><a name="IDX611"></a>
<a name="IDX612"></a>
<a name="IDX613"></a>
<p>The same as <code>tab/1</code>, but using stream <code>user_output</code>.
</p>
</dd>
<dt> <code>ttynl</code></dt>
<dd><a name="IDX614"></a>
<a name="IDX615"></a>
<a name="IDX616"></a>
<p>Outputs a new line to stream <code>user_output</code>.
</p>
</dd>
</dl>
<hr size="6">
<a name="I_002fO-Control"></a>
<a name="SEC44"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC43" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC45" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC31" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC37" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 6.6.7 Controlling Input/Output </h3>
<dl compact="compact">
<dt> <code>exists(+<var>F</var>)</code></dt>
<dd><a name="IDX617"></a>
<a name="IDX618"></a>
<a name="IDX619"></a>
<p>Checks if file <var>F</var> exists in the current directory.
</p>
</dd>
<dt> <code>nofileerrors</code></dt>
<dd><a name="IDX620"></a>
<a name="IDX621"></a>
<a name="IDX622"></a>
<p>Switches off the file_errors flag, so that the predicates <code>see/1</code>,
<code>tell/1</code>, <code>open/3</code> and <code>close/1</code> just fail, instead of producing
an error message and aborting whenever the specified file cannot be
opened or closed.
</p>
</dd>
<dt> <code>fileerrors</code></dt>
<dd><a name="IDX623"></a>
<a name="IDX624"></a>
<a name="IDX625"></a>
<p>Switches on the file_errors flag so that in certain error conditions
I/O predicates will produce an appropriated message and abort.
</p>
</dd>
<dt> <code>write_depth(<var>T</var>,<var>L</var>,<var>A</var>)</code></dt>
<dd><a name="IDX626"></a>
<a name="IDX627"></a>
<a name="IDX628"></a>
<p>Unifies <var>T</var> with the value of the maximum depth of a term to be
written, <var>L</var> with the maximum length of a list to write, and <var>A</var>
with the maximum number of arguments of a compound term to write. The
setting will be used by <code>write/1</code> or <code>write/2</code>. The default
value for all arguments is 0, meaning unlimited depth and length.
</p>
<table><tr><td> </td><td><pre class="example">?- write_depth(3,5,5).
yes
?- write(a(b(c(d(e(f(g))))))).
a(b(c(....)))
yes
?- write([1,2,3,4,5,6,7,8]).
[1,2,3,4,5,...]
yes
?- write(a(1,2,3,4,5,6,7,8)).
a(1,2,3,4,5,...)
yes
</pre></td></tr></table>
</dd>
<dt> <code>write_depth(<var>T</var>,<var>L</var>)</code></dt>
<dd><a name="IDX629"></a>
<a name="IDX630"></a>
<p>Same as <code>write_depth(<var>T</var>,<var>L</var>,_)</code>. Unifies <var>T</var> with the
value of the maximum depth of a term to be
written, and <var>L</var> with the maximum length of a list to write. The
setting will be used by <code>write/1</code> or <code>write/2</code>. The default
value for all arguments is 0, meaning unlimited depth and length.
</p>
<table><tr><td> </td><td><pre class="example">?- write_depth(3,5,5).
yes
?- write(a(b(c(d(e(f(g))))))).
a(b(c(....)))
yes
?- write([1,2,3,4,5,6,7,8]).
[1,2,3,4,5,...]
yes
</pre></td></tr></table>
</dd>
<dt> <code>always_prompt_user</code></dt>
<dd><a name="IDX631"></a>
<a name="IDX632"></a>
<a name="IDX633"></a>
<p>Force the system to prompt the user even if the <code>user_input</code> stream
is not a terminal. This command is useful if you want to obtain
interactive control from a pipe or a socket.
</p>
</dd>
</dl>
<hr size="6">
<a name="Sockets"></a>
<a name="SEC45"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC44" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC46" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC31" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC37" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 6.6.8 Using Sockets From Yap </h3>
<p>YAP includes a SICStus Prolog compatible socket interface. This
is a low level interface that provides direct access to the major socket
system calls. These calls can be used both to open a new connection in
the network or connect to a networked server. Socket connections are
described as read/write streams, and standard I/O built-ins can be used
to write on or read from sockets. The following calls are available:
</p>
<dl compact="compact">
<dt> <code>socket(+<var>DOMAIN</var>,+<var>TYPE</var>,+<var>PROTOCOL</var>,-<var>SOCKET</var>)</code></dt>
<dd><a name="IDX634"></a>
<a name="IDX635"></a>
<a name="IDX636"></a>
<p>Corresponds to the BSD system call <code>socket</code>. Create a socket for
domain <var>DOMAIN</var> of type <var>TYPE</var> and protocol
<var>PROTOCOL</var>. Both <var>DOMAIN</var> and <var>TYPE</var> should be atoms,
whereas <var>PROTOCOL</var> must be an integer. The new socket object is
accessible through a descriptor bound to the variable <var>SOCKET</var>.
</p>
<p>The current implementation of YAP only accepts two socket
domains: <code>'AF_INET'</code> and <code>'AF_UNIX'</code>. Socket types depend on the
underlying operating system, but at least the following types are
supported: <code>'SOCK_STREAM'</code> and <code>'SOCK_DGRAM'</code>.
</p>
</dd>
<dt> <code>socket(+<var>DOMAIN</var>,-<var>SOCKET</var>)</code></dt>
<dd><a name="IDX637"></a>
<a name="IDX638"></a>
<a name="IDX639"></a>
<p>Call <code>socket/4</code> with <var>TYPE</var> bound to <code>'SOCK_STREAM'</code> and
<var>PROTOCOL</var> bound to <code>0</code>.
</p>
</dd>
<dt> <code>socket_close(+<var>SOCKET</var>)</code></dt>
<dd><a name="IDX640"></a>
<a name="IDX641"></a>
<a name="IDX642"></a>
<p>Close socket <var>SOCKET</var>. Note that sockets used in
<code>socket_connect</code> (that is, client sockets) should not be closed with
<code>socket_close</code>, as they will be automatically closed when the
corresponding stream is closed with <code>close/1</code> or <code>close/2</code>.
</p>
</dd>
<dt> <code>socket_bind(+<var>SOCKET</var>, ?<var>PORT</var>)</code></dt>
<dd><a name="IDX643"></a>
<a name="IDX644"></a>
<a name="IDX645"></a>
<p>Interface to system call <code>bind</code>, as used for servers: bind socket
to a port. Port information depends on the domain:
</p><dl compact="compact">
<dt> <code>'AF_UNIX'(+<var>FILENAME</var>)</code></dt>
<dt> <code>'AF_FILE'(+<var>FILENAME</var>)</code></dt>
<dd><p>use file name <var>FILENAME</var> for UNIX or local sockets.
</p>
</dd>
<dt> <code>'AF_INET'(?<var>HOST</var>,?PORT)</code></dt>
<dd><p>If <var>HOST</var> is bound to an atom, bind to host <var>HOST</var>, otherwise
if unbound bind to local host (<var>HOST</var> remains unbound). If port
<var>PORT</var> is bound to an integer, try to bind to the corresponding
port. If variable <var>PORT</var> is unbound allow operating systems to
choose a port number, which is unified with <var>PORT</var>.
</p>
</dd>
</dl>
</dd>
<dt> <code>socket_connect(+<var>SOCKET</var>, +<var>PORT</var>, -<var>STREAM</var>)</code></dt>
<dd><a name="IDX646"></a>
<a name="IDX647"></a>
<a name="IDX648"></a>
<p>Interface to system call <code>connect</code>, used for clients: connect
socket <var>SOCKET</var> to <var>PORT</var>. The connection results in the
read/write stream <var>STREAM</var>.
</p>
<p>Port information depends on the domain:
</p><dl compact="compact">
<dt> <code>'AF_UNIX'(+<var>FILENAME</var>)</code></dt>
<dt> <code>'AF_FILE'(+<var>FILENAME</var>)</code></dt>
<dd><p>connect to socket at file <var>FILENAME</var>.
</p>
</dd>
<dt> <code>'AF_INET'(+<var>HOST</var>,+<var>PORT</var>)</code></dt>
<dd><p>Connect to socket at host <var>HOST</var> and port <var>PORT</var>.
</p></dd>
</dl>
</dd>
<dt> <code>socket_listen(+<var>SOCKET</var>, +<var>LENGTH</var>)</code></dt>
<dd><a name="IDX649"></a>
<a name="IDX650"></a>
<a name="IDX651"></a>
<p>Interface to system call <code>listen</code>, used for servers to indicate
willingness to wait for connections at socket <var>SOCKET</var>. The
integer <var>LENGTH</var> gives the queue limit for incoming connections,
and should be limited to <code>5</code> for portable applications. The socket
must be of type <code>SOCK_STREAM</code> or <code>SOCK_SEQPACKET</code>.
</p>
</dd>
<dt> <code>socket_accept(+<var>SOCKET</var>, -<var>STREAM</var>)</code></dt>
<dd><a name="IDX652"></a>
<a name="IDX653"></a>
<a name="IDX654"></a>
</dd>
<dt> <code>socket_accept(+<var>SOCKET</var>, -<var>CLIENT</var>, -<var>STREAM</var>)</code></dt>
<dd><a name="IDX655"></a>
<a name="IDX656"></a>
<a name="IDX657"></a>
<p>Interface to system call <code>accept</code>, used for servers to wait for
connections at socket <var>SOCKET</var>. The stream descriptor <var>STREAM</var>
represents the resulting connection. If the socket belongs to the
domain <code>'AF_INET'</code>, <var>CLIENT</var> unifies with an atom containing
the IP address for the client in numbers and dots notation.
</p>
</dd>
<dt> <code>socket_accept(+<var>SOCKET</var>, -<var>STREAM</var>)</code></dt>
<dd><a name="IDX658"></a>
<a name="IDX659"></a>
<a name="IDX660"></a>
<p>Accept a connection but do not return client information.
</p>
</dd>
<dt> <code>socket_buffering(+<var>SOCKET</var>, -<var>MODE</var>, -<var>OLD</var>, +<var>NEW</var>)</code></dt>
<dd><a name="IDX661"></a>
<a name="IDX662"></a>
<a name="IDX663"></a>
<p>Set buffering for <var>SOCKET</var> in <code>read</code> or <code>write</code>
<var>MODE</var>. <var>OLD</var> is unified with the previous status, and <var>NEW</var>
receives the new status which may be one of <code>unbuf</code> or
<code>fullbuf</code>.
</p>
</dd>
<dt> <code>socket_select(+<var>SOCKETS</var>, -<var>NEWSTREAMS</var>, +<var>TIMEOUT</var>, +<var>STREAMS</var>, -<var>READSTREAMS</var>)</code></dt>
<dd><a name="IDX664"></a>
<a name="IDX665"></a>
<a name="IDX666"></a>
<p>Interface to system call <code>select</code>, used for servers to wait for
connection requests or for data at sockets. The variable
<var>SOCKETS</var> is a list of form <var>KEY-SOCKET</var>, where <var>KEY</var> is
an user-defined identifier and <var>SOCKET</var> is a socket descriptor. The
variable <var>TIMEOUT</var> is either <code>off</code>, indicating execution will
wait until something is available, or of the form <var>SEC-USEC</var>, where
<var>SEC</var> and <var>USEC</var> give the seconds and microseconds before
<code>socket_select/5</code> returns. The variable <var>SOCKETS</var> is a list of
form <var>KEY-STREAM</var>, where <var>KEY</var> is an user-defined identifier
and <var>STREAM</var> is a stream descriptor
</p>
<p>Execution of <code>socket_select/5</code> unifies <var>READSTREAMS</var> from
<var>STREAMS</var> with readable data, and <var>NEWSTREAMS</var> with a list of
the form <var>KEY-STREAM</var>, where <var>KEY</var> was the key for a socket
with pending data, and <var>STREAM</var> the stream descriptor resulting
from accepting the connection.
</p>
</dd>
<dt> <code>current_host(?<var>HOSTNAME</var>)</code></dt>
<dd><p>Unify <var>HOSTNAME</var> with an atom representing the fully qualified
hostname for the current host. Also succeeds if <var>HOSTNAME</var> is bound
to the unqualified hostname.
</p>
</dd>
<dt> <code>hostname_address(?<var>HOSTNAME</var>,?<var>IP_ADDRESS</var>)</code></dt>
<dd><p><var>HOSTNAME</var> is an host name and <var>IP_ADDRESS</var> its IP
address in number and dots notation.
</p>
</dd>
</dl>
<hr size="6">
<a name="Database"></a>
<a name="SEC46"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC45" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC47" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC31" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC31" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 6.7 Using the Clausal Data Base </h2>
<p>Predicates in YAP may be dynamic or static. By default, when
consulting or reconsulting, predicates are assumed to be static:
execution is faster and the code will probably use less space.
Static predicates impose some restrictions: in general there can be no
addition or removal of clauses for a procedure if it is being used in the
current execution.
</p>
<p>Dynamic predicates allow programmers to change the Clausal Data Base with
the same flexibility as in C-Prolog. With dynamic predicates it is
always possible to add or remove clauses during execution and the
semantics will be the same as for C-Prolog. But the programmer should be
aware of the fact that asserting or retracting are still expensive operations,
and therefore he should try to avoid them whenever possible.
</p>
<dl compact="compact">
<dt> <code>dynamic +<var>P</var></code></dt>
<dd><a name="IDX667"></a>
<a name="IDX668"></a>
<a name="IDX669"></a>
<p>Declares predicate <var>P</var> or list of predicates [<var>P1</var>,...,<var>Pn</var>]
as a dynamic predicate. <var>P</var> must be written in form:
<var>name/arity</var>.
</p>
<table><tr><td> </td><td><pre class="example">:- dynamic god/1.
</pre></td></tr></table>
<p>a more convenient form can be used:
</p>
<table><tr><td> </td><td><pre class="example">:- dynamic son/3, father/2, mother/2.
</pre></td></tr></table>
<p>or, equivalently,
</p>
<table><tr><td> </td><td><pre class="example">:- dynamic [son/3, father/2, mother/2].
</pre></td></tr></table>
<p>Note:
</p>
<p>a predicate is assumed to be dynamic when
asserted before being defined.
</p>
</dd>
<dt> <code>dynamic_predicate(+<var>P</var>,+<var>Semantics</var>)</code></dt>
<dd><a name="IDX670"></a>
<a name="IDX671"></a>
<a name="IDX672"></a>
<p>Declares predicate <var>P</var> or list of predicates [<var>P1</var>,...,<var>Pn</var>]
as a dynamic predicate following either <code>logical</code> or
<code>immediate</code> semantics.
</p>
<table class="menu" border="0" cellspacing="0">
<p>Subnodes of Database
<a href="#SEC47">6.7.1 Modification of the Data Base</a> Asserting and Retracting
<a href="#SEC48">6.7.2 Looking at the Data Base</a> Finding out what is in the Data Base
<a href="#SEC49">6.7.3 Using Data Base References</a> Using Data Base References
<a href="#SEC50">6.8 Internal Data Base</a> Yap's Internal Database
<a href="#SEC51">6.9 The Blackboard</a> Storing and Fetching Terms in the BlackBoard
</p>
</table>
</dd>
</dl>
<hr size="6">
<a name="Modifying-the-Database"></a>
<a name="SEC47"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC46" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC48" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC31" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC46" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 6.7.1 Modification of the Data Base </h3>
<p>These predicates can be used either for static or for dynamic
predicates:
</p>
<dl compact="compact">
<dt> <code>assert(+<var>C</var>)</code></dt>
<dd><a name="IDX673"></a>
<a name="IDX674"></a>
<a name="IDX675"></a>
<p> Adds clause <var>C</var> to the program. If the predicate is undefined,
declare it as dynamic.
</p>
<p> Most Prolog systems only allow asserting clauses for dynamic
predicates. This is also as specified in the ISO standard. YAP allows
asserting clauses for static predicates, as long as the predicate is not
in use and the language flag is <tt>cprolog</tt>. Note that this feature is
deprecated, if you want to assert clauses for static procedures you
should use <code>assert_static/1</code>.
</p>
</dd>
<dt> <code>asserta(+<var>C</var>) [ISO]</code></dt>
<dd><a name="IDX676"></a>
<a name="IDX677"></a>
<a name="IDX678"></a>
<p> Adds clause <var>C</var> to the beginning of the program. If the predicate is
undefined, declare it as dynamic.
</p>
</dd>
<dt> <code>assertz(+<var>C</var>) [ISO]</code></dt>
<dd><a name="IDX679"></a>
<a name="IDX680"></a>
<a name="IDX681"></a>
<p> Adds clause <var>C</var> to the end of the program. If the predicate is
undefined, declare it as dynamic.
</p>
<p> Most Prolog systems only allow asserting clauses for dynamic
predicates. This is also as specified in the ISO standard. YAP allows
asserting clauses for static predicates. The current version of YAP
supports this feature, but this feature is deprecated and support may go
away in future versions.
</p>
</dd>
<dt> <code>abolish(+<var>PredSpec</var>) [ISO]</code></dt>
<dd><a name="IDX682"></a>
<a name="IDX683"></a>
<a name="IDX684"></a>
<p> Deletes the predicate given by <var>PredSpec</var> from the database. If
<var>PredSpec</var> is an unbound variable, delete all predicates for the
current module. The
specification must include the name and arity, and it may include module
information. Under <tt>iso</tt> language mode this built-in will only abolish
dynamic procedures. Under other modes it will abolish any procedures.
</p>
</dd>
<dt> <code>abolish(+<var>P</var>,+<var>N</var>)</code></dt>
<dd><a name="IDX685"></a>
<a name="IDX686"></a>
<a name="IDX687"></a>
<p> Deletes the predicate with name <var>P</var> and arity <var>N</var>. It will remove
both static and dynamic predicates.
</p>
</dd>
<dt> <code>assert_static(:<var>C</var>)</code></dt>
<dd><a name="IDX688"></a>
<a name="IDX689"></a>
<a name="IDX690"></a>
<p>Adds clause <var>C</var> to a static procedure. Asserting a static clause
for a predicate while choice-points for the predicate are available has
undefined results.
</p>
</dd>
<dt> <code>asserta_static(:<var>C</var>)</code></dt>
<dd><a name="IDX691"></a>
<a name="IDX692"></a>
<a name="IDX693"></a>
<p> Adds clause <var>C</var> to the beginning of a static procedure.
</p>
</dd>
<dt> <code>assertz_static(:<var>C</var>)</code></dt>
<dd><a name="IDX694"></a>
<a name="IDX695"></a>
<a name="IDX696"></a>
<p> Adds clause <var>C</var> to the end of a static procedure. Asserting a
static clause for a predicate while choice-points for the predicate are
available has undefined results.
</p>
</dd>
</dl>
<p>The following predicates can be used for dynamic predicates and for
static predicates, if source mode was on when they were compiled:
</p>
<dl compact="compact">
<dt> <code>clause(+<var>H</var>,<var>B</var>) [ISO]</code></dt>
<dd><a name="IDX697"></a>
<a name="IDX698"></a>
<a name="IDX699"></a>
<p> A clause whose head matches <var>H</var> is searched for in the
program. Its head and body are respectively unified with <var>H</var> and
<var>B</var>. If the clause is a unit clause, <var>B</var> is unified with
<var>true</var>.
</p>
<p>This predicate is applicable to static procedures compiled with
<code>source</code> active, and to all dynamic procedures.
</p>
</dd>
<dt> <code>clause(+<var>H</var>,<var>B</var>,-<var>R</var>)</code></dt>
<dd><a name="IDX700"></a>
<a name="IDX701"></a>
<a name="IDX702"></a>
<p>The same as <code>clause/2</code>, plus <var>R</var> is unified with the
reference to the clause in the database. You can use <code>instance/2</code>
to access the reference's value. Note that you may not use
<code>erase/1</code> on the reference on static procedures.
</p>
</dd>
<dt> <code>nth_clause(+<var>H</var>,<var>I</var>,-<var>R</var>)</code></dt>
<dd><a name="IDX703"></a>
<a name="IDX704"></a>
<a name="IDX705"></a>
<p>Find the <var>I</var>th clause in the predicate defining <var>H</var>, and give
a reference to the clause. Alternatively, if the reference <var>R</var> is
given the head <var>H</var> is unified with a description of the predicate
and <var>I</var> is bound to its position.
</p>
</dd>
</dl>
<p>The following predicates can only be used for dynamic predicates:
</p>
<dl compact="compact">
<dt> <code>retract(+<var>C</var>) [ISO]</code></dt>
<dd><a name="IDX706"></a>
<a name="IDX707"></a>
<a name="IDX708"></a>
<p>Erases the first clause in the program that matches <var>C</var>. This
predicate may also be used for the static predicates that have been
compiled when the source mode was <code>on</code>. For more information on
<code>source/0</code> (see section <a href="#SEC24">Changing the Compiler's Behavior</a>).
</p>
</dd>
<dt> <code>retractall(+<var>G</var>)</code></dt>
<dd><a name="IDX709"></a>
<a name="IDX710"></a>
<a name="IDX711"></a>
<p>Retract all the clauses whose head matches the goal <var>G</var>. Goal
<var>G</var> must be a call to a dynamic predicate.
</p>
</dd>
</dl>
<hr size="6">
<a name="Looking-at-the-Database"></a>
<a name="SEC48"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC47" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC49" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC31" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC46" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 6.7.2 Looking at the Data Base </h3>
<dl compact="compact">
<dt> <code>listing</code></dt>
<dd><a name="IDX712"></a>
<a name="IDX713"></a>
<a name="IDX714"></a>
<p>Lists in the current output stream all the clauses for which source code
is available (these include all clauses for dynamic predicates and
clauses for static predicates compiled when source mode was <code>on</code>).
</p>
</dd>
<dt> <code>listing(+<var>P</var>)</code></dt>
<dd><a name="IDX715"></a>
<a name="IDX716"></a>
<a name="IDX717"></a>
<p>Lists predicate <var>P</var> if its source code is available.
</p>
</dd>
<dt> <code>portray_clause(+<var>C</var>)</code></dt>
<dd><a name="IDX718"></a>
<a name="IDX719"></a>
<a name="IDX720"></a>
<p>Write clause <var>C</var> as if written by <code>listing/0</code>.
</p>
</dd>
<dt> <code>portray_clause(+<var>S</var>,+<var>C</var>)</code></dt>
<dd><a name="IDX721"></a>
<a name="IDX722"></a>
<a name="IDX723"></a>
<p>Write clause <var>C</var> on stream <var>S</var> as if written by <code>listing/0</code>.
</p>
</dd>
<dt> <code>current_atom(<var>A</var>)</code></dt>
<dd><a name="IDX724"></a>
<a name="IDX725"></a>
<a name="IDX726"></a>
<p>Checks whether <var>A</var> is a currently defined atom. It is used to find all
currently defined atoms by backtracking.
</p>
</dd>
<dt> <code>current_predicate(<var>F</var>) [ISO]</code></dt>
<dd><a name="IDX727"></a>
<a name="IDX728"></a>
<a name="IDX729"></a>
<p><var>F</var> is the predicate indicator for a currently defined user or
library predicate. <var>F</var> is of the form <var>Na/Ar</var>, where the atom
<var>Na</var> is the name of the predicate, and <var>Ar</var> its arity.
</p>
</dd>
<dt> <code>current_predicate(<var>A</var>,<var>P</var>)</code></dt>
<dd><a name="IDX730"></a>
<a name="IDX731"></a>
<a name="IDX732"></a>
<p>Defines the relation: <var>P</var> is a currently defined predicate whose
name is the atom <var>A</var>.
</p>
</dd>
<dt> <code>system_predicate(<var>A</var>,<var>P</var>)</code></dt>
<dd><a name="IDX733"></a>
<a name="IDX734"></a>
<a name="IDX735"></a>
<p>Defines the relation: <var>P</var> is a built-in predicate whose name
is the atom <var>A</var>.
</p>
</dd>
<dt> <code>predicate_property(<var>P</var>,<var>Prop</var>)</code></dt>
<dd><a name="IDX736"></a>
<a name="IDX737"></a>
<a name="IDX738"></a>
<p>For the predicates obeying the specification <var>P</var> unify <var>Prop</var>
with a property of <var>P</var>. These properties may be:
</p><dl compact="compact">
<dt> <code>built_in</code></dt>
<dd><p>true for built-in predicates,
</p></dd>
<dt> <code>dynamic</code></dt>
<dd><p>true if the predicate is dynamic
</p></dd>
<dt> <code>static</code></dt>
<dd><p>true if the predicate is static
</p></dd>
<dt> <code>meta_predicate(<var>M</var>)</code></dt>
<dd><p>true if the predicate has a meta_predicate declaration <var>M</var>.
</p></dd>
<dt> <code>multifile</code></dt>
<dd><p>true if the predicate was declared to be multifile
</p></dd>
<dt> <code>imported_from(<var>Mod</var>)</code></dt>
<dd><p>true if the predicate was imported from module <var>Mod</var>.
</p></dd>
<dt> <code>exported</code></dt>
<dd><p>true if the predicate is exported in the current module.
</p></dd>
<dt> <code>public</code></dt>
<dd><p>true if the predicate is public; note that all dynamic predicates are
public.
</p></dd>
<dt> <code>tabled</code></dt>
<dd><p>true if the predicate is tabled; note that only static predicates can
be tabled in YAP.
</p></dd>
<dt> <code>source</code></dt>
<dd><p>true if source for the predicate is available.
</p></dd>
<dt> <code>number_of_clauses(<var>ClauseCount</var>)</code></dt>
<dd><p>Number of clauses in the predicate definition. Always one if external
or built-in.
</p></dd>
</dl>
</dd>
</dl>
<hr size="6">
<a name="Database-References"></a>
<a name="SEC49"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC48" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC50" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC31" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC46" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 6.7.3 Using Data Base References </h3>
<p>Data Base references are a fast way of accessing terms. The predicates
<code>erase/1</code> and <code>instance/1</code> also apply to these references and may
sometimes be used instead of <code>retract/1</code> and <code>clause/2</code>.
</p>
<dl compact="compact">
<dt> <code>assert(+<var>C</var>,-<var>R</var>)</code></dt>
<dd><a name="IDX739"></a>
<a name="IDX740"></a>
<a name="IDX741"></a>
<p> The same as <code>assert(C)</code> (see section <a href="#SEC47">Modification of the Data Base</a>) but
unifies <var>R</var> with the database reference that identifies the new
clause, in a one-to-one way. Note that <code>asserta/2</code> only works for dynamic
predicates. If the predicate is undefined, it will automatically be
declared dynamic.
</p>
</dd>
<dt> <code>asserta(+<var>C</var>,-<var>R</var>)</code></dt>
<dd><a name="IDX742"></a>
<a name="IDX743"></a>
<a name="IDX744"></a>
<p> The same as <code>asserta(C)</code> but unifying <var>R</var> with
the database reference that identifies the new clause, in a
one-to-one way. Note that <code>asserta/2</code> only works for dynamic
predicates. If the predicate is undefined, it will automatically be
declared dynamic.
</p>
</dd>
<dt> <code>assertz(+<var>C</var>,-<var>R</var>)</code></dt>
<dd><a name="IDX745"></a>
<a name="IDX746"></a>
<a name="IDX747"></a>
<p> The same as <code>assertz(C)</code> but unifying <var>R</var> with
the database reference that identifies the new clause, in a
one-to-one way. Note that <code>asserta/2</code> only works for dynamic
predicates. If the predicate is undefined, it will automatically be
declared dynamic.
</p>
</dd>
<dt> <code>retract(+<var>C</var>,-<var>R</var>)</code></dt>
<dd><a name="IDX748"></a>
<a name="IDX749"></a>
<a name="IDX750"></a>
<p> Erases from the program the clause <var>C</var> whose
database reference is <var>R</var>. The predicate must be dynamic.
</p>
</dd>
</dl>
<hr size="6">
<a name="Internal-Database"></a>
<a name="SEC50"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC49" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC51" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC31" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC31" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 6.8 Internal Data Base </h2>
<p>Some programs need global information for, e.g. counting or collecting
data obtained by backtracking. As a rule, to keep this information, the
internal data base should be used instead of asserting and retracting
clauses (as most novice programmers do), .
In YAP (as in some other Prolog systems) the internal data base (i.d.b.
for short) is faster, needs less space and provides a better insulation of
program and data than using asserted/retracted clauses.
The i.d.b. is implemented as a set of terms, accessed by keys that
unlikely what happens in (non-Prolog) data bases are not part of the
term. Under each key a list of terms is kept. References are provided so that
terms can be identified: each term in the i.d.b. has a unique reference
(references are also available for clauses of dynamic predicates).
</p>
<dl compact="compact">
<dt> <code>recorda(+<var>K</var>,<var>T</var>,-<var>R</var>)</code></dt>
<dd><a name="IDX751"></a>
<a name="IDX752"></a>
<a name="IDX753"></a>
<p>Makes term <var>T</var> the first record under key <var>K</var> and unifies <var>R</var>
with its reference.
</p>
</dd>
<dt> <code>recordz(+<var>K</var>,<var>T</var>,-<var>R</var>)</code></dt>
<dd><a name="IDX754"></a>
<a name="IDX755"></a>
<a name="IDX756"></a>
<p>Makes term <var>T</var> the last record under key <var>K</var> and unifies <var>R</var>
with its reference.
</p>
</dd>
<dt> <code>recorda_at(+<var>R0</var>,<var>T</var>,-<var>R</var>)</code></dt>
<dd><a name="IDX757"></a>
<a name="IDX758"></a>
<a name="IDX759"></a>
<p>Makes term <var>T</var> the record preceding record with reference
<var>R0</var>, and unifies <var>R</var> with its reference.
</p>
</dd>
<dt> <code>recordz_at(+<var>R0</var>,<var>T</var>,-<var>R</var>)</code></dt>
<dd><a name="IDX760"></a>
<a name="IDX761"></a>
<a name="IDX762"></a>
<p>Makes term <var>T</var> the record following record with reference
<var>R0</var>, and unifies <var>R</var> with its reference.
</p>
</dd>
<dt> <code>recordaifnot(+<var>K</var>,<var>T</var>,-<var>R</var>)</code></dt>
<dd><a name="IDX763"></a>
<a name="IDX764"></a>
<a name="IDX765"></a>
<p>If a term equal to <var>T</var> up to variable renaming is stored under key
<var>K</var> fail. Otherwise, make term <var>T</var> the first record under key
<var>K</var> and unify <var>R</var> with its reference.
</p>
</dd>
<dt> <code>recordzifnot(+<var>K</var>,<var>T</var>,-<var>R</var>)</code></dt>
<dd><a name="IDX766"></a>
<a name="IDX767"></a>
<a name="IDX768"></a>
<p>If a term equal to <var>T</var> up to variable renaming is stored under key
<var>K</var> fail. Otherwise, make term <var>T</var> the first record under key
<var>K</var> and unify <var>R</var> with its reference.
</p>
</dd>
<dt> <code>recorded(+<var>K</var>,<var>T</var>,<var>R</var>)</code></dt>
<dd><a name="IDX769"></a>
<a name="IDX770"></a>
<a name="IDX771"></a>
<p>Searches in the internal database under the key <var>K</var>, a term that
unifies with <var>T</var> and whose reference matches <var>R</var>. This
built-in may be used in one of two ways:
</p><ul>
<li> <var>K</var> may be given, in this case the built-in will return all
elements of the internal data-base that match the key.
</li><li> <var>R</var> may be given, if so returning the key and element that
match the reference.
</li></ul>
</dd>
<dt> <code>nth_instance(?<var>K</var>,?<var>Index</var>,<var>T</var>,?<var>R</var>)</code></dt>
<dd><a name="IDX772"></a>
<a name="IDX773"></a>
<a name="IDX774"></a>
<p>Fetches the <var>Index</var>nth entry in the internal database under the
key <var>K</var>. Entries are numbered from one. If the key <var>K</var> are the
<var>Index</var> are bound, a reference is unified with <var>R</var>. Otherwise,
the reference <var>R</var> must be given, and the term the system will find
the matching key and index.
</p>
</dd>
<dt> <code>erase(+<var>R</var>)</code></dt>
<dd><a name="IDX775"></a>
<a name="IDX776"></a>
<a name="IDX777"></a>
<p>The term referred to by <var>R</var> is erased from the internal database. If
reference <var>R</var> does not exist in the database, <code>erase</code> just fails.
</p>
</dd>
<dt> <code>erased(+<var>R</var>)</code></dt>
<dd><a name="IDX778"></a>
<a name="IDX779"></a>
<a name="IDX780"></a>
<p>Succeeds if the object whose database reference is <var>R</var> has been
erased.
</p>
</dd>
<dt> <code>instance(+<var>R</var>,-<var>T</var>)</code></dt>
<dd><a name="IDX781"></a>
<a name="IDX782"></a>
<a name="IDX783"></a>
<p>If <var>R</var> refers to a clause or a recorded term, <var>T</var> is unified
with its most general instance. If <var>R</var> refers to an unit clause
<var>C</var>, then <var>T</var> is unified with <code><var>C</var> :- true</code>. When
<var>R</var> is not a reference to an existing clause or to a recorded term,
this goal fails.
</p>
</dd>
<dt> <code>eraseall(+<var>K</var>)</code></dt>
<dd><a name="IDX784"></a>
<a name="IDX785"></a>
<a name="IDX786"></a>
<p>All terms belonging to the key <code>K</code> are erased from the internal
database. The predicate always succeeds.
</p>
</dd>
<dt> <code>current_key(?<var>A</var>,?<var>K</var>)</code></dt>
<dd><a name="IDX787"></a>
<a name="IDX788"></a>
<a name="IDX789"></a>
<p>Defines the relation: <var>K</var> is a currently defined database key whose
name is the atom <var>A</var>. It can be used to generate all the keys for
the internal data-base.
</p>
</dd>
<dt> <code>key_statistics(+<var>K</var>,-<var>Entries</var>,-<var>Size</var>,-<var>IndexSize</var>)</code></dt>
<dd><a name="IDX790"></a>
<a name="IDX791"></a>
<a name="IDX792"></a>
<p>Returns several statistics for a key <var>K</var>. Currently, it says how
many entries we have for that key, <var>Entries</var>, what is the
total size spent on entries, <var>Size</var>, and what is the amount of
space spent in indices.
</p>
</dd>
<dt> <code>key_statistics(+<var>K</var>,-<var>Entries</var>,-<var>TotalSize</var>)</code></dt>
<dd><a name="IDX793"></a>
<a name="IDX794"></a>
<a name="IDX795"></a>
<p>Returns several statistics for a key <var>K</var>. Currently, it says how
many entries we have for that key, <var>Entries</var>, what is the
total size spent on this key.
</p>
</dd>
<dt> <code>get_value(+<var>A</var>,-<var>V</var>)</code></dt>
<dd><a name="IDX796"></a>
<a name="IDX797"></a>
<a name="IDX798"></a>
<p>In YAP, atoms can be associated with constants. If one such
association exists for atom <var>A</var>, unify the second argument with the
constant. Otherwise, unify <var>V</var> with <code>[]</code>.
</p>
<p>This predicate is YAP specific.
</p>
</dd>
<dt> <code>set_value(+<var>A</var>,+<var>C</var>)</code></dt>
<dd><a name="IDX799"></a>
<a name="IDX800"></a>
<a name="IDX801"></a>
<p>Associate atom <var>A</var> with constant <var>C</var>.
</p>
<p>The <code>set_value</code> and <code>get_value</code> built-ins give a fast alternative to
the internal data-base. This is a simple form of implementing a global
counter.
</p><table><tr><td> </td><td><pre class="example"> read_and_increment_counter(Value) :-
get_value(counter, Value),
Value1 is Value+1,
set_value(counter, Value1).
</pre></td></tr></table>
<p>This predicate is YAP specific.
</p>
</dd>
<dt> <code>recordzifnot(+<var>K</var>,<var>T</var>,-<var>R</var>)</code></dt>
<dd><a name="IDX802"></a>
<a name="IDX803"></a>
<a name="IDX804"></a>
<p>If a variant of <var>T</var> is stored under key <var>K</var> fail. Otherwise, make
term <var>T</var> the last record under key <var>K</var> and unify <var>R</var> with its
reference.
</p>
<p>This predicate is YAP specific.
</p>
</dd>
<dt> <code>recordaifnot(+<var>K</var>,<var>T</var>,-<var>R</var>)</code></dt>
<dd><a name="IDX805"></a>
<a name="IDX806"></a>
<a name="IDX807"></a>
<p>If a variant of <var>T</var> is stored under key <var>K</var> fail. Otherwise, make
term <var>T</var> the first record under key <var>K</var> and unify <var>R</var> with its
reference.
</p>
<p>This predicate is YAP specific.
</p>
</dd>
</dl>
<p>There is a strong analogy between the i.d.b. and the way dynamic
predicates are stored. In fact, the main i.d.b. predicates might be
implemented using dynamic predicates:
</p>
<table><tr><td> </td><td><pre class="example">recorda(X,T,R) :- asserta(idb(X,T),R).
recordz(X,T,R) :- assertz(idb(X,T),R).
recorded(X,T,R) :- clause(idb(X,T),R).
</pre></td></tr></table>
<p> We can take advantage of this, the other way around, as it is quite
easy to write a simple Prolog interpreter, using the i.d.b.:
</p>
<table><tr><td> </td><td><pre class="example">asserta(G) :- recorda(interpreter,G,_).
assertz(G) :- recordz(interpreter,G,_).
retract(G) :- recorded(interpreter,G,R), !, erase(R).
call(V) :- var(V), !, fail.
call((H :- B)) :- !, recorded(interpreter,(H :- B),_), call(B).
call(G) :- recorded(interpreter,G,_).
</pre></td></tr></table>
<p>In YAP, much attention has been given to the implementation of the
i.d.b., especially to the problem of accelerating the access to terms kept in
a large list under the same key. Besides using the key, YAP uses an internal
lookup function, transparent to the user, to find only the terms that might
unify. For instance, in a data base containing the terms
</p>
<table><tr><td> </td><td><pre class="example">b
b(a)
c(d)
e(g)
b(X)
e(h)
</pre></td></tr></table>
<p>stored under the key k/1, when executing the query
</p>
<table><tr><td> </td><td><pre class="example">:- recorded(k(_),c(_),R).
</pre></td></tr></table>
<p><code>recorded</code> would proceed directly to the third term, spending almost the
time as if <code>a(X)</code> or <code>b(X)</code> was being searched.
The lookup function uses the functor of the term, and its first three
arguments (when they exist). So, <code>recorded(k(_),e(h),_)</code> would go
directly to the last term, while <code>recorded(k(_),e(_),_)</code> would find
first the fourth term, and then, after backtracking, the last one.
</p>
<p> This mechanism may be useful to implement a sort of hierarchy, where
the functors of the terms (and eventually the first arguments) work as
secondary keys.
</p>
<p> In the YAP's i.d.b. an optimized representation is used for
terms without free variables. This results in a faster retrieval of terms
and better space usage. Whenever possible, avoid variables in terms in terms stored in the i.d.b.
</p>
<hr size="6">
<a name="BlackBoard"></a>
<a name="SEC51"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC50" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC52" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC31" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC31" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 6.9 The Blackboard </h2>
<p>YAP implements a blackboard in the style of the SICStus Prolog
blackboard. The blackboard uses the same underlying mechanism as the
internal data-base but has several important differences:
</p><ul>
<li> It is module aware, in contrast to the internal data-base.
</li><li> Keys can only be atoms or integers, and not compound terms.
</li><li> A single term can be stored per key.
</li><li> An atomic update operation is provided; this is useful for
parallelism.
</li></ul>
<dl compact="compact">
<dt> <code>bb_put(+<var>Key</var>,?<var>Term</var>)</code></dt>
<dd><a name="IDX808"></a>
<a name="IDX809"></a>
<a name="IDX810"></a>
<p>Store term table <var>Term</var> in the blackboard under key <var>Key</var>. If a
previous term was stored under key <var>Key</var> it is simply forgotten.
</p>
</dd>
<dt> <code>bb_get(+<var>Key</var>,?<var>Term</var>)</code></dt>
<dd><a name="IDX811"></a>
<a name="IDX812"></a>
<a name="IDX813"></a>
<p>Unify <var>Term</var> with a term stored in the blackboard under key
<var>Key</var>, or fail silently if no such term exists.
</p>
</dd>
<dt> <code>bb_delete(+<var>Key</var>,?<var>Term</var>)</code></dt>
<dd><a name="IDX814"></a>
<a name="IDX815"></a>
<a name="IDX816"></a>
<p>Delete any term stored in the blackboard under key <var>Key</var> and unify
it with <var>Term</var>. Fail silently if no such term exists.
</p>
</dd>
<dt> <code>bb_update(+<var>Key</var>,?<var>Term</var>,?<var>New</var>)</code></dt>
<dd><a name="IDX817"></a>
<a name="IDX818"></a>
<a name="IDX819"></a>
<p>Atomically unify a term stored in the blackboard under key <var>Key</var>
with <var>Term</var>, and if the unification succeeds replace it by
<var>New</var>. Fail silently if no such term exists or if unification fails.
</p>
</dd>
</dl>
<hr size="6">
<a name="Sets"></a>
<a name="SEC52"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC51" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC53" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC31" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC31" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 6.10 Collecting Solutions to a Goal </h2>
<p>When there are several solutions to a goal, if the user wants to collect all
the solutions he may be led to use the data base, because backtracking will
forget previous solutions.
</p>
<p>YAP allows the programmer to choose from several system
predicates instead of writing his own routines. <code>findall/3</code> gives you
the fastest, but crudest solution. The other built-in predicates
post-process the result of the query in several different ways:
</p>
<dl compact="compact">
<dt> <code>findall(<var>T</var>,+<var>G</var>,-<var>L</var>) [ISO]</code></dt>
<dd><a name="IDX820"></a>
<a name="IDX821"></a>
<a name="IDX822"></a>
<p>Unifies <var>L</var> with a list that contains all the instantiations of the
term <var>T</var> satisfying the goal <var>G</var>.
</p>
<p>With the following program:
</p><table><tr><td> </td><td><pre class="example">a(2,1).
a(1,1).
a(2,2).
</pre></td></tr></table>
<p>the answer to the query
</p><table><tr><td> </td><td><pre class="example">findall(X,a(X,Y),L).
</pre></td></tr></table>
<p>would be:
</p><table><tr><td> </td><td><pre class="example">X = _32
Y = _33
L = [2,1,2];
no
</pre></td></tr></table>
</dd>
<dt> <code>findall(<var>T</var>,+<var>G</var>,+<var>L</var>,-<var>L0</var>)</code></dt>
<dd><a name="IDX823"></a>
<a name="IDX824"></a>
<a name="IDX825"></a>
<p>Similar to <code>findall/3</code>, but appends all answers to list <var>L0</var>.
</p>
</dd>
<dt> <code>all(<var>T</var>,+<var>G</var>,-<var>L</var>)</code></dt>
<dd><a name="IDX826"></a>
<a name="IDX827"></a>
<a name="IDX828"></a>
<p>Similar to <code>findall(<var>T</var>,<var>G</var>,<var>L</var>)</code> but eliminating
repeated elements. Thus, assuming the same clauses as in the above
example, the reply to the query
</p>
<table><tr><td> </td><td><pre class="example">all(X,a(X,Y),L).
</pre></td></tr></table>
<p>would be:
</p>
<table><tr><td> </td><td><pre class="example">X = _32
Y = _33
L = [2,1];
no
</pre></td></tr></table>
</dd>
<dt> <code>bagof(<var>T</var>,+<var>G</var>,-<var>L</var>) [ISO]</code></dt>
<dd><a name="IDX829"></a>
<a name="IDX830"></a>
<a name="IDX831"></a>
<p>For each set of possible instances of the free variables occurring in
<var>G</var> but not in <var>T</var>, generates the list <var>L</var> of the instances of
<var>T</var> satisfying <var>G</var>. Again, assuming the same clauses as in the
examples above, the reply to the query
</p>
<table><tr><td> </td><td><pre class="example">bagof(X,a(X,Y),L).
would be:
X = _32
Y = 1
L = [2,1];
X = _32
Y = 2
L = [2];
no
</pre></td></tr></table>
</dd>
<dt> <code>setof(<var>X</var>,+<var>P</var>,-<var>B</var>) [ISO]</code></dt>
<dd><a name="IDX832"></a>
<a name="IDX833"></a>
<a name="IDX834"></a>
<p>Similar to <code>bagof(<var>T</var>,<var>G</var>,<var>L</var>)</code> but sorting list
<var>L</var> and keeping only one copy of each element. Again, assuming the
same clauses as in the examples above, the reply to the query
</p><table><tr><td> </td><td><pre class="example">setof(X,a(X,Y),L).
</pre></td></tr></table>
<p>would be:
</p><table><tr><td> </td><td><pre class="example">X = _32
Y = 1
L = [1,2];
X = _32
Y = 2
L = [2];
no
</pre></td></tr></table>
</dd>
</dl>
<hr size="6">
<a name="Grammars"></a>
<a name="SEC53"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC52" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC54" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC31" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC31" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 6.11 Grammar Rules </h2>
<p>Grammar rules in Prolog are both a convenient way to express definite
clause grammars and an extension of the well known context-free grammars.
</p>
<p>A grammar rule is of the form:
</p>
<table><tr><td> </td><td><pre class="example"><i> head --> body </i>
</pre></td></tr></table>
<p>where both <i>head</i> and <i>body</i> are sequences of one or more items
linked by the standard conjunction operator ','.
</p>
<p><em>Items can be:</em>
</p>
<ul>
<li>
a <em>non-terminal</em> symbol may be either a complex term or an atom.
</li><li>
a <em>terminal</em> symbol may be any Prolog symbol. Terminals are
written as Prolog lists.
</li><li>
an <em>empty body</em> is written as the empty list '[ ]'.
</li><li>
<em>extra conditions</em> may be inserted as Prolog procedure calls, by being
written inside curly brackets '{' and '}'.
</li><li>
the left side of a rule consists of a nonterminal and an optional list
of terminals.
</li><li>
alternatives may be stated in the right-hand side of the rule by using
the disjunction operator ';'.
</li><li>
the <em>cut</em> and <em>conditional</em> symbol ('->') may be inserted in the
right hand side of a grammar rule
</li></ul>
<p>Grammar related built-in predicates:
</p>
<dl compact="compact">
<dt> <code>expand_term(<var>T</var>,-<var>X</var>)</code></dt>
<dd><a name="IDX835"></a>
<a name="IDX836"></a>
<a name="IDX837"></a>
<a name="IDX838"></a>
<a name="IDX839"></a>
<a name="IDX840"></a>
<p>This predicate is used by YAP for preprocessing each top level
term read when consulting a file and before asserting or executing it.
It rewrites a term <var>T</var> to a term <var>X</var> according to the following
rules: first try to use the user defined predicate
<code>term_expansion/2</code>. If this call fails then the translating process
for DCG rules is applied, together with the arithmetic optimizer
whenever the compilation of arithmetic expressions is in progress.
</p>
</dd>
<dt> <code>user:goal_expansion(+<var>G</var>,+<var>M</var>,-<var>NG</var>)</code></dt>
<dd><a name="IDX841"></a>
<a name="IDX842"></a>
<a name="IDX843"></a>
<p>Yap now supports <code>goal_expansion/3</code>. This is an user-defined
procedure that is called after term expansion when compiling or
asserting goals for each sub-goal in a clause. The first argument is
bound to the goal and the second to the module under which the goal
<var>G</var> will execute. If <code>goal_expansion/3</code> succeeds the new
sub-goal <var>NG</var> will replace <var>G</var> and will be processed in the same
way. If <code>goal_expansion/3</code> fails the system will use the default
rules.
</p>
</dd>
<dt> <code>phrase(+<var>P</var>,<var>L</var>,<var>R</var>)</code></dt>
<dd><a name="IDX844"></a>
<a name="IDX845"></a>
<a name="IDX846"></a>
<p>This predicate succeeds when the difference list <code><var>L</var>-<var>R</var></code>
is a phrase of type <var>P</var>.
</p>
</dd>
<dt> <code>phrase(+<var>P</var>,<var>L</var>)</code></dt>
<dd><a name="IDX847"></a>
<a name="IDX848"></a>
<a name="IDX849"></a>
<p>This predicate succeeds when <var>L</var> is a phrase of type <var>P</var>. The
same as <code>phrase(P,L,[])</code>.
</p>
<p>Both this predicate and the previous are used as a convenient way to
start execution of grammar rules.
</p>
</dd>
<dt> <code>'C'(<var>S1</var>,<var>T</var>,<var>S2</var>)</code></dt>
<dd><a name="IDX850"></a>
<a name="IDX851"></a>
<a name="IDX852"></a>
<p>This predicate is used by the grammar rules compiler and is defined as
<code>'C'([H|T],H,T)</code>.
</p>
</dd>
</dl>
<hr size="6">
<a name="OS"></a>
<a name="SEC54"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC53" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC55" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC31" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC31" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 6.12 Access to Operating System Functionality </h2>
<p>The following built-in predicates allow access to underlying
Operating System functionality:
</p>
<dl compact="compact">
<dt> <code>cd(+<var>D</var>)</code></dt>
<dd><a name="IDX853"></a>
<a name="IDX854"></a>
<a name="IDX855"></a>
<p>Changes the current directory (on UNIX environments).
</p>
</dd>
<dt> <code>environ(+<var>E</var>,-<var>S</var>)</code></dt>
<dd><a name="IDX856"></a>
<a name="IDX857"></a>
<a name="IDX858"></a>
<p> Given an environment variable <var>E</var> this predicate unifies the second argument <var>S</var> with its value.
</p>
</dd>
<dt> <code>getcwd(-<var>D</var>)</code></dt>
<dd><a name="IDX859"></a>
<a name="IDX860"></a>
<a name="IDX861"></a>
<p>Unify the current directory, represented as an atom, with the argument
<var>D</var>.
</p>
</dd>
<dt> <code>putenv(+<var>E</var>,+<var>S</var>)</code></dt>
<dd><a name="IDX862"></a>
<a name="IDX863"></a>
<a name="IDX864"></a>
<p>Set environment variable <var>E</var> to the value <var>S</var>. If the
environment variable <var>E</var> does not exist, create a new one. Both the
environment variable and the value must be atoms.
</p>
</dd>
<dt> <code>rename(+<var>F</var>,+<var>G</var>)</code></dt>
<dd><a name="IDX865"></a>
<a name="IDX866"></a>
<a name="IDX867"></a>
<p>Renames file <var>F</var> to <var>G</var>.
</p>
</dd>
<dt> <code>sh</code></dt>
<dd><a name="IDX868"></a>
<a name="IDX869"></a>
<a name="IDX870"></a>
<p>Creates a new shell interaction.
</p>
</dd>
<dt> <code>system(+<var>S</var>)</code></dt>
<dd><a name="IDX871"></a>
<a name="IDX872"></a>
<a name="IDX873"></a>
<p>Passes command <var>S</var> to the Bourne shell (on UNIX environments) or the
current command interpreter in WIN32 environments.
</p>
</dd>
<dt> <code>unix(+<var>S</var>)</code></dt>
<dd><a name="IDX874"></a>
<a name="IDX875"></a>
<a name="IDX876"></a>
<p>Access to Unix-like functionality:
</p><dl compact="compact">
<dt> <code>argv/1</code></dt>
<dd><p>Return a list of arguments to the program. These are the arguments that
follow a <code>--</code>, as in the usual Unix convention.
</p></dd>
<dt> <code>cd/0</code></dt>
<dd><p>Change to home directory.
</p></dd>
<dt> <code>cd/1</code></dt>
<dd><p>Change to given directory. Acceptable directory names are strings or
atoms.
</p></dd>
<dt> <code>environ/2</code></dt>
<dd><p>If the first argument is an atom, unify the second argument with the
value of the corresponding environment variable.
</p></dd>
<dt> <code>getcwd/1</code></dt>
<dd><p>Unify the first argument with an atom representing the current directory.
</p></dd>
<dt> <code>putenv/2</code></dt>
<dd><p>Set environment variable <var>E</var> to the value <var>S</var>. If the
environment variable <var>E</var> does not exist, create a new one. Both the
environment variable and the value must be atoms.
</p></dd>
<dt> <code>shell/1</code></dt>
<dd><p>Execute command under current shell. Acceptable commands are strings or
atoms.
</p></dd>
<dt> <code>system/1</code></dt>
<dd><p>Execute command with <code>/bin/sh</code>. Acceptable commands are strings or
atoms.
</p></dd>
<dt> <code>shell/0</code></dt>
<dd><p>Execute a new shell.
</p></dd>
</dl>
</dd>
<dt> <code>alarm(+<var>Seconds</var>,+<var>Callable</var>,+<var>OldAlarm</var>)</code></dt>
<dd><a name="IDX877"></a>
<a name="IDX878"></a>
<a name="IDX879"></a>
<p>Arranges for YAP to be interrupted in <var>Seconds</var>
seconds. When interrupted, YAP will execute <var>Callable</var> and
then return to the previous execution. If <var>Seconds</var> is <code>0</code>, no
new alarm is scheduled. In any event, any previously set alarm is
canceled.
</p>
<p>The variable <var>OldAlarm</var> unifies with the number of seconds remaining
until any previously scheduled alarm was due to be delivered, or with
<code>0</code> if there was no previously scheduled alarm.
</p>
<p>Note that execution of <var>Callable</var> will wait if YAP is
executing built-in predicates, such as Input/Output operations.
</p>
<p>The next example shows how <var>alarm/3</var> can be used to implement a
simple clock:
</p>
<table><tr><td> </td><td><pre class="example">loop :- loop.
ticker :- write('.'), flush_output,
get_value(tick, yes),
alarm(1,ticker,_).
:- set_value(tick, yes), alarm(1,ticker,_), loop.
</pre></td></tr></table>
<p>The clock, <code>ticker</code>, writes a dot and then checks the flag
<code>tick</code> to see whether it can continue ticking. If so, it calls
itself again. Note that there is no guarantee that the each dot
corresponds a second: for instance, if the YAP is waiting for
user input, <code>ticker</code> will wait until the user types the entry in.
</p>
<p>The next example shows how <code>alarm/3</code> can be used to guarantee that
a certain procedure does not take longer than a certain amount of time:
</p>
<table><tr><td> </td><td><pre class="example">loop :- loop.
:- catch((alarm(10, throw(ball), _),loop),
ball,
format('Quota exhausted.~n',[])).
</pre></td></tr></table><p>In this case after <code>10</code> seconds our <code>loop</code> is interrupted,
<code>ball</code> is thrown, and the handler writes <code>Quota exhausted</code>.
Execution then continues from the handler.
</p>
<p>Note that in this case <code>loop/0</code> always executes until the alarm is
sent. Often, the code you are executing succeeds or fails before the
alarm is actually delivered. In this case, you probably want to disable
the alarm when you leave the procedure. The next procedure does exactly so:
</p><table><tr><td> </td><td><pre class="example">once_with_alarm(Time,Goal,DoOnAlarm) :-
catch(execute_once_with_alarm(Time, Goal), alarm, DoOnAlarm).
execute_once_with_alarm(Time, Goal) :-
alarm(Time, alarm, _),
( call(Goal) -> alarm(0, alarm, _) ; alarm(0, alarm, _), fail).
</pre></td></tr></table>
<p>The procedure has three arguments: the <var>Time</var> before the alarm is
sent; the <var>Goal</var> to execute; and the goal <var>DoOnAlarm</var> to execute
if the alarm is sent. It uses <code>catch/3</code> to handle the case the
<code>alarm</code> is sent. Then it starts the alarm, calls the goal
<var>Goal</var>, and disables the alarm on success or failure.
</p>
</dd>
<dt> <code>on_signal(+<var>Signal</var>,?<var>OldAction</var>,+<var>Callable</var>)</code></dt>
<dd><a name="IDX880"></a>
<a name="IDX881"></a>
<a name="IDX882"></a>
<p>Set the interrupt handler for soft interrupt <var>Signal</var> to be
<var>Callable</var>. <var>OldAction</var> is unified with the previous handler.
</p>
<p>Only a subset of the software interrupts (signals) can have their
handlers manipulated through <code>on_signal/3</code>.
Their POSIX names, YAP names and default behavior is given below.
The "YAP name" of the signal is the atom that is associated with
each signal, and should be used as the first argument to
<code>on_signal/3</code>. It is chosen so that it matches the signal's POSIX
name.
</p>
<p><code>on_signal/3</code> succeeds, unless when called with an invalid
signal name or one that is not supported on this platform. No checks
are made on the handler provided by the user.
</p>
<dl compact="compact">
<dt> <code>sig_up (Hangup)</code></dt>
<dd><p> SIGHUP in Unix/Linux; Reconsult the initialization files
~/.yaprc, ~/.prologrc and ~/prolog.ini.
</p></dd>
<dt> <code>sig_usr1 and sig_usr2 (User signals)</code></dt>
<dd><p> SIGUSR1 and SIGUSR2 in Unix/Linux; Print a message and halt.
</p></dd>
</dl>
<p>A special case is made, where if <var>Callable</var> is bound to
<code>default</code>, then the default handler is restored for that signal.
</p>
<p>A call in the form <code>on_signal(<var>S</var>,<var>H</var>,<var>H</var>)</code> can be used
to retrieve a signal's current handler without changing it.
</p>
<p>It must be noted that although a signal can be received at all times,
the handler is not executed while Yap is waiting for a query at the
prompt. The signal will be, however, registered and dealt with as soon
as the user makes a query.
</p>
<p>Please also note, that neither POSIX Operating Systems nor Yap guarantee
that the order of delivery and handling is going to correspond with the
order of dispatch.
</p>
</dd>
</dl>
<hr size="6">
<a name="Term-Modification"></a>
<a name="SEC55"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC54" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC56" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC31" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC31" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 6.13 Term Modification </h2>
<p>It is sometimes useful to change the value of instantiated
variables. Although, this is against the spirit of logic programming, it
is sometimes useful. As in other Prolog systems, YAP has
several primitives that allow updating Prolog terms. Note that these
primitives are also backtrackable.
</p>
<p>The <code>setarg/3</code> primitive allows updating any argument of a Prolog
compound terms. The <code>mutable</code> family of predicates provides
<em>mutable variables</em>. They should be used instead of <code>setarg/3</code>,
as they allow the encapsulation of accesses to updatable
variables. Their implementation can also be more efficient for long
deterministic computations.
</p>
<dl compact="compact">
<dt> <code>setarg(+<var>I</var>,+<var>S</var>,?<var>T</var>)</code></dt>
<dd><a name="IDX883"></a>
<a name="IDX884"></a>
<a name="IDX885"></a>
<p>Set the value of the <var>I</var>th argument of term <var>S</var> to term <var>T</var>.
</p>
<a name="IDX886"></a>
</dd>
<dt> <code>create_mutable(+<var>D</var>,-<var>M</var>)</code></dt>
<dd><a name="IDX887"></a>
<a name="IDX888"></a>
<a name="IDX889"></a>
<p>Create new mutable variable <var>M</var> with initial value <var>D</var>.
</p>
</dd>
<dt> <code>get_mutable(?<var>D</var>,+<var>M</var>)</code></dt>
<dd><a name="IDX890"></a>
<a name="IDX891"></a>
<a name="IDX892"></a>
<p>Unify the current value of mutable term <var>M</var> with term <var>D</var>.
</p>
</dd>
<dt> <code>is_mutable(?<var>D</var>)</code></dt>
<dd><a name="IDX893"></a>
<a name="IDX894"></a>
<a name="IDX895"></a>
<p>Holds if <var>D</var> is a mutable term.
</p>
</dd>
<dt> <code>get_mutable(?<var>D</var>,+<var>M</var>)</code></dt>
<dd><a name="IDX896"></a>
<a name="IDX897"></a>
<a name="IDX898"></a>
<p>Unify the current value of mutable term <var>M</var> with term <var>D</var>.
</p>
</dd>
<dt> <code>update_mutable(+<var>D</var>,+<var>M</var>)</code></dt>
<dd><a name="IDX899"></a>
<a name="IDX900"></a>
<a name="IDX901"></a>
<p>Set the current value of mutable term <var>M</var> to term <var>D</var>.
</p></dd>
</dl>
<hr size="6">
<a name="Profiling"></a>
<a name="SEC56"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC55" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC57" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC31" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC31" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 6.14 Profiling Prolog Programs </h2>
<p>Predicates compiled with YAP's flag <code>profiling</code> set to
<code>on</code>, keep information on the number of times the predicate was
called. This information can be used to detect what are the most
commonly called predicates in the program.
</p>
<p>The YAP profiling sub-system is currently
under-development. Functionality for this sub-system will increase with
newer implementation.
</p>
<p><strong>Notes:</strong>
</p>
<ul>
<li> Profiling works for both static and dynamic predicates.
</li><li> Currently only information on entries and retries to a predicate
are maintained. This may change in the future.
</li><li> As an example, the following user-level program gives a list of
the most often called procedures in a program. The procedure
<code>list_profile</code> shows all procedures, irrespective of module, and
the procedure <code>list_profile/1</code> shows the procedures being used in
a specific module.
<table><tr><td> </td><td><pre class="example">list_profile :-
% get number of calls for each profiled procedure
setof(D-[M:P|D1],(current_module(M),profile_data(M:P,calls,D),profile_data(M:P,retries,D1)),LP),
% output so that the most often called
% predicates will come last:
write_profile_data(LP).
list_profile(Module) :-
% get number of calls for each profiled procedure
setof(D-[Module:P|D1],(profile_data(Module:P,calls,D),profile_data(Module:P,retries,D1)),LP),
% output so that the most often called
% predicates will come last:
write_profile_data(LP).
write_profile_data([]).
write_profile_data([D-[M:P|R]|SLP]) :-
% swap the two calls if you want the most often
% called predicates first.
format('~a:~w: ~32+~t~d~12+~t~d~12+~n', [M,P,D,R]),
write_profile_data(SLP).
</pre></td></tr></table></li></ul>
<p>These are the current predicates to access and clear profiling data:
</p>
<dl compact="compact">
<dt> <code>profile_data(?<var>Na/Ar</var>, ?<var>Parameter</var>, -<var>Data</var>)</code></dt>
<dd><a name="IDX902"></a>
<a name="IDX903"></a>
<a name="IDX904"></a>
<p>Give current profile data on <var>Parameter</var> for a predicate described
by the predicate indicator <var>Na/Ar</var>. If any of <var>Na/Ar</var> or
<var>Parameter</var> are unbound, backtrack through all profiled predicates
or stored parameters. Current parameters are:
</p>
<dl compact="compact">
<dt> <code>calls</code></dt>
<dd><p>Number of times a procedure was called.
</p>
</dd>
<dt> <code>retries</code></dt>
<dd><p> Number of times a call to the procedure was backtracked to and retried.
</p></dd>
</dl>
</dd>
<dt> <code>profile_reset</code></dt>
<dd><a name="IDX905"></a>
<a name="IDX906"></a>
<a name="IDX907"></a>
<p>Reset all profiling information.
</p>
</dd>
</dl>
<hr size="6">
<a name="Call-Counting"></a>
<a name="SEC57"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC56" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC58" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC31" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC31" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 6.15 Counting Calls </h2>
<p>Predicates compiled with YAP's flag <code>call_counting</code> set to
<code>on</code> update counters on the numbers of calls and of
retries. Counters are actually decreasing counters, so that they can be
used as timers. Three counters are available:
</p><ul>
<li> <code>calls</code>: number of predicate calls since execution started or since
system was reset;
</li><li> <code>retries</code>: number of retries for predicates called since
execution started or since counters were reset;
</li><li> <code>calls_and_retries</code>: count both on predicate calls and
retries.
</li></ul>
<p>These counters can be used to find out how many calls a certain
goal takes to execute. They can also be used as timers.
</p>
<p>The code for the call counters piggybacks on the profiling
code. Therefore, activating the call counters also activates the profiling
counters.
</p>
<p>These are the predicates that access and manipulate the call counters:
</p>
<dl compact="compact">
<dt> <code>call_count_data(-<var>Calls</var>, -<var>Retries</var>, -<var>CallsAndRetries</var>)</code></dt>
<dd><a name="IDX908"></a>
<a name="IDX909"></a>
<a name="IDX910"></a>
<p>Give current call count data. The first argument gives the current value
for the <var>Calls</var> counter, next the <var>Retries</var> counter, and last
the <var>CallsAndRetries</var> counter.
</p>
</dd>
<dt> <code>call_count_reset</code></dt>
<dd><a name="IDX911"></a>
<a name="IDX912"></a>
<a name="IDX913"></a>
<p>Reset call count counters. All timers are also reset.
</p>
</dd>
<dt> <code>call_count(?<var>CallsMax</var>, ?<var>RetriesMax</var>, ?<var>CallsAndRetriesMax</var>)</code></dt>
<dd><a name="IDX914"></a>
<a name="IDX915"></a>
<a name="IDX916"></a>
<p>Set call count counter as timers. YAP will generate an exception
if one of the instantiated call counters decreases to 0. YAP will ignore
unbound arguments:
</p><ul>
<li> <var>CallsMax</var>: throw the exception <code>call_counter</code> when the
counter <code>calls</code> reaches 0;
</li><li> <var>RetriesMax</var>: throw the exception <code>retry_counter</code> when the
counter <code>retries</code> reaches 0;
</li><li> <var>CallsAndRetriesMax</var>: throw the exception
<code>call_and_retry_counter</code> when the counter <code>calls_and_retries</code>
reaches 0.
</li></ul>
</dd>
</dl>
<p>Next, we show a simple example of how to use call counters:
</p><table><tr><td> </td><td><pre class="example"> ?- yap_flag(call_counting,on), [-user]. l :- l. end_of_file. yap_flag(call_counting,off).
yes
yes
?- catch((call_count(10000,_,_),l),call_counter,format("limit_exceeded.~n",[])).
limit_exceeded.
yes
</pre></td></tr></table><p>Notice that we first compile the looping predicate <code>l/0</code> with
<code>call_counting</code> <code>on</code>. Next, we <code>catch/3</code> to handle an
exception when <code>l/0</code> performs more than 10000 reductions.
</p>
<hr size="6">
<a name="Arrays"></a>
<a name="SEC58"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC57" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC59" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC31" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC31" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 6.16 Arrays </h2>
<p>The YAP system includes experimental support for arrays. The
support is enabled with the option <code>YAP_ARRAYS</code>.
</p>
<p>There are two very distinct forms of arrays in YAP. The
<em>dynamic arrays</em> are a different way to access compound terms
created during the execution. Like any other terms, any bindings to
these terms and eventually the terms themselves will be destroyed during
backtracking. Our goal in supporting dynamic arrays is twofold. First,
they provide an alternative to the standard <code>arg/3</code>
built-in. Second, because dynamic arrays may have name that are globally
visible, a dynamic array can be visible from any point in the
program. In more detail, the clause
</p><table><tr><td> </td><td><pre class="example">g(X) :- array_element(a,2,X).
</pre></td></tr></table><p>will succeed as long as the programmer has used the built-in <tt>array/2</tt>
to create an array term with at least 3 elements in the current
environment, and the array was associated with the name <code>a</code>. The
element <code>X</code> is a Prolog term, so one can bind it and any such
bindings will be undone when backtracking. Note that dynamic arrays do
not have a type: each element may be any Prolog term.
</p>
<p>The <em>static arrays</em> are an extension of the database. They provide
a compact way for manipulating data-structures formed by characters,
integers, or floats imperatively. They can also be used to provide
two-way communication between YAP and external programs through
shared memory.
</p>
<p>In order to efficiently manage space elements in a static array must
have a type. Currently, elements of static arrays in YAP should
have one of the following predefined types:
</p>
<ul>
<li> <code>byte</code>: an 8-bit signed character.
</li><li> <code>unsigned_byte</code>: an 8-bit unsigned character.
</li><li> <code>int</code>: Prolog integers. Size would be the natural size for
the machine's architecture.
</li><li> <code>float</code>: Prolog floating point number. Size would be equivalent
to a double in <code>C</code>.
</li><li> <code>atom</code>: a Prolog atom.
</li><li> <code>dbref</code>: an internal database reference.
</li><li> <code>term</code>: a generic Prolog term. Note that this will term will
not be stored in the array itself, but instead will be stored in the
Prolog internal database.
</li></ul>
<p>Arrays may be <em>named</em> or <em>anonymous</em>. Most arrays will be
<em>named</em>, that is associated with an atom that will be used to find
the array. Anonymous arrays do not have a name, and they are only of
interest if the <code>TERM_EXTENSIONS</code> compilation flag is enabled. In
this case, the unification and parser are extended to replace
occurrences of Prolog terms of the form <code>X[I]</code> by run-time calls to
<code>array_element/3</code>, so that one can use array references instead of
extra calls to <code>arg/3</code>. As an example:
</p><table><tr><td> </td><td><pre class="example">g(X,Y,Z,I,J) :- X[I] is Y[J]+Z[I].
</pre></td></tr></table><p>should give the same results as:
</p><table><tr><td> </td><td><pre class="example">G(X,Y,Z,I,J) :-
array_element(X,I,E1),
array_element(Y,J,E2),
array_element(Z,I,E3),
E1 is E2+E3.
</pre></td></tr></table>
<p>Note that the only limitation on array size are the stack size for
dynamic arrays; and, the heap size for static (not memory mapped)
arrays. Memory mapped arrays are limited by available space in the file
system and in the virtual memory space.
</p>
<p>The following predicates manipulate arrays:
</p>
<dl compact="compact">
<dt> <code>array(+<var>Name</var>, +<var>Size</var>)</code></dt>
<dd><a name="IDX917"></a>
<a name="IDX918"></a>
<a name="IDX919"></a>
<p>Creates a new dynamic array. The <var>Size</var> must evaluate to an
integer. The <var>Name</var> may be either an atom (named array) or an
unbound variable (anonymous array).
</p>
<p>Dynamic arrays work as standard compound terms, hence space for the
array is recovered automatically on backtracking.
</p>
</dd>
<dt> <code>static_array(+<var>Name</var>, +<var>Size</var>, +<var>Type</var>)</code></dt>
<dd><a name="IDX920"></a>
<a name="IDX921"></a>
<a name="IDX922"></a>
<p>Create a new static array with name <var>Name</var>. Note that the <var>Name</var>
must be an atom (named array). The <var>Size</var> must evaluate to an
integer. The <var>Type</var> must be bound to one of types mentioned
previously.
</p>
</dd>
<dt> <code>static_array_location(+<var>Name</var>, -<var>Ptr</var>)</code></dt>
<dd><a name="IDX923"></a>
<a name="IDX924"></a>
<a name="IDX925"></a>
<p>Give the location for a static array with name
<var>Name</var>.
</p>
</dd>
<dt> <code>static_array_properties(?<var>Name</var>, ?<var>Size</var>, ?<var>Type</var>)</code></dt>
<dd><a name="IDX926"></a>
<a name="IDX927"></a>
<a name="IDX928"></a>
<p>Show the properties size and type of a static array with name
<var>Name</var>. Can also be used to enumerate all current
static arrays.
</p>
<p>This built-in will silently fail if the there is no static array with
that name.
</p>
</dd>
<dt> <code>static_array_to_term(?<var>Name</var>, ?<var>Term</var>)</code></dt>
<dd><a name="IDX929"></a>
<a name="IDX930"></a>
<a name="IDX931"></a>
<p>Convert a static array with name
<var>Name</var> to a compound term of name <var>Name</var>.
</p>
<p>This built-in will silently fail if the there is no static array with
that name.
</p>
</dd>
<dt> <code>mmapped_array(+<var>Name</var>, +<var>Size</var>, +<var>Type</var>, +<var>File</var>)</code></dt>
<dd><a name="IDX932"></a>
<a name="IDX933"></a>
<a name="IDX934"></a>
<p>Similar to <code>static_array/3</code>, but the array is memory mapped to file
<var>File</var>. This means that the array is initialized from the file, and
that any changes to the array will also be stored in the file.
</p>
<p>This built-in is only available in operating systems that support the
system call <code>mmap</code>. Moreover, mmapped arrays do not store generic
terms (type <code>term</code>).
</p>
</dd>
<dt> <code>close_static_array(+<var>Name</var>)</code></dt>
<dd><a name="IDX935"></a>
<a name="IDX936"></a>
<a name="IDX937"></a>
<p>Close an existing static array of name <var>Name</var>. The <var>Name</var> must
be an atom (named array). Space for the array will be recovered and
further accesses to the array will return an error.
</p>
</dd>
<dt> <code>resize_static_array(+<var>Name</var>, -<var>OldSize</var>, +<var>NewSize</var>)</code></dt>
<dd><a name="IDX938"></a>
<a name="IDX939"></a>
<a name="IDX940"></a>
<p>Expand or reduce a static array, The <var>Size</var> must evaluate to an
integer. The <var>Name</var> must be an atom (named array). The <var>Type</var>
must be bound to one of <code>int</code>, <code>dbref</code>, <code>float</code> or
<code>atom</code>.
</p>
<p>Note that if the array is a mmapped array the size of the mmapped file
will be actually adjusted to correspond to the size of the array.
</p>
</dd>
<dt> <code>array_element(+<var>Name</var>, +<var>Index</var>, ?<var>Element</var>)</code></dt>
<dd><a name="IDX941"></a>
<a name="IDX942"></a>
<a name="IDX943"></a>
<p>Unify <var>Element</var> with <var>Name</var>[<var>Index</var>]. It works for both
static and dynamic arrays, but it is read-only for static arrays, while
it can be used to unify with an element of a dynamic array.
</p>
</dd>
<dt> <code>update_array(+<var>Name</var>, +<var>Index</var>, ?<var>Value</var>)</code> </dt>
<dd><a name="IDX944"></a>
<a name="IDX945"></a>
<a name="IDX946"></a>
<p>Attribute value <var>Value</var> to <var>Name</var>[<var>Index</var>]. Type
restrictions must be respected for static arrays. This operation is
available for dynamic arrays if <code>MULTI_ASSIGNMENT_VARIABLES</code> is
enabled (true by default). Backtracking undoes <var>update_array/3</var> for
dynamic arrays, but not for static arrays.
</p>
<p>Note that <code>update_array/3</code> actually uses <code>setarg/3</code> to update
elements of dynamic arrays, and <code>setarg/3</code> spends an extra cell for
every update. For intensive operations we suggest it may be less
expensive to unify each element of the array with a mutable terms and
to use the operations on mutable terms.
</p>
</dd>
<dt> <code>add_to_array_element(+<var>Name</var>, +<var>Index</var>, , +<var>Number</var>, ?<var>NewValue</var>)</code> </dt>
<dd><a name="IDX947"></a>
<a name="IDX948"></a>
<a name="IDX949"></a>
<p>Add <var>Number</var> <var>Name</var>[<var>Index</var>] and unify <var>NewValue</var> with
the incremented value. Observe that <var>Name</var>[<var>Index</var>] must be an
number. If <var>Name</var> is a static array the type of the array must be
<code>int</code> or <code>float</code>. If the type of the array is <code>int</code> you
only may add integers, if it is <code>float</code> you may add integers or
floats. If <var>Name</var> corresponds to a dynamic array the array element
must have been previously bound to a number and <code>Number</code> can be
any kind of number.
</p>
<p>The <code>add_to_array_element/3</code> built-in actually uses
<code>setarg/3</code> to update elements of dynamic arrays. For intensive
operations we suggest it may be less expensive to unify each element
of the array with a mutable terms and to use the operations on mutable
terms.
</p>
</dd>
</dl>
<hr size="6">
<a name="Preds"></a>
<a name="SEC59"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC58" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC60" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC31" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC31" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 6.17 Predicate Information </h2>
<p>Built-ins that return information on the current predicates and modules:
</p>
<dl compact="compact">
<dt> <code>current_module(<var>M</var>)</code></dt>
<dd><a name="IDX950"></a>
<a name="IDX951"></a>
<a name="IDX952"></a>
<p>Succeeds if <var>M</var> are defined modules. A module is defined as soon as some
predicate defined in the module is loaded, as soon as a goal in the
module is called, or as soon as it becomes the current type-in module.
</p>
</dd>
<dt> <code>current_module(<var>M</var>,<var>F</var>)</code></dt>
<dd><a name="IDX953"></a>
<a name="IDX954"></a>
<a name="IDX955"></a>
<p>Succeeds if <var>M</var> are current modules associated to the file <var>F</var>.
</p>
</dd>
</dl>
<hr size="6">
<a name="Misc"></a>
<a name="SEC60"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC59" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC31" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC31" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 6.18 Miscellaneous </h2>
<dl compact="compact">
<dt> <code>statistics/0</code></dt>
<dd><a name="IDX956"></a>
<a name="IDX957"></a>
<a name="IDX958"></a>
<p>Send to the current user error stream general information on space used and time
spent by the system.
</p><table><tr><td> </td><td><pre class="example">?- statistics.
memory (total) 4784124 bytes
program space 3055616 bytes: 1392224 in use, 1663392 free
2228132 max
stack space 1531904 bytes: 464 in use, 1531440 free
global stack: 96 in use, 616684 max
local stack: 368 in use, 546208 max
trail stack 196604 bytes: 8 in use, 196596 free
0.010 sec. for 5 code, 2 stack, and 1 trail space overflows
0.130 sec. for 3 garbage collections which collected 421000 bytes
0.000 sec. for 0 atom garbage collections which collected 0 bytes
0.880 sec. runtime
1.020 sec. cputime
25.055 sec. elapsed time
</pre></td></tr></table><p>The example shows how much memory the system spends. Memory is divided
into Program Space, Stack Space and Trail. In the example we have 3MB
allocated for program spaces, with less than half being actually
used. Yap also shows the maximum amount of heap space having been used
which was over 2MB.
</p>
<p>The stack space is divided into two stacks which grow against each
other. We are in the top level so very little stack is being used. On
the other hand, the system did use a lot of global and local stack
during the previous execution (we refer the reader to a WAM tutorial in
order to understand what are the global and local stacks).
</p>
<p>Yap also shows information on how many memory overflows and garbage
collections the system executed, and statistics on total execution
time. Cputime includes all running time, runtime excludes garbage
collection and stack overflow time.
</p>
</dd>
<dt> <code>statistics(?<var>Param</var>,-<var>Info</var>)</code></dt>
<dd><a name="IDX959"></a>
<a name="IDX960"></a>
<a name="IDX961"></a>
<p>Gives statistical information on the system parameter given by first
argument:
</p>
<dl compact="compact">
<dt> <code>cputime</code></dt>
<dd><a name="IDX962"></a>
<p><code>[<var>Time since Boot</var>,<var>Time From Last Call to Cputime</var>]</code>
<br>
This gives the total cputime in milliseconds spent executing Prolog code,
garbage collection and stack shifts time included.
</p>
</dd>
<dt> <code>garbage_collection</code></dt>
<dd><a name="IDX963"></a>
<p><code>[<var>Number of GCs</var>,<var>Total Global Recovered</var>,<var>Total Time
Spent</var>]</code>
<br>
Number of garbage collections, amount of space recovered in kbytes, and
total time spent doing garbage collection in milliseconds. More detailed
information is available using <code>yap_flag(gc_trace,verbose)</code>.
</p>
</dd>
<dt> <code>global_stack</code></dt>
<dd><a name="IDX964"></a>
<p><code>[<var>Global Stack Used</var>,<var>Execution Stack Free</var>]</code>
<br>
Space in kbytes currently used in the global stack, and space available for
expansion by the local and global stacks.
</p>
</dd>
<dt> <code>local_stack</code></dt>
<dd><a name="IDX965"></a>
<p><code>[<var>Local Stack Used</var>,<var>Execution Stack Free</var>]</code>
<br>
Space in kbytes currently used in the local stack, and space available for
expansion by the local and global stacks.
</p>
</dd>
<dt> <code>heap</code></dt>
<dd><a name="IDX966"></a>
<p><code>[<var>Heap Used</var>,<var>Heap Free</var>]</code>
<br>
Total space in kbytes not recoverable
in backtracking. It includes the program code, internal data base, and,
atom symbol table.
</p>
</dd>
<dt> <code>program</code></dt>
<dd><a name="IDX967"></a>
<p><code>[<var>Program Space Used</var>,<var>Program Space Free</var>]</code>
<br>
Equivalent to <code>heap</code>.
</p>
</dd>
<dt> <code>runtime</code></dt>
<dd><a name="IDX968"></a>
<p><code>[<var>Time since Boot</var>,<var>Time From Last Call to Runtime</var>]</code>
<br>
This gives the total cputime in milliseconds spent executing Prolog
code, not including garbage collections and stack shifts. Note that
until Yap4.1.2 the <code>runtime</code> statistics would return time spent on
garbage collection and stack shifting.
</p>
</dd>
<dt> <code>stack_shifts</code></dt>
<dd><a name="IDX969"></a>
<p><code>[<var>Number of Heap Shifts</var>,<var>Number of Stack
Shifts</var>,<var>Number of Trail Shifts</var>]</code>
<br>
Number of times YAP had to
expand the heap, the stacks, or the trail. More detailed information is
available using <code>yap_flag(gc_trace,verbose)</code>.
</p>
</dd>
<dt> <code>trail</code></dt>
<dd><a name="IDX970"></a>
<p><code>[<var>Trail Used</var>,<var>Trail Free</var>]</code>
<br>
Space in kbytes currently being used and still available for the trail.
</p>
</dd>
<dt> <code>walltime</code></dt>
<dd><a name="IDX971"></a>
<p><code>[<var>Time since Boot</var>,<var>Time From Last Call to Runtime</var>]</code>
<br>
This gives the clock time in milliseconds since starting Prolog.
</p>
</dd>
</dl>
</dd>
<dt> <code>yap_flag(?<var>Param</var>,?<var>Value</var>)</code></dt>
<dd><a name="IDX972"></a>
<a name="IDX973"></a>
<a name="IDX974"></a>
<p>Set or read system properties for <var>Param</var>:
</p>
<dl compact="compact">
<dt> <code>argv</code></dt>
<dd><a name="IDX975"></a>
<br><p> Read-only flag. It unifies with a list of atoms that gives the
arguments to Yap after <code>--</code>.
</p>
</dd>
<dt> <code>bounded [ISO]</code></dt>
<dd><a name="IDX976"></a>
<br>
<p>Read-only flag telling whether integers are bounded. The value depends
on whether YAP uses the GMP library or not.
</p>
</dd>
<dt> <code>profiling</code></dt>
<dd><a name="IDX977"></a>
<br>
<p>If <code>off</code> (default) do not compile call counting information for
procedures. If <code>on</code> compile predicates so that they calls and
retries to the predicate may be counted. Profiling data can be read through the
<code>call_count_data/3</code> built-in.
</p>
</dd>
<dt> <code>char_conversion [ISO]</code></dt>
<dd><a name="IDX978"></a>
<br>
<p>Writable flag telling whether a character conversion table is used when
reading terms. The default value for this flag is <code>off</code> except in
<code>sicstus</code> and <code>iso</code> language modes, where it is <code>on</code>.
</p>
</dd>
<dt> <code>character_escapes [ISO]</code></dt>
<dd><a name="IDX979"></a>
<br><p> Writable flag telling whether a character escapes are enables,
<code>on</code>, or disabled, <code>off</code>. The default value for this flag is
<code>on</code>.
</p>
</dd>
<dt> <code>debug [ISO]</code></dt>
<dd><a name="IDX980"></a>
<br>
<p>If <var>Value</var> is unbound, tell whether debugging is <code>on</code> or
<code>off</code>. If <var>Value</var> is bound to <code>on</code> enable debugging, and if
it is bound to <code>off</code> disable debugging.
</p>
</dd>
<dt> <code>discontiguous_warnings</code></dt>
<dd><a name="IDX981"></a>
<br>
<p>If <var>Value</var> is unbound, tell whether warnings for discontiguous
predicates are <code>on</code> or
<code>off</code>. If <var>Value</var> is bound to <code>on</code> enable these warnings,
and if it is bound to <code>off</code> disable them. The default for YAP is
<code>off</code>, unless we are in <code>sicstus</code> or <code>iso</code> mode.
</p>
</dd>
<dt> <code>dollar_as_lower_case</code></dt>
<dd><a name="IDX982"></a>
<br>
<p>If <code>off</code> (default) consider the character '$' a control character, if
<code>on</code> consider '$' a lower case character.
</p>
</dd>
<dt> <code>double_quotes [ISO]</code></dt>
<dd><a name="IDX983"></a>
<br>
<p>If <var>Value</var> is unbound, tell whether a double quoted list of characters
token is converted to a list of atoms, <code>chars</code>, to a list of integers,
<code>codes</code>, or to a single atom, <code>atom</code>. If <var>Value</var> is bound, set to
the corresponding behavior. The default value is <code>codes</code>.
</p>
</dd>
<dt> <code>fast</code></dt>
<dd><a name="IDX984"></a>
<br>
<p>If <code>on</code> allow fast machine code, if <code>off</code> (default) disable it. Only
available in experimental implementations.
</p>
</dd>
<dt> <code>fileerrors</code></dt>
<dd><a name="IDX985"></a>
<br>
<p>If <code>on</code> <code>fileerrors</code> is <code>on</code>, if <code>off</code> (default)
<code>fileerrors</code> is disabled.
</p>
</dd>
<dt> <code>float_format</code></dt>
<dd><a name="IDX986"></a>
<br><p> C-library <code>printf()</code> format specification used by <code>write/1</code> and
friends to determine how floating point numbers are printed. The
default is <code>%.15g</code>. The specified value is passed to <code>printf()</code>
without further checking. For example, if you want less digits
printed, <code>%g</code> will print all floats using 6 digits instead of the
default 15.
</p>
</dd>
<dt> <code>gc</code></dt>
<dd><a name="IDX987"></a>
<br>
<p>If <code>on</code> allow garbage collection (default), if <code>off</code> disable it.
</p>
</dd>
<dt> <code>gc_margin</code></dt>
<dd><a name="IDX988"></a>
<br>
<p>Set or show the minimum free stack before starting garbage
collection. The default depends on total stack size.
</p>
</dd>
<dt> <code>gc_trace</code></dt>
<dd><a name="IDX989"></a>
<br><p> If <code>off</code> (default) do not show information on garbage collection
and stack shifts, if <code>on</code> inform when a garbage collection or stack
shift happened, if <code>verbose</code> give detailed information on garbage
collection and stack shifts. Last, if <code>very_verbose</code> give detailed
information on data-structures found during the garbage collection
process, namely, on choice-points.
</p>
</dd>
<dt> <code>host_type</code></dt>
<dd><a name="IDX990"></a>
<br><p> Return <code>configure</code> system information, including the machine-id
for which Yap was compiled and Operating System information.
</p>
</dd>
<dt> <code>index</code></dt>
<dd><a name="IDX991"></a>
<br>
<p>If <code>on</code> allow indexing (default), if <code>off</code> disable it.
</p>
</dd>
<dt> <code>informational_messages</code></dt>
<dd><a name="IDX992"></a>
<br>
<p>If <code>on</code> allow printing of informational messages, such as the ones
that are printed when consulting. If <code>off</code> disable printing
these messages. It is <code>on</code> by default except if Yap is booted with
the <code>-L</code> flag.
</p>
</dd>
<dt> <code>integer_rounding_function [ISO]</code></dt>
<dd><a name="IDX993"></a>
<br>
<p>Read-only flag telling the rounding function used for integers. Takes the value
<code>down</code> for the current version of YAP.
</p>
</dd>
<dt> <code>language</code></dt>
<dd><a name="IDX994"></a>
<br>
<p>Choose whether YAP is closer to C-Prolog, <code>cprolog</code>, iso-prolog,
<code>iso</code> or SICStus Prolog, <code>sicstus</code>. The current default is
<code>cprolog</code>. This flag affects update semantics, leashing mode,
style_checking, handling calls to undefined procedures, how directives
are interpreted, when to use dynamic, character escapes, and how files
are consulted.
</p>
</dd>
<dt> <code>max_arity [ISO]</code></dt>
<dd><a name="IDX995"></a>
<br>
<p>Read-only flag telling the maximum arity of a functor. Takes the value
<code>unbounded</code> for the current version of YAP.
</p>
</dd>
<dt> <code>max_integer [ISO]</code></dt>
<dd><a name="IDX996"></a>
<br>
<p>Read-only flag telling the maximum integer in the
implementation. Depends on machine and Operating System
architecture, and on whether YAP uses the <code>GMP</code> multi-precision
library. If <code>bounded</code> is false, requests for <code>max_integer</code>
will fail.
</p>
</dd>
<dt> <code>max_tagged_integer</code> </dt>
<dd><a name="IDX997"></a>
<br>
<p>Read-only flag telling the maximum integer we can store as a single
word. Depends on machine and Operating System
architecture. It can be used to find the word size of the current machine.
</p>
</dd>
<dt> <code>min_integer [ISO]</code></dt>
<dd><a name="IDX998"></a>
<br><p> Read-only flag telling the minimum integer in the
implementation. Depends on machine and Operating System architecture,
and on whether YAP uses the <code>GMP</code> multi-precision library. If
<code>bounded</code> is false, requests for <code>min_integer</code> will fail.
</p>
</dd>
<dt> <code>min_tagged_integer</code> </dt>
<dd><a name="IDX999"></a>
<br>
<p>Read-only flag telling the minimum integer we can store as a single
word. Depends on machine and Operating System
architecture.
</p>
</dd>
<dt> <code>n_of_integer_keys_in_bb</code></dt>
<dd><a name="IDX1000"></a>
<br>
<p>Read or set the size of the hash table that is used for looking up the
blackboard when the key is an integer.
</p>
</dd>
<dt> <code>n_of_integer_keys_in_db</code></dt>
<dd><a name="IDX1001"></a>
<br>
<p>Read or set the size of the hash table that is used for looking up the
internal data-base when the key is an integer.
</p>
</dd>
<dt> <code>profiling</code></dt>
<dd><a name="IDX1002"></a>
<br>
<p>If <code>off</code> (default) do not compile profiling information for
procedures. If <code>on</code> compile predicates so that they will output
profiling information. Profiling data can be read through the
<code>profile_data/3</code> built-in.
</p>
</dd>
<dt> <code>redefine_warnings</code></dt>
<dd><a name="IDX1003"></a>
<br>
<p>If <var>Value</var> is unbound, tell whether warnings for procedures defined
in several different files are <code>on</code> or
<code>off</code>. If <var>Value</var> is bound to <code>on</code> enable these warnings,
and if it is bound to <code>off</code> disable them. The default for YAP is
<code>off</code>, unless we are in <code>sicstus</code> or <code>iso</code> mode.
</p>
</dd>
<dt> <code>single_var_warnings</code></dt>
<dd><a name="IDX1004"></a>
<br>
<p>If <var>Value</var> is unbound, tell whether warnings for singleton variables
are <code>on</code> or <code>off</code>. If <var>Value</var> is bound to <code>on</code> enable
these warnings, and if it is bound to <code>off</code> disable them. The
default for YAP is <code>off</code>, unless we are in <code>sicstus</code> or
<code>iso</code> mode.
</p>
</dd>
<dt> <code>strict_iso</code></dt>
<dd><a name="IDX1005"></a>
<br>
<p> If <var>Value</var> is unbound, tell whether strict ISO compatibility mode
is <code>on</code> or <code>off</code>. If <var>Value</var> is bound to <code>on</code> set
language mode to <code>iso</code> and enable strict mode. If <var>Value</var> is
bound to <code>off</code> disable strict mode, and keep the current language
mode. The default for YAP is <code>off</code>.
</p>
<p>Under strict ISO prolog mode all calls to non-ISO built-ins generate an
error. Compilation of clauses that would call non-ISO built-ins will
also generate errors. Pre-processing for grammar rules is also
disabled. Module expansion is still performed.
</p>
<p>Arguably, ISO Prolog does not provide all the functionality required
from a modern Prolog system. Moreover, because most Prolog
implementations do not fully implement the standard and because the
standard itself gives the implementor latitude in a few important
questions, such as the unification algorithm and maximum size for
numbers there is not guarantee that programs compliant with this mode
will work the same way in every Prolog and in every platform. We thus
believe this mode is mostly useful when investigating how a program
depends on a Prolog's platform specific features.
</p>
</dd>
<dt> <code>stack_dump_on_error</code></dt>
<dd><a name="IDX1006"></a>
<br>
<p>If <code>on</code> show a stack dump when Yap finds an error. The default is
<code>off</code>.
</p>
</dd>
<dt> <code>syntax_errors</code></dt>
<dd><a name="IDX1007"></a>
<br>
<p>Control action to be taken after syntax errors while executing <code>read/1</code>,
<code>read/2</code>, or <code>read_term/3</code>:
</p><dl compact="compact">
<dt> <code>dec10</code></dt>
<dd><br>
<p>Report the syntax error and retry reading the term.
</p>
</dd>
<dt> <code>fail</code></dt>
<dd><br>
<p>Report the syntax error and fail (default).
</p>
</dd>
<dt> <code>error</code></dt>
<dd><br>
<p>Report the syntax error and generate an error.
</p>
</dd>
<dt> <code>quiet</code></dt>
<dd><br>
<p>Just fail
</p></dd>
</dl>
</dd>
<dt> <code>system_options</code></dt>
<dd><a name="IDX1008"></a>
<br><p> This read only flag tells which options were used to compile
Yap. Currently it informs whether the system supports
<code>coroutining</code>, <code>depth_limit</code>, the <code>low_level_tracer</code>,
<code>or-parallelism</code>, <code>rational_trees</code>, <code>tabling</code>,
<code>threads</code>, or the <code>wam_profiler</code>.
</p>
</dd>
<dt> <code>to_chars_mode</code></dt>
<dd><a name="IDX1009"></a>
<br><p> Define whether YAP should follow <code>quintus</code>-like
semantics for the <code>atom_chars/1</code> or <code>number_chars/1</code> built-in,
or whether it should follow the ISO standard (<code>iso</code> option).
</p>
<p>+</p></dd>
<dt> <code>toplevel_hook</code></dt>
<dd><a name="IDX1010"></a>
<br>
<p>+If bound, set the argument to a goal to be executed before entering the
top-level. If unbound show the current goal or <code>true</code> if none is
presented. Only the first solution is considered and the goal is not
backtracked into.
</p>
</dd>
<dt> <code>typein_module</code></dt>
<dd><a name="IDX1011"></a>
<br>
<p>If bound, set the current working or type-in module to the argument,
which must be an atom. If unbound, unify the argument with the current
working module.
</p>
</dd>
<dt> <code>unknown [ISO]</code></dt>
<dd><a name="IDX1012"></a>
<br>
<p>Corresponds to calling the <code>unknown/2</code> built-in.
</p>
</dd>
<dt> <code>update_semantics</code></dt>
<dd><a name="IDX1013"></a>
<br>
<p>Define whether YAP should follow <code>immediate</code> update
semantics, as in C-Prolog (default), <code>logical</code> update semantics,
as in Quintus Prolog, SICStus Prolog, or in the ISO standard. There is
also an intermediate mode, <code>logical_assert</code>, where dynamic
procedures follow logical semantics but the internal data base still
follows immediate semantics.
</p>
</dd>
<dt> <code>user_error</code></dt>
<dd><a name="IDX1014"></a>
<br>
<p>If the second argument is bound to a stream, set <code>user_error</code> to
this stream. If the second argument is unbound, unify the argument with
the current <code>user_error</code> stream.
</p>
<p>By default, the <code>user_error</code> stream is set to a stream
corresponding to the Unix <code>stderr</code> stream.
</p>
<p>The next example shows how to use this flag:
</p><table><tr><td> </td><td><pre class="example"> ?- open( '/dev/null', append, Error,
[alias(mauri_tripa)] ).
Error = '$stream'(3) ? ;
no
?- set_prolog_flag(user_error, mauri_tripa).
close(mauri_tripa).
yes
?-
</pre></td></tr></table><p>We execute three commands. First, we open a stream in write mode and
give it an alias, in this case <code>mauri_tripa</code>. Next, we set
<code>user_error</code> to the stream via the alias. Note that after we did so
prompts from the system were redirected to the stream
<code>mauri_tripa</code>. Last, we close the stream. At this point, YAP
automatically redirects the <code>user_error</code> alias to the original
<code>stderr</code>.
</p>
</dd>
<dt> <code>user_input</code></dt>
<dd><a name="IDX1015"></a>
<br>
<p>If the second argument is bound to a stream, set <code>user_input</code> to
this stream. If the second argument is unbound, unify the argument with
the current <code>user_input</code> stream.
</p>
<p>By default, the <code>user_input</code> stream is set to a stream
corresponding to the Unix <code>stdin</code> stream.
</p>
</dd>
<dt> <code>user_output</code></dt>
<dd><a name="IDX1016"></a>
<br>
<p>If the second argument is bound to a stream, set <code>user_output</code> to
this stream. If the second argument is unbound, unify the argument with
the current <code>user_output</code> stream.
</p>
<p>By default, the <code>user_output</code> stream is set to a stream
corresponding to the Unix <code>stdout</code> stream.
</p>
</dd>
<dt> <code>version</code></dt>
<dd><a name="IDX1017"></a>
<br>
<p>Read-only flag that giving the current version of Yap.
</p>
</dd>
<dt> <code>write_strings</code></dt>
<dd><a name="IDX1018"></a>
<br><p> Writable flag telling whether the system should write lists of
integers that are writable character codes using the list notation. It
is <code>on</code> if enables or <code>off</code> if disabled. The default value for
this flag is <code>off</code>.
</p>
</dd>
</dl>
</dd>
<dt> <code>current_prolog_flag(?<var>Flag</var>,-<var>Value</var>) [ISO]</code></dt>
<dd><a name="IDX1019"></a>
<a name="IDX1020"></a>
<a name="IDX1021"></a>
<p>Obtain the value for a YAP Prolog flag. Equivalent to calling
<code>yap_flag/2</code> with the second argument unbound, and unifying the
returned second argument with <var>Value</var>.
</p>
</dd>
<dt> <code>prolog_flag(?<var>Flag</var>,-<var>OldValue</var>,+<var>NewValue</var>)</code></dt>
<dd><a name="IDX1022"></a>
<a name="IDX1023"></a>
<a name="IDX1024"></a>
<p>Obtain the value for a YAP Prolog flag and then set it to a new
value. Equivalent to first calling <code>current_prolog_flag/2</code> with the
second argument <var>OldValue</var> unbound and then calling
<code>set_prolog_flag/2</code> with the third argument <var>NewValue</var>.
</p>
</dd>
<dt> <code>set_prolog_flag(+<var>Flag</var>,+<var>Value</var>) [ISO]</code></dt>
<dd><a name="IDX1025"></a>
<a name="IDX1026"></a>
<a name="IDX1027"></a>
<p>Set the value for YAP Prolog flag <code>Flag</code>. Equivalent to
calling <code>yap_flag/2</code> with both arguments bound.
</p>
</dd>
<dt> <code>op(+<var>P</var>,+<var>T</var>,+<var>A</var>) [ISO]</code></dt>
<dd><a name="IDX1028"></a>
<a name="IDX1029"></a>
<a name="IDX1030"></a>
<p>Defines the operator <var>A</var> or the list of operators <var>A</var> with type
<var>T</var> (which must be one of <code>xfx</code>, <code>xfy</code>,<code>yfx</code>,
<code>xf</code>, <code>yf</code>, <code>fx</code> or <code>fy</code>) and precedence <var>P</var>
(see appendix iv for a list of predefined operators).
</p>
<p>Note that if there is a preexisting operator with the same name and
type, this operator will be discarded. Also, <code>','</code> may not be defined
as an operator, and it is not allowed to have the same for an infix and
a postfix operator.
</p>
</dd>
<dt> <code>current_op(<var>P</var>,<var>T</var>,<var>F</var>) [ISO]</code></dt>
<dd><a name="IDX1031"></a>
<a name="IDX1032"></a>
<a name="IDX1033"></a>
<p>Defines the relation: <var>P</var> is a currently defined operator of type
<var>T</var> and precedence <var>P</var>.
</p>
</dd>
<dt> <code>prompt(-<var>A</var>,+<var>B</var>)</code></dt>
<dd><a name="IDX1034"></a>
<a name="IDX1035"></a>
<a name="IDX1036"></a>
<p>Changes YAP input prompt from <var>A</var> to <var>B</var>.
</p>
</dd>
<dt> <code>initialization</code></dt>
<dd><a name="IDX1037"></a>
<a name="IDX1038"></a>
<a name="IDX1039"></a>
<p>Execute the goals defined by initialization/1. Only the first answer is
considered.
</p>
</dd>
<dt> <code>prolog_initialization(<var>G</var>)</code></dt>
<dd><a name="IDX1040"></a>
<a name="IDX1041"></a>
<a name="IDX1042"></a>
<p>Add a goal to be executed on system initialization. This is compatible
with SICStus Prolog's <code>initialization/1</code>.
</p>
</dd>
<dt> <code>version</code></dt>
<dd><a name="IDX1043"></a>
<a name="IDX1044"></a>
<a name="IDX1045"></a>
<p>Write YAP's boot message.
</p>
</dd>
<dt> <code>version(-<var>Message</var>)</code></dt>
<dd><a name="IDX1046"></a>
<a name="IDX1047"></a>
<a name="IDX1048"></a>
<p>Add a message to be written when yap boots or after aborting. It is not
possible to remove messages.
</p>
</dd>
<dt> <code>prolog_load_context(?<var>Key</var>, ?<var>Value</var>)</code></dt>
<dd><a name="IDX1049"></a>
<a name="IDX1050"></a>
<a name="IDX1051"></a>
<p>Obtain information on what is going on in the compilation process. The
following keys are available:
</p>
<dl compact="compact">
<dt> <code>directory</code></dt>
<dd><a name="IDX1052"></a>
<br>
<p>Full name for the directory where YAP is currently consulting the
file.
</p>
</dd>
<dt> <code>file</code></dt>
<dd><a name="IDX1053"></a>
<br>
<p>Full name for the file currently being consulted. Notice that included
filed are ignored.
</p>
</dd>
<dt> <code>module</code></dt>
<dd><a name="IDX1054"></a>
<br>
<p>Current source module.
</p>
</dd>
<dt> <code>source</code></dt>
<dd><a name="IDX1055"></a>
<br>
<p>Full name for the file currently being read in, which may be consulted,
reconsulted, or included.
</p>
</dd>
<dt> <code>stream</code></dt>
<dd><a name="IDX1056"></a>
<br>
<p>Stream currently being read in.
</p>
</dd>
<dt> <code>term_position</code></dt>
<dd><a name="IDX1057"></a>
<br>
<p>Stream position at the stream currently being read in.
</p></dd>
</dl>
</dd>
</dl>
<hr size="6">
<a name="Library"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC60" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC62" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC31" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC83" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="SEC61"></a>
<h1 class="chapter"> 7. Library Predicates </h1>
<p>Library files reside in the library_directory path (set by the
<code>LIBDIR</code> variable in the Makefile for YAP). Currently,
most files in the library are from the Edinburgh Prolog library.
</p>
<table class="menu" border="0" cellspacing="0">
<p>Library, Extensions, Builtins, Top
<a href="#SEC62">7.1 Apply Macros</a> Apply a Predicate to a list or to sub-terms.
<a href="#SEC63">7.2 Association Lists</a> Binary Tree Implementation of Association Lists.
<a href="#SEC64">7.3 AVL Trees</a> Predicates to add and lookup balanced binary trees.
<a href="#SEC65">7.4 Heaps</a> Labelled binary tree where the key of each node is less
than or equal to the keys of its children.
<a href="#SEC66">7.5 List Manipulation</a> List Manipulation
<a href="#SEC67">7.6 Ordered Sets</a> Ordered Set Manipulation
<a href="#SEC68">7.7 Pseudo Random Number Integer Generator</a> Pseudo Random Numbers
<a href="#SEC69">7.8 Queues</a> Queue Manipulation
<a href="#SEC70">7.9 Random Number Generator</a> Random Numbers
<a href="#SEC71">7.10 Red-Black Trees</a> Predicates to add, lookup and delete in red-black binary trees.
<a href="#SEC72">7.11 Regular Expressions</a> Regular Expression Manipulation
<a href="#SEC73">7.12 Splay Trees</a> Splay Trees
<a href="#SEC74">7.13 Reading From and Writing To Strings</a> Writing To and Reading From Strings
<a href="#SEC75">7.14 Calling The Operating System from YAP</a> System Utilities
<a href="#SEC76">7.15 Utilities On Terms</a> Utilities on Terms
<a href="#SEC77">7.16 Call Cleanup</a> Call With registered Cleanup Calls
<a href="#SEC78">7.17 Calls With Timeout</a> Call With Timeout
<a href="#SEC79">7.18 Updatable Binary Trees</a> Updatable Binary Trees
<a href="#SEC80">7.19 Unweighted Graphs</a> Unweighted Graphs
<a href="#SEC81">7.20 Directed Graphs</a> Directed Graphs Implemented With Red-Black Trees
<a href="#SEC82">7.21 Undirected Graphs</a> Undirected Graphs Using DGraphs
</p>
</table>
<hr size="6">
<a name="Apply-Macros"></a>
<a name="SEC62"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC61" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC63" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC61" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC83" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 7.1 Apply Macros </h2>
<p>This library provides a set of utilities for applying a predicate to
all elements of a list or to all sub-terms of a term. They allow to
easily perform the most common do-loop constructs in Prolog. To avoid
performance degradation due to apply/2, each call creates an
equivalent Prolog program, without meta-calls, which is executed by
the Prolog engine instead. Note that if the equivalent Prolog program
already exists, it will be simply used. The library is based on code
by Joachim Schimpf.
</p>
<p>The following routines are available once included with the
<code>use_module(library(apply_macros))</code> command.
</p>
<dl compact="compact">
<dt> <code>maplist(+<var>Pred</var>, ?<var>ListIn</var>, ?<var>ListOut</var>)</code></dt>
<dd><a name="IDX1058"></a>
<a name="IDX1059"></a>
<a name="IDX1060"></a>
<p> Creates <var>ListOut</var> by applying the predicate <var>Pred</var> to all
elements of <var>ListIn</var>.
</p>
</dd>
<dt> <code>checklist(+<var>Pred</var>, +<var>List</var>)</code></dt>
<dd><a name="IDX1061"></a>
<a name="IDX1062"></a>
<a name="IDX1063"></a>
<p> Succeeds if the predicate <var>Pred</var> succeeds on all elements of <var>List</var>.
</p>
</dd>
<dt> <code>selectlist(+<var>Pred</var>, +<var>ListIn</var>, ?<var>ListOut</var>)</code></dt>
<dd><a name="IDX1064"></a>
<a name="IDX1065"></a>
<a name="IDX1066"></a>
<p> Creates <var>ListOut</var> of all list elements of <var>ListIn</var> that pass a given test
</p>
</dd>
<dt> <code>convlist(+<var>Pred</var>, +<var>ListIn</var>, ?<var>ListOut</var>)</code></dt>
<dd><a name="IDX1067"></a>
<a name="IDX1068"></a>
<a name="IDX1069"></a>
<p> A combination of <code>maplist</code> and <code>selectlist</code>: creates <var>ListOut</var> by
applying the predicate <var>Pred</var> to all list elements on which
<var>Pred</var> succeeds
</p>
</dd>
<dt> <code>sumlist(+<var>Pred</var>, +<var>List</var>, ?<var>AccIn</var>, ?<var>AccOut</var>)</code></dt>
<dd><a name="IDX1070"></a>
<a name="IDX1071"></a>
<a name="IDX1072"></a>
<p> Calls <var>Pred</var> on all elements of List and collects a result in
<var>Accumulator</var>.
</p>
</dd>
<dt> <code>mapargs(+<var>Pred</var>, ?<var>TermIn</var>, ?<var>TermOut</var>)</code></dt>
<dd><a name="IDX1073"></a>
<a name="IDX1074"></a>
<a name="IDX1075"></a>
<p> Creates <var>TermOut</var> by applying the predicate <var>Pred</var> to all
arguments of <var>TermIn</var>
</p>
</dd>
<dt> <code>sumargs(+<var>Pred</var>, +<var>Term</var>, ?<var>AccIn</var>, ?<var>AccOut</var>)</code></dt>
<dd><a name="IDX1076"></a>
<a name="IDX1077"></a>
<a name="IDX1078"></a>
<p> Calls the predicate <var>Pred</var> on all arguments of <var>Term</var> and
collects a result in <var>Accumulator</var>
</p>
</dd>
<dt> <code>mapnodes(+<var>Pred</var>, +<var>TermIn</var>, ?<var>TermOut</var>)</code> </dt>
<dd><a name="IDX1079"></a>
<a name="IDX1080"></a>
<a name="IDX1081"></a>
<p> Creates <var>TermOut</var> by applying the predicate <var>Pred</var>
to all sub-terms of <var>TermIn</var> (depth-first and left-to-right order)
</p>
</dd>
<dt> <code>checknodes(+<var>Pred</var>, +<var>Term</var>)</code> </dt>
<dd><a name="IDX1082"></a>
<a name="IDX1083"></a>
<a name="IDX1084"></a>
<p> Succeeds if the predicate <var>Pred</var> succeeds on all sub-terms of
<var>Term</var> (depth-first and left-to-right order)
</p>
</dd>
<dt> <code>sumnodes(+<var>Pred</var>, +<var>Term</var>, ?<var>AccIn</var>, ?<var>AccOut</var>)</code></dt>
<dd><a name="IDX1085"></a>
<a name="IDX1086"></a>
<a name="IDX1087"></a>
<p> Calls the predicate <var>Pred</var> on all sub-terms of <var>Term</var> and
collect a result in <var>Accumulator</var> (depth-first and left-to-right order)
</p></dd>
</dl>
<p>Examples:
</p>
<table><tr><td> </td><td><pre class="example">%given
plus(X,Y,Z) :- Z is X + Y.
plus_if_pos(X,Y,Z) :- Y > 0, Z is X + Y.
vars(X, Y, [X|Y]) :- var(X), !.
vars(_, Y, Y).
trans(TermIn, TermOut) :-
(compound(TermIn) ; atom(TermIn)),
TermIn =.. [p|Args],
TermOut =..[q|Args],
!.
trans(X,X).
%success
maplist(plus(1), [1,2,3,4], [2,3,4,5]).
checklist(var, [X,Y,Z]).
selectlist(<(0), [-1,0,1], [1]).
convlist(plus_if_pos(1), [-1,0,1], [2]).
sumlist(plus, [1,2,3,4], 1, 11).
mapargs(number_atom,s(1,2,3), s('1','2','3')).
sumargs(vars, s(1,X,2,Y), [], [Y,X]).
mapnodes(trans, p(a,p(b,a),c), q(a,q(b,a),c)).
checknodes(\==(T), p(X,p(Y,X),Z)).
sumnodes(vars, [c(X), p(X,Y), q(Y)], [], [Y,Y,X,X]).
% another one
maplist(mapargs(number_atom),[c(1),s(1,2,3)],[c('1'),s('1','2','3')]).
</pre></td></tr></table>
<hr size="6">
<a name="Association-Lists"></a>
<a name="SEC63"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC62" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC64" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC61" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC83" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 7.2 Association Lists </h2>
<p>The following association list manipulation predicates are available
once included with the <code>use_module(library(assoc))</code> command. The
original library used Richard O'Keefe's implementation, on top of
unbalanced binary trees. The current code utilises code from the
red-black trees library and emulates the SICStus Prolog interface.
</p>
<dl compact="compact">
<dt> <code>assoc_to_list(+<var>Assoc</var>,?<var>List</var>)</code></dt>
<dd><a name="IDX1088"></a>
<a name="IDX1089"></a>
<a name="IDX1090"></a>
<p>Given an association list <var>Assoc</var> unify <var>List</var> with a list of
the form <var>Key-Val</var>, where the elements <var>Key</var> are in ascending
order.
</p>
</dd>
<dt> <code>del_assoc(+<var>Key</var>, +<var>Assoc</var>, ?<var>Val</var>, ?<var>NewAssoc</var>)</code></dt>
<dd><a name="IDX1091"></a>
<a name="IDX1092"></a>
<a name="IDX1093"></a>
<p>Succeeds if <var>NewAssoc</var> is an association list, obtained by removing
the element with <var>Key</var> and <var>Val</var> from the list <var>Assoc</var>.
</p>
</dd>
<dt> <code>del_max_assoc(+<var>Assoc</var>, ?<var>Key</var>, ?<var>Val</var>, ?<var>NewAssoc</var>)</code></dt>
<dd><a name="IDX1094"></a>
<a name="IDX1095"></a>
<a name="IDX1096"></a>
<p>Succeeds if <var>NewAssoc</var> is an association list, obtained by removing
the largest element of the list, with <var>Key</var> and <var>Val</var> from the
list <var>Assoc</var>.
</p>
</dd>
<dt> <code>del_min_assoc(+<var>Assoc</var>, ?<var>Key</var>, ?<var>Val</var>, ?<var>NewAssoc</var>)</code></dt>
<dd><a name="IDX1097"></a>
<a name="IDX1098"></a>
<a name="IDX1099"></a>
<p>Succeeds if <var>NewAssoc</var> is an association list, obtained by removing
the smallest element of the list, with <var>Key</var> and <var>Val</var>
from the list <var>Assoc</var>.
</p>
</dd>
<dt> <code>empty_assoc(+<var>Assoc</var>)</code></dt>
<dd><a name="IDX1100"></a>
<a name="IDX1101"></a>
<a name="IDX1102"></a>
<p>Succeeds if association list <var>Assoc</var> is empty.
</p>
</dd>
<dt> <code>gen_assoc(+<var>Assoc</var>,?<var>Key</var>,?<var>Value</var>)</code></dt>
<dd><a name="IDX1103"></a>
<a name="IDX1104"></a>
<a name="IDX1105"></a>
<p>Given the association list <var>Assoc</var>, unify <var>Key</var> and <var>Value</var>
with two associated elements. It can be used to enumerate all elements
in the association list.
</p>
</dd>
<dt> <code>get_assoc(+<var>Key</var>,+<var>Assoc</var>,?<var>Value</var>)</code></dt>
<dd><a name="IDX1106"></a>
<a name="IDX1107"></a>
<a name="IDX1108"></a>
<p>If <var>Key</var> is one of the elements in the association list <var>Assoc</var>,
return the associated value.
</p>
</dd>
<dt> <code>get_assoc(+<var>Key</var>,+<var>Assoc</var>,?<var>Value</var>,+<var>NAssoc</var>,?<var>NValue</var>)</code></dt>
<dd><a name="IDX1109"></a>
<a name="IDX1110"></a>
<a name="IDX1111"></a>
<p>If <var>Key</var> is one of the elements in the association list <var>Assoc</var>,
return the associated value <var>Value</var> and a new association list
<var>NAssoc</var> where <var>Key</var> is associated with <var>NValue</var>.
</p>
</dd>
<dt> <code>get_prev_assoc(+<var>Key</var>,+<var>Assoc</var>,?<var>Next</var>,?<var>Value</var>)</code></dt>
<dd><a name="IDX1112"></a>
<a name="IDX1113"></a>
<a name="IDX1114"></a>
<p>If <var>Key</var> is one of the elements in the association list <var>Assoc</var>,
return the previous key, <var>Next</var>, and its value, <var>Value</var>.
</p>
</dd>
<dt> <code>get_next_assoc(+<var>Key</var>,+<var>Assoc</var>,?<var>Next</var>,?<var>Value</var>)</code></dt>
<dd><a name="IDX1115"></a>
<a name="IDX1116"></a>
<a name="IDX1117"></a>
<p>If <var>Key</var> is one of the elements in the association list <var>Assoc</var>,
return the next key, <var>Next</var>, and its value, <var>Value</var>.
</p>
</dd>
<dt> <code>is_assoc(+<var>Assoc</var>)</code></dt>
<dd><a name="IDX1118"></a>
<a name="IDX1119"></a>
<a name="IDX1120"></a>
<p>Succeeds if <var>Assoc</var> is an association list, that is, if it is a
red-black tree.
</p>
</dd>
<dt> <code>list_to_assoc(+<var>List</var>,?<var>Assoc</var>)</code></dt>
<dd><a name="IDX1121"></a>
<a name="IDX1122"></a>
<a name="IDX1123"></a>
<p>Given a list <var>List</var> such that each element of <var>List</var> is of the
form <var>Key-Val</var>, and all the <var>Keys</var> are unique, <var>Assoc</var> is
the corresponding association list.
</p>
</dd>
<dt> <code>map_assoc(+<var>Pred</var>,+<var>Assoc</var>)</code></dt>
<dd><a name="IDX1124"></a>
<a name="IDX1125"></a>
<a name="IDX1126"></a>
<p>Succeeds if the unary predicate name <var>Pred</var>(<var>Val</var>) holds for every
element in the association list.
</p>
</dd>
<dt> <code>map_assoc(+<var>Pred</var>,+<var>Assoc</var>,?<var>New</var>)</code></dt>
<dd><a name="IDX1127"></a>
<a name="IDX1128"></a>
<a name="IDX1129"></a>
<p>Given the binary predicate name <var>Pred</var> and the association list
<var>Assoc</var>, <var>New</var> in an association list with keys in <var>Assoc</var>,
and such that if <var>Key-Val</var> is in <var>Assoc</var>, and <var>Key-Ans</var> is in
<var>New</var>, then <var>Pred</var>(<var>Val</var>,<var>Ans</var>) holds.
</p>
</dd>
<dt> <code>max_assoc(+<var>Assoc</var>,-<var>Key</var>,?<var>Value</var>)</code></dt>
<dd><a name="IDX1130"></a>
<a name="IDX1131"></a>
<a name="IDX1132"></a>
<p>Given the association list
<var>Assoc</var>, <var>Key</var> in the largest key in the list, and <var>Value</var>
the associated value.
</p>
</dd>
<dt> <code>min_assoc(+<var>Assoc</var>,-<var>Key</var>,?<var>Value</var>)</code></dt>
<dd><a name="IDX1133"></a>
<a name="IDX1134"></a>
<a name="IDX1135"></a>
<p>Given the association list
<var>Assoc</var>, <var>Key</var> in the smallest key in the list, and <var>Value</var>
the associated value.
</p>
</dd>
<dt> <code>ord_list_to_assoc(+<var>List</var>,?<var>Assoc</var>)</code></dt>
<dd><a name="IDX1136"></a>
<a name="IDX1137"></a>
<a name="IDX1138"></a>
<p>Given an ordered list <var>List</var> such that each element of <var>List</var> is
of the form <var>Key-Val</var>, and all the <var>Keys</var> are unique, <var>Assoc</var> is
the corresponding association list.
</p>
</dd>
<dt> <code>put_assoc(+<var>Key</var>,+<var>Assoc</var>,+<var>Val</var>,+<var>New</var>)</code></dt>
<dd><a name="IDX1139"></a>
<a name="IDX1140"></a>
<a name="IDX1141"></a>
<p>The association list <var>New</var> includes and element of association
<var>key</var> with <var>Val</var>, and all elements of <var>Assoc</var> that did not
have key <var>Key</var>.
</p>
</dd>
</dl>
<hr size="6">
<a name="AVL-Trees"></a>
<a name="SEC64"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC63" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC65" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC61" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC83" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 7.3 AVL Trees </h2>
<p>AVL trees are balanced search binary trees. They are named after their
inventors, Adelson-Velskii and Landis, and they were the first
dynamically balanced trees to be proposed. The YAP AVL tree manipulation
predicates library uses code originally written by Martin van Emdem and
published in the Logic Programming Newsletter, Autumn 1981. A bug in
this code was fixed by Philip Vasey, in the Logic Programming
Newsletter, Summer 1982. The library currently only includes routines to
insert and lookup elements in the tree. Please try red-black trees if
you need deletion.
</p>
<dl compact="compact">
<dt> <code>avl_insert(+<var>Key</var>,?<var>Value</var>,+<var>T0</var>,+<var>TF</var>)</code></dt>
<dd><a name="IDX1142"></a>
<a name="IDX1143"></a>
<a name="IDX1144"></a>
<p>Add an element with key <var>Key</var> and <var>Value</var> to the AVL tree
<var>T0</var> creating a new AVL tree <var>TF</var>. Duplicated elements are
allowed.
</p>
</dd>
<dt> <code>avl_lookup(+<var>Key</var>,-<var>Value</var>,+<var>T</var>)</code></dt>
<dd><a name="IDX1145"></a>
<a name="IDX1146"></a>
<a name="IDX1147"></a>
<p>Lookup an element with key <var>Key</var> in the AVL tree
<var>T</var>, returning the value <var>Value</var>.
</p>
</dd>
</dl>
<hr size="6">
<a name="Heaps"></a>
<a name="SEC65"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC64" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC66" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC61" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC83" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 7.4 Heaps </h2>
<p>A heap is a labelled binary tree where the key of each node is less than
or equal to the keys of its sons. The point of a heap is that we can
keep on adding new elements to the heap and we can keep on taking out
the minimum element. If there are N elements total, the total time is
O(NlgN). If you know all the elements in advance, you are better off
doing a merge-sort, but this file is for when you want to do say a
best-first search, and have no idea when you start how many elements
there will be, let alone what they are.
</p>
<p>The following heap manipulation routines are available once included
with the <code>use_module(library(heaps))</code> command.
</p>
<dl compact="compact">
<dt> <code>add_to_heap(+<var>Heap</var>,+<var>key</var>,+<var>Datum</var>,-<var>NewHeap</var>)</code></dt>
<dd><a name="IDX1148"></a>
<a name="IDX1149"></a>
<a name="IDX1150"></a>
<p>Inserts the new <var>Key-Datum</var> pair into the heap. The insertion is not
stable, that is, if you insert several pairs with the same <var>Key</var> it
is not defined which of them will come out first, and it is possible for
any of them to come out first depending on the history of the heap.
</p>
</dd>
<dt> <code>empty_heap(?<var>Heap</var>)</code></dt>
<dd><a name="IDX1151"></a>
<a name="IDX1152"></a>
<a name="IDX1153"></a>
<p>Succeeds if <var>Heap</var> is an empty heap.
</p>
</dd>
<dt> <code>get_from_heap(+<var>Heap</var>,-<var>key</var>,-<var>Datum</var>,-<var>Heap</var>)</code></dt>
<dd><a name="IDX1154"></a>
<a name="IDX1155"></a>
<a name="IDX1156"></a>
<p>Returns the <var>Key-Datum</var> pair in <var>OldHeap</var> with the smallest
<var>Key</var>, and also a <var>Heap</var> which is the <var>OldHeap</var> with that
pair deleted.
</p>
</dd>
<dt> <code>heap_size(+<var>Heap</var>, -<var>Size</var>)</code></dt>
<dd><a name="IDX1157"></a>
<a name="IDX1158"></a>
<a name="IDX1159"></a>
<p>Reports the number of elements currently in the heap.
</p>
</dd>
<dt> <code>heap_to_list(+<var>Heap</var>, -<var>List</var>)</code></dt>
<dd><a name="IDX1160"></a>
<a name="IDX1161"></a>
<a name="IDX1162"></a>
<p>Returns the current set of <var>Key-Datum</var> pairs in the <var>Heap</var> as a
<var>List</var>, sorted into ascending order of <var>Keys</var>.
</p>
</dd>
<dt> <code>list_to_heap(+<var>List</var>, -<var>Heap</var>)</code></dt>
<dd><a name="IDX1163"></a>
<a name="IDX1164"></a>
<a name="IDX1165"></a>
<p>Takes a list of <var>Key-Datum</var> pairs (such as keysort could be used to sort)
and forms them into a heap.
</p>
</dd>
<dt> <code>min_of_heap(+<var>Heap</var>, -<var>Key</var>, -<var>Datum</var>)</code></dt>
<dd><a name="IDX1166"></a>
<a name="IDX1167"></a>
<a name="IDX1168"></a>
<p>Returns the Key-Datum pair at the top of the heap (which is of course
the pair with the smallest Key), but does not remove it from the heap.
</p>
</dd>
<dt> <code>min_of_heap(+<var>Heap</var>, -<var>Key1</var>, -<var>Datum1</var>,</code></dt>
<dd><p>-<var>Key2</var>, -<var>Datum2</var>)
<a name="IDX1169"></a>
<a name="IDX1170"></a>
<a name="IDX1171"></a>
Returns the smallest (Key1) and second smallest (Key2) pairs in the
heap, without deleting them.
</p></dd>
</dl>
<hr size="6">
<a name="Lists"></a>
<a name="SEC66"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC65" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC67" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC61" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC83" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 7.5 List Manipulation </h2>
<p>The following list manipulation routines are available once included
with the <code>use_module(library(lists))</code> command.
</p>
<dl compact="compact">
<dt> <code>append(?<var>Prefix</var>,?<var>Suffix</var>,?<var>Combined</var>)</code></dt>
<dd><a name="IDX1172"></a>
<a name="IDX1173"></a>
<a name="IDX1174"></a>
<p>True when all three arguments are lists, and the members of
<var>Combined</var> are the members of <var>Prefix</var> followed by the members of <var>Suffix</var>.
It may be used to form <var>Combined</var> from a given <var>Prefix</var>, <var>Suffix</var> or to take
a given <var>Combined</var> apart.
</p>
</dd>
<dt> <code>delete(+<var>List</var>, ?<var>Element</var>, ?<var>Residue</var>)</code></dt>
<dd><a name="IDX1175"></a>
<a name="IDX1176"></a>
<a name="IDX1177"></a>
<p>True when <var>List</var> is a list, in which <var>Element</var> may or may not
occur, and <var>Residue</var> is a copy of <var>List</var> with all elements
identical to <var>Element</var> deleted.
</p>
</dd>
<dt> <code>flatten(+<var>List</var>, ?<var>FlattenedList</var>)</code></dt>
<dd><a name="IDX1178"></a>
<a name="IDX1179"></a>
<a name="IDX1180"></a>
<p>Flatten a list of lists <var>List</var> into a single list
<var>FlattenedList</var>.
</p>
<table><tr><td> </td><td><pre class="example">?- flatten([[1],[2,3],[4,[5,6],7,8]],L).
L = [1,2,3,4,5,6,7,8] ? ;
no
</pre></td></tr></table>
</dd>
<dt> <code>is_list(+<var>List</var>)</code></dt>
<dd><a name="IDX1181"></a>
<a name="IDX1182"></a>
<a name="IDX1183"></a>
<p>True when <var>List</var> is a proper list. That is, <var>List</var>
is bound to the empty list (nil) or a term with functor '.' and arity 2.
</p>
</dd>
<dt> <code>last(+<var>List</var>,?<var>Last</var>)</code></dt>
<dd><a name="IDX1184"></a>
<a name="IDX1185"></a>
<a name="IDX1186"></a>
<p>True when <var>List</var> is a list and <var>Last</var> is identical to its last element.
</p>
</dd>
<dt> <code>list_concat(+<var>Lists</var>,?<var>List</var>)</code></dt>
<dd><a name="IDX1187"></a>
<a name="IDX1188"></a>
<a name="IDX1189"></a>
<p>True when <var>Lists</var> is a list of lists and <var>List</var> is the
concatenation of <var>Lists</var>.
</p>
</dd>
<dt> <code>member(?<var>Element</var>, ?<var>Set</var>)</code></dt>
<dd><a name="IDX1190"></a>
<a name="IDX1191"></a>
<a name="IDX1192"></a>
<p>True when <var>Set</var> is a list, and <var>Element</var> occurs in it. It may be used
to test for an element or to enumerate all the elements by backtracking.
</p>
</dd>
<dt> <code>memberchk(+<var>Element</var>, +<var>Set</var>)</code></dt>
<dd><a name="IDX1193"></a>
<a name="IDX1194"></a>
<a name="IDX1195"></a>
<p>As <code>member/2</code>, but may only be used to test whether a known
<var>Element</var> occurs in a known Set. In return for this limited use, it
is more efficient when it is applicable.
</p>
</dd>
<dt> <code>nth0(?<var>N</var>, ?<var>List</var>, ?<var>Elem</var>)</code></dt>
<dd><a name="IDX1196"></a>
<a name="IDX1197"></a>
<a name="IDX1198"></a>
<p>True when <var>Elem</var> is the Nth member of <var>List</var>,
counting the first as element 0. (That is, throw away the first
N elements and unify <var>Elem</var> with the next.) It can only be used to
select a particular element given the list and index. For that
task it is more efficient than <code>member/2</code>
</p>
</dd>
<dt> <code>nth(?<var>N</var>, ?<var>List</var>, ?<var>Elem</var>)</code></dt>
<dd><a name="IDX1199"></a>
<a name="IDX1200"></a>
<a name="IDX1201"></a>
<p>The same as <code>nth0/3</code>, except that it counts from
1, that is <code>nth(1, [H|_], H)</code>.
</p>
</dd>
<dt> <code>nth0(?<var>N</var>, ?<var>List</var>, ?<var>Elem</var>, ?<var>Rest</var>)</code></dt>
<dd><a name="IDX1202"></a>
<a name="IDX1203"></a>
<a name="IDX1204"></a>
<p>Unifies <var>Elem</var> with the Nth element of <var>List</var>,
counting from 0, and <var>Rest</var> with the other elements. It can be used
to select the Nth element of <var>List</var> (yielding <var>Elem</var> and <var>Rest</var>), or to
insert <var>Elem</var> before the Nth (counting from 1) element of <var>Rest</var>, when
it yields <var>List</var>, e.g. <code>nth0(2, List, c, [a,b,d,e])</code> unifies List with
<code>[a,b,c,d,e]</code>. <code>nth/4</code> is the same except that it counts from 1. <code>nth0/4</code>
can be used to insert <var>Elem</var> after the Nth element of <var>Rest</var>.
</p>
</dd>
<dt> <code>nth(?<var>N</var>, ?<var>List</var>, ?<var>Elem</var>, ?<var>Rest</var>)</code></dt>
<dd><a name="IDX1205"></a>
<a name="IDX1206"></a>
<a name="IDX1207"></a>
<p>Unifies <var>Elem</var> with the Nth element of <var>List</var>, counting from 1,
and <var>Rest</var> with the other elements. It can be used to select the
Nth element of <var>List</var> (yielding <var>Elem</var> and <var>Rest</var>), or to
insert <var>Elem</var> before the Nth (counting from 1) element of
<var>Rest</var>, when it yields <var>List</var>, e.g. <code>nth(1, List, c,
[a,b,d,e])</code> unifies List with <code>[a,b,c,d,e]</code>. <code>nth/4</code>
can be used to insert <var>Elem</var> after the Nth element of <var>Rest</var>.
</p>
</dd>
<dt> <code>permutation(+<var>List</var>,?<var>Perm</var>)</code></dt>
<dd><a name="IDX1208"></a>
<a name="IDX1209"></a>
<a name="IDX1210"></a>
<p>True when <var>List</var> and <var>Perm</var> are permutations of each other.
</p>
</dd>
<dt> <code>remove_duplicates(+<var>List</var>, ?<var>Pruned</var>)</code></dt>
<dd><a name="IDX1211"></a>
<a name="IDX1212"></a>
<a name="IDX1213"></a>
<p>Removes duplicated elements from <var>List</var>. Beware: if the <var>List</var> has
non-ground elements, the result may surprise you.
</p>
</dd>
<dt> <code>reverse(+<var>List</var>, ?<var>Reversed</var>)</code></dt>
<dd><a name="IDX1214"></a>
<a name="IDX1215"></a>
<a name="IDX1216"></a>
<p>True when <var>List</var> and <var>Reversed</var> are lists with the same elements
but in opposite orders.
</p>
</dd>
<dt> <code>same_length(?<var>List1</var>, ?<var>List2</var>)</code></dt>
<dd><a name="IDX1217"></a>
<a name="IDX1218"></a>
<a name="IDX1219"></a>
<p>True when <var>List1</var> and <var>List2</var> are both lists and have the same number
of elements. No relation between the values of their elements is
implied.
Modes <code>same_length(-,+)</code> and <code>same_length(+,-)</code> generate either list given
the other; mode <code>same_length(-,-)</code> generates two lists of the same length,
in which case the arguments will be bound to lists of length 0, 1, 2, ...
</p>
</dd>
<dt> <code>select(?<var>Element</var>, ?<var>Set</var>, ?<var>Residue</var>)</code></dt>
<dd><a name="IDX1220"></a>
<a name="IDX1221"></a>
<a name="IDX1222"></a>
<p>True when <var>Set</var> is a list, <var>Element</var> occurs in <var>Set</var>, and <var>Residue</var> is
everything in <var>Set</var> except <var>Element</var> (things stay in the same order).
</p>
</dd>
<dt> <code>sublist(?<var>Sublist</var>, ?<var>List</var>)</code></dt>
<dd><a name="IDX1223"></a>
<a name="IDX1224"></a>
<a name="IDX1225"></a>
<p>True when both <code>append(_,Sublist,S)</code> and <code>append(S,_,List)</code> hold.
</p>
</dd>
<dt> <code>suffix(?<var>Suffix</var>, ?<var>List</var>)</code></dt>
<dd><a name="IDX1226"></a>
<a name="IDX1227"></a>
<a name="IDX1228"></a>
<p>Holds when <code>append(_,Suffix,List)</code> holds.
</p>
</dd>
<dt> <code>sum_list(?<var>Numbers</var>, ?<var>Total</var>)</code></dt>
<dd><a name="IDX1229"></a>
<a name="IDX1230"></a>
<a name="IDX1231"></a>
<p>True when <var>Numbers</var> is a list of numbers, and <var>Total</var> is their sum.
</p>
</dd>
<dt> <code>sumlist(?<var>Numbers</var>, ?<var>Total</var>)</code></dt>
<dd><a name="IDX1232"></a>
<a name="IDX1233"></a>
<a name="IDX1234"></a>
<p>True when <var>Numbers</var> is a list of integers, and <var>Total</var> is their
sum. The same as <code>sum_list/2</code>, please do use <code>sum_list/2</code>
instead.
</p>
</dd>
<dt> <code>max_list(?<var>Numbers</var>, ?<var>Max</var>)</code></dt>
<dd><a name="IDX1235"></a>
<a name="IDX1236"></a>
<a name="IDX1237"></a>
<p>True when <var>Numbers</var> is a list of numbers, and <var>Max</var> is the maximum.
</p>
</dd>
<dt> <code>min_list(?<var>Numbers</var>, ?<var>Min</var>)</code></dt>
<dd><a name="IDX1238"></a>
<a name="IDX1239"></a>
<a name="IDX1240"></a>
<p>True when <var>Numbers</var> is a list of numbers, and <var>Min</var> is the minimum.
</p>
</dd>
</dl>
<hr size="6">
<a name="Ordered-Sets"></a>
<a name="SEC67"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC66" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC68" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC61" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC83" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 7.6 Ordered Sets </h2>
<p>The following ordered set manipulation routines are available once
included with the <code>use_module(library(ordsets))</code> command. An
ordered set is represented by a list having unique and ordered
elements. Output arguments are guaranteed to be ordered sets, if the
relevant inputs are. This is a slightly patched version of Richard
O'Keefe's original library.
</p>
<dl compact="compact">
<dt> <code>list_to_ord_set(+<var>List</var>, ?<var>Set</var>)</code></dt>
<dd><a name="IDX1241"></a>
<a name="IDX1242"></a>
<a name="IDX1243"></a>
<p>Holds when <var>Set</var> is the ordered representation of the set
represented by the unordered representation <var>List</var>.
</p>
</dd>
<dt> <code>merge(+<var>List1</var>, +<var>List2</var>, -<var>Merged</var>)</code></dt>
<dd><a name="IDX1244"></a>
<a name="IDX1245"></a>
<a name="IDX1246"></a>
<p>Holds when <var>Merged</var> is the stable merge of the two given lists.
</p>
<p>Notice that <code>merge/3</code> will not remove duplicates, so merging
ordered sets will not necessarily result in an ordered set. Use
<code>ord_union/3</code> instead.
</p>
</dd>
<dt> <code>ord_add_element(+<var>Set1</var>, +<var>Element</var>, ?<var>Set2</var>)</code></dt>
<dd><a name="IDX1247"></a>
<a name="IDX1248"></a>
<a name="IDX1249"></a>
<p>Inserting <var>Element</var> in <var>Set1</var> returns <var>Set2</var>. It should give
exactly the same result as <code>merge(Set1, [Element], Set2)</code>, but a
bit faster, and certainly more clearly. The same as <code>ord_insert/3</code>.
</p>
</dd>
<dt> <code>ord_del_element(+<var>Set1</var>, +<var>Element</var>, ?<var>Set2</var>)</code></dt>
<dd><a name="IDX1250"></a>
<a name="IDX1251"></a>
<a name="IDX1252"></a>
<p>Removing <var>Element</var> from <var>Set1</var> returns <var>Set2</var>.
</p>
</dd>
<dt> <code>ord_disjoint(+<var>Set1</var>, +<var>Set2</var>)</code></dt>
<dd><a name="IDX1253"></a>
<a name="IDX1254"></a>
<a name="IDX1255"></a>
<p>Holds when the two ordered sets have no element in common.
</p>
</dd>
<dt> <code>ord_member(+<var>Element</var>, +<var>Set</var>)</code></dt>
<dd><a name="IDX1256"></a>
<a name="IDX1257"></a>
<a name="IDX1258"></a>
<p>Holds when <var>Element</var> is a member of <var>Set</var>.
</p>
</dd>
<dt> <code>ord_insert(+<var>Set1</var>, +<var>Element</var>, ?<var>Set2</var>)</code></dt>
<dd><a name="IDX1259"></a>
<a name="IDX1260"></a>
<a name="IDX1261"></a>
<p>Inserting <var>Element</var> in <var>Set1</var> returns <var>Set2</var>. It should give
exactly the same result as <code>merge(Set1, [Element], Set2)</code>, but a
bit faster, and certainly more clearly. The same as <code>ord_add_element/3</code>.
</p>
</dd>
<dt> <code>ord_intersect(+<var>Set1</var>, +<var>Set2</var>)</code></dt>
<dd><a name="IDX1262"></a>
<a name="IDX1263"></a>
<a name="IDX1264"></a>
<p>Holds when the two ordered sets have at least one element in common.
</p>
</dd>
<dt> <code>ord_intersection(+<var>Set1</var>, +<var>Set2</var>, ?<var>Intersection</var>)</code></dt>
<dd><a name="IDX1265"></a>
<a name="IDX1266"></a>
<a name="IDX1267"></a>
<p>Holds when Intersection is the ordered representation of <var>Set1</var>
and <var>Set2</var>.
</p>
</dd>
<dt> <code>ord_intersection(+<var>Set1</var>, +<var>Set2</var>, ?<var>Intersection</var>, ?<var>Diff</var>)</code></dt>
<dd><a name="IDX1268"></a>
<a name="IDX1269"></a>
<a name="IDX1270"></a>
<p>Holds when Intersection is the ordered representation of <var>Set1</var>
and <var>Set2</var>. <var>Diff</var> is the difference between <var>Set2</var> and <var>Set1</var>.
</p>
</dd>
<dt> <code>ord_seteq(+<var>Set1</var>, +<var>Set2</var>)</code></dt>
<dd><a name="IDX1271"></a>
<a name="IDX1272"></a>
<a name="IDX1273"></a>
<p>Holds when the two arguments represent the same set.
</p>
</dd>
<dt> <code>ord_setproduct(+<var>Set1</var>, +<var>Set2</var>, -<var>Set</var>)</code></dt>
<dd><a name="IDX1274"></a>
<a name="IDX1275"></a>
<a name="IDX1276"></a>
<p>If Set1 and Set2 are ordered sets, Product will be an ordered
set of x1-x2 pairs.
</p>
</dd>
<dt> <code>ord_subset(+<var>Set1</var>, +<var>Set2</var>)</code></dt>
<dd><a name="IDX1277"></a>
<a name="IDX1278"></a>
<a name="IDX1279"></a>
<p>Holds when every element of the ordered set <var>Set1</var> appears in the
ordered set <var>Set2</var>.
</p>
</dd>
<dt> <code>ord_subtract(+<var>Set1</var>, +<var>Set2</var>, ?<var>Difference</var>)</code></dt>
<dd><a name="IDX1280"></a>
<a name="IDX1281"></a>
<a name="IDX1282"></a>
<p>Holds when <var>Difference</var> contains all and only the elements of <var>Set1</var>
which are not also in <var>Set2</var>.
</p>
</dd>
<dt> <code>ord_symdiff(+<var>Set1</var>, +<var>Set2</var>, ?<var>Difference</var>)</code></dt>
<dd><a name="IDX1283"></a>
<a name="IDX1284"></a>
<a name="IDX1285"></a>
<p>Holds when <var>Difference</var> is the symmetric difference of <var>Set1</var>
and <var>Set2</var>.
</p>
</dd>
<dt> <code>ord_union(+<var>Sets</var>, ?<var>Union</var>)</code></dt>
<dd><a name="IDX1286"></a>
<a name="IDX1287"></a>
<a name="IDX1288"></a>
<p>Holds when <var>Union</var> is the union of the lists <var>Sets</var>.
</p>
</dd>
<dt> <code>ord_union(+<var>Set1</var>, +<var>Set2</var>, ?<var>Union</var>)</code></dt>
<dd><a name="IDX1289"></a>
<a name="IDX1290"></a>
<a name="IDX1291"></a>
<p>Holds when <var>Union</var> is the union of <var>Set1</var> and <var>Set2</var>.
</p>
</dd>
<dt> <code>ord_union(+<var>Set1</var>, +<var>Set2</var>, ?<var>Union</var>, ?<var>Diff</var>)</code></dt>
<dd><a name="IDX1292"></a>
<a name="IDX1293"></a>
<a name="IDX1294"></a>
<p>Holds when <var>Union</var> is the union of <var>Set1</var> and <var>Set2</var> and
<var>Diff</var> is the difference.
</p>
</dd>
</dl>
<hr size="6">
<a name="Pseudo-Random"></a>
<a name="SEC68"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC67" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC69" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC61" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC83" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 7.7 Pseudo Random Number Integer Generator </h2>
<p>The following routines produce random non-negative integers in the range
0 .. 2^(w-1) -1, where w is the word size available for integers, e.g.
32 for Intel machines and 64 for Alpha machines. Note that the numbers
generated by this random number generator are repeatable. This generator
was originally written by Allen Van Gelder and is based on Knuth Vol 2.
</p>
<dl compact="compact">
<dt> <code>rannum(-<var>I</var>)</code></dt>
<dd><a name="IDX1295"></a>
<a name="IDX1296"></a>
<a name="IDX1297"></a>
<p>Produces a random non-negative integer <var>I</var> whose low bits are not
all that random, so it should be scaled to a smaller range in general.
The integer <var>I</var> is in the range 0 .. 2^(w-1) - 1. You can use:
</p><table><tr><td> </td><td><pre class="example">rannum(X) :- yap_flag(max_integer,MI), rannum(R), X is R/MI.
</pre></td></tr></table><p>to obtain a floating point number uniformly distributed between 0 and 1.
</p>
</dd>
<dt> <code>ranstart</code></dt>
<dd><a name="IDX1298"></a>
<a name="IDX1299"></a>
<a name="IDX1300"></a>
<p>Initialize the random number generator using a built-in seed. The
<code>ranstart/0</code> built-in is always called by the system when loading
the package.
</p>
</dd>
<dt> <code>ranstart(+<var>Seed</var>)</code></dt>
<dd><a name="IDX1301"></a>
<a name="IDX1302"></a>
<a name="IDX1303"></a>
<p>Initialize the random number generator with user-defined <var>Seed</var>. The
same <var>Seed</var> always produces the same sequence of numbers.
</p>
</dd>
<dt> <code>ranunif(+<var>Range</var>,-<var>I</var>)</code></dt>
<dd><a name="IDX1304"></a>
<a name="IDX1305"></a>
<a name="IDX1306"></a>
<p><code>ranunif/2</code> produces a uniformly distributed non-negative random
integer <var>I</var> over a caller-specified range <var>R</var>. If range is <var>R</var>,
the result is in 0 .. <var>R</var>-1.
</p>
</dd>
</dl>
<hr size="6">
<a name="Queues"></a>
<a name="SEC69"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC68" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC70" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC61" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC83" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 7.8 Queues </h2>
<p>The following queue manipulation routines are available once
included with the <code>use_module(library(queues))</code> command. Queues are
implemented with difference lists.
</p>
<dl compact="compact">
<dt> <code>make_queue(+<var>Queue</var>)</code></dt>
<dd><a name="IDX1307"></a>
<a name="IDX1308"></a>
<a name="IDX1309"></a>
<p>Creates a new empty queue. It should only be used to create a new queue.
</p>
</dd>
<dt> <code>join_queue(+<var>Element</var>, +<var>OldQueue</var>, -<var>NewQueue</var>)</code></dt>
<dd><a name="IDX1310"></a>
<a name="IDX1311"></a>
<a name="IDX1312"></a>
<p>Adds the new element at the end of the queue.
</p>
</dd>
<dt> <code>list_join_queue(+<var>List</var>, +<var>OldQueue</var>, -<var>NewQueue</var>)</code></dt>
<dd><a name="IDX1313"></a>
<a name="IDX1314"></a>
<a name="IDX1315"></a>
<p>Ads the new elements at the end of the queue.
</p>
</dd>
<dt> <code>jump_queue(+<var>Element</var>, +<var>OldQueue</var>, -<var>NewQueue</var>)</code></dt>
<dd><a name="IDX1316"></a>
<a name="IDX1317"></a>
<a name="IDX1318"></a>
<p>Adds the new element at the front of the list.
</p>
</dd>
<dt> <code>list_jump_queue(+<var>List</var>, +<var>OldQueue</var>, +<var>NewQueue</var>)</code></dt>
<dd><a name="IDX1319"></a>
<a name="IDX1320"></a>
<a name="IDX1321"></a>
<p>Adds all the elements of <var>List</var> at the front of the queue.
</p>
</dd>
<dt> <code>head_queue(+<var>Queue</var>, ?<var>Head</var>)</code></dt>
<dd><a name="IDX1322"></a>
<a name="IDX1323"></a>
<a name="IDX1324"></a>
<p>Unifies Head with the first element of the queue.
</p>
</dd>
<dt> <code>serve_queue(+<var>OldQueue</var>, +<var>Head</var>, -<var>NewQueue</var>)</code></dt>
<dd><a name="IDX1325"></a>
<a name="IDX1326"></a>
<a name="IDX1327"></a>
<p>Removes the first element of the queue for service.
</p>
</dd>
<dt> <code>empty_queue(+<var>Queue</var>)</code></dt>
<dd><a name="IDX1328"></a>
<a name="IDX1329"></a>
<a name="IDX1330"></a>
<p>Tests whether the queue is empty.
</p>
</dd>
<dt> <code>length_queue(+<var>Queue</var>, -<var>Length</var>)</code></dt>
<dd><a name="IDX1331"></a>
<a name="IDX1332"></a>
<a name="IDX1333"></a>
<p>Counts the number of elements currently in the queue.
</p>
</dd>
<dt> <code>list_to_queue(+<var>List</var>, -<var>Queue</var>)</code></dt>
<dd><a name="IDX1334"></a>
<a name="IDX1335"></a>
<a name="IDX1336"></a>
<p>Creates a new queue with the same elements as <var>List.</var>
</p>
</dd>
<dt> <code>queue_to_list(+<var>Queue</var>, -<var>List</var>)</code></dt>
<dd><a name="IDX1337"></a>
<a name="IDX1338"></a>
<a name="IDX1339"></a>
<p>Creates a new list with the same elements as <var>Queue</var>.
</p>
</dd>
</dl>
<hr size="6">
<a name="Random"></a>
<a name="SEC70"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC69" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC71" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC61" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC83" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 7.9 Random Number Generator </h2>
<p>The following random number operations are included with the
<code>use_module(library(random))</code> command. Since Yap-4.3.19 Yap uses
the O'Keefe public-domain algorithm, based on the "Applied Statistics"
algorithm AS183.
</p>
<dl compact="compact">
<dt> <code>getrand(-<var>Key</var>)</code></dt>
<dd><a name="IDX1340"></a>
<a name="IDX1341"></a>
<a name="IDX1342"></a>
<p>Unify <var>Key</var> with a term of the form <code>rand(X,Y,Z)</code> describing the
current state of the random number generator.
</p>
</dd>
<dt> <code>random(-<var>Number</var>)</code></dt>
<dd><a name="IDX1343"></a>
<a name="IDX1344"></a>
<a name="IDX1345"></a>
<p>Unify <var>Number</var> with a floating-point number in the range <code>[0...1)</code>.
</p>
</dd>
<dt> <code>random(+<var>LOW</var>, +<var>HIGH</var>, -<var>NUMBER</var>)</code></dt>
<dd><a name="IDX1346"></a>
<a name="IDX1347"></a>
<a name="IDX1348"></a>
<p>Unify <var>Number</var> with a number in the range
<code>[LOW...HIGH)</code>. If both <var>LOW</var> and <var>HIGH</var> are
integers then <var>NUMBER</var> will also be an integer, otherwise
<var>NUMBER</var> will be a floating-point number.
</p>
</dd>
<dt> <code>randseq(+<var>LENGTH</var>, +<var>MAX</var>, -<var>Numbers</var>)</code></dt>
<dd><a name="IDX1349"></a>
<a name="IDX1350"></a>
<a name="IDX1351"></a>
<p>Unify <var>Numbers</var> with a list of <var>LENGTH</var> unique random integers
in the range <code>[1...<var>MAX</var>)</code>.
</p>
</dd>
<dt> <code>randset(+<var>LENGTH</var>, +<var>MAX</var>, -<var>Numbers</var>)</code></dt>
<dd><a name="IDX1352"></a>
<a name="IDX1353"></a>
<a name="IDX1354"></a>
<p>Unify <var>Numbers</var> with an ordered list of <var>LENGTH</var> unique random
integers in the range <code>[1...<var>MAX</var>)</code>.
</p>
</dd>
<dt> <code>setrand(+<var>Key</var>)</code></dt>
<dd><a name="IDX1355"></a>
<a name="IDX1356"></a>
<a name="IDX1357"></a>
<p>Use a term of the form <code>rand(X,Y,Z)</code> to set a new state for the
random number generator. The integer <code>X</code> must be in the range
<code>[1...30269)</code>, the integer <code>Y</code> must be in the range
<code>[1...30307)</code>, and the integer <code>Z</code> must be in the range
<code>[1...30323)</code>.
</p>
</dd>
</dl>
<hr size="6">
<a name="Red_002dBlack-Trees"></a>
<a name="SEC71"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC70" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC72" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC61" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC83" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 7.10 Red-Black Trees </h2>
<p>Red-Black trees are balanced search binary trees. They are named because
nodes can be classified as either red or black. The code we include is
based on "Introduction to Algorithms", second edition, by Cormen,
Leiserson, Rivest and Stein. The library includes routines to insert,
lookup and delete elements in the tree.
</p>
<dl compact="compact">
<dt> <code>rb_new(?<var>T</var>)</code></dt>
<dd><a name="IDX1358"></a>
<a name="IDX1359"></a>
<a name="IDX1360"></a>
<p>Create a new tree.
</p>
</dd>
<dt> <code>rb_empty(?<var>T</var>)</code></dt>
<dd><a name="IDX1361"></a>
<a name="IDX1362"></a>
<a name="IDX1363"></a>
<p>Succeeds if tree <var>T</var> is empty.
</p>
</dd>
<dt> <code>is_rbtree(+<var>T</var>)</code></dt>
<dd><a name="IDX1364"></a>
<a name="IDX1365"></a>
<a name="IDX1366"></a>
<p>Check whether <var>T</var> is a valid red-black tree.
</p>
</dd>
<dt> <code>rb_insert(+<var>T0</var>,+<var>Key</var>,?<var>Value</var>,+<var>TF</var>)</code></dt>
<dd><a name="IDX1367"></a>
<a name="IDX1368"></a>
<a name="IDX1369"></a>
<p>Add an element with key <var>Key</var> and <var>Value</var> to the tree
<var>T0</var> creating a new red-black tree <var>TF</var>. Duplicated elements are not
allowed.
</p>
</dd>
<dt> <code>rb_lookup(+<var>Key</var>,-<var>Value</var>,+<var>T</var>)</code></dt>
<dd><a name="IDX1370"></a>
<a name="IDX1371"></a>
<a name="IDX1372"></a>
<p>Backtrack through all elements with key <var>Key</var> in the red-black tree
<var>T</var>, returning for each the value <var>Value</var>.
</p>
</dd>
<dt> <code>rb_lookupall(+<var>Key</var>,-<var>Value</var>,+<var>T</var>)</code></dt>
<dd><a name="IDX1373"></a>
<a name="IDX1374"></a>
<a name="IDX1375"></a>
<p>Lookup all elements with key <var>Key</var> in the red-black tree
<var>T</var>, returning the value <var>Value</var>.
</p>
</dd>
<dt> <code>rb_delete(+<var>T</var>,+<var>Key</var>,-<var>TN</var>)</code></dt>
<dd><a name="IDX1376"></a>
<a name="IDX1377"></a>
<a name="IDX1378"></a>
<p>Delete element with key <var>Key</var> from the tree <var>T</var>, returning a new
tree <var>TN</var>.
</p>
</dd>
<dt> <code>rb_delete(+<var>T</var>,+<var>Key</var>,-<var>Val</var>,-<var>TN</var>)</code></dt>
<dd><a name="IDX1379"></a>
<a name="IDX1380"></a>
<a name="IDX1381"></a>
<p>Delete element with key <var>Key</var> from the tree <var>T</var>, returning the
value <var>Val</var> associated with the key and a new tree <var>TN</var>.
</p>
</dd>
<dt> <code>rb_del_min(+<var>T</var>,-<var>Key</var>,-<var>Val</var>,-<var>TN</var>)</code></dt>
<dd><a name="IDX1382"></a>
<a name="IDX1383"></a>
<a name="IDX1384"></a>
<p>Delete the least element from the tree <var>T</var>, returning the key
<var>Key</var>, the value <var>Val</var> associated with the key and a new tree
<var>TN</var>.
</p>
</dd>
<dt> <code>rb_del_max(+<var>T</var>,-<var>Key</var>,-<var>Val</var>,-<var>TN</var>)</code></dt>
<dd><a name="IDX1385"></a>
<a name="IDX1386"></a>
<a name="IDX1387"></a>
<p>Delete the largest element from the tree <var>T</var>, returning the key
<var>Key</var>, the value <var>Val</var> associated with the key and a new tree
<var>TN</var>.
</p>
</dd>
<dt> <code>rb_update(+<var>T</var>,+<var>Key</var>,+<var>NewVal</var>,-<var>TN</var>)</code></dt>
<dd><a name="IDX1388"></a>
<a name="IDX1389"></a>
<a name="IDX1390"></a>
<p>Tree <var>TN</var> is tree <var>T</var>, but with value for <var>Key</var> associated
with <var>NewVal</var>. Fails if it cannot find <var>Key</var> in <var>T</var>.
</p>
</dd>
<dt> <code>rb_apply(+<var>T</var>,+<var>Key</var>,+<var>G</var>,-<var>TN</var>)</code></dt>
<dd><a name="IDX1391"></a>
<a name="IDX1392"></a>
<a name="IDX1393"></a>
<p>If the value associated with key <var>Key</var> is <var>Val0</var> in <var>T</var>, and
if <var>call(G,Val0,ValF)</var> holds, then <var>TN</var> differs from <var>T</var>
only in that <var>Key</var> is associated with value <var>ValF</var> in tree
<var>TN</var>. Fails if it cannot find <var>Key</var> in <var>T</var>, or if
<var>call(G,Val0,ValF)</var> is not satisfiable.
</p>
</dd>
<dt> <code>rb_visit(+<var>T</var>,-<var>Pairs</var>)</code></dt>
<dd><a name="IDX1394"></a>
<a name="IDX1395"></a>
<a name="IDX1396"></a>
<p><var>Pairs</var> is an infix visit of tree <var>T</var>, where each element of
<var>Pairs</var> is of the form <var>K-Val</var>.
</p>
</dd>
<dt> <code>rb_size(+<var>T</var>,-<var>Size</var>)</code></dt>
<dd><a name="IDX1397"></a>
<a name="IDX1398"></a>
<a name="IDX1399"></a>
<p><var>Size</var> is the number of elements in <var>T</var>.
</p>
</dd>
<dt> <code>rb_keys(+<var>T</var>,+<var>Keys</var>)</code></dt>
<dd><a name="IDX1400"></a>
<a name="IDX1401"></a>
<a name="IDX1402"></a>
<p><var>Keys</var> is an infix visit with all keys in tree <var>T</var>. Keys will be
sorted, but may be duplicate.
</p>
</dd>
<dt> <code>rb_map(+<var>T</var>,+<var>G</var>,-<var>TN</var>)</code></dt>
<dd><a name="IDX1403"></a>
<a name="IDX1404"></a>
<a name="IDX1405"></a>
<p>For all nodes <var>Key</var> in the tree <var>T</var>, if the value associated with
key <var>Key</var> is <var>Val0</var> in tree <var>T</var>, and if
<var>call(G,Val0,ValF)</var> holds, then the value associated with <var>Key</var>
in <var>TN</var> is <var>ValF</var>. Fails if or if <var>call(G,Val0,ValF)</var> is not
satisfiable for all <var>Var0</var>.
</p>
</dd>
<dt> <code>rb_partial_map(+<var>T</var>,+<var>Keys</var>,+<var>G</var>,-<var>TN</var>)</code></dt>
<dd><a name="IDX1406"></a>
<a name="IDX1407"></a>
<a name="IDX1408"></a>
<p>For all nodes <var>Key</var> in <var>Keys</var>, if the value associated with key
<var>Key</var> is <var>Val0</var> in tree <var>T</var>, and if <var>call(G,Val0,ValF)</var>
holds, then the value associated with <var>Key</var> in <var>TN</var> is
<var>ValF</var>. Fails if or if <var>call(G,Val0,ValF)</var> is not satisfiable
for all <var>Var0</var>. Assumes keys are not repeated.
</p>
</dd>
<dt> <code>rb_clone(+<var>T</var>,+<var>NT</var>,+<var>Nodes</var>)</code></dt>
<dd><a name="IDX1409"></a>
<a name="IDX1410"></a>
<a name="IDX1411"></a>
<p>"Clone" the red-back tree into a new tree with the same keys as the
original but with all values set to unbound values. Nodes is a list
containing all new nodes as pairs <var>K-V</var>.
</p>
</dd>
<dt> <code>rb_min(+<var>T</var>,-<var>Key</var>,-<var>Value</var>)</code></dt>
<dd><a name="IDX1412"></a>
<a name="IDX1413"></a>
<a name="IDX1414"></a>
<p><var>Key</var> is the minimum key in <var>T</var>, and is associated with <var>Val</var>.
</p>
</dd>
<dt> <code>rb_max(+<var>T</var>,-<var>Key</var>,-<var>Value</var>)</code></dt>
<dd><a name="IDX1415"></a>
<a name="IDX1416"></a>
<a name="IDX1417"></a>
<p><var>Key</var> is the maximal key in <var>T</var>, and is associated with <var>Val</var>.
</p>
</dd>
<dt> <code>rb_next(+<var>T</var>, +<var>Key</var>,-<var>Next</var>,-<var>Value</var>)</code></dt>
<dd><a name="IDX1418"></a>
<a name="IDX1419"></a>
<a name="IDX1420"></a>
<p><var>Next</var> is the next element after <var>Key</var> in <var>T</var>, and is
associated with <var>Val</var>.
</p>
</dd>
<dt> <code>rb_previous(+<var>T</var>, +<var>Key</var>,-<var>Previous</var>,-<var>Value</var>)</code></dt>
<dd><a name="IDX1421"></a>
<a name="IDX1422"></a>
<a name="IDX1423"></a>
<p><var>Previous</var> is the previous element after <var>Key</var> in <var>T</var>, and is
associated with <var>Val</var>.
</p>
</dd>
<dt> <code>list_to_rbtree(+<var>L</var>, -<var>T</var>)</code></dt>
<dd><a name="IDX1424"></a>
<a name="IDX1425"></a>
<a name="IDX1426"></a>
<p><var>T</var> is the red-black tree corresponding to the mapping in list <var>L</var>.
</p>
</dd>
<dt> <code>ord_list_to_rbtree(+<var>L</var>, -<var>T</var>)</code></dt>
<dd><a name="IDX1427"></a>
<a name="IDX1428"></a>
<a name="IDX1429"></a>
<p><var>T</var> is the red-black tree corresponding to the mapping in ordered
list <var>L</var>.
</p></dd>
</dl>
<hr size="6">
<a name="RegExp"></a>
<a name="SEC72"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC71" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC73" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC61" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC83" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 7.11 Regular Expressions </h2>
<p>This library includes routines to determine whether a regular expression
matches part or all of a string. The routines can also return which
parts parts of the string matched the expression or subexpressions of
it. This library relies on Henry Spencer's <code>C</code>-package and is only
available in operating systems that support dynamic loading. The
<code>C</code>-code has been obtained from the sources of FreeBSD-4.0 and is
protected by copyright from Henry Spencer and from the Regents of the
University of California (see the file library/regex/COPYRIGHT for
further details).
</p>
<p>Much of the description of regular expressions below is copied verbatim
from Henry Spencer's manual page.
</p>
<p>A regular expression is zero or more branches, separated by "|". It
matches anything that matches one of the branches.
</p>
<p>A branch is zero or more pieces, concatenated. It matches a match for
the first, followed by a match for the second, etc.
</p>
<p>A piece is an atom possibly followed by "*", "+", or "?". An atom
followed by "*" matches a sequence of 0 or more matches of the atom.
An atom followed by "+" matches a sequence of 1 or more matches of the
atom. An atom followed by "?" matches a match of the atom, or the
null string.
</p>
<p>An atom is a regular expression in parentheses (matching a match for the
regular expression), a range (see below), "." (matching any single
character), "^" (matching the null string at the beginning of the
input string), "$" (matching the null string at the end of the input
string), a "\" followed by a single character (matching that
character), or a single character with no other significance (matching
that character).
</p>
<p>A range is a sequence of characters enclosed in "[]". It normally
matches any single character from the sequence. If the sequence begins
with "^", it matches any single character not from the rest of the
sequence. If two characters in the sequence are separated by "-",
this is shorthand for the full list of ASCII characters between them
(e.g. "[0-9]" matches any decimal digit). To include a literal "]"
in the sequence, make it the first character (following a possible
"^"). To include a literal "-", make it the first or last
character.
</p>
<dl compact="compact">
<dt> <code>regexp(+<var>RegExp</var>,+<var>String</var>,+<var>Opts</var>)</code></dt>
<dd><a name="IDX1430"></a>
<a name="IDX1431"></a>
<a name="IDX1432"></a>
<p>Match regular expression <var>RegExp</var> to input string <var>String</var>
according to options <var>Opts</var>. The options may be:
</p><ul>
<li> <code>nocase</code>: Causes upper-case characters in <var>String</var> to
be treated as lower case during the matching process.
</li></ul>
</dd>
<dt> <code>regexp(+<var>RegExp</var>,+<var>String</var>,+<var>Opts</var>,<var>SubMatchVars</var>)</code></dt>
<dd><a name="IDX1433"></a>
<a name="IDX1434"></a>
<a name="IDX1435"></a>
<p>Match regular expression <var>RegExp</var> to input string <var>String</var>
according to options <var>Opts</var>. The variable <var>SubMatchVars</var> should
be originally a list of unbound variables all will contain a sequence of
matches, that is, the head of <var>SubMatchVars</var> will contain the
characters in <var>String</var> that matched the leftmost parenthesized
subexpression within <var>RegExp</var>, the next head of list will contain
the characters that matched the next parenthesized subexpression to the
right in <var>RegExp</var>, and so on.
</p>
<p>The options may be:
</p><ul>
<li> <code>nocase</code>: Causes upper-case characters in <var>String</var> to
be treated as lower case during the matching process.
</li><li> <code>indices</code>: Changes what is stored in
<var>SubMatchVars</var>. Instead of storing the matching characters from
<var>String</var>, each variable will contain a term of the form <var>IO-IF</var>
giving the indices in <var>String</var> of the first and last characters in
the matching range of characters.
</li></ul>
<p>In general there may be more than one way to match a regular expression
to an input string. For example, consider the command
</p><table><tr><td> </td><td><pre class="example"> regexp("(a*)b*","aabaaabb", [], [X,Y])
</pre></td></tr></table><p>Considering only the rules given so far, <var>X</var> and <var>Y</var> could end up
with the values <code>"aabb"</code> and <code>"aa"</code>, <code>"aaab"</code> and
<code>"aaa"</code>, <code>"ab"</code> and <code>"a"</code>, or any of several other
combinations. To resolve this potential ambiguity <code>regexp</code> chooses among
alternatives using the rule "first then longest". In other words, it
considers the possible matches in order working from left to right
across the input string and the pattern, and it attempts to match longer
pieces of the input string before shorter ones. More specifically, the
following rules apply in decreasing order of priority:
</p>
<ol>
<li> If a regular expression could match two different parts of an
input string then it will match the one that begins earliest.
</li><li> If a regular expression contains "|" operators then the leftmost matching sub-expression is chosen.
</li><li> In *, +, and ? constructs, longer matches are chosen in preference to shorter ones.
</li><li> In sequences of expression components the components are considered from left to right.
</li></ol>
<p>In the example from above, <code>"(a*)b*"</code> matches <code>"aab"</code>: the
<code>"(a*)"</code> portion of the pattern is matched first and it consumes
the leading <code>"aa"</code>; then the <code>"b*"</code> portion of the pattern
consumes the next <code>"b"</code>. Or, consider the following example:
</p><table><tr><td> </td><td><pre class="example"> regexp("(ab|a)(b*)c", "abc", [], [X,Y,Z])
</pre></td></tr></table>
<p>After this command <var>X</var> will be <code>"abc"</code>, <var>Y</var> will be
<code>"ab"</code>, and <var>Z</var> will be an empty string. Rule 4 specifies that
<code>"(ab|a)"</code> gets first shot at the input string and Rule 2 specifies
that the <code>"ab"</code> sub-expression is checked before the <code>"a"</code>
sub-expression. Thus the <code>"b"</code> has already been claimed before the
<code>"(b*)"</code> component is checked and <code>(b*)</code> must match an empty string.
</p>
</dd>
</dl>
<hr size="6">
<a name="Splay-Trees"></a>
<a name="SEC73"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC72" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC74" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC61" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC83" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 7.12 Splay Trees </h2>
<p>Splay trees are explained in the paper "Self-adjusting Binary Search
Trees", by D.D. Sleator and R.E. Tarjan, JACM, vol. 32, No.3, July 1985,
p. 668. They are designed to support fast insertions, deletions and
removals in binary search trees without the complexity of traditional
balanced trees. The key idea is to allow the tree to become
unbalanced. To make up for this, whenever we find a node, we move it up
to the top. We use code by Vijay Saraswat originally posted to the Prolog
mailing-list.
</p>
<dl compact="compact">
<dt> <code>splay_access(-<var>Return</var>,+<var>Key</var>,?<var>Val</var>,+<var>Tree</var>,-<var>NewTree</var>)</code></dt>
<dd><a name="IDX1436"></a>
<a name="IDX1437"></a>
<a name="IDX1438"></a>
<p>If item <var>Key</var> is in tree <var>Tree</var>, return its <var>Val</var> and
unify <var>Return</var> with <code>true</code>. Otherwise unify <var>Return</var> with
<code>null</code>. The variable <var>NewTree</var> unifies with the new tree.
</p>
</dd>
<dt> <code>splay_delete(+<var>Key</var>,?<var>Val</var>,+<var>Tree</var>,-<var>NewTree</var>)</code></dt>
<dd><a name="IDX1439"></a>
<a name="IDX1440"></a>
<a name="IDX1441"></a>
<p>Delete item <var>Key</var> from tree <var>Tree</var>, assuming that it is present
already. The variable <var>Val</var> unifies with a value for key <var>Key</var>,
and the variable <var>NewTree</var> unifies with the new tree. The predicate
will fail if <var>Key</var> is not present.
</p>
</dd>
<dt> <code>splay_init(-<var>NewTree</var>)</code></dt>
<dd><a name="IDX1442"></a>
<a name="IDX1443"></a>
<a name="IDX1444"></a>
<p>Initialize a new splay tree.
</p>
</dd>
<dt> <code>splay_insert(+<var>Key</var>,?<var>Val</var>,+<var>Tree</var>,-<var>NewTree</var>)</code></dt>
<dd><a name="IDX1445"></a>
<a name="IDX1446"></a>
<a name="IDX1447"></a>
<p>Insert item <var>Key</var> in tree <var>Tree</var>, assuming that it is not
there already. The variable <var>Val</var> unifies with a value for key
<var>Key</var>, and the variable <var>NewTree</var> unifies with the new
tree. In our implementation, <var>Key</var> is not inserted if it is
already there: rather it is unified with the item already in the tree.
</p>
</dd>
<dt> <code>splay_join(+<var>LeftTree</var>,+<var>RighTree</var>,-<var>NewTree</var>)</code></dt>
<dd><a name="IDX1448"></a>
<a name="IDX1449"></a>
<a name="IDX1450"></a>
<p>Combine trees <var>LeftTree</var> and <var>RighTree</var> into a single
tree<var>NewTree</var> containing all items from both trees. This operation
assumes that all items in <var>LeftTree</var> are less than all those in
<var>RighTree</var> and destroys both <var>LeftTree</var> and <var>RighTree</var>.
</p>
</dd>
<dt> <code>splay_split(+<var>Key</var>,?<var>Val</var>,+<var>Tree</var>,-<var>LeftTree</var>,-<var>RightTree</var>)</code></dt>
<dd><a name="IDX1451"></a>
<a name="IDX1452"></a>
<a name="IDX1453"></a>
<p>Construct and return two trees <var>LeftTree</var> and <var>RightTree</var>,
where <var>LeftTree</var> contains all items in <var>Tree</var> less than
<var>Key</var>, and <var>RightTree</var> contains all items in <var>Tree</var>
greater than <var>Key</var>. This operations destroys <var>Tree</var>.
</p>
</dd>
</dl>
<hr size="6">
<a name="String-I_002fO"></a>
<a name="SEC74"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC73" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC75" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC61" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC83" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 7.13 Reading From and Writing To Strings </h2>
<p>From Version 4.3.2 onwards YAP implements SICStus Prolog compatible
String I/O. The library allows users to read from and write to a memory
buffer as if it was a file. The memory buffer is built from or converted
to a string of character codes by the routines in library. Therefore, if
one wants to read from a string the string must be fully instantiated
before the library built-in opens the string for reading. These commands
are available through the <code>use_module(library(charsio))</code> command.
</p>
<dl compact="compact">
<dt> <code>format_to_chars(+<var>Form</var>, +<var>Args</var>, -<var>Result</var>)</code></dt>
<dd><a name="IDX1454"></a>
<a name="IDX1455"></a>
<a name="IDX1456"></a>
<p>Execute the built-in procedure <code>format/2</code> with form <var>Form</var> and
arguments <var>Args</var> outputting the result to the string of character
codes <var>Result</var>.
</p>
</dd>
<dt> <code>format_to_chars(+<var>Form</var>, +<var>Args</var>, -<var>Result0</var>, -<var>Result</var>)</code></dt>
<dd><a name="IDX1457"></a>
<a name="IDX1458"></a>
<a name="IDX1459"></a>
<p>Execute the built-in procedure <code>format/2</code> with form <var>Form</var> and
arguments <var>Args</var> outputting the result to the difference list of
character codes <var>Result-Result0</var>.
</p>
</dd>
<dt> <code>write_to_chars(+<var>Term</var>, -<var>Result</var>)</code></dt>
<dd><a name="IDX1460"></a>
<a name="IDX1461"></a>
<a name="IDX1462"></a>
<p>Execute the built-in procedure <code>write/1</code> with argument <var>Term</var>
outputting the result to the string of character codes <var>Result</var>.
</p>
</dd>
<dt> <code>write_to_chars(+<var>Term</var>, -<var>Result0</var>, -<var>Result</var>)</code></dt>
<dd><a name="IDX1463"></a>
<a name="IDX1464"></a>
<a name="IDX1465"></a>
<p>Execute the built-in procedure <code>write/1</code> with argument <var>Term</var>
outputting the result to the difference list of character codes
<var>Result-Result0</var>.
</p>
</dd>
<dt> <code>atom_to_chars(+<var>Atom</var>, -<var>Result</var>)</code></dt>
<dd><a name="IDX1466"></a>
<a name="IDX1467"></a>
<a name="IDX1468"></a>
<p>Convert the atom <var>Atom</var> to the string of character codes
<var>Result</var>.
</p>
</dd>
<dt> <code>atom_to_chars(+<var>Atom</var>, -<var>Result0</var>, -<var>Result</var>)</code></dt>
<dd><a name="IDX1469"></a>
<a name="IDX1470"></a>
<a name="IDX1471"></a>
<p>Convert the atom <var>Atom</var> to the difference list of character codes
<var>Result-Result0</var>.
</p>
</dd>
<dt> <code>number_to_chars(+<var>Number</var>, -<var>Result</var>)</code></dt>
<dd><a name="IDX1472"></a>
<a name="IDX1473"></a>
<a name="IDX1474"></a>
<p>Convert the number <var>Number</var> to the string of character codes
<var>Result</var>.
</p>
</dd>
<dt> <code>number_to_chars(+<var>Number</var>, -<var>Result0</var>, -<var>Result</var>)</code></dt>
<dd><a name="IDX1475"></a>
<a name="IDX1476"></a>
<a name="IDX1477"></a>
<p>Convert the atom <var>Number</var> to the difference list of character codes
<var>Result-Result0</var>.
</p>
</dd>
<dt> <code>read_from_chars(+<var>Chars</var>, -<var>Term</var>)</code></dt>
<dd><a name="IDX1478"></a>
<a name="IDX1479"></a>
<a name="IDX1480"></a>
<p>Parse the list of character codes <var>Chars</var> and return the result in
the term <var>Term</var>. The character codes to be read must terminate with
a dot character such that either (i) the dot character is followed by
blank characters; or (ii) the dot character is the last character in the
string.
</p>
</dd>
<dt> <code>open_chars_stream(+<var>Chars</var>, -<var>Stream</var>)</code></dt>
<dd><a name="IDX1481"></a>
<a name="IDX1482"></a>
<a name="IDX1483"></a>
<p>Open the list of character codes <var>Chars</var> as a stream <var>Stream</var>.
</p>
</dd>
<dt> <code>with_output_to_chars(?<var>Goal</var>, -<var>Chars</var>)</code></dt>
<dd><a name="IDX1484"></a>
<a name="IDX1485"></a>
<a name="IDX1486"></a>
<p>Execute goal <var>Goal</var> such that its standard output will be sent to a
memory buffer. After successful execution the contents of the memory
buffer will be converted to the list of character codes <var>Chars</var>.
</p>
</dd>
<dt> <code>with_output_to_chars(?<var>Goal</var>, ?<var>Chars0</var>, -<var>Chars</var>)</code></dt>
<dd><a name="IDX1487"></a>
<a name="IDX1488"></a>
<a name="IDX1489"></a>
<p>Execute goal <var>Goal</var> such that its standard output will be sent to a
memory buffer. After successful execution the contents of the memory
buffer will be converted to the difference list of character codes
<var>Chars-Chars0</var>.
</p>
</dd>
<dt> <code>with_output_to_chars(?<var>Goal</var>, -<var>Stream</var>, ?<var>Chars0</var>, -<var>Chars</var>)</code></dt>
<dd><a name="IDX1490"></a>
<a name="IDX1491"></a>
<a name="IDX1492"></a>
<p>Execute goal <var>Goal</var> such that its standard output will be sent to a
memory buffer. After successful execution the contents of the memory
buffer will be converted to the difference list of character codes
<var>Chars-Chars0</var> and <var>Stream</var> receives the stream corresponding to
the memory buffer.
</p>
</dd>
</dl>
<p>The implementation of the character IO operations relies on three YAP
built-ins:
</p><dl compact="compact">
<dt> <code>charsio:open_mem_read_stream(+<var>String</var>, -<var>Stream</var>)</code></dt>
<dd><p>Store a string in a memory buffer and output a stream that reads from this
memory buffer.
</p>
</dd>
<dt> <code>charsio:open_mem_write_stream(-<var>Stream</var>)</code></dt>
<dd><p>Create a new memory buffer and output a stream that writes to it.
</p>
</dd>
<dt> <code>charsio:peek_mem_write_stream(-<var>Stream</var>, L0, L)</code></dt>
<dd><p>Convert the memory buffer associated with stream <var>Stream</var> to the
difference list of character codes <var>L-L0</var>.
</p>
</dd>
</dl>
<p>These built-ins are initialized to belong to the module <code>charsio</code> in
<code>init.yap</code>. Novel procedures for manipulating strings by explicitly
importing these built-ins.
</p>
<p>YAP does not currently support opening a <code>charsio</code> stream in
<code>append</code> mode, or seeking in such a stream.
</p>
<hr size="6">
<a name="System"></a>
<a name="SEC75"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC74" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC76" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC61" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC83" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 7.14 Calling The Operating System from YAP </h2>
<p>Yap now provides a library of system utilities compatible with the
SICStus Prolog system library. This library extends and to some point
replaces the functionality of Operating System access routines. The
library includes Unix/Linux and Win32 <code>C</code> code. They
are available through the <code>use_module(library(system))</code> command.
</p>
<dl compact="compact">
<dt> <code>datime(datime(-<var>Year</var>, -<var>Month</var>, -<var>DayOfTheMonth</var>,</code></dt>
<dd><p>-<var>Hour</var>, -<var>Minute</var>, -<var>Second</var>)
<a name="IDX1493"></a>
<a name="IDX1494"></a>
<a name="IDX1495"></a>
The <code>datime/1</code> procedure returns the current date and time, with
information on <var>Year</var>, <var>Month</var>, <var>DayOfTheMonth</var>,
<var>Hour</var>, <var>Minute</var>, and <var>Second</var>. The <var>Hour</var> is returned
on local time. This function uses the WIN32
<code>GetLocalTime</code> function or the Unix <code>localtime</code> function.
</p>
<table><tr><td> </td><td><pre class="example"> ?- datime(X).
X = datime(2001,5,28,15,29,46) ?
</pre></td></tr></table>
</dd>
<dt> <code>mktime(datime(+<var>Year</var>, +<var>Month</var>, +<var>DayOfTheMonth</var>,</code></dt>
<dd><p>+<var>Hour</var>, +<var>Minute</var>, +<var>Second</var>), -<var>Seconds</var>)
<a name="IDX1496"></a>
<a name="IDX1497"></a>
<a name="IDX1498"></a>
The <code>mktime/1</code> procedure returns the number of <var>Seconds</var>
elapsed since 00:00:00 on January 1, 1970, Coordinated Universal Time
(UTC). The user provides information on <var>Year</var>, <var>Month</var>,
<var>DayOfTheMonth</var>, <var>Hour</var>, <var>Minute</var>, and <var>Second</var>. The
<var>Hour</var> is given on local time. This function uses the WIN32
<code>GetLocalTime</code> function or the Unix <code>mktime</code> function.
</p>
<table><tr><td> </td><td><pre class="example"> ?- mktime(datime(2001,5,28,15,29,46),X).
X = 991081786 ? ;
</pre></td></tr></table>
</dd>
<dt> <code>delete_file(+<var>File</var>)</code></dt>
<dd><a name="IDX1499"></a>
<a name="IDX1500"></a>
<a name="IDX1501"></a>
<p>The <code>delete_file/1</code> procedure removes file <var>File</var>. If
<var>File</var> is a directory, remove the directory <em>and all its
subdirectories</em>.
</p>
<table><tr><td> </td><td><pre class="example"> ?- delete_file(x).
</pre></td></tr></table>
</dd>
<dt> <code>delete_file(+<var>File</var>,+<var>Opts</var>)</code></dt>
<dd><a name="IDX1502"></a>
<a name="IDX1503"></a>
<a name="IDX1504"></a>
<p>The <code>delete_file/2</code> procedure removes file <var>File</var> according to
options <var>Opts</var>. These options are <code>directory</code> if one should
remove directories, <code>recursive</code> if one should remove directories
recursively, and <code>ignore</code> if errors are not to be reported.
</p>
<p>This example is equivalent to using the <code>delete_file/1</code> predicate:
</p><table><tr><td> </td><td><pre class="example"> ?- delete_file(x, [recursive]).
</pre></td></tr></table>
</dd>
<dt> <code>directory_files(+<var>Dir</var>,+<var>List</var>)</code></dt>
<dd><a name="IDX1505"></a>
<a name="IDX1506"></a>
<a name="IDX1507"></a>
<p>Given a directory <var>Dir</var>, <code>directory_files/2</code> procedures a
listing of all files and directories in the directory:
</p><table><tr><td> </td><td><pre class="example"> ?- directory_files('.',L), writeq(L).
['Makefile.~1~','sys.so','Makefile','sys.o',x,..,'.']
</pre></td></tr></table><p>The predicates uses the <code>dirent</code> family of routines in Unix
environments, and <code>findfirst</code> in WIN32.
</p>
</dd>
<dt> <code>file_exists(+<var>File</var>)</code></dt>
<dd><a name="IDX1508"></a>
<a name="IDX1509"></a>
<a name="IDX1510"></a>
<p>The atom <var>File</var> corresponds to an existing file.
</p>
</dd>
<dt> <code>file_exists(+<var>File</var>,+<var>Permissions</var>)</code></dt>
<dd><a name="IDX1511"></a>
<a name="IDX1512"></a>
<a name="IDX1513"></a>
<p>The atom <var>File</var> corresponds to an existing file with permissions
compatible with <var>Permissions</var>. YAP currently only accepts for
permissions to be described as a number. The actual meaning of this
number is Operating System dependent.
</p>
</dd>
<dt> <code>file_property(+<var>File</var>,?<var>Property</var>)</code></dt>
<dd><a name="IDX1514"></a>
<a name="IDX1515"></a>
<a name="IDX1516"></a>
<p>The atom <var>File</var> corresponds to an existing file, and <var>Property</var>
will be unified with a property of this file. The properties are of the
form <code>type(<var>Type</var>)</code>, which gives whether the file is a regular
file, a directory, a fifo file, or of unknown type;
<code>size(<var>Size</var>)</code>, with gives the size for a file, and
<code>mod_time(<var>Time</var>)</code>, which gives the last time a file was
modified according to some Operating System dependent
timestamp; <code>mode(<var>mode</var>)</code>, gives the permission flags for the
file, and <code>linkto(<var>FileName</var>)</code>, gives the file pointed to by a
symbolic link. Properties can be obtained through backtracking:
</p>
<table><tr><td> </td><td><pre class="example"> ?- file_property('Makefile',P).
P = type(regular) ? ;
P = size(2375) ? ;
P = mod_time(990826911) ? ;
no
</pre></td></tr></table>
</dd>
<dt> <code>make_directory(+<var>Dir</var>)</code></dt>
<dd><a name="IDX1517"></a>
<a name="IDX1518"></a>
<a name="IDX1519"></a>
<p>Create a directory <var>Dir</var>. The name of the directory must be an atom.
</p>
</dd>
<dt> <code>rename_file(+<var>OldFile</var>,+<var>NewFile</var>)</code></dt>
<dd><a name="IDX1520"></a>
<a name="IDX1521"></a>
<a name="IDX1522"></a>
<p>Create file <var>OldFile</var> to <var>NewFile</var>. This predicate uses the
<code>C</code> built-in function <code>rename</code>.
</p>
</dd>
<dt> <code>environ(?<var>EnvVar</var>,+<var>EnvValue</var>)</code></dt>
<dd><a name="IDX1523"></a>
<a name="IDX1524"></a>
<a name="IDX1525"></a>
<p>Unify environment variable <var>EnvVar</var> with its value <var>EnvValue</var>,
if there is one. This predicate is backtrackable in Unix systems, but
not currently in Win32 configurations.
</p>
<table><tr><td> </td><td><pre class="example"> ?- environ('HOME',X).
X = 'C:\\cygwin\\home\\administrator' ?
</pre></td></tr></table>
</dd>
<dt> <code>host_id(-<var>Id</var>)</code></dt>
<dd><a name="IDX1526"></a>
<a name="IDX1527"></a>
<a name="IDX1528"></a>
<p>Unify <var>Id</var> with an identifier of the current host. Yap uses the
<code>hostid</code> function when available,
</p>
</dd>
<dt> <code>host_name(-<var>Name</var>)</code></dt>
<dd><a name="IDX1529"></a>
<a name="IDX1530"></a>
<a name="IDX1531"></a>
<p>Unify <var>Name</var> with a name for the current host. Yap uses the
<code>hostname</code> function in Unix systems when available, and the
<code>GetComputerName</code> function in WIN32 systems.
</p>
</dd>
<dt> <code>kill(<var>Id</var>,+<var>SIGNAL</var>)</code></dt>
<dd><a name="IDX1532"></a>
<a name="IDX1533"></a>
<a name="IDX1534"></a>
<p>Send signal <var>SIGNAL</var> to process <var>Id</var>. In Unix this predicate is
a direct interface to <code>kill</code> so one can send signals to groups of
processes. In WIN32 the predicate is an interface to
<code>TerminateProcess</code>, so it kills <var>Id</var> indepent of <var>SIGNAL</var>.
</p>
</dd>
<dt> <code>mktemp(<var>Spec</var>,-<var>File</var>)</code></dt>
<dd><a name="IDX1535"></a>
<a name="IDX1536"></a>
<a name="IDX1537"></a>
<p>Direct interface to <code>mktemp</code>: given a <var>Spec</var>, that is a file
name with six <var>X</var> to it, create a file name <var>File</var>. Use
<code>tmpnam/1</code> instead.
</p>
</dd>
<dt> <code>pid(-<var>Id</var>)</code></dt>
<dd><a name="IDX1538"></a>
<a name="IDX1539"></a>
<a name="IDX1540"></a>
<p>Unify <var>Id</var> with the process identifier for the current
process. An interface to the <tt>getpid</tt> function.
</p>
</dd>
<dt> <code>tmpnam(-<var>File</var>)</code></dt>
<dd><a name="IDX1541"></a>
<a name="IDX1542"></a>
<a name="IDX1543"></a>
<p>Interface with <var>tmpnam</var>: create an unique file and unify its name
with <var>File</var>.
</p>
</dd>
<dt><code></code></dt>
<dd><p>exec(+<var>Command</var>,[+<var>InputStream</var>,+<var>OutputStream</var>,+<var>ErrorStream</var>],
-<var>Status</var>)
<a name="IDX1544"></a>
<a name="IDX1545"></a>
<a name="IDX1546"></a>
Execute command <var>Command</var> with its streams connected to
<var>InputStream</var>, <var>OutputStream</var>, and <var>ErrorStream</var>. The result
for the command is returned in <var>Status</var>. The command is executed by
the default shell <code>bin/sh -c</code> in Unix.
</p>
<p>The following example demonstrates the use of <code>exec/3</code> to send a
command and process its output:
</p>
<table><tr><td> </td><td><pre class="example">exec(ls,[std,pipe(S),null],P),repeat, get0(S,C), (C = -1, close(S) ! ; put(C)).
</pre></td></tr></table>
<p>The streams may be one of standard stream, <code>std</code>, null stream,
<code>null</code>, or <code>pipe(S)</code>, where <var>S</var> is a pipe stream. Note
that it is up to the user to close the pipe.
</p>
</dd>
<dt> <code>working_directory(-<var>CurDir</var>,?<var>NextDir</var>)</code></dt>
<dd><a name="IDX1547"></a>
<a name="IDX1548"></a>
<a name="IDX1549"></a>
<p>Fetch the current directory at <var>CurDir</var>. If <var>NextDir</var> is bound
to an atom, make its value the current working directory.
</p>
</dd>
<dt> <code>popen(+<var>Command</var>, +<var>TYPE</var>, -<var>Stream</var>)</code></dt>
<dd><a name="IDX1550"></a>
<a name="IDX1551"></a>
<a name="IDX1552"></a>
<p>Interface to the <tt>popen</tt> function. It opens a process by creating a
pipe, forking and invoking <var>Command</var> on the current shell. Since a
pipe is by definition unidirectional the <var>Type</var> argument may be
<code>read</code> or <code>write</code>, not both. The stream should be closed
using <code>close/1</code>, there is no need for a special <code>pclose</code>
command.
</p>
<p>The following example demonstrates the use of <code>popen/3</code> to process
the output of a command, as <code>exec/3</code> would do:
</p>
<table><tr><td> </td><td><pre class="example"> ?- popen(ls,read,X),repeat, get0(X,C), (C = -1, ! ; put(C)).
X = 'C:\\cygwin\\home\\administrator' ?
</pre></td></tr></table>
<p>The WIN32 implementation of <code>popen/3</code> relies on <code>exec/3</code>.
</p>
</dd>
<dt> <code>shell</code></dt>
<dd><a name="IDX1553"></a>
<a name="IDX1554"></a>
<a name="IDX1555"></a>
<p>Start a new shell and leave Yap in background until the shell
completes. Yap uses the shell given by the environment variable
<code>SHELL</code>. In WIN32 environment YAP will use <code>COMSPEC</code> if
<code>SHELL</code> is undefined.
</p>
</dd>
<dt> <code>shell(+<var>Command</var>)</code></dt>
<dd><a name="IDX1556"></a>
<a name="IDX1557"></a>
<a name="IDX1558"></a>
<p>Execute command <var>Command</var> under a new shell. Yap will be in
background until the command completes. In Unix environments Yap uses
the shell given by the environment variable <code>SHELL</code> with the option
<code>" -c "</code>. In WIN32 environment YAP will use <code>COMSPEC</code> if
<code>SHELL</code> is undefined, in this case with the option <code>" /c "</code>.
</p>
</dd>
<dt> <code>shell(+<var>Command</var>,-<var>Status</var>)</code></dt>
<dd><a name="IDX1559"></a>
<a name="IDX1560"></a>
<a name="IDX1561"></a>
<p>Execute command <var>Command</var> under a new shell and unify <var>Status</var>
with the exit for the command. Yap will be in background until the
command completes. In Unix environments Yap uses the shell given by the
environment variable <code>SHELL</code> with the option <code>" -c "</code>. In
WIN32 environment YAP will use <code>COMSPEC</code> if <code>SHELL</code> is
undefined, in this case with the option <code>" /c "</code>.
</p>
</dd>
<dt> <code>sleep(+<var>Time</var>)</code></dt>
<dd><a name="IDX1562"></a>
<a name="IDX1563"></a>
<a name="IDX1564"></a>
<p>Block the current process for <var>Time</var> seconds. The number of seconds
must be a positive number, and it may an integer or a float. The Unix
implementation uses <code>usleep</code> if the number of seconds is below one,
and <code>sleep</code> if it is over a second. The WIN32 implementation uses
<code>Sleep</code> for both cases.
</p>
</dd>
<dt> <code>system</code></dt>
<dd><a name="IDX1565"></a>
<a name="IDX1566"></a>
<a name="IDX1567"></a>
<p>Start a new default shell and leave Yap in background until the shell
completes. Yap uses <code>/bin/sh</code> in Unix systems and <code>COMSPEC</code> in
WIN32.
</p>
</dd>
<dt> <code>system(+<var>Command</var>,-<var>Res</var>)</code></dt>
<dd><a name="IDX1568"></a>
<a name="IDX1569"></a>
<a name="IDX1570"></a>
<p>Interface to <code>system</code>: execute command <var>Command</var> and unify
<var>Res</var> with the result.
</p>
</dd>
<dt> <code>wait(+<var>PID</var>,-<var>Status</var>)</code></dt>
<dd><a name="IDX1571"></a>
<a name="IDX1572"></a>
<a name="IDX1573"></a>
<p>Wait until process <var>PID</var> terminates, and return its exits <var>Status</var>.
</p>
</dd>
</dl>
<hr size="6">
<a name="Terms"></a>
<a name="SEC76"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC75" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC77" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC61" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC83" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 7.15 Utilities On Terms </h2>
<p>The next routines provide a set of commonly used utilities to manipulate
terms. Most of these utilities have been implemented in <code>C</code> for
efficiency. They are available through the
<code>use_module(library(terms))</code> command.
</p>
<dl compact="compact">
<dt> <code>acyclic_term(?<var>Term</var>)</code></dt>
<dd><a name="IDX1574"></a>
<a name="IDX1575"></a>
<a name="IDX1576"></a>
<p>Succeed if the argument <var>Term</var> is an acyclic term.
</p>
</dd>
<dt> <code>cyclic_term(?<var>Term</var>)</code></dt>
<dd><a name="IDX1577"></a>
<a name="IDX1578"></a>
<a name="IDX1579"></a>
<p>Succeed if the argument <var>Term</var> is a cyclic term.
</p>
</dd>
<dt> <code>term_hash(+<var>Term</var>, ?<var>Hash</var>)</code></dt>
<dd><a name="IDX1580"></a>
<a name="IDX1581"></a>
<a name="IDX1582"></a>
<p>If <var>Term</var> is ground unify <var>Hash</var> with a positive integer
calculated from the structure of the term. Otherwise the argument
<var>Hash</var> is left unbound. The range of the positive integer is from
<code>0</code> to, but not including, <code>33554432</code>.
</p>
</dd>
<dt> <code>term_hash(+<var>Term</var>, +<var>Depth</var>, +<var>Range</var>, ?<var>Hash</var>)</code></dt>
<dd><a name="IDX1583"></a>
<a name="IDX1584"></a>
<a name="IDX1585"></a>
<p>Unify <var>Hash</var> with a positive integer calculated from the structure
of the term. The range of the positive integer is from <code>0</code> to, but
not including, <var>Range</var>. If <var>Depth</var> is <code>-1</code> the whole term
is considered. Otherwise, the term is considered only up to depth
<code>1</code>, where the constants and the principal functor have depth
<code>1</code>, and an argument of a term with depth <var>I</var> has depth <var>I+1</var>.
</p>
</dd>
<dt> <code>term_variables(?<var>Term</var>, -<var>Variables</var>)</code></dt>
<dd><a name="IDX1586"></a>
<a name="IDX1587"></a>
<a name="IDX1588"></a>
<p>Unify <var>Variables</var> with a list of all variables in term <var>Term</var>.
</p>
</dd>
<dt> <code>variant(?<var>Term1</var>, ?<var>Term2</var>)</code></dt>
<dd><a name="IDX1589"></a>
<a name="IDX1590"></a>
<a name="IDX1591"></a>
<p>Succeed if <var>Term1</var> and <var>Term2</var> are variant terms.
</p>
</dd>
<dt> <code>subsumes(?<var>Term1</var>, ?<var>Term2</var>)</code></dt>
<dd><a name="IDX1592"></a>
<a name="IDX1593"></a>
<a name="IDX1594"></a>
<p>Succeed if <var>Term1</var> subsumes <var>Term2</var>. Variables in term
<var>Term1</var> are bound so that the two terms become equal.
</p>
</dd>
<dt> <code>subsumes_chk(?<var>Term1</var>, ?<var>Term2</var>)</code></dt>
<dd><a name="IDX1595"></a>
<a name="IDX1596"></a>
<a name="IDX1597"></a>
<p>Succeed if <var>Term1</var> subsumes <var>Term2</var> but does not bind any
variable in <var>Term1</var>.
</p>
</dd>
<dt> <code>variable_in_term(?<var>Term</var>,?<var>Var</var>)</code></dt>
<dd><a name="IDX1598"></a>
<a name="IDX1599"></a>
<a name="IDX1600"></a>
<p>Succeed if the second argument <var>Var</var> is a variable and occurs in
term <var>Term</var>.
</p>
</dd>
</dl>
<hr size="6">
<a name="Cleanup"></a>
<a name="SEC77"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC76" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC78" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC61" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC83" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 7.16 Call Cleanup </h2>
<p><tt>call_cleanup/1</tt> and <tt>call_cleanup/2</tt> allow predicates to register
code for execution after the call is finished. Predicates can be
declared to be <tt>fragile</tt> to ensure that <tt>call_cleanup</tt> is called
for any Goal which needs it. This library is loaded with the
<code>use_module(library(cleanup))</code> command.
</p>
<dl compact="compact">
<dt> <code>:- fragile <var>P</var>,....,<var>Pn</var></code></dt>
<dd><a name="IDX1601"></a>
<a name="IDX1602"></a>
<a name="IDX1603"></a>
<p>Declares the predicate <var>P</var>=<tt>[module:]name/arity</tt> as a fragile
predicate, module is optional, default is the current
typein_module. Whenever such a fragile predicate is used in a query
it will be called through call_cleanup/1.
</p><table><tr><td> </td><td><pre class="example">:- fragile foo/1,bar:baz/2.
</pre></td></tr></table>
</dd>
<dt> <code>call_cleanup(+<var>Goal</var>)</code></dt>
<dd><a name="IDX1604"></a>
<a name="IDX1605"></a>
<a name="IDX1606"></a>
<p>Execute goal <var>Goal</var> within a cleanup-context. Called predicates
might register cleanup Goals which are called right after the end of
the call to <var>Goal</var>. Cuts and exceptions inside Goal do not prevent the
execution of the cleanup calls. <tt>call_cleanup</tt> might be nested.
</p>
</dd>
<dt> <code>call_cleanup(+<var>Goal</var>, +<var>CleanUpGoal</var>)</code></dt>
<dd><a name="IDX1607"></a>
<a name="IDX1608"></a>
<a name="IDX1609"></a>
<p>This is similar to <tt>call_cleanup/1</tt> with an additional
<var>CleanUpGoal</var> which gets called after <var>Goal</var> is finished.
</p>
</dd>
<dt> <code>on_cleanup(+<var>CleanUpGoal</var>)</code></dt>
<dd><a name="IDX1610"></a>
<a name="IDX1611"></a>
<a name="IDX1612"></a>
<p>Any Predicate might registers a <var>CleanUpGoal</var>. The
<var>CleanUpGoal</var> is put onto the current cleanup context. All such
CleanUpGoals are executed in reverse order of their registration when
the surrounding cleanup-context ends. This call will throw an exception
if a predicate tries to register a <var>CleanUpGoal</var> outside of any
cleanup-context.
</p>
</dd>
<dt> <code>cleanup_all</code></dt>
<dd><a name="IDX1613"></a>
<a name="IDX1614"></a>
<a name="IDX1615"></a>
<p>Calls all pending CleanUpGoals and resets the cleanup-system to an
initial state. Should only be used as one of the last calls in the
main program.
</p>
</dd>
</dl>
<p>There are some private predicates which could be used in special
cases, such as manually setting up cleanup-contexts and registering
CleanUpGoals for other than the current cleanup-context.
Read the Source Luke.
</p>
<hr size="6">
<a name="Timeout"></a>
<a name="SEC78"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC77" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC79" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC61" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC83" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 7.17 Calls With Timeout </h2>
<p>The <tt>time_out/3</tt> command relies on the <tt>alarm/3</tt> built-in to
implement a call with a maximum time of execution. The command is
available with the <code>use_module(library(timeout))</code> command.
</p>
<dl compact="compact">
<dt> <code>time_out(+<var>Goal</var>, +<var>Timeout</var>, -<var>Result</var>)</code></dt>
<dd><a name="IDX1616"></a>
<a name="IDX1617"></a>
<a name="IDX1618"></a>
<p>Execute goal <var>Goal</var> with time limited <var>Timeout</var>, where
<var>Timeout</var> is measured in milliseconds. If the goal succeeds, unify
<var>Result</var> with success. If the timer expires before the goal
terminates, unify <var>Result</var> with <tt>timeout</tt>.
</p>
<p>This command is implemented by activating an alarm at procedure
entry. If the timer expires before the goal completes, the alarm will
through an exception <var>timeout</var>.
</p>
<p>One should note that <code>time_out/3</code> is not reentrant, that is, a goal
called from <code>time_out</code> should never itself call
<tt>time_out</tt>. Moreover, <code>time_out/3</code> will deactivate any previous
alarms set by <code>alarm/3</code> and vice-versa, hence only one of these
calls should be used in a program.
</p>
<p>Last, even though the timer is set in milliseconds, the current
implementation relies on <tt>alarm/3</tt>, and therefore can only offer
precision on the scale of seconds.
</p>
</dd>
</dl>
<hr size="6">
<a name="Trees"></a>
<a name="SEC79"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC78" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC80" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC61" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC83" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 7.18 Updatable Binary Trees </h2>
<p>The following queue manipulation routines are available once
included with the <code>use_module(library(trees))</code> command.
</p>
<dl compact="compact">
<dt> <code>get_label(+<var>Index</var>, +<var>Tree</var>, ?<var>Label</var>)</code></dt>
<dd><a name="IDX1619"></a>
<a name="IDX1620"></a>
<a name="IDX1621"></a>
<p>Treats the tree as an array of <var>N</var> elements and returns the
<var>Index</var>-th.
</p>
</dd>
<dt> <code>list_to_tree(+<var>List</var>, -<var>Tree</var>)</code></dt>
<dd><a name="IDX1622"></a>
<a name="IDX1623"></a>
<a name="IDX1624"></a>
<p>Takes a given <var>List</var> of <var>N</var> elements and constructs a binary
<var>Tree</var>.
</p>
</dd>
<dt> <code>map_tree(+<var>Pred</var>, +<var>OldTree</var>, -<var>NewTree</var>)</code></dt>
<dd><a name="IDX1625"></a>
<a name="IDX1626"></a>
<a name="IDX1627"></a>
<p>Holds when <var>OldTree</var> and <var>NewTree</var> are binary trees of the same shape
and <code>Pred(Old,New)</code> is true for corresponding elements of the two trees.
</p>
</dd>
<dt> <code>put_label(+<var>Index</var>, +<var>OldTree</var>, +<var>Label</var>, -<var>NewTree</var>)</code></dt>
<dd><a name="IDX1628"></a>
<a name="IDX1629"></a>
<a name="IDX1630"></a>
<p>constructs a new tree the same shape as the old which moreover has the
same elements except that the <var>Index</var>-th one is <var>Label</var>.
</p>
</dd>
<dt> <code>tree_size(+<var>Tree</var>, -<var>Size</var>)</code></dt>
<dd><a name="IDX1631"></a>
<a name="IDX1632"></a>
<a name="IDX1633"></a>
<p>Calculates the number of elements in the <var>Tree</var>.
</p>
</dd>
<dt> <code>tree_to_list(+<var>Tree</var>, -<var>List</var>)</code></dt>
<dd><a name="IDX1634"></a>
<a name="IDX1635"></a>
<a name="IDX1636"></a>
<p>Is the converse operation to list_to_tree.
</p>
</dd>
</dl>
<hr size="6">
<a name="UGraphs"></a>
<a name="SEC80"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC79" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC81" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC61" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC83" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 7.19 Unweighted Graphs </h2>
<p>The following graph manipulation routines are based in code originally
written by Richard O'Keefe. The code was then extended to be compatible
with the SICStus Prolog ugraphs library. The routines assume directed
graphs, undirected graphs may be implemented by using two edges. Graphs
are represented in one of two ways:
</p>
<ul>
<li> The P-representation of a graph is a list of (from-to) vertex
pairs, where the pairs can be in any old order. This form is
convenient for input/output.
</li><li> The S-representation of a graph is a list of (vertex-neighbors)
pairs, where the pairs are in standard order (as produced by keysort)
and the neighbors of each vertex are also in standard order (as
produced by sort). This form is convenient for many calculations.
</li></ul>
<p>These built-ins are available once included with the
<code>use_module(library(ugraphs))</code> command.
</p>
<dl compact="compact">
<dt> <code>vertices_edges_to_ugraph(+<var>Vertices</var>, +<var>Edges</var>, -<var>Graph</var>)</code></dt>
<dd><a name="IDX1637"></a>
<a name="IDX1638"></a>
<a name="IDX1639"></a>
<p>Given a graph with a set of vertices <var>Vertices</var> and a set of edges
<var>Edges</var>, <var>Graph</var> must unify with the corresponding
s-representation. Note that the vertices without edges will appear in
<var>Vertices</var> but not in <var>Edges</var>. Moreover, it is sufficient for a
vertice to appear in <var>Edges</var>.
</p><table><tr><td> </td><td><pre class="example">?- vertices_edges_to_ugraph([],[1-3,2-4,4-5,1-5],L).
L = [1-[3,5],2-[4],3-[],4-[5],5-[]] ?
</pre></td></tr></table><p>In this case all edges are defined implicitly. The next example shows
three unconnected edges:
</p><table><tr><td> </td><td><pre class="example">?- vertices_edges_to_ugraph([6,7,8],[1-3,2-4,4-5,1-5],L).
L = [1-[3,5],2-[4],3-[],4-[5],5-[],6-[],7-[],8-[]] ?
</pre></td></tr></table>
</dd>
<dt> <code>vertices(+<var>Graph</var>, -<var>Vertices</var>)</code></dt>
<dd><a name="IDX1640"></a>
<a name="IDX1641"></a>
<a name="IDX1642"></a>
<p>Unify <var>Vertices</var> with all vertices appearing in graph
<var>Graph</var>. In the next example:
</p><table><tr><td> </td><td><pre class="example">?- vertices([1-[3,5],2-[4],3-[],4-[5],5-[]], V).
L = [1,2,3,4,5]
</pre></td></tr></table>
</dd>
<dt> <code>edges(+<var>Graph</var>, -<var>Edges</var>)</code></dt>
<dd><a name="IDX1643"></a>
<a name="IDX1644"></a>
<a name="IDX1645"></a>
<p>Unify <var>Edges</var> with all edges appearing in graph
<var>Graph</var>. In the next example:
</p><table><tr><td> </td><td><pre class="example">?- vertices([1-[3,5],2-[4],3-[],4-[5],5-[]], V).
L = [1,2,3,4,5]
</pre></td></tr></table>
</dd>
<dt> <code>add_vertices(+<var>Graph</var>, +<var>Vertices</var>, -<var>NewGraph</var>)</code></dt>
<dd><a name="IDX1646"></a>
<a name="IDX1647"></a>
<a name="IDX1648"></a>
<p>Unify <var>NewGraph</var> with a new graph obtained by adding the list of
vertices <var>Vertices</var> to the graph <var>Graph</var>. In the next example:
</p><table><tr><td> </td><td><pre class="example">?- add_vertices([1-[3,5],2-[4],3-[],4-[5],
5-[],6-[],7-[],8-[]],
[0,2,9,10,11],
NG).
NG = [0-[],1-[3,5],2-[4],3-[],4-[5],5-[],
6-[],7-[],8-[],9-[],10-[],11-[]]
</pre></td></tr></table>
</dd>
<dt> <code>del_vertices(+<var>Vertices</var>, +<var>Graph</var>, -<var>NewGraph</var>)</code></dt>
<dd><a name="IDX1649"></a>
<a name="IDX1650"></a>
<a name="IDX1651"></a>
<p>Unify <var>NewGraph</var> with a new graph obtained by deleting the list of
vertices <var>Vertices</var> and all the edges that start from or go to a
vertex in <var>Vertices</var> to the graph <var>Graph</var>. In the next example:
</p><table><tr><td> </td><td><pre class="example">?- del_vertices([2,1],[1-[3,5],2-[4],3-[],
4-[5],5-[],6-[],7-[2,6],8-[]],NL).
NL = [3-[],4-[5],5-[],6-[],7-[6],8-[]]
</pre></td></tr></table>
</dd>
<dt> <code>add_edges(+<var>Graph</var>, +<var>Edges</var>, -<var>NewGraph</var>)</code></dt>
<dd><a name="IDX1652"></a>
<a name="IDX1653"></a>
<a name="IDX1654"></a>
<p>Unify <var>NewGraph</var> with a new graph obtained by adding the list of
edges <var>Edges</var> to the graph <var>Graph</var>. In the next example:
</p><table><tr><td> </td><td><pre class="example">?- add_edges([1-[3,5],2-[4],3-[],4-[5],5-[],6-[],
7-[],8-[]],[1-6,2-3,3-2,5-7,3-2,4-5],NL).
NL = [1-[3,5,6],2-[3,4],3-[2],4-[5],5-[7],6-[],7-[],8-[]]
</pre></td></tr></table>
</dd>
<dt> <code>del_edges(+<var>Graph</var>, +<var>Edges</var>, -<var>NewGraph</var>)</code></dt>
<dd><a name="IDX1655"></a>
<a name="IDX1656"></a>
<a name="IDX1657"></a>
<p>Unify <var>NewGraph</var> with a new graph obtained by removing the list of
edges <var>Edges</var> from the graph <var>Graph</var>. Notice that no vertices
are deleted. In the next example:
</p><table><tr><td> </td><td><pre class="example">?- del_edges([1-[3,5],2-[4],3-[],4-[5],5-[],
6-[],7-[],8-[]],
[1-6,2-3,3-2,5-7,3-2,4-5,1-3],NL).
NL = [1-[5],2-[4],3-[],4-[],5-[],6-[],7-[],8-[]]
</pre></td></tr></table>
</dd>
<dt> <code>transpose(+<var>Graph</var>, -<var>NewGraph</var>)</code></dt>
<dd><a name="IDX1658"></a>
<a name="IDX1659"></a>
<a name="IDX1660"></a>
<p>Unify <var>NewGraph</var> with a new graph obtained from <var>Graph</var> by
replacing all edges of the form <var>V1-V2</var> by edges of the form
<var>V2-V1</var>. The cost is <code>O(|V|^2)</code>. In the next example:
</p><table><tr><td> </td><td><pre class="example">?- transpose([1-[3,5],2-[4],3-[],
4-[5],5-[],6-[],7-[],8-[]], NL).
NL = [1-[],2-[],3-[1],4-[2],5-[1,4],6-[],7-[],8-[]]
</pre></td></tr></table><p>Notice that an undirected graph is its own transpose.
</p>
</dd>
<dt> <code>neighbors(+<var>Vertex</var>, +<var>Graph</var>, -<var>Vertices</var>)</code></dt>
<dd><a name="IDX1661"></a>
<a name="IDX1662"></a>
<a name="IDX1663"></a>
<p>Unify <var>Vertices</var> with the list of neighbors of vertex <var>Vertex</var>
in <var>Graph</var>. If the vertice is not in the graph fail. In the next
example:
</p><table><tr><td> </td><td><pre class="example">?- neighbors(4,[1-[3,5],2-[4],3-[],
4-[1,2,7,5],5-[],6-[],7-[],8-[]],
NL).
NL = [1,2,7,5]
</pre></td></tr></table>
</dd>
<dt> <code>neighbours(+<var>Vertex</var>, +<var>Graph</var>, -<var>Vertices</var>)</code></dt>
<dd><a name="IDX1664"></a>
<a name="IDX1665"></a>
<a name="IDX1666"></a>
<p>Unify <var>Vertices</var> with the list of neighbours of vertex <var>Vertex</var>
in <var>Graph</var>. In the next example:
</p><table><tr><td> </td><td><pre class="example">?- neighbours(4,[1-[3,5],2-[4],3-[],
4-[1,2,7,5],5-[],6-[],7-[],8-[]], NL).
NL = [1,2,7,5]
</pre></td></tr></table>
</dd>
<dt> <code>complement(+<var>Graph</var>, -<var>NewGraph</var>)</code></dt>
<dd><a name="IDX1667"></a>
<a name="IDX1668"></a>
<a name="IDX1669"></a>
<p>Unify <var>NewGraph</var> with the graph complementary to <var>Graph</var>.
In the next example:
</p><table><tr><td> </td><td><pre class="example">?- complement([1-[3,5],2-[4],3-[],
4-[1,2,7,5],5-[],6-[],7-[],8-[]], NL).
NL = [1-[2,4,6,7,8],2-[1,3,5,6,7,8],3-[1,2,4,5,6,7,8],
4-[3,5,6,8],5-[1,2,3,4,6,7,8],6-[1,2,3,4,5,7,8],
7-[1,2,3,4,5,6,8],8-[1,2,3,4,5,6,7]]
</pre></td></tr></table>
</dd>
<dt> <code>compose(+<var>LeftGraph</var>, +<var>RightGraph</var>, -<var>NewGraph</var>)</code></dt>
<dd><a name="IDX1670"></a>
<a name="IDX1671"></a>
<a name="IDX1672"></a>
<p>Compose the graphs <var>LeftGraph</var> and <var>RightGraph</var> to form <var>NewGraph</var>.
In the next example:
</p><table><tr><td> </td><td><pre class="example">?- compose([1-[2],2-[3]],[2-[4],3-[1,2,4]],L).
L = [1-[4],2-[1,2,4],3-[]]
</pre></td></tr></table>
</dd>
<dt> <code>top_sort(+<var>Graph</var>, -<var>Sort</var>)</code></dt>
<dd><a name="IDX1673"></a>
<a name="IDX1674"></a>
<a name="IDX1675"></a>
<p>Generate the set of nodes <var>Sort</var> as a topological sorting of graph
<var>Graph</var>, if one is possible.
In the next example we show how topological sorting works for a linear graph:
</p><table><tr><td> </td><td><pre class="example">?- top_sort([_138-[_219],_219-[_139], _139-[]],L).
L = [_138,_219,_139]
</pre></td></tr></table>
</dd>
<dt> <code>top_sort(+<var>Graph</var>, -<var>Sort0</var>, -<var>Sort</var>)</code></dt>
<dd><a name="IDX1676"></a>
<a name="IDX1677"></a>
<a name="IDX1678"></a>
<p>Generate the difference list <var>Sort</var>-<var>Sort0</var> as a topological
sorting of graph <var>Graph</var>, if one is possible.
</p>
</dd>
<dt> <code>transitive_closure(+<var>Graph</var>, +<var>Closure</var>)</code></dt>
<dd><a name="IDX1679"></a>
<a name="IDX1680"></a>
<a name="IDX1681"></a>
<p>Generate the graph <var>Closure</var> as the transitive closure of graph
<var>Graph</var>.
In the next example:
</p><table><tr><td> </td><td><pre class="example">?- transitive_closure([1-[2,3],2-[4,5],4-[6]],L).
L = [1-[2,3,4,5,6],2-[4,5,6],4-[6]]
</pre></td></tr></table>
</dd>
<dt> <code>reachable(+<var>Node</var>, +<var>Graph</var>, -<var>Vertices</var>)</code></dt>
<dd><a name="IDX1682"></a>
<a name="IDX1683"></a>
<a name="IDX1684"></a>
<p>Unify <var>Vertices</var> with the set of all vertices in graph
<var>Graph</var> that are reachable from <var>Node</var>. In the next example:
</p><table><tr><td> </td><td><pre class="example">?- reachable(1,[1-[3,5],2-[4],3-[],4-[5],5-[]],V).
V = [1,3,5]
</pre></td></tr></table>
</dd>
</dl>
<hr size="6">
<a name="DGraphs"></a>
<a name="SEC81"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC80" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC82" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC61" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC83" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 7.20 Directed Graphs </h2>
<p>The following graph manipulation routines use the red-black tree library
to try to avoid linear-time scans of the graph for all graph
operations. Graphs are represented as a red-black tree, where the key is
the vertex, and the associated value is a list of vertices reachable
from that vertex through an edge (ie, a list of edges).
</p>
<dl compact="compact">
<dt> <code>dgraph_new(+<var>Graph</var>)</code></dt>
<dd><a name="IDX1685"></a>
<a name="IDX1686"></a>
<a name="IDX1687"></a>
<p>Create a new directed graph. This operation must be performed before
trying to use the graph.
</p>
</dd>
<dt> <code>dgraph_vertices(+<var>Graph</var>, -<var>Vertices</var>)</code></dt>
<dd><a name="IDX1688"></a>
<a name="IDX1689"></a>
<a name="IDX1690"></a>
<p>Unify <var>Vertices</var> with all vertices appearing in graph
<var>Graph</var>.
</p>
</dd>
<dt> <code>dgraph_edges(+<var>Graph</var>, -<var>Edges</var>)</code></dt>
<dd><a name="IDX1691"></a>
<a name="IDX1692"></a>
<a name="IDX1693"></a>
<p>Unify <var>Edges</var> with all edges appearing in graph
<var>Graph</var>.
</p>
</dd>
<dt> <code>dgraph_add_vertices(+<var>Graph</var>, +<var>Vertices</var>, -<var>NewGraph</var>)</code></dt>
<dd><a name="IDX1694"></a>
<a name="IDX1695"></a>
<a name="IDX1696"></a>
<p>Unify <var>NewGraph</var> with a new graph obtained by adding the list of
vertices <var>Vertices</var> to the graph <var>Graph</var>.
</p>
</dd>
<dt> <code>dgraph_del_vertices(+<var>Vertices</var>, +<var>Graph</var>, -<var>NewGraph</var>)</code></dt>
<dd><a name="IDX1697"></a>
<a name="IDX1698"></a>
<a name="IDX1699"></a>
<p>Unify <var>NewGraph</var> with a new graph obtained by deleting the list of
vertices <var>Vertices</var> and all the edges that start from or go to a
vertex in <var>Vertices</var> to the graph <var>Graph</var>.
</p>
</dd>
<dt> <code>dgraph_add_edges(+<var>Graph</var>, +<var>Edges</var>, -<var>NewGraph</var>)</code></dt>
<dd><a name="IDX1700"></a>
<a name="IDX1701"></a>
<a name="IDX1702"></a>
<p>Unify <var>NewGraph</var> with a new graph obtained by adding the list of
edges <var>Edges</var> to the graph <var>Graph</var>.
</p>
</dd>
<dt> <code>dgraph_del_edges(+<var>Graph</var>, +<var>Edges</var>, -<var>NewGraph</var>)</code></dt>
<dd><a name="IDX1703"></a>
<a name="IDX1704"></a>
<a name="IDX1705"></a>
<p>Unify <var>NewGraph</var> with a new graph obtained by removing the list of
edges <var>Edges</var> from the graph <var>Graph</var>. Notice that no vertices
are deleted.
</p>
</dd>
<dt> <code>dgraph_neighbors(+<var>Vertex</var>, +<var>Graph</var>, -<var>Vertices</var>)</code></dt>
<dd><a name="IDX1706"></a>
<a name="IDX1707"></a>
<a name="IDX1708"></a>
<p>Unify <var>Vertices</var> with the list of neighbors of vertex <var>Vertex</var>
in <var>Graph</var>. If the vertice is not in the graph fail.
</p>
</dd>
<dt> <code>dgraph_neighbours(+<var>Vertex</var>, +<var>Graph</var>, -<var>Vertices</var>)</code></dt>
<dd><a name="IDX1709"></a>
<a name="IDX1710"></a>
<a name="IDX1711"></a>
<p>Unify <var>Vertices</var> with the list of neighbours of vertex <var>Vertex</var>
in <var>Graph</var>.
</p>
</dd>
<dt> <code>dgraph_complement(+<var>Graph</var>, -<var>NewGraph</var>)</code></dt>
<dd><a name="IDX1712"></a>
<a name="IDX1713"></a>
<a name="IDX1714"></a>
<p>Unify <var>NewGraph</var> with the graph complementary to <var>Graph</var>.
</p>
</dd>
<dt> <code>dgraph_transpose(+<var>Graph</var>, -<var>Transpose</var>)</code></dt>
<dd><a name="IDX1715"></a>
<a name="IDX1716"></a>
<a name="IDX1717"></a>
<p>Unify <var>NewGraph</var> with a new graph obtained from <var>Graph</var> by
replacing all edges of the form <var>V1-V2</var> by edges of the form
<var>V2-V1</var>.
</p>
</dd>
<dt> <code>dgraph_close(+<var>Graph1</var>, +<var>Graph2</var>, -<var>ComposedGraph</var>)</code></dt>
<dd><a name="IDX1718"></a>
<a name="IDX1719"></a>
<a name="IDX1720"></a>
<p>Unify <var>ComposedGraph</var> with a new graph obtained by composing
<var>Graph1</var> and <var>Graph2</var>, ie, <var>ComposedGraph</var> has an edge
<var>V1-V2</var> iff there is a <var>V</var> such that <var>V1-V</var> in <var>Graph1</var>
and <var>V-V2</var> in <var>Graph2</var>.
</p>
</dd>
<dt> <code>dgraph_transitive_closure(+<var>Graph</var>, -<var>Closure</var>)</code></dt>
<dd><a name="IDX1721"></a>
<a name="IDX1722"></a>
<a name="IDX1723"></a>
<p>Unify <var>Closure</var> with the transitive closure of graph <var>Graph</var>.
</p>
</dd>
<dt> <code>dgraph_symmetric_closure(+<var>Graph</var>, -<var>Closure</var>)</code></dt>
<dd><a name="IDX1724"></a>
<a name="IDX1725"></a>
<a name="IDX1726"></a>
<p>Unify <var>Closure</var> with the symmetric closure of graph <var>Graph</var>,
that is, if <var>Closure</var> contains an edge <var>U-V</var> it must also
contain the edge <var>V-U</var>.
</p>
</dd>
<dt> <code>dgraph_top_sort(+<var>Graph</var>, -<var>Vertices</var>)</code></dt>
<dd><a name="IDX1727"></a>
<a name="IDX1728"></a>
<a name="IDX1729"></a>
<p>Unify <var>Vertices</var> with the topological sort of graph <var>Graph</var>.
</p>
</dd>
</dl>
<hr size="6">
<a name="UnDGraphs"></a>
<a name="SEC82"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC81" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC83" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC61" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC61" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC83" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 7.21 Undirected Graphs </h2>
<p>The following graph manipulation routines use the red-black tree graph
library to implement undirected graphs. Mostly, this is done by having
two directed edges per undirected edge.
</p>
<dl compact="compact">
<dt> <code>undgraph_new(+<var>Graph</var>)</code></dt>
<dd><a name="IDX1730"></a>
<a name="IDX1731"></a>
<a name="IDX1732"></a>
<p>Create a new directed graph. This operation must be performed before
trying to use the graph.
</p>
</dd>
<dt> <code>undgraph_vertices(+<var>Graph</var>, -<var>Vertices</var>)</code></dt>
<dd><a name="IDX1733"></a>
<a name="IDX1734"></a>
<a name="IDX1735"></a>
<p>Unify <var>Vertices</var> with all vertices appearing in graph
<var>Graph</var>.
</p>
</dd>
<dt> <code>undgraph_edges(+<var>Graph</var>, -<var>Edges</var>)</code></dt>
<dd><a name="IDX1736"></a>
<a name="IDX1737"></a>
<a name="IDX1738"></a>
<p>Unify <var>Edges</var> with all edges appearing in graph
<var>Graph</var>.
</p>
</dd>
<dt> <code>undgraph_add_vertices(+<var>Graph</var>, +<var>Vertices</var>, -<var>NewGraph</var>)</code></dt>
<dd><a name="IDX1739"></a>
<a name="IDX1740"></a>
<a name="IDX1741"></a>
<p>Unify <var>NewGraph</var> with a new graph obtained by adding the list of
vertices <var>Vertices</var> to the graph <var>Graph</var>.
</p>
</dd>
<dt> <code>undgraph_del_vertices(+<var>Vertices</var>, +<var>Graph</var>, -<var>NewGraph</var>)</code></dt>
<dd><a name="IDX1742"></a>
<a name="IDX1743"></a>
<a name="IDX1744"></a>
<p>Unify <var>NewGraph</var> with a new graph obtained by deleting the list of
vertices <var>Vertices</var> and all the edges that start from or go to a
vertex in <var>Vertices</var> to the graph <var>Graph</var>.
</p>
</dd>
<dt> <code>undgraph_add_edges(+<var>Graph</var>, +<var>Edges</var>, -<var>NewGraph</var>)</code></dt>
<dd><a name="IDX1745"></a>
<a name="IDX1746"></a>
<a name="IDX1747"></a>
<p>Unify <var>NewGraph</var> with a new graph obtained by adding the list of
edges <var>Edges</var> to the graph <var>Graph</var>.
</p>
</dd>
<dt> <code>undgraph_del_edges(+<var>Graph</var>, +<var>Edges</var>, -<var>NewGraph</var>)</code></dt>
<dd><a name="IDX1748"></a>
<a name="IDX1749"></a>
<a name="IDX1750"></a>
<p>Unify <var>NewGraph</var> with a new graph obtained by removing the list of
edges <var>Edges</var> from the graph <var>Graph</var>. Notice that no vertices
are deleted.
</p>
</dd>
<dt> <code>undgraph_neighbors(+<var>Vertex</var>, +<var>Graph</var>, -<var>Vertices</var>)</code></dt>
<dd><a name="IDX1751"></a>
<a name="IDX1752"></a>
<a name="IDX1753"></a>
<p>Unify <var>Vertices</var> with the list of neighbors of vertex <var>Vertex</var>
in <var>Graph</var>. If the vertice is not in the graph fail.
</p>
</dd>
<dt> <code>undgraph_neighbours(+<var>Vertex</var>, +<var>Graph</var>, -<var>Vertices</var>)</code></dt>
<dd><a name="IDX1754"></a>
<a name="IDX1755"></a>
<a name="IDX1756"></a>
<p>Unify <var>Vertices</var> with the list of neighbours of vertex <var>Vertex</var>
in <var>Graph</var>.
</p>
</dd>
<dt> <code>undgraph_complement(+<var>Graph</var>, -<var>NewGraph</var>)</code></dt>
<dd><a name="IDX1757"></a>
<a name="IDX1758"></a>
<a name="IDX1759"></a>
<p>Unify <var>NewGraph</var> with the graph complementary to <var>Graph</var>.
</p></dd>
</dl>
<hr size="6">
<a name="SWI_002dProlog"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC82" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC84" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC61" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC90" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<table class="menu" border="0" cellspacing="0">
SWI-Prolog Emulation
<p>Subnodes of SWI-Prolog
<a href="#SEC84">8.1 Invoking Predicates on all Members of a List</a> maplist and friends
<a href="#SEC85">8.2 Forall</a> forall built-in
<a href="#SEC86">8.3 hProlog and SWI-Prolog Attributed Variables</a> Emulating SWI-like attributed variables
<a href="#SEC88">8.4 SWI Global variables</a> Emulating SWI-like attributed variables
</p></table>
<a name="SEC83"></a>
<h1 class="chapter"> 8. SWI-Prolog Emulation </h1>
<p>This library provides a number of SWI-Prolog builtins that are not by
default in YAP. This library is loaded with the
<code>use_module(library(swi))</code> command.
</p>
<dl compact="compact">
<dt> <code>append(?<var>List1</var>,?<var>List2</var>,?<var>List3</var>)</code></dt>
<dd><a name="IDX1760"></a>
<a name="IDX1761"></a>
<a name="IDX1762"></a>
<p>Succeeds when <var>List3</var> unifies with the concatenation of <var>List1</var>
and <var>List2</var>. The predicate can be used with any instantiation
pattern (even three variables).
</p>
</dd>
<dt> <code>between(+<var>Low</var>,+<var>High</var>,?<var>Value</var>)</code></dt>
<dd><a name="IDX1763"></a>
<a name="IDX1764"></a>
<a name="IDX1765"></a>
<p><var>Low</var> and <var>High</var> are integers, <var>High</var> less or equal than
<var>Low</var>. If <var>Value</var> is an integer, <var>Low</var> less or equal than
<var>Value</var> less or equal than <var>High</var>. When <var>Value</var> is a
variable it is successively bound to all integers between <var>Low</var> and
<var>High</var>. If <var>High</var> is <code>inf</code>, <code>between/3</code> is true iff
<var>Value</var> less or equal than <var>Low</var>, a feature that is particularly
interesting for generating integers from a certain value.
</p>
</dd>
<dt> <code>chdir(+<var>Dir</var>)</code></dt>
<dd><a name="IDX1766"></a>
<a name="IDX1767"></a>
<a name="IDX1768"></a>
<p>Compatibility predicate. New code should use <code>working_directory/2</code>.
</p>
</dd>
<dt> <code>concat_atom(+<var>List</var>,-<var>Atom</var>)</code></dt>
<dd><a name="IDX1769"></a>
<a name="IDX1770"></a>
<a name="IDX1771"></a>
<p><var>List</var> is a list of atoms, integers or floating point numbers. Succeeds
if <var>Atom</var> can be unified with the concatenated elements of <var>List</var>. If
<var>List</var> has exactly 2 elements it is equivalent to <code>atom_concat/3</code>,
allowing for variables in the list.
</p>
</dd>
<dt> <code>concat_atom(?<var>List</var>,+<var>Separator</var>,?<var>Atom</var>)</code></dt>
<dd><a name="IDX1772"></a>
<a name="IDX1773"></a>
<a name="IDX1774"></a>
<p>Creates an atom just like concat_atom/2, but inserts <var>Separator</var>
between each pair of atoms. For example:
\</p><table><tr><td> </td><td><pre class="example">?- concat_atom([gnu, gnat], ', ', A).
A = 'gnu, gnat'
</pre></td></tr></table>
<p>(Unimplemented) This predicate can also be used to split atoms by
instantiating <var>Separator</var> and <var>Atom</var>:
</p>
<table><tr><td> </td><td><pre class="example">?- concat_atom(L, -, 'gnu-gnat').
L = [gnu, gnat]
</pre></td></tr></table>
</dd>
<dt> <code>nth1(+<var>Index</var>,?<var>List</var>,?<var>Elem</var>)</code></dt>
<dd><a name="IDX1775"></a>
<a name="IDX1776"></a>
<a name="IDX1777"></a>
<p>Succeeds when the <var>Index</var>-th element of <var>List</var> unifies with
<var>Elem</var>. Counting starts at 1.
</p>
<p>Set environment variable. <var>Name</var> and <var>Value</var> should be
instantiated to atoms or integers. The environment variable will be
passed to <code>shell/[0-2]</code> and can be requested using <code>getenv/2</code>.
They also influence <code>expand_file_name/2</code>.
</p>
</dd>
<dt> <code>setenv(+<var>Name</var>,+<var>Value</var>)</code></dt>
<dd><a name="IDX1778"></a>
<a name="IDX1779"></a>
<a name="IDX1780"></a>
<p>Set environment variable. <var>Name</var> and <var>Value</var> should be
instantiated to atoms or integers. The environment variable will be
passed to <code>shell/[0-2]</code> and can be requested using <code>getenv/2</code>.
They also influence <code>expand_file_name/2</code>.
</p>
</dd>
<dt> <code>term_to_atom(?<var>Term</var>,?<var>Atom</var>)</code></dt>
<dd><a name="IDX1781"></a>
<a name="IDX1782"></a>
<a name="IDX1783"></a>
<p>Succeeds if <var>Atom</var> describes a term that unifies with <var>Term</var>. When
<var>Atom</var> is instantiated <var>Atom</var> is converted and then unified with
<var>Term</var>. If <var>Atom</var> has no valid syntax, a <code>syntax_error</code>
exception is raised. Otherwise <var>Term</var> is "written" on <var>Atom</var>
using <code>write/1</code>.
</p>
</dd>
<dt> <code>working_directory(-<var>Old</var>,+<var>New</var>)</code></dt>
<dd><a name="IDX1784"></a>
<a name="IDX1785"></a>
<a name="IDX1786"></a>
<p>Unify <var>Old</var> with an absolute path to the current working directory
and change working directory to <var>New</var>. Use the pattern
<code>working_directory(CWD, CWD)</code> to get the current directory. See
also <code>absolute_file_name/2</code> and <code>chdir/1</code>.
</p>
</dd>
</dl>
<hr size="6">
<a name="Invoking-Predicates-on-all-Members-of-a-List"></a>
<a name="SEC84"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC83" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC85" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC83" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC83" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC90" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 8.1 Invoking Predicates on all Members of a List </h2>
<p>All the predicates in this section call a predicate on all members of a
list or until the predicate called fails. The predicate is called via
<code>call/[2..]</code>, which implies common arguments can be put in
front of the arguments obtained from the list(s). For example:
</p>
<table><tr><td> </td><td><pre class="example">?- maplist(plus(1), [0, 1, 2], X).
X = [1, 2, 3]
</pre></td></tr></table>
<p>we will phrase this as "<var>Predicate</var> is applied on ..."
</p>
<dl compact="compact">
<dt> <code>maplist(+<var>Pred</var>,+<var>List</var>)</code></dt>
<dd><a name="IDX1787"></a>
<a name="IDX1788"></a>
<a name="IDX1789"></a>
<p><var>Pred</var> is applied successively on each element of <var>List</var> until
the end of the list or <var>Pred</var> fails. In the latter case
<code>maplist/2</code> fails.
</p>
</dd>
<dt> <code>maplist(+<var>Pred</var>,+<var>List1</var>,+<var>List2</var>)</code></dt>
<dd><a name="IDX1790"></a>
<a name="IDX1791"></a>
<a name="IDX1792"></a>
<p>Apply <var>Pred</var> on all successive triples of elements from
<var>List1</var> and
<var>List2</var>. Fails if <var>Pred</var> can not be applied to a
pair. See the example above.
</p>
</dd>
<dt> <code>maplist(+<var>Pred</var>,+<var>List1</var>,+<var>List2</var>,+<var>List4</var>)</code></dt>
<dd><a name="IDX1793"></a>
<a name="IDX1794"></a>
<a name="IDX1795"></a>
<p>Apply <var>Pred</var> on all successive triples of elements from <var>List1</var>,
<var>List2</var> and <var>List3</var>. Fails if <var>Pred</var> can not be applied to a
triple. See the example above.
</p>
</dd>
</dl>
<hr size="6">
<a name="Forall"></a>
<a name="SEC85"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC84" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC86" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC83" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC83" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC90" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 8.2 Forall </h2>
<dl compact="compact">
<dt> <code>forall(+<var>Cond</var>,+<var>Action</var>)</code></dt>
<dd><a name="IDX1796"></a>
<a name="IDX1797"></a>
<a name="IDX1798"></a>
<p>For all alternative bindings of <var>Cond</var> <var>Action</var> can be proven.
The next example verifies that all arithmetic statements in the list
<var>L</var> are correct. It does not say which is wrong if one proves wrong.
</p>
<table><tr><td> </td><td><pre class="example">?- forall(member(Result = Formula, [2 = 1 + 1, 4 = 2 * 2]),
Result =:= Formula).
</pre></td></tr></table>
</dd>
</dl>
<hr size="6">
<a name="hProlog-and-SWI_002dProlog-Attributed-Variables"></a>
<a name="SEC86"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC85" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC87" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC83" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC83" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC90" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 8.3 hProlog and SWI-Prolog Attributed Variables </h2>
<p>Attributed variables
provide a technique for extending the
Prolog unification algorithm by hooking the binding of attributed
variables. There is little consensus in the Prolog community on the
exact definition and interface to attributed variables. Yap Prolog
traditionally implements a SICStus-like interface, but to enable
SWI-compatibility we have implemented the SWI-Prolog interface,
identical to the one realised by Bart Demoen for hProlog.
</p>
<p>Binding an attributed variable schedules a goal to be executed at the
first possible opportunity. In the current implementation the hooks are
executed immediately after a successful unification of the clause-head
or successful completion of a foreign language (builtin) predicate. Each
attribute is associated to a module and the hook (attr_unify_hook/2) is
executed in this module. The example below realises a very simple and
incomplete finite domain reasoner.
</p>
<table><tr><td> </td><td><pre class="example">:- module(domain,
[ domain/2 % Var, ?Domain
]).
:- use_module(library(oset)).
domain(X, Dom) :-
var(Dom), !,
get_attr(X, domain, Dom).
domain(X, List) :-
sort(List, Domain),
put_attr(Y, domain, Domain),
X = Y.
% An attributed variable with attribute value Domain has been
% assigned the value Y
attr_unify_hook(Domain, Y) :-
( get_attr(Y, domain, Dom2)
-> oset_int(Domain, Dom2, NewDomain),
( NewDomain == []
-> fail
; NewDomain = [Value]
-> Y = Value
; put_attr(Y, domain, NewDomain)
)
; var(Y)
-> put_attr( Y, domain, Domain )
; memberchk(Y, Domain)
).
</pre></td></tr></table>
<p>Before explaining the code we give some example queries:
</p>
<dl compact="compact">
<dt> <code>?- domain(X, [a,b]), X = c</code> </dt>
<dd><p>no
</p></dd>
<dt> <code>?- domain(X, [a,b]), domain(X, [a,c]).</code> </dt>
<dd><p> X = a
</p></dd>
<dt> <code>?- domain(X, [a,b,c]), domain(X, [a,c]).</code> </dt>
<dd><p> X = _D0
</p></dd>
</dl>
<p>The predicate <code>domain/2</code> fetches (first clause) or assigns
(second clause) the variable a <em>domain</em>, a set of values it can
be unified with. In the second clause first associates the domain
with a fresh variable and then unifies X to this variable to deal
with the possibility that X already has a domain. The
predicate <code>attr_unify_hook/2</code> is a hook called after a variable with
a domain is assigned a value. In the simple case where the variable
is bound to a concrete value we simply check whether this value is in
the domain. Otherwise we take the intersection of the domains and either
fail if the intersection is empty (first example), simply assign the
value if there is only one value in the intersection (second example) or
assign the intersection as the new domain of the variable (third
example).
</p>
<dl compact="compact">
<dt> <code>put_attr(+<var>Var</var>,+<var>Module</var>,+<var>Value</var>)</code></dt>
<dd><a name="IDX1799"></a>
<a name="IDX1800"></a>
<a name="IDX1801"></a>
<p>If <var>Var</var> is a variable or attributed variable, set the value for the
attribute named <var>Module</var> to <var>Value</var>. If an attribute with this
name is already associated with <var>Var</var>, the old value is replaced.
Backtracking will restore the old value (i.e. an attribute is a mutable
term. See also <code>setarg/3</code>). This predicate raises a type error if
<var>Var</var> is not a variable or <var>Module</var> is not an atom.
</p>
</dd>
<dt> <code>get_attr(+<var>Var</var>,+<var>Module</var>,+<var>Value</var>)</code></dt>
<dd><a name="IDX1802"></a>
<a name="IDX1803"></a>
<a name="IDX1804"></a>
<p>Request the current <var>value</var> for the attribute named <var>Module</var>. If
<var>Var</var> is not an attributed variable or the named attribute is not
associated to <var>Var</var> this predicate fails silently. If <var>Module</var>
is not an atom, a type error is raised.
</p>
</dd>
<dt> <code>del_attr(+<var>Var</var>,+<var>Module</var>)</code></dt>
<dd><a name="IDX1805"></a>
<a name="IDX1806"></a>
<a name="IDX1807"></a>
<p>Delete the named attribute. If <var>Var</var> loses its last attribute it
is transformed back into a traditional Prolog variable. If <var>Module</var>
is not an atom, a type error is raised. In all other cases this
predicate succeeds regarless whether or not the named attribute is
present.
</p>
</dd>
<dt> <code>attr_unify_hook(+<var>AttValue</var>,+<var>VarValue</var>)</code></dt>
<dd><a name="IDX1808"></a>
<a name="IDX1809"></a>
<a name="IDX1810"></a>
<p>Hook that must be defined in the module an attributed variable refers
to. Is is called <em>after</em> the attributed variable has been
unified with a non-var term, possibly another attributed variable.
<var>AttValue</var> is the attribute that was associated to the variable
in this module and <var>VarValue</var> is the new value of the variable.
Normally this predicate fails to veto binding the variable to
<var>VarValue</var>, forcing backtracking to undo the binding. If
<var>VarValue</var> is another attributed variable the hook often combines
the two attribute and associates the combined attribute with
<var>VarValue</var> using <code>put_attr/3</code>.
</p>
</dd>
</dl>
<hr size="6">
<a name="SEC87"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC86" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC88" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC83" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC86" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC90" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 8.3.1 Special Purpose SWI Predicates for Attributes </h3>
<p>Normal user code should deal with <code>put_attr/3</code>, <code>get_attr/3</code>
and <code>del_attr/2</code>. The routines in this section fetch or set the
entire attribute list of a variables. Use of these predicates is
anticipated to be restricted to printing and other special purpose
operations.
</p>
<dl compact="compact">
<dt> <code>get_attrs(+<var>Var</var>,-<var>Attributes</var>)</code></dt>
<dd><a name="IDX1811"></a>
<a name="IDX1812"></a>
<a name="IDX1813"></a>
<p>Get all attributes of <var>Var</var>. <var>Attributes</var> is a term of the form
<code>att(Module, Value, MoreAttributes)</code>, where <var>MoreAttributes</var> is
<code>[]</code> for the last attribute.
</p>
</dd>
<dt> <code>put_attrs(+<var>Var</var>,+<var>Attributes</var>)</code></dt>
<dd><a name="IDX1814"></a>
<a name="IDX1815"></a>
<a name="IDX1816"></a>
<p>Set all attributes of <var>Var</var>. See get_attrs/2 for a description of
<var>Attributes</var>.
</p>
</dd>
<dt> <code>copy_term_nat(?<var>TI</var>,-<var>TF</var>)</code></dt>
<dd><a name="IDX1817"></a>
<a name="IDX1818"></a>
<a name="IDX1819"></a>
<p>As <code>copy_term/2</code>. Attributes however, are <em>not</em> copied but replaced
by fresh variables.
</p></dd>
</dl>
<hr size="6">
<a name="SWI_002dProlog-Global-Variables"></a>
<a name="SEC88"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC87" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC89" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC83" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC83" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC90" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 8.4 SWI Global variables </h2>
<p>SWI-Prolog global variables are associations between names (atoms) and
terms. They differ in various ways from storing information using
<code>assert/1</code> or <code>recorda/3</code>.
</p>
<ul>
<li> The value lives on the Prolog (global) stack. This implies
that lookup time is independent from the size of the term.
This is particulary interesting for large data structures
such as parsed XML documents or the CHR global constraint
store.
</li><li> They support both global assignment using <code>nb_setval/2</code> and
backtrackable assignment using <code>b_setval/2</code>.
</li><li> Only one value (which can be an arbitrary complex Prolog
term) can be associated to a variable at a time.
</li><li> Their value cannot be shared among threads. Each thread
has its own namespace and values for global variables.
</li><li> Currently global variables are scoped globally. We may
consider module scoping in future versions.
</li></ul>
<p>Both <code>b_setval/2</code> and <code>nb_setval/2</code> implicitely create a variable if the
referenced name does not already refer to a variable.
</p>
<p>Global variables may be initialised from directives to make them
available during the program lifetime, but some considerations are
necessary for saved-states and threads. Saved-states to not store global
variables, which implies they have to be declared with <code>initialization/1</code>
to recreate them after loading the saved state. Each thread has
its own set of global variables, starting with an empty set. Using
<code>thread_inititialization/1</code> to define a global variable it will be
defined, restored after reloading a saved state and created in all
threads that are created <em>after</em> the registration.
</p>
<dl compact="compact">
<dt> <code>b_setval(+<var>Name</var>,+<var>Value</var>)</code></dt>
<dd><a name="IDX1820"></a>
<a name="IDX1821"></a>
<a name="IDX1822"></a>
<p>Associate the term <var>Value</var> with the atom <var>Name</var> or replaces
the currently associated value with <var>Value</var>. If <var>Name</var> does
not refer to an existing global variable a variable with initial value
<code>[]</code> is created (the empty list). On backtracking the
assignment is reversed.
</p>
</dd>
<dt> <code>b_getval(+<var>Name</var>,-<var>Value</var>)</code></dt>
<dd><a name="IDX1823"></a>
<a name="IDX1824"></a>
<a name="IDX1825"></a>
<p>Get the value associated with the global variable <var>Name</var> and unify
it with <var>Value</var>. Note that this unification may further instantiate
the value of the global variable. If this is undesirable the normal
precautions (double negation or <code>copy_term/2</code>) must be taken. The
<code>b_getval/2</code> predicate generates errors if <var>Name</var> is not an atom or
the requested variable does not exist.
</p></dd>
</dl>
<dl compact="compact">
<dt> <code>nb_setval(+<var>Name</var>,+<var>Value</var>)</code></dt>
<dd><a name="IDX1826"></a>
<a name="IDX1827"></a>
<a name="IDX1828"></a>
<p>Associates a copy of <var>Value</var> created with <code>duplicate_term/2</code>
with the atom <var>Name</var>. Note that this can be used to set an
initial value other than <code>[]</code> prior to backtrackable assignment.
</p>
</dd>
<dt> <code>nb_getval(+<var>Name</var>,-<var>Value</var>)</code></dt>
<dd><a name="IDX1829"></a>
<a name="IDX1830"></a>
<a name="IDX1831"></a>
<p>The <code>nb_getval/2</code> predicate is a synonym for b_getval/2, introduced for
compatibility and symetry. As most scenarios will use a particular
global variable either using non-backtracable or backtrackable
assignment, using <code>nb_getval/2</code> can be used to document that the
variable is used non-backtracable.
</p>
</dd>
<dt> <code>nb_current(?<var>Name</var>,?<var>Value</var>)</code></dt>
<dd><a name="IDX1832"></a>
<a name="IDX1833"></a>
<a name="IDX1834"></a>
<p>Enumerate all defined variables with their value. The order of
enumeration is undefined.
</p>
</dd>
<dt> <code>nb_delete(?<var>Name</var>)</code></dt>
<dd><a name="IDX1835"></a>
<a name="IDX1836"></a>
<a name="IDX1837"></a>
<p>Delete the named global variable.
</p></dd>
</dl>
<hr size="6">
<a name="SEC89"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC88" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC90" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC83" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC88" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC90" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 8.4.1 Compatibility of SWI-Prolog Global Variables </h3>
<p>Global variables have been introduced by various Prolog
implementations recently. The implementation of them in SWI-Prolog is
based on hProlog by Bart Demoen. In discussion with Bart it was
decided that the semantics if hProlog <code>nb_setval/2</code>, which is
equivalent to <code>nb_linkval/2</code> is not acceptable for normal Prolog
users as the behaviour is influenced by how builtin predicates
constructing terms (<code>read/1</code>, <code>=../2</code>, etc.) are implemented.
</p>
<p>GNU-Prolog provides a rich set of global variables, including arrays.
Arrays can be implemented easily in SWI-Prolog using <code>functor/3</code> and
<code>setarg/3</code> due to the unrestricted arity of compound terms.
</p>
<hr size="6">
<a name="Extensions"></a>
<a name="SEC90"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC89" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC91" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC83" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC93" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 9. Extensions to Prolog </h1>
<p>YAP includes several extensions that are not enabled by
default, but that can be used to extend the functionality of the
system. These options can be set at compilation time by enabling the
related compilation flag, as explained in the <code>Makefile</code>
</p>
<table class="menu" border="0" cellspacing="0">
<p>Extensions to Traditional Prolog
</p>
<tr><td align="left" valign="top"><a href="#SEC91">9.1 Rational Trees</a></td><td> </td><td align="left" valign="top"> Working with Rational Trees
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC92">9.2 Coroutining</a></td><td> </td><td align="left" valign="top"> Changing the Execution of Goals
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC93">10. Attributed Variables</a></td><td> </td><td align="left" valign="top"> Using attributed Variables
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC100">11. Constraint Logic Programming over Reals</a></td><td> </td><td align="left" valign="top"> The CLP(R) System
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC125">13. Logtalk</a></td><td> </td><td align="left" valign="top"> The Logtalk Object-Oriented system
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC126">14. Threads</a></td><td> </td><td align="left" valign="top"> Thread Library
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC134">15. Parallelism</a></td><td> </td><td align="left" valign="top"> Running in Or-Parallel
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC135">16. Tabling</a></td><td> </td><td align="left" valign="top"> Storing Intermediate Solutions of programs
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC137">18. Profiling the Abstract Machine</a></td><td> </td><td align="left" valign="top"> Profiling Abstract Machine Instructions
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC136">17. Tracing at Low Level</a></td><td> </td><td align="left" valign="top"> Tracing at Abstract Machine Level
</td></tr>
</table>
<hr size="6">
<a name="Rational-Trees"></a>
<a name="SEC91"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC90" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC92" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC90" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC90" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC93" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 9.1 Rational Trees </h2>
<p>Prolog unification is not a complete implementation. For efficiency
considerations, Prolog systems do not perform occur checks while
unifying terms. As an example, <code>X = a(X)</code> will not fail but instead
will create an infinite term of the form <code>a(a(a(a(a(...)))))</code>, or
<em>rational tree</em>.
</p>
<p>Rational trees are no supported by default in YAP. In previous
versions, this was not the default and these terms could easily lead
to infinite computation. For example, <code>X = a(X), X = X</code> would
enter an infinite loop.
</p>
<p>The <code>RATIONAL_TREES</code> flag improves support for these
terms. Internal primitives are now aware that these terms can exist, and
will not enter infinite loops. Hence, the previous unification will
succeed. Another example, <code>X = a(X), ground(X)</code> will succeed
instead of looping. Other affected built-ins include the term comparison
primitives, <code>numbervars/3</code>, <code>copy_term/2</code>, and the internal
data base routines. The support does not extend to Input/Output routines
or to <code>assert/1</code> YAP does not allow directly reading
rational trees, and you need to use <code>write_depth/2</code> to avoid
entering an infinite cycle when trying to write an infinite term.
</p>
<hr size="6">
<a name="Coroutining"></a>
<a name="SEC92"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC91" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC93" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC90" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC90" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC93" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 9.2 Coroutining </h2>
<p>Prolog uses a simple left-to-right flow of control. It is sometimes
convenient to change this control so that goals will only be executed
when conditions are fulfilled. This may result in a more "data-driven"
execution, or may be necessary to correctly implement extensions such as
negation by default.
</p>
<p>The <code>COROUTINING</code> flag enables this option. Note that the support for
coroutining will in general slow down execution.
</p>
<p>The following declaration is supported:
</p>
<dl compact="compact">
<dt> <code>block/1</code></dt>
<dd><p>The argument to <code>block/1</code> is a condition on a goal or a conjunction
of conditions, with each element separated by commas. Each condition is
of the form <code>predname(<var>C1</var>,...,<var>CN</var>)</code>, where <var>N</var> is the
arity of the goal, and each <var>CI</var> is of the form <code>-</code>, if the
argument must suspend until the variable is bound, or <code>?</code>, otherwise.
</p>
</dd>
<dt> <code>wait/1</code></dt>
<dd><p>The argument to <code>wait/1</code> is a predicate descriptor or a conjunction
of these predicates. These predicates will suspend until their first
argument is bound.
</p></dd>
</dl>
<p>The following primitives are supported:
</p>
<dl compact="compact">
<dt> <code>dif(<var>X</var>,<var>Y</var>)</code></dt>
<dd><a name="IDX1838"></a>
<a name="IDX1839"></a>
<a name="IDX1840"></a>
<p>Succeed if the two arguments do not unify. A call to <code>dif/2</code> will
suspend if unification may still succeed or fail, and will fail if they
always unify.
</p>
</dd>
<dt> <code>freeze(?<var>X</var>,:<var>G</var>)</code></dt>
<dd><a name="IDX1841"></a>
<a name="IDX1842"></a>
<a name="IDX1843"></a>
<p>Delay execution of goal <var>G</var> until the variable <var>X</var> is bound.
</p>
</dd>
<dt> <code>frozen(<var>X</var>,<var>G</var>)</code></dt>
<dd><a name="IDX1844"></a>
<a name="IDX1845"></a>
<a name="IDX1846"></a>
<p>Unify <var>G</var> with a conjunction of goals suspended on variable <var>X</var>,
or <code>true</code> if no goal has suspended.
</p>
</dd>
<dt> <code>when(+<var>C</var>,:<var>G</var>)</code></dt>
<dd><a name="IDX1847"></a>
<a name="IDX1848"></a>
<a name="IDX1849"></a>
<p>Delay execution of goal <var>G</var> until the conditions <var>C</var> are
satisfied. The conditions are of the following form:
</p>
<dl compact="compact">
<dt> <code><var>C1</var>,<var>C2</var></code></dt>
<dd><p>Delay until both conditions <var>C1</var> and <var>C2</var> are satisfied.
</p></dd>
<dt> <code><var>C1</var>;<var>C2</var></code></dt>
<dd><p>Delay until either condition <var>C1</var> or condition <var>C2</var> is satisfied.
</p></dd>
<dt> <code>?=(<var>V1</var>,<var>C2</var>)</code></dt>
<dd><p>Delay until terms <var>V1</var> and <var>V1</var> have been unified.
</p></dd>
<dt> <code>nonvar(<var>V</var>)</code></dt>
<dd><p>Delay until variable <var>V</var> is bound.
</p></dd>
<dt> <code>ground(<var>V</var>)</code></dt>
<dd><p>Delay until variable <var>V</var> is ground.
</p></dd>
</dl>
<p>Note that <code>when/2</code> will fail if the conditions fail.
</p>
</dd>
<dt> <code>call_residue(:<var>G</var>,<var>L</var>)</code></dt>
<dd><a name="IDX1850"></a>
<a name="IDX1851"></a>
<a name="IDX1852"></a>
<p>Call goal <var>G</var>. If subgoals of <var>G</var> are still blocked, return
a list containing these goals and the variables they are blocked in. The
goals are then considered as unblocked. The next example shows a case
where <code>dif/2</code> suspends twice, once outside <code>call_residue/2</code>,
and the other inside:
</p>
<table><tr><td> </td><td><pre class="example">?- dif(X,Y),
call_residue((dif(X,Y),(X = f(Z) ; Y = f(Z))), L).
X = f(Z),
L = [[Y]-dif(f(Z),Y)],
dif(f(Z),Y) ? ;
Y = f(Z),
L = [[X]-dif(X,f(Z))],
dif(X,f(Z)) ? ;
no
</pre></td></tr></table><p>The system only reports one invocation of <code>dif/2</code> as having
suspended.
</p>
</dd>
</dl>
<hr size="6">
<a name="Attributed-Variables"></a>
<a name="SEC93"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC92" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC94" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC90" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC100" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 10. Attributed Variables </h1>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC94">10.1 Attribute Declarations</a></td><td> </td><td align="left" valign="top"> Declaring New Attributes
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC95">10.2 Attribute Manipulation</a></td><td> </td><td align="left" valign="top"> Setting and Reading Attributes
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC96">10.3 Attributed Unification</a></td><td> </td><td align="left" valign="top"> Tuning the Unification Algorithm
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC97">10.4 Displaying Attributes</a></td><td> </td><td align="left" valign="top"> Displaying Attributes in User-Readable Form
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC98">10.5 Projecting Attributes</a></td><td> </td><td align="left" valign="top"> Obtaining the Attributes of Interest
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC99">10.6 Attribute Examples</a></td><td> </td><td align="left" valign="top"> Two Simple Examples of how to use Attributes.
</td></tr>
</table>
<p>YAP now supports the attributed variables packaged developed at OFAI by
Christian Holzbaur. Attributes are a means of declaring that an
arbitrary term is a property for a variable. These properties can be
updated during forward execution. Moreover, the unification algorithm is
aware of attributed variables and will call user defined handlers when
trying to unify these variables.
</p>
<p>Attributed variables provide an elegant abstraction over which one can
extend Prolog systems. Their main application so far has been in
implementing constraint handlers, such as Holzbaur's CLPQR and Fruewirth
and Holzbaur's CHR, but other applications have been proposed in the
literature.
</p>
<p>The command
</p><table><tr><td> </td><td><pre class="example">| ?- use_module(library(atts)).
</pre></td></tr></table><p>enables the use of attributed variables. The package provides the
following functionality:
</p><ul>
<li> Each attribute must be declared first. Attributes are described by a functor
and are declared per module. Each Prolog module declares its own sets of
attributes. Different modules may have different functors with the same
module.
</li><li> The built-in <code>put_atts/2</code> adds or deletes attributes to a
variable. The variable may be unbound or may be an attributed
variable. In the latter case, YAP discards previous values for the
attributes.
</li><li> The built-in <code>get_atts/2</code> can be used to check the values of
an attribute associated with a variable.
</li><li> The unification algorithm calls the user-defined predicate
<tt>verify_attributes/3</tt> before trying to bind an attributed
variable. Unification will resume after this call.
</li><li> The user-defined predicate
<tt>attribute_goal/2</tt> converts from an attribute to a goal.
</li><li> The user-defined predicate
<tt>project_attributes/2</tt> is used from a set of variables into a set of
constraints or goals. One application of <tt>project_attributes/2</tt> is in
the top-level, where it is used to output the set of
floundered constraints at the end of a query.
</li></ul>
<hr size="6">
<a name="Attribute-Declarations"></a>
<a name="SEC94"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC93" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC95" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC93" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC93" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC100" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 10.1 Attribute Declarations </h2>
<p>Attributes are compound terms associated with a variable. Each attribute
has a <em>name</em> which is <em>private</em> to the module in which the
attribute was defined. Variables may have at most one attribute with a
name. Attribute names are defined with the following declaration:
</p>
<a name="IDX1853"></a>
<a name="IDX1854"></a>
<a name="IDX1855"></a>
<table><tr><td> </td><td><pre class="example">:- attribute <var>AttributeSpec</var>, ..., <var>AttributeSpec</var>.
</pre></td></tr></table>
<p>where each <var>AttributeSpec</var> has the form (<var>Name</var>/<var>Arity</var>).
One single such declaration is allowed per module <var>Module</var>.
</p>
<p>Although the YAP module system is predicate based, attributes are local
to modules. This is implemented by rewriting all calls to the
built-ins that manipulate attributes so that attribute names are
preprocessed depending on the module. The <code>user:goal_expansion/3</code>
mechanism is used for this purpose.
</p>
<hr size="6">
<a name="Attribute-Manipulation"></a>
<a name="SEC95"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC94" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC96" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC93" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC93" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC100" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 10.2 Attribute Manipulation </h2>
<p>The attribute manipulation predicates always work as follows:
</p><ol>
<li> The first argument is the unbound variable associated with
attributes,
</li><li> The second argument is a list of attributes. Each attribute will
be a Prolog term or a constant, prefixed with the <tt>+</tt> and <tt>-</tt> unary
operators. The prefix <tt>+</tt> may be dropped for convenience.
</li></ol>
<p>The following three procedures are available to the user. Notice that
these built-ins are rewritten by the system into internal built-ins, and
that the rewriting process <em>depends</em> on the module on which the
built-ins have been invoked.
</p>
<dl compact="compact">
<dt> <code><var>Module</var>:get_atts(<var>-Var</var>,<var>?ListOfAttributes</var>)</code></dt>
<dd><a name="IDX1856"></a>
<a name="IDX1857"></a>
<a name="IDX1858"></a>
<p>Unify the list <var>?ListOfAttributes</var> with the attributes for the unbound
variable <var>Var</var>. Each member of the list must be a bound term of the
form <code>+(<var>Attribute</var>)</code>, <code>-(<var>Attribute</var>)</code> (the <tt>kbd</tt>
prefix may be dropped). The meaning of <tt>+</tt> and <tt>-</tt> is:
</p></dd>
<dt> <code>+(<var>Attribute</var>)</code></dt>
<dd><p>Unifies <var>Attribute</var> with a corresponding attribute associated with
<var>Var</var>, fails otherwise.
</p>
</dd>
<dt> <code>-(<var>Attribute</var>)</code></dt>
<dd><p>Succeeds if a corresponding attribute is not associated with
<var>Var</var>. The arguments of <var>Attribute</var> are ignored.
</p>
</dd>
<dt> <code><var>Module</var>:put_atts(<var>-Var</var>,<var>?ListOfAttributes</var>)</code></dt>
<dd><a name="IDX1859"></a>
<a name="IDX1860"></a>
<a name="IDX1861"></a>
<p>Associate with or remove attributes from a variable <var>Var</var>. The
attributes are given in <var>?ListOfAttributes</var>, and the action depends
on how they are prefixed:
</p></dd>
<dt> <code>+(<var>Attribute</var>)</code></dt>
<dd><p>Associate <var>Var</var> with <var>Attribute</var>. A previous value for the
attribute is simply replace (like with <code>set_mutable/2</code>).
</p>
</dd>
<dt> <code>-(<var>Attribute</var>)</code></dt>
<dd><p>Remove the attribute with the same name. If no such attribute existed,
simply succeed.
</p></dd>
</dl>
<hr size="6">
<a name="Attributed-Unification"></a>
<a name="SEC96"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC95" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC97" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC93" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC93" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC100" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 10.3 Attributed Unification </h2>
<p>The user-predicate predicate <code>verify_attributes/3</code> is called when
attempting to unify an attributed variable which might have attributes
in some <var>Module</var>.
</p>
<dl compact="compact">
<dt> <code><var>Module</var>:verify_attributes(<var>-Var</var>, <var>+Value</var>, <var>-Goals</var>)</code></dt>
<dd><a name="IDX1862"></a>
<a name="IDX1863"></a>
<a name="IDX1864"></a>
<p>The predicate is called when trying to unify the attributed variable
<var>Var</var> with the Prolog term <var>Value</var>. Note that <var>Value</var> may be
itself an attributed variable, or may contain attributed variables. The
goal <tt>verify_attributes/3</tt> is actually called before <var>Var</var> is
unified with <var>Value</var>.
</p>
<p>It is up to the user to define which actions may be performed by
<tt>verify_attributes/3</tt> but the procedure is expected to return in
<var>Goals</var> a list of goals to be called <em>after</em> <var>Var</var> is
unified with <var>Value</var>. If <tt>verify_attributes/3</tt> fails, the
unification will fail.
</p>
<p>Notice that the <tt>verify_attributes/3</tt> may be called even if <var>Var</var>
has no attributes in module <tt>Module</tt>. In this case the routine should
simply succeed with <var>Goals</var> unified with the empty list.
</p>
</dd>
<dt> <code>attvar(<var>-Var</var>)</code></dt>
<dd><a name="IDX1865"></a>
<a name="IDX1866"></a>
<a name="IDX1867"></a>
<p>Succeed if <var>Var</var> is an attributed variable.
</p></dd>
</dl>
<hr size="6">
<a name="Displaying-Attributes"></a>
<a name="SEC97"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC96" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC98" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC93" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC93" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC100" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 10.4 Displaying Attributes </h2>
<p>Attributes are usually presented as goals. The following routines are
used by built-in predicates such as <code>call_residue/2</code> and by the
Prolog top-level to display attributes:
</p>
<dl compact="compact">
<dt> <code><var>Module</var>:attribute_goal(<var>-Var</var>, <var>-Goal</var>)</code></dt>
<dd><a name="IDX1868"></a>
<a name="IDX1869"></a>
<a name="IDX1870"></a>
<p>User-defined procedure, called to convert the attributes in <var>Var</var> to
a <var>Goal</var>. Should fail when no interpretation is available.
</p>
</dd>
<dt> <code><var>Module</var>:project_attributes(<var>-QueryVars</var>, <var>+AttrVars</var>)</code></dt>
<dd><a name="IDX1871"></a>
<a name="IDX1872"></a>
<a name="IDX1873"></a>
<p>User-defined procedure, called to project the attributes in the query,
<var>AttrVars</var>, given that the set of variables in the query is
<var>QueryVars</var>.
</p>
</dd>
</dl>
<hr size="6">
<a name="Projecting-Attributes"></a>
<a name="SEC98"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC97" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC99" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC93" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC93" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC100" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 10.5 Projecting Attributes </h2>
<p>Constraint solvers must be able to project a set of constraints to a set
of variables. This is useful when displaying the solution to a goal, but
may also be used to manipulate computations. The user-defined
<code>project_attributes/2</code> is responsible for implementing this
projection.
</p>
<dl compact="compact">
<dt> <code><var>Module</var>:project_attributes(<var>+QueryVars</var>, <var>+AttrVars</var>)</code></dt>
<dd><a name="IDX1874"></a>
<a name="IDX1875"></a>
<a name="IDX1876"></a>
<p>Given a list of variables <var>QueryVars</var> and list of attributed
variables <var>AttrVars</var>, project all attributes in <var>AttrVars</var> to
<var>QueryVars</var>. Although projection is constraint system dependent,
typically this will involve expressing all constraints in terms of
<var>QueryVars</var> and considering all remaining variables as existentially
quantified.
</p></dd>
</dl>
<p>Projection interacts with <code>attribute_goal/2</code> at the prolog top
level. When the query succeeds, the system first calls
<code>project_attributes/2</code>. The system then calls
<code>attribute_goal/2</code> to get a user-level representation of the
constraints. Typically, <code>attribute_goal/2</code> will convert from the
original constraints into a set of new constraints on the projection,
and these constraints are the ones that will have an
<code>attribute_goal/2</code> handler.
</p>
<hr size="6">
<a name="Attribute-Examples"></a>
<a name="SEC99"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC98" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC100" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC93" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC93" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC100" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 10.6 Attribute Examples </h2>
<p>The following two examples example is taken from the SICStus Prolog manual. It
sketches the implementation of a simple finite domain "solver". Note
that an industrial strength solver would have to provide a wider range
of functionality and that it quite likely would utilize a more efficient
representation for the domains proper. The module exports a single
predicate <code>domain(<var>-Var</var>,<var>?Domain</var>)</code> which associates
<var>Domain</var> (a list of terms) with <var>Var</var>. A variable can be
queried for its domain by leaving <var>Domain</var> unbound.
</p>
<p>We do not present here a definition for <code>project_attributes/2</code>.
Projecting finite domain constraints happens to be difficult.
</p>
<table><tr><td> </td><td><pre class="example">:- module(domain, [domain/2]).
:- use_module(library(atts)).
:- use_module(library(ordsets), [
ord_intersection/3,
ord_intersect/2,
list_to_ord_set/2
]).
:- attribute dom/1.
verify_attributes(Var, Other, Goals) :-
get_atts(Var, dom(Da)), !, % are we involved?
( var(Other) -> % must be attributed then
( get_atts(Other, dom(Db)) -> % has a domain?
ord_intersection(Da, Db, Dc),
Dc = [El|Els], % at least one element
( Els = [] -> % exactly one element
Goals = [Other=El] % implied binding
; Goals = [],
put_atts(Other, dom(Dc))% rescue intersection
)
; Goals = [],
put_atts(Other, dom(Da)) % rescue the domain
)
; Goals = [],
ord_intersect([Other], Da) % value in domain?
).
verify_attributes(_, _, []). % unification triggered
% because of attributes
% in other modules
attribute_goal(Var, domain(Var,Dom)) :- % interpretation as goal
get_atts(Var, dom(Dom)).
domain(X, Dom) :-
var(Dom), !,
get_atts(X, dom(Dom)).
domain(X, List) :-
list_to_ord_set(List, Set),
Set = [El|Els], % at least one element
( Els = [] -> % exactly one element
X = El % implied binding
; put_atts(Fresh, dom(Set)),
X = Fresh % may call
% verify_attributes/3
).
</pre></td></tr></table>
<p>Note that the "implied binding" <code>Other=El</code> was deferred until after
the completion of <code>verify_attribute/3</code>. Otherwise, there might be a
danger of recursively invoking <code>verify_attribute/3</code>, which might bind
<code>Var</code>, which is not allowed inside the scope of <code>verify_attribute/3</code>.
Deferring unifications into the third argument of <code>verify_attribute/3</code>
effectively serializes the calls to <code>verify_attribute/3</code>.
</p>
<p>Assuming that the code resides in the file <tt>`domain.yap'</tt>, we
can use it via:
</p>
<table><tr><td> </td><td><pre class="example">| ?- use_module(domain).
</pre></td></tr></table>
<p>Let's test it:
</p>
<table><tr><td> </td><td><pre class="example">| ?- domain(X,[5,6,7,1]), domain(Y,[3,4,5,6]), domain(Z,[1,6,7,8]).
domain(X,[1,5,6,7]),
domain(Y,[3,4,5,6]),
domain(Z,[1,6,7,8]) ?
yes
| ?- domain(X,[5,6,7,1]), domain(Y,[3,4,5,6]), domain(Z,[1,6,7,8]),
X=Y.
Y = X,
domain(X,[5,6]),
domain(Z,[1,6,7,8]) ?
yes
| ?- domain(X,[5,6,7,1]), domain(Y,[3,4,5,6]), domain(Z,[1,6,7,8]),
X=Y, Y=Z.
X = 6,
Y = 6,
Z = 6
</pre></td></tr></table>
<p>To demonstrate the use of the <var>Goals</var> argument of
<code>verify_attributes/3</code>, we give an implementation of
<code>freeze/2</code>. We have to name it <code>myfreeze/2</code> in order to
avoid a name clash with the built-in predicate of the same name.
</p>
<table><tr><td> </td><td><pre class="example">:- module(myfreeze, [myfreeze/2]).
:- use_module(library(atts)).
:- attribute frozen/1.
verify_attributes(Var, Other, Goals) :-
get_atts(Var, frozen(Fa)), !, % are we involved?
( var(Other) -> % must be attributed then
( get_atts(Other, frozen(Fb)) % has a pending goal?
-> put_atts(Other, frozen((Fa,Fb))) % rescue conjunction
; put_atts(Other, frozen(Fa)) % rescue the pending goal
),
Goals = []
; Goals = [Fa]
).
verify_attributes(_, _, []).
attribute_goal(Var, Goal) :- % interpretation as goal
get_atts(Var, frozen(Goal)).
myfreeze(X, Goal) :-
put_atts(Fresh, frozen(Goal)),
Fresh = X.
</pre></td></tr></table>
<p>Assuming that this code lives in file <tt>`myfreeze.yap'</tt>,
we would use it via:
</p>
<table><tr><td> </td><td><pre class="example">| ?- use_module(myfreeze).
| ?- myfreeze(X,print(bound(x,X))), X=2.
bound(x,2) % side effect
X = 2 % bindings
</pre></td></tr></table>
<p>The two solvers even work together:
</p>
<table><tr><td> </td><td><pre class="example">| ?- myfreeze(X,print(bound(x,X))), domain(X,[1,2,3]),
domain(Y,[2,10]), X=Y.
bound(x,2) % side effect
X = 2, % bindings
Y = 2
</pre></td></tr></table>
<p>The two example solvers interact via bindings to shared attributed
variables only. More complicated interactions are likely to be found
in more sophisticated solvers. The corresponding
<code>verify_attributes/3</code> predicates would typically refer to the
attributes from other known solvers/modules via the module prefix in
<code><var>Module</var>:get_atts/2</code>.
</p>
<hr size="6">
<a name="CLPR"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC99" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC101" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC93" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC105" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC101">11.1 Solver Predicates</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC102">11.2 Syntax of the predicate arguments</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC103">11.3 Use of unification</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC104">11.4 Non-Linear Constraints</a></td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<a name="SEC100"></a>
<h1 class="chapter"> 11. Constraint Logic Programming over Reals </h1>
<p>YAP now uses the CLP(R) package developed by <em>Leslie De Koninck</em>,
K.U. Leuven as part of a thesis with supervisor Bart Demoen and daily
advisor Tom Schrijvers, and distributed with SWI-Prolog.
</p>
<p>This CLP(R) system is a port of the CLP(Q,R) system of Sicstus Prolog
and YAP by Christian Holzbaur: Holzbaur C.: OFAI clp(q,r) Manual,
Edition 1.3.3, Austrian Research Institute for Artificial
Intelligence, Vienna, TR-95-09, 1995,
<a href="http://www.ai.univie.ac.at/cgi-bin/tr-online?number+95-09">http://www.ai.univie.ac.at/cgi-bin/tr-online?number+95-09</a> This
port only contains the part concerning real arithmetics. This manual
is roughly based on the manual of the above mentioned <strong>CLP(QR)</strong>
implementation.
</p>
<p>Please note that the <tt>`clpr'</tt> library is <em>not</em> an
<code>autoload</code> library and therefore this library must be loaded
explicitely before using it:
</p>
<table><tr><td> </td><td><pre class="example">:- use_module(library(clpr)).
</pre></td></tr></table>
<hr size="6">
<a name="CLPR-Solver-Predicates"></a>
<a name="SEC101"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC100" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC102" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC100" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC100" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC105" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 11.1 Solver Predicates </h2>
<p>The following predicates are provided to work with constraints:
</p>
<dl compact="compact">
<dt> <code>{+<var>Constraints</var>}</code></dt>
<dd><p>Adds the constraints given by <var>Constraints</var> to the constraint store.
</p>
</dd>
<dt> <code>entailed(+<var>Constraint</var>)</code></dt>
<dd><p>Succeeds if <var>Constraint</var> is necessarily true within the current
constraint store. This means that adding the negation of the constraint
to the store results in failure.
</p>
</dd>
<dt> <code>inf(+<var>Expression</var>,-<var>Inf</var>)</code></dt>
<dd><p>Computes the infimum of <var>Expression</var> within the current state of the
constraint store and returns that infimum in <var>Inf</var>. This predicate
does not change the constraint store.
</p>
</dd>
<dt> <code>inf(+<var>Expression</var>,-<var>Sup</var>)</code></dt>
<dd><p>Computes the supremum of <var>Expression</var> within the current state of
the constraint store and returns that supremum in <var>Sup</var>. This
predicate does not change the constraint store.
</p>
</dd>
<dt> <code>min(+<var>Expression</var>)</code></dt>
<dd><p>Minimizes <var>Expression</var> within the current constraint store. This is
the same as computing the infimum and equation the expression to that
infimum.
</p>
</dd>
<dt> <code>max(+<var>Expression</var>)</code></dt>
<dd><p>Maximizes <var>Expression</var> within the current constraint store. This is
the same as computing the supremum and equating the expression to that
supremum.
</p>
</dd>
<dt> <code>bb_inf(+<var>Ints</var>,+<var>Expression</var>,-<var>Inf</var>,-<var>Vertext</var>,+<var>Eps</var>)</code></dt>
<dd><p>Computes the infimum of <var>Expression</var> within the current constraint
store, with the additional constraint that in that infimum, all
variables in <var>Ints</var> have integral values. <var>Vertex</var> will contain
the values of <var>Ints</var> in the infimum. <var>Eps</var> denotes how much a
value may differ from an integer to be considered an integer. E.g. when
<var>Eps</var> = 0.001, then X = 4.999 will be considered as an integer (5 in
this case). <var>Eps</var> should be between 0 and 0.5.
</p>
</dd>
<dt> <code>bb_inf(+<var>Ints</var>,+<var>Expression</var>,-<var>Inf</var>)</code></dt>
<dd><p>The same as bb_inf/5 but without returning the values of the integers
and with an eps of 0.001.
</p>
</dd>
<dt> <code>bb_inf(+<var>Target</var>,+<var>Newvars</var>,-<var>CodedAnswer</var>)</code></dt>
<dd><p>Returns the constraints on <var>Target</var> in the list <var>CodedAnswer</var>
where all variables of <var>Target</var> have veen replaced by <var>NewVars</var>.
This operation does not change the constraint store. E.g. in
</p>
<table><tr><td> </td><td><pre class="example">dump([X,Y,Z],[x,y,z],Cons)
</pre></td></tr></table>
<p><var>Cons</var> will contain the constraints on <var>X</var>, <var>Y</var> and
<var>Z</var> where these variables have been replaced by atoms <code>x</code>, <code>y</code> and <code>z</code>.
</p>
</dd>
</dl>
<hr size="6">
<a name="CLPR-Syntax"></a>
<a name="SEC102"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC101" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC103" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC100" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC100" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC105" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 11.2 Syntax of the predicate arguments </h2>
<p>The arguments of the predicates defined in the subsection above are
defined in the following table. Failing to meet the syntax rules will
result in an exception.
</p>
<table><tr><td> </td><td><pre class="example"><Constraints> ---> <Constraint> \\ single constraint \\
| <Constraint> , <Constraints> \\ conjunction \\
| <Constraint> ; <Constraints> \\ disjunction \\
<Constraint> ---> <Expression> {<} <Expression> \\ less than \\
| <Expression> {>} <Expression> \\ greater than \\
| <Expression> {=<} <Expression> \\ less or equal \\
| {<=}(<Expression>, <Expression>) \\ less or equal \\
| <Expression> {>=} <Expression> \\ greater or equal \\
| <Expression> {=\=} <Expression> \\ not equal \\
| <Expression> =:= <Expression> \\ equal \\
| <Expression> = <Expression> \\ equal \\
<Expression> ---> <Variable> \\ Prolog variable \\
| <Number> \\ Prolog number (float, integer) \\
| +<Expression> \\ unary plus \\
| -<Expression> \\ unary minus \\
| <Expression> + <Expression> \\ addition \\
| <Expression> - <Expression> \\ substraction \\
| <Expression> * <Expression> \\ multiplication \\
| <Expression> / <Expression> \\ division \\
| abs(<Expression>) \\ absolute value \\
| sin(<Expression>) \\ sine \\
| cos(<Expression>) \\ cosine \\
| tan(<Expression>) \\ tangent \\
| exp(<Expression>) \\ exponent \\
| pow(<Expression>) \\ exponent \\
| <Expression> {^} <Expression> \\ exponent \\
| min(<Expression>, <Expression>) \\ minimum \\
| max(<Expression>, <Expression>) \\ maximum \\
</pre></td></tr></table>
<hr size="6">
<a name="CLPR-Unification"></a>
<a name="SEC103"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC102" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC104" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC100" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC100" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC105" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 11.3 Use of unification </h2>
<p>Instead of using the <code>{}/1</code> predicate, you can also use the standard
unification mechanism to store constraints. The following code samples
are equivalent:
</p>
<dl compact="compact">
<dt> <samp>`Unification with a variable'</samp></dt>
<dd>
<table><tr><td> </td><td><pre class="example">{X =:= Y}
{X = Y}
X = Y
</pre></td></tr></table>
</dd>
<dt> <samp>`Unification with a number'</samp></dt>
<dd>
<table><tr><td> </td><td><pre class="example">{X =:= 5.0}
{X = 5.0}
X = 5.0
</pre></td></tr></table>
</dd>
</dl>
<hr size="6">
<a name="CLPR-Non_002dlinear-Constraints"></a>
<a name="SEC104"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC103" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC105" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC100" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC100" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC105" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 11.4 Non-Linear Constraints </h2>
<p>In this version, non-linear constraints do not get solved until certain
conditions are satisfied. We call these conditions the isolation axioms.
They are given in the following table.
</p>
<table><tr><td> </td><td><pre class="example">A = B * C when B or C is ground or // A = 5 * C or A = B * 4 \\
A and (B or C) are ground // 20 = 5 * C or 20 = B * 4 \\
A = B / C when C is ground or // A = B / 3
A and B are ground // 4 = 12 / C
X = min(Y,Z) when Y and Z are ground or // X = min(4,3)
X = max(Y,Z) Y and Z are ground // X = max(4,3)
X = abs(Y) Y is ground // X = abs(-7)
X = pow(Y,Z) when X and Y are ground or // 8 = 2 ^ Z
X = exp(Y,Z) X and Z are ground // 8 = Y ^ 3
X = Y ^ Z Y and Z are ground // X = 2 ^ 3
X = sin(Y) when X is ground or // 1 = sin(Y)
X = cos(Y) Y is ground // X = sin(1.5707)
X = tan(Y)
</pre></td></tr></table>
<hr size="6">
<a name="CHR"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC104" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC106" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC100" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC125" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC106">12.1 Introduction</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC107">12.2 Syntax and Semantics</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC114">12.3 CHR in YAP Programs</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC118">12.4 Debugging</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC122">12.5 Examples</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC123">12.6 Compatibility with SICStus CHR</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC124">12.7 Guidelines</a></td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<a name="SEC105"></a>
<h1 class="chapter"> 12. CHR: Constraint Handling Rules </h1>
<p>This chapter is written by Tom Schrijvers, K.U. Leuven for the hProlog
system. Adjusted by Jan Wielemaker to fit the SWI-Prolog documentation
infrastructure and remove hProlog specific references.
</p>
<p>The CHR system of SWI-Prolog is the K.U.Leuven CHR system. The runtime
environment is written by Christian Holzbaur and Tom Schrijvers while the
compiler is written by Tom Schrijvers. Both are integrated with SWI-Prolog
and licenced under compatible conditions with permission from the authors.
</p>
<p>The main reference for SWI-Prolog's CHR system is:
</p><ul class="toc">
<li> T. Schrijvers, and B. Demoen, <em>The K.U.Leuven CHR System: Implementation
and Application</em>, First Workshop on Constraint Handling Rules: Selected
Contributions (Fruwirth, T. and Meister, M., eds.), pp. 1-5, 2004.
</li></ul>
<hr size="6">
<a name="CHR-Introduction"></a>
<a name="SEC106"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC105" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC107" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC105" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC105" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC125" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 12.1 Introduction </h2>
<p>Constraint Handling Rules (CHR) is a committed-choice bottom-up language
embedded in Prolog. It is designed for writing constraint solvers and is
particularily useful for providing application-specific constraints.
It has been used in many kinds of applications, like scheduling,
model checking, abduction, type checking among many others.
</p>
<p>CHR has previously been implemented in other Prolog systems (SICStus,
Eclipse, Yap), Haskell and Java. This CHR system is based on the
compilation scheme and runtime environment of CHR in SICStus.
</p>
<p>In this documentation we restrict ourselves to giving a short overview
of CHR in general and mainly focus on elements specific to this
implementation. For a more thorough review of CHR we refer the reader to
[Freuhwirth:98]. More background on CHR can be found at the CHR web site.
</p>
<hr size="6">
<a name="CHR-Syntax-and-Semantics"></a>
<a name="SEC107"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC106" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC108" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC105" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC105" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC125" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 12.2 Syntax and Semantics </h2>
<p>@c=============================
</p>
<hr size="6">
<a name="SEC108"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC107" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC109" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC105" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC107" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC125" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 12.2.1 Syntax </h3>
<p>The syntax of CHR rules in hProlog is the following:
</p>
<table><tr><td> </td><td><pre class="example">rules --> rule, rules.
rules --> [].
rule --> name, actual_rule, pragma, [atom('.')].
name --> atom, [atom(')'].
name --> [].
actual_rule --> simplification_rule.
actual_rule --> propagation_rule.
actual_rule --> simpagation_rule.
simplification_rule --> constraints, [atom('<=>')], guard, body.
propagation_rule --> constraints, [atom('==>')], guard, body.
simpagation_rule --> constraints, [atom('\')], constraints, [atom('<=>')],
guard, body.
constraints --> constraint, constraint_id.
constraints --> constraint, [atom(',')], constraints.
constraint --> compound_term.
constraint_id --> [].
constraint_id --> [atom('#')], variable.
guard --> [].
guard --> goal, [atom('|')].
body --> goal.
pragma --> [].
pragma --> [atom('pragma')], actual_pragmas.
actual_pragmas --> actual_pragma.
actual_pragmas --> actual_pragma, [atom(',')], actual_pragmas.
actual_pragma --> [atom('passive(')], variable, [atom(')')].
</pre></td></tr></table>
<p>Additional syntax-related terminology:
</p>
<ul class="toc">
<li> <strong>head:</strong> the constraints in an <code>actual_rule</code> before
the arrow (either <code><=></code> or <code>==></code>)
</li></ul>
<hr size="6">
<a name="SEC109"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC108" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC110" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC105" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC107" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC125" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 12.2.2 Semantics </h3>
<p>In this subsection the operational semantics of CHR in Prolog are presented
informally. They do not differ essentially from other CHR systems.
</p>
<p>When a constraint is called, it is considered an active constraint and
the system will try to apply the rules to it. Rules are tried and executed
sequentially in the order they are written.
</p>
<p>A rule is conceptually tried for an active constraint in the following
way. The active constraint is matched with a constraint in the head of
the rule. If more constraints appear in the head they are looked for
among the suspended constraints, which are called passive constraints in
this context. If the necessary passive constraints can be found and all
match with the head of the rule and the guard of the rule succeeds, then
the rule is committed and the body of the rule executed. If not all the
necessary passive constraint can be found, the matching fails or the
guard fails, then the body is not executed and the process of trying and
executing simply continues with the following rules. If for a rule,
there are multiple constraints in the head, the active constraint will
try the rule sequentially multiple times, each time trying to match with
another constraint.
</p>
<p>This process ends either when the active constraint disappears, i.e. it
is removed by some rule, or after the last rule has been processed. In
the latter case the active constraint becomes suspended.
</p>
<p>A suspended constraint is eligible as a passive constraint for an active
constraint. The other way it may interact again with the rules, is when
a variable appearing in the constraint becomes bound to either a nonvariable
or another variable involved in one or more constraints. In that case the
constraint is triggered, i.e. it becomes an active constraint and all
the rules are tried.
</p>
<hr size="6">
<a name="SEC110"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC109" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC111" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC105" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC109" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC125" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h4 class="unnumberedsubsubsec"> Rule Types </h4>
<p>There are three different kinds of rules, each with their specific semantics:
</p>
<dl compact="compact">
<dt> <code>simplification</code></dt>
<dd><p>The simplification rule removes the constraints in its head and calls its body.
</p>
</dd>
<dt> <code>propagation</code></dt>
<dd><p>The propagation rule calls its body exactly once for the constraints in
its head.
</p>
</dd>
<dt> <code>simpagation</code></dt>
<dd><p>The simpagation rule removes the constraints in its head after the
<code>\</code> and then calls its body. It is an optimization of
simplification rules of the form: \[constraints_1, constraints_2 <=>
constraints_1, body \] Namely, in the simpagation form:
</p>
<table><tr><td> </td><td><pre class="example">constraints1 \ constraints2 <=> body
</pre></td></tr></table>
<p><var>constraints1</var>
constraints are not called in the body.
</p></dd>
</dl>
<hr size="6">
<a name="SEC111"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC110" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC112" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC105" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC109" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC125" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h4 class="unnumberedsubsubsec"> Rule Names </h4>
<p>Naming a rule is optional and has no semantical meaning. It only functions
as documentation for the programmer.
</p>
<hr size="6">
<a name="SEC112"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC111" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC113" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC105" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC109" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC125" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h4 class="unnumberedsubsubsec"> Pragmas </h4>
<p>The semantics of the pragmas are:
</p>
<dl compact="compact">
<dt> <samp>`passive(Identifier)'</samp></dt>
<dd><p>The constraint in the head of a rule <var>Identifier</var> can only act as a
passive constraint in that rule.
</p></dd>
</dl>
<p>Additional pragmas may be released in the future.
</p>
<hr size="6">
<a name="SEC113"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC112" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC114" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC105" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC109" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC125" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h4 class="unnumberedsubsubsec"> Options </h4>
<p>It is possible to specify options that apply to all the CHR rules in the module.
Options are specified with the <code>option/2</code> declaration:
</p>
<table><tr><td> </td><td><pre class="example"> option(Option,Value).
</pre></td></tr></table>
<p>Available options are:
</p><dl compact="compact">
<dt> <code>check_guard_bindings</code></dt>
<dd><p>This option controls whether guards should be checked for illegal
variable bindings or not. Possible values for this option are
<code>on</code>, to enable the checks, and <code>off</code>, to disable the
checks.
</p>
</dd>
<dt> <code>optimize</code></dt>
<dd><p>This is an experimental option controlling the degree of optimization.
Possible values are <code>full</code>, to enable all available
optimizations, and <code>off</code> (default), to disable all optimizations.
The default is derived from the SWI-Prolog flag <code>optimise</code>, where
<code>true</code> is mapped to <code>full</code>. Therefore the commandline
option <samp>`-O'</samp> provides full CHR optimization.
If optimization is enabled, debugging should be disabled.
</p>
</dd>
<dt> <code>debug</code></dt>
<dd><p>This options enables or disables the possibility to debug the CHR code.
Possible values are <code>on</code> (default) and <code>off</code>. See
<samp>`debugging'</samp> for more details on debugging. The default is
derived from the prolog flag <code>generate_debug_info</code>, which
is <code>true</code> by default. See <samp>`-nodebug'</samp>.
If debugging is enabled, optimization should be disabled.
</p>
</dd>
<dt> <code>mode</code></dt>
<dd><p>This option specifies the mode for a particular constraint. The
value is a term with functor and arity equal to that of a constraint.
The arguments can be one of <code>-</code>, <code>+</code> or <code>?</code>.
The latter is the default. The meaning is the following:
</p><dl compact="compact">
<dt> <code>-</code></dt>
<dd><p> The corresponding argument of every occurrence
of the constraint is always unbound.
</p></dd>
<dt> <code>+</code> </dt>
<dd><p> The corresponding argument of every occurrence
of the constraint is always ground.
</p></dd>
<dt> <code>?</code></dt>
<dd><p> The corresponding argument of every occurrence
of the constraint can have any instantiation, which may change
over time. This is the default value.
</p></dd>
</dl>
<p>The declaration is used by the compiler for various optimizations.
Note that it is up to the user the ensure that the mode declaration
is correct with respect to the use of the constraint.
This option may occur once for each constraint.
</p>
</dd>
<dt> <code>type_declaration</code></dt>
<dd><p>This option specifies the argument types for a particular constraint. The
value is a term with functor and arity equal to that of a constraint.
The arguments can be a user-defined type or one of
the built-in types:
</p><dl compact="compact">
<dt> <code>int</code></dt>
<dd><p> The corresponding argument of every occurrence
of the constraint is an integer number.
</p></dd>
<dt> <code>float</code></dt>
<dd><p> … a floating point number.
</p></dd>
<dt> <code>number</code></dt>
<dd><p> … a number.
</p></dd>
<dt> <code>natural</code></dt>
<dd><p> … a positive integer.
</p></dd>
<dt> <code>any</code></dt>
<dd><p> The corresponding argument of every occurrence
of the constraint can have any type. This is the default value.
</p></dd>
</dl>
<p>Currently, type declarations are only used to improve certain
optimizations (guard simplification, occurrence subsumption, …).
</p>
</dd>
<dt> <code>type_definition</code></dt>
<dd><p>This option defines a new user-defined type which can be used in
type declarations. The value is a term of the form
<code>type(</code><var>name</var><code>,</code><var>list</var><code>)</code>, where
<var>name</var> is a term and <var>list</var> is a list of alternatives.
Variables can be used to define generic types. Recursive definitions
are allowed. Examples are
</p>
<table><tr><td> </td><td><pre class="example">type(bool,[true,false]).
type(complex_number,[float + float * i]).
type(binary_tree(T),[ leaf(T) | node(binary_tree(T),binary_tree(T)) ]).
type(list(T),[ [] | [T | list(T)]).
</pre></td></tr></table>
</dd>
</dl>
<p>The mode, type_declaration and type_definition options are provided
for backward compatibility. The new syntax is described below.
</p>
<hr size="6">
<a name="CHR-in-YAP-Programs"></a>
<a name="SEC114"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC113" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC115" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC105" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC105" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC125" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 12.3 CHR in YAP Programs </h2>
<p>@c===========================
</p>
<hr size="6">
<a name="SEC115"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC114" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC116" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC105" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC114" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC125" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 12.3.1 Embedding in Prolog Programs </h3>
<p>The CHR constraints defined in a particulary <tt>`chr'</tt> file are
associated with a module. The default module is <code>user</code>. One should
never load different <tt>`chr'</tt> files with the same CHR module name.
</p>
<hr size="6">
<a name="SEC116"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC115" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC117" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC105" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC114" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC125" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 12.3.2 Constraint declaration </h3>
<p>Every constraint used in CHR rules has to be declared.
There are two ways to do this. The old style is as follows:
</p>
<table><tr><td> </td><td><pre class="example">option(type_definition,type(list(T),[ [] , [T|list(T)] ]).
option(mode,foo(+,?)).
option(type_declaration,foo(list(int),float)).
:- constraints foo/2, bar/0.
</pre></td></tr></table>
<p>The new style is as follows:
</p>
<table><tr><td> </td><td><pre class="example">:- chr_type list(T) ---> [] ; [T|list(T)].
:- constraints foo(+list(int),?float), bar.
</pre></td></tr></table>
<hr size="6">
<a name="SEC117"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC116" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC118" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC105" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC114" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC125" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 12.3.3 Compilation </h3>
<p>The SWI-Prolog CHR compiler exploits term_expansion/2 rules to translate
the constraint handling rules to plain Prolog. These rules are loaded
from the library <tt>`chr'</tt>. They are activated if the compiled file
has the <tt>`chr'</tt> extension or after finding a declaration of the
format below.
</p>
<table><tr><td> </td><td><pre class="example">:- constraints ...
</pre></td></tr></table>
<p>It is adviced to define CHR rules in a module file, where the module
declaration is immediately followed by including the <tt>`chr'</tt>
library as examplified below:
</p>
<table><tr><td> </td><td><pre class="example">:- module(zebra, [ zebra/0 ]).
:- use_module(library(chr)).
:- constraints ...
</pre></td></tr></table>
<p>Using this style CHR rules can be defined in ordinary Prolog
<tt>`pl'</tt> files and the operator definitions required by CHR do not
leak into modules where they might cause conflicts.
</p>
<hr size="6">
<a name="CHR-Debugging"></a>
<a name="SEC118"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC117" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC119" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC105" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC105" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC125" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 12.4 Debugging </h2>
<p>@c=================
</p>
<p>The CHR debugging facilities are currently rather limited. Only tracing
is currently available. To use the CHR debugging facilities for a CHR
file it must be compiled for debugging. Generating debug info is
controlled by the CHR option <code>debug</code>, whose default is derived
from the SWI-Prolog flag <code>generate_debug_info</code>. Therefore debug
info is provided unless the <samp>`-nodebug'</samp> is used.
</p>
<hr size="6">
<a name="SEC119"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC118" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC120" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC105" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC118" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC125" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 12.4.1 Ports </h3>
<p>@c===============
</p>
<p>For CHR constraints the four standard ports are defined:
</p>
<dl compact="compact">
<dt> <code>call</code></dt>
<dd><p>A new constraint is called and becomes active.
</p></dd>
<dt> <code>exit</code></dt>
<dd><p>An active constraint exits: it has either been inserted in the store after
trying all rules or has been removed from the constraint store.
</p></dd>
<dt> <code>fail</code></dt>
<dd><p>An active constraint fails.
</p></dd>
<dt> <code>redo</code></dt>
<dd><p>An active constraint starts looking for an alternative solution.
</p></dd>
</dl>
<p>In addition to the above ports, CHR constraints have five additional
ports:
</p>
<dl compact="compact">
<dt> <code>wake</code></dt>
<dd><p>A suspended constraint is woken and becomes active.
</p></dd>
<dt> <code>insert</code></dt>
<dd><p>An active constraint has tried all rules and is suspended in
the constraint store.
</p></dd>
<dt> <code>remove</code></dt>
<dd><p>An active or passive constraint is removed from the constraint
store, if it had been inserted.
</p></dd>
<dt> <code>try</code></dt>
<dd><p> An active constraints tries a rule with possibly
some passive constraints. The try port is entered
just before committing to the rule.
</p></dd>
<dt> <code>apply</code></dt>
<dd><p> An active constraints commits to a rule with possibly
some passive constraints. The apply port is entered
just after committing to the rule.
</p></dd>
</dl>
<hr size="6">
<a name="SEC120"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC119" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC121" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC105" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC118" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC125" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 12.4.2 Tracing </h3>
<p>@c=================
</p>
<p>Tracing is enabled with the chr_trace/0 predicate
and disabled with the chr_notrace/0 predicate.
</p>
<p>When enabled the tracer will step through the <code>call</code>,
<code>exit</code>, <code>fail</code>, <code>wake</code> and <code>apply</code> ports,
accepting debug commands, and simply write out the other ports.
</p>
<p>The following debug commans are currently supported:
</p>
<table><tr><td> </td><td><pre class="example"> CHR debug options:
<cr> creep c creep
s skip
g ancestors
n nodebug
b break
a abort
f fail
? help h help
</pre></td></tr></table>
<p>Their meaning is:
</p>
<dl compact="compact">
<dt> <code>creep</code></dt>
<dd><p>Step to the next port.
</p></dd>
<dt> <code>skip</code></dt>
<dd><p>Skip to exit port of this call or wake port.
</p></dd>
<dt> <code>ancestors</code></dt>
<dd><p>Print list of ancestor call and wake ports.
</p></dd>
<dt> <code>nodebug</code></dt>
<dd><p>Disable the tracer.
</p></dd>
<dt> <code>break</code></dt>
<dd><p>Enter a recursive Prolog toplevel. See break/0.
</p></dd>
<dt> <code>abort</code></dt>
<dd><p>Exit to the toplevel. See abort/0.
</p></dd>
<dt> <code>fail</code></dt>
<dd><p>Insert failure in execution.
</p></dd>
<dt> <code>help</code></dt>
<dd><p>Print the above available debug options.
</p></dd>
</dl>
<hr size="6">
<a name="SEC121"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC120" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC122" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC105" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC118" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC125" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 12.4.3 CHR Debugging Predicates </h3>
<p>@c====================================
</p>
<p>The <tt>`chr'</tt> module contains several predicates that allow
inspecting and printing the content of the constraint store.
</p>
<dl compact="compact">
<dt> <code>chr_trace/0</code></dt>
<dd><p>Activate the CHR tracer. By default the CHR tracer is activated and
deactivated automatically by the Prolog predicates trace/0 and
notrace/0.
</p>
</dd>
<dt> <code>chr_notrace/0</code></dt>
<dd><p>De-activate the CHR tracer. By default the CHR tracer is activated and
deactivated automatically by the Prolog predicates trace/0 and
notrace/0.
</p>
</dd>
<dt> <code>chr_leash/0</code> </dt>
<dd>
<p>Define the set of CHR ports on which the CHR
tracer asks for user intervention (i.e. stops). <var>Spec</var> is either a
list of ports or a predefined `alias'. Defined aliases are:
<code>full</code> to stop at all ports, <code>none</code> or <code>off</code> to never
stop, and <code>default</code> to stop at the <code>call</code>, <code>exit</code>,
<code>fail</code>, <code>wake</code> and <code>apply</code> ports. See also leash/1.
</p>
</dd>
<dt> <code>chr_show_store(+<var>Mod</var>)</code></dt>
<dd><p>Prints all suspended constraints of module <var>Mod</var> to the standard
output. This predicate is automatically called by the SWI-Prolog toplevel at
the end of each query for every CHR module currently loaded. The prolog-flag
<code>chr_toplevel_show_store</code> controls whether the toplevel shows the
constraint stores. The value <code>true</code> enables it. Any other value
disables it.
</p>
</dd>
</dl>
<hr size="6">
<a name="CHR-Examples"></a>
<a name="SEC122"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC121" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC123" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC105" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC105" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC125" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 12.5 Examples </h2>
<p>@c================
</p>
<p>Here are two example constraint solvers written in CHR.
</p>
<ul class="toc">
<li>
The program below defines a solver with one constraint,
<code>leq/2</code>, which is a less-than-or-equal constraint.
<table><tr><td> </td><td><pre class="example">:- module(leq,[cycle/3, leq/2]).
:- use_module(library(chr)).
:- constraints leq/2.
reflexivity leq(X,X) <=> true.
antisymmetry leq(X,Y), leq(Y,X) <=> X = Y.
idempotence leq(X,Y) \ leq(X,Y) <=> true.
transitivity leq(X,Y), leq(Y,Z) ==> leq(X,Z).
cycle(X,Y,Z):-
leq(X,Y),
leq(Y,Z),
leq(Z,X).
</pre></td></tr></table>
</li><li>
The program below implements a simple finite domain
constraint solver.
<table><tr><td> </td><td><pre class="example">:- module(dom,[dom/2]).
:- use_module(library(chr)).
:- constraints dom/2.
dom(X,[]) <=> fail.
dom(X,[Y]) <=> X = Y.
dom(X,L1), dom(X,L2) <=> intersection(L1,L2,L3), dom(X,L3).
intersection([],_,[]).
intersection([H|T],L2,[H|L3]) :-
member(H,L2), !,
intersection(T,L2,L3).
intersection([_|T],L2,L3) :-
intersection(T,L2,L3).
</pre></td></tr></table>
</li></ul>
<hr size="6">
<a name="CHR-Compatibility"></a>
<a name="SEC123"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC122" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC124" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC105" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC105" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC125" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 12.6 Compatibility with SICStus CHR </h2>
<p>@c==================
</p>
<p>There are small differences between CHR in SWI-Prolog and newer
YAPs and SICStus and older versions of YAP. Besides differences in
available options and pragmas, the following differences should be
noted:
</p>
<dl compact="compact">
<dt> <code>[The handler/1 declaration]</code></dt>
<dd><p>In SICStus every CHR module requires a <code>handler/1</code>
declaration declaring a unique handler name. This declaration is valid
syntax in SWI-Prolog, but will have no effect. A warning will be given
during compilation.
</p>
</dd>
<dt> <code>[The rules/1 declaration]</code></dt>
<dd><p>In SICStus, for every CHR module it is possible to only enable a subset
of the available rules through the <code>rules/1</code> declaration. The
declaration is valid syntax in SWI-Prolog, but has no effect. A
warning is given during compilation.
</p>
</dd>
<dt> <code>[Sourcefile naming]</code></dt>
<dd><p>SICStus uses a two-step compiler, where <tt>`chr'</tt> files are
first translated into <tt>`pl'</tt> files. For SWI-Prolog CHR
rules may be defined in a file with any extension.
</p></dd>
</dl>
<hr size="6">
<a name="CHR-Guidelines"></a>
<a name="SEC124"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC123" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC125" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC105" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC105" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC125" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 12.7 Guidelines </h2>
<p>In this section we cover several guidelines on how to use CHR to write
constraint solvers and how to do so efficiently.
</p>
<dl compact="compact">
<dt> <code>[Set semantics]</code></dt>
<dd><p>The CHR system allows the presence of identical constraints, i.e.
multiple constraints with the same functor, arity and arguments. For
most constraint solvers, this is not desirable: it affects efficiency
and possibly termination. Hence appropriate simpagation rules should be
added of the form:
</p>
<table><tr><td> </td><td><pre class="example">{constraint \ constraint <=> true}.
</pre></td></tr></table>
</dd>
<dt> <code>[Multi-headed rules]</code></dt>
<dd><p>Multi-headed rules are executed more efficiently when the constraints
share one or more variables.
</p>
</dd>
<dt> <code>[Mode and type declarations]</code></dt>
<dd><p>Provide mode and type declarations to get more efficient program execution.
Make sure to disable debug (<samp>`-nodebug'</samp>) and enable optimization
(<samp>`-O'</samp>).
</p></dd>
</dl>
<hr size="6">
<a name="Logtalk"></a>
<a name="SEC125"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC124" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC126" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC105" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC126" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 13. Logtalk </h1>
<p>The Logtalk object-oriented extension is available once included
with the <code>use_module(library(logtalk))</code> command. Note that,
although we load Logtalk using the <code>use_module/1</code> built-in
predicate, the system is not packaged as a module not does it use
modules in its implementation.
</p>
<p>Logtalk documentation is included in the Logtalk directory. Be sure to read the Logtalk/INSTALL file for additional instructions on how to customize your Logtalk installation to match your working environment.
</p>
<p>For the latest Llogtalk news, please see the URL <a href="http://www.logtalk.org/">http://www.logtalk.org/</a>.
</p>
<hr size="6">
<a name="Threads"></a>
<a name="SEC126"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC125" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC127" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC125" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC134" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 14. Threads </h1>
<p>YAP implements a SWI-Prolog compatible multithreading
library. Like in SWI-Prolog, Prolog threads have their own stacks and
only share the Prolog <em>heap</em>: predicates, records, flags and other
global non-backtrackable data. The package is based on the POSIX thread
standard (Butenhof:1997:PPT) used on most popular systems except
for MS-Windows.
</p>
<table class="menu" border="0" cellspacing="0">
<p>Subnodes of Threads
<a href="#SEC127">14.1 Creating and Destroying Prolog Threads</a> </p>
<tr><td align="left" valign="top"><a href="#SEC128">14.2 Monitoring Threads</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC129">14.3 Thread communication</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC133">14.4 Thread Synchronisation</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
Subnodes of Thread Communication
</pre></th></tr><tr><td align="left" valign="top"><a href="#SEC130">14.3.1 Message Queues</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC131">14.3.2 Signalling Threads</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC132">14.3.3 Threads and Dynamic Predicates</a></td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr size="6">
<a name="Creating-and-Destroying-Prolog-Threads"></a>
<a name="SEC127"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC126" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC128" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC126" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC126" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC134" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 14.1 Creating and Destroying Prolog Threads </h2>
<dl compact="compact">
<dt> <code>thread_create(:<var>Goal</var>, -<var>Id</var>, +<var>Options</var>)</code></dt>
<dd><a name="IDX1877"></a>
<a name="IDX1878"></a>
<a name="IDX1879"></a>
<p>Create a new Prolog thread (and underlying C-thread) and start it
by executing <var>Goal</var>. If the thread is created succesfully, the
thread-identifier of the created thread is unified to <var>Id</var>.
<var>Options</var> is a list of options. Currently defined options are:
</p>
<dl compact="compact">
<dt> <code>stack</code></dt>
<dd><p>Set the limit in K-Bytes to which the Prolog stacks of
this thread may grow. If omited, the limit of the calling thread is
used. See also the commandline <code>-S</code> option.
</p>
</dd>
<dt> <code>trail</code></dt>
<dd><p>Set the limit in K-Bytes to which the trail stack of this thread may
grow. If omited, the limit of the calling thread is used. See also the
commandline option <code>-T</code>.
</p>
</dd>
<dt> <code>alias</code></dt>
<dd><p>Associate an alias-name with the thread. This named may be used to
refer to the thread and remains valid until the thread is joined
(see <code>thread_join/2</code>).
</p>
</dd>
<dt> <code>detached</code></dt>
<dd><p>If <code>false</code> (default), the thread can be waited for using
<code>thread_join/2</code>. <code>thread_join/2</code> must be called on this thread
to reclaim the all resources associated to the thread. If <code>true</code>,
the system will reclaim all associated resources automatically after the
thread finishes. Please note that thread identifiers are freed for reuse
after a detached thread finishes or a normal thread has been joined.
See also <code>thread_join/2</code> and <code>thread_detach/1</code>.
</p></dd>
</dl>
<p>The <var>Goal</var> argument is <em>copied</em> to the new Prolog engine.
This implies further instantiation of this term in either thread does
not have consequences for the other thread: Prolog threads do not share
data from their stacks.
</p>
</dd>
<dt> <code>thread_self(-<var>Id</var>)</code></dt>
<dd><a name="IDX1880"></a>
<a name="IDX1881"></a>
<a name="IDX1882"></a>
<p>Get the Prolog thread identifier of the running thread. If the thread
has an alias, the alias-name is returned.
</p>
</dd>
<dt> <code>thread_join(+<var>Id</var>, -<var>Status</var>)</code></dt>
<dd><a name="IDX1883"></a>
<a name="IDX1884"></a>
<a name="IDX1885"></a>
<p>Wait for the termination of thread with given <var>Id</var>. Then unify the
result-status of the thread with <var>Status</var>. After this call,
<var>Id</var> becomes invalid and all resources associated with the thread
are reclaimed. Note that threads with the attribute <code>detached</code>
<code>true</code> cannot be joined. See also <code>current_thread/2</code>.
</p>
<p>A thread that has been completed without <code>thread_join/2</code> being
called on it is partly reclaimed: the Prolog stacks are released and the
C-thread is destroyed. A small data-structure representing the
exit-status of the thread is retained until <code>thread_join/2</code> is called on
the thread. Defined values for <var>Status</var> are:
</p>
<dl compact="compact">
<dt> <code>true</code></dt>
<dd><p>The goal has been proven successfully.
</p>
</dd>
<dt> <code>false</code></dt>
<dd><p>The goal has failed.
</p>
</dd>
<dt> <code>exception(<var>Term</var>)</code></dt>
<dd><p> The thread is terminated on an
exception. See <code>print_message/2</code> to turn system exceptions into
readable messages.
</p>
</dd>
<dt> <code>exited(<var>Term</var>)</code></dt>
<dd><p>The thread is terminated on <code>thread_exit/1</code> using the argument <var>Term</var>.
</p></dd>
</dl>
</dd>
<dt> <code>thread_detach(+<var>Id</var>)</code></dt>
<dd><a name="IDX1886"></a>
<a name="IDX1887"></a>
<a name="IDX1888"></a>
<p>Switch thread into detached-state (see <code>detached</code> option at
<code>thread_create/3</code> at runtime. <var>Id</var> is the identifier of the thread
placed in detached state.
</p>
<p>One of the possible applications is to simplify debugging. Threads that
are created as <code>detached</code> leave no traces if they crash. For
not-detached threads the status can be inspected using
<code>current_thread/2</code>. Threads nobody is waiting for may be created
normally and detach themselves just before completion. This way they
leave no traces on normal completion and their reason for failure can be
inspected.
</p>
</dd>
<dt> <code>thread_exit(+<var>Term</var>)</code></dt>
<dd><a name="IDX1889"></a>
<a name="IDX1890"></a>
<a name="IDX1891"></a>
<p>Terminates the thread immediately, leaving <code>exited(<var>Term</var>)</code> as
result-state for <code>thread_join/2</code>. If the thread has the attribute
<code>detached</code> <code>true</code> it terminates, but its exit status cannot be
retrieved using <code>thread_join/2</code> making the value of <var>Term</var>
irrelevant. The Prolog stacks and C-thread are reclaimed.
</p>
</dd>
<dt> <code>thread_at_exit(:<var>Term</var>)</code></dt>
<dd><a name="IDX1892"></a>
<a name="IDX1893"></a>
<a name="IDX1894"></a>
<p>Run <var>Goal</var> just before releasing the thread resources. This is to
be compared to <code>at_halt/1</code>, but only for the current
thread. These hooks are ran regardless of why the execution of the
thread has been completed. As these hooks are run, the return-code is
already available through <code>current_thread/2</code> using the result of
<code>thread_self/1</code> as thread-identifier.
</p>
</dd>
<dt> <code>thread_setconcurrency(+<var>Old</var>, -<var>New</var>)</code></dt>
<dd><a name="IDX1895"></a>
<a name="IDX1896"></a>
<a name="IDX1897"></a>
<p>Determine the concurrency of the process, which is defined as the
maximum number of concurrently active threads. `Active' here means
they are using CPU time. This option is provided if the
thread-implementation provides
<code>pthread_setconcurrency()</code>. Solaris is a typical example of this
family. On other systems this predicate unifies <var>Old</var> to 0 (zero)
and succeeds silently.
</p></dd>
</dl>
<hr size="6">
<a name="Monitoring-Threads"></a>
<a name="SEC128"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC127" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC129" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC126" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC126" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC134" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 14.2 Monitoring Threads </h2>
<p>Normal multi-threaded applications should not need these the predicates
from this section because almost any usage of these predicates is
unsafe. For example checking the existence of a thread before signalling
it is of no use as it may vanish between the two calls. Catching
exceptions using <code>catch/3</code> is the only safe way to deal with
thread-existence errors.
</p>
<p>These predicates are provided for diagnosis and monitoring tasks.
</p>
<dl compact="compact">
<dt> <code>current_thread(+<var>Id</var>, -<var>Status</var>)</code></dt>
<dd><a name="IDX1898"></a>
<a name="IDX1899"></a>
<a name="IDX1900"></a>
<p>Enumerates identifiers and status of all currently known threads.
Calling current_thread/2 does not influence any thread. See also
<code>thread_join/2</code>. For threads that have an alias-name, this name is
returned in <var>Id</var> instead of the numerical thread identifier.
<var>Status</var> is one of:
</p>
<dl compact="compact">
<dt> <code>running</code></dt>
<dd><p>The thread is running. This is the initial status of a thread. Please
note that threads waiting for something are considered running too.
</p>
</dd>
<dt> <code>false</code></dt>
<dd><p>The <var>Goal</var> of the thread has been completed and failed.
</p>
</dd>
<dt> <code>true</code></dt>
<dd><p>The <var>Goal</var> of the thread has been completed and succeeded.
</p>
</dd>
<dt> <code>exited(<var>Term</var>)</code></dt>
<dd><p>The <var>Goal</var> of the thread has been terminated using <code>thread_exit/1</code>
with <var>Term</var> as argument. If the underlying native thread has
exited (using pthread_exit()) <var>Term</var> is unbound.
</p>
</dd>
<dt> <code>exception(<var>Term</var>)</code></dt>
<dd><p>The <var>Goal</var> of the thread has been terminated due to an uncaught
exception (see <code>throw/1</code> and <code>catch/3</code>).
</p></dd>
</dl>
</dd>
<dt> <code>thread_statistics(+<var>Id</var>, +<var>Key</var>, -<var>Value</var>)</code></dt>
<dd><a name="IDX1901"></a>
<a name="IDX1902"></a>
<a name="IDX1903"></a>
<p>Obtains statistical information on thread <var>Id</var> as <code>statistics/2</code>
does in single-threaded applications. This call returns all keys
of <code>statistics/2</code>, although only information statistics about the
stacks and CPU time yield different values for each thread.
</p>
</dd>
<dt> <code>mutex_statistics</code></dt>
<dd><a name="IDX1904"></a>
<a name="IDX1905"></a>
<a name="IDX1906"></a>
<p>Print usage statistics on internal mutexes and mutexes associated
with dynamic predicates. For each mutex two numbers are printed:
the number of times the mutex was acquired and the number of
collisions: the number times the calling thread has to
wait for the mutex. The collistion-count is not available on
Windows as this would break portability to Windows-95/98/ME or
significantly harm performance. Generally collision count is
close to zero on single-CPU hardware.
</p></dd>
</dl>
<hr size="6">
<a name="Thread-Communication"></a>
<a name="SEC129"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC128" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC130" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC126" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC126" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC134" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 14.3 Thread communication </h2>
<table class="menu" border="0" cellspacing="0">
<p>Subnodes of Thread Communication
<a href="#SEC130">14.3.1 Message Queues</a> </p>
<tr><td align="left" valign="top"><a href="#SEC131">14.3.2 Signalling Threads</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC132">14.3.3 Threads and Dynamic Predicates</a></td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr size="6">
<a name="Message-Queues"></a>
<a name="SEC130"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC129" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC131" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC126" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC129" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC134" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 14.3.1 Message Queues </h3>
<p>Prolog threads can exchange data using dynamic predicates, database
records, and other globally shared data. These provide no suitable means
to wait for data or a condition as they can only be checked in an
expensive polling loop. <em>Message queues</em> provide a means for
threads to wait for data or conditions without using the CPU.
</p>
<p>Each thread has a message-queue attached to it that is identified
by the thread. Additional queues are created using
<code>message_queue_create/2</code>.
</p>
<dl compact="compact">
<dt> <code>thread_send_message(+<var>QueueOrThreadId</var>, +<var>Term</var>)</code></dt>
<dd><a name="IDX1907"></a>
<a name="IDX1908"></a>
<a name="IDX1909"></a>
<p>Place <var>Term</var> in the given queue or default queue of the indicated
thread (which can even be the message queue of itself (see
<code>thread_self/1</code>). Any term can be placed in a message queue, but note that
the term is copied to the receiving thread and variable-bindings are
thus lost. This call returns immediately.
</p>
<p>If more than one thread is waiting for messages on the given queue and
at least one of these is waiting with a partially instantiated
<var>Term</var>, the waiting threads are <em>all</em> sent a wakeup signal,
starting a rush for the available messages in the queue. This behaviour
can seriously harm performance with many threads waiting on the same
queue as all-but-the-winner perform a useless scan of the queue. If
there is only one waiting thread or all waiting threads wait with an
unbound variable an arbitrary thread is restarted to scan the queue.%
</p>
</dd>
<dt> <code>thread_get_message(?<var>Term</var>)</code></dt>
<dd><a name="IDX1910"></a>
<a name="IDX1911"></a>
<a name="IDX1912"></a>
<p>Examines the thread message-queue and if necessary blocks execution
until a term that unifies to <var>Term</var> arrives in the queue. After
a term from the queue has been unified unified to <var>Term</var>, the
term is deleted from the queue and this predicate returns.
</p>
<p>Please note that not-unifying messages remain in the queue. After
the following has been executed, thread 1 has the term <code>gnu</code>
in its queue and continues execution using <var>A</var> is <code>gnat</code>.
</p>
<table><tr><td> </td><td><pre class="example"> <thread 1>
thread_get_message(a(A)),
<thread 2>
thread_send_message(b(gnu)),
thread_send_message(a(gnat)),
</pre></td></tr></table>
<p>See also <code>thread_peek_message/1</code>.
</p>
</dd>
<dt> <code>thread_peek_message(?<var>Term</var>)</code></dt>
<dd><a name="IDX1913"></a>
<a name="IDX1914"></a>
<a name="IDX1915"></a>
<p>Examines the thread message-queue and compares the queued terms
with <var>Term</var> until one unifies or the end of the queue has been
reached. In the first case the call succeeds (possibly instantiating
<var>Term</var>. If no term from the queue unifies this call fails.
</p>
</dd>
<dt> <code>thread_message_queue_create(?<var>Queue</var>)</code></dt>
<dd><a name="IDX1916"></a>
<a name="IDX1917"></a>
<a name="IDX1918"></a>
<p>If <var>Queue</var> is an atom, create a named queue. To avoid ambiguity
on <code>thread_send_message/2</code>, the name of a queue may not be in use
as a thread-name. If <var>Queue</var> is unbound an anonymous queue is
created and <var>Queue</var> is unified to its identifier.
</p>
</dd>
<dt> <code>thread_message_queue_destroy(+<var>Queue</var>)</code></dt>
<dd><a name="IDX1919"></a>
<a name="IDX1920"></a>
<a name="IDX1921"></a>
<p>Destroy a message queue created with message_queue_create/1. It is
<em>not</em> allows to destroy the queue of a thread. Neither is it
allowed to destroy a queue other threads are waiting for or, for
anynymous message queues, may try to wait for later.%
</p>
</dd>
<dt> <code>thread_get_message(+<var>Queue</var>, +<var>Term</var>)</code></dt>
<dd><a name="IDX1922"></a>
<a name="IDX1923"></a>
<a name="IDX1924"></a>
<p>As thread_get_message/1, operating on a given queue. It is allowed to
peek into another thread's message queue, an operation that can be used
to check whether a thread has swallowed a message sent to it.
</p></dd>
</dl>
<p>Explicit message queues are designed with the <em>worker-pool</em> model
in mind, where multiple threads wait on a single queue and pick up the
first goal to execute. Below is a simple implementation where the
workers execute arbitrary Prolog goals. Note that this example provides
no means to tell when all work is done. This must be realised using
additional synchronisation.
</p>
<table><tr><td> </td><td><pre class="example">% create_workers(+Id, +N)
%
% Create a pool with given Id and number of workers.
create_workers(Id, N) :-
message_queue_create(Id),
forall(between(1, N, _),
thread_create(do_work(Id), _, [])).
do_work(Id) :-
repeat,
thread_get_message(Id, Goal),
( catch(Goal, E, print_message(error, E))
-> true
; print_message(error, goal_failed(Goal, worker(Id)))
),
fail.
% work(+Id, +Goal)
%
% Post work to be done by the pool
work(Id, Goal) :-
thread_send_message(Id, Goal).
</pre></td></tr></table>
<hr size="6">
<a name="Signalling-Threads"></a>
<a name="SEC131"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC130" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC132" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC126" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC129" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC134" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 14.3.2 Signalling Threads </h3>
<p>These predicates provide a mechanism to make another thread execute some
goal as an <em>interrupt</em>. Signalling threads is safe as these
interrupts are only checked at safe points in the virtual machine.
Nevertheless, signalling in multi-threaded environments should be
handled with care as the receiving thread may hold a <em>mutex</em>
(see with_mutex). Signalling probably only makes sense to start
debugging threads and to cancel no-longer-needed threads with <code>throw/1</code>,
where the receiving thread should be designed carefully do handle
exceptions at any point.
</p>
<dl compact="compact">
<dt> <code>thread_signal(+<var>ThreadId</var>, :<var>Goal</var>)</code></dt>
<dd><a name="IDX1925"></a>
<a name="IDX1926"></a>
<a name="IDX1927"></a>
<p>Make thread <var>ThreadId</var> execute <var>Goal</var> at the first
opportunity. In the current implementation, this implies at the first
pass through the <em>Call-port</em>. The predicate <code>thread_signal/2</code>
itself places <var>Goal</var> into the signalled-thread's signal queue
and returns immediately.
</p>
<p>Signals (interrupts) do not cooperate well with the world of
multi-threading, mainly because the status of mutexes cannot be
guaranteed easily. At the call-port, the Prolog virtual machine
holds no locks and therefore the asynchronous execution is safe.
</p>
<p><var>Goal</var> can be any valid Prolog goal, including <code>throw/1</code> to make
the receiving thread generate an exception and <code>trace/0</code> to start
tracing the receiving thread.
</p>
</dd>
</dl>
<hr size="6">
<a name="Threads-and-Dynamic-Predicates"></a>
<a name="SEC132"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC131" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC133" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC126" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC129" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC134" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 14.3.3 Threads and Dynamic Predicates </h3>
<p>Besides queues threads can share and exchange data using dynamic
predicates. The multi-threaded version knows about two types of
dynamic predicates. By default, a predicate declared <em>dynamic</em>
(see <code>dynamic/1</code>) is shared by all threads. Each thread may
assert, retract and run the dynamic predicate. Synchronisation inside
Prolog guarantees the consistency of the predicate. Updates are
<em>logical</em>: visible clauses are not affected by assert/retract
after a query started on the predicate. In many cases primitive from
thread synchronysation should be used to ensure application invariants on
the predicate are maintained.
</p>
<p>Besides shared predicates, dynamic predicates can be declared with the
<code>thread_local/1</code> directive. Such predicates share their
attributes, but the clause-list is different in each thread.
</p>
<dl compact="compact">
<dt> <code>thread_local(<var>+Functor/Arity</var>)</code> </dt>
<dd><a name="IDX1928"></a>
<a name="IDX1929"></a>
<a name="IDX1930"></a>
<p>related to the dynamic/1 directive. It tells the system that the
predicate may be modified using <code>assert/1</code>, <code>retract/1</code>,
etc, during execution of the program. Unlike normal shared dynamic
data however each thread has its own clause-list for the predicate.
As a thread starts, this clause list is empty. If there are still
clauses as the thread terminates these are automatically reclaimed by
the system. The thread_local property implies
the property dynamic.
</p>
<p>Thread-local dynamic predicates are intended for maintaining
thread-specific state or intermediate results of a computation.
</p>
<p>It is not recommended to put clauses for a thread-local predicate into
a file as in the example below as the clause is only visible from the
thread that loaded the source-file. All other threads start with an
empty clause-list.
</p>
<table><tr><td> </td><td><pre class="example">:- thread_local
foo/1.
foo(gnat).
</pre></td></tr></table>
</dd>
</dl>
<hr size="6">
<a name="Thread-Synchronisation"></a>
<a name="SEC133"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC132" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC134" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC126" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC126" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC134" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 14.4 Thread Synchronisation </h2>
<p>All internal Prolog operations are thread-safe. This implies two Prolog
threads can operate on the same dynamic predicate without corrupting the
consistency of the predicate. This section deals with user-level
<em>mutexes</em> (called <em>monitors</em> in ADA or
<em>critical-sections</em> by Microsoft). A mutex is a
<em>MUT</em>ual <em>EX</em>clusive device, which implies at most one thread
can <em>hold</em> a mutex.
</p>
<p>Mutexes are used to realise related updates to the Prolog database.
With `related', we refer to the situation where a `transaction' implies
two or more changes to the Prolog database. For example, we have a
predicate <code>address/2</code>, representing the address of a person and we want
to change the address by retracting the old and asserting the new
address. Between these two operations the database is invalid: this
person has either no address or two addresses, depending on the
assert/retract order.
</p>
<p>Here is how to realise a correct update:
</p>
<table><tr><td> </td><td><pre class="example">:- initialization
mutex_create(addressbook).
change_address(Id, Address) :-
mutex_lock(addressbook),
retractall(address(Id, _)),
asserta(address(Id, Address)),
mutex_unlock(addressbook).
</pre></td></tr></table>
<dl compact="compact">
<dt> <code>mutex_create(?<var>MutexId</var>)</code></dt>
<dd><a name="IDX1931"></a>
<a name="IDX1932"></a>
<a name="IDX1933"></a>
<p>Create a mutex. if <var>MutexId</var> is an atom, a <em>named</em> mutex is
created. If it is a variable, an anonymous mutex reference is returned.
There is no limit to the number of mutexes that can be created.
</p>
</dd>
<dt> <code>mutex_destroy(+<var>MutexId</var>)</code></dt>
<dd><a name="IDX1934"></a>
<a name="IDX1935"></a>
<a name="IDX1936"></a>
<p>Destroy a mutex. After this call, <var>MutexId</var> becomes invalid and
further references yield an <code>existence_error</code> exception.
</p>
</dd>
<dt> <code>with_mutex(+<var>MutexId</var>, :<var>Goal</var>)</code></dt>
<dd><a name="IDX1937"></a>
<a name="IDX1938"></a>
<a name="IDX1939"></a>
<p>Execute <var>Goal</var> while holding <var>MutexId</var>. If <var>Goal</var> leaves
choicepoints, these are destroyed (as in <code>once/1</code>). The mutex is unlocked
regardless of whether <var>Goal</var> succeeds, fails or raises an exception.
An exception thrown by <var>Goal</var> is re-thrown after the mutex has been
successfully unlocked. See also <code>mutex_create/2</code>.
</p>
<p>Although described in the thread-section, this predicate is also
available in the single-threaded version, where it behaves simply as
once/1.
</p>
</dd>
<dt> <code>mutex_lock(+<var>MutexId</var>)</code></dt>
<dd><a name="IDX1940"></a>
<a name="IDX1941"></a>
<a name="IDX1942"></a>
<p>Lock the mutex. Prolog mutexes are <em>recursive</em> mutexes: they
can be locked multiple times by the same thread. Only after unlocking
it as many times as it is locked, the mutex becomes available for
locking by other threads. If another thread has locked the mutex the
calling thread is suspended until to mutex is unlocked.
</p>
<p>If <var>MutexId</var> is an atom, and there is no current mutex with that
name, the mutex is created automatically using <code>mutex_create/1</code>. This
implies named mutexes need not be declared explicitly.
</p>
<p>Please note that locking and unlocking mutexes should be paired
carefully. Especially make sure to unlock mutexes even if the protected
code fails or raises an exception. For most common cases use
<code>with_mutex/2</code>, wich provides a safer way for handling prolog-level
mutexes.
</p>
</dd>
<dt> <code>mutex_trylock(+<var>MutexId</var>)</code></dt>
<dd><a name="IDX1943"></a>
<a name="IDX1944"></a>
<a name="IDX1945"></a>
<p>As mutex_lock/1, but if the mutex is held by another thread, this
predicates fails immediately.
</p>
</dd>
<dt> <code>mutex_unlock(+<var>MutexId</var>)</code></dt>
<dd><a name="IDX1946"></a>
<a name="IDX1947"></a>
<a name="IDX1948"></a>
<p>Unlock the mutex. This can only be called if the mutex is held by the
calling thread. If this is not the case, a <code>permission_error</code>
exception is raised.
</p>
</dd>
<dt> <code>mutex_unlock_all</code></dt>
<dd><a name="IDX1949"></a>
<a name="IDX1950"></a>
<a name="IDX1951"></a>
<p>Unlock all mutexes held by the current thread. This call is especially
useful to handle thread-termination using <code>abort/0</code> or exceptions. See
also <code>thread_signal/2</code>.
</p>
</dd>
<dt> <code>current_mutex(?<var>MutexId</var>, ?<var>ThreadId</var>, ?<var>Count</var>)</code></dt>
<dd><a name="IDX1952"></a>
<a name="IDX1953"></a>
<a name="IDX1954"></a>
<p>Enumerates all existing mutexes. If the mutex is held by some thread,
<var>ThreadId</var> is unified with the identifier of te holding thread and
<var>Count</var> with the recursive count of the mutex. Otherwise,
<var>ThreadId</var> is <code>[]</code> and <var>Count</var> is 0.
</p></dd>
</dl>
<hr size="6">
<a name="Parallelism"></a>
<a name="SEC134"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC133" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC135" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC126" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC135" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 15. Parallelism </h1>
<p>There has been a sizeable amount of work on an or-parallel
implementation for YAP, called <strong>YapOr</strong>. Most of this work has
been performed by Ricardo Rocha. In this system parallelism is exploited
implicitly by running several alternatives in or-parallel. This option
can be enabled from the <code>configure</code> script or by checking the
system's <code>Makefile</code>.
</p>
<p><strong>YapOr</strong> is still a very experimental system, going through rapid
development. The following restrictions are of note:
</p>
<ul>
<li> <strong>YapOr</strong> currently only supports the Linux/X86 and SPARC/Solaris
platforms. Porting to other Unix-like platforms should be straightforward.
</li><li> <strong>YapOr</strong> does not support parallel updates to the
data-base.
</li><li> <strong>YapOr</strong> does not support opening or closing of streams during
parallel execution.
</li><li> Garbage collection and stack shifting are not supported in
<strong>YapOr</strong>.
</li><li> Built-ins that cause side-effects can only be executed when
left-most in the search-tree. There are no primitives to provide
asynchronous or cavalier execution of these built-ins, as in Aurora or
Muse.
</li><li> YAP does not support voluntary suspension of work.
</li></ul>
<p>We expect that some of these restrictions will be removed in future
releases.
</p>
<hr size="6">
<a name="Tabling"></a>
<a name="SEC135"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC134" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC136" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC134" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC136" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 16. Tabling </h1>
<p>An initial cut for an implementation of tabling in the style of
XSB-Prolog is now available. Tabling was implemented by Ricardo
Rocha. To experiment with tabling use <code>-DTABLING</code> to
<code>YAP_EXTRAS</code> in the system's <code>Makefile</code>.
</p>
<p>You can use the directive <code>table</code> to force calls for the argument
predicate to be tabled. Tabling information is stored in a trie, as for
XSB-Prolog.
</p>
<p>The following predicates may be useful to control tabled execution:
</p><dl compact="compact">
<dt> <code>is_tabled(+<var>PredIndicator</var>)</code></dt>
<dd><a name="IDX1955"></a>
<a name="IDX1956"></a>
<a name="IDX1957"></a>
<p>Succeeds if the predicate <var>PredIndicator</var>, of the form
<var>Name/Arity</var>, is a tabled predicate.
</p>
</dd>
<dt> <code>tabling_mode(+<var>PredIndicator</var>,+<var>Options</var>)</code></dt>
<dd><a name="IDX1958"></a>
<a name="IDX1959"></a>
<a name="IDX1960"></a>
<p>Sets tabling mode options for the list or predicate given by
<var>PredIndicator</var>. The list of <var>Options</var> includes:
</p><dl compact="compact">
<dt> <code><code>batched</code>: use batched scheduling for this predicate (default).</code></dt>
<dt> <code><code>local</code>: use local scheduling for this predicate.</code></dt>
<dt> <code><code>exec_answers</code>: use complete tries as code (default).</code></dt>
<dt> <code><code>load_answers</code>: use complete tries as a consumer, somewhat less</code></dt>
<dd><p>efficient but creates less choice-points.
</p></dd>
</dl>
</dd>
<dt> <code>abolish_table(+<var>PredIndicator</var>)</code></dt>
<dd><a name="IDX1961"></a>
<a name="IDX1962"></a>
<a name="IDX1963"></a>
<p>Remove tables for <var>PredIndicator</var>
</p>
</dd>
<dt> <code>show_table(+<var>PredIndicator</var>)</code></dt>
<dd><a name="IDX1964"></a>
<a name="IDX1965"></a>
<a name="IDX1966"></a>
<p>Print out the contents of the table generated for <var>PredIndicator</var>.
</p>
</dd>
<dt> <code>table_statistics(+<var>PredIndicator</var>)</code></dt>
<dd><a name="IDX1967"></a>
<a name="IDX1968"></a>
<a name="IDX1969"></a>
<p>Print out some information on the current tables for
<var>PredIndicator</var>.
</p>
</dd>
</dl>
<hr size="6">
<a name="Low-Level-Tracing"></a>
<a name="SEC136"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC135" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC137" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC135" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC137" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 17. Tracing at Low Level </h1>
<p>It is possible to follow the flow at abstract machine level if
YAP is compiled with the flag <code>LOW_LEVEL_TRACER</code>. Note
that this option is of most interest to implementers, as it quickly generates
an huge amount of information.
</p>
<p>Low level tracing can be toggled from an interrupt handler by using the
option <code>T</code>. There are also two built-ins that activate and
deactivate low level tracing:
</p>
<dl compact="compact">
<dt> <code>start_low_level_trace</code></dt>
<dd><a name="IDX1970"></a>
<a name="IDX1971"></a>
<a name="IDX1972"></a>
<p>Begin display of messages at procedure entry and retry.
</p>
</dd>
<dt> <code>stop_low_level_trace</code></dt>
<dd><a name="IDX1973"></a>
<a name="IDX1974"></a>
<a name="IDX1975"></a>
<p>Stop display of messages at procedure entry and retry.
</p></dd>
</dl>
<p>Note that this compile-time option will slow down execution.
</p>
<hr size="6">
<a name="Low-Level-Profiling"></a>
<a name="SEC137"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC136" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC138" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC136" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC138" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 18. Profiling the Abstract Machine </h1>
<p>Implementors may be interested in detecting on which abstract machine
instructions are executed by a program. The <code>ANALYST</code> flag can give
WAM level information. Note that this option slows down execution very
substantially, and is only of interest to developers of the system
internals, or to system debuggers.
</p>
<dl compact="compact">
<dt> <code>reset_op_counters</code></dt>
<dd><a name="IDX1976"></a>
<a name="IDX1977"></a>
<a name="IDX1978"></a>
<p>Reinitialize all counters.
</p>
</dd>
<dt> <code>show_op_counters(+<var>A</var>)</code></dt>
<dd><a name="IDX1979"></a>
<a name="IDX1980"></a>
<a name="IDX1981"></a>
<p>Display the current value for the counters, using label <var>A</var>. The
label must be an atom.
</p>
</dd>
<dt> <code>show_ops_by_group(+<var>A</var>)</code></dt>
<dd><a name="IDX1982"></a>
<a name="IDX1983"></a>
<a name="IDX1984"></a>
<p>Display the current value for the counters, organized by groups, using
label <var>A</var>. The label must be an atom.
</p>
</dd>
</dl>
<hr size="6">
<a name="Debugging"></a>
<a name="SEC138"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC137" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC139" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC137" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC141" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 19. Debugging </h1>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC139">19.1 Debugging Predicates</a></td><td> </td><td align="left" valign="top"></td></tr>
<tr><td align="left" valign="top"><a href="#SEC140">19.2 Interacting with the debugger</a></td><td> </td><td align="left" valign="top"></td></tr>
</table>
<hr size="6">
<a name="Deb-Preds"></a>
<a name="SEC139"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC138" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC140" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC138" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC138" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC141" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 19.1 Debugging Predicates </h2>
<p>The following predicates are available to control the debugging of
programs:
</p>
<dl compact="compact">
<dt> <code>debug</code></dt>
<dd><a name="IDX1985"></a>
<a name="IDX1986"></a>
<a name="IDX1987"></a>
<p>Switches the debugger on.
</p>
</dd>
<dt> <code>debugging</code></dt>
<dd><a name="IDX1988"></a>
<a name="IDX1989"></a>
<a name="IDX1990"></a>
<p>Outputs status information about the debugger which includes the leash
mode and the existing spy-points, when the debugger is on.
</p>
</dd>
<dt> <code>nodebug</code></dt>
<dd><a name="IDX1991"></a>
<a name="IDX1992"></a>
<a name="IDX1993"></a>
<p>Switches the debugger off.
</p>
</dd>
<dt> <code>spy +<var>P</var></code></dt>
<dd><a name="IDX1994"></a>
<a name="IDX1995"></a>
<a name="IDX1996"></a>
<p> Sets spy-points on all the predicates represented by
<var>P</var>. <var>P</var> can either be a single specification or a list of
specifications. Each one must be of the form <var>Name/Arity</var>
or <var>Name</var>. In the last case all predicates with the name
<var>Name</var> will be spied. As in C-Prolog, system predicates and
predicates written in C, cannot be spied.
</p>
</dd>
<dt> <code>nospy +<var>P</var></code></dt>
<dd><a name="IDX1997"></a>
<a name="IDX1998"></a>
<a name="IDX1999"></a>
<p> Removes spy-points from all predicates specified by <var>P</var>.
The possible forms for <var>P</var> are the same as in <code>spy P</code>.
</p>
</dd>
<dt> <code>nospyall</code></dt>
<dd><a name="IDX2000"></a>
<a name="IDX2001"></a>
<a name="IDX2002"></a>
<p>Removes all existing spy-points.
</p>
</dd>
<dt> <code>notrace</code></dt>
<dd><p>Switches off the debugger and stops tracing.
</p>
</dd>
<dt> <code>leash(+<var>M</var>)</code></dt>
<dd><a name="IDX2003"></a>
<a name="IDX2004"></a>
<a name="IDX2005"></a>
<p> Sets leashing mode to <var>M</var>.
The mode can be specified as:
</p><dl compact="compact">
<dt> <code>full</code></dt>
<dd><p>prompt on Call, Exit, Redo and Fail
</p></dd>
<dt> <code>tight</code></dt>
<dd><p>prompt on Call, Redo and Fail
</p></dd>
<dt> <code>half</code></dt>
<dd><p>prompt on Call and Redo
</p></dd>
<dt> <code>loose</code></dt>
<dd><p>prompt on Call
</p></dd>
<dt> <code>off</code></dt>
<dd><p>never prompt
</p></dd>
<dt> <code>none</code></dt>
<dd><p>never prompt, same as <code>off</code>
</p></dd>
</dl>
<p>The initial leashing mode is <code>full</code>.
</p>
<p>The user may also specify directly the debugger ports
where he wants to be prompted. If the argument for leash
is a number <var>N</var>, each of lower four bits of the number is used to
control prompting at one the ports of the box model. The debugger will
prompt according to the following conditions:
</p>
<ul>
<li>
if <code>N/\ 1 =\= 0</code> prompt on fail
</li><li>
if <code>N/\ 2 =\= 0</code> prompt on redo
</li><li>
if <code>N/\ 4 =\= 0</code> prompt on exit
</li><li>
if <code>N/\ 8 =\= 0</code> prompt on call
</li></ul>
<p>Therefore, <code>leash(15)</code> is equivalent to <code>leash(full)</code> and
<code>leash(0)</code> is equivalent to <code>leash(off)</code>.
</p>
<p>Another way of using <code>leash</code> is to give it a list with the names of
the ports where the debugger should stop. For example,
<code>leash([call,exit,redo,fail])</code> is the same as <code>leash(full)</code> or
<code>leash(15)</code> and <code>leash([fail])</code> might be used instead of
<code>leash(1)</code>.
</p>
</dd>
<dt> <code>spy_write(+<var>Stream</var>,Term)</code></dt>
<dd><a name="IDX2006"></a>
<a name="IDX2007"></a>
<a name="IDX2008"></a>
<p>If defined by the user, this predicate will be used to print goals by
the debugger instead of <code>write/2</code>.
</p>
</dd>
<dt> <code>trace</code></dt>
<dd><p>Switches on the debugger and starts tracing.
</p>
</dd>
</dl>
<hr size="6">
<a name="Deb-Interaction"></a>
<a name="SEC140"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC139" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC141" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC138" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC138" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC141" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 19.2 Interacting with the debugger </h2>
<p>Debugging with YAP is similar to debugging with C-Prolog. Both
systems include a procedural debugger, based in the four port model. In
this model, execution is seen at the procedure level: each activation of
a procedure is seen as a box with control flowing into and out of that
box.
</p>
<p> In the four port model control is caught at four key points: before
entering the procedure, after exiting the procedure (meaning successful
evaluation of all queries activated by the procedure), after backtracking but
before trying new alternative to the procedure and after failing the
procedure. Each one of these points is named a port:
</p>
<table><tr><td> </td><td><pre class="smallexample"> *--------------------------------------*
Call | | Exit
---------> + descendant(X,Y) :- offspring(X,Y). + --------->
| |
| descendant(X,Z) :- |
<--------- + offspring(X,Y), descendant(Y,Z). + <---------
Fail | | Redo
*--------------------------------------*
</pre></td></tr></table>
<dl compact="compact">
<dt> <code>Call</code></dt>
<dd><p>The call port is activated before initial invocation of
procedure. Afterwards, execution will try to match the goal with the
head of existing clauses for the procedure.
</p></dd>
<dt> <code>Exit</code></dt>
<dd><p>This port is activated if the procedure succeeds.
Control will now leave the procedure and return to its ancestor.
</p></dd>
<dt> <code>Redo</code></dt>
<dd><p>if the goal, or goals, activated after the call port
fail then backtracking will eventually return control to this procedure
through the redo port.
</p></dd>
<dt> <code>Fail</code></dt>
<dd><p>If all clauses for this predicate fail, then the
invocation fails, and control will try to redo the ancestor of this
invocation.
</p></dd>
</dl>
<p> To start debugging, the user will usually spy the relevant procedures,
entering debug mode, and start execution of the program. When finding
the first spy-point, YAP's debugger will take control and show a
message like:
</p>
<table><tr><td> </td><td><pre class="example">* (1) call: quicksort([1,2,3],_38) ?
</pre></td></tr></table>
<p> The debugger message will be shown while creeping, or at spy-points,
and it includes four or five fields:
</p>
<ul>
<li>
The first three characters are used to point out special states of the
debugger. If the port is exit and the first character is '?', the
current call still has alternatives to be tried. If the second character is a <code>*</code>, execution is at a
spy-point. If the third character is a <code>></code>, execution has returned
either from a skip, a fail or a redo command.
</li><li>
The second field is the activation number, and uniquely identifies the
activation. The number will start from 1 and will be incremented for
each activation found by the debugger.
</li><li>
In the third field, the debugger shows the active port.
</li><li>
The fourth field is the goal. The goal is written by <code>write/1</code>.
</li></ul>
<p> If the active port is leashed, the debugger will prompt the user with a
<code>?</code>, and wait for a command. A debugger command is just a
character, followed by a return. By default, only the call and redo
entries are leashed, but the <code>leash/1</code> predicate can be used in
order to make the debugger stop where needed.
</p>
<p> There are several commands available, but the user only needs to
remember the help command, which is <code>h</code>. This command shows all the
available options, which are:
</p><dl compact="compact">
<dt> <code>c - creep</code></dt>
<dd><p>this command makes YAP continue execution and stop at the next
leashed port.
</p></dd>
<dt> <code>return - creep</code></dt>
<dd><p>the same as c
</p></dd>
<dt> <code>l - leap</code></dt>
<dd><p>YAP will continue execution until a port of a spied predicate
is found;
</p></dd>
<dt> <code>k - quasi-leap</code></dt>
<dd><p>similar to leap but faster since the computation history is
not kept; useful when leap becomes too slow.
</p></dd>
<dt> <code>s - skip</code></dt>
<dd><p>YAP will continue execution without showing any messages until
returning to the current activation. Spy-points will be ignored in this
mode. This command is meaningless, and therefore illegal, in the fail
and exit ports.
</p></dd>
<dt> <code>t - fast-skip</code></dt>
<dd><p>similar to skip but faster since the computation history is not
kept; useful when skip becomes too slow.
</p></dd>
<dt> <code>q - quasi-leap</code></dt>
<dd><p>YAP will continue execution until a port of a spied
predicate is found or until returning to the current activation.
</p></dd>
<dt> <code>f - fail</code></dt>
<dd><p>forces YAP to fail the goal proceeding directly to the fail port.
The command is not available in the fail port.
</p></dd>
<dt> <code>r - retry</code></dt>
<dd><p>after this command, YAP will retry the present goal, and so go
back to the call port. Note that any side effects of the goal will not
be undone. This command is not available at the call port.
</p></dd>
<dt> <code>a - abort</code></dt>
<dd><p>execution will be aborted, and the interpreter will return to the
top-level.
</p></dd>
<dt> <code>n - nodebug</code></dt>
<dd><p>stop debugging but continue execution. The command will clear all active
spy-points, leave debugging mode and continue execution.
</p></dd>
<dt> <code>e - exit</code></dt>
<dd><p>leave YAP.
</p></dd>
<dt> <code>h - help</code></dt>
<dd><p>show the debugger commands.
</p></dd>
<dt> <code>! Query</code></dt>
<dd><p>execute a query. YAP will not show the result of the query.
</p></dd>
<dt> <code>b - break</code></dt>
<dd><p>break active execution and launch a break level. This is the same as !
break.
</p></dd>
<dt> <code>+ - spy this goal</code></dt>
<dd><p>start spying the active goal. The same as <code>! spy G</code> where <var>G</var>
is the active goal.
</p></dd>
<dt> <code>- - nospy this goal</code></dt>
<dd><p>stop spying the active goal. The same as <code>! nospy G</code> where <var>G</var> is
the active goal.
</p></dd>
<dt> <code>p - print</code></dt>
<dd><p>shows the active goal using print/1
</p></dd>
<dt> <code>d - display</code></dt>
<dd><p>shows the active goal using display/1
</p></dd>
<dt> <code><Depth - debugger write depth</code></dt>
<dd><p>sets the maximum write depth, both for composite terms and lists, that
will be used by the debugger. For more
information about <code>write_depth/2</code> (see section <a href="#SEC44">Controlling Input/Output</a>).
</p></dd>
<dt> <code>< - full term</code></dt>
<dd><p>resets to the default of ten the debugger's maximum write depth. For
more information about <code>write_depth/2</code> (see section <a href="#SEC44">Controlling Input/Output</a>).
</p></dd>
<dt> <code>A - alternatives</code></dt>
<dd><p> show the list of backtrack points in the current execution.
</p></dd>
</dl>
<p>The debugging information, when fast-skip <code>quasi-leap</code> is used, will
be lost.
</p>
<hr size="6">
<a name="Efficiency"></a>
<a name="SEC141"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC140" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC142" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC138" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC142" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 20. Indexing </h1>
<p>The indexation mechanism restricts the set of clauses to be tried in a
procedure by using information about the status of a selected argument of
the goal (in YAP, as in most compilers, the first argument).
This argument
is then used as a key, selecting a restricted set of a clauses from all the
clauses forming the procedure.
</p>
<p>As an example, the two clauses for concatenate:
</p>
<table><tr><td> </td><td><pre class="example">concatenate([],L,L).
concatenate([H|T],A,[H|NT]) :- concatenate(T,A,NT).
</pre></td></tr></table>
<p>If the first argument for the goal is a list, then only the second clause
is of interest. If the first argument is the nil atom, the system needs to
look only for the first clause. The indexation generates instructions that
test the value of the first argument, and then proceed to a selected clause,
or group of clauses.
</p>
<p>Note that if the first argument was a free variable, then both clauses
should be tried. In general, indexation will not be useful if the first
argument is a free variable.
</p>
<p>When activating a predicate, a Prolog system needs to store state
information. This information, stored in a structure known as choice point
or fail point, is necessary when backtracking to other clauses for the
predicate. The operations of creating and using a choice point are very
expensive, both in the terms of space used and time spent.
Creating a choice point is not necessary if there is only a clause for
the predicate as there are no clauses to backtrack to. With indexation, this
situation is extended: in the example, if the first argument was the atom
nil, then only one clause would really be of interest, and it is pointless to
create a choice point. This feature is even more useful if the first argument
is a list: without indexation, execution would try the first clause, creating
a choice point. The clause would fail, the choice point would then be used to
restore the previous state of the computation and the second clause would
be tried. The code generated by the indexation mechanism would behave
much more efficiently: it would test the first argument and see whether it
is a list, and then proceed directly to the second clause.
</p>
<p>An important side effect concerns the use of "cut". In the above
example, some programmers would use a "cut" in the first clause just to
inform the system that the predicate is not backtrackable and force the
removal the choice point just created. As a result, less space is needed but
with a great loss in expressive power: the "cut" would prevent some uses of
the procedure, like generating lists through backtracking. Of course, with
indexation the "cut" becomes useless: the choice point is not even created.
</p>
<p>Indexation is also very important for predicates with a large number
of clauses that are used like tables:
</p>
<table><tr><td> </td><td><pre class="example">logician(aristhoteles,greek).
logician(frege,german).
logician(russel,english).
logician(godel,german).
logician(whitehead,english).
</pre></td></tr></table>
<p>An interpreter like C-Prolog, trying to answer the query:
</p>
<table><tr><td> </td><td><pre class="example">?- logician(godel,X).
</pre></td></tr></table>
<p>would blindly follow the standard Prolog strategy, trying first the
first clause, then the second, the third and finally finding the
relevant clause. Also, as there are some more clauses after the
important one, a choice point has to be created, even if we know the
next clauses will certainly fail. A "cut" would be needed to prevent
some possible uses for the procedure, like generating all logicians. In
this situation, the indexing mechanism generates instructions that
implement a search table. In this table, the value of the first argument
would be used as a key for fast search of possibly matching clauses. For
the query of the last example, the result of the search would be just
the fourth clause, and again there would be no need for a choice point.
</p>
<p> If the first argument is a complex term, indexation will select clauses
just by testing its main functor. However, there is an important
exception: if the first argument of a clause is a list, the algorithm
also uses the list's head if not a variable. For instance, with the
following clauses,
</p>
<table><tr><td> </td><td><pre class="example">rules([],B,B).
rules([n(N)|T],I,O) :- rules_for_noun(N,I,N), rules(T,N,O).
rules([v(V)|T],I,O) :- rules_for_verb(V,I,N), rules(T,N,O).
rules([q(Q)|T],I,O) :- rules_for_qualifier(Q,I,N), rules(T,N,O).
</pre></td></tr></table>
<p>if the first argument of the goal is a list, its head will be tested, and only
the clauses matching it will be tried during execution.
</p>
<p>Some advice on how to take a good advantage of this mechanism:
</p>
<ul>
<li>
Try to make the first argument an input argument.
</li><li>
Try to keep together all clauses whose first argument is not a
variable, that will decrease the number of tests since the other clauses are
always tried.
</li><li>
Try to avoid predicates having a lot of clauses with the same key.
For instance, the procedure:
</li></ul>
<table><tr><td> </td><td><pre class="example">type(n(mary),person).
type(n(john), person).
type(n(chair),object).
type(v(eat),active).
type(v(rest),passive).
</pre></td></tr></table>
<p> becomes more efficient with:
</p>
<table><tr><td> </td><td><pre class="example">type(n(N),T) :- type_of_noun(N,T).
type(v(V),T) :- type_of_verb(V,T).
type_of_noun(mary,person).
type_of_noun(john,person).
type_of_noun(chair,object).
type_of_verb(eat,active).
type_of_verb(rest,passive).
</pre></td></tr></table>
<hr size="6">
<a name="C_002dInterface"></a>
<a name="SEC142"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC141" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC143" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC141" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC153" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 21. C Language interface to YAP </h1>
<p>YAP provides the user with the necessary facilities for writing
predicates in a language other than prolog. Since, under Unix systems,
most language implementations are link-able to C, we will describe here
only the YAP interface to the C language.
</p>
<p>Before describing in full detail how to interface to C code, we will examine
a brief example.
</p>
<p>Assume the user requires a predicate <code>my_process_id(Id)</code> which succeeds
when <var>Id</var> unifies with the number of the process under which YAP is running.
</p>
<p>In this case we will create a <code>my_process.c</code> file containing the
C-code described below.
</p>
<table><tr><td> </td><td><table class="cartouche" border="1"><tr><td>
<pre class="example">#include "Yap/YapInterface.h"
static int my_process_id(void)
{
YAP_Term pid = YAP_MkIntTerm(getpid());
YAP_Term out = YAP_ARG1;
return(YAP_Unify(out,pid));
}
void init_my_predicates()
{
YAP_UserCPredicate("my_process_id",my_process_id,1);
}
</pre></td></tr></table>
</td></tr></table>
<p>The commands to compile the above file depend on the operating
system. Under Linux (i386 and Alpha) you should use:
</p><table><tr><td> </td><td><pre class="example"> gcc -c -shared -fPIC my_process.c
ld -shared -o my_process.so my_process.o
</pre></td></tr></table>
<p>Under Solaris2 it is sufficient to use:
</p><table><tr><td> </td><td><pre class="example"> gcc -fPIC -c my_process.c
</pre></td></tr></table>
<p>Under SunOS it is sufficient to use:
</p><table><tr><td> </td><td><pre class="example"> gcc -c my_process.c
</pre></td></tr></table>
<p>Under Digital Unix you need to create a <code>so</code> file. Use:
</p><table><tr><td> </td><td><pre class="example"> gcc tst.c -c -fpic
ld my_process.o -o my_process.so -shared -expect_unresolved '*'
</pre></td></tr></table>
<p>and replace my <code>process.so</code> for my <code>process.o</code> in the
remainder of the example.
And could be loaded, under YAP, by executing the following prolog goal
</p><table><tr><td> </td><td><pre class="example"> load_foreign_files(['my_process'],[],init_my_predicates).
</pre></td></tr></table><p>Note that since Yap4.3.3 you should not give the suffix for object
files. YAP will deduce the correct suffix from the operating system it
is running under.
</p>
<p>Yap4.3.3 now supports loading WIN/NT DLLs. Currently you must compile
YAP under cygwin to create a library yap.dll first. You can then use
this dll to create your own dlls. Have a look at the code in
library/regex to see how to create a dll under the cygwin/mingw32
environment.
</p>
<p>After loading that file the following prolog goal
</p><table><tr><td> </td><td><pre class="example"> my_process_id(N)
</pre></td></tr></table>
<p>would unify N with the number of the process under which Yap is running.
</p>
<p>Having presented a full example, we will now examine in more detail the
contents of the C source code file presented above.
</p>
<p>The include statement is used to make available to the C source code the
macros for the handling of prolog terms and also some Yap public
definitions.
</p>
<p>The function <code>my_process_id</code> is the implementation, in C, of the
desired predicate. Note that it returns an integer denoting the success
of failure of the goal and also that it has no arguments even though the
predicate being defined has one.
In fact the arguments of a prolog predicate written in C are accessed
through macros, defined in the include file, with names <var>YAP_ARG1</var>,
<var>YAP_ARG2</var>, ..., <var>YAP_ARG16</var> or with <var>YAP_A</var>(<var>N</var>)
where <var>N</var> is the argument number (starting with 1). In the present
case the function uses just one local variable of type <code>YAP_Term</code>, the
type used for holding Yap terms, where the integer returned by the
standard unix function <code>getpid()</code> is stored as an integer term (the
conversion is done by <code>YAP_MkIntTerm(Int))</code>. Then it calls the
pre-defined routine <code>YAP_Unify(YAP_Term, YAP_Term)</code> which in turn returns an
integer denoting success or failure of the unification.
</p>
<p>The role of the procedure <code>init_my_predicates</code> is to make known to
YAP, by calling <code>YAP_UserCPredicate</code>, the predicates being
defined in the file. This is in fact why, in the example above,
<code>init_my_predicates</code> was passed as the third argument to
<code>load_foreign_files</code>.
</p>
<p>The rest of this appendix describes exhaustively how to interface C to YAP.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC143">21.1 Terms</a></td><td> </td><td align="left" valign="top"> Primitives available to the C programmer
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC144">21.2 Unification</a></td><td> </td><td align="left" valign="top"> How to Unify Two Prolog Terms
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC145">21.3 Strings</a></td><td> </td><td align="left" valign="top"> From character arrays to Lists of codes and back
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC146">21.4 Memory Allocation</a></td><td> </td><td align="left" valign="top"> Stealing Memory From Yap
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC147">21.5 Controlling Yap Streams from <code>C</code></a></td><td> </td><td align="left" valign="top"> Control How Yap sees Streams
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC148">21.6 From <code>C</code> back to Prolog</a></td><td> </td><td align="left" valign="top"> From C to Yap to C to Yap
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC149">21.7 Writing predicates in C</a></td><td> </td><td align="left" valign="top"> Writing Predicates in C
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC150">21.8 Loading Object Files</a></td><td> </td><td align="left" valign="top"></td></tr>
<tr><td align="left" valign="top"><a href="#SEC151">21.9 Saving and Restoring</a></td><td> </td><td align="left" valign="top"></td></tr>
<tr><td align="left" valign="top"><a href="#SEC152">21.10 Changes to the C-Interface in Yap4</a></td><td> </td><td align="left" valign="top"> Changes in Foreign Predicates Interface
</td></tr>
</table>
<hr size="6">
<a name="Manipulating-Terms"></a>
<a name="SEC143"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC142" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC144" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC142" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC142" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC153" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 21.1 Terms </h2>
<p>This section provides information about the primitives available to the C
programmer for manipulating prolog terms.
</p>
<p>Several C typedefs are included in the header file <code>yap/YapInterface.h</code> to
describe, in a portable way, the C representation of prolog terms.
The user should write is programs using this macros to ensure portability of
code across different versions of YAP.
</p>
<p>The more important typedef is <var>YAP_Term</var> which is used to denote the
type of a prolog term.
</p>
<p>Terms, from a point of view of the C-programmer, can be classified as
follows
</p><dl compact="compact">
<dt> <i>uninstantiated variables</i></dt>
<dt> <i>instantiated variables</i></dt>
<dt> <i>integers</i></dt>
<dt> <i>floating-point numbers</i></dt>
<dt> <i>database references</i></dt>
<dt> <i>atoms</i></dt>
<dt> <i>pairs (lists)</i></dt>
<dt> <i>compound terms</i></dt>
</dl>
<a name="IDX2009"></a>
<p>The primitive
</p><table><tr><td> </td><td><pre class="example"> YAP_Bool YAP_IsVarTerm(YAP_Term <var>t</var>)
</pre></td></tr></table>
<a name="IDX2010"></a>
<p>returns true iff its argument is an uninstantiated variable. Conversely the
primitive
</p><table><tr><td> </td><td><pre class="example"> YAP_Bool YAP_NonVarTerm(YAP_Term <var>t</var>)
</pre></td></tr></table>
<p>returns true iff its argument is not a variable.
</p>
<p>The user can create a new uninstantiated variable using the primitive
</p><table><tr><td> </td><td><pre class="example"> YAP_Term YAP_MkVarTerm()
</pre></td></tr></table>
<a name="IDX2011"></a>
<a name="IDX2012"></a>
<a name="IDX2013"></a>
<a name="IDX2014"></a>
<a name="IDX2015"></a>
<a name="IDX2016"></a>
<p>The following primitives can be used to discriminate among the different types
of non-variable terms:
</p><table><tr><td> </td><td><pre class="example"> YAP_Bool YAP_IsIntTerm(YAP_Term <var>t</var>)
YAP_Bool YAP_IsFloatTerm(YAP_Term <var>t</var>)
YAP_Bool YAP_IsDbRefTerm(YAP_Term <var>t</var>)
YAP_Bool YAP_IsAtomTerm(YAP_Term <var>t</var>)
YAP_Bool YAP_IsPairTerm(YAP_Term <var>t</var>)
YAP_Bool YAP_IsApplTerm(YAP_Term <var>t</var>)
</pre></td></tr></table>
<p>Next, we mention the primitives that allow one to destruct and construct
terms. All the above primitives ensure that their result is
<i>dereferenced</i>, i.e. that it is not a pointer to another term.
</p>
<a name="IDX2017"></a>
<a name="IDX2018"></a>
<p>The following primitives are provided for creating an integer term from an
integer and to access the value of an integer term.
</p><table><tr><td> </td><td><pre class="example"> YAP_Term YAP_MkIntTerm(YAP_Int <var>i</var>)
YAP_Int YAP_IntOfTerm(YAP_Term <var>t</var>)
</pre></td></tr></table>
<p>where <code>YAP_Int</code> is a typedef for the C integer type appropriate for
the machine or compiler in question (normally a long integer). The size
of the allowed integers is implementation dependent but is always
greater or equal to 24 bits: usually 32 bits on 32 bit machines, and 64
on 64 bit machines.
</p>
<a name="IDX2019"></a>
<a name="IDX2020"></a>
<p>The two following primitives play a similar role for floating-point terms
</p><table><tr><td> </td><td><pre class="example"> YAP_Term YAP_MkFloatTerm(YAP_flt <var>double</var>)
YAP_flt YAP_FloatOfTerm(YAP_Term <var>t</var>)
</pre></td></tr></table>
<p>where <code>flt</code> is a typedef for the appropriate C floating point type,
nowadays a <code>double</code>
</p>
<a name="IDX2021"></a>
<a name="IDX2022"></a>
<a name="IDX2023"></a>
<p>The following primitives are provided for verifying whether a term is
a big int, creating a term from a big integer and to access the value
of a big int from a term.
</p><table><tr><td> </td><td><pre class="example"> YAP_Bool YAP_IsBigNumTerm(YAP_Term <var>t</var>)
YAP_Term YAP_MkBigNumTerm(void *<var>b</var>)
void *YAP_BigNumOfTerm(YAP_Term <var>t</var>, void *<var>b</var>)
</pre></td></tr></table>
<p>YAP must support bignum for the configuration you are using (check the
YAP configuration and setup). For now, Yap only supports the GNU GMP
library, and <code>void *</code> will be a cast for <code>mpz_t</code>. Notice
that <code>YAP_BigNumOfTerm</code> requires the number to be already
initialised. As an example, we show how to print a bignum:
</p>
<table><tr><td> </td><td><pre class="example">static int
p_print_bignum(void)
{
mpz_t mz;
if (!YAP_IsBigNumTerm(YAP_ARG1))
return FALSE;
mpz_init(mz);
YAP_BigNumOfTerm(YAP_ARG1, mz);
gmp_printf("Shows up as %Zd\n", mz);
mpz_clear(mz);
return TRUE;
}
</pre></td></tr></table>
<p>Currently, no primitives are supplied to users for manipulating data base
references.
</p>
<a name="IDX2024"></a>
<a name="IDX2025"></a>
<p>A special typedef <code>YAP_Atom</code> is provided to describe prolog
<i>atoms</i> (symbolic constants). The two following primitives can be used
to manipulate atom terms
</p><table><tr><td> </td><td><pre class="example"> YAP_Term YAP_MkAtomTerm(YAP_Atom at)
YAP_Atom YAP_AtomOfTerm(YAP_Term <var>t</var>)
</pre></td></tr></table>
<a name="IDX2026"></a>
<a name="IDX2027"></a>
<a name="IDX2028"></a>
<p>The following primitives are available for associating atoms with their
names
</p><table><tr><td> </td><td><pre class="example"> YAP_Atom YAP_LookupAtom(char * <var>s</var>)
YAP_Atom YAP_FullLookupAtom(char * <var>s</var>)
char *YAP_AtomName(YAP_Atom <var>t</var>)
</pre></td></tr></table><p>The function <code>YAP_LookupAtom</code> looks up an atom in the standard hash
table. The function <code>YAP_FullLookupAtom</code> will also search if the
atom had been "hidden": this is useful for system maintenance from C
code. The functor <code>YAP_AtomName</code> returns a pointer to the string
for the atom.
</p>
<a name="IDX2029"></a>
<a name="IDX2030"></a>
<a name="IDX2031"></a>
<a name="IDX2032"></a>
<p>A <i>pair</i> is a Prolog term which consists of a tuple of two prolog
terms designated as the <i>head</i> and the <i>tail</i> of the term. Pairs are
most often used to build <em>lists</em>. The following primitives can be
used to manipulate pairs:
</p><table><tr><td> </td><td><pre class="example"> YAP_Term YAP_MkPairTerm(YAP_Term <var>Head</var>, YAP_Term <var>Tail</var>)
YAP_Term YAP_MkNewPairTerm(void)
YAP_Term YAP_HeadOfTerm(YAP_Term <var>t</var>)
YAP_Term YAP_TailOfTerm(YAP_Term <var>t</var>)
</pre></td></tr></table><p>One can construct a new pair from two terms, or one can just build a
pair whose head and tail are new unbound variables. Finally, one can
fetch the head or the tail.
</p>
<a name="IDX2033"></a>
<a name="IDX2034"></a>
<a name="IDX2035"></a>
<a name="IDX2036"></a>
<p>A <i>compound</i> term consists of a <i>functor</i> and a sequence of terms with
length equal to the <i>arity</i> of the functor. A functor, described in C by
the typedef <code>Functor</code>, consists of an atom and of an integer.
The following primitives were designed to manipulate compound terms and
functors
</p><table><tr><td> </td><td><pre class="example"> YAP_Term YAP_MkApplTerm(YAP_Functor <var>f</var>, unsigned long int <var>n</var>, YAP_Term[] <var>args</var>)
YAP_Term YAP_MkNewApplTerm(YAP_Functor <var>f</var>, int <var>n</var>)
YAP_Term YAP_ArgOfTerm(int argno,YAP_Term <var>ts</var>)
YAP_Functor YAP_FunctorOfTerm(YAP_Term <var>ts</var>)
</pre></td></tr></table>
<p>The <code>YAP_MkApplTerm</code> function constructs a new term, with functor
<var>f</var> (of arity <var>n</var>), and using an array <var>args</var> of <var>n</var>
terms with <var>n</var> equal to the arity of the
functor. <code>YAP_MkNewApplTerm</code> builds up a compound term whose
arguments are unbound variables. <code>YAP_ArgOfTerm</code> gives an argument
to a compound term. <code>argno</code> should be greater or equal to 1 and
less or equal to the arity of the functor.
</p>
<p>YAP allows one to manipulate the functors of compound term. The function
<code>YAP_FunctorOfTerm</code> allows one to obtain a variable of type
<code>YAP_Functor</code> with the functor to a term. The following functions
then allow one to construct functors, and to obtain their name and arity.
</p>
<a name="IDX2037"></a>
<a name="IDX2038"></a>
<a name="IDX2039"></a>
<table><tr><td> </td><td><pre class="example"> YAP_Functor YAP_MkFunctor(YAP_Atom <var>a</var>,unsigned long int <var>arity</var>)
YAP_Atom YAP_NameOfFunctor(YAP_Functor <var>f</var>)
YAP_Int YAP_ArityOfFunctor(YAP_Functor <var>f</var>)
</pre></td></tr></table>
<p>Note that the functor is essentially a pair formed by an atom, and
arity.
</p>
<hr size="6">
<a name="Unifying-Terms"></a>
<a name="SEC144"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC143" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC145" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC142" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC142" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC153" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 21.2 Unification </h2>
<p>YAP provides a single routine to attempt the unification of two prolog
terms. The routine may succeed or fail:
</p><table><tr><td> </td><td><pre class="example"> Int YAP_Unify(YAP_Term <var>a</var>, YAP_Term <var>b</var>)
</pre></td></tr></table>
<p>The routine attempts to unify the terms <var>a</var> and
<var>b</var> returning <code>TRUE</code> if the unification succeeds and <code>FALSE</code>
otherwise.
</p>
<hr size="6">
<a name="Manipulating-Strings"></a>
<a name="SEC145"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC144" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC146" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC142" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC142" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC153" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 21.3 Strings </h2>
<p>The YAP C-interface now includes an utility routine to copy a string
represented as a list of a character codes to a previously allocated buffer
</p><table><tr><td> </td><td><pre class="example"> int YAP_StringToBuffer(YAP_Term <var>String</var>, char *<var>buf</var>, unsigned int <var>bufsize</var>)
</pre></td></tr></table>
<p>The routine copies the list of character codes <var>String</var> to a
previously allocated buffer <var>buf</var>. The string including a
terminating null character must fit in <var>bufsize</var> characters,
otherwise the routine will simply fail. The <var>StringToBuffer</var> routine
fails and generates an exception if <var>String</var> is not a valid string.
</p>
<a name="IDX2040"></a>
<a name="IDX2041"></a>
<p>The C-interface also includes utility routines to do the reverse, that
is, to copy a from a buffer to a list of character codes or to a list of
character atoms
</p><table><tr><td> </td><td><pre class="example"> YAP_Term YAP_BufferToString(char *<var>buf</var>)
YAP_Term YAP_BufferToAtomList(char *<var>buf</var>)
</pre></td></tr></table>
<p>The user-provided string must include a terminating null character.
</p>
<a name="IDX2042"></a>
<p>The C-interface function calls the parser on a sequence of characters
stored at <var>buf</var> and returns the resulting term.
</p><table><tr><td> </td><td><pre class="example"> YAP_Term YAP_ReadBuffer(char *<var>buf</var>,YAP_Term *<var>error</var>)
</pre></td></tr></table>
<p>The user-provided string must include a terminating null
character. Syntax errors will cause returning <code>FALSE</code> and binding
<var>error</var> to a Prolog term.
</p>
<hr size="6">
<a name="Memory-Allocation"></a>
<a name="SEC146"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC145" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC147" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC142" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC142" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC153" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 21.4 Memory Allocation </h2>
<p>The next routine can be used to ask space from the Prolog data-base:
</p><table><tr><td> </td><td><pre class="example"> void *YAP_AllocSpaceFromYap(int <var>size</var>)
</pre></td></tr></table>
<p>The routine returns a pointer to a buffer allocated from the code area,
or <code>NULL</code> if sufficient space was not available.
</p>
<a name="IDX2043"></a>
<p>The space allocated with <code>YAP_AllocSpaceFromYap</code> can be released
back to Yap by using:
</p><table><tr><td> </td><td><pre class="example"> void YAP_FreeSpaceFromYap(void *<var>buf</var>)
</pre></td></tr></table>
<p>The routine releases a buffer allocated from the code area. The system
may crash if <code>buf</code> is not a valid pointer to a buffer in the code
area.
</p>
<hr size="6">
<a name="Controlling-Streams"></a>
<a name="SEC147"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC146" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC148" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC142" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC142" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC153" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 21.5 Controlling Yap Streams from <code>C</code> </h2>
<p>The C-Interface also provides the C-application with a measure of
control over the Yap Input/Output system. The first routine allows one
to find a file number given a current stream:
</p><table><tr><td> </td><td><pre class="example"> int YAP_StreamToFileNo(YAP_Term <var>stream</var>)
</pre></td></tr></table>
<p>This function gives the file descriptor for a currently available
stream. Note that null streams and in memory streams do not have
corresponding open streams, so the routine will return a
negative. Moreover, Yap will not be aware of any direct operations on
this stream, so information on, say, current stream position, may become
stale.
</p>
<a name="IDX2044"></a>
<p>A second routine that is sometimes useful is:
</p><table><tr><td> </td><td><pre class="example"> void YAP_CloseAllOpenStreams(void)
</pre></td></tr></table>
<p>This routine closes the Yap Input/Output system except for the first
three streams, that are always associated with the three standard Unix
streams. It is most useful if you are doing <code>fork()</code>.
</p>
<a name="IDX2045"></a>
<p>The next routine allows a currently open file to become a stream. The
routine receives as arguments a file descriptor, the true file name as a
string, an atom with the user name, and a set of flags:
</p><table><tr><td> </td><td><pre class="example"> void YAP_OpenStream(void *<var>FD</var>, char *<var>name</var>, YAP_Term <var>t</var>, int <var>flags</var>)
</pre></td></tr></table>
<p>The available flags are <code>YAP_INPUT_STREAM</code>,
<code>YAP_OUTPUT_STREAM</code>, <code>YAP_APPEND_STREAM</code>,
<code>YAP_PIPE_STREAM</code>, <code>YAP_TTY_STREAM</code>, <code>YAP_POPEN_STREAM</code>,
<code>YAP_BINARY_STREAM</code>, and <code>YAP_SEEKABLE_STREAM</code>. By default, the
stream is supposed to be at position 0. The argument <var>name</var> gives
the name by which YAP should know the new stream.
</p>
<hr size="6">
<a name="Calling-Yap-From-C"></a>
<a name="SEC148"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC147" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC149" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC142" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC142" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC153" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 21.6 From <code>C</code> back to Prolog </h2>
<p>Newer versions of YAP allow for calling the Prolog interpreter from
<code>C</code>. One must first construct a goal <code>G</code>, and then it is
sufficient to perform:
</p><table><tr><td> </td><td><pre class="example"> YAP_Bool YapCallProlog(YAP_Term <var>G</var>)
</pre></td></tr></table>
<p>the result will be <code>FALSE</code>, if the goal failed, or <code>TRUE</code>, if
the goal succeeded. In this case, the variables in <var>G</var> will store
the values they have been unified with. Execution only proceeds until
finding the first solution to the goal, but you can call
<code>findall/3</code> or friends if you need all the solutions.
</p>
<hr size="6">
<a name="Writing-C"></a>
<a name="SEC149"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC148" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC150" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC142" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC142" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC153" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 21.7 Writing predicates in C </h2>
<p>We will distinguish two kinds of predicates:
</p><dl compact="compact">
<dt> <i><i>deterministic</i> predicates which either fail or succeed but are not</i></dt>
<dd><p>backtrackable, like the one in the introduction;
</p></dd>
<dt> <i><i>backtrackable</i></i></dt>
<dd><p>predicates which can succeed more than once.
</p></dd>
</dl>
<a name="IDX2046"></a>
<p>The first kind of predicates should be implemented as a C function with
no arguments which should return zero if the predicate fails and a
non-zero value otherwise. The predicate should be declared to
YAP, in the initialization routine, with a call to
</p><table><tr><td> </td><td><pre class="example"> void YAP_UserCPredicate(char *<var>name</var>, YAP_Bool *<var>fn</var>(), unsigned long int <var>arity</var>);
</pre></td></tr></table>
<p>where <var>name</var> is the name of the predicate, <var>fn</var> is the C function
implementing the predicate and <var>arity</var> is its arity.
</p>
<a name="IDX2047"></a>
<a name="IDX2048"></a>
<a name="IDX2049"></a>
<a name="IDX2050"></a>
<a name="IDX2051"></a>
<p>For the second kind of predicates we need two C functions. The first one
which is called when the predicate is first activated, and the second one
to be called on backtracking to provide (possibly) other solutions. Note
also that we normally also need to preserve some information to find out
the next solution.
</p>
<p>In fact the role of the two functions can be better understood from the
following prolog definition
</p><table><tr><td> </td><td><pre class="example"> p :- start.
p :- repeat,
continue.
</pre></td></tr></table>
<p>where <code>start</code> and <code>continue</code> correspond to the two C functions
described above.
</p>
<p>As an example we will consider implementing in C a predicate <code>n100(N)</code>
which, when called with an instantiated argument should succeed if that
argument is a numeral less or equal to 100, and, when called with an
uninstantiated argument, should provide, by backtracking, all the positive
integers less or equal to 100.
</p>
<p> To do that we first declare a structure, which can only consist
of prolog terms, containing the information to be preserved on backtracking
and a pointer variable to a structure of that type.
</p>
<table><tr><td> </td><td><pre class="example">#include "YapInterface.h"
static int start_n100(void);
static int continue_n100(void);
typedef struct {
YAP_Term next_solution; /* the next solution */
} n100_data_type;
n100_data_type *n100_data;
</pre></td></tr></table>
<p>We now write the <code>C</code> function to handle the first call:
</p>
<table><tr><td> </td><td><pre class="example">static int start_n100(void)
{
YAP_Term t = YAP_ARG1;
YAP_PRESERVE_DATA(n100_data,n100_data_type);
if(YAP_IsVarTerm(t)) {
n100_data->next_solution = YAP_MkIntTerm(0);
return continue_n100();
}
if(!YAP_IsIntTerm(t) || YAP_IntOfTerm(t)<0 || YAP_IntOfTerm(t)>100) {
YAP_cut_fail();
} else {
YAP_cut_succeed();
}
}
</pre></td></tr></table>
<p>The routine starts by getting the dereference value of the argument.
The call to <code>YAP_PRESERVE_DATA</code> is used to initialize the memory which will
hold the information to be preserved across backtracking. The first
argument is the variable we shall use, and the second its type. Note
that we can only use <code>YAP_PRESERVE_DATA</code> once, so often we will
want the variable to be a structure.
</p>
<p>If the argument of the predicate is a variable, the routine initializes the
structure to be preserved across backtracking with the information
required to provide the next solution, and exits by calling <code>
continue_n100</code> to provide that solution.
</p>
<p>If the argument was not a variable, the routine then checks if it was an
integer, and if so, if its value is positive and less than 100. In that
case it exits, denoting success, with <code>YAP_cut_succeed</code>, or
otherwise exits with <code>YAP_cut_fail</code> denoting failure.
</p>
<p>The reason for using for using the functions <code>YAP_cut_succeed</code> and
<code>YAP_cut_fail</code> instead of just returning a non-zero value in the
first case, and zero in the second case, is that otherwise, if
backtracking occurred later, the routine <code>continue_n100</code> would be
called to provide additional solutions.
</p>
<p>The code required for the second function is
</p><table><tr><td> </td><td><pre class="example">static int continue_n100(void)
{
int n;
YAP_Term t;
YAP_Term sol = YAP_ARG1;
YAP_PRESERVED_DATA(n100_data,n100_data_type);
n = YAP_IntOfTerm(n100_data->next_solution);
if( n == 100) {
t = YAP_MkIntTerm(n);
YAP_Unify(sol,t);
YAP_cut_succeed();
}
else {
YAP_Unify(sol,n100_data->next_solution);
n100_data->next_solution = YAP_MkIntTerm(n+1);
return(TRUE);
}
}
</pre></td></tr></table>
<p>Note that again the macro <code>YAP_PRESERVED_DATA</code> is used at the
beginning of the function to access the data preserved from the previous
solution. Then it checks if the last solution was found and in that
case exits with <code>YAP_cut_succeed</code> in order to cut any further
backtracking. If this is not the last solution then we save the value
for the next solution in the data structure and exit normally with 1
denoting success. Note also that in any of the two cases we use the
function <code>YAP_unify</code> to bind the argument of the call to the value
saved in <code> n100_state->next_solution</code>.
</p>
<p>Note also that the only correct way to signal failure in a backtrackable
predicate is to use the <code>YAP_cut_fail</code> macro.
</p>
<p>Backtrackable predicates should be declared to YAP, in a way
similar to what happened with deterministic ones, but using instead a
call to
</p><table><tr><td> </td><td><pre class="example"> void YAP_UserBackCPredicate(char *<var>name</var>,
int *<var>init</var>(), int *<var>cont</var>(),
unsigned long int <var>arity</var>, unsigned int <var>sizeof</var>);
</pre></td></tr></table>
<p>where <var>name</var> is a string with the name of the predicate, <var>init</var> and
<var>cont</var> are the C functions used to start and continue the execution of
the predicate, <var>arity</var> is the predicate arity, and <var>sizeof</var> is
the size of the data to be preserved in the stack. In this example, we
would have something like
</p>
<table><tr><td> </td><td><pre class="example">void
init_n100(void)
{
YAP_UserBackCPredicate("n100", start_n100, continue_n100, 1, 1);
}
</pre></td></tr></table>
<hr size="6">
<a name="Loading-Objects"></a>
<a name="SEC150"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC149" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC151" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC142" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC142" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC153" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 21.8 Loading Object Files </h2>
<p>The primitive predicate
</p><table><tr><td> </td><td><pre class="example"> load_foreign_files(<var>Files</var>,<var>Libs</var>,<var>InitRoutine</var>)
</pre></td></tr></table>
<p>should be used, from inside YAP, to load object files produced by the C
compiler. The argument <var>ObjectFiles</var> should be a list of atoms
specifying the object files to load, <var>Libs</var> is a list (possibly
empty) of libraries to be passed to the unix loader (<code>ld</code>) and
InitRoutine is the name of the C routine (to be called after the files
are loaded) to perform the necessary declarations to YAP of the
predicates defined in the files.
</p>
<p>YAP will search for <var>ObjectFiles</var> in the current directory first. If
it cannot find them it will search for the files using the environment
variable <code>YAPLIBDIR</code>, if defined, or in the default library.
</p>
<p>In a.out systems YAP by default only reserves a fixed amount of memory
for object code (64 Kbytes in the current version). Should this size
prove inadequate the flag <code>-c n</code> can be passed to YAP (in the
command line invoking YAP) to force the allocation of <code>n</code> Kbytes.
</p>
<hr size="6">
<a name="Sav_0026Rest"></a>
<a name="SEC151"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC150" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC152" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC142" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC142" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC153" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 21.9 Saving and Restoring </h2>
<p>Yap4 currently does not support <code>save</code> and <code>restore</code> for object code
loaded with <code>load_foreign_files</code>. We plan to support save and restore
in future releases of Yap.
</p>
<hr size="6">
<a name="Yap4-Notes"></a>
<a name="SEC152"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC151" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC153" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC142" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC142" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC153" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 21.10 Changes to the C-Interface in Yap4 </h2>
<p>Yap4 includes several changes over the previous <code>load_foreign_files</code>
interface. These changes were required to support the new binary code
formats, such as ELF used in Solaris2 and Linux.
</p><ul>
<li> All Names of YAP objects now start with <var>YAP_</var>. This is
designed to avoid clashes with other code. Use <code>YapInterface.h</code> to
take advantage of the new interface. <code>c_interface.h</code> is still
available if you cannot port the code to the new interface.
</li><li> Access to elements in the new interface always goes through
<em>functions</em>. This includes access to the argument registers,
<code>YAP_ARG1</code> to <code>YAP_ARG16</code>. This change breaks code such as
<code>unify(&ARG1,&t)</code>, which is nowadays:
<table><tr><td> </td><td><pre class="example">{
YAP_Unify(ARG1, t);
}
</pre></td></tr></table>
</li><li> <code>cut_fail()</code> and <code>cut_succeed()</code> are now functions.
</li><li> The use of <code>Deref</code> is deprecated. All functions that return
Prolog terms, including the ones that access arguments, already
dereferenciate their arguments.
</li><li> Space allocated with PRESERVE_DATA is ignored by garbage
collection and stack shifting. As a result, any pointers to a Prolog
stack object, including some terms, may be corrupted after garbage
collection or stack shifting. Prolog terms should instead be stored as
arguments to the backtrackable procedure.
</li></ul>
<hr size="6">
<a name="YapLibrary"></a>
<a name="SEC153"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC152" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC142" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 22. Using YAP as a Library </h1>
<p>YAP can be used as a library to be called from other
programs. To do so, you must first create the YAP library:
</p><table><tr><td> </td><td><pre class="example">make library
make install_library
</pre></td></tr></table><p>This will install a file <code>libyap.a</code> in <var>LIBDIR</var> and the Prolog
headers in <var>INCLUDEDIR</var>. The library contains all the functionality
available in YAP, except the foreign function loader and for
<code>Yap</code>'s startup routines.
</p>
<p>To actually use this library you must follow a five step process:
</p>
<ol>
<li>
You must initialize the YAP environment. A single function,
<code>YAP_FastInit</code> asks for a contiguous chunk in your memory space, fills
it in with the data-base, and sets up YAP's stacks and
execution registers. You can use a saved space from a standard system by
calling <code>save_program/1</code>.
</li><li> You then have to prepare a query to give to
YAP. A query is a Prolog term, and you just have to use the same
functions that are available in the C-interface.
</li><li> You can then use <code>YAP_RunGoal(query)</code> to actually evaluate your
query. The argument is the query term <code>query</code>, and the result is 1
if the query succeeded, and 0 if it failed.
</li><li> You can use the term destructor functions to check how
arguments were instantiated.
</li><li> If you want extra solutions, you can use
<code>YAP_RestartGoal()</code> to obtain the next solution.
</li></ol>
<p>The next program shows how to use this system. We assume the saved
program contains two facts for the procedure <tt>b</tt>:
</p>
<table><tr><td> </td><td><table class="cartouche" border="1"><tr><td>
<pre class="example">#include <stdio.h>
#include "Yap/YapInterface.h"
int
main(int argc, char *argv[]) {
if (YAP_FastInit("saved_state") == YAP_BOOT_ERROR)
exit(1);
if (YAP_RunGoal(YAP_MkAtomTerm(YAP_LookupAtom("do")))) {
printf("Success\n");
while (YAP_RestartGoal())
printf("Success\n");
}
printf("NO\n");
}
</pre></td></tr></table>
</td></tr></table>
<p>The program first initializes YAP, calls the query for the
first time and succeeds, and then backtracks twice. The first time
backtracking succeeds, the second it fails and exits.
</p>
<p>To compile this program it should be sufficient to do:
</p>
<table><tr><td> </td><td><pre class="example">cc -o exem -I../Yap4.3.0 test.c -lYap -lreadline -lm
</pre></td></tr></table>
<p>You may need to adjust the libraries and library paths depending on the
Operating System and your installation of Yap.
</p>
<p>Note that Yap4.3.0 provides the first version of the interface. The
interface may change and improve in the future.
</p>
<p>The following C-functions are available from Yap:
</p>
<ul>
<li> YAP_CompileClause(<code>YAP_Term</code> <var>Clause</var>)
<a name="IDX2052"></a>
Compile the Prolog term <var>Clause</var> and assert it as the last clause
for the corresponding procedure.
</li><li> <code>int</code> YAP_ContinueGoal(<code>void</code>)
<a name="IDX2053"></a>
Continue execution from the point where it stopped.
</li><li> <code>void</code> YAP_Error(<code>int</code> <var>ID</var>,<code>YAP_Term</code> <var>Cause</var>,<code>char *</code> <var>error_description</var>)
<a name="IDX2054"></a>
Generate an YAP System Error with description given by the string
<var>error_description</var>. <var>ID</var> is the error ID, if known, or
<code>0</code>. <var>Cause</var> is the term that caused the crash.
</li><li> <code>void</code> YAP_Exit(<code>int</code> <var>exit_code</var>)
<a name="IDX2055"></a>
Exit YAP immediately. The argument <var>exit_code</var> gives the error code
and is supposed to be 0 after successful execution in Unix and Unix-like
systems.
</li><li> <code>YAP_Term</code> YAP_GetValue(<code>Atom</code> <var>at</var>)
<a name="IDX2056"></a>
Return the term <var>value</var> associated with the atom <var>at</var>. If no
such term exists the function will return the empty list.
</li><li> YAP_FastInit(<code>char *</code> <var>SavedState</var>)
<a name="IDX2057"></a>
Initialize a copy of YAP from <var>SavedState</var>. The copy is
monolithic and currently must be loaded at the same address where it was
saved. <code>YAP_FastInit</code> is a simpler version of <code>YAP_Init</code>.
</li><li> YAP_Init(<var>InitInfo</var>)
<a name="IDX2058"></a>
Initialize YAP. The arguments are in a <code>C</code>
structure of type <code>YAP_init_args</code>.
<p>The fields of <var>InitInfo</var> are <code>char *</code> <var>SavedState</var>,
<code>int</code> <var>HeapSize</var>, <code>int</code> <var>StackSize</var>, <code>int</code>
<var>TrailSize</var>, <code>int</code> <var>NumberofWorkers</var>, <code>int</code>
<var>SchedulerLoop</var>, <code>int</code> <var>DelayedReleaseLoad</var>, <code>int</code>
<var>argc</var>, <code>char **</code> <var>argv</var>, <code>int</code> <var>ErrorNo</var>, and
<code>char *</code> <var>ErrorCause</var>. The function returns an integer, which
indicates the current status. If the result is <code>YAP_BOOT_ERROR</code>
booting failed.
</p>
<p>If <var>SavedState</var> is not NULL, try to open and restore the file
<var>SavedState</var>. Initially YAP will search in the current directory. If
the saved state does not exist in the current directory YAP will use
either the default library directory or the directory given by the
environment variable <code>YAPLIBDIR</code>. Note that currently
the saved state must be loaded at the same address where it was saved.
</p>
<p>If <var>HeapSize</var> is different from 0 use <var>HeapSize</var> as the minimum
size of the Heap (or code space). If <var>StackSize</var> is different from 0
use <var>HeapSize</var> as the minimum size for the Stacks. If
<var>TrailSize</var> is different from 0 use <var>TrailSize</var> as the minimum
size for the Trails.
</p>
<p>The <var>NumberofWorkers</var>, <var>NumberofWorkers</var>, and
<var>DelayedReleaseLoad</var> are only of interest to the or-parallel system.
</p>
<p>The argument count <var>argc</var> and string of arguments <var>argv</var>
arguments are to be passed to user programs as the arguments used to
call YAP.
</p>
<p>If booting failed you may consult <code>ErrorNo</code> and <code>ErrorCause</code>
for the cause of the error, or call
<code>YAP_Error(ErrorNo,0L,ErrorCause)</code> to do default processing.
</p>
</li><li> <code>void</code> YAP_PutValue(<code>Atom</code> <var>at</var>, <code>YAP_Term</code> <var>value</var>)
<a name="IDX2059"></a>
Associate the term <var>value</var> with the atom <var>at</var>. The term
<var>value</var> must be a constant. This functionality is used by YAP as a
simple way for controlling and communicating with the Prolog run-time.
</li><li> <code>YAP_Term</code> YAP_Read(<code>int (*)(void)</code> <var>GetC</var>)
<a name="IDX2060"></a>
Parse a Term using the function <var>GetC</var> to input characters.
</li><li> <code>YAP_Term</code> YAP_RunGoal(<code>YAP_Term</code> <var>Goal</var>)
<a name="IDX2061"></a>
Execute query <var>Goal</var> and return 1 if the query succeeds, and
0 otherwise. The predicate returns 0 if failure, otherwise it will
return <var>YAP_Term</var>. Note that <var>YAP_Term</var> may change due to garbage
collection, so you should use something like:
<table><tr><td> </td><td><pre class="example"> t = YAP_RunGoal(t);
if (t == 0) return FALSE;
</pre></td></tr></table><p>If the execution fails, garbage collection might still have changed
the term, so you should not use the input argument again.
</p>
<p>An alternative is to use <em>slots</em>, as shown next:
</p>
<table><tr><td> </td><td><pre class="example"> long sl = YAP_InitSlot(scoreTerm);
out = YAP_RunGoal(t);
t = YAP_GetFromSlot(sl);
YAP_RecoverSlots(1);
if (out == 0) return FALSE;
</pre></td></tr></table><p>Slots are safe houses in the stack, preserved by the garbage collector
and the stack shifter. In this case, we use a slot to preserve <var>t</var>
during the execution of <code>YAP_RunGoal</code>. When the execution of
<var>t</var> is over we read the (possibly changed) value of <var>t</var> back
from the slot <var>sl</var> and tell YAP that the slot <var>sl</var> is not
needed and can be given back to the system.
</p>
</li><li> <code>int</code> YAP_RestartGoal(<code>void</code>)
<a name="IDX2062"></a>
Look for the next solution to the current query by forcing YAP to backtrack.
</li><li> <code>int</code> YAP_Reset(<code>void</code>)
<a name="IDX2063"></a>
Reset execution environment (similar to the <code>abort/0</code>
built-in). This is useful when you want to start a new query before
asking all solutions to the previous query.
</li><li> <code>YAP_Bool</code> YAP_GoalHasException(<code>YAP_Term *tp</code>)
<a name="IDX2064"></a>
Check if the last goal generated an exception, and if so copy it to the
space pointed to by <var>tp</var>
</li><li> <code>void</code> YAP_ClearExceptions(<code>void</code>)
<a name="IDX2065"></a>
Reset any exceptions left over by the system.
</li><li> <code>void</code> YAP_Write(<code>YAP_Term</code> <var>t</var>, <code>void (*)(int)</code>
<var>PutC</var>, <code>int</code> <var>flags</var>)
<a name="IDX2066"></a>
Write a Term <var>t</var> using the function <var>PutC</var> to output
characters. The term is written according to a mask of the following
flags in the <code>flag</code> argument: <code>YAP_WRITE_QUOTED</code>,
<code>YAP_WRITE_HANDLE_VARS</code>, and <code>YAP_WRITE_IGNORE_OPS</code>.
</li><li> <code>void</code> YAP_WriteBuffer(<code>YAP_Term</code> <var>t</var>, <code>char *</code>
<var>buff</var>, <code>unsigned int</code>
<var>size</var>, <code>int</code> <var>flags</var>)
<a name="IDX2067"></a>
Write a YAP_Term <var>t</var> to buffer <var>buff</var> with size <var>size</var>. The
term is written according to a mask of the following flags in the
<code>flag</code> argument: <code>YAP_WRITE_QUOTED</code>,
<code>YAP_WRITE_HANDLE_VARS</code>, and <code>YAP_WRITE_IGNORE_OPS</code>.
</li><li> <code>void</code> YAP_InitConsult(<code>int</code> <var>mode</var>, <code>char *</code> <var>filename</var>)
<a name="IDX2068"></a>
Enter consult mode on file <var>filename</var>. This mode maintains a few
data-structures internally, for instance to know whether a predicate
before or not. It is still possible to execute goals in consult mode.
<p>If <var>mode</var> is <code>TRUE</code> the file will be reconsulted, otherwise
just consulted. In practice, this function is most useful for
bootstrapping Prolog, as otherwise one may call the Prolog predicate
<code>compile/1</code> or <code>consult/1</code> to do compilation.
</p>
<p>Note that it is up to the user to open the file <var>filename</var>. The
<code>YAP_InitConsult</code> function only uses the file name for internal
bookkeeping.
</p>
</li><li> <code>void</code> YAP_EndConsult(<code>void</code>)
<a name="IDX2069"></a>
Finish consult mode.
</li></ul>
<p>Some observations:
</p>
<ul>
<li> The system will core dump if you try to load the saved state in a
different address from where it was made. This may be a problem if
your program uses <code>mmap</code>. This problem will be addressed in future
versions of YAP.
</li><li> Currently, the YAP library will pollute the name
space for your program.
</li><li> The initial library includes the complete YAP system. In
the future we plan to split this library into several smaller libraries
(e.g. if you do not want to perform I/O).
</li><li> You can generate your own saved states. Look at the
<code>boot.yap</code> and <code>init.yap</code> files.
</li></ul>
<hr size="6">
<a name="Compatibility"></a>
<a name="SEC154"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC153" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC155" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC153" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC167" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 23. Compatibility with Other Prolog systems </h1>
<p>YAP has been designed to be as compatible as possible with
other Prolog systems, and initially with C-Prolog. More recent work on
YAP has included features initially proposed for the Quintus
and SICStus Prolog systems.
</p>
<p>Developments since <code>Yap4.1.6</code> we have striven at making
YAP compatible with the ISO-Prolog standard.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC155">23.1 Compatibility with the C-Prolog interpreter</a></td><td> </td><td align="left" valign="top"></td></tr>
<tr><td align="left" valign="top"><a href="#SEC161">23.2 Compatibility with the Quintus and SICStus Prolog systems</a></td><td> </td><td align="left" valign="top"> Compatibility with the SICStus Prolog system
</td></tr>
<tr><td align="left" valign="top"><a href="#SEC166">23.3 Compatibility with the ISO Prolog standard</a></td><td> </td><td align="left" valign="top"></td></tr>
</table>
<hr size="6">
<a name="C_002dProlog"></a>
<a name="SEC155"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC154" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC156" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC154" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC167" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 23.1 Compatibility with the C-Prolog interpreter </h2>
<table class="menu" border="0" cellspacing="0">
<p>C-Prolog Compatibility
<a href="#SEC156">23.1.1 Major Differences between YAP and C-Prolog.</a> Major Differences between YAP and C-Prolog
<a href="#SEC157">23.1.2 Yap predicates fully compatible with C-Prolog</a> Yap predicates fully compatible with
C-Prolog
<a href="#SEC158">23.1.3 Yap predicates not strictly compatible with C-Prolog</a> Yap predicates not strictly as C-Prolog
<a href="#SEC159">23.1.4 Yap predicates not available in C-Prolog</a> Yap predicates not available in C-Prolog
<a href="#SEC160">23.1.5 Yap predicates not available in C-Prolog</a> C-Prolog predicates not available in YAP
</p></table>
<hr size="6">
<a name="Major-Differences-with-C_002dProlog"></a>
<a name="SEC156"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC155" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC157" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC154" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC155" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC167" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 23.1.1 Major Differences between YAP and C-Prolog. </h3>
<p>YAP includes several extensions over the original C-Prolog system. Even
so, most C-Prolog programs should run under YAP without changes.
</p>
<p>The most important difference between YAP and C-Prolog is that, being
YAP a compiler, some changes should be made if predicates such as
<code>assert</code>, <code>clause</code> and <code>retract</code> are used. First
predicates which will change during execution should be declared as
<code>dynamic</code> by using commands like:
</p>
<table><tr><td> </td><td><pre class="example">:- dynamic f/n.
</pre></td></tr></table>
<p>where <code>f</code> is the predicate name and n is the arity of the
predicate. Note that several such predicates can be declared in a
single command:
</p><table><tr><td> </td><td><pre class="example"> :- dynamic f/2, ..., g/1.
</pre></td></tr></table>
<p>Primitive predicates such as <code>retract</code> apply only to dynamic
predicates. Finally note that not all the C-Prolog primitive predicates
are implemented in YAP. They can easily be detected using the
<code>unknown</code> system predicate provided by YAP.
</p>
<p>Last, by default YAP enables character escapes in strings. You can
disable the special interpretation for the escape character by using:
</p><table><tr><td> </td><td><pre class="example"><code>:- yap_flag(character_escapes,off).</code>
</pre></td></tr></table>
<p>or by using:
</p><table><tr><td> </td><td><pre class="example"><code>:- yap_flag(language,cprolog).</code>
</pre></td></tr></table>
<hr size="6">
<a name="Fully-C_002dProlog-Compatible"></a>
<a name="SEC157"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC156" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC158" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC154" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC155" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC167" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 23.1.2 Yap predicates fully compatible with C-Prolog </h3>
<p>These are the Prolog built-ins that are fully compatible in both
C-Prolog and YAP:
</p>
<table><tr><th valign="top">Jump to: </th><td><a href="#SEC157_0" class="summary-letter"><b>!</b></a>
<a href="#SEC157_1" class="summary-letter"><b>,</b></a>
<a href="#SEC157_2" class="summary-letter"><b>;</b></a>
<a href="#SEC157_3" class="summary-letter"><b><</b></a>
<a href="#SEC157_4" class="summary-letter"><b>=</b></a>
<a href="#SEC157_5" class="summary-letter"><b>></b></a>
<a href="#SEC157_6" class="summary-letter"><b>@</b></a>
<a href="#SEC157_7" class="summary-letter"><b>[</b></a>
<a href="#SEC157_8" class="summary-letter"><b>\</b></a>
<br>
<a href="#SEC157_9" class="summary-letter"><b>A</b></a>
<a href="#SEC157_10" class="summary-letter"><b>B</b></a>
<a href="#SEC157_11" class="summary-letter"><b>C</b></a>
<a href="#SEC157_12" class="summary-letter"><b>D</b></a>
<a href="#SEC157_13" class="summary-letter"><b>E</b></a>
<a href="#SEC157_14" class="summary-letter"><b>F</b></a>
<a href="#SEC157_15" class="summary-letter"><b>G</b></a>
<a href="#SEC157_16" class="summary-letter"><b>H</b></a>
<a href="#SEC157_17" class="summary-letter"><b>I</b></a>
<a href="#SEC157_18" class="summary-letter"><b>K</b></a>
<a href="#SEC157_19" class="summary-letter"><b>L</b></a>
<a href="#SEC157_20" class="summary-letter"><b>N</b></a>
<a href="#SEC157_21" class="summary-letter"><b>O</b></a>
<a href="#SEC157_22" class="summary-letter"><b>P</b></a>
<a href="#SEC157_23" class="summary-letter"><b>R</b></a>
<a href="#SEC157_24" class="summary-letter"><b>S</b></a>
<a href="#SEC157_25" class="summary-letter"><b>T</b></a>
<a href="#SEC157_26" class="summary-letter"><b>V</b></a>
<a href="#SEC157_27" class="summary-letter"><b>W</b></a>
</td></tr></table>
<table border="0" class="index-cy">
<tr><td></td><th align="left">Index Entry</th><th align="left"> Section</th></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC157_0">!</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX151">!/0</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC157_1">,</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX136">,/2</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC157_2">;</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX139">;/2</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC157_3"><</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX357"></2</a></td><td valign="top"><a href="#SEC36">6.5 Arithmetic</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC157_4">=</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX309">=../2</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX369">=:=/2</a></td><td valign="top"><a href="#SEC36">6.5 Arithmetic</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX360">=</2</a></td><td valign="top"><a href="#SEC36">6.5 Arithmetic</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX327">==/2</a></td><td valign="top"><a href="#SEC35">6.4 Comparing Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX372">=\=/2</a></td><td valign="top"><a href="#SEC36">6.5 Arithmetic</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC157_5">></a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX363">>/2</a></td><td valign="top"><a href="#SEC36">6.5 Arithmetic</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX366">>=/2</a></td><td valign="top"><a href="#SEC36">6.5 Arithmetic</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC157_6">@</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX333">@</2</a></td><td valign="top"><a href="#SEC35">6.4 Comparing Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX336">@</2</a></td><td valign="top"><a href="#SEC35">6.4 Comparing Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX339">@>/2</a></td><td valign="top"><a href="#SEC35">6.4 Comparing Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX342">@>=/2</a></td><td valign="top"><a href="#SEC35">6.4 Comparing Terms</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC157_7">[</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX19">[-]/1</a></td><td valign="top"><a href="#SEC23">4.1 Program loading and updating</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX16">[]/1</a></td><td valign="top"><a href="#SEC23">4.1 Program loading and updating</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC157_8">\</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX154">\+/1</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX330">\==/2</a></td><td valign="top"><a href="#SEC35">6.4 Comparing Terms</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC157_9">A</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX181">abort/0</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX225">atom/1</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX228">atomic/1</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC157_10">B</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX831">bagof/3</a></td><td valign="top"><a href="#SEC52">6.10 Collecting Solutions to a Goal</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX184">break/0</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC157_11">C</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX166">call/1</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX384">close/1</a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX324">compare/3</a></td><td valign="top"><a href="#SEC35">6.4 Comparing Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX10">consult/1</a></td><td valign="top"><a href="#SEC23">4.1 Program loading and updating</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX726">current_atom/1</a></td><td valign="top"><a href="#SEC48">6.7.2 Looking at the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX729">current_predicate/1</a></td><td valign="top"><a href="#SEC48">6.7.2 Looking at the Data Base</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC157_12">D</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX234">db_reference/1</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1987">debug/0</a></td><td valign="top"><a href="#SEC139">19.1 Debugging Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1990">debugging/0</a></td><td valign="top"><a href="#SEC139">19.1 Debugging Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX466">display/1</a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC157_13">E</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX777">erase/1</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX780">erased/1</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX619">exists/1</a></td><td valign="top"><a href="#SEC44">6.6.7 Controlling Input/Output</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX55">expand_exprs/2</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX837">expand_term/2</a></td><td valign="top"><a href="#SEC53">6.11 Grammar Rules</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC157_14">F</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX145">fail/0</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX625">fileerrors/0</a></td><td valign="top"><a href="#SEC44">6.6.7 Controlling Input/Output</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX822">findall/3</a></td><td valign="top"><a href="#SEC52">6.10 Collecting Solutions to a Goal</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX306">functor/3</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC157_15">G</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX499">get/1</a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX502">get0/1</a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC157_16">H</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX187">halt/0</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC157_17">I</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX783">instance/2</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX240">integer/1</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC157_18">K</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX348">keysort/2</a></td><td valign="top"><a href="#SEC35">6.4 Comparing Terms</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC157_19">L</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2005">leash/1</a></td><td valign="top"><a href="#SEC139">19.1 Debugging Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX351">length/2</a></td><td valign="top"><a href="#SEC35">6.4 Comparing Terms</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC157_20">N</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX258">name/2</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX529">nl/0</a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1993">nodebug/0</a></td><td valign="top"><a href="#SEC139">19.1 Debugging Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX622">nofileerrors/0</a></td><td valign="top"><a href="#SEC44">6.6.7 Controlling Input/Output</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX243">nonvar/1</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1999">nospy/1</a></td><td valign="top"><a href="#SEC139">19.1 Debugging Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX157">not/1</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX246">number/1</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC157_21">O</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1030">op/3</a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC157_22">P</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX249">primitive/1</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX478">print/1</a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1036">prompt/2</a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX487">put/1</a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC157_23">R</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX447">read/1</a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX13">reconsult/1</a></td><td valign="top"><a href="#SEC23">4.1 Program loading and updating</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX753">recorda/3</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX771">recorded/3</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX756">recordz/3</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX867">rename/2</a></td><td valign="top"><a href="#SEC54">6.12 Access to Operating System Functionality</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX163">repeat/0</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC157_24">S</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX100">save/1</a></td><td valign="top"><a href="#SEC25">4.3 Saving and Loading Prolog States</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX438">see/1</a></td><td valign="top"><a href="#SEC39">6.6.2 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX441">seeing/1</a></td><td valign="top"><a href="#SEC39">6.6.2 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX444">seen/0</a></td><td valign="top"><a href="#SEC39">6.6.2 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX834">setof/3</a></td><td valign="top"><a href="#SEC52">6.10 Collecting Solutions to a Goal</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX870">sh/0</a></td><td valign="top"><a href="#SEC54">6.12 Access to Operating System Functionality</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX523">skip/1</a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX345">sort/2</a></td><td valign="top"><a href="#SEC35">6.4 Comparing Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1996">spy/1</a></td><td valign="top"><a href="#SEC139">19.1 Debugging Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX958">statistics/0</a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX873">system/1</a></td><td valign="top"><a href="#SEC54">6.12 Access to Operating System Functionality</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC157_25">T</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX526">tab/1</a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX429">tell/1</a></td><td valign="top"><a href="#SEC39">6.6.2 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX432">telling/1</a></td><td valign="top"><a href="#SEC39">6.6.2 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX840">term_expansion/2</a></td><td valign="top"><a href="#SEC53">6.11 Grammar Rules</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX435">told/0</a></td><td valign="top"><a href="#SEC39">6.6.2 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX142">true/0</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC157_26">V</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX222">var/1</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC157_27">W</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX463">write/1</a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX475">writeq/1</a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
</table>
<table><tr><th valign="top">Jump to: </th><td><a href="#SEC157_0" class="summary-letter"><b>!</b></a>
<a href="#SEC157_1" class="summary-letter"><b>,</b></a>
<a href="#SEC157_2" class="summary-letter"><b>;</b></a>
<a href="#SEC157_3" class="summary-letter"><b><</b></a>
<a href="#SEC157_4" class="summary-letter"><b>=</b></a>
<a href="#SEC157_5" class="summary-letter"><b>></b></a>
<a href="#SEC157_6" class="summary-letter"><b>@</b></a>
<a href="#SEC157_7" class="summary-letter"><b>[</b></a>
<a href="#SEC157_8" class="summary-letter"><b>\</b></a>
<br>
<a href="#SEC157_9" class="summary-letter"><b>A</b></a>
<a href="#SEC157_10" class="summary-letter"><b>B</b></a>
<a href="#SEC157_11" class="summary-letter"><b>C</b></a>
<a href="#SEC157_12" class="summary-letter"><b>D</b></a>
<a href="#SEC157_13" class="summary-letter"><b>E</b></a>
<a href="#SEC157_14" class="summary-letter"><b>F</b></a>
<a href="#SEC157_15" class="summary-letter"><b>G</b></a>
<a href="#SEC157_16" class="summary-letter"><b>H</b></a>
<a href="#SEC157_17" class="summary-letter"><b>I</b></a>
<a href="#SEC157_18" class="summary-letter"><b>K</b></a>
<a href="#SEC157_19" class="summary-letter"><b>L</b></a>
<a href="#SEC157_20" class="summary-letter"><b>N</b></a>
<a href="#SEC157_21" class="summary-letter"><b>O</b></a>
<a href="#SEC157_22" class="summary-letter"><b>P</b></a>
<a href="#SEC157_23" class="summary-letter"><b>R</b></a>
<a href="#SEC157_24" class="summary-letter"><b>S</b></a>
<a href="#SEC157_25" class="summary-letter"><b>T</b></a>
<a href="#SEC157_26" class="summary-letter"><b>V</b></a>
<a href="#SEC157_27" class="summary-letter"><b>W</b></a>
</td></tr></table>
<hr size="6">
<a name="Not-Strictly-C_002dProlog-Compatible"></a>
<a name="SEC158"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC157" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC159" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC154" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC155" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC167" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 23.1.3 Yap predicates not strictly compatible with C-Prolog </h3>
<p>These are YAP built-ins that are also available in C-Prolog, but
that are not fully compatible:
</p>
<table><tr><th valign="top">Jump to: </th><td><a href="#SEC158_0" class="summary-letter"><b>A</b></a>
<a href="#SEC158_1" class="summary-letter"><b>C</b></a>
<a href="#SEC158_2" class="summary-letter"><b>I</b></a>
<a href="#SEC158_3" class="summary-letter"><b>L</b></a>
<a href="#SEC158_4" class="summary-letter"><b>N</b></a>
<a href="#SEC158_5" class="summary-letter"><b>R</b></a>
</td></tr></table>
<table border="0" class="index-ca">
<tr><td></td><th align="left">Index Entry</th><th align="left"> Section</th></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC158_0">A</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX684">abolish/1</a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX687">abolish/2</a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX675">assert/1</a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX741">assert/2</a></td><td valign="top"><a href="#SEC49">6.7.3 Using Data Base References</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX678">asserta/1</a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX744">asserta/2</a></td><td valign="top"><a href="#SEC49">6.7.3 Using Data Base References</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX681">assertz/1</a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX747">assertz/2</a></td><td valign="top"><a href="#SEC49">6.7.3 Using Data Base References</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC158_1">C</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX699">clause/2</a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX702">clause/3</a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC158_2">I</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX354">is/2</a></td><td valign="top"><a href="#SEC36">6.5 Arithmetic</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC158_3">L</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX714">listing/0</a></td><td valign="top"><a href="#SEC48">6.7.2 Looking at the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX717">listing/1</a></td><td valign="top"><a href="#SEC48">6.7.2 Looking at the Data Base</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC158_4">N</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX705">nth_clause/3</a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC158_5">R</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX750">retract/2</a></td><td valign="top"><a href="#SEC49">6.7.3 Using Data Base References</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
</table>
<table><tr><th valign="top">Jump to: </th><td><a href="#SEC158_0" class="summary-letter"><b>A</b></a>
<a href="#SEC158_1" class="summary-letter"><b>C</b></a>
<a href="#SEC158_2" class="summary-letter"><b>I</b></a>
<a href="#SEC158_3" class="summary-letter"><b>L</b></a>
<a href="#SEC158_4" class="summary-letter"><b>N</b></a>
<a href="#SEC158_5" class="summary-letter"><b>R</b></a>
</td></tr></table>
<hr size="6">
<a name="Not-in-C_002dProlog"></a>
<a name="SEC159"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC158" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC160" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC154" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC155" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC167" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 23.1.4 Yap predicates not available in C-Prolog </h3>
<p>These are YAP built-ins not available in C-Prolog.
</p>
<table><tr><th valign="top">Jump to: </th><td><a href="#SEC159_0" class="summary-letter"><b>-</b></a>
<a href="#SEC159_1" class="summary-letter"><b>=</b></a>
<a href="#SEC159_2" class="summary-letter"><b>\</b></a>
<br>
<a href="#SEC159_3" class="summary-letter"><b>A</b></a>
<a href="#SEC159_4" class="summary-letter"><b>B</b></a>
<a href="#SEC159_5" class="summary-letter"><b>C</b></a>
<a href="#SEC159_6" class="summary-letter"><b>D</b></a>
<a href="#SEC159_7" class="summary-letter"><b>E</b></a>
<a href="#SEC159_8" class="summary-letter"><b>F</b></a>
<a href="#SEC159_9" class="summary-letter"><b>G</b></a>
<a href="#SEC159_10" class="summary-letter"><b>H</b></a>
<a href="#SEC159_11" class="summary-letter"><b>I</b></a>
<a href="#SEC159_12" class="summary-letter"><b>J</b></a>
<a href="#SEC159_13" class="summary-letter"><b>K</b></a>
<a href="#SEC159_14" class="summary-letter"><b>L</b></a>
<a href="#SEC159_15" class="summary-letter"><b>M</b></a>
<a href="#SEC159_16" class="summary-letter"><b>N</b></a>
<a href="#SEC159_17" class="summary-letter"><b>O</b></a>
<a href="#SEC159_18" class="summary-letter"><b>P</b></a>
<a href="#SEC159_19" class="summary-letter"><b>Q</b></a>
<a href="#SEC159_20" class="summary-letter"><b>R</b></a>
<a href="#SEC159_21" class="summary-letter"><b>S</b></a>
<a href="#SEC159_22" class="summary-letter"><b>T</b></a>
<a href="#SEC159_23" class="summary-letter"><b>U</b></a>
<a href="#SEC159_24" class="summary-letter"><b>V</b></a>
<a href="#SEC159_25" class="summary-letter"><b>W</b></a>
<a href="#SEC159_26" class="summary-letter"><b>Y</b></a>
</td></tr></table>
<table border="0" class="index-cn">
<tr><td></td><th align="left">Index Entry</th><th align="left"> Section</th></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC159_0">-</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX160">->/2</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC159_1">=</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX312">=/2</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC159_2">\</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX315">\=/2</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC159_3">A</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1963">abolish_table/1</a></td><td valign="top"><a href="#SEC135">16. Tabling</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX390">absolute_file_name/2</a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1654">add_edges/3</a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX949">add_to_array_element/4</a></td><td valign="top"><a href="#SEC58">6.16 Arrays</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1150">add_to_heap/4</a></td><td valign="top"><a href="#SEC65">7.4 Heaps</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1648">add_vertices/3</a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX879">alarm/3</a></td><td valign="top"><a href="#SEC54">6.12 Access to Operating System Functionality</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX828">all/3</a></td><td valign="top"><a href="#SEC52">6.10 Collecting Solutions to a Goal</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX633">always_prompt_user/0</a></td><td valign="top"><a href="#SEC44">6.6.7 Controlling Input/Output</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1174">append/3</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1762">append/3</a></td><td valign="top"><a href="#SEC83">8. SWI-Prolog Emulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX303">arg/3</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX919">array/2</a></td><td valign="top"><a href="#SEC58">6.16 Arrays</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX943">array_element/3</a></td><td valign="top"><a href="#SEC58">6.16 Arrays</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX690">assert_static/1</a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX693">asserta_static/1</a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX696">assertz_static/1</a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1090">assoc_to_list/2</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX417">at_end_of_stream/0</a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX420">at_end_of_stream/1</a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX261">atom_chars/2</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX264">atom_codes/2</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX267">atom_concat/2</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX273">atom_concat/3</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX279">atom_concat/3</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX276">atom_length/2</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1468">atom_to_chars/2</a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1471">atom_to_chars/3</a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX270">atomic_concat/2</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1810">attr_unify_hook/2</a></td><td valign="top"><a href="#SEC86">8.3 hProlog and SWI-Prolog Attributed Variables</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1870">attribute_goal/2</a></td><td valign="top"><a href="#SEC97">10.4 Displaying Attributes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1867">attvar/1</a></td><td valign="top"><a href="#SEC96">10.3 Attributed Unification</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1144">avl_insert/4</a></td><td valign="top"><a href="#SEC64">7.3 AVL Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1147">avl_lookup/3</a></td><td valign="top"><a href="#SEC64">7.3 AVL Trees</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC159_4">B</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1825">b_getval/2</a></td><td valign="top"><a href="#SEC88">8.4 SWI Global variables</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1822">b_setval/2</a></td><td valign="top"><a href="#SEC88">8.4 SWI Global variables</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX816">bb_delete/2</a></td><td valign="top"><a href="#SEC51">6.9 The Blackboard</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX813">bb_get/2</a></td><td valign="top"><a href="#SEC51">6.9 The Blackboard</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX810">bb_put/2</a></td><td valign="top"><a href="#SEC51">6.9 The Blackboard</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX819">bb_update/3</a></td><td valign="top"><a href="#SEC51">6.9 The Blackboard</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1765">between/3</a></td><td valign="top"><a href="#SEC83">8. SWI-Prolog Emulation</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC159_5">C</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX852">C/3</a></td><td valign="top"><a href="#SEC53">6.11 Grammar Rules</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1606">call_cleanup/1</a></td><td valign="top"><a href="#SEC77">7.16 Call Cleanup</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1609">call_cleanup/2</a></td><td valign="top"><a href="#SEC77">7.16 Call Cleanup</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX913">call_count_data/0</a></td><td valign="top"><a href="#SEC57">6.15 Counting Calls</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX910">call_count_data/3</a></td><td valign="top"><a href="#SEC57">6.15 Counting Calls</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX916">call_count_data/3</a></td><td valign="top"><a href="#SEC57">6.15 Counting Calls</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1852">call_residue/2</a></td><td valign="top"><a href="#SEC92">9.2 Coroutining</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX172">call_with_args/n</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX255">callable/1</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX193">catch/3</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX855">cd/1</a></td><td valign="top"><a href="#SEC54">6.12 Access to Operating System Functionality</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX291">char_code/2</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX457">char_conversion/2</a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1768">chdir/1</a></td><td valign="top"><a href="#SEC83">8. SWI-Prolog Emulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1063">checklist/2</a></td><td valign="top"><a href="#SEC62">7.1 Apply Macros</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1084">checknodes/3</a></td><td valign="top"><a href="#SEC62">7.1 Apply Macros</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1615">cleanup_all/0</a></td><td valign="top"><a href="#SEC77">7.16 Call Cleanup</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX387">close/2</a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX937">close_static_array/1</a></td><td valign="top"><a href="#SEC58">6.16 Arrays</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX22">compile/1</a></td><td valign="top"><a href="#SEC23">4.1 Program loading and updating</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX25">compile/1</a></td><td valign="top"><a href="#SEC23">4.1 Program loading and updating</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX28">compile/1 (directive)</a></td><td valign="top"><a href="#SEC23">4.1 Program loading and updating</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX40">compile_expressions/0</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1669">complement/2</a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1672">compose/3</a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX231">compound/1</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1771">concat_atom/2</a></td><td valign="top"><a href="#SEC83">8. SWI-Prolog Emulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1774">concat_atom/3</a></td><td valign="top"><a href="#SEC83">8. SWI-Prolog Emulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1069">convlist/3</a></td><td valign="top"><a href="#SEC62">7.1 Apply Macros</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX321">copy_term/2</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1819">copy_term_nat/2</a></td><td valign="top"><a href="#SEC87">8.3.1 Special Purpose SWI Predicates for Attributes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX889">create_mutable/2</a></td><td valign="top"><a href="#SEC55">6.13 Term Modification</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX460">current_char_conversion/2</a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX411">current_input/1</a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX789">current_key/2</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX952">current_module/1</a></td><td valign="top"><a href="#SEC59">6.17 Predicate Information</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX955">current_module/2</a></td><td valign="top"><a href="#SEC59">6.17 Predicate Information</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1954">current_mutex/3</a></td><td valign="top"><a href="#SEC133">14.4 Thread Synchronisation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1033">current_op/3</a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX414">current_output/1</a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX732">current_predicate/2</a></td><td valign="top"><a href="#SEC48">6.7.2 Looking at the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1021">current_prolog_flag/2</a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX393">current_stream/3</a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1900">current_thread/2</a></td><td valign="top"><a href="#SEC128">14.2 Monitoring Threads</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1576">cyclic_term/1</a></td><td valign="top"><a href="#SEC76">7.15 Utilities On Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1579">cyclic_term/1</a></td><td valign="top"><a href="#SEC76">7.15 Utilities On Terms</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC159_6">D</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1495">datime/1</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1093">del_assoc/4</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1807">del_attr/2</a></td><td valign="top"><a href="#SEC86">8.3 hProlog and SWI-Prolog Attributed Variables</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1657">del_edges/3</a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1096">del_max_assoc/4</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1099">del_min_assoc/4</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1651">del_vertices/3</a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1177">delete/3</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1501">delete_file/1</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1504">delete_file/2</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1702">dgraph_add_edges/3</a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1696">dgraph_add_vertices/3</a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1714">dgraph_complement/2</a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1720">dgraph_compose/3</a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1705">dgraph_del_edges/3</a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1699">dgraph_del_vertices/3</a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1693">dgraph_edges/2</a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1708">dgraph_neighbors/3</a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1711">dgraph_neighbours/3</a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1687">dgraph_new/1</a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1726">dgraph_symmetric_closure/2</a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1729">dgraph_top_sort/2</a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1723">dgraph_transitive_closure/2</a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1717">dgraph_transpose/2</a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1690">dgraph_vertices/2</a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1840">dif/2</a></td><td valign="top"><a href="#SEC92">9.2 Coroutining</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1507">directory_files/2</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX79">discontiguous/1 (directive)</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX469">display/1</a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX541">display/1</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX550">display/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX43">do_not_compile_expressions/0</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX669">dynamic/1</a></td><td valign="top"><a href="#SEC46">6.7 Using the Clausal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX672">dynamic_predicate/2</a></td><td valign="top"><a href="#SEC46">6.7 Using the Clausal Data Base</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC159_7">E</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1645">edges/2</a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1102">empty_assoc/1</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1153">empty_heap/1</a></td><td valign="top"><a href="#SEC65">7.4 Heaps</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1330">empty_queue/1</a></td><td valign="top"><a href="#SEC69">7.8 Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX858">environ/2</a></td><td valign="top"><a href="#SEC54">6.12 Access to Operating System Functionality</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1525">environ/2</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX786">eraseall/1</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1546">exec/3</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC159_8">F</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX148">false/0</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1510">file_exists/1</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1513">file_exists/2</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1516">file_property/2</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX88">file_search_path/2</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX825">findall/4</a></td><td valign="top"><a href="#SEC52">6.10 Collecting Solutions to a Goal</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1180">flatten/2</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX237">float/1</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX396">flush_output/0</a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX399">flush_output/1</a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1798">forall/2</a></td><td valign="top"><a href="#SEC85">8.2 Forall</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX481">format/2</a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX484">format/3</a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1456">format_to_chars/3</a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1459">format_to_chars/4</a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1603">fragile</a></td><td valign="top"><a href="#SEC77">7.16 Call Cleanup</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1843">freeze/2</a></td><td valign="top"><a href="#SEC92">9.2 Coroutining</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1846">frozen/2</a></td><td valign="top"><a href="#SEC92">9.2 Coroutining</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC159_9">G</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX199">garbage_collect/0</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX202">garbage_collect_atoms/0</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX205">gc/0</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1105">gen_assoc/3</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX568">get/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX571">get0/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1117">get_assoc/3</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1111">get_assoc/5</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1804">get_attr/3</a></td><td valign="top"><a href="#SEC86">8.3 hProlog and SWI-Prolog Attributed Variables</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1813">get_attrs/2</a></td><td valign="top"><a href="#SEC87">8.3.1 Special Purpose SWI Predicates for Attributes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1858">get_atts/2</a></td><td valign="top"><a href="#SEC95">10.2 Attribute Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX505">get_byte/1</a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX574">get_byte/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX508">get_char/1</a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX577">get_char/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX511">get_code/1</a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX580">get_code/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1156">get_from_heap/4</a></td><td valign="top"><a href="#SEC65">7.4 Heaps</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1621">get_label/3</a></td><td valign="top"><a href="#SEC79">7.18 Updatable Binary Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX892">get_mutable/2</a></td><td valign="top"><a href="#SEC55">6.13 Term Modification</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX898">get_mutable/2</a></td><td valign="top"><a href="#SEC55">6.13 Term Modification</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1108">get_next_assoc/4</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1114">get_prev_assoc/4</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX798">get_value/2</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX861">getcwd/1</a></td><td valign="top"><a href="#SEC54">6.12 Access to Operating System Functionality</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1342">getrand/1</a></td><td valign="top"><a href="#SEC70">7.9 Random Number Generator</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX843">goal_expansion/3</a></td><td valign="top"><a href="#SEC53">6.11 Grammar Rules</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX300">ground/1</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX210">grow_heap/1</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX213">grow_stack/1</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC159_10">H</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX190">halt/1</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1324">head_queue/2</a></td><td valign="top"><a href="#SEC69">7.8 Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1159">heap_size/2</a></td><td valign="top"><a href="#SEC65">7.4 Heaps</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1162">heap_to_list/2</a></td><td valign="top"><a href="#SEC65">7.4 Heaps</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX46">hide/1</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX52">hide_predicate/1</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1528">host_id/1</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1531">host_name/1</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC159_11">I</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX175">if/3</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX169">incore/1</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1039">initialization/0</a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX82">initialization/1 (directive)</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1120">is_assoc/1</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1183">is_list/1</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX895">is_mutable/1</a></td><td valign="top"><a href="#SEC55">6.13 Term Modification</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1366">is_rbtree/1</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1957">is_tabled/1</a></td><td valign="top"><a href="#SEC135">16. Tabling</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1960">is_tabled/1</a></td><td valign="top"><a href="#SEC135">16. Tabling</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC159_12">J</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1312">join_queue/3</a></td><td valign="top"><a href="#SEC69">7.8 Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1318">jump_queue/3</a></td><td valign="top"><a href="#SEC69">7.8 Queues</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC159_13">K</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX795">key_statistics/3</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX792">key_statistics/4</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1534">kill/2</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC159_14">L</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1186">last/2</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1333">length_queue/2</a></td><td valign="top"><a href="#SEC69">7.8 Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX85">library_directory/1</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX91">library_directory/1</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1189">list_concat/2</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1315">list_join_queue/3</a></td><td valign="top"><a href="#SEC69">7.8 Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1321">list_jump_queue/3</a></td><td valign="top"><a href="#SEC69">7.8 Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1123">list_to_assoc/2</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1165">list_to_heap/2</a></td><td valign="top"><a href="#SEC65">7.4 Heaps</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1243">list_to_ord_set/2</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1336">list_to_queue/2</a></td><td valign="top"><a href="#SEC69">7.8 Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1426">list_to_rbtree/2</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1429">list_to_rbtree/2</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1624">list_to_tree/2</a></td><td valign="top"><a href="#SEC79">7.18 Updatable Binary Trees</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC159_15">M</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1519">make_directory/2</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1309">make_queue/1</a></td><td valign="top"><a href="#SEC69">7.8 Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1126">map_assoc/2</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1129">map_assoc/3</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1627">map_tree/3</a></td><td valign="top"><a href="#SEC79">7.18 Updatable Binary Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1075">mapargs/3</a></td><td valign="top"><a href="#SEC62">7.1 Apply Macros</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1789">maplist/2</a></td><td valign="top"><a href="#SEC84">8.1 Invoking Predicates on all Members of a List</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1060">maplist/3</a></td><td valign="top"><a href="#SEC62">7.1 Apply Macros</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1792">maplist/3</a></td><td valign="top"><a href="#SEC84">8.1 Invoking Predicates on all Members of a List</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1795">maplist/4</a></td><td valign="top"><a href="#SEC84">8.1 Invoking Predicates on all Members of a List</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1081">mapnodes/3</a></td><td valign="top"><a href="#SEC62">7.1 Apply Macros</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1132">max_assoc/3</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1237">max_list/2</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1192">member/2</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1195">memberchk/2</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1246">merge/3</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX133">meta_predicate/1 (directive)</a></td><td valign="top"><a href="#SEC30">5.4 Meta-Predicates in Modules</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1135">min_assoc/3</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1240">min_list/2</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1168">min_of_heap/3</a></td><td valign="top"><a href="#SEC65">7.4 Heaps</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1171">min_of_heap/5</a></td><td valign="top"><a href="#SEC65">7.4 Heaps</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1537">mktemp/2</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1498">mktime/2</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX121">module/1</a></td><td valign="top"><a href="#SEC28">5.2 Defining a New Module</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX115">module/2 (directive)</a></td><td valign="top"><a href="#SEC28">5.2 Defining a New Module</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX118">module/3 (directive)</a></td><td valign="top"><a href="#SEC28">5.2 Defining a New Module</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX76">multifile/1 (directive)</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1933">mutex_create/1</a></td><td valign="top"><a href="#SEC133">14.4 Thread Synchronisation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1936">mutex_destroy/1</a></td><td valign="top"><a href="#SEC133">14.4 Thread Synchronisation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1942">mutex_lock/1</a></td><td valign="top"><a href="#SEC133">14.4 Thread Synchronisation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1906">mutex_statistics/0</a></td><td valign="top"><a href="#SEC128">14.2 Monitoring Threads</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1945">mutex_trylock/1</a></td><td valign="top"><a href="#SEC133">14.4 Thread Synchronisation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1948">mutex_unlock/1</a></td><td valign="top"><a href="#SEC133">14.4 Thread Synchronisation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1951">mutex_unlock_all/0</a></td><td valign="top"><a href="#SEC133">14.4 Thread Synchronisation</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC159_16">N</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1834">nb_current/2</a></td><td valign="top"><a href="#SEC88">8.4 SWI Global variables</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1837">nb_delete/1</a></td><td valign="top"><a href="#SEC88">8.4 SWI Global variables</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1831">nb_getval/2</a></td><td valign="top"><a href="#SEC88">8.4 SWI Global variables</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1828">nb_setval/2</a></td><td valign="top"><a href="#SEC88">8.4 SWI Global variables</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1663">neighbors/3</a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1666">neighbours/3</a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX598">nl/1</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX37">no_source/0</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX208">nogc/0</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2002">nospyall/0</a></td><td valign="top"><a href="#SEC139">19.1 Debugging Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1201">nth/2</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1207">nth/4</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1198">nth0/2</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1204">nth0/4</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1777">nth1/3</a></td><td valign="top"><a href="#SEC83">8. SWI-Prolog Emulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX774">nth_recorded/3</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX288">number_atom/2</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX282">number_chars/2</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX285">number_codes/2</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1474">number_to_chars/2</a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1477">number_to_chars/3</a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX297">numbervars/3</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC159_17">O</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1612">on_cleanup/1</a></td><td valign="top"><a href="#SEC77">7.16 Call Cleanup</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX882">on_signal/3</a></td><td valign="top"><a href="#SEC54">6.12 Access to Operating System Functionality</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX178">once/1</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX378">open/3</a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX381">open/4</a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1483">open_chars_stream/2</a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1249">ord_add_element/3</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1252">ord_del_element/3</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1255">ord_disjoint/2</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1261">ord_insert/3</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1264">ord_intersect/2</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1267">ord_intersect/3</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1270">ord_intersect/4</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1138">ord_list_to_assoc/2</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1258">ord_member/2</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1273">ord_seteq/2</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1276">ord_setproduct/3</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1282">ord_subtract/3</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1285">ord_symdiff/3</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1288">ord_union/2</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1291">ord_union/3</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1294">ord_union/4</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1279">ordsubset/2</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC159_18">P</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX58">path/1</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX61">path/1</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX64">path/1</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX514">peek_byte/1</a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX583">peek_byte/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX517">peek_char/1</a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX586">peek_char/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX520">peek_code/1</a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX589">peek_code/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1210">permutation/2</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX849">phrase/2</a></td><td valign="top"><a href="#SEC53">6.11 Grammar Rules</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX846">phrase/3</a></td><td valign="top"><a href="#SEC53">6.11 Grammar Rules</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1540">pid/1</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1552">popen/3</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX720">portray_clause/1</a></td><td valign="top"><a href="#SEC48">6.7.2 Looking at the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX723">portray_clause/2</a></td><td valign="top"><a href="#SEC48">6.7.2 Looking at the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX738">predicate_property/2</a></td><td valign="top"><a href="#SEC48">6.7.2 Looking at the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX553">print/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX904">profile_data/3</a></td><td valign="top"><a href="#SEC56">6.14 Profiling Prolog Programs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX907">profiled_reset/0</a></td><td valign="top"><a href="#SEC56">6.14 Profiling Prolog Programs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1873">project_attributes/2</a></td><td valign="top"><a href="#SEC97">10.4 Displaying Attributes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1876">project_attributes/2</a></td><td valign="top"><a href="#SEC98">10.5 Projecting Attributes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX94">prolog_file_name/2</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1024">prolog_flag/3</a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1042">prolog_initialization/1</a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1051">prolog_load_context/2</a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX97">public/1 (directive)</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX556">put/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1141">put_assoc/4</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1801">put_attr/3</a></td><td valign="top"><a href="#SEC86">8.3 hProlog and SWI-Prolog Attributed Variables</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1816">put_attrs/2</a></td><td valign="top"><a href="#SEC87">8.3.1 Special Purpose SWI Predicates for Attributes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1861">put_atts/2</a></td><td valign="top"><a href="#SEC95">10.2 Attribute Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX490">put_byte/1</a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX559">put_byte/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX493">put_char/1</a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX562">put_char/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX496">put_code/1</a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX565">put_code/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1630">put_label/4</a></td><td valign="top"><a href="#SEC79">7.18 Updatable Binary Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX864">putenv/2</a></td><td valign="top"><a href="#SEC54">6.12 Access to Operating System Functionality</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC159_19">Q</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1339">queue_to_list/2</a></td><td valign="top"><a href="#SEC69">7.8 Queues</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC159_20">R</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1345">random/1</a></td><td valign="top"><a href="#SEC70">7.9 Random Number Generator</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1348">random/3</a></td><td valign="top"><a href="#SEC70">7.9 Random Number Generator</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1351">randseq/3</a></td><td valign="top"><a href="#SEC70">7.9 Random Number Generator</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1354">randset/3</a></td><td valign="top"><a href="#SEC70">7.9 Random Number Generator</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1297">rannum/1</a></td><td valign="top"><a href="#SEC68">7.7 Pseudo Random Number Integer Generator</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1300">ranstart/0</a></td><td valign="top"><a href="#SEC68">7.7 Pseudo Random Number Integer Generator</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1303">ranstart/1</a></td><td valign="top"><a href="#SEC68">7.7 Pseudo Random Number Integer Generator</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1306">ranunif/2</a></td><td valign="top"><a href="#SEC68">7.7 Pseudo Random Number Integer Generator</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1393">rb_apply/4</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1411">rb_clone/3</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1387">rb_del_max/4</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1384">rb_del_min/4</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1378">rb_delete/3</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1381">rb_delete/4</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1363">rb_empty/1</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1369">rb_insert/4</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1402">rb_keys/2</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1372">rb_lookup/3</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1375">rb_lookupall/3</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1405">rb_map/3</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1417">rb_max/3</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1414">rb_min/3</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1360">rb_new/1</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1420">rb_next/4</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1408">rb_partial_map/4</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1423">rb_previous/4</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1399">rb_size/2</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1390">rb_update/4</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1396">rb_visit/2</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1684">reachable/3</a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX532">read/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1480">read_from_chars/2</a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX450">read_term/2</a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX535">read_term/3</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX768">recorda/3</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX759">recorda_at/3</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX765">recordaifnot/3</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX807">recordaifnot/3</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX762">recordz_at/3</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX804">recordzifnot/3</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1432">regexp/3</a></td><td valign="top"><a href="#SEC72">7.11 Regular Expressions</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1435">regexp/4</a></td><td valign="top"><a href="#SEC72">7.11 Regular Expressions</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1213">remove_duplicates/2</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX67">remove_from_path/1</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1522">rename_file/2</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1978">reset_op_counters/0</a></td><td valign="top"><a href="#SEC137">18. Profiling the Abstract Machine</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX940">resize_static_array/3</a></td><td valign="top"><a href="#SEC58">6.16 Arrays</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX112">restore/1</a></td><td valign="top"><a href="#SEC25">4.3 Saving and Loading Prolog States</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX708">retract/1</a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX711">retractall/1</a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1216">reverse/2</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC159_21">S</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1219">same_length/2</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX103">save/2</a></td><td valign="top"><a href="#SEC25">4.3 Saving and Loading Prolog States</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX106">save_program/1</a></td><td valign="top"><a href="#SEC25">4.3 Saving and Loading Prolog States</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX109">save_program/2</a></td><td valign="top"><a href="#SEC25">4.3 Saving and Loading Prolog States</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1222">select/3</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1066">selectlist/3</a></td><td valign="top"><a href="#SEC62">7.1 Apply Macros</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1327">serve_queue/3</a></td><td valign="top"><a href="#SEC69">7.8 Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX402">set_input/1</a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX405">set_output/1</a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1027">set_prolog_flag/2</a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX423">set_stream_position/2</a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX801">set_value/2</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX885">setarg/3n</a></td><td valign="top"><a href="#SEC55">6.13 Term Modification</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1780">setenv/2</a></td><td valign="top"><a href="#SEC83">8. SWI-Prolog Emulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1357">setrand/1</a></td><td valign="top"><a href="#SEC70">7.9 Random Number Generator</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1555">shell/0</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1558">shell/1</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1561">shell/1</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1981">show_op_counters/1</a></td><td valign="top"><a href="#SEC137">18. Profiling the Abstract Machine</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1984">show_ops_by_group/1</a></td><td valign="top"><a href="#SEC137">18. Profiling the Abstract Machine</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1966">show_table/1</a></td><td valign="top"><a href="#SEC135">16. Tabling</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX252">simple/1</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX592">skip/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1564">sleep/1</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX639">socket/2</a></td><td valign="top"><a href="#SEC45">6.6.8 Using Sockets From Yap</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX636">socket/4</a></td><td valign="top"><a href="#SEC45">6.6.8 Using Sockets From Yap</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX654">socket_accept/2</a></td><td valign="top"><a href="#SEC45">6.6.8 Using Sockets From Yap</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX660">socket_accept/2</a></td><td valign="top"><a href="#SEC45">6.6.8 Using Sockets From Yap</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX657">socket_accept/3</a></td><td valign="top"><a href="#SEC45">6.6.8 Using Sockets From Yap</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX645">socket_bind/2</a></td><td valign="top"><a href="#SEC45">6.6.8 Using Sockets From Yap</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX663">socket_buffering/4</a></td><td valign="top"><a href="#SEC45">6.6.8 Using Sockets From Yap</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX642">socket_close/1</a></td><td valign="top"><a href="#SEC45">6.6.8 Using Sockets From Yap</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX648">socket_connect/3</a></td><td valign="top"><a href="#SEC45">6.6.8 Using Sockets From Yap</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX651">socket_listen/2</a></td><td valign="top"><a href="#SEC45">6.6.8 Using Sockets From Yap</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX666">socket_select/5</a></td><td valign="top"><a href="#SEC45">6.6.8 Using Sockets From Yap</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX34">source/0</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX31">source_mode/2</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1438">splay_access/5</a></td><td valign="top"><a href="#SEC73">7.12 Splay Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1441">splay_delete/4</a></td><td valign="top"><a href="#SEC73">7.12 Splay Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1444">splay_init/3</a></td><td valign="top"><a href="#SEC73">7.12 Splay Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1447">splay_insert/4</a></td><td valign="top"><a href="#SEC73">7.12 Splay Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1450">splay_join/3</a></td><td valign="top"><a href="#SEC73">7.12 Splay Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1453">splay_split/5</a></td><td valign="top"><a href="#SEC73">7.12 Splay Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2008">spy_write/2</a></td><td valign="top"><a href="#SEC139">19.1 Debugging Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX375">srandom/1</a></td><td valign="top"><a href="#SEC36">6.5 Arithmetic</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1972">start_low_level_trace/0</a></td><td valign="top"><a href="#SEC136">17. Tracing at Low Level</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1975">start_low_level_trace/0</a></td><td valign="top"><a href="#SEC136">17. Tracing at Low Level</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX922">static_array/3</a></td><td valign="top"><a href="#SEC58">6.16 Arrays</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX934">static_array/3</a></td><td valign="top"><a href="#SEC58">6.16 Arrays</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX925">static_array_location/4</a></td><td valign="top"><a href="#SEC58">6.16 Arrays</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX928">static_array_properties/3</a></td><td valign="top"><a href="#SEC58">6.16 Arrays</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX931">static_array_to_term/3</a></td><td valign="top"><a href="#SEC58">6.16 Arrays</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX961">statistics/2</a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX426">stream_property/2</a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX408">stream_select/3</a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX70">style_check/1</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX73">style_check/1</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX294">sub_atom/5</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1225">sublist/2</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1594">subsumes/2</a></td><td valign="top"><a href="#SEC76">7.15 Utilities On Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1597">subsumes_chk/2</a></td><td valign="top"><a href="#SEC76">7.15 Utilities On Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1228">suffix/2</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1231">sum_list/2</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1078">sumargs/4</a></td><td valign="top"><a href="#SEC62">7.1 Apply Macros</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1234">sumlist/2</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1072">sumlist/4</a></td><td valign="top"><a href="#SEC62">7.1 Apply Macros</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1087">sumnodes/4</a></td><td valign="top"><a href="#SEC62">7.1 Apply Macros</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1567">system/0</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1570">system/2</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX735">system_predicate/2</a></td><td valign="top"><a href="#SEC48">6.7.2 Looking at the Data Base</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC159_22">T</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX595">tab/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1969">table_statistics/1</a></td><td valign="top"><a href="#SEC135">16. Tabling</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1582">term_hash/2</a></td><td valign="top"><a href="#SEC76">7.15 Utilities On Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1585">term_hash/4</a></td><td valign="top"><a href="#SEC76">7.15 Utilities On Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1783">term_to_atom/2</a></td><td valign="top"><a href="#SEC83">8. SWI-Prolog Emulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1588">term_variables/2</a></td><td valign="top"><a href="#SEC76">7.15 Utilities On Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1894">thread_at_exit/1</a></td><td valign="top"><a href="#SEC127">14.1 Creating and Destroying Prolog Threads</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1879">thread_create/3</a></td><td valign="top"><a href="#SEC127">14.1 Creating and Destroying Prolog Threads</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1888">thread_detach/1</a></td><td valign="top"><a href="#SEC127">14.1 Creating and Destroying Prolog Threads</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1891">thread_exit/1</a></td><td valign="top"><a href="#SEC127">14.1 Creating and Destroying Prolog Threads</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1912">thread_get_message/1</a></td><td valign="top"><a href="#SEC130">14.3.1 Message Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1924">thread_get_message/2</a></td><td valign="top"><a href="#SEC130">14.3.1 Message Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1885">thread_join/2</a></td><td valign="top"><a href="#SEC127">14.1 Creating and Destroying Prolog Threads</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1930">thread_local/1 (directive)</a></td><td valign="top"><a href="#SEC132">14.3.3 Threads and Dynamic Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1918">thread_message_queue_create/1</a></td><td valign="top"><a href="#SEC130">14.3.1 Message Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1921">thread_message_queue_destroy/1</a></td><td valign="top"><a href="#SEC130">14.3.1 Message Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1915">thread_peek_message/1</a></td><td valign="top"><a href="#SEC130">14.3.1 Message Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1882">thread_self/1</a></td><td valign="top"><a href="#SEC127">14.1 Creating and Destroying Prolog Threads</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1909">thread_send_message/2</a></td><td valign="top"><a href="#SEC130">14.3.1 Message Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1897">thread_setconcurrency/2</a></td><td valign="top"><a href="#SEC127">14.1 Creating and Destroying Prolog Threads</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1927">thread_signal/2</a></td><td valign="top"><a href="#SEC131">14.3.2 Signalling Threads</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1903">thread_statistics/3</a></td><td valign="top"><a href="#SEC128">14.2 Monitoring Threads</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX196">throw/1</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1618">time_out/3</a></td><td valign="top"><a href="#SEC78">7.17 Calls With Timeout</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1543">tmpnam/1</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1675">top_sort/2</a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1678">top_sort/3</a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1681">transitive_closure/2</a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1660">transpose/3</a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1633">tree_size/2</a></td><td valign="top"><a href="#SEC79">7.18 Updatable Binary Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1636">tree_to_list/2</a></td><td valign="top"><a href="#SEC79">7.18 Updatable Binary Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX604">ttyget/1</a></td><td valign="top"><a href="#SEC43">6.6.6 Compatible C-Prolog predicates for Terminal I/O</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX607">ttyget0/1</a></td><td valign="top"><a href="#SEC43">6.6.6 Compatible C-Prolog predicates for Terminal I/O</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX616">ttynl/0</a></td><td valign="top"><a href="#SEC43">6.6.6 Compatible C-Prolog predicates for Terminal I/O</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX601">ttyput/1</a></td><td valign="top"><a href="#SEC43">6.6.6 Compatible C-Prolog predicates for Terminal I/O</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX610">ttyskip/1</a></td><td valign="top"><a href="#SEC43">6.6.6 Compatible C-Prolog predicates for Terminal I/O</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX613">ttytab/1</a></td><td valign="top"><a href="#SEC43">6.6.6 Compatible C-Prolog predicates for Terminal I/O</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC159_23">U</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1747">undgraph_add_edges/3</a></td><td valign="top"><a href="#SEC82">7.21 Undirected Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1741">undgraph_add_vertices/3</a></td><td valign="top"><a href="#SEC82">7.21 Undirected Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1759">undgraph_complement/2</a></td><td valign="top"><a href="#SEC82">7.21 Undirected Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1750">undgraph_del_edges/3</a></td><td valign="top"><a href="#SEC82">7.21 Undirected Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1744">undgraph_del_vertices/3</a></td><td valign="top"><a href="#SEC82">7.21 Undirected Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1738">undgraph_edges/2</a></td><td valign="top"><a href="#SEC82">7.21 Undirected Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1753">undgraph_neighbors/3</a></td><td valign="top"><a href="#SEC82">7.21 Undirected Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1756">undgraph_neighbours/3</a></td><td valign="top"><a href="#SEC82">7.21 Undirected Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1732">undgraph_new/1</a></td><td valign="top"><a href="#SEC82">7.21 Undirected Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1735">undgraph_vertices/2</a></td><td valign="top"><a href="#SEC82">7.21 Undirected Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX49">unhide/1</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX318">unify_with_occurs_check/2</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX876">unix/1</a></td><td valign="top"><a href="#SEC54">6.12 Access to Operating System Functionality</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX216">unknown/2</a></td><td valign="top"><a href="#SEC33">6.2 Handling Undefined Procedures</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX219">unknown_predicate_handler/3</a></td><td valign="top"><a href="#SEC33">6.2 Handling Undefined Procedures</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX946">update_array/3</a></td><td valign="top"><a href="#SEC58">6.16 Arrays</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX901">update_mutable/2</a></td><td valign="top"><a href="#SEC55">6.13 Term Modification</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX124">use_module/1</a></td><td valign="top"><a href="#SEC29">5.3 Using Modules</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX127">use_module/2</a></td><td valign="top"><a href="#SEC29">5.3 Using Modules</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX130">use_module/3</a></td><td valign="top"><a href="#SEC29">5.3 Using Modules</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC159_24">V</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1600">variable_in_term/2</a></td><td valign="top"><a href="#SEC76">7.15 Utilities On Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1591">variant/2</a></td><td valign="top"><a href="#SEC76">7.15 Utilities On Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1864">verify_attributes/3</a></td><td valign="top"><a href="#SEC96">10.3 Attributed Unification</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1045">version/0</a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1048">version/1</a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1642">vertices/2</a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1639">vertices_edges_to_ugraph/3</a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC159_25">W</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1573">wait/2</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1849">when/2</a></td><td valign="top"><a href="#SEC92">9.2 Coroutining</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1939">with_mutex/2</a></td><td valign="top"><a href="#SEC133">14.4 Thread Synchronisation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1486">with_output_to_chars/2</a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1489">with_output_to_chars/3</a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1492">with_output_to_chars/4</a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1549">working_directory/2</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1786">working_directory/2</a></td><td valign="top"><a href="#SEC83">8. SWI-Prolog Emulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX538">write/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX628">write_depth/3</a></td><td valign="top"><a href="#SEC44">6.6.7 Controlling Input/Output</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX472">write_term/2</a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX544">write_term/3</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1462">write_to_chars/2</a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1465">write_to_chars/3</a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX547">writeq/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC159_26">Y</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX974">yap_flag/2</a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
</table>
<table><tr><th valign="top">Jump to: </th><td><a href="#SEC159_0" class="summary-letter"><b>-</b></a>
<a href="#SEC159_1" class="summary-letter"><b>=</b></a>
<a href="#SEC159_2" class="summary-letter"><b>\</b></a>
<br>
<a href="#SEC159_3" class="summary-letter"><b>A</b></a>
<a href="#SEC159_4" class="summary-letter"><b>B</b></a>
<a href="#SEC159_5" class="summary-letter"><b>C</b></a>
<a href="#SEC159_6" class="summary-letter"><b>D</b></a>
<a href="#SEC159_7" class="summary-letter"><b>E</b></a>
<a href="#SEC159_8" class="summary-letter"><b>F</b></a>
<a href="#SEC159_9" class="summary-letter"><b>G</b></a>
<a href="#SEC159_10" class="summary-letter"><b>H</b></a>
<a href="#SEC159_11" class="summary-letter"><b>I</b></a>
<a href="#SEC159_12" class="summary-letter"><b>J</b></a>
<a href="#SEC159_13" class="summary-letter"><b>K</b></a>
<a href="#SEC159_14" class="summary-letter"><b>L</b></a>
<a href="#SEC159_15" class="summary-letter"><b>M</b></a>
<a href="#SEC159_16" class="summary-letter"><b>N</b></a>
<a href="#SEC159_17" class="summary-letter"><b>O</b></a>
<a href="#SEC159_18" class="summary-letter"><b>P</b></a>
<a href="#SEC159_19" class="summary-letter"><b>Q</b></a>
<a href="#SEC159_20" class="summary-letter"><b>R</b></a>
<a href="#SEC159_21" class="summary-letter"><b>S</b></a>
<a href="#SEC159_22" class="summary-letter"><b>T</b></a>
<a href="#SEC159_23" class="summary-letter"><b>U</b></a>
<a href="#SEC159_24" class="summary-letter"><b>V</b></a>
<a href="#SEC159_25" class="summary-letter"><b>W</b></a>
<a href="#SEC159_26" class="summary-letter"><b>Y</b></a>
</td></tr></table>
<hr size="6">
<a name="Not-in-YAP"></a>
<a name="SEC160"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC159" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC161" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC154" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC155" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC167" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 23.1.5 Yap predicates not available in C-Prolog </h3>
<p>These are C-Prolog built-ins not available in YAP:
</p>
<dl compact="compact">
<dt> <code>'LC'</code></dt>
<dd><p>The following Prolog text uses lower case letters.
</p>
</dd>
<dt> <code>'NOLC'</code></dt>
<dd><p>The following Prolog text uses upper case letters only.
</p></dd>
</dl>
<hr size="6">
<a name="SICStus-Prolog"></a>
<a name="SEC161"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC160" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC162" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC154" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC167" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 23.2 Compatibility with the Quintus and SICStus Prolog systems </h2>
<p>The Quintus Prolog system was the first Prolog compiler to use Warren's
Abstract Machine. This system was very influential in the Prolog
community. Quintus Prolog implemented compilation into an abstract
machine code, which was then emulated. Quintus Prolog also included
several new built-ins, an extensive library, and in later releases a
garbage collector. The SICStus Prolog system, developed at SICS (Swedish
Institute of Computer Science), is an emulator based Prolog system
largely compatible with Quintus Prolog. SICStus Prolog has evolved
through several versions. The current version includes several
extensions, such as an object implementation, co-routining, and
constraints.
</p>
<p>Recent work in YAP has been influenced by work in Quintus and
SICStus Prolog. Wherever possible, we have tried to make YAP
compatible with recent versions of these systems, and specifically of
SICStus Prolog. You should use
</p><table><tr><td> </td><td><pre class="example">:- yap_flag(language, sicstus).
</pre></td></tr></table>
<p>for maximum compatibility with SICStus Prolog.
</p>
<table class="menu" border="0" cellspacing="0">
<p>SICStus Compatibility
<a href="#SEC162">23.2.1 Major Differences between YAP and SICStus Prolog.</a> Major Differences between YAP and SICStus Prolog
<a href="#SEC163">23.2.2 Yap predicates fully compatible with SICStus Prolog</a> Yap predicates fully compatible with
SICStus Prolog
<a href="#SEC164">23.2.3 Yap predicates not strictly compatible with SICStus Prolog</a> Yap predicates not strictly as
SICStus Prolog
<a href="#SEC165">23.2.4 Yap predicates not available in SICStus Prolog</a> Yap predicates not available in SICStus Prolog
</p></table>
<hr size="6">
<a name="Major-Differences-with-SICStus"></a>
<a name="SEC162"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC161" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC163" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC154" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC161" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC167" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 23.2.1 Major Differences between YAP and SICStus Prolog. </h3>
<p>Both YAP and SICStus Prolog obey the Edinburgh Syntax and are based on
the WAM. Even so, there are quite a few important differences:
</p>
<ul>
<li> Differently from SICStus Prolog, YAP does not have a
notion of interpreted code. All code in YAP is compiled.
</li><li> YAP does not support an intermediate byte-code
representation, so the <code>fcompile/1</code> and <code>load/1</code> built-ins are
not available in YAP.
</li><li> YAP implements escape sequences as in the ISO standard. SICStus
Prolog implements Unix-like escape sequences.
</li><li> YAP implements <code>initialization/1</code> as per the ISO
standard. Use <code>prolog_initialization/1</code> for the SICStus Prolog
compatible built-in.
</li><li> Prolog flags are different in SICStus Prolog and in YAP.
</li><li> The SICStus Prolog <code>on_exception/3</code> and
<code>raise_exception</code> built-ins correspond to the ISO built-ins
<code>catch/3</code> and <code>throw/1</code>.
</li><li> The following SICStus Prolog v3 built-ins are not (currently)
implemented in YAP (note that this is only a partial list):
<code>call_cleanup/1</code>, <code>file_search_path/2</code>,
<code>stream_interrupt/3</code>, <code>reinitialize/0</code>, <code>help/0</code>,
<code>help/1</code>, <code>trimcore/0</code>, <code>load_files/1</code>,
<code>load_files/2</code>, and <code>require/1</code>.
<p> The previous list is incomplete. We also cannot guarantee full
compatibility for other built-ins (although we will try to address any
such incompatibilities). Last, SICStus Prolog is an evolving system, so
one can be expect new incompatibilities to be introduced in future
releases of SICStus Prolog.
</p>
</li><li> YAP allows asserting and abolishing static code during
execution through the <code>assert_static/1</code> and <code>abolish/1</code>
built-ins. This is not allowed in Quintus Prolog or SICStus Prolog.
</li><li> YAP implements rational trees and co-routining but they
are not included by default in the system. You must enable these
extensions when compiling the system.
</li><li> YAP does not currently implement constraints.
</li><li> The socket predicates, although designed to be compatible with
SICStus Prolog, are built-ins, not library predicates, in YAP.
</li><li> This list is incomplete.
</li></ul>
<p>The following differences only exist if the <code>language</code> flag is set
to <code>yap</code> (the default):
</p>
<ul>
<li> The <code>consult/1</code> predicate in YAP follows C-Prolog
semantics. That is, it adds clauses to the data base, even for
preexisting procedures. This is different from <code>consult/1</code> in
SICStus Prolog.
<a name="IDX2070"></a>
</li><li> By default, the data-base in YAP follows "immediate update
semantics", instead of "logical update semantics", as Quintus Prolog or
SICStus Prolog do. The difference is depicted in the next example:
<table><tr><td> </td><td><pre class="example">:- dynamic a/1.
?- assert(a(1)).
?- retract(a(X)), X1 is X +1, assertz(a(X)).
</pre></td></tr></table><p>With immediate semantics, new clauses or entries to the data base are
visible in backtracking. In this example, the first call to
<code>retract/1</code> will succeed. The call to <strong>assertz/1</strong> will then
succeed. On backtracking, the system will retry
<code>retract/1</code>. Because the newly asserted goal is visible to
<code>retract/1</code>, it can be retracted from the data base, and
<code>retract(a(X))</code> will succeed again. The process will continue
generating integers for ever. Immediate semantics were used in C-Prolog.
</p>
<p>With logical update semantics, any additions or deletions of clauses
for a goal <em>will not affect previous activations of the
goal</em>. In the example, the call to <code>assertz/1</code> will not see the
update performed by the <code>assertz/1</code>, and the query will have a
single solution.
</p>
<p>Calling <code>yap_flag(update_semantics,logical)</code> will switch
YAP to use logical update semantics.
</p>
</li><li> <code>dynamic/1</code> is a built-in, not a directive, in YAP.
</li><li> By default, YAP fails on undefined predicates. To follow default
SICStus Prolog use:
<table><tr><td> </td><td><pre class="example">:- yap_flag(unknown,error).
</pre></td></tr></table>
</li><li> By default, directives in YAP can be called from the top level.
</li></ul>
<hr size="6">
<a name="Fully-SICStus-Compatible"></a>
<a name="SEC163"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC162" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC164" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC154" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC161" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC167" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 23.2.2 Yap predicates fully compatible with SICStus Prolog </h3>
<p>These are the Prolog built-ins that are fully compatible in both SICStus
Prolog and YAP:
</p>
<table><tr><th valign="top">Jump to: </th><td><a href="#SEC163_0" class="summary-letter"><b>!</b></a>
<a href="#SEC163_1" class="summary-letter"><b>,</b></a>
<a href="#SEC163_2" class="summary-letter"><b>-</b></a>
<a href="#SEC163_3" class="summary-letter"><b>;</b></a>
<a href="#SEC163_4" class="summary-letter"><b><</b></a>
<a href="#SEC163_5" class="summary-letter"><b>=</b></a>
<a href="#SEC163_6" class="summary-letter"><b>></b></a>
<a href="#SEC163_7" class="summary-letter"><b>@</b></a>
<a href="#SEC163_8" class="summary-letter"><b>\</b></a>
<br>
<a href="#SEC163_9" class="summary-letter"><b>A</b></a>
<a href="#SEC163_10" class="summary-letter"><b>B</b></a>
<a href="#SEC163_11" class="summary-letter"><b>C</b></a>
<a href="#SEC163_12" class="summary-letter"><b>D</b></a>
<a href="#SEC163_13" class="summary-letter"><b>E</b></a>
<a href="#SEC163_14" class="summary-letter"><b>F</b></a>
<a href="#SEC163_15" class="summary-letter"><b>G</b></a>
<a href="#SEC163_16" class="summary-letter"><b>H</b></a>
<a href="#SEC163_17" class="summary-letter"><b>I</b></a>
<a href="#SEC163_18" class="summary-letter"><b>J</b></a>
<a href="#SEC163_19" class="summary-letter"><b>K</b></a>
<a href="#SEC163_20" class="summary-letter"><b>L</b></a>
<a href="#SEC163_21" class="summary-letter"><b>M</b></a>
<a href="#SEC163_22" class="summary-letter"><b>N</b></a>
<a href="#SEC163_23" class="summary-letter"><b>O</b></a>
<a href="#SEC163_24" class="summary-letter"><b>P</b></a>
<a href="#SEC163_25" class="summary-letter"><b>Q</b></a>
<a href="#SEC163_26" class="summary-letter"><b>R</b></a>
<a href="#SEC163_27" class="summary-letter"><b>S</b></a>
<a href="#SEC163_28" class="summary-letter"><b>T</b></a>
<a href="#SEC163_29" class="summary-letter"><b>U</b></a>
<a href="#SEC163_30" class="summary-letter"><b>V</b></a>
<a href="#SEC163_31" class="summary-letter"><b>W</b></a>
</td></tr></table>
<table border="0" class="index-sy">
<tr><td></td><th align="left">Index Entry</th><th align="left"> Section</th></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC163_0">!</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX150">!/0</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC163_1">,</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX135">,/2</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC163_2">-</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX159">->/2</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC163_3">;</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX138">;/2</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC163_4"><</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX356"></2</a></td><td valign="top"><a href="#SEC36">6.5 Arithmetic</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC163_5">=</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX308">=../2</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX311">=/2</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX368">=:=/2</a></td><td valign="top"><a href="#SEC36">6.5 Arithmetic</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX359">=</2</a></td><td valign="top"><a href="#SEC36">6.5 Arithmetic</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX326">==/2</a></td><td valign="top"><a href="#SEC35">6.4 Comparing Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX371">=\=/2</a></td><td valign="top"><a href="#SEC36">6.5 Arithmetic</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC163_6">></a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX362">>/2</a></td><td valign="top"><a href="#SEC36">6.5 Arithmetic</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX365">>=/2</a></td><td valign="top"><a href="#SEC36">6.5 Arithmetic</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC163_7">@</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX332">@</2</a></td><td valign="top"><a href="#SEC35">6.4 Comparing Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX335">@</2</a></td><td valign="top"><a href="#SEC35">6.4 Comparing Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX338">@>/2</a></td><td valign="top"><a href="#SEC35">6.4 Comparing Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX341">@>=/2</a></td><td valign="top"><a href="#SEC35">6.4 Comparing Terms</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC163_8">\</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX153">\+/1</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX329">\==/2</a></td><td valign="top"><a href="#SEC35">6.4 Comparing Terms</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC163_9">A</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX180">abort/0</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX389">absolute_file_name/2</a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1653">add_edges/3</a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1149">add_to_heap/4</a></td><td valign="top"><a href="#SEC65">7.4 Heaps</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1647">add_vertices/3</a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1173">append/3</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX302">arg/3</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1089">assoc_to_list/2</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX416">at_end_of_stream/0</a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX419">at_end_of_stream/1</a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX224">atom/1</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX263">atom_codes/2</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX266">atom_concat/2</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX272">atom_concat/3</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1467">atom_to_chars/2</a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1470">atom_to_chars/3</a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX227">atomic/1</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1869">attribute_goal/2</a></td><td valign="top"><a href="#SEC97">10.4 Displaying Attributes</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC163_10">B</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX815">bb_delete/2</a></td><td valign="top"><a href="#SEC51">6.9 The Blackboard</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX812">bb_get/2</a></td><td valign="top"><a href="#SEC51">6.9 The Blackboard</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX809">bb_put/2</a></td><td valign="top"><a href="#SEC51">6.9 The Blackboard</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX818">bb_update/3</a></td><td valign="top"><a href="#SEC51">6.9 The Blackboard</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX183">break/0</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC163_11">C</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX851">C/3</a></td><td valign="top"><a href="#SEC53">6.11 Grammar Rules</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX165">call/1</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1605">call_cleanup/1</a></td><td valign="top"><a href="#SEC77">7.16 Call Cleanup</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1608">call_cleanup/2</a></td><td valign="top"><a href="#SEC77">7.16 Call Cleanup</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1851">call_residue/2</a></td><td valign="top"><a href="#SEC92">9.2 Coroutining</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX254">callable/1</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX290">char_code/2</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX456">char_conversion/2</a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1614">cleanup_all/0</a></td><td valign="top"><a href="#SEC77">7.16 Call Cleanup</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX383">close/1</a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX323">compare/3</a></td><td valign="top"><a href="#SEC35">6.4 Comparing Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX21">compile/1</a></td><td valign="top"><a href="#SEC23">4.1 Program loading and updating</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX24">compile/1</a></td><td valign="top"><a href="#SEC23">4.1 Program loading and updating</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1668">complement/2</a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1671">compose/3</a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX230">compound/1</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX320">copy_term/2</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX888">create_mutable/2</a></td><td valign="top"><a href="#SEC55">6.13 Term Modification</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX725">current_atom/1</a></td><td valign="top"><a href="#SEC48">6.7.2 Looking at the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX459">current_char_conversion/2</a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX410">current_input/1</a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX788">current_key/2</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX951">current_module/1</a></td><td valign="top"><a href="#SEC59">6.17 Predicate Information</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX954">current_module/2</a></td><td valign="top"><a href="#SEC59">6.17 Predicate Information</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1032">current_op/3</a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX413">current_output/1</a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX728">current_predicate/1</a></td><td valign="top"><a href="#SEC48">6.7.2 Looking at the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX731">current_predicate/2</a></td><td valign="top"><a href="#SEC48">6.7.2 Looking at the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX392">current_stream/3</a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1575">cyclic_term/1</a></td><td valign="top"><a href="#SEC76">7.15 Utilities On Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1578">cyclic_term/1</a></td><td valign="top"><a href="#SEC76">7.15 Utilities On Terms</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC163_12">D</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1494">datime/1</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX233">db_reference/1</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1989">debugging/0</a></td><td valign="top"><a href="#SEC139">19.1 Debugging Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1092">del_assoc/4</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1656">del_edges/3</a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1095">del_max_assoc/4</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1098">del_min_assoc/4</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1650">del_vertices/3</a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1176">delete/3</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1500">delete_file/1</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1503">delete_file/2</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1698">dgraph_del_vertices/3</a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1839">dif/2</a></td><td valign="top"><a href="#SEC92">9.2 Coroutining</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1506">directory_files/2</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX78">discontiguous/1 (directive)</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX465">display/1</a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX468">display/1</a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX540">display/1</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX549">display/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC163_13">E</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1644">edges/2</a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1101">empty_assoc/1</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1152">empty_heap/1</a></td><td valign="top"><a href="#SEC65">7.4 Heaps</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1329">empty_queue/1</a></td><td valign="top"><a href="#SEC69">7.8 Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX857">environ/2</a></td><td valign="top"><a href="#SEC54">6.12 Access to Operating System Functionality</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1524">environ/2</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1545">exec/3</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX836">expand_term/2</a></td><td valign="top"><a href="#SEC53">6.11 Grammar Rules</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC163_14">F</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX144">fail/0</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX147">false/0</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1509">file_exists/1</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1512">file_exists/2</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1515">file_property/2</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX87">file_search_path/2</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX624">fileerrors/0</a></td><td valign="top"><a href="#SEC44">6.6.7 Controlling Input/Output</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX821">findall/3</a></td><td valign="top"><a href="#SEC52">6.10 Collecting Solutions to a Goal</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX824">findall/4</a></td><td valign="top"><a href="#SEC52">6.10 Collecting Solutions to a Goal</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1179">flatten/2</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX236">float/1</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX395">flush_output/0</a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX398">flush_output/1</a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1455">format_to_chars/3</a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1458">format_to_chars/4</a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1602">fragile</a></td><td valign="top"><a href="#SEC77">7.16 Call Cleanup</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1842">freeze/2</a></td><td valign="top"><a href="#SEC92">9.2 Coroutining</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1845">frozen/2</a></td><td valign="top"><a href="#SEC92">9.2 Coroutining</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX305">functor/3</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC163_15">G</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX198">garbage_collect/0</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX201">garbage_collect_atoms/0</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX204">gc/0</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1104">gen_assoc/3</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX498">get/1</a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX567">get/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX501">get0/1</a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX570">get0/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1116">get_assoc/3</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1110">get_assoc/5</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1857">get_atts/2</a></td><td valign="top"><a href="#SEC95">10.2 Attribute Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1155">get_from_heap/4</a></td><td valign="top"><a href="#SEC65">7.4 Heaps</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1620">get_label/3</a></td><td valign="top"><a href="#SEC79">7.18 Updatable Binary Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX891">get_mutable/2</a></td><td valign="top"><a href="#SEC55">6.13 Term Modification</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX897">get_mutable/2</a></td><td valign="top"><a href="#SEC55">6.13 Term Modification</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1107">get_next_assoc/4</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1113">get_prev_assoc/4</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1341">getrand/1</a></td><td valign="top"><a href="#SEC70">7.9 Random Number Generator</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX299">ground/1</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC163_16">H</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX186">halt/0</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX189">halt/1</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1323">head_queue/2</a></td><td valign="top"><a href="#SEC69">7.8 Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1158">heap_size/2</a></td><td valign="top"><a href="#SEC65">7.4 Heaps</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1161">heap_to_list/2</a></td><td valign="top"><a href="#SEC65">7.4 Heaps</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1527">host_id/1</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1530">host_name/1</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC163_17">I</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX174">if/3</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX168">incore/1</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1038">initialization/0</a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX239">integer/1</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX353">is/2</a></td><td valign="top"><a href="#SEC36">6.5 Arithmetic</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1119">is_assoc/1</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1182">is_list/1</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX894">is_mutable/1</a></td><td valign="top"><a href="#SEC55">6.13 Term Modification</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC163_18">J</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1311">join_queue/3</a></td><td valign="top"><a href="#SEC69">7.8 Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1317">jump_queue/3</a></td><td valign="top"><a href="#SEC69">7.8 Queues</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC163_19">K</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX347">keysort/2</a></td><td valign="top"><a href="#SEC35">6.4 Comparing Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1533">kill/2</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC163_20">L</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1185">last/2</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2004">leash/1</a></td><td valign="top"><a href="#SEC139">19.1 Debugging Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX350">length/2</a></td><td valign="top"><a href="#SEC35">6.4 Comparing Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1332">length_queue/2</a></td><td valign="top"><a href="#SEC69">7.8 Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1314">list_join_queue/3</a></td><td valign="top"><a href="#SEC69">7.8 Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1320">list_jump_queue/3</a></td><td valign="top"><a href="#SEC69">7.8 Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1122">list_to_assoc/2</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1164">list_to_heap/2</a></td><td valign="top"><a href="#SEC65">7.4 Heaps</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1242">list_to_ord_set/2</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1335">list_to_queue/2</a></td><td valign="top"><a href="#SEC69">7.8 Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1623">list_to_tree/2</a></td><td valign="top"><a href="#SEC79">7.18 Updatable Binary Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX716">listing/1</a></td><td valign="top"><a href="#SEC48">6.7.2 Looking at the Data Base</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC163_21">M</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1518">make_directory/2</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1308">make_queue/1</a></td><td valign="top"><a href="#SEC69">7.8 Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1125">map_assoc/2</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1128">map_assoc/3</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1626">map_tree/3</a></td><td valign="top"><a href="#SEC79">7.18 Updatable Binary Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1131">max_assoc/3</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1236">max_list/2</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1191">member/2</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1194">memberchk/2</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1245">merge/3</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX132">meta_predicate/1 (directive)</a></td><td valign="top"><a href="#SEC30">5.4 Meta-Predicates in Modules</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1134">min_assoc/3</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1239">min_list/2</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1167">min_of_heap/3</a></td><td valign="top"><a href="#SEC65">7.4 Heaps</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1170">min_of_heap/5</a></td><td valign="top"><a href="#SEC65">7.4 Heaps</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1536">mktemp/2</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX120">module/1</a></td><td valign="top"><a href="#SEC28">5.2 Defining a New Module</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX114">module/2 (directive)</a></td><td valign="top"><a href="#SEC28">5.2 Defining a New Module</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX117">module/3 (directive)</a></td><td valign="top"><a href="#SEC28">5.2 Defining a New Module</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX75">multifile/1 (directive)</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC163_22">N</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX257">name/2</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1662">neighbors/3</a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1665">neighbours/3</a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX528">nl/0</a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX597">nl/1</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1992">nodebug/0</a></td><td valign="top"><a href="#SEC139">19.1 Debugging Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX621">nofileerrors/0</a></td><td valign="top"><a href="#SEC44">6.6.7 Controlling Input/Output</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX207">nogc/0</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX242">nonvar/1</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1998">nospy/1</a></td><td valign="top"><a href="#SEC139">19.1 Debugging Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2001">nospyall/0</a></td><td valign="top"><a href="#SEC139">19.1 Debugging Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1200">nth/2</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1206">nth/4</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1197">nth0/2</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1203">nth0/4</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX245">number/1</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX284">number_codes/2</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1473">number_to_chars/2</a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1476">number_to_chars/3</a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX296">numbervars/3</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC163_23">O</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1611">on_cleanup/1</a></td><td valign="top"><a href="#SEC77">7.16 Call Cleanup</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1029">op/3</a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX377">open/3</a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1482">open_chars_stream/2</a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1248">ord_add_element/3</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1251">ord_del_element/3</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1254">ord_disjoint/2</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1260">ord_insert/3</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1263">ord_intersect/2</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1266">ord_intersect/3</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1269">ord_intersect/4</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1137">ord_list_to_assoc/2</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1257">ord_member/2</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1272">ord_seteq/2</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1275">ord_setproduct/3</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1281">ord_subtract/3</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1284">ord_symdiff/3</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1287">ord_union/2</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1290">ord_union/3</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1293">ord_union/4</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1278">ordsubset/2</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC163_24">P</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX516">peek_char/1</a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1209">permutation/2</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX848">phrase/2</a></td><td valign="top"><a href="#SEC53">6.11 Grammar Rules</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX845">phrase/3</a></td><td valign="top"><a href="#SEC53">6.11 Grammar Rules</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1539">pid/1</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1551">popen/3</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX719">portray_clause/1</a></td><td valign="top"><a href="#SEC48">6.7.2 Looking at the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX722">portray_clause/2</a></td><td valign="top"><a href="#SEC48">6.7.2 Looking at the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX248">primitive/1</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX477">print/1</a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX552">print/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1872">project_attributes/2</a></td><td valign="top"><a href="#SEC97">10.4 Displaying Attributes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1875">project_attributes/2</a></td><td valign="top"><a href="#SEC98">10.5 Projecting Attributes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX93">prolog_file_name/1</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1023">prolog_flag/3</a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1050">prolog_load_context/2</a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1035">prompt/2</a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX486">put/1</a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX555">put/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1140">put_assoc/4</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1860">put_atts/2</a></td><td valign="top"><a href="#SEC95">10.2 Attribute Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1629">put_label/4</a></td><td valign="top"><a href="#SEC79">7.18 Updatable Binary Trees</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC163_25">Q</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1338">queue_to_list/2</a></td><td valign="top"><a href="#SEC69">7.8 Queues</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC163_26">R</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1344">random/1</a></td><td valign="top"><a href="#SEC70">7.9 Random Number Generator</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1347">random/3</a></td><td valign="top"><a href="#SEC70">7.9 Random Number Generator</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1350">randseq/3</a></td><td valign="top"><a href="#SEC70">7.9 Random Number Generator</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1353">randset/3</a></td><td valign="top"><a href="#SEC70">7.9 Random Number Generator</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1683">reachable/3</a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX446">read/1</a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX531">read/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1479">read_from_chars/2</a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1212">remove_duplicates/2</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1521">rename_file/2</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX162">repeat/0</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX111">restore/1</a></td><td valign="top"><a href="#SEC25">4.3 Saving and Loading Prolog States</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1215">reverse/2</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC163_27">S</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1218">same_length/2</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX105">save_program/1</a></td><td valign="top"><a href="#SEC25">4.3 Saving and Loading Prolog States</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX108">save_program/2</a></td><td valign="top"><a href="#SEC25">4.3 Saving and Loading Prolog States</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX437">see/1</a></td><td valign="top"><a href="#SEC39">6.6.2 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX440">seeing/1</a></td><td valign="top"><a href="#SEC39">6.6.2 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX443">seen/0</a></td><td valign="top"><a href="#SEC39">6.6.2 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1221">select/3</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1326">serve_queue/3</a></td><td valign="top"><a href="#SEC69">7.8 Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX401">set_input/1</a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX404">set_output/1</a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX422">set_stream_position/2</a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1356">setrand/1</a></td><td valign="top"><a href="#SEC70">7.9 Random Number Generator</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1554">shell/0</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1557">shell/1</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1560">shell/1</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX251">simple/1</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX522">skip/1</a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX591">skip/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1563">sleep/1</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX638">socket/2</a></td><td valign="top"><a href="#SEC45">6.6.8 Using Sockets From Yap</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX635">socket/4</a></td><td valign="top"><a href="#SEC45">6.6.8 Using Sockets From Yap</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX653">socket_accept/2</a></td><td valign="top"><a href="#SEC45">6.6.8 Using Sockets From Yap</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX659">socket_accept/2</a></td><td valign="top"><a href="#SEC45">6.6.8 Using Sockets From Yap</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX656">socket_accept/3</a></td><td valign="top"><a href="#SEC45">6.6.8 Using Sockets From Yap</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX644">socket_bind/2</a></td><td valign="top"><a href="#SEC45">6.6.8 Using Sockets From Yap</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX662">socket_buffering/4</a></td><td valign="top"><a href="#SEC45">6.6.8 Using Sockets From Yap</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX641">socket_close/1</a></td><td valign="top"><a href="#SEC45">6.6.8 Using Sockets From Yap</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX647">socket_connect/3</a></td><td valign="top"><a href="#SEC45">6.6.8 Using Sockets From Yap</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX650">socket_listen/2</a></td><td valign="top"><a href="#SEC45">6.6.8 Using Sockets From Yap</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX665">socket_select/5</a></td><td valign="top"><a href="#SEC45">6.6.8 Using Sockets From Yap</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX344">sort/2</a></td><td valign="top"><a href="#SEC35">6.4 Comparing Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1995">spy/1</a></td><td valign="top"><a href="#SEC139">19.1 Debugging Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX407">stream_select/3</a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1224">sublist/2</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1593">subsumes/2</a></td><td valign="top"><a href="#SEC76">7.15 Utilities On Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1596">subsumes_chk/2</a></td><td valign="top"><a href="#SEC76">7.15 Utilities On Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1227">suffix/2</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1230">sum_list/2</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1233">sumlist/2</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1566">system/0</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1569">system/2</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX734">system_predicate/2</a></td><td valign="top"><a href="#SEC48">6.7.2 Looking at the Data Base</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC163_28">T</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX525">tab/1</a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX594">tab/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX428">tell/1</a></td><td valign="top"><a href="#SEC39">6.6.2 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX431">telling/1</a></td><td valign="top"><a href="#SEC39">6.6.2 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX839">term_expansion/2</a></td><td valign="top"><a href="#SEC53">6.11 Grammar Rules</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1581">term_hash/2</a></td><td valign="top"><a href="#SEC76">7.15 Utilities On Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1584">term_hash/4</a></td><td valign="top"><a href="#SEC76">7.15 Utilities On Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1587">term_variables/2</a></td><td valign="top"><a href="#SEC76">7.15 Utilities On Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1617">time_out/3</a></td><td valign="top"><a href="#SEC78">7.17 Calls With Timeout</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1542">tmpnam/1</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX434">told/0</a></td><td valign="top"><a href="#SEC39">6.6.2 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1674">top_sort/2</a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1677">top_sort/3</a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1680">transitive_closure/2</a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1659">transpose/3</a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1632">tree_size/2</a></td><td valign="top"><a href="#SEC79">7.18 Updatable Binary Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1635">tree_to_list/2</a></td><td valign="top"><a href="#SEC79">7.18 Updatable Binary Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX141">true/0</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX603">ttyget/1</a></td><td valign="top"><a href="#SEC43">6.6.6 Compatible C-Prolog predicates for Terminal I/O</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX606">ttyget0/1</a></td><td valign="top"><a href="#SEC43">6.6.6 Compatible C-Prolog predicates for Terminal I/O</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX615">ttynl/0</a></td><td valign="top"><a href="#SEC43">6.6.6 Compatible C-Prolog predicates for Terminal I/O</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX600">ttyput/1</a></td><td valign="top"><a href="#SEC43">6.6.6 Compatible C-Prolog predicates for Terminal I/O</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX609">ttyskip/1</a></td><td valign="top"><a href="#SEC43">6.6.6 Compatible C-Prolog predicates for Terminal I/O</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX612">ttytab/1</a></td><td valign="top"><a href="#SEC43">6.6.6 Compatible C-Prolog predicates for Terminal I/O</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC163_29">U</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1743">undgraph_del_vertices/3</a></td><td valign="top"><a href="#SEC82">7.21 Undirected Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX317">unify_with_occurs_check/2</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX218">unknown_predicate_handler/3</a></td><td valign="top"><a href="#SEC33">6.2 Handling Undefined Procedures</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX900">update_mutable/2</a></td><td valign="top"><a href="#SEC55">6.13 Term Modification</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX123">use_module/1</a></td><td valign="top"><a href="#SEC29">5.3 Using Modules</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX126">use_module/2</a></td><td valign="top"><a href="#SEC29">5.3 Using Modules</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX129">use_module/3</a></td><td valign="top"><a href="#SEC29">5.3 Using Modules</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC163_30">V</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX221">var/1</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1590">variant/2</a></td><td valign="top"><a href="#SEC76">7.15 Utilities On Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1863">verify_attributes/3</a></td><td valign="top"><a href="#SEC96">10.3 Attributed Unification</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1047">version/1</a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1641">vertices/2</a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1638">vertices_edges_to_ugraph/3</a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC163_31">W</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1572">wait/2</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1848">when/2</a></td><td valign="top"><a href="#SEC92">9.2 Coroutining</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1485">with_output_to_chars/2</a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1488">with_output_to_chars/3</a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1491">with_output_to_chars/4</a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1548">working_directory/2</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX462">write/1</a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX537">write/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX471">write_term/2</a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX543">write_term/3</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1461">write_to_chars/2</a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1464">write_to_chars/3</a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX474">writeq/1</a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX546">writeq/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
</table>
<table><tr><th valign="top">Jump to: </th><td><a href="#SEC163_0" class="summary-letter"><b>!</b></a>
<a href="#SEC163_1" class="summary-letter"><b>,</b></a>
<a href="#SEC163_2" class="summary-letter"><b>-</b></a>
<a href="#SEC163_3" class="summary-letter"><b>;</b></a>
<a href="#SEC163_4" class="summary-letter"><b><</b></a>
<a href="#SEC163_5" class="summary-letter"><b>=</b></a>
<a href="#SEC163_6" class="summary-letter"><b>></b></a>
<a href="#SEC163_7" class="summary-letter"><b>@</b></a>
<a href="#SEC163_8" class="summary-letter"><b>\</b></a>
<br>
<a href="#SEC163_9" class="summary-letter"><b>A</b></a>
<a href="#SEC163_10" class="summary-letter"><b>B</b></a>
<a href="#SEC163_11" class="summary-letter"><b>C</b></a>
<a href="#SEC163_12" class="summary-letter"><b>D</b></a>
<a href="#SEC163_13" class="summary-letter"><b>E</b></a>
<a href="#SEC163_14" class="summary-letter"><b>F</b></a>
<a href="#SEC163_15" class="summary-letter"><b>G</b></a>
<a href="#SEC163_16" class="summary-letter"><b>H</b></a>
<a href="#SEC163_17" class="summary-letter"><b>I</b></a>
<a href="#SEC163_18" class="summary-letter"><b>J</b></a>
<a href="#SEC163_19" class="summary-letter"><b>K</b></a>
<a href="#SEC163_20" class="summary-letter"><b>L</b></a>
<a href="#SEC163_21" class="summary-letter"><b>M</b></a>
<a href="#SEC163_22" class="summary-letter"><b>N</b></a>
<a href="#SEC163_23" class="summary-letter"><b>O</b></a>
<a href="#SEC163_24" class="summary-letter"><b>P</b></a>
<a href="#SEC163_25" class="summary-letter"><b>Q</b></a>
<a href="#SEC163_26" class="summary-letter"><b>R</b></a>
<a href="#SEC163_27" class="summary-letter"><b>S</b></a>
<a href="#SEC163_28" class="summary-letter"><b>T</b></a>
<a href="#SEC163_29" class="summary-letter"><b>U</b></a>
<a href="#SEC163_30" class="summary-letter"><b>V</b></a>
<a href="#SEC163_31" class="summary-letter"><b>W</b></a>
</td></tr></table>
<hr size="6">
<a name="Not-Strictly-SICStus-Compatible"></a>
<a name="SEC164"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC163" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC165" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC154" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC161" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC167" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 23.2.3 Yap predicates not strictly compatible with SICStus Prolog </h3>
<p>These are YAP built-ins that are also available in SICStus Prolog, but
that are not fully compatible:
</p>
<table><tr><th valign="top">Jump to: </th><td><a href="#SEC164_0" class="summary-letter"><b>[</b></a>
<br>
<a href="#SEC164_1" class="summary-letter"><b>A</b></a>
<a href="#SEC164_2" class="summary-letter"><b>B</b></a>
<a href="#SEC164_3" class="summary-letter"><b>C</b></a>
<a href="#SEC164_4" class="summary-letter"><b>D</b></a>
<a href="#SEC164_5" class="summary-letter"><b>E</b></a>
<a href="#SEC164_6" class="summary-letter"><b>F</b></a>
<a href="#SEC164_7" class="summary-letter"><b>I</b></a>
<a href="#SEC164_8" class="summary-letter"><b>L</b></a>
<a href="#SEC164_9" class="summary-letter"><b>N</b></a>
<a href="#SEC164_10" class="summary-letter"><b>O</b></a>
<a href="#SEC164_11" class="summary-letter"><b>P</b></a>
<a href="#SEC164_12" class="summary-letter"><b>R</b></a>
<a href="#SEC164_13" class="summary-letter"><b>S</b></a>
<a href="#SEC164_14" class="summary-letter"><b>U</b></a>
<a href="#SEC164_15" class="summary-letter"><b>V</b></a>
</td></tr></table>
<table border="0" class="index-sa">
<tr><td></td><th align="left">Index Entry</th><th align="left"> Section</th></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC164_0">[</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX18">[-]/1</a></td><td valign="top"><a href="#SEC23">4.1 Program loading and updating</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX15">[]/1</a></td><td valign="top"><a href="#SEC23">4.1 Program loading and updating</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC164_1">A</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX683">abolish/1</a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX686">abolish/2</a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX674">assert/1</a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX740">assert/2</a></td><td valign="top"><a href="#SEC49">6.7.3 Using Data Base References</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX677">asserta/1</a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX743">asserta/2</a></td><td valign="top"><a href="#SEC49">6.7.3 Using Data Base References</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX680">assertz/1</a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX746">assertz/2</a></td><td valign="top"><a href="#SEC49">6.7.3 Using Data Base References</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX260">atom_chars/2</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC164_2">B</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX830">bagof/3</a></td><td valign="top"><a href="#SEC52">6.10 Collecting Solutions to a Goal</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC164_3">C</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX698">clause/2</a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX701">clause/3</a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX386">close/2</a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC164_4">D</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1986">debug/0</a></td><td valign="top"><a href="#SEC139">19.1 Debugging Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX668">dynamic/1</a></td><td valign="top"><a href="#SEC46">6.7 Using the Clausal Data Base</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC164_5">E</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX776">erase/1</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX779">erased/1</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC164_6">F</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX480">format/2</a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX483">format/3</a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC164_7">I</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX782">instance/2</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC164_8">L</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX713">listing/0</a></td><td valign="top"><a href="#SEC48">6.7.2 Looking at the Data Base</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC164_9">N</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX704">nth_clause/3</a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX773">nth_recorded/3</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX281">number_chars/2</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC164_10">O</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX380">open/4</a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC164_11">P</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX737">predicate_property/2</a></td><td valign="top"><a href="#SEC48">6.7.2 Looking at the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1041">prolog_initialization/1</a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC164_12">R</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX449">read_term/2</a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX534">read_term/3</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX752">recorda/3</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX764">recordaifnot/3</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX770">recorded/3</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX755">recordz/3</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX707">retract/1</a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX749">retract/2</a></td><td valign="top"><a href="#SEC49">6.7.3 Using Data Base References</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX710">retractall/1</a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC164_13">S</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX833">setof/3</a></td><td valign="top"><a href="#SEC52">6.10 Collecting Solutions to a Goal</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX957">statistics/0</a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX960">statistics/2</a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC164_14">U</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX215">unknown/2</a></td><td valign="top"><a href="#SEC33">6.2 Handling Undefined Procedures</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC164_15">V</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1044">version/0</a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
</table>
<table><tr><th valign="top">Jump to: </th><td><a href="#SEC164_0" class="summary-letter"><b>[</b></a>
<br>
<a href="#SEC164_1" class="summary-letter"><b>A</b></a>
<a href="#SEC164_2" class="summary-letter"><b>B</b></a>
<a href="#SEC164_3" class="summary-letter"><b>C</b></a>
<a href="#SEC164_4" class="summary-letter"><b>D</b></a>
<a href="#SEC164_5" class="summary-letter"><b>E</b></a>
<a href="#SEC164_6" class="summary-letter"><b>F</b></a>
<a href="#SEC164_7" class="summary-letter"><b>I</b></a>
<a href="#SEC164_8" class="summary-letter"><b>L</b></a>
<a href="#SEC164_9" class="summary-letter"><b>N</b></a>
<a href="#SEC164_10" class="summary-letter"><b>O</b></a>
<a href="#SEC164_11" class="summary-letter"><b>P</b></a>
<a href="#SEC164_12" class="summary-letter"><b>R</b></a>
<a href="#SEC164_13" class="summary-letter"><b>S</b></a>
<a href="#SEC164_14" class="summary-letter"><b>U</b></a>
<a href="#SEC164_15" class="summary-letter"><b>V</b></a>
</td></tr></table>
<hr size="6">
<a name="Not-in-SICstus-Prolog"></a>
<a name="SEC165"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC164" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC166" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC154" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC161" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC167" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h3 class="subsection"> 23.2.4 Yap predicates not available in SICStus Prolog </h3>
<p>These are YAP built-ins not available in SICStus Prolog.
</p>
<table><tr><th valign="top">Jump to: </th><td><a href="#SEC165_0" class="summary-letter"><b>\</b></a>
<br>
<a href="#SEC165_1" class="summary-letter"><b>A</b></a>
<a href="#SEC165_2" class="summary-letter"><b>B</b></a>
<a href="#SEC165_3" class="summary-letter"><b>C</b></a>
<a href="#SEC165_4" class="summary-letter"><b>D</b></a>
<a href="#SEC165_5" class="summary-letter"><b>E</b></a>
<a href="#SEC165_6" class="summary-letter"><b>F</b></a>
<a href="#SEC165_7" class="summary-letter"><b>G</b></a>
<a href="#SEC165_8" class="summary-letter"><b>H</b></a>
<a href="#SEC165_9" class="summary-letter"><b>I</b></a>
<a href="#SEC165_10" class="summary-letter"><b>K</b></a>
<a href="#SEC165_11" class="summary-letter"><b>L</b></a>
<a href="#SEC165_12" class="summary-letter"><b>M</b></a>
<a href="#SEC165_13" class="summary-letter"><b>N</b></a>
<a href="#SEC165_14" class="summary-letter"><b>O</b></a>
<a href="#SEC165_15" class="summary-letter"><b>P</b></a>
<a href="#SEC165_16" class="summary-letter"><b>R</b></a>
<a href="#SEC165_17" class="summary-letter"><b>S</b></a>
<a href="#SEC165_18" class="summary-letter"><b>T</b></a>
<a href="#SEC165_19" class="summary-letter"><b>U</b></a>
<a href="#SEC165_20" class="summary-letter"><b>V</b></a>
<a href="#SEC165_21" class="summary-letter"><b>W</b></a>
<a href="#SEC165_22" class="summary-letter"><b>Y</b></a>
</td></tr></table>
<table border="0" class="index-sn">
<tr><td></td><th align="left">Index Entry</th><th align="left"> Section</th></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC165_0">\</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX314">\=/2</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC165_1">A</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1962">abolish_table/1</a></td><td valign="top"><a href="#SEC135">16. Tabling</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX948">add_to_array_element/4</a></td><td valign="top"><a href="#SEC58">6.16 Arrays</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX878">alarm/3</a></td><td valign="top"><a href="#SEC54">6.12 Access to Operating System Functionality</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX827">all/3</a></td><td valign="top"><a href="#SEC52">6.10 Collecting Solutions to a Goal</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX632">always_prompt_user/0</a></td><td valign="top"><a href="#SEC44">6.6.7 Controlling Input/Output</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1761">append/3</a></td><td valign="top"><a href="#SEC83">8. SWI-Prolog Emulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX918">array/2</a></td><td valign="top"><a href="#SEC58">6.16 Arrays</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX942">array_element/3</a></td><td valign="top"><a href="#SEC58">6.16 Arrays</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX689">assert_static/1</a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX692">asserta_static/1</a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX695">assertz_static/1</a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX278">atom_concat/3</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX275">atom_length/2</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX269">atomic_concat/2</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1809">attr_unify_hook/2</a></td><td valign="top"><a href="#SEC86">8.3 hProlog and SWI-Prolog Attributed Variables</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1866">attvar/1</a></td><td valign="top"><a href="#SEC96">10.3 Attributed Unification</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1143">avl_insert/4</a></td><td valign="top"><a href="#SEC64">7.3 AVL Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1146">avl_lookup/3</a></td><td valign="top"><a href="#SEC64">7.3 AVL Trees</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC165_2">B</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1824">b_getval/2</a></td><td valign="top"><a href="#SEC88">8.4 SWI Global variables</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1821">b_setval/2</a></td><td valign="top"><a href="#SEC88">8.4 SWI Global variables</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1764">between/3</a></td><td valign="top"><a href="#SEC83">8. SWI-Prolog Emulation</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC165_3">C</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX912">call_count_data/0</a></td><td valign="top"><a href="#SEC57">6.15 Counting Calls</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX909">call_count_data/3</a></td><td valign="top"><a href="#SEC57">6.15 Counting Calls</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX915">call_count_data/3</a></td><td valign="top"><a href="#SEC57">6.15 Counting Calls</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX171">call_with_args/n</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX192">catch/3</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX854">cd/1</a></td><td valign="top"><a href="#SEC54">6.12 Access to Operating System Functionality</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1767">chdir/1</a></td><td valign="top"><a href="#SEC83">8. SWI-Prolog Emulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1062">checklist/2</a></td><td valign="top"><a href="#SEC62">7.1 Apply Macros</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1083">checknodes/3</a></td><td valign="top"><a href="#SEC62">7.1 Apply Macros</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX936">close_static_array/1</a></td><td valign="top"><a href="#SEC58">6.16 Arrays</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX27">compile/1 (directive)</a></td><td valign="top"><a href="#SEC23">4.1 Program loading and updating</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX39">compile_expressions/0</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1770">concat_atom/2</a></td><td valign="top"><a href="#SEC83">8. SWI-Prolog Emulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1773">concat_atom/3</a></td><td valign="top"><a href="#SEC83">8. SWI-Prolog Emulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX9">consult/1</a></td><td valign="top"><a href="#SEC23">4.1 Program loading and updating</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1068">convlist/3</a></td><td valign="top"><a href="#SEC62">7.1 Apply Macros</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1818">copy_term_nat/2</a></td><td valign="top"><a href="#SEC87">8.3.1 Special Purpose SWI Predicates for Attributes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1953">current_mutex/3</a></td><td valign="top"><a href="#SEC133">14.4 Thread Synchronisation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1020">current_prolog_flag/2</a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1899">current_thread/2</a></td><td valign="top"><a href="#SEC128">14.2 Monitoring Threads</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC165_4">D</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1806">del_attr/2</a></td><td valign="top"><a href="#SEC86">8.3 hProlog and SWI-Prolog Attributed Variables</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1701">dgraph_add_edges/3</a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1695">dgraph_add_vertices/3</a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1713">dgraph_complement/2</a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1719">dgraph_compose/3</a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1704">dgraph_del_edges/3</a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1692">dgraph_edges/2</a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1707">dgraph_neighbors/3</a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1710">dgraph_neighbours/3</a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1686">dgraph_new/1</a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1725">dgraph_symmetric_closure/2</a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1728">dgraph_top_sort/2</a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1722">dgraph_transitive_closure/2</a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1716">dgraph_transpose/2</a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1689">dgraph_vertices/2</a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX42">do_not_compile_expressions/0</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX671">dynamic_predicate/2</a></td><td valign="top"><a href="#SEC46">6.7 Using the Clausal Data Base</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC165_5">E</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX785">eraseall/1</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX618">exists/1</a></td><td valign="top"><a href="#SEC44">6.6.7 Controlling Input/Output</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX54">expand_exprs/2</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC165_6">F</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1797">forall/2</a></td><td valign="top"><a href="#SEC85">8.2 Forall</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC165_7">G</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1803">get_attr/3</a></td><td valign="top"><a href="#SEC86">8.3 hProlog and SWI-Prolog Attributed Variables</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1812">get_attrs/2</a></td><td valign="top"><a href="#SEC87">8.3.1 Special Purpose SWI Predicates for Attributes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX504">get_byte/1</a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX573">get_byte/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX507">get_char/1</a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX576">get_char/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX510">get_code/1</a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX579">get_code/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX797">get_value/2</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX860">getcwd/1</a></td><td valign="top"><a href="#SEC54">6.12 Access to Operating System Functionality</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX842">goal_expansion/3</a></td><td valign="top"><a href="#SEC53">6.11 Grammar Rules</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX209">grow_heap/1</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX212">grow_stack/1</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC165_8">H</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX45">hide/1</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX51">hide_predicate/1</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC165_9">I</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX81">initialization/1 (directive)</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1365">is_rbtree/1</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1956">is_tabled/1</a></td><td valign="top"><a href="#SEC135">16. Tabling</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1959">is_tabled/1</a></td><td valign="top"><a href="#SEC135">16. Tabling</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC165_10">K</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX794">key_statistics/3</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX791">key_statistics/4</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC165_11">L</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX84">library_directory/1</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX90">library_directory/1</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1188">list_concat/2</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1425">list_to_rbtree/2</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1428">list_to_rbtree/2</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC165_12">M</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1074">mapargs/3</a></td><td valign="top"><a href="#SEC62">7.1 Apply Macros</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1788">maplist/2</a></td><td valign="top"><a href="#SEC84">8.1 Invoking Predicates on all Members of a List</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1059">maplist/3</a></td><td valign="top"><a href="#SEC62">7.1 Apply Macros</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1791">maplist/3</a></td><td valign="top"><a href="#SEC84">8.1 Invoking Predicates on all Members of a List</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1794">maplist/4</a></td><td valign="top"><a href="#SEC84">8.1 Invoking Predicates on all Members of a List</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1080">mapnodes/3</a></td><td valign="top"><a href="#SEC62">7.1 Apply Macros</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1497">mktime/2</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1932">mutex_create/1</a></td><td valign="top"><a href="#SEC133">14.4 Thread Synchronisation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1935">mutex_destroy/1</a></td><td valign="top"><a href="#SEC133">14.4 Thread Synchronisation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1941">mutex_lock/1</a></td><td valign="top"><a href="#SEC133">14.4 Thread Synchronisation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1905">mutex_statistics/0</a></td><td valign="top"><a href="#SEC128">14.2 Monitoring Threads</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1944">mutex_trylock/1</a></td><td valign="top"><a href="#SEC133">14.4 Thread Synchronisation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1947">mutex_unlock/1</a></td><td valign="top"><a href="#SEC133">14.4 Thread Synchronisation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1950">mutex_unlock_all/0</a></td><td valign="top"><a href="#SEC133">14.4 Thread Synchronisation</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC165_13">N</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1833">nb_current/2</a></td><td valign="top"><a href="#SEC88">8.4 SWI Global variables</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1836">nb_delete/1</a></td><td valign="top"><a href="#SEC88">8.4 SWI Global variables</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1830">nb_getval/2</a></td><td valign="top"><a href="#SEC88">8.4 SWI Global variables</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1827">nb_setval/2</a></td><td valign="top"><a href="#SEC88">8.4 SWI Global variables</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX36">no_source/0</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX156">not/1</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1776">nth1/3</a></td><td valign="top"><a href="#SEC83">8. SWI-Prolog Emulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX287">number_atom/2</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC165_14">O</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX881">on_signal/3</a></td><td valign="top"><a href="#SEC54">6.12 Access to Operating System Functionality</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX177">once/1</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC165_15">P</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX57">path/1</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX60">path/1</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX63">path/1</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX513">peek_byte/1</a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX582">peek_byte/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX585">peek_char/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX519">peek_code/1</a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX588">peek_code/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX903">profile_data/3</a></td><td valign="top"><a href="#SEC56">6.14 Profiling Prolog Programs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX906">profiled_reset/0</a></td><td valign="top"><a href="#SEC56">6.14 Profiling Prolog Programs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX96">public/1 (directive)</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1800">put_attr/3</a></td><td valign="top"><a href="#SEC86">8.3 hProlog and SWI-Prolog Attributed Variables</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1815">put_attrs/2</a></td><td valign="top"><a href="#SEC87">8.3.1 Special Purpose SWI Predicates for Attributes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX489">put_byte/1</a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX558">put_byte/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX492">put_char/1</a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX561">put_char/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX495">put_code/1</a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX564">put_code/2</a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX863">putenv/2</a></td><td valign="top"><a href="#SEC54">6.12 Access to Operating System Functionality</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC165_16">R</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1296">rannum/1</a></td><td valign="top"><a href="#SEC68">7.7 Pseudo Random Number Integer Generator</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1299">ranstart/0</a></td><td valign="top"><a href="#SEC68">7.7 Pseudo Random Number Integer Generator</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1302">ranstart/1</a></td><td valign="top"><a href="#SEC68">7.7 Pseudo Random Number Integer Generator</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1305">ranunif/2</a></td><td valign="top"><a href="#SEC68">7.7 Pseudo Random Number Integer Generator</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1392">rb_apply/4</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1410">rb_clone/3</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1386">rb_del_max/4</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1383">rb_del_min/4</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1377">rb_delete/3</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1380">rb_delete/4</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1362">rb_empty/1</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1368">rb_insert/4</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1401">rb_keys/2</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1371">rb_lookup/3</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1374">rb_lookupall/3</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1404">rb_map/3</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1416">rb_max/3</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1413">rb_min/3</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1359">rb_new/1</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1419">rb_next/4</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1407">rb_partial_map/4</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1422">rb_previous/4</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1398">rb_size/2</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1389">rb_update/4</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1395">rb_visit/2</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX12">reconsult/1</a></td><td valign="top"><a href="#SEC23">4.1 Program loading and updating</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX767">recorda/3</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX758">recorda_at/3</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX806">recordaifnot/3</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX761">recordz_at/3</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX803">recordzifnot/3</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1431">regexp/3</a></td><td valign="top"><a href="#SEC72">7.11 Regular Expressions</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1434">regexp/4</a></td><td valign="top"><a href="#SEC72">7.11 Regular Expressions</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX66">remove_from_path/1</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX866">rename/2</a></td><td valign="top"><a href="#SEC54">6.12 Access to Operating System Functionality</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1977">reset_op_counters/0</a></td><td valign="top"><a href="#SEC137">18. Profiling the Abstract Machine</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX939">resize_static_array/3</a></td><td valign="top"><a href="#SEC58">6.16 Arrays</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC165_17">S</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX99">save/1</a></td><td valign="top"><a href="#SEC25">4.3 Saving and Loading Prolog States</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX102">save/2</a></td><td valign="top"><a href="#SEC25">4.3 Saving and Loading Prolog States</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1065">selectlist/3</a></td><td valign="top"><a href="#SEC62">7.1 Apply Macros</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1026">set_prolog_flag/2</a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX800">set_value/2</a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX884">setarg/3n</a></td><td valign="top"><a href="#SEC55">6.13 Term Modification</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1779">setenv/2</a></td><td valign="top"><a href="#SEC83">8. SWI-Prolog Emulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX869">sh/0</a></td><td valign="top"><a href="#SEC54">6.12 Access to Operating System Functionality</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1980">show_op_counters/1</a></td><td valign="top"><a href="#SEC137">18. Profiling the Abstract Machine</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1983">show_ops_by_group/1</a></td><td valign="top"><a href="#SEC137">18. Profiling the Abstract Machine</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1965">show_table/1</a></td><td valign="top"><a href="#SEC135">16. Tabling</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX33">source/0</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX30">source_mode/2</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1437">splay_access/5</a></td><td valign="top"><a href="#SEC73">7.12 Splay Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1440">splay_delete/4</a></td><td valign="top"><a href="#SEC73">7.12 Splay Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1443">splay_init/3</a></td><td valign="top"><a href="#SEC73">7.12 Splay Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1446">splay_insert/4</a></td><td valign="top"><a href="#SEC73">7.12 Splay Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1449">splay_join/3</a></td><td valign="top"><a href="#SEC73">7.12 Splay Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1452">splay_split/5</a></td><td valign="top"><a href="#SEC73">7.12 Splay Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2007">spy_write/2</a></td><td valign="top"><a href="#SEC139">19.1 Debugging Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX374">srandom/1</a></td><td valign="top"><a href="#SEC36">6.5 Arithmetic</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1971">start_low_level_trace/0</a></td><td valign="top"><a href="#SEC136">17. Tracing at Low Level</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1974">start_low_level_trace/0</a></td><td valign="top"><a href="#SEC136">17. Tracing at Low Level</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX921">static_array/3</a></td><td valign="top"><a href="#SEC58">6.16 Arrays</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX933">static_array/3</a></td><td valign="top"><a href="#SEC58">6.16 Arrays</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX924">static_array_location/4</a></td><td valign="top"><a href="#SEC58">6.16 Arrays</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX927">static_array_properties/3</a></td><td valign="top"><a href="#SEC58">6.16 Arrays</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX930">static_array_to_term/3</a></td><td valign="top"><a href="#SEC58">6.16 Arrays</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX425">stream_property/2</a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX69">style_check/1</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX72">style_check/1</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX293">sub_atom/5</a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1077">sumargs/4</a></td><td valign="top"><a href="#SEC62">7.1 Apply Macros</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1071">sumlist/4</a></td><td valign="top"><a href="#SEC62">7.1 Apply Macros</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1086">sumnodes/4</a></td><td valign="top"><a href="#SEC62">7.1 Apply Macros</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX872">system/1</a></td><td valign="top"><a href="#SEC54">6.12 Access to Operating System Functionality</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC165_18">T</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1968">table_statistics/1</a></td><td valign="top"><a href="#SEC135">16. Tabling</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1782">term_to_atom/2</a></td><td valign="top"><a href="#SEC83">8. SWI-Prolog Emulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1893">thread_at_exit/1</a></td><td valign="top"><a href="#SEC127">14.1 Creating and Destroying Prolog Threads</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1878">thread_create/3</a></td><td valign="top"><a href="#SEC127">14.1 Creating and Destroying Prolog Threads</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1887">thread_detach/1</a></td><td valign="top"><a href="#SEC127">14.1 Creating and Destroying Prolog Threads</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1890">thread_exit/1</a></td><td valign="top"><a href="#SEC127">14.1 Creating and Destroying Prolog Threads</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1911">thread_get_message/1</a></td><td valign="top"><a href="#SEC130">14.3.1 Message Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1923">thread_get_message/2</a></td><td valign="top"><a href="#SEC130">14.3.1 Message Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1884">thread_join/2</a></td><td valign="top"><a href="#SEC127">14.1 Creating and Destroying Prolog Threads</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1929">thread_local/1 (directive)</a></td><td valign="top"><a href="#SEC132">14.3.3 Threads and Dynamic Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1917">thread_message_queue_create/1</a></td><td valign="top"><a href="#SEC130">14.3.1 Message Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1920">thread_message_queue_destroy/1</a></td><td valign="top"><a href="#SEC130">14.3.1 Message Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1914">thread_peek_message/1</a></td><td valign="top"><a href="#SEC130">14.3.1 Message Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1881">thread_self/1</a></td><td valign="top"><a href="#SEC127">14.1 Creating and Destroying Prolog Threads</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1908">thread_send_message/2</a></td><td valign="top"><a href="#SEC130">14.3.1 Message Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1896">thread_setconcurrency/2</a></td><td valign="top"><a href="#SEC127">14.1 Creating and Destroying Prolog Threads</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1926">thread_signal/2</a></td><td valign="top"><a href="#SEC131">14.3.2 Signalling Threads</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1902">thread_statistics/3</a></td><td valign="top"><a href="#SEC128">14.2 Monitoring Threads</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX195">throw/1</a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC165_19">U</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1746">undgraph_add_edges/3</a></td><td valign="top"><a href="#SEC82">7.21 Undirected Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1740">undgraph_add_vertices/3</a></td><td valign="top"><a href="#SEC82">7.21 Undirected Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1758">undgraph_complement/2</a></td><td valign="top"><a href="#SEC82">7.21 Undirected Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1749">undgraph_del_edges/3</a></td><td valign="top"><a href="#SEC82">7.21 Undirected Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1737">undgraph_edges/2</a></td><td valign="top"><a href="#SEC82">7.21 Undirected Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1752">undgraph_neighbors/3</a></td><td valign="top"><a href="#SEC82">7.21 Undirected Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1755">undgraph_neighbours/3</a></td><td valign="top"><a href="#SEC82">7.21 Undirected Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1731">undgraph_new/1</a></td><td valign="top"><a href="#SEC82">7.21 Undirected Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1734">undgraph_vertices/2</a></td><td valign="top"><a href="#SEC82">7.21 Undirected Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX48">unhide/1</a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX875">unix/1</a></td><td valign="top"><a href="#SEC54">6.12 Access to Operating System Functionality</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX945">update_array/3</a></td><td valign="top"><a href="#SEC58">6.16 Arrays</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC165_20">V</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1599">variable_in_term/2</a></td><td valign="top"><a href="#SEC76">7.15 Utilities On Terms</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC165_21">W</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1938">with_mutex/2</a></td><td valign="top"><a href="#SEC133">14.4 Thread Synchronisation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1785">working_directory/2</a></td><td valign="top"><a href="#SEC83">8. SWI-Prolog Emulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX630">write_depth/2</a></td><td valign="top"><a href="#SEC44">6.6.7 Controlling Input/Output</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX627">write_depth/3</a></td><td valign="top"><a href="#SEC44">6.6.7 Controlling Input/Output</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC165_22">Y</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX973">yap_flag/2</a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
</table>
<table><tr><th valign="top">Jump to: </th><td><a href="#SEC165_0" class="summary-letter"><b>\</b></a>
<br>
<a href="#SEC165_1" class="summary-letter"><b>A</b></a>
<a href="#SEC165_2" class="summary-letter"><b>B</b></a>
<a href="#SEC165_3" class="summary-letter"><b>C</b></a>
<a href="#SEC165_4" class="summary-letter"><b>D</b></a>
<a href="#SEC165_5" class="summary-letter"><b>E</b></a>
<a href="#SEC165_6" class="summary-letter"><b>F</b></a>
<a href="#SEC165_7" class="summary-letter"><b>G</b></a>
<a href="#SEC165_8" class="summary-letter"><b>H</b></a>
<a href="#SEC165_9" class="summary-letter"><b>I</b></a>
<a href="#SEC165_10" class="summary-letter"><b>K</b></a>
<a href="#SEC165_11" class="summary-letter"><b>L</b></a>
<a href="#SEC165_12" class="summary-letter"><b>M</b></a>
<a href="#SEC165_13" class="summary-letter"><b>N</b></a>
<a href="#SEC165_14" class="summary-letter"><b>O</b></a>
<a href="#SEC165_15" class="summary-letter"><b>P</b></a>
<a href="#SEC165_16" class="summary-letter"><b>R</b></a>
<a href="#SEC165_17" class="summary-letter"><b>S</b></a>
<a href="#SEC165_18" class="summary-letter"><b>T</b></a>
<a href="#SEC165_19" class="summary-letter"><b>U</b></a>
<a href="#SEC165_20" class="summary-letter"><b>V</b></a>
<a href="#SEC165_21" class="summary-letter"><b>W</b></a>
<a href="#SEC165_22" class="summary-letter"><b>Y</b></a>
</td></tr></table>
<hr size="6">
<a name="ISO-Prolog"></a>
<a name="SEC166"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC165" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC167" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC154" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC167" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 23.3 Compatibility with the ISO Prolog standard </h2>
<p>The Prolog standard was developed by ISO/IEC JTC1/SC22/WG17, the
international standardization working group for the programming language
Prolog. The book "Prolog: The Standard" by Deransart, Ed-Dbali and
Cervoni gives a complete description of this standard. Development in
YAP from YAP4.1.6 onwards have striven at making YAP
compatible with ISO Prolog. As such:
</p>
<ul>
<li> YAP now supports all of the built-ins required by the
ISO-standard, and,
</li><li> Error-handling is as required by the standard.
</li></ul>
<p>YAP by default is not fully ISO standard compliant. You can set the
<code>language</code> flag to <code>iso</code> to obtain very good
compatibility. Setting this flag changes the following:
</p>
<ul>
<li> By default, YAP uses "immediate update semantics" for its
database, and not "logical update semantics", as per the standard,
(see section <a href="#SEC161">Compatibility with the Quintus and SICStus Prolog systems</a>). This affects <code>assert/1</code>,
<code>retract/1</code>, and friends.
<p>Calling <code>set_prolog_flag(update_semantics,logical)</code> will switch
YAP to use logical update semantics.
</p>
</li><li> By default, YAP implements the <code>atom_chars/2</code>
(see section <a href="#SEC34">Predicates on terms</a>), and <code>number_chars/2</code>, (see section <a href="#SEC34">Predicates on terms</a>), built-ins as per the original Quintus Prolog definition, and
not as per the ISO definition.
<p>Calling <code>set_prolog_flag(to_chars_mode,iso)</code> will switch
YAP to use the ISO definition for
<code>atom_chars/2</code> and <code>number_chars/2</code>.
</p>
</li><li> By default, YAP fails on undefined predicates. To follow the ISO
Prolog standard use:
<table><tr><td> </td><td><pre class="example">:- set_prolog_flag(unknown,error).
</pre></td></tr></table>
</li><li> By default, YAP allows executable goals in directives. In ISO mode
most directives can only be called from top level (the exceptions are
<code>set_prolog_flag/2</code> and <code>op/3</code>).
</li><li> Error checking for meta-calls under ISO Prolog mode is stricter
than by default.
</li><li> The <code>strict_iso</code> flag automatically enables the ISO Prolog
standard. This feature should disable all features not present in the
standard.
</li></ul>
<p>The following incompatibilities between YAP and the ISO standard are
known to still exist:
</p>
<ul>
<li> Currently, YAP does not handle overflow errors in integer
operations, and handles floating-point errors only in some
architectures. Otherwise, YAP follows IEEE arithmetic.
</li></ul>
<p>Please inform the authors on other incompatibilities that may still
exist.
</p>
<hr size="6">
<a name="Operators"></a>
<a name="SEC167"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC166" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC168" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC154" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC168" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="appendix"> A. Summary of Yap Predefined Operators </h1>
<p> The Prolog syntax caters for operators of three main kinds:
</p>
<ul>
<li>
prefix;
</li><li>
infix;
</li><li>
postfix.
</li></ul>
<p> Each operator has precedence in the range 1 to 1200, and this
precedence is used to disambiguate expressions where the structure of the
term denoted is not made explicit using brackets. The operator of higher
precedence is the main functor.
</p>
<p> If there are two operators with the highest precedence, the ambiguity
is solved analyzing the types of the operators. The possible infix types are:
xfx, xfy, yfx.
</p>
<p> With an operator of type xfx both sub-expressions must have lower
precedence than the operator itself, unless they are bracketed (which
assigns to them zero precedence). With an operator type xfy only the
left-hand sub-expression must have lower precedence. The opposite happens
for yfx type.
</p>
<p> A prefix operator can be of type fx or fy, and a postfix operator, xf, yf.
The meaning of the notation is analogous to the above.
</p><table><tr><td> </td><td><pre class="example">a + b * c
</pre></td></tr></table>
<p>means
</p><table><tr><td> </td><td><pre class="example">a + (b * c)
</pre></td></tr></table>
<p>as + and * have the following types and precedences:
</p><table><tr><td> </td><td><pre class="example">:-op(500,yfx,'+').
:-op(400,yfx,'*').
</pre></td></tr></table>
<p>Now defining
</p><table><tr><td> </td><td><pre class="example">:-op(700,xfy,'++').
:-op(700,xfx,'=:=').
a ++ b =:= c
</pre></td></tr></table><p>means
</p><table><tr><td> </td><td><pre class="example">a ++ (b =:= c)
</pre></td></tr></table>
<p>The following is the list of the declarations of the predefined operators:
</p>
<table><tr><td> </td><td><pre class="example">:-op(1200,fx,['?-', ':-']).
:-op(1200,xfx,[':-','-->']).
:-op(1150,fx,[block,dynamic,mode,public,multifile,meta_predicate,
sequential,table,initialization]).
:-op(1100,xfy,[';','|']).
:-op(1050,xfy,->).
:-op(1000,xfy,',').
:-op(999,xfy,'.').
:-op(900,fy,['\+', not]).
:-op(900,fx,[nospy, spy]).
:-op(700,xfx,[@>=,@=<,@<,@>,<,=,>,=:=,=\=,\==,>=,=<,==,\=,=..,is]).
:-op(500,yfx,['\/','/\','+','-']).
:-op(500,fx,['+','-']).
:-op(400,yfx,['<<','>>','//','*','/']).
:-op(300,xfx,mod).
:-op(200,xfy,['^','**']).
:-op(50,xfx,same).
</pre></td></tr></table>
<hr size="6">
<a name="Predicate-Index"></a>
<a name="SEC168"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC167" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC169" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC167" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="#SEC169" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="unnumbered"> Predicate Index </h1>
<table><tr><th valign="top">Jump to: </th><td><a href="#SEC168_0" class="summary-letter"><b>!</b></a>
<a href="#SEC168_1" class="summary-letter"><b>,</b></a>
<a href="#SEC168_2" class="summary-letter"><b>-</b></a>
<a href="#SEC168_3" class="summary-letter"><b>;</b></a>
<a href="#SEC168_4" class="summary-letter"><b><</b></a>
<a href="#SEC168_5" class="summary-letter"><b>=</b></a>
<a href="#SEC168_6" class="summary-letter"><b>></b></a>
<a href="#SEC168_7" class="summary-letter"><b>@</b></a>
<a href="#SEC168_8" class="summary-letter"><b>[</b></a>
<a href="#SEC168_9" class="summary-letter"><b>\</b></a>
<br>
<a href="#SEC168_10" class="summary-letter"><b>A</b></a>
<a href="#SEC168_11" class="summary-letter"><b>B</b></a>
<a href="#SEC168_12" class="summary-letter"><b>C</b></a>
<a href="#SEC168_13" class="summary-letter"><b>D</b></a>
<a href="#SEC168_14" class="summary-letter"><b>E</b></a>
<a href="#SEC168_15" class="summary-letter"><b>F</b></a>
<a href="#SEC168_16" class="summary-letter"><b>G</b></a>
<a href="#SEC168_17" class="summary-letter"><b>H</b></a>
<a href="#SEC168_18" class="summary-letter"><b>I</b></a>
<a href="#SEC168_19" class="summary-letter"><b>J</b></a>
<a href="#SEC168_20" class="summary-letter"><b>K</b></a>
<a href="#SEC168_21" class="summary-letter"><b>L</b></a>
<a href="#SEC168_22" class="summary-letter"><b>M</b></a>
<a href="#SEC168_23" class="summary-letter"><b>N</b></a>
<a href="#SEC168_24" class="summary-letter"><b>O</b></a>
<a href="#SEC168_25" class="summary-letter"><b>P</b></a>
<a href="#SEC168_26" class="summary-letter"><b>Q</b></a>
<a href="#SEC168_27" class="summary-letter"><b>R</b></a>
<a href="#SEC168_28" class="summary-letter"><b>S</b></a>
<a href="#SEC168_29" class="summary-letter"><b>T</b></a>
<a href="#SEC168_30" class="summary-letter"><b>U</b></a>
<a href="#SEC168_31" class="summary-letter"><b>V</b></a>
<a href="#SEC168_32" class="summary-letter"><b>W</b></a>
<a href="#SEC168_33" class="summary-letter"><b>Y</b></a>
</td></tr></table>
<table border="0" class="index-fn">
<tr><td></td><th align="left">Index Entry</th><th align="left"> Section</th></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC168_0">!</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX149"><code>!/0</code></a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC168_1">,</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX134"><code>,/2</code></a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC168_2">-</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX158"><code>->/2</code></a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC168_3">;</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX137"><code>;/2</code></a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC168_4"><</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX355"><code></2</code></a></td><td valign="top"><a href="#SEC36">6.5 Arithmetic</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC168_5">=</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX307"><code>=../2</code></a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX310"><code>=/2</code></a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX367"><code>=:=/2</code></a></td><td valign="top"><a href="#SEC36">6.5 Arithmetic</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX358"><code>=</2</code></a></td><td valign="top"><a href="#SEC36">6.5 Arithmetic</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX325"><code>==/2</code></a></td><td valign="top"><a href="#SEC35">6.4 Comparing Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX370"><code>=\=/2</code></a></td><td valign="top"><a href="#SEC36">6.5 Arithmetic</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC168_6">></a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX361"><code>>/2</code></a></td><td valign="top"><a href="#SEC36">6.5 Arithmetic</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX364"><code>>=/2</code></a></td><td valign="top"><a href="#SEC36">6.5 Arithmetic</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC168_7">@</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX331"><code>@</2</code></a></td><td valign="top"><a href="#SEC35">6.4 Comparing Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX334"><code>@=</2</code></a></td><td valign="top"><a href="#SEC35">6.4 Comparing Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX337"><code>@>/2</code></a></td><td valign="top"><a href="#SEC35">6.4 Comparing Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX340"><code>@>=/2</code></a></td><td valign="top"><a href="#SEC35">6.4 Comparing Terms</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC168_8">[</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX17"><code>[-]/1</code></a></td><td valign="top"><a href="#SEC23">4.1 Program loading and updating</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX14"><code>[]/1</code></a></td><td valign="top"><a href="#SEC23">4.1 Program loading and updating</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC168_9">\</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX152"><code>\+/1</code></a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX313"><code>\=/2</code></a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX328"><code>\==/2</code></a></td><td valign="top"><a href="#SEC35">6.4 Comparing Terms</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC168_10">A</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX682"><code>abolish/1</code></a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX685"><code>abolish/2</code></a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1961"><code>abolish_table/1</code></a></td><td valign="top"><a href="#SEC135">16. Tabling</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX179"><code>abort/0</code></a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX388"><code>absolute_file_name/2</code></a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1652"><code>add_edges/3</code></a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX947"><code>add_to_array_element/4</code></a></td><td valign="top"><a href="#SEC58">6.16 Arrays</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1148"><code>add_to_heap/4</code></a></td><td valign="top"><a href="#SEC65">7.4 Heaps</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX59"><code>add_to_path/1</code></a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX62"><code>add_to_path/2</code></a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1646"><code>add_vertices/3</code></a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX877"><code>alarm/3</code></a></td><td valign="top"><a href="#SEC54">6.12 Access to Operating System Functionality</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX826"><code>all/3</code></a></td><td valign="top"><a href="#SEC52">6.10 Collecting Solutions to a Goal</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX631"><code>always_prompt_user/0</code></a></td><td valign="top"><a href="#SEC44">6.6.7 Controlling Input/Output</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1172"><code>append/3</code></a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1760"><code>append/3</code></a></td><td valign="top"><a href="#SEC83">8. SWI-Prolog Emulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX301"><code>arg/3</code></a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX975"><code>argv (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX917"><code>array/2</code></a></td><td valign="top"><a href="#SEC58">6.16 Arrays</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX941"><code>array_element/3</code></a></td><td valign="top"><a href="#SEC58">6.16 Arrays</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX673"><code>assert/1</code></a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX739"><code>assert/2</code></a></td><td valign="top"><a href="#SEC49">6.7.3 Using Data Base References</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX688"><code>assert_static/1</code></a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX676"><code>asserta/1</code></a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX742"><code>asserta/2</code></a></td><td valign="top"><a href="#SEC49">6.7.3 Using Data Base References</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX691"><code>asserta_static/1</code></a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX679"><code>assertz/1</code></a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX745"><code>assertz/2</code></a></td><td valign="top"><a href="#SEC49">6.7.3 Using Data Base References</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX694"><code>assertz_static/1</code></a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1088"><code>assoc_to_list/2</code></a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX415"><code>at_end_of_stream/0</code></a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX418"><code>at_end_of_stream/1</code></a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX223"><code>atom/1</code></a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX259"><code>atom_chars/2</code></a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX262"><code>atom_codes/2</code></a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX265"><code>atom_concat/2</code></a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX271"><code>atom_concat/3</code></a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX277"><code>atom_concat/3</code></a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX274"><code>atom_length/2</code></a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1466"><code>atom_to_chars/2</code></a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1469"><code>atom_to_chars/3</code></a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX226"><code>atomic/1</code></a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX268"><code>atomic_concat/2</code></a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1808"><code>attr_unify_hook/2</code></a></td><td valign="top"><a href="#SEC86">8.3 hProlog and SWI-Prolog Attributed Variables</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1855"><code>attribute/1 (declaration)</code></a></td><td valign="top"><a href="#SEC94">10.1 Attribute Declarations</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1868"><code>attribute_goal/2</code></a></td><td valign="top"><a href="#SEC97">10.4 Displaying Attributes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1865"><code>attvar/1</code></a></td><td valign="top"><a href="#SEC96">10.3 Attributed Unification</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1142"><code>avl_insert/4</code></a></td><td valign="top"><a href="#SEC64">7.3 AVL Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1145"><code>avl_lookup/3</code></a></td><td valign="top"><a href="#SEC64">7.3 AVL Trees</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC168_11">B</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1823"><code>b_getval/2</code></a></td><td valign="top"><a href="#SEC88">8.4 SWI Global variables</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1820"><code>b_setval/2</code></a></td><td valign="top"><a href="#SEC88">8.4 SWI Global variables</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX829"><code>bagof/3</code></a></td><td valign="top"><a href="#SEC52">6.10 Collecting Solutions to a Goal</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX814"><code>bb_delete/2</code></a></td><td valign="top"><a href="#SEC51">6.9 The Blackboard</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX811"><code>bb_get/2</code></a></td><td valign="top"><a href="#SEC51">6.9 The Blackboard</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX808"><code>bb_put/2</code></a></td><td valign="top"><a href="#SEC51">6.9 The Blackboard</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX817"><code>bb_update/3</code></a></td><td valign="top"><a href="#SEC51">6.9 The Blackboard</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1763"><code>between/3</code></a></td><td valign="top"><a href="#SEC83">8. SWI-Prolog Emulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX976"><code>bounded (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX182"><code>break/0</code></a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC168_12">C</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX850"><code>C/3</code></a></td><td valign="top"><a href="#SEC53">6.11 Grammar Rules</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX164"><code>call/1</code></a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1604"><code>call_cleanup/1</code></a></td><td valign="top"><a href="#SEC77">7.16 Call Cleanup</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1607"><code>call_cleanup/2</code></a></td><td valign="top"><a href="#SEC77">7.16 Call Cleanup</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX911"><code>call_count_data/0</code></a></td><td valign="top"><a href="#SEC57">6.15 Counting Calls</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX908"><code>call_count_data/3</code></a></td><td valign="top"><a href="#SEC57">6.15 Counting Calls</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX914"><code>call_count_data/3</code></a></td><td valign="top"><a href="#SEC57">6.15 Counting Calls</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX977"><code>call_counting (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1850"><code>call_residue/2</code></a></td><td valign="top"><a href="#SEC92">9.2 Coroutining</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX170"><code>call_with_args/n</code></a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX253"><code>callable/1</code></a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX191"><code>catch/3</code></a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX853"><code>cd/1</code></a></td><td valign="top"><a href="#SEC54">6.12 Access to Operating System Functionality</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX289"><code>char_code/2</code></a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX978"><code>char_conversion (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX455"><code>char_conversion/2</code></a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX979"><code>character_escapes (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1766"><code>chdir/1</code></a></td><td valign="top"><a href="#SEC83">8. SWI-Prolog Emulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1061"><code>checklist/2</code></a></td><td valign="top"><a href="#SEC62">7.1 Apply Macros</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1082"><code>checknodes/3</code></a></td><td valign="top"><a href="#SEC62">7.1 Apply Macros</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX697"><code>clause/2</code></a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX700"><code>clause/3</code></a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1613"><code>cleanup_all/0</code></a></td><td valign="top"><a href="#SEC77">7.16 Call Cleanup</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX382"><code>close/1</code></a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX385"><code>close/2</code></a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX935"><code>close_static_array/1</code></a></td><td valign="top"><a href="#SEC58">6.16 Arrays</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX322"><code>compare/3</code></a></td><td valign="top"><a href="#SEC35">6.4 Comparing Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX20"><code>compile/1</code></a></td><td valign="top"><a href="#SEC23">4.1 Program loading and updating</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX38"><code>compile_expressions/0</code></a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1667"><code>complement/2</code></a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1670"><code>compose/3</code></a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX229"><code>compound/1</code></a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1769"><code>concat_atom/2</code></a></td><td valign="top"><a href="#SEC83">8. SWI-Prolog Emulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1772"><code>concat_atom/3</code></a></td><td valign="top"><a href="#SEC83">8. SWI-Prolog Emulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX8"><code>consult/1</code></a></td><td valign="top"><a href="#SEC23">4.1 Program loading and updating</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1067"><code>convlist/3</code></a></td><td valign="top"><a href="#SEC62">7.1 Apply Macros</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX319"><code>copy_term/2</code></a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1817"><code>copy_term_nat/2</code></a></td><td valign="top"><a href="#SEC87">8.3.1 Special Purpose SWI Predicates for Attributes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX962"><code>cputime (statistics/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX887"><code>create_mutable/2</code></a></td><td valign="top"><a href="#SEC55">6.13 Term Modification</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX724"><code>current_atom/1</code></a></td><td valign="top"><a href="#SEC48">6.7.2 Looking at the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX458"><code>current_char_conversion/2</code></a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX409"><code>current_input/1</code></a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX787"><code>current_key/2</code></a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX950"><code>current_module/1</code></a></td><td valign="top"><a href="#SEC59">6.17 Predicate Information</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX953"><code>current_module/2</code></a></td><td valign="top"><a href="#SEC59">6.17 Predicate Information</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1952"><code>current_mutex/3</code></a></td><td valign="top"><a href="#SEC133">14.4 Thread Synchronisation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1031"><code>current_op/3</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX412"><code>current_output/1</code></a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX727"><code>current_predicate/1</code></a></td><td valign="top"><a href="#SEC48">6.7.2 Looking at the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX730"><code>current_predicate/2</code></a></td><td valign="top"><a href="#SEC48">6.7.2 Looking at the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1019"><code>current_prolog_flag/2</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX391"><code>current_stream/3</code></a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1898"><code>current_thread/2</code></a></td><td valign="top"><a href="#SEC128">14.2 Monitoring Threads</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1574"><code>cyclic_term/1</code></a></td><td valign="top"><a href="#SEC76">7.15 Utilities On Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1577"><code>cyclic_term/1</code></a></td><td valign="top"><a href="#SEC76">7.15 Utilities On Terms</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC168_13">D</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1493"><code>datime/1</code></a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX232"><code>db_reference/1C</code></a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX980"><code>debug (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1985"><code>debug/0</code></a></td><td valign="top"><a href="#SEC139">19.1 Debugging Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1988"><code>debugging/0</code></a></td><td valign="top"><a href="#SEC139">19.1 Debugging Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1091"><code>del_assoc/4</code></a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1805"><code>del_attr/2</code></a></td><td valign="top"><a href="#SEC86">8.3 hProlog and SWI-Prolog Attributed Variables</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1655"><code>del_edges/3</code></a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1094"><code>del_max_assoc/4</code></a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1097"><code>del_min_assoc/4</code></a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1649"><code>del_vertices/3</code></a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1175"><code>delete/3</code></a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1499"><code>delete_file/1</code></a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1502"><code>delete_file/2</code></a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1700"><code>dgraph_add_edges/3</code></a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1694"><code>dgraph_add_vertices/3</code></a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1712"><code>dgraph_complement/2</code></a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1718"><code>dgraph_compose/3</code></a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1703"><code>dgraph_del_edges/3</code></a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1697"><code>dgraph_del_vertices/3</code></a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1691"><code>dgraph_edges/2</code></a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1706"><code>dgraph_neighbors/3</code></a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1709"><code>dgraph_neighbours/3</code></a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1685"><code>dgraph_new/1</code></a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1724"><code>dgraph_symmetric_closure/2</code></a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1727"><code>dgraph_top_sort/2</code></a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1721"><code>dgraph_transitive_closure/2</code></a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1715"><code>dgraph_transpose/2</code></a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1688"><code>dgraph_vertices/2</code></a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1838"><code>dif/2</code></a></td><td valign="top"><a href="#SEC92">9.2 Coroutining</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1052"><code>directory (prolog_load_context/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1505"><code>directory_files/2</code></a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX77"><code>discontiguous/1 (directive)</code></a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX981"><code>discontiguous_warnings (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1003"><code>discontiguous_warnings (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX464"><code>display/1</code></a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX467"><code>display/1</code></a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX539"><code>display/1</code></a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX548"><code>display/2</code></a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX41"><code>do_not_compile_expressions/0</code></a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX982"><code>dollar_as_lower_case (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX983"><code>double_quotes (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX667"><code>dynamic/1</code></a></td><td valign="top"><a href="#SEC46">6.7 Using the Clausal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX670"><code>dynamic_predicate/2</code></a></td><td valign="top"><a href="#SEC46">6.7 Using the Clausal Data Base</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC168_14">E</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1643"><code>edges/2</code></a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1100"><code>empty_assoc/1</code></a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1151"><code>empty_heap/1</code></a></td><td valign="top"><a href="#SEC65">7.4 Heaps</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1328"><code>empty_queue/1</code></a></td><td valign="top"><a href="#SEC69">7.8 Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX23"><code>ensure_loaded/1</code></a></td><td valign="top"><a href="#SEC23">4.1 Program loading and updating</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX856"><code>environ/2</code></a></td><td valign="top"><a href="#SEC54">6.12 Access to Operating System Functionality</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1523"><code>environ/2</code></a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX775"><code>erase/1</code></a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX784"><code>eraseall/1</code></a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX778"><code>erased/1</code></a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1544"><code>exec/3</code></a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX617"><code>exists/1</code></a></td><td valign="top"><a href="#SEC44">6.6.7 Controlling Input/Output</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX53"><code>expand_exprs/2</code></a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX835"><code>expand_term/2</code></a></td><td valign="top"><a href="#SEC53">6.11 Grammar Rules</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC168_15">F</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX143"><code>fail/0</code></a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX146"><code>false/0</code></a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX984"><code>fast (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1053"><code>file (prolog_load_context/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1055"><code>file (prolog_load_context/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1056"><code>file (prolog_load_context/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1057"><code>file (prolog_load_context/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1508"><code>file_exists/1</code></a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1511"><code>file_exists/2</code></a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1514"><code>file_property/2</code></a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX86"><code>file_search_path/2</code></a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX985"><code>fileerrors (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX623"><code>fileerrors/0</code></a></td><td valign="top"><a href="#SEC44">6.6.7 Controlling Input/Output</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX820"><code>findall/3</code></a></td><td valign="top"><a href="#SEC52">6.10 Collecting Solutions to a Goal</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX823"><code>findall/4</code></a></td><td valign="top"><a href="#SEC52">6.10 Collecting Solutions to a Goal</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1178"><code>flatten/2</code></a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX235"><code>float/1</code></a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX986"><code>float_format (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX394"><code>flush_output/0</code></a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX397"><code>flush_output/1</code></a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1796"><code>forall/2</code></a></td><td valign="top"><a href="#SEC85">8.2 Forall</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX479"><code>format/2</code></a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX482"><code>format/3</code></a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1454"><code>format_to_chars/3</code></a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1457"><code>format_to_chars/4</code></a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1601"><code>fragile</code></a></td><td valign="top"><a href="#SEC77">7.16 Call Cleanup</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1841"><code>freeze/2</code></a></td><td valign="top"><a href="#SEC92">9.2 Coroutining</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1844"><code>frozen/2</code></a></td><td valign="top"><a href="#SEC92">9.2 Coroutining</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX304"><code>functor/3</code></a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC168_16">G</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX197"><code>garbage_collect/0</code></a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX200"><code>garbage_collect_atoms/0</code></a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX963"><code>garbage_collection (statistics/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX987"><code>gc (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX203"><code>gc/0</code></a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX988"><code>gc_margin (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX989"><code>gc_trace (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1103"><code>gen_assoc/3</code></a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX497"><code>get/1</code></a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX566"><code>get/2</code></a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX500"><code>get0/1</code></a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX569"><code>get0/2</code></a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1115"><code>get_assoc/3</code></a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1109"><code>get_assoc/5</code></a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1802"><code>get_attr/3</code></a></td><td valign="top"><a href="#SEC86">8.3 hProlog and SWI-Prolog Attributed Variables</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1811"><code>get_attrs/2</code></a></td><td valign="top"><a href="#SEC87">8.3.1 Special Purpose SWI Predicates for Attributes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1856"><code>get_atts/2</code></a></td><td valign="top"><a href="#SEC95">10.2 Attribute Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX503"><code>get_byte/1</code></a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX572"><code>get_byte/2</code></a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX506"><code>get_char/1</code></a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX575"><code>get_char/2</code></a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX509"><code>get_code/1</code></a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX578"><code>get_code/2</code></a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1154"><code>get_from_heap/4</code></a></td><td valign="top"><a href="#SEC65">7.4 Heaps</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1619"><code>get_label/3</code></a></td><td valign="top"><a href="#SEC79">7.18 Updatable Binary Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX890"><code>get_mutable/2</code></a></td><td valign="top"><a href="#SEC55">6.13 Term Modification</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX896"><code>get_mutable/2</code></a></td><td valign="top"><a href="#SEC55">6.13 Term Modification</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1106"><code>get_next_assoc/4</code></a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1112"><code>get_prev_assoc/4</code></a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX796"><code>get_value/2</code></a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX859"><code>getcwd/1</code></a></td><td valign="top"><a href="#SEC54">6.12 Access to Operating System Functionality</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1340"><code>getrand/1</code></a></td><td valign="top"><a href="#SEC70">7.9 Random Number Generator</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX964"><code>global_stack (statistics/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX841"><code>goal_expansion/3</code></a></td><td valign="top"><a href="#SEC53">6.11 Grammar Rules</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX298"><code>ground/1</code></a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX211"><code>grow_stack/1</code></a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC168_17">H</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX185"><code>halt/0</code></a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX188"><code>halt/1</code></a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1322"><code>head_queue/2</code></a></td><td valign="top"><a href="#SEC69">7.8 Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX966"><code>heap (statistics/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1157"><code>heap_size/2</code></a></td><td valign="top"><a href="#SEC65">7.4 Heaps</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1160"><code>heap_to_list/2</code></a></td><td valign="top"><a href="#SEC65">7.4 Heaps</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX44"><code>hide/1</code></a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX50"><code>hide_predicate/1</code></a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1526"><code>host_id/1</code></a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1529"><code>host_name/1</code></a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX990"><code>host_type (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC168_18">I</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX173"><code>if/3</code></a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX26"><code>include/1 (directive)</code></a></td><td valign="top"><a href="#SEC23">4.1 Program loading and updating</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX167"><code>incore/1</code></a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX991"><code>index (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX992"><code>informational_messages (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1037"><code>initialization/0</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX80"><code>initialization/1 (directive)</code></a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX781"><code>instance/2</code></a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX238"><code>integer/1</code></a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX993"><code>integer_rounding_function (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX352"><code>is/2</code></a></td><td valign="top"><a href="#SEC36">6.5 Arithmetic</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1118"><code>is_assoc/1</code></a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1181"><code>is_list/1</code></a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX893"><code>is_mutable/1</code></a></td><td valign="top"><a href="#SEC55">6.13 Term Modification</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1364"><code>is_rbtree/1</code></a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1955"><code>is_tabled/1</code></a></td><td valign="top"><a href="#SEC135">16. Tabling</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1958"><code>is_tabled/1</code></a></td><td valign="top"><a href="#SEC135">16. Tabling</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC168_19">J</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1310"><code>join_queue/3</code></a></td><td valign="top"><a href="#SEC69">7.8 Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1316"><code>jump_queue/3</code></a></td><td valign="top"><a href="#SEC69">7.8 Queues</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC168_20">K</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX793"><code>key_statistics/3</code></a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX790"><code>key_statistics/4</code></a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX346"><code>keysort/2</code></a></td><td valign="top"><a href="#SEC35">6.4 Comparing Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1532"><code>kill/2</code></a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC168_21">L</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX994"><code>language (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1184"><code>last/2</code></a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2003"><code>leash/1</code></a></td><td valign="top"><a href="#SEC139">19.1 Debugging Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX349"><code>length/2</code></a></td><td valign="top"><a href="#SEC35">6.4 Comparing Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1331"><code>length_queue/2</code></a></td><td valign="top"><a href="#SEC69">7.8 Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX83"><code>library_directory/1</code></a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX89"><code>library_directory/1</code></a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1187"><code>list_concat/2</code></a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1313"><code>list_join_queue/3</code></a></td><td valign="top"><a href="#SEC69">7.8 Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1319"><code>list_jump_queue/3</code></a></td><td valign="top"><a href="#SEC69">7.8 Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1121"><code>list_to_assoc/2</code></a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1163"><code>list_to_heap/2</code></a></td><td valign="top"><a href="#SEC65">7.4 Heaps</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1241"><code>list_to_ord_set/2</code></a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1334"><code>list_to_queue/2</code></a></td><td valign="top"><a href="#SEC69">7.8 Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1424"><code>list_to_rbtree/2</code></a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1427"><code>list_to_rbtree/2</code></a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1622"><code>list_to_tree/2</code></a></td><td valign="top"><a href="#SEC79">7.18 Updatable Binary Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX712"><code>listing/0</code></a></td><td valign="top"><a href="#SEC48">6.7.2 Looking at the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX715"><code>listing/1</code></a></td><td valign="top"><a href="#SEC48">6.7.2 Looking at the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX965"><code>local_stack (statistics/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC168_22">M</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1517"><code>make_directory/2</code></a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1307"><code>make_queue/1</code></a></td><td valign="top"><a href="#SEC69">7.8 Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1124"><code>map_assoc/2</code></a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1127"><code>map_assoc/3</code></a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1625"><code>map_tree/3</code></a></td><td valign="top"><a href="#SEC79">7.18 Updatable Binary Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1073"><code>mapargs/3</code></a></td><td valign="top"><a href="#SEC62">7.1 Apply Macros</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1787"><code>maplist/2</code></a></td><td valign="top"><a href="#SEC84">8.1 Invoking Predicates on all Members of a List</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1058"><code>maplist/3</code></a></td><td valign="top"><a href="#SEC62">7.1 Apply Macros</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1790"><code>maplist/3</code></a></td><td valign="top"><a href="#SEC84">8.1 Invoking Predicates on all Members of a List</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1793"><code>maplist/4</code></a></td><td valign="top"><a href="#SEC84">8.1 Invoking Predicates on all Members of a List</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1079"><code>mapnodes/3</code></a></td><td valign="top"><a href="#SEC62">7.1 Apply Macros</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX995"><code>max_arity (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1130"><code>max_assoc/3</code></a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX996"><code>max_integer (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1235"><code>max_list/2</code></a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX997"><code>max_tagged_integer (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX999"><code>max_tagged_integer (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1190"><code>member/2</code></a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1193"><code>memberchk/2</code></a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1244"><code>merge/3</code></a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX131"><code>meta_predicate/1 (directive)</code></a></td><td valign="top"><a href="#SEC30">5.4 Meta-Predicates in Modules</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1133"><code>min_assoc/3</code></a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX998"><code>min_integer (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1238"><code>min_list/2</code></a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1166"><code>min_of_heap/3</code></a></td><td valign="top"><a href="#SEC65">7.4 Heaps</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1169"><code>min_of_heap/5</code></a></td><td valign="top"><a href="#SEC65">7.4 Heaps</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1535"><code>mktemp/2</code></a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1496"><code>mktime/2</code></a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1054"><code>module (prolog_load_context/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX119"><code>module/1</code></a></td><td valign="top"><a href="#SEC28">5.2 Defining a New Module</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX113"><code>module/2 (directive)</code></a></td><td valign="top"><a href="#SEC28">5.2 Defining a New Module</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX116"><code>module/3 (directive)</code></a></td><td valign="top"><a href="#SEC28">5.2 Defining a New Module</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX74"><code>multifile/1 (directive)</code></a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1931"><code>mutex_create/1</code></a></td><td valign="top"><a href="#SEC133">14.4 Thread Synchronisation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1934"><code>mutex_destroy/1</code></a></td><td valign="top"><a href="#SEC133">14.4 Thread Synchronisation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1940"><code>mutex_lock/1</code></a></td><td valign="top"><a href="#SEC133">14.4 Thread Synchronisation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1904"><code>mutex_statistics/0</code></a></td><td valign="top"><a href="#SEC128">14.2 Monitoring Threads</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1943"><code>mutex_trylock/1</code></a></td><td valign="top"><a href="#SEC133">14.4 Thread Synchronisation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1946"><code>mutex_unlock/1</code></a></td><td valign="top"><a href="#SEC133">14.4 Thread Synchronisation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1949"><code>mutex_unlock_all/0</code></a></td><td valign="top"><a href="#SEC133">14.4 Thread Synchronisation</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC168_23">N</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1000"><code>n_of_integer_keys_in_bb (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1001"><code>n_of_integer_keys_in_db (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX256"><code>name/2</code></a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1832"><code>nb_current/2</code></a></td><td valign="top"><a href="#SEC88">8.4 SWI Global variables</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1835"><code>nb_delete/1</code></a></td><td valign="top"><a href="#SEC88">8.4 SWI Global variables</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1829"><code>nb_getval/2</code></a></td><td valign="top"><a href="#SEC88">8.4 SWI Global variables</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1826"><code>nb_setval/2</code></a></td><td valign="top"><a href="#SEC88">8.4 SWI Global variables</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1661"><code>neighbors/3</code></a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1664"><code>neighbours/3</code></a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX527"><code>nl/0</code></a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX596"><code>nl/1</code></a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX35"><code>no_source/0</code></a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX71"><code>no_style_check/1</code></a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1991"><code>nodebug/0</code></a></td><td valign="top"><a href="#SEC139">19.1 Debugging Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX620"><code>nofileerrors/0</code></a></td><td valign="top"><a href="#SEC44">6.6.7 Controlling Input/Output</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX206"><code>nogc/0</code></a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX241"><code>nonvar/1</code></a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1997"><code>nospy/1</code></a></td><td valign="top"><a href="#SEC139">19.1 Debugging Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2000"><code>nospyall/0</code></a></td><td valign="top"><a href="#SEC139">19.1 Debugging Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX155"><code>not/1</code></a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1199"><code>nth/2</code></a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1205"><code>nth/4</code></a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1196"><code>nth0/2</code></a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1202"><code>nth0/4</code></a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1775"><code>nth1/3</code></a></td><td valign="top"><a href="#SEC83">8. SWI-Prolog Emulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX703"><code>nth_clause/3</code></a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX772"><code>nth_recorded/3</code></a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX244"><code>number/1</code></a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX286"><code>number_atom/2</code></a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX280"><code>number_chars/2</code></a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX283"><code>number_codes/2</code></a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1472"><code>number_to_chars/2</code></a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1475"><code>number_to_chars/3</code></a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX295"><code>numbervars/3</code></a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC168_24">O</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1610"><code>on_cleanup/1</code></a></td><td valign="top"><a href="#SEC77">7.16 Call Cleanup</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX880"><code>on_signal/3</code></a></td><td valign="top"><a href="#SEC54">6.12 Access to Operating System Functionality</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX176"><code>once/1</code></a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1028"><code>op/3</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX376"><code>open/3</code></a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX379"><code>open/4</code></a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1481"><code>open_chars_stream/2</code></a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1247"><code>ord_add_element/3</code></a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1250"><code>ord_del_element/3</code></a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1253"><code>ord_disjoint/2</code></a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1259"><code>ord_insert/3</code></a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1262"><code>ord_intersect/2</code></a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1265"><code>ord_intersect/3</code></a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1268"><code>ord_intersect/4</code></a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1136"><code>ord_list_to_assoc/2</code></a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1256"><code>ord_member/2</code></a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1271"><code>ord_seteq/2</code></a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1274"><code>ord_setproduct/3</code></a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1280"><code>ord_subtract/3</code></a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1283"><code>ord_symdiff/3</code></a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1286"><code>ord_union/2</code></a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1289"><code>ord_union/3</code></a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1292"><code>ord_union/4</code></a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1277"><code>ordsubset/2</code></a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC168_25">P</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX56"><code>path/1</code></a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX512"><code>peek_byte/1</code></a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX581"><code>peek_byte/2</code></a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX515"><code>peek_char/1</code></a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX584"><code>peek_char/2</code></a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX518"><code>peek_code/1</code></a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX587"><code>peek_code/2</code></a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1208"><code>permutation/2</code></a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX847"><code>phrase/2</code></a></td><td valign="top"><a href="#SEC53">6.11 Grammar Rules</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX844"><code>phrase/3</code></a></td><td valign="top"><a href="#SEC53">6.11 Grammar Rules</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1538"><code>pid/1</code></a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1550"><code>popen/3</code></a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX718"><code>portray_clause/1</code></a></td><td valign="top"><a href="#SEC48">6.7.2 Looking at the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX721"><code>portray_clause/2</code></a></td><td valign="top"><a href="#SEC48">6.7.2 Looking at the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX736"><code>predicate_property/2</code></a></td><td valign="top"><a href="#SEC48">6.7.2 Looking at the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX247"><code>primitive/1</code></a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX476"><code>print/1</code></a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX551"><code>print/2</code></a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX902"><code>profile_data/3</code></a></td><td valign="top"><a href="#SEC56">6.14 Profiling Prolog Programs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX905"><code>profiled_reset/0</code></a></td><td valign="top"><a href="#SEC56">6.14 Profiling Prolog Programs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1002"><code>profiling (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX967"><code>program (statistics/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1871"><code>project_attributes/2</code></a></td><td valign="top"><a href="#SEC97">10.4 Displaying Attributes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1874"><code>project_attributes/2</code></a></td><td valign="top"><a href="#SEC98">10.5 Projecting Attributes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX92"><code>prolog_file_name/2</code></a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1022"><code>prolog_flag/3</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1040"><code>prolog_initialization/1</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1049"><code>prolog_load_context/2</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1034"><code>prompt/2</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX95"><code>public/1 (directive)</code></a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX485"><code>put/1</code></a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX554"><code>put/2</code></a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1139"><code>put_assoc/4</code></a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1799"><code>put_attr/3</code></a></td><td valign="top"><a href="#SEC86">8.3 hProlog and SWI-Prolog Attributed Variables</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1814"><code>put_attrs/2</code></a></td><td valign="top"><a href="#SEC87">8.3.1 Special Purpose SWI Predicates for Attributes</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1859"><code>put_atts/2</code></a></td><td valign="top"><a href="#SEC95">10.2 Attribute Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX488"><code>put_byte/1</code></a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX557"><code>put_byte/2</code></a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX491"><code>put_char/1</code></a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX560"><code>put_char/2</code></a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX494"><code>put_code/1</code></a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX563"><code>put_code/2</code></a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1628"><code>put_label/4</code></a></td><td valign="top"><a href="#SEC79">7.18 Updatable Binary Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX862"><code>putenv/2</code></a></td><td valign="top"><a href="#SEC54">6.12 Access to Operating System Functionality</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC168_26">Q</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1337"><code>queue_to_list/2</code></a></td><td valign="top"><a href="#SEC69">7.8 Queues</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC168_27">R</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1343"><code>random/1</code></a></td><td valign="top"><a href="#SEC70">7.9 Random Number Generator</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1346"><code>random/3</code></a></td><td valign="top"><a href="#SEC70">7.9 Random Number Generator</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1349"><code>randseq/3</code></a></td><td valign="top"><a href="#SEC70">7.9 Random Number Generator</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1352"><code>randset/3</code></a></td><td valign="top"><a href="#SEC70">7.9 Random Number Generator</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1295"><code>rannum/1</code></a></td><td valign="top"><a href="#SEC68">7.7 Pseudo Random Number Integer Generator</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1298"><code>ranstart/0</code></a></td><td valign="top"><a href="#SEC68">7.7 Pseudo Random Number Integer Generator</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1301"><code>ranstart/1</code></a></td><td valign="top"><a href="#SEC68">7.7 Pseudo Random Number Integer Generator</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1304"><code>ranunif/2</code></a></td><td valign="top"><a href="#SEC68">7.7 Pseudo Random Number Integer Generator</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1391"><code>rb_apply/4</code></a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1409"><code>rb_clone/3</code></a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1385"><code>rb_del_max/4</code></a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1382"><code>rb_del_min/4</code></a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1376"><code>rb_delete/3</code></a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1379"><code>rb_delete/4</code></a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1361"><code>rb_empty/1</code></a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1367"><code>rb_insert/4</code></a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1400"><code>rb_keys/2</code></a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1370"><code>rb_lookup/3</code></a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1373"><code>rb_lookupall/3</code></a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1403"><code>rb_map/3</code></a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1415"><code>rb_max/3</code></a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1412"><code>rb_min/3</code></a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1358"><code>rb_new/1</code></a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1418"><code>rb_next/4</code></a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1406"><code>rb_partial_map/4</code></a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1421"><code>rb_previous/4</code></a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1397"><code>rb_size/2</code></a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1388"><code>rb_update/4</code></a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1394"><code>rb_visit/2</code></a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1682"><code>reachable/3</code></a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX445"><code>read/1</code></a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX530"><code>read/2</code></a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1478"><code>read_from_chars/2</code></a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX448"><code>read_term/2</code></a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX533"><code>read_term/3</code></a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX11"><code>reconsult/1</code></a></td><td valign="top"><a href="#SEC23">4.1 Program loading and updating</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX751"><code>recorda/3</code></a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX766"><code>recorda/3</code></a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX757"><code>recorda_at/3</code></a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX763"><code>recordaifnot/3</code></a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX805"><code>recordaifnot/3</code></a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX769"><code>recorded/3</code></a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX754"><code>recordz/3</code></a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX760"><code>recordz_at/3</code></a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX802"><code>recordzifnot/3</code></a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1430"><code>regexp/3</code></a></td><td valign="top"><a href="#SEC72">7.11 Regular Expressions</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1433"><code>regexp/4</code></a></td><td valign="top"><a href="#SEC72">7.11 Regular Expressions</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1211"><code>remove_duplicates/2</code></a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX65"><code>remove_from_path/1</code></a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX865"><code>rename/2</code></a></td><td valign="top"><a href="#SEC54">6.12 Access to Operating System Functionality</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1520"><code>rename_file/2</code></a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX161"><code>repeat/0</code></a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1976"><code>reset_op_counters/0</code></a></td><td valign="top"><a href="#SEC137">18. Profiling the Abstract Machine</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX938"><code>resize_static_array/3</code></a></td><td valign="top"><a href="#SEC58">6.16 Arrays</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX110"><code>restore/1</code></a></td><td valign="top"><a href="#SEC25">4.3 Saving and Loading Prolog States</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX706"><code>retract/1</code></a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX748"><code>retract/2</code></a></td><td valign="top"><a href="#SEC49">6.7.3 Using Data Base References</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX709"><code>retractall/1</code></a></td><td valign="top"><a href="#SEC47">6.7.1 Modification of the Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1214"><code>reverse/2</code></a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX968"><code>runtime (statistics/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC168_28">S</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1217"><code>same_length/2</code></a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX98"><code>save/1</code></a></td><td valign="top"><a href="#SEC25">4.3 Saving and Loading Prolog States</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX101"><code>save/2</code></a></td><td valign="top"><a href="#SEC25">4.3 Saving and Loading Prolog States</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX104"><code>save_program/1</code></a></td><td valign="top"><a href="#SEC25">4.3 Saving and Loading Prolog States</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX107"><code>save_program/2</code></a></td><td valign="top"><a href="#SEC25">4.3 Saving and Loading Prolog States</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX436"><code>see/1</code></a></td><td valign="top"><a href="#SEC39">6.6.2 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX439"><code>seeing/1</code></a></td><td valign="top"><a href="#SEC39">6.6.2 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX442"><code>seen/0</code></a></td><td valign="top"><a href="#SEC39">6.6.2 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1220"><code>select/3</code></a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1064"><code>selectlist/3</code></a></td><td valign="top"><a href="#SEC62">7.1 Apply Macros</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1325"><code>serve_queue/3</code></a></td><td valign="top"><a href="#SEC69">7.8 Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX400"><code>set_input/1</code></a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX403"><code>set_output/1</code></a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1025"><code>set_prolog_flag/2</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX421"><code>set_stream_position/2</code></a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX799"><code>set_value/2</code></a></td><td valign="top"><a href="#SEC50">6.8 Internal Data Base</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX883"><code>setarg/3n</code></a></td><td valign="top"><a href="#SEC55">6.13 Term Modification</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1778"><code>setenv/2</code></a></td><td valign="top"><a href="#SEC83">8. SWI-Prolog Emulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX832"><code>setof/3</code></a></td><td valign="top"><a href="#SEC52">6.10 Collecting Solutions to a Goal</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1355"><code>setrand/1</code></a></td><td valign="top"><a href="#SEC70">7.9 Random Number Generator</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX868"><code>sh/0</code></a></td><td valign="top"><a href="#SEC54">6.12 Access to Operating System Functionality</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1553"><code>shell/0</code></a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1556"><code>shell/1</code></a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1559"><code>shell/1</code></a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1979"><code>show_op_counters/1</code></a></td><td valign="top"><a href="#SEC137">18. Profiling the Abstract Machine</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1982"><code>show_ops_by_group/1</code></a></td><td valign="top"><a href="#SEC137">18. Profiling the Abstract Machine</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1964"><code>show_table/1</code></a></td><td valign="top"><a href="#SEC135">16. Tabling</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX250"><code>simple/1</code></a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1004"><code>single_var_warnings (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX451"><code>singletons/1 (read_term/2 option)</code></a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX521"><code>skip/1</code></a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX590"><code>skip/2</code></a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1562"><code>sleep/1</code></a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX637"><code>socket/2</code></a></td><td valign="top"><a href="#SEC45">6.6.8 Using Sockets From Yap</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX634"><code>socket/4</code></a></td><td valign="top"><a href="#SEC45">6.6.8 Using Sockets From Yap</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX652"><code>socket_accept/2</code></a></td><td valign="top"><a href="#SEC45">6.6.8 Using Sockets From Yap</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX658"><code>socket_accept/2</code></a></td><td valign="top"><a href="#SEC45">6.6.8 Using Sockets From Yap</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX655"><code>socket_accept/3</code></a></td><td valign="top"><a href="#SEC45">6.6.8 Using Sockets From Yap</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX643"><code>socket_bind/2</code></a></td><td valign="top"><a href="#SEC45">6.6.8 Using Sockets From Yap</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX661"><code>socket_buffering/4</code></a></td><td valign="top"><a href="#SEC45">6.6.8 Using Sockets From Yap</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX640"><code>socket_close/1</code></a></td><td valign="top"><a href="#SEC45">6.6.8 Using Sockets From Yap</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX646"><code>socket_connect/3</code></a></td><td valign="top"><a href="#SEC45">6.6.8 Using Sockets From Yap</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX649"><code>socket_listen/2</code></a></td><td valign="top"><a href="#SEC45">6.6.8 Using Sockets From Yap</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX664"><code>socket_select/5</code></a></td><td valign="top"><a href="#SEC45">6.6.8 Using Sockets From Yap</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX343"><code>sort/2</code></a></td><td valign="top"><a href="#SEC35">6.4 Comparing Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX32"><code>source/0</code></a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX29"><code>source_mode/2</code></a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1436"><code>splay_access/5</code></a></td><td valign="top"><a href="#SEC73">7.12 Splay Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1439"><code>splay_delete/4</code></a></td><td valign="top"><a href="#SEC73">7.12 Splay Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1442"><code>splay_init/3</code></a></td><td valign="top"><a href="#SEC73">7.12 Splay Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1445"><code>splay_insert/4</code></a></td><td valign="top"><a href="#SEC73">7.12 Splay Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1448"><code>splay_join/3</code></a></td><td valign="top"><a href="#SEC73">7.12 Splay Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1451"><code>splay_split/5</code></a></td><td valign="top"><a href="#SEC73">7.12 Splay Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1994"><code>spy/1</code></a></td><td valign="top"><a href="#SEC139">19.1 Debugging Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2006"><code>spy_write/2</code></a></td><td valign="top"><a href="#SEC139">19.1 Debugging Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX373"><code>srandom/1</code></a></td><td valign="top"><a href="#SEC36">6.5 Arithmetic</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1006"><code>stack_dump_on_error (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX969"><code>stack_shifts (stack_shifts/3 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1970"><code>start_low_level_trace/0</code></a></td><td valign="top"><a href="#SEC136">17. Tracing at Low Level</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1973"><code>start_low_level_trace/0</code></a></td><td valign="top"><a href="#SEC136">17. Tracing at Low Level</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX920"><code>static_array/3</code></a></td><td valign="top"><a href="#SEC58">6.16 Arrays</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX932"><code>static_array/3</code></a></td><td valign="top"><a href="#SEC58">6.16 Arrays</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX923"><code>static_array_location/4</code></a></td><td valign="top"><a href="#SEC58">6.16 Arrays</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX926"><code>static_array_properties/3</code></a></td><td valign="top"><a href="#SEC58">6.16 Arrays</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX929"><code>static_array_to_term/3</code></a></td><td valign="top"><a href="#SEC58">6.16 Arrays</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX956"><code>statistics/0</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX959"><code>statistics/2</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX424"><code>stream_property/2</code></a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX406"><code>stream_select/3</code></a></td><td valign="top"><a href="#SEC38">6.6.1 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1005"><code>strict_iso (prolog_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX68"><code>style_check/1</code></a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX292"><code>sub_atom/5</code></a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1223"><code>sublist/2</code></a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1592"><code>subsumes/2</code></a></td><td valign="top"><a href="#SEC76">7.15 Utilities On Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1595"><code>subsumes_chk/2</code></a></td><td valign="top"><a href="#SEC76">7.15 Utilities On Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1226"><code>suffix/2</code></a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1229"><code>sum_list/2</code></a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1076"><code>sumargs/4</code></a></td><td valign="top"><a href="#SEC62">7.1 Apply Macros</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1232"><code>sumlist/2</code></a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1070"><code>sumlist/4</code></a></td><td valign="top"><a href="#SEC62">7.1 Apply Macros</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1085"><code>sumnodes/4</code></a></td><td valign="top"><a href="#SEC62">7.1 Apply Macros</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1007"><code>syntax_errors (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX452"><code>syntax_errors/1 (read_term/2 option)</code></a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1565"><code>system/0</code></a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX871"><code>system/1</code></a></td><td valign="top"><a href="#SEC54">6.12 Access to Operating System Functionality</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1568"><code>system/2</code></a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1008"><code>system_options (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX733"><code>system_predicate/2</code></a></td><td valign="top"><a href="#SEC48">6.7.2 Looking at the Data Base</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC168_29">T</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX524"><code>tab/1</code></a></td><td valign="top"><a href="#SEC41">6.6.4 Handling Input/Output of Characters</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX593"><code>tab/2</code></a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1967"><code>table_statistics/1</code></a></td><td valign="top"><a href="#SEC135">16. Tabling</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX427"><code>tell/1</code></a></td><td valign="top"><a href="#SEC39">6.6.2 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX430"><code>telling/1</code></a></td><td valign="top"><a href="#SEC39">6.6.2 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX838"><code>term_expansion/2</code></a></td><td valign="top"><a href="#SEC53">6.11 Grammar Rules</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1580"><code>term_hash/2</code></a></td><td valign="top"><a href="#SEC76">7.15 Utilities On Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1583"><code>term_hash/4</code></a></td><td valign="top"><a href="#SEC76">7.15 Utilities On Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1781"><code>term_to_atom/2</code></a></td><td valign="top"><a href="#SEC83">8. SWI-Prolog Emulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1586"><code>term_variables/2</code></a></td><td valign="top"><a href="#SEC76">7.15 Utilities On Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1892"><code>thread_at_exit/1</code></a></td><td valign="top"><a href="#SEC127">14.1 Creating and Destroying Prolog Threads</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1877"><code>thread_create/3</code></a></td><td valign="top"><a href="#SEC127">14.1 Creating and Destroying Prolog Threads</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1886"><code>thread_detach/1</code></a></td><td valign="top"><a href="#SEC127">14.1 Creating and Destroying Prolog Threads</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1889"><code>thread_exit/1</code></a></td><td valign="top"><a href="#SEC127">14.1 Creating and Destroying Prolog Threads</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1910"><code>thread_get_message/1</code></a></td><td valign="top"><a href="#SEC130">14.3.1 Message Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1922"><code>thread_get_message/2</code></a></td><td valign="top"><a href="#SEC130">14.3.1 Message Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1883"><code>thread_join/2</code></a></td><td valign="top"><a href="#SEC127">14.1 Creating and Destroying Prolog Threads</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1928"><code>thread_local/1 (directive)</code></a></td><td valign="top"><a href="#SEC132">14.3.3 Threads and Dynamic Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1916"><code>thread_message_queue_create/1</code></a></td><td valign="top"><a href="#SEC130">14.3.1 Message Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1919"><code>thread_message_queue_destroy/1</code></a></td><td valign="top"><a href="#SEC130">14.3.1 Message Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1913"><code>thread_peek_message/1</code></a></td><td valign="top"><a href="#SEC130">14.3.1 Message Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1880"><code>thread_self/1</code></a></td><td valign="top"><a href="#SEC127">14.1 Creating and Destroying Prolog Threads</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1907"><code>thread_send_message/2</code></a></td><td valign="top"><a href="#SEC130">14.3.1 Message Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1895"><code>thread_setconcurrency/2</code></a></td><td valign="top"><a href="#SEC127">14.1 Creating and Destroying Prolog Threads</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1925"><code>thread_signal/2</code></a></td><td valign="top"><a href="#SEC131">14.3.2 Signalling Threads</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1901"><code>thread_statistics/3</code></a></td><td valign="top"><a href="#SEC128">14.2 Monitoring Threads</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX194"><code>throw/1</code></a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1616"><code>time_out/3</code></a></td><td valign="top"><a href="#SEC78">7.17 Calls With Timeout</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1541"><code>tmpnam/1</code></a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1009"><code>to_chars_modes (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX433"><code>told/0</code></a></td><td valign="top"><a href="#SEC39">6.6.2 Handling Streams and Files</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1673"><code>top_sort/2</code></a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1676"><code>top_sort/3</code></a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1010"><code>toplevel_hook (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX970"><code>trail (statistics/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1679"><code>transitive_closure/2</code></a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1658"><code>transpose/3</code></a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1631"><code>tree_size/2</code></a></td><td valign="top"><a href="#SEC79">7.18 Updatable Binary Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1634"><code>tree_to_list/2</code></a></td><td valign="top"><a href="#SEC79">7.18 Updatable Binary Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX140"><code>true/0</code></a></td><td valign="top"><a href="#SEC32">6.1 Control Predicates</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX602"><code>ttyget/1</code></a></td><td valign="top"><a href="#SEC43">6.6.6 Compatible C-Prolog predicates for Terminal I/O</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX605"><code>ttyget0/1</code></a></td><td valign="top"><a href="#SEC43">6.6.6 Compatible C-Prolog predicates for Terminal I/O</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX614"><code>ttynl/0</code></a></td><td valign="top"><a href="#SEC43">6.6.6 Compatible C-Prolog predicates for Terminal I/O</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX599"><code>ttyput/1</code></a></td><td valign="top"><a href="#SEC43">6.6.6 Compatible C-Prolog predicates for Terminal I/O</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX608"><code>ttyskip/1</code></a></td><td valign="top"><a href="#SEC43">6.6.6 Compatible C-Prolog predicates for Terminal I/O</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX611"><code>ttytab/1</code></a></td><td valign="top"><a href="#SEC43">6.6.6 Compatible C-Prolog predicates for Terminal I/O</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1011"><code>typein_module (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC168_30">U</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1745"><code>undgraph_add_edges/3</code></a></td><td valign="top"><a href="#SEC82">7.21 Undirected Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1739"><code>undgraph_add_vertices/3</code></a></td><td valign="top"><a href="#SEC82">7.21 Undirected Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1757"><code>undgraph_complement/2</code></a></td><td valign="top"><a href="#SEC82">7.21 Undirected Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1748"><code>undgraph_del_edges/3</code></a></td><td valign="top"><a href="#SEC82">7.21 Undirected Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1742"><code>undgraph_del_vertices/3</code></a></td><td valign="top"><a href="#SEC82">7.21 Undirected Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1736"><code>undgraph_edges/2</code></a></td><td valign="top"><a href="#SEC82">7.21 Undirected Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1751"><code>undgraph_neighbors/3</code></a></td><td valign="top"><a href="#SEC82">7.21 Undirected Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1754"><code>undgraph_neighbours/3</code></a></td><td valign="top"><a href="#SEC82">7.21 Undirected Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1730"><code>undgraph_new/1</code></a></td><td valign="top"><a href="#SEC82">7.21 Undirected Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1733"><code>undgraph_vertices/2</code></a></td><td valign="top"><a href="#SEC82">7.21 Undirected Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX47"><code>unhide/1</code></a></td><td valign="top"><a href="#SEC24">4.2 Changing the Compiler's Behavior</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX316"><code>unify_with_occurs_check/2</code></a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX874"><code>unix/1</code></a></td><td valign="top"><a href="#SEC54">6.12 Access to Operating System Functionality</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1012"><code>unknown (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX214"><code>unknown/2</code></a></td><td valign="top"><a href="#SEC33">6.2 Handling Undefined Procedures</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX217"><code>unknown_predicate_handler/3</code></a></td><td valign="top"><a href="#SEC33">6.2 Handling Undefined Procedures</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX944"><code>update_array/3</code></a></td><td valign="top"><a href="#SEC58">6.16 Arrays</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX899"><code>update_mutable/2</code></a></td><td valign="top"><a href="#SEC55">6.13 Term Modification</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1013"><code>update_semantics (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX122"><code>use_module/1</code></a></td><td valign="top"><a href="#SEC29">5.3 Using Modules</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX125"><code>use_module/2</code></a></td><td valign="top"><a href="#SEC29">5.3 Using Modules</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX128"><code>use_module/3</code></a></td><td valign="top"><a href="#SEC29">5.3 Using Modules</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1014"><code>user_error (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1015"><code>user_input (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1016"><code>user_output (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC168_31">V</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX220"><code>var/1</code></a></td><td valign="top"><a href="#SEC34">6.3 Predicates on terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1598"><code>variable_in_term/2</code></a></td><td valign="top"><a href="#SEC76">7.15 Utilities On Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX453"><code>variable_names/1 (read_term/2 option)</code></a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX454"><code>variables/1 (read_term/2 option)</code></a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1589"><code>variant/2</code></a></td><td valign="top"><a href="#SEC76">7.15 Utilities On Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1862"><code>verify_attributes/3</code></a></td><td valign="top"><a href="#SEC96">10.3 Attributed Unification</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1017"><code>version (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1043"><code>version/0</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1046"><code>version/1</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1640"><code>vertices/2</code></a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1637"><code>vertices_edges_to_ugraph/3</code></a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC168_32">W</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1571"><code>wait/2</code></a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX971"><code>walltime (statistics/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1847"><code>when/2</code></a></td><td valign="top"><a href="#SEC92">9.2 Coroutining</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1937"><code>with_mutex/2</code></a></td><td valign="top"><a href="#SEC133">14.4 Thread Synchronisation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1484"><code>with_output_to_chars/2</code></a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1487"><code>with_output_to_chars/3</code></a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1490"><code>with_output_to_chars/4</code></a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1547"><code>working_directory/2</code></a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1784"><code>working_directory/2</code></a></td><td valign="top"><a href="#SEC83">8. SWI-Prolog Emulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX461"><code>write/1</code></a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX536"><code>write/2</code></a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX629"><code>write_depth/2</code></a></td><td valign="top"><a href="#SEC44">6.6.7 Controlling Input/Output</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX626"><code>write_depth/3</code></a></td><td valign="top"><a href="#SEC44">6.6.7 Controlling Input/Output</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1018"><code>write_strings (yap_flag/2 option)</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX470"><code>write_term/2</code></a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX542"><code>write_term/3</code></a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1460"><code>write_to_chars/2</code></a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1463"><code>write_to_chars/3</code></a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX473"><code>writeq/1</code></a></td><td valign="top"><a href="#SEC40">6.6.3 Handling Input/Output of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX545"><code>writeq/2</code></a></td><td valign="top"><a href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC168_33">Y</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#SEC146"><code>YAP_AllocSpaceFromYap (C-Interface function)</code></a></td><td valign="top"><a href="#SEC146">21.4 Memory Allocation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2035"><code>YAP_ArgOfTerm (C-Interface function)</code></a></td><td valign="top"><a href="#SEC143">21.1 Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2039"><code>YAP_ArityOfFunctor (C-Interface function)</code></a></td><td valign="top"><a href="#SEC143">21.1 Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2028"><code>YAP_AtomName (C-Interface function)</code></a></td><td valign="top"><a href="#SEC143">21.1 Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2025"><code>YAP_AtomOfTerm (C-Interface function)</code></a></td><td valign="top"><a href="#SEC143">21.1 Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2023"><code>YAP_BigNumOfTerm (C-Interface function)</code></a></td><td valign="top"><a href="#SEC143">21.1 Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2041"><code>YAP_BufferToAtomList (C-Interface function)</code></a></td><td valign="top"><a href="#SEC145">21.3 Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2040"><code>YAP_BufferToString (C-Interface function)</code></a></td><td valign="top"><a href="#SEC145">21.3 Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC148"><code>YAP_CallProlog (C-Interface function)</code></a></td><td valign="top"><a href="#SEC148">21.6 From <code>C</code> back to Prolog</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2065"><code>YAP_ClearExceptions/0</code></a></td><td valign="top"><a href="#SEC153">22. Using YAP as a Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2044"><code>YAP_CloseAllOpenStreams (C-Interface function)</code></a></td><td valign="top"><a href="#SEC147">21.5 Controlling Yap Streams from <code>C</code></a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2052"><code>YAP_CompileClause/1</code></a></td><td valign="top"><a href="#SEC153">22. Using YAP as a Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2053"><code>YAP_ContinueGoal/0</code></a></td><td valign="top"><a href="#SEC153">22. Using YAP as a Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2051"><code>YAP_cutfail (C-Interface function)</code></a></td><td valign="top"><a href="#SEC149">21.7 Writing predicates in C</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2050"><code>YAP_cutsucceed (C-Interface function)</code></a></td><td valign="top"><a href="#SEC149">21.7 Writing predicates in C</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2069"><code>YAP_EndConsult/0</code></a></td><td valign="top"><a href="#SEC153">22. Using YAP as a Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2054"><code>YAP_Error/1</code></a></td><td valign="top"><a href="#SEC153">22. Using YAP as a Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2055"><code>YAP_Exit/1</code></a></td><td valign="top"><a href="#SEC153">22. Using YAP as a Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2057"><code>YAP_FastInit/1</code></a></td><td valign="top"><a href="#SEC153">22. Using YAP as a Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX972"><code>yap_flag/2</code></a></td><td valign="top"><a href="#SEC60">6.18 Miscellaneous</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2020"><code>YAP_FloatOfTerm (C-Interface function)</code></a></td><td valign="top"><a href="#SEC143">21.1 Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2043"><code>YAP_FreeSpaceFromYap (C-Interface function)</code></a></td><td valign="top"><a href="#SEC146">21.4 Memory Allocation</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2027"><code>YAP_FullLookupAtom (C-Interface function)</code></a></td><td valign="top"><a href="#SEC143">21.1 Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2036"><code>YAP_FunctorOfTerm (C-Interface function)</code></a></td><td valign="top"><a href="#SEC143">21.1 Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2056"><code>YAP_GetValue/1</code></a></td><td valign="top"><a href="#SEC153">22. Using YAP as a Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2031"><code>YAP_HeadOfTerm (C-Interface function)</code></a></td><td valign="top"><a href="#SEC143">21.1 Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2058"><code>YAP_Init/1</code></a></td><td valign="top"><a href="#SEC153">22. Using YAP as a Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2068"><code>YAP_InitConsult/2</code></a></td><td valign="top"><a href="#SEC153">22. Using YAP as a Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2018"><code>YAP_IntOfTerm (C-Interface function)</code></a></td><td valign="top"><a href="#SEC143">21.1 Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2016"><code>YAP_IsApplTerm (C-Interface function)</code></a></td><td valign="top"><a href="#SEC143">21.1 Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2014"><code>YAP_IsAtomTerm (C-Interface function)</code></a></td><td valign="top"><a href="#SEC143">21.1 Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2021"><code>YAP_IsBigNumTerm (C-Interface function)</code></a></td><td valign="top"><a href="#SEC143">21.1 Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2013"><code>YAP_IsDBRefTerm (C-Interface function)</code></a></td><td valign="top"><a href="#SEC143">21.1 Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2012"><code>YAP_IsFloatTerm (C-Interface function)</code></a></td><td valign="top"><a href="#SEC143">21.1 Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2011"><code>YAP_IsIntTerm (C-Interface function)</code></a></td><td valign="top"><a href="#SEC143">21.1 Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2010"><code>YAP_IsNonVarTerm (C-Interface function)</code></a></td><td valign="top"><a href="#SEC143">21.1 Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2015"><code>YAP_IsPairTerm (C-Interface function)</code></a></td><td valign="top"><a href="#SEC143">21.1 Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2009"><code>YAP_IsVarTerm (C-Interface function)</code></a></td><td valign="top"><a href="#SEC143">21.1 Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2026"><code>YAP_LookupAtom (C-Interface function)</code></a></td><td valign="top"><a href="#SEC143">21.1 Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2033"><code>YAP_MkApplTerm (C-Interface function)</code></a></td><td valign="top"><a href="#SEC143">21.1 Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2024"><code>YAP_MkAtomTerm (C-Interface function)</code></a></td><td valign="top"><a href="#SEC143">21.1 Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2022"><code>YAP_MkBigNumTerm (C-Interface function)</code></a></td><td valign="top"><a href="#SEC143">21.1 Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2019"><code>YAP_MkFloatTerm (C-Interface function)</code></a></td><td valign="top"><a href="#SEC143">21.1 Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2037"><code>YAP_MkFunctor (C-Interface function)</code></a></td><td valign="top"><a href="#SEC143">21.1 Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2017"><code>YAP_MkIntTerm (C-Interface function)</code></a></td><td valign="top"><a href="#SEC143">21.1 Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2034"><code>YAP_MkNewApplTerm (C-Interface function)</code></a></td><td valign="top"><a href="#SEC143">21.1 Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2030"><code>YAP_MkNewPairTerm (C-Interface function)</code></a></td><td valign="top"><a href="#SEC143">21.1 Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2029"><code>YAP_MkPairTerm (C-Interface function)</code></a></td><td valign="top"><a href="#SEC143">21.1 Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2038"><code>YAP_NameOfFunctor (C-Interface function)</code></a></td><td valign="top"><a href="#SEC143">21.1 Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2045"><code>YAP_OpenStream (C-Interface function)</code></a></td><td valign="top"><a href="#SEC147">21.5 Controlling Yap Streams from <code>C</code></a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2048"><code>YAP_PRESERVE_DATA (C-Interface function)</code></a></td><td valign="top"><a href="#SEC149">21.7 Writing predicates in C</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2049"><code>YAP_PRESERVED_DATA (C-Interface function)</code></a></td><td valign="top"><a href="#SEC149">21.7 Writing predicates in C</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2059"><code>YAP_PutValue/2</code></a></td><td valign="top"><a href="#SEC153">22. Using YAP as a Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2060"><code>YAP_Read/1</code></a></td><td valign="top"><a href="#SEC153">22. Using YAP as a Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2042"><code>YAP_ReadBuffer (C-Interface function)</code></a></td><td valign="top"><a href="#SEC145">21.3 Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2063"><code>YAP_Reset/0</code></a></td><td valign="top"><a href="#SEC153">22. Using YAP as a Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2062"><code>YAP_RestartGoal/0</code></a></td><td valign="top"><a href="#SEC153">22. Using YAP as a Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2064"><code>YAP_RestartGoal/1</code></a></td><td valign="top"><a href="#SEC153">22. Using YAP as a Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2061"><code>YAP_RunGoal/1</code></a></td><td valign="top"><a href="#SEC153">22. Using YAP as a Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC147"><code>YAP_StreamToFileNo (C-Interface function)</code></a></td><td valign="top"><a href="#SEC147">21.5 Controlling Yap Streams from <code>C</code></a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC145"><code>YAP_StringToBuffer (C-Interface function)</code></a></td><td valign="top"><a href="#SEC145">21.3 Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2032"><code>YAP_TailOfTerm (C-Interface function)</code></a></td><td valign="top"><a href="#SEC143">21.1 Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC144"><code>YAP_Unify (C-Interface function)</code></a></td><td valign="top"><a href="#SEC144">21.2 Unification</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2047"><code>YAP_UserBackCPredicate (C-Interface function)</code></a></td><td valign="top"><a href="#SEC149">21.7 Writing predicates in C</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2046"><code>YAP_UserCPredicate (C-Interface function)</code></a></td><td valign="top"><a href="#SEC149">21.7 Writing predicates in C</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2066"><code>YAP_Write/3</code></a></td><td valign="top"><a href="#SEC153">22. Using YAP as a Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2067"><code>YAP_WriteBuffer/4</code></a></td><td valign="top"><a href="#SEC153">22. Using YAP as a Library</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX3"><code>YAPBINDIR</code></a></td><td valign="top"><a href="#SEC9">2.1 Running Yap Interactively</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX4"><code>YAPLIBDIR</code></a></td><td valign="top"><a href="#SEC9">2.1 Running Yap Interactively</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX5"><code>YAPSHAREDIR</code></a></td><td valign="top"><a href="#SEC9">2.1 Running Yap Interactively</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
</table>
<table><tr><th valign="top">Jump to: </th><td><a href="#SEC168_0" class="summary-letter"><b>!</b></a>
<a href="#SEC168_1" class="summary-letter"><b>,</b></a>
<a href="#SEC168_2" class="summary-letter"><b>-</b></a>
<a href="#SEC168_3" class="summary-letter"><b>;</b></a>
<a href="#SEC168_4" class="summary-letter"><b><</b></a>
<a href="#SEC168_5" class="summary-letter"><b>=</b></a>
<a href="#SEC168_6" class="summary-letter"><b>></b></a>
<a href="#SEC168_7" class="summary-letter"><b>@</b></a>
<a href="#SEC168_8" class="summary-letter"><b>[</b></a>
<a href="#SEC168_9" class="summary-letter"><b>\</b></a>
<br>
<a href="#SEC168_10" class="summary-letter"><b>A</b></a>
<a href="#SEC168_11" class="summary-letter"><b>B</b></a>
<a href="#SEC168_12" class="summary-letter"><b>C</b></a>
<a href="#SEC168_13" class="summary-letter"><b>D</b></a>
<a href="#SEC168_14" class="summary-letter"><b>E</b></a>
<a href="#SEC168_15" class="summary-letter"><b>F</b></a>
<a href="#SEC168_16" class="summary-letter"><b>G</b></a>
<a href="#SEC168_17" class="summary-letter"><b>H</b></a>
<a href="#SEC168_18" class="summary-letter"><b>I</b></a>
<a href="#SEC168_19" class="summary-letter"><b>J</b></a>
<a href="#SEC168_20" class="summary-letter"><b>K</b></a>
<a href="#SEC168_21" class="summary-letter"><b>L</b></a>
<a href="#SEC168_22" class="summary-letter"><b>M</b></a>
<a href="#SEC168_23" class="summary-letter"><b>N</b></a>
<a href="#SEC168_24" class="summary-letter"><b>O</b></a>
<a href="#SEC168_25" class="summary-letter"><b>P</b></a>
<a href="#SEC168_26" class="summary-letter"><b>Q</b></a>
<a href="#SEC168_27" class="summary-letter"><b>R</b></a>
<a href="#SEC168_28" class="summary-letter"><b>S</b></a>
<a href="#SEC168_29" class="summary-letter"><b>T</b></a>
<a href="#SEC168_30" class="summary-letter"><b>U</b></a>
<a href="#SEC168_31" class="summary-letter"><b>V</b></a>
<a href="#SEC168_32" class="summary-letter"><b>W</b></a>
<a href="#SEC168_33" class="summary-letter"><b>Y</b></a>
</td></tr></table>
<hr size="6">
<a name="Concept-Index"></a>
<a name="SEC169"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC168" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[ > ]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC168" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[ >> ]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="unnumbered"> Concept Index </h1>
<table><tr><th valign="top">Jump to: </th><td><a href="#SEC169_0" class="summary-letter"><b>A</b></a>
<a href="#SEC169_1" class="summary-letter"><b>B</b></a>
<a href="#SEC169_2" class="summary-letter"><b>C</b></a>
<a href="#SEC169_3" class="summary-letter"><b>D</b></a>
<a href="#SEC169_4" class="summary-letter"><b>E</b></a>
<a href="#SEC169_5" class="summary-letter"><b>F</b></a>
<a href="#SEC169_6" class="summary-letter"><b>H</b></a>
<a href="#SEC169_7" class="summary-letter"><b>I</b></a>
<a href="#SEC169_8" class="summary-letter"><b>L</b></a>
<a href="#SEC169_9" class="summary-letter"><b>M</b></a>
<a href="#SEC169_10" class="summary-letter"><b>N</b></a>
<a href="#SEC169_11" class="summary-letter"><b>O</b></a>
<a href="#SEC169_12" class="summary-letter"><b>P</b></a>
<a href="#SEC169_13" class="summary-letter"><b>Q</b></a>
<a href="#SEC169_14" class="summary-letter"><b>R</b></a>
<a href="#SEC169_15" class="summary-letter"><b>S</b></a>
<a href="#SEC169_16" class="summary-letter"><b>T</b></a>
<a href="#SEC169_17" class="summary-letter"><b>U</b></a>
<a href="#SEC169_18" class="summary-letter"><b>V</b></a>
</td></tr></table>
<table border="0" class="index-cp">
<tr><td></td><th align="left">Index Entry</th><th align="left"> Section</th></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC169_0">A</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX7">anonymous variable</a></td><td valign="top"><a href="#SEC19">3.2.4 Variables</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC63">association list</a></td><td valign="top"><a href="#SEC63">7.2 Association Lists</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC18">atom</a></td><td valign="top"><a href="#SEC18">3.2.3 Atoms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1853">attribute declaration</a></td><td valign="top"><a href="#SEC94">10.1 Attribute Declarations</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC93">attributed variables</a></td><td valign="top"><a href="#SEC93">10. Attributed Variables</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC64">AVL trees</a></td><td valign="top"><a href="#SEC64">7.3 AVL Trees</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC169_1">B</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1">booting</a></td><td valign="top"><a href="#SEC8">2. Running YAP</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC169_2">C</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#SEC77">cleanup</a></td><td valign="top"><a href="#SEC77">7.16 Call Cleanup</a></td></tr>
<tr><td></td><td valign="top"><a href="#CLPR">CLPQ</a></td><td valign="top"><a href="#SEC100">11. Constraint Logic Programming over Reals</a></td></tr>
<tr><td></td><td valign="top"><a href="#CLPR">CLPR</a></td><td valign="top"><a href="#SEC100">11. Constraint Logic Programming over Reals</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC21">comment</a></td><td valign="top"><a href="#SEC21">3.2.6 Layout</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC57">Counting Calls</a></td><td valign="top"><a href="#SEC57">6.15 Counting Calls</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC169_3">D</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#IDX1854">declaration, attribute</a></td><td valign="top"><a href="#SEC94">10.1 Attribute Declarations</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC169_4">E</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#SEC81">Efficient Directed Graphs</a></td><td valign="top"><a href="#SEC81">7.20 Directed Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX6">end of term</a></td><td valign="top"><a href="#SEC12">3.1 Syntax of Terms</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2">environment variables</a></td><td valign="top"><a href="#SEC9">2.1 Running Yap Interactively</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC169_5">F</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#SEC16">floating-point number</a></td><td valign="top"><a href="#SEC16">3.2.1.2 Floating-point Numbers</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC169_6">H</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#SEC65">heap</a></td><td valign="top"><a href="#SEC65">7.4 Heaps</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC86">hProlog Attributed Variables</a></td><td valign="top"><a href="#SEC86">8.3 hProlog and SWI-Prolog Attributed Variables</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC169_7">I</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#SEC2">installation</a></td><td valign="top"><a href="#SEC2">1. Installing YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC15">integer</a></td><td valign="top"><a href="#SEC15">3.2.1.1 Integers</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC169_8">L</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#SEC66">list manipulation</a></td><td valign="top"><a href="#SEC66">7.5 List Manipulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC125">Logtalk</a></td><td valign="top"><a href="#SEC125">13. Logtalk</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC169_9">M</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#SEC4">machine optimizations</a></td><td valign="top"><a href="#SEC4">1.2 Tuning YAP for a Particular Machine and Compiler</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC62">macros</a></td><td valign="top"><a href="#SEC62">7.1 Apply Macros</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX886">mutable variables</a></td><td valign="top"><a href="#SEC55">6.13 Term Modification</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC169_10">N</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#SEC14">number</a></td><td valign="top"><a href="#SEC14">3.2.1 Numbers</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC169_11">O</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#SEC75">Operating System Utilities</a></td><td valign="top"><a href="#SEC75">7.14 Calling The Operating System from YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC134">or-parallelism</a></td><td valign="top"><a href="#SEC134">15. Parallelism</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC67">ordered set</a></td><td valign="top"><a href="#SEC67">7.6 Ordered Sets</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC169_12">P</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#SEC134">parallelism</a></td><td valign="top"><a href="#SEC134">15. Parallelism</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC56">profiling</a></td><td valign="top"><a href="#SEC56">6.14 Profiling Prolog Programs</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC68">pseudo random</a></td><td valign="top"><a href="#SEC68">7.7 Pseudo Random Number Integer Generator</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC20">punctuation token</a></td><td valign="top"><a href="#SEC20">3.2.5 Punctuation Tokens</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC169_13">Q</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#SEC69">queue</a></td><td valign="top"><a href="#SEC69">7.8 Queues</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC70">queue</a></td><td valign="top"><a href="#SEC70">7.9 Random Number Generator</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC169_14">R</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#SEC71">Red-Black Trees</a></td><td valign="top"><a href="#SEC71">7.10 Red-Black Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC72">regular expressions</a></td><td valign="top"><a href="#SEC72">7.11 Regular Expressions</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC169_15">S</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#SEC73">splay trees</a></td><td valign="top"><a href="#SEC73">7.12 Splay Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC17">string</a></td><td valign="top"><a href="#SEC17">3.2.2 Character Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC74">string I/O</a></td><td valign="top"><a href="#SEC74">7.13 Reading From and Writing To Strings</a></td></tr>
<tr><td></td><td valign="top"><a href="#SWI_002dProlog">SWI-Prolog</a></td><td valign="top"><a href="#SEC83">8. SWI-Prolog Emulation</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC3">syntax</a></td><td valign="top"><a href="#SEC3">1.1 Tuning the Functionality of YAP</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC12">syntax</a></td><td valign="top"><a href="#SEC12">3.1 Syntax of Terms</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC169_16">T</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#SEC135">tabling</a></td><td valign="top"><a href="#SEC135">16. Tabling</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC78">timeout</a></td><td valign="top"><a href="#SEC78">7.17 Calls With Timeout</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC13">token</a></td><td valign="top"><a href="#SEC13">3.2 Prolog Tokens</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC169_17">U</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#SEC82">undrected graphs</a></td><td valign="top"><a href="#SEC82">7.21 Undirected Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC80">unweighted graphs</a></td><td valign="top"><a href="#SEC80">7.19 Unweighted Graphs</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC79">updatable tree</a></td><td valign="top"><a href="#SEC79">7.18 Updatable Binary Trees</a></td></tr>
<tr><td></td><td valign="top"><a href="#IDX2070">update semantics</a></td><td valign="top"><a href="#SEC162">23.2.1 Major Differences between YAP and SICStus Prolog.</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC55">updating terms</a></td><td valign="top"><a href="#SEC55">6.13 Term Modification</a></td></tr>
<tr><td></td><td valign="top"><a href="#SEC76">utilities on terms</a></td><td valign="top"><a href="#SEC76">7.15 Utilities On Terms</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC169_18">V</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="#SEC19">variable</a></td><td valign="top"><a href="#SEC19">3.2.4 Variables</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
</table>
<table><tr><th valign="top">Jump to: </th><td><a href="#SEC169_0" class="summary-letter"><b>A</b></a>
<a href="#SEC169_1" class="summary-letter"><b>B</b></a>
<a href="#SEC169_2" class="summary-letter"><b>C</b></a>
<a href="#SEC169_3" class="summary-letter"><b>D</b></a>
<a href="#SEC169_4" class="summary-letter"><b>E</b></a>
<a href="#SEC169_5" class="summary-letter"><b>F</b></a>
<a href="#SEC169_6" class="summary-letter"><b>H</b></a>
<a href="#SEC169_7" class="summary-letter"><b>I</b></a>
<a href="#SEC169_8" class="summary-letter"><b>L</b></a>
<a href="#SEC169_9" class="summary-letter"><b>M</b></a>
<a href="#SEC169_10" class="summary-letter"><b>N</b></a>
<a href="#SEC169_11" class="summary-letter"><b>O</b></a>
<a href="#SEC169_12" class="summary-letter"><b>P</b></a>
<a href="#SEC169_13" class="summary-letter"><b>Q</b></a>
<a href="#SEC169_14" class="summary-letter"><b>R</b></a>
<a href="#SEC169_15" class="summary-letter"><b>S</b></a>
<a href="#SEC169_16" class="summary-letter"><b>T</b></a>
<a href="#SEC169_17" class="summary-letter"><b>U</b></a>
<a href="#SEC169_18" class="summary-letter"><b>V</b></a>
</td></tr></table>
<hr size="6">
<a name="SEC_Contents"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1>Table of Contents</h1>
<div class="contents">
<ul class="toc">
<li><a name="TOC1" href="#SEC1">Introduction</a></li>
<li><a name="TOC2" href="#SEC2">1. Installing YAP</a>
<ul class="toc">
<li><a name="TOC3" href="#SEC3">1.1 Tuning the Functionality of YAP</a></li>
<li><a name="TOC4" href="#SEC4">1.2 Tuning YAP for a Particular Machine and Compiler</a></li>
<li><a name="TOC5" href="#SEC5">1.3 Tuning YAP for <code>GCC</code>.</a>
<ul class="toc">
<li><a name="TOC6" href="#SEC6">1.3.1 Compiling Under Visual C++</a></li>
<li><a name="TOC7" href="#SEC7">1.3.2 Compiling Under SGI's cc</a></li>
</ul>
</li>
</ul></li>
<li><a name="TOC8" href="#SEC8">2. Running YAP</a>
<ul class="toc">
<li><a name="TOC9" href="#SEC9">2.1 Running Yap Interactively</a></li>
<li><a name="TOC10" href="#SEC10">2.2 Running Prolog Files</a></li>
</ul></li>
<li><a name="TOC11" href="#SEC11">3. Syntax</a>
<ul class="toc">
<li><a name="TOC12" href="#SEC12">3.1 Syntax of Terms</a></li>
<li><a name="TOC13" href="#SEC13">3.2 Prolog Tokens</a>
<ul class="toc">
<li><a name="TOC14" href="#SEC14">3.2.1 Numbers</a>
<ul class="toc">
<li><a name="TOC15" href="#SEC15">3.2.1.1 Integers</a></li>
<li><a name="TOC16" href="#SEC16">3.2.1.2 Floating-point Numbers</a></li>
</ul></li>
<li><a name="TOC17" href="#SEC17">3.2.2 Character Strings</a></li>
<li><a name="TOC18" href="#SEC18">3.2.3 Atoms</a></li>
<li><a name="TOC19" href="#SEC19">3.2.4 Variables</a></li>
<li><a name="TOC20" href="#SEC20">3.2.5 Punctuation Tokens</a></li>
<li><a name="TOC21" href="#SEC21">3.2.6 Layout</a></li>
</ul>
</li>
</ul></li>
<li><a name="TOC22" href="#SEC22">4. Loading Programs</a>
<ul class="toc">
<li><a name="TOC23" href="#SEC23">4.1 Program loading and updating</a></li>
<li><a name="TOC24" href="#SEC24">4.2 Changing the Compiler's Behavior</a></li>
<li><a name="TOC25" href="#SEC25">4.3 Saving and Loading Prolog States</a></li>
</ul></li>
<li><a name="TOC26" href="#SEC26">5. The Module System</a>
<ul class="toc">
<li><a name="TOC27" href="#SEC27">5.1 Module Concepts</a></li>
<li><a name="TOC28" href="#SEC28">5.2 Defining a New Module</a></li>
<li><a name="TOC29" href="#SEC29">5.3 Using Modules</a></li>
<li><a name="TOC30" href="#SEC30">5.4 Meta-Predicates in Modules</a></li>
</ul></li>
<li><a name="TOC31" href="#SEC31">6. Built-In Predicates</a>
<ul class="toc">
<li><a name="TOC32" href="#SEC32">6.1 Control Predicates</a></li>
<li><a name="TOC33" href="#SEC33">6.2 Handling Undefined Procedures</a></li>
<li><a name="TOC34" href="#SEC34">6.3 Predicates on terms</a></li>
<li><a name="TOC35" href="#SEC35">6.4 Comparing Terms</a></li>
<li><a name="TOC36" href="#SEC36">6.5 Arithmetic</a></li>
<li><a name="TOC37" href="#SEC37">6.6 I/O Predicates</a>
<ul class="toc">
<li><a name="TOC38" href="#SEC38">6.6.1 Handling Streams and Files</a></li>
<li><a name="TOC39" href="#SEC39">6.6.2 Handling Streams and Files</a></li>
<li><a name="TOC40" href="#SEC40">6.6.3 Handling Input/Output of Terms</a></li>
<li><a name="TOC41" href="#SEC41">6.6.4 Handling Input/Output of Characters</a></li>
<li><a name="TOC42" href="#SEC42">6.6.5 Input/Output Predicates applied to Streams</a></li>
<li><a name="TOC43" href="#SEC43">6.6.6 Compatible C-Prolog predicates for Terminal I/O</a></li>
<li><a name="TOC44" href="#SEC44">6.6.7 Controlling Input/Output</a></li>
<li><a name="TOC45" href="#SEC45">6.6.8 Using Sockets From Yap</a></li>
</ul></li>
<li><a name="TOC46" href="#SEC46">6.7 Using the Clausal Data Base</a>
<ul class="toc">
<li><a name="TOC47" href="#SEC47">6.7.1 Modification of the Data Base</a></li>
<li><a name="TOC48" href="#SEC48">6.7.2 Looking at the Data Base</a></li>
<li><a name="TOC49" href="#SEC49">6.7.3 Using Data Base References</a></li>
</ul></li>
<li><a name="TOC50" href="#SEC50">6.8 Internal Data Base</a></li>
<li><a name="TOC51" href="#SEC51">6.9 The Blackboard</a></li>
<li><a name="TOC52" href="#SEC52">6.10 Collecting Solutions to a Goal</a></li>
<li><a name="TOC53" href="#SEC53">6.11 Grammar Rules</a></li>
<li><a name="TOC54" href="#SEC54">6.12 Access to Operating System Functionality</a></li>
<li><a name="TOC55" href="#SEC55">6.13 Term Modification</a></li>
<li><a name="TOC56" href="#SEC56">6.14 Profiling Prolog Programs</a></li>
<li><a name="TOC57" href="#SEC57">6.15 Counting Calls</a></li>
<li><a name="TOC58" href="#SEC58">6.16 Arrays</a></li>
<li><a name="TOC59" href="#SEC59">6.17 Predicate Information</a></li>
<li><a name="TOC60" href="#SEC60">6.18 Miscellaneous</a></li>
</ul></li>
<li><a name="TOC61" href="#SEC61">7. Library Predicates</a>
<ul class="toc">
<li><a name="TOC62" href="#SEC62">7.1 Apply Macros</a></li>
<li><a name="TOC63" href="#SEC63">7.2 Association Lists</a></li>
<li><a name="TOC64" href="#SEC64">7.3 AVL Trees</a></li>
<li><a name="TOC65" href="#SEC65">7.4 Heaps</a></li>
<li><a name="TOC66" href="#SEC66">7.5 List Manipulation</a></li>
<li><a name="TOC67" href="#SEC67">7.6 Ordered Sets</a></li>
<li><a name="TOC68" href="#SEC68">7.7 Pseudo Random Number Integer Generator</a></li>
<li><a name="TOC69" href="#SEC69">7.8 Queues</a></li>
<li><a name="TOC70" href="#SEC70">7.9 Random Number Generator</a></li>
<li><a name="TOC71" href="#SEC71">7.10 Red-Black Trees</a></li>
<li><a name="TOC72" href="#SEC72">7.11 Regular Expressions</a></li>
<li><a name="TOC73" href="#SEC73">7.12 Splay Trees</a></li>
<li><a name="TOC74" href="#SEC74">7.13 Reading From and Writing To Strings</a></li>
<li><a name="TOC75" href="#SEC75">7.14 Calling The Operating System from YAP</a></li>
<li><a name="TOC76" href="#SEC76">7.15 Utilities On Terms</a></li>
<li><a name="TOC77" href="#SEC77">7.16 Call Cleanup</a></li>
<li><a name="TOC78" href="#SEC78">7.17 Calls With Timeout</a></li>
<li><a name="TOC79" href="#SEC79">7.18 Updatable Binary Trees</a></li>
<li><a name="TOC80" href="#SEC80">7.19 Unweighted Graphs</a></li>
<li><a name="TOC81" href="#SEC81">7.20 Directed Graphs</a></li>
<li><a name="TOC82" href="#SEC82">7.21 Undirected Graphs</a></li>
</ul></li>
<li><a name="TOC83" href="#SEC83">8. SWI-Prolog Emulation</a>
<ul class="toc">
<li><a name="TOC84" href="#SEC84">8.1 Invoking Predicates on all Members of a List</a></li>
<li><a name="TOC85" href="#SEC85">8.2 Forall</a></li>
<li><a name="TOC86" href="#SEC86">8.3 hProlog and SWI-Prolog Attributed Variables</a>
<ul class="toc">
<li><a name="TOC87" href="#SEC87">8.3.1 Special Purpose SWI Predicates for Attributes</a></li>
</ul></li>
<li><a name="TOC88" href="#SEC88">8.4 SWI Global variables</a>
<ul class="toc">
<li><a name="TOC89" href="#SEC89">8.4.1 Compatibility of SWI-Prolog Global Variables</a></li>
</ul>
</li>
</ul></li>
<li><a name="TOC90" href="#SEC90">9. Extensions to Prolog</a>
<ul class="toc">
<li><a name="TOC91" href="#SEC91">9.1 Rational Trees</a></li>
<li><a name="TOC92" href="#SEC92">9.2 Coroutining</a></li>
</ul></li>
<li><a name="TOC93" href="#SEC93">10. Attributed Variables</a>
<ul class="toc">
<li><a name="TOC94" href="#SEC94">10.1 Attribute Declarations</a></li>
<li><a name="TOC95" href="#SEC95">10.2 Attribute Manipulation</a></li>
<li><a name="TOC96" href="#SEC96">10.3 Attributed Unification</a></li>
<li><a name="TOC97" href="#SEC97">10.4 Displaying Attributes</a></li>
<li><a name="TOC98" href="#SEC98">10.5 Projecting Attributes</a></li>
<li><a name="TOC99" href="#SEC99">10.6 Attribute Examples</a></li>
</ul></li>
<li><a name="TOC100" href="#SEC100">11. Constraint Logic Programming over Reals</a>
<ul class="toc">
<li><a name="TOC101" href="#SEC101">11.1 Solver Predicates</a></li>
<li><a name="TOC102" href="#SEC102">11.2 Syntax of the predicate arguments</a></li>
<li><a name="TOC103" href="#SEC103">11.3 Use of unification</a></li>
<li><a name="TOC104" href="#SEC104">11.4 Non-Linear Constraints</a></li>
</ul></li>
<li><a name="TOC105" href="#SEC105">12. CHR: Constraint Handling Rules</a>
<ul class="toc">
<li><a name="TOC106" href="#SEC106">12.1 Introduction</a></li>
<li><a name="TOC107" href="#SEC107">12.2 Syntax and Semantics</a>
<ul class="toc">
<li><a name="TOC108" href="#SEC108">12.2.1 Syntax</a></li>
<li><a name="TOC109" href="#SEC109">12.2.2 Semantics</a>
<ul class="toc">
<li><a name="TOC110" href="#SEC110">Rule Types</a></li>
<li><a name="TOC111" href="#SEC111">Rule Names</a></li>
<li><a name="TOC112" href="#SEC112">Pragmas</a></li>
<li><a name="TOC113" href="#SEC113">Options</a></li>
</ul>
</li>
</ul></li>
<li><a name="TOC114" href="#SEC114">12.3 CHR in YAP Programs</a>
<ul class="toc">
<li><a name="TOC115" href="#SEC115">12.3.1 Embedding in Prolog Programs</a></li>
<li><a name="TOC116" href="#SEC116">12.3.2 Constraint declaration</a></li>
<li><a name="TOC117" href="#SEC117">12.3.3 Compilation</a></li>
</ul></li>
<li><a name="TOC118" href="#SEC118">12.4 Debugging</a>
<ul class="toc">
<li><a name="TOC119" href="#SEC119">12.4.1 Ports</a></li>
<li><a name="TOC120" href="#SEC120">12.4.2 Tracing</a></li>
<li><a name="TOC121" href="#SEC121">12.4.3 CHR Debugging Predicates</a></li>
</ul></li>
<li><a name="TOC122" href="#SEC122">12.5 Examples</a></li>
<li><a name="TOC123" href="#SEC123">12.6 Compatibility with SICStus CHR</a></li>
<li><a name="TOC124" href="#SEC124">12.7 Guidelines</a></li>
</ul></li>
<li><a name="TOC125" href="#SEC125">13. Logtalk</a></li>
<li><a name="TOC126" href="#SEC126">14. Threads</a>
<ul class="toc">
<li><a name="TOC127" href="#SEC127">14.1 Creating and Destroying Prolog Threads</a></li>
<li><a name="TOC128" href="#SEC128">14.2 Monitoring Threads</a></li>
<li><a name="TOC129" href="#SEC129">14.3 Thread communication</a>
<ul class="toc">
<li><a name="TOC130" href="#SEC130">14.3.1 Message Queues</a></li>
<li><a name="TOC131" href="#SEC131">14.3.2 Signalling Threads</a></li>
<li><a name="TOC132" href="#SEC132">14.3.3 Threads and Dynamic Predicates</a></li>
</ul></li>
<li><a name="TOC133" href="#SEC133">14.4 Thread Synchronisation</a></li>
</ul></li>
<li><a name="TOC134" href="#SEC134">15. Parallelism</a></li>
<li><a name="TOC135" href="#SEC135">16. Tabling</a></li>
<li><a name="TOC136" href="#SEC136">17. Tracing at Low Level</a></li>
<li><a name="TOC137" href="#SEC137">18. Profiling the Abstract Machine</a></li>
<li><a name="TOC138" href="#SEC138">19. Debugging</a>
<ul class="toc">
<li><a name="TOC139" href="#SEC139">19.1 Debugging Predicates</a></li>
<li><a name="TOC140" href="#SEC140">19.2 Interacting with the debugger</a></li>
</ul></li>
<li><a name="TOC141" href="#SEC141">20. Indexing</a></li>
<li><a name="TOC142" href="#SEC142">21. C Language interface to YAP</a>
<ul class="toc">
<li><a name="TOC143" href="#SEC143">21.1 Terms</a></li>
<li><a name="TOC144" href="#SEC144">21.2 Unification</a></li>
<li><a name="TOC145" href="#SEC145">21.3 Strings</a></li>
<li><a name="TOC146" href="#SEC146">21.4 Memory Allocation</a></li>
<li><a name="TOC147" href="#SEC147">21.5 Controlling Yap Streams from <code>C</code></a></li>
<li><a name="TOC148" href="#SEC148">21.6 From <code>C</code> back to Prolog</a></li>
<li><a name="TOC149" href="#SEC149">21.7 Writing predicates in C</a></li>
<li><a name="TOC150" href="#SEC150">21.8 Loading Object Files</a></li>
<li><a name="TOC151" href="#SEC151">21.9 Saving and Restoring</a></li>
<li><a name="TOC152" href="#SEC152">21.10 Changes to the C-Interface in Yap4</a></li>
</ul></li>
<li><a name="TOC153" href="#SEC153">22. Using YAP as a Library</a></li>
<li><a name="TOC154" href="#SEC154">23. Compatibility with Other Prolog systems</a>
<ul class="toc">
<li><a name="TOC155" href="#SEC155">23.1 Compatibility with the C-Prolog interpreter</a>
<ul class="toc">
<li><a name="TOC156" href="#SEC156">23.1.1 Major Differences between YAP and C-Prolog.</a></li>
<li><a name="TOC157" href="#SEC157">23.1.2 Yap predicates fully compatible with C-Prolog</a></li>
<li><a name="TOC158" href="#SEC158">23.1.3 Yap predicates not strictly compatible with C-Prolog</a></li>
<li><a name="TOC159" href="#SEC159">23.1.4 Yap predicates not available in C-Prolog</a></li>
<li><a name="TOC160" href="#SEC160">23.1.5 Yap predicates not available in C-Prolog</a></li>
</ul></li>
<li><a name="TOC161" href="#SEC161">23.2 Compatibility with the Quintus and SICStus Prolog systems</a>
<ul class="toc">
<li><a name="TOC162" href="#SEC162">23.2.1 Major Differences between YAP and SICStus Prolog.</a></li>
<li><a name="TOC163" href="#SEC163">23.2.2 Yap predicates fully compatible with SICStus Prolog</a></li>
<li><a name="TOC164" href="#SEC164">23.2.3 Yap predicates not strictly compatible with SICStus Prolog</a></li>
<li><a name="TOC165" href="#SEC165">23.2.4 Yap predicates not available in SICStus Prolog</a></li>
</ul></li>
<li><a name="TOC166" href="#SEC166">23.3 Compatibility with the ISO Prolog standard</a></li>
</ul></li>
<li><a name="TOC167" href="#SEC167">A. Summary of Yap Predefined Operators</a></li>
<li><a name="TOC168" href="#SEC168">Predicate Index</a></li>
<li><a name="TOC169" href="#SEC169">Concept Index</a></li>
</ul>
</div>
<hr size="1">
<a name="SEC_About"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC154" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1>About This Document</h1>
<p>
This document was generated by <em>Ricardo Lopes</em> on <em>April, 17 2006</em> using <a href="http://texi2html.cvshome.org/"><em>texi2html 1.76</em></a>.
</p>
<p>
The buttons in the navigation panels have the following meaning:
</p>
<table border="1">
<tr>
<th> Button </th>
<th> Name </th>
<th> Go to </th>
<th> From 1.2.3 go to</th>
</tr>
<tr>
<td align="center"> [ < ] </td>
<td align="center">Back</td>
<td>previous section in reading order</td>
<td>1.2.2</td>
</tr>
<tr>
<td align="center"> [ > ] </td>
<td align="center">Forward</td>
<td>next section in reading order</td>
<td>1.2.4</td>
</tr>
<tr>
<td align="center"> [ << ] </td>
<td align="center">FastBack</td>
<td>beginning of this chapter or previous chapter</td>
<td>1</td>
</tr>
<tr>
<td align="center"> [ Up ] </td>
<td align="center">Up</td>
<td>up section</td>
<td>1.2</td>
</tr>
<tr>
<td align="center"> [ >> ] </td>
<td align="center">FastForward</td>
<td>next chapter</td>
<td>2</td>
</tr>
<tr>
<td align="center"> [Top] </td>
<td align="center">Top</td>
<td>cover (top) of document</td>
<td> </td>
</tr>
<tr>
<td align="center"> [Contents] </td>
<td align="center">Contents</td>
<td>table of contents</td>
<td> </td>
</tr>
<tr>
<td align="center"> [Index] </td>
<td align="center">Index</td>
<td>index</td>
<td> </td>
</tr>
<tr>
<td align="center"> [ ? ] </td>
<td align="center">About</td>
<td>about (help)</td>
<td> </td>
</tr>
</table>
<p>
where the <strong> Example </strong> assumes that the current position is at <strong> Subsubsection One-Two-Three </strong> of a document of the following structure:
</p>
<ul>
<li> 1. Section One
<ul>
<li>1.1 Subsection One-One
<ul>
<li>...</li>
</ul>
</li>
<li>1.2 Subsection One-Two
<ul>
<li>1.2.1 Subsubsection One-Two-One</li>
<li>1.2.2 Subsubsection One-Two-Two</li>
<li>1.2.3 Subsubsection One-Two-Three
<strong><== Current Position </strong></li>
<li>1.2.4 Subsubsection One-Two-Four</li>
</ul>
</li>
<li>1.3 Subsection One-Three
<ul>
<li>...</li>
</ul>
</li>
<li>1.4 Subsection One-Four</li>
</ul>
</li>
</ul>
<hr size="1">
<p>
<font size="-1">
This document was generated by <em>Ricardo Lopes</em> on <em>April, 17 2006</em> using <a href="http://texi2html.cvshome.org/"><em>texi2html 1.76</em></a>.
</font>
<br>
</p>
</body>
</html>
|