![](bg3.png)
and transitions of object states. This transformation depends precisely on transforma-
tions done on variables used in these operations. For example, if the variables used are
transformed in states then the corresponding operation will be transformed into a
transition between states obtained from the pre-condition and states obtained from the
post-condition. On the other hand, if these variables are transformed into attributes,
then B operations will be transformed into operations in the corresponding class in the
class diagram. Corresponding translation rules are given in [3].
3 THINKER: An Interactive Inference Engine
THINKER is an interactive inference engine supporting the derivation of UML class
diagrams from event B models, which at each step allows us to select one solution
from set of proposed solutions if there is an ambiguous choice and to modify previous
decisions. Different inference engines have been developed for the construction of
rules or object based expert systems such as CLIPS (Johnson, 1994), PROLOG [9] or
JESS [7]. Despite the different characteristics of these inference engines, there is a
common failure point: the lack of interactivity between the user and the engine in the
case of ambiguity between several rules. We need at each derivation step to choose
one rule if there are different rules with the same premise and also to backtrack to
change previously selected rules. THINKER is an interactive inference engine operat-
ing by forward chaining. It employs a top-down method which takes facts as they
become available and attempts to draw conclusions (from satisfied conditions in rules)
which lead to actions being executed. The knowledge base of an inference engine is
composed of a set of production rules SR and a set of facts SF. The set SF is generated
from a B model using a developed parser and SR is the set of formalized translation
rules. After loading SF and SR, THINKER starts its execution by extracting the set of
rules that can be applied: RuleApp.
The conflict resolution strategy of THINKER is to fire the rule which the system
designer defined first. Forward chaining continues until it encounters an ambiguity,
i.e, in RuleApp we find several rules with the same set of premises. In this case, the
interactivity between THINKER and the user is required. The user decides which rule
to apply. In addition, the user is shown the result of each candidate rule before choos-
ing one of them. Note that after each application of a rule, SF is incremented with
potential new results. The set of facts is presented to the user as a result of his choice.
After the first ambiguity, a boolean variable Reb which is initialized to 0 changes of
value to 1. This is used to know when we must propose to the user the possibility of
backtracking. So, when Reb = 1, after every application of a rule, Thinker asks the
user if he wants to backtrack. If the answer is affirmative, our engine proposes to de-
fine the Level of backtracking. SR can be decomposed on SR
1
, … SR
n
, that is, we de-
fine n levels of inference. The user defines level = i if the concerned ambiguity is in
the rules SR
i
; after the user selects a Level, our inference engine restores SF by remov-
ing all facts added after the Level point. We mean by Level point, the ambiguity that
Thinker will represent to the user for reviewing his choice.
If the required level is different from the actual one, Thinker will reload all the rules
of the SR corresponding to level. Moreover, in the process of backtracking, Thinker
121