35
Expert Systems Expert Systems

Expert Systems

Embed Size (px)

Citation preview

Page 1: Expert Systems

Expert SystemsExpert Systems

Page 2: Expert Systems

Expert SystemsExpert Systems

http://www.exsys.com/demomain.html http://www.aiinc.ca/demos/whale.html http://www.myacquire.com/aiinc/stock/ http://www.myacquire.com/aiinc/spa/ http://www.myacquire.com/aiinc/pest/

http://www.lpa.co.uk/pws_exec/flx/webflex.exe?webflex=yield

http://www.youtube.com/watch?v=pqlSO_GlmeQ

http://easydiagnosis.com/

Page 3: Expert Systems

Expert SystemsExpert Systems

Solves problems or gives advice within a Solves problems or gives advice within a specialized area of knowledge. specialized area of knowledge.

A good system can match the performance of a A good system can match the performance of a human specialist; in wide commercial use. human specialist; in wide commercial use.

Uses include: Uses include: medical diagnosis, chemical analysis, medical diagnosis, chemical analysis, credit authorization, financial management, corporate credit authorization, financial management, corporate planning, automobile design and manufacture, camera planning, automobile design and manufacture, camera lens design, computer installation design, airline lens design, computer installation design, airline scheduling, cargo placement, and on and on….scheduling, cargo placement, and on and on….

Page 4: Expert Systems

ResourcesResources

Handout on e-reserve from AI illuminated, pages 46-50, 75-78, 81-83, 144-152, 267-284

http://en.wikipedia.org/wiki/Expert_system

http://www.cs.usfca.edu/www.AlanTuring.net/turing_archive/pages/Reference%20Articles/what_is_AI/What%20is%20AI07.html

Page 5: Expert Systems

InductiveInductive reasoning (machine reasoning (machine learning)learning)– make generalizations based on observed make generalizations based on observed

patterns (“the sun will come up patterns (“the sun will come up tomorrow”)tomorrow”)

– generalizations are “guesses”, not generalizations are “guesses”, not guaranteedguaranteed

ReasoningReasoning

Page 6: Expert Systems

ReasoningReasoning

DeductiveDeductive reasoning ( reasoning (Logical Logical

InferenceInference))– use rules of logic to conclude new facts use rules of logic to conclude new facts

based on existing knowledge based on existing knowledge ““all men are mortal; socrates is a man; all men are mortal; socrates is a man;

thus socrates is mortal”. thus socrates is mortal”.

If the first two statements are true, the If the first two statements are true, the conclusion must be true.conclusion must be true.

Page 7: Expert Systems

Expert SystemsExpert Systems

““Common sense” hard to program - just so Common sense” hard to program - just so broad.broad.

““Deep Knowledge” / Expert System / Fact-Rich Deep Knowledge” / Expert System / Fact-Rich easier to program easier to program if the domain is limited.if the domain is limited.

Hundreds of applications: medical, science, Hundreds of applications: medical, science, business, …business, …

One of great success stories of AIOne of great success stories of AI

Page 8: Expert Systems

Procedural Knowledge

A decision diagram is a kindof expert system

Easy to implement this logic in a computer program

Human knowledge not typically “stored” in this waybut instead as a collection offacts and relationships.

Page 9: Expert Systems

Big ViewBig View

Knowledge Base

Inference Engine

User

what to think about

how to think

Page 10: Expert Systems

Knowledge BaseKnowledge Base

stores facts about a domainstores facts about a domain often in form of “if-then” rulesoften in form of “if-then” rules

– http://www.youtube.com/watch?v=pqlSO_GlmeQ

– example [FROM example [FROM CS IlluminatedCS Illuminated]...]...

Page 11: Expert Systems

LAST: the last date a lawn treatment was appliedCURRENT: the current dateSEASON: the current season

IF (CURRENT - LAST < 30) THEN NONEIF (SEASON = winter) THEN not BUGSIF (BARE) then TURFIF (SPARSE and not WEEDS) THEN FEEDIF (BUGS and not SPARSE) THEN BUGIF (WEEDS and not SPARSE) THEN WEEDIF (WEEDS and SPARSE) THEN WEEDFEED

NONE: apply no treatment at this timeTURF: apply a turf-building treatmentWEED: apply a weed-killing treatmentBUG: apply a bug-killing treatmentFEED: apply a basic fertilizer treatmentWEEDFEED: apply a combination of WEED & FEED

Page 12: Expert Systems

Example rule in knowledge Example rule in knowledge basebase

(from MYCIN - bacterial infections - 1972)(from MYCIN - bacterial infections - 1972)

If the site of the culture is blood, and the stain of the If the site of the culture is blood, and the stain of the organism is gramneg, and the morphology of the organism is gramneg, and the morphology of the organism is rod, and the patient has been organism is rod, and the patient has been seriously burned, then there is evidence (.4) that seriously burned, then there is evidence (.4) that the identity of the organism is pseudomonas.the identity of the organism is pseudomonas.

Thousands of rules possibleThousands of rules possible Knowledge EngineerKnowledge Engineer works in concert with works in concert with

domain expert to extract useful rules.domain expert to extract useful rules.

Page 13: Expert Systems

Inference EngineInference Engine

Abstract rules of logic showing what Abstract rules of logic showing what deductions can be made.deductions can be made.

Crash course: propositional logicCrash course: propositional logic

Represent Represent propositionspropositions as variables as variables

r: “It is raining” r: “It is raining” T or FT or Fc: “It is cloudy” c: “It is cloudy” T or FT or Fs: “Santa has 4 wheels” s: “Santa has 4 wheels” T or FT or F

Page 14: Expert Systems

Compound propositionsCompound propositions

Operators:Operators: AND (AND (), OR (), OR (), IMPLIES (), IMPLIES (), NOT (), NOT ())

r r c: It is raining and it is cloudy c: It is raining and it is cloudy (T/F ?)(T/F ?)r r c: It is raining or it is cloudy c: It is raining or it is cloudy (T/F ?)(T/F ?) s:s: Santa does not have 4 wheels Santa does not have 4 wheels

(T/F ?)(T/F ?)c c r: If it is cloudy, then it is raining r: If it is cloudy, then it is raining (T/F ?)(T/F ?)r r c: If it is raining, then it is cloudy c: If it is raining, then it is cloudy (T/F ?)(T/F ?)

Page 15: Expert Systems

Truth tablesTruth tables

AND (AND (), OR (), OR (), NOT (), NOT ())

A B AA B AB AB AB B AA

TT TT TT T T F F

TT FF FF T T F F

F F TT FF T T T T

FF FF FF F F T T

Page 16: Expert Systems

Truth Table for ImpliesTruth Table for Implies

A B A A B A BB

TT TT TT

TT FF FF

F F TT ??

FF FF ??

Not the same as “causes” !!Not the same as “causes” !!

Page 17: Expert Systems

Example TranslationExample Translation

1.1. If symptom P is present, then syndrome Q is If symptom P is present, then syndrome Q is likely.likely.

2.2. Either P is present, or diagnosis R is correct.Either P is present, or diagnosis R is correct.

3.3. The patient has symptom S if R is correct.The patient has symptom S if R is correct.

4.4. The patient does not have symptom S.The patient does not have symptom S.

1.1. P P Q Q

2.2. P P R R3.3. R R S S

4.4. SS

Translation into logic statements

Page 18: Expert Systems

Different? ExampleDifferent? Example

1.1. If Pat was involved, then Quinn was too.If Pat was involved, then Quinn was too.

2.2. Pat or Ralph did it.Pat or Ralph did it.

3.3. If Ralph did it, then so did Sam.If Ralph did it, then so did Sam.

4.4. Sam has a good alibi.Sam has a good alibi.

1.1. P P Q Q

2.2. P P R R3.3. R R S S

4.4. SS

Translation into logic statements

Page 19: Expert Systems

Value of abstractionValue of abstraction

Symbols can represent anythingSymbols can represent anything We can encode our knowledge We can encode our knowledge

symbolically, and all that matters is symbolically, and all that matters is the structure of the rules, not the the structure of the rules, not the original meaning. original meaning.

The same rules of logic will apply The same rules of logic will apply regardless of what knowledge the regardless of what knowledge the symbols represented.symbols represented.

Page 20: Expert Systems

Example deduction rulesExample deduction rulesIf you knowIf you know Then you Then you

can can concludeconclude

p, p p, p q q qq forward forward chainingchaining

p p q q pp

pp p p q qp p q, q q, q r r p p r r resolutionresolution

p p q, q, qq pp contrapositivcontrapositivee

p p q, q, pp qq

Page 21: Expert Systems

Example DeductionExample Deduction

1.1. If symptom P is present, then syndrome Q If symptom P is present, then syndrome Q is likely.is likely.

2.2. Either P is present, or diagnosis R is correct.Either P is present, or diagnosis R is correct.3.3. The patient has symptom S if R is correct. The patient has symptom S if R is correct. 4.4. The patient does not have symptom S.The patient does not have symptom S.

1.1. P P Q Q

2.2. P P R R3.3. R R S S

4.4. SS

Translation into logic statements

Page 22: Expert Systems

1.1. P P Q Q2.2. P P R R3.3. R R S S4.4. SS

stmt 3, 4, contrapositive, gives:stmt 3, 4, contrapositive, gives:5.5. RR

stmt 2, 5 impliesstmt 2, 5 implies6.6. PP

stmts 6, 1 impliesstmts 6, 1 implies7.7. QQ

Therefore, syndrome Q is likely.Therefore, syndrome Q is likely.

Page 23: Expert Systems

1. If the apples are tasty then the burgers or the chips are delicious.2. If the chips are delicious, then so are the dogs.3. If the burgers are delicious, then the grapes are sweet.4. The french fries are warm and the grapes are sour.5. The apples are tasty.

Q: How good are the hot dogs ??

Challenge Problem

STEP 1: translate into formulas

1. A B B C C2.2. C C D D3.3. B B G G4.4. F F GG5.5. AA

Page 24: Expert Systems

STEP 2: Deduce new facts

1. A B B C C2.2. C C D D3.3. B B G G4.4. F F GG5.5. AA

Page 25: Expert Systems

STEP 2: Deduce new facts

1. A B B C C2.2. C C D D3.3. B B G G4.4. F F GG5.5. AA

From 4., we know GGFrom 3., we now know From 3., we now know BBFrom 1. and 5., From 1. and 5., we know B B C CFrom two above facts, we know CFrom two above facts, we know CFrom 2., we now know DFrom 2., we now know DSo the hot dogs are delicious!So the hot dogs are delicious!

Page 26: Expert Systems

Lewis Carroll

Page 27: Expert Systems

Inference EngineInference Engine

Two methodsTwo methods– forward chaining (you’ve just seen it)forward chaining (you’ve just seen it)

start with known factsstart with known facts look for left sides of implications that are met, and look for left sides of implications that are met, and

conclude the right side.conclude the right side. repeatrepeat

– backward chaining (example to follow)backward chaining (example to follow) goal to conclude some goal “fact” G goal to conclude some goal “fact” G find implication rule with right side Gfind implication rule with right side G adopt as subgoals those items on left sideadopt as subgoals those items on left side repeatrepeat (sometimes can be working on many goals at once)(sometimes can be working on many goals at once)

Page 28: Expert Systems

RULES (from KB)RULES (from KB)1.1. A A B B C C2.2. A A D D3.3. C C D D E E4.4. B B E E F F H H5.5. A A E E G G

FACTS (from FACTS (from user): user):

A, B, FA, B, F

GOAL: GGOAL: G

FORWARD CHAININGFORWARD CHAINING(a)(a) Facts A, B, and rule (1) Facts A, B, and rule (1)

gives Cgives C(b)(b) Fact A, rule (2) Fact A, rule (2)

gives Dgives D(c)(c) (a), (b), and (3) (a), (b), and (3)

gives Egives E(d)(d) Fact A, (c), rule (5) Fact A, (c), rule (5)

gives Ggives G

THUS, G is true.THUS, G is true.

Page 29: Expert Systems

RULES (from KB)RULES (from KB)1.1. A A B B C C2.2. A A D D3.3. C C D D E E4.4. B B E E F F H H5.5. A A E E G G

FACTS (from FACTS (from user): user):

A, B, FA, B, F

GOAL: GGOAL: G

BACKWARD CHAININGBACKWARD CHAINING(a)(a) Goal GGoal G(b)(b) By (5), subgoals: A, EBy (5), subgoals: A, E(c)(c) Subgoal A met (FACT)Subgoal A met (FACT)(d)(d) By (3), subgoals C, DBy (3), subgoals C, D(e)(e) By (2), subgoal D metBy (2), subgoal D met(f)(f) By (1), subgoals A, BBy (1), subgoals A, B(g)(g) A, B met (FACTS)A, B met (FACTS)

THUS, G is true.THUS, G is true.

Page 30: Expert Systems

the processthe process

INFERENCE ENGINE

chaining with logical rules

USER SUPPLIED FACTS DOMAIN KNOWLEDGE

MORE FACTS

CONCLUSIONS

Main task in building an expert system

system may requestmore facts from user

Page 31: Expert Systems

INFERENCE ENGINE

chaining with logical rules

USER SUPPLIED FACTS DOMAIN KNOWLEDGE

MORE FACTS

CONCLUSIONS

system may requestmore facts from user

1.1. P P Q Q2.2. P P R R3.3. R R S S

SS

syndrome Q is likely.syndrome Q is likely.

Page 32: Expert Systems

INFERENCE ENGINE

chaining with logical rules

USER SUPPLIED FACTS DOMAIN KNOWLEDGE

MORE FACTS

CONCLUSIONS

system may requestmore facts from user

New expert New expert system obtained system obtained by changing by changing knowledge baseknowledge base

new new factsfacts

new conclusionsnew conclusions

Page 33: Expert Systems

Algorithm for Logical Algorithm for Logical Inference?Inference?

Input: Facts, rules, + GInput: Facts, rules, + G Keep applying rules of inference.Keep applying rules of inference. Stop when we get to GStop when we get to G

Does this terminate?Does this terminate?–Try every possible inference over and overTry every possible inference over and over

may not haltmay not halt

–Which problem does this remind you of?Which problem does this remind you of?

How to best do inference: Research areaHow to best do inference: Research area

Page 34: Expert Systems

Explainable resultsExplainable results

Nice feature of expert systems is that Nice feature of expert systems is that typically they can typically they can explainexplain the the reasons for their answers to human reasons for their answers to human users:users:

““G is true because A and B were found to be G is true because A and B were found to be true.”true.”

““A is true because C and D are true.”A is true because C and D are true.”

Page 35: Expert Systems

SummarySummary

Expert systems solve specialized Expert systems solve specialized problemsproblems

Knowledge is obtained from a human Knowledge is obtained from a human expert, and encoded symbolically in expert, and encoded symbolically in a a knowledge baseknowledge base

Additional facts are obtained from Additional facts are obtained from the userthe user

Rules of logic crank away and obtain Rules of logic crank away and obtain new facts, until…new facts, until…

A deduction can be madeA deduction can be made