Det
descriptional language
Det is not a programming system. However any data must be somehow described before use. In Det, the compiler is separated from the executor. Hence, first it is necessary to write a source file using Det descriptional language and then compile it to get file that can be opened by Det executing system.
Det supports the following data structures:
Far before creating computers botanists, entomologists and other scientists wrote the hypertext-like keys to determine biological objects. 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. Each proposition is followed by number of new question or short final conclusion. Assuming "yes" for a certain proposition, you go from question to question until some conclusion if reached. For example:
15 The lichen is brightly
yellow. 16
-- The lichen has different colour, only sometimes it is a little
yellowish 20;
16 The lichen has a round shape with lobes that
are flat (1-2 mm). Typically it is rather large. There are
numerous orange-yellow apothecia (fruit bodies). If you drop 10 %
KOH solution on it, the bright purple colour appear. - Xantoria
parietina
-- The lichen is usually small and don't change colour after KOH
treatment' 17;
17 Thallus remembers small scales, only 2-3 mm
length, sulphur colour. These scales makes rosette. As a rule,
this lichen grows on deciduous trees - Candelaria sp
-- Thallus quite large, up to 50 mm in diameter, laciniate, lemon
colour. As a rule, grows on pines and other coniferous trees,
sometimes on stones. - Cetraria pinastri;
Det syntax is very close to this classic standard. 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 group (explained below). Final conclusions are always preceded by dash (-).
Yes/No against Left/Right. It is possible to provide only the first proposition, replacing the second one by empty text ('', two apostrophes only). In this case, the second empty text will not be displayed: Det will widen the screen area for the first question and the first image through the whole program window width and change the texts on the layout from "Left" - "Right" to "Yes" - "No" style.
Groups. It is much easier to write several simpler keys that one large at once. Scientists do this by establishing a hierarchy of taxons. They join species into genus, then genus into familia, then familia into clasis and so on. First, we can write one key to determine the genus, and then can write for each genus separate key to distinguish between its species. 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. Of if we write a system to determine ships, we can first choose between sailers, steamers, etc and then write for sailers separate key to determine yachts, clippers, etc. Differently from the final conclusion, 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.
Global and local groups. By default, the group definition is valid only for the current key. When the compiler reaches next key definition, it clears the group list. Compiler supposes that the new key should have its own groups, not necessary coinciding with the ones described earlier. However in some cases it is desired to refer the group from other key.
If you need to make the groups global, insert compiler directive <#G+>. The directive is valid from insertion point until the end of file or directive <#G->. However the source with the global group description must precede the following sources that refers to this group as to global group.
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 or 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. The next compiler version will support possibility to specify individual addresses for each question. To do this now, you must manually edit the .ts file.
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.
While the dichotomic keys are optimal for using earlier written manuals, the description tables is the best tool to create the expert system from new data. For example, before writing a key, many scientists draw tables like this:
The lichen is yellow | Lichen is quite large | Red colour after KOH treatment | |
Xantoria parietina | yes | yes | yes |
Cetraria pinastri | yes | can vary | no |
Candelaria sp | no | no | no |
In reality they are obviously much larger. Det format is a little different from the simple table about, but translation is usually straightforward.
There are situations, when some questions are not legal for a certain object. This can be if the feature, described in the question, can vary for the given object, if the feature is difficult or impossible to determine for this object, or if it is simply not known for that object. In Det, such situations are understood and handled.
Det format is a little different from the simple table about, but translation is usually straightforward. The Det format is the following:
?[List of objects for that the rule is valid ] 'Main proposition' [List of objects for that the main proposition is valid] 'Alternative proposition' [List of objects for that the alternative proposition is valid];
Hence it is possible to provide more information than in the table above. Now lets rewrite this table for Det:
?[Xantoria_parietina+Candelaria_sp+Cetraria_pinastri] 'The lichen is yellow' [Xantoria_parietina+ Cetraria_pinastri] 'The lichen is not yellow' [Candelaria_sp];
?[Xantoria_parietina+Candelaria_sp+Cetraria_pinastri] 'Red colour after KOH treatment' [Xantoria_parietina] 'No red colour after KOH treatment' [Candelaria_sp+Cetraria_pinastri];
?[Xantoria_parietina+Candelaria_sp] 'The lichen is quite large' [Xantoria_parietina] 'The lichen is small' [Candelaria_sp];
Note that the last item about size not includes Cetraria_pinastri in the entry condition, nor in conclusion lists, preserving the system from possible wrong occlusion after answering incorrect question.
This might appear a little too verbose. However if the description is valid for all objects in the database the entry list can be omitted, for example:
? 'Red colour after KOH treatment' [Xantoria_parietina] 'No red colour after KOH treatment' [Candelaria_sp,Cetraria_pinastri];
You can use keyword [ALL] to specify all members in the database. It is also possible to use the minus operator (exclude from the set). For example, [ALL-Xantoria_parietina-Cetraria_pinastri] means all lichens in the database except the two mentioned species. You can also define and use the names of groups in these expressions.
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. Rules are very similar to elements of description table.
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 excluding the element from the set (-). The keyword ALL 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 {..}.
With rules, it is possible to launch a new determining process after the current one is finished. For example, the key on lichens contains the following rule:
?[Ramalina_sp] 'It can be one of the Ramalina species. Press "Yes" to determine more exactly. ' [Ramalina_fraxinea+Ramalina_fastigiata+Ramalina_farinacea] ' ' [ALL];
In this case, the entry condition consist only single fact Ramalina_sp. The rule is launched when this fact is concluded during the process of determining. The rule sets the current situation as set of three possible additional final conclusions that are tested using other data in the key.
If the entry condition consist only one final conclusion, the display area is widen automatically to dipole only the first proposition and the first text. This allow to add detailed descriptions of the determined object that appear after the object is determined. For example
?[Circle] 'Very detailed, long description of the circle and $large_its_image.jpg ';
This will make a long description to appear after the final conclusion is reached. It is quite similar to the rule without conclusions and second proposition. There is no difference, which of the defined keys was used to reach the condition. Hence the description need not be repeated in each key.
All texts that appear on the buttons and other areas of the expert system program window are stored in the file language.txt. You can easily add new language by translating this file. Please mind that the order of messages is very important: don't change it, dot add or delete lines. Otherwise program will pick the wrong message from the list. Some pre-translated sets are stored into files language.UK (English), language.lt (Lithuanian) and language.DE (Dutch). I suggest to submit your translated version to us, making it available for all Det users.
Universal environments to work with Det
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.
Attention: the keys, written for older versions of Det, will be understood by newer versions, but obviously not other way round. To use all features, you can always download the updated version of Det from the main page.