********************************************************************* This article is being presented through the *StarBoard* Journal of the FlagShip/StarShip, SIGS (Special Interest Groups) on the Delphi and GEnie telecommunications networks. Permission is hereby granted to non-profit organizations only to reprint this article or pass it along electronically as long as proper credit is given to both the author (when known) and the *StarBoard* Journal. ********************************************************************* From: COMAL TODAY 6041 Monona Dr Madison, WI 53716 EXPERT SYSTEMS by Michael J. Erskine An expert system is a program which reads a data base while asking the user questions until it has identified the record containing the information which the user has been describing. Sounds pretty fantastic, doesn't it? Well, a good one is the closest thing to artificial intelligence there is. The problem is that an expert system is designed to support a specific task. That's where the rub lies. A system designed to diagnose illnesses can do a very fine job diagnosing illnesses but can't tell you what the weather will be like in a few hours. The system is not intelligent, it simply seems that way because it has been prepared in an intelligent manner. The game 20 questions is a good example of how an expert system makes decisions. When people play the game the strategy becomes, "What question can I ask which will most isolate the correct answer?" In most versions of the game the person being questioned may only answer yes or no, yet it is not unusual for an astute questioner to solve the problem in less than 20 questions, even though he only receives a binary answer, a yes or a no. Why is this possible? If there were ten million things you could think of and half were alive, all you would have to do to isolate the correct half is ask if it were alive. For either answer you would have immediatly eliminated half of the possibilities. You could then ask if it were an animal and based upon that answer eliminate another 2.5 million possibilities. This process could be continued and in a very few tries you could eliminate all but one possibility. Let's see just how many tries that would require. In a binary system, the number of questions which must be asked to isolate a specific record (the answer) would be equal to the exponent of the power of 2 which would exceed the number of possibilities. In other words, if you had 10 million possibilities you would need to ask no more than 23 questions to isolate the item required to answer the question, "What am I thinking of?" The trick is to ask the right questions at the right time. This is what an expert system does. In any field which requires analysis of data to produce a conclusion which is not inspired (does not require a break in logic), an expert system can be written to do the analysis, thus freeing the human to make the inspired decisions which are beyond the scope of the machine. The easiest type of expert system to write is probably a decision tree, sometimes called a rule based program. This type of program will ask the user a question, then will either ask another question based on the answer given, or select a final answer and present it to the user for consideration. If the user doesn't accept the answer, the system will ask him for the correct answer and for a question (RULE) which it can use to differentiate between the answer the system suggested and the answer the user expected. In this manner the system "learns" the correct response. There are 2 programs written in COMAL 0.14 which use the decision tree structure. One by Carl Frierichs called GUESS IT, documented in COMAL TODAY #5, and TUTOR written by myself (on TODAY DISK #10). The former makes use of the fact that data statements can be modified by a running program and all rules (questions) and answers are stored with the program. The latter uses a data base contained in a relative file which is constantly changing to reflect user input. Both programs emulate learning by association. The decision tree programs are easier to write but have the disadvantage of rigorous structure and logic which ultimately selects only one answer for presentation to the user. In other words, rule based systems cannot easily accomodate fuzzy logic or partial data. TUTOR was a quick test of rule based systems. It took about 20 hours to design and code and can easily be improved by someone having the time and inclination. Another type of expert system uses algebraic set theory operations to select all possible answers contained in a data base, and rate, sort and present them to the user in sequence of highest probability of correctness. Set theory systems require huge files of pointers which are constantly searched as a problem is described to the program. For each change in the problem description the system must upgrade its collection of possibe answers. In such systems, the user must be able to query the data base after any change in the description of the problem. Set theory systems are much more flexible to use and considerably more difficult to code. An example of this type of expert system has been written in COMAL 2.0. It maintains 2 pointer files for each question the system supports and a relative data base of up to 4000 individual records. The system can support up to 70 questions. This system probably will be made available as data bases are filled. The end user will not be able to alter the data base. Anyone wishing more information about this system should contact: Michael Erskine, Homegrown Software, 65 East 24th Street, San Angelo, Texas, 76903, phone: 915-655-2882. We are looking for experts who wish to join us in building a library of Expert Systems which can be read by the common reader program. In comparison with a simple decision tree program this system took about 500 hours to write and required 3 prototypes before the current version. Currently the rage in the computer kingdom is not bigger, faster, more storage computers but smaller, faster, smarter software. COMAL allows and even encourages a programmer to write programs which are easier to alter, maintain and read. This is very important when you are writing a serious applications program. It is even more important when you are first learning to program. If COMAL wasn't your first language, it should be your next. Five years from now it may well be the only interpeted language running on any new micro. It's just that good. Remember "Think structure!"