verbatim7
<#1250#>not<#1250#> is a special function symbol:
#displaymath2232#
Example: \ \ 3
will succeed with 4.
<#1271#><#1271#>
<#1273#>An Extended Example<#1273#>
We will represent the natural numbers as
Prolog terms:
#tabular1275#
#tabular1280#
[Prolog have numbers, but we ignore them for now.]
<#1289#><#1289#>
<#1291#>Addition Predicate<#1291#>
Want to define <#1293#>sum<#1293#>:
<#1295#>sum(X,Y,Z)<#1295#> holds iff <#1296#>X + Y = Z<#1296#>.
Solution:
verbatim8
<#1300#><#1300#>
<#1302#>An Example<#1302#>
= cmr10 scaled
= cmr10 scaled 2
= cmr10 scaled 4
`@=11
graph@4@unt
graphtemp
`@=12
=<#1434#>to0pt<#1433#><#1432#>=.6ex by 4.158in
<#1417#>to 0pt<#1401#><#1340#>#tex2html_wrap_inline2974# <#1340#><#1401#><#1417#>=.6ex by 5.782in
<#1418#>to 0pt<#1402#><#1341#>#tex2html_wrap_inline2976# Total = s(s(s(s(s(0))))) <#1341#><#1402#><#1418#>=.6ex by 2.988in
<#1419#>to 0pt<#1403#><#1342#>#tex2html_wrap_inline2980# <#1342#><#1403#><#1419#>=.6ex by 2.209in
<#1420#>to 0pt<#1404#><#1343#>#tex2html_wrap_inline2982# <#1343#><#1404#><#1420#>=.6ex by 3.443in
<#1421#>to 0pt<#1405#><#1344#>sum(0,s(s(s(0))),#tex2html_wrap_inline2984#) <#1344#><#1405#><#1421#>=.6ex by 1.689in
<#1422#>to 0pt<#1406#><#1345#>sum(s(0),s(s(s(0))),Z) <#1345#><#1406#><#1422#>=.6ex
<#1423#>to 0pt<#1407#><#1346#>sum(s(s(0)),s(s(s(0))),Total) <#1346#><#1407#><#1423#>=.6ex by 0.78in
<#1424#>to 0pt<#1408#><#1347#>(2) <#1347#><#1408#><#1424#>=.6ex by 5.132in
<#1425#>to 0pt<#1409#><#1348#>success <#1348#><#1409#><#1425#>=.6ex by 2.534in
<#1426#>to 0pt<#1410#><#1369#>(2) <#1369#><#1410#><#1426#>=.6ex by 4.353in
<#1427#>to 0pt<#1411#><#1381#>(1) <#1381#><#1411#><#1427#>=.6ex by 2.599in
<#1428#>to 0pt<#1412#><#1382#>#tex2html_wrap_inline2986# <#1382#><#1412#><#1428#>=.6ex by 1.169in
<#1429#>to 0pt<#1413#><#1383#>Y = s(s(s(0))) <#1383#><#1413#><#1429#>=.6ex by 0.39in
<#1430#>to 0pt<#1414#><#1384#>Total = s(Z) <#1384#><#1414#><#1430#>=.6ex by 0.78in
<#1431#>to 0pt<#1415#><#1385#>X = s(0) <#1385#><#1415#><#1431#><#1432#><#1433#><#1434#>
<#1389#><#1389#>
<#1391#>Another Example<#1391#>
Notation: #tex2html_wrap_inline2994# #tex2html_wrap_inline2996# #tex2html_wrap_inline2998#
= cmr10 scaled
= cmr10 scaled 4
`@=11
graph@4@unt
graphtemp
`@=12
=<#1527#>to0pt<#1526#><#1525#>=.6ex by 4.158in
<#1504#>to 0pt<#1490#><#1436#>No unification possible. <#1436#><#1490#><#1504#>=.6ex by 2.209in
<#1505#>to 0pt<#1491#><#1437#>#tex2html_wrap_inline3000# <#1437#><#1491#><#1505#>=.6ex by 2.989in
<#1518#>to 0pt<#1506#><#1492#>#tex2html_wrap_inline3002# <#1492#><#1506#><#1518#>=.6ex by 2.599in
<#1519#>to 0pt<#1507#><#1493#>#tex2html_wrap_inline3004# <#1493#><#1507#><#1519#>=.6ex by 0.39in
<#1520#>to 0pt<#1508#><#1494#>#tex2html_wrap_inline3006# <#1494#><#1508#><#1520#>=.6ex by 1.169in
<#1521#>to 0pt<#1509#><#1495#>#tex2html_wrap_inline3008# <#1495#><#1509#><#1521#>=.6ex by 5.782in
<#1524#>to 0pt<#1522#><#1510#>#tex2html_wrap_inline3010# <#1496#>sum(#tex2html_wrap_inline3012#)<#1496#> fails <#1510#><#1522#><#1524#>=.6ex by 0.78in
<#1523#>to 0pt<#1511#><#1497#>#tex2html_wrap_inline3014# <#1497#><#1511#><#1523#>=.6ex by 5.133in
<#1512#>to 0pt<#1498#><#1446#>failure <#1446#><#1498#><#1512#>=.6ex by 3.443in
<#1513#>to 0pt<#1499#><#1447#>sum(0,s(s(s(0))),s(s(0))) <#1447#><#1499#><#1513#>=.6ex by 1.689in
<#1514#>to 0pt<#1500#><#1448#>sum(s(0),s(s(s(0))),s(s(s(0)))) <#1448#><#1500#><#1514#>=.6ex
<#1515#>to 0pt<#1501#><#1449#>sum(s(s(0)),s(s(s(0))),s(s(s(s(0))))) <#1449#><#1501#><#1515#>=.6ex by 2.534in
<#1516#>to 0pt<#1502#><#1461#>(2) <#1461#><#1502#><#1516#>=.6ex by 0.78in
<#1517#>to 0pt<#1503#><#1482#>(2) <#1482#><#1503#><#1517#><#1525#><#1526#><#1527#>
<#1486#><#1486#>
<#1488#>Addition as Subtraction<#1488#>
= cmr10 scaled
= cmr10 scaled 4
`@=11
graph@4@unt
graphtemp
`@=12
=<#1604#>to0pt<#1603#><#1602#>=.6ex by 0.78in
<#1586#>to 0pt<#1575#><#1529#>Y = W <#1529#><#1575#><#1586#>=.6ex by 3.508in
<#1601#>to 0pt<#1596#><#1587#>#tex2html_wrap_inline3018# <#1576#>W = #tex2html_wrap_inline3020#<#1576#> <#1587#><#1596#><#1601#>=.6ex by 1.689in
<#1597#>to 0pt<#1588#><#1577#>sum(#tex2html_wrap_inline3022#) <#1577#><#1588#><#1597#>=.6ex
<#1598#>to 0pt<#1589#><#1578#>sum(#tex2html_wrap_inline3024#) <#1578#><#1589#><#1598#>=.6ex by 2.534in
<#1590#>to 0pt<#1579#><#1535#>(1) <#1535#><#1579#><#1590#>=.6ex by 3.508in
<#1591#>to 0pt<#1580#><#1536#>success <#1536#><#1580#><#1591#>=.6ex by 2.599in
<#1599#>to 0pt<#1592#><#1581#>#tex2html_wrap_inline3026# <#1581#><#1592#><#1599#>=.6ex by 1.169in
<#1600#>to 0pt<#1593#><#1582#>#tex2html_wrap_inline3028# <#1582#><#1593#><#1600#>=.6ex by 0.39in
<#1594#>to 0pt<#1583#><#1539#>X = 0 <#1539#><#1583#><#1594#>=.6ex by 0.78in
<#1595#>to 0pt<#1584#><#1560#>(2) <#1560#><#1584#><#1595#><#1602#><#1603#><#1604#>
Similarly, <#1585#>sum(D,#tex2html_wrap_inline3032# \ D =
#tex2html_wrap_inline3036#<#1585#>
#tex2html_wrap_inline3038# can define subtraction via one axiom:
5
<#1568#>diff(X,Y,Z)<#1568#> holds iff X-Y=Z.
<#1571#><#1571#>
<#1573#>Creative Use of Variables<#1573#>
= cmr10
= cmr10 scaled 2
= cmr10 scaled 3
= cmti10 scaled 2
`@=11
graph@4@unt
graphtemp
`@=12
=<#2229#>to0pt<#2228#><#2227#>=.6ex by 3.3in
<#2191#>to 0pt<#2143#><#1606#>#tex2html_wrap_inline3042# <#1606#><#2143#><#2191#>=.6ex by 4.08in
<#2192#>to 0pt<#2144#><#1607#>#tex2html_wrap_inline3044# <#1607#><#2144#><#2192#>=.6ex by 0.3in
<#2193#>to 0pt<#2145#><#1608#>A = s(X) <#1608#><#2145#><#2193#>=.6ex by 1.02in
<#2219#>to 0pt<#2194#><#2146#>#tex2html_wrap_inline3048# <#2146#><#2194#><#2219#>=.6ex by 0.84in
<#2220#>to 0pt<#2195#><#2147#>#tex2html_wrap_inline3050# <#2147#><#2195#><#2220#>=.6ex by 1.5in
<#2196#>to 0pt<#2148#><#1621#>success <#1621#><#2148#><#2196#>=.6ex by 1.74in
<#2221#>to 0pt<#2197#><#2149#>#tex2html_wrap_inline3052# <#2149#><#2197#><#2221#>=.6ex by 2.16in
<#2198#>to 0pt<#2150#><#1623#>X = 0 <#1623#><#2150#><#2198#>=.6ex by 2.4in
<#2222#>to 0pt<#2199#><#2151#>#tex2html_wrap_inline3056# <#2151#><#2199#><#2222#>=.6ex by 3.72in
<#2200#>to 0pt<#2152#><#1626#>#tex2html_wrap_inline3058# <#1626#><#2152#><#2200#>=.6ex by 2.58in
<#2201#>to 0pt<#2153#><#1627#>Z = 0 <#1627#><#2153#><#2201#>=.6ex by 1.86in
<#2202#>to 0pt<#2154#><#1628#>#tex2html_wrap_inline3062# <#1628#><#2154#><#2202#>=.6ex by 0.48in
<#2203#>to 0pt<#2155#><#1630#>(1) <#1630#><#2155#><#2203#>=.6ex by 2.22in
<#2204#>to 0pt<#2156#><#1631#>(2) <#1631#><#2156#><#2204#>=.6ex by 2.22in
<#2205#>to 0pt<#2157#><#1633#>#tex2html_wrap_inline3064# <#1633#><#2157#><#2205#>=.6ex by 1.92in
<#2206#>to 0pt<#2158#><#1635#>(1) <#1635#><#2158#><#2206#>=.6ex by 0.66in
<#2207#>to 0pt<#2159#><#1636#>(2) <#1636#><#2159#><#2207#>=.6ex by 0.66in
<#2208#>to 0pt<#2160#><#1638#>B = Y <#1638#><#2160#><#2208#>=.6ex by 3.3in
<#2223#>to 0pt<#2209#><#2161#>#tex2html_wrap_inline3068# <#2161#><#2209#><#2223#>=.6ex by 2.94in
<#2210#>to 0pt<#2162#><#1669#>success <#1669#><#2162#><#2210#>=.6ex by 3in
<#2211#>to 0pt<#2163#><#1670#>sum(#tex2html_wrap_inline3070#) <#1670#><#2163#><#2211#>=.6ex by 3.9in
<#2212#>to 0pt<#2164#><#1671#>(1) <#1671#><#2164#><#2212#>=.6ex by 4.44in
<#2213#>to 0pt<#2165#><#1672#>success <#1672#><#2165#><#2213#>=.6ex by 4.8in
<#2224#>to 0pt<#2214#><#2166#>#tex2html_wrap_inline3072# <#2166#><#2214#><#2224#>=.6ex
<#2225#>to 0pt<#2215#><#2167#>sum(A,B,#tex2html_wrap_inline3074#) <#2167#><#2215#><#2225#>=.6ex by 1.5in
<#2226#>to 0pt<#2216#><#2168#>sum(X,Y,#tex2html_wrap_inline3076#) <#2168#><#2216#><#2226#><#2227#><#2228#><#2229#>
Similarly, <#2169#>sum(A,B,#tex2html_wrap_inline3078#)<#2169#> succeeds with
#tabular1691#
<#1701#><#1701#>
<#1703#>
Assignment and Arithmetic
<#1703#>
#tabular1705#
<#1710#><#1710#>
<#1712#>
Arithmetic Compare
<#1712#>
Arithmetic Comparisons apply to <#1714#>numbers<#1714#> only.
Use arithmetic comparisons as goals in terms.
#tabular1715#
<#1720#><#1720#>
<#1722#>
Term Comparisons in Prolg<#1722#>
- <#2171#>Term comparisons in Prolog are used to compare and
order <#1725#>terms<#1725#>. Comparisons do not cause variables to
be instantiated.<#2171#>
- <#1726#>Comparison predicates succeeed or fail. No side effects,
substitutions or error conditions.<#1726#>
- <#1727#>Don't use predicates described below when you want
arithmetic comparison or unification.<#1727#>
<#1731#><#1731#>
<#1733#>
Comparison Predicates
<#1733#>
#tabular1735#
<#1740#><#1740#>
<#1742#>
compare predicate
<#1742#>
- <#2172#>compare( <#1746#>Op<#1746#> , <#1747#>T1<#1747#>, <#1748#>T2<#1748#> )<#2172#>
- <#2173#>Succeeds if the result of comparing <#1754#>T1<#1754#> and <#1755#>T2<#1755#> is
<#1756#>Op<#1756#><#2173#>
- <#2174#><#1757#>Op<#1757#> is one of 25<#2174#>
<#1761#><#1761#>
<#1763#>Special Tool: The Cut Symbol ``!''<#1763#>
In general,verbatim9
May have to try <#1766#>Q<#1766#> twice.
Solution: The cut symbol ``!''
verbatim10
Behaviour:- if <#1772#>Q<#1772#> succeeds, then <#1773#>P<#1773#> succeeds if
<#1775#>R<#1775#> and <#1776#>S<#1776#> succeed. <#1777#>T<#1777#> and <#1778#>U<#1778#> will never be
attempted even if <#1779#>R<#1779#> or <#1780#>S<#1780#> cannot be satisfied.
- if <#1782#>Q<#1782#> fails, only then will <#1783#>R<#1783#> and <#1784#>S<#1784#> be
attempted.
<#1788#><#1788#>
<#1790#>More on the Cut<#1790#>
- ``!'' always succeeds; it has the side-effect of committing Prolog to
the current rule and the current set of choices for variable
values. Effectively, the cut creates a that the
system is not allowed to back up beyond.
- <#1794#>e.g.<#1794#>\ 26
Prolog can backtrack as much as its likes in attempting to satisfy
<#1795#>B, C<#1795#> and <#1796#>D<#1796#>, but once <#1797#>D<#1797#> has been satisfied, it may
backtrack beyond the cut. However, it
backtrack over <#1800#>E, F<#1800#> and <#1801#>G<#1801#> as much as it
likes in attempting to satisfy them.
<#1805#><#1805#>
- effectively, the ``!'' indicates that if you get this far, then
you've made the only correct choice, and you succeed or fail with
that choice. You may not back up in this rule, or use any other
rule for the same goal.
- Thus,
verbatim11
behaves like 27 <#1807#>if<#1807#> 28 <#1808#>then<#1808#> 29 <#1809#>else<#1809#> 30
<#1813#><#1813#>
<#1815#>Examples<#1815#>
- The cut is often used with the special term <#1818#>fail<#1818#> (that always
fails) to indicate that a goal cannot be satisfied.
<#1819#>e.g.<#1819#>\ can define <#1820#>not<#1820#> ourselves:verbatim12If <#1823#>G<#1823#> succeeds, the commit to failure;
otherwise succeed.
-
verbatim13
if the first clause succeeds, then on <#1832#>failure<#1832#> (later on),
we know we don't have to <#1833#>examine<#1833#> the rest of the list.
List membership is <#1834#>decided<#1834#> once and for all if we satisfy
the first rule.
<#1838#><#1838#>
<#1840#>Examples<#1840#>
- <#1845#>``Everyone has two parents, except Adam and Eve who have none.''<#1845#>
First attempt:
<#1847#>
verbatim14
<#1847#>
What happened? The last query unified with (3), but not (2) so the cut was
not encountered.
<#1851#><#1851#>
Better Solution:
verbatim15
Note that the order is important: cannot
interchange (1) and (3).
<#1852#>Moral:<#1852#>\ be careful how you use cuts.
verbatim16
Exercise: Rewrite axioms so that it also
returns 31.
<#1858#><#1858#>
<#1860#>Assert, Retract and Abolish<#1860#>
These are special Prolog predicates with side-effect --- they allow clauses
to be added and deleted from the current KB.
- <#1863#>assert(C), asserta(C), assertz(C)<#1863#>
the clause <#1864#>C<#1864#> is added somewhere / at the beginning / at the
end of the KB. - <#1865#>retract C<#1865#>
the first clause in the KB that unifies with <#1866#>C<#1866#> is deleted. - <#1867#>abolish(C,N)<#1867#>
remove all instances of clause <#1868#>C<#1868#> with <#2175#>arity <#1869#>N<#1869#><#2175#>.
<#1870#>abolish<#1870#> is often used to wipe out all
instances of a
temporary variable.
<#1874#><#1874#>
<#1876#>Examples<#1876#>
<#1879#>
verbatim17
<#1879#>
<#2218#>
- 32 wipes out (4), (5).
33 wipes out (1), (2), (3).
<#1884#>[Assuming all axioms are still there:]<#1884#>
- 34 wipes out (1) on the first call, (2) on the
second and (3) on the third.
- 35 wipes out (5).
- 36 wipes out (6) on the first call
and returns <#1886#>Z<#1886#> = <#1887#>harry<#1887#> and <#1888#>Y<#1888#> = <#1889#>true<#1889#>.
On the second call it wipes out (7) and returns
<#1890#>Z<#1890#> = <#1891#>_23<#1891#> and
<#1892#>Y<#1892#> = <#2176#><#1893#>player(_12), player(_6), player(_9)<#1893#>.<#2176#>
<#2218#>
<#1897#><#1897#>
<#1899#>Another Example<#1899#>
<#1901#>
verbatim18
<#1901#>
Note that <#1903#>big(fred)<#1903#> can be satisfied in 6 ways!
So we introduce:
<#1905#>bigamist(X) :- big(X), not(injail(X)),<#1905#>
<#1908#>assert(injail(X)).<#1908#>
<#1909#>
verbatim19
<#1909#>
<#1912#><#1912#>
<#1914#>
Clause
<#1914#>
- <#1918#>clause ( LHS , RHS )<#1918#>
- <#2177#><#1924#>clause<#1924#> searches the Prolog Knowledge Base for
a clause of the form:
\
LHS :- RHS<#2177#> - <#1925#>Relation symbol of LHS must be a constant, but it can contain
other variables (which may get instantiated).<#1925#>
<#1929#><#1929#>
<#1931#>
Clause Example
<#1931#>
verbatim20
<#1935#><#1935#>
<#1937#>
Executing Data
<#1937#>
- <#2178#><#1941#>Term<#1941#> 37 [ <#1942#>Functor<#1942#> 38 <#1943#>Arglist<#1943#> ] <#2178#>
- <#2179#>The 39 operator (pronounced ;SPMquot;univ;SPMquot;) transforms a list into a
<#1949#>functor<#1949#><#2179#>
- <#2180#><#1950#>Term<#1950#> is any prolog term.
<#1951#>Functor<#1951#> is its functor, and
<#1952#>Arglist<#1952#> is its argument list
<#2180#> - <#1953#>40 fails if operands are not properly instantiated<#1953#>
<#1957#><#1957#>
<#1959#>
41 Example<#1959#>
verbatim21
<#1963#><#1963#>
<#1965#>
Improving Efficiency by Helping Functions
<#1965#>
- <#2181#>Compute Fibonacci numbers
Fib(1) <#1968#>=<#1968#> 1
Fib(2) <#1969#>=<#1969#> 1
Fib(N) <#1970#>=<#1970#> Fib(N-1) + Fib(N-2)<#2181#> - <#1971#>Naive Algorithm using Definition<#1971#>
verbatim22
<#1975#><#1975#>
<#1977#>
Naive Fibonnaci Analysis
<#1977#>
- <#1980#>Naive solution wastes effort by repeating
parts of the computation<#1980#>
<#1985#><#1985#>
<#2182#>
Use <#1987#>assert<#1987#> to Save Effort
<#2182#>
- <#1990#>When each Fibonnaci Number is
computed add it as a fact to the knowledge base.<#1990#>
verbatim23
<#1994#><#1994#>
<#2183#>
Using <#1996#>assert<#1996#> to Save Effort
<#2183#>
- <#1999#>For a call of fib(N,F) all Fibonnaci numbers
upto N will become facts in the knowledge base.<#1999#>
- <#2000#>The second recursive call in the definition will
always succeed imediately because its results has been
asserted in the knowledge base by the first recursive call.<#2000#>
<#2005#><#2005#>
<#2007#>
Use Helping Function for Efficiency
<#2007#>
- <#2010#>Avoid recursive computation by computing
Fibonnaci numbers in the forward direction.<#2010#>
verbatim24
<#2015#><#2015#>
<#2017#>A Bigger Example: Sorting<#2017#>
Declarative approach:
42
<#2021#>i.e.<#2021#> <#2022#>Y<#2022#> is the sorted version of <#2023#>X<#2023#> if <#2024#>Y<#2024#> is a
permutation of <#2025#>X<#2025#> and <#2026#>Y<#2026#> is ordered.
<#2027#>permute<#2027#> and <#2028#>ordered<#2028#> are not difficult to
define, but <#2029#>ordered<#2029#> will depend of the type
list element.
However, this is a terrible way to sort.
A list with n elements has n! permutations, and each of them will be
tried until one is found to be ordered.
<#2032#><#2032#>
<#2034#>
Sorting Lists
<#2034#>
- <#2037#>Common Operation for Organizing Data<#2037#>
- <#2038#>Could use builtin list sorting primitives in
Prolog. We'll look at how to do it directly.<#2038#>
- <#2184#>Assume that there is an ordering relation:
Tgt(X,Y)
for whatever data type we want to sort.
Also assume non-empty lists.<#2184#> - <#2040#>Look at several alternatives:
bubble sort
insertion sort
quick sort
<#2040#>
<#2044#><#2044#>
<#2046#>
Basic Bubble Sort
<#2046#>
Algorithm: swap adjacent elements in the list until
all items are in order
verbatim25
<#2050#><#2050#>
<#2052#>
Insertion Sort
<#2052#>
- <#2185#>To sort a non-empty list <#2055#>L = [X|T]<#2055#>
- <#2057#>Sort the tail T of L<#2057#>
- <#2058#>Insert the head X into the sorted tail such that
the resulting list is sorted<#2058#>
<#2185#>
verbatim26
<#2063#><#2063#>
<#2065#>
Quicksort
<#2065#>
To sort a non-empty list L:
- <#2186#>Select some element X from L as a <#2069#>pivot<#2069#><#2186#>
- <#2070#>Split the rest of L into two lists (Small and Big)
such that all elements of L greater than X are in Big and
all the rest are in Small<#2070#>
- <#2071#>Sort Small to obtain SortedSmall
Sort Big to obtain SortedBig<#2071#> - <#2187#>The whole sorted list is the concatenation of
SortedSmall
and <#2072#>[ X | SortedBig ]<#2072#><#2187#>
<#2076#><#2076#>
<#2078#>
Quicksort Algorithm
<#2078#>
verbatim27
<#2082#><#2082#>
<#2084#>
More Efficient List Concatenation
<#2084#>
- <#2087#>Naive list concatenation:
verbatim28
<#2087#> - <#2088#>This is very inefficient when first list is long.
Recurs down first list until it is empty.
Could do better if we could efficiently find end of
first list.<#2088#> - <#2188#>Change representation of lists to represent a list as
a pair of lists.
A <#2089#>Difference List<#2089#> represents a list L and a
difference of two lists L1 and L2, written as L1-L2<#2188#>
<#2093#><#2093#>
<#2095#>
Difference List Example
<#2095#>
verbatim29
<#2099#><#2099#>
<#2101#>
Concatentation of Difference Lists
<#2101#>
verbatim30
<#2105#><#2105#>
<#2107#>
More Efficient Quicksort
Using Difference Lists
<#2107#>
verbatim31
<#2111#><#2111#>
<#2113#>Prolog vs.\ ``Standard'' Procedures<#2113#>
-
verbatim32
Procedural: Try 43.
If that fails, try44. -
<#2189#>
verbatim33
Call <#2123#>p(a)<#2123#>. Assign Y=b then fails.
Reassign Y=c then succeeds.
Can tell Prolog to find another proof.
Reassign Y=d then succeeds.
Try again #tex2html_wrap_inline3110# failure.
<#2189#>
<#2127#><#2127#>
- (in principle)
We can execute a goal in more than one way.
verbatim34
Which body will be executed?
(Prolog's use of DFS makes this deterministic.) -
<#2190#>
- variables can be given values proc.\
call or proc.\ call
- variables need not have or be given values at all, but can
simply be with respect to other variables
via unification.
- can about particular values
that variables must have as long as possible
#tex2html_wrap_inline3112# major strength of Prolog.
<#2190#>