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
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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
• 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
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'
• 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
• 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).
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
• 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
• 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
• possible enhancements:
- Better text messages for queries
- more error checking
- numeric input with menus (see handout)
- *** explanation ***