1 / 21

Expert Systems

Expert Systems. Expert systems are AI programs that solve a highly technical problem in some domain Normally a human expert is used for solving such problems. An expert system encodes a human expert’s knowledge. Common areas: medicine science: chemistry, biology engineering agriculture

baris
Télécharger la présentation

Expert Systems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Expert Systems COSC 2P93 Prolog: Expert Systems • Expert systems are AI programs that solve a highly technical problem in some domain • Normally a human expert is used for solving such problems. • An expert system encodes a human expert’s knowledge. • Common areas: • medicine • science: chemistry, biology • engineering • agriculture • military • finance.

  2. Expert systems COSC 2P93 Prolog: Expert Systems • Prolog is an excellent language for implementing expert systems 1. declarative Prolog can denote expert rules (knowledge base) 2. Prolog’s default execution is an “inference” strategy. (called “backward chaining”) 3. Can write meta-interpreters for inference, which can implement things like explanation (knowledge traces), as well as new logic inference strategies. 4. Can use operators and grammars to make user-friendly knowledge languages.

  3. Expert Systems: terms COSC 2P93 Prolog: Expert Systems Knowledge-based system (or expert system): a program which exhibits, within a specific domain, a degree of expertise in problem solving that is comparable with a human expert expert: person with superior knowledge in some particular field, usually only obtained through experience knowledge base: repository of expert's rules and facts about a domain inference engine: procedure for drawing conclusions from knowledge base knowledge engineer: develops, implements, and maintains a model of an expert's knowledge base expert system shell: software used to implement an expert system; usually generic (and commercialized)

  4. Expert System Architecture Knowledge Base I n t e r f a c e "Real world" ( humans, robots, machines, ... ) Inference Engine Working Storage COSC 2P93 Prolog: Expert Systems

  5. Simple example: Bird Identification COSC 2P93 Prolog: Expert Systems Expert’s rule IF family is albatross and color is white THEN bird is laysan_albatross In Prolog the same rule is: bird(laysan_albatross) :- family(albatross), color(white).

  6. More Bird KB rules COSC 2P93 Prolog: Expert Systems bird(laysan_albatross):- family(albatross), color(white). bird(black_footed_albatross):- family(albatross), color(dark). bird(whistling_swan) :- family(swan), voice(muffled_musical_whistle). bird(trumpeter_swan) :- family(swan), voice(loud_trumpeting).

  7. Running Bird KB COSC 2P93 Prolog: Expert Systems At some point, the user must indicate the family and colour of a bird. In Prolog, these facts would be added to KB... family(albatross). color(dark). Then... ?- bird(X). X = black_footed_albatross

  8. An expert system shell COSC 2P93 Prolog: Expert Systems • Preferable to ask user to enter colour, or answer “yes” or “no” as necessary. • Also, don’t want to ask user same question repeatedly. Save answers (eg. colour). • But note that Prolog does not do this by default. Repeated calls to the same goal will be executed each time called. • Need a “cache” of computed goals. • Improvements that a shell could offer: 1. Add predicates to ask questions when required. 2. Save the answers to questions.

  9. Shell COSC 2P93 Prolog: Expert Systems color(X) :- ask(color, X). % put this in KB. ask(A, V):-known(yes, A, V),  % succeed if true!. % and don’t ask user ask(A, V):-known(_, A, V), % was asked before, but not “yes”!, fail. % therefore fail ask(A, V):-write(A:V),  % ask userwrite('? : '), read(Y),  % get the answerasserta(known(Y, A, V)),  % remember itY == yes. % succeed or fail

  10. Bird ES COSC 2P93 Prolog: Expert Systems ?- bird(X). nostrils : external_tubular? yes. live : at_sea? yes. bill : hooked? yes. size : large? yes. wings : long_narrow? yes. color : white? yes. X = laysan_albatross

  11. Explanation COSC 2P93 Prolog: Expert Systems • A valuable feature of expert systems is their ability to explain their line of reasoning. • Often users want to know WHY advice was given, in addition to the advice itself. • Explanation also a good way to debug KB. • eg. nostrils : external_tubular?why. [nostrils(external_tubular), order(tubenose), family(albatross), bird(laysan_albatross)] nostrils : external_tubular?

  12. Explanation COSC 2P93 Prolog: Expert Systems • Why: explain the line of reasoning for this question • Goes from node UP to the root of the tree. • How: How was some advice derived? • Goes from node DOWN the branch. • Why not: Why was some other advice not given? • If Prolog’s inference is used, then the above can be implemented with a meta-interpreter. • Very similar to the one that kept the proof tree for boolean logic. • Also similar to grammars that keep the parse tree.

  13. Simple meta-interpreter COSC 2P93 Prolog: Expert Systems prove(true,_) :- !. prove(menuask(X,Y,Z),Hist) :- menuask(X,Y,Z,Hist), !. prove(ask(X,Y),Hist) :- ask(X,Y,Hist), !. prove((Goal, Rest),Hist) :- !, prove(Goal, [Goal|Hist]), prove(Rest, Hist). prove(Goal,Hist) :- clause(Goal,Body), prove(Body,Hist).

  14. Meta-interpreter COSC 2P93 Prolog: Expert Systems • 2nd argument of prove is the “explanation” list. • Every time a goal is called, it is added to list. • represents the goals from a node up the tree to the root. • Explanation list passed to ask, menuask utilities. • If user asks “why”, then the list can be written out. • Best to write it out in pieces, in “english” format.

  15. Improving the shell COSC 2P93 Prolog: Expert Systems Using “op”, can make nicer looking rules in KB. rule 1 if nostrils is external_tubular and live is at_sea and bill is hooked then order is tubenose cf 80. rule 2 if feet is webbed and bill is flat then order is waterfowl cf 80.

  16. Explanation COSC 2P93 Prolog: Expert Systems With nicer looking rules, you can make explanation and queries more English-like... Are the nostrils external_tubular?why. The nostrils are external_tubular is necessary To show that the order is tubenose To show that the family is albatross To show that the bird is a laysan_albatross

  17. Uncertainty COSC 2P93 Prolog: Expert Systems • Previous rules had “CF 80” terms: Certainty Factor • Expertise is often vague, rather than black and white. • eg. medical diagnoses: could be likelihoods of different diseases. • Doctors want to consider all possibilities. • Expert systems with uncertainty will allow multiple conclusions to be reached. • an ordered list of conclusions (disease diagnoses) will be generated at end of a session... Measles CF 80 Chicken Pox CF 75 Yellow Fever CF 45

  18. Forward-chaining COSC 2P93 Prolog: Expert Systems • Backward chaining: Prolog’s default inference • hierarchical, top-down strategy • However, some problems are not top-down in nature. • eg. building complex machines: often start bottom-up • Forward chaining: bottom-up reasoning strategy • You start with low-level facts (requirements), and “fire” rules until a high-level conclusion reached. • Prolog easily lets you make a forward-chaining meta-interpreter • This is a new “logic programming language” paradigm. • However, no longer a top-down “tree” for inference (like regular Prolog). • Instead, forward-chaining uses a “working storage” of facts. • facts are asserted/retracted during inference.

  19. Forward-chaining rules COSC 2P93 Prolog: Expert Systems rule id1: [1: has(X,hair)] ==> [assert(isa(X,mammal)), retract(all)]. rule id3: [1: has(X,feathers)] ==> [assert(isa(X,bird)), retract(all)].

  20. Forward-chaining interpreter COSC 2P93 Prolog: Expert Systems % the main inference loop, find a rule and try it. if it fired, say so % and repeat the process. if not go back and try the next rule. when % no rules succeed, stop the inference go :- call(rule ID: LHS ==> RHS), try(LHS,RHS), write('Rule fired '),write(ID),nl, !,go. go.

  21. Conclusion COSC 2P93 Prolog: Expert Systems • Expert systems: one of the major commercial success stories of AI (along with data mining, vision, object-oriented programming, ...) • tens of thousands of expert systems being used. • If you qualify (or not) for a mortgage or credit card, an expert system probably made the decision! • Prolog is commonly used as an expert system implementation language. • Its ability to interface with databases, other languages, and the WWW, makes it ideal for implementing ES software.

More Related