Distributed Logic Programming 1 Introduction

0 downloads 0 Views 151KB Size Report
PARLOG 3], Concurrent Prolog 13] and GHC 16] are typical examples of applying ... is to unify terms, particularly to bind variables, which in turn could further propagate both data ..... used in the practical implementations of the SLD-resolution.
Distributed Logic Programming Zd ra v k o M a rk o v , C h ris t o D ic h e v

Institute of Informatics Bulgarian Academy of Sciences Acad.G.Bonchev St. Block 29A, 1113 So a, Bulgaria

1 Introduction Most of the network models used in AI are just notations (e.g. semantic networks). The real working network systems are mainly connected with Parallel Distributed Processing (PDP), well developed in the eld of numeric computation. Even modern connectionism, which attempts to generalize the PDP paradigm is also based on numeric computation. Opposed to numeric computation are the symbolic approaches in AI - the methods for problem solving, including automatic deduction. There is another research direction integrating both approaches. A considerable part of this research is in the eld of Logic Programming. PARLOG [3], Concurrent Prolog [13] and GHC [16] are typical examples of applying PDP approaches in a pure symbolic eld. However the main purpose of these works is not integrating symbolic and parallel computation in a consistent way, rather improving the eciency of the implementations. An interesting approach is proposed by Jorrand in [5] and in some later works. Logic programs are represented as networks of communicating by uni cation agents working in parallel. This approach preserves the original herbrand semantics of Logic Programs without introducing any additional control means (used in the parallel Prolog implementations). This is a formal and elegant way of introducing a new computational paradigm - computation by communication. However this approach is dicult to implement and use in practice. The present paper describes a PDP approach to Logic Programming. The issue of parallelism is not discussed, rather the emphasize is on the distributedness, which is one of the basic features of the described formalism. The main contribution of this paper is showing a way of implementing logical inference in a network environment, called NetClause language (NCL). The basis of NCL is the network formalism presented in [7], where it was considered as an extension of logic programming. Its applications in the eld of graphical object representation and as a connectionist modeling tool are shown there. In the present paper the interpretation of NCL as a logical reasoning scheme is shown. Various aspects of NCL are also discussed in [9,10,11]. The application of NCL in the eld of natural language processing in discussed in [11,14].

2 An overview of the Net-Clause Language Syntactically the Net-Clause language (NCL) is an extension of the standard Prolog. Its semantics however is aimed at modeling graph like structures (networks), consisting of nodes and links. The nodes specify procedures unifying terms, and the links are channels along which the terms are propagated. The language is designed for describing distributed computation schemes, without centralized control using uni cation as a basic data processing mechanism. The basic constructors of NCL programs are the net-clauses. A net-clause is a sequence of nodes, syntactically represented as structures (complex terms), separated by the delimiter ":". The network links are implicitly de ned by shared variables among di erent nodes in a net-clause. The variables in NCL are called net-variables. The NCL networks are built out of two types of nodes - free nodes and procedural nodes. The free nodes are structures (in the form of Prolog facts) used to access netvariables, inside and outside the net-clause. The procedural nodes are the active elements in the network. Procedures unifying terms are associated to the procedural nodes. The procedures are activated under certain conditions, de ned locally in each node. Thus the control in NCL is distributed. It is based on the uni cation procedure, which is also the basic data processing mechanism in the language. Since there are no explicit control means in the language the control in NCL is data-driven. Generally when unifying netvariables two possible results can occur: binding net-variables to non-variable terms and sharing net-variables. These possibilities de ne the two control schemes in NCL. Each one of them is speci ed by a particular type of procedural node. We describe brie y only the rst control scheme - spreading activation, since the second one (activation by need) does not relate to the connectionist features of NCL. It is described elsewhere (e.g. [11]) in the framework of default reasoning.

2.1 Spreading Activation in NCL The spreading activation control scheme is de ned by procedural nodes written in the following syntax: node(X1,...,Xn,M,). The purpose of the node procedure is to unify terms, particularly to bind variables, which in turn could further propagate both data (terms) and control (activation) among other nodes in the network. The node procedure is also an interface to the Prolog system, which is an environment for NCL, i.e. Prolog built-in procedures and predicates can be called too. M is an integer number and its semantics is to de ne a threshold, determining the amount of data required to activate the procedure. Xi are net-variables which serve as channels for term propagating. They can be used both as excitatory links and as inhibitory links for the activation of the procedure. The excitatory links are represented as simple (ordinary) variables and the inhibitory links are represented as negated variables (written as ~Xi). The procedure is activated if the di erence between the number of the bound simple variables and the number of the bound negated ones is equal to M. When de ning a spreading activation node the condition M>0 is required. This ensures that the procedure can not be activated "by de nition", i.e. at least one variable binding is needed for that purpose. Actually

binding a simple variable decrements M, and binding a negated one increments it, thus the procedure is activated when M=0. In such a way M can be used to indicate dynamically the number of bound Xi. To illustrate the features of the spreading activation control scheme let us discuss a simple example. Consider the problem of polyhedron recognition. A solution of this problem in Prolog is described in [7,8]. A polyhedron can be considered as an attributed graph, represented as a list of edges, each one in the following form: edge(Vertex1,Vertex2,Slope,Length)

Thus an instance of a parallelogram can be represented by the following list: [edge(1,2,0,20),edge(2,3,30,50),edge(3,4,0,20),edge(4,1,30,50)]

An important feature of this representation is the possibility to de ne a class of gures, using variables instead of xed values standing for the vertex names and attributes. Thus the class of all parallelograms is represented as follows: [edge(A,B,S1,L1),edge(B,C,S2,L2),edge(C,D,S1,L1),edge(D,E,S2,L2)]

Using variables as edge attributes ensures that the class representation is free of any speci c geometric properties as size, orientation, etc. Using this representation the problem of polyhedron recognition comes to the problem of graph isomorphism. This in turn is solved easily (but not eciently) by a simple recursive predicate, checking whether a list is a sublist of another list. The pure subgraph matching problem is NP-complete. However, in some cases a proper representation may be found to make the graph matching algorithm applicable in practice. The aim is to minimize the number of the backtracking steps occurring in the "bad" ordering combinations. The use of attributes in the graph improves the eciency as it is shown in [8]. However, there is a "second order" problem, which appears where more than one class is used. The overall eciency in such case depends very much on the order of the selected classes to be recognized, since the matchings between the instance and each of the classes is tested sequentially. Yet another disadvantage is that more complex geometric properties (e.g. perpendicularity) cannot be directly represented as graph attributes. Let us discuss now the NCL solution of the above stated problem. Consider the following net-clause program: /* Free Nodes - Network Inputs */ edge(A,B,S1,L1): edge(B,C,S2,L1): edge(C,D,S1,L1): edge(D,A,S2,L1): edge(B,E,S2,L2): edge(E,F,S1,L1):

edge(F,A,S2,L2): edge(E,G,S3,L3): edge(G,A,S4,L4): /* General case of a four-side figure */ node(A,B,E,G,4,fig(four_side_figure)): /* Hidden node checking perpendicularity */ node(S1,S2,2,perp(S1,S2,P)): /* Non-perpendicular figures */ node(A,B,E,F,~P,4,fig(parallelogram)): node(A,B,C,D,~P,4,fig(rhombus)): /* Perpendicular figures */ node(A,B,E,F,P,5,fig(rectangular)): node(A,B,C,D,P,5,fig(square)): /* Free Node - Network Output */ fig(Fig). /* Procedure calculating perpendicularity */ perp(X,Y,ok):-0 is (X-Y) mod 90,!. perp(_,_,_).

/* 1 */ /* 2 */ /* 3 */ /* 4 */ /* 5 */ /* 6 */

The program describes a network for recognition of planar four-side geometric gures. The gures are represented as a collection of edges with parameters - written as free nodes. The shared variables in these nodes represent the common vertices and the geometric constraints (parallel and same-length edges). The variables, grouped in the spreading activation nodes, represent a "part-of" hierarchy. Thus, unifying the free nodes with the nodes of a particular instance, the bound net-variables activate the corresponding class of gures. The example shows a way of using hidden nodes in such networks. Node 2 is activated when the net-variables S1 and S2 (representing the slopes of the corresponding edges) are bound. If the condition for perpendicularity is present, then the procedure "perp" binds the net-variable P, thus activating the "perpendicular" classes and suppressing the "non-perpendicular" ones (because of the inhibitory link ~P). The network is activated by specifying the edges of sample gures as a net-clause query. The corresponding class is obtained by the free node " g". Some examples of the network activation are shown below: