i n f s y s - tu wien · i n f s y s r e s e a r c h r e p o ... although mcss and related...

56
INFSYS R ESEARCH R E P O R T Institut f ¨ ur Informationssysteme AB Wissensbasierte Systeme Technische Universit¨ at Wien Favoritenstraße 9-11 A-1040 Wien, Austria Tel: +43-1-58801-18405 Fax: +43-1-58801-18493 [email protected] www.kr.tuwien.ac.at I NSTITUT F ¨ UR I NFORMATIONSSYSTEME ARBEITSBEREICH WISSENSBASIERTE S YSTEME D ISTRIBUTED E VALUATION OF N ONMONOTONIC MULTI -C ONTEXT S YSTEMS MINH DAO-TRAN THOMAS EITER MICHAEL F INK THOMAS KRENNWALLNER INFSYS RESEARCH REPORT 14-03 SEPTEMBER 2014

Upload: others

Post on 06-Jun-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

I N F S Y SR E S E A R C H

R E P O R T

Institut fur Informationssysteme

AB Wissensbasierte Systeme

Technische Universitat Wien

Favoritenstraße 9-11

A-1040 Wien, Austria

Tel: +43-1-58801-18405

Fax: +43-1-58801-18493

[email protected]

www.kr.tuwien.ac.at

INSTITUT FUR INFORMATIONSSYSTEME

ARBEITSBEREICH WISSENSBASIERTE SYSTEME

DISTRIBUTED EVALUATION OF

NONMONOTONIC MULTI-CONTEXT

SYSTEMS

MINH DAO-TRAN THOMAS EITER

MICHAEL FINK THOMAS KRENNWALLNER

INFSYS RESEARCH REPORT 14-03

SEPTEMBER 2014

INFSYS RESEARCH REPORT

INFSYS RESEARCH REPORT 14-03, SEPTEMBER 2014

DISTRIBUTED EVALUATION OF NONMONOTONIC MULTI-CONTEXT

SYSTEMS

Minh Dao-Tran1 Thomas Eiter1 Michael Fink1 Thomas Krennwallner1

Abstract.Multi-Context Systems (MCSs) are a formalism for systems consisting of knowledgebases (possibly heterogeneous and non-monotonic) that are interlinked via bridge rules, where theglobal system semantics emerges from the local semantics of the knowledge bases (also called “con-texts”) in an equilibrium. While MCSs and related formalisms are inherently targeted for distributedsettings, no truly distributed algorithms for their evaluation were available. We address this short-coming and present a suite of such algorithms which includes a basic algorithm DMCS, an ad-vanced version DMCSOPT that exploits topology-based optimizations, and a streaming algorithmDMCS-STREAMING that computes equilibria in packages of bounded size. The algorithms behavequite differently in several respects, as experienced in thorough experimental evaluation of a sys-tem prototype. From the experimental results, we derive a guideline for choosing the appropriatealgorithm and running mode in particular situations, determined by the parameter settings.

1Institut fur Informationssysteme, Technische Universitat Wien, Favoritenstraße 9-11, A-1040 Vienna, Austria;email: {dao,eiter,fink,tkren}@kr.tuwien.ac.at.

Acknowledgements: This research has been supported by the Austrian Science Fund (FWF) project P20841.Some of the results were presented in preliminary form at KR 2010 [Dao-Tran et al., 2010],JELIA 2010 [Bairakdar et al., 2010b], and LogiCS 2011 [Dao-Tran et al., 2011].

Copyright c© 2014 by the authors

2 INFSYS RR 14-03

Contents

1 Introduction 2

2 Preliminaries 52.1 Multi-Context Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.2 Semantics of multi-context systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

3 Basic Algorithm (DMCS) 93.1 Basic notions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93.2 The basic algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103.3 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

4 Topology-Based Optimization Algorithm (DMCSOPT) 164.1 Running Scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164.2 Decomposition of Nonmonotonic MCS . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194.3 Query Plan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224.4 Evaluation with Query Plans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

5 Streaming Equilibria (DMCS-STREAMING) 245.1 Basic Streaming Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255.2 Parallelized Streaming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

6 Experimental Evaluation 306.1 Benchmark Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306.2 Experiments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326.3 Observations and Interpretations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

6.3.1 DMCS vs. DMCSOPT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326.3.2 Streaming v.s. non-streaming DMCS . . . . . . . . . . . . . . . . . . . . . . . . . 336.3.3 Effects of the package size in streaming mode . . . . . . . . . . . . . . . . . . . . . 356.3.4 Effect of topology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356.3.5 Behavior on deterministic contexts . . . . . . . . . . . . . . . . . . . . . . . . . . . 366.3.6 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

7 Related Work 37

8 Conclusion 38

1 Introduction

In the last decade, there has been an increasing interest in systems that comprise information from multipleknowledge bases. This includes a wide range of application fields such as data integration, multi-agent sys-tems, argumentation and many others. To picture a more concrete real-world application, we may considerMETIS [Velikova et al., 2014], an industrial prototype system for facilitating timely human decision makingin maritime control. In this application, human operators need support to determine whether a ship enteringa port might hide its identity for illegal activities or might be a high risk for environmental hazard. To access

INFSYS RR 14-03 3

such risks, METIS relies on a number of heterogeneous external information sources such as the commercialship database IHS Fairplay,1 ship tracking websites,2 and news items for history of pollution events the shipmay have been involved in.

The rise of the Word Wide Web and distributed systems has propelled this development, and to date sev-eral AI-based formalisms are available to host multiple, possibly distributed knowledge bases in a compoundsystem. Well-known such formalisms are distributed SAT solving [Hirayama and Yokoo, 2005], distributedconstraint satisfaction [Faltings and Yokoo, 2005, Yokoo and Hirayama, 2000], distributed ontologies indifferent flavors [Homola, 2010], MWeb [Analyti et al., 2011], and different approaches to multi-contextsystems [Giunchiglia and Serafini, 1994, Ghidini and Giunchiglia, 2001, Brewka et al., 2007, Brewka andEiter, 2007, Bikakis and Antoniou, 2010] rooted in [McCarthy, 1993] work; among then, we focus here onHeterogeneous Nonmonotonic Multi-Context Systems (MCSs) [Brewka and Eiter, 2007].

As a generalization of previous proposals, MCSs are a powerful formalism to specify systems of knowl-edge bases that may have different formats and reasoning powers, ranging from simple query answering overa relational database to reasoning over description logic knowledge bases (see [Baader et al., 2003]), as wellas to nonmonotonic formalisms such as default logic [Reiter, 1980] or answer set programs [Gelfond andLifschitz, 1991]. To allow for heterogeneous knowledge bases and to deal with the impedance mismatchbetween them, MCSs abstract knowledge bases to plain mathematical structures; on top, special bridgerules interlink the knowledge bases, where a bridge rule adds a formula to a knowledge base, depending oncertain beliefs at other knowledge bases. Hence the semantics of a knowledge base with associated bridgerules, which forms a context), depends on the other contexts, possibly in a cyclic manner. Based on this,MCSs have an equilibrium semantics in terms of global states in which every context adopts an abstract“local model,” called belief set, that is conformant with the local models adopted by the other contexts andin addition obeys the bridge rules. The following simple example, which is a paraphrase of [Ghidini andGiunchiglia, 2001] Magic Box, illustrates the power of this idea,

Example 1 Suppose that in a computer game, players Batman and Robin chased player Joker to a partiallyoccluded area, as shown in Figure 1; Robin is wounded and cannot read his distance to objects. NeitherBatman nor Robin can tell Joker’s exact position on the 3×3 box: Batman can only assure that he is notin columns 2 and 3, while Robin can only tell that he is on row 1. However, if they exchange their partialknowledge, they can pinpoint Joker to row 1 and column 1.

We can model Batman and Robin as contexts whose local knowledge bases include their informationabout Joker’s position, which is exchanged using bridge rules, such as at row(X)← (2 : at row(X)). forBatman, which informally “imports” the Robin’s knowledge (context 2) about row positions; a full encodingis given in Example 2. The equilibrium of the emerging MCS discloses then Joker’s position to both Batmanand Robin.

Although MCSs and related formalisms inherently target distributed systems, no truly distributed al-gorithms for computing equilibria of MCSs were available. [Brewka and Eiter, 2007] encoded equilibriainto HEX-programs [Eiter et al., 2005], which can be evaluated using the dlvhex solver. However, while thisapproach elegantly offers full heterogeneity, it is fully centralized and needs technical assumptions. [Roelof-sen et al., 2004] had proposed earlier an algorithm to check satisfiability of homogeneous, monotonic MCSwith a centralized control that accesses contexts in parallel (hence is not truly distributed). [Bikakis andAntoniou, 2010] instead gave a distributed algorithm for their defeasible multi-context systems; however,

1www.ihs.com/products/maritime-information/2marinetraffic.com, myship.com

4 INFSYS RR 14-03

Figure 1: Pinpointing Joker

the latter have homogeneous (possibly nonmonotonic) contexts with a particular type of semantics, and thealgorithm serves query answering but not model building.

The lack of distributed algorithms for evaluating MCSs based on local context handlers is due to severalobstacles:• the abstract view of local semantics as belief sets limits for an algorithm at the global level interference

with the knowledge bases and the evaluation process at each context.

• Towards real life applications, certain levels of information hiding and security are required (e.g. forinformation exchange between knowledge bases of companies) such that only selected information is trans-ferred between contexts via well-defined interfaces. This prevents a context from getting more insight aboutits neighbors for optimization, for instance to learn conflicts (i.e., joint beliefs leading to contradiction)across contexts.

• The MCS system topology, i.e., the structure of context linkage, might be unknown at a context; thisdisables decomposing the system for more efficient, modular evaluation.

• The bridge rules might fuel a cyclic information flow through a group of contexts. Even if each con-text is easy to evaluate (e.g., all knowledge bases are acyclic logic programs), such global cycles requirenontrivial care.

In this article, we address these obstacles and present results towards efficient distributed evaluation ofMCSs. Our main contributions are a suite of generic algorithms DMCS, DMCSOPT, and DMCS-STREAMINGwhich work truly distributed, and their implementation in a system prototype. In more detail, the contribu-tions are as follows.

Algorithms and optimization techniques. (1) Our first, basic algorithm DMCS aims at full distributed-ness, and we deal with the obstacles above in a generic way: contexts just exchange belief sets and thecall history (i.e., the access path traversing bridge rules), but no further information. At the global level,belief states are formed as tuples of belief sets; each context with bridge rules must respect the belief sets

INFSYS RR 14-03 5

of its neighbors when computing its own belief sets using a local solver for its knowledge base. Cycles aredetected from the call history, if a context gets a request and finds itself in the call history; to break a cycle,a guessing technique is used with checks on the return path.

(2) By localizing a context’s knowledge about the system and information exchange, DMCS can fairlyeasily adapt to context changes (additions or deletions), but at the same time faces some scalability issues.To enhance the performance in an optimized version DMCSOPT, we disclose meta-level information tocontexts, viz. (i) the topology of context dependencies, which is exploited for decomposing the MCS intosub-MCSs (blocks) that are linked in a block-tree, and (ii) the interface between contexts, for optimizing thedata transfer between blocks. Here (i) breaks cycles in advance and (ii) significantly reduces duplicate localevaluation; each yields a remarkable performance gain.

(3) Still as DMCS and DMCSOPT compute all equilibria of an MCS, they can not escape from scal-ability and memory issues, as multiple local belief sets can lead to combinatorial explosion at the globallevel. We thus consider computing equilibria in a streaming mode; to this end, contexts pass their beliefsets not in one shot to their parents but gradually in small packages. Memory blowup can be thus avoidedand moreover contexts can continue earlier than when they wait for all answers from all neighbors. Thisapproach seems more user-friendly as equilibria gradually appear rather than all at once, possibly after longtime; and one may quit the computation after seeing sufficiently many results (i.e., equilibria).

Implementation and experiments. We have implemented the algorithms in a system prototype. To assessthe effects of the optimization techniques, we have set up a benchmarking system and conducted compre-hensive experiments with MCSs of various topologies and interlinking. The results confirm our expectationof the optimization techniques in general; in a nutshell, (i) the decomposition technique clearly improvesthe performance in the non-streaming mode; (ii) streaming is worthwhile as it may still find answers whilenon-streaming times out; (iii) for streaming, choosing the package size is very important; (iv) the systemtopology is important as some optimization techniques show drastic improvements for specific topologies;(v) sometimes, the techniques yield no gain but incur overhead.

The results of this work provide not only truly distributed algorithms for evaluating MCSs, but throughthis also for distributed versions of non-monotonic knowledge base formalisms as such (e.g., for distributedanswer set programs), and the underlying principles and techniques might be exploited in related contexts.Furthermore, they may provide a basis for the evaluation of extensions and generalizations of MCSs, suchas non-ground MCSs [Fink et al., 2011], managed MCSs [Brewka et al., 2011b], supported MCS [Tasharrofiand Ternovska, 2014], or reactive MCSs [Goncalves et al., 2014, Brewka et al., 2014].Organization. The remainder of this article is organized as follows. The next section provides pre-liminaries on Multi-Context Systems. Section 3 introduces the basic distributed algorithm DMCS, whileSection 4 develops the optimized algorithm DMCSOPT; Section 5 presents then the streaming algorithmDMCS-STREAMING. Experimental results of the prototype implementation are reported in Section 6. InSection 7, we consider related works, and in Section 8 we summarize and address further and open issues.To increase readability, proofs have been moved to the Appendix.

2 Preliminaries

2.1 Multi-Context Systems

This section briefly introduces the formalization of Heterogeneous Nonmonotonic Multi-Context Systems(MCSs) proposed in [Brewka and Eiter, 2007] and further described in [Brewka et al., 2011a], which serves

6 INFSYS RR 14-03

as the base of this work. The idea behind MCSs is to allow different logics to be used in different contexts,and to model information flow among contexts via bridge rules. The notion of logic is defined as follows.

Definition 1 ([Brewka and Eiter, 2007]) A logic L = (KBL,BSL,ACCL) is composed of the followingcomponents:

1. KBL is the set of well-formed knowledge bases of L, each of which consists of a set of elements calledformulas;

2. BSL is the set of possible belief sets, where each S ∈ BSL is a set of elements called beliefs; and

3. ACCL : KBL → 2BSL is a function describing the “semantics” of the logic, by assigning to eachelement of KBL a set of acceptable sets of beliefs.

This notion of logic is very generic, and it abstracts the formation of an agent’s beliefs to a bare min-imum. Structure of formulas (both in the knowledge base and the belief sets) is dismissed, and they areviewed as “naked elements.” Likewise no particular inference mechanism is associated with a knowledgebase, nor are any logical properties imposed on belief sets; the term “belief” reflects that statements held bythe agent might be on an epistemic basis, without going into further detail. The assignment of acceptablebeliefs sets to a knowledge base, each of which is intuitively a set of beliefs that an agent is willing to adoptgien the knowledge base, captures that in some logics (e.g., in nonmonotonic logics) multiple or even noacceptable belief sets are possible.

This abstract model allows us to capture a range of different logics for knowledge representation andreasoning, including classical logic, modal logics, epistemic logics, spatial logics, description logics etc,but also nonmonotonic logics such as default logic [Reiter, 1980] or answer set programs [Gelfond andLifschitz, 1991], in different varieties and settings; for a comparison to other formalisms, see [Brewka et al.,2011a]. For example, classical (propositional or predicate logic) may be modeled as follows:

• KB: the set of (well-formed) sentences over a signature Σ,

• BS: the set of deductively closed set of Σ-sentences, (i.e., Cn(S) = S, where Cn(·) denotes deduc-tive closure),

• ACC(kb): the singleton containing the deductive closure of kb, i.e., ACC(kb) = {Cn(kb)}.

For an example of nonmonotonic logics, (disjunctive) logic programs under answer set semantics [Gelfondand Lifschitz, 1991] can be modeled by

• KB: the set of logic programs over a signature Σ,

• BS: the set of consistent sets of literals over Σ,

• ACC(kb): the set AS (kb) of answer sets of kb according to [Gelfond and Lifschitz, 1991].3

We refer to this setting, which will be used repeatedly in the sequel, as Answer Set Programming (ASP).Note that answer sets of a knowledge base kb amount to particular 3-valued models of kb; this shows thatthe formalism is also flexible enough to capture for knowledge bases entailment reasoning (truth in allmodels) as well as possible world views (model generation), and many other forms of belief set formation.

Bridge rules. Based on logics, bridge rules are introduced to provide a uniform way of interlinkingheterogeneous information sources as follows.

3As common, we exclude inconsistent answer sets admitted in [Gelfond and Lifschitz, 1991].

INFSYS RR 14-03 7

Definition 2 (cf. [Brewka and Eiter, 2007]) Let L = {L1, . . . , Ln} be a (multi-)set of logics. An Lk-bridge rule over L, 1 ≤ k ≤ n, is of the form

s← (c1 : p1), . . . , (cj : pj),not (cj+1 : pj+1), . . . ,not (cm : pm) (1)

where (i) for each 1 ≤ i ≤ m, ci ∈ {1, . . . , n} and pi is an element of some belief set of Lci , and (ii) foreach kb ∈ KBk, it holds that kb ∪ {s} ∈ KBk.

Informally, bridge rules refer in their bodies to other contexts (identified by ci) and can thus add infor-mation to a context’s knowledge base depending on what is believed or disbelieved in other contexts. Incontrast to [Giunchiglia, 1992] multi-context systems, there is no single, global set of bridge rules; eachcontext knows only its own bridge rules.

Now that the means for connecting contexts is available, MCSs can be formally defined.

Definition 3 ([Brewka and Eiter, 2007]) A multi-context system (MCS) M = (C1, . . . , Cn) consists ofa collection of contexts Ci = (Li, kbi, br i) where Li = (KBi,BSi,ACCi) is a logic, kbi ∈ KBi is aknowledge base, and br i is a set of Li-bridge rules over {L1, . . . , Ln}.

Remark. Brewka and Eiter use a context Ci to identify itself in bridge rules of an MCS (i.e., in rule (1),Cci is in place of ci). To simplify matters and avoid naming issues, we use here (similar as in relationaldatabases) positional reference and use context names informally.

Example 2 (cont’d) The scenario from Example 1 can be formalized by an MCS M = (C1, C2), where inboth contexts L1, L2 are instances of Answer Set Programming, and:

• kb1 = F ∪ F1 ∪{

at col(X)← see col(X).¬at col(X)←¬see col(X).

}∪R,

• br1 =

{at row(X)← (2 : at row(X)).

¬at row(X) ∨ covered row(X)← not (2 : see row(X)), (1 : row(X)).

}• kb2 = F ∪ F2 ∪

{at row(X)← see row(X).¬at row(X)←¬see row(X).

}∪R,

• br2 =

{at col(X)← (1 : at col(X)).

¬at col(X) ∨ covered col(X)← not (1 : see col(X)), (2 : col(X)).

},

where

• F = {row(1). row(2). row(3). col(1). col(2). col(3).},• F1 = {¬see col(2). ¬see col(3).},• F2 = {see row(1).}, and

• R =

{joker in ← at row(X).joker in ← at col(X).

}∪

at row(X)← joker in, row(X), not ¬at row(X).¬at row(X)← joker in, row(X), at row(Y ), X 6= Y.

at col(X)← joker in, col(X), not ¬at col(X).¬at col(X)← joker in, col(X), at col(Y ), X 6= Y.

.

8 INFSYS RR 14-03

Here, X and Y are variables used in schematic rules, and they range over rows resp. columns (i.e., 1,2,3).Intuitively, C1 formalizes Batman’s knowledge about the scene and C2 that of Robin. In the knowledgebases kb1 and kb2, the facts F represent the box of size 3 × 3, while F1 and F2 state what Batman andRobin see, viz. that Joker is not in columns 2 and 3 respectively that he is on row 1. The next two rulessimply map sensed locations to respective facts. Informally, the rules in R make a guess on the row and thecolumn where Joker is, if he is concluded to be in the box (first two rules); this may lead to multiple beliefsets. Importantly, Batman adjusts his knowledge base depending on beliefs communicated by Robin (bridgerules br1) and vice versa (bridge rules br2).

2.2 Semantics of multi-context systems

The semantics of an MCS is defined in terms of special belief states, which are sequences S = (S1, . . . , Sn)such that each Si is an element of BSi. Intuitively, Si should be a belief set of the knowledge base kbi;however, also the bridge rules must be respected. To this end, kbi is augmented with the conclusions of itsbridge rules that are applicable. More precisely, a bridge rule r of form (1) is applicable in S, if pi ∈ Sci ,for 1 ≤ i ≤ j, and pk /∈ Sck , for j+ 1 ≤ k ≤ m. Denote by head(r) is the head of r. and by app(R,S) theset of bridge rules r ∈ R that are applicable in S. Then,

Definition 4 ([Brewka and Eiter, 2007]) A belief state S = (S1, . . . , Sn) of an MCS M = (C1, . . . , Cn)is an equilibrium, if Si ∈ ACCi(kbi ∪ {head(r) | r ∈ app(br i, S)}), for all 1 ≤ i ≤ n.

An equilibrium thus is a belief state which contains for each context an acceptable belief set, given thebelief sets of the other contexts.

Example 3 (cont’d) The MCS M in Example 2 has the single equilibrium S = (S1, S2) where S1 =F ∪F1∪F3 and S2 = F ∪F2∪F3 where F3 = {joker in, at row(1), ¬at row(2), ¬at row(3), at col(1),¬at col(2),¬at col(3)}. This equilibrium ideed reflects the intuition in the scenario in Example 1, whereBatman and Robin together can infer the location of Joker, while any single one of them cannot accomplishthis task without communication.

Example 4 Let M = (C1, C2, C3, C4) be an MCS such that all Li are ASP logics, with alphabets A1 ={a}, A2 = {b}, A3 = {c, d, e}, A4 = {f, g}. Suppose

• kb1 = ∅, br1 = {a← (2 : b), (3 : c)};• kb2 = ∅, br2 = {b← (4 : g)};• kb3 = {c← d; d← c}, br3 = {c ∨ e← not (4 : f)};• kb4 = {f ∨ g ←}, br4 = ∅.

One can check that S = ({a}, {b}, {c, d}, {g}) is an equilibrium of M .

The computation of equilibria for a given MCS has been realized by a declarative implementation us-ing HEX-programs [Eiter et al., 2005] which can be evaluated using the dlvhex system.4 The idea is totranslate an MCS into a HEX-program with (i) disjunctive facts for guessing the truth values of beliefs,(ii) HEX-rules for capturing bridge rules, and (iii) constraints with external atoms for capturing the accept-ability functions. For further details on a concrete implementation of this approach, we refer the reader to

4www.kr.tuwien.ac.at/research/systems/dlvhex/

INFSYS RR 14-03 9

In(1)

C1

C2 C3

C4

(a) Import neighborhood of C1

IC (1)C1

C2 C3

C4

(b) Import closure of C1

Figure 2: Import neighborhood and Import closure

[Bogl et al., 2010]. In this paper, we pursue a more sophisticated approach, i.e., we design and implementdistributed algorithms, to compute equilibria of MCSs. During evaluation, there is no centralized compo-nent that controls the communication between contexts. Each context independently runs an instance ofthe algorithm and communicates with each other to exchange beliefs as well as to detect and break cycles.These novel contributions are described in the next sections.

3 Basic Algorithm (DMCS)

This section introduces a very first, basic, truly distributed algorithm for evaluating equilibria of an MCS.The algorithm takes a general setting as input, that is, each context has a minimal knowledge about thewhole system; or in other words, it just knows the interface with direct neighbors (parents and childrencontexts) but not the topological information or any further metadata of the system. Under this setting,we concentrate on distributeness. Section 4 shifts the focus towards optimization techniques when moremetadata is provided.

Taking a local stance, we consider a context Ck and compute those parts of (potential) equilibria of thesystem which contain coherent information from all contexts that are “reachable” from Ck.

3.1 Basic notions

We start with some basic concepts. The import closure formally captures reachability.

Definition 5 (Import Closure) Let M = (C1, . . . , Cn) be an MCS. The import neighborhood of contextCk, k ∈ {1, . . . , n}, is the set

In(k) = {ci | (ci : pi) ∈ B(r), r ∈ brk}.Furthermore, the import closure IC (k) of Ck is the smallest set S such that (i) k ∈ S and (ii) for all i ∈ S,In(i) ⊆ S.

Equivalently, we can define the import closure constructively by IC (k) = {k} ∪ ⋃j≥0 IC j(k), whereIC 0(k)=In(k), and IC j+1(k) =

⋃i∈IC j(k) In(i).

Example 5 Consider M in Example 4. Then In(1) = {2, 3}, In(2) = In(3) = {4}, and In(4) = ∅; theimport closure of C1 is IC (1) = {1, 2, 3, 4} (see Figure 2).

10 INFSYS RR 14-03

S1

ε

S1

...

...

...

ε

ε

ε

...

...

...

ε

Ti

Ti

...

...

...

...

...

...

Sn

Tn

Sj

Tj

Sj(= Tj)

S =

T =

S ./ T =

Figure 3: Joining partial belief states

Based on the import closure we define partial equilibria.

Definition 6 (Partial Belief States and Equilibria) LetM = (C1, . . . , Cn) be an MCS, and let ε /∈ ⋃ni=1 BSi.

Then a sequence S = (S1, . . . , Sn) such that Si ∈ BSi ∪ {ε}, for all 1 ≤ i ≤ n, is a partial belief state(PBS) of M , and S is a partial equilibrium (PE) of M w.r.t. Ck, k∈{1, . . . , n}, if in addition i ∈ IC (k)implies Si ∈ACCi(kbi ∪ {head(r) | r ∈ app(br i, S)}), and i 6∈ IC (k) implies Si = ε, for all 1 ≤ i ≤ n.

Note that IC (k) essentially defines a subsystem M ′ of M that is connected by bridge rules. We use PEs ofM instead of equilibria of M ′ to keep the original MCS M intact.

For combining partial belief states S = (S1, . . . , Sn) and T = (T1, . . . , Tn), we define their join S ./ Tas the partial belief state (U1, . . . , Un) such that

Ui =

{Si, if Ti = ε or Si = Ti,Ti, if Ti 6= ε and Si = ε,

, for all 1 ≤ i ≤ n

(see Figure 3). Note that S ./ T is void, if some Si, Ti are from BSi but different. Naturally, the join of twosets S and T of partial belief states is then S ./ T = {S ./ T | S ∈ S, T ∈ T }.

Example 6 Consider two sets of partial belief states:

S = { (ε, {b}, ε, {¬f, g}) , (ε, {¬b}, ε, {f,¬g}) } and

T = {(ε, ε, {¬c,¬d, e}, {¬f, g}), (ε, ε, {c, d,¬e}, {¬f, g}), (ε, ε, {¬c,¬d,¬e}, {f,¬g})} .

Their join is given by

S ./ T =

{(ε, {b}, {¬c,¬d, e}, {¬f, g}), (ε, {b}, {c, d,¬e}, {¬f, g}),(ε, {¬b}, {¬c,¬d,¬e}, {f,¬g})

}.

3.2 The basic algorithm

Given an MCS M and a starting context Ck, we aim at finding all PEs of M w.r.t. Ck in a distributed way.To this end, we design an algorithm DMCS whose instances run independently at a node for each contextand communicate with each other for exchanging sets of partial belief states. This provides a method for dis-tributed model building, and the DMCS algorithm can be applied to any MCS such that appropriate solversfor the respective context logics are available. As a main feature of DMCS, it can also compute projectedpartial equilibria, i.e., PEs projected to a relevant part of the signature of Ck’s import closure. This canbe exploited for specific tasks like, e.g., local query answering or consistency checking. When computing

INFSYS RR 14-03 11

projected PEs, the information communicated between contexts is minimized, keeping communication costlow.

In the sequel, we present a basic version of the algorithm, abstracting from low-level implementationissues; the overall MCS structure is assumed to be unknown at context nodes. The idea is as follows: startingfrom contextCk, we visit its import closure by expanding the import neighborhood at each contextCi like ina depth-first search (DFS), until a leaf context is reached or a cycle is detected, by finding the current contextin the set hist of already visited contexts. A leaf context simply computes its local belief sets, transformsthem into partial belief states, and returns this result to its parent (invoking context, Figure 4a). In case ofa cycle (Figure 4c), the context Ci which detects must also break the cycle, by (i) guessing belief sets forits “export” interface, (ii) transforming the guesses into partial belief states, and (iii) returning them to theinvoking context.

An intermediate context Ci produces partial belief states that will be joined, i.e., consistently combined,with partial belief states of its neighbors; to enable this, Ci returns its local belief sets, joined with the resultsof its own neighbors (Figure 4b).

For computing projected PEs, the algorithm offers a parameter V called the relevant interface whichmust fulfill some conditions w.r.t. import closure that we next discuss.

Given a (partial) belief state S and set V ⊆ Σ of variables, we denote by S|V the restriction of S to V ,i.e., the (partial) belief state S′ = (S1|V , . . . , Sn|V ), where Si|V = Si ∩ V if Si 6= ε, and ε|V = ε; for a setS of (partial) belief states, we let S|V = {S|V | S ∈ S}. Next,

Definition 7 (Recursive Import Interface) For an MCS M = (C1, . . . , Cn) and k ∈ {1, . . . , n}, we callV (k) = {pi | (ci : pi) ∈ B(r), r ∈ brk} the import interface of context Ck and V ∗(k) =

⋃i∈IC (k) V (i) the

recursive import interface of context Ck.

For a correct relevant interface V , we have two extremal cases: (1) V = V ∗(k) and (2) V = Σ. In (1),DMCS basically checks for consistency on the import closure ofCk by computing PEs projected to interfacevariables. In (2), it computes PEs w.r.t. Ck. In between, by providing a fixed interface V , problem-specificknowledge (such as query variables) and/or infrastructure information can be exploited to keep computationsfocused on relevant projections of partial belief states.

The projections of partial belief states are cached in every context such that recomputation and recom-bination of belief states with local belief sets are kept at a minimum.

We assume that each context Ck has a background process (or daemon in Unix terminology) that waitsfor incoming requests of the form (V, hist), upon which it starts the computation outlined in Algorithm 1.This process also serves the purpose of keeping the cache c(k) persistent. We write Ci.DMCS(V, hist) tospecify that we send (V, hist) to the process at context Ci and wait for its return message.

Algorithm 1 uses the following primitives:

• function lsolve(S) (Algorithm 2): augments the knowledge base kb of the current context with theheads of bridge rules in br that are applicable w.r.t. partial belief state S, computes local belief setsusing function ACC, combines each local belief set with S, and returns the resulting set of partialbelief states; and

• function guess(V,Ck): guesses all possible truth assignments for the relevant interface w.r.t. Ck, i.e.,for Σk ∩ V .5

5In order to relate variables to context signatures, V can either be a vector of sets, or variables in V are prefixed with contextids; for simplicity, we kept V as a set without further assumptions.

12 INFSYS RR 14-03

C`

lsolve((ε, . . . , ε)) = S

(V, hist) S

(a) Leaf context

Ci

C` Cj

(V, hist)

(V, hist ∪

{i})S S

j

Si =⋃

S∈S`./Sjlsolve(S)

(b) Intermediate context

Ci

V

Cj

Ct

C`

hist={. . . , i, . . . }

(c) Cycle breaking

Figure 4: Basic distributed algorithm - casewise

DMCS proceeds in the following way:

(a) check the cache for an appropriate partial belief state;

(b) check for a cycle;

(c) if a cycle is detected, then guess partial belief states of the relevant interface of the context runningDMCS;

(d) if no cycle is detected, but import from neighbor contexts is needed, then request partial belief statesfrom all neighbors and join them;

(e) compute local belief states given the partial belief states collected from neighbors;

(f) cache the current (projected) partial belief state.

The next examples illustrate evaluation runs of DMCS for finding all partial equilibria with differentMCS. We start with an acyclic run.

Example 7 Reconsider M from Example 4. Suppose the user invokes C1.DMCS(V, ∅), where V ={a, b, c, f, g}, to trigger the evaluation process. Next, C1 forwards in (d) requests to C2 and C3, which

INFSYS RR 14-03 13

Algorithm 1: DMCS(V, hist) at Ck = (Lk, kbk, brk)

Input: V : relevant interface, hist : visited contextsData: c(k): static cacheOutput: set of accumulated partial belief states

(a) if c(k) is not empty then return c(k)

S := ∅(b) if k ∈ hist then // cyclic: guess local beliefs w.r.t. V

(c) S := guess(V,Ck)

else // acyclic: collect neighbor beliefs and add local ones

T := {(ε, . . . , ε)} and hist := hist ∪ {k}(d) foreach i ∈ In(k) do

if for some T ∈ T , Ti = ε thenT := T ./ Ci.DMCS(V, hist)

(e) foreach T ∈ T do S := S ∪ lsolve(T )

(f) c(k) := S|Vreturn S|V

Algorithm 2: lsolve(S) at Ck = (Lk, kbk, brk)

Input: S: partial belief state S = (S1, . . . , Sn)Output: set of locally acceptable partial belief states

T := ACCk(kbk ∪ {head(r) | r ∈ app(brk, S)})return {(S1, , . . . , Sk−1, Tk, Sk+1, . . . , Sn) | Tk ∈ T}

both call C4. When called for the first time, C4 calculates in (e) its own belief sets and assembles the set ofpartial belief states

S4 = {(ε, ε, ε, {f,¬g}), (ε, ε, ε, {¬f, g})} .After caching S4|V in (f), C4 returns S4|V = S4 to the context from C2, C3 whose request arrived first. Onsecond call, C4 simply returns S4|V to the other context from the cache.

C2 and C3 next call lsolve (in (e)) two times each, which results in S2 = S resp. S3 = T with S, Tfrom Example 6.

S = { (ε, {b}, ε, {¬f, g}) , (ε, {¬b}, ε, {f,¬g}) } and

T = {(ε, ε, {¬c,¬d, e}, {¬f, g}), (ε, ε, {c, d,¬e}, {¬f, g}), (ε, ε, {¬c,¬d,¬e}, {f,¬g})} .Thus,

S2|V = { (ε, {b}, ε, {¬f, g}) , (ε, {¬b}, ε, {f,¬g}) } and

S3|V = {(ε, ε, {¬c}, {¬f, g}), (ε, ε, {c}, {¬f, g}), (ε, ε, {¬c}, {f,¬g})} .C1, after computing in (d)

S2|V ./ S3|V = {(ε, {b}, {¬c}, {¬f, g}), (ε, {b}, {c}, {¬f, g}), (ε, {¬b}, {¬c}, {f,¬g})}

14 INFSYS RR 14-03

C1

V c(1) : S1

C2

c(2) : S2C3

c(3) : S3S′1|V

S3|V

S2|V

Figure 5: A cyclic topology

calls lsolve in (e) thrice to compute the final result:

S1|V = {({a}, {b}, {c}, {¬f, g}), ({¬a}, {b}, {¬c}, {¬f, g}), ({¬a}, {¬b}, {¬c}, {f,¬g})} .

The next example illustrates the run of DMCS on a cyclic topology.

Example 8 Let M = (C1, C2, C3) be an MCS such that each Li is an ASP logic, and

• kb1 = ∅, br1 = {a← not (2 : b)};• kb2 = ∅, br2 = {b← (3 : c)}; and

• kb3 = ∅, br3 = {c ∨ d← not (1 : a)}.

Figure 5 shows the cyclic topology ofM . Suppose that the user sends a request toC1 by callingC1.DMCS(V, ∅)with V = {a, b, c}. In step (d) of Algorithm 1, C1 calls C2.DMCS(V, {1}), then context C2 issues a callC3.DMCS(V, {1, 2}), thus C3 invokes C1.DMCS(V, {1, 2, 3}). At this point, the instance of DMCS at C1

detects a cycle in (b) and guesses the partial belief states

S ′1 = {({a}, ε, ε), ({¬a}, ε, ε)}

for Σ1∩V . Then, following the dotted lines in Figure 5, the set S ′1|V = S ′1 is the return value for the requestfrom C3, who joins it with an initial empty belief state (ε, ε, ε), gives us T and then calls lsolve(T ) for eachT ∈ T in (e), resulting in

S3 = {({¬a}, ε, {c,¬d}), ({¬a}, ε, {¬c, d}), ({a}, ε, {¬c,¬d})} .

The next step of C3 is to return S3|V back to C2, which will proceed as C3 before. The result is the setof belief states

S2 = {({¬a}, {b}, {c}), ({¬a}, {¬b}, {c}), ({a}, {¬b}, {¬c})} ,

which will be sent back to C1 as S2|V . Notice that belief state ({¬a}, {¬b}, {c}) is inconsistent in C1, butwill be eventually eliminated once C1 evaluates S2|V with lsolve.

Next, C1 will join S2|V with (ε, ε, ε), which yields S2|V , and then use this result to call lsolve. Theunion gives us

S1 = {({¬a}, {b}, {c}), ({a}, {¬b}, {¬c})} ,

which is also sent back to the user as final result.

INFSYS RR 14-03 15

Given an MCS M = (C1, . . . , Cn) and a context Ck, using the recursive import interface of Ck, i.e.,V ∗(k), as the relevant interface is a safe (lower) bound for the correctness of Algorithm 1. In what follows,let M , Ck, and V ∗(k) as above.

Theorem 1 (Correctness of DMCS with partial equilibrium) For every V ⊇ V ∗(k), it holds that S′ ∈Ck.DMCS(V, ∅) iff M has some partial equilibrium S w.r.t. Ck such that S′ = S|V .

We can compute partial equilibria at Ck if we use VΣ. This holds because using VΣ preserves all beliefsets returned from step (e), as the projection at step (f) takes no effect.

Corollary 2 S is a partial equilibrium of M w.r.t. Ck iff S ∈ Ck.DMCS(VΣ, ∅).

Under the assumption that M has a single root context C1, i.e., such that i ∈ IC (1) for all 2 ≤ i ≤ n,DMCS computes equilibria. (Disconnected contexts in M can be always connected to a new root contextusing simple bridge rules. An MCS with a self-loop context can also be converted to a single root contextusing Definition 13.)

Corollary 3 If an MCSM has a single root contextC1, then S is an equilibrium ofM iff S ∈ C1.DMCS(VΣ, ∅).

An analysis of the algorithm yields the following upper bound on the computational complexity andcommunication activity.

Proposition 4 In each run of DMCS with an interface V , it holds that

(1) the total number of calls to lsolve is exponentially bound by n× |V |, i.e., O(2n×|V |).

(2) the number of messages exchanged between contexts Ci, where i ∈ IC (k), is bounded by 2 · |E(k)|,where E(k) = {(i, cj) | i ∈ IC (k), r ∈ bri, (cj : pj) ∈ B(r)}.

3.3 Discussion

Algorithm DMCS naturally proceeds “forward” in the import direction of context Ck. Thus, starting fromthere, it computes partial equilibria which coverCk and contexts in its import closure. All other contexts willbe ignored; in fact, they are unknown to all contexts in the closure. While partial equilibria may exist for Ck

and its import closure, the whole MCS could have no equilibrium, because, e.g., (P1) contexts that accessbeliefs from Ck or its closure get inconsistent, or (P2) an isolated context or subsystem is inconsistent.

Enhancements of DMCS may deal with such situations: As for (P1), the context neighborhood mayinclude both importing and supporting contexts. Intuitively, if Ci imports from Cj , then Ci must registerto Cj . By carefully adapting DMCS, we can then solve (P1). However, (P2) remains; this needs knowledgeabout the global system topology.

A suitable assumption is that a managerM exists which every context Ci in the system can reach andask whether some isolated inconsistent context or subsystem exists; ifM confirms this, Ci’s DMCS instancesimply returns ∅, eliminating all partial equilibria.

To improve decentralization and information hiding, we can weaken the manager assumption by intro-ducing routers. Instead of askingM, a context Ci queries an assigned router R, which collects topologyinformation need by Ci or looks up a cache. The information exchange between Ci and R is flexible, de-pending on the system setting, and could contain contexts that import information from Ci, or isolated andinconsistent contexts.

16 INFSYS RR 14-03

A further advantage of topological information is that Ci can recognize cyclic and acyclic branches up-front; the invocation order of the neighborhood can then be optimized, by starting with all acyclic branchesbefore entering cyclic subsystems. The caching mechanism can be adapted for acyclic branches, as inter-mediate results are complete and the cache is meaningful even across different evaluation sessions.

In our setting, we are safe assuming that V ∗(k) ⊆ V . But this is not needed if M resp. Ck’s importclosure has no join-contexts, i.e., contexts having at least two parents. If we have access to path informationin M at each context, we could calculate V on the fly and adjust it during MCS traversal. In particular,for a tree- or ring-shaped M , we can restrict V to the locally shared interface between Ck and its importneighbors, i.e., restricting V to the bridge atoms of brk. In presence of join-contexts, V must be made“big enough,” e.g. using path information. Furthermore, join-contexts may be eliminated by virtually split-ting them, if orthogonal parts of the contexts are accessed. This way, scalability to many contexts can beachieved.

Next, we present optimization techniques using topological information of the system.

4 Topology-Based Optimization Algorithm (DMCSOPT)

As a basic version, Algorithm DMCS uses no further metadata apart from the minimal information that eachcontext must know: its interface with every neighboring context. There are scalability issues which can betracked down to the following problems:(1) contexts are unaware of context dependencies in the system beyond their neighbors, and thus treats

all neighbors equally. Specifically, cyclic dependencies remain undetected until a context, seeing theinvocation chain, requests models from a context in the chain. Furthermore, a context Ci does not knowwhether a neighborCj already requested models from another neighborCj′ which then would be passedto Ci; hence, Ci makes possibly a superfluous request to C′j .

(2) a contextCi returns its local models combined with the results from all its neighbors. In case of multiplemodels, the result size can become huge as the system respectively number of neighbors increases. Infact, this is one of the main performance obstacles.In this section we address optimizations to increase the scalability of distributed MCS evaluation. Re-

sorting to methods from graph theory, we aim at decomposing, pruning, and improved cycle breaking fordependencies in MCSs. Focusing on (1), we describe a decomposition method using biconnected compo-nents of inter-context dependencies. Based on it we can break cycles and prune acyclic parts ahead andcreate an acyclic query plan. To address (2), we foster a partial view of the system, which is often suf-ficient for a satisfactory answer, as a compromise between partial information and performance. We thusdefine a set of variables for each import dependency in the system to project the models in each context toa bare minimum such that they remain meaningful. In this manner, we can omit needless information andcircumvent excessive model combinations.

We proceed as follows. After introducing a running example and a superficial explanation of optimiza-tion on it, we present the details of the techniques in Section 4.2. Finally, Section 4.4 describes the algorithmDMCSOPTwhich intertwines decomposition and pruning with variable projection for performance gains inMCS evaluation.

4.1 Running Scenario

We first present a scenario in Example 9 as a running example for this section.

INFSYS RR 14-03 17

1

2

4

3

5

6

(a) Diamond-ring

B1

B2 B3

1

2 3

3

3

4

4

4

56

(b) Diamond-ring block tree

Figure 6: Topologies and decomposition of the scientist group example

Example 9 (Scientists Group) A group of four scientists, Alice, Bob, Charlie, and Demi meets after aconference closing to arrange travel back home. The options are going by train or by car (which is slower);if they use the train, they should bring along some food. Alice as the group leader finally decides, based onthe information she gets from Bob and Charlie.6

Alice prefers to go by car, but she would not object if Bob and Charlie want to go by train. Charlie has adaughter, Fiona; he does not mind transport, but if Fiona is sick he wants the fastest. Demi just got married,and her husband, Eddie, wants her to be back soon, and even sooner if she would come soon; Demi tries toyield to her husband’s plea.

Charlie is in charge of buying provisions if they go by train. He might choose either salad or peanuts;notably, Alice is allergic to nuts. The options for beverages are coke and juice. Bob is modest; he agreesto any choice of Charlie and Demi for transport but he dislikes coke. Charlie and Demi do not want tobother the others with their personal matters and just communicate their preferences, which is sufficient forreaching an agreement.

Example 10 The scenario in Example 9 can be encoded as an MCS M = (C1, . . . , C6), where Alice = 1,Bob = 2, etc in lexicographic order and all Li are ASP logics the knowledge bases kbi and bridge rules briare as follows:

C1 : kb1 =

{car1← not train1.⊥← nuts1.

}and br1 =

{train1← (2 : train2), (3 : train3).nuts1← (3 : peanuts3).

};

C2 : kb2 = {⊥ ← not car2,not train2.} and br2 =

car2← (3 : car3), (4 : car4).

train2← (3 : train3), (4 : train4),not (3 : coke3).

;

6Similar scenarios have already been investigated in the realm of multi-agent systems (see, e.g., [Buccafurri and Caminiti, 2008]on social answer set programming). We do not aim at introducing a new semantics for such scenarios; our example serves as a plainMCS showcase for the algorithms.

18 INFSYS RR 14-03

C1

query

C2 C3

C4

C5 C6

C7

(a) Original Topology

C1

C2 C3

(ε, ε, S3)

(ε, S

2, S

3) (ε, ε, S

3 )

(b) Triangle

C1

query

C2 C3

C4

C5 C6

C7

(c) Transitive Reduction

Figure 7: Topology of Example 11 (two stacked zig-zag diamonds)

C3 : kb3 =

car3 ∨ train3.←

train3← urgent3.salad3 ∨ peanuts3← train3.

coke3 ∨ juice3← train3

and br3 =

{urgent3← (6 : sick6).

train3← (4 : train4)

};

C4 : kb4 ={

car4 ∨ train4←}

and br4 ={

train4← (5 : sooner5)}

;

C5 : kb5 ={

sooner5← soon5

}and br5 =

{soon5← (4 : train4)

};

C6 : kb6 ={

sick6 ∨ fit6←}

and br6 = ∅ .

The context dependencies of M are shown in Fig. 6a. M has three equilibria, namely:

• ({train1}, {train2}, {train3, urgent3, juice3, salad3}, {train4}, {soon5, sooner5}, {sick6});

• ({train1}, {train2}, {train3, juice3, salad3}, {train4}, {soon5, sooner5}, {fit6}); and

• ({car1}, {car2}, {car3}, {car4}, ∅, {fit6}).

Example 11 Consider an MCSM = (C1, . . . , C7) with context dependencies as drawn in Figure 7a. Whenthe user queries C1 and just cares about the local belief sets in C1, then in the evaluation process, C4 candiscard all local belief sets of C5 and C6 when answering to call from C2 or C3. However, when C1 callsC2 (or C3), the invoked context must carry local belief sets of C4 in its answers to C1. The reason is thatbelief sets of C4 can cause inconsistent joins at C1 for partial belief states returned from C2 and C3, whilethose of C5 to C7 contribute only directly to computing local belief sets at C4. Note that belief sets of C4 toC7 play no role in determining the applicability of bridge rules in C1.

Now, take a sub-system including C1, C2, and C3, assuming that C1 has bridge rules with atoms (2 : p2)and (3 : p3) in the body, and C2 with atoms (3 : p3). That is, C1 depends on both C2 and C3, while C2

depends on C3 (see Fig. 7b). A straightforward approach to evaluate this MCS asks at C1 for the belief setsof C2 and C3. But as C2 also depends on C3, we would need another query from C2 to C3 to evaluate C2

w.r.t. the belief sets of C3. This shows evident redundancy, as C3 will need to compute its belief sets twice.

INFSYS RR 14-03 19

Simple caching strategies could mellow out the second belief state building at C3; nonetheless, when C1

asks C3, the context will transmit its belief states back, thus consuming network resources.Moreover, when C2 asks for the PEs of C3, it will receive a set of PEs that covers the belief sets of C3

and in addition of all contexts in C3’s import closure. This is excessive from C1’s view, as it only needs toknow about (2 : p2) and (3 : p3). However, C1 needs the belief states of both C2 and C3 in reply of C2:if C2 only reports its own belief sets (which are consistent w.r.t. C3), C1 can’t align the belief sets receivedfrom C2 with those received from C3. Realizing that C2 also reports the belief sets of C3, no call to C3 mustbe made.

4.2 Decomposition of Nonmonotonic MCS

Based on the observations above, we present an optimization strategy that pursues two orthogonal goals:(i) to prune dependencies in an MCS and cut superfluous transmissions, belief state building, and joining ofbelief states; and (ii) to minimize content in transmissions. We start with defining the topology of an MCS.

Definition 8 (Topology) The topology of an MCS M = (C1, . . . , Cn) is the directed graph GM = (V,E),where V = {C1, . . . , Cn} resp. V = {1, . . . , n} and (i, j) ∈ E iff some rule in br i has an atom (j:p) in thebody.

The first optimization technique is made up of three graph operations. We get a coarse view of the topologyby splitting it into biconnected components, which form a tree representation of the MCS. Then, edgeremoval techniques yield acyclic structures.

In the sequel, we will use standard terminology from graph theory (see [Bondy and Murty, 2008]);graphs are directed by default.

For any graph G and edges S ⊆ E(G), we denote by G\S the maximal subgraph of G having no edgesfrom S. For a vertex v ∈ V (G), we denote by G\v the subgraph of G induced by V (G)\{v}.

A graph is weakly connected if replacing every directed edge by an undirected edge yields a connectedgraph. A vertex c of a weakly connected graph G is a cut vertex, if G\c is disconnected. A biconnectedgraph is a weakly connected graph without cut vertices.

A block in a graph G is a maximal biconnected subgraph of G. Let T (G) = (B ∪ C, E) denote theundirected bipartite graph, called block tree of graph G, where

(i) B is the set of blocks of G,

(ii) C is the set of cut vertices of G,

(iii) and (B, c) ∈ E with B ∈ B and c ∈ C iff c ∈ V (B).

Note that T (G) is a forest for any graph G and a rooted tree if G is weakly connected.

Example 12 Consider the graph in Figure 7a. One can check that 4 is the only cut vertex and there are twoblocks, viz. the subgraphs induced by {1, 2, 3, 4} and {4, 5, 6, 7}.

The next example shows the block tree of our scenario in Example 9.

Example 13 The topologyGM ofM in Example 10 is shown in Figure 6a. It has two cut vertices, namely 3and 4; thus the block tree T (GM ) (Figure 6b) contains the blocks B1, B2, and B3, which are subgraphs ofGM induced by {1, 2, 3, 4}, {4, 5}, and {3, 6}, respectively.

20 INFSYS RR 14-03

1

2 3

4

5

(a) A strongly connected component

1

2 3

4

5

(b) Acyclic topology

Figure 8: Ear decomposition example

Pruning In acyclic topologies, like the triangle presented in the previous section, we can exploit a minimalgraph representation to avoid unnecessary calls between contexts, namely, the transitive reduction of thegraph GM . Recall that the transitive reduction of a directed graph G is the graph G− with the smallest setof edges (with respect to set inclusion) whose transitive closure equals the one of G. Note that G− is uniqueif G is acyclic. For instance, the graph in Figure 7c is the unique transitive reduction of the one in Figure 7a.

Ear decomposition Another essential part of our optimization strategy is to break cycles by removingedges. To this end, we use ear decompositions of cyclic graphs. A block may have multiple cycles thatare not necessarily strongly connected; thus we first decompose cyclic blocks into their strongly connectedcomponents. Topological sorting them yield a sequence of nodes r1, . . . , rs that are used as entry points toeach component. The next step is to break cycles.

An ear decomposition of a strongly connected graphG rooted at a node r is a sequenceP = 〈P0, . . . , Pm〉of subgraphs of G such that

(i) G = P0 ∪ · · · ∪ Pm,(ii) P0 is a simple cycle (i.e., has no repeated edges or vertices) with r ∈ V (P0), and

(iii) each Pi (i > 0) is a non-trivial path (without cycles) whose endpoint ti is in P0 ∪ · · · ∪ Pi−1, but theother nodes are not.

Let cb(G,P ) be the set of edges containing (`0, r) of P0 and the last edge (`i, ti) of each Pi, i > 0.

Example 14 Take, as an example, a strongly connected graph G in Figure 8a. An ear decomposition of Grooted at node 1 is P = 〈P0, P1, P2, P3〉 where

VP0 = {1, 2, 3}, EP0 = {(1, 2), (2, 3), (3, 1)}, VP1 = {2, 4, 3}, EP1 = {(2, 4), (4, 3)},VP2 = {2, 5, 3}, EP2 = {(2, 5), (5, 3)}, VP3 = {1, 4}, EP4 = {(1, 4)}.

The last edges of Pi are dashed. They form the set cb(G,P ) = {(3, 1), (4, 3), (5, 3), (1, 4)}. Removingthese edges results in an acyclic topology as in Figure 8b.

INFSYS RR 14-03 21

Intuitively, ear decomposition is used to remove cycles from the original system M . On the resultingacyclic topology, algorithms for evaluating MCSs can be designed more conveniently. The trade off is thatfor any edge (`, t) removed from M , context C`, despite being now a leaf context, has to guess values forvariables from Ct. The following example shows the application of the optimization techniques above toour running scenario.

Example 15 (cont’d) Block B1 of T (GM ) is acyclic, and the transitive reduction gives B−1 with edges{(1, 2), (2, 3), (3, 4)}. B2 is cyclic, and 〈B2〉 is the only ear decomposition rooted at 4; removing cb(B2,〈B2〉) = {(5, 4)}, we obtain B′2 with edges {(4, 5)}. B3 is acyclic and already reduced. Fig. 6b shows thefinal result (dotted edges are removed).

The graph-theoretic concepts introduced here, in particular the transitive reduction of acyclic blocks and theear decomposition of cyclic blocks, are used to implement the first optimization of MCS evaluation outlinedabove. Intuitively, in each block, we apply ear decomposition to get rid of cycles (with the trade-off ofguessing), and then use transitive reduction to minimize communication. Given the transitive reduction B−

of an acyclic block B ∈ B, and a total order on V (B−) that extends B−, one can evaluate the respectivecontexts in reverse order for computing PEs at some context Ck: the first context simply computes its localbelief sets which—represented as a set of partial belief states S0—constitutes an initial set of partial beliefstates T0. In each iteration step i, Ti−1 is updated by joining it with the local belief sets Si of the consideredcontextCi. Given the final Tk, we have that Tk|V ∗(k) is the set of PEs atCk (restricted to contexts in V (B−)).

Refined recursive import Next, we define the second part of our optimization strategy which handlesminimization of information needed for transmission between two neighboring contexts Ci and Cj . For thispurpose, we refine the notion of recursive import interface in a context w.r.t. a particular neighbor and agiven (sub-)graph.

Definition 9 Given an MCS M = (C1, . . . , Cn) and a subgraph G of GM , for an edge (i, j) ∈ E(G), therecursive import interface of Ci to Cj w.r.t. G is V ∗(i, j)G = {V ∗(i) ∩⋃`∈G|j Σ`} where G|j contains allnodes in G reachable from j.

Example 16 (cont’d) For the MCS in Example 10, we have V ∗(1) = {train2, train3, peanuts3, car3,coke3, car4, train4, sooner5, sick6}. When we focus on block B1, the refined recursive import interfaceV ∗(1, 2)B−1

can be obtained by removing bridge atoms from contexts in the other blocksB2 andB3, yielding{train2, train3, peanuts3, car3, coke3, car4, train4}.

Algorithms Algorithms 3 and 4 combine the optimization techniques outlined above. Intuitively, OptimizeTreetakes as input a block tree T with parent cut vertex cp and root cut vertex cr. It traverses T in DFS mannerand calls OptimizeBlock on every block. The call results are collected in a set F of removed edges; after allblocks have been processed, the final result of OptimizeTree is the pair (F, v) where v is a labeling for theremaining edges. OptimizeBlock takes a graphG and calls CycleBreaker for cyclicG, which decomposesGinto its strongly connected components, creates an ear decomposition P for each component Gc, and breakscycles by removing edges cb(Gc, P ). For the resulting acyclic subgraph of G, OptimizeBlock computesthe transitive reduction G− and returns all edges that have been removed from G. OptimizeTree continuescomputing the labeling v for the remaining edges, building on the recursive import interface, but keepingrelevant interface variables of child cut vertices and removed edges. Formally, the following property holds.

22 INFSYS RR 14-03

Algorithm 3: OptimizeTree(T = (B ∪ C, E), cp, cr)

Input: T : block tree, cp: identifies level in T , cr: identifies level above cpOutput: F : removed edges from

⋃B, v: labels for (⋃B)\F

B′ := ∅, F := ∅, v := ∅ // initialize siblings B′ and return values

if cp = cr thenB′ := {B ∈ B | cr ∈ V (B)}

elseB′ := {B ∈ B | (B, cp) ∈ E}

foreach sibling block B ∈ B′ do // sibling blocks B of parent cpE := OptimizeBlock(B, cp) // prune block

C′ := {c ∈ C | (B, c) ∈ E ∧ c 6= cp} // children cut vertices of B

B′ := B\E, F := F ∪ E(a) foreach edge (i, j) of B′ do // setup interface of pruned B

v(i, j) := V ∗(i, j)B′ ∪⋃

c∈C′ V∗(cp)|Σc ∪

⋃(`,t)∈E V

∗(cp)|Σt

foreach child cut vertex c ∈ C′ do // accumulate children

(b) (F ′, v′) := OptimizeTree(T\B, c, cp)F := F ∪ F ′, v := v ∪ v′

return (F, v)

Algorithm 4: OptimizeBlock(G : graph, r : context id)

F := ∅if G is cyclic then

(c) F := CycleBreaker(G, r) // ear decomposition of strongly connected components

(d) Let G− be the transitive reduction of G\Freturn E(G) \ E(G−) // removed edges from G

Proposition 5 For any context Ck in an MCS M , OptimizeTree(T (GM ), k, k) returns a pair (F, v) suchthat

(i) the subgraph G of GM\F induced by IC (k) is acyclic, and

(ii) in any block B of G and for all (i, j) ∈ E(B), it holds that v(i, j) ⊇ V ∗(i, j)B .

Regarding the computational cost of computation, we obtain:

Proposition 6 For any context Ck in an MCS M , OptimizeTree(T (GM ), k, k) runs in time polynomial(quadratic) in the size of T (GM ) resp. GM .

4.3 Query Plan

Given the topology of an MCS, we need to represent a stripped version of it that contains both the minimaldependencies between contexts and interface variables that need to be transferred between contexts. Thisrepresentation will be a query plan that can be used for execution processing. Syntactically, query planshave the following form.

INFSYS RR 14-03 23

Definition 10 (Query Plan) A query plan of an MCSM w.r.t. context Ck is any labeled subgraph Π ofGM

induced by IC (k) with E(Π) ⊆ E(GM ), and edge labels v : E(G)→ 2Σ.

For any MCS M and context Ck of M , not every query plan is suitable for evaluating M; however, thefollowing query plan is in fact effective.

Definition 11 (Effective Query Plan) Given an MCS M and a context Ck, the effective query plan of Mwith respect to Ck is Πk = (V (G), E(G)\F, v) where G is the subgraph of GM induced by IC (k) and(F, v) = OptimizeTree(T (GM ), k, k).

We next use Πk for MCS evaluation, and tacitly assume that query plans are effective.

4.4 Evaluation with Query Plans

We now present the algorithm DMCSOPT, which is based on DMCS but exploits the optimization tech-niques from above. The idea of DMCSOPT is as follows: we start with context Ck and traverse a givenquery plan Πk by expanding the outgoing edges of Πk at each context, like in a DFS, until a leaf contextCi is reached. The context simply computes its local belief sets, transforms all belief sets into partial beliefstates, and returns the result to its parent. If Ci has (j : p) in bridge rules bodies but context Cj is not in thequery plan (this means we broke a cycle by removing the last edge to Cj), all possible truth assignments tothe import interface to Cj are considered.

The result of any context Ci is a set of partial belief states, which amounts to the join, i.e., the consistentcombination, of its local belief sets with the results of its neighbors; the final result is obtained from Ck.To keep recomputation and recombination of belief states with local belief sets at a minimum, partial beliefstates are cached in every context.

Algorithm 5 shows our distributed algorithm, DMCSOPT, with its instance at context Ck. On input ofthe id c of a predecessor context (which the process awaits), it proceeds based on an (acyclic) query plan Πr

w.r.t. context Cr, i.e., the starting context of the system. The algorithm maintains in cache(k) a cache at Ck

(which is kept persistent).

• Ci.DMCSOPT(c): send id c to DMCSOPT at context Ci and wait for its result.

• guess(V ): guess all possible truth assignments for the interface variables V .

• lsolve(S) (Algorithm 2): given a partial belief state S, augment kbk with all heads from bridge rulesbrk applicable w.r.t. S (=: kb′k), compute local belief sets by ACC(kb′k), and merge them with S;return the resulting set of partial belief states.

The steps of Algorithm 5 are explained as follows:(a)+(b) check the cache, and if it is empty get neighbor contexts from the query plan, request partial belief

states from all neighbors and join them;(c) if there are (i : p) in the bridge rules brk such that (k, i) /∈ E(Πr), and no neighbor delivered the

belief sets for Ci in step (b) (i.e., Ti = ε), we have to call guess on the interface v(c, k) and join theresult with T (intuitively, this happens when edges had been removed from cycles);

(d) compute local belief states given the partial belief states collected from neighbors; and(e) return the locally computed belief states and project them to the variables in v(c, k) for non-root

contexts; this is the point where we mask out parts of the belief states that are not needed in contextslying in a different block of T (GM ).

24 INFSYS RR 14-03

Algorithm 5: DMCSOPT(c : context id of predecessor) at Ck = (Lk, kbk, brk)

Data: Πr: query plan w.r.t. starting context Cr and label v, cache(k): cacheOutput: set of accumulated partial belief states

(a) if cache(k) is not empty thenS := cache(k)

elseT := {(ε, . . . , ε)}(b) foreach (k, i) ∈ E(Πr) do T := T ./ Ci.DMCSOPT(k) // neighbor belief sets

(c) if there is i ∈ In(k) s.t. (k, i) /∈ E(Πr) and Ti = ε for T ∈ T thenT := guess(v(c, k)) ./ T // guess for removed dependencies in Πr

S := ∅(d) foreach T ∈ T do S := S ∪ lsolve(T ) // get local beliefs w.r.t. T

cache(k) := S(e) if (c, k) ∈ E(Πr) (i.e., Ck is non-root) then

return S|v(c,k)

elsereturn S

Theorem 7 shows that DMCSOPT is sound and complete.

Theorem 7 Let Ck be a context of an MCS M , let Πk be the query plan as in Definition 11 and let V ={p ∈ v(k, j) | (k, j) ∈ E(Πk)}. Then,

(i) for each S′ ∈ Ck.DMCSOPT(k), there exists a partial equilibrium S of M w.r.t. Ck such that S′ =S|

V; and

(ii) for each partial equilibrium S of M w.r.t. Ck, there exists an S′ ∈ Ck.DMCSOPT(k) such thatS′ = S|

V.

5 Streaming Equilibria (DMCS-STREAMING)

Algorithm DMCSOPT shows substantial improvements over DMCS; however, when the sizes of the localsignatures and the context interfaces increase, it also suffers from bottlenecks.

This stems from the way in which models are exchanged between contexts. Suppose contextC1 accessesseveral neighborsC2, . . . , Cm under an acyclic information flow, and that eachCi, i ≥ n, has ni PEs. BeforeCi computes in DMCS resp. DMCSOPT any local models, it must join all PEs from its neighbors; this maylead to n2×n3× · · · ×nm many PEs, and each of them an input to the local solver. This may not only takeconsiderable time but also exhaust memory, even before local model computation start.

Note however that if instead each neighbor would transfer just a portion of its PEs, then the computationat C1 can avoid such a memory blowup. Moreover, this strategy also helps to reduce inactive running timeat C1 while waiting for all neighbors to return all PEs, as C1 can already start local computing while theneighbors are producing more models.

In general, it is indispensable to trade more computation time, due to recomputations, for less memory ifeventually all partial equilibria at C1 shall be computed. This is the idea underlying a streaming evaluationmethod for distributed MCS. It is particularly useful when a user is interested in obtaining just some instead

INFSYS RR 14-03 25

Solver

Handler

Output

Joiner

CiCj1

...

Cjm

request (k1, k2)

≤ k belief states

Figure 9: DMCS-STREAMING architecture

of all answers from the system, but also for other realistic scenarios where the current evaluation algorithmdoes not manage to output under resource constraints in practice any equilibrium at all.

In this section, we turn this idea into a concrete streaming algorithm DMCS-STREAMING for computingpartial equilibria. Its main features are briefly summarized as follows:

• the algorithm is fully distributed, i.e., instances of its components run at every context and communi-cate, thus cooperating at the level of peers;

• when invoked at a context Ci, the algorithm streams (i.e. computes) k ≥ 1 partial equilibria at Ci at atime; in particular, setting k = 1 allows for consistency checking of the MCS (sub-)system.

• issuing follow-up invocations one may compute the next k partial equilibria at context C1 until nofurther equilibria exist; i.e., this evaluation scheme is complete.

• local buffers can be used for storing and exchanging local models (partial belief states) at contexts,avoiding the space explosion problem.

As this section mainly studies the streaming aspect of the algorithm, we simplify the presentation andomit the interface between contexts. The principles presented here can be applied for both DMCS andDMCSOPT by adapting the interface and pruning the topology at preprocessing time. Furthermore, weassume to work with acyclic MCSs. Treatment of cyclic cases can be easily achieved by adding guessingcode to the solving component as in DMCS and DMCSOPT.

To the best of our knowledge, a similar streaming algorithm has neither been developed for the particularcase of computing equilibria of a MCS, nor more generally for computing models of distributed knowledgebases. Thus, the results obtained here are not only of interest in the setting of heterogeneous MCS, but theyare also relevant in general for model computation and reasoning over distributed (potentially homogeneous)knowledge bases like e.g. distributed SAT instances.

5.1 Basic Streaming Procedure

The basic idea is as follows: each pair of neighboring contexts can communicate in multiple rounds, andeach request has the effect to receive at most k PEs. Each communication window of k PEs ranges from thek1-th PE to the k2-th (= k1 +k−1) PE. A parent context Ci requests from a child context Cj a pair (k1, k2)and will receive sometimes later a package of at most k PEs; receiving ε indicates that Cj has fewer than k1

models. A parallelized version is discussed in Section 5.2.

26 INFSYS RR 14-03

Algorithm 6: Handler(k1, k2: package range) at Ci

Output.k1 := k1, Output.k2 := k2,Solver.k2 := k2, Joiner.k := k2 − k1 + 1call Solver

Algorithm 7: Solver() at Ci

Data: Input queue: q, maximal number of models: k2

count := 0while count < k2 do

(a) if Ci is a leaf then S := ∅(b) else call Joiner and pop S from q

if S = ε then count := k2

(c) while count < k2 dopick the next model S? from lsolve(S)if S? 6= ε then

push S? to Output.qcount := count + 1

else break

refresh() and push ε to Output.q

Important subroutines of the new algorithm DMCS-STREAMING take care of receiving the requestsfrom parents, receiving and joining answers from neighbors, local solving and returning results to parents.They are reflected in four components: Handler, Solver, Output, and Joiner (only active in non-leaf con-texts); see Figure 9 for an architectural overview.

All components except Handler (shown in Algorithm 6) communicate using message queues: Joiner hasj queues to store partial equilibria from j neighbors, Solver has one queue to hold joined PEs from Joiner,and Output has a queue to carry results from Solver. To bound space usage, each queue has a limit on thenumber of entries. When a queue is full (resp., empty), the enqueuing writer (resp., dequeuing reader) isautomatically blocked. Furthermore, getting an element also removes it from the queue, which makes roomfor other PEs in the queue later. This property frees us from synchronization technicalities.

Algorithms 7 and 8 show how Solver and Joiner work. They use the following primitives:• lsolve(S): works as lsolve in DMCS and DMCSOPT, but in addition may return only one answer at

a time and may be able to tell whether there are models left. Moreover, we require that the results fromlsolve are returned in a fixed order, regardless of when it is called. This property is the key to guarantee thecorrectness of our algorithm.

• get first(`1, `2, k): send to each neighbor from c`1 to c`2 a request for the first k partial equilibria, i.e.,k1 = 1 and k2 = k; if they all return some models, store them in the respective queues and return true;otherwise, return false (some neighbor is inconsistent).

• get next(`, k): request the next k equilibria from neighbor Cc` ; if Cc` sends back some models, storethem in the queue q` and return true; otherwise, return false as the neighbor already exhaustively returnedits PEs from the previous request. Note that this subroutine needs to keep track of which range has beenalready asked for to what neighbor, by maintaining a set of counters. A counter w.r.t. a neighbor Cc` is

INFSYS RR 14-03 27

C1

C2 C3

C4 C5 C6 C7

Figure 10: Binary tree MCS

initialized to 0 and increased each time get next(`, k) is called. When its value is t, the request to Cc` asksfor the t’th package of k models, i.e., models in the range given by k1 = (t − 1) × k + 1 and k2 = t × k.When get first(`1, `2, k) is called, all counters in range [`1, `2] are reset to 0.

• refresh(): reset all counters and flags of Joiner to their starting states, e.g., first join to true , allcounters to 0.

The process at each context Ci is triggered when a message from a parent, which contains the range(k1, k2) arrives at Handler. The latter notifies Solver to compute up to k2 models and Output to collectthose in the range (k1, k2) and return them to the parent. Furthermore, it sets the package size at Joiner tok = k2 − k1 + 1 in case Ci needs to query further neighbors (cf. Algorithm 6).

When Solver receives a notification from Handler, it first prepares the input for the local solver. If Ci isa leaf context, the input S gets the empty set assigned in Step (a); otherwise, Solver triggers Joiner (Step (b))for input from neighbors. Fed with input from them, lsolve is used in Step (c) to compute at most k2 resultsand send them to the output queue.

The Joiner, which is only activated for intermediate contexts as discussed, gathers partial equilibria fromthe neighbors in a fixed ordering and stores the joined, consistent input to a local buffer. It communicatesjust one input at a time to Solver upon request. The fixed joining order is guaranteed by always asking thefirst package of k models from all neighbors at the beginning in Step (d). In subsequent rounds, we beginwith finding the first neighbor Cc` that can return further models (Step (e)), and reset the query to ask forfirst packs of k models from neighbors from Cc1 to Cc`−1

. When all neighbors run out of models in Step (f),the joining process ends and sends ε to Solver.

Note that while the above procedure guarantees that no models are missed, it can lead to considercombinations (inputs to Solver) multiple times. Using a cache helps to mitigate recomputation, but asunlimited buffering again quickly exceeds memory limits, recomputation is an inevitable part of tradingcomputation time for less memory.

The Output component simply reads from its queue until it receives ε or reaches k2 models (cf. Algo-rithm 9). Upon reading, it throws away the first k1 − 1 models and only keeps the ones from k1 onwards.Eventually, if fewer than k1 models have been returned by Solver, then Output will return ε to the parent.

Example 17 LetM = (C1, . . . , Cn) be an MCS such that for a given integerm > 0, we have n = 2m+1−1contexts, and let ` > 0 be an integer. Let all contexts in M have ASP logics. For i < 2m, the contextCi = (Li, kbi, bri) has

kbi = {aji ∨ ¬aji ← ti | 1 ≤ j ≤ `} and bri =

{ti ← (2i : aj2i),

ti ← (2i+ 1 : aj2i+1)

∣∣∣∣ 1 ≤ j ≤ `}

, (2)

28 INFSYS RR 14-03

Algorithm 8: Joiner() at Ci

Data: Queue q1, . . . , queue qj for In(i) = {c1, . . . , cj}, buffer for partial equilibria: buf , flagfirst join

while true doif buf is not empty then

pop S from buf , push S to Solver.qreturn

if first join then(d) if get first(1, j, k) = false then

push ε to Solver.qreturn

else first join := false

else` := 1

(e) while get next(`, k) = false and ` ≤ j do ` := `+ 1if 1 < ` ≤ j then

get first(1, `− 1, k)(f) else if ` > j then

push ε to Solver.qreturn

for S1 ∈ q1, . . . , Sj ∈ qj do add S1 ./ · · · ./ Sj to buf

and for i ≥ 2m, we let Ci have

kbi = {aji ∨ ¬aji | 1 ≤ j ≤ `} and bri = ∅ . (3)

Intuitively, M is a binary tree-shaped MCS with depth m and ` + 1 is the size of the alphabet in eachcontext. Figure 10 shows such an MCS with n = 7 contexts and depth m = 2; the internal contexts haveknowledge bases and bridge rules as in (2), while the leaf contexts are as in (3). The directed edges showthe dependencies of the bridge rules. Such a system M has equilibria S = (S1, . . . , Sn) with Si = {aki , ti},for 1 ≤ k ≤ `.

To compute one PE of M using DMCS or DMCSOPT, one needs to transfer packages of 2` PEs fromeach context to its parent (as each context Ci computes all subsets of {a1

i , . . . , a`i}). Each intermediate

context receives 2` results from each of its children, whose join leads to 22` inputs for lsolve; it invokeslsolve that often and only then returns its 2` models to the parent, which has to wait for this.

On the other hand, DMCS-STREAMING only needs to transfer a single PE between each pair of con-nected contexts, which is a significant saving. Indeed, consider e.g. m = 1, ` = 5, i.e., M = (C1, C2, C3).Querying C1 with package size k = 1 first causes the query to be forwarded to C2 as a pair k1 = k2 = 1.As C2 is a leaf context, it invokes the local solver and eventually gets five different models. However, itjust returns one PE to C1, say (ε, {a1

2}, ε). Note that t2 is projected off as it is not among the atoms of C2

accessed by C1. The same happens at C3, which we assume to return (ε, ε, {a23}) to C1. At the root context

C1, the two PEs from its neighbors are consistently combined into (ε, {a12}, {a2

3}). Feeding this to the localsolver, C1 obtains five models, and returns one of them, say S = ({a1

1, t1}, {a12}, {a2

3}).

INFSYS RR 14-03 29

Algorithm 9: Output() at Ci

Data: Input queue: q, starting model: k1, end model: k2

buf := ∅ and count := 0while count < k1 do

pick an S from Output.qif S = ε then count := k2 + 1else count := count + 1

while count < k2 + 1 dowait for an S from Output.qif S = ε then count := k2 + 1else

count := count + 1add S to buf

if buf is empty thensend ε to parent

elsesend content of buf to parent

The following proposition shows the correctness of our algorithm.

Proposition 8 Let M = (C1, . . . , Cn) be an MCS, i ∈ {1, . . . , n} and let k ≥ 1 be an integer. On input(1, k) to Ci.Handler, Ci.Output returns up to k different partial equilibria with respect to Ci, and in fact kif at least k such partial equilibria exist.

5.2 Parallelized Streaming

As one might expect, the strategy of ignoring up to k1 models and then collecting the next k is not likely to bethe most effective. The reason is that each context uses only one Solver, which in general has to serve morethan one parent, i.e., requests for different ranges of models of size k. When a new parent context requestsmodels, we have to refresh the state of Solver and Joiner and redo from scratch. This is unavoidable, unlessa context satisfies the specific property that only one parent can call it.

A way to address this problem is parallelization. The idea is to serve each parent with a suite of Handler,Joiner, Solver and Output. The basic interaction between units is still as shown in Figure 9, with the notabledifference that each component now runs in an individual thread. The significant change is that Solverdoes not control Joiner but waits at its queue to get new input for the local solving process. The Joinerindependently queries the neighbors, combines PEs from neighbors, and puts the results into the Solverqueue.

The effect is that we do not waste recomputation time for unused models. However, parallelizationhas its limits in practice. While DMCSOPT may run out of memory, unlimited parallel instances of thestreaming algorithm can exceed the number of threads/processes that the operating system can support; thishappens if contexts can reach others on many alternative paths, like in the stacked diamond topology: their,the number of threads is exponential in the number of connected contexts, which prohibits scaling to largesystem sizes. However, in real-world applications the number of paths might still be ok.

30 INFSYS RR 14-03

C1

C2 C3

C4 C5 C6 C7

(a) Binary Tree (T)

C1

C2 C3

C4

C5 C6

C7

(b) Diamond (D)

C1

C2 C3

C4

C5 C6

C7

(c) Zig-Zag (Z)

C1

C2

C3

C4

C4

(d) Ring (R)

Figure 11: Topologies for testing DMCS algorithms

A compromise between the two extremes is a bounded parallel algorithm. The idea is to create afixed-size pool of multiple threads and components to share among the contexts; when incoming requestscannot be served with the resources available, the algorithm continues with the basic streaming procedure.A realization remains for future work.

6 Experimental Evaluation

We have implemented the algorithms above using C ++ in a system prototype called DMCS, which is on-line available.7 For space reasons, we omit a detailed presentation and refer for it to [Bairakdar et al.,2010a], [Dao-Tran, 2014, Chapter 7]. Briefly, the main components of the global architecture are (i) acommand-line frontend dmcs for the user to access the system; (ii) demons daemon which representnodes that contain (a set of) contexts; and (iii) a manager dmcsm containing meta-information about theMCS (topology, interfaces) with a helper dmcsgen for generating configurations with optimized compo-nents. Contexts are implemented as groups of threads that communicate with each other through concurrentmessage queues. The system has two main command-line tools, viz. for running the algorihms and fortest case generation, respectively. It allows to switch between different algorithms and modes by simplychanging the command-line arguments.

We now turn to an experimental evaluation of DMCS under various aspects. Next we describe how thebenchmarks were set up, and then we go into runs and results interpretion.

6.1 Benchmark Setup

The idea is to analyze strong and weak points of each algorithm with respect to different parameters, namelysystem topology, system size, local theory (i.e., knowledge base) size, and interface size. Specifically, weconsidered MCSs with topologies as in Figure 11, including:

Binary Tree (T): Binary trees grow balanced, i.e., every level except the last is complete. With this topol-ogy, no edge needs to be removed to form the optimal topology; as every intermediate node is a

7http://www.kr.tuwien.ac.at/research/systems/dmcs,https://github.com/DistributedMCS/dmcs/

INFSYS RR 14-03 31

a1 a2 a3 a4 a5 a6 a7 a8

Figure 12: Local theory structure

cut-vertex, the import interface in the query plan is drastically reduced, leading to an extremal perfor-mane improvement.

(Stack of) Diamond(s) (D): a diamond consists of four nodes connecting as C1 to C4 in Figure 11b. Astack of diamonds combines multiple diamonds in a row, i.e., stacking m diamonds in a tower of3m + 1 contexts. Similar to Binary Tree, no edge is removed in constructing the query plan. W.r.t.this topology, every context connecting two diamonds is a cut-vertex. As such, the import interfacein the query plan is refined after every diamond; this avoids significantly repetition of partial PEs inevaluation.

(Stack of) Zig-Zag Diamond(s) (Z): a zig-zag diamond is a diamond with a connection between the twomiddle contexts, as depicted by contexts C1 to C4 in Figure 11c. A stack of zig-zag diamonds is builtas above. This topology is interesting as after removing two edges per block, the query plan turns intoa linear topology.

Ring (R): ring (Figure 11d). The query plan removes the connection from contextCn toC1 and then carriesthe interface between them all the way back to C1. This topology requires guessing and checking inany DMCS algorithm; thus it is quite unpredictable which algorithm performs better in general.

The other quantitative parameters are represented as tuple P = (n, s, b, r), where

• n is the system size (number of contexts),

• s is the local theory size (number of ground atoms in a local theory),

• b is the number of local atoms that can be used as bridge atoms in other contexts, in other words, thenumber of interface atoms, and

• r is the maximal number of bridge rules. The generator generates a bridge rule while iterating from1 to r with 50% chance; hence on average r/2 bridge rules are generated. We allow bridge bodies ofsize 1 or 2.

A test configuration is formulated as X/(n, s, b, r) where X ∈ {T,D,Z,R} represents the topology andn, s, b, r are integers representing the quantitative (i.e., size-related) parameters. As we would like to runseveral instances over one configuration, the final formulation of a test instance is Xi/(n, s, b, r), where i isthe index of the test instance.

Inside each context, the local theories are structured as follows. ContextCi has s ground atoms indicatedby ai,1, . . . , ai,s. Rules are of the form ai,j ← not ai,k where k = j+1, if j is odd; otherwise, we randomlychoose k to be j − 1 or j + 1 with a probability of 50% for each possibility. In case if k > s then the ruledoes not exist. An example of a context with local theory size is 8 can be illustrated with the dependencygraph as in Figure 12. With this setting, a local context has 2m answer sets, where m ∈ [0, s/2].

Furthermore, one can obtain deterministic contexts (having just one answer set) by disallowing cyclesin the structure of local theories.

32 INFSYS RR 14-03

6.2 Experiments

We conducted the experiments on a host system using 4-core Intel(R) Xeon(R) CPU 3.0GHz processor with16GB RAM, running Ubuntu Linux 12.04.1. Furthermore, we used DLV [build BEN/Sep 28 2011 gcc 4.3.3]as a back-end ASP solver.

We ran a comprehensive set of benchmarks under the setup described in Section 6.1. As the parameterspace P = (n, s, b, r) is huge, we singled out in an initial probing phase the following values for theexperiments:

• for the system size n, depending on the topology:

T : n ∈ {7, 10, 15, 31, 70, 100} Z: n ∈ {4, 7, 10, 13, 25, 31, 70}D: n ∈ {4, 7, 10, 13, 25, 31} R: n ∈ {4, 7, 10, 13, 70}

• s, b, r are fixed to either 10, 5, 5 or 20, 10, 10, respectively.

A combination of topology X and parameters P = (n, s, b, r) is denoted by X(n, s, b, r) or Xn,s,b,r

(used in figures). Each parameter setting has been tested on five instances. For each instance, we measuredthe total running time and the total number of returned partial equilibria on DMCS, DMCSOPT in non-streaming and streaming mode. For the latter mode, DMCS-STREAMING, we asked for k answers, wherek{1, 10, 100}. This parameter also influences the size of packages transferred between contexts (at most kpartial equilibria are transferred in one message) As in streaming mode, asking for more than one PE mayrequire multiple rounds to get all answers, it is of interest to see how fast the first answers arrive comparedto having all answers. We thus compared the running time of these tasks for k = 10 and k = 100.

6.3 Observations and Interpretations

Figures 13-17 summarize the results of our experiments. From these data, several interesting properties canbe observed. We organize our analysis along the following aspects: (1) comparing DMCS and DMCSOPT,(2) comparing streaming and non-streaming mode, (3) effect of the package size, (4) role of the topologies,and (5) the behavior of the algorithms on deterministic contexts.

6.3.1 DMCS vs. DMCSOPT

Figure 13 shows the running time of DMCS and DMCSOPT for computing all partial equilibria, i.e., innon-streaming mode, of five instances of the respective parameter settings. clearly DMCSOPT outperformsDMCS. This can be explained by the fact that when computing all answers, DMCS always produces morepartial equilibria than DMCSOPT, as one PE returned by DMCSOPT can be obtained from projecting manypartial equilibria returned by DMCS on the imported interface. Furthermore, all intermediate results aretransferred in one message, which makes no difference in terms of the number of communications betweenthe algorithms. As such, DMCS must spend more time on processing possibly exponentially more input;hence unsurprisingly, it is consistently slower than DMCSOPT.

However, the observation in streaming mode is different. Figure 14 shows the running time of DMCSand DMCSOPT in streaming mode to compute the first 100 respectively 10 unique partial equilibria forT (25, 10, 5, 5) respectivelyD(10, 10, 5, 5),Z(10, 10, 5, 5) andR(4, 10, 5, 5). On a first view, as DMCSOPTis consistently slower than DMCS, one might question the correctness of the results. However, they are nota surprise: again a PE returned by DMCSOPT should correspond to several PEs returned by DMCS. Hence,

INFSYS RR 14-03 33

0.01

0.1

1

10

100

1000

-5 0 5 10 15 20 25 30 35 40 45 50

DMCSDMCSOPT

R10,10,5,5

Z10,10,5,5

D10,10,5,5

T10,10,5,5

R7,10,5,5

Z7,10,5,5

D7,10,5,5

T7,10,5,5

Figure 13: DMCS vs. DMCSOPT in non-streaming mode

the batch of the first k unique answers in DMCS corresponds to only a smaller number of (few) uniqueanswers in DMCSOPT.

Therefore, comparing DMCS and DMCSOPT in streaming mode by measuring the runtime to computethe first k answers is not fair. We thus took the time when both algorithms finished the first round of answers(denoted by DMCS-1st and DMCSOPT-1st in Figure 14). With this setting, we observed the following:

• on many instances DMCSOPT finishes the first round faster than DMCS; this confirms the effect ofusing the query plan;

• however, in some cases DMCS wins. This can be explained as follows. First of all, in streaming mode,we transfer only packages of k partial equilibria at a time; therefore, the effect of reducing the amount oftotal work to be done does not always apply as in the non-streaming mode. Furthermore, at every context,we compute k PEs and project them to the output interface before returning the results. According to thisstrategy, when a context Ci returns k1 partial equilibria in non-streaming mode and k2 partial equilibria instreaming to another context Cj , it might happen that k2 is much smaller than k1 and hence does not provideenough input for Cj to compute k PEs. Therefore, Cj will issue more requests to Ci asking for furtherpackages of k PEs, e.g., [k+ 1, 2k], [2k+ 1, 3k], etc; and this costs DMCSOPT more time to even computethe first batch of PEs at the root context. Another approach is to compute always k unique partial equilibriabefore returning to a parent context. However, this strategy risks to compute even all local models before kunique partial equilibria can be found.

Overall, there is not much difference in running time when DMCSOPT is slower than DMCS, except forinstance R3 (Figure 14d). This however comes from a different reason: the cyclic topology with guess-and-check effects, which play a much more important role than choosing between DMCS and DMCSOPT (seeSection 6.3.4).

6.3.2 Streaming v.s. non-streaming DMCS

We now compare streaming and non-streaming for the same algorithm (DMCS resp. DMCSOPT).Figure 15 shows the results for DMCSin (15a), and the results for DMCSOPT to compute the first 10

resp. 100 PEs with small systems/local knowledge bases in (15b) and with large systems/local theories in

34 INFSYS RR 14-03

1

10

100

T1 T2 T3 T4 T5

DMCS-1st

DMCSOPT-1st

DMCS-100

DMCSOPT-100

(a) T (25, 10, 5, 5)

0.1

1

10

100

D1 D2 D3 D4 D5

DMCS-1st

DMCSOPT-1st

DMCS-10

DMCSOPT-10

(b) D(10, 10, 5, 5)

0.1

1

10

100

1000

Z1 Z2 Z3 Z4 Z5

DMCS-1st

DMCSOPT-1st

DMCS-10

DMCSOPT-10

(c) Z(10, 10, 5, 5)

0.1

1

10

100

R1 R2 R3 R4 R5

DMCS-1st

DMCSOPT-1st

DMCS-10

DMCSOPT-10

(d) R(4, 10, 5, 5)

Figure 14: DMCS v.s. DMCSOPT in streaming mode

(15c). Excepting Ring (which behaves abnormally due to guess-and-check) one can see that:

• For DMCS, the streaming mode is definitely worth pursuing since DMCS in non-streaming mode timesout in many cases (see also Figure 13), while in streaming mode we still could find some answers after areasonable time.

• For DMCSOPT, the situation is a bit different, as streaming loses against non-streaming on smallinstances. This is due to the recomputation that the streaming mode pays for transferring just chunks ofpartial equilibria between contexts; furthermore, there are duplications between answers When one movesto larger systems and local knowledge bases, the streaming mode starts gaining back. However, it does notalways win, as recomputation still significantly takes time in some cases.

Summing up, when the system is small enough, one should try the non-streaming mode as it avoidsrecomputation and duplication of PEs between different rounds of computation. But for large systems,streaming can rescue us from timing out. Even if we have to pay for recomputation, it still helps in caseswhen some but not all results are needed, e.g. in brave query answering (membership of the query in somePE).

INFSYS RR 14-03 35

6.3.3 Effects of the package size in streaming mode

The considerations above raise the question of the optimal number of PEs that should be transferred in returnmessages between contexts. We will analyze the experimental results on the streaming mode with packagesizes 1, 10, and 100 to give some hints on this.

Figure 16 shows the average time to compute 1 PE of DMCSOPT in streaming mode with respect tothree package sizes. One can see that transferring just a single PE to get the first answer is acceptable in mostcases, in particular if no guessing is needed. However, a small package size is sometimes better, as one cansave communication time (sending once a package of 10 partial equilibria vs. sending ten times a packagewith a single PE). This setting (small package sizes like 10) will be more effective when communication isa big factor, which happens in real application where contexts are located at physically distributed nodes. Insuch cases, computing 10 partial equilibria should be faster than computing 1 PE in 10 consecutive times.

Furthermore, having package of size 1 is not safe in cases where guessing is applied, e.g., inR3(4, 20, 10, 10).For these cases, a large enough package size might help to cover the correct guess; but in general, there isno guarantee for such a coverage. To thoroughly solve this problem, one needs to apply conflict learning onthe whole MCS evaluation.

Also, it is interesting to see that with package size 100, DMCSOPT usually times out. The reason is thatthere are many duplications and once DMCSOPT is stuck with a local search branch that promises fewerthan 100 partial equilibria, the algorithm will lose time here without finding new unique answers and willeventually time out.

To find a good package size p with a specific setting (topology, system size, local theory size), one mayrun the system on a training set and apply binary search on p.

6.3.4 Effect of topology

A quick glance over all plots in Figures 13–16 reveals the pattern that the algorithms, especially the opti-mizations, perform better on tree than on zigzag and diamond, depending on DMCS or DMCSOPT, andworst on ring.

The system topology plays an important role here. The aspects that affect the performance of the algo-rithms are (i) number of connections, (ii) the structure of block trees and cut vertices, and (iii) acyclicity vs.cyclicity.

Regarding (i), the topology introduces the number of connections based on the system size. Tree hasfewer connections than Diamond and Zigzag, which reduces not only communication but also local solvingtime as fewer requests are made; and the performance of DMCS on these topologies proves this observation.If one follows this argument, then Ring must offer the best performance. However, this is actually not thecase due to aspect (iii) that we will shortly analyze below.

Concerning (ii), tree can be ultimately optimized as every intermediate node is a cut vertex. Hence,when applying the query plan for DMCSOPT, we can strip off all beliefs in PEs sent from child contexts toa parent context. In other words, only local beliefs at a context Ci are needed to be transferred back to itsparents. This drastically decreases the amount of information to be communicated, and more importantly,the number of calls to lsolve. Due to this special property, DMCSOPT performs extremely well on the treetopology, and scales to hundreds of contexts.

Comparing Diamond and Zigzag, they have the same number of cut vertices. However, Zigzag is con-verted to a linear topology with an optimal query plan (cf. Figure 11c), and therefore can be processed muchfaster than Diamond. In Figure 16, DMCSOPT scales on Zigzag to 70 contexts with an average time tocompute one answer that still better than the one on diamond with 25 contexts.

36 INFSYS RR 14-03

Regarding (iii), Ring is a cyclic topology while the other topologies are acyclic. Hence each of thealgorithms must do some guess-and-check at some context in the topology. Making the right guess is mostimportant, even more important than reducing communication and calls to local solvers. The result ofrunning DMCS and DMCSOPT on this topology (Figure 17) does not follow any pattern; it absolutelydepends on a specific instance whether the above sequential guessing luckily arrives at the result. Therefore,we frequently see that DMCS outperforms DMCSOPT in streaming mode, as in such cases, guessing atthe root context (after detecting the cycle) is more effective than guessing at the parent of the root contextaccording to the optimal query plan.

Based on these observations, one can come up with a best strategy to evaluate different types of topolo-gies. When dealing with MCSs of arbitrary topologies, it looks natural to decompose them into parts offamiliar topologies for which efficient strategies are known, and to combine then these strategies to an over-all evaluation method. Studying this is beyond the scope of this work and an interesting issue for futureresearch.

6.3.5 Behavior on deterministic contexts

Above we considered our algorithms on MCSs consisting of possibly non-deterministic contexts, i.e., theycan have more than one acceptable belief set per knowledge base. It is intriguing to see how the algorithmsbehave if all contexts always have exactly one accepted belief set per knowledge base; this might be becausethe the underlying logic is genuinely “deterministic” and the accepted belief set clear (e.g., closure in clas-sical logic) or among multiple candidates a particular belief set is chosen (in implementations typically thefirst or a “best” solution computed, e.g. in SAT solving or in ASP). We observed that:

• for non-cyclic topologies, there is no difference in performance between DMCS and DMCSOPT, be-cause the smaller interface used in DMCSOPT does not reduce the number of intermediate PEs transferredbetween contexts, as there is only one partial equilibrium computed at every context.

• for cyclic topology (Ring), guessing plays the main role. Hence it depends on the individual instancewhether DMCS or DMCSOPT wins, like in the case of non-deterministic contexts (cf. Section 6.3.4). .

• non-streaming mode is much faster than streaming (on both DMCS and DMCSOPT); this is reasonableas any request for further partial equilibria is redundant.

6.3.6 Summary

Summing up, the analysis of the experimental results shows that there is no clear winner among the algo-rithms (DMCS vs. DMCSOPT) under different running modes (streaming vs. non-streaming, with differentpackage size) on different topologies. We can distill from it a guideline to choose the setup that fits specificinstances in practice, including some issues open for further investigation, which can be briefly stated asfollows:

• choose DMCSOPT over DMCS in non-streaming mode, except for cyclic topologies;

• in streaming mode, choose an appropriate package size carefully (e.g., doing a binary search on sometraining instances;

• decompose random topologies into parts whose topologies have effective strategies to evaluate, andstudy how to combine the strategies for the over allsystem.

INFSYS RR 14-03 37

7 Related Work

In this section, we resume the discussion of related work. Starting with multi-context systems, we providemore details on [Roelofsen et al., 2004, Bikakis et al., 2011] and consider other work. We then move torelated formalisms in SAT, CSP and ASP.

[Roelofsen et al., 2004] described evaluation of monotone MCS with classical theories using SAT solversfor the contexts in parallel. They used a (co-inductive) fixpoint strategy to check MCS satisfiability, wherea centralized process iteratively combines results of the SAT solvers. Apart from being not truly distributed,an extension to nonmonotonic MCS is non-obvious; furthermore, no caching technique was used.

[Serafini et al., 2005] and [Serafini and Tamilin, 2005] developed distributed tableaux algorithms forreasoning in distributed ontologies, which can be regarded as multi-context systems with special bridgerules. The algorithms serve to decide whether such a system is consistent, provided no cyclic contextdependencies exist (in technical terms, the distributed TBox is acyclic); the DRAGO system [Serafini andTamilin, 2005] implements this approach for OWL ontologies. Compared to ours, this work is tailored fora specific class of multi-context systems resp. knowledge bases, without nonmonotonic negation and cyclicdependencies (which are challenging); furthermore, it targets query answering rather than model building,which in a sense is a dual problem.

Most related to our work as regards distributed evaluation is the work of [Bikakis et al., 2011]. They de-veloped a distributed algorithm for query evaluation in a multi-context system framework that is specificallybased on (propositional) defeasible logic. In this framework, contexts are built using defeasible rules andcan exchange literals via bridge rules. Each knowledge base at a context has, in our terminology, a singleaccepted belief set which contains the literals concluded; the global system semantics is given in terms ofa (unique) three-valued assignment to all literals, which can be determined using the algorithm: whetherliteral l is provably (not) a logical conclusion of the system, or whether this remains open. Apart from beingtailored to a particular logic and preference mechanisms for evaluating interlinked contexts, applying thisalgorithm to model building is not straightforward; in particular, as it produces unique belief sets, dealingwith nondeterminism and multiple equilibria is not possible.

Our work on computing equilibria for distributed multi-context systems is clearly related to work onsolving constraint satisfaction problems (CSP) and SAT solving in a distributed setting; [Yokoo and Hi-rayama, 2000] survey some algorithms for distributed CSP solving, which are usually developed for a set-ting where each node (agent) holds exactly one variable, the constraints are binary, communication is donevia messages, and every node holds constraints in which it is involved. This is also adopted by later works[Gao et al., 2007] but can be generalized [Yokoo and Hirayama, 2000]. In relation to the topology-basedoptimization techniques in Section 4, biconnected components are used in [Baget and Tognetti, 2001] todecompose CSP problems. The decomposition is used to localize the computation of a single solution in thecomponents of undirected constraint graphs. Along the same lines, we are based on directed dependencies,which allows us to use a query plan for MCS evaluation.

The predominant solution methods in CSP are backtracking algorithms. [Bessiere et al., 2011] tookthem a step further with backtracking on a dynamic total ordering between agents guided by nogoods. Ourapproach, however, allows for cyclic dependency between contexts. In [Hirayama and Yokoo, 2005], asuite of algorithms was presented for solving distributed SAT (DisSAT), based on a random assignment andimprovement flips to reduce conflicts. However, the algorithms are geared towards finding a single model,and an extension to streaming multiple (or all) models is not straightforward; for other works on distributedCSP and SAT, this is similar.

Finally, (distributed) SAT and CSP solving concerns monotonic systems (removal of clauses resp. con-

38 INFSYS RR 14-03

straints preserves satisfiability), while MCSs evaluation concerns nonmonotonic systems, even if all contextswere monotonic (e.g., clause sets); this makes efficient evaluation more difficult, as important structuralproperties of the search space cannot be exploited.

[Adjiman et al., 2006] presented a framework of peer-to-peer inference systems, where local theories ofpropositional clause sets share atoms and a special algorithm for consequence finding is available. As wepursue the dual problem of model building, applying it for our needs is not straightforward; furthermore,we are dealing with non-monotonic systems, while the peer-peer systems in [Adjiman et al., 2006] aremonotonic.

Moving to ASP, [Pontelli et al., 2011] ASP-PROLOG shares with MCS the idea of integrating severalknowledge bases, called modules, possibly under different semantics. However, they restricted module se-mantics to ASP and Prolog (that is, the least Herbrand model), and ASP-PROLOG pursues query answeringinstead of model building.

As for streaming, an answer set streaming algorithm for HEX-programs (which generalize ASP with ex-ternal information access) was given in [Eiter et al., 2011]. Despite some similarities to Algorithm DMCS-STREAMING,it is rather different: monolithic programs are syntactically decomposed into modules and answer sets com-puted in a modular fashion; it is not fully distributed and combines partial models from lower componentsto input for upper components straightforwardly; moreover, it may use exponential space in components.

8 Conclusion

We have considered distributed evaluation of Multi-Context Systems (MCSs) that were introduced in [Brewkaand Eiter, 2007] as a general formalism to interlink possibly nonmonotonic and heterogeneous knowledgebases. We have presented a suite of generic algorithms to compute the equilibria, i.e., the semantics of anMCS in a fully distributed manner, using local solvers for the knowledge bases at the contexts. It containsa basic algorithm DMCS, an advanced version DMCSOPT that uses topology-based optimizations, and astreaming variant DMCS-STREAMING for computing partial equilibria gradually. We believe that the un-derlying principles and techniques might be exploited in related contexts, and in particular for distributedevaluation of other non-monotonic knowledge base formalisms.

The algorithms have been implemented in a prototype system that is available as open source. On topof this implementation, we have conducted comprehensive experiments to compare the performance of thealgorithms and we gave an insight analysis on the results. It points out advantages, disadvantages as well asthe time/memory trade off between the algorithms in different situations depending on parameters such assystem topology, local interface and theory size, and number of equilibria desired by the user. Based on this,the user can choose the setting (algorithm and mode) that fits her need best for finding (partial) equilibria ofan MCS. A more extensive treatment is given in [Dao-Tran, 2014].

Further work and open issues. Several issues remain for further investigation. One is further improvementof the algorithms. Here, the experimental results on the Ring topology strongly suggest to incorporateconflict learning, which proved to be valuable in ASP and SAT solving, to in DMCS and DMCSOPT; weexpect that cyclic topologies will benefit from a better guided guessing process. Another issue concernsfurther semantics and variants of MCSs. As for the former, grounded equilibria are considered in [Dao-Tran, 2014], which are akin to answer sets of logic programs and applicable to MCSs that satisfy certainalgebraic conditions; they can be characterized like answer sets using an (adapted) loop formula approach[Lee and Lifschitz, 2003]. Dealing with supported equilibria [Tasharrofi and Ternovska, 2014], however, isopen.

INFSYS RR 14-03 39

Regarding MCS variants, managed MCSs [Brewka et al., 2011b] generalize bridge rules to derive op-erations (commands) for a management function that is applied on the knowledge bases; it seems possibleto generalize our algorithms to this setting, but an efficient realization is not straightforward. Another gen-eralization of MCS concerns dynamic data: in areas like sensor networks, social networks, or smart cityapplications, data may change or even continuously arrive at nodes, which motivates reactive and streamprocessing for MCSs [Goncalves et al., 2014, Brewka et al., 2014]. Extending our algorithms to thesesettings is interesting but challenging.

Finally, extending this work to query answering over MCSs, where the user poses a query at a contextand receives results derived from (partial) equilibria is another natural issue. As there is no need for buildingwhole equilibria, better performance may be achieved.

References

P. Adjiman, P. Chatalic, F. Goasdoue, M.-C. Rousset, and L. Simon. Distributed reasoning in a peer-to-peersetting: Application to the semantic web. J. Artif. Intell. Res., 25:269–314, 2006.

A. Analyti, G. Antoniou, and C. V. Damasio. MWeb: A principled framework for modular web rule basesand its semantics. ACM Trans. Comput. Log., 12(2):17, 2011.

F. Baader, D. Calvanese, D. McGuinness, D. Nardi, and P. F. Patel-Schneider, editors. The DescriptionLogic Handbook. Cambridge University Press, 2003.

J.-F. Baget and Y. S. Tognetti. Backtracking through biconnected components of a constraint graph. InB. Nebel, editor, Proceedings of the Seventeenth International Joint Conference on Artificial Intelligence,IJCAI 2001, Seattle, Washington, USA, August 4-10, 2001, pages 291–296. Morgan Kaufmann, August2001.

S. E.-D. Bairakdar, M. Dao-Tran, T. Eiter, M. Fink, and T. Krennwallner. The DMCS solver for distributednonmonotonic multi-context systems. In T. Janhunen and I. Niemela, editors, Logics in Artificial Intelli-gence - 12th European Conference, JELIA 2010, Helsinki, Finland, September 13-15, 2010. Proceedings,volume 6341 of Lecture Notes in Computer Science, pages 352–355. Springer, September 2010a.

S. E.-D. Bairakdar, M. Dao-Tran, T. Eiter, M. Fink, and T. Krennwallner. Decomposition of distributednonmonotonic multi-context systems. In T. Janhunen and I. Niemela, editors, Logics in Artificial Intelli-gence - 12th European Conference, JELIA 2010, Helsinki, Finland, September 13-15, 2010. Proceedings,volume 6341 of Lecture Notes in Computer Science, pages 24–37. Springer, September 2010b.

C. Bessiere, E. Bouyakhf, Y. Mechqrane, and M. Wahbi. Agile asynchronous backtracking for distributedconstraint satisfaction problems. In IEEE 23rd International Conference on Tools with Artificial Intelli-gence, ICTAI 2011, Boca Raton, FL, USA, November 7-9, 2011, pages 777–784, 2011.

A. Bikakis and G. Antoniou. Defeasible contextual reasoning with arguments in ambient intelligence. IEEETransactions on Knowledge and Data Engineering, 22(11):1492–1506, 2010.

A. Bikakis, G. Antoniou, and P. Hassapis. Strategies for contextual reasoning with conflicts in ambientintelligence. Knowl. Inf. Syst., 27(1):45–84, 2011.

40 INFSYS RR 14-03

M. Bogl, T. Eiter, M. Fink, and P. Schuller. The MCS-IE system for explaining inconsistency in multi-context systems. In Logics in Artificial Intelligence - 12th European Conference, JELIA 2010, Helsinki,Finland, September 13-15, 2010. Proceedings, volume 6341 of Lecture Notes in Computer Science, pages356–359. Springer, 2010.

A. Bondy and U. S. R. Murty. Graph Theory, volume 244 of Graduate Texts in Mathematics. Springer,2008.

G. Brewka and T. Eiter. Equilibria in heterogeneous nonmonotonic multi-context systems. In Proceedingsof the Twenty-Second AAAI Conference on Artificial Intelligence, July 22-26, 2007, Vancouver, BritishColumbia, Canada, pages 385–390. AAAI Press, 2007.

G. Brewka, F. Roelofsen, and L. Serafini. Contextual default reasoning. In M. M. Veloso, editor, IJCAI2007, Proceedings of the 20th International Joint Conference on Artificial Intelligence, Hyderabad, India,January 6-12, 2007, pages 268–273, 2007.

G. Brewka, T. Eiter, and M. Fink. Nonmonotonic Multi-Context Systems: A Flexible Approach for Integrat-ing Heterogeneous Knowledge Sources. In M. Balduccini and T. C. Son, editors, Logic Programming,Knowledge Representation, and Nonmonotonic Reasoning - Essays Dedicated to Michael Gelfond on theOccasion of His 65th Birthday, volume 6565 of Lecture Notes in Computer Science, pages 233–258.Springer, 2011a.

G. Brewka, T. Eiter, M. Fink, and A. Weinzierl. Managed multi-context systems. In T. Walsh, editor,Proceedings of the 22nd International Joint Conference on Artificial Intelligence (IJCAI-11), pages 786–791. AAAI Press/IJCAI, 2011b.

G. Brewka, S. Ellmauthaler, and J. Puhrer. Multi-context systems for reactive reasoning in dynamic environ-ments. In S. Ellmauthaler and J. Puhrer, editors, Proceedings of the International Workshop on ReactiveConcepts in Knowledge Representation (ReactKnow) 2014, pages 23–30. Tech.Rep. 1, Computer ScienceInstitute, Univ. Leipzig, ISSN 1430-3701, 2014.

F. Buccafurri and G. Caminiti. Logic programming with social features. Theory and Practice of LogicProgramming, 8(5-6):643–690, 2008.

M. Dao-Tran. Distributed Nonmonotonic Multi-Context Systems: Algorithms and Efficient Evaluation. PhDthesis, Faculty of Informatics, Vienna University of Technology, Austria, Jan. 2014.

M. Dao-Tran, T. Eiter, M. Fink, and T. Krennwallner. Distributed nonmonotonic multi-context systems. InF. Lin, U. Sattler, and M. Truszczynski, editors, Principles of Knowledge Representation and Reasoning:Proceedings of the Twelfth International Conference, KR 2010, Toronto, Ontario, Canada, May 9-13,2010. AAAI Press, 2010.

M. Dao-Tran, T. Eiter, M. Fink, and T. Krennwallner. Model streaming for distributed multi-context systems.In A. Mileo and M. Fink, editors, 2nd International Workshop on Logic-based Interpretation of Context:Modeling and Applications, volume 738 of CEUR Workshop Proceedings, pages 11–22, May 2011.

T. Eiter, G. Ianni, R. Schindlauer, and H. Tompits. A uniform integration of higher-order reasoning andexternal evaluations in answer-set programming. In IJCAI, pages 90–96, 2005.

INFSYS RR 14-03 41

T. Eiter, M. Fink, G. Ianni, T. Krennwallner, and P. Schuller. Pushing efficient evaluation of hex programsby modular decomposition. In J. P. Delgrande and W. Faber, editors, 11th International Conference onLogic Programming and Nonmonotonic Reasoning (LPNMR 2011), Vancouver, BC, Canada, May 16-19,2011, volume 6645 of Lecture Notes in Computer Science, pages 93–106. Springer, May 2011.

B. Faltings and M. Yokoo. Introduction: Special issue on distributed constraint satisfaction. Artif. Intell.,161(1-2):1–5, 2005.

M. Fink, L. Ghionna, and A. Weinzierl. Relational information exchange and aggregation in multi-contextsystems. In J. P. Delgrande and W. Faber, editors, 11th International Conference on Logic Programmingand Nonmonotonic Reasoning (LPNMR 2011), Vancouver, BC, Canada, 16-19 May, 2011, volume 6645of Lecture Notes in Computer Science, pages 120–133. Springer, May 2011.

J. Gao, J. Sun, and Y. Zhang. An improved concurrent search algorithm for distributed CSPs. In AustralianConference on Artificial Intelligence, pages 181–190, 2007.

M. Gelfond and V. Lifschitz. Classical negation in logic programs and disjunctive databases. New Genera-tion Comput., 9(3/4):365–386, 1991.

C. Ghidini and F. Giunchiglia. Local models semantics, or contextual reasoning=locality+compatibility.Artif. Intell., 127(2):221–259, 2001.

F. Giunchiglia. Contextual Reasoning. Epistemologia, Special Issue on I Linguaggi e le Macchine, 345:345–364, 1992.

F. Giunchiglia and L. Serafini. Multilanguage hierarchical logics or: How we can do without modal logics.Artif. Intell., 65(1):29–70, 1994.

R. Goncalves, M. Knorr, and J. Leite. Evolving multi-context systems. In T. Schaub, G. Friedrich,and B. O’Sullivan, editors, Proceedings of the 21st Eureopean Conference on Artificial Intelligence,ECAI’2014, Prague, Czech Republic, August 18-23, 2014. IOS Press, 2014.

K. Hirayama and M. Yokoo. The distributed breakout algorithms. Artif. Intell., 161(1–2):89–115, 2005.

M. Homola. Semantic Investigations in Distributed Ontologies. PhD thesis, Comenius University,Bratislava, Slovakia, 2010.

J. Lee and V. Lifschitz. Loop formulas for disjunctive logic programs. In C. Palamidessi, editor, LogicProgramming, 19th International Conference, ICLP 2003, Mumbai, India, December 9-13, 2003, Pro-ceedings, Lecture Notes in Computer Science, pages 451–465. Springer, 2003.

J. McCarthy. Notes on formalizing context. In R. Bajcsy, editor, Proceedings of the 13th International JointConference on Artificial Intelligence. Chambery, France, August 28 - September 3, 1993, pages 555–562.Morgan Kaufmann, 1993.

E. Pontelli, T. Son, and N.-H. Nguyen. Combining answer set programming and prolog: The ASP-PROLOGsystem. In M. Balduccini and T. Son, editors, Logic Programming, Knowledge Representation, andNonmonotonic Reasoning, volume 6565, pages 452–472. Springer Berlin Heidelberg, 2011.

R. Reiter. A logic for default reasoning. Artificial Intelligence, 13:81–132, 1980.

42 INFSYS RR 14-03

F. Roelofsen, L. Serafini, and A. Cimatti. Many hands make light work: Localized satisfiability for multi-context systems. In R. L. de Mantaras and L. Saitta, editors, Proceedings of the 16th Eureopean Confer-ence on Artificial Intelligence, ECAI’2004, including Prestigious Applicants of Intelligent Systems, PAIS2004, Valencia, Spain, August 22-27, 2004, pages 58–62. IOS Press, August 2004.

L. Serafini and A. Tamilin. Drago: Distributed reasoning architecture for the semantic web. In A. Gomez-Perez and J. Euzenat, editors, The Semantic Web: Research and Applications, Second European SemanticWeb Conference, ESWC 2005, Heraklion, Crete, Greece, May 29 - June 1, 2005, Proceedings, LectureNotes in Computer Science, pages 361–376. Springer, 2005.

L. Serafini, A. Borgida, and A. Tamilin. Aspects of distributed and modular ontology reasoning. In Nine-teenth International Joint Conference on Artificial Intelligence (IJCAI 2005), pages 570–575. AAAIPress, 2005.

S. Tasharrofi and E. Ternovska. Generalized multi-context systems. In C. Baral, G. D. Giacomo, and T. Eiter,editors, Principles of Knowledge Representation and Reasoning: Proceedings of the Fourteenth Interna-tional Conference, KR 2014, Vienna, Austria, July 20-24, 2014. AAAI Press, 2014. ISBN 978-1-57735-657-8. URL http://www.aaai.org/ocs/index.php/KR/KR14/paper/view/8024.

J. Valdes, R. E. Tarjan, and E. L. Lawler. The recognition of series parallel digraphs. SIAM J. Comput., 11(2):298–313, 1982.

D. Vats and J. M. F. Moura. Graphical models as block-tree graphs. CoRR, abs/1007.0563, 2010.

M. Velikova, P. Novak, B. Huijbrechts, J. Laarhuis, J. Hoeksma, and S. Michels. An Integrated Recon-figurable System for Maritime Situational Awareness. In ECAI 2014 - 21st European Conference onArtificial Intelligence, 18-22 August 2014, Prague, Czech Republic - Including Prestigious Applicationsof Intelligent Systems (PAIS 2014), pages 1197–1202, 2014.

M. Yokoo and K. Hirayama. Algorithms for distributed constraint satisfaction: A review. AutonomousAgents and Multi-Agent Systems, 3(2):185–207, 2000.

Appendix A. Proofs

Proof of Theorem 1

To prove this theorem, we first prove the following Lemmas 9 and 10. The latter aims at simplifying theproof for the cyclic case, based on the notion of converting cyclic MCSs to acyclic ones.

Lemma 9 For any context Ck and partial belief state S of an MCS M = (C1, . . . , Cn), app(brk, S) =app(brk, S|V ) for all VΣ ⊇ V ⊇ V ∗(k).

Proof For any r ∈ app(brk, S), we have that for all (ci : pi) ∈ B+(r) : pi ∈ Sci and for all (cj : pj) ∈B−(r) : pj /∈ Scj . We need to show that pi ∈ Sci |Vci

∧ pj /∈ Scj |Vcj. Indeed:

We have V ⊆ VΣ ⇒ Vcj ⊆ VΣj ⇒ Scj |Vcj⊆ Scj . Therefore, pj /∈ Scj ⇒ pj /∈ Scj |Vcj

.Now, assume that pi /∈ Sci |V . From the fact that pi ∈ Sci , it follows that pi /∈ Vci , hence pi /∈ V ∗(k).

But this is in contradiction with the fact that pi occurs some bridge rule body.Therefore, r ∈ app(brk, S|V ). �

INFSYS RR 14-03 43

The next Lemma 10 is based on the following notions that convert cyclic MCSs to acyclic ones andshow that they have corresponding equilibria. The idea is to introduce an additional context Cg

k for everycycle breaker Ck and to modify the bridge rules of Ck as well as its parent contexts. We start with a functionren that renames part of bridge rules.

Definition 12 Let Ck be a context in an MCS M , and let V be an interface for running DMCS. Therenaming function ren is defined as follows:

• For an atom a: ren(a, k, V ) =

{ag if a ∈ Σk ∩ Va otherwise

• For a context index c: ren(c, k, V ) =

{c if c ∈ {1, . . . , n}c otherwise

• For a bridge atom (ci : pi): ren((ci : pi), k, V ) = (ren(ci, k, V ) : ren(pi, k, V ))

• For a bridge body B = {(c1 : p1) . . . (cj : pj)}:ren(B, k, V ) = {ren((ci : pi), k, V ) | (ci : pi) ∈ B}

• For a bridge rule r = head(r)← B(r):

ren(r, k, V ) = head(r)← ren(B(r), k, V )

• For a set of bridge rules br : ren(br , k, V ) = {ren(r, k, V ) | r ∈ br}• For a context Ci = (Li, kbi, br i) in M : ren(Ci, k, V ) = (Li, kbi, ren(bri, k, V )).

For two contexts Ci and Cj , the former is called a parent of the latter with respect to an interface V ,denoted by parent(Ci, Cj , V ) iff there exists a bridge rule r ∈ br i such that there exists (c : p) ∈ B(r) andp ∈ Σj ∩ V .

A set of contexts {Cc1 , Cc2 , . . . , Cc`} of an MCS M is called a cycle w.r.t. an interface V iff

parent(Cc` , C1) ∧∧

1≤i≤`−1

parent(Cci , Cci+1)

holds. One can pick an arbitrary context in this set to be its cycle-breaker. Given an MCS M , there areseveral way to choose a (finite) set of its contexts to be cycle-breakers. In Algorithm DMCS, Step (d)practically establishes the cycle-breakers based on the order that elements in In(k) are iterated. For the nextdefinition, we are interested in this particular set of cycle-breakers.

Definition 13 Given an MCS M = (C1, . . . , Cn) and let CBrM = {Cc1 , . . . , Ccj} be the set of cycle-breakers for M based on the application of DMCS on M starting from context Cr. The conversion of M toan equal acyclic M? based on CBrM and an interface V is done as follows:

Let C ′i = (Li, kbi, br ′i) =

{ren(Ci, i, V ) if Ci ∈ CBrMCi otherwise

Let C ′′i = (Li, kbi, br ′′i ) = ◦Ck∈CBM ren(C ′i, k, V )

Let C ′′′i = (Li, kbi, br ′′′i ) where br ′′′i =

{br ′′i ∪ {a← (i : ag)} if Ci ∈ CBrMbr ′′i otherwise

For eachCj ∈ CBM , introduceCj = (Lj , kbj , br j) where br j = ∅ and kbj = {ag∨¬ag | a ∈ Σj∩V }.Then M? = (C ′′′1 , . . . , C

′′′n , Cc1 , . . . , Ccj ).

44 INFSYS RR 14-03

Lemma 10 Let M be an MCS and M? be its conversion to an acyclic MCS as in Definition 13. Then theequilibria of M and M? are in 1-1 correspondence.

Proof (Sketch) Let (R1) and (R2) be the runs of DMCS on M and M?, respectively. Due to the selectionof CBrM to construct M?, both (R1) and (R2) have the same order visiting the contexts, except that when(R1) revisits a cycle-breaker Ck ∈ CBrM , its counterpart (R2) visits Ck. At these corresponding locations:

• (R1) calls guess(V,Ck) at Step (c), and

• (R2) calls lsolve({ε, . . . , ε}) at Step (e) since Ck is a leaf context.

The construction of the local knowledge base of Ck gives us exactly the guess on Ck. Furthermore, theseguesses are passed on to the parent contexts of Ck and then later on unified by the additional bridge rulesa ← (k : ag) introduced in br ′′′k . Therefore, the belief combinations (Step (d)) done at Ck are executed onthe same input on two runs (R1) and (R2). The correspondence of equilibria hence follows. �

Proof (Theorem 1) Thanks to Lemma 10, we now need to prove Theorem 1 only for the acyclic case andautomatically get the result for the cyclic case.

(⇒) We start by showing soundness of DMCS. Let S′ ∈ Ck.DMCS(V, ∅) such that V ⊇ V ∗(k). We shownow that there is a partial equilibrium S of an acyclic M w.r.t. Ck such that S′ = S|V . We proceed bystructural induction on the topology of M .

Base case: Ck is a leaf with In(k) = ∅ and brk = ∅ and k /∈ hist . This means that (d) is not executed,hence, in (e), lsolve runs exactly once on (ε, . . . , ε), and we get as result the set of all belief states S =lsolve((ε, . . . , ε)) = {(ε, . . . , ε, Tk, ε, . . . , ε) | Tk ∈ ACCk(kbk)}. We now show that S′ ∈ S|V . Towards acontradiction, assume that there is no partial equilibrium S = (S1, . . . , Sn) of M w.r.t. Ck such that S′ =S|V . From In(k) = ∅, we get that IC (k) = {k}, thus the partial belief state (ε, . . . , ε, Tk, ε, . . . , ε) ∈ S is apartial equilibrium of M w.r.t. Ck. Contradiction.

Induction step: assume context Ck has import neighborhood In(k) = {i1, . . . , im} and

Si1 = Ci1 .DMCS(V, hist ∪ {k}),...

Sim = Cim .DMCS(V, hist ∪ {k}).

Then by the induction hypothesis, for every S′ij ∈ Sij , there exists a partial equilibrium Sij of M w.r.t. Cij

such that Sij |V = S′ij .Let S = Ck.DMCS(V, hist). We need to show that for every S′ ∈ S , there is a partial equilibrium of

M w.r.t. Ck such that S′ = S|V . Indeed, since In(k) 6= ∅, Step (d) is executed; let

T = Si1 ./ · · · ./ Sim

be the result of combining partial belief states from calling DMCS at Ci1 , . . . , Cim . Furthermore, let S =⋃{lsolve(S) | S ∈ T } be the result of executing Step (e). Eventually, S′ ∈ S|V . Since every DMCS atCi1 , . . . , Cim returns its partial equilibria w.r.t. Cij projected to V , we have that every T ∈ T is a partialequilibrium w.r.t. Cij projected to V . M is acyclic and we have visited all contexts from In(k), thus byLemma 9 we get that for every T ∈ T , app(brk, T ) gives us all applicable bridge rules r regardless of

INFSYS RR 14-03 45

Tj = ε in T , for j /∈ In(k). Hence, for all T ∈ T , lsolve(T ) returns only partial belief states, where eachcomponent is projected to V except the kth component. As every T ∈ T preserves applicability of the rulesby Lemma 9, we get that for every S′ ∈ S|V , there exists a partial equilibrium S of M w.r.t. Ck such thatS′ = S|V .

(⇐) We give now a proof for completeness of DMCS by structural induction on the topology of an acyclicM . Let S = (S1, . . . , Sn) be a partial equilibrium of M w.r.t. Ck and let S′ = S|V . We show now thatS′ ∈ Ck.DMCS(V, ∅).

Base case: Ck is a leaf context. Then in executing Ck.DMCS(V, ∅), step (d) is ignored and step (e) is calledwith input (ε, . . . , ε), and lsolve((ε, . . . , ε)) gives us all belief sets S of Ck. As S is an equilibrium of Mw.r.t. Ck, S ∈ S; hence, S′ = S|V will be returned from Ck.DMCS(V, ∅).

Induction case: suppose that the import neighborhood of context Ck is In(k) = {i1, . . . , im}. Let therestriction of S to every context Cij ∈ In(k) be denoted by Sij , where:

Sij = (S′1, . . . , S′n) where S′` =

{S` if ` ∈ IC (ij)ε otherwise

Informally speaking, this restriction keeps only belief sets of the contexts reachable from Cij and sets thoseof non-reachable contexts to ε. By the induction hypothesis, Sij |V is computed by Cij .DMCS(V, ∅) for allij ∈ In(k). We will show that S|V is computed by Ck.DMCS(V, ∅).

Indeed, because we are considering an acyclic M , it holds that Sij |V is also returned from a callCij .DMCS(V, {k}), as k plays no role in further calls from Cij to its neighbors. This means that afterstep (d), T contains a T = Si1 ./ . . . ./ Sim where Sij appears at position ij in S.

Since S is a partial equilibrium of M w.r.t. Ck, we have that Sk ∈ ACCk(kbk ∪ {head(r) | r ∈app(brk, S)}). Furthermore, by choosing V ⊇ V ∗(k), Lemma 9 tells us that the applicability of bridgerules is preserved under the projection of belief sets to V . This gives us that Sk ∈ lsolve(T ) in step (e), andhence S′ = S|V is returned from Ck.DMCS(V, ∅). �

Proof of Proposition 4

(1) For a context Ck, let the number of calls to its local solver be denoted by c(k). It is decided in computingT in Step (d), which is bounded by the maximal number of combined partial belief sets from its neighbors.Formally speaking:

c(k) ≤ Πi∈In(k)2|V ∩Σi| ≤ 2|In(k)|×|V | ≤ 2n×|V |.

Hence for the whole MCS, the upper bound of calls to lsolve in a run of DMCS is

c = Σ1≤k≤nc(k) ≤ n× 2n×|V |

(2) For a context Ck of an MCS M = (C1, . . . , Cn), the set E(k) contains all dependencies from contextsCi for i ∈ IC (k). We visit all (i, j) ∈ E(k) exactly twice during DFS-traversal of M : once when callingCj .DMCS(V, hist) at Ci, and once when retrieving S|V from Cj in Ci. Furthermore, the caching techniquein Step (a) prevents recomputation on already visited nodes, thus prevents recommunication in the subtreeof any visited node. The claim hence follows. �

46 INFSYS RR 14-03

Proof of Proposition 5

Item (i) is trivial to see since CycleBreaker is applied in Algorithm 4. To prove item (ii), let us look at twocases in which an edge (`, t) is removed from the original topology at Step (a) of Algorithm 3:

• (`, t) is removed by CycleBreaker: this causes that certain nodes in the graph cannot reach t via `.However, the interface that Ct provides is already attached to v(i, j) via V ∗(cp)|Σt .

• (`, t) is removed by transitive reduction: this does not change the reachability of t from other nodes;therefore, the interface that Ct provides is already included in V ∗(i, j)B′ .

This argument gives us property (ii). �

Proof of Proposition 6

First, we estimate the complexity to compute v(i, j) in loop (a).

v(i, j) := V ∗(i, j)B′ ∪⋃c∈C′

V ∗(cp)|Σc ∪⋃

(`,t)∈EV ∗(cp)|Σt

On the one hand, the refined recursive import V ∗(i, j)′B is defined as (Definition 9):

V ∗(i, j)′B = {V ∗(i) ∩⋃

`∈B′|jΣ`}

where B′|j contains all nodes reachable from j.On the other hand, since all signatures disjoint, we have that⋃

c∈C′V ∗(cp)|Σc ∪

⋃(`,t)∈E

V ∗(cp)|Σt = V ∗(cp)|⋃c∈C′ Σc∪

⋃(`,t)∈E Σt

Since the recursive import interface for a node k is defined as V ∗(k) =⋃

i∈IC (k) V (i), the expressionto compute v(i, j) is in the end a combination of set intersection, union, and projection. With an implemen-tation of sets using hash set, that is, look up takes O(1), these operators can be implemented in linear time.Therefore, v(i, j) can be computed in linear time in the size of the signatures of contexts in the system.

Given GM , the block tree graph T (GM ) can be constructed in linear time [Vats and Moura, 2010]. Ear-decomposition (Step (c)) can also be done in linear time [Valdes et al., 1982]. Transitive reduction (Step (d))can be computed in quadratic time with respect to the number of edges in the block.

OptimizeTree(T (GM ), k, k) iterates through all blocks. Assume that we have m blocks B1 . . . , Bm,and each Bi contains ni edges, where n = Σm

i=1ni is the total number of edges in the original graph. Let tibe the time to process block Bi. Then the bound of the total processing time can be assessed as follows:

t =

m∑i=1

ti ≤m∑i=1

n2i ≤ (

m∑i=1

ni)2 = n2.

Therefore, if we ignore loop (a), OptimizeTree can be done in quadratic time in the size of the original input,i.e., the size of GM . �

INFSYS RR 14-03 47

Proof of Theorem 7

To prove this, we need Proposition 11 to claim that partial equilibria returned from DMCS and DMCSOPTare in correspondence. But first, we need the following supportive notion.

Definition 14 Let Ck be a context of an MCS M , and let Πk be the query plan as in Definition 11. For eachblock B of Πk, the block interface of B, whose root vertex is cB , is

VB = {p ∈ v(i, j) | (i, j) ∈ E(B)} ∪ ΣcB .

Let Ci be a context in B. The self-recursive import interface of Ci in B is

V ∗(i)B = Σi ∪⋃

(i,`)∈E(Πk)

V ∗(i, `)B.

Proposition 11 Let Ck be a context of an MCS M , let Πk be the query plan as in Definition 11 in which Ck

belongs to block B of Πk and let V =⋃

B∈ΠkVB . Then,

(i) for each S′ ∈ DMCSOPT(k) called from Cc where (c, k) ∈ E(Πk) or c = k, there exists a partialequilibrium S ∈ Ck.DMCS(V, ∅) such that S′ = S|V ∗(c,k)B if (c, k) ∈ E(Πk) or S′ = S|V ∗(k)B ifc = k;

(ii) for each S ∈ Ck.DMCS(V, ∅), there exists some S ∈ DMCSOPT(k) called from Cc such that S′ =S|V ∗(c,k)B if (c, k) ∈ E(Πk) or S′ = S|V ∗(k)B if c = k.

A detailed proof for Proposition 11 is given in the next section, we now give a proof for Theorem 7.

Proof (Theorem 7) (i) Let S′ ∈ Ck.DMCSOPT(k) be a result from DMCSOPT. By Proposition 11 (i) forc = k, there exists an S′′ ∈ Ck.DMCS(V, ∅) such that S′ = S′′|V ∗(k)B , where we choose V =

⋃B∈Πk

VB .Note that V ∗(k) ⊆ V as V collects all bridge atoms from all blocks, which might contain blocks notreachable from k. By Theorem 1, there exists a partial equilibrium S of M such that S′′ = S|V . Thus, wehave that

S′ = (S|V )|V ∗(k)B

= S|V ∗(k)B because V ∗(k)B ⊆ V= S|

Vbecause V ⊆ V ∗(k)B

(ii) Let S be a partial equilibrium of M . By Theorem 1, there exists S′′ ∈ Ck.DMCS(V, ∅) such thatS′′ = S|V where we choose V =

⋃B∈Πk

VB . As above, V ∗(k) ⊆ V . By Proposition 11 (ii) for c = k,there exists S′ ∈ Ck.DMCSOPT(k) such that S′ = S′′|V ∗(k)B . As above, we have that S′ = S|

V. �

Proof of Proposition 11

To support the proof of Proposition 11, we need the following lemmas.

Lemma 12 Assume context Ck has import neighborhood In(k) = {i1, . . . , im}, no (k, ij) is removed fromthe original topology by OptimizeBlock(B, cB), and

S ′i1 = DMCSOPT(k) at Ci1 Si1 = Ci1 .DMCS(VB, ∅)...

...S ′im = DMCSOPT(k) at Cim Sim = Cim .DMCS(VB, ∅)

48 INFSYS RR 14-03

such that for every partial equilibrium S′ ∈ S ′ij , there exists S ∈ Sij such that S′ = S|V ∗(k,ij)B .Let T ′ = S ′i1 ./ . . . ./ S ′im and T = Si1 ./ . . . ./ Sim . Then, for each T ′ ∈ T ′, there exists T ∈ T

such that T ′ = T |Vinput (1,m) with Vinput(`1, `2) =⋃`2

j=`1V ∗(k, ij)B .

Proof We prove by induction on the number of neighbors in In(k).

Base case: In(k) = {i}, the claim trivially holds.

Induction case: In(k) = {i1, . . . , i`}, U ′ = S ′i1 ./ . . . ./ S ′i`−1 , U = Si1 ./ . . . ./ Si`−1 , and for eachU ′ ∈ U ′, there exists U ∈ U such that U ′ = U |Vinput(1,`−1)

. We need to show that for each T ′ ∈ U ′ ./ S ′i` ,there exists a T ∈ U ./ Si` such that T ′ = T |Vinput (1,`).

Assume that the opposite holds, i.e., there exists T = U ′ ./ S′ where U ′ ∈ U ′ and S′ ∈ S ′i` , and for allU ∈ U , S ∈ Si` such that U ′ = U |Vinput (1,`−1) and S′ = S|V ∗(k,i`)B , we have that U ./ S is void.

This means there exists a context Ct reachable from Ck by two different ways, one via i` and the othervia one of i1, . . . , i`−1 such that Ut 6= ε, St 6= ε, Ut 6= St, and either

(i) U ′t = ε or S′t = ε, or

(ii) U ′t = S′t 6= ε

Case (i) cannot happen becauseCt is reachable fromCk, hence Vinput(1, `−1)∩Σt 6= ∅ and V ∗(k, i`)∩Σt 6=∅.

Concerning case (ii), we have that Ut|Vinput (1,`−1) = St|V ∗(k,i`) 6= ε, hence there exists a ∈ Ut \Ut|Vinput (1,`−1) and a /∈ St|V ∗(k,i`). This means that Vinput(1, `− 1) ∩ Σt 6= V ∗(k, i`) ∩ Σt.

However, from Definition 9 of recursive import interface, we have that V ∗(k, ix)B = V ∗(k)∩⋃`∈B|k Σ`

where B|ix contains all nodes in B reachable from ix, it follows that V ∗(k, i`) and V ∗(k, ij) for any 1 ≤j ≤ `− 1 that reaches t, share the same projection to Σt, hence Vinput(1, `− 1) ∩ Σt = V ∗(k, i`) ∩ Σt.

We reach a contradiction, and therefore Lemma 12 is proved. �

Lemma 13 The join operator ./ has the following properties, given arbitrary belief states S, T , U with thesame size: (i) S ./ S = S (ii) S ./ T = T ./ S (iii) S ./ (T ./ U) = (S ./ T ) ./ U . These properties alsohold for sets of belief states.

Proof The first two properties are trivial to prove. We will prove associativity.Let R = S ./ (T ./ U) and W = (S ./ T ) ./ U . Consider doing the joins from left to right. At

each position i (1 ≤ i ≤ n), Ri and Wi are determined by locally comparing Si, Ti and Ui. If we reachinconsistency, the process terminates and void is returned; otherwise, we conclude the value for Ri, Wi andcontinue to the next position. The final join is returned if position n is processed without any inconsistency.

All possible combination of Si, Ti, and Wi are shown in Table 1. One can see that we always have thesame outcome forRi andWi. Therefore, we have in the end eitherR = W or both are void . This concludesthat the join operator ./ is commutative. �

Lemma 14 LetCi andCj be two contexts inM such that they are in the same block after OptimizeTree andthere is a directed path from Ci to Cj . Suppose that Si = DMCSOPT(k) at Ci and Sj = DMCSOPT(k)at Cj . Then Si = Si ./ Sj .

INFSYS RR 14-03 49

Si = ε Ti = ε Ui = ε Si = Ti Ti = Ui Ui = Si Ri Wi

Y Y Y Y Y Y ε ε

Y Y N Y N N Ui Ui

Y N Y N N Y Ti Ti

Y N N N Y N Ti Ti

N N N void voidN Y Y N Y N Si Si

N Y N N N Y Si Si

N N N void void

N N Y Y N N Si Si

N N N void void

N N N

Y Y Y Si Si

Y N N void voidN Y N void voidN N N void void

Table 1: Possible cases when joining at position ith

Proof The use of cache in DMCSOPT does not change the result and can be disregarded, i.e., we canassume without loss of generality that cache(k) = ∅ in DMCSOPT. Indeed, cache(k) is filled with theresult of the computation when it is empty (i.e., when Ck is accessed the first time), and is after that neverchanged and DMCSOPT just returns cache(k), i.e., the value of the computation with empty cache(k).

Under the above assumption, Lemma 14 can be proven by taking any path Ci = Cp1 , . . . , Cph = Cj

that connects Ci to Cj , and arguing that for each index ` ∈ {1, . . . , h}, it holds that Sp` = Sp` ./ Sj (?).Indeed, we can show this by an induction on the path.

Base case: ` = h, statement (?) holds as we have Sph ./ Sj = Sj ./ Sj = Sj by identity (Lemma (13), (i)).

Induction case: consider ` < h, and suppose we already established by the induction hypothesis thatSp`+1 = Sp`+1 ./ Sj .

Now by definition of Sp` and DMCSOPT, it holds that Sp` = lsolve(T )8 and T is, by the statements (b)and (c), of the form T = Sp`+1 ./ T ′; this holds because there is an edge (p`, p`+1) in E, and because ./ iscommutative and associative (Lemma (13), (ii) and (iii)). By the induction hypothesis, we get

T = Sp`+1 ./ T ′ = (Sp`+1 ./ Sj) ./ T ′ = Sj ./ (Sp`+1 ./ T ′),

that is, T is of the form Sj ./ T ′′.Next, lsolve(T ) does not change the value of any component of any interpretation I in T that is defined

in Sj ; that is, lsolve(T ) ./ Sj = lsolve(T ). This means Sp` = lsolve(T ) = lsolve(T ) ./ Sj = Sp` ./ Sj ,which proves statement (?) holds for `.

Eventually, we get for ` = 1 that Si = Sp1 = Sp1 ./ Sj = Si ./ Sj . �

Based on Lemma 14, we have the following result.

8With abuse of notation, we write lsolve(T ) for⋃

T∈T lsolve(T )

50 INFSYS RR 14-03

Lemma 15 Assume the import neighborhood of context Ck is In(k) = {i1, . . . , im}, and that Sij =DMCSOPT(k) at Cij , 1 ≤ j ≤ m. Furthermore, suppose that edge (k, ij) was removed by the opti-mization process (1 ≤ j ≤ m), and that Ci` is a neighbor of Ck such that there exists a path from k to ijthrough i` in the optimized topology. Then Si` = Si` ./ Sij ; in other words, the input to DMCSOPT at Ck

is not affected by the removal of (k, ij).

Proof Since Cij and Ci` are directed children of Ck, it follows that they belong to the same block. There-fore, by Lemma 14 we have that Si` = Si` ./ Sij . �

Proof (Proposition 11) We proceed by structural induction on the block tree of an MCS M . First, weconsider the case where the topology of M is a single block B. In this case, the interface passed to DMCSis V = VB .Base case: Ck is a leaf. Then we now compare a call DMCSOPT(k) at Ck and Ck.DMCS(V, ∅), whereV = V ∗(k)B = Σk. Algorithm 1 returns local belief sets of Ck projected to V and Algorithm 5 returnsplain local belief sets, the claim follows as V = V ∗(k)B = Σk.Induction case: Assume the import neighborhood of context Ck is In(k) = {i1, . . . , im}, and

S ′i1 = DMCSOPT(k) at Ci1 Si1 = Ci1 .DMCS(VB, ∅)...

...S ′im = DMCSOPT(k) at Cim Sim = Cim .DMCS(VB, ∅)

such that for every partial equilibrium S′ ∈ S ′ij , there exists S ∈ Sij such that S′ = S|V ∗(k,ij)B .There are two cases. First, no edge (k, ij) is removed by the optimization procedure. Then, by

Lemma 12, we have the correspondence between the input to DMCSOPT and DMCS at Ck.On the other hand, assume that an edge (k, ij) was removed by the optimization process. The removal

can be from either transitive reduction or ear decomposition. In the former case, Lemma 15 shows that theinput to Ck is not affected by the removal of this edge. For the latter case, the removal can be one of threepossibilities as illustrated in Figure 18, assuming that context C1 gets called:

(i) (6, 1), the last edge of the simple cycle P0 = {1, 2, 3, 4, 5, 6}

(ii) (9, 6), the last edge of path P1 = {5, 7, 8, 9, 6}

(iii) (12, 2), the last edge of path P2 = {3, 10, 11, 12}Cases (i) and (iii) differ from case (ii) in the sense that a cycle will be recognized by DMCS why for

case (ii), no cycle is detected along the corresponding path.Now, consider when (k, ij) is removed in situations similar to cases (i) and (iii), DMCSOPT will issue

a guess at Step (c) of Algorithm 5 on v(k, ij), which includes V ∗(cB)|Σij= VB ∩ Σij . On the other hand,

DMCS will recognize the cycle at Cij and issue a guess on VB ∩ Σij at Step (c) of Algorithm 1. Therefore,the guess is fed equally to Ck.

When (k, ij) is removed in situations similar to case (ii), all guesses of Ck on the interface from Cij

will be eventually filtered when being combined with the local belief states computed by Cij , at the startingnode of the path containing (k, ij) as the last edge (in the ear decomposition). In Figure 18, this is node 5.

In all cases, we have that whenever there is an input T ′ into lsolve in DMCSOPT(k) called by Cc, thereis an input T to lsolve in Ck.DMCS(VB, ∅). Therefore, the claim on the output holds.

Now that Proposition 11 holds for a single leaf block. One can see that the upper blocks only need toimport the interface beliefs from the cut vertices (also the root contexts of the lower blocks). Under the

INFSYS RR 14-03 51

setting of V =⋃

B∈ΠkVB , results from DMCSOPT and DMCS projected to the interface of the cut vertices

are identical. Therefore, the upper blocks receive the same input regarding the interfaces of the cut verticesin running both algorithms. And therefore the final results projected to V ∗(k)B are in the end the same. �

Proof of Proposition 8

Note that the components Handler and Output simply take care of the communication part of DMCS-STREAMING.Output makes sure that the models sent back to the invokers are in correspondence with the request thatHandler got. The other routines Joiner and Solver are the main components that play the role of Step (b)and (d) in Algorithm 5, respectively.

To prove the correctness of DMCS-STREAMING, we just need to show that the input to lsolve is com-plete in the sense that if Step (e) of Algorithm 8 is exhaustively executed, the full join of partial equilibriafrom the neighboring contexts is delivered.

Formally, assume that the current context’s import neighborhood is {1, 2, . . . ,m}. Assume that forneighbor Ci where 1 ≤ i ≤ m, the full partial equilibria are Ti and the returned packages of size k aredenoted by Ti,1, . . . , Ti,pi , that is, Ti = Ti,1 ∪ . . . ∪ Ti,pi . For the correctness of the algorithm, we assumethat Ti,1, . . . , Ti,pi is a fixed partition of Ti. This is possible when, for example, lsolve always returnsanswers in a fixed order. We need to show that the accumulation of the join by Algorithm 8 is actuallyT1 ./ . . . ./ Tm.

Indeed, each possible join T1,i1 ./ T2,i2 ./ . . . ./ Tm,im is considered by Joiner, which performs alexicographical traversal of all suitable combinations. Formally speaking, let F (p, q), where q < q, denotethe join result of neighbors from p to q, that is, F (p, q) = Tp ./ Tp+1 ./ . . . ./ Tq. According to thelexicographical order, we have that the accumulation of Joiner is

⋃p1j=1[T1,j ./ F (2,m)] = F (1,m) as

demonstrated in Table 2.This shows that the input to lsolve is complete. Hence, DMCS-STREAMING is correct. �

52 INFSYS RR 14-03

0.01

0.1

1

10

100

1000

-5 0 5 10 15 20 25 30

Non-StreamingStreaming-10

Streaming-100

R4,10,5,5

Z10,10,5,5

D10,10,5,5

T10,10,5,5

(a) DMCS

0.01

0.1

1

10

100

1000

-5 0 5 10 15 20 25 30

Non-StreamingStreaming-10

Streaming-100

R4,10,5,5

Z10,10,5,5

D10,10,5,5

T10,10,5,5

(b) DMCSOPT with small systems and local theories

0.01

0.1

1

10

100

1000

-5 0 5 10 15 20 25 30

Non-StreamingStreaming-10

Streaming-100

R4,20,10,10

Z10,20,10,10

D10,20,10,10

T31,20,10,10

(c) DMCSOPT with large systems and local theories

Figure 15: Non-streaming v.s. streaming under DMCS and DMCSOPT

INFSYS RR 14-03 53

0.001

0.01

0.1

1

10

100

1000

-5 0 5 10 15 20 25

Streaming-1Streaming-10

Streaming-100

R4,20,10,10

Z70,20,10,10

D25,20,10,10

T100,20,10,10

Figure 16: Average time of DMCSOPT to find one partial equilibrium in streaming mode, varying packagesize

1

10

100

1000

-2 0 2 4 6 8 10 12 14 16 18

DMCS-100DMCSOPT-100

R4,20,10,10

R7,10,5,5

R4,10,5,5

Figure 17: DMCS v.s. DMCSOPT in streaming mode with package size 100 on ring

1

2

3

4

5

6

7

8

9

10

11

12

Figure 18: Possible cycle breakings

54 INFSYS RR 14-03

T1,1 ./ T2,1 ./ · · · ./ Tm−1,1 ./ Tm,1 ∪· · · · · ·T1,1 ./ T2,1 ./ · · · ./ Tm−1,1 ./ Tm,pm

T1,1 ./ T2,1 ./ · · · ./ Tm−1,2 ./ Tm,1 ∪· · · · · ·T1,1 ./ T2,1 ./ · · · ./ Tm−1,2 ./ Tm,pm

∪· · · · · ·T1,1 ./ T2,1 ./ · · · ./ Tm−1,pm−1 ./ Tm,1 ∪· · · · · ·T1,1 ./ T2,1 ./ · · · ./ Tm−1,pm−1

./ Tm,pm∪

· · · · · ·T1,1 ./ T2,p2 ./ · · · ./ Tm−1,1 ./ Tm,1 ∪· · · · · ·T1,1 ./ T2,p2

./ · · · ./ Tm−1,pm−1./ Tm,pm

∪· · · · · ·T1,p1

./ T2,1 ./ · · · ./ Tm−1,p1./ Tm,1 ∪

· · · · · ·T1,p1 ./ T2,p2 ./ · · · ./ Tm−1,pm−1 ./ Tm,pm

= T1,1 ./ T2,1 ./ · · · ./ Tm−1,1 ./ F (m,m) ∪· · · · · ·T1,1 ./ T2,1 ./ · · · ./ Tm−1,pm−1 ./ F (m,m) ∪· · · · · ·T1,1 ./ T2,p2

./ · · · ./ Tm−1,1 ./ F (m,m) ∪· · · · · ·T1,1 ./ T2,p2

./ · · · ./ Tm−1,pm−1./ F (m,m) ∪

· · · · · ·T1,p1 ./ T2,p2 ./ · · · ./ Tm−1,pm−1 ./ F (m,m)

= T1,1 ./ T2,1 ./ · · · ./ F (m− 1,m) ∪· · · · · ·T1,1 ./ T2,p2

./ · · · ./ F (m− 1,m) ∪· · · · · ·T1,p1 ./ T2,p2 ./ · · · ./ F (m− 1,m)

= [T1,1 ./ F (2,m)] ∪ · · · ∪ [T1,p1./ F (2,m)]

= F (1,m).

Table 2: Accumulation of Joiner