Vous êtes sur la page 1sur 17

D. S. R.

Murthy

AI Unit 1 Unit I

Introduction Artificial Intelligence (AI) is the study of how to make computers do things which, at the moment, people do better. AI Problems Task Domains of Artificial Intelligence Mundane Tasks Perception o Vision o peech !atural "an#ua#e o Understandin# o $eneration o Translation %ommonsense reasonin# &obot control 'ormal Tasks $ames o %hess o (ack#ammon o %heckers o $o Mathematics o $eometry o "o#ic o Inte#ral calculus o Pro)in# properties o* pro#rams +,pert Tasks +n#ineerin# o -esi#n o 'ault *indin# o Manu*acturin# plannin# cienti*ic analysis Medical dia#nosis 'inancial analysis AI Technique AI Techni.ue is a method that e,ploits knowled#e. Intelli#ence re.uires knowled#e Knowledge captures #enerali/ations. People pro)ide knowled#e.

D. S. R. Murthy

AI Unit 1

Modi*ied easily to correct errors. Many situations use knowled#e, e)en i* it is not totally accurate or complete. TicTacToe problem using AI technique Tic Tac Toe is a child0s #ame played on a 1 by 1 #rid. 2ne player, 3, starts by placin# an 3 at an unoccupied #rid position. Then the other player, 2, places an 2 at an unoccupied #rid position. Play alternates between 3 and 2 until the #rid is *illed or one player0s symbols occupy an entire line ()ertical, hori/ontal, or dia#onal) in the #rid. 4e will denote the initial empty Tic Tac Toe #rid with nine dots. 4hene)er 3 or 2 plays we *ill in an 3 or an 2 in the appropriate position. The e,ample below illustrates each #rid con*i#uration *rom the be#innin# to the end o* a #ame in which 3 wins. ... X.. X.O X.O X.O X.O X.O X.O ... ... ... ... .O. .O. OO. OO. ... ... ... ..X ..X X.X X.X XXX Board position

tructure containin# a 56element )ector representin# the board, a list o* board positions that could result *rom the ne,t mo)e, and a number representin# an estimate o* how likely the board position is to lead to an ultimate win *or the player to mo)e. Algorithm To decide on the ne,t mo)e, look ahead at the board positions that result *rom each possible mo)e. -ecide which position is best, make the mo)e that leads to that position, and assi#n the ratin# o* that best mo)e to the current position. 7. ee i* it is a win. I* so, call it the best by #i)in# it the hi#hest possible ratin#. 8. 2therwise, consider all the mo)es the opponent could make ne,t. ee which o* them is worst *or us (by recursi)ely callin# the procedure). Assume the opponent will make that mo)e. 4hate)er ratin# mo)e has, assi#n it to the node considered. 1. The best node is then the one with the hi#hest ratin#. -e*inin# Problem as a tatic pace earch To build a system to solve a particular problem 7. -e*ine the problem precisely. Must include precise speci*ications o* what the initial situation(s) will be. 4hat *inal situations constitute acceptable solutions to the problem. 8. Analyse the problem. 1. Isolate and represent the task knowled#e that is necessary to sol)e the problem. 9. %hoose the best problem6sol)in# techni.ue(s) and apply it to the particular problem. ame of !hess "roblem as a #tatic #pace #earch peci*y the startin# position o* the chess board. &ules that de*ine the le#al mo)es. (oard positions that represent a win *or one side or the other. tartin# position : , : array +ach position contains a symbol standin# *or

D. S. R. Murthy

AI Unit 1

the appropriate piece in the o**icial chess openin# position. $oal Any board position in which the opponent does not ha)e a le#al mo)e and the kin# is under attack. "e#al mo)es Pro)ide the way o* #ettin# *rom the initial state to a #oal state. 4rite the rules describin# the le#al mo)es in as #eneral a way as possible. $%ample; 4hite pawn at .uare(*ile e, rank 8) A!Mo)e pawn *rom .uare(*ile e, rank 1) is empty .uare(*ile e, rank 8) to A!.uare(*ile e, rank 9) .uare(*ile e, rank 9) is empty #tate space +ach state corresponds to a le#al position o* the board. Play chess by startin# at an initial state Use a set o* rules to mo)e *rom one state to another. +nd up in one o* a set o* *inal states.

#tate space representation Allows *or a *ormal de*inition o* a problem as the need to con)ert some #i)en situation into some desired situation usin# a set o* permissible operations. Permits to de*ine the process o* sol)in# a particular problem as a combination o* known techni.ues and search, the #eneral techni.ue o* e,plorin# the space to try to *ind some path *rom the current state to a #oal state. &ater 'ug "roblem <ou are #i)en two =u#s, a 96#allon one and a 16#allon one. !either ha)e any measurin# markers on it. There is a pump that can be used to *ill the =u#s with water. >ow can you #et e,actly 86#allons o* water into the 96#allon =u#? #tate #pace et o* ordered pairs o* inte#ers (,, y) , !o. o* #allons o* water in the 96#allon =u# (@, 7, 8, 1, or 9). y !o. o* #allons o* water in the 16#allon =u# (@, 7, 8, or 1). #tart state oal state (@, @) (8, n) *or any )alue o* n.

Assumptions 'ill =u# *rom the pump. Pour water out o* a =u# onto the #round. Pour water *rom one =u# to another.

D. S. R. Murthy

AI Unit 1

There are no measurin# de)ices a)ailable. !ew tate (9, y) (,, 1) (, C d, y) (,, y C d) (@, y) (,, @) &emarks 'ill the 96#allon =u# 'ill the 16#allon =u# Pour some water out o* the 96#allon =u# Pour some water out o* the 16#allon =u# +mpty the 96#allon =u# on the #round +mpty the 16#allon =u# on the #round

"roduction (ules &ul %urrent tate e 7 (,, y) i* , A 9 8 (,, y) i* y A 1 1 (,, y) i* , B @ 9 (,, y) i* y B @ D (,, y) i* , B @ E (,, y) i* y B @ F (,, y) i* , G y H 9 and y B @ : (,, y) i* , G y H 1 and , B @ 5 (,, y) i* , G y I 9 and y B @ 7@ (,, y) i* , G y I 1 and , B @ 77 (@, 8) 78 (8, y) )ne solution

(9, y C (9 C ,)) Pour water *rom the 16#allon =u# into the 96#allon =u# until the 96#allon =u# is *ull (, C (1 C y), 1) Pour water *rom the 96#allon =u# into the 16#allon =u# until the 16#allon =u# is *ull (, G y, @) (@, , G y) (8, @) (@, y) Pour all the water *rom the 16#allon =u# into the 96#allon =u# Pour all the water *rom the 96#allon =u# into the 16#allon =u# Pour the 86#allons water *rom the 16#allon =u# into the 96#allon =u# +mpty the 86#allons water in the 96#allon =u# on the #round $allons in the 16#allon =u# @ 1 @ 1 8 8 @ &ule Applied 8 5 8 F D or 78 5 or 77 66

$allons in the 96#allon =u# @ @ 1 1 9 @ 8

*ormal description of a problem 7. -e*ine a state space that contains all the possible con*i#urations o* the rele)ant ob=ects. 8. (Initial states) peci*y one or more states within that space that describe possible situations *rom which the problem6sol)in# process may start. 1. ($oal states) peci*y one or more states that would be acceptable as solutions to the problem.

D. S. R. Murthy 9.

AI Unit 1

peci*y a set o* rules that describe the actions a)ailable.

D. S. R. Murthy

AI Unit 1

"roduction #ystems A production system consists o* A set of rules, each consistin# o* a le*t side that determines the applicability o* the rule and a ri#ht side that describes the operation to be per*ormed i* the rule is applied. 2ne or more knowledge + databases that contain whate)er in*ormation is appropriate *or the particular task. A control strategy that speci*ies the order in which the rules will be compared to the database and a way o* resol)in# the con*licts that arise when se)eral rules match at once. A rule applier. !ontrol #trategies (equirements of a good control strategy %ause motion ystematic Breadth,*irst #earch algorithm 7. %reate a )ariable called !2-+6"I T and set it to the initial )alue. 8. Until a #oal state is *ound or !2-+6"I T is empty do a. &emo)e the *irst element *rom !2-+6"I T and call it +. I* !2-+6"I T was empty, .uit. b. 'or each way that each rule can match the state described in e do i. Apply the rule to #enerate a new state. ii. I* the new state is a #oal state, .uit and return this state. iii. 2therwise, add the new state to the end o* !2-+6"I T. $%ample; (@, @)

(9, @)

(@, 1)

(9, 1)

(@, @)

(7, 1)

(9, 1)

(@, @)

(1, @)

Depth,*irst #earch algorithm 7. I* the initial state is a #oal state, .uit and return success. 8. 2therwise, do the *ollowin# until success or *ailure is si#naled; a. $enerate a successor, +, o* the initial state. I* there are no more successors, si#nal *ailure. b. %all -epth6'irst earch with + as the initial state. c. I* success is returned, si#nal success. 2therwise continue in this loop.

D. S. R. Murthy $%ample;

AI Unit 1

(@, @)

(9, @)

(9, 1) Advantages of Depth,*irst #earch -epth6'irst search re.uires less memory since only the nodes on the current path are stored and in (readth6'irst earch all o* the tree that has so *ar been #enerated must be stored. -epth6'irst search *inds a solution without e,aminin# much o* the search space at all and in (readth6'irst search all parts o* the tree must be e,amined to le)el n be*ore any nodes on le)el n G 7 can be e,amined. -epth6'irst search stops when one o* them is *ound. Advantages of Breadth,*irst #earch (readth6'irst search will not #et trapped e,plorin# a blind alley. -epth6'irst search *ollows a sin#le, un*ruit*ul path *or a )ery lon# time, perhaps *ore)er, be*ore the path actually terminates in a state that has no successors. I* there is a solution, then breadth6*irst search is #uaranteed to *ind it. I* there are multiple solutions, then a minimal solution (one that re.uires the minimum number o* steps) will be *ound. In -epth6'irst search, *ind a lon# path to a solution in one part o* the tree, when a shorter path e,ists in some other, une,plored part o* the tree. Traveling #ales person "roblem A salesman has a list o* cities, each o* which he must )isit e,actly once. There are direct roads between each pair o* cities on the list. 'ind the route the salesman solution should *ollow *or the shortest possible round trip that both starts and *inishes at any one o* the cities. I* there are ! cities, then the number o* paths amon# them is 7.8J(! C 7), or (! C 7)K. The time to e,amine a sin#le path is proportional to !. o the total time re.uired to per*orm this search is proportional to !K (!ombinatorial e%plosion). +,ample; 'or ! L 7@, !K L 7@K L 1E8::@@ (Very lar#e number). -euristic #earch The word heuristic comes *rom the $reek word heuriskein, meanin# M to discoverN, which is also the ori#in o* eureka, deri)ed *rom ArchimedesO reputed e,clamation, heurika (MI have foundN), uttered when he had disco)ered a method *or determinin# the purity o* #old. A -euristic is a techni.ue that impro)es the e**iciency o* a search process, possibly by sacri*icin# claims o* completeness. >euristics are like tour #uides. They are #ood to the e,tent that they may miss points o* interest to particular indi)iduals. They impro)e the .uality o* the paths that are e,plored. Usin# #ood heuristics, we can hope to #et #ood

D. S. R. Murthy

AI Unit 1

solutions to hard problems, such as tra)elin# salesman. It is possible to construct special6 purpose heuristics that e,ploit domain6speci*ic knowled#e to sol)e particular problems. +,ample; .earest neighbour heuristic selects the locally superior alternati)e at each step. -euristic search for Traveling #alesman problem 7. Arbitrarily select a startin# city. 8. To select the ne,t city, look at all cities not yet )isited, and select the one closest to the current city. $o to ne,t. 1. &epeat step 8 until all cities ha)e been )isited. This procedure e,ecutes in time proportional to !8, a si#ni*icant impro)ement o)er !K. A heuristic *unction is a *unction that maps *rom problem state descriptions to measures o* desirability, usually represented as numbers. The purpose o* heuristic *unction is to #uide the search process in the most pro*itable direction by su##estin# which path to *ollow *irst when more than one is a)ailable. "roblem !haracteristics Is the problem decomposable into a set o* independent smaller or easier subproblems? %an solution steps be i#nored or at least undone i* they pro)e unwise? Is the problemOs uni)erse predictable? Is a #ood solution to the problem ob)ious without comparison to all other possible solutions? Is the desired solution a state o* the world or a path to a state? Is a lar#e amount o* knowled#e absolutely re.uired to sol)e the problem, or in knowled#e important only to constrain the search? %an a computer that is simply #i)en the problem return the solution, or will the solution o* the problem re.uire interaction between the computer and a person? Is the "roblem Decomposable/ ol)e P(,8 G 1, G sin8,.cos8,) d, P(,8 G 1, G sin8,.cos8,) d, P(,8 d, ,1Q1 P(1, d, 1 P, d, 1,8Q8 Psin8,.cos8, d, P(7 6 cos8,)cos8, d, Pcos8, d, PR(7 G cos 8,) d, RP 7 d, R P cos 8, d, CPcos9, d,

R, S sin 8, Usin# the techni.ue o* problem decomposition, )ery lar#e problems can be sol)ed easily.

D. S. R. Murthy

AI Unit 1

0"u11le ame The :Cpu//le is a s.uare tray in which are placed ei#ht s.uare tiles. The remainin# 5 th s.uare is unco)ered. +ach tile has a number on it. A tile that is ad=acent to the blank space can be slid into that space. A #ame consists o* a startin# position and a speci*ied #oal position. The #oal is to trans*orm the startin# position into the #oal position by slidin# the tiles around. +,ample; tart $oal 8 7 F : E 1 9 D 7 : F E 8 1 9 D

!an #olutions Be Ignored or 2ndone/ An additional step must be per*ormed to undo each incorrect step. The control mechanism *or an :6pu//le sol)er must keep track o* the order in which operations are per*ormed so that the operations can be undone one at a time i* necessary. Important classes of problems Ignorable olution steps can be i#nored. +,ample; Theorem pro)in# sol)ed usin# simple control structure that ne)er backtracks. easy to implement. (ecoverable olution steps can be undone. +,ample; :6pu//le #ame sol)ed by a sli#htly more complicated control strate#y that does sometimes make mistakes. (acktrackin# will be necessary to reco)er *rom such mistakes and control structure must be implemented usin# a push6down stack, in which decisions are recorded in case they need to be undone later. Irrecoverable olution steps cannot be undone. +,ample; %hess sol)ed by a system that e,pends a #reat deal o* e**ort makin# each decision since the decision must be *inal. The reco)erability o* a problem plays an important role in determinin# the comple,ity o* the control structure necessary *or the problemOs solution. Is the 2niverse "redictable/ 0,pu11le game %ertain outcome problem. %ontrol structure that allows backtrackin# will be necessary. Bridge game Uncertain outcome problem.

D. S. R. Murthy

AI Unit 1

10

In)esti#ate se)eral plans and use probabilities o* the )arious outcomes to choose a plan that has the hi#hest estimated probability o* leadin# to a #ood score on the hand. ol)e irreco)erable problems is to plan an entire solution be*ore embarkin# on an implementation o* the plan. 2ne o* the hardest problems to sol)e is the irreco)erable, uncertain6outcome. +,amples; Playin# (rid#e #ame %ontrollin# a robot arm >elpin# a lawyer decide how to de*end the client a#ainst a murder char#e. Is a ood #olution Absolute or (elative/ %onsider the problem o* answerin# .uestions based on a database o* simple *acts. (y representin# each o* the *acts in a predicate lo#ic and then usin# *ormal in*erence methods, one can easily deri)e an answer to the .uestion. (est6path problems are computationally harder than any6path problems. Any6path problems can be sol)ed in a reasonable amount o* time by usin# heuristics that su##est #ood paths to e,plore. Is the #olution a #tate or a "ath/ Plan ( e.uences o* operations) produces the *inal state. &hat is the (ole of Knowledge/ "ot o* knowled#e is important only to constrain the search *or a solution and a lot o* knowled#e is re.uired e)en to be able to reco#nise a solution. "roduction #ystem !haracteristics Partially %ommutati) e !ot partially %ommutati) e Monotonic Theorem pro)in# %hemical synthesis !onmonotonic &obot na)i#ation (rid#e

!ategories of "roduction #ystems A monotonic production system is a production system in which the application o* a rule ne)er pre)ents the later application o* another rule that could also ha)e been applied at the time the *irst rule was selected. A .onmonotonic production system is one in which this is not true. A partially commutative production system is a production system with the property that i* the application o* a particular se.uence o* rules trans*orms state , into state y, then any permutation o* those rules that is allowable also trans*orms state , into state y. A commutative production system is a production system that is both monotonic and partially commutati)e. The 3issionaries and !annibals "roblem Three missionaries and three cannibals *ind themsel)es on one side o* a ri)er. They ha)e a#reed that they would all like to #et to the other side. (ut the missionaries are not sure what else the cannibals ha)e a#reed to. o the missionaries want to mana#e the trip across

D. S. R. Murthy

AI Unit 1

11

the ri)er in such a way that the number o* missionaries on either side o* the ri)er is ne)er less than the number o* cannibals who are on the same side. The only boat a)ailable holds only two people at a time. >ow can e)eryone #et across the ri)er without the missionaries riskin# bein# eaten? The Tower of -anoi omewhere near >anoi there is a monastery whose monks de)ote their li)es to a )ery important task. In their courtyard are three tall posts. 2n these posts is a set o* si,ty6*our disks, each with a hole in the center and each o* a di**erent radius. 4hen the monastery was established, all o* the disks were on one o* the posts, each disk restin# on the one =ust lar#er than it. The monksO task is to mo)e all o* the disks to one o* the other pe#s. 2nly one disk may be mo)ed at a time, and all the other disks must be on one o* the pe#s. In addition, at no time durin# the process may a disk be placed on top o* a smaller disk. The third pe# can be used as a temporary restin# place *or the disks. 4hat is the .uickest way *or the monks to accomplish their mission? The 3onkey and Bananas "roblem A hun#ry monkey *inds himsel* in a room in which a bunch o* bananas is han#in# *rom the ceilin#. The monkey cannot reach the bananas. >owe)er, in the room there are also a chair and a stick. The ceilin# is =ust the ri#ht hei#ht so that a monkey standin# on a chair could knock the bananas down with the stick. The monkey knows how to mo)er around, carry other thin#s around, reach *or the bananas, and wa)e a stick in the air. 4hat is the best se.uence o* actions *or the monkey to take to ac.uire lunch? !ryptarithmetic %onsider an arithmetic problem represented in letters. Assi#n a decimal di#it to each o* the letters in such a way that the answer to the problem is correct. I* the same letter occurs more than once, it must be assi#ned the same di#it each time. !o two di**erent letters may be assi#ned the same di#it. +,amples; +!-2!A"%&2 G M2&+ G $+&A"G &2A66666666666 6666666666666 66666666666 M2!+< &2(+&T -A!$+& -euristic #earch Techniques enerate,and,Test strategy Algorithm 7. enerate a possible solution. 'or some problems, #eneratin# a particular point in the problem space. 'or others, #eneratin# a path *rom a start state. 8. Test to see i* this is actually a solution by comparin# the chosen point or the end point o* the chosen path to the set o* acceptable #oal states. 1. I* a solution has been found, quit. 2therwise, return to step 7. Depth,first search procedure since complete solutions must be #enerated be*ore they can be tested. Also known as the British 3useum algorithm (*indin# an ob=ect in the (ritish Museum by wanderin# randomly).

D. S. R. Murthy

AI Unit 1

12

-ill !limbing In >ill climbin#, *eedback *rom the test procedure is used to help the #enerator decide which direction to mo)e in the search space. Algorithm 7. $valuate the initial value. I* it is a #oal state, then return it and .uit. 2therwise, continue with the initial state as the current stat. 8. 4oop until a solution is found or until there are no new operators le*t to be applied in the current state; a. #elect an operator that has not yet been applied to the current state and apply it to produce a new state. b. $valuate the new state. i. I* it is a #oal state, then return it and .uit. ii. I* it is not a #oal state but it is better than the current state, then make it the current state. iii. I* it is not better than the current state, then continue in the loop. Best,*irst #earch Depth,*irst search allows a solution to be *ound without all competin# branches ha)in# to be e,panded. Breadth,*irst search does not #et trapped on dead6end paths. Best,*irst #earch combines the advantages of both depth,first and breadth,first search into a sin#le method. It *ollows a sin#le path at a time, but switch paths whene)er competin# path looks more promisin# than the current one does. !ode lists used )"$. Priority .ueue. Most promisin# )alue o* the heuristic *unction are the hi#hest priority elements. >euristic *unction applied to #enerated nodes, but ha)e not yet been e,amined. !4)#$D Already e,amined nodes kept in the memory. 4hene)er a new node is #enerated, need to check whether it has been #enerated be*ore. Algorithm 7. tart with 2P+! containin# =ust the initial state. 8. Until a #oal is *ound or there are no nodes le*t on 2P+! do; a. Pick the best node on 2P+!. b. $enerate its successors. c. 'or each successor do; i. I* it has not been #enerated be*ore, e)aluate it, add it to 2P+!, and record its parent. ii. I* it has been #enerated be*ore, chan#e the parent i* this new path is better than the pre)ious one and update the cost o* #ettin# to this node and to any successors that this node may already ha)e. Agenda,Driven #earch An agenda is a list o* tasks a system could per*orm. Associated with task, a list o* reasons why the task is bein# proposed (5ustification) and a ratin# representin# the o)erall wei#ht o* e)idence su##estin# that the task would be use*ul.

D. S. R. Murthy

AI Unit 1

13

D. S. R. Murthy

AI Unit 1

14

Algorithm 7. -o until a #oal state is reached or the a#enda is empty; a. %hoose the most promisin# task *rom the a#enda. b. +,ecute the task by de)otin# to it the important resources, time and space. +,ecutin# the task will probably #enerate additional tasks (successor nodes). i. ee i* it is already on the a#enda. I* so, then see i* this same reason *or doin# it is already on its list o* =usti*ications. I* so, i#nore this current e)idence. I* this =usti*ication was not already present, add it to the list. I* the task was not on the a#enda, insert it. ii. %ompute the new taskOs ratin#, combinin# the e)idence *rom all its =usti*ications. "roblem (eduction A.D)( raphs is use*ul *or representin# the solution o* problems that can be sol)ed by decomposin# them into a set o* smaller problems, all o* which must then be sol)ed. This decomposition #enerates A!- arcs. 2ne A!- arc may point to any number o* successor nodes, all o* which must be sol)ed in order *or the arc to point to a solution. A!- arcs are indicated with a line connectin# all the components. A (1:) ( % (7F) (5) (8F) + ' $ > I T (D) (7@) (1) (9) (7D) (7@) The top node A has been e,panded producin# yow arcs, one leadin# to ( and one leadin# to % and -. The numbers at each node represent the )alue o* *O at that node. Assume that e)ery operation has a uni*orm cost, so each arc with a sin#le successor has a cost o* 7 and each A!- arc with multiple successors has a cost o* 7 *or each o* its components. The most promisin# sin#le node is $ with an *O )alue o* 1. It is e)en part o* the most promisin# arc $6>, with a total cost o* 5. It is not part o* the current best path since to use it, we must also use the arc I6T with a cost o* 8F. The path *rom A, throu#h (, to + and ' is better, with a total cost o* 7:. !onstraint #atisfaction oal -isco)er some problem state that satis*ies a #i)en set o* constraints. $%ample; %ryptarithmetic problem %onstraint satis*action approach a)oids makin# #uesses on particular assi#nments o* numbers to letters until it has to. +ach number may correspond to only one letter and that the sums o* the di#its must be as they are #i)en in the problem. Th e number o* allowable #uesses is reduced. %onstraint satis*action is a search procedure that operates in a space o* constraint sets. The initial state contains the constraints that are ori#inally #i)en in the problem description. A #oal state is any state that has been constrained Menou#hN. +,ample *or %ryptarithmetic problem is each letter has been assi#ned a uni.ue numeric )alue. 7. %onstraints are disco)ered and propa#ated as *ar as possible throu#hout the system. A #uess about somethin# is made and added as a new constraint. Propa#ation can then occur with this new constraint and so on. 8. ome hypothesis about a way to stren#then the constraints must be made.

D. S. R. Murthy

AI Unit 1

15

Algorithm 7. "ropagate available constraints. 'irst set 2P+! to the set o* all ob=ects that must ha)e )alues assi#ned to them in a complete solution. Then do until an inconsistency is detected or until 2P+! is empty. a. elect an ob=ect 2( *rom 2P+!. tren#then as much as possible the set o* constraints that apply to 2(. b. I* this set is di**erent *rom the set that was assi#ned the last time 2( was e,amined or i* this is the *irst time 2( has been e,amined, then add to 2P+! all ob=ects that share any constraints with 2(. c. &emo)e 2( *rom 2P+!. 8. I* the union of the constraints disco)ered abo)e de*ines a solution, then quit and report the solution. 1. I* the union of the constraints disco)ered abo)e de*ines a contradiction, then return failure. 9. I* neither o* the abo)e occurs, then it is necessary to make a #uess at somethin# in order to proceed. "oop until a solution i* *ound or all possible solutions ha)e been eliminated; a. elect an ob=ect whose )alue is not yet determined and select a way o* stren#thenin# the constraints on that ob=ect. b. &ecursi)ely in)oke constraint satis*action with the current set o* constraints au#mented by the stren#thenin# constraint =ust selected. !ryptarithmetic "roblem +!GM2&+ 66666666666 M2!+< Initial #tate !o two letters ha)e the same )alue. The sums o* the di#its must be shown in the problem. oal state All letters ha)e been assigned a digit in such a way that all the initial constraints are satis*ied. olution process proceeds in cycles. At each cycle, 7. %onstraints are propa#ated by usin# rules that correspond to the properties o* arithmetic. 8. A )alue is #uessed *or some letter whose )alue is not yet determined. 'ew heuristics can help to select the best #uess to try *irst. $%amples; 7. I* there is a letter that has only two possible )alues and another with si, possible )alues, there is a better chance o* #uessin# ri#ht on the *irst than on the second. 8. I* there is a letter that participates in many constraints then it is a #ood idea to pre*er it to a letter that participates in a *ew. A #uess on a hi#hly constrained letter will lead .uickly either to a contradiction (i* it is wron#) or to the #eneration o* many additional constraints (i* it is ri#ht). A #uess on a less constrained letter pro)ides less in*ormation. %K, %8, %1, and %9 indicate the carry bits out o* the columns, numberin# *rom the ri#ht.

D. S. R. Murthy

AI Unit 1

16

!ycle 6 Additional !onstraints generated 7. Two sin#le6di#it numbers plus a carry cannot total more than 75. ML7 8. G M G %1 B 5 (to #enerate the carry) G 7 G %1 B 5 G %1 B : %1 L @ or 7 L : or 5 1. 7@ G 2 L G M (7) G %1 (@ or 7) L 7@ or 77 (to #enerate carry) 2 L @ or 7 2 L @ (since M L 7) 9. + G 2 G %8 L ! + G %8 L ! (since 2 L@) %8 L @ or 7 I* %8 L @, ! L + (ut ! + %8 L 7 !L+G7 D. ! G & G %7 B 5 (since %8 L 7) %7 L @ or 7 !G&B: E. ! G & G %7 I 7: + AB 5 !o more constraints can be #enerated. $uess + L 8 !ycle 7 F. ! L + G 7 L 1 :. ! (1) G & G %7 (@ or 7) L + L 8 or 78 1 G & G @ or 7 L 78 & L : or 5 5. + G - L < or 7@ G < 8 G - L < or 7@ G < !o more constraints can be #enerated. $uess %7 L 7 !ycle 8 7@. 8 G - L 7@ G < -L:G< - L : or 5 I* - L :, < L @ (%on*lict as 2 L @) I* - L 5, < L 7 (%on*lict as M L 7) %7 L @ 77. 8 G - L < ! G & L 7@ G + &L5 L:

D. S. R. Murthy

AI Unit 1

17

)perator subgoaling The kind o* backward chainin# in which operators are selected and then sub#oals are set up to establish the preconditions o* the operators 3eans,$nds Analysis The means6ends analysis process centers around the detection o* di**erences between the current state and the #oal state. An operator that can reduce the di**erence must be *ound. et up a subproblem o* #ettin# to a state in which it can be applied. The operator does not produce e,actly the #oal state we want. Then we ha)e a second subproblem o* #ettin# *rom the state it does produce to the #oal. (ut i* the di**erence was chosen correctly and i* the operator is really e**ecti)e at reducin# the di**erence then the two subproblems should be easier to sol)e than the ori#inal problem. The means6ends analysis process can then be applied recursi)ely.

Vous aimerez peut-être aussi