1 / 31

Declarative Programming PROLOG

Declarative Programming PROLOG. (+ Bayesian Nets). Second part of Cmput325 Fall 2004 R Greiner + B Price. Declarative Programming. Motivation Warm Fuzzies What is Logic? ... Logic Programming? Mechanics of Prolog Terms, Substitution, Unification, Horn Clauses, Proof process

baylee
Download Presentation

Declarative Programming PROLOG

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. Declarative Programming PROLOG (+ Bayesian Nets) Second part of Cmput325 Fall 2004 R Greiner + B Price

  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. 2004 … 1990 … 1980

  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. 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. The Catch … Expert System

  7. Expert System 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. MYCIN Blood Infections CADUCEUS Internal Medicine CASNET Glaucoma Present lllness Program Kidney Medical Expert Systems • Digitalis advisor • Erratic Heartbeat • VM • Ventilator Management • ALVEN • Ventricle Movement • ONCOCIN • Cancer Treatment Protocols • …

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

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

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

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

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

  14. R1 (New Goal) Socrates is a Man Example of Deduction Socrates is Mortal (Goal) Knowledge Base

  15. R2 R1 Plato is a Cat Plato is a Man R3 Plato purrs Example of Deduction, #2 Plato is Mortal

  16. R9 Aristotleis a Human Aristotle is male Example of Deduction, #3 Aristotle is a man

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

  18. Consider claim This is Belgium. based on “proof” Today is Tuesday. If Today is TuesdayThen 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… Just Manipulating Symbols

  19. 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.

  20. 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 $18.00. • ...

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

  22. 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. Additional Rules

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

  24. 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] . . .

  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 … 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] . . .

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

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

  28. Variables You can park at X RL RA RB X = SpaceA X = ParkingLot-L X = SpaceB RA: if (1) …, then Can park @ SpaceA. o o o RB: if (1) …, then Can park @ SpaceB. o o o RL: if (1) …, then Can park @ Lot-L. o o o

  29. R1 R2 f(Abe, Dave) f(Abe, y1) f(Abe, y2) a(Abe, y1) a(Abe, y2) a(Abe, y3) a(y3, y2) a(y2, y1) a( y1, Dave) R1 R2 R1 R2 Control of Search FACTS F1: f( Abe, Bob ) F2: f( Bob, Charles ) F3: f( Charles, Dave ) RULES R1: a( x, y ) & a( y, z )  a( x, z ) R2: f( x, y )  a ( x, y ) a(Abe, Dave)

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

More Related