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

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