How do the Det works?
Det is based on so-called "dichotomic trees". Take for example any old key for determining plant or insect species and you will understand the main idea in minutes. The main element in these keys is a question. It has the entry point (situation identifier), and two propositions, from that only one can be true in a certain situation. Answering "yes" for each proposition activates a final conclusion or a new question. To use in Det, the text of the manual must be a little rewritten, but no special programming is required. Then the text then must be compiled into special .ts format with compile Esk_cpp that is also provided. Det can use several keys at the same time, switching where necessary from one to another (and not necessary starting from the beginning again!). In addition to a set of "keys" you can include an ungrouped rules, a classic element for the most of expert systems.
The "key" file structure
The main element in these keys is a question. It has the entry point (situation identifier), and two propositions, from that only one can be true in a certain situation. Answering "yes" for each proposition activates a final conclusion or a new question. For example:
" Simple key for determining geometric figures http://members.xoom.com/AudriusA/es.htm " 10:
{ Figures:
1 '
The Object has four corners $Rectangle.jpg'
- Quadrilateral_figure
' The object has other number of corners or does not has them at
all $Helix.jpg' 2;
2 '
The object has no corners $Orion.jpg
' - Formless_figure
' Clear corners can be seen ' 3;
<comments can be inserted anywhere>
3 '
Three corners $Triangle.jpg
' Triangle
' Six corners ' - Hexagon;
}
Here, we start from the first item and try to recognise a certain figure. The questions being displayed must be closed inside apostrophes ('). The image file can also be given after the dollar sign ($). Images, stored in JPEG format requires much smaller file size than stored in BMP format. Each pair of propositions (a question) terminates by semicolon (;). It is possible to write comments, bounded by signs < and >.
Each proposition must be followed by number of next item to activate if the proposition is true or a fact that can be concluded if the proposition is true. The fact can be final conclusion or a name of a certain category that has its own dichotomic tree (with independent numeration of items) to establish the final conclusion. For example, if we have an insect, we first determine that this is a beetle, and then use a special key to recognise which beetle. The final conclusion is indicated by dash (-) before the conclusion name. The group name is written without the dash. In our case the name Triangle means the name of the group. Other facts are final conclusions. The group must be described below like:
{ Triangle:
1 'All sides have the same length
' - Equilateral_rectangle
' At least two sides are not equal ' 2;
2 'One angle is right' - Right_rectangle
' No right angles' - Irregular_rectangle;
}
As you see, a group description begins with bracket {, then follows the group name, then colon (:). Next follows the dichotomic key. The description must be finished by closing bracket }. Other group can be invoked from inside the group. The most of earlier written keys are organised into groups, and this feature significantly accelerates the preparation of such material for use in the system.
The initial group must be described in the same style and also have a name. This helps to reach the uniform style.
The names (identifiers) of categories and final conclusions can contain letters, numbers and underscore. During the determining process, these names are used to present additional information in the bottom window of the program.
You can imagine this like a branching trees with a number of "leaves" - possible conclusions. Det supports simultaneous use of several trees, so called "keys".
Each key must also have header with the following syntax
" The name of the key http://internet.address mailto:E-mail.address " :
It is possible to use the system with a single key, but this is not very effective. The best idea is to use several different keys, written by different specialists. The keys simply follows each other in the text file.
The http or (and) E-mail addresses are not required. However after pressing the "Connect" button (available from Det v1.09) the header is scanned, looking for an URL. If one is found, Det launches the default Internet browser asking to show this page. If the E-mail address is found instead, Det launches the default mail client. The addresses can be different for different keys.
During the execution, if the current question can not be answered, the system switches to the alternative key. During these process, the internal structures of the keys are compared. As a rule, a certain "common point" is found, where the set of possible conclusions in the new key is the same or wider than the current set of all possible conclusions. Hence, it is possible to restart the process from this "common point" rather than from the beginning. Switching between different keys it is possible to reach the correct decision even if certain questions in all available keys cannot be answered in a current situation.
The keys description file must be ended by three apostrophes (''').
If you use already written keys, you find the described system very convenient. However if you create your own keys, you may also want ungrouped rules, the classic element of many expert systems since the time of Mycin.
The ungrouped rule does not belong to any tree and can be called an "assembly language" of Det. It must be directly stated when it is activated and how does the situation changes after answering one of the questions. For example:
?[ALL] ' Figure
is a closed curve, every point of which is equidistant from a
given fixed point, the centre ' [
Circle]
' This geometric definition of circle is not correct for the
object. ' [ALL - Circle];
The question mark indicates the beginning of the ungrouped rule. In square brackets, you must list the objects that currently can appear to be a final conclusion. For example, if you are defining a rule to distinguish between circle and ellipse, the entry condition will look like [Circle+Ellipse]. The question only would be asked if only these two alternatives are remaining in current situation.
The propositions (that have the same syntax as for trees) must be followed by analogical lists. Each of them defines the new current situation after this proposition . If none of the propositions is chosen, the current situation variable inside the expert system is not changed.
The names of categories can also be used between the brackets. Det supports the set union (+) and removing the element from the set (-). The keyword ALL or its Lithuanian analog VISI means the complete set of all possible final facts.
The ungrouped rules must be added at the end or beginning of the each key. They must not appear inside the scope of delimiters {..}.
There are a number of good universal environments that allow you easily edit your keys, launch the compiler in pressing a button, capture its output and error messages in a separate window. Despite the keys are not written in C++, I recommend to use editor with C++ or Java syntax highlighting. Such editors correctly highlights text between apostrophes (as text constants) and also numbers. I recommend CodeMagic. It will not take a long time for you to understand it and easily integrate the expert system compiler into this system. You can also try SuperIde that supports special syntax highlighting for Det keys. You can also use your favourite text editor to create the text file. Is all this this much worse than to learn new sophisticated tree-building interface? Please only save the file it in plain text format. You can also look at the example of the key file.