1 / 34

M1/M4

M1/M4. CIS 479/579 Bruce R. Maxim UM-Dearborn. What is it?. Expert system shell for developing medium size applications Written in C/C++ Allows interface to external functions written in C/C++ and VB Allows access to database applications as well. Features. Symbolic Variables

matia
Download Presentation

M1/M4

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. M1/M4 CIS 479/579 Bruce R. Maxim UM-Dearborn

  2. What is it? • Expert system shell for developing medium size applications • Written in C/C++ • Allows interface to external functions written in C/C++ and VB • Allows access to database applications as well

  3. Features • Symbolic Variables • Certainty factors • Backward chaining (mostly) • Limited forward chaining allowed (pre-suppositions) • Rule order used for conflict resolution • Cache (WM) manipulation allowed • Symbolic List processing • Debugging Environment • Explanation Facilities • Meta knowledge

  4. How does M1 find work? M1 seeks to determine values found in a goal or initialdata statement • Obtain value of expression computed by M1 • Look for value already in cache • Inference rules (searching and matching) • Prompts user for value if first 3 fail

  5. Examples • Goal statement goal = wine. • Initialdata statement initialdata = [preferred-color, preferred-body]. • Rule rule-5: if has-sauce = yes and sauce = cream then best-body = medium and best-body = full.

  6. Getting Started • You need copies of the files m1.exe and m1.cfg • You may find it helpful to examine the knowledge bases “wine”, “vine”, “cwine” • There is also an M1 Short Guide written by a former student posted on the course web page

  7. Syntax • Use lowercase for everything except variables • Identifiers begin with characters, may contain numbers and hyphens • To comment use /* */ • Rules can have multiple antecedents and make use of “and”, “or”, “not” • Rules can have multiple consequents

  8. Certainties • Similar to ad hoc approach described earlier -100 < CF < 100 100 completely certain 20 default threshold for true 0 neutral -100 completely false

  9. Certainties • If antecedents do not have an explicit CF if x = y then z = w cf 50 M1 uses 20 as threshold for truth of cache expression “x = y” and adds “z = w” to cache • If antecedents have explicit CF if x = y cf 30 then z = w cf 50 M1 uses 30 as threshold for truth of cache expression “x = y” and adde “z = w” to cache

  10. Certainties • What CF value is assigned to “z = w” ? • We take the product of the antecedent certainty and the rule certainties • If CF = 20 for “x = y” and CF = 50 in rule consequent then CF = (CF 20 * CF 50) = (0.2 * 0.5) = (0.1) = 10

  11. Certainties • For conjunction, use the minimum of all the antecedent CF values if x = y and a = b then z = w

  12. Certainties • For disjunction, we use the CF value of the antecedent that triggered the rule or the maximum of all antecedent CF values if x = y or a = b then z = w

  13. Meta-facts • Multivalued (needed with CF) multivalued(sauce). • Questions question(sauce) = 'What kind of sauce does the meal have?'. • Answers legalvals(sauce) = [spicy, sweet, cream]. • Automatic menu automaticmenu(sauce). • Enumerated answers enumeratedanswers(sauce).

  14. Meta-facts • Explanation rule-16: if the main component = poultry and has turkey = no then the best color = white cf 90 and the best color = red cf 30. explanation(rule-16) = [nl, 'For poultry dishes, I recommend white wines. Turkey, ', 'however, goes very well with some red wines.', nl].

  15. Wine has lots of similar rules rule-14: if best-body = light then recommended-body = light. rule-15: if best-body = medium then recommended-body = medium. rule-16: if best-body = full then recommended-body = full.

  16. Wine has lots of similar rules rule-21: if best-color = red then recommended-color = red. rule-22: if best-color = white then recommended-color = white.

  17. Wine has lots of similar rules rule-26: if best-sweetness = dry then recommended-sweetness = dry. rule-27: if best-sweetness = medium then recommended-sweetness = medium. rule-28: if best-sweetness = sweet then recommended-sweetness = sweet.

  18. Using variables in Vine we can replace 27 rules with these 3. v-rule-1: if best-X = V then recommended-X = V. v-rule-2: if best-X is unknown and preferred-X = V then recommended-X = V. v-rule-3: if best-X is unknown and preferred-X is unknown and default-X = V then recommended-X = V.

  19. Default values are used when M1 can’t find values noautomaticquestion(default-X). default-body = medium. default-color = red cf 50. default-color = white cf 50. default-sweetness = medium. • Sometimes we need to turn off automatic question generation to prevent user from entering values and allow M1 to skip searching the rule-base

  20. Wine has lots of specific rules rule-33: if recommended-color = red and recommended-body = medium and recommended-sweetness = medium or recommended-sweetness = sweet then wine = gamay.

  21. Vine makes use of tables to reduce number of rules multivalued(wine(COLOR,BODY,SWEETNESS)). v-rule-4: if recommended-color = C and recommended-body = B and recommended-sweetness = S and wine(C,B,S) = W then wine = W.

  22. Sample Table Entries wine(red,medium,medium) = gamay. wine(red,medium,sweet) = gamay. wine(white,light,dry) = chablis. wine(white,medium,dry) = 'sauvignon blanc'. wine(white,light,medium) = riesling. wine(white,light,sweet) = riesling. wine(white,medium,medium) = riesling. wine(white,medium,sweet) = riesling. wine(red,light,ANY) = valpolicella. wine(red,ANY,dry) = 'cabernet sauvignon'. wine(red,ANY,dry) = zinfandel. wine(red,ANY,medium) = 'cabernet sauvignon'. wine(red,ANY,medium) = zinfandel. wine(red,medium,medium) = 'pinot noir'. wine(red,full,ANY) = burgundy.

  23. Variable Scope • Variables restricted to the rule itself • M1 puts facts (e.g. recommended-color = preferred-color) in cache not values • This means we have to write v-rule-2: if best-X is unknown and preferred-X = V then recommended-X = V. and not bad-2: if best-color is unknown and then recommended-color = preferred-color.

  24. Comparing Numeric Facts • Correct if age N and N > 20 then category = adult. • Incorrect if age > 20 then category = adult.

  25. Arithmetic • Correct if distance = D and fare-mile = M and M * D = R then total-fare = R. • Incorrect total-fare = distance * fare-mile.

  26. Additional Features • User defined syntax lets you skip hyphens prefix best. prefix has. infix to. postfix ends. prefix main. infix with. prefix preferred. • Assigning string to identifier begin-message = [nl, nl, ‘hello’, nl, nl]. • Nocache prevents M1 from saving fact nocache(begin-message). • Presupostion presupposition(sauce) = has-sauce.

  27. Cwine initialdata = [begin the consultation, end the consultation ]. question(begin signal) = [nl,'Are you ready to begin the consultation (y/n)?']. legalvals(begin signal) = [yes,no]. rule-1: if begin message = M and display(M) and begin signal and display('\f') then begin the consultation. rule-2: if not begin signal and display("Issue 'go' command when ready to begin.") and do(abort) then begin the consultation.

  28. Cwine rule-3: if the wine for cycle N is known and user informed of selection N and user happy with selection N then consulting ends with cycle N. rule-4: if the wine for cycle N is unknown and display(['Sorry, not able to recommend any wines.', nl]) then consulting ends with cycle N. rule-5: if positiveinteger = I and consulting ends with cycle I and display([nl,nl,'The consultation is over.', nl]) then end the consultation.

  29. Cwine rule-30: if listof(the wine for cycle N) = [ONLYONE] and display([nl,'The best wine for this meal is ', ONLYONE, '.', nl,nl]) then the winelist for N is displayed. rule-31: if listof(X,ordered(the wine for cycle N) = X) = [ONE,TWO] and display([nl,'The best wines for this meal are ', ONE, ' and ', TWO, '.', nl,nl]) then the winelist for N is displayed.

  30. Cwine question(user happy with selection N) = ['Are you happy with these?']. legalvals(user happy with selection N) = [yes,no]. rule-33: if the description for N is given and the winelist for N is displayed then user informed of selection N.

  31. Cwine rule-9: if M > 1 and M - 1 = N then previouscycle to M = N. question(the new value for X for cycle N) = ['What ', X ,' would you prefer?']. legalvals(the new value for color for cycle N) = [red, white]. legalvals(the new value for body for cycle N) = [light, medium, full].

  32. Cwine legalvals(the new value for sweetness for cycle N) = [dry, medium, sweet]. automaticmenu(the new value for ANY for cycle N). enumeratedanswers(the new value for ANY for cycle N).

  33. Cwine rule-26: if previouscycle to M = N and not(the fault with cycle N = X) and the recommended X for cycle N = V then the recommended X for cycle M = V. rule-27: if previouscycle to M = N and the fault with cycle N = X and the new value for X for cycle M = V then the recommended X for cycle M = V.

  34. Cwine rule-28: if the recommended color for cycle N = C and the recommended body for cycle N = B and the recommended sweetness for cycle N = S and wine(C,B,S) = W then the wine for cycle N = W. rule-29: if the recommended color for cycle N = white and the recommended body for cycle N = full and feature = spiciness then the wine for cycle N = gewuerztraminer.

More Related