3. Operational semantics of APS

The background of operational (O-) semantics of the considered query language is the so-called S-unification, which is generalization of well-known unification, introduced by J. Robinson in [7] and used in the resolution procedures, developed for the first-order predicate logic. (In fact, S-unification is a strict generalized definition of heuristically described unification, which, as it was shown in [1], is incorrect in the case of multiple occurrences of at least one variable to one of the unified terms.)

We shall consider basic concept of S-unification and then describe operational semantics of used query language, corresponding to (11–18) and defining main features of the controlled logical inference of answers to queries to APS KB.

Let , s, d . be a query and , s i <sup>0</sup>, di . is couple, formed from S-production:

$$
\sigma\_i \colon \prec s\_0^i \gets s\_1^i \dots \square s\_{m\_i}^i, d\_i \ge \tag{19}
$$

As may be seen easily, the answer to , s, d . may contain headers of the CSproductions, being concretizations of σi, i.e., belonging to set σi, if

$$W^{\epsilon,d}\_{\sigma\_i} = \text{Ex}(<\{<\epsilon \leftarrow, d>\}, D>) \cap$$

$$\text{Ex}(<\{\}, D>) \neq \{\mathfrak{B}\} \tag{20}$$

This condition is equivalent to the existence of solution of word equation on context-free language (WECFL):

$$\left[\mathfrak{s} = \mathfrak{s}\_o^i, d\uplus d\_i\right],\tag{21}$$

(for correctness, sets of variables of terms s and s i <sup>o</sup> would not intersect, that is, simply implemented by variables renaming, if this condition is not satisfied).

Result of WECFL (21) solution is the new declaration of variables of Sproduction σi, "concreted" in accordance with query , s, d . . This concretization will be denoted as di <sup>s</sup> i o s, <sup>d</sup> ; it is obtained by replacing variable declarations <sup>β</sup><sup>i</sup> <sup>j</sup> of term s i <sup>0</sup> by new ones β i j , which are more informative ("concrete," "precise"), regarding initial declarations in di: This concretization is adequate to query , s, d . in such a way, that CS-productions, whose headers may enter the answer to this query, may be created at the following steps of inference.

Logics of S-unification are illustrated in Figure 1, followed by Example 2. Example 2. Consider query , s, d . , where

$$\begin{aligned} s &= AREA \ e \text{ IS } NORMAL \ AT \ t, \\ d &= \{ e \to \text{ } \land \text{ } \land \text{ } area \ge \text{ }, t \to \text{ } \land time \ge \}, \end{aligned}$$

and S-production σ<sup>1</sup> from Example 10, where

$$\begin{aligned} s\_0^1 &= \text{AREA } a \text{ IS } s \text{ AT } t, \\ d\_1 &= \{ a \to \text{ } \land \text{name of } area > , \text{s } \to \text{ } \land \text{state } >, e \to \text{ } \land \text{> }, t \to \text{ } \land \text{time } > \}. \end{aligned}$$

According to (21),

$$s\_0^1[d\_1] = \text{AREA}  \text{IS} < \text{state} > \text{AT} < time > ,$$

$$s[d] = \text{AREA}  \text{IS} \text{ NORMAL } AT < time > ,$$

$$d\_1(\frac{s\_0^1}{s, d}) = d\_1 - \{s \to  \} \cup \{s \to \text{NORMAL}\} =$$

Augmented Post Systems: Syntax, Semantics, and Applications DOI: http://dx.doi.org/10.5772/intechopen.86207

¼ fa ! , name of area . , s ! NORMAL, e ! , i . ,

t ! , time . g.∎

S-unification provides opportunity of answer derivation by controlled logical inference, which is implemented by the axiomatic system, which contains only three inference rules—top-down successful S-resolution, top-down unsuccessful S-resolution, and bottom-up S-resolution [1, 2]. Here we shall describe more natural and understandable procedural representation of the considered O-semantics, which fully corresponds to the aforementioned axiomatics.

This representation contains two recursively interconnected algorithmically defined functions.

The first of them Q has two input variables s and d, which values represent query , s, d . , and one output variable A, which value, returned after Q termination, is the answer to this query, as defined by (17).

The second function RB has also two input variables, φ and d, which values represent, respectively, the so-called residual body RB of S-production (subset of body of S-production, including terms, which until current call were not used for the derivation of new queries) and variable declaration, obtained after previous steps of logical inference. Function RB returns set Dof variable declarations, each corresponding to one element of answer to the query , s, d . , where s∈ φ is the next term, extracted from RB. By this, input variables declaration d is made "more precise."

Text of function Q is as follows: 1 Q : functionð Þ s; d returns ð Þ A ;

2 variablesðð Þ s; s<sup>0</sup> term, d, d<sup>0</sup> ; δ; δ<sup>0</sup> declaration, φ set of terms, <sup>3</sup> <sup>A</sup> set of words  initialð ÞÞ f g <sup>∅</sup> local; 4 variablesð Þ Sset of productions; D set of context � free rules global; 5 do , s0, φ, d<sup>0</sup> . ∈S; <sup>6</sup> <sup>δ</sup>≔d<sup>0</sup> <sup>s</sup><sup>0</sup> s, d ; 7 if δ 6¼ ∇ 8 then doδ<sup>0</sup> ∈RBð Þ φ; δ ; 9 A : ∪ s<sup>0</sup> δ<sup>0</sup> f g ½ � ; 10 endδ<sup>0</sup> ; 11 endS; 12 endQ

As seen, lines 2–4 contain declarations of variables, used lower in the function body. It is essential that there are two variables declared as global, namely, S (set of S-productions) and D (metadatabase). Nevertheless the last one is not used in the body, it is presumed that MDB is used inside S-unification (line 6). The initial value of local variable A is an empty set.

The main part of Q is loop (lines 5–11) on S-productions, entering set S and represented in the form of triples , s0, φ, d<sup>0</sup> . , where s<sup>0</sup> is header; φ is body of Sproduction, being set of terms; and d<sup>0</sup> is its variable declaration. The first operator inside loop (line 6) implements S-unification of query , s, d . and couple , s0, d<sup>0</sup> . . If this S-unification is successful (i.e., its result is not a special value ∇), then loop on elements of set of variable declarations, obtained by function RB, is executed (lines 8–10). The values of input variables of function RB are φ (set of terms, entering body of the current S-production) and δ (result of the

aforementioned S-unification). Each δ<sup>0</sup> , being set of variable declarations of the form <sup>γ</sup> ! <sup>u</sup>, where <sup>u</sup>∈<sup>V</sup> <sup>∗</sup> , is used for making facts <sup>s</sup><sup>0</sup> <sup>δ</sup><sup>0</sup> ½ � by substitution right parts of those declarations to term s0, and all such facts are joined to the output set A (line 9). Text of function RB, in turn, is as follows:

> 1 RB : functionð Þ φ; d returns ð Þ D ; 2 variablesðφ set of terms, d declaration, sterm, w fact, <sup>3</sup> <sup>D</sup>set of declarations  initialð Þ f g <sup>∅</sup> local; 4 variablesð Þ D set of context�free rules global; 5 if φ ¼ f g ∅ 6 thenD≔f gd ; 7 else dos ∈φ; 8 dow ∈ Q sð Þ ; d ; <sup>9</sup> <sup>D</sup> : <sup>∪</sup>RB <sup>φ</sup> � f g<sup>s</sup> ; <sup>d</sup> <sup>s</sup> w, f g ∅ ; 10 endw; 11 ends; 12 endRB

Here lines 2–4, as in the text of Q, are declarations of variables, used in the RB body. RB execution begins by check, whether set φ is empty (line 5): if so, search of terms of S-production body is already finished (or, as partial case, it is empty because S-production is axiom), and the returned value is one-element set f gd , where d is the same, as input value. Otherwise loop on terms, entering residual body, is executed (lines 7–11). Every selected term s is used in query , s, d . to KB <S,D>, which is processed by recursive call Q (s,d), and loop on all facts, entering answer to this query, is executed (lines 8–10). The body of this loop contains single operator (line 9), providing accumulation of set D as a result of recursive call of the same function RB with the first input variable being φ � f gs (i.e., set of terms of the body of the processed S-production, reduced by extraction of the processed term s) and the second input variable value being d <sup>s</sup> w, f g <sup>∅</sup> (i.e., S-production variables declaration, made "more precise" according to result of S-unification of query , s, d . and fact w).

As it is easy to see, execution of loop s∈φ provides generation of n! sequences of terms of body of S-production, i.e., all possible permutations of these terms.

Let Q sð Þ ; d be finite result of function Q application to the query , s, d . and APS KB <S,D>. There is theorem on the correctness of the described operational semantics of the augmented Post systems [2].

Theorem 1. Q sð Þ¼ ; d Ex Sð Þ ; D ∩Exð Þ , f g s ; f gd . :

In fact, Q and RB collaborative operation provides top-down derivation of the set of CS-productions, involved in creation of non-ground facts, which enter the answer to the query , s, d . , in full accordance with bottom-up definition of M-semantics of APS. (Ground facts are simply selected by one-step application of Q and RB.)

As seen from this description, logical inference is implemented in a wavelike manner. "Direct waves," including generated queries, which contain "more and more concrete" variables declarations, are "spreading" until S-axioms are reached. This leads to the creation of CS-productions, and "back waves" start until a new set of facts, being answer to some intermediate (or, finally, initial) query, is assembled. Both direct and back waves meet one another and "interfere," producing new queries. As may be seen, APS operational semantics corresponds to the universal

mode of inference (all facts, being goal of the query, are derived), unlike existential mode (anyone fact from the possibly multifact set), which is inherent to known resolution procedures. By this, full accordance of APS O-semantics to its S- and M-semantics is achieved.
