home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Interactive Guide / c-cplusplus-interactive-guide.iso / c_ref / csource4 / 241_01 / verifytr.ci < prev    next >
Encoding:
Text File  |  1987-08-31  |  3.0 KB  |  115 lines

  1. /*
  2. HEADER:         CUG241;
  3. TITLE:          Inference Engine for Expert System;
  4. DATE:           12/30/85;
  5. VERSION:
  6. DESCRIPTION:   "Source code for inference engine for an Expert System.";
  7. KEYWORDS:       Artificial Intelligence, expert systems, inference engine;
  8. SYSTEM:         MS-DOS or UNIX System V;
  9. FILENAME:       VERIFYTR.C;
  10. WARNINGS:      "User-supported, non-commercial"
  11. AUTHORS:        George Hageman; 
  12. COMPILERS:      Microsoft C V3.00 or UNIX System V Portable C Compiler;
  13. REFERENCES:     ;
  14. ENDREF
  15. */
  16.  
  17. /*****************************************************************
  18. **                                **
  19. **      Inference -- (C) Copyright 1985 George Hageman    **
  20. **                                **
  21. **        user-supported software:                **
  22. **                                **
  23. **            George Hageman                **
  24. **            P.O. Box 11234                **
  25. **            Boulder, Colorado 80302            **
  26. **                                **
  27. *****************************************************************/
  28.  
  29. /*****************************************************
  30. **
  31. **    verifyTruth(antecedent) ;
  32. **
  33. **    This routine verifies the truth of a string or routine which
  34. **    is not a consequnt of a rule (ie an antecedent)
  35. **
  36. **    The routine remembers the final state of the antecedent in
  37. **    the knownTrue, or knownFalse stacks
  38. **
  39. **    accomplishes task either by running the routine or by
  40. **    asking the user for the specific truth of a statement
  41. **
  42. **    returns -- 
  43. **        the "true" predicate value of the antecedent
  44. **        according to its .flag:
  45. **
  46. **            TRUE if the antecedent phrase is TRUE and
  47. **               the antecedent .flag indicates positive,
  48. **            FALSE if the antecedent phrase is TRUE and
  49. **               the antecedent .flag indicates negative.
  50. **            etc.
  51. **
  52. *******************************************************/
  53.  
  54. #include <stdio.h>
  55. #include "expert.h"
  56. #include "inference.h"
  57.  
  58. int    verifyTruth(antecedent) 
  59.     int antecedent ;
  60. {
  61. switch(ruleBuff[antecedent].flag)
  62.     {
  63.     case STRING_TRUE :
  64.     case STRING_TRUE_HYP:
  65.         if( getTruth(antecedent) == TRUE) 
  66.             {
  67.             knownTrue[numTrue++] = ruleBuff[antecedent].string ;
  68.             return(TRUE) ;
  69.             }
  70.         else
  71.             {
  72.             knownFalse[numFalse++] = ruleBuff[antecedent].string ;
  73.             return(FALSE) ;
  74.             }
  75.     case STRING_FALSE :
  76.         if( getTruth(antecedent) == TRUE) 
  77.             {
  78.             knownTrue[numTrue++] = ruleBuff[antecedent].string ;
  79.             return(FALSE) ;
  80.             }
  81.         else
  82.             {
  83.             knownFalse[numFalse++] = ruleBuff[antecedent].string ;
  84.             return(TRUE) ;
  85.             }
  86.     case ROUTINE_TRUE :
  87.     case ROUTINE_TRUE_HYP:
  88.         if( runRoutine(antecedent) == TRUE) 
  89.             {
  90.             knownTrue[numTrue++] = ruleBuff[antecedent].string ;
  91.             return(TRUE) ;
  92.             }
  93.         else
  94.             {
  95.             knownFalse[numFalse++] = ruleBuff[antecedent].string ;
  96.             return(FALSE) ;
  97.             }
  98.     case ROUTINE_FALSE :
  99.         if (runRoutine(antecedent) == TRUE)
  100.             {
  101.             knownTrue[numTrue++] = ruleBuff[antecedent].string ;
  102.             return(FALSE) ;
  103.             }
  104.         else
  105.             {
  106.             knownFalse[numFalse++] = ruleBuff[antecedent].string ;
  107.             return(TRUE) ;
  108.             }
  109.         default:
  110.             printf("\major problem # 0001 -- llegal antecedent flag\n") ;
  111.             return(TRUE) ;
  112.         }
  113. }
  114.  
  115.