Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Declarative Programming PROLOG Second part of Cmput325 Fall 2004 R Greiner + B Price (+ Bayesian Nets)

Similar presentations


Presentation on theme: "1 Declarative Programming PROLOG Second part of Cmput325 Fall 2004 R Greiner + B Price (+ Bayesian Nets)"— Presentation transcript:

1 1 Declarative Programming PROLOG Second part of Cmput325 Fall 2004 R Greiner + B Price (+ Bayesian Nets)

2 2 Declarative Programming Motivation Warm Fuzzies What is Logic?... Logic Programming? Mechanics of Prolog Terms, Substitution, Unification, Horn Clauses, Proof process Example: List Processing Theoretical Foundations Semantics Logic / Theorem Proving … Resolution Other Issues Search Strategies Declarative/Procedural,... “Impure'' Operators” --- NOT, ! Utilities ? Constraint Programming ? Bayesian Belief Nets

3 … 1990 …1980

4 4 Story … MD sees patient … perhaps MENINGITIS! Performs standard tests Calls Infection Disease (medical) expert Dialogue: Expert asks for info re: patient Fever, Organism Morphology, Gram Stain, Spinal Fluid, … Doctor's answers: DIRECT : from direct measurement, Lab tests Qualitative: Has HIGH fever Vague: Portal of Entry was GastroIntestinal (w/certainty 0.6) Unknown: don’t know identity of organism?

5 5 Story … con’t MD can ask questions: Why ask about portal of entry? Expert answers: trying to show infecting organism is ENTEROBACTERICAE this information is crucial in that decision. If further questioned, … point to definitive study Expert provides DIAGNOSIS organism was one of {E.coli, Enterobacteria } suggest TREATMENT: Give GENTAMICIN Happily ever after...

6 6 The Catch … Expert System

7 7 An EXPERT SYSTEM is a computer program that exhibits Expert Level performance in solving complex problems. Reasons with Facts about the World: Combines General Facts/Rules (about Diseases,...) with Specific Facts (about Patient) to Produce new Conclusion (diagnosis)

8 8 Medical Expert Systems MYCIN Blood Infections CADUCEUS Internal Medicine CASNET Glaucoma Present lllness Program Kidney Digitalis advisor Erratic Heartbeat VM Ventilator Management ALVEN Ventricle Movement ONCOCIN Cancer Treatment Protocols …

9 9 Other Domains Medicine Chemistry Instruction Job-Shop Management Financial Planning Computer Diagnosis, Configuration VLSI Design Molecular Genetics Signal Analysis Structural Mechanics Mathematics …

10 10 “Declarative Programming'' Knowledge Base Facts about the world Is  true? Proof Procedure 2 Yes … No Give Gentamycin?

11 11 Advantages of Framework Simply Information is Modular Easy to Build Easy to Modify (Extend, Debug) Capable of Explanation Declarative Re-use same info for different tasks store “truths” ask for other truths

12 12 Computers Manipulate SYMBOLS Numbers 3, 5,... Addition, Multiplication,... Propositions “D1 is an inverter'' “Inverters flip bits''... Deduction,...

13 13 Simple Deduction Socrates is a man. If Socrates is a man, Then Socrates is mortal. Socrates is mortal. In general…     

14 14 Example of Deduction Socrates is Mortal (Goal) RULESFACTS R1: If Socrates is a Man, Then Socrates is Mortal o F1: Socrates is a Man. o o Socrates is a Man (New Goal) R1 Knowledge Base

15 15 Example of Deduction, #2 Plato is Mortal RULESFACTS R1: If Plato is a Man, Then Plato is Mortal R2: If Plato is a Cat Then Plato is Mortal. R3: If Plato purrs, Then Plato is a Cat. o F3: Plato purrs. o Plato is a Man R1 Plato is a Cat R2 Plato purrs R3

16 16 Example of Deduction, #3 Aristotle is a man RULESFACTS R2: If Plato is a Cat Then Plato is Mortal. o R9: If Aristotle is a human and Aristotle is male, Then Aristotle is a man o F3: Aristotle is male. o F8: Aristotle is a human o Aristotle is maleAristotle is a Human R9

17 17 Oversimplified Proof Process 1. If Goal = FACT then DONE YES Else … 2. Goal = “Then Part” of Rule R then Goal  “If Part” of R i i i+1 else DONE NO

18 18 Just Manipulating Symbols Consider claim This is Belgium. based on “proof” Today is Tuesday. If Today is Tuesday Then This is Belgium. This is Belgium Conclusion is wrong! Conclusion is ONLY AS TRUE as PREMISES If Premises true, then Conclusion is. Not fault of PROOF process GIGO…

19 19

20 20 Rules R1: if (1) You have a Parking Permit & (2) This space is Permit-Parkable, then You can park at this space. R2: if (1) This space is a Parking Space & (2) Permit-Sign at this space & (3) Current date is Acceptable, then This space is Permit-Parkable. R3: if (1) Current time is 7am-Midnight & (2) This space is Permit-Parkable, then You can park at this space. R4: if (1) Current month is Dec-Mar, then Current date is Acceptable. R5: if (1) Current month is in Apr-Nov & (2) Current day of month is ≤ 15 then Current date is Acceptable.

21 21 Facts This space is a Parking Space. You live near this space. You have a Parking Permit. Current month is in Apr-Nov. Current day is Tuesday. Current day of month is ≤ 15. Permit-Sign at this space. You own a car. Your car is >5 years old. Current time is 3am. You have $

22 22 Inference Graph You can park at this space You have a Parking PermitThis space is Permit-Parkable … Parking Space Permit-Sign … Current date is Acceptable … ≤ 15 …Apr-Nov R1 R2 R5

23 23 Additional Rules R1: if (1) You have a Parking Permit & (2) This space is Permit-Parkable, then You can park at this space. R2: if (1) This space is a Parking Space & (2) Permit-Sign at this space & (3) Current date is Acceptable, then This space is Permit-Parkable. R3: if (1) Current time is 7am-Midnight & (2) This space is Permit-Parkable, then You can park at this space. R4: if (1) Current month is Dec-Mar, then Current date is Acceptable. R5: if (1) Current month is in Apr-Nov & (2) Current day of month is ≤ 15 then Current date is Acceptable. R7: if (1) You live near this space & (2) You own a car & (3) You apply for a permit, then You have a Parking Permit. R8: if (1) You can park at this space then You can take a car.

24 24 Inference Graph You can park at this space You have a Parking PermitThis space is Permit-Parkable … Parking Space Permit-Sign … Current date is Acceptable … ≤ 15 …Apr-Nov You can take a car … live near … …own a car … apply for permit R7 R8 R1 R2 R5

25 25 Mycin: What is the suspected portal of entry of ORGANISM-1 into this sterile site? Doctor: WHY Mycin: [ie, why is it important to determine the … site?] [3.0] … to determine which organism(s) to cover … It has already been established that 3.1] site of culture is blood 3.2] organism stain is gram positive Therefore, if 3.3] portal of entry is g.i. 3.4] locus of infection is Pelvis or Abdomen, Then  strongly suggestive evidence (0.9) that therapy should cover enterobacteriaceae. [Rule 095]...

26 26 Mycin: What is the suspected portal of entry of ORGANISM-1 into this sterile site? Doctor: WHY Mycin: [ie, why is it important to determine the … site?] [3.0] … to determine which organism(s) to cover … If has already been established that 3.1] site of culture is blood 3.2] organism stain is gram positive Therefore, if 3.3] portal of entry is g.i. 3.4] locus of infection is Pelvis or Abdomen, Then  strongly suggestive evidence (0.9) that therapy should cover enterobacteriaceae. [Rule 095]...

27 27 Advantage of Rule Transparency Explain reasoning Support / Credability Helpful when… building/extending system modifying system

28 28 Issues Faster Computation User Interaction Focus of Attention “Human Engineering” Variables Control of Search Which (sub)goal? Which rule?

29 29 Variables You can park at X RARA X = SpaceA X = SpaceB X = ParkingLot-L RBRB RLRL R A : if (1) …, then Can SpaceA. o R B : if (1) …, then Can SpaceB. o R L : if (1) …, then Can Lot-L. o

30 30 Control of Search FACTS F1: f( Abe, Bob ) F2: f( Bob, Charles ) F3: f( Charles, Dave ) RULES R 1 : a( x, y ) & a( y, z )  a( x, z ) R 2 : f( x, y )  a ( x, y ) a(Abe, Dave) R1R1 a(Abe, y 2 ) a(y 2, y 1 ) f(Abe, y 1 ) R2R2 R1R1 a(Abe, y 3 ) a(y 3, y 2 ) f(Abe, y 2 ) R2R2 R1R1 R2R2 a(Abe, y 1 ) a( y 1, Dave) f(Abe, Dave)

31 31 Research Issues Better Decision Making Coping with Uncertainty Better Explanation “Deeper Knowledge” First Principles “Meta” Acquiring the Knowledge … from expert … from data


Download ppt "1 Declarative Programming PROLOG Second part of Cmput325 Fall 2004 R Greiner + B Price (+ Bayesian Nets)"

Similar presentations


Ads by Google