Artificial Intelligence Knowledge Representation Problem 2.

58
Artificial Intelligence Knowledge Representation Problem 2

Transcript of Artificial Intelligence Knowledge Representation Problem 2.

Artificial Intelligence

Knowledge Representation Problem 2

first-order logic

for all x: (NOT(Knows(John, x)) OR IsMean(x) OR Loves(John, x)) John loves everything he knows, with the possible exception of mean

things

for all y: (Loves(Jane, y) OR Knows(y, Jane)) Jane loves everything that does not know her

3

Converting sentences to CNF1. Eliminate all ↔ connectives

(P ↔ Q) ((P Q) ^ (Q P))

2. Eliminate all connectives

(P Q) (P Q)

3. Reduce the scope of each negation symbol to a single predicate

P P

(P Q) P Q

(P Q) P Q

(x)P (x)P

(x)P (x)P

4. Standardize variables: rename all variables so that each quantifier has its own unique variable name

Converting sentences

5. Eliminate existential quantification by introducing Skolem constants/functions

(x)P(x) P(c)

c is a Skolem constant (a brand-new constant symbol that is not used in any other sentence)

(x)(y)P(x,y) (x)P(x, f(x))

since is within the scope of a universally quantified variable, use a Skolem function f to construct a new value that depends on the universally quantified variable

f must be a brand-new function name not occurring in any other sentence in the KB.

E.g., (x)(y)loves(x,y) (x)loves(x,f(x))

In this case, f(x) specifies the person that x loves

Generalized Modus Ponens

Modus Ponens - special case of Resolution

p qpq

Sunday Dr Yasser is teaching AISundayDr Yasser teaching AI

Using the tricks:p q pp p q q, i.e. q

Sound rules of inference Each can be shown to be sound using a truth

tableRULE PREMISE

CONCLUSION

Modus Ponens A, A B B

And Introduction A, B A BAnd Elimination A B A

Double Negation A A

Unit Resolution A B, B A

Resolution A B, B C A C

An example(x)(P(x) ((y)(P(y) P(f(x,y))) (y)(Q(x,y) P(y))))

2. Eliminate (x)(P(x) ((y)(P(y) P(f(x,y))) (y)(Q(x,y) P(y))))

3. Reduce scope of negation(x)(P(x) ((y)(P(y) P(f(x,y))) (y)(Q(x,y) P(y))))

4. Standardize variables(x)(P(x) ((y)(P(y) P(f(x,y))) (z)(Q(x,z) P(z))))

5. Eliminate existential quantification(x)(P(x) ((y)(P(y) P(f(x,y))) (Q(x,g(x)) P(g(x)))))

6. Drop universal quantification symbols(P(x) ((P(y) P(f(x,y))) (Q(x,g(x)) P(g(x)))))

Two broad kinds of rule system forward chaining systems, and backward chaining

systems. In a forward chaining system you start with the

initial facts, and keep using the rules to draw new conclusions (or take certain actions) given those facts

In a backward chaining system you start with some hypothesis (or goal) you are trying to prove, and keep looking for rules that would allow you to conclude that hypothesis, perhaps setting new subgoals to prove as you go.

Forward chaining

Proofs start with the given axioms/premises in KB, deriving new sentences until the goal/query sentence is derived

This defines a forward-chaining inference procedure because it moves “forward” from the KB to the goal [eventually]

Forward chaining

Idea: fire any rule whose premises are satisfied in the KB, add its conclusion to the KB, until query is found

Forward chaining example

Backward chaining

Proofs start with the goal query, find rules with that conclusion, and then prove each of the antecedents in the implication

Keep going until you reach premises Avoid loops: check if new sub-goal is

already on the goal stack Avoid repeated work: check if new sub-

goal Has already been proved true Has already failed

Backward Chaining

)(.5

)(.4

)(.3

)()()(.2

),()()(.1

SteveCreeps

SteveSlimy

TomTortoise

zSlugzCreepszSlimy

yxFasterySlugxTortoise

Is Tom faster than someone?

Forward chaining example

KB: allergies(X) sneeze(X) cat(Y) allergic-to-cats(X) allergies(X) cat(Felix) allergic-to-cats(Lise)

Goal: sneeze(Lise)

Exercise You go to the doctor and for insurance

reasons they perform a test for a horrible disease

You test positive The doctor says the test is 99% accurate Do you worry?

Reduction to propositional inferenceSuppose the KB contains just the following:

x King(x) Greedy(x) Evil(x)King(Ali)Greedy(Ali)Brother(Saad, Ali)

Instantiating the universal sentence in all possible ways, we have:

King(John) Greedy(John) Evil(John)King(Richard) Greedy(Richard) Evil(Richard)King(John)Greedy(John)Brother(Richard,John)

The new KB is propositionalized: proposition symbols are

King(John), Greedy(John), Evil(John), King(Richard), etc.

An example

1. Sameh is a lawyer.

2. Lawyers are rich.

3. Rich people have big houses.

4. Big houses are a lot of work. We would like to conclude that Sameh’s

house is a lot of work.

Axiomatization 11. lawyer(Sameh)2. x lawyer(x) rich(x)3. x rich(x) y house(x,y) 4. x,y rich(x) house(x,y) big(y)5. x,y ( house(x,y) big(y) work(y) ) 3 and 4, say that rich people do have at least one house and all

their houses are big. Conclusion we want to show:

house(Sameh, S_house) work(Sameh, S_house) Or, do we want to conclude that Sameh has at least one house

that needs a lot of work? I.e. y house(Sameh,y) work(y)

Hassan and the cat Every animal owner is an animal lover Everyone who loves all animals is loved by

someone. Anyone who kills an animal is loved by no one. Mustafa owns a dog. Either Mustafa or Hassan killed the cat, who is

named SoSo. Did Hassan kill the cat?

Practice example Did Hassan kill the cat

Mustafa owns a dog. Every dog owner is an animal lover. No animal lover kills an animal. Either Hassan or Mustafa killed the cat, who is named SoSo . Did Hassan kill the cat?

These can be represented as follows:

A. (x) Dog(x) Owns(Mustafa ,x)

B. (x) ((y) Dog(y) Owns(x, y)) AnimalLover(x)

C. (x) AnimalLover(x) ((y) Animal(y) Kills(x,y))

D. Kills(Mustafa ,SoSo) Kills(Hassan,SoSo)

E. Cat(SoSo)

F. (x) Cat(x) Animal(x)

G. Kills(Hassan, SoSo)GOAL

22

Convert to clause formA1. (Dog(D))

A2. (Owns(Mustafa,D))

B. (Dog(y), Owns(x, y), AnimalLover(x))

C. (AnimalLover(a), Animal(b), Kills(a,b))

D. (Kills(Mustafa,SoSo), Kills(Hassan,SoSo))

E. Cat(SoSo)

F. (Cat(z), Animal(z)) Add the negation of query:

G: (Kills(Hassan, SoSo))

23

The resolution refutation proof

R1: G, D, {} (Kills(Mustafa,SoSo))

R2: R1, C, {a/Mustafa, b/SoSo}(~AnimalLover(Mustafa),

~Animal(SoSo))

R3: R2, B, {x/Mustafa} (~Dog(y), ~Owns(Mustafa, y), ~Animal(SoSo))

R4: R3, A1, {y/D} (~Owns(Mustafa, D), ~Animal(SoSo))

R5: R4, A2, {} (~Animal(SoSo))

R6: R5, F, {z/SoSo} (~Cat(SoSo))

R7: R6, E, {} FALSE

The proof tree

G D

C

B

A1

A2

F

A

R1: K(J,T)

R2: AL(J) A(T)

R3: D(y) O(J,y) A(T)

R4: O(J,D), A(T)

R5: A(T)

R6: C(T)

R7: FALSE

{}

{a/J,b/T}

{x/J}

{y/D}

{}

{z/T}

{}

Example knowledge base

The law says that it is a crime for an American to sell weapons to hostile nations. The country Nono, an enemy of America, has some missiles, and all of its missiles were sold to it by Colonel West, who is American.

Prove that Col. West is a criminal

Example knowledge base... it is a crime for an American to sell weapons to hostile nations:

American(x) Weapon(y) Sells(x,y,z) Hostile(z) Criminal(x)Nono … has some missiles, i.e., x Owns(Nono,x) Missile(x):… all of its missiles were sold to it by Colonel West

Missile(x) Owns(Nono,x) Sells(West,x,Nono)Missiles are weapons:An enemy of America counts as "hostile“:

Enemy(x,America) Hostile(x)West, who is American …The country Nono, an enemy of America …

Enemy(Nono,America)

American(West) Missile(x) Weapon(x) Owns(Nono,M1) and Missile(M1)

Resolution proof: definite clauses

Rule-Based Systems Also known as “production systems” or

“expert systems” Rule-based systems are one of the most

successful AI paradigms Used for synthesis (construction) type systems Also used for analysis (diagnostic or

classification) type systems

Rule-Based Systems Instead of representing knowledge in a relatively

declarative, static way (as a bunch of things that are true), rule-based system represent knowledge in terms of a bunch of rules that tell you what you should do or what you could conclude in different situations.

A rule-based system consists of a bunch of IF-THEN rules, a bunch of facts, and some interpreter controlling the application of the rules, given the facts.

1. IF (lecturing X) AND (marking-practicals X) THEN ADD (overworked X)

2. IF (month february) THEN ADD (lecturing ali)

3. IF (month february) THEN ADD (marking-practicals ali)

4. IF (overworked X) OR (slept-badly X) THEN ADD (bad-mood X)

5. IF (bad-mood X) THEN DELETE (happy X)

6. IF (lecturing X) THEN DELETE (researching X)

Rule Based Reasoning The advantages of rule-based approach:

The ability to use Good performance Good explanation

The disadvantage are Cannot handle missing information Knowledge tends to be very task dependent

Other Reasoning

There exist some other approaches as: Case-Based Reasoning Model-Based Reasoning Hybrid Reasoning

Rule-based + case-based Rule-based + model-based Model-based + case-based

Expert System

An Expert System is a computer program that

represents and reasons with knowledge of some

specialist subject with a view to solving problems or

giving advice

It is practical program that use heuristic strategies

developed by humans to solve specific class of

problems

Expert System Functionality replace human expert decision making when

not available assist human expert when integrating various

decisions provides an ES user with

an appropriate hypothesismethodology for knowledge storage and reuse

expert system – software systems simulating expert-like decision making while keeping knowledge separate from the reasoning mechanism

Parties in XS world Human Expert

Can solve problems; we desire to solve the problems without her.

Knowledge EngineerCan communicate with HE to obtain and model the knowledge that we need in the system

ProgrammerBuilds and maintains all the necessary computer programs

UserWants to use expertise to solve problems (better, cheaper)

Expert System

User

User Interface

Question&Answer

Natural Language

Graphical interface

Inference Engine

Explanation

Knowledge editor

General Knowledge

Case-specific data

Expert System Components

Global Database content of working memory (WM)

Production Rules knowledge-base for the system

Inference Engine rule interpreter and control subsystem

Rule-Based System

knowledge in the form of if condition then effect (production) rules

reasoning algorithm:

(i) FR detect(WM)(ii) R select(FR)(iii) WM apply R(iv) goto (i)

conflicts in FR: examples – CLIPS (OPS/5), Prolog

39

The Structure of ES

INFERENCE ENGINE

Knowledge processor which is modeled after the expert reasoning power.

Processor in an expert system that matches the facts contained in the working memory with the domain knowledge contained in the knowledge base, to draw conclusion about the problems.

It taps the knowledge base and working memory to derive new information and solve problems

40

The Structure of ES

THE USER INTERFACE

The user communicates with the expert system through the user interface.

It allows the user to query the system, supply information and receive advice.

The aims are to provide the same form of communication facilities provided by the expert.

But normally has less capability of understanding natural language and general knowledge.

41

The Structure of ESTHE EXPLANATION FACILITY

A trademark of expert systems: ability to explain their reasoning.

An additional component of expert system. ES can provide explanation on:

WHY it is asking the question HOW it reached some conclusion.

Main challenges in Expert Systems field Acquiring knowledge

Expert is unaware, uncommunicative, busy, unwilling Representing knowledge

Facts, Relations, Conclusions, Meta-knowledge Controlling reasoning

Selection between alternatives is guided by higher order knowledge (meta rules)

Explanation Sequence of reasoning steps? Interpretation at higher level Why were other steps NOT chosen?

Quality evaluation; acceptance

Weaknesses of Expert Systems

Require a lot of detailed knowledge Restrict knowledge domain Not all domain knowledge fits rule format Expert consensus must exist Knowledge acquisition is time consuming Truth maintenance is hard to maintain Forgetting bad facts is hard

Expert Systems in Practice XCON/R1

classical rule-based system configuration DEC computer systems commercial application, well used, followed by XSEL, XSITE failed operating after 1700 rules in the knowledge base

FelExpert rule-based, baysian model, taxonomised, used in a number of applications

ICON configuration expert system uses proof planning structure of methods

45

Selected Business Expert Systems and Functions

SystemSystem DeveloperDeveloper Business Business FunctionFunction

ActivityActivity

AS/ASOAS/ASO Arthur Arthur AndersenAndersen

Accounts Accounts ReceivableReceivable

Aid auditing Aid auditing proceduresprocedures

Authorizers Authorizers AssistantAssistant

American American ExpressExpress

Consumer Consumer CreditCredit

Evaluate Evaluate credit records credit records to protect to protect against credit against credit card fraudcard fraud

Helpdesk Helpdesk advisoradvisor

Publix Publix SupermarketsSupermarkets

RetailingRetailing Handle Handle problem calls problem calls from store from store managersmanagers

46

Selected Business Expert Systems and FunctionsSystemSystem DeveloperDeveloper Business Business

FunctionFunctionActivityActivity

Intelligent Intelligent SecretarySecretary

Nippon T & TNippon T & T PersonnelPersonnel Coordinate Coordinate schedules of schedules of company company personnelpersonnel

Mortgage Mortgage loan loan AnalyzerAnalyzer

Arthur Arthur AndersenAndersen

BankingBanking Help loan officer Help loan officer make final make final decisions on decisions on home mortgage home mortgage loanloan

Direct Labor Direct Labor Mgmt Mgmt System System (DLMSISIS)(DLMSISIS)

Ford Motor Ford Motor CompanyCompany

ManufacturingManufacturing Improve Improve efficiency in all efficiency in all phases of the phases of the production production processprocess

47

Selected Business Expert Systems and FunctionsSystemSystem DevelopDevelop

ererBusiness Business FunctionFunction

ActivityActivity

InspectorInspector BankingBanking Monitor Worldwide Monitor Worldwide foreign exchange foreign exchange trading to identify trading to identify irregular activitiesirregular activities

Prohibited Prohibited Transaction Transaction Exemption Exemption (TPE) (TPE) AnalystAnalyst

LawLaw Help attorney Help attorney evaluate transactions evaluate transactions subject to Employee subject to Employee Retirement Income Retirement Income security Act security Act

Personnel Personnel Policy Policy ExpertExpert

PersonnelPersonnel Help devise Help devise employee policies & employee policies & write employee write employee handbooks;handbooks;

48

MYCIN: A medical expert system Developed at Stanford University in the mid 1970's.

The first large expert system that perform at the level of human expert and use as benchmark by expert system developers.

Provide consultative advise about bacteremia and meningitis.

Bacteremia is an infections that involve bacteria in the blood.

49

MYCIN: A medical expert system Meningitis is an infection which is an inflammation of the

membranes that envelop the brain and spinal cord. Can be fatal, thus need quick response, but positive

identification normally takes 24 - 48 hours. Normally doctors must begin treatment in the absence of lab

results. Very complex and doctor need advice of an expert of

bacteremia and meningitis.

50

How MYCIN reasons?

Laboratory results of body fluid analyses Symptoms that patient is displaying Characteristics of the patient such as age, sex etc.

51

MYCIN

MYCIN consultative proceeds in 2 phases: Diagnosis is made to identify the most likely infection

organisms Prescribe one or more drugs (antibiotics)

52

MYCIN: Example of a rule

IF the stain of the organism is gram-positive

AND the morphology of the organism is coccus,

AND the growth conformation of the organism is

clumps,

THEN

there is suggestive evidence (0.7) that the identity of the organism is staphyloccus

53

A consultation With MYCIN1. Please enter information about the patient.Name Age Sex RaceSally 42 years Female Melayu2. Are there any positive cultures obtained from SALLY?No3. Are there any pending cultures of SALLY?Yes4. Site: date collected: stain examined: methodCSF 3-Jun-75 Yes N/A5. Stain of smear:(type NONE if no organism was seen on the smear)None

(Unable to reach conclusion from lab test, like physician continue asking questions.)

54

A consultation With MYCIN (cont..)

6. Has Sally recently had symptoms of persistent headache or other abnormal neurologic symptoms(dizziness, lethargy etc.)

Yes

7. Has SALLY recently had objective evidence of abnormal neurologic signs documented by physician observation of examination?

Yes

Questions 6 and 7 traditional approach to diagnose by symptoms.

Conclude from the questions by giving first conclusion.

Conclusion: The CSF cultures will be considered to be associated with MENINGITIS.

55

The following questions will identify particular organism that cause the infections.

8. Is the meningitis a hospital-acquired infection? Yes9. Is SALLY clinical history consistent with EPIGLOTTITIS? No 10. Is Sally clinical history consistent with OTITIS-MEDIA? No11. Has the patient ever been to an area that is endemic for coccidiomycoses?Unknown12. Is Sally a burn patient?Yes (Why)

Conclusion: The type of infection may be BACTERIAL.

A consultation With MYCIN A consultation With MYCIN (cont..)(cont..)

56

The final phase, prescription of antibiotics.

13. Does SALLY have clinically significant allergic reaction to any antimicrobial agent?

No14. Is Sally pregnant of breast feeding? No15. Do you have reason to suspect that SALLY may have

impaired renal functions? No16. SALLY weight in kilograms? 51.4

A consultation With MYCIN (cont..)A consultation With MYCIN (cont..)

57

A consultation With MYCINMy preferred therapy recommendation is as follows:

Give the following combination:1. ETHAMBUTAL Dose: 1.28g (13.0 100mg tablets) q24h PO for 60 days

then 770 mg (7.5 100 mg tablets) q24h PO. Comments: periodic vision screening tests are

recommended for optic neuritis.2. INH Dose: 513 mg (5.0 100mg-tablets) q24h PO3. RIFAMPIN Dose: 600 mg PO q24h Comments: Administer dose on empty stomach.

S 5

B 1

A 2

G1 0

C 3

E 6

D 1

G2 0

2

3

8

4

1 1

5

9

7

2

1 2

1

5