18 1024x768

18 1024x768



ftinctional programming. combined \vith a rich set of high-levcl tools for building synj. bolic dala structures such as predtćaies, frames. nętworks. and objccts. is rcsponsiblc for LISPs popularity in the Al community. USP is widcly uscd as a languagc for implcmcnt-ing Al tools and modcls, particularły in the research community. wherc its high-1evcl func-tionality and rich dcwlopmcnt cmironmcnt make it an ideał languagc for building and testing prototype Systems.

In (his chaptcr we introducc the syntax and semanties of Common LISP, with particu-lar emphosis on the fcalures of the languagc that make it useful for Al programming: the usc of lists to create symbolic data structurcs. and the implemcntation of interpreter* and scareh algorithms to manipulate thesc structurcs. Examplcs of LISP programs that we devcłop in this chaptcr indude scareh engines. panem matchcrs. theorem provers, rak-based expert system shells. semantie nętworks. algorithms for leaming. and objcct-ori-ented simulations. It is not our goal to prosidc a complctc introduclion to LISP: a number of esccllcnt tcxts (see the cpiloguc to this chaptcr) do this in far greater detail ihaa om spiec allows. Instcad. we focus on using LISP to implcmcnt the reprcscntation languagc* and algorithms of artittciai imelligencc programming.

15.1 LISP: A Brief Overview

15.1.1 Symbolic Exprcssions, the Syniactic Basis of LISP

The syntactic elcmcnts of the LISP programming languagc arc symbolic expressions, also known as s-cspnrssions. Both programs and data arc rcpresented as s-exprcssions: an s-cxprcssion mny be cither an atom or a list. LISP aioms arc the basie syntactic units of the languagc and include both numbers and symbols. Symbolic aioms arc composed oflettm. numbers. and the following non-alphanumeric charactcrs:

F.xampłcs of USP aioms indude:

3.1416

100

jK:

hyphenated-name

‘śomo^tobal*

nil

A lisi is a sequencc of cither aioms or other lists scpąrated by blanks and cnclosed in parentheses. Example$ of lists indude:

(1234)

(tom mary John joyce)

(a (bc)(d (•!)))

PART VI / LANOUAGES FOR Al PROBLEM SOLVING

Notę that lists may bc clcmcnts of lists. This nesting may be arbitrarily dccp and alKws u* to crcatc symbol structurcs of any desircd form and complcxity. The empcy list. ”( )". plays a spccial role in the construction and manipulation of LISP data structurcs and is given the spccial namc nil. nil is the only s-cxpression that is considcrcd to be both an atom and a list. Lists arc cxtrcmcly flexiblc tools for constructing rcprcscntational struć-tores. For cxnmplc. we can usc lists to represent cxpressions in the prcdicatc calcu! us:

(on block-1 tablo)

(likos bill X)

(and (likes georgo kata) (likes bill merry))

NVc usc this syntax to represent prcdicatc calculus cxprcssions in the unińcation algo-ritłmt of this chaptcr. The ncxt two cxampies suggest ways in which lists may bc uscd to msptemcnt the data structurcs nccdcd in a databasc Application. Scction 15.1.5 dcscribcs ifae implcmcntation of a si nipie data rctricval system using these representations.

((2467 (lovelac© «da) programmer) (3592 (babbage Charles) computer-designer)) ((key-1 valu©-1) (key-2 valuo-2) (key-3 value-3))

An important fen turę of LISP is its usc of LISP syntax lo represent programs as uell as data. For cxomplc. the lists.

r 79)

(-(♦34) 7)

may be interpreted as arithmetie cxprcssions in a prcfix noćation. This is exactly how LISP trciilS these exprcssions. witla (“ 7 9) represent ing the product of 7 and 9. When LISP is śmokcd on the Computer, the u ser enters an intcractive dialog uc with the LISP interpreter. The interpreter prints a prompt (in the examplcs in this tcxt: >), rcads ehe user input. anempts to evaluatc that input. and. if successful. prints the result. For cxample:

>(•79)

63

>

Herc. the user enters (* 7 9) and the LISP interpreter responds with 63. i.c.. the iu/w asso-ciaicd with that cxprcssion. LISP then prints another prompt and waits for morę user input. This cyclc is known as the ncad-eral-print toop and is the heart of the LISP interpreter.

When givcn a list. the LISP cvaluator attempts to interpret the ftr>t demem of the list « the namc of a function and the rcmaining clcmcnts as its arguments. Thus. the y-espression (f x y) is equivalcnt to the morę traditional mathematical function notataon f(x.y). The value prinicd by LISP is the result of applying the function to its arguments. LISP cxprcssions that mny bc mcaningfully cvaluated arc cattcd Jorms. If the user enters aa cKprcssion that may not be correctly cvaluatcd. LISP prints an error messa gc and allows the user to trące and correct the problem. A sample LISP session appears be Iow;

681


CHAPTER 15/AN INTRCX>UCTlON TO USP


Wyszukiwarka

Podobne podstrony:
18 son volet de programme d echanges d’ćtudiants), the Association of International Educators (NAFSA
Matematyka nr w szkolnym zestawie programów: 18/SP/2014 program: Program nauczania matematyki w kl.
18.    Semantyka języków programowania, 19.    Sieci neuronowe, 20.
Iterativeswitchingcircuits lterative circuits are such combinational circuits that consist of a set
Plan studiów zatwierdzono Uchwałg Rady Wydziału Mechanicznego dnia 18.09.2014 Program kształcenia
Wyjaśnienie: Zadanie 18. (0-2) Fragment wypowiedzi programowej z epoki [...] [Pjaństwo może stworzyć
ex3 4 O i OD JC 119/Change to a jump on carry 0110/-xyy . P=010B 100/ Reset program counrer back to
image002 ‘McAuley [has an] acute ability to get under bis characters’ skins and convey a rich sense
skanuj0176 „A coherent set of actions aimed at gaining a sustainable advantage over competition im
00056 na606836bd6c2f599916ab238e8c554 55 Adaptive Hierarchical Bayesian Kalman Filtering where Yt.i
00084 8a84776b80a82af6fe353d1bf09489 5A Very Simple Set of Process Control Rules*Arnon M. HurwitzS
00085 ?5c54cc53a0b9e32369adfc9c63114c 84Hurwitz & Mathur factors of complexity. On the other ha
00086 s4929f2605de3c43391d910b6633f9d 85 A Very Simple Set of Process Control Rules Cl = (T(l,l,-0O
00088 e23747bf2be5db3f0ee3295fd07ac7 87A Very Simple Set of Process Control Rules Table 3. New &
00090 ?d1d351fe584f51c4e23c939fd54473 89 A Very Simple Set of Process Control Rules ZONĘ SCORE b
00092 ?546ec4ad45fd72a0b658e111513581 91 A Very Simple Set of Process Control Rules Figurę 2 shows

więcej podobnych podstron