next up previous contents
Next: Priorities Up: Definition of ECArules Previous: Definition of ECArules

ECAassertion

A ECAassertion has the following structure (the syntax is described in section A.3).

$ x,y/Proposition z/Class
  ON event
  IF condition
  DO action1, action2
  ELSE action3
$

The first line contains the declaration of all variables used in the ECAassertion. The specified classes of the variables (here: Proposition and Class) are only used for compilation of the rule, during the evaluation of the rule it is not tested if the variables are instances of the specified classes. The variables are bound to objects by event, condition or action statements.

Possible events are the insertion (Tell) or deletion (Untell) of attributes (A), instantiation links (In), or specialization links (Isa). For example, if the rule should be executed if an object is inserted as instance of Class, then the event statement is: Tell(In(x,Class)). Furthermore, an event may be a query, e.g. if you specify the event Ask(find_instances[Class/class]) the ECA rule is executed before the query find_instances with the parameter Class is evaluated. It is possible to use a variable as placeholder for a parameter.

The event detection algorithm takes only extensional events into account. Events that can be deduced by a rule or a query are not detected. However, the algorithm cares about the predefined Telos axioms, e.g. if an object is declared as an instance of a class, the object is also an instance of the super classes of this class.

The condition is a query to the object base. It can be either a normal literal (A, In or Isa) or a query. For example, if you want to check that the variable x is an instance of Class you can either evaluate the query x in find_instances[Class/class] or evaluate the more simple literal x in Class.

If the condition contains a free variable the actions of the 'DO' block are executed for each result for this variable. If condition contains only constants or bound variables and can be evaluated to 'TRUE', the 'DO' action block is executed once. Otherwise the 'ELSE' block is executed.

By default, queries are evaluated on the old state of the object base before the transaction started. If you want to take into account new information you have to use the new literal, e.g. use new(In(x,Class)) instead of In(x,Class).

Actions are specified in a comma-separated list. The syntax is similar to that one of events, except that you can also ask queries (Ask) and call PROLOG predicates (CALL). In Tell and Untell actions all variables must be bound. In Ask actions, you can have one free variable. In that case, the rest of the action block is executed for each result of this variable.

There are two simple builtin actions: commit finishes the execution of the current ECArule, and reject aborts the current transaction.


next up previous contents
Next: Priorities Up: Definition of ECArules Previous: Definition of ECArules

ConceptBase Team