4. Procedural connection to APS KB

One of the most important features of any knowledge representation model are embedded tools of the procedural connection, providing interaction of "rigid" (non-updated by knowledge engineers) software modules with inference process and data exchange between inference engine and the aforementioned modules.

Background of the procedural connection to APS knowledge bases are program (P-) productions.

P-production is couple , s<sup>0</sup> ( p, d . , where term s<sup>0</sup> is header and set d variable declaration; s<sup>0</sup> and d are declarative component of the procedural connection. Symbol } ( } is the divider, distinct from } }, and p is the name of the connected program (software module), which has its own extensional Wp⊆Ex ð Þ , ,f g s<sup>0</sup> ; d . ; D . ⊆L Gð Þ.

Couple , s0, d . is called cover of the connected program p. In general case one and the same program may be connected to APS KB by several P-productions with different covers.

Example 3. Program named MULT for multiplication of integer numbers may be connected to knowledge base by P-production:

$$a \le a \ast b = c \Leftarrow \text{MULT}, \{ a \to \text{} , b \to \text{} \}, c \to \text{} \} \ge \dots$$

MULT extensional is an infinite set containing strings like 1 ∗ 1 ¼ 1, 0 ∗ 5 ¼ 0, 311 ∗ � 1 ¼ �311, etc.∎

Let Π be the set of names of programs, connected to APS KB. The extensional of this KB will differ from (12) to (14) by the only feature; instead of (12) the following is used:

$$\mathcal{W}\_{(0)} = \left( \bigcup\_{p \in \Pi} \mathcal{W}\_p \right) \cup \{ w \vert \{ w \leftarrow, \{ \rho \} \succ \in \overline{S} \} \},\tag{22}$$

i.e., Wð Þ <sup>0</sup> is a join of extensionals of all connected programs and set of ground facts, being heads of CS-axioms. Until general case will be discussed, we shall consider programs with the so-called static extentionals, whose basic feature is Wp ¼ const for all period of query processing.

Concerning operational semantics, it is sufficient to extend function Q by operators, providing call of the "perspective" connected programs via unified application programs interface and joining resulting sets to the accumulated answers. The extension is as follows:

> 12 do , s0, p, d<sup>0</sup> . ∈S; <sup>13</sup> <sup>δ</sup>≔d<sup>0</sup> <sup>s</sup><sup>0</sup> s, d ; 14 if δ 6¼ ∇ 15 thenA : ∪p sð Þ <sup>0</sup>; δ ; 16 endS;

As seen, after search on S-production set (lines 5–11), similar search on Pproduction set would be executed (lines 12–16). If S-unification of query , s, d . and program p cover , s0, d<sup>0</sup> . is successful, program call is executed, and its result —set of words, denoted p sð Þ <sup>0</sup>; δ —is joined to the accumulated set A. This fully corresponds to (22).

As seen, search on the set S is nondeterministic (there is no any predefined order on this set, except S-productions processing before P-productions; but in general case, this ordering, of course, is not mandatory). This obstacle creates some difficulties in implementation of calls of the connected programs, when input data are less informative, than it is necessary for computation (e.g., MULTð Þ a ∗ b ¼ c; fa ! , integer . ; b ! 4;c ! , integer . g . By this, result of such call may be infinite set, even if there would be an opportunity to implement this operation using tools for N-facts processing, developed in [1–4].

To avoid such difficulty, it would be reasonable to implant to S- and Pproductions some information, which may cut off "dangerous" branches.

There is a simple tool for logical inference control within APS knowledge representation. Namely, variables, which the declarations after S-unification would have right parts, consisting only of terminal symbols (i.e., there would be no incomplete information, associated with non-terminals, inside these declarations), are marked by point over arrow in the initial descriptions, having place in P- and S-productions. Such variables are called complete. In example 3 declarations of variables a and b would be a!\_ , integer . , b!\_ , integer . , so query

$$<\varepsilon \ast e = f, \{\varepsilon \to 1, e \to 4, f \to \infty \text{integer} \ge \} \ge 1$$

while inference will result in program MULT call, while query

, x ∗ a ¼ s, xf g ! , integer . ; a ! 135; s ! , integer . . will not, because of information incompleteness of the declaration of x, which is a complete variable. Negative result of S-unification in the case of such incompleteness is, as higher, denoted by symbol ∇.

Let us consider now the general case, where extensionals of programs, connected to APS KB, are not static, i.e., may vary while answer derivation. The simplest examples of such kind of programs are database management systems.

To connect DBMS, operating key-addressed databases, it is sufficient to join to APS KB P-production:

$$k \le ?\\k = d \Leftarrow \text{DBMS}, \{k \to \le key > , d \to \le data > \} > 1$$

for queries (variable k, denoting key, is complete), as well as

$$k \lhd k \text{::} d \Leftarrow \text{DBMS, } \{k \text{→} \land key \rhd, d \lhd d \text{data} \rhd \} > 0$$

for update operations (both variables k and d, corresponding to key and data, are complete).

DBMS, operating databases with symmetric access, may be connected in a following way. In order to minimize redundant search while queries processing, some substrings of facts may be declared indexed (used for creation and maintenance of dynamic search trees, as it is described in [2, 3]). So some covers of the relational DBMS, corresponding to some subsets of DB, may contain complete variables, with declarations like γ\_u, where ! u defines domain of the indexed attribute of the relation. Covers, providing inclusion to SDB, contain only complete variables. (If DBMS operate SDB with incomplete information, any variable may be incomplete.)
