COMPOUND MODULES AS GOALS INFORMATICA 3/1988 UOK 681.3.06 PR0L0G:519.682 Monika Kapus-Kolar IJS, Ljubljana Osnovna objektna interpretacija jezikov tipa Prolog je kreiranje in brisanje modulov. Nekateri jeziki te družine (npr. Delta Prolog) uvajajo vzporedno/zaporedno kompozicijo in eksplicitno komunikacijo, zaradi česar so primerni za specifikacijo komunikacijskih protokolov. Najvažnejša ideja pričujočega dela je ločitev pojma modula od pojma cilja, tako da lahko vsak modul sodeluje v več ciljih (sestavljenih modulih). Jezik Hornovih stavkov z vzporedno/zaporedno kompozicijo atomičnih dogodkovnih in nedogodkovnih ciljev smo dopolnili z novimi sintaktičnimi elementi, ki v luči nove izvedbene semantike omogočajo bolj jedrnato specifikacijo komunikacijskih protokolov, posebno tistih, pri katerih so potrebne številne operacije na posamezni zapleteni podatkovni strukturi. Jedrnatost dosežemo s temeljito izrabo možnosti, ki jih nudi struktura sestavijenih modulov, ki je ponavadi precej preprostejša kot sintaksa atomičnih modulov. The basic object paradigm of Prolog-type language modu les. Some languages of the farnily (e.g. De lel/3equential composition and explicit communic table for specification of communication protocol the paper is separation of the "module" concept f that a module may participate in several goal svntactic enhancements have been proposed for t with parallel/3equential composition of atomic which in the light of the new operational semant specification of protocols, particularlv those r on a complicated piece of data. The core idea exploitation of the structure of compound modules simple than the 3yntax of atomic modules. s is creation and deletion of Ita Prolog) introduce paral- ation, what makes them sui- s. The main contribution of rom the concept of "goal", so s (compound modules). Some he language of Horn clauses event and non-event goals, ics provide for more concise equiring multiple operations of the new language is full vjhich is usually much more 1. Introduction The basic idea behind languages of the Prolog faniily is to find solutions to a problem (goal) by its reduction into more and more trivial subproblems (subgoals). A Prolog program, [4], is a set of universally quantified first order axioms (Horn clauses) of the form A:- Bi.Ba,...,Bo vhere the fl and the B's are atomic formulae, also called atomic goals. A is called the clause's head and the B's are called its body. The computation proceeds by selection of a goal Al frora the current conjunctive goal (Ai.Aa Am), which is then reduced with a selected clause A' :— Bt , B3, . . . ,Bi« where A and A' must be unifiable via the most common substitution 6. The reduction step transforms the current goal into (Al ,Ai_i,Bi,...,Bw,Ai-. ,A„)e. In the process of unification, some of the variables of the initial goal are assigned values, vjhich constitute • the output of the computation. The computation terminates suc- cessfully, when the initial goal is reduced into an empty goal, but may terminate unsuc- cessfully, if no further reduction is possible, or not terminate at ali. Several successful computations of a program may exist, resulting from various selections of clauses for reduc­ tion . Graphical representation of a Prolog program is an AND/OR tree with AlfD nodes mode 11 ing compo­ sition of goals into a clause body and OR nodes enumerating the suitable clauses for reduction of a particular goal. Several goals can be reduced in parallel (AND-parallelism) and seve­ ral alternative solutions searched for in pa­ rallel (OR-parallelism). True concurrency is allowed, if atomicity of reduction steps is preserved. The inherent AND-parallelism of Prolog programs makes them suitable for operational specifica- tion of communication protocols. An AND subtree of the AND/OR tree mode Is a particular execu- tion of a system, while the search of the entire AND/OR tree represervts verification of ali ' possible behaviours of the system. Note, that logic programming is also suitable for axiomatic specification and verification of communication protocols, but the paper does not deal with this aspect. The language has two major deficiencies: First, by introducing AND-parallelism, the execution order is controlled by the goal-subgoal rela- tion only, ao it is difficult to deacribe 3equential protocols. Second, communication between goals is implicit and asynchronous via coOTDon variables, vhile partners in communica­ tion protocols are usually loosely coupled (not sharing any variables). To solve the first problem, many Prolog-type languages (e.g. Delta-Prolog (DP) [6,7]. Con- current Prolog (CP) [5], M-Prolog [9]) maJ cl{LS.A d)#M; (event goal - true; reduction atate - no-reduction) # execution-ordering relations: 1,composition operator: ((a), (alb), (a;b;c), (alblcld)) < {(b), (C), (d); (bic), (c;d), (blc:d)) 2.composition operator: <(c), (d)) < {(bic), (alblc), (bicid), (a,'blc;d)> 3.composition operator: ((a), (b), (c)> < ((d), (cld). (blcld), (a!b:c:d)) ignored relations: <(b)< >(a;b:c;d) , (c)<>(a;b:c), (c)<>(a:b:c:d), (d)<>(a;b:c), (d)<>(a:blc:d)> Fig.2; The execution-ordering role of compoaition operators. A compound module may be a exclu3ive composition of exclu3ive forms of the paral le 1 composition ope while their exclu3ive f respectively. Each module position of moduleg is att (drawn from the set of al representing the guard section 5 and Fig.3 for an non-exclu3ive or an modu les. The non- sequential and the rator are I and I 1 , orms are / and //, of,an exclu3ive com- ached a set of goals 1 goals of the node) of the module (see example). body: (((a#M: (reduction state - pending; reduction type - weak-common)# lb#M: event goal - true* ) I c ld#M: event goal - true* )((ll)M] // (e#M: (reduction state reduction type • pending; weak-common)# :f ig :h#M: ) // (i#M: :j#M: ) event goal - true* (reduction state - pending; reduction type - weeik-common) * event goal - true* )#M: reduction state - no-reduction; WM: event goal - true* scenario: execution of event goal (((a;b)lc:d)//(e;flg;h)//(i:j)) -> ((aibjicid) not ready for selection, (elfigih) and (ilj) ready for selection -> the node transformed into (elfigih) or into (ilj) -> execution of event goal (h) (or event goal (j)) Fig.3: An example of a guarded command. After the guard of a module has been executed. the next operation on the module may only be its selection for further execution or its deletion from the 3y3tem. Several roodules with executed guards may exi3t, but exactly one of them is selected non-deterministically and the entire exclu3ive composition of modulea repla- ced by the selected module, which from that moment behaves like an ordinary. module. Because guards are regular processes of a 3ystem and one of the modules in exclusive composition disrupts the others, this is a model of process disruption, more general than the one of LOTOS. 3.3. Ex«cution of Reduction Goala In DP, a reduction goal is executed either by the ordinary type of reduction (reduction of a goal into more and more trivial subgoals), or by partjcipation in an event as exactly the whole event goal. In our language, a reduction goal can also be executed in event, where it is just a submodule of the relevant event goal. Hence, according to this criterion, there are three types of reduction. 1. On-the-apot reduction is the ordinary type of reducCion and could serve for specifying an internal process of a node. It may be non- trlvlal or trivial. Reduction of an atomic module is non-trivial, as it potentially crea- tes descendants in the architectural tree. Reduction of a compound module is trivial, as it is just an observation that ali the reduc­ tion goals within the module have been execu- ted. 2. Strong comnon reduction teOtes plače, when a module is a reduction goal and an event goal at the same time (the DP-type event goal). When the event goal is executed, the reduction goal is executed, too. The adjective "common" steams from the fact that the participants can execute the reduction as a coianon action, without any of them executing the reduction on the spot. Common reduction could serve for exchange of values of any origin. 3. W«ak conison reduction is like strong common reduction, but the reduction goal may also be just a submodule of the relevant event goal. To . facilitate observation of final (exit) results of modules, we introduce a fourth type of reduction, which is a weak common reduction with some additional requirement3: 4. Obaojrved reduction takes plače, when a reduction goal participates in an event, in of the participating event goals submodule, unifiable with the reduc- That submodule must be an executed goal with reduction type "on-the- must have been unified with such a goal in one of the previous events. In thia way, the node does not have to execute the reduction goal on the spot (that might be a difficult operation, if the event goal is atomic), but just gathers the necessarv results by observing someone, who has already executed a matching goal on the spot or has learned the results from another node. Observation of exit results is important from several aspect: First, it can strongly reduce the execution effort. Second, it can reduce non-determinism by forcing various nodes to accept the same solution to various incarnations of the same problem. Thlrd, it could serve to implement monitors of overall system activity. Fourth, the concept of exit results is another step towards LOTOS. On-the-spot reduction may be thought of as being executed in the node, containing the which one contains a tion goal. reduction spot" or reduction goal, observed reduction as executed in another node and common reduction as execu- ted in the space between nodes. Observed and cominon reduction are treated as trivial, as they do not create deacendants. At the tirne of its creation, each module is assigned its reduction type and state. The possible reduction type3 are the four tvpes, declared above. The possible states are "executed", "pending" and "no-reduction". If a module is a reduction goal, its initial reduction state is "pending" and its initial reduction type may be any type. If a module is not a reduction goal, its initial reduction state is "no-reduction" and its reduction type is "weak-common". Vfhen a reduction goal is executed, its reduction state is set to "executed". If reduction type of a reduction goal is "strong-common", the module is an event goal by definition. If reduction type of a reduction goal is "observed" or "wea)<-common" and the module is not a submodule of any event goal, it is an event goal by definition. Implicit modules are never able to propagate exit results of an on-the-spot reduction. while explicit modules are alwaya able to do that. When created, reduction goals with the reduc­ tion type "on-the-spot" are assigned unigue reduction identifiers. Reduction identifiers of other modules are undefined, until they begin to propagate results of an on-the-spot reduc­ tion. In that čase, their reduction type and state are set to "on-the-spot" and "executed" and their reduction identifier is set to the identifier cf the reduction fhey propagate. Reduction identifiers have been introduced to distinguish among various incarnations of a procedure and to facilitate specification of events with a limited number of active roles, in which the participating event goals may enroll (aee section 5 for the example in Fig.7). Each atomic reduction goal with reduction type "on-the-spot" is attached a predefined or user- vrritten procedure for unification with clauses' heads. Similarly, heads are attached procedures for unification with reduction goals. Such procedures may be treated as sets of con- straints. A necessary condition for reduction of a reduction. goal with a particular clause is, that their proposed constraints can be satisfied simultaneously. The reduction is exe- cuted exactly according to the constraints, proposed by the goal or the head. The default unification procedure is the most common sub- stitution. 3imultaneou3ly. The event is executed exactly according to the constraints, proposed by at least one participant. When a group of event goals is ready to execute a common event, the pending event is created in the sy3tem as a free module, vhich may (or may not) later be executed (deleted from the 3ystem). Each of the participating event goals (according to its synchronization requirements) may be executed simultaneou3ly with the event or before the event, but never after the event. Event goals remain formal participants of an event, until the event has been executed, even if they have already been executed or even deleted from the system. If not forbidden by the exi3ting participants, new participants (sometimes even an unlimited number . of them) may join with tirne. In that čase, a partici­ pant, which has not requested an iinmediate execution, can not be executed while new parti­ cipants could potentially change its execution results (e.g. if they could assign some of its remaining variables). Regardless the type of the execution procedure, an event must manda- tory execute aH reduction goals, that are aubmodules of the participating event goals, and must not introduce any new tight coupling of nodes. We propose to cla33ify requirement3, posed by execution procedures, into those considering 1. the number of participants, ' 2. timing relations (e.g. 3ynchronization, delay3), 3. relation between the state of the partici­ pants before and after the event, and 4. potential side-effects. The proposed defaults are: any non-zero number of participants, full •3ynchronization (ali event goals executed simultaneously with the event), no speci al side-effects and the third relation defined by the following unification procedure: The procedure first tries to malce the partici­ pating event goals unifiable via substitution. together with a legal distribution of roles. If it succeeds, the event goals are unified via substitution and their pending reductions . exe- cuted. The exclusive • and the non-exclu3ive version of composition operators are treated as equivalent. To make the event goals unifiable via substitu­ tion, the procedure may apply to them the following transformations, which are not visible after the event: 3.4. Executlon of Event Goals - permutation of modules in parallel composi­ tion. An event goal can execute, if it meets a group of suitable event goals. Execution must be fair in the sense that an event goal, which is ready to execute, must not wait indefinitely, if suitable groups keep occurring, and must be allowed to join a group, vhich is able to accept it. If there is more than one suitable group, the event goal selects between them non- deterministically. While an event goal is wai- ting for execution, its variables might be getting assigned by other goals, so its selec- tivity improves with tirne. Each event goal is attached a predefined or user-written procedure for its execution. A nece3sary an sufficient condition for a group of event goals to realize an event is, that their proposed constraints can be satisfied - grouping of modules (creation of explicit modules for the t ime of the execution of the event). The new modules are neither reduction nor event goals and are unable to propagate results of an on-the-spot reduction. The first transformation type supports the idea of using parallel and sequential composition operators for data ordering and reflects the fact that modules in parallel composition are not ordered. The second transformation type facilitates structured observation of unstruc- tured data. Usually, an event goal (EG) can be transformed in several way3 to meet the requirements. In that čase, the selection betveen the transfor- mations is non-deterministic and the procedure acts as a generator of permutations of modules (e.g. Fig.4). l.EG: (A!IB) - ready to receive data into A and B 2.EG: (a,'lb) - ready to send data-items a and b posgible tranaformations before unification and the resulting EG: l.EG 2.EG l.EG after unification A B 1. (Al;B) (alIb) (alIb) 2. (AlIB) (bila) (bila) 3. (BI lA) (al!b) (b! I a) 4. (BllA) (bila) (alIb) Fig.4: An event, whlch does not preserve the order- of data. When the event goals have been made unifiable via substitution, sets of correaponding modules can be identified (e.g. Fig.5). We are interea- ted only in the explicit modules of the event goals (the event goals themselves are treated as explicit modules). l.EG: (al(biICIId)) 2.EG: (al(XIIclId)) sets of corresponding modules: ((a), (a)); {(b),(X)); ((C), (O); {(d) , (d) ) {(blIClId),(XIICIId)}; {(al(biICIId)).(al(XIIclId))> Fig.5: An example of sets of corresponding modules. differs from the default procedure for unifying atomic goals with clause heads only in the way of unifying variables, which remain unassigned in the event: The corresponding variables are not unified into a single variable, but retain their identities to prevent tight coupling of loo3ely coupled modules. The modules of the event goals, which have a corresponding module with the reduction type "on-the-3pot" and are able to propagate results of an "on-the-3pot" reduction. are aasigned this property. 4. The Problem of Verlflcatlon The ease of verification of specifications in the new language depends on the nature of procedures for execution of goals. For the čase of the proposed default procedures we provide some basic guidelines, how clauses of the language could be converted into the farniliar and widely treated form with just atomic event and non-event goals, the classical parallel and sequential composition, guarded 3equences of goals and 3ynchronou3 events. which reguire just pure unification. The behaviour of a node can be represented as a set of possible execution seguences of "on-the- spot" reduction goals and event goals. If a reduction goal is executed simultaneou3ly with an event goal, it is not represented separa- tely. As goals are not executed more than once, the set is finite and so are the 3equences. Hence, they can be specified with the classical composition operators and guards. Each event goal is then replaced by an OR composition of ali its forms, that can be generated by grou- ping and permutation of submodules. Changing any term into an atomic goal is juat a 3yntac- tic operation, but an exotic component of the language stili remains, naniely the procedure for execution of event goals. A distribution of roles betveen the participa- ting event goals is legal if the distribution of reduction type3, states and identifiers of the corresponding modules is legal for ali sets of corresponding modules. We define the procedure for checl, enumerating some execution- ordering relations in the form SKS2 (the goals of the set SI must be executed before the goals of the set S2) . AH specified sets of modules are implicitly in intersection with G. e) Each module in an exclusive composition may be folloved by a comment (.. ], 3pecifying its guard. Ali specified sets of modules are impli­ citlv in intersection with G. f) The defaults are those, proposed earlier in the paper, plus: - Modules are not event goals. - Atomic modules are reduction goals with reduction type "on-the-spot". - Compound modules are not reduction goals. - Execution-ordering relation of I and / opera- tors: {A.RG.LS processl(X,Y) ) . processl(X,Y):- receiver2:- ((a(X):;b(Y) )#WM: (reduction tvpe - strong-common; reduction state - pending); A; reduction type - observed* l(> wait2#M: (event goal - true; reduction state - no-reduction; participants - 2)* ;{LS processl ) . processl:- active2:- (( a(X) lla(Y)#M: reduction type - obaerved* llb(Z)#M: reduction type - obaerved* )#WM: event goal - true# 1{LS process3 ) . proce333:-. Fig.7: Distribution of data from aeveral sources and the concept of roles. Example in Fig.7: A svnchronous evenf is speci- fied, involving collection of data-itema from aeveral sources, tnerging of data into a com­ pound mesaage and its dissemination to ali modules of the svstem. activei and actlve2 wi11 wait for each other to execute the firat event, but will not wait for the passive observer if its event goal ia created to late. If the event was asvnchronous, alloving an unlimited number of participants, the passive observer could receive the message regardleas of the execution speeda. There are three roles in the event (a, a and b), the first played by aotive2 and the others by activei. The concept of reduction has been separated from the concept of event by introducing inde­ pendent promotion of modules into reduction goals or into event goals. Reduction goals have as well been assigned the execution-ordering role. To indicate to which extent the execution of a reduction goal depends on execution of an event goal, four reduction tvpea have been introdu- ced: on-the-apot reduction, atrong cotrmon reduction, weak common reduction and observed reduction. The most original one is the obaer­ ved reduction, which could aerve for apecifving observation of exit reaults, for apecifving eventa with a limited number of roles. for reduction of the computational effort, for reduction of non-determinism and for implemen- tation of monitors of the overall svstem acti- vitv. The paper indicates, hov the architectural and the behavioural aspect of a svstem can be unified into a aingle semantic model and effi- cientlv apecified by a simple language. References aender:- (Address#M: event goal - true* ;(LS Ccimputer applications ' ParaltelarKj concurrent programming ' Operatlng system$ and databases ' Softwareengineering ' Real-time8ystems • Artificial intelligence • Supercomputtng ' Computer Vision • Rcbotics ' Alprogrammingartdenvironment ' Software aystems > Localareanetvvorks • Optimlzlngcompilors Threo tutoriaJs wll| be presented by teadtng experts In the fieid. Tentative topics are: Advanced Computer Archilecture, Parallel Computers and Artificial Intaltigenc«. SUBMtSSION OF PAPERS Flve copfes of a 400-word summary Notiflcation of authors Full papers In camera-ready form Confererx» JunelS. 1988 July15.1988 Oclober 1.1988 December 14-16.1988 Ali papers shall be reviewed for possible publication In or« o1 the ISMM journals: International Journal of Mini and Microcomputars, and Microcomputer Applications. IKTERNATX>NAL PROGRAM COMMrTTEE G. Rabbat, General Chairman B. Furht. Proorain Chairman P. Alpar M. Carapic R. BteianI E. Femandez 0. Gulch M. Hamza C.C. Hsu T. lahlko U.S.A. U.SJV. U.S.A. U.SA U.SA U.S.A. U.S.A Canada R.O.C. Japan M. Kabuka P. Uu E. Luque N. Marovac G. Mastronardi J.D. Meng V. Mllullnovic D. Motdovan S.C. Moon B.N. Naumov U.S.A. U.S.A Spain U.S.A. ltaly U.S.A. U.S.A. U.S.A. Korea U.S.S.R. V. Oklobdzlja D. Pattovic A.M. Salem B. Soucek W.V. Subbara/o D. Tabak M. tapia J. Urtan F. Vaida P. Visuri M. Vuskovic U.S.A U.S.A. Egypl U.S.A. U.S.A. U.S.A. U.S.A. U.S.A. Hungary Rnland U.S.A. AODRESS For correeporKienco, submisslon of exterxtod summaries, and to be placed on the mailing list, write to: Or. B. Furhl, Director of Advanced Techr>olo9y. Modcomp, 1650 West McNab Road, P.O. Box 6099. Mali Stop 850, Ft. Uuderdale, FL 33340-6099, U.S.A. Please comptete and retum this form to: ISMM SecretaHat, P.O. Box 25, Calgary. Alberta, Canada T3A 2G1 Ptease sand me Information corv»mlng: Q The Intemallonal Joomal of Mini and Microcomputers • Microcomputer Applications Journal O The International Jourr^ of Robotlcs and Aulomation Q Expen 5ystems, Los Angeles, December 1988 Q Computer Appllcatioris in Design Simulation and Analy5is, Reno. Nevada, U.S.A.. FebruaTy 1988 Q Reliabil)ty and Ouallty Control, Los Angeles, December 1988. O SefxJ me caJI for papers to conferences in the following areas: