PII: 0898-1221(91)90112-H Computers Math. Applic. Vol. 21, No. 11/12, pp. 111-116, 1991 0097-4943/91 $3.00 + 0.00 Printed in Great Britain. All rights reserved Copyright~) 1991 Pergamon Press plc F U Z Z Y D E C I S I O N T A B L E S F O R E X P E R T S Y S T E M S ART LEW Department of Information and Computer Science University of Hawaii (Received July 1990) A b s t r a c t - - T h e use of fuzzy decision tables as a programming language for representing both the knowledge and the procedures in expert systems is discussed. Examples of their use for the generation of procedural code and for the generation of if-then rules are given. I. INTRODUCTION The main a~Ivantages of decision tables [1,2] are that: (a) they provide a systematic way to design algorithms; (b) they are amenable to certain forms of automated error-checking (such as for consistency [3]) and to formal verification (by correctness proofs [4]); and (c) a processor to compile and execute them is relatively easy to implement [5]. Decision tables (DTs) are compatible with most programming languages, including general- purpose languages such as Ada and C as well as special-purpose languages such as LISP [6] and Prolog; the processor described in [5] can be adapted, with varying degrees of difficulty, to translate DTs into any of these languages. We previously discussed the use of DTs as a general-purpose programming language [7]; here, we discuss their use for the implementation of rule-based expert systems. 2. F U Z Z Y A L G O R I T H M S In an earlier p a p e r [8], we d e m o n s t r a t e d t h a t an y ( n o n f u z z y ) a l g o r i t h m can b e i m p l e m e n t e d b y a D T . In principle, a n y f u z z y a l g o r i t h m [9,10], if it is t o b e realized (i.e., e x e c u t e d on an a c t u a l c o m p u t e r ) , can also be i m p l e m e n t e d using a D T , al b ei t possibly a n o n d e t e r m i n i s t i c one [11]. For e x a m p l e , a f u z z y version o f t h e D T in [7] for finding t h e s h o r t e s t p a t h in a g r a p h can be b ased on f u z z y o p t i m i z a t i o n a l g o r i t h m s [12]; some o t h e r ex am p l es o f f u z z y o p t i m i z a t i o n a l g o r i t h m s a p p e a r in [13-15]. 3. A P P L I C A T I O N O F D T S T O E X P E R T S Y S T E M S It is n a t u r a l t o use D T s to express the knowledge base o f an e x p e r t s y s t e m [16]. Each IF-THEN rule o f t h e f o r m IF P1 . o . AND Pn THEN CI AND Cm {with certainty factor of=n} can be r e p r e s e n t e d by a rule (or c o l u m n ) of a D T Ty p ~et by A ~ - ~ _ X 111 112 A. L~.w P1 : T Pn : T Cl :X am: X {cf = n} where the premises and consequents of the productions are the conditions and the actions of the DT. This idea is quite old; numerous rule-based expert systen~ incorporating decision-table concepts in their design and analysis have been reported (see, for example, [17219]). Much of this prior work concerned methods of detecting ambiguities, regarded as a problem in that other context; here, we regard ambiguities as a desirable way to express fuzziness. We distinguish between "procedural" DTs, in which the consequents are general actions (which may include "call" statements), and "nonprocedural" DTs in which the consequents are simple actions (i.e., value assignments). Generally speaking, we liken procedural DTs to forward-chaining production systems such as OPS5 [20], and nonprocedural DTs to backward-chaining inference systems such as Mycin [16]. Decision table processors can be designed to perform both forward and backward chaining. In this paper, we focus our attention on procedural DTs. 4. F U Z Z Y DTS DTs are suitable for expressing fuzziness in expert systems in a number of ways. The fuzzi- ness may be in multi-valueness of conditions, nondeterminism of rules, or a variety of forms of uncertainty in the entries of any of the four DT quadrants or with respect to any row or column. For example, in the above DT, Pn or Cm may be fuzzy expressions, their values may be fuzzy rather than truth-valued possibly with varying degrees of certainty, and rules themselves may have associated certainty factors and may or may not be mutually exclusive. These variations can all be accommodated within the framework of "ambiguous" DTs. Ambiguous procedural DTs can be implemented as nondeterministic algorithms. One problem in the handling of fuzziness for which there is no clear-cut solution relates to how fuzzy certainty factors should be defined and blended. Even in nonfuzzy contexts, different expert systems have adopted different conventions, none of which may be appropriate for a given application [21]. Use of DTs permits users to program their own blending formulas; unlike the case in most systems, many different formulas may be used in the same application and these formulas may be dynamically defined. 5. E X A M P L E S Examples of the application of fuzzy procedural DTs to the design of expert systems appear in [12], in which the nonfuzzy DTs used to solve the stock market problem as given in [2] were modified in what are rather minor ways. Even so, there are several errors in the fuzzy DTs of [12], such as the one given here as Table 1. Table 1. ~1 ~ 2 R3 R4 trading possible? : Y Y N stkavg (X1)\ } : XI+X2 XI.X2 bndavg (X2)/ XI/X2 call(stocks) : <=0.2 >0 call(bonds) : <=0.2 =0 call(account) : <=0.2 X process R4 : <=0.4 go again : <=0.2 X stop >0.4 X Fuzzy decision t a b l e s for e x p e r t systems Table 2. trading possible ? : s t k a v g ( X 1 ) \ ) bndavg (X2)/ R1 R2 R2 ~ R3 : R4 Y Y Y N X I + X 2 Xl.X2 Xl/X2 update averages : X X X call(stocks) : <=0.2 call(bonds) : <=0.2 call(account) : <=0.2 process R4 {goto~ : <=0.4 go again {repeat} : <=0.2 stop ~exit} : >0.4 X =0 >0 X X 113 (Here, + , . , and / are fuzzy max, min, and diff operators.) A corrected version is given in Table 2; note the reversal of the relations X1/X2 > 0 and Xl/X2 = 0. The adoption in these procedural tables of a left-to-right interpretation convention with implicit ELSE rules, as well as of conditional rules associated with "goto" statements (such as to rule R4), is, we believe, undesirable. Table 3 shows an equivalent table which utilizes different conventions in which the "logic" is expressed in the upper right quadrant. T a b l e 3. trading possible? : T T T T F stkavg+bndavg : <=0.2 >0.2 >0.2 >0.2 - stkavg.bndavg : - <=0.4 <=0.4 >0.4 - stkavg/bndavg : - >0 =0 - - update averages : X X X X - call(stocks) : X - X - - call(bonds) : X X - - - call(account) : X X X - - repeat : X X X - - exit : - - - X X One advantage of this format, in which the rules can be evaluated in any order, is t h a t optimal conversion algorithms (such as in [22]) may then be applied. (To simplify lexical processing, we used a slightly different "syntax" in our implementation, as illustrated below.) 6. I M P L E M E N T A T I O N We attribute the errors in Table 1 and the other fuzzy DTs of [12] to the unavailability of a programming system with which the tables could be tested. This provided us with the motivation to design such a programming system. Our system [which at this writing is not yet complete] is essentially a preprocessor which translates fuzzy DTs, expressed in a format similar to that used in Table 3, into a conventional (procedural) language in a manner like that described in [5]. The precise DT format we adopted is given in the Appendix 1; its translation into a procedural language (which can be executed using an ordinary compiler) is shown in Appendix 2. Using the slightly different syntax given in Appendix 3, the DT can be translated into the set of IF-THEN rules shown in Appendix 4, which in turn can be processed using a simple expert system such as in [23]. 7. C O N C L U S I O N Fuzzy DTs can be used to express the knowledge base of an expert system. DTs can also be used as the programming language in which expert systems are implemented (i.e., programmed, 114 A. L~.w in a c h o i c e o f e n v i r o n m e n t s , s u c h as L I S P a n d C ) . T h a t use o f D T s is a n a d v a n t a g e o u s w a y f o r h u m a n s t o i n t e r a c t w i t h c o m p u t e r s , e s p e c i a l l y as a m e a n s t o r e p r e s e n t p r o d u c t i o n rules, is d e m o n s t r a t e d b y t h e i r f r e q u e n t a d o p t i o n in t h e A I l i t e r a t u r e (e.g., see [13,20,24]). O f c o u r s e , s i n c e t a b l e s a r e c o m m o n l y u s e d for a v a r i e t y o f o t h e r k i n d s o f i n f o r m a t i o n , s u c h as r e l a t i o n a l d a t a b a s e s , d e s i g n o f a n i n t e g r a t e d s y s t e m e m p l o y i n g t a b u l a r r e p r e s e n t a t i o n s o f k n o w l e d g e a n d p r o c e d u r e s is w o r t h s e r i o u s c o n s i d e r a t i o n . A n o t h e r a d v a n t a g e o f t h e u s e o f f u z z y D T s t o i m p l e m e n t e x p e r t s y s t e m s is flexibility. D T s p e r m i t b o t h f o r w a r d a n d b a c k w a r d c h a i n i n g , a n d allow t h e i n c o r p o r a t i o n o f d i f f e r e n t w a y s o f h a n d l i n g f u z z i n e s s ( s u c h as b l e n d i n g c e r t a i n t y f a c t o r s ) w i t h i n t h e s a m e a p p l i c a t i o n . ( D e t a i l s o f a d e s i g n w h i c h is c o m p a r a b l e t o S y s t e m Z-11 [25] will b e d i s c u s s e d in a f o r t h c o m i n g p a p e r . ) W e c o n c l u d e t h a t t h e d e s i g n o f e x p e r t s y s t e m s u t i l i z i n g f u z z y D T s is w o r t h w h i l e a n d w a r r a n t s f u r t h e r r e s e a r c h a n d d e v e l o p m e n t , a n d we a r e so p r o c e e d i n g . O n e o p e n r e s e a r c h p r o b l e m is w h e t h e r b e t t e r e x p e r t s y s t e m s c a n b e i m p l e m e n t e d u s i n g f u z z y D T p r o c e s s o r s , i.e., b y i n c o r p o - r a t i n g f u z z i n e s s i n t h e p r o c e s s o r r a t h e r t h a n in t h e t a b l e s u p o n w h i c h t h e y o p e r a t e . REFEIIEN CES 1. CODASYL Task Group, A Modern Appraisal of Decision Tables, ACM, New York, (1982). 2. R.B. Hurley, Decision Tables in Software Engineering, Van Nostrand Reinhold, New York, (1983). 3. P.J.H. King, The interpretation of limited entry decision table format and relationships among conditions, Computer Journal 12,320-326 (1969). 4. A. Lew, Proof of correctness of decision table programs, Computer Journal 27,230-232 (1984). 5. A. Lew, A decision table processor, University o] Hawaii, technical report (1988). 6. B.M. Schwartz, LISP 1.5 decision tables interpreted for a small computer and proposed for parallel com- puters, S I G P L A N Notices 6 (8), 93-103 (1971). 7. A. Lew, Decision tables for general-purpose scientific programming, Software-Practice and Experience 13, 181-188 (1983). 8. A. Lew, On the emulation of flowcharts by decision tables, Commun. A C M 25, 895-905 (1982). 9. L. Zadeh, Fuzzy algorithms, Information and Control 12, 94-102 (1968). 10. L. Zadeh, The role of fuzzy logic in the management of uncertainty in expert systems, Fuzzy Sets and Systems 11, 199-227 (1983). 11. A. Lew, Decision table programmlng-some new perspectives, University o.f Hawaii, technical report (1983). 12. A. Kandel, Fuzzy Mathematical Techniques with Applications, Addison-Wesley, Reading, Mass., (1986). 13. R. Bellman and L.A. Zadeh, Decision-making in a fuzzy environment, Management Sci. 17 (4), B141-164 (1970). 14. R.L.P. Chang, Fuzzy decision tree algorithms, IEEE Trans. Sys. Man Cyb. 7, 28-35 (1977). 15. A.O. Esogbue, Dynamic programming, fuzzy sets, and the modeling of R & D management control systems, IEEE Trans. Sys. Man Cyb. 13, 18--40 (1983). 16. B. Buchanan and E. Shortliffe, Rule-Based Expert Systems, Addison-Wesley, Reading, Mass., (1984). 17. M. Trigoboff and C.A. Kulikowski, IRIS: A system for the propagation of inferences in a semantic net, Proc. 5th IJCAI, 274-280 (1977). 18. B.J. Cragun and H.J. Steudel, A decision-table-based processor for checking completeness and consistency in rule-based expert systems, Int. J. Man-Machine Studies 26,633-648 (1987). 19. R. Maes and J.E.M. VanDijk, On the role of ambiguity and incompleteness in the design of decision tables and rule-based systems, Computer Journal 31,481-489 (1988). 20. T. Cooper and N. Wogrin, Rule-Based Programming in OPSS, Morgan Kaufmarm, San Mates, Calif., (1988). 21. D. Kopso, L. Pipino and W. Rybolt, A comparison of the manipulation of certainty factors by individuals and expert system shells, J.MIS 5, 66-81 (1988). 22. A. Lew, Optimal conversion of extended-entry decision tables with general cost criteria, Commun. A CM 21,269--279 (1978). 23. B. Sawyer and D. Foster, Programming Expert Systems in Pascal, Wiley, New York, (1986). 24. M.A. Carrico, J.E. Girard and J.P. Jones, Building Expert Systems, McGraw-Hill, New York, (1989). 25. K.S. Leung and W. Lava, Fuzzy concepts in expert systems, Computer 21 (9), 43-53 (1988). Fuzzy decision tables for expert systems 115 A P P E N D I X A A F~zz~ Procedural DT. dtbegin! trading possible max(stkavg,bndavg) min(stkavg,bndavg) diff(stkavg,bndavg) update averages c a l l ( s t o c k s ) call(bonds) call(account) repeat! exit! dtend! :T T T T F !<=0.2 >0.2 >0.2 >0.2 - !- <=0.4 <=0.4 >0.4 - !- >0 =0 - - :X X X X - :X - X - - :X X - - - :X X X - - :X X X - - :- - - X X A P P E N D I X B Translation oJ the D T of Appendix A. while not(lambda0.2) and (min(stkavg,bndavg)<=0.4) and (diff(stkavg,bndavg)>O) then begin update averages; call (bonds); call (account); lambda:=l; end else if (trading possible) and (max(stkavg,bndavg)>0.2) and (min(stkavg,bndavg)<=0.4) and (diff(stkavg,bndavg)=O) then begin update averages; call (stocks); call (account); lambda:=1; end else if (trading possible) and (max(stkavg,bndavg)>0.2) and (min(stkavg,bndavg)>0.4) then begin update averages; lambda:=-1; end else if not(trading possible) then begin lambda:=-1; end else begin lambda:=-2; end; end; 116 A. Lsw A P P E N D I X C A F~zz~ Exper~ S~/8~em (in ~ D T Formal). d t b e g i n ) t r a d i n g p o s s i b l e = m a x ( s t k a v g , b n d a v g ) min(etkavg,bndavg) diff(stkavg,bndavg) update averages c a l l ( s t o c k s ) c a l l ( b o n d s ) call(account) exit dtend! IT T T T F !<=0.2 >0;2 >0.2 >0.2 ! <=0.4 <=0.4 >0.4 ! >0 =0 !, m X X A P P E N D I X D R~le8 Asaociated wi~A the Expert S~mtern of A~pe.dix C. Rule 1.1: if trading possible=T and max(stkavg,bndavg)<=0.2 then update averages, and call(stocks), and call(bonds), and call(account). Rule 1.2: if trading possible=T and max(stkavg,bndavg)>0.2 min(stkavg,bndavg)<=0.4 diff(stkavg,bndavg)>O then update averages, and call(bonds), and call(account). Rule 1.3: if trading possible=T and max(stkavg,bndavg)>0.2 min(stkavg,bndavg)>=0.4 diff(stkavg,bndavg)=O then update averages, and call(stocks), and call(account). Rule 1.4: if trading possible=T and max(stkavg,bndavg)>0.2 min(stkavg,bndavg)>0.4 then update averages, and exit. Rule 1.5: if trading possible=F then and exit. and and and and and