ìW0mK1RYUmasuæÇºr░┴g╙πZπ^Φs±;·5^bfKCGK$$79BI<Vs`g>n3ry~,â,ëPÅRû¢Y₧|ñ⌐-«2│]╣╝]─╔y╧╒%▐
µ*ε"≥y∙i6>ii#	(?,29.@3EbHPLSWO\
ae.lisbx/Nà~î|ÆZùzÜQá-ª¼+▓
╣+└l╟U═d╤
╓{▄HΓ9Θ5φ:⌠n∙J■o	
P](j"_',A2j9y@EPJMO&S
Y,_`eZlKq/vj|yâXèzô9Ö-íUñ4¬.░╕O┐╟W╬~╓B▐aΣZδST

                           Getting Started: Main Menu

    The Main Menu provides access to all of the major functions of the
    LEVEL5 TUTOR system.  From any point in the system you can return to
    the Main Menu by using the MENU or BACK function keys (F8, F10 from
    the text editor).

Selecting A    Position the cursor arrow to your choice using the
Function:      up / down arrow keys on the numeric keypad or with
               the spacebar or with the tab keys and press Return
               (Enter).

Help System:   Function key F9, HELP, will give helpful information
               about where you are;  press HELP again to see additional
               Help topics.  The Main Help Menu lists all of the major
               Help system topics.




       Press F1, PAGE, or PgDn to see additional screens of information.

                           Getting Started: Main Menu

The LEVEL5        Function key F9, HELP, will give helpful information
Study Guide:   about where you are; from Help you can then use function
               key 7, SG, to get access to the LEVEL5 Study Guide. The LEVEL5
               Study Guide is a hands-on tutorial that will teach you
               how to write and run your own knowledge bases.

               You can switch between context-sensitive Help and the Study
               Guide when using the TUTOR with the HELP function key. Every
               time you press the HELP function key you will be returned
               to the page in the LEVEL5 Study Guide you were last viewing or
               you will get Help.  The TUTOR will always remember what
               you were viewing last.

Installation:  Use the INST function key (F5) to change color schemes,
               or to redefine the default directory path to your
               knowledge bases.


       Press F1, PAGE, or PgDn to see additional screens of information.

                           Getting Started: Main Menu

RUN A Knowledge Base:     Displays the file load menu of all available
                          compiled knowledge bases that may be run. Select
                          a file and press Return to begin a TUTOR
                          knowledge base session.

EDIT A Knowledge Base:    Enters the text editor for creating and editing
                          knowledge base PRL source files.

COMPILE A Knowledge Base: Provides access to the PRL compiler.
                          PRL knowledge base source files must be compiled
                          before they can be run by LEVEL5 TUTOR.
ö
                              Using The Keyboard

Moving the cursor:     Arrow keys -   Up / Down ;  Left / Right
                       Tab        -   Right
                       Shift Tab  -   Left
                       Spacebar   -   Right / Down

Selecting From Menus:  Position cursor to desired item and press
                       Return (Enter).

Using Pop-Up Menus:    Move highlighted bar to desired topic with
                       up/down arrow keys or the spacebar and press
                       Return (Enter).

Function Keys:         Illuminated row on the bottom of your screen
                       corresponds to keyboard function keys F1 - F10.
                       Functions are available whenever they are lit.





                           LEVEL5 TUTOR Function Keys

     BACK    Returns you to the previous screen.
     BBLK    Text editor command. Marks the beginning of a block.
     BOTT    Text editor command. Moves cursor to bottom of file.

     COLR    Resets the default color scheme.
     COMP    Text editor command.  Compiles current .PRL or .PAS file.
     CONT    Resumes knowledge base execution.
     COPY    Text editor command.  Copies the currently marked block.

     DELE    Deletes the selected file.
     DIR     Changes the current drive or directory.

     EBLK    Text editor command. Marks the end of a block.
     EDIT    Permits you to edit an existing record from the data base
             editor or enter the text editor directly from the compilers.
     EXIT    Gives you the opportunity to leave LEVEL5 TUTOR.




                           LEVEL5 TUTOR Function Keys

     HELP    Gives you helpful information.

     INST    Activates the installation menu.

     MENU    Returns you to the main menu.
     MONO    Sets system to monochrome display.
     MORE    Accesses the compiler load menus to compile another file.
     MOVE    Text editor command.  Moves the currently marked block.

     NEW     Opens a new file from the text or data base editors.

     PAGE    Advances to the next screen or "page" of information.
     PRNT    Allows you to send text displays to your printer.

     RUN     Runs a knowledge base from the compiler.

     SAVE    Text editor command.  Saves the current file.



                           LEVEL5 TUTOR Function Keys

     SG      Shows the LEVEL5 Study Guide.

     SKIP    Skips to the next installation item.
     STRT    Starts or restarts the knowledge base currently in memory.

     TOP     Text editor command.  Moves cursor to top of file.

     UNKN    Indicates that you are unable to answer the question.

     YES     Indicates that you wish to execute the action TUTOR is
             asking about: either to exit, restart a knowledge base or
             delete the designated file.
B

                              Expert System Basics

What Is An Expert System?

    An expert system is a computer program that uses inferential
    reasoning processes in conjunction with a base of factual
    knowledge in order to solve problems and make decisions normally
    requiring a human expert.

What Do Expert Systems Do?

    Expert systems provide the non-expert user a highly interactive,
    simple mechanism for obtaining expert advice and decision-making
    capabilities in a specific field, or domain, of knowledge. Unlike
    other computer programs, expert systems can make decisions based
    on uncertain or 'fuzzy' information and offer judgement like a
    human expert.





                              Expert System Basics

What Is LEVEL5 TUTOR?

    LEVEL5 TUTOR is a tool for building and running expert systems. It
    consists of an inference engine - that part of the system that
    performs the reasoning processes, a knowledge representation
    language - a mechanism for capturing the knowledge of the expert
    system, a user interface - that part of the system the user interacts
    with to receive advice, and development tools - functions used to
    create a knowledge base: editors, compilers, and reporting facilities
    for debugging and investigating the expert system's behavior.

What Is A Knowledge Base?

    A knowledge base is a collection of factual information and rules
    relating these facts that contains the expertise of the system.  A
    LEVEL5 TUTOR knowledge base is written as a series of condition-action
    rules in a simple language called Production Rule Language or PRL.



                              Expert System Basics
What Is A Rule?

    A PRL knowledge base rule consists of a condition that, if verified,
    will result in a certain consequence or conclusion. Rules are written
    in the form of IF....THEN statements -  IF it is raining  THEN don't
    go to the beach.  All of the rules of a knowledge base are related or
    interconnected by the goals of the system, the ultimate conclusions
    that the system can achieve.

What Is Backwards Chaining?

    LEVEL5 TUTOR uses a backwards chaining inference process to achieve
    the goals of the system. Starting with the first goal of the knowledge
    base, the inference engine will seek rules that conclude the goal (THEN
    statements) and then it will see if the supporting conditions of the
    rule (IF statements) can be met. When an IF statement is not known, the
    inference engine will ask the user for the information in order to
    continue in its attempt to reach the final goal.



                              Expert System Basics

What Is An Expert System Session?

    An expert system session consists of an interactive dialogue between
    the user and the inference engine. The user provides his or her
    situation dependent information to the inference engine and the
    inference engine evaluates that information in reference to the
    knowledge contained in the rules of the knowledge base.  Ultimately
    the inference engine will either reach a final goal of the knowledge
    base or will determine that insufficient information is available from
    either the user or the knowledge base to proceed any further.
ª
                            Change Color Or Set Mono

Change Color:  First select the color you want to change by pressing
               function key 2, PICK, until the color shows at the end
               of the line "You are changing the color:".

               Then select a new color by pressing the spacebar until
               the color shows at the end of the line "To the color:".

               Press Return (Enter) to set the new color.

Color Chart:   Color chart on the left of the screen shows the available
               text (foreground) and background colors.  Background
               colors #9 - #16 are flashing video.

Reset Color:   Press function key 4, COLR, to restore original colors.

Set Mono:      Press function key 5, MONO, to set LEVEL5 TUTOR to
               monochrome display if your computer has a monochrome
               monitor and a color graphics board.
Æ
                        Setting The Default Directory

Default Directory:  Drive or directory where LEVEL5 TUTOR will look for
                    knowledge bases.

Changing A Directory Setting:

         At the prompt enter the complete DOS path designation.

                             For example:  C:\PRL

         Press Return (Enter) to save the change in the LT.USR file.
í
                             The LEVEL5 Study Guide

What Is The LEVEL5 Study Guide?

    The LEVEL5 Study Guide is a tutorial that will teach you how to write
    your own knowledge bases and how to run the TUTOR.  The Study
    Guide provides you with a good foundation of understanding about
    Artificial Intelligence and Expert Systems by walking you through
    the process of creating and running several sample knowledge bases.
    It is available in one keystroke from any screen in the system.

How Do You Use The Guide?

    To get to the Study Guide, press function key 9, HELP. At this point
    you will either see a context-sensitive Help screen or a page from
    the Study Guide. If you are viewing a Help screen function key 7, SG,
    will be highlighted. Press SG to turn on the guide. Now whenever you
    press function key 9, HELP, you will be shown your current page in the
    Study Guide. To turn context-sensitive Help back on, press function key
    9, HELP, and select a Help topic to view.


                             The LEVEL5 Study Guide

How Do You Print The Guide?

    You can print the Study Guide by pressing function key 6, PRNT,
    while viewing any page of the guide. The entire LEVEL5 Study Guide
    will be printed. There are approximately 100 pages in the guide.
    If you want to stop from printing the whole guide, press function
    key 6, STOP.
c	
                            File Selection Menus

    File selection menus display a list of the available files on the
    current default directory for the particular TUTOR function
    you have chosen.  Since each TUTOR function requires a unique
    file extension, file selection menus display only those files that
    have the appropriate extension to match the TUTOR function.

               Function                 File Extension

         RUN a knowledge base                .KNB
         EDIT a knowledge base               .PRL
         COMPILE a knowledge base            .PRL

Selecting Files:     Position the cursor arrow to your choice using the
                     arrow keys on the numeric keypad, the Tab key, or
                     with the spacebar and press Return (Enter).





                            File Selection Menus

Change Directory:    If your files are located in a directory other than
                     the current default they won't be displayed on the
                     file selection menu. Use function key F3, DIR, to
                     enter the new directory location.

Deleting Files:      Function key F4, DELE, will delete the file being
                     pointed to by the cursor when pressed.  After
                     selecting a file for deletion you will be asked if
                     you are sure you want to delete the file.  Press F1,
                     YES, if you do or go back to the file selection menu
                     with F8, BACK, to leave the file intact.

Creating New Files:  From the text editor you can create new files using
                     function key F2, NEW.  Enter the name of the new file
                     at the prompt. No file extension is necessary; the
                     editor automatically appends the appropriate extension
                     when saving the file.



                            File Selection Menus

Creating New Files: You can create a file with no extension by putting
                     a period after the file name.

Other File           If you want to edit files that have a file extension
Extensions:          other than .PRL, use the NEW function key.  When
                     prompted for the file name, enter the name and extension
                     of the file to edit.
	
                                The Text Editor

Editor Commands:  There are five types of editor commands: cursor movement,
                  editing, block movement, file operations, and graphics.

Conventions:      Function keys  -  (F1 - F10) can be used instead of the
                                    control key sequence where indicated

                  Control keys   -  ^ before a key: hold down the control
                                    key, Ctrl, while pressing the next key

                  Alternate keys -  Alt before a key: hold down the
                                    alternate key, Alt, while pressing
                                    the next key








                                The Text Editor


Cursor Movement:

       ^S    Character left               ^QS       Left end of line
       ^D    Character right              ^QD       Right end of line
       ^A    Word left                    ^OI       Jump to column
       ^F    Word right                   ^ON       Jump to line
       ^X    Line down                    ^KM       Set marker
       ^E    Line up                      ^QJ       Jump to marker
       ^C    Page down                    ^QR (F1)  Top of file
       ^R    Page up                      ^QC (F2)  Bottom of file
       ^Z    Scroll down
       ^W    Scroll up
       ^J    Jump to beg-end of line






                                The Text Editor


Editing:

     ^G (Del)    Delete character
     Back Space  Delete character left     ^OL       Set left margin
     ^T          Delete word               ^OR       Set right margin
     ^Y          Delete line               ^KT       Set tab width
     ^QY         Delete line right         ^I (Tab)  Tab
     RETURN      New line                  ^B        Reformat paragraph
     ^N          Insert new line           ^OW       Word wrap ON/OFF
     ^QF         Find                      ^V (Ins)  Insert mode ON/OFF
     ^L          Repeat find               ^QI       Auto-indent ON/OFF
     ^QA         Find and replace          ^OC       Center text
     ^U          Cancel command            Esc       Undo
     ^OK         Change case               ^OS       Set Undo limit





                                The Text Editor


Block Commands:                          File Operations:

     ^KB (F7)  Mark block beginning         ^KR        Read File
     ^KK (F8)  Mark block end               ^KW        Write File
     ^KC (F5)  Copy block                   ^KS (F3)   Save File
     ^KV (F6)  Move block                   ^KP        Print File
     ^KY       Delete block                 ^OP        Stop Print
     ^KH       Hide block                   ^KX (F10)  Exit, no Save
     ^QB       To block beginning
     ^QK       To block end









                                The Text Editor


Graphics Characters:

              Alt 1    │         Alt Q    ║           Alt A    ╬
              Alt 2    ─         Alt W     ═          Alt S     ░
              Alt 3    └         Alt E    ╚           Alt D    ▒
              Alt 4    ┘         Alt R     ╝          Alt F     ▓
              Alt 5    ┌         Alt T    ╔           Alt G    █
              Alt 6    ┐         Alt Y     ╗          Alt H     ▄
              Alt 7     ┴        Alt U    ╩           Alt J    ▌
              Alt 8    ┬         Alt I      ╦         Alt K     ▐
              Alt 9     ├        Alt O    ╠           Alt L    ▀
              Alt 0    ┤         Alt P      ╣
              Alt -     ┼
              Alt =    ■
≡

                                 The Compiler

    PRL source files (.PRL) must be compiled by the PRL compiler
    before they can be run by the inference engine. The compiler produces
    a new file as a result of compilation - .KNB for knowledge bases. The
    compiled files are the only ones necessary to run the knowledge base.

File Selection:  From the Main Menu choose "COMPILE a Knowledge Base"
                 to display a file selection menu of the source files
                 available for compiling.

Compiling:       Select a file to compile by positioning the cursor and
                 press Return to start the compilation.  During compilation
                 the compiler displays the file name and line number being
                 compiled at the top of the screen.







                                 The Compiler

Available        For PRL files an estimate of the total number of facts and
Memory:          total number of rules your computer can accommodate based
                 on the available memory is displayed during compilation.

Error Messages:  When an error is encountered during compilation, the compiler
                 stops and displays an error message at the bottom of the
                 screen.  The first line of the message is the line number
                 of the error in your source file followed by the actual
                 error.  The second line is an error message number with a
                 brief description of the error.

Continuing:      Once an error is encountered you can continue compiling by
                 pressing F2, CONT.  The compiler will resume compiling until
                 another error or the end of the file is encountered.






                                 The Compiler

Editing:         When compilation has stopped because of an error you can
                 directly enter the text editor at the location of the error
                 by pressing F3, EDIT.  Correct the error in the source and
                 then use F4, COMP, to restart compilation of the file.

Stopping:        At any time during compilation F8, MENU, will stop the
                 compilation and return you to the Main Menu.

Successful       Following successful compilation of a knowledge base, the
Compilation:     compiler displays the total number of facts and rules
                 contained in a knowledge base.

Options:         At the end of compilation display you can run the compiled
                 knowledge base or program using F3, RUN, enter the editor
                 for making changes or additions with F4, EDIT, or go to the
                 file selection menu to compile another file with F5, MORE.
)
                                Title Displays

    Knowledge base title displays present whatever information the
    knowledge engineer who wrote the knowledge base wished to display.
    Usually, the format is similar to the title page of a book or
    sign-on screen of a program and would include a title, author,
    date, copyright notice, etc.  Often they contain introductory
    information and instructions for using the knowledge base.

Additional Information:     Use F1, PAGE, to view all of the available
                            screens of information.

Starting A Session:         Press F3, STRT, to start the knowledge base.

Asking Why?:  At any time during a knowledge base session you can enter
              the Reports system by pressing F6, WHY?.  From a title
              display of a session, the TUTOR hasn't begun evaluating
              any rules, so there is no line of reasoning to display.
              You can however, use the other Reports system functions
              from this entry point.
╚
                              Simple Fact Queries

    Simple fact queries ask you to decide whether a factual statement
    is true or false.  How you indicate your response to the query
    depends on whether confidence prompting has been enabled.

Confidence Off:  When user confidence is off, the choices TRUE / FALSE
                 appear beneath the question being asked.  Indicate
                 your choice by moving the highlighted field with the
                 spacebar or arrow keys to the appropriate answer and
                 press Return.  LEVEL5 TUTOR records the confidence of a
                 TRUE response as 100 and a FALSE as 0.

Confidence On:   When user confidence is on, a simple fact query asks
                 you to indicate your confidence in the statement
                 being presented.  Confidence values are entered by
                 changing the length of a "confidence bar" until the
                 desired value between  0 and 100 appears at the end of
                 the bar.  Use the arrow keys (increments of 1) or the
                 spacebar (increments of 10) to select a value. Press
                 Return to enter your answer and continue.

                              Simple Fact Queries

Threshold:   The knowledge base threshold is set by the knowledge
             engineer and represents the lowest level of confidence a
             fact must achieve for it to be used by LEVEL5 TUTOR in
             evaluating a rule.  The threshold is indicated on the
             confidence bar by the position of the carat ^ .

Answering    If you are unable to answer the question, you can enter
Unknown:     "unknown" by pressing F2, UNKN.

Restarting:  F3, STRT, will restart the session from the beginning.
             LEVEL5 TUTOR asks if you are sure because restarting erases
             all of the context from the current session.

Asking Why?: At any time during a knowledge base session you can enter
             the Reports system by pressing F6, WHY?, and see an explan-
             ation of the current reasoning, view the rule currently being
             evaluated, or review the line of reasoning report.
¬
                                Numeric Queries

    A numeric query asks you to provide a numeric value as an answer
    to the question shown on your screen.  The value entered may be
    compared by the inference engine to values contained in the rules,
    or used for mathematical calculations.

Entering Values: LEVEL5 TUTOR accepts integers or floating point decimals
                 as numeric input.  Type your answer at the prompt and
                 press Return to enter the value.  Do not enter any
                 commas in the number.  If confidence is off, numeric
                 answers will be assigned a confidence of 100.

Confidence On:   When user confidence is on, you will also be asked to
                 specify a level of confidence in the number you entered.
                 Confidence values are entered by changing the length of
                 a "confidence bar" until the desired value between  0
                 and 100 appears at the end of the bar.  Use the arrow
                 keys (increments of 1) or the spacebar (increments of 10)
                 to select a value. Press Return to enter your answer.


                                Numeric Queries

Threshold:   The knowledge base threshold is set by the knowledge
             engineer and represents the lowest level of confidence a
             fact must achieve for it to be used by LEVEL5 TUTOR in
             evaluating a rule.  The threshold is indicated on the
             confidence bar by the position of the carat ^ .

Answering    If you are unable to enter a value in response to the
Unknown:     question, you can enter "unknown" by pressing F2, UNKN.

Restarting:  F3, STRT, will restart the session from the beginning.
             LEVEL5 TUTOR asks if you are sure because restarting erases
             all of the context from the current session.

Asking Why?: At any time during a knowledge base session you can enter
             the Reports system by pressing F6, WHY?, and see an explan-
             ation of the current reasoning, view the rule currently being
             evaluated, or review the line of reasoning report.
E
                           Object / Attribute Queries

     Object / Attribute queries ask you to select from a list of choices
     the item or attribute that best describes the stated condition or
     object.  Position the cursor to your choice using the arrow keys or
     spacebar and press Return.   Use F1, PAGE, (if available) to view
     all available choices before answering.

Confidence Off:  When user confidence prompting is off, all attributes
                 selected will be assigned a confidence of 100.

Confidence On:   When user confidence is on, you will be asked to enter
                 a confidence value for each attribute selected. Confidence
                 values are entered by changing the length of a "confidence
                 bar" until the desired value between  0 and 100 appears at
                 the end of the bar.  Use the arrow keys (increments of 1)
                 or the spacebar (increments of 10) to select a value. Press
                 Return to enter your answer and continue.




                           Object / Attribute Queries

Threshold:       The knowledge base threshold is set by the knowledge
                 engineer and represents the lowest level of confidence a
                 fact must achieve for it to be used by LEVEL5 TUTOR in
                 evaluating a rule.  The threshold is indicated on the
                 confidence bar by the position of the carat ^ .

Answering        If you are unable to select an attribute, you can enter
Unknown:         "unknown" by pressing F2, UNKN.

Restarting:   F3, STRT, will restart the session from the beginning.
              LEVEL5 TUTOR asks if you are sure because restarting erases
              all of the context from the current session.

Asking Why?: At any time during a knowledge base session you can enter
             the Reports system by pressing F6, WHY?, and see an explan-
             ation of the current reasoning, view the rule currently being
             evaluated, or review the line of reasoning report.

ô
                            Explanatory Information

    During a knowledge base session the user may be presented explanatory
    information pertinent to the goal, fact, or rule currently being
    evaluated.

Information          These displays can be shown as a result of a goal,
Displays:            fact or conclusion becoming actively evaluated. They
                     can contain multiple pages of text and graphic
                     information as well as references from the known
                     facts of the current session.  After reviewing the
                     display, press F2, CONT, to continue the session.
F
                              Conclusion Displays

    This display is shown when LEVEL5 TUTOR has reached a final goal or
    conclusion at the end of a knowledge base session.  The display
    presents a summary of all of the intermediate and final conclusions
    resulting from the current session.

Final conclusion:  This is that item which LEVEL5 TUTOR determined to best
                   fit the information obtained and inferred during the
                   session.

Intermediate      These are those conclusions resulting from the evaluation
Conclusions:      of individual rules leading to the final conclusion.

    In some cases LEVEL5 TUTOR will not be able to reach a conclusion and
    displays "Insufficient information available to reach a conclusion".
    This results when LEVEL5 TUTOR could not verify any hypotheses from the
    goals of the knowledge base.  Some intermediate conclusions may have
    been reached but LEVEL5 TUTOR was unable to differentiate between the
    goals sufficiently to permit selection of a final conclusion.
x
                                 Goal Selection

    The current display is a menu of possible conclusions or goals that
    can be achieved during the knowledge base session.  If you have a
    particular topic of interest, you can narrow the list of possible
    conclusions LEVEL5 TUTOR will hypothesize on by selecting a goal from
    the menu.  Position the cursor to your choice and press Return.

    If there are further sub-goals beneath the selected goal, you can
    continue to narrow the possible conclusions by selecting a sub-goal.

    If you are undecided, press UNKN and LEVEL5 TUTOR will begin the query
    process in an attempt to obtain sufficient information to reach a
    conclusion.

    NOTE:  If you select a goal for which there are no further sub-goals,
           you may place LEVEL5 TUTOR at a final conclusion of the
           knowledge base.  In this case you will see a conclusion or
           end of session display.  Restart the knowledge base and answer
           "unknown" by pressing UNKN at the last goal menu in order to
           start execution of the knowledge base.
º
                                  Asking WHY?

    When running a knowledge base, the WHY? function key is the single
    access point to the LEVEL5 TUTOR Reports System.  Pressing WHY? will
    show you a pop-up menu of available report functions.

Current Reasoning:  From most LEVEL5 TUTOR queries and displays, WHY? will
                    show you the current reasoning by indicating the rule
                    being used and the fact currently needed to reach the
                    stated conclusion.

Line of Reasoning   The Line of Reasoning Report is a historical trace
Report:             of the reasoning used by LEVEL5 TUTOR to reach the
                    current position in the knowledge base.

Current Rule:       Displays the current rule being pursued by LEVEL5 TUTOR.
                    The rule is shown as it exists in the PRL source of the
                    knowledge base.


π
                                 Current Rule

    The Current Rule function displays the rule that LEVEL5 TUTOR is presently
    evaluating. The rule is shown as it exists in the PRL source of the
    knowledge base.
v
                           The Line Of Reasoning

    This function on the WHY? menu displays the Line of Reasoning Report,
    a historical account of the line of reasoning followed by the inference
    engine. The report lists, in the order of evaluation, the goals pursued,
    the rules applied, the facts obtained and the conclusions that were
    achieved.


W
                           PRL Quick Reference Guide


Production Rule Language:  PRL uses reserved words and symbols as a
                           structure for organizing facts and knowledge
                           into a knowledge base.  The reserved words of
                           PRL are recognized by the PRL compiler only
                           when they are capitalized.

Knowledge Base Structure:  In a knowledge base, the PRL language elements
                           must be used in the proper location within the
                           PRL source file to correctly form a complete
                           knowledge base.

                           Press function key 1, PAGE, for the structure
                           of a PRL knowledge base and the proper location
                           of the knowledge base elements.





                           Knowledge Base Structure

    1.  The title and title display  :  TITLE....DISPLAY

    2.  Control element selectors    :  THRESHOLD CONFIDENCE
                                        GOALSELECT

    3.  Knowledge base goals         :  Goal Outline

    4.  Knowledge base rules         :  RULE...IF...THEN...ELSE

    7.  Information display text     :  DISPLAY TEXT

    8.  The ending statement         :  END
æ	
                             Reserved Words: A - D

 AND      Conjunction to connect multiple supporting conditions, conclusions
          of a rule, or fact type declarations.
          Syntax:  condition
                   AND next condition

 ARE      Designates object attribute statements; synonymous with IS and
          the grammatical operator \ .
          Syntax:  object ARE attribute

 BAR      Results in graphic representation of confidence value of a fact.
          BAR statement is replaced in DISPLAY, or TEXT display with a
          bar graph of current confidence value for designated fact.
          Syntax:  BAR fact name

 CF       Synonym for CONFIDENCE; see below.



                   ( ) required as shown         < > optional

                             Reserved Words: A - D

 CONFIDENCE  Numeric estimate (0-100) of the confidence placed in the logical
             assertion of a rule. Synonymous with CF. Default value is 100.
             Syntax:  conclusion statement CONFIDENCE 0-100

             As a knowledge base control element, CONFIDENCE turns
             prompting for user confidence ON/OFF.  Default value is OFF.
             Syntax:  CONFIDENCE ON-OFF

             Confidence prompting can be enabled on an individual fact
             basis from the control element section.
             Syntax:  CONFIDENCE  fact name







                   ( ) required as shown         < > optional

                             Reserved Words: A - D

 DISPLAY  Permits the knowledge engineer to designate supplemental
          information that is automatically shown to the user from a
          title, goal, supporting condition, or conclusion. In a
          title Display, the supporting text immediately follows the
          title line.
          Syntax:  TITLE knowledge base title  DISPLAY
                   text to be displayed

          When used from a goal, supporting condition, or conclusion,
          DISPLAY text is located at the end of the PRL file immediately
          following the rules.
          Syntax:  1. goal statement   DISPLAY  Display identifier
                   IF/AND/OR/THEN/ELSE  DISPLAY  Display identifier

                   DISPLAY  Display identifier
                   text to be displayed


                   ( ) required as shown         < > optional
ë

                             Reserved Words: E - P

 ELSE       Asserts an alternate conclusion upon failure of a rule.
            Syntax:  THEN primary conclusion
                     ELSE alternate conclusion

 END        Signals the end of a knowledge base. END should
            be the last line of a knowledge base PRL source file.
            Syntax:  END

 GOALSELECT Control element that enables the user goal selection process. If
            goal selection is ON, user will be allowed to select an area of
            interest from a goal selection menu.  Default state is OFF.
            Syntax:  GOALSELECT ON-OFF

            GOALSELECT can also be set from the rules of the knowledge base.
            Syntax:  AND GOALSELECT ON-OFF



                   ( ) required as shown         < > optional

                             Reserved Words: E - P

 IF       Indicates the first antecedent of a rule. It can be followed by
          additional supporting conditions (see AND, OR) but must be
          followed by at least one conclusion (see RULE, THEN).
          Syntax:  IF <supporting condition>

 IS       Designates object-attribute binding; synonymous with ARE and \ .
          Syntax:  <object> IS <attribute>

 NOT      Logical negation operator.  When placed as the beginning of a
          supporting condition or conclusion, negates the appended
          condition or conclusion.
          Syntax:  NOT antecedent
                   NOT conclusion

 NUMERIC  Fact type declaration identifying designated fact as numeric.
          Syntax:  NUMERIC fact name
                   AND     fact name

                   ( ) required as shown         < > optional

                             Reserved Words: E - P

 OBJECT   Fact type declaration function.  Identifies the designated fact
          to be of the object fact type.
          Syntax:  OBJECT fact name
                   AND    fact name

 OFF      Indicates that the specified control element is turned OFF.
          Syntax:  control element OFF

 ON       Indicates that the specified control element is turned ON.
          Syntax:  control element ON

 OR       Disjunctive connector for multiple supporting conditions of a
          rule. It is used in the inclusive sense in that if either of the
          supporting conditions is verified then the condition is verified.
          OR cannot be used as part of a multiple conclusion.
          Syntax:  IF supporting condition
                   OR supporting condition

                   ( ) required as shown         < > optional
°
                            Reserved Words: Q - Z

 RULE        All PRL rules must begin with RULE and a rule title.
             Syntax:  RULE  rule title

 SIMPLEFACT  Fact type declaration identifying a simple fact.
             Syntax:  SIMPLEFACT fact name
                      AND        fact name

 TEXT        This function is used for controlling the format of a LEVEL5
             TUTOR query and for creating antecedents, conclusions or goals
             greater than 60 characters. The textual information designated
             by the TEXT identifier replaces the identifier when displayed to
             the user. The body of extended text is placed after the rules
             section, identified by the reserved word TEXT and an identifier.
             Syntax:  IF/AND/OR fact name

                      TEXT fact name
                      Textual information

                   ( ) required as shown         < > optional

                             Reserved Words: Q - Z

 THEN       Each PRL rule must contain one conclusion designated by THEN.
            Syntax:  THEN conclusion statement

 THRESHOLD  The threshold is the lowest degree of confidence necessary for
            an antecedent to achieve in order to continue with the current
            line of reasoning. The THRESHOLD statement in the control element
            sector sets the level to an integer value between 0 and 100.
            The default value is 50.
            Syntax:  THRESHOLD = 0-100

            The threshold can also be set from within the rules.
            Syntax:  IF/AND/OR/THEN/ELSE  THRESHOLD = 0-100

 TITLE      The first statement of a knowledge base must be the title line
            consisting of the reserved word TITLE followed by the knowledge
            base title. The title is limited to a maximum of 60 characters.
            Syntax:  TITLE knowledge base title

                   ( ) required as shown         < > optional
╡
                               Reserved Symbols

Relational Operators:                      Numeric Operators:

     <        Less than                         ( )        Parenthetical
     >        Greater than                       *         Multiplication
     <=       Less than or equal to              /         Division
     >=       Greater than or equal to           +         Addition
     < >      Not equal to                       -         Subtraction
     =        Equal

Assignment Operator:  :=

  Sets the value of the right operand to that of the left operand.
  May be used with numeric and string expressions and with the CONF
  function.

  Syntax: fact := value or expression




                                Reserved Symbols

Display Operators:

[ ]  Identifies text file location where the identified simple fact,
     numeric fact or attribute from the context is to be displayed.

( )  Contains the field width specification within the display operator
     statement.

 ,   Separates field width, f, from decimal place specification, d, for
     a numeric fact display replacement.

     Syntax:  [fact name(f,d)]

     Default values for numeric replacement are (8,2). Other facts will
     take as much space as required.





                                Reserved Symbols

Grammatical Operators:

  \   Separates the components of an object-attribute fact.
      Syntax:  object \ attribute

Editorial Operators:

  !   Signifies a comment line. All text right of the ! to end of the
      line is ignored by the PRL compiler unless it occurs in a TEXT,
      EXPAND or DISPLAY.

á
                              ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
                              ██▀  ██  ██  ██  ███
                              ███      ██  ██  ███
                              ███  ██      ██  ███
                              ███  ██  ██      ███
                              ███  ██  ██  ██  ▄██
                              ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
    ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
    ██                               ██████    ██████
    ██     ▄▄▄▄▄ ▄▄   ▄▄ ▄▄▄▄▄ ▄▄    ██▄▄▄▄      ██   ▄▄ ▄▄ ▄██▄ ▄▄▄▄▄ ▄▄▄▄▄
    ██     ██▄▄▄  ██ ██  ██▄▄▄ ██    ▀▀▀▀██      ██   ██ ██  ██  ██ ██ ██
    ██████ ██▄▄▄   ███   ██▄▄▄ ██▄▄▄ █▄▄▄██      ██   ██▄██  ██  ██▄██ ██
    ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄

                L E V E L 5   T U T O R   S T U D Y   G U I D E

Editors:                        Authors:                        Software:
Ron Hencin                      Carol Billman                   Karl Seiler
Cornelius Willis                Will Norman                     Henry Seiler

          Copyright (C) 1987, Information Builders, Inc., Release 1.0
º
                          HOW TO USE THE STUDY GUIDE

To turn ON the Study Guide:      From any screen in the LEVEL5 TUTOR press
                                 function key 9, HELP. This will put you
                                 in the Help system. Then press function
                                 key 7, SG to turn on the Study Guide.

To turn OFF the Study Guide:     Go to the Study Guide from any screen in
                                 the LEVEL5 TUTOR by pressing function key 9,
                                 HELP.  Press the HELP function key again to
                                 turn the Help system back on and the Study
                                 Guide off.

To PRINT the Study Guide:        From any Study Guide screen press function
                                 key 6, PRINT. This will send the complete
                                 Study Guide to your printer.
s
                          HOW TO USE THE STUDY GUIDE

To STOP the PRINTING:            While the Study Guide is being printed
                                 you can stop printing by pressing function
                                 key 6, STOP.

To MOVE around:                  To move down a page, press function key
                                 1, PgDn, or press PgDn on the numeric
                                 key pad.

                                 To move up a page, press function key 2,
                                 PgUp, or press PgUp on the numeric key pad.

                                 To return to page 1 of the Guide, press
                                 function key 3, TOP.

                                 The current page is always indicated in the
                                 top right corner of the screen.
┘
                                 OBJECTIVES


          Upon completing this study guide you will be able to:

          o    represent expertise as IF-THEN rules and facts

          o    edit and compile knowledge bases in LEVEL5 TUTOR

          o    explain how the LEVEL5 TUTOR inference engine works

          o    follow LEVEL5 TUTOR's line of reasoning

          o    construct complex rules using IF-THEN-ELSE, AND,
               OR, and NOT
v
                             OVERVIEW OF LEVEL5 TUTOR

        Knowledge is represented in LEVEL5 TUTOR as IF-THEN rules
        formulated by the knowledge engineer. The inference engine is
        backward chaining--starting with a goal, it looks for rules
        whose THEN statements match the goal, then determines whether
        the IF statements of the rules are satisfied.

        LEVEL5 TUTOR allows the knowledge engineer considerable latitude in
        controlling the inference mechanism and the user interface. It
        has a built-in text editor that you can use to construct your
        knowledge bases.


                      LEVEL5 TUTOR FROM THE USER'S PERSPECTIVE

        We'll first look at what users see when they run an expert
        systems application developed in LEVEL5 TUTOR. Our sample
        application is called DEMO.
ñ
        What you do                        How you do it

        1.   Start LEVEL5 TUTOR.              Type LT and press <ENTER>

        A screen with the LEVEL5 TUTOR logo will appear. After a brief
        pause, you will see a screen with the main menu.

        2.   Look at topics for which      Press <F9>
             help is available.

        3.   Return to the main menu.      Press <F9>

        4.   From the main menu, select    Use the arrow keys to move
             RUN a knowledge base.         the cursor

                                           Press <ENTER>
                                           to complete the selection
~
        You will now see the file selection menu.  This is a list of
        the available knowledge bases, which, if you are running the
        TUTOR for the first time, is only the the DEMO knowledge base.

        5.   Load the DEMO knowledge       Move the arrow to DEMO
             base.                         and press <ENTER>


        Try going through the DEMO application several times giving
        different responses to the questions.  You can restart the
        session from the beginning by pressing <F3>.  After the system
        has reached a conclusion, return to the main menu by pressing <F8>.
"
                          ARCHITECTURE OF LEVEL5 TUTOR

        Our perspective on LEVEL5 TUTOR now shifts from that of users to
        that of knowledge engineers. Before we start building applications,
        we need to take a closer look at the tool we are using and
        understand how it works. After considering the basic design of LEVEL5
        TUTOR, we'll learn how expertise must be represented in order for
        LEVEL5 TUTOR to make use of it. Then we will see what happens inside
        the system when a consultation session is run.

        The architecture of an expert system refers to the components of
        the system and the way they are connected to each other.

        In architecture of LEVEL5 TUTOR, there are three principal
        components:

        o   the knowledge base consists of the facts and rules that
            comprise an expert's problem-solving knowledge

        o   working memory is a scratch pad where facts obtained during
            the current consultation session are stored

        o   the inference engine is the driving force--it decides what
            the next step will be by examining the rules in the knowledge
            base and the facts in working memory


                REPRESENTING KNOWLEDGE: FACTS AND RULES

        There are two ways of representing knowledge in LEVEL5 TUTOR: as
        facts and as rules:

        o    facts are simple statements such as:

                   The switch is off

                   The temperature > 90
<
        o    rules are IF-THEN statements that express relationships
             among facts:

                   IF The switch is off
                   THEN The computer does not work

        IF-THEN rules are also called production rules.

        Facts and rules must be expressed in LEVEL5 TUTOR's Production Rule
        Language, often abbreviated as PRL. Let's take a quick look at
        how facts and rules are expressed in PRL. Additional features of
        PRL will be introduced as they are needed.

                                     FACTS

        Facts are used in several ways in LEVEL5 TUTOR knowledge bases,
        such as:
                  -  premises of rules
                  -  conclusions of rules
                  -  goals that the inference engine tries to achieve
╟
        The LEVEL5 TUTOR's Production Rule Language allows three different
        types of facts:

          o    simple facts

          o    Object-Attribute facts

          o    numeric facts

        Right now we'll consider only the simple facts--the other types
        of facts will be explained later.


                             SIMPLE FACTS

        A simple fact is a sequence of characters that can be
        interpreted as a statement. Simple facts are simple in that LEVEL5
        TUTOR does not analyze them into meaningful parts. All LEVEL5
        TUTOR knows is that simple facts can be true or false and that
        one simple fact is different from another.
í
        Here are some examples of simple facts:

                     the weather is terrible

                     have solution to problem

                     battery is low

                     battery low

                     BL


        LEVEL5 TUTOR doesn't care whether facts are complete sentences--
        "battery low" or "BL" will do just as well as "the battery is
        low".
û
        Restrictions on Simple Facts

          o    simple facts can't contain more than 60 characters

          o    they must not use any of LEVEL5 TUTOR's reserved words
               or special symbols (See the LEVEL5 Quick Reference
               Guide in the HELP system for a list of reserved words.)

          o    for two simple facts to be the same, they must
               match exactly, including the capitalization of the
               letters and the number of spaces between words


                    REPRESENTING KNOWLEDGE:  RULES

        Rules in the Production Rule Language have these
        characteristics:
ù
          o    all rules have the form

                    RULE <name>
                    IF <condition>
                    THEN <conclusion>

          o    the condition and the conclusion of a rule consist
               of one or more facts

          o    whenever all the statements in the condition of
               the rule are valid, then the conclusion is also
               valid; it is added to the facts stored in working
               memory

        This is an example of a LEVEL5 TUTOR rule:

                    RULE low battery
                    IF car lights are dim
                    THEN battery may be low
â
        Two Important Points About Rules

        1.  The first fact following THEN must be a simple fact or
            an Object-Attribute fact.

        2.  There can be only one IF per rule. This rule is illegal
            because it has two IF's:

                    RULE illegal rule
                    IF car lights are dim
                    AND IF engine cranks slowly
                    THEN battery may be low

        This rule is OK:

                    RULE OK rule
                    IF car lights are dim
                    AND engine cranks slowly
                    THEN battery may be low
⌐
                       KNOWLEDGE BASE STRUCTURE

        Knowledge bases consist of facts and rules plus some special
        control statements. The basic format of knowledge bases is
        illustrated on the next page in DAYOFF1, an expert system for
        deciding whether you should take a day of vacation or go to work.

        DAYOFF1 exemplifies the components that must be present in every
        LEVEL5 TUTOR knowledge base:

        1. TITLE followed by the name of the knowledge base

        2. A goal outline-- a numbered list of goals for the
           inference engine to work on

        3. One or more rules

        4. The word END
▒
        Comments can be included in a knowledge base by putting an
        exclamation mark at the beginning of each line of comment text.
        When LEVEL5 TUTOR encounters an exclamation mark, it ignores
        everything following the ! on the same line.

        Knowledge bases can have other components besides the ones
        listed above. We will learn about these later in the tutorial.

        LEVEL5 TUTOR is very picky about the order of elements in
        knowledge bases, so make sure that your knowledge bases follow
        the correct format. See the LEVEL5 Quick Reference Guide in the
        HELP system for a summary of knowledge base structure.
╦
                         KNOWLEDGE BASE DAYOFF1

TITLE Going to Work

1. Go to work

RULE for no vacation days left
IF      You have no vacation days left
THEN    Go to work

RULE for terrible weather
IF      The weather is terrible
THEN    Go to work

END

                         USING THE TEXT EDITOR

        We are ready to create a knowledge base in LEVEL5 TUTOR. To do
        so, we need to know how to use the text editor.
ú
        LEVEL5 TUTOR knowledge bases may be created using any text editor
        that produces normal ASCII text files. In this tutorial we will
        use LEVEL5 TUTOR's built-in text editor, which is similar to the
        WordStar word processor. The basic cursor movement and editing
        commands are listed in the Text Editor section of the HELP
        system.

        Our objective is to create the knowledge base DAYOFF1 with the
        built-in text editor.

        What you do                        How you do it

        1.   Get into the text             Select edit a knowledge base
             editor.                       from the main menu

        2.   Create a new know-            Press <F2> to create a new
             ledge base.                   file

                                           Name the knowledge base
                                           DAYOFF1
⌡
        The editor automatically assigns the file extension
        .PRL to knowledge base files.

        3.   Find out what help            Press <F9>, then select
             is available.                 Using the Text Editor


        <F1> will take you to the next help screen. When you are done,
        press <F8> to return to the editor.

        4.   Type in the knowledge base    Use the editor commands
             DAYOFF1                       on the reference card

        5.   Save your file, then          Press <F3> to save the file
             return to the main menu.
                                           Press <F10> to quit the editor

        The knowledge base will be saved in the file DAYOFF1.PRL.
è
                      COMPILING A KNOWLEDGE BASE

        Knowledge bases such as the one we just edited are called PRL
        files in LEVEL5 TUTOR.

        Characteristics of PRL Files

          o    text files that can be read, printed out, or
               edited

          o    must have the DOS file extension .PRL

          o    must be compiled before they can be run

        The LEVEL5 TUTOR inference engine cannot run a PRL knowledge base
        directly--it must first be compiled into a more compact,
        machine readable form. The system contains a knowledge base
        compiler for this purpose.

        Functions of the Compiler

          o    translates a PRL knowledge base into compact form,
               storing the result in a file of the same name but
               with extension .KNB

          o    detects errors in the format of the knowledge base
               or the rules, gives appropriate message, and
               allows user to edit the mistake

        Let's compile DAYOFF1.

        What you do                        How you do it

        1.   Choose to compile a           At the main menu,
             knowledge base.               select compile a knowledge
                                           base

        2.   Compile DAYOFF1.              Select DAYOFF1 from the
                                           available files
f
        The compilation is now under way. On the status line at the
        top of the screen, you will see the number of the line
        currently being compiled. Below the status line is a message
        stating the amount of memory available to store rules and
        facts. If an error is found, an error message will be displayed
        and you will have the option to enter the editor or to continue
        compiling. The message "Compilation complete, no errors
        detected" signals that the compilation was successful.

        When the compiler is finished, press the <F3> key to run the
        knowledge base and see how it will look to the user.

                          HOW LEVEL5 TUTOR WORKS

        Now that we know what goes into a knowledge base, our next
        objective is to understand what LEVEL5 TUTOR does with the knowledge.
        You will find it much easier to write rules for LEVEL5 TUTOR if you
        understand how the rules will be applied.

        Here is a slightly simplified account of what the inference
        engine does when we run DAYOFF1:

        1. The inference engine gets a goal to work on from the
           goal list in the knowledge base. In this case, the
           first goal is "Go to work".  At this point there are no
           facts in working memory.

        2. The inference engine looks for the first rule whose
           conclusion matches the current goal.  If there aren't
           any, the inference engine gives up on this goal and
           tries another.  In our example, it discovers that the
           conclusion of the rule "for no vacation days left"
           matches the current goal "Go to work".

        3. Now the inference engine tries to establish the truth
           of the IF part of the current rule.  Assuming it can
           show that "You have no vacation days left" is true, it
           will be able to reach the conclusion "Go to work".

        4. The system checks working memory to see if the truth of
           "You have no vacation days left" is already known, but
           it doesn't find an answer.
÷
        5. Now the inference engine searches for an IF-THEN rule
           it could use to determine whether "You have no vacation
           days left" is true, but again it doesn't find anything.

        6. Now the only way it can find out the truth of "You have
           no vacation days left" is to ask the user.  The answer
           is recorded in working memory.  If the answer is TRUE,
           the IF part of the rule has been proven, and the rule
           fires, achieving the goal "Go to work".  If the answer
           is FALSE, the rule fails, and the inference engine
           repeats steps 2 through 6 with the rule "for terrible
           weather".

        7. If the top-level goal has been achieved, the inference
           engine stops, otherwise, it goes back to step 2.


                   HOW LEVEL5 TUTOR SEARCHES FOR FACTS

        How does the inference engine find out whether a fact is true?
        Let's take another look at steps 4, 5, and 6.
U
        Whenever the inference engine needs a fact, it follows this
        procedure:

          o    it looks for the fact in working memory; if this
               fails,

          o    it searches for rules that can conclude the fact,
               then determines whether their premises are true;
               if this fails,

          o    it asks the user for the fact

        Searching for information in this order ensures that the system
        will not ask for the same information twice and will not request
        information that it could compute by itself.
n
                           ADDING MORE RULES

        In the knowledge base for DAYOFF1, there is no way the inference
        engine can verify that the weather is terrible except by asking
        the user. Now we'll add a rule for concluding terrible weather so
        LEVEL5 TUTOR will never have to ask the user for this information.

                RULE relating rain and terrible weather
                IF      It is raining cats and dogs
                THEN    The weather is terrible

        Knowledge base DAYOFF2 is a modified version of DAYOFF1. Edit
        DAYOFF1 to create DAYOFF2 by adding the above rule.

        What you do                        How you do it

        1.   Go to the text editor         Select Edit a knowledge base
             and create a new file         from the Main Menu.
             called DAYOFF2.
K
        2.   Use the Read File             Enter ^KR and then type DAYOFF1.PRL
             command to bring DAYOFF1      when asked for a file name.
             into the new file.

        3.   Enter the above rule          Follow the Text Editor HELP for
             after the other rules         instructions on using the editor.
             and change the title to
             DAYOFF2.

        4.   Compile DAYOFF2.              Press <F4> COMP

        5.   Run DAYOFF2.                  Press <F3> RUN

        6.   Give answers that lead        Answer FALSE to "You have no
             to the conclusion that          vacation days left"
             the weather is terrible.
                                           Answer TRUE to "It is raining
                                             cats and dogs"
å
            LOOKING BEHIND THE SCENES:  THE REPORT FACILITY

        LEVEL5 TUTOR allows us to look behind the scenes at what really
        went on during a consultation session. We can follow the line of
        reasoning of the inference engine, examine the rule currently
        being tested or see why the TUTOR is asking for a piece of
        information. These capabilities are part of the REPORT
        facility. This facility is accessed by pressing the WHY? key,
        <F6>, after a conclusion has been reached.

        We have just run the DAYOFF2 knowledge base and are looking at
        the screen displaying the conclusions. Now we will go into the
        REPORT facility and see how LEVEL5 TUTOR made use of the knowledge
        base.

        What you do                        How you do it

        1.   Enter the REPORT facility.    Press <F6>



╟
        2.   Examine the line of           Select Line of Reason
             reasoning followed by         from the menu and
             the inference engine.         press <ENTER>

        You will see a display that summarizes the goals LEVEL5 TUTOR has
        tried, the rules it applied, and the facts it discovered.

                           BACKWARD CHAINING

        When we observe the LEVEL5 TUTOR inference engine in action, we
        are in a position to see what is meant by backward chaining.
        LEVEL5 TUTOR applies IF-THEN rules backwards, starting with the
        THEN part of a rule and then trying to verify the IF part:

        IF It is raining cats and dogs THEN  The weather is terrible
                      <--------------------------
                           backward inference

        The inference engine can prove that the weather is terrible by
        showing that it is raining cats and dogs.
`
        The chaining part of backward chaining comes from the way the
        IF part of one rule is linked to the THEN part of another. In
        the following example, "The weather is terrible" occurs in the
        IF and THEN parts of different rules, so it links these rules
        together into a chain:

                IF It is raining cats and dogs
                THEN The weather is terrible

                IF   The weather is terrible
                THEN Go to work

        Starting with a goal, the inference engine follows such links
        from the premise of one rule back to the conclusion of another
        until it finds a match or comes to the end of a chain.

                            RULES WITH NOT

        Facts can be negated using the logical operator NOT. For
        example, instead of this rule:
■
                RULE for no vacation days left
                IF   You have no vacation days left
                THEN Go to work

        we could use this one:

                RULE to illustrate negation
                IF NOT You have vacation days left
                THEN Go to work

        Relating Positive and Negative Statements

        Although both versions of the rule say the same thing, the
        second one is preferred when the knowledge base contains both
        positive and negative instances of the same fact. For example,
        suppose the knowledge base includes this rule:

                RULE for taking the day off
                IF   You have vacation days left
                THEN Take the day off
₧
        LEVEL5 TUTOR does not know that "You have no vacation days left"
        is incompatible with "You have vacation days left". As far as
        LEVEL5 TUTOR is concerned, these facts are independent, so it might
        request the value of both the positive and negative form of the
        same fact. This problem is remedied by the use of NOT, since
        LEVEL5 TUTOR recognizes that "You have vacation days left" is the
        opposite of "NOT You have vacation days left".

                        JOINING FACTS WITH AND

        The logical operator AND can link together facts in the premise
        or the conclusion of a rule. Here are some examples of AND in
        the IF part of a rule:

                RULE    for terrible weather
                IF      The weather is terrible
                AND NOT You must take your vacation days soon
                THEN    Go to work
┤
                RULE    if you will lose vacation time
                IF      You have vacation days left
                AND     You must take your vacation days soon
                THEN    Take the day off

        All the facts joined by AND must be true for the rules to fire.

        The knowledge base DAYOFF3 shows how NOT and AND can be used to
        write more expressive rules.

        On your own:  Create the DAYOFF3 knowledge base by modifying the
                      source file of DAYOFF2, compile DAYOFF3 and run it.
                      Then go into REPORTS and review what LEVEL5 TUTOR did
                      during the consultation session.
┘
                        KNOWLEDGE BASE DAYOFF3

TITLE Going to Work with NOT and Another Goal

1. Go to work
2. Take the day off

RULE for no vacation days left
IF NOT  You have vacation days left
THEN    Go to work

RULE for terrible weather
IF      The weather is terrible
AND NOT You must take your vacation days soon
THEN    Go to work

RULE relating rain and terrible weather
IF      It is raining cats and dogs
THEN    The weather is terrible
c
RULE if you will lose vacation time
IF      You have vacation days left
AND     You must take your vacation days soon
THEN    Take the day off

END

                      GETTING THE FACTS STRAIGHT

        By this point you should have a feel for how the inference
        engine operates. The next objective is to acquire more powerful
        ways of representing knowledge in order to tackle harder problems.
        This means learning more about facts and rules. LEVEL5 TUTOR recognizes
        numeric and Object-Attribute facts as well as simple facts.

                        OBJECT-ATTRIBUTE FACTS

        Object-Attribute facts are marked by the reserved words IS or
        ARE or the backslash symbol \. This type of fact is appropriate
        when a fact can take on one of a limited number of non-numeric
        values.
-
        In the rule below, "The weather outside" is an Object-Attribute
        fact:

                RULE relating rain, snow, hail and terrible weather
                IF      The weather outside IS raining cats and dogs
                OR      The weather outside ARE hailing
                OR      The weather outside \ snowing
                THEN    The weather is terrible

        It does not matter to LEVEL5 TUTOR whether you use IS, ARE, or \
        in Object-Attribute facts.

        Where Object-Attribute Facts Can Appear

        Object-Attribute facts can be used in goals, premises, and
        conclusions of rules. In the condition of a rule, IS means "is
        equal to", while in the conclusion, IS means "is assigned the
        value". Consider this example:
â
                IF the season IS summer
                THEN the weather IS warm

        If the value of "the season" is equal to "summer", then "the
        weather" will be assigned the value "warm".

        Be careful to distinguish "is" from "IS". Lowercase "is" is not
        a reserved word. Substituting "is" for "IS" changes a fact from
        Object-Attribute to simple fact. For example, "the tank is on
        fire" is a simple fact, not an Object-Attribute fact.

        Generating Questions for Object-Attribute Facts

        LEVEL5 TUTOR asks about object facts in a different way than for
        simple facts. When LEVEL5 TUTOR requests the value of a simple
        fact, it displays the fact and asks the user to choose between
        TRUE and FALSE. For object facts, it presents a menu of the
        entire range of values the fact can take on.
¡
        For example, DAYOFF4 on the following page mentions possible
        values of "The weather outside" in two different rules. When the
        knowledge base is run, LEVEL5 TUTOR collects all those values and
        presents them as possible choices the first time it asks for the
        value of "The weather outside":

                        Select what describes :

        The weather outside

      ==>  raining cats and dogs

           hailing

           snowing

           glorious

        On your own:  Create DAYOFF4 by modifying DAYOFF3 and observe how
                      LEVEL5 TUTOR requests the value of "The weather outside".
l
                        KNOWLEDGE BASE DAYOFF4

TITLE Going to Work with Object Attribute Values


1. Go to work
2. Take the day off

RULE for no vacation days left
IF NOT  You have vacation days left
THEN    Go to work

RULE for terrible weather
IF      The weather is terrible
AND NOT You must take your vacation days soon
THEN    Go to work
-
RULE relating rain, snow, hail and terrible weather
IF      The weather outside IS raining cats and dogs
OR      The weather outside ARE hailing
OR      The weather outside \ snowing
THEN    The weather is terrible

RULE about glorious weather
IF      You have vacation days left
AND     The weather outside IS glorious
THEN    Take the day off

RULE if you will lose vacation time
IF      You have vacation days left
AND NOT The weather outside IS glorious
AND     You must take your vacation days soon
THEN    Take the day off

END


                             NUMERIC FACTS

        Numeric facts are facts whose values are numbers. The number
        can be either a whole number or a decimal fraction. The :=
        operator assigns a value to a numeric fact. For example,

                        today's high := 50

        causes the value 50 to be associated with "today's high".

        Numeric facts can be compared with numbers or other numeric
        facts using the standard relational operators listed in the LEVEL5
        Quick Reference Guide in the HELP system.

        Here is an example of a numeric fact:

                RULE chance of snow
                IF today's high < 35
                AND sky is overcast
                THEN it may snow

K
                          USING NUMERIC FACTS

        Knowledge base DAYOFF5 shows how numeric facts can be put to
        use. "Number of vacation days left" is a numeric fact. The
        numeric fact is used to infer whether "You have vacation days
        left" is true.

        On your own:   Create DAYOFF5 by modifying DAYOFF4 and observe
                       how LEVEL5 TUTOR requests the values of numeric facts.


                        KNOWLEDGE BASE DAYOFF5

TITLE Going to Work with Numbers from the User


1. Go to work
2. Take the day off

<
RULE for no vacation days left
IF NOT  You have vacation days left
THEN    Go to work

RULE about the number of vacation days left
IF      Number of vacation days left  > 0
THEN    You have vacation days left

RULE for terrible weather
IF      The weather is terrible
AND NOT You must take your vacation days soon
THEN    Go to work

RULE relating rain, snow, hail and terrible weather
IF      The weather outside IS raining cats and dogs
OR      The weather outside ARE hailing
OR      The weather outside \ snowing
THEN    The weather is terrible

â
RULE about glorious weather
IF      You have vacation days left
AND     The weather outside IS glorious
THEN    Take the day off

RULE if you will lose vacation time
IF      You have vacation days left
AND NOT The weather outside IS glorious
AND     You must take your vacation days soon
THEN    Take the day off

END

                     USING OR IN PREMISES OF RULES

        We can reduce the number of rules by using the logical
        connective OR to combine several rules with the same conclusion
        into a single rule. For example, RULE 1 expresses the same
        knowledge as RULE 1a through RULE 1c:

        Individual Rules:

               RULE 1a
               IF it is raining
               THEN the weather is bad

               RULE 1b
               IF it is snowing
               THEN the weather is bad

               RULE 1c
               IF NOT the sun is shining
               THEN the weather is bad

        Combined Rule:

               RULE 1
               IF it is raining
               OR it is snowing
               OR NOT the sun is shining
               THEN the weather is bad
╣
        There is one difference between using RULE 1 and the separate
        rules 1a to 1c. If RULE 1 is used, LEVEL5 TUTOR will always ask
        whether it is raining, whether it is snowing, and whether the
        sun is shining, regardless of how the questions are answered. If
        rules 1a to 1c are used, LEVEL5 TUTOR will stop asking questions as
        soon as it can prove the weather is bad.

                     AND and OR--SOME GORY DETAILS

        For the most part, AND and OR mean the same thing in LEVEL5 TUTOR
        as they do in English. There are just a few details that should
        be kept in mind:

        1. AND and OR must appear at the beginning of a line.
           This example is illegal because AND does not begin a
           new line:

                RULE illegal use of AND
                IF The payoff is high AND The risk is low
                THEN The project is promising
w
        2.  OR may only be used in the condition of a rule. It is
            illegal to join facts with OR in the conclusion of a
            rule.

        To understand why OR is not allowed in conclusions, consider
        what would happen if this kind of rule were allowed:

                IF precipitation is falling
                THEN it is raining
                OR it is snowing

        Assuming the IF part were true, LEVEL5 TUTOR could not be certain
        of the truth of either fact in the conclusion.

        3. OR has higher precedence than AND.  In a sequence of
           statements connected by ANDs and ORs, the statements
           are grouped together by starting at the top, joining
           all facts connected by OR, then starting at the top
           again and grouping the facts connected by AND.  For
           example,
K
                A
                OR B
                AND C
                OR D

        is analyzed as ((A OR B) AND (C OR D)). LEVEL5 TUTOR does not
        provide a way to force a different grouping.

                          IF-THEN-ELSE RULES

        In some situations the failure of a rule can provide useful
        positive information. Consider the following example:

                1.  Take the day off
                2.  Go to work

                RULE 1
                IF You have vacation days left
                THEN Take the day off
¥
                RULE 2
                IF NOT You have vacation days left
                THEN Go to work

        Suppose LEVEL5 TUTOR is pursuing the goal "Take the day off" and
        it discovers that you don't have any vacation days left. Even
        though your only alternative is to go to work, LEVEL5 TUTOR can't
        immediately draw this conclusion because it is busy trying to
        get you to consider taking the day off. Not until it starts
        pursuing the goal "Go to work" does it realize that it has the
        information to reach a conclusion.

        Combining Rules with IF-THEN-ELSE

        Since the failure of RULE 1 implies the success of RULE 2, we
        can combine these two rules into one using IF-THEN-ELSE:

                RULE 1a
                IF You have vacation days left
                THEN Take the day off
                ELSE Go to work
.
        When the condition of an IF-THEN-ELSE rule turns out to be
        false, the fact following the ELSE is taken to be true. With
        RULE 1a, LEVEL5 TUTOR can immediately conclude "Go to work" if it
        finds that you don't have any vacation days left.

        Pitfalls of IF-THEN-ELSE Rules

        IF-THEN-ELSE rules are tricky because you have to look at the
        overall structure of the knowledge base before deciding whether
        two rules can be combined. In the example above, we are able to
        combine the two rules because we know two things:

        1.  The knowledge base has no other way of achieving the
             goal "Take the day off"

        2.   Whenever the condition of RULE 1 is false, the
             condition of RULE 2 must be true
|
                          THE MEANING OF NOT

        NOT has two distinct meanings in LEVEL5 TUTOR. One meaning is
        "proven false", the other meaning is "not proven true".
        Consider this example:

                RULE for no vacation
                IF NOT You have vacation days left
                THEN Go to work

        The condition of this rule can be true for two different
        reasons:

        1.   "You have vacation days left" has been proven to be
             false.  Working memory contains "You have vacation days
             left = FALSE".  In this case NOT means "proven false".

        2.   The inference engine tried to prove "You have vacation
             days left" but failed.  Working memory does not contain
             any reference to "You have vacation days left".  Here
             NOT means "not proven true".
▄
        Negation by Failure

        The second instance above illustrates what is known in AI
        jargon as negation by failure--if you try to prove that a fact
        is true and you fail, then assume the fact is not true.
        Negation by failure applies only to NOT in the premises of
        rules.

        For an example of negation by failure, try the following
        experiment.

        What you do                        How you do it

        1.   Study NEG.PRL on the next
             page.

        2.   Create and run NEG.PRL.       Enter the knowledge base
                                           with the editor, compile it
                                           and run.
₧
        3.   Cause the rule "about the     Answer 0 when asked for
             number of vacation days       the number of vacation
             left" to fail.                days left

        The system should conclude "Go to work".

        Notice that working memory does not contain "You have vacation
        days left = false". But for the rule "for no vacation days
        left" to fire, the statement

                NOT You have vacation days left

        had to be true. The negated fact was considered true because
        the system tried to prove the positive version but failed. This
        is an example of negation by failure.
U
                        KNOWLEDGE BASE NEG.PRL

TITLE Illustration of Negation by Failure

1.  Go to work

RULE about the number of vacation days left
IF      Number of vacation days left  > 0
THEN    You have vacation days left

RULE for no vacation days left
IF NOT  You have vacation days left
THEN    Go to work

END
┌
                                 RECAP

        By now you should be able to do the following:

          o    describe the operation of the LEVEL5 TUTOR inference
               engine

          o    construct PRL knowledge bases using simple,
               Object-Attribute, numeric, and string facts

          o    edit, compile, and run knowledge bases

          o    write IF-THEN and IF-THEN-ELSE rules

          o    connect facts with AND, OR, and NOT

          o    get reports about a consultation session

        With the skills you have acquired, you can solve surprisingly
        complex problems--all you need is practice and some guidelines
        for putting your skills to work.
ε
                   MASTERING LEVEL5 TUTOR - OBJECTIVES

        After finishing this section of the tutorial, you will be
        able to:

          o    approach the design of LEVEL5 TUTOR knowledge bases
               with a clearcut methodology

          o    use Object-Attribute facts to avoid redundant
               questions and possible inconsistencies

          o    restrict the goals that LEVEL5 TUTOR will pursue

          o    write a knowledge base that will achieve multiple
               goals in a single session

          o    customize the user interface of an expert system

          o    use rules to perform arithmetic computations

          o    qualify conclusions using confidence factors

                     ATTACKING REAL-WORLD PROBLEMS

        What You Should Know by Now

        By this point you should be able to:

          o    write IF-THEN rules

          o    construct simple knowledge bases

          o    understand the operation of the inference engine


        Using LEVEL5 TUTOR to Solve Problems

        There is no recipe for turning the description of a problem
        into a working LEVEL5 TUTOR knowledge base. We can give you some
        guidelines, but the best way to proceed is to practice with
        small problems and study examples of successful solutions. In
        this section of the tutorial, we will show how to solve several
        small problems that represent the range of applications most
α
        often encountered. Along the way we'll introduce additional
        features of LEVEL5 TUTOR.


       GUIDELINES FOR TRANSLATING EXPERTISE INTO KNOWLEDGE BASES

        1.  determine the goals

        What do you want LEVEL5 TUTOR to produce at the end of a session?
        Do you want a yes/no answer, one specific recommendation, or a
        list of possible recommendations?

        2. order the goals

        Which goals should be tried first? For a go/no go decision, it
        may be easier to reach a negative decision than a positive one,
        so you might pursue no go before trying go. In a troubleshooting
        system, if you know which problems are most frequent, try them first.
£
        3. determine the different ways of reaching the goals

        For each goal, write down every way of arriving at that goal.

        4. separate decision making from information gathering

        Many applications can be broken down into two phases: getting
        relevant information and making decisions. For the present,
        concentrate on making the decisions and forget about where the
        information will come from.

        5. write a small knowledge base

        Using the results of steps 1, 2, and 3, write a knowledge base
        that solves the problem in its simplest form. Pretend that all
        relevant information is already available. If this doesn't
        work, what is missing? Are the goals wrong? Are the goals
        ordered correctly? Does every goal appear in the conclusion of
        at least one rule? Has some crucial information been left out?
┐
        6. identify the information needed to arrive at each goal

        Go back to step 3 and look at the different ways of arriving at
        conclusions. In each case, identify the information that would
        lead an expert to reach the conclusion.

        7. identify sources of information

        Where will LEVEL5 TUTOR get the information listed in step 6? Will
        the information come from the user, from a computation in a
        rule, or will it be built into the knowledge base?

        8. integrate decision making and information gathering

        Make sure all relevant information will be available at the
        point where a decision must be made, but do not collect more
        information than is necessary. The system should not request
        information that will have no bearing on the final conclusion.
        You may have to write rules whose sole purpose is to gather
        information.
g
                       MORE ABOUT OBJECT-ATTRIBUTE FACTS

        Object-Attribute facts are now covered in more detail, since
        they are used extensively in the knowledge bases in this
        section.

        Recall that LEVEL5 TUTOR is unaware of similarities in meaning
        between different simple facts. If a knowledge base makes use
        of facts that refer to the same object, it may be more
        convenient and more efficient to capture the similarity with
        Object-Attribute facts.

        PC Troubleshooting System

        To demonstrate the advantages of Object-Attribute facts, we'll
        represent the same knowledge using first simple facts and then
        Object-Attribute facts. The knowledge base we are going to
        develop contains expertise on fault diagnosis for personal
        computers.


        Relevant Expertise

                fault                    symptom

                Printer off              Printer lights are off

                Printer off line         Online light is off


        The first cut at the knowledge base is shown below.

        On your own: Enter the PC1 knowledge base, compile and run it
                      to observe its behavior for all possible combinations
                      of user input. Give the system problems it can solve
                      (printer light off, online light off), then give it
                      one that it can't solve (printer light on, online
                      light on). Note places where the system asks seemingly
                      unnecessary questions.
ñ
                              KNOWLEDGE BASE PC1

TITLE Personal Computer Troubleshooting System

1.  Printer is off
2.  Printer is off line
3.  Beyond expertise

RULE printer turned off
IF   Printer light is off
THEN Printer is off

RULE printer not online
IF  Online light is off
THEN Printer is off line

RULE Too hard
IF  Printer light is on
AND Online light is on
THEN Beyond expertise
END
∩
                         DISADVANTAGES OF SIMPLE FACTS

        Asking Redundant Questions

        When the PC1 expert system could not reach a conclusion using
        the first answers it obtained, it asked questions whose answers
        were implicit in facts already known:

          o    the user is asked whether the printer light is off

          o    afterwards the user is asked whether the printer
               light is on

        The problem arises because all the knowledge has been
        represented as simple facts. Since LEVEL5 TUTOR does not recognize
        connections among simple facts, "Printer light is off" and
        "Printer light is on" are as different to it as apples and
        oranges.
╦
        Allowing Inconsistent Facts

        There is another potential problem with PC1--it is possible to
        have inconsistent facts in working memory. For example, there is
        nothing to prevent having both of the following facts at the
        same time:

                Printer light is off = False

                Printer light is on = False

        Since LEVEL5 TUTOR doesn't notice any connection between the two
        facts, it can't detect the contradiction. Having self-
        contradictory facts in working memory might not cause any
        problems in a knowledge base as simple as PC1, but in a real
        application, it could lead to unpredictable results.
∩
                   THE ADVANTAGES OF OBJECT-ATTRIBUTE FACTS

        Values Not Selected Are Closed Out

        When LEVEL5 TUTOR needs the value of an Object-Attribute fact, it
        pulls together all the different values that can apply to the
        same object and presents them as a menu. Suppose the possible
        values of "printer light" are "on" and "off". The menu looks
        like this:

              printer light is(are):

                              ==>  off

                                   on

        When the user chooses one value from the menu, all the other
        values are assumed to be false.  This process is known as
        closeout because the values not chosen are closed out.
z
        Closeout Avoids Redundant Questions

        If the user selects "off" from the menu above, LEVEL5 TUTOR closes
        out "printer light IS on".  If LEVEL5 TUTOR needs to know the value
        of "printer light IS on" for a subsequent rule, it will assume the
        value is FALSE and will not request it from the user.

        On your own:  Compare knowledge base PC2 to PC1, then enter and
                      run PC2 to observe the differences.  For the case
                      where the printer light is on and the online light
                      is on, note that the system concludes that the
                      problem is too hard without asking any more questions.


                              KNOWLEDGE BASE PC2

TITLE Personal Computer Troubleshooting System

1.  Printer is off
2.  Printer is off line
3.  Beyond expertise

RULE printer turned off
IF   Printer light IS off
THEN Printer is off

RULE printer not online
IF  Online light IS off
THEN Printer is off line

RULE Too hard
IF  Printer light IS on
AND Online light IS on
THEN Beyond expertise

END

                        MORE TROUBLESHOOTING EXPERTISE

        Let's extend the coverage of the PC troubleshooting system by
        adding more expertise about printer problems.  Here are two
        additional rules that can go into the knowledge base:
▓
        1.   The printer won't work if the printer cable is loose.

        2.   For a serial printer, the serial port parameters (baud
             rate, parity, etc.) must be the ones the printer expects.

        Each of these faults has characteristic symptoms associated
        with it.

             fault                    symptom

             cable loose              printer sometimes works if
                                      cable is moved around

             improper settings        printer is attached to serial
                                      port and you are not sure
                                      that the settings are right

        On your own:   Write a knowledge base that incorporates this
                       expertise.  Don't worry about writing a rule to
                       conclude that the problem is beyond the expertise
                       of the system.
Z
                       Compare your results to knowledge base PC3 shown
                       below.  Since in PC3 there is no object that can
                       have more than one value, Object-Attribute facts
                       are not used.

                              KNOWLEDGE BASE PC3

TITLE Diagnosing a PC Printer Problem

1.  printer off
2.  printer not online
3.  loose cable
4.  serial port settings

RULE    printer off
IF      printer light is off
THEN    printer off

RULE    printer not online
IF      online light is off
THEN    printer not online
ú
RULE    cable loose
IF      moving the cable around seems to help
THEN    loose cable

RULE    improper parameters
IF      the printer is attached to a serial port
AND NOT you are sure the port settings are correct
THEN    serial port settings

END

                         EXPANDING THE KNOWLEDGE BASE

        Now we'll add expertise about monitor problems to the PC trouble-
        shooting system.  Suppose the computer is on but you don't see
        anything on the screen.  What could cause this situation?

        Expertise on Monitor Problems

        1.   Nothing will appear on the monitor screen if
             the monitor is off.

        2.   A loose cable from computer to monitor can cause the
             screen to go dead.

        3.   If the configuration switches on the motherboard
             inside the computer are not set right, nothing
             may show up on the screen.

        4.   If there are two monitors (for example, a graphics and
             a monochrome) attached to the system, display output
             may be going to the wrong one--use the MODE command
             to switch to the active monitor.

        5.   A program may be hung--try <CTRL>C to stop it or
             <CTRL> <ALT> <DEL> to restart.

        On your own:  Taking the PC3 knowledge base as a starting point,
                      add goals and rules to cover the expertise above.
                      Observe the course of the consultation session and
                      note any problems that need to be resolved.
                      Compare your knowledge base with the enhanced
                      version of PC3 on the next page.
┼
                  TITLE Diagnosing Personal Computer Problems

1.   printer off
2.   printer not online
3.   loose cable
4.   serial port settings
5.   monitor off
6.   loose monitor cable
7.   improper switch settings
8.   output going to wrong monitor
9.   program is hung

RULE    printer off
IF      printer light is off
THEN    printer off

RULE    printer not online
IF      online light is off
THEN    printer not online

4
RULE    cable loose
IF      moving the cable around seems to help
THEN    loose cable

RULE    improper parameters
IF      the printer is attached to a serial port
AND NOT you are sure the port settings are correct
THEN    serial port settings

RULE    monitor off
IF      the monitor switch is off
THEN    monitor off

RULE    monitor cable loose
IF      moving the monitor cable seems to help
THEN    loose monitor cable

RULE    improper switch settings
IF NOT  configuration switches are set correctly
THEN    improper switch settings

╒
RULE    for two monitors
IF      the computer has two monitors attached to it
AND NOT display output is going to the active monitor
THEN    output going to wrong monitor

RULE    for a hung program
IF      rebooting the computer fixes the problem
THEN    program is hung

END

                            USING THE GOAL OUTLINE

        The enhanced version of PC3 pursues all goals related to printer
        problems before considering any monitor problems.  This is
        annoying to the user with a monitor problem.  In the tutorials
        that follow, we will learn various techniques for assuring that
        the goals most relevant to the problem at hand are the ones
        addressed.

╔
        Organizing the Goal Outline Using Subgoals

        With LEVEL5 TUTOR's goal outline, it is possible to group goals into
        monitor-related or printer-related subgoals, as shown in knowledge
        base PC4 which follows.  There are two top level goals--printer
        problem and monitor problem--with each individual fault as a
        subgoal under one or the other heading.

        When the knowledge base is run, the user will be asked about each
        top level goal until a TRUE answer is given:

                         Is it true that :

             printer problem

                         TRUE      FALSE

        If the answer is FALSE, LEVEL5 TUTOR asks:
@
                         Is it true that :

             monitor problem

                         TRUE      FALSE

        If the user answers TRUE, subgoals relating to monitor
        problems will be pursued.

        On your own:  Enter, compile and PC4 to observe the effect of
                      the goal outline.


                              KNOWLEDGE BASE PC4

TITLE Diagnosing Personal Computer Problems
!
!    Goals are organized into a goal outline
!    with two levels to distinguish printer
!    problems from monitor problems
≤
1. printer problem
       1.1   printer off
       1.2   printer not online
       1.3   loose cable
       1.4   serial port settings

2. monitor problem
       2.1   monitor off
       2.2   loose monitor cable
       2.3   improper switch settings
       2.4   output going to wrong monitor
       2.5   program is hung

RULE    printer off
IF      printer light is off
THEN    printer off

RULE    printer not online
IF      online light is off
THEN    printer not online
2
RULE    cable loose
IF      moving the cable around seems to help
THEN    loose cable

RULE    improper parameters
IF      the printer is attached to a serial port
AND NOT you are sure the port settings are correct
THEN    serial port settings

RULE    monitor off
IF      the monitor switch is off
THEN    monitor off

RULE    monitor cable loose
IF      moving the monitor cable seems to help
THEN    loose monitor cable

RULE    improper switch settings
IF NOT  configuration switches are set correctly
THEN    improper switch settings
¼
RULE    for two monitors
IF      the computer has two monitors attached to it
AND NOT display output is going to the active monitor
THEN    output going to wrong monitor

RULE    for a hung program
IF      rebooting the computer fixes the problem
THEN    program is hung

END

                       LETTING THE USER SELECT A SUBGOAL

        GOALSELECT is a control statement that makes it possible for the
        user to select a relevant goal from a menu.  Control statements
        are instructions that modify LEVEL5 TUTOR's normal behavior.  Any
        control statements in a knowledge base must be placed immediately
        before the goal outline.
'
        Let's now modify the PC4 knowledge base to allow goal selection.
        Once modified, the new knowledge base will be called PC5.

        What you do                        How you do it

        1. Edit knowledge base PC4.

        2. Turn on goal selection for      Type GOALSELECT ON immediately
           this knowledge base.            before the goal outline

        3. Compile PC5.

        4. See how goal selection          Run PC5.  When asked "Can you
           looks from the user's           identify the area of interest?",
           viewpoint.                      choose "monitor problem"

        5. at the next level,              Press <F2> for UNKNOWN
           indicate that you can
           no longer identify the
           area of interest.
ì
        6. Complete the consultation.


        Bottoming Out During Goal Selection

        If the user makes a menu choice instead of pressing <F2> at the
        bottom level of the goal outline, the solution to the problem
        will have been identified, and LEVEL5 TUTOR will immediately reach a
        conclusion without asking any questions.  This unexpected
        "bottoming out" can be problematic, since it is not apparent to
        the user when the lowest level of the goal outline has been
        reached.  The problem can be solved by ensuring that the lowest
        level of each part of the outline consists of a single goal,
        since LEVEL5 TUTOR does not display a goal selection menu if there is
        only one goal at the current level.

        In PC5, bottoming out can be avoided by modifying the goal
        outline to look something like this:

          1. printer problem
               1.1  printer appears to be off
                 1.1.1   printer off
               1.2  printer does not appear to be online
                 1.2.1   printer not online
               1.3  the cable appears to be loose
                 1.3.1   loose cable
               1.4  the serial port settings may be incorrect
                 1.4.1   serial port settings

                    and so on


                      WORKING WITH OBJECT-ATTRIBUTE GOALS

        Just as Object-Attribute facts can appear in IF statements, they
        can also appear in goals.  Our knowledge bases so far have used
        only simple facts as goals, but there are times when it is
        preferable to set up Object-Attribute goals.
╜
        There are two reasons why a knowledge engineer might choose to
        represent goals as Object-Attribute facts:

          o    conciseness, since it is possible to reduce the
               number of subgoals

          o    flexibility, since some things that can be done
               with Object-Attribute facts can't be done using
               simple facts

        Reducing the Number of Subgoals

        Long lists of subgoals can be eliminated by following this
        procedure:

          o    make the higher level goal an Object-Attribute
               fact

          o    convert the lowest level subgoals into values of
               that fact
{
        We'll show how this works using the BEFORE and AFTER examples
        that follow.

        BEFORE

        In this example, the top level goals are simple facts, and
        subgoals are listed in the goal outline.  The facts that appear
        as subgoals must be mentioned twice--once in the subgoal list and
        once in the conclusion of a rule, for example, "printer off".

1. printer problem
     1.1   printer off
     1.2   printer not online

2. monitor problem
     2.1   monitor off
     2.2   loose monitor cable

RULE    printer off
IF      printer light is off
THEN    printer off
W
RULE    printer not online
IF      online light is off
THEN    printer not online

RULE    monitor off
IF      the monitor switch is off
THEN    monitor off

RULE    monitor cable loose
IF      moving the monitor cable seems to help
THEN    loose monitor cable


        AFTER

        Now the top level goals are Object-Attribute facts and the
        subgoals have been converted into values of those facts.  The
        conclusion of each rule assigns a value to some top level goal.
        There are no subgoals, so "printer off" only has to be mentioned
        once.
Γ
1. printer problem IS WHAT
2. monitor problem IS WHAT

RULE    printer off
IF      printer light is off
THEN    printer problem IS printer off

RULE    printer not online
IF      online light is off
THEN    printer probem IS printer not online

RULE    monitor off
IF      the monitor switch is off
THEN    monitor problem IS monitor off

RULE    monitor cable loose
IF      moving the monitor cable seems to help
THEN    monitor problem IS loose monitor cable
 
        The reserved word WHAT is used in the goal statements to represent
        all of the possible attributes the objects "printer" and "monitor"
        can assume.  This is useful in that your goal statements do not have
        to list each of the various attributes that may be possible.


                         ENHANCING THE USER INTERFACE

        An expert system must have a good user interface in order to gain
        acceptance among end users.  LEVEL5 TUTOR enables the developer to
        construct friendlier user interfaces by controlling query
        generation and providing explanatory information to the user.

        There are two LEVEL5 TUTOR commands that generate customized text
        displays:

          o    TEXT

          o    DISPLAY
2
                              THE TEXT STATEMENT

        The TEXT function associates a fact with text to be displayed in
        place of the automatically generated query.  Automatic query
        generation is nice for rapid prototyping, but the questions do
        not sound very polished.  More importantly, facts must be
        represented in a form that makes sense to the user.


        Advantages of Text Displays for Facts

          o    the text associated with a fact can be of any
               length and can even contain graphics characters

          o    facts don't have to be changed in order to change
               the text

          o    the internal form of the fact can be abbreviated

        Suppose we add the following statement to the PC5 knowledge base:
°
             TEXT moving the cable around seems to help

             Does the printer sometimes work if the cable
             is moved around?

        Now LEVEL5 TUTOR will display the lines following "moving the cable
        ..." when it tests the supporting condition of the loose cable
        rule.

        Usage of TEXT Statement

          o    format: TEXT <fact> followed by the text to be
               displayed, starting on the next line

          o    location:  TEXT statements go at the end of the
               knowledge base, after the rules and before the END
               statement

        On your own:   Add TEXT statements to PC5 and replace the wordy
                       facts with shorter facts.
o
                              THE DISPLAY COMMAND

        Use the DISPLAY statement for text that is not associated with
        questions.  The DISPLAY command can appear in titles and goals as
        well as in the conditions and conclusions of rules.  The DISPLAY
        statements go in the same part of the knowledge base as TEXT
        statements.

        Here is an example of how the DISPLAY statement works in
        conditions and conclusions of rules:

             RULE printer not online
             IF DISPLAY check control panel
             AND online light is not on
             THEN printer problem IS printer not online
             AND DISPLAY put online

             DISPLAY check control panel

             Please find the indicator lights on the printer
             control panel.  Note the status of the online light.
b
             Press <F3> to continue.


             DISPLAY put online

             Please press the online button on the printer
             control panel.  I think that should solve the
             problem.

             Press <F3> to continue.

        This is what happens when the "printer not online" rule is tried:

          o    the DISPLAY text for "check control panel" appears
               on the screen

          o    the system pauses after displaying the text

          o    the user presses <F3> CONTINUE to proceed with the
               evaluation of the rule
╣
          o    if the rule fires, the text associated with "put
               online" is displayed


        DISPLAY in TITLE Statements

        DISPLAY can be used in TITLE statements to create an introductory
        screen to be read at the start of every session.  For example, we
        could include the following statement in the title of PC5:


TITLE Diagnosing Personal Computer Problems DISPLAY

          Hello.  I am an expert system for diagnosing problems
          with your personal computer.  I will ask for some
          information about the problem and then recommend a
          solution.

          Please press <F3> when you are ready to go on.


        At the beginning of the session, everything following DISPLAY
        up to the next PRL reserved word will appear on the screen.


        DISPLAY in Goal Outlines

        DISPLAY statements can also appear after goals in the goal
        outline.  In this case the text will be displayed when the goal
        is selected by the user.


        On your own:  Add DISPLAY statements to the conclusions and
                      TITLE statement of the PC5 knowledge base.


                             AN EVALUATION SYSTEM

        Many business applications of expert systems can be viewed as
        evaluation systems.  The objective of such systems is to evaluate
        the input by matching it to one of several predefined categories.
]
        For example, credit analysis involves matching a borrower with a
        credit rating.  Insurance underwriting can be viewed as matching
        a client with a risk category.  Personnel decisions match
        employees or job applicants with categories of action such as
        hire, promote, or fire.

        Designing an Evaluation System

          o    the top-level goals correspond to the categories
               of evaluation

          o    the problem solving process consists of pursuing
               goals until the right category is found

          o    the rules represent the criteria that define each
               category

        The example we will study is a system for evaluating research
        and development proposals.

        A brief description of the expert's knowledge is shown below.
á
                     EXPERTISE FOR EVALUATING R&D PROJECTS

        R&D projects are aimed either at increasing savings or increasing
        profits through expansion of capacity.  Savings can be manpower
        savings or yield savings.  Capacity can be expanded in production
        of high tech, industrial, or consumer products.  Projects are
        ranked according to the relative need for each type.  There is
        twice as much need for manpower savings as for increased consumer
        capacity, so if the relative need for consumer capacity is 1.0,
        the need for manpower savings is 2.0.


             project type             relative need

             manpower savings              2.0
             yield savings                 1.8
             high tech capacity            1.6
             industrial capacity           1.4
             consumer capacity             1.0
=
        Projects that increase savings are favored over those that
        increase capacity.  Furthermore, no project for increasing
        capacity will be funded if the time frame is too long.  Consumer
        capacity projects can't take longer than 6 months.  High tech and
        industrial capacity projects can't take longer than one year.
        Otherwise, projects are evaluated on the basis of a formula that
        takes into account the expected profit ratio and the relative
        need for that type of project:

        project merit = relative need * (annual profit or savings /
                                    (investment + development costs))

        To be funded, the merit of a project must be higher than an
        established cutoff point or hurdle value--we'll assume a hurdle
        value of 1.

                         SETTING UP THE KNOWLEDGE BASE

        Our present objective is to translate the expertise into elements
        of a PRL knowledge base.  First we will determine the goals, then
        the rules.
≥
        Proposals are either successful or unsuccessful, so the result of
        a consultation with the expert system will be "go" or "no go".
        Since capacity expansion projects are disqualifed if the time
        frame is too long, "no go" should be tried before "go".

             goals

             no go

             go

        Now we'll list the different ways to arrive at a "no go" or a
        "go" decision:

             goal           criteria for arriving at goal

             no go          time frame over 6 months for
                            consumer capacity project

                            time frame over 1 year for high tech
                            or industrial capacity project
&
                            project merit less than hurdle value

             go             project merit greater than or equal to
                            hurdle value


        Try creating a small knowledge base for this expert system.  To
        keep it simple, omit the formula for computing project merit--the
        system can get the project merit by asking the user.  If you
        leave out the formula, you won't have to deal with relative need.

        Once you have created the knowledge base and compiled it, test it
        with various combinations of project type, time frame, and
        project merit.

        An example of a simple knowledge base for the R&D project
        evaluator appears on the following pages.  The formula for
        computing project merit was left out of this version.  "project
        type" was declared to be an Object-Attribute fact since it takes
        on the values "manpower savings", "yield savings", etc.  The
        project merit and the time frame are numeric facts.
]
                       R&D PROJECT EVALUATOR--VERSION 1

TITLE  R&D Project Evaluator

1. no go
2. go

RULE 1
IF  hurdle value := 1
AND time frame in months > 6
AND project type IS consumer capacity
THEN no go

RULE 2
IF time frame in months > 12
AND project type IS high tech
OR project type IS industrial capacity
THEN no go
°
RULE 3
IF project merit > hurdle value
THEN go
ELSE no go

END

                      PERFORMING ARITHMETIC CALCULATIONS

        At this point we have a small knowledge base that represents the
        core of the R&D project evaluator.  The next step is to
        incorporate the formula that computes the merit of a project.
        LEVEL5 TUTOR allows an arithmetic computation to be performed within a
        rule as long as it is on the right-hand side of the assignment or
        relational operator.

        Your current objective is to incorporate this formula into Rule 3:

             project merit = relative need * (annual profit or savings /
                                        (investment + development costs))
α
        Some helpful hints:

        1.  If a fact or formula is too long to fit on one line, it can
            be continued on the next line.  Put a colon at the end of the
            first line to inform LEVEL5 TUTOR that there is more to come.

        2.  Compute the project merit in one step and compare it to the
            hurdle value in a subsequent step.

        3.  Remember to use := for the assignment operator, not =.

        4.  Assume that the unit for dollar amounts is millions of dollars.

        5.  LEVEL5 TUTOR will automatically ask for the values of the unknown
            quantities in the formula, so you don't have to go to the
            trouble of writing rules to elicit them.
=
                      FIRING RULES FOR THEIR SIDE EFFECTS

        You should now have a knowledge base that calculates project
        merit based on relative need, annual profit or savings,
        investment, and development costs.  At this point the system gets
        the value of relative need by asking the user.  This is a
        problem, since relative need should be part of the knowledge base
        rather than user input.  Nothing in the current knowledge base
        prevents someone from entering incorrect values for relative
        need.  Our next objective is to add rules for calculating
        relative need based on the type of project.

        Note that we cannot write a rule like this in LEVEL5 TUTOR:

          RULE illegal rule
          IF project type = manpower savings
          THEN relative need := 2.0

        This doesn't work because LEVEL5 TUTOR requires goals and conclusions
        to be either simple facts or Object-Attribute facts, so the
        numeric fact in the rule above will cause a compiler error.
N
        To get around the problem, we have to use a new technique--set up
        a goal which causes the value of relative need to be computed and
        make sure the goal is satisfied before calculating project merit.
        The idea behind the technique is this: if you can't get something
        directly (by making it a goal), get it indirectly (by making it a
        side effect of a goal).

        Here is how the technique works.  We'll set up a subgoal "know
        relative need" and put it in Rule 3 before the formula:

          RULE 3
          IF know relative need
          AND project merit := relative need * :
                (annual profit or savings :
                         /(investment + development costs))
          AND project merit >= hurdle value
          THEN go
          ELSE no go
6
        When Rule 3 is tried, LEVEL5 TUTOR will first prove "know relative
        need" before doing anything else.  The next part of the technique
        is to make "know relative need" the conclusion of a rule that
        assigns the right value to "relative need":

          RULE 4
          IF project type IS manpower savings
          THEN know relative need
          AND relative need := 2.0

        Rule 4 is legal because the numeric fact "relative need" doesn't
        directly follow THEN.  The restriction on conclusions only
        applies to the first fact following THEN.  The statements
        following the first conclusion are not really conclusions--they
        are side effects of the firing of the rule.

        The essence of the technique is to set up subgoals whose sole
        purpose is to cause some side effect, such as collecting
        information or assigning values to facts.  Such techniques make
        knowledge bases harder to understand, so they should be used only
        when absolutely necessary.
Ñ
        On your own:  Using the approach outlined above, add rules
                      for assigning relative need to the R&D project
                      evaluator.


               IMPROVING THE USER INTERFACE OF THE R&D EVALUATOR

        Earlier we saw how to use TEXT and DISPLAY statements to customize
        the user interface.  Now would be a good time to improve the
        interface of the R&D knowledge base.  We will introduce some new
        features of LEVEL5 TUTOR that should prove helpful.

        An expert system seems more intelligent if its messages are adapted
        to the context of the current session.  A simple way to make
        messages adaptable is to display the current values of the facts
        that caused the message to appear.  For example, the text associated
        with the conclusion of a rule can contain the values that caused the
        rule to fire.
┬
        The following example shows how to include the value of the fact
        "time frame in months" in the text displayed when Rule 1 fires.

             RULE 1
             IF time frame in months > 6
             AND project type IS consumer capacity
             THEN no go
             AND DISPLAY over six months

             DISPLAY over six months

             This proposal is not acceptable because
             [time frame in months (2,0)] is too long
             a time frame for a consumer capacity project.
             Consumer capacity projects can be funded only if
             their duration is six months or less.

        In LEVEL5 TUTOR, enclosing a fact in square brackets causes its value
        to be displayed when the text appears on the screen.  If the fact
        is numeric, its field width can also be specified--this is done
        by placing the field width in parentheses following the fact.

        In the example above, [time frame in months (2,0)] is an instruction
        to LEVEL5 TUTOR to display the value of "time frame in months" as a
        two-digit number with no digits to the right of the decimal point.


                           ADDING CONFIDENCE FACTORS

        In real-world applications, decisions are often made on the basis
        of uncertain or unreliable information.  To model such situations,
        many expert systems shells allow facts that are not completely
        true or completely false, but believed with greater or lesser
        degrees of confidence.  If an expert system uses uncertain facts
        to reach a conclusion, it should qualify the conclusions so that
        users realize the information is not completely reliable.

        LEVEL5 TUTOR allows confidence factors to be associated with facts
        and conclusions.

          o    confidence factors are numbers between 0 and 100 that
               express the degree of confidence in the truth of a fact
≈
          o    a confidence factor of 100 means complete
               confidence that the fact is true

          o    a confidence factor of 0 means complete confidence
               the fact is false

          o    a confidence factor of 50 is interpreted as
               noncommittal--the fact might just as well be true
               as false

          o    the confidence factor of the conclusion of a rule
               reflects the confidence factors of the facts in
               the premise of the rule


        Prompting for Confidence Factors

          o    turn on prompting by placing the control statement
               CONFIDENCE ON in the knowledge base immediately
               before the goal outline
w
          o    LEVEL5 TUTOR displays a reverse video bar after
               requesting a value

          o    the user adjusts the length of the bar to reflect
               the degree of confidence in the answer

        On your own:  Add CONFIDENCE ON to the R&D knowledge base.
                      Compile and run the knowledge base.  Experiment by
                      running the system several times, giving the same
                      answers but with different confidence values.


        Disadvantages of Confidence Factors

        Unless confidence factors are especially appropriate for your
        application, you should probably avoid them for these reasons:

          o    confidence factors are very subjective

          o    confidence factors make it difficult to predict
               what conclusions the system will reach
≈
                                     RECAP

        Now that you have completed the Advanced LEVEL5 TUTOR module,
        you should be able to:

          o    apply a structured methodology to the solution of
               expert systems problems

          o    write knowledge bases for troubleshooting systems
               and evaluation systems

          o    control the selection of goals

          o    set up a knowledge base to reach more than one
               conclusion

          o    build a custom interface for a LEVEL5 TUTOR
               application

         This concludes our introduction to LEVEL5 Knowledge Engineering.
To continue these studies, contact INFORMATION BUILDERS, INC. at (212) 736-4433.
ntroduction to LEVEL5 Knowledge Engineering.
To cont