Presentation is loading. Please wait.

Presentation is loading. Please wait.

Expert Systems Expert systems are AI programs that solve a highly technical problem in some domain Expert systems are AI programs that solve a highly technical.

Similar presentations


Presentation on theme: "Expert Systems Expert systems are AI programs that solve a highly technical problem in some domain Expert systems are AI programs that solve a highly technical."— Presentation transcript:

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

2 Expert systems Prolog is an excellent language for implementing 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”) (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. 2COSC 2P93 Prolog: Expert Systems

3 Expert Systems: terms 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 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 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 knowledge base: repository of expert's rules and facts about a domain inference engine: procedure for drawing conclusions from knowledge base inference engine: procedure for drawing conclusions from knowledge base knowledge engineer: develops, implements, and maintains a model of an expert's 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) expert system shell: software used to implement an expert system; usually generic (and commercialized) 3COSC 2P93 Prolog: Expert Systems

4 Expert System Architecture 4COSC 2P93 Prolog: Expert Systems Knowledge Base Inference Engine InterfaceInterface "Real world" ( humans, robots, machines,... ) Working Storage

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

6 More Bird KB rules 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). 6COSC 2P93 Prolog: Expert Systems

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

8 An expert system shell Preferable to ask user to enter colour, or answer “yes” or “no” as necessary. 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). 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. 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. Need a “cache” of computed goals. Improvements that a shell could offer: Improvements that a shell could offer: 1. Add predicates to ask questions when required. 2. Save the answers to questions. 8COSC 2P93 Prolog: Expert Systems

9 Shell 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 user write('? : '), read(Y), % get the answer asserta(known(Y, A, V)), % remember it Y == yes. % succeed or fail 9COSC 2P93 Prolog: Expert Systems

10 Bird ES ?- 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 10COSC 2P93 Prolog: Expert Systems

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

12 Explanation Why: explain the line of reasoning for this question Why: explain the line of reasoning for this question Goes from node UP to the root of the tree. Goes from node UP to the root of the tree. How: How was some advice derived? How: How was some advice derived? Goes from node DOWN the branch. Goes from node DOWN the branch. Why not: Why was some other advice not given? 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. 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. Very similar to the one that kept the proof tree for boolean logic. Also similar to grammars that keep the parse tree. Also similar to grammars that keep the parse tree. 12COSC 2P93 Prolog: Expert Systems

13 Simple meta-interpreter 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). 13COSC 2P93 Prolog: Expert Systems

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

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

16 Explanation With nicer looking rules, you can make explanation and queries more English-like... 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 16COSC 2P93 Prolog: Expert Systems

17 Uncertainty Previous rules had “CF 80” terms: Certainty Factor Previous rules had “CF 80” terms: Certainty Factor Expertise is often vague, rather than black and white. Expertise is often vague, rather than black and white. eg. medical diagnoses: could be likelihoods of different diseases. eg. medical diagnoses: could be likelihoods of different diseases. Doctors want to consider all possibilities. Doctors want to consider all possibilities. Expert systems with uncertainty will allow multiple conclusions to be reached. 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... 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 17COSC 2P93 Prolog: Expert Systems

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

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

20 Forward-chaining interpreter % 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. 20COSC 2P93 Prolog: Expert Systems

21 Conclusion Expert systems: one of the major commercial success stories of AI (along with data mining, vision, object- oriented programming,...) 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. 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! 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. 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. Its ability to interface with databases, other languages, and the WWW, makes it ideal for implementing ES software. 21COSC 2P93 Prolog: Expert Systems


Download ppt "Expert Systems Expert systems are AI programs that solve a highly technical problem in some domain Expert systems are AI programs that solve a highly technical."

Similar presentations


Ads by Google