home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / e / e010 / 1.ddi / VINE < prev   
Encoding:
Text File  |  1980-01-03  |  8.5 KB  |  305 lines

  1. /*
  2.                         <M.1> V I N E
  3.              Version 1.1
  4.                 Copyright (c) Teknowledge Inc, 1984
  5.                       
  6.                         August 16, 1984
  7. */
  8.  
  9. /*
  10.     This knowledge base contains the same knowledge as WINE,
  11.     but uses logical variables (denoted by capital letters)
  12.     so that syntactically identical rules from the WINE knowledge
  13.     base can be collapsed into a single rule in VINE.
  14.  
  15.     In addition, VINE uses logical variables in conjunction with
  16.     a small database of wines, and a single  'table lookup' rule 
  17.     to find the wines, rather than a separate rule for each wine.
  18. */
  19.  
  20. /*
  21.     The top-level goal of the consultation is 'wine'.
  22. */
  23.  
  24. goal = wine.
  25.  
  26. /* 
  27.    Before the system attempts any inferences, 
  28.    the user's preferences are obtained:
  29. */
  30.  
  31. initialdata = [preferred-color, preferred-body, preferred-sweetness].
  32.  
  33. /* --------------------------- BEST-BODY ------------------------------- */
  34.  
  35. /*
  36.     The following rules use information about the sauce on the meal
  37.     and the meal's tastiness to find the best body for the wine.
  38. */
  39. rule-1:  if has-sauce and
  40.         sauce = spicy
  41.          then best-body = full.
  42.  
  43. rule-2:  if tastiness = delicate
  44.          then best-body = light cf 80.
  45.  
  46. rule-3:  if tastiness = average
  47.          then best-body = light cf 30 and
  48.           best-body = medium cf 60 and
  49.           best-body = full cf 30.
  50.  
  51. rule-4:  if tastiness = strong
  52.          then best-body = medium cf 40 and
  53.           best-body = full cf 80.
  54.  
  55. rule-5:  if has-sauce  and
  56.          sauce = cream
  57.          then best-body = medium cf 40 and
  58.           best-body = full cf 60.
  59.  
  60. /* --------------------------------- BEST-COLOR -------------------- */
  61.  
  62. /*
  63.     The following rules use information about the main component
  64.     of the meal and the sauce on the meal to determine the best
  65.     color of wine to accompany the meal.
  66. */
  67.  
  68. rule-6:  if main-component = meat and
  69.         has-veal = no
  70.          then best-color = red cf 90.
  71.         
  72. rule-7:  if main-component = poultry and
  73.         has-turkey = no
  74.          then best-color = white cf 90 and
  75.           best-color = red cf 30.
  76.         
  77. rule-8: if main-component = fish
  78.         then best-color = white.
  79.  
  80. rule-9:  if not(main-component = fish) and
  81.         has-sauce  and
  82.         sauce = tomato
  83.          then best-color = red.
  84.         
  85. rule-10: if main-component = poultry and
  86.         has-turkey
  87.          then best-color = red cf 80 and
  88.           best-color = white cf 50.
  89.  
  90. rule-11: if main-component is unknown and
  91.         has-sauce  and
  92.         sauce = cream
  93.          then best-color = white cf 40.
  94.  
  95. /* -------------------------- BEST-SWEETNESS -------------------------- */
  96.  
  97. /*
  98.     The only rule that can help provide information about how sweet
  99.     the recommended wines should be 'fires' when the meal has a sweet
  100.     sauce on it.
  101. */
  102.  
  103. rule-12: if has-sauce  and
  104.         sauce = sweet
  105.          then best-sweetness = sweet cf 90 and
  106.           best-sweetness = medium cf 40.
  107.  
  108. /* ----------------------- DEFAULT-X --------------------------------- */
  109.  
  110. /*
  111.     These default expressions are used when M.1 is unable to find
  112.     values for either best-CHARACTERISTIC or preferred-CHARACTERISTIC.
  113.  
  114.     The single 'noautomaticquestion' entry keeps M.1 from ever asking
  115.     the user to provide a value for a default characteristic.
  116. */
  117.  
  118.  
  119. noautomaticquestion(default-X).
  120.  
  121. default-body = medium.
  122.  
  123. default-color = red cf 50.
  124. default-color = white cf 50.
  125.  
  126. default-sweetness = medium.
  127.  
  128.  
  129.  
  130. /* ----------------------- FEATURE ----------------------------------- */
  131.  
  132. /*
  133.     'Feature' is a special characteristic of wine, currently used
  134.     only to indicate that the meal is spicy.
  135. */
  136.             
  137. multivalued(feature).
  138.  
  139.         
  140. rule-13: if has-sauce  and
  141.         sauce = spicy
  142.          then feature = spiciness.
  143.  
  144. /* ----------------------------- HAS-SAUCE --------------------------- */
  145.  
  146. question(has-sauce) =  'Does the meal have a sauce on it?'.
  147.  
  148. legalvals(has-sauce) = [yes, no].
  149.  
  150. /* ---------------------------- HAS-TURKEY ---------------------------- */
  151.  
  152. question(has-turkey) =  'Does the meal have turkey in it?'.
  153.  
  154. legalvals(has-turkey) = [yes, no].
  155.  
  156. /* ---------------------------- HAS-VEAL ------------------------------- */
  157.  
  158. question(has-veal) =  'Does the meal have veal in it?'.
  159.  
  160. legalvals(has-veal) = [yes, no].
  161.  
  162. /* ---------------------------- MAIN-COMPONENT ------------------------- */
  163.  
  164. multivalued(main-component).
  165.  
  166. question(main-component) =
  167.   'Is the main component of the meal meat, fish or poultry?'.
  168.  
  169. legalvals(main-component) = [meat, fish, poultry].
  170.  
  171. /* --------------------------- PREFERRED-BODY -------------------------- */
  172.  
  173. multivalued(preferred-body).
  174.  
  175. question(preferred-body) =
  176.   'Do you generally prefer light, medium or full bodied wines?'.
  177.  
  178. legalvals(preferred-body) = [light, medium, full].
  179.  
  180. /* -------------------------- PREFERRED-COLOR -------------------------- */
  181.  
  182. multivalued(preferred-color).
  183.  
  184. question(preferred-color) =
  185.   'Do you generally prefer red or white wines?'.
  186.  
  187. legalvals(preferred-color) = [red, white].
  188.  
  189. /* -------------------------- PREFERRED-SWEETNESS ---------------------- */
  190.  
  191. multivalued(preferred-sweetness).
  192.  
  193. question(preferred-sweetness) = 'Do you generally prefer dry, medium or sweet wines?'.
  194.  
  195. legalvals(preferred-sweetness) = [dry, medium, sweet].
  196.  
  197.  
  198. /* -------------------------- RECOMMENDED-X ------------------------- */
  199.  
  200. /*
  201.     These rules contain logical variables (in capital letters)
  202.     that make these rules applicable when seeking best-color,
  203.     best-body, and best-sweetness.
  204.  
  205.     If best-CHARACTERISTIC is known, then that is what's recommended.
  206.     If the users preference about a particular characteristic is known,
  207.     then that's used as the recommended characteristic. If neither
  208.     the best nor the preferred characteristic is known, then a default
  209.     value is used.
  210. */
  211.  
  212. v-rule-1: if best-X = V
  213.      then recommended-X = V.
  214.         
  215. v-rule-2: if best-X is unknown and
  216.              preferred-X = V
  217.          then recommended-X = V.
  218.  
  219. v-rule-3: if best-X is unknown and
  220.          preferred-X is unknown and
  221.          default-X = V
  222.       then recommended-X = V.
  223.  
  224. /* -------------------------- SAUCE ---------------------------------- */
  225.  
  226. multivalued(sauce).
  227.  
  228. question(sauce) =
  229.   'Is the sauce for the meal spicy, sweet, cream or tomato?'.
  230.  
  231. legalvals(sauce) = [spicy, sweet, cream, tomato].
  232.  
  233.  
  234. /* ------------------------- TASTINESS ------------------------------- */
  235.  
  236. multivalued(tastiness).
  237.  
  238. question(tastiness) =
  239.   'Is the flavor of the meal delicate, average or strong?'.
  240.  
  241. legalvals(tastiness) = [delicate, average, strong].
  242.  
  243. /* ----------------------------- WINE ------------------------------ */
  244.  
  245. multivalued(wine).  
  246. multivalued(wine(COLOR,BODY,SWEETNESS)).
  247.  
  248. /*
  249. The following rule, with the table entries that follow, replaces the bulk
  250. of the rules from the wine KB that conclude wine:
  251. */
  252.  
  253. v-rule-4: if recommended-color = C and
  254.         recommended-body = B and
  255.         recommended-sweetness = S and
  256.         wine(C,B,S) = W
  257.           then wine = W.
  258.  
  259. /* This 'noautomaticquestions' statement ensures that no automatic question
  260.    will be generated for wines not included in this table.   
  261. */
  262.  
  263. noautomaticquestion(wine(COLOR,BODY,SWEETNESS)).
  264.  
  265.  
  266. /*
  267. These table entries represent the mapping of attribute triples to specific
  268. wines. Note the use of the variable ANY in some entries to indicate that
  269. a particular attribute doesn't play a role in the selection of that wine:
  270. */
  271.  
  272. wine(red,medium,medium) = gamay.
  273. wine(red,medium,sweet) = gamay.
  274. wine(white,light,dry) = chablis.
  275. wine(white,medium,dry) = 'sauvignon blanc'.wine(white,medium,dry) = chardonnay.
  276. wine(white,medium,medium) = chardonnay.
  277. wine(white,full,dry) = chardonnay.
  278. wine(white,full,medium) = chardonnay.
  279. wine(white,light,dry) = soave.
  280. wine(white,light,medium) = soave.
  281. wine(white,light,medium) = riesling.
  282. wine(white,light,sweet) = riesling.
  283. wine(white,medium,medium) = riesling.
  284. wine(white,medium,sweet) = riesling.
  285. wine(white,light,medium) = 'chenin blanc'.
  286. wine(white,light,sweet) = 'chenin blanc'.
  287. wine(red,light,ANY) = valpolicella.
  288. wine(red,ANY,dry) = 'cabernet sauvignon'.
  289. wine(red,ANY,dry) = zinfandel.
  290. wine(red,ANY,medium) = 'cabernet sauvignon'.
  291. wine(red,ANY,medium) = zinfandel.
  292. wine(red,medium,medium) = 'pinot noir'.
  293. wine(red,full,ANY) = burgundy.
  294.  
  295. /*
  296. The following rule mentions feature, and hence is inconvenient to replace by 
  297. a table-entry.
  298. */
  299.  
  300. rule-14: if recommended-color = white and
  301.         recommended-body = full and
  302.         feature = spiciness
  303.         then wine = gewuerztraminer.
  304.  
  305. /* ----------------------------------------------------------------------- */