                      Notes on ExpertWin
                     Michael Floyd -- DDJ
  
ExpertWin was written to test the features of Turbo Pascal for Windows 
and the suitability of the Object Windows Library (OWL) for creating 
Windows applications. The purpose of ExpertWin is to provide a medium 
for exploring TPW and OWL--not to be a complete application (see notes 
below). The article describing my experiences with TPW 1.5
and OWL appears in the November '92 issue of Dr. Dobb's Journal.

Note that ExpertWin is a "toy" expert system shell and lacks many of the 
features of a true backward chaining system. For example, ExpertWin does 
not allow for ORing of conditions, which means that if any condition in 
the condition list fails, the system fails to prove the conclusion. In 
addition, the UI is not complete. For instance, the application lacks a 
suitable paint method that will redraw the list of conclusions in the 
main window when the list has been covered by a dialog box. Also, there
is no provision for scrolling when the list of items exceeds the 
boundries of the main window.

Using ExpertWin

A sample database is supplied with ExpertWin so that you can get a feel
for how the system works. The database is a classification of
zoo animals and was taken from the book "Artificial Intelligence" by
Patrick Henry Winston (Addison Wesley, Reading MA, 1992).

To get started, load ExpertWin from Windows (requires 3.0 or later) and 
select "Open" from the "File" pull-down menu. The Open dialog starts out
in your Windows directory, so use the dialog to move to the directory 
in which ExpertWin is installed and choose the file "zoo.dat." Once loaded,
a list of zoo classifications appears: Some are general classifications
such as mammal and carnivore; others are specific classifications such as
zebra and tiger.

Now go to the "Inference" pull-down and select "Back Chain" and enter,
say, tiger into the edit control dialog. You will be asked a series
of questions to either prove or disprove the conclusion. Note that a 
tiger is defined to be both a carnivore and a mammal, so ExpertWin 
attempts to prove these "sub-conclusions" as well. I have left the 
name of conclusion in the question as it asked so that you can see which
goal is currently being proved. This accounts for some of the "poor" 
english that ExpertWin speaks.

You can use the edit controls in the main window to enter new 
classifications or extend existing classifications. Note, however that
classification definitions (see zoo.dat) must be gouped together. 
For example, you cannot define a horse, then a cow, then extend the 
horse definition again. As written the inference engine assumes that all
definitions in zoo.dat are grouped together and fails to locate the
extended definitions that are not within the group. Note, however, that
ExpertWin generates an ASCII file, so you can edit the .dat file using
notepad. Keep in mind that ExpertWin assumes that the .dat file was 
generated by the application and therefore does no syntax checking.
Incorrect syntax will have unpredictable results. Also, strings in the
application are defined to be array[0..40] of char. If you want larger
strings, simply define them to be larger. Alternatively, the application
can be modified to handle dynamic strings.

To create a new knowledge domain (such as a database that "knows" about
IBM PC hardware or one that classifies diseases) simply choose "Clear
Facts" from the "Inference" pull-down menu, then use the edit control
in the main window to enter definitions for the new classifications. Do
this by adding a classification name and an attribute in the appropriate
edit controls. Then select "Insert Item" from the "Inference" pull-down.
You can then add additional attributes for that classification by editing
the "Attribute:" edit control. The edit pull-down menu supports cut, 
paste, etc. for these edit controls. All definitions are stored in working 
memory until saved. Choose "Save As" from the "File" pull-down to create 
the new database file (default is a .dat file). 

Other features

There are some limited search features that allow you to locate either
a classification or an attribute (condition) in the database. Also, you 
can list classifications and attributes by choosing "Forward Chain" from
the "Inference" pull-down. Despite its name, this feature is not a 
complete forward chainer since it does not infer facts from sub-classes.
For example, choosing zebra from the item list poses the question of 
whether this is an ungulate. It does not (but should) ask about the
attributes of an ungulate. This includes asking about the attributes of a
mammal since an ungulate is also defined as a mammal. (The back chainer
does this.)

In any case, go ahead and play with the system, clean it up, add to 
it--whatever. If you do something useful with it, I'd like to hear 
about.  You can contact me with coments, questions, etc., at the 
following:

Michael Floyd
Dr. Dobb's Journal
November 1992
CIS: 76703,4057
MCI Mail: mfloyd
Phone: 415-358-9500