home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / educaton / inf_src.arc / EXPERT.H < prev    next >
C/C++ Source or Header  |  1986-03-14  |  5KB  |  163 lines

  1. /*************************************************************************
  2. **                                    **
  3. **    The software contained in this distribution is copyright (C)    **
  4. **    by George Hageman 1985 and is released into the public         **
  5. **    domain with the following restrictions:                 **
  6. **                                    **
  7. **        (1)  This software is intended for non-commertial    **
  8. **            usage.                        **
  9. **        (2)  I am held save from damages resulting from        **
  10. **            its use, and                    **
  11. **        (3)  The following concepts and legal jargon are    **
  12. **            agreed to by the user of this software.        **
  13. **                                    **
  14. **    User-supported software concept:                 **
  15. **                                    **    
  16. **    IF    you find use for this software                **
  17. **    ANDIF it saves you some development time            **
  18. **    THEN        send me $10.00                    **
  19. **    ANDTHENHYP  you will feel good!                    **
  20. **                                    **
  21. **                                    **
  22. **    This source code is provided on an "as is" basis without    **
  23. **    warranty of any kind, expressed or implied, including but    **
  24. **    not limited to the implied warranties of merchantability    **
  25. **    and fitness for a particular purpose.  The entire risk as    **
  26. **    to quality and performance of this software is with you.     **
  27. **    Should the software prove defective, you assume the entire    **
  28. **    cost of all necessary repair, servicing, or correction.  In    **
  29. **    no event will the author be liable to you for any damages,    **
  30. **    including any lost profits, lost savings, or other        **
  31. **    incidental or consequential damages arising out of the  use    **
  32. **    of inability to use this software.  In short my friends, I    **
  33. **    have done  a reasonable ammount of work in debugging this    **
  34. **    software and I think it is pretty good but, as you know,    **
  35. **    there is always some chance that a bug is still lurking     **
  36. **    around. If you should happen to be lucky enough to  find one,    **
  37. **    please let me know so I    can make an attempt to fix it.        **
  38. **                                    **
  39. **                Thanks,                    **
  40. **                                    **
  41. **                George Hageman                **
  42. **                P.O. Box 11234                **
  43. **                Boulder, Colorado 80302            **
  44. **                                    **
  45. *************************************************************************/
  46.  
  47.  
  48. /*
  49. **    These are the structures of the rulebase which will
  50. **    be used to compile the rules into.  
  51. */
  52.  
  53. #define FALSE             0 
  54. #define TRUE              -1 
  55. #define MAX_STRING_BUFF     5000
  56. #define MAX_STR_LEN        100
  57. #define MAX_RULE_STATEMENTS     500
  58. #define MAX_HYPS        250 
  59. #define ANTECEDENT         1
  60. #define CONSEQUENT         2
  61. #define COMMENT_CHAR        '!'
  62. #define    BLANK             0x20
  63. #define EOL            0x0a
  64.  
  65. #define KEY_EOF            -2 
  66. #define LINE_ERROR        -3
  67. #define KEY_WORD_ERROR        -4
  68. #define ERROR             -5    
  69. #define STR_LEN_ERROR        -6
  70.  
  71. /*
  72. **    Other definitions of key words
  73. */
  74.  
  75. #define    AND_N            0
  76. #define    ANDIF_N          1
  77. #define    ANDIFRUN_N       2
  78. #define    ANDNOT_N         3    
  79. #define    ANDNOTRUN_N      4
  80. #define    ANDRUN_N         5
  81. #define    ANDTHEN_N        6 
  82. #define ANDTHENHYP       7
  83. #define    ANDTHENRUN_N     8
  84. #define    ANDTHENRUNHYP_N  9
  85. #define    IF_N            10
  86. #define    IFNOT_N         11
  87. #define    IFNOTRUN_N      12
  88. #define    IFRUN_N         13
  89. #define    THEN_N          14
  90. #define    THENHYP_N         15  
  91. #define THENRUN_N    16
  92. #define THENRUNHYP_N    17
  93.         
  94. /*
  95. **    Flag definitions:
  96. */
  97.  
  98. #define    STRING_TRUE     1
  99. #define    STRING_FALSE     2
  100. #define    ROUTINE_TRUE     3
  101. #define ROUTINE_FALSE     4
  102. #define STRING_TRUE_HYP  5
  103. #define ROUTINE_TRUE_HYP 6
  104.  
  105. #define NUM_KEYWORDS    18
  106.  
  107. struct    rule_statement_r
  108.         {
  109.         int flag ;   /* logical flag for inference engine */
  110.         int string ; /* offset into string buffer */
  111.         };
  112.  
  113.  
  114. /* 
  115. **    rules are compiled into the array rules in the folloiwng form:
  116. **
  117. **    antecedent-group consequent-group 
  118. **    ... 
  119. **    antecedent-group consequent-group
  120. **    end-group
  121. **
  122. **    Each group of consequences and antecedents
  123. **    are compiled in a group like the following:
  124. **
  125. **    flag pointer flag pointer ... flag pointer 0-flag 0-pointer
  126. **
  127. **    The end-group is merely:
  128. **
  129. **    0-flag 0-pointer 0-flag 0-pointer 0-flag 0-pointer
  130. **
  131. **    flags are used by the inference engine to determine what to
  132. **    do with the following string pointer.  
  133. **    string pointers are merely offsets into the string array.
  134. **    The pointers may either point
  135. **    to a string which is a rule statement such as "the animal has wings"
  136. **    or is a UNIX pathname for a particular routine which is to be
  137. **    executed such as "/g1/hageman/Diagnostics/Disk1diag".   This
  138. **    routine will then be executed and will return either a true or
  139. **    false indication.  Latter versions of the inference engin may be
  140. **    capable of returning more than this via some pipe-line mechanism or
  141. **    other.
  142. **
  143. **    Once an anicedent whether string or routine is verified it is placed
  144. **    in either a known-true or known-false stack for later verification 
  145. **    in other rules which use them.  In short they only have to be verified
  146. **    once.
  147. **
  148. **    Examples of a rule structure are:
  149. **
  150. **    IFNOT the animal is a bird
  151. **    AND the animal has wings
  152. **    ANDNOT the animal lives in caves
  153. **    AND the animal is nocternal
  154. **    THEN the animal is a bat
  155. **    IF the animal is a bat
  156. **    ANDRUN /g1/hageman/Src/Expert/speed_of_bat
  157. **    THENHYP the bat is out of hell
  158. **    IF the animal is a bat
  159. **    ANDNOTRUN /g1/hageman/Src/Expert/speed_of_bat
  160. **    THENHYP the bat is out of cave
  161. **
  162. */
  163.