b. ross cosc 4f79 1 inference mechanisms backward chaining - goal-driven reasoning which gathers...

6
B. Ross Cosc 4f79 1 Inference mechanisms ward chaining goal-driven reasoning which gathers data as needed Prolog's default mechanism good for identification problems rd chaining data-driven reasoning which must be initialized with all data value system refines problem state towards solution state good for configuration problems

Upload: phyllis-caldwell

Post on 04-Jan-2016

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: B. Ross Cosc 4f79 1 Inference mechanisms Backward chaining - goal-driven reasoning which gathers data as needed - Prolog's default mechanism - good for

B. Ross Cosc 4f79 1

Inference mechanisms• Backward chaining - goal-driven reasoning which gathers data as needed - Prolog's default mechanism - good for identification problems

• Forward chaining - data-driven reasoning which must be initialized with all data values - system refines problem state towards solution state - good for configuration problems

Page 2: B. Ross Cosc 4f79 1 Inference mechanisms Backward chaining - goal-driven reasoning which gathers data as needed - Prolog's default mechanism - good for

B. Ross Cosc 4f79 2

Misc Prolog notes

1. With Sicstus prolog, need to do either a "nl" or a "ttyflush" command in order to see output on screen before a read

- these commands flush the output buffer (similar things happen in C)

2. With Prolog's "read", a capitalized word will be interpreted as a variable.

eg. read(X) --> enter Yes means X is unified with variable Yes enter 'Yes' unifies X with constant 'Yes' enter yes unifies X with constant 'yes'

Page 3: B. Ross Cosc 4f79 1 Inference mechanisms Backward chaining - goal-driven reasoning which gathers data as needed - Prolog's default mechanism - good for

B. Ross Cosc 4f79 3

Separation of KB and shell

• Important to separate declarative KB code from procedural shell utilities

- knowledge base can then be used by other inference schemes

- shell can be altered and made as flexible as one needs, w/o touching KB

- Basically, put each into distinct files.

• In Merritt "bird" system, one line in KB is:

top_goal(X) :- bird(X).

• Then, shell always executes "top_goal(X)".

--> this gives a hook between KB and shell

Page 4: B. Ross Cosc 4f79 1 Inference mechanisms Backward chaining - goal-driven reasoning which gathers data as needed - Prolog's default mechanism - good for

B. Ross Cosc 4f79 4

Bowen Toy system

• from “Prolog and Expert Systems”, K.A. Bowen (McGraw Hill)• similar in spirit to Bird• he handles some things differently

eg. to keep track of similar input words: synonym(pain, severe_pain). synonym(pain, numb_pain). ...

then you can check synonym for user input X by doing: ?- synonym(S, X).

• he also uses setof(V, synonym(pain,V), Vlist)

--> returns Vlist = [severe_pain, numb_pain, ...]

- setof(Template, Goal, List): successively solves Goal, and saves variables shared between Goal and Template in List, using Template - sorts List, and removes duplicates - Template is a term: a variables, or even a structure eg. p(X,Y)

• bagof: similar, except that it keeps all solutions in the order discovered, and doesn't sort nor remove duplicates

Page 5: B. Ross Cosc 4f79 1 Inference mechanisms Backward chaining - goal-driven reasoning which gathers data as needed - Prolog's default mechanism - good for

B. Ross Cosc 4f79 5

Friendly User Input

• Prolog's Input-Output is too unfriendly and unforgiving

• should develop a library of user-friendy I/O

• expert system interface:

- users may have little or no computer background

- users may have little or no background in domain area

- recover from errors (typing, misunderstandings, ...)

- avoid unnecessary dialog - remember input - use menus

- perhaps remember input from different sessions - keep a history database

- provide various levels of explanation and help

Page 6: B. Ross Cosc 4f79 1 Inference mechanisms Backward chaining - goal-driven reasoning which gathers data as needed - Prolog's default mechanism - good for

B. Ross Cosc 4f79 6

Summary• The knowledge base and shell utilities are separate.

• The knowledge base is declarative. It can be processed by any kind of inference system. It is easily modified.

• The system prompts user for facts. It remembers input.

• Menu input is used.

• Note that, although shell utilities are procedural, it is possible to write declarative utilities. This is an ideal, but they might be inefficient.

• possible enhancements:

- Better text messages for queries - more error checking - numeric input with menus (see handout)

- *** explanation ***