This content was uploaded by our users and we assume good faith they have the permission to share this book. If you own the copyright to this book and it is wrongfully on our website, we offer a simple DMCA procedure to remove your content from our site. Start by pressing the button below!
Vice Prc:oi~pb:tn IN rok of learning as wmchng lhe ruch of the ck!itptr 1010 unknown mnronmmb. and •e show hovo' that role consnainti 11en1 dot&n. (a,'Oring t~plic:it ~;;no\\ I· cdet rtpre\.C:ntation and reasoning.. We treat robocks and' •~tOn not t i mdepenck:nlly defined probktn,. btlt aJ. OC'IG' htlpful >ug<s~iclns. Most helpful ol all 1m
•"*
Preface been Julie Sussman. P.P.A .• who read C\'er)' ch~pter and provided extensive improveztK".niS. In previous editions w~ hOO proo(rcaders who would tell u.o;; wh~n we left out a com ma and said whidr when we me:uu llrM: Julie told us whc.n we le ft out :1 mi1' US sig.n and s:tid .c, when we mcam :r1 • For every typo or confusing explnn:uion that remains in the book. rest assured that
Preface
xi ~skin. Tony ~sscra. Amit P:.uel. Michael P~.zani . Fcma.ndo PereirJ. J oseph Pc.rta. \Vim Pijls.. Ira l)ohl. Martha l)ollock, David l)oole. Bn1ce Poner. Mnlcolm Prndhan ~ Hill Pringle, Lor· mine Prior. Greg Pro\•an. WiUi:un RajX\pon. Oeep:lk Ra\•ichandi".Ul, Joannis RefMidis. Philip Resnik. F'r~ Rossi, Sam Rowcis. Ric-hard Rus..~ll. Jonathnn Sc-h at.~rfcr. Richard Seher!.
Julie h:l!l fixed :n least fi\•e. She 1>erseveted t!\'t-n when a power failure fon.'Cd her 10 wort by
lantem light rather than LCD glow. Stuart would like to thank his J)arems fM their SUJ)pon and eocouragemem ruld his wife. Loy Shc-Oou. for her endk:ss patience and bowld les.~ wisdom. He hopes that Gordon. Lucy. Goorgc. and l s:l.o'IC will soon be reading this book a.fter ti'IC)' haYe forgiven him fM working so long on i.t KUGS (Russell's Unusual Group of Students) h.·we been unusually hc:lpful. :as always. Peter would like to tha nk his p:~rcms (rorsten and Gerda) for gcuing him s1arted, and his wife (Krb:). children (Bella and Juliet). colleagut.·~o:. and friends ror encouraging and 1olcrnting him 1hrough the long hours: of writing and longer hours: of rewriti ng. \Vt> both tll:mk the librarians at Bt-rl:eley. Stanford. and NASA and the developers of Cite-Seer, Wikipcdia, and Coogle, who ha\'e revolutionized the way we do re.._~arch . We can't ;)('.knowledge all the p..-oplt who h.we used the book :.\nd made s ugg is so impor~ana to us. For thousands or rea~. we have tried to ualdrn.tand IN1w wc think: th:u is., how a mcre tw.dful or mauer can pcrcth·c. undrNMWI, pred11:1. and m.a.nipul:uc .a world rar largtr and rnon' complicated thm itself. 1be field or ar1iRdaJ lntdliJtmtt. or AI. goes (unhrt- s1lll: tl auemps noc just 10 ~ bul al..o co OOtid •n~c ll i~ff~t erni1ies. AI is Olllt" of W newest fiekls 1n ~tt'ftC'C and ~ncatnJ.. Woct suncd in c:t.mt'SI soon afitf Wortd War II. and lhe name ibetf "~)- C'Oincd a.n 1956. Along " 'ilh molc'ICul.- bioloay. Airs rqubrfy cited as lhc -Midi \\OUid moM hk 10 ~ Ul.. b)' 5CK':nhs&s in otberdlSC'aphnes.. A quc~en, ;n physM:s miJ!w . . . - . , feelllul olllh< Jood ;dea< ~>a>-. ol=ody bmlul;m b) t'/t/(' •I IIIII t'XII("t/y it iS.. tltis f>eiltg tt
WHAT IS A I? We t.J,·e claimed lh:il AI is C'Aching. but "c h:we 1KM ~a~ " 'hat it is. In Figure I. I we~ dghl defini tions or AI. l:.id Qut alone 1....-o dlnk'n!liOn!l. 1'hr: cktini1ions on 1op are concerned ~ith tl•ought prot:~~Ms and fMj~fi'IJl· "hcfea, the ont( on 1hc: bot-tom address bt'hu~·;or. Tbe defimltonS on the left me:asu~ suooeu an ltmh or fihcd ttS-t I)C'Ovides l'lenty to work on. ·n,c t.-orntJutcr wouk11~d 10 phSCSS the following c:~t,abilitic~":
~lAIICl.II{M
• mtturallanguuge processing to enable it to communic:~te \UCce...~fully i11 E1 lglis.h: • kntw. h.'Cige N"pmtnlation 10 Slott wh111 it t..now., or hcnl'l:
=
•
...c.~ UMflrlfiO
•
~
automnlt.'CI n.>nsoning to use the StOftd information to :Ul\\\'Cf queMions and 10 draw new cone! usians: rna('hlnt' lea mJng 10 adap 10 Ae\\' cirtum.~mct" and to dd«1 and eMrapola1e pauerM.
1.1.3 Thinking rationaiJy: The ';laws of thought'' approach
ththesis th~t perfect r:.uiono the problem and pnwidcs the ;!ppropriate setting for most of the found3tional ma1cri:tl in the field. ChapletS S and 17 deal expficirly with the issue of limited rationality-acting Olte might like.
The Gn."fds. 8«-JtUSC this rul~ out mos• ol ~~~pll~ic$, t i "'~the imC'I'Ic.ion. tot~ ~c.ivism w~ ~popuiJt iQ son~ .:in:k$.
ScIace (1749-1827), and others advrulpatcnt complexity of making rational d~isions. ·n,e pioneering AI I"C'Sresent:rtion. (2) the rtprescn t~tion ili manipulated by cognitive pn.lC(.":SSes 10 deri\'C- new intem al rcpresenlntions. :md (3) these are in tum !\!translated back into action. He ciC!lrly explaint.."art or a secret military projc:e1 at the Univel'$ity or l,cnnsyl,·ania by a team induding John Maudlly and John Ec'ki.'rt. that pro"""(( to be the most inAoential forerunner or modem CQnli)U ICtS. Since that time, e.'ICh generation or com()\lter hardware Ms brought an i nerca..~ in speed and capacity and a detTC.a.se in price. Perrom1;uK"¢ doubled every 18 lncHiths or so until around 2005, when power dissip.rinceton was home 10 another influential figure in AI. John r-.·tcCMhy. Afic:r receiving his PhD ti'IC-1"¢ in 19SI :md working for two )'ear'S a:s illl instructor. McCarthy moved 10 Strut· ford and then 10 Dartmouth College. which was to become the oNicial birtf.lpl:.cc:= of the field. McCarthy con\•inced Minsky. Claude Shannon. and Nathaniel Roches-ter 10 he-lp him bring together U.S. rese:trohers interc.;;ced in automata theory, neuml nets. and ·the: stud)' of intcl· ligshirc. 'l'hc study is to proceed on the ba.sis or the conjecture that e\'CI)' a.;;pcct of learning (1f :Uly Other feature of intelligence C:Ul in principle be so l)f'C(isely de· scrilx-d that a mac-hine can be made to simulate it. An aucmpt will be made to find how 10 make machi1lCS use language. form abSU':'ICiions :~.nd concepcs. solve kinds of problems now rt"$Crved for humans. and impro\•e thcmscl\'eS. We think thalli significant ad\•ance can be made in one or more of these problems if a c.1.tefully sclcctc:d group of scientists work on it together for a summer. There were 10 :mcndces in all, including Trench:1rd More fro m l>rinceton, Anhur Samuel from IBM. and Ray Solomonoff ;uld Olhw Selfridge from MIT. Twtl rese-archers from Carnegie Tech. 11 Allen Newell and Herbert Simon, rather stole the sllOw. Although the othe-rs had ideas and in some cases progr.uns for particular upplications such as chccl.:crs, Newell and Simon already h:td a reasoning program. the Logic 1l!eoris1 ( LT). about w'hich Simon Ioins lhc lcan1ing ICchniques used by Samuel.
The D:uunomh \VOI'irshop did not lead to any IW!W bre:tlnhroughs. bot it did iruroduee
1.3.3 Early enthusiasm, greal expt."Chtlion.s (1952-1969) The early yt:~JS of AI were full of su«essc:s-tn a limite in 19S8. McCanhy published a p.-.per em it led Progmms wit lt Commt)lt St'tl$~. in which he described 1hc Advice Taker, a hypo~heli Cttl progrnm that can be seen as 1hc first complete AI s~tcm. Li.ke the Logic 11K'orb:t ;tnd Gt."'mctry Theorem Pro,•er. McC~uth y's program was designed 10 usc knowledge 10 scareh for solutions to problems. But unlike ttl.! Olhe-rs. it was 10 embody ge-neral knowledge of the world, FOr example. he showed how some simple :utioms would enable the progmm to generate a plan 10 drive to the airport. The progr.un was a lso designed to ;K(epl new axiom.;: in the nonn~l course of oOper.n ion. tiK".reby allowing it 10 achieve eompclenc.'C in new nrca.o; witlrom b>~.•itlg reprogrammed. The Advice Taker thus embodied the centr..\1 principles of knowledge represcntatiOft Olnd ~soni ng : th:at it is useful 10 have a fonnal. explicit n:pn."$Ciltation of the world and its workings and to be able to manipulate that rtpresem:uion with deductive pi'OC~~$. It is retMitkable how much of 1he 19S8 paper n::mai1l$ relcv:~m t od~y. 1958 also marl:t..' d the year thm M:m•in Minsky moved to MIT. His initial collabor.uioo wi1h McCanh)' did n01last. hov.-c:\'ct. McC:~tthy S-lressed rtprcscntation a11d teaSning in for· mal logic. wht.'fCa.;; Minsky wn.~ more interested in getting progr.uns to work and eventually developed a.n anti·logic Quilook. In 1963. McCanhy S~:atted 1he AI lab a1 Stanford. His l)lan to use logic to build the ultimate Advice Take r was ad\':UlCI..'d by J. A. Robinson's discovery in 1965 of the resolution mc1hod (a complete lheorem·proving algori1hm for fi rst"()rder logic: Sl"t Ch;1peer 9). Work at Stanford emphasizc.-d gcneml-purpose m.ethods for logical reasoning. Applications of logic included Cordell Green's question-answering and planning systems (Green. 1969b) and the Shakey robotics J)I'Ojclution~ sum appn:lQ(hr.S ha\'t bctn c:alkd \lof:l.k mt thocb ~-although ~r:al. the) do noc SC3k up 10 targr- or dd6cult pobk,m JMI~ The :aJtt"m:.ti'\Y to v.·~;ak mdhod... '"' to ust ~ ~M'UI. dcmain~ific ~led~ thai ~~~~ btJa' CUS()fting ~lind can INft nstl)' hmdk typically ocnmn.a ~ 1n rY-tro'ft ltC'U ol cxperusc. One m1P ..a) that 10 )()1\'e a lwd problem. )"'U haw: ~ almosll.IM.l'fl the ans:v.n alrndy. 1bt 01 'DIAL progr.un (Buchanan~~ o/.. 1969) \loolthe .. hole .nolll'tvltk
All the rdC'\'W tbeofloi.IUI ~ lotdlf 10 I!Oivt" lht",;e pmbl('f1K b• bcea ~pedO\"er (rom geneDJ (Qfm mlbc )~m prtdit'II<MI ron'Jl'Cl'Mnl) ("'fina rnr.ctpleC) to cflk~mt specul forms ("'cookbook r«tpc,"'). (Fcilnlbaum t'l (1./.• 191 1) tl:i
OltlfltM'IM
C81'Nm UC1CIIII
The significance of 0£NORAL wa"' lh:tt it wa~ the fi,..t sue«ssful J:non·lrdge·illl~nsil ~ sys.· 1cm: its expcnise derivc:d from la'le m1mbe~ of St)C(itt.l·pm'JX)S(' n•les.. Later sys1ems ai"' incorpor.ded Lhe main theme of McCianlly\ Adviee T>.ak(•r aPt>roorh-the ck.an separ:nion of the knowledge (in the fonn or nllt.'S) from the rea~oning C(lfnponem, With Ibis leswn in nti1td. Feittl'nb:wm :1nd oil~~ at Stanford began the l-leuriSliC: Pro· gr.tnuning I:Jroject (HI'I)) to inn~..litpte the cxtcm co which the new methodology or UJ~rt systems could be applied 10 other area" or human expcor1i~. n,e next naajOr effor1 was in the 3rea of mrdic.al dia&oosk Fd&cnl»um. 8~h:u1an. and Or. Edward Shortlitrc dc\·cloped MYCIN to di:a.gnose blood infeCtiON. With about 450 ruiC'~. MYCIN w;as able tO perform :\.'\, well a..o; some expem. and com.ldcr.abl y bener lh;~n JUfliot doctors. It also cootainctt '" o major differmcu from DE., ORAL.. F'tN, unhl.t the- DE., ORAl. Nks.. no gener.allbeoftucal modd existed from "hic-h tht M YC" Nk' could be~ "Tbe) h:ld 10 be xquitul from «.tensi\"C irwcnic•rfioJ o( op:ru.. "hom lutn il((flll~ them from kxtboob. odlc:r ~ and dift'ICI ~perimcc o( cases. S«ond. the Nlo hd &o rtftC'C11he UtKlC'fUin1y associaled v. nh mo:tlCOll J.:nooA·kdgc'. M YCIN ~ a C'aln dus of unttruinly called ttrtainly fadors (see Ch3pccf 14), v."hieh seemed (a11he lll'lW) to fil wC'II v.ith ho-•dociM assessed 1he impact of C'\'iden« on the diagnosis. The imponance ()( dom:un l-00\lo ttdcc \1, ~ al,oo tppat('nt in the area. of Uf'lder,q:m 1.3.8 AI adopts Ihe scientific mel hod (1987-pn:senl) 1.3.6 AI bccomt.'S no indus lry (1980-present) The 11~ succl·~o:sfu l commcrti:al expert system. R I. began opcmtion at the Digital Bquipmcnt Corporation (Mc:Dcnnou. 1932). i1lt progr.un helped cor1tigure Ordtl'$ for new computer systems; by 1986. it w:ts saving the comp3ny :m estimated $40 million a year. By 1988. DEC's AI group h;td 40 expen Sy$1ems deployed. with more 011 the way. DuPont h.1d 100 in usc and 500 in development, saving nn cs.timatcd SIO million a year. Nearly CVCf)' major U.S. corporJtiOfl h::td its own AI group tmd was e ither using or iri\'CStig;uing tJ~.pen S)'Stems. In 1931.th.: J:tp:uKose nnnounccd the ..Fifth Generation.. project. a )().year plan to build intelligent compull."-1'$ running Prolog. In response. the United Sunes formed the MicroeltC· tronics and Computer Technology Corporation (MCC) as a research consortium designt.-d to assure national compelitiveness. In both c.,ses. AI w;'LS pan of a broOO erron. including chip design and human·intcrf3Ct' research. In Britain. the Alvey repon reinstated tlll: funding that wa.ullot!S of ickas. ....-rile~ prognms. 1111lC11hM aSS¢$$ "''hal $CtC'n's t(l be ....'Ortins. BOth l(lprooche$ a~ impon;aftl. A shift tOV."Nd ne:.IJ'ICSS in\plie$ th;at tht field h;as K;achOO a k:-\-botics, computer \•ision. and knowledge n:-presc-nt:uion. t-\ beuer wldel'$tanding of the problems and their complexity propc.·nie~"· com· bincd with i ncrea..~ mathem:uical sophistication, h:.s led to wori:-able rc$Carch agendas and robuSI methods. Although inc-rt:tSed fonn ::aliz.ation and SJX-eiali1'.:.tion k-d fields suc-h as vision and robotic.;; to become somewh:.t ii;olatod from "mainstream" AI in the 1990$. this trend has reversed in n.·tttH years as tools from moc-hine le:t.ming in particul:'lr have proved effcc1ivc for many problems. 1ne proeess of reinlt.-g.r.nion is already yielding signiflc-a.tl be.netits
1.3.9 The emergence ofinteUigent agents (1995-present) Per1taps encour.A.ged by the pR.>gress i11 soh•in_g the subpR.>blcms of AI. researthers have :llso started to look at the "'whole ttgt'nC problem again. 1'he work of Allen Newell. John L:tird. and P.,ul Rose,,bloom on SOAR (Newell. 1990: Laird t'l til.. 1987) is the best·known example of a complete agent arc-h it~"Cturr. One of lhe most impol1:ull i:nvirorunents for intelligent agents is the lntcmet. AI systems have become so common in Wl.'b--bascd applications that the ···bot"' suffix h."'S entered e'·ctyd~y langu~e. MOt\.-'~l\'Cr. AI u:clmolog.ies underlie many
27
The History of Aniliciallnlt."-Uige.nce
Lntemel IOOis. such as searc-h engines. recommender systems. and Web si1c ;aggreg:UOI"$.. One consequence of trying 10 build complete agents is the renli7...'ltion chal the previously isolated subfield$ of A I .night ocOOISI~p to l(anl
Chapter
28
I.
Introduction
Sc label new examples. s~nko ~nd Brill (2001) show that t(!('hniques like this pcrfonn C\ 'Cn better ns th.: nmount of available text ~s from a million words to a biHion and thou the increase in perfonnanee from using more d;ua exeecml.e the llrsc compu1er progr.un 10 defeat 1he world ch:unpion in a chess malch when it bested Garry Kasp.vov by a soorc of 3.5 10 2.5 in M exhibition match (Goodman and Ke\".ne. 1997). KaS)W'O\' said thai he felt a "new ki1KI of intelligence" across 1he board from him. N~wswuk magazine d.:scribcd 1 ~ match as "1'he
now you need to fill in the ma. ?
~
" In ~'Mt•h ~t·r tlisnus tmn'lflllmtms,
Ch:ij)t~·r I
l ilt• tw ttlrt'
of a.lt'llts, J"'rfrct "' otltrrwlu. th~ tlkersity of
mul lite resulti11g ,,.,wg;:rle (II fl/lf'"' I)J)t',J.
idemifk-d the ~ C'tntr.tl to o ur appro3Ch 10
Flxurt 2.1 artifiCial
imclli,cnt.~. In this chapter. o,~,·e m.al:e this notion more COilCrttc. We wdl !I('(' th:tl the concq>t of rJIIOnalily can b( appliM to a wide varidy of 21~11 ' 01,.,.rruina in any imag_inabk environ· nlt'nl. Our pl:vt 1.n thit: book is to u..;;e this Ciontq)l to Se-,nfiRIIe.
U)
fm. unkss we place a bound on the
kf11:lh of percept sequences .... C' ~•• to C'on•..cltr. Ot\'Cfl an l&ff'l to a:perimern ~ilh. ~e nn. m pnnc'lpk:. COOSUUC'I lhts lablt by lt)I"S OUI all ~l biC' pt:rt"'C'p( SCCfiJC':IliCeS and rt't'OtdlftS. •1ucil anions the ~· does ln rtifiO'bC'. 1 '1llr lrognun chat imJ,km cnh i1 #IPI>Clii'S iJ\ Figure 2.8 on pa;ge 48. Looking a1 Fi,gu~ 2.3. we~ th:at \'llriOU!> ' 'X'uum-world agents can be: defined simply by fi UUtg in lhe right~hand column in "'ariou• war~. 1be ofwious questton. then. is this: Whm is 1M riglu k'O)' 10 fill ou1 tilt- rablt'! In ocher ~·on:b•• 'oltflal rn.ttcs an agr:n1 good or b3d. in~elliltnt or srupid? We ans....u lht •n the nt\t section.
.n-. ..
t lf . . . . . ~I IOdlocMot ... WC' .....w lww .. .,acta~..., .._.,. '*-1)- ,......,. of ad!.--. Ow . . . . . . . . . . . . it Qda Qll). - •Y ... t.tt. 6itdwpc:r ... Ill (M k ''"'Y .-dll. . I
,
....
act111if,.,..,..,
Chapccr 2.
36
A.dQ Of5oa
37
Good Behavior. The Concept of Rationality
IL'IS perfonned well. This: no1ion of ~i r,.,bility is: esp1ured by :'1
ooo
Right Sllck
w(miS in lire cm •hrmmt'lll. mrl~t•r rlum
A \';•euum -dcMc r wqrlc,l with jul!l two lc::trion§,
Pt'fttpl sequence
Action
!A. CitY.HI)
R move the ercepc sequence: the ris.k of ;)(Xidem from crossing withoot looking i..« too great. Second. a mtional agent should choose the ''looking" oction before stepping imo the s_,ccc. because looking I'ICips m.'l,Ximi7.C the C>:J>oetcd j:>erfom1ancc. Doing actions ;, t~rder w modify fimm~ prrrrpts-somctimes calll-d infonnution gullu:ring- is an imponant pMt of r:uionality and is CQ\'cred in depth in Chaj>ter 16. A SC\.'Qnd example of inf()mtati()n gathering is provided by the uplomli()n that must be undenakcn by a \':te'UUm-deaning agent in an initially unknown environment Ourdcfiniti()n requires a rnti on:~J agent n01 Qnly to gather infom1ation but also to leant a:t much a.« possible from what it J:>ertei\"CS, TI\C agent':t initial Vides anim:lls with er.ough built-in rtilexes to survi\'e IMg er1ough to le.,m for thint out. before the reader beron'feS: :~lanr)('d. th:n a fully autom:ued taxi is currently somewhat beyond 1hc capabili1ics of existing technology. (page 28 describes an existing driving roboc.) Tin~ full dri,•ing_ task is eKtrtmely QPC'II~udt·d. 11.ere is no limit to the no\'cl combin:uions of cin:um..;tances thm can arise--another ~a..eiU' in Exercise 2.4. ll1nay conle as~ surprise to SOn\C read· ers thai our list of :.gent ty~s ineludcs some progrnm.OSS-iblc. In COIIIr.l.t>t. some sol"'wnrt SJel.'n lS (or software robot..« or sof1bots) c.xLt>t in rich. un limired domains. Imagine a soflbol Web site opcra10r designed 10 scan Interne• news sources :tnd show the interesting items to its users. while selling advenising space to gt'lte-mte re\·enue. To do well. that oper:ttor will nt."td some naturnl I:Uiguage pi'OCC$sing abilities. it will need 10 !c-am what each user and ndvc:l1iscr is interested in, :111d il will n!X'd t., change its plans dyn:unieally- fOr example. wf'K"n the cormec1ion for one news sou.rc:e gOC".s down or \vi'IC.n a new one comes online. Tb: lntcmcl is an environment whose complcxit)' rivals that of 1b: 1))1)'$iC-al world ~nd \vltOSe inhabitanls include many ~n ifi c-ial :u'ld human lg Scc1ion 2.3.
45
The Nature of &wironments Task Environment
Observ~bk
Crosswotd puule Chcs.." with a clock
fully fully
t\gcnt.s Dctenninistic Episodic
St:uic
Oiscrtte
Sins le Oecennitlistic St(t\lential Multi Oete:nninistic Stqucn1ial
Stllli< So:mi
Oiscrctt Oiscrett
Sialic
OiKrete
Statie
Oisctttt
Poker Backgammon
P'Jiti:llly Fully
Multi Multi
StochJStic Stochastic
Seque.nliJI Scquenti2l
T.-xi driving Medkill diagno!li.s
P'.uti:dly P',utially
Multi Singk
St cxh~~ ic
Sectue-ntial Dynamk Cootinw11~ Sec1ucntial Oyn;unic Contin...o1.11 anicular C.'ISC but might l'l()t identify a good design for drh,ing in genctal. For this
Chapccr 2.
46
Intelligent Agen~
reason. the ry.
THE STRUCTURE OF AGENTS
I(.(J(f~ ~
So f:~r we h:we talk'-"(! about :•gents by describing bt'lun·i(Jr- the ;K:tion thts. Now we must bit!!' 1he bullet and talk :~bout how the insides work. TI.c job of Al is to design an agt.•nt pi"()J:tram that implcmc:-nts the agent funrtd:i" g then initimt>·lmlld11g.
I Iuman ~ "lso h:we many such connections. so•ne of which are lcuml"~alc of the ....'Orld. using 311 i.m('mal model. It then choo~s an .-ction in the same way as 1hc ~flex :agent.
is re,;;ponsible for crtating the new iJJtc-n'id state di:~""Cript ion. The dt."-laits of how models and !51:tles are represented vary widely depending On the type of en.,.ironmt.'ltt and the panicuhlf tech no!~)' used in Ihe agent design. l)ctailed cx.runplcs of modds ;u)lj upd:tling algorithms appc-arin Chaptc-r&4. 12.1 1. 15. 17.:md25. Regardless of 1he kind of representation used. il is seldom possible for the agcn1 to de1em1ine the current stale of a partiall)' observable tnvironmenl l'XtKIIy. lns1ead. lh the t:.t.' mic,ht t~l.e and concludes - some more expeditious mrthod 5ttms desirable.- Tk mdhod he ~ i( to t"uld ~.uning machines and then to text. ehem. In l'n3n)' ~ of AJ. thl,. i.), """' the pttfemd n~thod fc.w ClnliQg swe-of·tht--.an S)'S&tmS. ~ tw ~r ach'"NIIa~t"• .._, ••e not.cd earbtr. i1 alto-·s the~ 10 opt'Dlt' m u.I.Wiy unknot4'11 tn\"lrot'lmeniS and to bc'c-k fron1 the critic on how the "'S-CIII io; doing "''d deeennines how the pcrfonnance element should be modified eo do bcner in the future. 11'e design of the teaming eleme11t depcnch ver)' much on ehe design of the perfonnance dcmem. When trying eo cksis n ru' l~J;C'nt !hat kan~J a t."t:rtain c:1pabili1y. the first quc..seion is riOI"I-Iow ~11 going to gee il to team thi,1" OOe" \Vhae kindofpedonnaneeelen-.nu ...,ill my agenl nero 10 do this OOC'C i1ha~ learned how?'' Ghm an agent design. learning mechrulisms ean be ron.~ed eo impro\'e e''tl')' part of the a&e••· Till: critic tells 1M leount.nJ element how ~ell !.he agent is domg with resprcc1o a fiud p::tfotnWlCC ~. The critic' i~ ~ b«~use the perttpcS tbemseh-es P'O\ ide no mdllc.llion of tbC' agt"nl·s SUC't't'SS.. Fot eumplt. a C'heS) pm;nm coukl f'tt"ci,~ a perttp md.talln, lhal it has cbc.rl:nwtd 1.ts orpoac-1'11. bu1 11 ne-eds a pn(CifllWI« suncbrd 10 know tlw this is :a IOOd ~ lht pc1'CC'JlC tbC'If Q)' '10. Ita' lm~ th:u the perf~
2.4.6 IA::itrning agents We ha'-e delcnbcd asmt programs v.ith \'MlOUS mtehock (cw \Ck-atn,g .-tMJOS. WC Jla\·e noc. ~ r... C'\pbtnrd how l.br agent procnms NI'W lltiD In hu (;I[IJ(JW. carly paptt. "'"''nn1 (19SO) ~the idea ofacnWI) pcogr.vnnuns h.1' ltlklh~t madunes by hand.
....... blot·
~J
"':s. = a
"a ;;
A~1U'*"'
Agen1
•.l jtU~ 2. 14 A tl'lodel·b:tSl-d, utili t y · N~I liJt:l\1, II u-.e11 a model of t l~ world. ~k>n& with It \lltlhy fu.nc:llo" !hat n.r:a:,(Uf't'!l il.s t)rtf~telkC'\ ani()I1.J ..-u.ttll of the ~orld. 1'htn it thoost:ll l~
OUironlt. (Appt'IKtit: A define$ expectation more prtti.!otl)'.) In C'haP'et" 16. w-e show that all)' DIJOI\IJ q,ml must bdm:c- as ijit posses.s;es a Ullht')' funn.on v.tlooo;e Upx1cd \ '.IIUC' 11 tries lO mannuu. An q.rnt tml possc:s.ses an aplie'it uhllt)' funn.on c.an mal.C" r.II.KliO.II drcuions V.tth a ~ntral·purpciiSC: ~dn tha doe$ ROC dC'pmd Oft the 'fU'Ifir UIIIIC)' funaiof'l being maxamllt'd. In thiS ·~y. the defuu110n ol ntiOft;lhl)~l.&f'llm& as mbomllhoscllft'l funneon:s th mic,ht t~l.e and concludes - some more expeditious mrthod 5ttms desirable.- Tk mdhod he ~ i( to t"uld ~.uning machines and then to text. ehem. In l'n3n)' ~ of AJ. thl,. i.), """' the pttfemd n~thod fc.w ClnliQg swe-of·tht--.an S)'S&tmS. ~ tw ~r ach'"NIIa~t"• .._, ••e not.cd earbtr. i1 alto-·s the~ 10 opt'Dlt' m u.I.Wiy unknot4'11 tn\"lrot'lmeniS and to bc'c-k fron1 the critic on how the "'S-CIII io; doing "''d deeennines how the pcrfonnance element should be modified eo do bcner in the future. 11'e design of the teaming eleme11t depcnch ver)' much on ehe design of the perfonnance dcmem. When trying eo cksis n ru' l~J;C'nt !hat kan~J a t."t:rtain c:1pabili1y. the first quc..seion is riOI"I-Iow ~11 going to gee il to team thi,1" OOe" \Vhae kindofpedonnaneeelen-.nu ...,ill my agenl nero 10 do this OOC'C i1ha~ learned how?'' Ghm an agent design. learning mechrulisms ean be ron.~ed eo impro\'e e''tl')' part of the a&e••· Till: critic tells 1M leount.nJ element how ~ell !.he agent is domg with resprcc1o a fiud p::tfotnWlCC ~. The critic' i~ ~ b«~use the perttpcS tbemseh-es P'O\ ide no mdllc.llion of tbC' agt"nl·s SUC't't'SS.. Fot eumplt. a C'heS) pm;nm coukl f'tt"ci,~ a perttp md.talln, lhal it has cbc.rl:nwtd 1.ts orpoac-1'11. bu1 11 ne-eds a pn(CifllWI« suncbrd 10 know tlw this is :a IOOd ~ lht pc1'CC'JlC tbC'If Q)' '10. Ita' lm~ th:u the perf~
'*'not
58
Chapccr 2.
Intelligent Agen~
underlying stan:h and gam e-plen t acts so rogram. rationality. autonomy. n:tkx agent. modcl-basc:d ag"'nl. goal-b;cs(:d agent. utility-base-d agent. lea.ming agcm. 2.5
2.6 This cxc-ocL.;e e-x p ion·~" the differeoc.:ts bctw. The following exercises all ooncem the illlJ)Iement:uion of enviroomcms Md agents for the "'Culun·cleancr world.
Show your resuiiS. d. Can a reflex agent wilh .s1atc OUIJX.--rfonn a simple rellcx agent? De-.sign suc:h an agent
and measure its I)CI'fonn:ulCe on SC\'Cf';.ll e•wironments. Can )"'U dcsi£ 11 a rntion:li agent or this type? 2.12 Repeat Exercise 2.1 1 for the case in whic-h the location sensor i.." replactd wilh a ..bump" se-nsor that detetc.s the ag~-n t'.s auemp~.s to mo"e into ;m obstacle or 10 cross the boundaries of the- environment. Suppose 1he bump sensor stops working; how should 1he agent be.have? 2. 13 The V:tetJum environments in the- prec-eding exe-rcise-s have all ~~~ dc-lemlinistic-. Dis:· cuSS: possible agent programs for eac-h of the folloYo·ing stoch:.stie \·ers.ions-: "'· Murpl1y's law: tweiUy-five percent ofahe time. the Suck action fails 1.0 clean the floor if it is diny :Uld deposits dirt onto Lhe lloor iflhc fl oor is cleoo. How i.-. y·our agt"nt prognun aff«1ed if the dirt sensot g_ive.s lhe \\'TQ"-8 answer 10% of the tinle'? b. Small children: AI cac:h tim"' step. cac:-h c-lean square has a 10% chance of becoming diny. Can you come up with a rotional agent dcs.ign for this c:~se:?
S«tton 3. 1.
3
SOLVING PROBLEMS BY SEARCHING
/11 wllirh Wt' St'f' lrt}W on agmt am find a :1-t"qucl~t' tif llt'IIQnS tlttll tlt'hin't's its J:tJtil,f whtll no slr~glt- (Jl'tlon will do.
-
The ,.imple..l a.gcnb di)o(.:ussed in Ch-:tpter 2 wett the n:llu a_gent.;, wl1ic:h b:be their octions on a direct m~ppina (l'(lm st.'ltC$10 oct ions.. Such ageniS cann04 opcr!Ut well in cnviR)nments for ~·h•ch thi" m)ppi••g \lf'Ould be too laf8e to s1cn and ~oukl c;a~e too Ions 10 kam. (ioal·b:lsN lli&C:nh, on 1~ oche-r h;lnd. consider fu1un: :.c1ions and lhe dc"ir.~balaty of thdr ouk'omcs.
. . . . . b.*CI
3.1
Th•" f'hapccr deia'ibes one k:ind o( pl·ba.scd apl c:aUC'd a pn)l)lf1lt·S4lhing agt:nL
Prob&mt·M>hing agenb u.se alom.k repcumtation:s. as dc"'nbtd in S«tioo 2.4..7-ctw is. SUIC' of the- \\ot&d ~considered as whoks. with no trUrnal ~lure \l'(lbk to the p:obk:m"'O true for
ruwig:uing in Romania because each city is connected 10 a small number of 01hcr eilits. We will a. suffices 10 meet this c<mditiOrl f()( rla\•ig:uion problems..) Firul.lly. we a.o;swne th~nd nOI the 3 This :tSSumpioo i.s :alpilhmic-~l )'«lff''(fliftll bul :also thcor«i~ly juS~ili~o--sc-e ~ 64? in~« 17.
• 'The inl(ltK\I!lionS of ncs~l.~'¢ CO$!$ arc U.f!klrcd in ~Ki~ J..S.
3 .2
EXAMPLE PROBLEMS
1llC problem-solving ti.J>proac.h has bei"1l :J.J>plied to a vast arr:t)' of task e nvironmc.niS. We liS! some of the best known here. distinguishing between IO)' nnd rt!itl·w.orld problem..o;. A toy problem is intended to iUustrate or exereise V:\lious problcm·solving •ntthods. It can be given a concise. exoct dcscripcion and hence is us:Lble by difl'erenl n.~;;ean:her.s tocomp:u\' the p:p.-.:lt.-d efirtcs. c.xctpt thm moving Uft in chc: leflmost square. mo\•ing Right in the rightmost squ:uc, and Sttcking in a clean square h.a"e no effect. The oompkte state Sp.'l(;e is show·n in Figure 3.3. 1l •
• Goallt.'SI: This checks whether all the squares are dean. • P-..th cosl: E.1ch step costs I. so the path rosa is the number or stc~ in the path. COillJ).'ll\.--d with the real wortd. this tO)' problem has discrete locations. discrete din. reliable ckMing. and it llCVt.' r gelS any d irtier. Chapcer 4 n-la;(t.•s some or these as:mmptions. The 8·1>uu le. an inSt.-nce or which is shown in Figute 3.4. CO•lsists or a 3x3 OO:ud with dght numbcn."d tiles tuld a blank sp..lce. A tile adjacent to the bl:utk sp..lce c:ut slide into the sp.'lce. 11)C object is 10 te:u:h a St>eeified goal s:tate. sud• as the one shown on the right or the figure. The standard romlulation is as follows:
GJ 0 000 0
[2] ~
(;o;1l State
A typical in!>lancc o( the 8--pu-r.~k.
• St.ates: A st:ue deseription :>pccifies the location or each of the eig.lu tiles and 1hc blank in one of the nine squares. • Initial state: Any l!l:lh! can be designated as the ini t i :~l ~t me . Note th:;\t any gi\'en go.11 can be reached from ex:~ctl)' h.'llf of the possible initi:'tl states (Exc:n:"i.~ 3.4). • Actions: The simplest fommlation defines the actions as movements or lllC blank space U:ft. Right. Up. or Down, Different subsets of these :U'e possible depending on w'llCre the blank is. • lran.ible.) • Path cosl: Each step t.-osts I. so lhe path cost is the number of steps i n the path. What abstrJCtions ha\'e v.-e includl-d ht.·re? The action." are abtstraOSitive intet:,ttr. Fijtu rt 3.5
Ahnos12 solu1ion
t () lhc $.queens pr(lbleltL
(Solution islcfl
!1$ :111 nercl~ .)
;\hhough eflicient spc.xi:d·pui'JX)Se algorithms exist for lhis J)I'Oblem and for the whole Jl·quecns family. it remains a useful teSI J)tOblem for searth algorithms.. 1bere are two m:Lin kinds of fonnulation. An increme ntal formulation involves opcrntors that lm.~m~llllhc st:lte dle algorithm th:u soh-es even the million-queens problem with ea.-.c.
To our knowledge there is no bound on how large n number might be con.stmctcd in the process of rtt~rncticaJ algre juililioo by 1ho cos• ond likelihOOo originol plan.
is protein design. in which the goal is to find a sequence of amino ~eids tJt:.u \ViU rold imo !I
Touring problem.. arc closely rcl:m."d to roUic-·finding problem s. bot with an impor· 1an1difference. Consider. for example. the problem " Visit C\'CI')' city in Figure 3.2 :u k::asl one."rimarily according to how they choose which state to expand ne:xt-thc so-calk'd Sl..~tn-h ~"'rJt cttv. 11'e eagle-<m:: complexity is O(b''). i.e.. it is dominated by the size of the fro11tier. Switching ton IRX' ~arch would not s:t\'e much space. and in a state sp.'lCe with many redundant paths. switching couk1 cos1:r~gre.;u deal of time. An exponential complexity bound such as O(b'1) is scary. Figure 3.13 sho\VS why. It ilrst sean:h with branching f:K1or b = 10. ·n1e mblc ns..~umes that I million nodes can be genet"Jte b suctts..c;ors. The root of the seai'Ch ttee genet.ues b nodes 3t the fi rst level. each of which genei"Jtes b mon: nodes. for a total of b2 at the st•cond It-vel. E.uch of tht>.fe gencr.ttt'S b more nodc.'S. yielding t} nOOes m the third level, and so on. Now suppose that the solution is :'It depth d. In the woot ca..o;c. it is the la..'>t node gencmted at that le\'el. Then the tOial number of nodes gt'ltcraK'd is
b + b2 + b3 + · · · +b' = O(b'). (If the algorithm were to :1pply the goal test to nock.s when t-J:Iec:ted fO£ cxp:u1sion. rather th<m when generated, the whole layer of nodes at depth d would be cxp."'nded before the gool w01s detectt.-d and the timet.-omplexity would be O(tl+ 1).) As for SpGCC complexity: for any kind of gmph scarch, which stores e\'cry expanded node in the e.rplorol set. tilt space complexity is alway5 within a factor of b of the time complexity. For bre:.dth·first grnph ~arch in particular. every node generntcd remains in memory. TI)Crt will be 0(11'- 1) nCk.s in the ezplorttl sc.t :.lnd 0 (11) nodes in the frontier.
110
1011
Time
M.cmory
. II milliseconds I I milliset."()nds 1.1 seconds
107 l:ilobytes I0.6 tm-gab)1« I g igabyte 103 g igaby1es I0 ICnlb)'tCS I pctnb)'IC 99 pctabyte..~ 10 exabytes
2
min ute-~
3 hours 13 da)'S 3.5 ye-ars 3SO years
figureJ.I3 Time :tnd m~·mOf)' n:quirtments for bread:th-fir:u scatth. The numlx'rsW<won ~,&5-Stl mc br.mthing (~tor b • 10: I million nod~ond; 1000 byt.:-.slnodc. 1\l.·o lessons can be lcamed ftonl Figute 3.13. Firse.
tilt.' m~mlU)' rYQll irtm ems orf! t•
bigga pmbll'm ftJr l~retulth.first seardt tltall is tire l'..'Ct'Cidioll timt•. One 1n ig.ht wait 13 days
for the sohuion 10 an im))()lttant problem with search depth 12. bt.n no personal COOl)>u~er h~,as the pl"'ab)•te of memory it would take. fortunate!)'. other strategies require less ntcmory. 1l1e second lcs....~n is 1h.:u 1ime is s.1ill a major f:ac1or. If your problem has a solution m depth 16. then (gi\•en our ;I$Sumptions) it willt~lke about 3SO rc;m; for breadth-fi rst search (or indeed :Ul)' uninformed search) 10 find it. I n gcnernl. UfiOIIemhJI·romple.ril)• s~ardt probln11S t·amtot ht' sol\'t'il by tmilifonlled methods for (Ill)' lmtlhe smallest iusttmcts..
3.4.2
Unirorm-cost search
When all step costs arc cqu:tl. brc-adth·tlrs..t search is optimal because it always expands the slwllowtst unexpandtd node. By a simple extension. we ean find an algorithm th:\t is op1im:d
•' l j:un: 3.12 ~xp:uldcd ne.xt
Brc-:'ldth·fitst U:mh on a
i,s indic-:ned by a marker.
simple bi.n:'U'Y tr«. At each stag-e. the node 10 bt
with any step othet significant differences from breudlh·firsl search. 1'hc first is lh:tt the go.'l test is npplk'd loa node when it is st:l«ted for e~1Hu•sitm (as in the genetic gr.tph·scarch algOtithm sh()Wn in Figure 3. 7) r:uher 1h3n when i1 is fi rst ge••erau.xl. T1le reason is thal lht fi rs1 goal node thai i.s gt•ttemtt:il
Solving Problems by Sc:ttthing
84
function U~tFO Ut -COST·S 6A RCII(problem) rtturns \11 $01Ution. or (;~il ure rWJI': -
frtmtler" - a priotily ql.tt'ue ordcrcd b)' PA1'H·COST. with r1ode as:: the only c lc·m~:nl
npltn"ttl ,_ nn tmpt~· !i:l'C loop do if E~H'TY'!(ftmt.t,cr) t ht-n rteun1 f:ailurc node- P OP(/t'Qrllit:r) r chooses the IO\Io~H:ot~t node in frrmlicr •t if pt'Qblrm. GOA~· 1'£sT(nodc.STATE) lht n r e-tum Sot.UTIOS(n(N/e) add n00c.STATE I Q c:zr,/qn:J
for c:u:h t.~~tion in pn)blcm.ACTIOSS(nodc.STAU) d() cluld - CHIU)· NOI>f.(prvblcm, nQt/t',(l(;lion) i.r rluld.STA1'€ illllOI in 47plort:rl or /ronllcr th...-n /rontu~r- ISSERT(cl!ild,/rtmtu•r·) tlsc if duld.STAT€ is in jrontter with hiJhtr PATtt·COST t hen rcplace 1h.11 fnmLit'T nod~ with r:/uld
f'igurt' 3. 14 UnifomH0$.1 $Cnt(h on a grnph. 'The algorithm is idcntic.al to the ~nernl graph ~arth algorithm in Figure 3.7, CXC~,~,·er cost: thus unifoml•COSt search -c:tocs 5'tictly more wori; by expanding noitcs.ti forexp:tnsioo :md addiog a second path
The progress of 1hc search is illusmucd in Figure 3. 16. The search pi"()C'('eds immediately to the dl"(! JC:', so why do we include it? Tile rca...~n is the space complcxi1y. F« a gt:lph se:areh. there is
•'i jtu ~ 3.16 Oepth,first ~areh on a birt:tf)' m~c. The unexplored region i.s shown in light grny. Explored oodcs with no dtsccndants in the frontier fl~ rtmO\'cd from m('mory. Nodes :u depth 3 have no .sucttl>l\01'1' and M is 1hc onl)• goal node.
no advantage. but :t depth-tiM u-ce search IK'Cds to s1orc only a single path from lhe root. to a leaf node, along: with 1he: remaining une:xp:tndcd sibling nodes for each node oo the p;llh. Once a node ha.o; b.-cn expanded. it can be removed from mc.·mory as soon as all its descendants have been fully explored. (Sec Figure 3. 16.) For a st:ne sp:K"C with bmnching: fac1or band maximum dc.p1h m, dcpch·lirst search n.'(Juires &torsge or on ly O(bm) nodes.. Using the same a..::swnp.:ions as fOf Pigure 3.13 and :1$.."uming that nodes at the same depth ru> the goal node have no successors. we lind that dcpth·lirst search would rc(1uire 156 kilobytes instead of 10 exabyU.".S at depth d • l6. a fat1or of 7 1rillion times less sp:•ce. This has Jed to Ihe adoption of d.::pth·l'irst tree search as 1hc basic workhorse of rnany :ucas of AI, including acts because it will e\·cntually eXJ)and every node.
3.4.4 Depth-limited search
The trcc-sc:ul:h \'ersion, on the other httnd. is nm complete-for example, in Figure 3.6 Ihe
The emba~T:~...~ing failu re or dcJ>Ih·tirst search in inllnile state s-p.."'ces can be alle\•iatcd by supplying dcpth·fii'Sl se.a.rc.h with a pn."detcmlin" • IIIli( "
Yes" 4
O(IJ')
O(IJ'"J
O(bd)
OW'11)
YtX'ta t:rorit
This S«tion shows how ~m informed seolreh S:tl'ategy-one thai uses problem•:Spceific knowl-
Rlmnl in tum gcnemte.o; Buchn.rest. which is the goal. For this panicular l)t()blcm. g.n:edy best·tln;.t search using IISLD finds ~ solution without ever
0
Hlrso,·a l_.. ugoj
implcmcmation of bcs•· fi rst graph search is identical 10 th:u for uniformst SC3n:h (Fig· ure 3.14). cxc.-cpt for the use off instead of g to order the priority queue. The choice or f dctemtincs 1he scttn:h smucgy. (For example. as Exercise 3.2 1 shows. best-ti~t tree search irlC-ludcs depch.first sc3tth a_;: a sp«ial cas~.) Most best-tir!l algorithms include as a component off :1 heuristic function. dcn01ed h(n ):
366
93
3.5.2 A• search:
.. """'
M ir1im i1~ng
the totalt."Stimatcd solution cost
'The mO.."t widely known fonn of bt.'$'1-fir.o;t sc:uth is t:alled A" se-arch (pronounced "A·.!itar St"!'lrch''). It evaluates nodes by combining g (n), the cost to reach rhc node, and li{n), rtw= cost to !WI from the rloOde to the goal: / ( " ) = 9(" ) + lo(n) . Since g( 11) gives the path cOOt from the Slllit riiOde to node n. and !1(11) is the estimated cost of the cheapest p:tth from n to che go:1l. we have
/ (11)
= estirn;ued cost of the chc.aJ)(:.St solution through 11 •
Thus. ir we nrc trying to tind the du~apc.•.st solurion. a reasonable thing to try first is the node with the lowest ''alue of 9 ( 11) + h(u). lt tunlS OUI Ih;~.t this str:ueg)' is more th:ln just re.nsonable: provi ht>uristic. An art this subcl\.--e while still g,u arnnl ~ing optimality. 11le concept of pruning-diminating, pos.o;ibilities from consiWcm. node. Qt:tior•) imo $t.IC«.UOr$ if $ll~$$()f':'i i.scn1p1y Uten n:luna /ailurr;. 00 f(l r e-:~eh $ in $1'1('(1'.~~0~ d(l ,. uprithm. 1bc main difference bct\l.'ttn IDA" and Sl:tndatd iter:uive decpenillg is th:u 1hc ctuofT usc..-d is the f -cost (.q+ II) rJ.thcr than the depth: at eac-h iterJ.tion. the cutoff ''tdue is the small· est /--coSt of any node that exceeded 1he c utoff on the pre,•ious iter.uion. ION is prnccieal for m:u1y problems with unil step ro:scs and avoid.;: the substanti;LI o,·t·rhc~ a.."soti:•tt.." Each mind cll!lltge cottespoods to an ilel':llion or 1DA' and oould requite 11lany reexpansions
.... U1
"' •·igun> 3.21 St:ages in an RBFS scal\'h fort~ ~hortc~n rout\' to Buchartst. ~/·limit value for e:t("b rtC'\ItSi\•c call is :ohown on top of each cumnt node. and C\'«)' node is labeled wilh its /·cost (a) 1be JX~th via Rimnicu Vikl.
rt'C."Xp:uuljng the subtree at some later time. figure 3.27 shows how RS!!S reaches Bucharest. RBFS is somewh:u more efficient lh3.1) ION. bl11 still suO'c:tS from excessive 1l0de l'e· geoer.llioo. In the ex:.mlple in Figure 3.27. RBFS foii()WS the p..•uh \'ia Rimnic" Vilce.:t, ll'lell
of fo"om•n nodes to n."t"reatc !he l>e.'>t path and exu.•nd il one more node. Like A' lt'Ce search. RSFS is an O))lim:tl :tlf!Otithm if lhe heuristic func1 ion lt{ti) is admis:•ible. Its space complexity is linear in the depth of the deepest optimal solution. but its time complexity is r:nl'ler difficult to cha.t".)C''crii'..e: i1 depends boch on the accuracy of 1hc heuristic function and on how often the be-st path changes as nodes are expanded. IDA" :.nd RBFS sutTer from u:;ing too little memory. Benvcen i1erotions. IDA" retains only a sinf!k number: the curTtnl fst limi1. RBFS re1ains more infonnation in memory. but it uses only linear sp:.ce: even if more mt.'lnory were :wailablc. RBF'S h:a.s nO way to make usc of it. Because they forge• most of what they have done, boch :.lgorithmso ma)' end up reex· JXmding the same states many times owr, F'unhennore. they suffer the pc>ICtltially exportl!'ntial inc·rea.sc in complexity associ:ued with redund:uu p:tth.s in graphs (sec Section 3.3). h seems sensible. tltl!'.refore. to use ~II available memory. Two algorithm$ that do this arc MA" (memory-bounded A") and SMA' (simplified MA'). SMA' is-well-simpler. so we will describe it. SMA' t)nx«ds just like A'. exp:.lnding lhe best leaf ulltil memory is full. At this point. it cannoc add a l'leW node to the search tl'\.'(' withou1 dropping :.n old one. SMA" always drops the worst leaf 11ode-thohuion p.1th.-.. only n small subset of which can fit i11 memory. (This resembles the pl\lblem of thrashing in disk paging systems.) T hen t~ cxtm time 1\."qUin.-d for re~alt.'d regeneration o( the snmc nodc.•s lTK'MS that problem.;; Tll!U would be ,,mctieally solvable by A' . gi\'t n unlimited memory. become inu·:lcmble for SMN. That i.;; to say. m~mor)' limiU1tim1s CIIII ntak~ (t pmbl~m intrttNa!J/~ from the point of n't•w of COI11J111Utlio" timt•. Ahhough no cum:m throry explains lhe trodeoff bctwce•l lime and tne"tnory. it seem..; thai this is an inescapable problem. The only way out is to drop the optimality rcquircmcm.
3.5.4
tlgun: 3.28
Learning 10 s.:.arch btttcr
In this section. we look ~~ hrori slic~ for the 8-puT..z.lc, in orde-r to shed light on the nature of heuristics in ge.nernl. The S·puT.zle w~s one of the earlic:i-.t heuristic se-arc-h problems. As me-ntioned in Sec:· tion 3.2. the object of the pu1.:de is to slide the tik.s horizontally or venicall)' into the empcy sp.1ce until the conJlgumtion matches the go.1l confi guration (f-Igure 3.28). The :werog.e solution cost for :t r.uldooll)' gcoerJted S·pu?.zle instance is about 2'2 steps. The branching factor is about 3. (When the l~mpt)' tile is in the middle. four moves are possible: when it is in :. oomer. tw-brt-adth ·fl~ . gn.-td)' besc.firsl. and so on-th:n have been designed by comp1ter scienlists. Could an agenl l t:llf'll how 10 seareh bctcer'! The an:5wer is yes. ;md the nteti\Od n.·.sts on an important conc.:cpt called the met{Lit-n:l state- spa«. Each state in a mct:llevel state space captures the intemal (computali on:~l) Slate of a progrnm thtLt i.s searthing in an objttl·lc, ·cl s-tute space such as Romania. For example. the intemal state of theN algorithm consists of 1he current seareh tree. E.'lCh ~cl'ion in the metalcvcl state sp.1ce is n comput.ation step th:tl alters the intemal state: for example. eac-h compu.ation step in A' expands a leaf oode and adds its successors 10 the tree. Thus. Figure 3.24. which shows a Sl'C.JIXnct' of larger :mel larger search trees. can be seen a.~> depicting a path in the mctale\'el Slate sp.,ce whel'e e.ach .\luld give the tling is th;)t h~ would be the proJX~r score if we mo\'ed each tile in tum to its destin:ttion. 1'he heuristic dcri\"Cd (mm (b) is discuss.c:d itl Exctcise 3.3 1. From (c), we -c:an de-rive 11 1 (misplaced tiles) because it would be the proper score if tiles could move to their intcndi.."l non:~diti vc hcurisaie for lhc problem.
3.6.4
Learning h eurl~lics fro m CX:J)Cricnce
A hwristiU!)po!ot'd to e'timatc the co~t of a solurion beginning from the l'late at node n. How could an agent C'Oil,INCI '-uch a function? One solution was gh·rn in the preceding sections-nwntly. 10 den~ rd:a.\ed p\Jbk:ms for ~ hieh :m optim.a.l solutioo can bC' found easily. Another solut100 "to learn from o.penence. -E.xpericra·· he~ meam sol\'1111 lots of8-puzzks, for inlit&n('('. Each op.un~ -'OiutMX~ loan 8-puu.le: problem ptO\·idM: examples from •'tlioch h(n) can bC' ~. Each d 5f.'Un'h methods have access onl)' to the problem definition. The basic algorithms ate as follows: - Bre-adth -first sta rth eXJ)ands the shallowest nodes tits1: i• is complclc, op1imal for unit SICJ) costs. but has exponcmial S.p;)Ct complexity. - Uniform-cost scan:h expands the node with IO\'·est path cost. g (n ). and is optimal for general step costs. - Oepth-fi rst searc:h expands d.: deepest m'ICxpanded node firs-.. It is e'ICilhcr CQmplete nor optimal. 001 h.1.s linear SjX]C'e complexity. Dcpth-limiled .star c.h adds {I depth bound. - llernti\'e dttpening ge3rch calls depth-fi rst search with increasing depth limits until a goal i.s fou nd. h i.s cotn j)lete. optimal for unit srep cosu. has rimeIored :tnd frontier seiS (closl"' column,)
.l.5
JXtgC 72.
3.6 Gh-c :l complcle problem fommlmion for e.-.ch of lhe following. Choose., fonnul:uion 1ba1 is pn..-c-i..'>C enough to be implemcntl'd. a. Using only four colors. you have 10 color 3 planar map in such ,.. wa)' th:tt no two adj3Cent regions ha\'e llle same color. b. A 3-fooHall monkey is in a room where some lxtnanas are suspc.•-nded from the S·foot ceilittg. He would like to get the bananas. Tile room ('()tU:tins two s.raekable. movable. climb:tble 3·fOOI·h ig.h cr;ues.
Solving Problems by Scan:hing
114
l iS
b. Des it help if we insist that SIC')) COS-IS must be greater than or cqu~l to some neg_ati\'e constant c1 Consider both trees and grnphs.. c. Suppose th:u a set of :l.Ctions forms.-. loop in the Slate space such th.·u executing_ the set in some orderresuhs in no net change 10 the st.ate. If all of 1t.ese actions have negati\'C cost. whnl d<X.-s lhis imply about the oplimaJ behavior (or an agent in such an environmenl'? d. One can easily imagine actions with high negative cost.. even in dom n.in.o; such as route finding. For exam1>lc. some stretches of roa(l might h;we such be:;uu iful scerlcl')' as to far outweigh the nonnal costs in tenns of 1irnc and fue l. Explain. in precise lcnns. within the oonrext of sr:ue-sp.'lcc search, why hum:ms do n01 drive around scenic loops indefin itely. and expbin how to define the state space and actions for route finding so that anilicial agents can also : '1 \'0id looping. e.. Can )'Of.! think of a real domain in whic-h step costs :ti'C such as to cause looping'!
c. You have a progrnm tMt outpuL'\ the mcs.;;agc "illegal inpul record" when fed a ccn.ain file or input re 3.17 On page 90. we mentioned itcralin:lengthening sean:h. an itcmt.ivc analog of uni· f(}(ln cost search. The idea is to usc i1tcrt:~sing limiiS o•t p:uh COl\t. If a •lOde is gtner.ucd whose path cost cxcet.-ds the current limit. it is imm 0)1 What is the m:uimum number of nod~.s ~xp.mded by bre:ldlh-first t~e .search? What is. the maximum number of nodes e.~tp.1nden.>blem (TSP) can be soh·ed with the minimum-spanning· tree (MST) hcuri~k. whid1 estimates the cOS-1 of compl-eting_ a tour. g_ivel'llthal a pal1ial tour has already been C(H'lSttUCicd. The MST cos• of a SCI of cities is the s.mallc.s• smn of the link cOS1s of any tree that lution sc:ue. ooc tlk p;wh C"'"o'ro tnch il. The family or Local 5C'.1fCb :aJconthR\5 int~ methods i:nspi:ra.t b)· ~uhC"al pf'l)~~ (sinlulaled anncalio~) and t'\'OlultOWI) btolos> ( ~lk alg9rithrm). ThM. an S«t~~MS -$..3--IA. • ·e exarrune •tUil hilpptm v.htn 'WI't' rc:l:u the :lSStlmpcion.s of dr1nnuntMT~ and obsC'n'llbility. 1llc key idea i'l; 1hll1f an a1m1 annot pm:tict cucdy ...1w p¢r«p~lt •Ill ttUr\'t', lhen it •iD need tocoru.kr •hl aodo ~ c-xh rontin~ncy lh3l 1b pn~·c·pb m;~y f'e\"eal. With p3nial obscn-abdity, tht :&$ml •dlal,.g ntC"d 10 teep tract of lhe !ol;~iJIC"" II tnil}lt be in. hnally, Se-ction 4.5 im·C"stigates onlint ~aKh. in vohtC'h the a&ent as fiiiiXd wilh a ~ale ~opace th.tt i~ initially unknown 3nd musa be uplored. ronnK"nt~
If the palb to lbe g011l dot.s not m:tllCf, ~o~rt< migtu comickr a diffcren1 e~ ()( alJorirhms. ones that do not worry about p!lths IU uiL l.ot:ll srarm aJgorithms opn-ak us.tnJ a Nn&k currml oodt (r.athotr than multtpk p;Mib) and ~ntnlly tnO\~ Ol'll) tO nClJb~ ollh.u nod locol snrdl ~.,.,.. S)lltlllllac. they M< 1'"' l.ly :11cr
--~----------------~
I
4,
ScIUO:) ond lhcn ~uoJiy o:duc< Ill< 1Nensdy of the stuklnJ (i.e:_ kwo-c:r lhc IC'n'lpC1"atUrt). 1be jnnetmc)o:g toop of the ~•mul;~lt'd-annnhnt algorithm (figUI"C' 4.5) is quite simalv 10 hill climbing. lrut~ad or picking the /Ns.r MO\'t, ho'llt"ntf, it picks a rrmdom tnO\'C:. llthe tn(r\"C impn)\'CS the siruation, it is alwa)" aca-pt~. O.herv. i..c.lhe algorithm accept.'l the mM"C:.., 1th MMn e probabilily ki'S chan I, The I)..OO..bality dccrtOl!>t'~ t.xponcntiaUy ~itb the "N~s"' or rhe mo,·o-thc amount fl.£ by which lllC' C:\'llha:.lion i~ 'A'OI'llie:ned. The prob:lbility also dC'· e~ascs as the '"tcmpemtute" T goe11 down: "b;td" •nove' are more likely to be allowed ~I the s.tM when Tis high. and they bt.'t.-omc more unhkely us T decreases. l(dliC !ichcdlllt lowers 1' slowly t'flough, the nlgorithm will find :aglob0\1 Oj)timuan with probabilil!y :tppro3C'hing I. Simulated annealing was II ~• u'\Cd c.-:telhh•dy to M:llve VLSI la)'OUI problems in the early 1980s.. II ha..'Oix.'t'n :tpplied widcl)' to (;U:tOt)' ~hedul ing :.nd ocher larg.e-scale optimit.;~ tion tasks. Ln Excrti:se 4,4, )'OU :lit :a..l.cd 10 I.'OfllJ);I~ ib perfonnan< one node in mtmOC) m•Jht '«m to~ an nfft"me rt.aaion 10 the probkm or ~ limit:JI:ioos. The loc-al br•m s.ratdl alson•hrn t k«ps uact: ol k :s:tatc:s flllbc Otht•n n.ITI'r•t- ,.cz~ dst cNrrrr~t - ,•ul only with p~balit)' t .).l:tY
3274102 1
l 247~ 24uH 24752411 1
~~Mrftk. a~ from lillie' 10 ~""-
c"wTu•l- M"KE-So~.lllr.mAL..STAn) for i•I IO'- dO
H
t m m24 H
:::;:~;:;:;~>--< I 2441S411 H
1@s2124 l 2441S411ill
"' ........ •i,gu~ 4.6 The gen('tit aiJOnltun. , uu~l rl'l1rd for d!JIIl'tnnc" rcopresenting S-.quec.n~:~a.to.. 1'hc lnicilll popubti011 m (a) , ~ tal\l.t'd by the llti'K"'~ f1.1m11on in (b), rewllil1$ in pat~ for nu11h1$ in (ter 4.
Beyond Classic-al Scan~h
Scc1ion 4.2.
abililies in (b). N01ice th3t one individual is selected 1wice and one not at all.A For e..ch p.'Lir to be matl'd, a cms.'im-c.r point is chosen randomly from !he positions in th~ string. In Figurt 4.6. thugh tim~ has elapsed n:tum tile b »e:micul:-tr Slate once we compute the closest cilies.. Let C, be 1hc set of cities whose closest ;"tirpott (in the current S-tate) is airpon i, Then, in the Heigltbr>rhOtXI of lire t'11~111 SI(IU'. where the C,s rtmain constant we h:.\'e 3
l(rJ, Yt• :r2.tl'l• :r.s, 93) =
L: L (:r, - :rd2 + (y, - y(")2 .
(4.1)
•• lc£(;,
Tttis expression is correct 10I)' any of the local scateh algOtithms described pre,·iousty. We co'rld also :q>ply stoc:'ha.'>tic hill climbing and simulatl-d anm•aling dire-ctly, without di.o;cretizing the space. These :tlgolse successors rnndomly. which can be dO•'Ie by generating random \'CC• tors of length 6. Many methods nuempc to usc 1he gradient of 1he land.scape lO find a maximum. The gr.tdic-nt of the objccth·e function i:s a vector VI that gi\'es the magnitude and direction or the ~cepe~ slope. For our probkm. we have
'1/ • ( {)J {)J {)J {)J {)J
IJJ)
&r1 ' &y1 ' 0:¥'2' &!t! · lJra · &y3
'
In some ca._OSilion by using a sequence of ac-1ions with no sensing at all. 1bc high cost of st~nsing is another reason to avoid it: for example. doctoo often pfc~:ribe a brood· spccmtm amibio1ic r:uher 1han using the comingem plan of doing an expensive blood lest, then w;Uting for the ~u lts to come back. and lht.'ll pn'SCribing a more sp.-cific ;mtibiG~ic and perha1n ho$pitali;,.ntion bcc3tL..'iC the infection hss progrcs...'ied too far. We can make a sensorie~;;.s \'f:I'Sion of !he. \';M:uum world. Assume lh::\t the :~gent kl10'o\'S the geography of its world, bul docsn'l know its local ion or the dislribulion of din. In that case, its inilial st.atc could be nny element of1he SCI { I, 2, 3, •1, :). 6, 7, S}. Now, consider what h:l.J,pens if it tries the :tetion Rig11t. This will cause it to be in one of the states {2. 4. 6,8}-che agent now has more infomuuion! Funhem1orc. !he 3C'Iion sequence (Right.S11ck( will always end up in one of the st:ues {4. 8}. Finally. the se has N Sl:nes. 1hen the sensorless problem has up 10 2·'' s•mes. ahhough many may be unreachable from the ini1i:tl S.l:lte. • Initial stale-: Typic;tlly the sec of ;1.1 1Slates in P. although in some c::IS¢S the. agenl will h:we more knowledge th:m 1his. • Actioru;.: This is slightly tricky. Suppose the agent is in belief $1:U¢ b = {.~11 ...2 }. bot ACTtONSp{s 1) '# ACTtONSr(s2 ) : then the agent is un:5ure of which actions hysK'al problem. Or.ce this is done. we c:u1 apply any of the search algorithms of Ch:Lpler 3. In fact. we C'rul do a linlc bit more than thou. In "ordinary" &t'J.J)h scmh. newly gc.ner:ncft.Surl:l. namely. {5. 7}. Now. COE,sider the belief state reached by IUftl. n:uocly. {1,3,5, 7}. Obviously. this is 004 i, 7j. but it is a supuut. It is easy to pro\•e (Exercise 4.8) th;u if an action sequence is a solution for a belief s t:.uc b. i1 is also a oolutioo for any subset of b. l·lence. we can disc.·ard a path reaching { I. 3. i), 7} if {5, 7} ha..; already bc.'t'n gencrntcd. Com'Cf'Scly. if {1, 3.5, 7} has already been gencmted and found 10 be ooh•ablc, then ;Uiy substt. s uch as. {5, 7}. is. guarontced to be solvable. This extr.alevcl of pruning may drnm:uically imptO\'C the efficiency of scnsorless problem solving. E\·c-n with this improvement. however. scn~Ofk...;s problem-solving as we have nd s E b} , Nocice that each updated belie f stntc b0 can be no larger ttwn lhc pn'dictcd belief state b: observations CM only hICI"
--------------------~
4,
S«tton 4.4.
Two pr~htll~pc:l:.tc C)'dlvc 11. and C"1ans ahead, 1hc less often it will find itself up 1he creek wit!lout a p:tddle. Online search is a m·as:UII)' idea for unkllO'o\'n Cllvironmenls. wll('.re the agenl doe..,; 1101 know what Slates exist or what its :~C~ ions do. In this state of ignorsnce. ·the agent faces an exploration problem and must usc its actions as experiments in order too lcam enough to make dclilx--1':.\tion worthwhile. ·n,e canonical example of online search is a robol thnt is pi:K'Cd in ,'1;1 new building and mus1 explore it to build a map lhat it can use for geuing from A to B . Methods for esco:~ping from labyrinths-required knowledge ror a.piring heroes or nntiquit)'-:UC also examples of online searth algorithms. Spmial e:mmonty uSter 4.
Beyond Classic-al Scan~h
Scc1ion 4.5.
G
3
........
2
Onlir.c Searth Agc.nts and Unknown Environnu.·.nts
149
Althoug.h this s.ounds like a rt:.sonable rtqueSI . it is c.;asy 10 see that the beSI :.chievable compctiti\'e rntio is infin ite in some caes. For example. if some netions :are irn-l·trsibl ~ i.e.. they lc"d to:. state from wttich no action leads b:ld:. to the prt\•ious. st:ue- the online search might occidcrually reach a dcad·cnd state from which no goal state- is renchable. J>cr-
IL'I pS the tenn ··aceidcnutlly" is uncotwir.cing- :Jfler all. lhere might be :1n algorithm thar hilpjXns no! to tak.: t.h.: deOO-ic:t.lly.the :.gem's objecti\'e is to rtach a goal state while mi1limi.z.ing cost (1\ nod.er possible objective is simply to explore the e ntire cnviromncnt.) 1bc cost is the total p:tth cost of the p:uh that the agent ~ u;llly tr:wels. II is common 10 OOnlJ>ate this COSI with the path COS1 of the path the ugt'llt would follow if it b1ew I he searrl1 spac~ ;,. tukm1c~hat is. the 3C1u;d shoneSI path (or shoncst complete exploration). In the langu~e of online :dgotithms. this is callcdthe competilin ratio: we w(M.IId like it to be as small as possible.
Aflcre:.ch aetio·n. an online agent receives a pcrttpltelling it what su1c i1 has rc~: from this infonnation. it can augment its map or the cnvirocunent. The current map is used to decide where 10 go I'ICXI. 11•is imerlc:.n•ing of pl:.uuting :md ac1ion means thai online se.1rch algorithms are quite different from the oflline .search ;tlgorithms we h;we St."'t."-11 previously. For example. om inc algorithms such as A" can ex.p.1nd a node in one pall of t:he space :tnd ll'len immedimely exp:uld :1 node in another p;ut of the ~pact . because node expansion invol\'e.;; simulatl-d rnther thMt real actions. An online algorithm. on the other h~tld. can discover SI.K"Ces.sors only for a node Ihat il physiC':llly occupies. To a\'oid trnveling nJ11hc way across the tn."C to expand the nexc node. it seems bener 10 expand nodes in a locaf otdC'.r. l)(,o.pth·lirs:t search hao; ex:Ktl)' Ihis property ~usc (exccp1 when backtracking) the next node expanded is a ehikt of the pn..--vious node exJX1nded. An online depth-first SCliK'h nge-nt i..o; shown in 1-i gurc 4.21. This agenl stores its map in a table. RESULT(s. aJ. 1h.a.t recor\ts the state resulling from exccu1ing O'ICtion a in Slate s. Whenc\'c.~r an oct ion from the cum-nt state hao; not bc.:n explored. the agent 1rics that oc1ion. 1ltc difficulty COm($ when the ..gem has tried all the :'ICiions in ., st:ue. hlJ ofnine depch·llrst search. 1hc state is simply dropped from the quem~: in an onJinc sc:arch. the ~ nt has to backtr.Kk physic;1Jiy. In ter 4.
Beyond Classic-al Scan~h
Sct.11C:md JI~1Wn. initi;ali)' null if (;OAI.· "I"I~ST(.s') tht n rth 1rn #op if ~~ iS :' in the worst cnsc. 11 R:u.clom \lo"JII:s a~ compk1c on infini1c one4in~nsion:d and l'olo'O- 1he $IM1 in, point i< only a~ 0. ).$()$ (II up¢~.. I9?:S).
152
ChaJ>ter 4.
Beyond Classic-al Scan~h
Sc1a1e 11'1atb the location()( the :.scm, and the upd:ucd cost C"stim:.u:~ :n tach ircrmioc>11att circled.
(unction L RTA •·AG£l'"T(s1 ) rtturn.~ an 31Ction ln pul~: t~'. a pctcep!that identifies 1hc eum:nt Sl.lt t pttsl'ittnt: rt.slllt. l'l tabk-. indtxcd by Sla te and :.ctton. initially emp1y II. a table of cost estimates irukxcd by s.t:ur. initially cmp•y "· a. tlk" pll'\•ious sl3te and action. initially null
4.6
SUMMARY
ir GOAL·T'E:ST(s') then rtturn ~top ir ¥ is a llt'w state (oot in 1/) thcn /1(6/ 1- l1(¥)
This chapte-r ha.;: examined searth algorithm.;: for problems beyond the '"cl:wkaf' 1aiC: s pACe.
cUmbi.n~ Oj>l!'.r:.Ue on Iynomial·time algorithms thtu arc oftl.'n ex tn~mely efficient in practice. • A genetic algorithm i.s a stocha.o;tic hill-dimbing search in which a Large populntion of Slates is ma.im:)illed. New st:u cs are ge1lCN1teairs of s•:nes (f()m the popul:ui01l.
• Loclll umrll methods such as hi.U
IS4
ChaJ>ter 4.
Beyond Classic-al Scan~h
• In nondttermi.nistk environments. agents eM lim::tl 00S1 of solving the physical state !l in the fully ohscn•ablc problem. for every stn.te s in b. Find :m :t(lmiS$ible heuristic II( b) for the sensories.-. problem in tenns of these costs. and pmvc its admi...,sibihy. Co•~uoon on the a«uracy of this heuristic on the sc.nsorless vac-uum problem of Figure 4, 14. How well doe.-OR search for p.'ltlially obswel"'llble problem.-.. beyond the modificatiOIIS you dcs for lt to get stuck • ·ith com·n ~txlc'? b. Con!\truct a noncom·ex polygon:tl mviron~t in '*tuch thr iii£Ctll aet~ ~uck. Rc:~ou
a,
Modify die hill-climbing algorithm so that. ins.tr;xl of dmns a depch· l ~an:h to decide whet't' to ao next, it does a dcp:h·k sc;~n;h, It ~1ld llnd the Jxo..,t k-stcp p.1th and do one ~t C JJ :~l ong il. and then repeal the Jmxes~. d . It there some J: for which the new algorithm it guuruntl"Cd IOtM:apc from loca l minima? t:. Ell.plnin how LRTN enables 1he ;agent to esc111>e from loc:1l m lnirt~ll in this ca.-.e. t' ,
~. 14
LiL.e DFS. online DFS is inromplete for rt\'tn.ible ~Hate 'P:ICes with inlinite p!Lths. For uampk. ~uppo;.r thai states are points on the infinite two-dunen,ionOSCd oo 1hc fu ll g-ame tree. and examines enough nodes to allow a player 10 dc-tcnn ine what move to makuld be.- sequence of actions le::~ding to a goal slate-a tl~nninal slate thai is a win. In OOvcrsarial sc:arch. MIN has something to sa)' about i1. MAX therefore must find a comingem Sl!'trud of b- for ehe,s. ~bou1 6 instead oi 35. Put another way. alpha-beta can soh•c a lrtc ~h.ly '""'Icc IL'- ckcp as minun:u in abc !lMI'IIt amounl of lime. If successors are examined in random order r.uher 1han besl·first. lhe toea! numbc':r ol nocS6 cxamint'd v.iJJ be rouply O(b,.. a) for mock nile h. For chess. a fairly simplor ordenn.C funt~ion (wc:h as uying caplurt:~ fio.c. thm thrt:au. thtn f~Or I( wonh 2. ,o 1\0W Dis 'A'Orlh C'.UCd)• 2. MAX'$ decision :lithe root i.~ 10 ltlO\'C 10 /), Jh'illlll \.;;;:::,:....;._ 'll fUC' of 3. _ ___j M>~1lCY.1\C're
,.,._here
Chaptc.r 5.
170
Advt-"l'il3rial Se3tth
Scc1ion 5.4.
171
Imperfect Real-1ime Ot."tis ions
lis t in GRAPit·SeARCII (Section 3.3). Using a tr:tnspos:ition 1able The minimax algorithm gt·nemtes the entire game se;ut' h space. wherea.o;lhe alpha-beta algo· rithm allows us tO prune large parts of it. However, alph:.-bcla st ill has to se:uch all the way
rtturn u
11-+oo ror tach
o in AcnONS(~tal(:) do
11- M1N(11. ~·1 AX· V,\l,UE(RESULT(s.a) .o./.1))
if v S o then retun1 v
fJ- MIN(IJ, v) return ,, •' ltture 5.1
~
to tenninal state~" for at lea.o;t a ponion of the search spoce. llti.s de1)th is uwally not pmct ic:-1. because moves must be made in a reasonable :unount rime- typically a few minutes :u tnOS•. Claude Shwnor1'$ paper Programmi11g o Computt 175
Imperfect Real-1ime 0t"(:isions
I
• ''
2 3 4
5
6 7
8 a
b
c
d
e
f
s
h
fi)tu rt 5.9 The horizon cO'tcL With Bl ~ l: ro mo,·~. th~ bl..cl: biSIV>J) i$ sun:!ly d001ned. ~~~ Sl:tt.k nn (()ttstall tlull.,'Cnl by c:hcekht~; the white kins with it$ p:awns., !orting I.IW! kin; ro n pturt tb! pa..mlt ihi!~ pu.,hcJC !he hW!''il3bl~ los.o< of llW! bi.~hop ewer liW! horizon, and thu.~ tiW! pawtlllaltritlces a~ sttn by tiW! k :tteh 3lgoritlun 3!1J()()(III'IOv~~ rat l~r th!!.n bad Ont:'i.
Unfonun:uely. lhis npprooch is r.uher dangerous beC'nuse Ihere is no gu:lmnt~ rhat the best rtl(We will1lOI be pnmed aw~y. 11le PROBCUT. 01' I)I'Oixtbilistie cu1. algOI'ilhm (8uro. 1995) is a forwal'd·pn.ming ver· sion o( alpha- beta search thul uses suuisric.s gained (rom prior experience to lessen the c hance th.·u the bes.t move will be pru1'1Cd. Alpha-beta seatth pnmcs :\ny oode tho:u is f'rtJ''' 'bly Otll· side the current {o , ,O) window. J)ROBCUT also prunt•s nodi."S that are prr.Jbably outside the window. 11 COmJ)Utes this I)I'Obabilily by doing a sh:tllow scai'Ch 10 compoure the backed·UJ) value v of a node and then using pa~ exJx.·riencc to estimate how likely it is that a score of v :\t depch d in rhe I I\.~ would be omsidc (a, (J). Buro applied 1his rcchnique .:o his Orhcllo progr.un. LOCISTELLO. and found thnt a version of his progrnrn with PROBCUT bl!'~111he regul;lf version 64% of the rime, even when 1he regular version was given twice as much time. Combining all the tl"('hniques di.'SCTibed lte-re results in a prog.r.un that c.:u1 play eredit:.ble chess (or ocl.cr g:unes) . Let us assume we have implemented :u1 eV31untion func1ion for che$$, a reasonable cutoff test with a quiescence sean:h, tmd n large trnnsposition table. U1 us also assume that. after months of tedious bit·bashing. we c:ul gtoner.-~te and evaluate around a million nodes per second on the latest PC. allowing us to scnn:h roughly 200 million nodes JliCr move u r~-r sranda.rd time cornrols (three minutes per move). nw: br.a.nehin.g f::.ctOr for chess is about 3$, on avcr.sge. :md 3Su is about 50 million. so if we used minimax search. we could look ahe--ad only aboo1 five plies. lbough llOI incompetent. such a progr.1.m C:Ul be fooled easily by nn nvernge human chcs.~ pla)'Cr, who can OCC3l>ionally plan six or cig_hl plies >"head. Wirh alp!l.')o.beta sea.teh we get to about 10 plies. \lthich resuhs in an expert leve l ()f play. Sccrion 5.8 describes additiona l pn.ming tcc:hniqlk"s ttuLI can extend tJ.e cfl'ecli\'c SClll't"h depth to roughly 14 plies. ·ro reach gr.mdma.oply an evatu:uion fuoo i01l 10 e~ lc:tf. One migh1 think th:u evaho~aLioo functions for grunes such as backgammon should be just like e\•aho~ation function-s
2
2
J
'
20
20
30
30
1 400 400
If the progr.un ktK.-w in adv.mce all the dice rolls thai would occur for the rcsl of the g-ame, SQlving a game with dice would be ju.stlikc solving a game witl~u dice, which mini· m:u does in O (bm) lime. where b is lhe branching factor and m is lhe maximum depth of the game tree. Because cxpcc~ im inimax is also w ns.idering all the possible dice·roll sequences, it willl;tke O(ll''n 11' ) . where 11 is the number of distine of simulation is calltd a roiJout
referee s:~ys so~ Oll~etwise. i1 is Black's 1utn to mo\•e.
:u all i1s children'!
5.6
Scc1ion 5.6.
PARTIALLY OBSERVABLE GAM ES
Chess ha.o; often bc.oen described as war in miniaiUre. btH it locks at least one major c.hame· teristic of 1\!0ll w:vs. namely. p~rtlal (lobse.n-ability. ln the "fog of wal'." the existence and disposition of Cot.'lny units is often unknown until ne'Ycalcd by direct conlltCt. As a result. warfare inc:ludcs the usc of scouts and spies to gather infonnation ;LOCI the use of cooccalmcnt and bluff tO confuse the enemy. P:mi:'tlly observable g:.unes share these char.)Ctethtics and are thus qualitath•ely difi'crent from the games describOS(d. the referee :ulnounces o-ne (lot'
Kricgspiel may seem ti.'rrifyingly impossible. bul humans mallitgt' it q uite well and comp.nel' progro.ms are beginning to catch up. It helps to recall the notion Ohopping or dnVIO$ off· ~\lad. Nonethde.5S. r..cing and g_arrl('·pbying gcncr.ue extitcmcm and a steady ~trcam of innovatiom th:u ha\·e been :tdop1cd by the wider cornrnunily. Ln this S('(tion we look ut wh~11 it lUke~ toron~e Oul On lop in vJriou..:; game~. OQI
Da)' I : ROJd A kack 1o a fQp ol &okl: Road B k011Ck to a f«l T.llc ~ left fort mel )OU'II fi.lldabqan~o(Jold.bul tak lhcn,N fod.-' )OU'U bt""'~nb)· a bus. Dol)' 2: Road A lack Do a ~ of J01c1; Road II kleb eo • fori. "''ld..t ~ n~• t'ort and )OU'JI fi..W a~' hc;apo( JOicl. bull t-ake lhc kft for\. Md )'o.t'tl bt Nft~C'f by a but.. OJiy J: Road A leadl to a hnp or JOIha-bctn ~arch. l1'1C unique pan wa..:; :1 configuration or 480 C\biOm VLS I c:he~ Jlf~Mln th:u pnfonned mo ..·e gcnemtion and ffiO\'e on::le:ring for che lasa few IC"'tl"' or the tttt. and cv~luated the lcar nodes. Deep Slue starthed up to 30 billion pchiliom pcr rnc:)\'e, rtOK'h1ng depth 14 routinely. The key 10 ib SUI."Cl!SS Sttms to ha\~ bttn tiS ablli1y 10 lent"f'alc "angulu extensions beyond 1he depth hmi1 for sufficimtly imem.t~& line" of fornft.&/'(on:td fnO\es. In some cases the searth "'~a depch of 4() plies. The e-.'aluaaioo (unthon tud 0\'C'f 8000 fc.a~:uru. many of them desnibi.nt bls,hly specific palkmS of~· An -optniAJ bool... o( aboul 4000 positions •-as us.ed. as: •-ell as a~ of 100.000 &rand~ Camt:' from •hdl consensus ~ion~ could be- cxmctc:d. 'The sysccm aho u~ a LvJe endpmc ~ of .soh"'t'd posi110m con· &tutinJ all posititllnd~1rd PCs to win Wortd Computer Cbe~s Ch;un1>iOrt,hi1x . t\ wriety of pruning heuristit-s nre usc.-d to n.'duc~ the dfccti\'e brnnchin,g f:IICtor 10 I t~ th;an3 (c:omp.ued wilh the ae~ual bmnching fncror of about 35). The mos1 illlJ)()I1tutl of the~ i"thc null nuwe heuristic. whic~ gcncrJtl:$ a good lower bound on 1~ \'alue of t!l posi!ion. "'ina 11 ~hallow M'lllt"h in which the opponent gea-. 10 lilO\'e twice at the btgi.nni.ng. Thi.:; lower bound often aUows alpha- bet::a pruning without lht expense of a full-dcpch search.. Al-.o imponwn b. fulllity pruning. which helps decide in ach-anct which rl\0\U 1Aill eauJ>e a bru. C'utoll" Ill the "uccessor nodes. HYDRA can be .set:n M lhe ~.....~ 10 0H_P 8LLB. HYDRA runs on a 64-prottSSOr duSier "'ilh I gigabyte pn- prot\"~ and ._,,h cu\tom hardware in the fOtm o( FPGA (F~itJd J>ros.r.unmable Gale Amy) dups. II YDRA rexhc" 200 maiiKJn C"'31Uions per second. about the AmC' as 0oep Blue. bd. HYDRA ~ik'~ 18 plieS dttp ratbtr Ibm jusa 14 btause o( auressn'C' U$e of the null lnO\~ heufi~te and fON'M\1 prunlnJ.
Chaptc.r 5.
186
Scc1ion 5.8..
187
van1agc appt'Ill'S to be its evaluation function. whic-h has been lUIX-"layers ;\lt: JXI.ired into two teams. t\s in Section 5.6. optim ~l pia)' in p;:utiall)' observable gnme.s like bridge can include elements of infonna1ion gathering. communication, and careful weighing of pR>OObililies. Many of these techniques are used in the Bridge Baron pR>gr.un (Smith t!l lll.. 1998). which won the 1997 compuler bridge championship. While it does
lmem:uion:d Masu.~r Vasik Rsjlich. and :u lea~t three 01her grJndmasters.
not
Till: most rccem matches sugst-st that the top com puter chess progr.uns have pulled ahe:xi of all hum3.1l romerKiers. (See the historical n01es for details.)
complex. hierarchical plan..;: (sc.."C Chapter I I ) involving_ high·lcvcl icka.s. such as finc..-ssing nnd squ e-ezing. thai are famili.u 10 bridge pla)'ers. ll•e GJB prognun (Ginsberg. 1999) won the 2000 computer bridge championship quite decisively using the t-.·tome Carto med\0grorns have followed CIS 's kad. GIB 's major innovation is using explan ulion-buscd Ktntralization to c..-ompute and c:t at Othello. Backgammon: Sttcr 16. we see IIO'o\• these ideas c:u1 be made pn.."Cise ;u.J impk ment:ablc-. Finally, let us reenmine the nature of search itself. r-\ lgorithms for heuristic senrch :md for game playing generate St-quenha--bela search :tlgorithm cornptHCS the same op1imal mo,·e as mi1limax. bot achiews much gremer efficicnc..")' by eliminating subtrees that are PI'O'\'abl)' im:k-vunt. • Usually. it is not feasible 10 consider lhe whole game t.n.-c (e\·en with alpha--beta). so we
Chaptc.r 5.
190
Bibliographical and
r\eed to cut the se3n:h off at some point 3nd apply a heuristi-c tvalualion funtdon th:u estimmcs the utility of a stale.
• Man)' gO'me programs precompute table.s of best mo,·e..o: i1lthe opening and endgame so that they can look up a move mther than scnrc·h. • Games of chance can ~ hlmdled by an extc.•nsion to the minimax algorithm th:u evnl u:ucs a chance nodt by 1akin.g the avct3.ge utility of all its childten. weighted by the 4
probabilil)' of e:.c:h child.
• Optimal pl;•y in games of imperfect inrormutjon. such a.-. Kricg.spiel :u1d bridge. requires reasoning about the currem and future belief' states of each player. A s.imJ)lc approximation can be obtained by 3\'t'f".-g:ing the value of an action ovt·r each possible configurotion of missing infonn:uion. •
!~grams have bcS~cd even champion human pla)'Crs at games such as chess. checkers. and Othello. Hum3lls retain the edge in M.-vtrJ.I g;unt"$ of imperfect infonnation. such as poker, bridge, and Krieg.spicl, and in games with very large brnnching factors and link= good heuristic knowledge. such as Go.
BHlLIOCRAPI-IICAL AND HISTORICAL NOTES
The eatly history of n)C(hanical game playing was mam.'d by numerous fliluds. The most notorious of these was Baron Wolfgang von Kcmpt"k'n's (1734-1804) '1'1ll: ·rurk." a supposed chess·playing autom:uon th:n defeated N_,poleon before being exposed as a magic-ian's trick cabinr Plrryi11g Cltcss (1950) th:tt had 1hc mC)St er that introduced LI\C dynamic progl".tnuning apj,ro.'I.Ch
well agau1Sll1uman 1llayers !llld
to retrogmdc analysis. he wrote. " In checkers.. the number of possible moves in any given
bridge championship wa-. won 6\'e tinx."S by JACK and twice by WBRIOOE5. Neither has. h•••d :~cadcmic anicles expl:l.ining lheir strue1ure. btu l.x'Mh are 1\lmOC'Cd to use the Momc C:.rlo technique. which was til"$1 proJx>scd for bridge by Levy (1989). Scrabble: A good description of a top progr.Jm, MAVE.N. is given by irs (1'"C.310t. Brian Shi.·ppard (2002). Gcner:•ting the: highest-scoring mo"e is. described by Gordon (1994). and modeling opponents is oovered by Richards and Amir (2007). $()('Ctr ( Kitano ~~ al.• 1997b: Visser l!t 111.. 2008) and billiards (l...;•tm and Greenspan. 2008: Arthibald tt (1/•• 2009) and odM.·r s.tocha..:;tic g;unt.·~" with :t con1inuous space of oc1ions sre beginning 10 nnrnct anent ion in AI. both in simul:uion and with ph)•s.ical robol pla)'ers. COinJ)Uter grune competitions occur atUJua.lly. and p:·tpcrs appear in a ' 'aricly of venues. The rather misleadingly named conference proceedings He11ri.1tic Programmitrg in Anijicit~l lntl!lligt•nct• rtpon Oltlhe Computer Ol)'nlJ)i;ads. which i r~lude a wide variety of games. 11.e Gencrnl Game Compelilion ( Love~~ al.. 2006) tests programs that mus1 !cam to play an un· known game gi\'en only a logical description of the n1les of the game. There :trt also several edi1ed collec1ions of imponant papers on g:une·pl:a)•ing rese3rch (Levy. 19S8a. 1988b: Mars· IMd a.nd Sch;.effer. 1990). 11le lntem:uiona.l Computer Chess Associalion (ICCA). founded in 1971. publishes the ICGt\ Joumlll (fom1el'ly the ICCA Jmmwf). Jmponan1 p:.pers h:.ve been published in the serial anthology Adwmct's in Compmer Chess. staning with Cltltke (1977). Volume 134 of the jn dnJ Jt!(childn:n: n 1 = min(l'12', 1, ••. ,nl&o,.). Find a similar C;.tpn=-s.\ion for n1 and hel1ee an t.lif)tt~ioo far n 1 in cern's of nJ . b. Let 11 be rhe minimum (or m,vcinmm) ....tluc of the node!( to the /~fi of node ''• at depth'· whose minim:u. \•:due i~ aln.•:ldy l nown. Sirnil:illy.lct r, be the mi.nimum(or maximum) r.tluc of the unexplored node..~ 10 the righl of,., at dcph i. Rewrite )'OUr expression fOf' " 1 in tenns of the I, and,., \•alucs. 1.'. Now refonn ulate the ~Xpt't'.)Sion to ~how th:tt in Ofdcr 10 affect 11 1• ' t J muS1 not CXOC'l-d a «n~in bound deri,-cd from IlK' I, v;aluc).. d . Repeal the process ftlf thec:t.\C: wtK'ft n1 h 1 min-node. 5.14 J>ro,·e th:l.t alpha-Oeca pnminc 1al.e~ 11mc 0(2''"12) 'A·ilh optimal mo~·e ordering. "hm'
m is tbC' maximum depth or l~ Jatr'IC ·~. S.I S Suppose you h~YC' a mess procram 1Nt ( ,11'1 ~-;~lu»C" 10 million nodes per second. D«1ck on a cc:wnpaa tt"prtSmUll._ o ( a pme "Me f01 ~e in a 1r.w;pos;Rton ublt. Aboul how lft3tl)' entries C01n )'OU fi1 in a 2-&tpb)le e.n•nW'I'l'IOt) u.bk? Will1tw be enough for che
200
E.~cre-i'-C"~'
·~-----------------
201
• Use the resuJb> to t-~imale the \~lue of ueh mO\'t a.MI 10 choose the besl. Wby (or \lo hy 001)?
Willlhi~ procedure ~'Ori: ~'t'll?
5.20 In lhc: foiJ<w. in&. a "'nw.- trtc C'Cn~~h ml) ol maJC nodes. "bere:as an -opec:~ima.\.. urc rnnsosrs of a mn nod< 11 lht 1001 "llh a~cmllm' l.lym of dJ.1oc< and max llClth. t\l ~ nodes. all OUic:omt problbilit~ art" nonltro. The aoaJ is 10foul tlu mlw of tit" ft'JCit ..,,Ch a boundcd-«pph SCCrfffily rntional backgrunmon agent never l~cll.. 5.22 Consider carefull >' the interpluy of chance t\'en to~; and J).'Utial infonnatiOn in e:K in time: either one come.s firs.! or 1he Other doe.s:
f'iguno 6.1 (a) lbe principal states and tcnitOfiC$ of Ausar..llia. Coloring this map C".1n be viewed as a constraint $lltisfaction probkm (CSP), The go.al i.s to :wign colors touch region~ that no rlC'ighbori.ng regions ha,·e lhe AAme color, (b) Tile map.coloring problem repm;cntcd as a constraint graph, imm~.--d iatdy
$
+ 10 ~ A Lraints and objcc1ivc fUJtelions h:we also been suldicd-qu:)(!r:uic progr:unming. sccond·ordct conk progmnuning. and so on. In addi1ion U) examining 1hc 1ypes of \'ariablcs 1ha1 can appear in CSPs. i1 is u$C'ful 10 look :u 1hc t)'peS of CQns•rnims. The simplest 1ype is 1hc unary conslminl, which rcsuicts the ~lue of a single variable. For cx:~mple. in lhc map-m::d, whh the adckd rtJ';trktM>n 1ha1M lead ins ,..crocs :tN! :.Uqy,·ed. (b) The con..-n hu h)'Pt.'rgr:apl! (Ot tl.e crypt:u'ithml'fie probkm, s.howins, 1l1e A lld•ff cunj;tr.\inl (~u:ttt box :.t the tOp) :.s well :as the column :.ddi1ion eon..•traints ((our $qu:IN! boXC$ in the n1M.klle). i1'te v:.ri:i»le$ C1. C:~ . :and C:1 ~ptt:~nt the C:uT)' digi!S (Ot ll.e ll1~e columns.
one binary constraint for c~lCS or local con"i.!itc.r•c>'· wl1ich we now CO\'Cr in mm,
6.2.1 IIIOCC~
Node tonsislency
A toirtale ~ri :tble (t:orrtsponding to a node in the CSI• netw.orl ) j, nodNonsisttnt if :til the \',lh.te' tn the variable's domain 53tisfy the v;an;tbk '~ un;~ry eot'''"'int~. For ex:unple. tn the v;viant of lhc Australia m:lp nodt-~1. h ~~ U....--a)'S pos.s•bk to eliminate all thC' wwy cons&raaniS u1 a CSP b)• runruns. nodC' ro«N"'-MCY· It is also possible 10 tnn.sfOtm all rt•ary romtr.atnb tnto binar) onr.s (sec Ex· m•~ 6.6). JkntM o( Ibis. i1 is commoo to define CSP sof\'C" thM wort ••th only birw)• C'Ofb.lr.aanl': "'l: mal.e dw a...~mp:ion for the ~ ~ 1h1" chap4n. nttpl w. he-re notc'd.
••th
6.2:.2 w:~PC\'
Al"t" consist.ency
A vari11bk 111 a CSP is art"-ttNiim bctw«n X , and N 1 tht n de Ieee % from 0, r.o:t•t$«1- true rtlum rt:~
•s aR'M *' cmpcy doma.n, IAdtC;tillna:llw the CSP aMOt be $01\"cd.. l'bc: DM~C -AJ;.)- "''" UM'd b) the a4Jondw's lft\'fl!IOf (Mxtwortb. 1971) bc'C.•·• lhc diUd \'U'AOII dndopc. lems, although they may not recogni1.c it. A Sudoku board consis1s of 81 squares., some of which ;lte initially tilled with digits from I to 9. The pu1ile is 10 fill in all the remaining squares such that no digit appears twice in any row. column. or 3 x 3 box (sec Figure: 6.4). A row. column. or box is called a unit. T he Sudo~u pu1.zles that are printed in lll'Wspapers and puzzle books have the propcny 1ha11here is ex..etl)' one solutton. Although some can be tricky to solve by hand. taking tens or minute.'>, even the hardest Sodoku problem.'> yieklto II CSP solver in k ss than 0.1 .sec-ond. A Sudoku puzz.le CO\n be c<msidered a CSP with 81 vMiables. one for e:.ch square. We usc the v;Lriable names ; l 1 through A 9 for the top row (left to right). down to I/ through 19 for the bonom row. The enlJ>l)' squatts h:we the domain {I. 2, 3. •1. S. 6. i.8. 9} and 1hc )>teo filled squares h.'IVC a domain oonsiSEing of a si1l.glc value. In add ilion. there are 27 difTercm
213
ConSimint Prop.ngation: Inference in CSPs 2
I
•
9
c
G
I
s
2
•
7
6
3
5
6 4
8 I
2 9
8
•
6 7 8 2 2 6 9 5 2 3 I 5 3
I
9
I
9
2
3
4 8 3 9 6 7 c 2 5 I 0 5 4 8 E 7 2 9 F I 3 6 G 3 7 2 H 8 I 4 I 6 9 s A
8
7
F
H
• 8
I
0 E
3
3
A
•
•
(a)
Fiaurt 6.4
s
• •• 7
9 2 I 6 5 7 3 4 5 8 2 I 8 7 6 4 9 3 I 3 2 9 7 6 5 6 4 I 3 8 7 9 8 2 4 5 6 8 9 5 I 4 2 5 3 7 6 9 4 I 7 3 8 2 (b)
(a) A Sudoku t)U):zl~ :md (b) lis solution.
illldiff oon&~mints: one for each row. column., and box of9 squ:uu. Alldiff(A I , A2, .43. Aluhon. In th11C 'i«'tlon we look :u bad:trx:king ~a.t'C'h alaorhhm~ th;u \\ort on partial :ls.Mgnmetu~: in the: next s«tion wt' look atlocallltan:h algorithm" over complete ~gnmmts.. Wt' could :1pply :11 :s.t:.ndatd depth~limited ~atth (from 0\iiJ)Icr 3). A ~:Ut' would be a p.:u1i:1l ll~igruncrlt. and an action woold be ndding t'tlr l'fllt;t· to the ~lligruuent Out for a CSr' with, Volli:~bk~"~~ or domain size d. we quickly not k~ M>nt~d1ing tciTiblc: the br.mthing (nCIOI' al the lop le\'CI i$ rt(/ because any Qf d Yahl(~ c-an be llS.Signcd 10 :my of n v:1riablcs. AI the next level. lhe bi':UlChing factor i~ (n - l)d. and Ml on for n k"Vcl,, We ~ 1\CI"'\Te a lree with u! • d" lc;l\•c:s. c..-m though thert: a~ only,,. possible COillJ>ktc a!l-."i' nrr)(nts! Our ~mi ng.l)' reasonable but nai'-e fonnul:nion i$JKW'~~ cruci:d J)f'OI"'"Y common 10 all CSJ>~ turnmulath ·ily. A problm~ is commutati\'C if the order of llf1plk.11ion of :my gi\·cn M't of acttOn\ has no dfecl on lhc: outrome. CSP~ are rommut :~tw~ b«au~ \\hen assigning \'IIUC' 10 \wiablcs. \\(' ~ach the.' S3tne p:uti.al :migntntfll r'C£afdk=" Of Oil'lkf. Theft' fort":. WC' n«d only oonsider a sintl~ 'oariabie aa earn node in the ""'ll«'h tttt. For~u:~npk. at the rOOl node of • ~•h CfC"C' for- coloring the nup of Ausnha, \lot n1e'ht mal.e a choic:c bdv."ttn S..l tt J, SA grttd, Md SA= 6/w . but "-e w.'OUid """"" thoo!-c bee"'""' SA = m1 and l'Jl 61.,1!. With 1h15 ~rit'tion. the nurnbn' of tw.n- b ,r, a_, "e wrould hope.
ru.IK'lion 8.ACKTI.AC'KI:rs
T:bmania! Obviou.sly this is s.iUy-~«in.c Ta..,m.mi;a c;annoc possibly resol"e lbt prob&cm "Ailh Solnh AUSir.ll:i.a. A~ intdligc-D~ approach to br;adJr.K'..InJ •~ 10 bx\:trxL: 10 a \~k that M1gfU fi~ the pobkm--a \-an;~bk lh3l "'"'" ~·bk for nul.t"J one of IN possible \'allk'S of SJI impossiblt. To do 111;, •'< '"lll«p lrx\. or • 1lll WJritlblu. IO ha,·e no COrl.Sifitem solutioo. In this case. the .Ki i.s IVA ;~nd NS ll'. -.o 1he alaorichm should b x ktrock to NSIV and skip 0\"er Tasmania. A bad;jumpin& alaorithm thou u;;c., conflict sets defined i.n this way
m.
IS calkd ronftict-dirKIOO b;lc.Yum.pin~tWc mUSt llC)'A npbin ~· these I'll!\\ ron1hct lltt5 _. compuled. Tbc ~ i~ in rxt quite simple. Tbc- "'krrntnaa.. (;ad~ ot a br.anc:'h of 1hC' seOlfCh at.-a.:rs occurs bttauS~: a \'MSablc ·s domain becomes m~ply: dul '~ ~ a J:l;an&.td conftin sc·t. ln our aampk. SA r,;ls. X1d ;,. «< os (y) ( 11\1 .~T Q}. We bos
.,....,;co
Chap!er 6.
220
Conscmint Satisf:tctiorl ProbJems
the that are only one conllict away from a sohuion. l, latcau search---allowing si' b¢ ('OI(Irh. noc lhe cominem) b)' fixi1l£, a v:.\lue for SA :m
if il n nnot be m.1dc c:on~ist cntthe-n rtluna failure fe)r 1 =I to r1 do (1.._"-..s: the situation is more complicated with highet·ol'd~ when there is a collectiOft e>f :agcnt.s, eoch of whkh COfllrOIS :a sulhet or tile eothtmim v~ri nblt-s. There have brcn (IJUUi fil work~hop~ on this problem sin('(! 2(K)(). and aood ccwcr.1gc cbewherc (Collin t•r ill., 1999: Pl·:ut'e ' ' al.• 2008: Shoh:un and Leytw•· Orown. 2009). Comp.uin& CSP algorithms is mostly nn empirical M:icnc:c: rc:w llli.'Ortlical results sbt:w.• 1h.11 or~~e :1lpilhm dominates mot.her on ~I probkm~: in,h!ad, "C •~NI 10 run ~xpcriments 10 ' « which "l&orithm~ pe-rform better on 1ypical insl:u~ of' proble•n~. A~ Uook~ (1995) poinh out, \\(' n«d to be careful ro diStinguish bctwtcn compc111ive le,ling-mctice of Co1htmint Prog.r.umning. oftera e connection" :ttt ~ible. The points n-pn:'sent re-gions on Lhe m!•p :u•d the: line:. connect IM:igt11>0nl. NO\\• try to find k-c:olorings or e:K'h map. for boch 1.· 3 o\nd 1.: 1. u~ng min·c:onllictli, b.lclritruc:kina. b:.cktr.td.ing with forward ehtt·king. Md b:•cktr.l("king wilh MAC. Co1NI'\IC:t a t:.ble orawmge run limes for t:-neh algorithm for values of n up to the largclit you c~n nuu11•gc. Comment on )'OOr rest.~h ., ,
6.11 U!~e 1he AC·3 algorithnt to ~how thnt arc ronsi!>t~ncy can dctt.'(t the inconsisten Logieal AgenL.~
236
runction KB·AGii..S T(ptrotpt) ntu.rnsan oclion pcniste-nt: KB. a kno"'' ledge base
t. a col.lntc-r. initi.:dly 0. it)(licating time TELL( Ide. In the 1970s :uld 1980s. adVOC:ltCS of the two approaches engaged in heatt-d de-batt'$. We now understand that a su1 (None, Nont', Nont', Ntmt, No,le). (b) Afler o.~~e mtw~. whh l>t~'«J'If (Nor1e, Brl'.!e: s
·""
",.
'·' " "
..._
·~
'·' '" •••
•••
1.3w!
urn s c
3.3 1'1
....
3.2
....
... "
'·'
0"' •S.f•~
"
C) I\
3,1 I'!
.......
.....n
" v
...
s
'·' v
" ,
'·'
·• Vlsifod
I J: S
,.
OK
'·' v OK
OK (>)
... •,. OK 2,1 B
"
OK
(b)
FiJtu re 7.4 Two l :ll~r S.l:l$~~ in !11~ p«>gress of th~ 3$f!r'll. (:..) After the third 1n0\'e, with pe~p: (Stt'nC'h, Nom:, Nont', Nom•, Nor1 tJ. (b) Afl~r the lifth roove, with 1>trap: (Sten~lt,
Bru.u, Cltttcr, Nont',
Non~J.
wumpus cannot be in 11.1 (. by 1.h~ rul~.s or LllC game. nnd it rnnnot be in (2.21 (or the agent w()uld have detected a Slei'M:h when it was in 12.1)), 11'1Crtfon:=. th¢ agent can infer th:Uihe wumpus is in (1.3). Tile notation W! indicau•.s this in (erenc~. Moreover. the lock or a bn."CZ~ in 11.2) implies that then:= is no pit in (2.2). Yet the agent h.'IS alre.ady inferred thou there mu.st be a pit in dther [2.2( or (3.1 (. so this ml~:&ns it mu.;;t ~in (3. 1). This is a (airly difficult inference. because it combines k1\0wlcdge gai1\e--, \ CElli CLD a: ' ..
The Jg(nl tw now pn:n't'd to irselfltw thtre i~ neilhrr a p11 nor a wumpus in 12.2). so it '"OK 10 100\"C t~. We do no1 showdr :ttt"nl'$ lil31C oftno-kdJC aal2.2]: "'" jusl as..wmt"
INillht ..,., IUmj and MO\'e$ 10 12.31. JivinJ U$ fi&u~ 7.4(b). In 12 •.ll. the~ dc1ects a &hlk'r. jO "~ pab the gold and rhea rerum homt.
N01t IIW on t>dlm. for "llidl
~
Illw11 n.cldtN or n 1 (no ph in 11.21). (b) Dotted line showli moncr:s
consist or:. single l}n.I:H>shlon symbol. Each MK'h '-)1nbol scands for a propo~oition that t~'\n be true or (abc. We w~e ,;ymbols that sl:l.rt wilh :m uppercn.se lcllcr :uK1 rlliay c-onuain other leners or subs4.-riph. (()( example: P, Q, fl, H't 3 and North. 11'e names :u~ atbitr.uy ~u a~
often chmen
10 ha~·c
some mm:monk vah~we use H'u to ~.-ud for the propo.~ition
1~1 the w--umpu~ '"in (1.31. (Rcrt'IC'mber tNt 'yn\bol~ wch as U"1.;s are ctltHttk. i.e•• W. I. and 3 :m noc. nk:llbn&(ul p;ans ol the- symbol.) 'l"twtt ~ cv;o proposition ,)ymbol~ Y.ath tbtd meani~ l..\ chtr ~~-~)'5-uut ~110n and F~ is the :atv.~)--c·bk propos:ilico.
n-..,
Complu .stottnm art: rorutnldtd from ~mpkr 'ietWmc"C'S. using ~ and ~ connectins. lllc:re are fh·c connecti\'es in common u~:
--
.........
---....
"' (noc). A 3ilt1Uen«: such as ..,ll'a.:s is called the ll('Jt:U iion of 11'a,:s. ;-\ IHtral i" tilhe:r :Ul atomic !(CfiiCIK't (a pos-jth·e literal) or :a ncgutcd ruomic sentence (:1 n c~:alh·e lltcrill), 1\ (and). A ~UCilC'e whose main rotuU."f.'1ivc j, /\,/!oUCh as 11'13 /\ P~ 1 • iJ:Xbitioo ~)·mbol.$ Pu. Pu . :and P.,,,.1hen one: po)S.1bk model i~
or
"'•- { P I.l -fuL,t. rn ~t. P.s.•• llllt} With ltw'« pn:lpO:Sition symbol'- 1httt a« 2'- b posstblc n.odrl-pcdfy how to compute the trul.h Vlll ~te or fill)' SC.'1Ucnce. gi\·en :a model. ·nli~ ls done recm·sjvcly, All sentences are constructt.'d from Oltomic sentences :and the: live roNM.'Ctives: then:rorc. we need 10 e fa/$< fnL"ie
/tmt
li'U(!
tr-ue
true troe false troe
troe false false troe
,,,e fabl! ,,,e
tn1e
Fi:gurt 7.$ Tn11h t~bk:~ for the tivc logice fa/$< fnL"ie
/tmt
li'U(!
tr-ue
true troe false troe
troe false false troe
,,,e fabl! ,,,e
tn1e
Fi:gurt 7.$ Tn11h t~bk:~ for the tivc logic {1 :mel n from fl Let us see how these inference rule.s and equivalences can be used in tile wumpus wortd. We stan wilh Lhe knowk" ( Po,2 V !',,,)) II ((/'o.2 V P2.1) => Bo.o).
Then we :tJ)p!y t\1\d·Eiimin:uion to Rc; to obtain
R,'
((Po.2 V P2 •1) => Bu ).
L..ogical e ~(Po,> v P,,, )) .
Now we can apply Modus l)onens with Rs and the pcreep1 R 1 (i.e.. -.8t,1), tooblain R9 :
..,(Pt,2V Pv ).
Finally. we nppl)' De Morg3n's rule. giving the conelusion Rto:
..,p, ,2/\ ..,fll,t .
Th.:\t is. tlCither 11.2] nor (2.1) contains a pit. We foond this proof by hand. but we can apply any of the: ~arc-h nl,gotiLhm.;; in Chapcer 3 10 lind a sequence of steps th:u constitutes tl proof. We jus1 need to define ::r proof problem as follows:
the initi"l knowlt"3.1
'""'""'
1)1
t, v .. . vf,_, vt,+l v ... vt"' · where each t is a literal aJ\d f 1 and m Me cCHnpltmtntary literals (i.e .. one is the ncg:.tiO•l
v -. P~.2
Tht.'re i:s one more technical aspect or the n.'SOiution n•le: the rcsuhing cl:u.•sc shoold comain only one copy of each lilcrnl.9 TIM! removal or multiple copies or lilerats i$ called fa ctoring,. FOr example. if we re-.sol\·e ( A V B) with ()l v ..,B ). we obla.in (A v A). whkh is reductd to jus! A. l11e sowulnrss of the re.~ol ution rule can be setn easily by considering the liter.al t. tt1at is complcmenUU)' 10 litem! mJ in the other clause. Jf t, is true. !hen mJ is fal~. and hence m 1 v · · · v mi - l v mi+ 1 v · · · v m~, must be true. beC'o:~usltlonallogk is logimlly t'lflU'mlt'nl to 11 t·mljunctltm of dmlst's. A ~nt cncc cxpres....OO tts a conjmll'1ion of clauses is said to be in conjuncth1e normal fonn or CNF (see Figure 7. 14). We now describe n.
254
Logieal AgenL.~
Scc1ion 7 .5.
255
3. CNF requires -. to :IPIX"M only i.n litcrnls. so we "nl(lve -. inwards.. by repeated appJi· cation of the following equivalences from Figure 7. 11:
-.(-.a)= a (double-ncgruion e limination) ~(cu\{1) =(-.a V ~11) (De MO'llan) ~ $1fi11bol ($ymbol 1 1\•••I\ Symbol1) ~ FaUe
l''igurt 7.J.a
A • rnmmar fCK«Nij1JnctiYc nQnn al fom\,llom clauses, and 4clinitc cl:t.IJSeS. A 1\ 8 ~ C is still a definite cl~u~ wht'fl it is writtl,l as ....... V ...IJ v C. but onl)' the' fom)Cr i11 conskk~ the c-anonic~! fonn forddlnilt: d:wses. 0 1)C mo~ d.UII is tht k·CNF sttltence, whic:h i112 CNF lltnU:ncc whc~ t:aeh d:1uk hti at n)C)!.~A iitcrnl$. A dausc suc-h 2S
2. Infe-rence with Hom clauses can be done through the ron,·nrd-chaining and h:.rk ward· tholinJng algorithms. which we explain next. BOth of tlk'Se algorithms are tl.s arc obvious :u•d easy (or humans to foil~·. 1nis type or inJettnce is the b:lSiS (Ot logic progr L1.t. bt.u it is simpler 10 write just Lu .
7.5.4
Forward a nd backwnrd c haining
The (orward-chotining_ algorithm PL-FC-ENTAtLS?(KD. q) dctennines it: a single proposition symbol q- the query-is entailed by a knowledge base or dclinitc daus.cs. It begins from known facts (positi\'e lilerab) in the knowk-dg_e base. If ;Lilthe premiSt'$ of an implic-;tlion arc known. then its conclusion is added to the set of known facts. For example. if 1.. 1.t and Dn.-eze are kl\0\\'11 :md (Lu A Bruu) 10 B u is in the knowledge bo:l$t'-. then /Ju can be rtddcd. This pl'()(-ess t.'OntintJt"S untillhe query q is ad P. f1gun• 7.15
II is easy to see that forward c:haining is sound: c.-..·e ry inferenc."t is es;scntiall)' :tn appli· cation of Modus l,oncns. Rlnv:~rd ch:'lining is also complete-: eV(:ty elll:'lile/$. model) n"1uniS true or /tJ./.1t
1r ¢\'Cry clause in dltt~.tu is true in model then rttum tr'14e ir S()fne cl~usc: in da•t.~e-1 is f;~lsc in model tht"ll rttun1 /o.l.•·c P,lta/ue- fiNI> ·PIJRE·SYMBOI.(symiK>l•'o daiLff$, modtl) ir P ill llOO•rm ll thtn retunl O J)l,..L(clau.~~ . symboL~- P, model U {P=mfet~}) P,•,al•~t! - ftND •UNIT•CLAUSf.(clcJ•Qt.ot, modd) ir P ill llOO•IIIIII then retun1 O J)l,..l,.(clau.~.• . symboL1- P, modt"l U {P=mfet~}) P ..- J::"tlt ST(.'~"!JI'ibob): rr.~t- R EST(.•ymborl.~)
A complete backtracking algorithm
The fit:).t algorilhm \\'C consider is ofien called 1hc Dtn•i s-IJutnnm algor-ithm. after I he scm· inal paper by M3r1in Da\'i:t :u1d Hilary Pu1nam ( 1960). 1ne algorithm is in fact the vcr.~.ion described by Davis, Logem:mn, and Loveland ( 1962), so we will call it Dl,ll after 1he ini· tials of all four authoo. DPLL l:lkes as input a sentence in oonjunctive normal fonn- a set of clauses. Like BAC" TRAC" INC·SB.ARCII and TT·ENTAILS'!. il is c:;;senlially a recursive, depth·l'irs,l enumcm1ion of possible models. II embodies three improvements over the simple sd1t1ne of TT·ENTAILS?:
.........
Et~rly
fa lse. C\'Cn wi1h a partially rompleted model. A clause is 1.rue if tmy lilet:'ll is true. even if the other litcmlo; do not )'CI ha\·c truth valU(.'S: hencx. lhc sentence a.o; a whole could be judged true even befOte the model is complelc. Fl ltellri$tic: A pure symbol is :.t symbolth:u always appears with 1hc same ..sign'' in all clauses. For example. in the thrt" umrinmio11: 1'be algorithm detl"C1S whether the sen1ence must be Ink'
261
runc:lion DPLL·SATISF1A6lB'.1(.1) n turns true or fal$e inJmiS: s. a scnfC'IW.le in proposifioR;'lllogi e
oh< owo families of algorioluns cl.crhncntation to find a JOOd bal:ml.'i! belween greediness and r.J,ndorMe-.ss. One of the ,;implc.~~t and most efTccli\·e aiJorithm!t to cmcrae from all 1hi" "-''Ork is called WALKSAT (F'igurt 7. 18). On CV"Y ittrJtion. 1he aJaorilltm pil in t~ cl:w~ 10 flip. It chootw.'s r.mdomly bet"'"" two wn)'" to pick which symbol to ftip: ( I) a ..min-confticcs"' ~cp lhat miniml.t.t'< the num~r o( W1~1isfied c:t;~uscs in the nev. ..ule :1nd (2) a ··ranc~om ""'-alk- step lhat picks thc J )1l'lbo4 randomly. \\'hen WALKSAT rtiUtM a model. &be inpul t.t~ l" 1ndt-'fll ~illfi;1bk. but ~hen 11 ft1\lm~ /otlurr, 1~ are r.r.·o possible nusa: C'lthc-r Lhe SCNC'n« •., unsoatss:tiabk or ..,-c: n«d IOJ,I\"e 1~ :t:llOflthm mcntimc.l!wc-K't muJf•P' "-:and p > 0. WALKSAT'Aill C'\"C'flh.l;all) rtfl.im a model (if one exisas). bec:aloi:Sit tht random·v."Jll. '~~Ill C'\'t'ntua.ll)' hit
function WALKSAT(deM.K•.p.,..,.,- .Jft,_.) ~tunu a iO!Ittd)·"'' modd or /oflv~ inputs; cM-ast--•. a Kt ol da~HC"~ 11'1 P'"J'PO'dtOIW loftt p. die probilblllty ol C~I'IJ IO do a ......... •-..It"' 1*'\·c-. rypgJJy afOIIIIId ().$ ,_,. ..Jbpt~. numbn ot ll'f't alkltwrtcd be-few lr\"lftf, up
•odd- .a l'3nCiom a__q;apatn~ ot trwr/J.t~r 10 tht q lbbob • •~• for • 1 1o mu.jft~ do if motkl s.ab~ n.o ...., .• thfon ~um l'ltObl t'lfJw.&~- .a r.andomly ~!«ted ttau..c- from t"lltlll..n llutl,; f.t~ In modd "'ilh protdbility p R1p the' at~ 1n modfl of a randomly ~le«C'd t>)'mbol from clott.u: C'lsc: flip whkhc'\·cr "')'n,bolul rltnU>r maAilfl11t'l> the munber of !1011111\fied cbu"C5
stt of C'OOfbcts IS LqJc.. ..d rartl) used Oft('S are dropped.
4, Jbndom l"tSSarts (as .seen on ~c 124 for hall< lunbln&):
~--
I
can bt soh·at in vo ilh il'lldlige~W bactncting ttw bac'ls up alllht ••~y co tht ~kvant poinl or
not be babili1y is close to 0. The pR.>babili1y drops fairly sharply aR.>und m/n = 4.3. Empirically, we find that the "cliO'.. stays in roughly the same place (for k • 3) :Uld gels sharper :u1d sharper as n increa:~cs. Theoretically, the satisfi ability threshold conj~tu re s.-1ys that for c\'cry J.· ~ 3. there is a threshold r.1tio rk $UCh thai. as n goes 10 intini1y. the probabilily that CNFk(n. rt1) is satisfiable becomes I for all \'alues of r below the threshold, and 0 for all values above. The conjecture remains unprow.".n. I
2M 1!00
~
•••
""'
1positional Logic
265
AGENTS B ASED ON PROPOSITIONAL LOG IC
l1l this scc1ion. we bring togecher wh:u we havt lean-ed so far in order 10 llf-11' ~ S.~,,). N \I,OUld 1\Nd onr such St'nlence for each ~~·ble lime '-ltp, for t'Jich o( 1he 16 square.;;. and e:ach of' the four orientations. We would also 1\Ctd ~imi l ll.r ""'nl('nt'C:Ii for the Olher :K"Lions: Gmb. Sl~tK1t , ClimiJ. TumV:fi. and TumRight. Ut u' !>Uj)pose lhal the agent does dc(ide 10 rn<we l~mwml :u tirne 0 and assert.;; this f;~ct imo ilith
Lhe~
;,. no (7.2)
For the agent's loc.:.'ltion. II~ ~~ce~sor~l:tlc :t..,iocn' are more elabor.~te. FOr example. 1..~;1 ' ioc true if either (:1) t~ 3~1lt mo,·cd f'mw(Uv/ from (I. 2J when (:\Cing sooth, or from (2. 1) whtn rxing wes:t; or (b) Lt, WM ll i.s. where it is lf()l known 1h.11 then: is 1101 a wumpus. The runction l)t.AN·SIIOT (not shown) uses PLAN·ROUTU 10 pbn n seque-nce or actions that will line up thi\ ..hot. If this fail ~. the ~,!Ill l ook.~ for { I squ::tl't' 10 explore thai is not prov:lbly un~~fe-d1111 b. a SliU:Lre for which ASK(K 8, -.OK~..,) remn'~ faJ~. If there is no s uch squcut:. the11 the mi-.~on is hllJ)OSSible and the age·nt retreats to [I , I) and c limbs out of the cave.
7.7.3
Logical state es:Hnuuion
1bc "''~nt program in Figure 7.20 v.m~ qui1e •dl. 001 1t has one major ....n~.:ness: as time C-OtS by. the computa~ional t>;pm~ im'Oh't'd 1n lilt n.ll\ to ASK £ClCS up and up. This h~PPMS mainly because the n~qtured inf~ ha\'(" •o J.O back fwthn and further in time and tn\'Oh'(" mort and mc)ft: pn>pC)Silioft S)'mbol_, ()M.IOU).))', thiS IS UftSUS~'e tannol ha\'t an ~ v.host- time to process exh pctttpe J.fO\\"t.AN •SH01'(currerti,JIO.•.o:tblc: ~ urump•L~.J.a/r) it pltm ~ en'tpc)' thel'l // 1\0 eholct: bui iO t:~kc a rW: not.u1bajr - (1:~:, rl ASK(KB, ... OK ~.,.) = faL~d pl(m - PLAN · ROUT~( tltm:'l'tl, um:u1IM n 11ol.lm.~/t>.M/r) it pliw i$ empcy thel'l plar1- PLAN · ROUTil( t~rn'CJ'tt. {II. l)} . a.~J/e) + ICI~mlt) cu:t 1tm - POP(J;o/tm)
=
TELL(KIJ, M A K I!· ACTtO:O.:·S~r-.'T~NCE(adior~ . l)) t-t + I
aetitm
(UnC'tion PLA N· ROlrf£(et~n>erd,gool$.a/Wtt.'Ui) n-turn1: an :tetion sequt'I'ICC intJUIS: cun'(!lll, the a.gcnt'$ c:um:n t po:~iti()ln ~:r, a set of~uai'Cll; try to piM ;a R>llle co one of them llllo•rcd. a ...et of squ:u~!lthat 1ate of the workl. atk.l :1 ron)blnation of problcm·solvinj. seareh :t1'1d donuin·spcdRc code to d~MJe what actions tO taR.
by n unique binnt)' number. we would ~ed numbers with 1og2(22•) = 2"' biL;; to label the curre•n belief state. That is. exact s-oue estim;uion m"y requiA! logical fomlulas whose size is ~xponemi nl in Lhe number o( symbols.. Ot'e very common and muur.d scheme for llJJPrtJXimtll~ &late e)\1immi01' is h) rel)rtsent bclie(slnte:.o; as conjunctions of lilemls. Lhat is. I·C'I' IF fonnulas. To do Lhis. lhe ngent program simply uics 10 l)f'()\'C X ' and -.)(' (()r c.:'lch symbol X' (as well as each 3temporn.l symbol whose U\llh \•alt.N! is 1l <M yc1 knO\.Io•n). gh·cn the belief s1a1c "' t - I. 1be COiljunc•ion o f
I...........................................
I
l"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'t
I
0 0 0 0 LQ_.Q_Q__ Q__ Q!
=
~turn
271
Agenls Bast."d on Propositio n>tl Logie
OerfetM>n of 3 I·CNF belie( sL1tc (bokl outline) as :~ llim1>l.y rcpttset'ltable, 10 the c:cac1 (wi"ly) belief g31e (sh:.e.kd rc'-ioo with daj;bed outli ne). 1!3eh I>OS.;;ible wotklii j;hown :'1..-t :1 c:irele: l11e shaded ooes are ron~isu:m v.·i1h 2ll 1he pctttpcs. FIJturt 7.2 1
«w~o.-;er...:uive al>l>mxim•.,tiun
provable litc:mls becomes the n~w belief state. "nd the p~vious belief suuc: is discarded. It is imt>Onant 10 undens1a11d tha1 this scheme may lose some illfonn;uion as time ges along. Forcxrunplc:. if the: scntcnC't' in Equation (7.4) wen: the true bt.'lid slate. then nc:ithcr Pa. 1 nor Pu would be provable indi\'idually and ncil.her would appear i11 thc 1-CNF belief s-:ue. (EJCet(-ise 7.27 explores Ot'le possible sohuio11 to lhis problem.) On lhc Other h-and. because e\·ery literal in the I ·CN'F belie:( slate is proved (rom the previous belief slale. nod 1he initi"l belief Sl"te is a t.nH: a.._~;;enion . we knO\.Io' thm cmire I·CNF belief Slate must be true. Thus. lilt• st'l tlj'possibl~ swus rt'flrt'smu•d by llu• 1-CN/o" bt'li~f stou• incltult•s all SJ(II~s Ilu:u ''re ;,. fiJCl possible gi\'4!" tlte fi•ll f.14!trl:JII fri$tln'): As illusu:.~t cd in Figure 7.21. 1hc I ~ CNr belief state ~ciS a..;~ simple outcr t-tn-tlope. or conSen ·ati,·e a pproxii11UUOn. ~II'Owld the ex:tcp up to l. If the ~ti.sil:lbilil y ;~lgoriUun finds a n~l. then ;1 plan isc:xlr.KIC:d by looking :~t thOt'C p~itiP is asscned itl.SICad. Now. SATPtAN will flrKI lhe plan !Font·anially observable c•wironmem: SATPLAN wo.•ld juSl set the unobscrv:tbk v:u-iablcs to the values it ncl"rOOChes 10 AI are :tn:tly7..cd in depth b)' Boden (1977). Tile deb3te was rcvi\·ed by. among others. Brooks (1991) and Nilsson ( 1991). and contjnues to this day (Shapar.IU ~~ :luJJ ( 1983) showed l.hat the Slune problems could be sol\'t.'d in constam time simply by guessing random a..o;sigrune.us.. 1bc random-generation method described in the chapecr produces much hardl~r problems. MOl ivnted by thco empirical suct.x·ss of local se:vch on these problems. Kou1soupias and Papadimitriou (1992) showed 1hat a sim· pie hill--climbing algorilhm can SOI\'e 11/mosr (1/1 sacistiability problem inst:utceS \"Cry quickly. ~aggcs1i ng &hat h:~td problems are rare. Moreover. Schi.Sning ( 1999) exhibiTed a mndorni1.cd hill-climbing algorirhm whose wom·txiJe expccled run lime on 3·SAT pm'blems (rhm is. sat· is:fiabilil)' of 3-CNF sentell(;eS) is 0 ( 1.33..1"}--:till exponential. but subsW.nliall)' faster than pt\!vious worst-case bounds. The current record is 0 ( 1.324") (lwama and 'Thmaki. 2004). Achlioptas rt al. (2004) and AleklmO\'iCh t•t P) is valid. d. o fJ if and only if the sente-nce (n {J) is valid. e. C). g. (C v(~A A~ D))s((;l => C)A(D => C)). h. (.4 v D) 1\ (~C v ~D v £)I= (.'I v D).
I. ( A V D) 1\ (~C v~ D v £)I= ( A V D) 1\ (~ D v £). j . (.4 V B ) 1\ -.(A ~ B) is satisfiable. k. ( A D) 1\ (~A V D) iss••isfi3blc . I. ( A 8 ) ~ C h.'IS the ~me number of models as (A 8 ) for any tixcd set of proposi1ion symbols th.:u includes A. 8. C.
=
7.6 Pro,·e. or find a coonterex:mlt)le to, each of the followi11g :\SS.Crtions: a. If o )s ~ or /1 I=~ (or bolh) !hen (o A /1) 1•"7
b. If o )2 (Ill\~) !hen o )s /l and o )s ~ · c. If o I= (ll v 1) 1hen o I= P oro I= 1 (or both). 7.7 Consider:\ \'OC:abulary with only four propos.ition& A, B. C. :mel D. How many models :trc there for Ihe foiiO\Io•ing sentences'!
•· /J v C. b.
.-.A v -.B v -.c v -.o.
c. (A ==> B ) A A A
~B A
C A D.
7.8 We have defined four binary logical connooh-es.. a. An: there any others that might be useful? b. ~low many binary COOIX't."'ivcs c;m lhl~re be? c. Wll)' are some of1hem not \'tl)' useful? 7.9 Using a method of yoorchoice. \'erify each of the equiv:'Liences in Figure 7 . I I (IX\8C 249).
7.10 Decide whether each of the following stnte-IX" Fire) -=> ( .....SmoJ.·~ -=> -.Pire) d . Smol.·e v Pire v -.Fire t . (( Smoke A J/oot) o Fire) Q ((Smoke ..,. Firt ) v ( 1/et.~l ~ Fire)) r. (Smol.·e c> Fire) :o- (( Smoke A Ileal ) :o- Fire) g. JJig v Dumb v(8ig => Dumb) 7. 11 Any proposilionallogic ~ntence is logic-:LII)' toquivalcntlo tl~ assertion that cnch pos· s.ible world in which i1 would be false is n01 the case. From this obsct\':ltioon. pro\'¢ th:u any sentence can be wriuen in CNF. 7.12
Use resolution 10 provt the SClUe fiCC -o..-1/\ -.fJ from the clauses in Exetti..~ 7.20.
7. 13 This exercise looks imo 1he rclationshit>between clauses and impHc:uion SClUe•lCCS.
Logieal AgenL.~
283
a . St1ow th:u the ¢13ust ( .,p, v · · · V ..,p"* V Q) is lotically equi~len t 10 the implieC logically equh•alenl. liow 1nany scm:uuically distint'l 2--CNF clauses c:ul be construct~.."Sitio•'31 re.solut ion always tenninatc-s i1' time polynomial inn given a 2-CNF sentence containing no more th:ut n di.> Q. b. Show that every clause (regardless of the: number (I( positive literols) can be wrinen in the foml ( P1 1\ ··· A P,") => (Q 1 V · · · V Q 11) . where the Ps and Qs are proposition
symbols. A knowledge b.'l.Se f.Xmsisilng of such senienc.' ((C => E) v ~£)
7. IS Thill question consitraint graph com-sponding to the SAT problem (-.X, V X'l) 1\ (-. X1 V X :J) A •.. A (-.X,... a V X ,.) fot the particular case tl = 5.
b. How m:~.ny sohuions are there for this ~neral SAT problem as a function of n'?
c:. Suppose we apply 8ACKTRACKINO·S£ARCU (p.'l.g(: 215) to find tr// soh.uions to a SAT CSP of the type given in (a). (To find till solutiOilS to :\ CSP. we simply modify the ba.s.ic algorithm so i1 comin~tC-S sc:trching afler each solution is found.) Assume that V'.lrinbles are ord P«l'ly) V ( Drinl..·!~ => P(lrly)J => !( Food 1\ Or;rli.'S) => Ptt,.tyJ, a. Dctcnninc. using cnumcrntion. whc1hcr this scmencc is valid. satistia'ble (btu not valid), or ullSlltisfiabk. b. Con\'en the lcft·h:md and rigJu-h:u•d sides of the main implication eac-h ste--p. :uld expl11in how the results confinn your answer 10 (a). c. J>nwe your att.w•er to (a) using resolution.
i ~no CNF.
showing
7. 19 A sentence i.o; in dh;j unctin! normal form (ONF) if it is the disjunctioo olconjunctions of lite-r.tls. f« example. the scnt(."llee (A 1\ B A -.C ) v (-.A A C ) v ( B A--G) is in DNF.
b. Whieh of the sesucnet-..~ in (a) can be txpres:$00 in Hom fo-rm'?
(A V 8)1\(~A VC) 1\ (~ B v D ) 1\ (~C v C) 1\ (~D v C)
7. 18
.
a. Any propositional l(lg_ic sentenct is logically equivalent to the assenion that some possible world in which it would be true is in fact lhe ca.m.
In Ch:.ptc-r 7, we showed how :. l:nowledge-b3scd age-nt could represent the world in which it oper..tes and deduce wh:.t actions to lake. We used propositional logic as our reprt.S~t ntati on language because- it sufficed 10 illus..tmle the OO:;ic conccps of logic and knowledge·b.'I..W agents. Unfon.unately. PI'OI)()Sitional logic is too puny a language 10 rtpresenl knowleOtS$ible to describe 1he ctwironmcnt concisely.
8.1.1 The lnngut•ge of thought Natural language~" (:weh as English or Sp.1ni~h) are very expressive indeed. We managl-" "This section OO\ 'CI"$ the topic of knowledge I'CJ>rtscntation l:lllgU..'Ige'S •.. " W:uulcr ( 1974) did a simil:ll' expcrime1U :md fOtmd that subjeeakers c.hosc bt:<mrifill. dt•gtmr.Jmgilt:. and sl~ndt:r, Words can scn·e as anchor points thllt nf'rcct how we JX'fCt'ive the world. LofttL~ a nd P:llmcr ( 1974) showed experimt~ual subjCCts a ffi()\' ie of an auto accident. Subj'*m prcdK'ti oorrt'C'LI)' 77'il ol t~ llme. Tllc: S)'SCcm can C\'en predict ar :lbo\"C'-chan« k\'el\ (OJ \o\'Ordt> it has ne'-er $CUI Wl fMRI unae-e of befort' (by considering the imagd of n:hnod v.-ords) and for people it has I'IC\'cr ~n before (proving th:u ~·tRI l't'\'eal\i some k\•el ol common I'C~U:uion across
a computn-
• "E\·il King John ruled England .n 1200... Objecu: John. England, 1200; Rel;thOn: Nll'd: Propentes;: C\·il. king,.
The l~~.ngu.a.gc of first~rder logiC', w~ ") nuu: and ~matnic~ we de: fine i n the nexr seccion. i~ t'M.•ilt :uot~nd objtcls :~nd relalion... II has brcn M) imponan110 m:uhem:uics., philosophy. nnd a11irkial intelligence pcttistly bcc:.u,.e lllO'ot fiekl--"'nd indctd. much o:r e'"C'I)'da)' hurnw' cxi.;.u:·nct-ean be usefully tOO.aghl o( =-~ clciLiins: with objects :~~~d 1he relations among Ihem. 1::-in.t..ordcr logic can also t:tpttss f:1cts :1bou1 smllt' or fill of the objt."C''s in 1hc universe. 1ld~ enables one 10 represa1t geneml laws or ml c:~. SI.ICh ~~~ the starcmcm "Squares ncighborina lhe wwupus are smelly." The primary dHTercnce bclwccn proJ)()ti,ition;ll :.od fir«~rdcr logic lies in the onl4•loJti· tal conmlitmt nl made by each lanau..,~tho11 h, wh:Lt ila...sun'IC's about tbe naru~ of rroli1y.
people). TI1i.: l)'pe of work is s till in iLS infancy. but I'MRI (and other i m~ing t«hnology
such :1, intmt-r.tnial tlectrophysiology (Sahin ~~(II.. 2009)) J)romi'ie;; to ¥ive us mlK"h more conc1\:lt ldcll..~ of wh:u hum:m knowledge rcprescnlations arc like. 1:rom lhc \•iewr1oin1 of formal logic. rtpn:-.:o:c•uing d.c ...:un~ knowledge in 1wo differe11t wayll makc~ 4\bsoluldy no difference: the sam~ (:acb will be dcriwable from either rcprc~n t:Ukln. In pr.telice. ho"""·evcr. one rt-pn:sentalion 1nig.lu rt(tUirt fewer ~CP-' 10 dcri\'t a conclu· liiOn. meanins •hat a reasoner with limited resource~ coold ace 10 the conc lu~ion using one rc:prc"CN~Iion but noc the ochtr. For ntHrlktlu~nf! tlhb ~uch :L\ laming from exp:rience. OUICOMIK :n nl'·ussarily ~ndr:nt on the fonn o( the rtprt"fni;JteO•h uW.. We ilhow in Ch;aptt'r 18 thai ~hen a lnmin.g program coos~ two ~·bk t~ oflht \loor1d. bolh o( w.hte'h ~ corbiltmt ~ ilh aD the: g.ic Fi~~rdcr logic Tcmpor:all~ic
Prob:lbilily lheory Fulzylogk f'igurt 8.1
On~olo_gic;u.J Commitmem
Epi,stc;tnologic-~1 Cornmiunent
(Wh.11 exi:sts in the v•orld)
(Wl\o11 an "3Cnt tx: lfcv;.-,s :tbout f~lll)
facts fa.cts, objc'Cis. n:lacion:s facts, bjet~s. n: lations, t im~ facts fa.cts with de$n.-e of truth E [0, 11
lrue/1'~1$.C'/unki'IO"'n
lruc/1':d.selun.k.r'IC)\\n
truc/1':dselun.kno"','
dcgrtt ()(belief e (0, 1) ki)Own interval value
r·ormallangua.gcs and lhcir ontological and cpi!>temologic-~1 commitments.
In the next serdcr logic as V-r
Ki11g(:r) => Per.1011(:r).
V is usually pronounced "For au .. ,". (Remember th."'lt the ups:iICr 8.
296
fiD,t-Order Logic
eMended tntc~atioo i)pttifies :t doaWn ekmttll to ll. hteh r rr(t'r"\. nu~ -.ounds compticakd. but it is no:atly JU:st a nrtful•~a)· of the inruitiw ~n~:an· of urU\'Cnal q~nlificaaioft. Consider lhe model Rk-h:mlthc Lic~tthcan i-t" p:t« lbc= crovm is a person. Ld "' lool c:attfully as lhi~ set of :t:SSMJOOS. Stnc~~:. 1t1 our modrtl. Kma John is che only l..nJ. lk 'oC'C"'nd ~~ assM.S dw he is a penon, as .,.,~~: .,.,ould hope'. 8u1 v.tw aboul
lh: oe.hcr four senttnaS• .,.,ilich appear to rrgtt cb.mu about I~ and C'tO'Iom? Is We p;xn ollhr I'I"'C':InJftl o( ..All~ are persons'"'? In fxt, the ochn four bloC'ftioos ~true in the modtl. bul fNl.( no cb.im v.hauoc:\n about me ~ qu;~hfiQltOM of kp. C':f'OI"'n§. or 1.ndec-d RIIChW. This is because none olthoe obJC(:b tJ l l t.n&- l..ool..an& a1 the 1ruth t1bk for • (Figu~ 7.8 on page 246). we see 1ha1 the •mplalton ., INC' v.hmc\
Per·sorl(::r)) . We can ask quesaions of 1he knowledge b.'ISC using ASK. For example, t-\ SK{KD. Kmg( Jolm )) retums tr-.,e. Questions asked wilh ASK :t.rc called queries or goal$.. Cencrnll)' speaking. any que-ry th3t is logic-ally entailed by the knowk."dge baj;e should be answered aflinnatively. For ex:tmple. given the two preceding as.o;cnions. the quel)'
Ast
Female(m ) A Parl!'nt(m ,c) .
is one's mrue SpQYSC':
IJ x Person(z) "> .. . ~onunatcl y.
first-order logic allows us to make use of the Pt!r'fi-On predicate without com· plctely detilling it. IMtead. v.-e c:tn wri1e p.'lnial spccifi c:uions of ,,ropenies: that every person has :Uld propc-rtk~s that m:tke something 3 person:
Male :\lld female are disjoim catcgOties: V:r M(J/e(r) ~ Female(.:r).
Vz Pt!I"$On(x ) => •..
P..trcnl and c hild are invcrse relation..::: Parer~t (1),c)
"*
V :r ... ::}
ChiM(~', I)) .
V g,c Cnuu/J)(l'ffmt(g, c) 3 t) Pare"t (g.J1) 1\ Panmt(JJ, f') .
A sibling is another child of one's p.1rents:
f. y 1\ 3p
Parr.~Qrl (:r) .
Axioms can al~ be "just plain facts," such as M(J[e(Jim ) and S(lu.~c(Jim , l.twm). Soch facL;; fonn the Mtde(li)A Spoti.Re{h,w) .
v,),r
Using First·Onkr Logic
HtX
Now we can deline addi1ion in tenns of 1he succe.ssor func1ion: 'lf l)r NalNum( nr) => + (0. m) = m. Vm , n NatNum(m) 1\ NatNtun(n) ~ + (S'(m), n) = S (+(m, t•)) . 1lte first of tl~eSe :l.Xioms says that adding 0 to any n3M'J.I number m gi\·es m itself. N01ice the usc of the binary (unction symbol "'+ ·· in the lcml +(nr. 0); in Ofdin:uy mathematics. the tcnn would be wriuen m + 0 usi•'8 infix not:uion. (The nota1i011 we ha\'e used for fi~ ·Otder 9 'Th¢ P 7. IRbflg
Identify the t.ask
A~~ mbl t the
Whal do we know aboul digital circuits? for oor purpoSt.·s. they are composed of wires and g-ates. Signals now along wires 10 dM: ini)'U tenninals of gates, and eaC:h gate produces a
I
' '
Vs Smtdly(s) => .411jacet~t( Jiom e( 1Vtmtpus ) . s),
ins1ead of 1he bicondi1ional. tl'le-n the agent will l'le\'c.r be ,.ble 10 pro"e the llhunu of wu mpu.._~. lncorreet a: c;,.u(9) f:ncode tht> specific problt>m instanct> The c ircuit shown in Figure 8.6 is encoded a." circuit C1 with the foiiO\ving description. First. we categorize the circuit a11d its component g"tes:
c;,.,;, 11 Anty(c., 3, 2) Cnte(X 1)A '/Ype(X1 )=XOR Cote( X,) A '/Ype(X2) = XOR Cnt.e(A1) II 7'ype(A 1) = A NO Cote( A>) II Type(A2) = AND Cote(01) II 7ltl>e(Oo)= OR.
312
Chaj)lcr 8.
Firs:t·Order Logic
8 ,5
Thert we show the connections between them: Connu l« l ( Out( I , X1 ).1n(l , X,)) Comoreled(h o( l. C 1), In( I, X 1)) G'f.tld be d~.."Ci nr.llivc . compositional. expressive. con~ex1 i11dcpendcm. :.nd un:unbiguous. • L..ogies differ in their ontological commitments :.nd epistemological commitments. \Vhilc propositional logic commits only to the existcoce of facts. tirst-urdc:-r logic commilS tO 1he existence of objects ~nd rcl31ions and thereby gains expressive po\.\'Cr. • llle syntax: of firsc·order logic bt1ilds on 1h:.u of propositional logic. II adds tenns 10 represent objects. and has universal ;md exbtentiaJ quantifie.rs to cons.truerson p i is a customer or person 1)2. 8W$(1Jl ,p2): Predicate. PetWn pi is" 00.~ of iX!I'OOtl Doctor, Surgeon. Lawyer. Actor: Con.. 3tl ln(d, E11rope) 1\ -.Bonfers(r, d). (i\') 'Vc ln(c.Soull•America) .o Vd ln(d.Europe) => -. Bonlc~(c.d). ~.
N'o two OOjaccnt countries have the s.nmc map color. (i) V :r,y -.Country(x) V -.CountnJ(y) V -.Bonlers(:.r, y) V ~( MnpColor(L) = Ma,>Color(y)). (ii) V .r. y ( Courltry{.c) 1\ Counlr:y(y) 1\ Bordt:r$(x. y) 1\ -o(z = y)) => ~( MnpColor(z) = MapColor(y)) . (iii) 'V x. y Cotmlr'1J(x) A Cou11try(y) A 8onlel"$(.t:, y) 1\ ~( MapColor(z) = M•1•Color(y)). (i\•) V:r.y (CourltnJ(x) 1\ Co~tnl,:y(y) 1\ BonJer$(x,y)) => J\la,)Co/or(:r; ~ y).
8. 11
Complete the following exercises about logical scnntenccs:
a. Translate into g001/, ~tamral English (no :rs or ys!): V z . y.l Spea.k5Ltmguagc(x.l) 1\ SJ.'(.'f.tJ.·$Language(y.l) => Vnder.stnnds(:r,y)A Urulertress
x,
'•
x,
7,
~
Yo
x, Y:
x, Y,
•·igurt 8.$
z,
~
x, x: x,
• z. z, Y,
z,
~ I~
~
X,
'• '• Yo
7.!
z,
,.
..z,
A (C)ur•bil adder. i!.'lch Ad, ill ;a one•b1t adder, ;all in Fi.gun: 8.6 on pa,ge 309.
h. Then::: is a barber who shav~s all me-n in cown who do not sh:lve che:mselves.. i. A person born in the UK. each of whose paretus is a UK citizen or a UK resident, is a UK cititen by birth. j . A person bom outside the UK. one of whose p:m::nts i.Iic:~tion for your country. identify the rult"S detennining eligibility for a passpon, :tnd lmnslatc them into first-order logic, following Ihe steps outlined in Sela•t•r. r. E\'ery song that McCartney sing." on Rt'l-·o/w•r wa-. wrillcn by McCartney. g. Gershwin did noc write :my of1hc songs on Remla·er. h. Every song th;1t Gershwin wrote has OC"Cn recorded on some album. ( Possibly different songs arc recorded on difTen:m albums.) i. l11ere is a single :tlbum that cor1tains evc.ry song that Joe hn.s wrlne-n. j . Joe owns a copy of an album Ihat has Billie Holiday singing "'The i\-t:ml Lo''e." k. Joe owns a copy of every album that has a song sung by McCartney. (Of cour1e. each diffcrt.'1lt album is inst:rnti:ned in a different physical CD.) I. Joe owrt Evii(Rir.ha.nl) Ki11g(FMher(John)) 1\ Cn:.:Jy(F(IJiter·( Jol,l)) => Et:il(F(I/her ( .Jol,l)).
INFERENCE IN
9
FIRST-ORDER LOGIC
The rule of Uni n~·.rs.'ll l nslan1iation (Ul for sho11) S.'\)'S lhat we c:t.n iMer atl)' scmence oblai~d by subs-tiiUiing a ~round term (a 1cnn without variables) for the vari;rble-. 1 i o write out the inference rule foml:tlly. \lo't use the r)(ltion of subs titutions imroduccd in Section 8.3. Let S UB.)I(O,o) denote the n.·s ult of applying the s ubstilution Oto the sen tence o. Tht·n the rule is wriuen
In wlti('/t Wt' dfjitre (fft:t:til'e
proc~d11rt:S for
mu u·ahrg
qt~cJtiQIIS
'Vtr 0
jJOSt•tl in first·
ordalogic'.
Chapter 7 s howed how sound :md complete infcn:.nce can be aclaie\'t.-d for propositional logic. In this c hal)ter, we ex1eocl !hose results 10 obl.ain algorilhm:o; that can answer any answer· able question staled in li~t ·Order lo~ie. SectiOn 9. 1 inlrodulancLlnJizing :1part.
SUBST(8,J>o')A .. . A SUBST(9.~') implication PI A . .. A p,. ~ q "'~ c:.n infer
S UIST(B.po)A ... A S U BST(9.~ ) •
SU8$T(9,q).
~ow.
9 •n ~u.cd Modus J>onens is dtfintd so tlul SuBST(B.p/)• SI.iasT(I.p.). for a.U t; l~forc d~ fi.s~ of lhcsc t•'O sen1encn ~ lht pcntu;,c ol the ~ t:Ua.ly. IIC'I'K't'. Sl.IST(I. q) folm"'S by ModllS Ponens. ~fll"f'alued Modus Pontns is a lifted '~ion of Modu~ Pontns-lt r.u'I;(S Modvs Pontrn from &:JOUnd ('~·frtt) propos.i1ional IOJ.c to fir~-otdrtr log-c. We "'LU !ott in lbc mot ot th1s t'hOlplff tha1 we can ck\-clop lifted \'Cf'ions oft~ f~a.rd cha..nin&. b.ad:w:atd ch;unil'la. :.nd ~ution algorithms introduced in Ch:~pter 7. The key adVIW'II;age of lifted 1nfc~ncc rules over propos:itionaliz:uion i-(0 th:u they malo.c only thoie sub$tilutions 1h:u a~ teqi.Urtd 10 allow ~kular inferences to proc-ced.
9.2.2
Unification
l~iflcd infcn.•nce rule... require tinding subslitmioni th ~t m!Ll:c: diffel\'nl logical expressions loolo. ldcruk:LI. 11Lis proces.s is c:tlled uniJinuion :uKI is a l.cy componem of ~II ti~.oOrder inference alsorithm!~... ·nu· UNIFY algorithm 1ak~ rwo 'cmcnccll ;u~ returns a unitif!r for t~rn if 01.e ex is~:
UNWY(I>,q)- 8 wh 9.2.3 Storage and retrif",ral llndat)in& the TELL :and ASK fUilC'IIOft'> u'1est way I() implcmem STOR E and F eTCH is to l:eep all the facts in one long lisa ;md unify e3C-h query against every ek.ment of the list. Such :a pi"'Ce$$ is ineJticknt. but it works. and it's all you need to underStand the n:..~t of the chapter. 10e remainder of this section outlines ways to make retrieval more effic-ient: it can be skippe-d on t'irst reading. We c.an m»:e FETCII n.ore eflkient by ensuri1lg that unilications are anernp«ed only with sentences that ha\'c .~om~ chance of unifying. For example-. there is no point in trying to unify K w>ws( Jolm . .r:) with Brother( Ril.'.hon.l, Joint). We can a\'oid such unifications by induing the f3C1s in the knowledge base. A simple scheme c:llled p~dica tc indexing pots all the Knows (~IS in one bud::ec and all the Brotlu:r faces in anOlher. T he buc'-keiS can be ston.·•d inn hash table for efficient access. J>rtdj.c:}te indexing is useful when there are many J>redic:ne symbols but only a few clauses for each symbol. Sometimes. howe\•er. a predicate h-tL'O many clauses. For example. suppose th:u the 1:\X authorities wam to kceJ) track or who employs whoen. usielg a predi· cate 6mJ)IO!J$(:r. y). This would be a very large bucket with perhaps millions of employers
and tens: of millions of employees. Answering a query sut:h a,..:; Employs( :c. RicJwnJ) with predic-ate indexing would require scanning the entire bucket. For this p.:1rtkular query. it would help if facts were indexed bolh b)' predicate: :uld by second srgumcnt, perhaps llSing a combined hash table l:ey. Then we c-ould s.imply COit~truct the key from the query and retrieve cx3CII)' those facl~ that unify with the qucl)'. For Other queries. such :tS Employs( llJM , y). we would need co ha\'t indexed the facts by c-ombining the J>~d icate with the first argument. Therefo~. f:tets can be ston.'d under multiple index keys. rendering them ir~:uuly :tcces:sible 10 v:uious IBM employ? Em,)Jous(x. y ) \Vh() empiO)'S whom? Em,>I<Ju$(a:. Richard)
These que-ries form a subsumption laHiee. as shown in Figure 9.2(a). 1bc l:mice has some interesting properties. For example. the child or any node in 1he lattice is: obtaint'd from its p.'l.rent by a single subs1i11nion: and the "highesf' c-ommon dc-sccnd:mt Qf any two nodes is the re..:;ult of :.pplying the-i r nlOS'I general unifier. The portion of the lanke above any ground fact c:m be cons,.m•ctcc contains a small numbe-r of nodes. For a l'redic:tte with 11 ~u n)('.niS.. howe\·e.r. the lattice contains 0 (2") nodes. If fmK'Iion srmbols nre allowed. the number of nodes is: also exponential in the si1.c of the tenns in the sentence 10 be stored. TI1is tan lead 10 ;). huge number of indices. At some point. the benefits of indexing are otuweighcd by the costs of storing :Uld maintaining nil the indices. We can respond by adopting a fixed policy. such as 1naim:.ining indiC\".S only Qn keys composed or a prcdicrue plus each argumt"nt. or by using an ndnp1iw policy th:u creates indices to mee1 the demands of d~ kinds of queries being asked. For mo.sa AI sysaems. the numbi.•r or facts to be ston" Respo,l.se arc especially useful for S)'Sicms that make inferences in response to newly arrivtd infocm;uion. Many sys1ems can be defined this way. and forward chaining can be implemc.·ntt-d \'Cry cfiiciently.
Thi! idea
9.3.1
First-order definite clau.ses
FirsH>rdt.·r dc:Jinite claui'C',. closely re-semble propositional der1nilc d:tuSC$ (p.1ge 256): they are disjunctions of litcrnls of which c>.•wctly 011~ is positil"e. A definite clause either is momic or is :m imj)lication wl1~ :ultectdtnt i.s a eonjunOSitive·lite1'31 l'eSlriclion. but man)' ca11. Consi«r the foliOVo•ing problem: The law ~ys tbat it is a crime for an American to sell weapons to hostile nations. The country Nono. an tncmy ot AmC'rica. has some missiks. and fill of its missiles wtrt sold to it by Colonel Wt.~• . wflo i:s Amcrie:•n.
We will PfO''e that W~t is a criminal. F'in;t. we will rtpttscnt these fac1s as tirs1-order definite clauses.. The next section shows how the forward-chaining algorithm solves the problem. " •.. it is a crime for an American to sell weapons to hostik natiOn5'': Americort(z) A IVcapqn(y) A &lU(a-. y. z) A J/ostik{::) o Crimimal{z),
(9.3)
"Nono .•• has some missiles: · 11testntenee 3z Oum.s(Nono.J:)A Mi$sile(z) is t~sformed into two definite clauses by Existentirtl lnstrtntimion, introducing a new const.:uu .\/ 1:
Owr1$(N01to, J\11)
(9.4)
.!liR3i/e(M 1)
(9.5)
..All of its missiles were sold to it by Colonel WesC:
We will also need 10 know tOOt missiles are weapons:
Mi.ssile(x) =>
Weapor~ (:£)
(9.7)
; lmen'CQ) =>
llost il~(.r;).
(9.8)
··wcsl. who is American .. .
Ameril.'llll( IVest) . '1'1~~: c.-ounuy
(9.9)
Nono. an enemy of America .. ."·
Ent!my(Noflo . America) .
(9.10)
This koowkdg.e ba.o;c contains no (unction symbols and is therefore :u1 instance of the cla.s of Oa t.alog knowledge OOses. 0 :-u alog is a l angu~ that is resrricu~d to fin;l-order definite clauses with no function symbols. Oatalog gets its nrunc blx·;tuse it c;m repn.·~o;cnt the type of ~:nemcnt.s typically made in relational databa..~. We will see that the absence or funcc ion symbols m:tkt.·~o: infC'n:nce mm·h easier.
9.3.2 A simple forward-cha ining algorithm The first forward NatNum(S(n )),
fo r cach b!>~.tetl lh;ti $U&ST(0.1~ A,,, A p,.)= S U6ST(0.pt A ••• 1\ p~) (or SQfne pt, . .. , p~ in KO
Vtl
,, ..... S U6ST(0,q) i.r f/ do\.~ no! unify wilh $Orne sentence :.ln·:ldy in Kl) or m"'u' IIK'II 1 add q 10 IH"Uf 9 - UN"tFY(q'.CI) if 0 is not foil then return 0
then forward chaining :tdds NulNum(S(O)). N(JlNum(S(S(O))). NatNwn(S(S(S(O)))). :tnd so on. This problem is un.'l\'()idable in gener:.tl. As with general lirst·order logic_. ent~il rnt.·nt with definite clauses is scmidecidable.
9.3.3
add Jlt-11'1 10 K 8 rtlurn fo~c
•·igun.' 9.J A conccptu;ally Slr.tig.htforward. btn V('l)' ind lk icnt rorward,haining al,go· rilhm. On c-liCh iter.ttioo. it adds to KB nil the ntomic S('ntenc-es that can be inferred i.n one S'ep (rom the implicnzion S('.ntc:n~;es and the :uomit SCniCntlC$ lllrc;td)' in KB. lbe function STANDAR.DIZE·VARIA81..ES n.•pi;K(;S all \•ruil'bk$ in il$ l.lrJUm('-111$ with RCW ones lh;U h;we no1b«n uscd before. C"""-''WtM;f
.l
Aowroh.,(M',~I
w......f""(M1)
I SrliJI! WrM.AI
'The 1>roblcm of matching 1he J)rtmise of a l\lle agains1 the facts in lhe knowledge base migh1 seem simple enough. For example. suppose " 'C want to aptll)' the rule ~..._)
\A
,V.ulk(M )
The forwW·cl"1ining algorithm in Figure 9.3 is designed for ease of underslanding rather than for e ffi c-iency of operation. Thf:re an: 1hrcc- po$siblc sources of incftlc-ienc-y. f':irst. 1he "inner loop" of the algoritlun invol\'ts find ing aU possible uniliers such that the premise of a rule unities wilh a suitable sel of facts in the knowledge base. This is oflcn called Jlattcm mald 1ing and CM be w:ty expensh·e. Second. the :tlgoritlun n.--checks every l\1le on e '·ery itct:u ion to see whether' i1s premises are satisfied. e"cn if very few additions are made to the knowll'dge base on eac-h itemtion. f inall)'· the algorithm migtu gencr.ue m any facts l.hat are im:lev:uu to the goal. We address e..c-h of these issues in turn. M alchinJ:t ruJes against known f<Jc iS
~\ 1 I
~YROtf!O
Efficient forward chaining
0•••••.1(,\~.J.t )
u,uUrl.N-)
Mi.tSile(:r) =>
ll'et~J;tOn {:r) .
'Then we need 10 fi nd all the facts Ihal unify with Mi.'<Sile(:r): in s suitably indexed knowledge txLSe. this can be done in constant time per fact. Now corL~ickr a rule such ;IS I.M.tt)f.,\'-~)
f'igun• ?..a The prooflrce gcncr:ucd by forward dlainin.g on the crimecxampk , lbe inilial facts ~ppc-ar a1 the bottom level. facts infcmd on the firsl ilcr.uion in the middle k.,.el. and facts infemd on the .seoond ilcmtion :u the lop le.,.el.
possible f:K'Is that can be added. which dctcnninc!'i tlx- maximum numbt-r o( itenuions.. l et k be lhe maxim um arity (numbei' Of al'guments) of any predicate. p be l he 1U1mbcr of predicates. and n be the numbt-r of conSI 334
lnftl\'l'ltt in Fio.t-Ordcr Logic
33S
Forward Chaining
S«t10n 9.3.
Australia from tbc map in Figure 9 ..S.Iht' ~ullin& cla.u~ i~ D>/1(n. ot) 1\ D>/1(•1. 9) 1\ 0.61•· ••w) 1\ 0./1(,_, el1 systems. M1my other ~imil:u lt)'Stcms have been b\1ih with the same undel'l)'ini h"t .. ' hnoloi)'. which has been irtt)>lemcrucd irlthe gcncml-puq>Otse language 0 1~~-S . l~luc.1ion systems arc also popular in cos:nilh•t Ul'\"hiletrict forw:1rcl ch:1ining 10 a selecu.-.:.1 Mlbscl of ruks. 11!1 in J)L·I:C-ENTAILS"! (p.:tgc 258). A third 3Jll)roOCh h~ oc emerged in the tlcld of declucth·\' databases. which :u-e large-scale d:uaOO;;cs, hke n:h•riortlll dat:~ba.,cs. but which usc fo~rd ch.ltininr. :as the standard infert:nce tool mther thln SQL qucrb. 'The idca is to rewritc 1hc rule '-d, u.!>inJ information from the 'ool, so that only rclev.nt \'llriablc btndinp-chOSIC' br:lanJ-i~ to a so-alled m~k ~ t<Mbidct'N duri.nc forward infc~. For example. if the coal b. Cnmmol( lVcsJ). tbe rule that concludes CnntrnGI{.r) v.lll be ~·nucn to uxlude :10 c-~tnl con.,una 1hu const:rains lhe: value of .r:
337
~
A bacan:h--thc OR p.m b«au..se the goal query ca•' be proved by :any rule in the- knowlcdic ba..e. and lhe ANO part b«.aus.e all the- conjunl'ls in the U1s of a clause must bC' p~d. I':OL-OC·OR wotl~ by ftiC-hing all cl;ube$ that might unify with the goal, stand.'ltdizing the ''arbbles in the cl:mse 10 be brand-new variables. and then. if the dt.s of the c lause doe'> indt.~d unify wid1 the gool. pi\Wing every pendl"d to give ( 1 , 2 ) ? We get back the solutions Y• (l,2 ) ; Y• ( 2) ; X• (l ,2 J Y• ()
X• ( I X• ( 1)
The execution of Prolog progr.un:s is done through depth·fin>t b.'ld:w;ud chaining. \Vhere clauses are tried in the on:lcr in which they arc wriucn in the knowledge b.a~. Some a_pl:!:;':;'_9 :;·~_;1 nfcn:nc~ in Fi~t ·Otder Logic:
•
Scc1ion 9.4.
£oal ..X ia 4 +3" succeeds ">itb X bound 10 7. On the OCher hand, d.e aoai''S is X+Y.. falls. b«MJSI." thr buLit-in functions do nol do n.r.uy fqualion \01\ .......J ~art' bualt-m prtchcates tJut ha\"(" sHit df«U "hen f\CCUiccl ~ mdude inpuiOUipul pn::d~ and lhe •ssertJretract rmhal~ f01 mocJaf)a!'f. tht tno.~ ""-". Such pmhan U...- no count<rp011 '" loco< ...! con P. so~ ProiOJ; compi.~ compde into an tntemMxhatr tan,uage rather than di~ly into ma·· chine langu~e. Tht ~ populJr intr-nntdaatt l.angu~ ij 1hc: W~ Abstrxt MxhiM. or- WAM. nmlN after O=evid H. 0 . Warrc-n. one of tht unpkmmttrs ol the tirst Proloc rom,. p;ler. The WAM is an *trxt ) d a..·~ ~t.uW* ror Prolog and can be eilhn mlerprekd or IDMLued mto mxtunt 1211~. Olhn compdtrs lr.lnSJ;a~c .Prolos: 1010 a h•Jh· k\-cl ~such as Ll5p or C and tt.rn u~ ttut l;ang~ ·~ c:-ompiler 10 tr.!nSbte 10 madtint bft&uaJC'. Foteumpk~ lhe dtfinition ol the Append ~It can be com_p ikd imo lht codt ~·n in FiJUIC' 9.8. Sc\·craJ poanu iii'C \loorth mcntiOnlng:
Jo:Niclcnl inl(lltmcntation of logic l )n )gnHn lO
ITII'M.Wed from the 1raiJ. E\'m the n)Q!;.t d6cimt Prolog imerptt1ns «quire ~·ml ahou~ machtlll!' tns.trucltOn~ ptT 1nfcrmt'C' step because of the cost of index looLup. untfk11taon. and bwldtng the a.ll ~aeL In efT~ the iderprtter al\lo'a)" bm&'\"C"~., 11 bas DC'\c-r S«n 1ht pro,.., broccdun: :u\d :1 lis.t of argun1enL.: tllill together define what should be done nex1 whcne\•cr the C'Uf'l't'nt goal succeeds. It would 1101 do juS! 10 rerum rrom :t prooedun: lil.e A Pre~o " hen the goal SU«eeds. becau~ i1 rould succeed in ~eraJ >A'3yt, and each of them has to be cxplol't'd. The roruinu:ulon arp.ment sohu lhi3> probk-m btcau'-C: 11c:ua be caUed eac-h time the goal succte&.. In thr APPE.'IOD code. if the fif'JOI :ars,unlent •~ empty and the S+eCOCld argumen1 uni.6ei w1th ~be 1hird. tben the: APP£.'0 pmbcate tu\ ,t.K'C'Iteded. We theft CAU. the continualion. •ith lhC' approprioue btndmp on the 1r21l. 10 do ·~a- sboukl be done no:t. Fu aanpk. if lhC' calllo API'F'D "C'rt II lhe lOp b"d. tht rontinwllion "A'OUid pnnt the • R;dher
--
bindinp of die~-
lnfcn.·•n
342
in Fio.t-Ordcr Logic
S«1a0n 9.4.
343
B:td:.w.ard Ch:tini.ng
BdOte W;~mn's "'-ork on the compil:uton or inJcrtnee •n ProiOJ.. lock progr:unming was too'~ ror f!tr'IC131 USC'. Compikts by Warrtn and otht" allov.·nt Prolos c()d(' tD achioe\·~ ~ thai ilK rompc:titi,·e wilh Con a \'anC'I) of stanlibnl bcndm.:.rU (V;an RO). 1990).
Of ('C)UN', lht
(:ll."t
dut ~can "Tik' a pbnntr or uural bn~ pat'li« 1n a '""' doznt
lw< otl'nllot nul.ts ~
-lw,.... de ean be soh-ro m 1>ar.tJiel. The ~nd. called ANI).panlllt:lisrn, rome!l from the pos,;ibility of soh•ing e:r.c:h coojunct in the body of :m implic-:ttion in parallel. ANO··~ m ll clhm i'i more: difficuh I() ~hiev~. ~cau~ liOiutions for the whole conjunction n.-quire (01\\i,tent bindings for :all the vari nbl t~. Each conjuncth·e brnnch must communic:1te with the Other brnnches 10 cnsun:= a gJoOOi liOIUiion.
9.4.4
B
C
small·sole AI
-rn>JCme lr:nowledge b.'lSCS. it faiL.; 10 pro,·c K'ntttw:t 111:11 :1re l'ntaill-d. Notice that (o~td cl"'lining does nor suffer rrom thi:( problem: once path (a , b). path (b , c) . and pat h(a,c) :u-e inftrred. forw;m.1 chaining halts. Ocpch·fiN b.1ckward chainins also has problem. with 1\."SC of which invoh•e finding all pos.gk prognrnmJn& (CLP) ai!O'o\~ ,~...ri;~blt).tO be ~onsrru;rwJ ~than hound. A CLP solution is the- most "-fl«•tk "• Z >• 1. SlMCbtd kJsliC ~ att jtJsa a spttW C"O , Y>O, Z>O, X+V>•Z, Y+Z>• X, X+Z>•Y. If """ as1 Prolo:c the qutf)' triangle (l , 4, S). 11 .,_u«ftds. On the other holnd. if ..-...-easl. tr i anqle( 3, 4, Z ). no solulion will be (ound. b«:au"'C lbt $Ubfcxll Z>•O cannot be twldkd by Proto«: ,..-e can't comp:we an unbound \~lit aoO.
9.5
R ESOLUTION
Tbc bsl of our lhrtt famihes of k>Jcot.l \)"'-tnl'' '"' bbtd on rtie>tution. \\'"c saw on~ lSO tbOJI propositiorW roolulton wmg n:fuu~~ron ~~a compkle 1nfermcc prooedUI'C' for~· tKJRal !ope. In this ~1011. v.-c ~be: hl,w. 10 c-xltnd nosolutton to 6M-ordcr los,lc.
9.5.1 Conjunctin nomud form for llrst-ordtr logic As in the prop for negated quamificrs. Thus., we h.wc -.'ttl x p lx."(.·ome:> 3..: ...,p -.3:r ]) becomes V -r -.p . Our st"11h"llCe goes through the following tr::msformations: V z J3y ~(~,lnimal(y) v w •"<s(z.y))) v (3y Lo ~ Kill$(u,
v)J
-.J.o.t.tt.~ (u,v) .
wilh unifier
[;humal(F(z)) V ~ Kill• ( G (x).x)j. IIIM'I'JOOu.mOM
This rule is ~led the binary rtSOiulion rule bt'talbe it resol"es exactly two litcmls. The binal)' resolution rule by i1sctr docs not yield a complete inference pi"OC'Cdurc. The full resolution rule resolves subseu of lite.r,lls in e.ach clause lll:ll :.ue unifiable. An al ~emative :lA>rc.>:JCh is to extend fae1oring- 1he removal of redundant litemls-co the first-order case. Proposi· tiona! facwring reduces two literJls to one if 1hey are idt•t~tkul: lits:t·orde-.- f:Kiorir\g reduces two litemls to one if they are unifiable. ·n~ unifier must be applied to the entire clause. The combination of binal)' resolution and factoring is complete, 9.5.3
Exa mJ)le proofs
ResolutiOel pr'O\'e$ th.'ll KB F o by provi1lg KB A...,(\ unsalisfiable.that is. by derivi•l8 the empty clause. The algori1hmie appro:lch is idem i ~ to the proposi1ional case. described in
348
-
....
Ch.1ptcr 9.
.........
--··.:--:~.-)
hlference in First-Order Logic
-~··-,:1 ...-.J-IJ
~
-...:/
B.
V-r (V y .4nimal(y) => IA>ve.•(x,y)J ~ (3y Lo~s(y. .r)j V < )3: ,lnimol(:) 1\ Kill>( )V y ~L•~•(y. Lot~s(JacJ.:,-r) Kili$(Jock. Ttma) V K ilt.,( Cu•iosity. nma)
A.
~ N.N0..:NJII"',.,_U
C. 0.
.lfl-....:.11,1
""'~olv...ow.,_,.__.,,~.~
E.
Cat('l\ma)
F.
V:r Cat(:r) => Aoimal(x)
•• ..u..... - ........ ......
0.•\'~J
~·--.. WJ-ot ~•.._.AafflHJ
-·-
~M(.\1-.U,)V~'"-'i
-.G.
4' .-J'. Any "' or '""""' S Is
m1mber Q/rc-solmimr steps 10 S will yic•lt/ a ctHurt.ulictimr.
Our proof skefC.h follows Robinson's original proof with some simplil'i~tions from (;enesercth :md Nilsson ( 1987). The basic structure of Ihe proof (Figure 9.13) is as follcw.•s: I . First. we observe tl.:.t if S is uns;ttisfiable. then there exiSis a p.'IJlicular set of grotmtl iruumcc-softhc clauses of S such that this set is :also uns:uis'liable (Herbr.md 's theorem).
2. We lhtm :appeal to !he gnmnd n...">C•Iution theorem gi\'en in Chapter7. which states that propositional resolution is complete for ground semenccs. 3. We then use a lirting lemma lo show !haL for any proposiliomll resolution proof u.o;ing 1he SCI of grotuld sentences. lhen: is a COI'I"eSpoElding fitst·orPfOOCh handles equalil)' reasoning emittly within a•' ex• coded unific:uion algorithm. 'J'hat is. tenns are unifiable if they arc pmmiJ/y equal under =-ome substitution. where "provably" allows for equality te:ISQning. For cxa.rnpk the •enn.s I + 2 and 2 + I oonnally arc not unifiable. but a unification algorithm that knows that x + y = y + x could unify them with the empty subslitulion. Equa tional u •lifi~fion of this kind can be done with eflkient algorithm..:; .hould be corrclalcd wilh ils si1.e or diflicully. Uni1 clauses :ue treated as light the sea.n:h can thus be S\.---cn as a ge.ner;dizatiorl of the unit preference slrntegy. Se~ of support: Preferences thai try ccn.ain resolulion..o; first are helpful. b.n in general il is 100tt effooive to try to e liminate some pltntial resolutions :t1together. For ex:unple. we can
insis1 1ha1 c."VCry resolution step involw at least one elcmcn1 of a special s:ct of c-lnu.o;e.o;- the of SliPJ10r1. T he resolvcru is the-n added into the set of suppon. If tJ..:: set of SUJ)port is small rdativc to the whole kOO\Io•kdgc b.1SiC. Ihe search sp3CC will be n.'duccd drnmtttically. We ha\'C 10 be careful with this 3PJ)I'Oa0n will make the algorithm incomplete. Howe\'er. i( we choose the set of suppon S so that the remainder of the sentl."nct.~s are jointly satisfiable. tht.•n sct·of·suppon resotution is complete. For example. one c.·m use: the negated query as the set of suppon. on the :\$...'Q.IIllplion that the S('l
Ch.1ptcr
356
9.
hlference in First-Order Logic
original knowltdge OOSe is consistent. (After all. if it is noc consiS'Itlll. then the fa¢1 that the query follows from it is \':K'liOUS.) The SCI·Of·support stmtcgy tms ttl.! additional OOvant:.ge of gcner.uing go.o•tJ-directcd proof trees that are often easy for humans 10 urKk-rst:tnd. Input resolution: In thi..o; stmtcgy, t:vcry resoiUiion combinc·s one of the input SCllU"IlCC-" (from the K8 or the query) with sonlC other sentence. 1be proof in Figurt 9. 11 on po'lge 348 uses only inJM resohuions aoo hss the charocteris.tic shape of :'1 single "spine" with sing.le sen· tcnces combining onto the spine. Clearly. the SJX'Ce of proof tn."t's o( this shaCC of all proof gmphs.. In Horn knowledge b.'I.SCS. Modus Ponens is a kind of input resolution stmtegy. b.-cause it combinc.-;s an implication from the original KB with some other semcoces. 11ulS. it is no surprise th:~t inpur n:...~hui on is CQrnpletc for knowledge ba.~ th.11 are in ~1om fonn. but ir)Complcte in the gt•ner;tl case. The lintar n"SSiulion ~Lmtt.-gy is n slight gencrali:r.1ltion th:u allows P and Q 10 be resolved together citi'ICr if I" is in dw: original K 8 or if P is an ance.;,:tor of Q in the proof tree. Linear ~lution is complete. Subsumplion: The s.ulmunption method eliminates aU sentences th;'lt are subsumed by (that is, more specific than) nnexisting sentence in the KB. For example. if P(:r) is in the KB. then there is no sense in adding P(A) and even less sense in :.Wding P( A) V Q{B ). Subsump1ion helps keep the K B small nnd thus helps keep t~ scn.rch sp.'lce small. Prarolog's clauses were imcndcd initially a..; context·rn.-"e gr.•mmar rules (Roussel. 1975: Colmer.tlk'r ~~ a/.. 1973). Much of the the· oretic':l.l background for logic l)rogrnmming was dc\'elopcd by Robert Kowalski. working
indcp:ndt.'lllly by Smith et al. (1986) and Tamaki nnd Suto (1986). The lam~r paper nlso inclugr.umning (Gel fond. 2008) exte-nds Prolog. aiiO'o\•ing disjunction and negation. Texts on logic programming and Prolog. inc-luding Shoham (1994), Brntl:o (2001). Clocksin (2003). and Cloc.ksin and Mellish (2003). Prior to 2000. the Jounwl ()j Logic Pro· grtrc also developed indcpendcnlly in lhe c.:ontext or lcnn -rewriting S)'Stl.'l11S ( Knuth and Bendi.x. 1970). The inc-orporation of C'(lualily reasoning into the unification a_lgorithm is due tO Gordon PlOtkin ( 1972). Jouannaud and Kin:hner ( 1991) sun'e y t-quational unification from a tenn-rewriting perspccci"e. An overview ofunitica1ion is gi"en by Baader arx.l Snyder (2001), A numbe-r of COIItrol str.ltcgics ha\·e been proposed for n.'SOiution. bcgiruting with the unit pn:f1!'-rence str.ucgy (Wos t'l til,. 1964). The set-of.support strategy was proposed by Wos C'l til. ( 1965) to provide a degree or goal·di rtC~ednes..; in resolution. Linear resolution first appeart.-d in Loveland ( 1970). Genesertth nnd Nilsson (l987. Chapter 5) provide a short but thorough analf$i..~ or a wide variety of control stmtcgics.. A Compmmiotutl Logic (Boyer and Moore. 1979) is the OO.sic reference on the Boyer· Moore theorem prover. Stickel ( 1992) OO\'Cts the Prolog Technology Theorem Prowr (P"n"P). which combines the :~dwunages of Prolog compilation with the completeness of model elimi· 0111ion. SE'l'HEO (Let£ ~~ al.. 1992) i.s aoothcr wi<Jci)' used tht•orem pron•r ba-.cd on this ap· pro."'ch. LEANTAP (BeckeR :tnd P()S(gga. 1995) is an efficient theorem prover implemented in only 25 lines of Pmlog.. Wcidcnb.1ch (2001) describes SPASS. ooe of the stralgcs.l cumnt theorem provers. 'l'he most suoccss(ul tht."'rt.'ln pro\W in rct"t" nt annual competition..; ha~ been VAMPIRI! (Riazanov and Voronl.:ov. 2002). The COQ S)'SICtn (BeltOl Cl ttf._. 2004) and theE
('I"'·
360
Ch.1ptcr 9.
IJ1ference in First-Order Logic
e<Ju.'l.tional solver (Schulz. 2004) have also proven to be valu ab~ tools for proving correct· ness. Theorem provers h:m: been used to :mtom:uically synthesize and verify sonwarc for controlling spac::e w +x:5 y + .z. S.. Vz.y.: ;e'5, y l\ y '5,: => :c-5:: a . Give a backward-chain ing proof of the .scnt"'nce 7
'5: 3 + 9. (Be sure. of course. to use
OOI)' 1he axioms gi\'en here. n01 :my1hi1lg else you may knov.· ~bout arithmetic.) Shov.• only the steps that leads to success. not the im:-lcvant steps. b. Give a forward-chaining proof of the scmcoce 7 '5: 3 + 9. Again, show only the s1cps that kad to success.
9.10 A popuk1r c-hildren's riddle is "Brollli.·N :utd sistcn; have I none. but that man's f~ther is my f:uhcr's son." Usc I he rules of 1hc family domain (Section 8.3.2 on page 301) 10 show who that m:u1 is. You m:1y apply any of the inference mC'lhods descrilx"t't in this chapter. Why do you think th::\t this riddle is dif'licull'? Suppose we put into a logtcal kr.o"•ledge base a segme111 of the U.S. ce.ns.us dat:t liSl· ing t~ age. city of residence. date of birth, :md m01hcr of every person, u:;;ing social se-curity numbers as idtluifying, constants for e~ch pcroon. T11us. Georg:e's a.ge is given by .4ge(443-65-1282 , 56). Which of lhe following indexing schemes S J-$5 enable :u1 efficient solution fot which of the queries Q1-Q4 (assuming nomutl b:-.ckward chaining)?
9.11
• St: :m index (or euch mom in eoch position. • S2: an illde;( fote.'tCh fii'St argumem. • SJ: :ut index (or c.•uch prcdk;;~te a1om.
• S.&:
9.12 One might suppo.'l(' that we can avoid the problem of v.1riable conJlict in unification durillg bac-kward chaining b)' &tandardi7.ing apan all of the sentences in the knowledge base once ;md for all. Show thiLt. for some sentcoccs. this approach c:umot work (llil1t: Consider a semcnce in which ()ne p.·u1 unifies with ano1her.) In this excn.:-isc, u."t: the sentences you wrote in Exercise 9.6 to snswcr a question by using a b:"1ckward·Chaining algorithm.
1.0 !£ 3. 2. 7
• QJ: MotJ.er (.z:, y) • Q4: ; lge(:.:, 3-1) A Residesln(:r, Tit~ y Towri US;l )
:u• indc;( for e.1Ch ~omMt~lllilm of predic:atc and first argument.
a. Drnw Ihe proof 11\.'C gcncrntcd by an exhaustive bac-kward-t'h:.ining algorithm (or the que-ry 3 h llonse(h ). where e-l ause..~ are matched in the orde.r given. b. What do you notice about this domain? c. Hov.• many solutions for h ac1u:.lll)' follov.• fr'OJn your Sn. primarily ~ a«ur.ale heurilCia lh=ll ean be~ auKJnWI(";lll) from tbt- SIJ\IICtUrC' oltbt- ~lOR. (l'h1s rs co 1ht .....,)' m •'hkh eff«''.n'e dom-aan·inckpmdenc hcvtislia: ·~ constnK'N (Of C'(llbiDAnl3o;llli:)fxtion pt(lblcms tn ~pen 6.) S«t110n 10.3 sbcrr.-os 00.• ~ dlla wue1un: calk-d Lhe planrunJ Jraph nn mate lhc' -.e::utlion means that 7M~ck 1 and n.,it'kt :art: dbtinct. The following llucnts :u~ um allowed inn lltatc: At(r, y} (because it is rl(}n-g.round). -.poo,. (because it is a ncg:uion). :rnd At(Nrthf·•·(f 'h'rl), Sylirli"U) (because it u..o;es :t function ~ymbol). The reprtSlnne from one location 10 mlOCbcr:
an»ocous
10. 1
In response to Ibis. pl:itlnina ~arthtf' tQ\·~ ~ttltd on a factort'd l't'PI"'C'St.ntatiou·OM in "'hich a state of tht is I'C'pR:st:nkd b) a coll«tton or \-ari.:l.bks. We USt" a l;;an&u:..~
'l'he problem-solving ~enc of CMp1er 3 can find M.XJUCrM:c~ of aclions lh:at re~uJt in a g.
"""
Jlt(t>.to))
The schema consins ()(the ac1ion nanl(. :a JJ,I of all the v;ui:ables used in lbc: schema. :a pl"t'l"''ndition and :an dfc.'CI. Afthouah 'AC ha\·cn'l '\tid yet how the :action schema convem into log.ical sentenec:s. think of lhe vatr<Jblc"' :b btin& uni,~ly qu;antilied. We art rf'f'IC to chc.:losc wtwC\·er \-.dues we "~ to r~IW'Ih:&tc 1he '"-;sriable:s. For aampk:. hen- is one Jround I
POOl. •-. ckri\"Cd (,_ ~...,... SHIPS,..... ~fitn _, Nibtoa. 1n1). n.da K .....,
The ~thon and dftce of an aetic:ln are Qth conjuntt~ ol ht(fllls (pos.n.,'t or rqaled 1lar pm:'Ondition Ortlllion plnnning probkm.
ig a conjunccion of ground :ttom .... (A~ .....-ilh all Malts, 1he dosed-wOrld a~..umplion i..
ustd. which means 1ha1 any :uom,; 1N1 are not mentioned are fal'lt'.) The: goal i!i just like a pr«ondition: a c:onjunc1ion of littr.d3o (po!!oithe or nqall\'t) 1ha.t may (:()l'llain ,"aJia~e), such :as At(p, SFO ) 1\. Plont(p). An)' \'llria~e~ an: ln-al~ as o:i~1nniaU y quantified. so 1hi~ p i
i§ 10 ha\'C any plane a1 SFO. 'l'llc probkm ... \Ohcd \\heft \I.e can find a sequence of xtioru, RtehA Famous A .\/lSN'dWf. Mwls 1M~ R~lt 1\ Femoh, and the ~t Pr.ttnt{ Pt.on~t) 1\. At(Pt.n.t 1.SF0) mttlls th< pol At(p. SFO) A Plont{p). NOOA \\C b:tYCckfinedpbnninJ a,. a \C'~h problem: •e ha\'e :11ft inilial $We. an ACT10'S func11on. a RESULT (unclion. and a JO)ItN. We'lllook Ill. some c.xampk probLems before un-c~gating dfidml .)('ateh alsonthm...., ltulmd in astJlt' s WI entails the~- Fort\ampk. lb: )bk
10.1.1 Example: Air c:urgo trunsJ)·Orl
(10. 1)
l:or cx:UllJ)Ic. wilh che at;lion Fly(P 1• SFO, JFK). we ""ould n:mo\'e At( P1, SFO) and add At(P, ,J,..K). It is an.."quiremcnt of :te1ion sc-hcm ~.;; dun !til)' \'llri:tblc in the: cfrL~I nuL'It also apjliCIIr in the pl\.~ndition. That way. when the 11n•condition i, lllL\Iched a.gai1h-l the St:'lle $. all the \'~ri :•bl cs will be bound. and RESUI.T(s, ll) will diC'rtron:: htwc only ground atom..'l. In Olhcr word, grow)(! S:I:UCS are closed undtr the R BSULT OI:N..'r.uion. Al\0 note thai the fluents do not explicitly rt'fer 10 lime. •~ dw=y dKi m Chap1cr 7. n.e~ \\.C fftded I>UI)CDCripts (or Lime. and SlK'Ce.'iSOr~tatC ~'{Mil~ Ohhe form
r
Dtlinitioo ofOa~ic:al Pl;anninJ
,•aJues for all the \'31rillblt:":
At loon(FI,(P,. SFO. JFK ). P.._co,o:At( P 1.SFO) A Pl•nblem Consider d)C problem of changing a Hat tire (figure 10.2). The goal is 10 have a good spare tire property mounted onto the car's axle, where dM! ini1i:tl st:uc has a fl at tire on 1he a.dc and a good spare tire in the trunk. To ket·p it s imple. our \'Crsion of the probkm L;; ;m abst ract one, with no sticky lug nuts or other complic:uions. There arc jusr four ac1ions: remo\•ing 1hc sp;u~ from the trunk. removing the flat tire from the axle. pulling the sp.1re on the ;tx.le. and leaving lhc C3r unattended O\'cmigtll. We assume thai lhc car is p.ukcd in 3 p:ulic ularty bad neig.hbort)(l(')d. so that the effec1 of leaving it O\'entighl is; thm the tires disappe3t. A soluti011 to the problem is ! Re m(me( H~l, A%/e), Hemot-e(SrJ(u'e , 1hmk), PutOt~(SJIMY: , .4%/e)j.
lmt( Tu'f:(Flat) A Tu-e($pctrr.) A ;lt(Flat, ;h/e) A ;U(Sparr. , 7hmJ:)) C..U( At(S,...,, Anund) A ~ At( FTat,A.dc) A ... At(Flat . Tnm.k)}
Fi)lure 10.2
The ~in1ple sp.:.tn: 1 i ~ problem.
10.1.3 Example:
TI1t
blocks world
One of the m()SI f:unou:S pl:1.11ning doma.ins is known as 1he blocks world. T his domain consists of a s-:1 of cube-shaped blocks siuing on :a 1ablc.2 1lte blocks c:ul ~ s1nckcd. but only Ol'le block can 111 di l\.~l y on 1op of illlOlhclldCnl hc-uri.stics. whereas systems b,'IS(':d on s-IC(essc>r· st:tte :txiOOls in first ·o~r logic have had less success in coming up with good heuris tics.
Section 10.2. I 0 .2
Algorithms for Planning
as St:tte..Sp;K"C Searth
373
A I GOR!THMS FOR PI ANN ING AS SWE-S pACE SEARCH
Now we tum our attention 10 planning :Ligorithm.;;. We saw how the description of a phmning problem dc-~ nes a search problem: we can search (rom the initial Slate through the sp;1ce or s t:ues. looking for a goal. One of the nice adv:tJu~ of the declarati\'e reprcscnt:ttion of action schema._.; is that we can also search backward from the gou.l. looking for the initial state. Figure 10.5 COfiiJ>3.r'CS fOtwMd :tnd backward searches. 10 .2. 1
Fonra rd (l, rogrt.-ssio n) sra t e~spuce S(.-arch
Now 1hat we have shown how a planning problem maps into a SC:'tteh problem, we ~n solve planning problems with :Ul)' of the heuri~tic search algorithms from C hnpter 3 or a local search algorithm from 0 1aptcr 4 (provided we keep track of the sc1ions used to reach !he goal). From the earlie-.st d:ays of planning research (around 1961) until around 1998 it was :~ssumcd th:'tt forwanl stale·space search was 100 incfl'Jc.ienl to be prnecical. It is not h:ll\1 to come up with reasons wh)'. First, forward scn.rch is prone co exploring irrelevant ae1ion.s. Consider the noble tao;:k or bu)•in_g a copy of AI: A M()(lf'm Approod1 from an online bookseller. Suppo.se there is :u1
(a)
(b)
ti~:u rt 10.5 1\\'0 :~ppi'OO('hes to sca.tching for a pl::m. (:'1) f·orw:~td (progttss:ion) ~ateh through the Sp:ttt of StaleS, Stani11g in lh(" initiDI Stille oocJ using the probkm's ~tions tO stareb fotwtlrd (ot a member of the set of goal StlliCS. (b) 811C'kward (rc-grt"ssion) search through sets of rt"k\·:uu StlltCS.. staning :111hc stt of st:ues ttp~nting the g<Jal and llSing the inverse of the actions to search Wick"''Drd for the inilial st:ue.
374
Chapter 10.
ClCCt 3 """' ... hcuri~tic function /l(.'$) C!'! limalc;oo, the dhlance rro.n "' $10\tt $ I() the go:1l :md thai if we can derive an admissible he1.1ri'\lic for 1hi~ di._.ance-onc thai does not
ovcrc,tim;uc-thcn we tan use N search to find O))lint:tl :iOhllioo,., An ~1 rnb:o:ible heuristic CIU1 be dcrh·cd by defining a relaxed pn»blt'm 1h:u i ~ eO'I,icr 10 .!-Oh·e, The cx:1e1 coo of a M>IU11on to this ea~ier problem 1hen berornes the heurhtic for the original problem. Uy dcflnilion. theft' is no wa)' 10 an:llyu an momic 'late. and thus it it requirt:s some anJenuity b)' a human analySIIO define gocxt cbnaifl·l. S1 represents a belief state: n set of possible stales.. The members of thi. set are nil subsccs of the litemls suc-h ch,at there is no mutcx: link between any members of the sub$ • JnnNrsistem t1/t'CIS: one actiOta negate$ an t-ffect of the other. F'Orex:ample. Eat( CaJ.·e) and the persistence of 1/ave(Cake) ha"e inconsistent effc."C''s because they disagree on the etrcc-t //m·e( Coke). • Jmetfe~nu: one of the effects of one action is the negation n ptteondition of 1hc Olher. fn( CaJ.-e). th."'t arc not mutex. A planning gr:1ph is polynomi:.'ll in the si~.e of the planning problem. Fr a plaruting JJI"'blem with / literals and a actions. eac-h S, has tW more than l nodes a:nd Jl mutex links.. and each A1 h:JS no more th:-tn '' + I nodes (including the no-ops). (a+ /)2 mutex links. nnd '2(al + /) prelate. The positi\"t': fluem s fR>m rhc problem reJ>enl in $ 0, !oO we tw.-ed 1lOI c:LII Ex·rRAC'r-SOLUTIONwe are ctrtain lhat there is no soluliOft )'Cl. ln,le:•d . EXI•ANO•GRAPII adds into 1\o the three :telions whose preconditions exi'i.t :tllcvtl So (i.e•• alllhe acllotts except p,lQn(Spn'-r, A:tlf')). IICN\g with persisr.ellC'PIIRl tiRl probkm ufltr t..'(J~*'~M>nto k:''tl S 2 •
tl.l utu l lnh art .!o.IM>\\n M Jr.'l)'lil~~r:s. Not all linl:.'\11\'i .,J)C)\\1', b«'u...c the ~IUU C'rrd lr~f: 4~·ed thtm
'fl"'"'
would)).! 100
:siL Tht ~W>Iu tion i~ ind ic'~tt'd by bokl ht~\ a1'1d atulh-.r~.
• llltrrfrrrmY: Rrmot!((Flal, A:dt!) is mu1ex with L«wtOtv-n~tgM lx-cau!it one has the prcccwhtion Al( flol . A.z:le) :and lhe othe-r h:H iu nt'J;ahon a,*" effect. • Contpt'tt'nl nuJs: Pu.tOn(Spart'. Azlt) h. muiC':'- ~•th Rrmotv(tloi. Azk) bec-ause one has Af(FIAl. Azlt:) as a prttandition and ahe ochn' has tb rqaLM'In. • lnNJ~Uuttnl appon: At(Spon ..ol.zl~) is mule,; ••th At(Fl•t . .1h k) m S, bcausc tM only •-.y At(Spo~. Adiect of C:tJJ!:O we load. fly, and unload. and for aUbut the last pie« we need 10 ny ~k 10 airpor1 A to get t~ nex1 pte«. How long do we ha\e co L«-p eAp;u' "'ill the action. • MtllfJ't'S dt't'fr'Wit' monmonicolly: L( two:.etion~ are mutex :u a gh't'n lt'\•el A,.then they will \\l'\0 be: m \IIC'X for all pre~·i(}tiS le\·el.s :u which they both nJ)JX'Ilr. 'Ole S..1nl(: holds for mut exc~ bctwef.'n litcrnls. h migltt not :tlways appear thul wuy in the figures. lx.-.:ause
1hc llg" rc'- have a simplification: ehcy di..tpt :~y ncilhcr lilcral'> that cannot hold a1 level S, n()r :~tCiQn~ chat cannot be ex«uted at le,•el A•. We can ~e that ··mutexes decrease nlOilOIOflically.. i" true if )'OU consider that t~ invitd,.e htet.'l l ~ >'nd actiorlt 3~ mutex \\'ith ~·erything. 1'he proof can b! lundkd by cases: if :Ktton.s A and 8 1m: nMc:c. nl Jn·el .4•. it muM tx- becou•~ of one of lbe lhttt t)'ptS of mutn 'J'h( flnttwo. tncofbblml df«U and uUrfC"''n''«, ~ propenies of ttr actions ~l\C", "0 1f the xtion." ~ mlllex 11 .4,. tht) '41ilU be muk'x a.nuy Jn~l The thud~. ll>b of lllr.'li~;ht(orward steps:
• Propositionalile the actions: repl~e ueh :w:tion ~>C:hc-ma with a sec of ground :.ctioo~ formed by substitutin' cotm~nb for ~:;.eh or the 't'Jtbblc' if their :11:111 and actions are the s~me : ( RESULT(&. a) a Re.SULT(.s',a')) Q (s • s' A a • a'). Some examples of at"! ions nnd situations :1tc sh~·n in Figure I 0.12. • A function orrelatio•' th:.u c:u1 vary from one situation to the 11)
• E.1ch fluent is describc,. .. )¢ A 1 (y,. . .)
390
Chapter
10.
Cl<S.t.Ade) t-~~ (b)
10.4.3 Planning as constraint sati.sraction We h.'''e S\_"(.·n that t-onstm.int s.1tisfaccion has a Joe in common with Boole-an satb:tiability. and we have seen th:u CSI, techniques sre effective for scheduling prob)lcms. so it is noc surprising tt~at it is pos~ible to encode 01 boundt.-d pl::u-lJling problem (i.e .• the problem of finding 01 plan of leng1h I.·) ss a constraint s:uisfac-1ion problem (CSP). The encoding is similar to the encoding to a SAT problem (Section 10.4. 1). with one impon.:uu simplification: at each time step we need only a single ''~i :lbltl b)' its engineers to be as e:asy 3S possible 10 control (subject to other conslmims). Taking adv:uatagt of the sc.rialized ordt..--ring of goals. the Rcn)(l(e Agcnl pl:trult-r was ;~ble to eliminate most of the sc:arch. This: meant that it was fast enough to conlrolthe spac«rnft in rtaltimc. something pn..--viously considered imJ)()S$ibk:. Planne-rs such n.-. GRAPIIPL,\N, SATJ>LAN. :ukJ FF have mo\'ed the field of plnnning fonvovd. by ~ising the le\·el of pcrfonnance of planning sysu:ms. by clarifying the repre· selllntional :md combinatorial issues in\'olvcd, :ukJ by the development of useful heuristics. HO\\'e\'Cr. thett: is a question ofhO\\' far these techniques will scale. It seems likely that funMt progress on larger problems cannot rely only on faetored and propositional rcprescntalions. and will require some kind of synthi.'$iS of first-order and hiemrehieal re presen t~ations with the efficient heuristics currtntly in 11se.
algorithmic approaches for solving them. 1'bc points to reme mber.
We described
1~
POOL rtpresti\Lfllion foi' plaMing ptoblems and se\'tl';ll
• Planning system." ;are problem-sol\'ing algorithms thai operate on explicit propositional or n.:la1ionaJ rtpreSS rcslriclions :.nd made i1 possible co encode more realistic problc:ms. Nebel (2000) explores schemes for compiling ADL. inco STRIPS. The Problem Domair' D) and its later deriva· lives (Bonet :md Geffner. 1999: H ~s l um e1 ,,/,. 2005: Haslum, 2006) were the tin;.t 10 make
niltivc repre~ntalion whic:h makes some of the con.;;trninls moct' explicit. lrASTDOWNW,\RD (Hclmen :uld Richter. 2004: Hclmen. 2006) w011 dli: 2004 planning: competition. and l t\MA (Richter and Westphal. 2008). a planner b3sed on fASTDOWN\Vt\RO with improved hcuris· 1ics. won 1hc 2(X)8 oompe1i1ion. 13ylandcr ( I~) and Gtmll::\b era/. (2004) discuss lhe ritllms (2006) rovers both classical ;lnd stochas:tie planning. with extensive coverngc of robot motion planning. Planning I"C$CM'Ch h:tS becrl central to AI since its ince,xion. :l.nd p.,pcrs 011 piMning are a staple of mainstream AI joumals nnd conferenc.'t's. 1'bere are also sp:cialii'.cd oonfercnccs such as the lmemalional Collference 011 A I PlaMing S)•srcn\S. the lntcmalional WOt'kshop on f>lam1ing and Scheduling for Sp.'l, JFK) 11 At(P2 , SFO) 11 Ptmre(P1) 11 P/o,.e(P2 ) A AirJJOri(JFK)A Airport(SFO) '! 10.3 The monkey-and·banan:LS problem is faced by a monkey in a 1:\bor:UOI)' with some b.m.'lna." hanging out or ~3C'h from the ceiling. A box i.." avaibble rhar will enable rhe monkey to reac.h the OO.nMas if he climbs on it. Initially. the monkey is a1 A.1he brulanii.S at 8. and the box ru C. The monkey and box hnve heigh! Low. bur if the monkey climbs onlo the box he will have height lligil. lhe S:'lti)C as rhc bananas. The actions available 10 rhe monkey include Co (rom one place 10 another. Pu.blem. sussw.-.NI()f.IU
10.7 Figure 10.4 (psge 371) shows a blocks-world problem 1h:u is known as lhe S ussman ano1naly. 11-e problem was , CO!-.SUMS: Lt~gzV•,ts(20), USE: 11'AtYlSUdiO"• ( I)) Jl tliOII(AJd lVhc.:ls2. D URATION: 15, CONSUMe: LugN••lS(20), USE: 1Vh(fl$tfiiiOt1 •( I )) l l tt1011( lti~JX.'Cl 1 , D URATION: 10.
Usu: lwi!ptdof':lf( l ))
_____
.-!~tun- 11 .1 A }tlb•),bop ~«Cnli;ll (or reducing complexily. Con-~idcr wh;u h:q,pcns when a proposl"mlslraCI plans. wilhout !he need 10 consider !heir irnpkmen1:1tions.. 11.2.2 Searching for primilh'e solulions HTN pl:trming is oftc.n formulated wi1h :. single "top Jevel" ac1ion (';died i kt. whe-re the aim is to find an implemenuuion of Act chat ac-hiC'\·es the goal. ·n1is :approaeh is cntirdy gcncr.tl. For example. classical piMning l)roblems Clli'l be defined as follows: for e;)C"h primitive ac1ion lt, . pl\lvidc one rcfi nemem of i\ ('1 with SlCJ)Sio,. Aft). Th:u Cf\':ues a rect,u·sh·e defi ni1ion of Act th.llkls us add actions. Btu we ococd some way to stop the rt.'Cursion: we do that by providing one more refinemem for Act. one with 3.n cmp1y liS-t of 5'eps :tnd with a precondition equal to the goal of the problem. 11lis says that if the goal is alrc:tdy ac:hk-vcd. then the right implcmcm:uion is to 00 nothing. The .-approach leads to a simple algorithm: n:pcali."dly dlOOSC an HL1-\ in the current plan and rcpi:~Cc it with one of its refinements. umil the plan achieves the goo!. One possible implement;dion ba.st-d on bre:adth.flrst tree .sea«h is .shown in Figure I 1.5. Plans are oort.fllin·) r chOOSI:S iht shal.lowe-s. plan in jr-ot~ti~r- •J hltl - lhc iin;l 1-ll.A in pion, or t~ull if none p~fa,$u/JU - lhe ac:tiQII subs.cqu~'tlc:es bc(on: and aflcr hlo in p/tl11 oulromc - R ESULT(pTQ6lem.I~ ITIAL· STATti. p~fir) i( Mil is nvll lht-n r so l'ton is prim itive a nd QU!CQm(' is its ~suit •1 ir oulromt' ttalisfles l'rollkm.(;OAL then r-t-~u rn ptnn else ((l r l"::('h $Ciff't'11« i.n R EFIN£ME.'IOTS(IIIn, QtllcQmt',ltu·mrt'hy) d e) /rollllt'r -
Fi)lu rt! 11.5 A brcadlh•tlrs.t implcm.....lt:tliOn ()(hier:lrthkal rorward plamtins ~e.1rth. The inid:ll plan supplk·d to the algorhhm is lt\ct). n it- R£1-'lNF.MEt.."TS (i.mcti()rlt rclums :t lid or
a('lion SC'qucnccj;. one (or c:ach rclincnte"nl o( 1hc f-ILA whose prtcondilions are $C'rience. i\ fter the ex.CI\ICiating ex· pcriencc of constn~et ing a plnn from sc:r.uch. the agent can sa\'C the plan in the library a.'> a method for impltmenting the high·level action defined by lhc t..'ISJ\, In this way. the agent can become more nod mon: competent owr time a. rll"'' melhods arc built on top of old methods. One important aspccl of this learning process i.s the ability to genemli:t" the method.'> th-lll arc constructed. d iminming dew_il th:n is specific to the problem insc:mee (e.g.. the name of
410
Chapt:er
II.
Planning and Acting in the Real World
Scc1ion 11.2.
• •.. • • tt• : ~: I. ; .. - • • • • • • •
the builder or the: addi"C$S of Lhe plot of land) and ketJ)ing j us1 the key clements of the plan. Methods for achieving this kind of gcnemli:t:Ltion are described in Chapter 19. It s~ms to us iiiCOnccivable that humans could be as tioos. 1bc basic concept required for understanding angelic semantics is the rtac-hable sel of :tn HLA: given a stale·'· the re:ach.'lble set for an Hlt\ h . written a.o; ~ Et\Cfl(s, h). is the set of states reachable by :my the ULA's impk menlations. The ke)' idea is that the agent c:tn choose which elemCIU of 1he rcachabl¢ set it ends Ul) in when it cxt"Cutcs the HLA: thus. an l-ILA with multiple n:Anc.·menls is more "powerful"lhan 1he same Hl..A wilh fewer rcfinemcms. We can also define 1he reactu1ble sell of a sequeiiC(S of HLAo;. for example. the reachable se-1of a sequence (1t 1 . 1t~ J is 1he union o f all lhe rcad1able sets obtaim..-d by applying 112 in -ctiCh ~tal e inlhe n:adw.ble set of h 1: scnuml i c~
or
REACII(.s,(lia. lt-2J) •
U
REACII{/. 11.2).
_.•E REACII(~.h 1 )
Given thc.__-.e definitions, a high-level plan-a sequroc."e of HLAs-achicves the goal if its reachable set lntust'cts the set of goal state-S. (Compare this to 1he much Slr04\ger condition for demonic semantics. where e\'ery member of the rt!lchsblc set has to be a goal state.) Conversely. if the reachable set doesn't intersect the goal. then the pl:.m definitely doesn't wori.:. Figure 11.6 illu.oO!Mbly odd« d' dtkt~.s CuA (if the "'Cfl' decicle$1o take a U.\i,. JO II JhoWd M\y Chc~ff«1 -C....Jt. nus_-~~ lhM dW!cloaipcions ofHW\s art' tknnJblf'. in pnnc-•f*. from lh( ~phons ol thr1t ttfinc-meru-in &c1.1his is rcquiml 1f v.~ \lo-;Jt~C u·ue: liLA dHrnpc.on,_ \UC'b ctu.lk dolo\nv;-.wd rt"finnnmt propeny holds.. Now. ~
v.'C'im·c-lk follcwo•nJ ~htmas for the fiU\'( 11 1 and h1: .4ct.,..(h, 1'1tECO,o:~A. EfHtt.t 1\ =D) . tlrt..on(hl. hEC0'0:-.0 , Et-.:-t:.CT:.+A 1\ ±C). Thou is. ht lldds A land po»•bl¢ dekkc D. v.h•k hl' Jl'O!'$tbly adds A :and has full control 0\·nC. N'~. if only 8 i" trw 1n the in1ll;tl :t~:;ne and Ihe JO:!.lrs A /1. C1httl the SC"qUmCC [h 1.h,J ac:h~·~ the 10'11: v;e d~ an impk:nl(niOlltOil of Jt 1 th;,n ma'-ts 8 false. 1hm choose :m tmpl~~ntnt •on of h1 1hat kavc:~ A INC: lll\1.1 mal.C" C INC'. The r«ecdins di!>C'u,,ion lb..\Urllr"t tNt the c:m:cc-c of an HLA- •he ~hable se1 ror any gi\'e-Jl ini11al smte--ran be dc:..cribc:d eX•ICIIy by ddnib•ns the- c:IYcct on e;teh variabk. It would be nice if ttlh. w~re iLiways true. bul in m:u1y c-a"C~ we can only approximarc rhc cf· (ccts b«'ause :ul II LA may h.1ve intinirely m.u,y hnplenM:ntatiOn~ and may produce arbitmrily wia;gly reachable :.et-mthcr li~e the wiuly-bc lic(-~ate fWoblcm illuslratl'd in Figun: 7.2 1 on P.lSt' 27 1. f« ex.unplc. we "aid that Co( lfome. S/o.O) 1~ibly dekti."S Ca.sll: it also possibly :1(kh At( Cr~r, SFOLong'ft ,-,uPQftmg): bur il ea.r,not do boch- in f:t~.1 . it must do exactly one. A;, with belief lllatcs. we m01y net.'\110 wrile (tppn>.fim(lff' desrudc:nc.-c would indicate lh:•l this "mbitious plan need.~ to be refined by- adding details of int~r-i ,l ;;tnd tr.uhpol1"tion. An alsorirllm for Merurtate is the guaranceed-~achabl(' eoal 'iate, and lhe lef't·hMd cift'l('d ~.11e io~: 1he inaermedia.e goal ot.a.ined by reg.n:ssiu.g the
Chapt:er
414
I I,
Planning and Acting in the Real World
Section 11.3.
frontier- :1 FIFO queue with irutinlPlan a.-c the only ~lcnw:m loop do i( EMPTY'!(front,cr) thl~:m.(iOAl. i ( ,9'1Mm"L«J ~ (} and MAKING· I)ROORESS(Jilan, i nitio/Ploll) 111(;0
finalStnu -
an>' cli.''lncnl
of yuamnt«d
re-turn 0 1iCOM POS~lucm rt:llfl, f'roblr·m, I NITIAL· STATE. plo11 ,finol$1tJLc) llln - ~nc lll.J.\ in plan J~rt:fiz, snffi.r - the aceion subscquen«s bcfate anc,l after llln in pion ror t:~th ~ltltlt'll« in R i;fo1SEMENTS(Iila,onloo-mt",lll('rQI'("hy) do /•vn tu~r - IsS ERT(A Pt>F.N u( p1Y'jiz, $rtJ•ten«:•.•·uffu), / ronh('r')
run('tion 0ECOMPOSE(hiemre/ly.8o.p/on.$J) rrtu.rns a .solution .~utior~ - an ctnjlt)' t~lan "''ile plan i$ !'tOt ctnpt)' do
artum- R£MOVe·LAST(plan) ·'• - a state in R£ACtl-($q, pl4n) sudl th3t stE R .;:Acu -(.~.. ~tction ) problem - a problem wilh I NITIAL·STATti • $ 0 a.nd COAL • $J
s,-s.
415
quence and prunes away the other options. Notice that c leaning a set of rooms by cleaning e3C'h room in tum is hardly rocket science: it is easy for humans precisely because of the hierd.rchical SlruCh•re of the task, When we considef" how difficult humans lind it 10 solve small puuJes such as the 8·J>U7.:t:lc, it st..'t'lns likely that lhe human capacit)' for solving com-
run c:tion ASOiiUC·SEARCII(problt'l'n. liicmrchJI. in1lialPtan) n:tums .solution Of fail
i(
Planning and Acting in Nondetenninistic Domains
11.3
PLANNING AND ACTING IN NONDETERM IN ISTIC DOMA INS
s()/tdi.on - A PI' EN 0( ANGELl C· StiARCII(problcm. hierorc/1y. odion), $oltlllion)
nh1.rn $()/utio" A hier:arehkill pll.lllning ;dgoritJun tho•t ~ses wtgc:lic SC!lnantic$10 identify ;~nd cofllmil t Q l•igh•k \'c:l pl;ms. th;~t wort while 01\'0Wing high ·lcvel pliln~ tl1llt doon 't, 1'hc ~i· eatc M AKISO·PR001tti$S c heeks 10 n~;~.lcc: sun: th011 we an:11 't sh•e k in an intlnilc ~3n:ssion o( refinement.~. At top ic~·c:J, call ASVEI.tC· SEARCU with (AdJllS the mihalPlotl ,
•'iJ;un: 11 ..8
goal through the linal action. The ability to eonunit 10 or reject high.Je,•el plans ea11 give ANOELI(>SEARCII a signific:mt computational :.dvantage over HIERARCIHCAL·SEARCII. which in tum rna)' h!l\'C a l:uge a. N:IICe'fti>«<M
Scc1ion 11.3.
To solve a partial!)' obscn•ablc problem. the agent will h;we 10 reason about the J>c:-rccpt5 it will obtain when il is executing the plan. Ttl.:: percept will be supplied by the agcn!'s sensors when it is actually acting. bul when it is pl:;ltlning it wiii i'M."'4."d a model of it..:: sensors. In Chapter 4. this model was given by a funclion. PER CEPT(~). For planning. we sugmenl I,ODL wilh s new type of schema. the J>tn:tpt schema:
Pem:pt( Color(7, c), PROCONO: Objocl(.c) A In \fiew(z) Perr:ept( Color(can, c), PROCONO:Cari{<XHl) A lr1View(oon) A 0pc.'1l(ttm) The fi rst schema says th"t whene,·et an objec1 is in view. the a.ge111 will peR:eh•e the color of the object (thnt is. for the object x. the agent willleam the truth \•:due of Color(x.c) (or all c). The SCC01ld schema s:~ys that if :m open c:m is in view. then the ~·n l:lei'Cei\'eS the color of the IXlim ill the e11n. Bec:mse there are no exogc•lOUS evtnlS in this world. the color of an object will n:main the same. even if it is not being pen:eived. until the agent perfonn..:; an acrion 10 cll:tngc the object's color. Of course. the agent will netd an ac~ i on that causes objl"d $ E b}
whert RESVLTp dcli»es the J>hysical lt:'U\!lition model. For the time bci•'S· we assume lhalthe
propeny 1h!11 enables the p~emtiort of the I.CNF belief·SI..'llC represem:nion. As soon as the
inilial belief state is always a conjunc1ion of lilc-r.tl.s. th:u is. a J..CNF fonnuh•. ·ro construe! the new belief state t/. "'t mus1 consider whal happens 10 each liter.~l t in e:'ICh physical S:C:lte ,. in b whc.•n action a is applied. for Jitemls whose truth value is aln-ady known in b. the trulh v:\Jue in 1/ is compu1cd from 1he currem v:tlue and 1~ :ldd list :tnd dclc1c lis- of 1hc ~ ion. (For example. if t is in the dekte Iiss of the oclion. then -.t is added lob'.) What about n literal whose 11\llh \'aluc is unknown in b'! There an:: three c~scs : I . If the :IC'I ion adds t. then t will be 1rue in II regardless of its initial \':t.luc. 2. If the :tt1ion , = Color(z.C(z)) II o,,... (c...,, II Color(G~····.C(Co.. ,)) A Color( TaWe. C( Can 1)) ,
The linal belief state S.'llistles Ihe go.'ll. Color(Table,r) A Color( CJ.oir, r). with the variable c bound to C(Canl). The pn.•ecding analysis of lhe upd:ate mle ha.ersccs of previously visited belief states is also ~y. :n least in the proposi1ional case. l11e tty in the ointmc:IH of this l)ku:\Jll pic;1ure is th,;u it only wMs for :ACiion schali.. our belief :~-.tate manageable. There is anOther. quite diffe.rent il.J)pt(t~ch to the J>roblem of unmanageably wiggly be·
lief states: don't bother computing them Ill all. Suppose the ini1inl belief state is bo and we would like 10 know the belief SltUe resulting frorn the .-ction sequence la1... • ,a ,~l · lnsteOO of computing it explicitly. just represent it a..'> ···~Jo then la1.. .. ,a,...J:· 1'bis is a laZ)' but un· ambiguous reprtsent:lliOil of the belief state. and it's propriate for en\'irorunentS with partial Qbsen·ability. nondctcnninism, C>t both. For 1he paninUy observable painting problem with t:he pctttpl axioms given wlier. one I)()(S:S;ible ct~t.e E. but observes it is :IC'Iu:tlly in 0 . The :~sent then n,l::ln§ for the miniln:~l ret>:Jir pll.lS entinuation to re.1c-h G.
11.3.3 Online replanning lm :.g.ine w:uchil\g a S-JXn-welding robot i.n a c-ar pl:tnt TI~e roboc's. fas:t. :l(:CurJte motions are repc.-med over :u•d O\'er again ns ench c-n.r pas~s d~·n the line. Although tcchni~ lly im· pressi\'e, Lhe robtte in the c:nviromn~nt - :md assume that the environment i.. re:tHy nondetenninistk. in lhe sen..e th;;u !~oUCh :. plan :.lway)- h:u :wm~ chance of ~ucct".ss on ar1y given cxt."'t-ution anempt. tht.•n lhc agc11t will t:\'CntU:tlly rtac.h the goal. Trouble occurs when nn net ion i ~ IIC'Iuotlly nell nondcccnninistic-, but rather dc-J)Cild~ on so•ne J)l't()Ondilion that the :&.gl'llt d~~ nol know about. For example. sometimes " l)aint can may be empty. so painriog from th~l Clu' h:a!l no dTcct. No amount of retrying i!t going 10 C-hMge 1his.5 One solution is to ('hoebe r.Jndornly from among the se1or possible rrp:Lir plan.._ rathe-r 1han to try the same one each rime. In thi~ C.a!o4.'. the n:-PJI_ir plan of opening anothe-r can might wed:.. A beuer 3ppto¥'h h. 10 l~am 1 bcuer n'ockl. E''U)' prediction failure il- an oppoctunity forleamins: an =-~nt ~'d be abk 10 modify rl"l mod::l of the world 10 acrord ~ 1lh i" ptrC'eplS. From thtn on. t~ rt"planner will be •o come up wi"' a tq)ait thai Cfb • lhe rool problem. rather 1han ~I) lft,J on 1\d. W) thoosc a Jood rqwr. This kind ol leMn~n' u ckscnbcd in Cbapccrs IS and 19. ••[)ror:s
•~sot Rerv.sn.
NO\\ l~ • "' i~ ready 10 execute the plan. Suppo5C' the a~nt ~n·ts that the tabk and can o( p.unc ~while: :and the chair is bbck. ltlhrn exect~tC'" Ptmtt{Chcur. Con 1). At this poinl :. cl;1ssical pl;;mncr would decl.:lte vicoory: the pl;~n has tx-cn uccutcd. But an online exccuhOI~
monilori11.g agent ne'C'd:J to clx."Ck the pn.•t:onditions of lhc n:mOSe the agent pen:ch'l!.." th:u they do no1 twvc lhc !lame: 1.'0ior-in fact. the chair is now 11 mottled gmy because the black pUill~. a nd the PturU .ac1i~' is mried. Tha"' bchll\ .or "'111 kxlp until tbc chair is pt:ttti\•ed 10 be compktcly PJ~inled. But notice thJt the loop'"' erc-.-ed by a proc:c:» ol plu-exocvce-«ptan. ~lhn' 1han by an e~lici1 b)p in a pba. NCMc abo lh.x CbC' ongm.al plan nttd. noc ccnw n'ndlhOM att satisfied (lhe £03.1has b«n athie,cd), and the a.&cnt can £0 holne early. h •-" MnuJhtforvoard to modify 3 pl:tnnins algonthm ..o that C'iiCh actton in t.be plan '' annot•ed 'A •lh 1hc aaion·$ pn:condilions. thus mabtina IC'ttOn morutonnJ.. h is slightly 1~1
• ,._ -tonllif ~ . . &ul;ty. ~ 4:!4 p&cn. ~y ~- . . . . . . . 1\ \MiftCf . . . . . . . . tiMk b« """)9J_ A ........................ IIOIIC'mposilion of the monolithic agent. An ag/hen anoth~r ~c1 ion occurs COilC'Um!nlly. For exampk 1wo agents are needed to c:trry :a cooler full of be\'tl";\gcS jolrshop scheduling of up to 16.000 worke.r·Shift;;. Remote Agent ( Mu.sceuola er (1/•• 1998) became the firs.t autQnomous planner-scheduler to comrol a sp.'lcccraft when it fl ew onboard the Oi!i!p Space One probe in 1999. S~re aJ>plications have dri,•en the de,·elopme-nt of algorithms for resource sllocations: see Laborie (2003) and Muscenola (2002). l l1e literature on scheduling is p«"SS..-·ntcd in a classic survey anic le (Lawler t'l (1/•• 1993). a re 434
Chapt:er
I I,
435
Planning and Acting in 1he Real World
The lirsl onli1M! planner wi1h execu1ion moniloring
w-:~s
PLANI!X (Fikes
t'l (II••
1972).
11'e boid model on page 429 is due to Reynokls ( 1987). who won an Academy Aw:uxl for its applic~'lt ion to swnrrns of penguins in Batmlm Rewms. The NERO game :mel the mclh· ods for leOlming s:tr.uegies are described by Bryant :utd Miikk:ulai11e11 (2007). Recx•nt book: on mulliagenl systems include those by Weiss (2000a). Young (2004).
which wod:c.'d wilh !he S TRIPS planner 10 conlrol the mbo4 Shakey. 1'hc N.\Sl planner
(McDennon. 197Sa) trea1ed :. pla_nning J)n>blem silllJ)I)' as a speciticatiOfl for carrying OUI a complex action • .so Lhat execution and planning were complelcly unified. S IPE (Sy.slcm (or
~IV>~
l11teme1i\'e Planning and ExecuLion monii(Hing) (Wilkins. 1988. 1990) \V3S Lhe firs1 planner
Vlassis (2008). and Sllolmm and l.e)'IOil·Brown (2000). There is :m :mn'"" conference on
to deal systematically wil.h the problem of n.•pl:mning. II has lx.'t'n used in dcmonstralion projcciS in several dom:Uns. including piM11ing opet'Jtions on the nigh1 deck of aJI aitcr.lfl carrier. job-sl1op scheduling for an Austr.llian bc."ual.. reprt·stntatioc' o( current goal;: ;md the agent's inte mal s.1me. "Universal plsns" ($choppers., 1987, 1989) were developed as a lookuptable nK.·thod for n:.at1ive planning. but tumed out to be :a n."disoovery of the idea of politics th:tl h:1d long been '"~ in Markov decision processes (see Ch.'lpter 17). A universal plan (or a policy) contains a mapping from any state to the aet of the goal set: can an)•thing be concluded aOO.u whether 1he plan :tchieves the go."'J'? What if 11~ pes· simistic reachable stl doc:s-n't intersect the g.oal se1'? Explain. 11.5 Write an algorithm 1h:u takes an initial Slate (spec-ified by a set of pi"(>J)OSitionttllitersls) and a sequence of IU..As (eac-h delincd by pn.'Conditions and ;mgelic specitic.ations of opti· rnislic and pessimistic reachable scLS) and COfiiJ)lltes optimiSiic and pessim istic descriptions of the tt3Chable set of the sequence. 11.6 In Figure 11.2 we shO\\'l"d how 10 describe actions in a scheduling problem by using scp.tr.tte lields for D URATION. USE. ;md CONSUME. Now SuPJ>OSe we wanted 10 rombine scheduling with nondetcm~in istic pl:uming. which requires nondetenninisl ic :mel conditional effects. Consider e:teh of the three fields and explain if they should rtmain se~r:ue lie Ids. or if they should beoome cffec~s of the action. Gi\'e :m example for each of the thn.'(:. J I. 7 Soane of the opI.S- !IuI"Cd:thlalloo o( 1hr UJ)ptr Otle. Spt'tructure of t~ circuit remains con..lant, A more 'ctM:"r.al ontolo;y would con,kter ,jg..:•ls: at particular times. and would include the wire lc•,gth"' and pi'Oj,ag:.uion cJe.. lay\, 11U!> W'OU id allow US 10 $imulate the tim ins ptc>pCfl~ Of d't Cll'tUil. and ind«d such ~>irnulahon' are often carried OUI by cil't'Uit do.i~ We could 1ho inlroduee mete incer· ~••n& Cb.l>!ol"..' o( p1cs. for example. by descnbmc the 1echnolosy (Tll.. CMOS. and so on) a,. -.dl ~ tht inpu1-ou1pw specifieatioa. lf -.e ,. *lk'd to di.)('U\3< rdaablhl)' or dla.gnosis. \\C -.-oukt lft('l\dc lhc posstbthty thai the SltUC'tlltt o( tht ('1ft'UII 01' lhc fl'l\lPI:'I1k!J; o( lhe piC'S m•cN ddn&c -'fJOIII.Jni!OUSiy. To X"CCUUO (or SU'a)' ~run«s. "'f -.--ould need 10 ~d -.hrft- ~ -. ~ are on lhe boatd.
bdon,mg 10 the cl;ass of pts, ~h tu\anJ dtffm-nl propat.o. SmuJ;uty• .,.,..... m•Jhl 'tlt;""OlniiO allolA fot other anim3l:s besiock:s 1Autnf1U~'- II m(Jht no4 be possibilt 10 p.in ~·n the CXII!Ct sp«ir:s (rom tht aqjlable perttpl~. ~ 'AC -.ould DC'Cd to buLid up a bioiOJical l~' of philo9>phical and cornputalion:tl invt"1:· tig:uion. the answer is "Ma)'be." In ttli .. M'ttion. we I)~SCrtt one gcncml ·pu~ ontology th:u S)'nthe.sil'.cs ic~:ls rrom d~c ocnn•rics.. 1Wo m:titJr c:h:m•cteristics or gcocrnl·pui'J>OShould be :_t,plicable irl more or less any speci:al·l)tJJ'I)O.!oC domain (with the addition of domain·,pcdfic axioms). This means that no rcpre~ma · tiona! issue can be finessed or hn1.JlCXI under lhe c-arpet. • In any sufficiently de:m:llfw,lln& domain. dJffC'rmt arc.:u ol k:nowkdg.f! mus1 be ttnjfit'd. bttause ~asonins and problem -.olun& cou&d ul\oh"C SC'\"Cnl an-.as simuh::tneous:ly. A roboc eirwit·rep;tit S)'.,.~m. for i~.l'l«ds to reason about eireWu in tenns of dec· tric;aJ ronnecti\ity :and phys.italla)'OUI.Ind about tlJU('. both (or ci::rcuittimin& aroi)'SU aod cscilmling bbor C'OSb. The- 3-tn~ ~.,.,., tune themorc muse be tapabtt ol beins oombined ~'llh 1host dticnbtn& ~Jal byoul and must v.odi: cqa;aJJy v.ell for ~ :tnd mlnulC'S and for anc..trom" and meters. We should s:.J'f up front •tw 1M c-ncC'rpn~oe ol aener.al ontoloaic:al Cft~inttring h;ls ~ f~ h;Jd only limited success. No~ o( the" top AI a.pplar~ (u listed in Cbapcer I) mal.:C' u.~ of a sfw'ed ontology-they :all U'\C lipcd.al·purpo!'t' linowlo:lge cnginec-rin..,g. Soci:ll/political eon~idcr.ation.s c:m make it difficult for eompchll$ p:anae-s to a.gtte on an o ntology. As Tom Gruber (2004) S3)'$. "Every onto!~ h a lf'(ILI)' - :1 M.Xial at,rteml."'lt-:unong people with somC' common motive in s~ring;· Wl1en COIIlJ>clint; conttm.1 ouawcigh the mociv:uion for sharing. there can be no common ontolog)'. 'l'll())C ontologies that do exist have lx"t'n cre:1t1.'d alor1g four routes: I. By a tc:un ortrnincd ootologhtJ1ogicllul,, who :ll\'hitL•t•1 II~ ontology and wrile axioms. 11lc CYC sy~cm w~!o mO!>lly t-.uill thh wa)' (l.cn:u and Guha. 1990). 2. By imponing categ~. auributC"~. and \'atuc.., from an cxis1in.g d:uabasc or databa~;;. DBt>EDIA was built by import inc 'tructured race~ frotn Wikipedia (Bizet~~ ol.. 2007). 3. By pamng kXl documeru"' and C').lniC'III'IJ•nfOnnllion from them. TEXTRUSS£R \\'Ol~ budl by re;adin.s a LarJe rorpus of \\'f:b pq.~ C8anl.o ll1d Etzioni. 2008). 4. 8)• enticmg unstiUed an'I.JieUI'i to t"nkr oocnmonstn5oe tno\\kd£e. The OP'E.,~h'D system "'-u budt by \'Oion~ttn •ho prerccpcual inp.n, in fe~ categ()()• membership from the percci\·ed proper· ties of the objects. and then use..- category infonnation to make predictions ~1boutthe objects. For example, from its &1\.'Cil and yellow monied skin, one· fOOl diameter. ovoid shape. red Oesh. bl:K'k Si.X-" Splterical{x) 1 T..-nin.g a proposition in1o VI obj«l i$ enies.
Dogs E Dom ~li('.aUdSJH!Cies Notice that because D()f}s is a c:ucgo.y and is a member or Domt$titXJ,lt'f.ISpecies. the Iauer must be a car~gory of carto,gorit'S. Of course there are exceptions to many of the nbo\'e rules (p4mctured b•••s.ke«balls are not sphcrie:~.l ); we de.'ll wi1h these exceptions la•er. Ahhoug.h subclass and member tc.latiOilS :vc the mos1 impon:uu ones for /nler'$etlicn{e-1.Cl)= {)) E:rhaustiveDccompo.sition(s,c) e (Vi iEc 302 qesAiEq) Poration (.~.c) # Di$j<Jirlt(.t) 1\ Ex/1(W.$1it·eDeoom,IQ&ition(.t,t:). Categories c:an also be (/tfrnt!d by providing lll'(:essnry and suflid-.~nt conditions for rncmbcf'Ship. Fore.x:unplc. a b:tChclor is an unntarried adult male: ;r: E Bachdot'$
o
Umnarricd{x) A ..c E Adult$ 1\ ..c E Male$ .
As we djscuss in Ihe sidcb.u on natural kinds on page 443. strict logical ddinilion.'\ for cate--goric$ :trc: nei1hcr always possible nor alway$ rw.."Cess.vy.
12.2. 1 Physical composition The idt:lthal one object can be ,,an or another is. a familiar one. One's nose is part of one ·s head. Romania is 1>an or Europe. nnd this chapter is part of this book. We use !he general PartOf relation 10 S-'Y that one thing is p:lrl of another. Objects can be g.rot~ped into PortO/ hierarchies. reminiscem of the Sullset hiernrth)': PortO/ ( BucJ1atest. Romania} PortOj( llomarli() , 8Q$lt'n1Eu~pe) PortOj(Eru;temEurope, Europe) Port0j( £1.u'Ope, EMI11).
442
Chapter
12.
K1.owk"dge Representation
The PartOj relation istmnsiti\'e and reflexive: th~t is.
Pa.·tOf(z,y) A PartOf(y,z) => PartOf(z,z) . PartOf(•.•). The~tfOII:. we (M eoneludW•lds." The temptation would be to ascribe this weight to the St!l of appks in the b:•g. but this would be a mis.L:ll:t bcc:luse the set is an :lbstroct m:uhc•natic.'ll ooncep4 lhat h3s elemems bl•l docs n01 tuwe weight. ln..::tcad. we nct."utlheir 1ypical in5':Jn«s: ::r:E 1!1rlictti(Tomatoes) => Red(:r) /1. Rou11d(x).
Thus. we can write down useful facts al.xxn ~tegories withoul exact defini· tions. 1l.e difficulty of providing cxac.1 definitions for most natural ca.tt.·gorit-s wa..:: explaifl('d in depth by Willgl~nstein ( 1953). 1-te usc.-d the cx:unplc or gam.-s to~· thai members of a category ~h arc:d "family resemblances" r:uhcr chan necessary :u1d suf'iick.nt c;harJcteristics: what strict definition encom pas~~ dK"-SS. tag. soli· t.aire, aM dodgcb.'lll? TI.e utility of the noti011 of strict definition was also challenged by Quine ( 1953). He pointed out that e\'cn the definition of "b.1chclor" as an un· manied adult male is suspebjl.-c:t is also a butter-object. at ka..:;t unlil v.-e get to very small parts in2 € £urt:i$e.~ A iVrote(Nonrig,t> 1 ) A 1Vrote( R~t..~dl,l'1)
-=>
Difficully(e l) > DiDiculty(e2). e, € EzeJ'Ci.~e." A e2 € Eun:i$e.~ A Diffic-~tlty (el) > Diffic~tlly (e1) => &peeteJSoo•~(c1 )
< E,...teJSoore(e,) .
This is enough to allow one to decide which exeR:"ises 1odo. e,·en lhough no numerical "aluc-s (or difficulty were ewr us~..-d. (One does. howi..'\'t~r. have to discover who WTOie which exer· ciscs.) These sons of nwnotonie relationships among measures fonn the basis for the field of quulitntin.' physics. a subfield AI that in\'e..;tigates haw to reason about physical systems without phmging into detailed equations a11d numetic.'ll simulations. QuaJit:t.ti\·e ,mysics is discusse-d in the hisaorical no•es sctlion.
or
_...
.....
or
bE 011ltet'l\ PartOf(l),b) -=> 1> E Buller·,
We can now say that butter mi.'lts at around 30 degrees centigrJdc: bE lJ•,aer => Meil;,,!JP()ir~t(b, Ccnligmrlc(30)).
We could go on to say lhitt buut·r is yello\v, is les.s de-nse than w;llcr. is soft at room temper.t· lure, has a high fm eotllent, and YJ on. On the 01hcr hmd. bt111cr has no P.'H1icular size. shape, Or weight. We. t<m define more specialized categork~o: of butter suc-h as. UMalledBuUcr. which is also a kind of swff. Noce thai the catct:,o-ory PoundOfOutler·. whic-h ineludl:s ru> members all butter-objects weighing one pound, is not :. kind of sm.ff. If we cut a pound of buller in h."LLf. we do noc. alas. get two pOunds of buncr. What is actually going on is this: some properties :ttc intrinsic: lhC)' belong to the very subs1ance of the object. r:.uher 1han to the object as :.l whole. When you cut .m instance of .miff in half. the 1wo pieces retain 1he intrinsic propenies.-things likedenj;ity. boiling point na"or. color. ownership. :uld so on. On 1hc tMhtr hMd. their extrinsk- propenies--weig.lu. length. shape. n.lld so on- are not re1aim'tley) is an ob· jt,"t"' that reftn; to the fact of Shankar being in Berkeley. but does not by itself sa.y anything about wht."lhe-r it i.>< true. To asse-11 th3t a fluent i.s a