Expert Systems Artificial Intelligence Lecture 4 Karim Bouzoubaa
Artificial Intelligence Copyright Karim Bouzoubaa 2 Introduction ES: Capture, represent, store and apply human K using a machine Practical way to build automated experts (where there is a need for practical experience) Application areas Medicine Management (Banking, Finance, Marketing) Mineral prospecting
General Architecture Artificial Intelligence Copyright Karim Bouzoubaa 3 Traditional software Data And results Prog (set of procedures) KB software KB Inference Engine (exploitation mechanism of the K)
Reasoning within ES Artificial Intelligence Copyright Karim Bouzoubaa 4 Expert systems have been developed in the 1970s as practical systems to reason on knowledge in terms of rules and facts as flat databases (triplets) In the 1980s other ideas, i.e. semantic nets, frames, etc. An expert system is an automatic reasoner that is based on the logic inference rule called Modus Ponens
Detailed Architecture The inference engine is the reasoning module which uses Modus Ponens IF P(x) Then Q(x) rule P(a) fact ----------------- (inference) Q(a) deduced fact The inference engine matches facts (P(a)) and rule premises (IF P(x)) to deduce new facts Q(a) It also chains rules: IF P Then Q and IF Q Then R Artificial Intelligence Copyright Karim Bouzoubaa 5
Detailed Architecture Artificial Intelligence Copyright Karim Bouzoubaa 6 UI Facilitate the dialogue (NL, graphical, etc.) System Explanation Justifies conclusions KB Production rules IE Modes of reasoning Filtering Choice of Rules
Artificial Intelligence Copyright Karim Bouzoubaa 7 K in the form of production rules KB Transferring a specialist's K to a machine Difficulty: Expert K's are very diverse His way of reasoning Making decisions To make a diagnosis To gain experience Formalism 'Rule of production' is the most used Cause: Experts tend to express K in form: situation -> action
Artificial Intelligence Copyright Karim Bouzoubaa 8 KB Some examples of rules IF AND THEN an animal is of a given species this animal has children children are of the same species IF AND THEN start time work > 7 pm finishing hour < 7 am work schedule = night time
Artificial Intelligence Copyright Karim Bouzoubaa 9 KB The + of this formalism Express very varied K Declarative K Rules are independent KB consists of granules of K Various types of information Inferences resulting from specific observations Abstraction, generalizations and categorization of data Conditions necessary to achieve a goal Strategies to eliminate uncertainty Probable causes of symptoms
Artificial Intelligence Copyright Karim Bouzoubaa 10 K in the form of schemas Frame: structure to describe an object KB The + of this formalism Lets translate the typical way experts organize most of their K Provides a structured representation of relationships between objects Supports a concise technique of definition by specialization that is easy to implement for most experts Sharing information between multiple schemas (inheritance) Procedural Attachment The - of this formalism No direct way to describe K in declarative form
Artificial Intelligence Copyright Karim Bouzoubaa 11 IM We consider the case of production rules The IM decides What rules apply? In which order? Use of FB with its enrichment The modes of reasoning How the IM uses the K made available to it Two modes of reasoning Forward Chaining : get all deductible facts until reaching the solution (no focus on purpose) Backward chaining: replace the hypothesis with a set of sub-goals (risk of looping)
IM Artificial Intelligence Copyright Karim Bouzoubaa 12 Introduction Set of candidate rules Choice of the rule to trigger Example RB R1 IF animal has feathers THEN animal is a bird R2 IF animal flies AND animal lays eggs THEN animal is a bird R3 IF animal is a bird AND animal remarkable flight THEN animal is an albatros BF F1 F2 F3 animal flies animal has feathers animal remarkable flight
IM (Forward chaining) Artificial Intelligence Copyright Karim Bouzoubaa 13 R1 IF animal has feathers THEN animal is a bird R2 IF animal flies AND animal lays eggs THEN animal is a bird R3 IF animal is a bird AND animal remarkable flight THEN animal is an albatros Proposition: animal is an albatros Forward chaining animal flies animal has feathers animal remarkable flight R1 animal flies animal has feathers animal remarkable flight animal is a bird R3 animal flies animal has feathers animal remarkable flight animal is a bird animal is analbatros
IM (Forward chaining) Forward-chaining consists in starting from facts describing a situation and using the rule base to try to deduce as many new facts as it is possible (saturation of the fact base). This is a direct use of the modus ponens inference rule Example (Forward Chaining) Facts: b, c, m, n Rules: R1 IF a Then d And f R2 IF b And d Then g And h R3 IF f And e Then l And o New fact1 (provided by user): a Deduced facts: d, f, g, h New fact2 (provided by user): e Deduced facts: none New fact3 (provided by user): a And e Deduced facts: d, f, g, h, l, o Artificial Intelligence Copyright Karim Bouzoubaa 14
IM (Backward-chaining ) Artificial Intelligence Copyright Karim Bouzoubaa 15 R1 IF animal has feathers THEN animal is a bird R2 IF animal flies AND animal lays eggs THEN animal is a bird R3 IF animal is a bird AND animal remarkable flight THEN animal is an albatros Proposition: animal is an albatros Backward chaining Animal is an albatros R3 animal remarkable flight animal is a bird R1 R2 animal has feathers animal flies animal lays eggs
IM (Backward-chaining ) Artificial Intelligence Copyright Karim Bouzoubaa 16 Backward-chaining consists in setting an hypothetical fact (in Prolog terms we speak of a goal) and using the rule base and the inference engine to go backward and to try to retrieve the facts in the fact base and the chain of rules that enable to deduce the hypothetical fact Example (Backward Chaining) Facts: b, c, m, n Rules: R1 IF a Then d And f R2 IF b And d Then g And h R3 IF f And e Then l And o Hypothesis (submitted by user): f Proof: No Explanation: R1 cannot be triggered Advice: Try to verify fact a New fact (provided by user): a Proof: f true (backward chaining) Explanation: d And f true because rule R1 and fact a Other deduced facts: g, h In practice, most systems use both Forward and Backward Chainings
IM Filtering operation and rule selection strategy Comparison of each of the rules of the KB with the set of facts à filtering operation (pattern matching) No ideal solution for choosing a single rule to trigger The 1st The simplest etc. Determine pertinent rules using matching General Cycle Select one rule Execute the selected rule Artificial Intelligence Copyright Karim Bouzoubaa 17
Deduction systems Artificial Intelligence Copyright Karim Bouzoubaa 18 Deduction system to identify animals (zoologist expert) Observing an animal Series of Questions Identify the observed animal Example of interaction ES: Does the animal have hairy bodies? User: yes ES: Does the animal have the tips of the paws with claws? User: yes ES: Does the animal have eyes directed forward? User: yes ES: Is the shape of the animal's teeth sharp? User: yes ES: Is the color of the animal brown? User: yes ES: Does the animal's dress have black stripes? User: yes ES: According to my K, the animal is a tiger
Deduction systems Artificial Intelligence Copyright Karim Bouzoubaa 19 R1 R2 R3 R4 IF animal body is worth "hairs" THEN animal is a mammal IF food_young animal is "milk" THEN animal is a mammal IF animal body is "feathers" THEN animal is a bird IF locomotion animal is flies" AND animal reproduction is "eggs" THEN animal is a bird R10 R11 IF animal is an "ungulate" AND nature of legs is "long" AND nature of the neck is "long" AND color is "brown" AND dress is "Black rayes" THEN animal is a giraffe IF animal is an "ungulate" AND color is "white" AND dress is "black stripes" THEN animal is a zebra R5 R6 IF animal is a "mammal" AND animal food is "meat" THEN animal is a carnivore IF animal is a "mammal" AND eye direction is "forward" AND teeth shape is "pointed" And ends of the legs is "claws" THEN animal is a carnivore R12 R13 IF animal is a "bird" AND animal locomotion is "does not fly" THEN animal is a non-flying bird IF animal is a "bird" AND animal locomotion is "swim" THEN animal is a non-flying bird R7 R8 R9 IF animal is a "mammal" And extremities of the legs is "nails" THEN animal is an ungulate IF animal is a "carnivore" AND color is "brown" AND dress is "Black Tasks" THEN animal is a hedge IF animal is a "carnivore" AND color is "brown" AND dress is "black stripes" THEN animal is a tiger R14 R15 R16 IF animal is a "non-flying bird" AND nature of legs is "long" AND nature of the neck is "long" AND color is "black and white" THEN animal is an ostrich IF animal is a "non-flying bird" AND nature of the legs is "palmate" AND color is "black and white" THEN animal is a penguin IF animal is a "bird" AND nature of the flight is "remarkable" THEN animal is an albatross bird
Systèmes de déduction - Exemple IM forward chaining Observed Animal : abcdef Working memory Covered body is "hairs" End of the legs is "nails" Nature of neck is "long" Color is "brown" Dress "black abcdef is a giraffe (R1, R7, R10) Artificial Intelligence Copyright Karim Bouzoubaa 20
Deduction system - Example Artificial Intelligence Copyright Karim Bouzoubaa 21 IE backward chaining Observed Animal: abcdef Hypothesis to be verified: abcdef is a cheetah Working memory
Explanation Artificial Intelligence Copyright Karim Bouzoubaa 22 How(B) ==> B1 B2 B3 B B1 B2 B3 Why(B2) ==> B
ES Examples The agricultural harvest Help with diagnosis Decision support in the identification of microorganisms responsible for infections: MYCIN Medical Decision Support: SPHINX Application to diagnose diseases frequently caught in shrimps Artificial Intelligence Copyright Karim Bouzoubaa 23
ES - Management Artificial Intelligence Copyright Karim Bouzoubaa 24 Aim of a Management ES: Assist business managers in making decisions to solve complex problems with the competence of a management expert Need M-ES for: HR management (recruitment, assignment, transfer, etc.) Financial management Marketing Management of Portfolios Assist a bank's advising clients with respect to investments Orient the loan decisions based on a complete diagnosis of the company's strengths and weaknesses
Loan Expert Systems Artificial Intelligence Copyright Karim Bouzoubaa 25
Medical ES The medical procedure is divided into four stages: 1. Examination of the patient 2. Elaboration of the diagnosis 3. Therapeutic prescription 4. Monitoring the evolution ESs concern steps 2, 3 & 4 Example: A patient consults a physician for some illness The physician asks the patient for data symptoms and patient s characteristics à Facts The physician uses his/her medical knowledge (rules about symptoms and illnesses) to deduce new facts (forward-chaining) He can also set hypothesis (backward chaining). Based on an hypothesis ( patient has the flu ), the physician may ask questions to the patient to verify facts that have not been identified yet, or the physician may ask the patient to undergo tests to verify some facts (Symptoms). With all these facts the physician can deduce the patient s illness (forward-chaining) with a certain degree of certainty When the physician has identified the patient s illness, s/he uses his/her knowledge of cures (rules about illnesses and medication) to prescribe some medicine to the patient (forwardchaining) Artificial Intelligence Copyright Karim Bouzoubaa 26
Known ES examples Artificial Intelligence Copyright Karim Bouzoubaa 27 DESIGN ADVISOR Gives advice to designers of processor chips DENDRAL Used to identify the structure of chemical compounds. PROSPECTOR Used by geologists to identify sites for drilling or mining MYCIN Medical system for diagnosing blood disorders. First used in 1979
Problems with Expert Systems Limited domain Systems are not always up to date, and don t learn No common sense Experts needed to setup and maintain system Who is responsible if the advice is wrong? Artificial Intelligence Copyright Karim Bouzoubaa 28
Demo PID ES Artificial Intelligence Copyright Karim Bouzoubaa 29
Demo PID ES Artificial Intelligence Copyright Karim Bouzoubaa 30
Demo PID ES Artificial Intelligence Copyright Karim Bouzoubaa 31
Examples of ES Artificial Intelligence Copyright Karim Bouzoubaa 32 http://www.easydiagnosis.com/login/modules.html http://www.exsys.com/demomain.html