# preferencebased_inconsistency_management_in_multicontext_systems__a85a9d47.pdf Journal of Artificial Intelligence Research 60 (2017) 347-424 Submitted 12/16; published 10/17 Preference-Based Inconsistency Management in Multi-Context Systems Thomas Eiter EITER@KR.TUWIEN.AC.AT Technische Universit at Wien Institut f ur Informationssysteme Abteilung f ur Wissensbasierte Systeme Favoritenstr. 9-11, 184/3 1040 Vienna, Austria Antonius Weinzierl ANTONIUS.WEINZIERL@AALTO.FI Aalto University Department of Computer Science Konemiehentie 2 02150 Espoo, Finland Multi-Context Systems (MCS) are a powerful framework for interlinking possibly heterogeneous, autonomous knowledge bases, where information can be exchanged among knowledge bases by designated bridge rules with negation as failure. An acknowledged issue with MCS is inconsistency that arises due to the information exchange. To remedy this problem, inconsistency removal has been proposed in terms of repairs, which modify bridge rules based on suitable notions for diagnosis of inconsistency. In general, multiple diagnoses and repairs do exist; this leaves the user, who arguably may oversee the inconsistency removal, with the task of selecting some repair among all possible ones. To aid in this regard, we extend the MCS framework with preference information for diagnoses, such that undesired diagnoses are filtered out and diagnoses that are most preferred according to a preference ordering are selected. We consider preference information at a generic level and develop meta-reasoning techniques on diagnoses in MCS that can be exploited to reduce preference-based selection of diagnoses to computing ordinary subset-minimal diagnoses in an extended MCS. We describe two meta-reasoning encodings for preference orders: the first is conceptually simple but may incur an exponential blowup. The second is increasing only linearly in size and based on duplicating the original MCS. The latter requires nondeterministic guessing if a subset-minimal among all most preferred diagnoses should be computed. However, a complexity analysis of diagnoses shows that this is worst-case optimal, and that in general, preferred diagnoses have the same complexity as subset-minimal ordinary diagnoses. Furthermore, (subset-minimal) filtered diagnoses and (subset-minimal) ordinary diagnoses also have the same complexity. 1. Introduction At the dawn of an age with growing information connectivity, the issue of interlinking and combining information from various knowledge sources is of increasing importance, posing a challenge to Artificial Intelligence and to Knowledge Representation and Reasoning in particular. Indeed, with the rise of the internet, sharing information has become as easy as never before, and a wealth of knowledge and information sources is available that can be accessed via communicating devices. Multi-Context Systems (Giunchiglia & Serafini, 1994; Roelofsen & Serafini, 2005; Brewka c 2017 AI Access Foundation. All rights reserved. EITER & WEINZIERL & Eiter, 2007; Bikakis & Antoniou, 2010) are a well-known approach to address the challenge of sharing information, where individual knowledge bases, called contexts, are interlinked with special bridge rules which govern the information exchange, such that a global semantics of the system emerges from the local semantics of the constituent knowledge bases. Some practical applications of MCS are defeasible reasoning in ambient intelligence (Bikakis & Antoniou, 2010), cooperation in distributed information systems (Caire & Bikakis, 2011), and the METIS system for maritime situation awareness support (Velikova et al., 2014). Rooted in the seminal work of Mc Carthy (1993), which proposed an explicit representation of context where combining different views may give a holistic picture of a situation, the Trento School around Giunchiglia and Serafini developed a notion of multi-context system that is geared to interlink possibly non-monotonic knowledge bases and can be utilized for query answering (Giunchiglia & Serafini, 1994; Ghidini & Giunchiglia, 2001; Roelofsen & Serafini, 2005; Brewka, Roelofsen, & Serafini, 2007). Brewka and Eiter (2007) generalized this to an abstract framework in which contexts can have heterogeneous knowledge bases that are described using a very abstract notion of logic; Context Knowledge Repositories (Serafini & Homola, 2012) evolved MCS in a different direction for the Semantic Web, where meta and object knowledge can be intermingled. For a more detailed overview of MCS, see the work of Brewka et al. (2011a). As the contexts of an MCS are typically autonomous and host knowledge bases that are inherited legacy systems, it may happen that the information exchange leads to unforeseen conclusions and in particular to inconsistency; to anticipate and handle all such situations at design time is difficult if not impossible, especially if sufficient details about the knowledge bases are lacking. Inconsistency of an MCS means that it has no model (called equilibrium) where a global model is composed of a local model for each context s knowledge base such that all bridge rules governing the information exchange are satisfied; thus, the whole MCS becomes useless. To repair an inconsistent MCS, basic notions for inconsistency management have been developed by Eiter, Fink, Sch uller, and Weinzierl (2010, 2014). Most notably, the notion of diagnosis formalizes the removal of an inconsistency by modifying the information exchange, that is, the bridge rules for the information flow between the contexts. However, while an arbitrary diagnosis restores consistency, the modified information exchange that it affects may have serious consequences, as shown in the following example. Example 1. Consider an MCS employed in a hospital, which interconnects three systems: (1) a patient knowledge base storing information e.g. about illnesses, insurance companies, and potential allergies of patients; (2) an expert system suggesting proper treatments to illnesses; and (3) a system billing the insurance company of patients for the administered treatments (a formal account is given later, cf. Example 3, Figure 1). The expert system only recommends treatments to which patients are not allergic, while the billing system only allows administered treatments that are covered by the insurance companies. Now suppose a patient with specific allergies can be cured only with a drug that is not covered by his/her insurance; this makes the whole MCS inconsistent and hence no treatment for any patient can be soundly inferred. It is easy to repair this inconsistency, e.g. by modifying the information flow such that either the illness or allergy of the patient is ignored, which results in either not treating the patient or causing an allergic reaction. An alternative repair is to not inform the billing system about the uncovered administration of the drug, so the patient is correctly treated at potential financial loss of the hospital. PREFERENCE-BASED INCONSISTENCY MANAGEMENT IN MULTI-CONTEXT SYSTEMS Fully-automated, unreflected inconsistency removal may ignore vital information and lead to dangerous results. It is thus desirable or even necessary to keep a human operator in the loop while selecting a suitable diagnosis for repair. However, in realistic scenarios often a large (even exponential) number of diagnoses exists, which makes careful manual selection a very time consuming task if not infeasible under time and cognitive constraints. The risk of choosing an improper diagnosis or ending up with no (approved) diagnosis clearly is an obstacle to the deployment of MCS to a broader range of application domains. Also note that inconsistency can arise in all applications: some context may consider certain data to be unrealistic, e.g. in ambient intelligence when the reading from a light sensor is regarded as too high after the janitor installed new light bulbs in the rooms; or some context may not expect to receive a certain combination of data from other contexts, e.g. in case of maritime control when a ship is reported to be both faster and bigger than in the record of the knowledge base. In the former case, removing the actual data from the light sensor restores consistency but it might be more preferred to replace the too-high value with an acceptable one. In the latter case there are scenarios where it is more useful to know the speed of a ship correctly and underestimate its size while for other scenarios it can be the other way round, e.g. to ensure that an inspection crew is large enough for the ship s size. The goal of this work thus is to develop some machinery for automatic identification of preferred diagnoses and pruning of those that are unwanted, in order to only require from the human operator to select from a much smaller set (of most preferred diagnoses) the best diagnosis manually. What constitutes a preferred or best diagnosis, cannot be decided in general since it will be different for each MCS and depends on the environment into which an MCS is embedded. In the above example, the health of patients may be considered paramount, but from an economic perspective billing correctly may be considered of highest importance. In any case, we observe that such a decision is up to the person or institution employing the MCS. Automatic selection of the preferred diagnoses according to some preference requires in turn a formalism for expressing and evaluating preferences. Many such formalisms are available; a prominent and important one are ceteris paribus preferences (Doyle et al., 1991), CP-nets (Boutilier et al., 2004; Domshlak et al., 2001; Goldsmith et al., 2008), or utility functions (Von Neumann & Morgenstern, 1944) widely used in economics. As there is no one-fits-all preference formalism that suits every use case, it is a challenge to accommodate any preference formalism that a user deems to fit for selecting most preferred diagnoses. Our approach is based on the idea that a user-customized preference on diagnoses, specified in a formalism chosen by the user, can be seen as a knowledgebase or context of an MCS. This context must be enabled to see the diagnoses of the MCS, which is technically challenging. Furthermore, the selection of most preferred diagnoses according to the preference context turns out to be computationally harder than originally thought. As we show, this complexity increase is not due to our meta-reasoning approach, but is intrinsic to the problem, and our approach is worst-case optimal. Our main contributions are briefly summarized as follows: We propose two basic methods for selection of preferred diagnoses: one allows to filter out diagnoses that fail some properties (similar to hard constraints); the other method compares diagnoses with each other in a binary relation and identifies the most preferred one(s). We call the functionalities of these methods filters and preference orders, respectively. Both are general concepts that can capture many concrete instances to express unwanted or preferred diagnoses. In the flexible and open spirit of the MCS framework, we do not commit to a particular formalism in which filters and EITER & WEINZIERL preference orders are specified, but remain at an abstract level and leave the choice of a particular formalism to the user. As illustrative sample instantiations, we consider here CP-nets. To realize the selection of diagnoses in such an open way, we develop three transformations to enable meta-reasoning about diagnoses in MCS, i.e., given an MCS and a filter or preference order, a transformed MCS is constructed such that the diagnoses of the original MCS also occur in the transformed MCS, but an additional context is able to observe these diagnoses and apply custom (preference) reasoning. Since the observer context is not restricted to any particular formalism, this allows one to express filters and preference orders in any formalism that can be couched into a context of an MCS. For the selection of (most) preferred diagnoses, three extensions of the notion of diagnosis are introduced, namely protected-minimal, prioritized-minimal, and subset-minimal prioritized minimal diagnosis. We investigate the computational complexity of these notions and show by polynomial-time reductions that the first two are of the same complexity as checking whether a pair of sets of bridge rules constitutes a subset-minimal diagnosis. For the third notion, we provide a novel non-deterministic refutation algorithm that works in polynomial time with the help of an oracle for one of the other notions. Still the algorithm is worst-case optimal in a number of settings, as it matches the complexity of the underlying problem. A byproduct of these results are concrete algorithms that can exploit an existing implementation of inconsistency explanation (B ogl, Eiter, Fink, & Sch uller, 2010). The results of this work may be applied to concrete instances of MCS, and the basic notions and results may be carried over to generalizations and recent extensions of MCS, as we shall discuss; furthermore, they may be of use for formalisms that can be modeled using (extensions or variants of) MCS, such as hybrid MKNF knowledge bases (Knorr, Slota, Leite, & Homola, 2014), knowledge base networks (Eiter & ˇSimkus, 2015), or Boolean networks (Kauffman, 1969, 1993, cf. Inoue, 2011), to mention a few. 1.1 Organization The remainder of this article is structured as follows. After recalling preliminary notions and fixing notation in Section 2, we introduce in Section 3 filters and preference orders and consider some sample instantiations. In Section 4 we investigate how an (extended) MCS can be enabled to select diagnoses of the original MCS. In Section 5 we show how diagnoses may be selected according to a filter or a preference order and prove the correctness of these realizations, while in Section 6 their computational complexity is investigated. Section 7 discusses related work and in Section 8 we conclude with a summary and an outlook. Proofs of theorems and propositions as well as some detailed examples are in the appendix. This article is strongly based on the work of Weinzierl (2014), which in turn is a significant extension and revision of work by Eiter, Fink, and Weinzierl (2010). 2. Preliminaries In this section we recall the framework of Multi-Context Systems (MCS) by Brewka and Eiter (2007) and notions for inconsistency management in MCS from Eiter et al. (2014). The MCS framework is based on three basic concepts: abstract logics to capture knowledge-representation formalisms, contexts which represent concrete instances of knowledge bases, and bridge rules to PREFERENCE-BASED INCONSISTENCY MANAGEMENT IN MULTI-CONTEXT SYSTEMS specify the information exchange; an MCS then simply is a collection of such contexts and their respective bridge rules. Finally, the semantics of an MCS is given in terms of equilibria. To capture all kinds of knowledge-representation formalisms, the concept of an abstract logic is used, which reduces it to the set-theoretic level. Definition 1 (Brewka & Eiter, 2007). An abstract logic L, is a triple L = (KB, BS, ACC) where: KB is the set of knowledge bases of L, where each knowledge base kb KB is a set of elements called formulas . BS is the set of possible belief sets, where each S BS is a set of elements called beliefs . ACC : KB 2BS is a function describing the semantics of the logic, by assigning to each knowledge base a set of acceptable belief sets. Intuitively, each knowledge base kb KB is a set of well-formed formulas while each belief set bs BS is a set of beliefs (statements) that a reasoner may jointly hold. The acceptability function ACC(kb) singles out, given a knowledge base kb KB, those sets of beliefs that are acceptable according to some reasoning method for kb. ACC is a multi-valued function in order to capture also nonmonotonic formalisms, where a knowledge base may have multiple acceptable belief sets (as e.g. for Answer-Set Programming, see Gelfond & Lifschitz, 1991; Default Logic, see Reiter, 1980; or in Abstract Argumentation, see Dung, 1995). Depending on the concrete situation, e.g. given an existing legacy system or a theorem prover for a specific logic, different formalizations for some logic might be used. There is no fixed mapping between a given logic and an abstract logic representing it, and the mapping may be adjusted to specific application needs. The approach allows one to capture flexibly, e.g., a knowledge-base, an expert system using a logic program, and a billing system using a description logic ontology as they might occur in the scenario described in Example 1. Let us consider two examples for abstract logics. Example 2. Classical propositional logic might be modeled as follows: KB is the set of all (well-formed) formulas over a signature Σ built using , , , ; BS is the set of deductively closed sets S of Σ-formulas (i.e., S = Cn(S)); and ACC(kb) is the singleton set {Cn(kb)}. Disjunctive logic programs under answer set semantics over a function-free first order signature Σ may be modeled as follows: KB is the set of disjunctive logic programs over Σ, i.e., each kb KB is a set of rules r a1 . . . an b1, . . . , bi, not bi+1, . . . , not bm. n + m > 0, (1) also written H(r) B(r), where all ai, bj, are atoms over Σ and not is negation as failure; we further require that each variable in r occurs also in b1, . . . , bi (safety). BS is the set of Herbrand interpretations over Σ, i.e, each S BS is a set of ground (variable-free) atoms from Σ, and EITER & WEINZIERL ACC(kb) is the set of answer sets of kb, i.e., consists of all S BS such that (i) S is a model of kb S and (ii) no S S is a model of kb S (Faber, Leone, & Pfeifer, 2004), where kb S = {r grnd(P) | S |= B(r)} is the set of all ground instances r of rules in P whose body B(r) is satisfied by S; here for evaluation, not is treated like classical negation . We denote these modelings by Lpl Σ and Lasp Σ , respectively. We remark that each rule r with n = 0 is a constraint; its heads H(r) amounts to , where is a falsity. We view the latter as a special atom that is false in every Herbrand interpretation. In the remainder of this work we often omit the explicit definition of the signature Σ for an abstract logic if it is clear from the context. To specify information exchange between contexts, so-called bridge rules are used. Bridge rules are similar in form and behavior to rules in logic programming. They differ from each other by the fact that bridge rules are based on beliefs from (possibly) different abstract logics and corresponding contexts. Based on the presence (or absence) of beliefs at other contexts, a bridge rule can add information to a context. Definition 2 (Brewka & Eiter, 2007). Given a sequence L = (L1, . . . , Ln) of abstract logics Lj = (KBj, BSj, ACCj), 1 j n, an Lk-bridge rule over L, with k {1, . . . , n} is of form: (k : s) (c1 : p1), . . . , (ci : pi), not (ci+1 : pi+1), . . . , not (cm : pm). (2) where for each 1 i m we have that ci {1, . . . , n}, pi S BSci is an element of some belief set of Lci, and s S KBk is a knowledge base formula of Lk. Each bridge rule in an MCS is associated to a certain context in such a way that all Lk bridge rules belong to the context with identifier k. We denote by ϕ (r) the formula s in the head of r and by Ch (r) the context k where r belongs to. The full head of r is denoted by head(r) = (k : s), thus head(r) = (Ch (r) : ϕ (r)). The literals in the body of r are referred to as body (r), body+(r), body (r), body(r), which denote the sets {(c1 : p1), . . . , (cm : pm)}, {(c1 : p1), . . . , (cj : pj)}, {(cj+1 : pj+1), . . . , (cm : pm)}, {(c1 : p1), . . . , (cj : pj), not (cj+1 : pj+1), . . . , not (cm : pm)}, respectively. Furthermore, Cb (r) denotes the set of contexts referenced in r s body, i.e., Cb (r) = {ci | (ci : pi) body (r)}. Note that different from the work of Brewka and Eiter (2007), the head of r contains not only the knowledge-base formula s but also the context identifier k. This choice merely is syntactic sugar and allows easier identification of the context where r belongs to. For later technical use, we denote by cf (r) the condition-free bridge rule resulting from r by removing all elements in its body, i.e., cf (r) is (k : s) . and for any set of bridge rules R, we let cf (R) = S r R cf (r). We emphasize that bridge rules only deal with elements of knowledge bases and elements of belief sets, both of which are considered to be atomic expressions from the perspective of MCS. Incorporating variables into bridge rules is possible but requires restrictions on context logics or additional machinery for variable substitution (for details, see Fink, Ghionna, & Weinzierl, 2011; Barilaro, Fink, Ricca, & Terracina, 2013; Sch uller & Weinzierl, 2011). Since bridge rules are the only way to exchange information between contexts and bridge rules only refer to beliefs, the contents of a context (i.e., its knowledge-base and semantics) is completely hidden from other contexts. In addition to that, there is no central point of information exchange, hence the MCS framework is somewhat decentralized. PREFERENCE-BASED INCONSISTENCY MANAGEMENT IN MULTI-CONTEXT SYSTEMS With bridge rules to connect contexts at hand, Multi-Context Systems are defined as follows. Definition 3 (cf. Brewka & Eiter, 2007). A Multi-Context System is a collection M = (C1, . . . , Cn) of contexts Ci = (Li, kbi, bri), 1 i n, where (i) Li = (KBi, BSi, ACCi) is an abstract logic, (ii) kbi KBi is a knowledge base, and (iii) bri is a set of Li-bridge rules over L = (L1, . . . , Ln). Furthermore, for each H {ϕ (r) | r bri} it holds that kbi H KBi (i.e., knowledge bases are closed under adding bridge rule heads). In the sequel, br(M) = Sn i=1 bri denotes the set of all bridge rules of M; C (M) = {1, . . . , n} denotes the set of all context identifiers of M; and bri(M) denotes the set of bridge rules of context i of M, i.e., bri(M) = {r br(M) | Ch (r) = i}. Example 3. The MCS described in Example 1 can now be formalized. Let M = (C1, C2, C2) be an MCS with three contexts: a patient knowledge-base C1, a logic program C2 suggesting proper medication, and a logic program C3 handling the billing. Context C1 uses the abstract logic Lpl Σ, while both C2 and C3 use Lasp Σ . We restrict our example to a single patient with the knowledge bases kb1, kb2, and kb3 as given in Figure 1 on page 354 for the contexts C1, C2, and C3, respectively. Intuitively, the knowledge base kb1 of context C1 states that the patient has severe hyperglycemia, that she is allergic to animal insulin, and that her health insurance is with company B. Context C2 s knowledge base kb2 suggests to apply either human or animal insulin if the patient has hyperglycemia and requires that the applied insulin does not cause an allergic reaction. Context C3 does the billing and encodes that insurance B only pays animal insulin. The MCS M contains five rather simple bridge rules shown in Figure 1 (bridge rules are presented in the format name: head body. ). Their task is to carry information from one context to another. Bridge rule r1, for example, carries information about hyperglycemia of the patient from the patient knowledge-base C1 to the medication recommender system C2. Bridge rule r2 is the sole non-monotonic one and it turns the absence of an allergy to animal insulin (in C1) into the allowance to administer this kind of insulin (in C2). A graphical depiction of M is shown in Picture 1 inside Figure 1. The latter also shows the minimal diagnoses of M (cf. below for further details). The semantics of an MCS M = (C1, . . . , Cn) is defined in terms of special belief states, which are sequences S = (S1, . . . , Sn) of belief sets Si BSi, 1 i n; intuitively, each Si must be a locally accepted belief set where the bridge rules of context Si are respected. To formalize this, we call a bridge rule r of form (2) applicable in a belief state S, denoted by S r, if (i) for each (j : p) body+(r) it holds that p Sj, and (ii) for each (j : p) body (r) it holds that p / Sj. For a set R of bridge rules and a belief state S, app(R, S) denotes the set of bridge rules of R that are applicable in S, i.e., app(R, S) = {r R | S r}. We can now define the desired belief states of an MCS as follows. Definition 4 (cf. Brewka & Eiter, 2007). A belief state S = (S1, . . . , Sn) of M is an equilibrium if for every belief set Si, 1 i n, it holds that Si ACCi kbi {ϕ (r) | r app(bri, S)} . The set of all equilibria of an MCS M is denoted by EQ(M). To create bridge rules that are always resp. never applicable, we also allow r = (k : s) , resp. r = (k : s) , where S r resp. S r for every belief state S. Here denotes the empty body and a body containing (ℓ: p), not (ℓ: p) where p is any belief of any context Cℓ. For simplicity, we assume that the bridge rules r and r have no body literals. EITER & WEINZIERL Figure 1: The Hospital MCS M = (C1, C2, C3) with knowledge bases kbi and bridge rules rj. kb1 = {hyperglycemia, allergic animal insulin, insurance B} kb2 = { give human insulin give animal insulin hyperglycemia. give animal insulin, not allow animal insulin} kb3 = { bill bill animal insulin. bill more bill human insulin. insurance B, bill more.} r1: (2 : hyperglycemia) (1 : hyperglycemia). r2: (2 : allow animal insulin) not (1 : allergic animal insulin). r3: (3 : bill animal insulin) (2 : give animal insulin). r4: (3 : bill human insulin) (2 : give human insulin). r5: (3 : insurance B) (1 : insurance B). Patient data C1 Medication C2 Picture 1: The MCS M visualized. The set of minimal diagnoses of M is: D m(M) = {r1} , , {r4} , , {r5} , , , r2 . Application of these diagnoses intuitively results in: ({r1} , ) illness of the patient is ignored. ({r4} , ) medication is not billed. ({r5} , ) insurance company receives bill it will not pay. ( , {r2}) patient is given medication she is allergic to. No diagnosis is clearly the best, it depends on one s preferences. PREFERENCE-BASED INCONSISTENCY MANAGEMENT IN MULTI-CONTEXT SYSTEMS Given an MCS M = (C1, . . . , Cn) over abstract logics L = (L1, . . . , Ln), a set R of bridge rules is compatible with M, if a partitioning R1, . . . , Rn of R = Sn k=1 Rk exists where every r Rk is an Lk-bridge rule over L. For such R, we write M[R] for the MCS that results by replacing its bridge rules with R. E.g., M[br(M)] = M and M[ ] is M with no bridge rules. We say that M is inconsistent, denoted M |= , if M has no equilibrium, i.e., EQ(M) = . The converse, that M is consistent, is denoted by M |= , i.e., EQ(M) = . For a consistency-based explanation of inconsistency pairs (D1, D2) of sets of bridge rules are considered, such that if we deactivate the rules in D1 and add the rules in D2 in condition-free form, the MCS becomes consistent (i.e., admits an equilibrium). Definition 5. Given an MCS M, a diagnosis of M is a pair (D1, D2), D1, D2 br(M), such that M[br(M) \ D1 cf (D2)] |= . We denote by D (M) the set of all diagnoses. An alternative reading of Def. 5 is that a diagnosis indicates which bridge rules are assumed to require modification in order to obtain a consistent MCS, i.e., a diagnosis constitutes a way to repair an MCS if its bridge rules are modified according to the diagnosis. Adding rules condition-free is the most severe form of modification of a rule s body, but as shown by Eiter et al. (2014), this notion also allows one to capture more fine-grained forms of modification. We call any pair D = (D1, D2) 2br(M) 2br(M) a candidate diagnosis (regardless of whether D D (M) holds). We denote the MCS resulting from the application of a candidate diagnosis (D1, D2) (br(M), br(M)) by M[D1, D2], which equals the MCS M[br(M) \ D1 cf (D2)]. Following Occam s razor, one may consider those diagnoses to be the preferred ones that require the least modifications. This motivates the notion of minimal diagnosis. Definition 6. Given an MCS M, a diagnosis D D (M) is (pointwise) subset minimal, if no D D is in D (M); by D m(M) we denote all such D, i.e., D m(M) = {D D (M) | D D (M) : D D D D }. Here, given pairs A = (A1, A2) and B = (B1, B2) of sets, the pointwise subset relation A B holds iff A1 B1 and A2 B2; moreover, A B holds iff A B A = B, where A = B holds iff A1 = B1 A2 = B2. Example 4. Reconsider the MCS M of Example 3. Since the patient has hyperglycemia and is allergic to animal insulin, the belief set containing give human insulin is the only one acceptable at C2, i.e., the human insulin must be given. Since the insurance company does not cover human insulin, the billing context C3 admits no acceptable belief set and the MCS M therefore is inconsistent. As shown at the bottom of Figure 1, the minimal diagnoses of M are D m(M) = {D(1), D(2), D(3), D(4)} with D(1) = ({r1}, ), D(2) = ({r4}, ), D(3) = ({r5}, ), and D(4) = ( , {r2}). Applying the diagnosis D(i) for 1 i 4, i.e., considering for D(i) = (D(i) 1 , D(i) 2 ) the MCS M[br(M) \ D(i) 1 cf (D(i) 2 )], yields that the illness of the patient is ignored (D(1)), that the medication is not billed (D(2)), that the insurance receives a bill it will not pay (D(3)), and that the patient is given a medication she is allergic to (D(4)). 3. Preferences Clearly, in general not all diagnoses of an MCS are equally appealing, as applying the selected repair might have serious consequences, e.g., in the MCS M of Example 4 if the illness of the patient is EITER & WEINZIERL ignored. It is not easy to identify the best diagnosis in D m(M): if the health of the patient is most important, then those diagnoses only causing a wrong billing are preferred; on the other hand, if costs matter, one might consider any diagnosis leading to a wrong billing as unacceptable. In the literature two basic ways occur frequently: one is to separately consider each outcome (i.e., diagnosis) and discard it whenever it fails some preference condition; the other is to compare outcomes with each other and decide which is the most appealing. We call the former a filter, since it filters unwanted diagnoses, and the other a preference. Both notions of diagnosis can be defined in general by relying on some notion of plausibility (see e.g., for abduction Bylander et al., 1991). As for preference among diagnoses, two immediate questions are (i) how to model preference formally and (ii) how to obtain or elicit a concrete preference description for a particular MCS. Regarding (i), we aim in this work to be rather general and resort to a prototypical model in terms of a preference relation, formalized as binary relation on the set of diagnoses that is reflexive and transitive; this abstract notion allows us to capture a large number of formalisms that have been developed for specifying preference. Regarding (ii), there is no simple or straightforward answer, since the construction of a particular preference order may very much depend on the particular MCS and its application domain. It may appear far easier instead to obtain a preference order on individual bridge rules; since diagnoses amount to special sets of bridge rules, it is possible to construct a preference order between diagnoses from such preferences, by using techniques that lift preference on elements to sets of elements, as in the work of Brewka, Truszczy nski, and Woltran (2010), or to apply iterative improvement techniques; we refer here to the work by Brafman, Domshlak, Shimony, and Silver (2006), and Brewka et al. (2010), where also respective preference representation languages are considered. Guaranteeing that such preference is desired and preference elicitation tailored specifically for MCS, however, requires a study of its own and is beyond the scope of this article. We thus assume that preferences (or filters) over diagnoses are already given and concentrate on the computational challenges of imposing them on an MCS. To illustrate some particular formalism for preference specification where elicitation respectively preference generation has been thoroughly studied, we consider here the widely known CP-nets (cf. Boutilier et al., 2004; Allen, 2016) in which preference is specified by statements like if bridge rules r1 and r2 are removed, then I prefer bridge rule r3 to be condition-free . Since preferences allow to compare diagnoses, but they do not allow the exclusion of diagnoses from being considered, preferences alone are not sufficient. If one wants to ensure that certain diagnoses are excluded from being considered acceptable, the need for a way to filter out certain diagnoses arises. For specifying a filter, we again use the most general approach, which is a Boolean function on diagnoses. In this section we introduce the definitions of filters and preference orders in general, as well as some specific preference formalisms. The following sections then show how they can be realized in MCS in such a way that any formalism used to define the preference order or filter can be incorporated thanks to using the abstract logic of an MCS context. Furthermore, our approach preserves core properties of MCS like information hiding and allows for a decentralized evaluation. 3.1 Filters on Diagnoses Filters allow the MCS designer to apply sanity checks on diagnoses; they act as hard constraints: diagnoses that fail to satisfy the conditions are filtered out and discarded for consistency restoration. PREFERENCE-BASED INCONSISTENCY MANAGEMENT IN MULTI-CONTEXT SYSTEMS 3.1.1 PROTECTING BRIDGE RULES In a first attempt, we may consider protecting some bridge rules from modification, i.e., we disallow a diagnosis to contain them. The adapted notion of diagnosis is as follows. Definition 7. Let M be an MCS with protected rules br P br(M). A diagnosis excluding protected rules br P is a diagnosis (D1, D2) D (M), where D1, D2 br(M) \ br P . We denote the set of all such diagnoses by D (M, br P ). The set of all minimal such diagnoses is D m(M, br P ) = {D D (M, br P ) | D D (M, br P ) : D D}. Example 5. Consider the hospital MCS M of Example 3 again. One might decide that bridge rules for health-related information-flow are protected, i.e., br P = {r1, r2}. The set of minimal protected diagnoses then is: D m(M, br P ) = {({r4}, ), ({r5}, )} In the following we also write diagnosis with protected bridge rules meaning a diagnosis excluding protected rules. The following property is easy to verify. Proposition 1. Let M be an inconsistent MCS with protected rules br P . Then D (M, br P ) D (M) and D m(M, br P ) D m(M), i.e., every diagnosis is a diagnosis excluding protected rules and every minimal diagnosis excluding protected rules is a minimal diagnosis. Proof. Let D D (M, br P ), then by definition D D (M). Given D = (D1, D2) with D D m(M, br P ), assume towards contradiction that there exists (D 1, D 2) D m(M) such that (D 1, D 2) (D1, D2). Observe that D 1, D 2 br(M)\br P , hence (D 1, D 2) D (M, br P ). This contradicts that D D m(M, br P ), thus it follows that D D m(M). In Section 6 it is shown that deciding whether D D (M, br P ) and D D (M) have the same complexity, i.e., protected bridge rules do not increase the complexity. 3.1.2 FILTERS IN GENERAL We now introduce filters in general. A candidate diagnosis (D1, D2) is considered whether it fails some conditions; if so, it is filtered out and not considered for consistency restoration; thus a filter can be seen as hard constraints on diagnoses. Example 6. Consider two scientists, Prof. K and Dr. J, who plan to write a paper. We formalize their reasoning in an MCS M with two contexts C1 and C2 that employ Lasp Σ for answer set semantics. Dr. J will write most of the paper and Prof. K will engage if she finds time or if Dr. J thinks the paper needs improvement (r1). Dr. J knows that involving Prof. K results in a good paper (r2 and kb1) and he will list her as an author if she participates (r3). The knowledge bases of the contexts are: kb1 = {contribute improve.; contribute has time.} kb2 = { good coauthored.} The bridge rules of M are: r1 : (1 : improve) not (2 : good). r2 : (2 : coauthored) (1 : contribute). r3 : (2 : name K) (1 : contribute). EITER & WEINZIERL Prof. K C1 Dr. J C2 Figure 2: Contexts and bridge rules of the MCS M = (C1, C2) from Example 6. Figure 2 depicts the contexts and bridge rules of M. It appears that M is inconsistent, intuitively because the cycle through bridge rules r1 and r2 has an odd number of negations. The set of minimal diagnoses of M is: D m(M) = {({r1} , ) , ({r2} , ) , ( , {r2}) , ( , {r1})} . The first two diagnoses break the cycle by removing a rule, the last two stabilize it. We aim for a general notion of a filter, therefore we define a filter to be a Boolean function on candidate diagnoses. Definition 8. Let M be an MCS with bridge rules br(M). A diagnosis filter for M is a function f:2br(M) 2br(M) {0, 1} and the set of filtered diagnoses is D f (M) = {(D1, D2) D (M) | f(D1, D2) = 1}. By D m,f (M) we denote the set of all subset-minimal such diagnoses. Given a candidate diagnosis D = (D1, D2) 2br(M) 2br(M), we also write f(D) to denote f(D1, D2). Writing the set D m,f(M) explicitly, we obtain: D m,f(M) = D D (M) | f(D) = 1 D D (M) : D D f(D ) = 1 (3) Example 7. Consider the MCS of Example 6 and the diagnoses D = ({r2} , ) and D = ( , {r2}), where the contribution of Prof. K is either enforced or forbidden. For both cases, the authorship information conveyed by r3 is wrong. Using a filter, we can declare diagnoses undesired if they modify r2 without modifying r3 accordingly as follows: f(D1, D2) = 0 if r3 D1, r2 / D1 or r3 / D1, r2 D1; 0 if r3 D2, r2 / D2 or r3 / D2, r2 D2; 1 otherwise. In particular it holds that f(D) = 0 = f(D ). Note that filters generalize diagnoses with protected bridge rules. Indeed, let M be an MCS with protected bridge rules br P . Then we construct a filter fbr P in the following way: fbr P (D1, D2) = ( 0 if r br P : r (D1 D2); 1 otherwise. It is easy to see that D D (M, br P ) holds iff fbr P (D) = 1. From the definition of fbr P one can also see that diagnoses with protected bridge rules are some kind of modular filter, where each bridge rule of a diagnosis D can be checked independently of the other bridge rules. It also holds that every filtered diagnosis is an ordinary diagnosis, but minimal filtered diagnoses are not necessarily minimal diagnoses. Thus an analog to Proposition 1 does not hold, as shown by the following example. PREFERENCE-BASED INCONSISTENCY MANAGEMENT IN MULTI-CONTEXT SYSTEMS Example 8. Reconsider the MCS M and the filter f of Example 7. The set of minimal filtered diagnoses is as follows: D m,f(M) = ({r1}, ), ( , {r1}), ({r2, r3}, ), ( , {r2, r3}) . While ({r2, r3}, ) is not in D m(M), it is a subset-minimal diagnosis respecting the condition expressed by the filter f. Intuitively, the latter diagnoses modify the authorship information in a consistent way and are minimal in the sense that no unnecessary modification is applied. One could argue whether minimal filtered diagnoses should select from the set of regular minimal diagnoses only those which pass the filter, i.e., select the set {D D m(M) | f(D) = 1}. This looks appealing, but no minimal diagnosis may pass the filter while (non-minimal) diagnoses do. The resulting set of filtered minimal diagnoses then is empty while there are useful diagnoses that satisfy the filter and do not incur unnecessary modifications other than to satisfy the filter condition and to make the MCS consistent. Therefore D m,f consists of the latter diagnoses, and thus seems to be more appropriate. 3.2 Preferences on Diagnoses To compare diagnoses and select the most appealing one(s), we use preferences. In the spirit of MCS we also want this approach to be open to any kind of formalism for specifying preference. In general, preference is just a binary order relation on diagnoses. To avoid counter-intuitive results like A being preferred over B and B being preferred over C, but A not being preferred over C, we require that preferences are transitive. Since virtually every other preference formalism yields an order relation, we first introduce the general formalization and later show how the specific formalism of CP-nets fits into our approach. Definition 9. A preference order over diagnoses for an MCS M is a transitive and reflexive binary relation on 2br(M) 2br(M); for D, D 2br(M) 2br(M) we say that D is preferred to D if D D . Given a preference order , we denote by the irreflexive and anti-symmetric version of , i.e., D D holds iff D D and D D hold. Using a preference order , we now define what constitutes a most preferred diagnosis. The intuition is that such a diagnosis incurs a minimal set of modifications and no other diagnosis exists that is strictly more preferred. We first introduce -preferred diagnoses, which are those diagnoses such that no other diagnosis is strictly more preferred. The most preferred diagnoses then are the subset-minimal ones from the set of -preferred diagnoses. Definition 10. Let M be an inconsistent MCS and let D D (M). Then D is called -preferred if for all D 2br(M) 2br(M) with D D it holds that D / D (M). Furthermore, D is minimal -preferred if D is subset-minimal among all -preferred diagnoses. The set of all -preferred diagnoses is denoted by D (M) and the set of all minimal -preferred by D m, (M). Observe that we do not require that is acyclic and by relying on we consider all diagnoses in a cycle to be equally preferred. Example 9. Consider the hospital MCS M of Example 3 again, where bridge rules r1 and r2 transport information regarding the patient s health and bridge rules r3, r4, and r5 cover the information flow for billing. If we consider it most important that the information flow regarding health information is changed as little as possible, a preference order as follows might be used: (D1, D2) (D 1, D 2) iff {r1, r2} (D1 D2) (D 1 D 2) {r1, r2} EITER & WEINZIERL We observe that following this definition, the following preferences (and several more) hold: ({r4, r5}, ) ({r1}, ) ({r4}, ) ({r1}, ) ({r5}, ) ({r1}, ) ({r4, r5}, ) ( , {r2}) ({r4}, ) ( , {r2}) ({r5}, ) ( , {r2}) ({r4}, ) ({r5}, ) ({r5}, ) ({r4}, ) Note that indeed yields cyclic preferences among those candidate diagnoses that are incomparable; in particular ({r4}, ) and ({r5}, ). We have that D (M) = {(D1, D2) | D1, D2 {r3, r4, r5} and r4 D1 \ D2 or r5 D1 \ D2} Note that ({r5}, ), ({r4}, ), and ({r4, r5}, ) are all in D (M). Selecting the subset-minimal diagnoses from D (M) we obtain D m, (M) = {({r5}, ), ({r4}, )}. This agrees with our intuition that a minimal set of modifications should be applied and we favor to modify bridge rules for billing information rather than modifying health-related bridge rules. For use in the following sections, we also state the sets D (M) and D m, (M) explicitly. D (M) = {D D (M) | D D (M) : (D D D = D D D )} (4) D m, (M) = {D D (M) | D D (M) : D D D = D} In Section 5 we show how preferences can be realized in general. 3.2.1 SAMPLE INSTANTIATIONS OF PREFERENCE ORDERS: CP-NETS We now briefly demonstrate how our notion of preference can capture some practical preference formalisms. Conditional preference networks (CP-nets) (Boutilier et al., 2004) are a widespread preference formalism with many appealing features. CP-nets capture a natural class of preference statements like If my new car is from Japan, I prefer hybrid over diesel engine, assuming all else is equal . We briefly present the essential concepts of CP-nets in compact form to show their flavor. A CP-net has a set of outcome variables where each variable ranges over some domain. In our example, we have the variables origin country and engine type with origin country including Japan and engine type including diesel and hybrid . A distinguishing feature of CP-nets is the dependency of preferences, e.g., the above preference on the engine type only upholds if the outcome of the origin country is Japan . This dependency is expressed in CP-nets as a directed graph N = (V, E) on outcome variables V . Each outcome variable v V is associated with a set dom(v) of possible outcomes. A total outcome o assigns each v V a value from dom(v), denoted by ov; for a subset V V of the variables, o V denotes the restriction of o to V (note that o = o V ). Furthermore, each variable v has an associated conditional-preference table cpt(v) which contains a total preference order over dom(v) for every possible outcome of the parent variables Pa(v) on which v depends, i.e., Pa(v) = {v | (v , v) E}. A preference order over total outcomes satisfies N, if for all total outcomes o, o and all variables v V it holds that o Pa(v) = o Pa(v) implies that o o holds iff ov is preferred to o v in cpt(v). Informally, satisfies N if it agrees with all conditional-preference tables of N; for formal details and further background see the work of Boutilier et al. (2004) and Allen (2016). Note that dependencies in CP-nets are natural to humans as CP-nets have successfully been used for preference elicitation, e.g. by Domshlak et al. (2001). CP-nets also allow one to compare total PREFERENCE-BASED INCONSISTENCY MANAGEMENT IN MULTI-CONTEXT SYSTEMS outcomes, so we may ask whether an outcome o is preferred to an outcome o under all preferences that satisfy N. If this is the case, then o is said to dominate o , written as N |= o o (entailment). CP-nets may be used to specify preference among diagnoses of an MCS M as follows: each bridge rule r br(M) is assigned two outcome variables V r 1 and V r 2 , where the domain of V r 1 is {in D1, not in D1} and the domain of V r 2 is {in D2, not in D2}. We call any CP-net N = (V, E) with V = {V r 1 , V r 2 | r br(M)} and domains as before fully compatible to M, or just a fully compatible CP-net. Every total outcome of such a CP-net corresponds one-to-one to a candidate diagnosis of M. Definition 11. Given an MCS M and a CP-net N that is fully compatible to M, we say a diagnosis D D (M) is N-preferred iff there exists no D D (M) such that N |= D D holds and N |= D D does not hold. Let DN(M) denote the set of all N-preferred diagnoses of M. Then the set D ird(M, N) of irredundant N-preferred diagnoses, consists of the subset-minimal diagnoses of DN(M). Formally, D ird(M, N) = {D DN(M) | D DN(M) : D D D = D }. Observe that given a CP-net N that is compatible to the MCS M, we can readily define a preference order N that is equivalent to N as follows: for all D, D 2br(M) 2br(M) it holds that D N D N |= D D . Since the entailment of the CP-net is transitive and reflexive, N is transitive and reflexive, therefore N is a preference relation in the sense of Definition 9. Hence, we can use N and the notion of most preferred diagnosis to select the irredundant N-preferred diagnoses, formally: Proposition 2. Given a CP-net N compatible to an MCS M, let D N D hold iff N |= D D holds. Then DN(M) = D N (M) and D m, N (M) = D ird(M, N). Deciding whether a global outcome o is preferred over o by a given CP-net N, i.e., deciding N |= o o, is no easy task in general. In the work of Goldsmith et al. (2008) it is shown that this task is PSPACE-complete. Restricting the CP-net, however, decreases the computational complexity, e.g., the same decision problem is NP-complete for binary-valued directed-path singly connected CP-nets and even in quadratic time for binary-valued tree-structured CP-nets as shown by Boutilier et al. (2004). Notice that fully-compatible CP-nets are binary-valued. 4. Meta-Reasoning for Diagnosis To realize filters and preference orders inside an MCS, some MCS context must be able to reason on diagnoses of the MCS. We achieve this by a rewriting technique, transforming an MCS M into an extended MCS M , where certain new context(s) can do meta-reasoning on diagnoses of the original MCS M. The underlying idea here is that a diagnosis D applied to M has the same effects as if D would be applied to M, but in M there are additional contexts that observe the behavior of the bridge rules in M to reason about the observed diagnosis D. A significant advantage of this approach is that the observation contexts may use any abstract logic for reasoning about the observed diagnoses. Thus our approach can capture a wide range of formalisms to specify preferences by filters or preference orders, and it allows the creator of an MCS to use whichever formalism she or he sees to fit best. Furthermore, the rewriting is not intrusive, since it only requires that each rule is duplicated and one additional positive literal added in it. The transformation given in this section realizes filters in general by using diagnoses with protected bridge rules. Preferences also require some additional notions of diagnoses that allow to EITER & WEINZIERL prioritize some bridge rules. This prioritization in principle establishes a lexicographic order on candidate diagnoses. We present in fact two possible ways to realize general preferences. The first adds exponentially many bridge rules, while the second adds only linearly many bridge rules but comes at the cost of duplicating the contexts of the original MCS. In the following section, we present a uniform encoding for meta-reasoning on diagnoses, which serves as the basis for realizing filters and preferences as well as for proving correctness. 4.1 Injecting Diagnoses We can encode the modifications of a diagnosis directly in an MCS such that observations are perfect, which means that the original system is not just observed but actively modified. Conceptually, given an MCS M = (C1, . . . , Cn) all its bridge rules are rewritten and protected such that a diagnosis is applied only to the bridge rules of an additional context Cn+1. This context Cn+1 then is able to definitely observe the modifications and to exhibit this observation to all other contexts via its acceptable belief set. The bridge rules of the original system are rewritten to consider the belief set of Cn+1. So they either behave like being removed or like being made condition-free, depending on what Cn+1 believes. Furthermore, the definition of the observation context Cn+1 is generic and only specifies some necessary properties. This provides the user with the possibility to instantiate it with a logic and a knowledge base of her choice, which is in line with the spirit of the MCS framework. To encode (observe) diagnoses, the context Cn+1 needs bridge rules to which a diagnosis can be applied and which can be observed reliably. To this end, for every r br(M) we have the following two bridge rules to encode/observe whether r is removed or made unconditional (i.e., condition-free). d1(r) : (n+1 : not removedr) . (5) d2(r) : (n+1 : uncondr) . (6) For a set R br(M), let d1(R) = {d1(r) | r R} and d2(R) = {d2(r) | r R}. Since the meta-reasoning encoding is used as uniform foundation for filters and preferences, we introduce a property θ that describes the additional behavior of the context Cn+1. This allows us to later specify the required behavior for both filters and preferences. The preference encoding requires further bridge rules for mapping preferences to bridge rules; this set of additional bridge rules is called Kp, so we obtain an MCS Mmr(θ,Kp) as the meta-reasoning encoding of M as follows. Definition 12. Let M = (C1, . . . , Cn) be an MCS, let Kp be a set of bridge rules such that the following holds for all r Kp: ϕ (r) / {not removedr , uncondr | r br(M)}, body(r) = { }, and Ch (r) = n+1. Furthermore, let θ be a ternary property over 2br(M) 2br(M) 2Kp. Then, the MCS Mmr(θ,Kp) = (C 1, . . . , C n, Cn+1) is a meta-reasoning encoding if the following holds: (i) for every Ci = (Li, kbi, bri) with 1 i n it holds that C i = (Li, kbi, br i) where br i contains for every r bri of form (2) the following two bridge rules: (i : s) (c1 : p1), . . . , (cj : pj), not (cj+1 : pj+1), . . . , not (cm : pm), not (n+1 : removedr). (7) (i : s) (n+1 : uncondr). (8) (ii) Cn+1 = (Ln+1, kbn+1, brn+1) is an arbitrary context such that: (a) the logic Ln+1 = (KBn+1, BSn+1, ACCn+1) is an arbitrary logic where PREFERENCE-BASED INCONSISTENCY MANAGEMENT IN MULTI-CONTEXT SYSTEMS KBn+1 fulfills that A {uncondr, not removedr | r br(M)} {ϕ(r) | r Kp} implies that there exists a knowledge-base kb KBn+1 with A kb. BSn+1 fulfills that B {removedr, uncondr | r br(M)} implies that there exists a belief set bs BSn+1 with B bs. ACCn+1 is such that some kb KBn+1 fulfills the property ( ) in item (d) below. (b) the set of bridge rules is brn+1 = d1(br(M)) d2(br(M)) Kp and the only rules with head formulas not removedr and uncondr are of form (5) and (6). (c) the knowledge base kbn+1 KBn+1 is arbitrary but fulfills the following property: ( ) for every H {ϕ (r) | r brn+1} it holds that Sn+1 ACCn+1(kbn+1 H) iff θ(R1, R2, R3) is true where R1 = {r br(M) | not removedr / H}, R2 = {r br(M) | uncondr H}, R3 = {r Kp | ϕ (r) H}, and Sn+1 = {removedr | r R1} {uncondr | r R2}. The protected bridge rules br P of Mmr(θ,Kp) are all rules of form (7) and (8). The bridge rules of form (7) and (8) for a bridge rule r br(M) either behave like removed or like made unconditional, depending on what Cn+1 believes. The bridge rule (7) behaves like r being removed by a diagnosis if Cn+1 believes it is removed (i.e., it does not fire even if the original body of r is satisfied). The bridge rule (8) behaves like r being made condition-free by a diagnosis if Cn+1 believes it is condition-free (i.e., it fires regardless of whether the original body of r is satisfied). The property ( ) guarantees that (i) the beliefs of Cn+1 coincide with the diagnosis encoded by bridge bridge rules of form (5) and (6), and (ii) that there is an acceptable belief set whenever θ holds. This definition of Mmr(θ,Kp) is thus generic and the Propositions 3-5 below are very general. The advantage of this approach is that we have a common foundation for encoding filters and preferences, such that several propositions hold for both encodings. Furthermore, as shown later in detail, the property θ to realize a filter f amounts to simply stating that θ(D1, D2, ) holds iff f(D1, D2) = 1, while θ and Kp suffice to capture preferences. The context Cn+1 is similar to an interface in programming, which defines certain properties but is open to an arbitrary implementation. A concrete realization of Cn+1 using the logic Lasp Σ for Answer-Set Programming is illustrated in Example 19 in Appendix B. Specifically, there the rules (22) (34) implement the interface . Example 10. Recall the MCS M = (C1, C2) of Example 6. Let Kp = and θ(D1, D2, ) always hold. Then the meta-reasoning encoding Mmr(θ,Kp) = (C 1, C 2, C3) is such that the contexts C1, C2, equal modulo bridge rules the contexts C 1, C 2, respectively. Recall that the bridge rules of M are: r1 : (1 : improve) not (2 : good). r2 : (2 : coauthored) (1 : contribute). r3 : (2 : name K) (1 : contribute). EITER & WEINZIERL Prof. K C1 Dr. J C2 Observer/Encoder C3 Figure 3: Contexts of the meta-reasoning encoding Mmr(θ,Kp) = (C1, C2, C3) from Example 10. Only bridge rules r 1, r 1, d1(r1), d2(r1) of Mmr(θ,Kp) that stem from bridge rule r1 br(M) are shown. The bridge rules of Mmr(θ,Kp) are then as follows: r 1 : (1 : improve) not (2 : good), not (3 : removedr1). r 1 : (1 : improve) (3 : uncondr1). r 2 (2 : coauthored) (1 : contribute), not (3 : removedr2). r 2 (2 : coauthored) (3 : uncondr2). r 3 (2 : name K) (1 : contribute), not (3 : removedr3). r 3 (2 : name K) (3 : uncondr3). d1(ri) : (3 : not removedri) . i {1, 2, 3} d2(ri) : (3 : uncondri) . i {1, 2, 3} Notice that only the last six bridge rules of Mmr(θ,Kp) are not protected, i.e., the first six bridge rules are guaranteed not to be modified in a diagnosis with protected bridge rules. Figure 3 depicts the contexts and, for better visibility, only those bridge rules of Mmr(θ,Kp) that stem from r1 br(M) are shown. Note that the observation context of a meta-reasoning encoding only knows that some bridge rules exist but it has no knowledge of the actual information exchange or the contents of any of the other contexts. Since the meta-reasoning encoding is the basis for all later encodings, it provides us with a mechanism to determine preferred solutions for both preference orders and filters that maintains privacy and information hiding of the contexts. For filters that are not inherently centralized, the realization even allows for finding preferred solutions in a decentralized, localized manner (cf. Section 7.1 on decomposing the central observation contexts). Thus we mostly preserve key properties of MCS also for inconsistency assessment and selection of preferred diagnoses. Def. 12 forbids the observation context Cn+1 to exhibit any belief not of the form removedr or uncondr for r br(M). In practice however, auxiliary beliefs are useful when realizing a preference or filter. Since the applicability of bridge rules does not depend on beliefs that do not occur in any bridge rule, this restriction can be lifted to allow for auxiliary beliefs in Cn+1. PREFERENCE-BASED INCONSISTENCY MANAGEMENT IN MULTI-CONTEXT SYSTEMS In the remainder of this section, we show some properties of Mmr(θ,Kp), which are the basis for proving the correctness of the subsequent realizations of filters and preferences. First, there is a one-to-one correspondence between diagnoses of M and diagnoses of Mmr(θ,Kp). Proposition 3. Let M be an MCS and Mmr(θ,Kp) be a meta-reasoning encoding with protected bridge rules br P , and let D1, D2 br(M), K Kp. Then, (1) let S = (S1, . . . , Sn) be a belief state of M and let S = (S1, . . . , Sn, Sn+1) where Sn+1 = {removedr | r D1} {uncondr | r D2}. Then, S EQ(M[D1, D2]) and θ(D1, D2, K) holds if and only if S EQ(Mmr(θ,Kp)[d1(D1), d2(D2) K]) holds. (2) (d1(D1), d2(D2) K) D (Mmr(θ,Kp), br P ) holds if and only if (D1, D2) D (M) and θ(D1, D2, K) hold. From this, the following correspondence between minimal θ-satisfying diagnoses of M and minimal diagnoses of Mmr(θ,Kp) holds. Proposition 4. Let Mmr(θ,Kp) be a meta-reasoning encoding of an MCS M. Then the set of minimal θ-satisfying diagnoses with protected bridge rules br P of Mmr(θ,Kp) is D m(Mmr(θ,Kp), br P ) = (d1(D1), d2(D2) K) | (D1, D2) D (M) and θ(D1, D2, K) holds and there exist no (D 1, D 2) D (M), K Kp such that (D 1, D 2 K ) (D1, D2 K) and θ(D 1, D 2, K ) holds . This result can be strengthened given that θ obeys some property. We say that θ is functional (or a function), if for every D1, D2 br(M) there exists at most one K Kp such that θ(D1, D2, K) holds. We say that θ is functional increasing if K K holds whenever θ is functional, θ(D1, D2, K), θ(D 1, D 2, K ), and (D1, D2) (D 1, D 2), where D1, D2, D 1, D 2 br(M), K, K Kp. Proposition 5. Let Mmr(θ,Kp) be a meta-reasoning encoding of an MCS M such that θ is functional increasing. Then, the set of minimal θ-satisfying diagnoses with protected bridge rules br P of Mmr(θ,Kp) is D m(Mmr(θ,Kp), br P ) = (d1(D1), d2(D2) K) | (D1, D2) D (M) and θ(D1, D2, K) holds and there exists no (D 1, D 2) D (M) such that (D 1, D 2) (D1, D2) and θ(D 1, D 2, K ) holds for some K, K Kp . Given these relationships between diagnoses of M and Mmr(θ,Kp) with respect to property θ, we show in the next section several ways how Mmr(θ,Kp) can be used to realize preferences. 5. Preference Realization In the previous section we introduced a transformation that enables meta-reasoning on diagnoses. In this section, we first present how filters can be realized and then proceed to preferences, where we first introduce a plain encoding using exponentially many bridge rules to realize total preference orders and then introduce an encoding that allows to realize arbitrary preference orders at the expense of cloning the contexts of the original MCS. EITER & WEINZIERL 5.1 Filter Encoding We use the meta-reasoning encoding to realize filters, by simply requiring that the observation context becomes inconsistent if the observed diagnosis does not pass the filter, i.e., we use Mmr(θ,Kp) where K = and θ is such that θ(D1, D2, K) holds if and only if f(D1, D2) = 1. Since no further bridge rules are needed to realize filtered diagnoses, it is sufficient to pick Kp = . Definition 13. Let M be an MCS and let f be a filter. Let Kp = and let θ(D1, D2, ) hold iff f(D1, D2) = 1. Then Mmr(θ,Kp) is the filter-encoding of M wrt. f, which we also denote by Mf. Example 11. Reconsider the MCS M = (C1, C2) of Example 7 where two scientists write a paper and diagnoses are to be filtered by a filter f if the authorship information is modified by a diagnosis in an incoherent way. The filter f (see Example 7) is defined as follows: f(D1, D2) = 0 if r3 D1, r2 / D1 or r3 / D1, r2 D1 0 if r3 D2, r2 / D2 or r3 / D2, r2 D2 1 otherwise The resulting filter encoding Mf is the MCS Mmr(θ,Kp) = (C 1, C 2, C3), which has the same contexts and bridge rules as the MCS of Example 10. It only differs in the contents of the observation/encoding context C3 which now realizes the filter f. We use ASP again for the logic of C3 = (Lasp Σ , kb3, br3). Recall that the knowledge-base formulas added by bridge rules to C3 are either of the form uncondr or not removedr and this information has to be exposed accordingly in the accepted belief set. Also remember that the definition of the meta-reasoning encoding requires that every accepted belief set only consists of beliefs in {removedr, uncondr | r br(M)}, but since no other bridge rule of Mmr(θ,Kp) uses any other belief, we may allow further beliefs in the accepted belief set, i.e., our ASP program may use additional atoms. The knowledge base kb3 of C3 then is: kb3 = { removedr1 not not removedr1. removedr3, not removedr2. removedr2 not not removedr2. not removedr3, removedr2. removedr3 not not removedr3. uncondr3, not uncondr2. not uncondr3, uncondr2. } The first three rules of kb3 ensure that the removal information is correct while nothing is needed to ensure that the information about condition-free bridge rules is exposed (if bridge rule ri is made unconditional, then the fact uncondri is added to kb3 by the bridge rule d2(ri) br3(Mmr(θ,Kp)) being applicable and hence uncondri is also present in the answer set and thus in the belief set of C3. The four constraints of kb3 finally encode the filter condition and they ensure that the context has no acceptable belief set if the corresponding diagnoses are applied. Observe that the definition of θ uses the notion of f, which is an abstraction / generalization of some desired actual behavior. Instead of f, it is possible to use the desired actual behavior directly to realize the context Cn+1 of Mmr(θ,Kp), i.e., for a concrete use case where some logic is used to describe which diagnoses should be filtered out, it is not really necessary to first abstract the concrete PREFERENCE-BASED INCONSISTENCY MANAGEMENT IN MULTI-CONTEXT SYSTEMS case to a filter f, build θ accordingly and then derive a concrete instantiation of Cn+1. Rather it is sufficient to take the definition of the meta-reasoning encoding and interpret it as the definition of the interfacing between the logic that does the filtering and the rest of the MCS framework. The reason why we introduced filters in general lies in the fact that this allows us to prove that all such filterings can be realized correctly. The following theorem now shows that diagnoses with protected bridge rules of Mf indeed correspond one-to-one to filtered diagnoses of M. Theorem 1. Let M be an MCS, let f be a filter and let Mf be the corresponding filter-encoding. Then, D m,f(M) = {(D1, D2) | (d1(D1), d2(D2)) D m(Mf, br P )}. To obtain all minimal-filtered diagnoses of an MCS M wrt. the filter f, it is therefore sufficient to compute all subset-minimal diagnoses (with protected bridge rules) of the MCS Mf = Mmr(θ,Kp). Note that this encoding does not come with increased computational cost, since M and Mf have the same number of bridge rules that possibly occur in a diagnosis with protected bridge rules. Consider Mf and the respective bridge rules, i.e., the set br(Mf) \ br P = d1(br(M)) d2(br(M)): since body(r) = { } for r d1(br(M)) and body(r) = { } for r d2(br(M)), it holds for every (R1, R2) D m(Mf, br P ) that r R1 implies r d1(br(M)) and r R2 implies r d2(br(M)) (this follows from Lemma 8 in Appendix A.2). Hence, there are 2|d1(br(M))| 2|d2(br(M))| possibly relevant diagnoses for Mf while there are 2|br(M)| 2|br(M)| possible diagnoses for M; since |d1(br(M))| = |d2(br(M))| = |br(M)|, the candidate space, i.e., the number of candidate diagnoses, for deciding whether a minimal-filtered diagnosis exists for M has the same size as the candidate space for deciding whether a minimal diagnosis with protected bridge rules exists for Mf. 5.2 Plain-Preference Encoding We now show how to use the meta-reasoning encoding Mmr(θ,Kp) for realizing preference orders. The set Kp plays a crucial role, since it is used to map a given preference order on diagnoses to the relation on Kp. This allows us to select minimal -preferred diagnoses by considering -minimal diagnoses of Mmr(θ,Kp). Since the -minimality on Kp should take precedence over the remaining modified bridge rules of Mmr(θ,Kp), we introduce a lexicographic order on bridge rules in which the latter are after those of Kp. As we show in Section 6, the complexity of identifying a diagnosis with respect to prioritized bridge rules Kp is not higher than identifying a minimal diagnosis. In the following, we present a plain and simple encoding, which comes at the cost of Kp being exponentially larger than br(M), i.e., Mmr(θ,Kp) contains exponentially many more bridge rules than M. We also prove that the approach is correct for total preference orders. Before presenting the plain encoding, first we introduce the notion of a prioritized-minimal diagnosis, and second we show how a total order can be mapped to the relation. In the following, we write (D1, D2) br H (D 1, D 2) as shorthand for (D1 br H, D2 br H) (D 1 br H, D 2 br H), i.e., we denote by br H the restriction of to the set br H; furthermore, we write =br H for an analogous restriction on =. To realize a total preference order, the following definition is sufficient where we select from the set of minimal diagnoses with protected bridge rules those that are minimal with respect to the prioritized bridge rules. The bridge rules that are marked as prioritized take precedence for minimality. A prioritized-minimal diagnosis is subset-minimal with respect to prioritized bridge rules (regardless of minimality of the remaining bridge rules). EITER & WEINZIERL Definition 14. Let M be an MCS with bridge rules br(M), protected rules br P br(M), and prioritized rules br H br(M). The set of prioritized-minimal diagnoses is D (M, br P , br H) = D D m(M, br P ) D D m(M, br P ) : D br H D D =br H D . We now show how an arbitrary order relation over a pair of sets may be mapped to the - relation on an exponentially larger set, i.e., we map on the diagnoses of an MCS M, to another exponentially larger set. Definition 15. Let be a preference relation on 2br(M) 2br(M) and let g : 2br(M) 2br(M) Kp be a bijective mapping where Kp is arbitrary. Then, the subset-mapping mapg : 2br(M) 2br(M) 2Kp is defined as follows. For every (D1, D2) 2br(M) 2br(M): mapg (D1, D2) = K Kp | K=g(D 1, D 2) for some (D 1, D 2) (D1, D2) . Observe that mapg (D1, D2) collects g(D 1, D 2) of all (D 1, D 2) below (D1, D2). The following lemma shows that the subset-mapping correctly maps a preference relation on diagnoses to the subset-relation on an exponentially larger set. This allows to decide whether a diagnosis is more preferred than another solely based on subset relationship. Lemma 1. Let be a preference on candidate diagnoses of an MCS M, and let g be a bijective mapping g : 2br(M) 2br(M) Kp for any set Kp. Then, for any (D1, D2), (D 1, D 2) 2br(M) 2br(M) it holds that (D1, D2) (D 1, D 2) iff mapg (D1, D2) mapg (D 1, D 2). We now use mapg to map the preference of a total order to the set Kp which occurs in the meta-reasoning transformation Mmr(θ,Kp). To that end, we choose θ(D1, D2, K) such that it holds iff mapg (D1, D2) = K, for K Kp. By that, every diagnosis of Mmr(θ,Kp) with protected bridge rules (d1(D1), d2(D2) K) contains the preference encoded in K. Selecting a diagnosis of Mmr(θ,Kp) where K is minimal then selects a preferred diagnosis according to . Definition 16. Let M be an MCS and let be a preference order over diagnoses of M. Furthermore, let Kp = {(n+1 : diag D1,D2) . | D1, D2 br(M)} (9) and let g : 2br(M) 2br(M) Kp be a bijective function such that g(D1, D2) = (n+1 : diag D1,D2) . for all D1, D2 br(M). Let θ(D1, D2, K) hold iff mapg (D1, D2) = K. Then the MCS Mmr(θ,Kp) is called the plain encoding of M wrt. , which we also denote by Mpl ; all bridge rules of Kp are prioritized, i.e., br H = Kp. Note that since mapg is a function, also θ is equivalent to a function 2br(M) 2br(M) Kp. Example 12. We consider the hospital MCS M of Example 3 again using a preference order on diagnoses similar to the one of Example 9, i.e., we prefer changing bridge rules regarding health, r1, r2, as little as possible. To make the preference total, we use cardinality-minimality, i.e., (D1, D2) (D 1, D 2) iff {r1, r2} (D1 D2) (D 1 D 2) {r1, r2} . The resulting MCS Mmr(θ,Kp) is outlined in Figure 4, where only bridge rules stemming from r5 of br(M) and some of the bridge rules of the observation context C4 are indicated. Note that br4(Mmr(θ,Kp)) contains for every possible diagnosis of M a distinguished bridge rule. For C4 = (Lasp Σ , kb4, br4), we use ASP again to show a possible realization; kb4 consists of the rules: PREFERENCE-BASED INCONSISTENCY MANAGEMENT IN MULTI-CONTEXT SYSTEMS Patient data C1 Medication C2 Observer/Encoder C4 r2 r3 r4 r 5 d2(r5) diag , diag{r1}, diag{r1,r2}, diagbr(M),br(M) Figure 4: Contexts and some bridge rules of the plain encoding Mpl = (C1, C2, C3, C4) of the hospital MCS wrt. from Example 12. For illustration purposes, only bridge rules stemming from r5 and some from Kp are shown; dashed lines indicate bridge rules r1, . . . , r4 from M whose corresponding bridge rules in Mpl are not shown. removedr not not removedr. r br(M) cur diag D1,D2, not diag D1,D2. D1, D2 br(M), cur diag D 1,D 2 cur diag D1,D2. (D 1, D 2) (D1, D2), cur diag D1,D2 removedr1, . . . , removedrk, uncondr 1, . . . , uncondr m. D1, D2 br(M), D1 = {r1, . . . , rk}, D2 = {r 1, . . . , r m}. Intuitively, the rules of the first line ensure that diagnosis observation is exposed correctly in an accepted belief set of C4; the constraints following ensure the presence of condition-free bridge rules. Rules of the third line guarantee that all bridge rules corresponding to more-preferred diagnoses also need to be condition-free; under ASP semantics, these rules effect mapg (D1, D2). Finally, the rules of the last line recognize one of the exponentially many candidate diagnoses. The next theorem shows the relation between minimal -preferred diagnoses of M wrt. a total preference and prioritized-minimal diagnoses of Mpl . Observe that mapg is injective since is reflexive, thus mapg (D1, D2) contains g(D1, D2), which by g being a bijection is different for every candidate diagnosis (D1, D2). Therefore, mapg is bijective on its range and it allows to establish a one-to-one relation between minimal -preferred diagnoses of M and prioritizedminimal ones of Mpl . Intuitively, this shows that for a total preference order, the set of prioritizedminimal diagnoses of the plain encoding of M wrt. can be used to select the minimal -preferred diagnoses of M. EITER & WEINZIERL Theorem 2. For every MCS M and total preference on its diagnoses, D (Mpl , br P , br H) = {(d1(D1), d2(D2) K) | (D1, D2) D m, (M), mapg (D1, D2) = K}. To select minimal -preferred diagnoses based on an arbitrary preference order, another encoding can be utilized, which we describe next. 5.3 Clone-Preference Encoding The clone encoding requires that the original MCS M is cloned, but comes at the advantage of only requiring linearly many bridge rules, specifically it holds that |Kp| = 4|br(M)| + 1. First an MCS 2M is built that consists of two independent copies of M, and then the meta-reasoning encoding is applied on 2M, i.e., the resulting MCS is (2M)mr(θ,Kp). We show that the minimal -preferred diagnoses can be selected from (2M)mr(θ,Kp) using a slightly more involved diagnosis notion with prioritized bridge rules. The complexity of selecting such diagnoses increases, but it is still worst-case optimal as shown later. The basic idea of the clone encoding is that the original MCS is duplicated such that the observation context sees two diagnoses of the original MCS at the same time and is able to compare them. Intuitively, if we combine two MCS M and M into a single one M , then every diagnosis of the combined MCS M is the combination of a diagnosis of M with a diagnosis of M . Establishing this technically requires some care, since one needs to account for the fact that contexts are identified by their position: Hence, M cannot simply contain the bridge rules of M and M . We thus introduce context shifting and build an operator to combine two MCS. We then show some general properties of the operator, and finally give the clone encoding, which adds a certain observation context to the combination M M of the MCS M whose minimal -preferred diagnoses we are interested in. For shifting contexts, we use a permutation I : N N, i.e., I is a bijective mapping. Given a bridge rule r of form (2), then I(r) is the bridge rule (I(k) : s) (I(c1) : p1), . . . , (I(cj) : pj), not (I(cj+1) : pj+1), . . . , not (I(cm) : pm); furthermore, for a set R of bridge rules we have I(R) = {I(r) | r R} and for a context Ci = (Li, kbi, bri) we have I(Ci) = (Li, kbi, I(bri)). Given an MCS M = (C1, . . . , Cn), a permutation I is compatible with M if I(x) n holds for all x n, i.e., I is a permutation on C (M); the shuffled version of M wrt. a compatible I then is I(M) = (I(CI 1(1)), . . . , I(CI 1(n))). Given a belief state S = (S1, . . . , Sn) we have I(S) = (SI 1(1), . . . , SI 1(n)). To combine two existing MCS M = (C1, . . . , Cn) and M = (C 1, . . . , C m) into a new one, we use the following operator: M M = (C1, . . . , Cn, I(C 1), . . . , I(C m)) where I(x) = n + x for 1 x m, x m for m + 1 x n + m, x otherwise. In the following, we call I the permutation wrt. M M . Note that by construction the permutation I wrt. M M is compatible with M M . Recall that M[R1, R2] = M[br(M) \ R1 cf (R2)]. Regarding modifications and candidate diagnoses, we then observe that M[A1, A2] M [B1, B2] = (M M )[A1 I(B1), A2 I(B2)] where I is the mapping wrt. M M . The following lemma shows that shifting has no influence on acceptability. PREFERENCE-BASED INCONSISTENCY MANAGEMENT IN MULTI-CONTEXT SYSTEMS Lemma 2. Given an MCS M = (C1, . . . , Cn) and a compatible permutation I, it holds that S EQ(M) iff I(S) EQ(I(M)). It immediately follows that S EQ(M[D1, D2]) iff I(S) EQ(I(M[D1, D2])) for any candidate diagnosis (D1, D2). The main observation on the operator is that M M admits exactly those diagnoses which are a combination of a diagnosis of M and a diagnosis of M . Proposition 6. Given two MCS M and M , then D (M M ) = {(A1 I(B1), A2 I(B2)) | (A1, A2) D (M), (B1, B2) D (M )} where I is the permutation wrt. M M . Next we define for an MCS M = (C1, . . . , Cn) the MCS 2M = (C1, . . . , C2n) as 2M = M M, i.e., 2M consists of two clones of M. For easier reference, we write 2.r to denote the clone of the bridge rule r, i.e., 2.r = I(r) where I is the permutation wrt. M M. Note that 2.br(M) is the set of bridge rules of M shifted by n, i.e., 2.br(M) is the set of bridge rules of the second clone of M. The next lemma, which follows from Proposition 6, shows that diagnoses of 2M correspond to diagnoses of M in such a way that every diagnosis of 2M is composed of two diagnoses of M. Lemma 3. Let M be an MCS. Then (D1, D2) D (2M) holds iff there exist (D 1, D 2) D (M) and (D 1, D 2) D (M) such that D1 = D 1 2.D 1 and D2 = D 2 2.D 2. The underlying idea of the encoding is that a specific prioritized bridge rule tmax indicates whether the diagnosis applied to the second clone is preferred over the diagnosis applied to the first clone. Additionally, the diagnosis of the first clone is exhibited via prioritized bridge rules, while the diagnosis of the second clone is only exhibited via non-prioritized bridge rules. If the diagnosis applied to the second clone is more preferred than the one applied to the first, then tmax needs not become condition-free. Thus, if for a given diagnosis of the first clone, there exists some more preferred diagnosis of the second clone, then there exists a diagnosis where tmax is not included. A diagnosis D such that no more preferred diagnosis D exists is maximal wrt. the inclusion of tmax, because there exists no more preferred diagnosis D of M that could occur at the second clone. Selecting a diagnosis that modifies a minimal set of prioritized bridge rules and that contains tmax thus selects a -preferred diagnosis. We define tmax as follows: tmax : (2n+1 : ismax) . To represent the diagnosis of the first clone, we use the following prioritized bridge rules. For a bridge rule r br(M) let in1(r), in1(r), in2(r), and in2(r) denote the following bridge rules: in1(r) : (2n+1 : in1(r)) . in2(r) : (2n+1 : in2(r)) . in1(r) : (2n+1 : in1(r)) . in2(r) : (2n+1 : in2(r)) . We identify a candidate diagnosis (D1, D2) 2br(M) 2br(M) using these bridge rules by the set K(D1, D2) = {in1(r) | r D1} {in1(r) | r / D1} {in2(r) | r D2} {in2(r) | r / D2}. The clone encoding then formally is as follows. EITER & WEINZIERL Definition 17. Let M = (C1, . . . , Cn) be an MCS and a preference order. The clone encoding of M wrt. is the MCS 2Mmr(θ,Kp) where 2M = (C1, . . . , C2n) = M M, (2n+1 : q) ., | q {in1(r), in1(r), in2(r), in2(r)} {tmax} and for any R1, R2 br(2M), and R3 Kp, θ(R1, R2, R3) holds iff R1 = D1 2.D 1, R2 = D2 2.D 2 and either (D1, D2) = (D 1, D 2) and R3 = K(D1, D2) {tmax} or (D 1, D 2) (D1, D2) and R3 = K(D1, D2). The protected bridge rules br P are all bridge rules except those of context C2n+1; the prioritized bridge rules are br H = Kp. We denote the clone encoding of M wrt. by M = 2Mmr(θ,Kp). Note that the second case above with (D 1, D 2) (D1, D2) implies that (D1, D2), (D 1, D 2) are two diagnoses of M, because the MCS 2M only admits a diagnosis if (D1, D2) D (M) and (D 1, D 2) D (M) both hold (cf. Lemma 3). Also observe that M = (2M)mr(θ,Kp) = (M M)mr(θ,Kp) is linear in the size of M, as for every bridge rule in M there exist 2 4+4 bridge rules in M , (the factor 2 is from M M, the factor 4 is from the meta-reasoning encoding itself and the +4 is due to Kp). In total |br(M )| = 12 |br(M)| + 1, where the +1 is due to tmax. Example 13. Reconsider the MCS M from Example 3 shown in Figure 1. Applying the clone encoding on M wrt. a preference order results in the MCS M = (C1, C2, C3, C4, C5, C6, C7) depicted in Figure 5. It is based on two clones of M, where the first comprises the contexts C1, C2, C3 and the second the contexts C4, C5, C6. The context C7 finally is the observation/encoding context. For each bridge rule r br(M) and each clone of M, there are two bridge rules simulating that r is removed respectively made condition-free in the clone. Hence the bridge rules in M for the contexts C1, . . . , C6 are: r 1 : (2 : hyperglycemia) (1 : hyperglycemia), not (7 : removedr1). r 1 : (2 : hyperglycemia) (7 : uncondr1). r 2 : (2 : allow animal insulin) not (1 : allergic animal insulin), not (7 : removedr2). r 2 : (2 : allow animal insulin) (7 : uncondr2). r 3 : (3 : bill animal insulin) (2 : give animal insulin), not (7 : removedr3). r 3 : (3 : bill animal insulin) (7 : uncondr3). r 4 : (3 : bill human insulin) (2 : give human insulin), not (7 : removedr4). r 4 : (3 : bill human insulin) (7 : uncondr4). r 5 : (3 : insurance B) (1 : insurance B), not (7 : removedr5). r 5 : (3 : insurance B) (7 : uncondr5). I(r1) : (5 : hyperglycemia) (4 : hyperglycemia), not (7 : removedr1). I(r1) : (5 : hyperglycemia) (7 : uncondr1). I(r2) : (5 : allow animal insulin) not (4 : allergic animal insulin), not (7 : removedr2). I(r2) : (5 : allow animal insulin) (7 : uncondr2). PREFERENCE-BASED INCONSISTENCY MANAGEMENT IN MULTI-CONTEXT SYSTEMS I(r3) : (6 : bill animal insulin) (5 : give animal insulin), not (7 : removedr3). I(r3) : (6 : bill animal insulin) (7 : uncondr3). I(r4) : (6 : bill human insulin) (5 : give human insulin), not (7 : removedr4). I(r4) : (6 : bill human insulin) (7 : uncondr4). I(r5) : (6 : insurance B) (4 : insurance B), not (7 : removedr5). I(r5) : (6 : insurance B) (7 : uncondr5). For each bridge rule r above there are two (non-protected) bridge rules at the observation context C7 indicating whether r is regarded as removed respectively condition-free. Overall, the set of bridge rules of C7 is: (7 : ismax) . (7 : not removedr1) . (7 : uncondr1) . (7 : not removedr2) . (7 : uncondr2) . (7 : not removed I(r4)) . (7 : uncond I(r4)) . (7 : not removed I(r5)) . (7 : uncond I(r5)) . (7 : in1(r1)) . (7 : in1(r1)) . (7 : in2(r1)) . (7 : in2(r1)) . (7 : in1(r5)) . (7 : in1(r5)) . (7 : in2(r5)) . (7 : in2(r5)) . The bridge rules of Kp are now all rules among them with head formula ini(r) or ini(r) for i {1, 2} and r br(M), plus the bridge rule tmax. These bridge rules are the prioritized ones i.e., br H = Kp. A detailed description for a concrete preference order is given in Appendix B (Example 19). For selecting minimal -preferred diagnoses based on an arbitrary preference order, Definition 14 is strengthened in two steps: first, if two diagnoses are equal considering their prioritized bridge rules, then subset-minimality on the remaining bridge rules is taken into account. Second, since we only want to select diagnoses where no more preferred ones exist, we consider only prioritized-minimal diagnoses that contain the bridge rule tmax. For the first step, let M be an MCS with bridge rules br(M), protected rules br P , and prioritized rules br H br(M). The set of subset-minimal prioritized-minimal diagnoses then is: D m(M, br P , br H) = D D m(M, br P ) | Minbr H,br P (M, D) D D m(M, br P ) : Minbr H,br P (M, D ) D br(M)\br H D D =br(M)\br H D (10) where Minbr H,br P (M, X) denotes that X is minimal among all protected diagnoses with respect to br H, i.e., Minbr H,br P (M, X) = D D m(M, br P ) : D br H X X =br H D. The first condition ensures that a diagnosis D is prioritized-minimal and for all other prioritized-minimal diagnoses D it holds that D is minimal wrt. non-prioritized bridge rules. For the second step, we just add to D m(M, br P , br H) the condition that D and D make tmax condition-free. Formally: EITER & WEINZIERL Patient data C1 Medication C2 Observer/Encoder C7 Patient data C4 Medication C5 I(r3) I(r4) d1(r5) d2(r5) d1(I(r5)) d2(I(r5)) Figure 5: The MCS M = (C1, C2, . . . , C7) of Example 13. Some bridge rules of the observation context C7 are shown and the bridge rules stemming from r5; dashed and gray lines indicate the other bridge rules of M M whose resulting bridge rules in M are omitted. The prioritized bridge rules of M are tmax and all bridge rules ini(rj) and ini(rj). Definition 18. Given an MCS M with protected bridge rules br P and prioritized bridge rules br H, the set of subset-minimal prioritized-minimal (mpm) diagnoses wrt. tmax is D m,tmax (M, br P , br H) = D D m(M, br P ) | Minbr H,br P (M, D) tmax D D D m(M, br P ) : (Minbr H,br P (M, D ) tmax D ) D br(M)\br H D D =br(M)\br H D where tmax D stands for D = (D1, D2) tmax D2 and Minbr H,br P (M, X) is as above. Intuitively, D is an mpm-diagnosis, if it respects protected bridge rules and contains tmax, if it is preferred, i.e., it is minimal wrt. prioritized bridge rules br H among all other diagnoses of the MCS M, and if for all other preferred diagnoses that contain tmax it holds that D is subset-minimal wrt. regular bridge rules. Example 14. Consider again the clone encoding M of Example 13 with a preference order on the diagnoses of the MCS M that prefers changing bridge rules regarding health, i.e., r1, r2, as little PREFERENCE-BASED INCONSISTENCY MANAGEMENT IN MULTI-CONTEXT SYSTEMS as possible. Formally, let (D1, D2) (D 1, D 2) hold iff {r1, r2} (D1 D2) (D 1 D 2) {r1, r2}. We illustrate the notion of mpm-diagnosis by examining three candidate diagnoses of M . (1) Consider a diagnosis on M corresponding to the diagnosis (D1, D2) = ({r4}, ) on M, viz. the diagnosis Dp = {d1(r4), d1(I(r4))}, K({r4}, ) {tmax} . Then Dp is an mpmdiagnosis of M , because (i) it contains no protected bridge rules; (ii) θ holds according to the conditions of the clone encoding, specifically for R1 = D1 2.D1, R2 = D2 2.D2 and R3 = K(D1, D2) {tmax}, hence Dp D m(M , br P ); (iii) Dp is minimal among diagnoses respecting prioritized bridge rules; and (iv) no other such diagnosis is a subset of Dp on non-prioritized bridge rules. (2) The diagnosis Do = {d1(r4), d1(r5), d1(I(r4)), d1(I(r5)}, K({r4, r5}, ) {tmax} contains no protected bridge rules and θ holds as defined by the clone encoding. Furthermore, Do is minimal among the diagnoses that respect prioritized bridge rules, since the encoding ensures that K({r4}, ) and K({r4, r5}, ) are incomparable, because in1(r5) K({r4}, ) \ K({r4, r5}, ) while in1(r5) K({r4}, ) \ K({r4, r5}, ). However, Do is not an mpm-diagnosis, because Dp is minimal with respect to prioritized rules and is smaller on the non-prioritized rules than Do, i.e., {d1(r4), d1(I(r4))} {d1(r4), d1(r5), d1(I(r4)), d1(I(r5)}. (3) Consider a diagnosis Dn stemming from the diagnosis ({r1}, ), which is not preferred according to , i.e., it holds that ({r4}, ) ({r1}, ). Let Dn = {d1(r1), d1(I(r1))}, K({r1}, ) {tmax} . Then, Dn is not an mpm-diagnosis, because it is not minimal among diagnoses respecting prioritized bridge rules. Consider the diagnosis where the diagnosis ({r4}, ) is applied to the second clone of M, i.e., Ds = {d1(r1), d1(I(r4)), K({r1}, ) . Observe that θ holds for Ds according to Definition 17, because ({r4}, ) ({r1}, ) and R3 = K({r1}, ). It also holds that Ds br H Dn, because K({r1}, ) K({r1}, ) {tmax} and therefore Minbr H,br P (M , Dn) does not hold. Consequently, Dn is not an mpm-diagnosis. As we show in the next section, the notion of mpm-diagnosis is computationally harder than the notion of prioritized-minimal diagnosis. Nevertheless, the problem itself (i.e., identifying a minimal -preferred diagnosis) is shown to be as hard as this notion, which means the notion of mpm-diagnosis is worst-case optimal. Note that D, D D (M, br P ) implies that D br(M)\br H D holds iff D br(M)\br H\br P D holds, because D = (D1, D2) D (M, br P ) implies that D1 br P = = D2 br P . The same also holds for =br(M)\br H and =br(M)\br H\br P . As it appears, D (M , br P , br H) suffices to obtain those diagnoses of M that are -preferred. In the following, we write t(D1, D2) as a shorthand for the corresponding candidate diagnosis in the MCS M , i.e., t(D1, D2) = (d1(D1 2.D1), d2(D2 2.D2) K(D1, D2) {tmax}). Theorem 3. Let M be an MCS and let be a preference order on the diagnoses of M. Then D D (M) is -preferred iff t(D) D (M , br P , br H) holds. Note that t(D) D (M , br P , br H) implies that tmax t(D); but there also are diagnoses T D (M , br P , br H) such that tmax / T. Nevertheless, it follows directly from the definition of M that for any T D (M , br P , br H) with tmax T there exist D1, D2 br(M) such that T = t(D1, D2). Hence, diagnoses of D (M , br P , br H) that contain tmax correspond one-to-one to -preferred diagnoses of M. Example 15 (ctd.). Consider the diagnosis D = ({r4, r5}, ). It is -preferred, as it does not modify any of the bridge rules in {r1, r2}. The corresponding diagnosis t(D) is the diagnosis Do EITER & WEINZIERL from Example 14, i.e, t(D) = {d1(r4), d1(r5), d1(I(r4)), d1(I(r5)}, K({r4, r5}, ) {tmax} . It holds that Do D (M , br P , br H), as stated by Theorem 3. The next theorem shows that the clone encoding M and the notion of mpm-diagnosis D m,tmax allow to select all minimal -preferred diagnoses of M. This theorem therefore establishes that the clone encoding is sound and complete. Theorem 4. Let M be an MCS and let be a preference order on diagnoses of M. Then (D1, D2) D m, (M) holds iff t(D1, D2) D m,tmax (M , br P , br H) holds. Recall that given a CP-net N that is compatible with an MCS M, the minimal -preferred diagnoses according to N and the irredundant N-preferred diagnoses coincide, i.e., D ird(M, N) = D m, N (M) (cf. Proposition 2). One thus can realize the selection of optimal diagnoses according to a CP-net using the clone encoding M N and the methods provided in this section. Also note that M N has size only linearly larger than M. Since the approaches only specify some of the behavior of the observation context, the concrete choice of a logic to realize the observation remains to the user. This is especially useful for preference formalisms like CP-nets where algorithms may be chosen according to the computational complexity of the employed CP-net. 6. Computational Complexity To select preferred and most preferred diagnoses, the previous section introduced several advanced notions of diagnosis. In this section we investigate the computational complexity of these notions. As it turns out, considering protected bridge rules as well as prioritized bridge rules does not increase the computational complexity of identifying a diagnosis.1 Identifying subset-minimal diagnoses among those with protected and prioritized bridge rules, however, incurs additional cost. Since selecting most preferred diagnoses is hard for the same complexity class in the basic case, the additional cost are expected and our approach is thus worst-case optimal. We begin by recalling the necessary notions of complexity analysis in MCS. 6.1 Complexity Classes and Context Complexity Recall that P, EXPTIME, and PSPACE are the classes of problems that can be decided using a deterministic Turing machine in polynomial time, exponential time, and polynomial space, respectively. Furthermore NP (resp., co NP) is the class of problems that can be decided on a nondeterministic Turing machine in polynomial time, where one (resp., all) computation paths accept. The polynomial hierarchy is built as follows: ΣP 0 = ΠP 0 = P, and for all i 1, ΣP i = NPΣP i 1 is NP with a ΣP i 1 oracle and ΠP i is co-ΣP i . Given a complexity class C, D(C) denotes the difference class of C, i.e., D(C) = {L1 L2 | L1 C, L2 co-C} is the complexity class of decision problems that are the conjunction of a problem L1 in C and a problem L2 in co-C. We use the notation that D(NP) = DP 1 and 1. In line with and for comparability to the work of Eiter et al. (2014), we concentrate on recognizing diagnoses and omit deciding (advanced) diagnosis existence. Briefly, the latter problem is for context complexity C in NPC for polynomial-time filters f (in particular, for protected bridge rules), which collapses to C if C is closed under conjunction and projection; thus for all considered notions, the existence problem is in this case C-complete. PREFERENCE-BASED INCONSISTENCY MANAGEMENT IN MULTI-CONTEXT SYSTEMS D(ΣP i ) = DP i . A prototypical problem that is complete for DP 1 is deciding, given a pair (F1, F2) of propositional Boolean formulas, whether F1 is satisfiable and F2 is unsatisfiable. Since MCS are composed of contexts where each context is a KR formalism, the complexity of deciding whether an MCS is consistent clearly depends on the complexity of the KR formalisms employed in its contexts. This intuition is captured by the notion of context complexity, which measures deciding whether a set of beliefs is acceptable under a given knowledge-base of a context and a given set of formulas added via bridge rules. Let OUT i = {p | (i : p) body(r) for some r br(M)} denote the set of beliefs of context Ci which occur in the body of some bridge rule of the MCS. Context complexity is defined wrt. output-projected beliefs, i.e., belief sets projected to output beliefs (for details see Eiter et al., 2014), formally: Definition 19 (cf. Eiter et al., 2014). Given a context Ci = (kbi, bri, Li) and a pair (H, Ti), with H {ϕ (r) | r bri} and Ti OUT i, the context complexity CC(Ci) of Ci is the computational complexity of deciding whether there exists an Si ACCi(kbi H) such that Si OUT i = Ti. We view here (as in Eiter et al., 2014) the computational complexity of a problem Π technically as the set of all problems Π that are polynomial-time many-one reducible to Π, i.e., as the problems that are not harder than Π; in particular SAT has the computational complexity NP. Furthermore, the logics Li of all contexts are considered to be given implicitly and thus the instance size of a given MCS M is |M| = |kb M| + |br(M)| where |kb M| denotes the size of the knowledge bases in M and |br(M)| denotes the size of its set of bridge rules. Given an MCS M, we say M has upper context complexity C, denoted CC(M) C, if CC(Ci) C for every context Ci of M; we say M has lower context complexity C, denoted CC(M) C, if C CC(Ci) for some context Ci of M. We say that M has context complexity C, denoted CC(M) = C, iff CC(M) C and CC(M) C. That is, if CC(M) = C all contexts in M have complexity at most C, and some context in M has C-complete complexity with respect to polynomial-time many-one reductions, which requires that the class C has complete problems. Restricting disjunctive ASP to the ground case admits ΣP 2 -complete acceptability checking (see Dantsin, Eiter, Gottlob, & Voronkov, 2001; Gottlob, 1992), hence the context complexity of a context using Lasp Σ is ΣP 2 -complete given that all kb-elements are ground; in the (function-free) non-ground case, the context complexity is NEXPTIMENP (Eiter, Gottlob, & Mannila, 1997). Acceptability checking of a context using Lpl Σ amounts to entailment checking for all literals present in the belief set and non-entailment checking for all literals absent in the belief set, i.e., it amounts to an UNSAT and an independent SAT check, hence the context complexity is DP. Example 16. The MCS M = (C1, C2, C3) of Example 3 is such that CC(C1) = NP and CC(C2) = CC(C3) = ΣP 2 . As NP ΣP 2 , it holds that CC(M) ΣP 2 , and as C2 is ΣP 2 -complete, we obtain CC(M) ΣP 2 ; hence CC(M) = ΣP 2 . The problem of deciding whether for a given MCS M and a pair (D1, D2) of bridge rules, it holds that (D1, D2) is a minimal diagnosis, i.e., deciding whether (D1, D2) D m(M), is denoted by MCSDm. As shown in [Prop. 11 by Eiter et al., 2014] if CC(M) = P, then MCSDm is DP 1 - complete; if CC(M) = C and C is a class with complete problems and closed under conjunction and projection, then the problem of MCSDm is D(C)-complete. Intuitively, a class C is closed under conjunction, if all its decision problems are such that checking multiple instances of the problem at the same time is a problem in C. For example, checking whether a propositional formula F is EITER & WEINZIERL Context Deciding (D1, D2) ? complexity D m(M) D m(M, br P ) D (M, br P , br H) D m,tmax (M, br P , br H) CC(M) MCSDm MCSDPm MCSDPH MCSDPHm,tmax P DP 1 -complete DP 1 -complete DP 1 -complete ΠP 2 -complete NP DP 1 -complete DP 1 -complete DP 1 -complete ΠP 2 -complete ΣP i , i 1 DP i -complete DP i -complete DP i -complete ΠP i+1-complete PSPACE PSPACE-complete EXPTIME EXPTIME-complete Shown by Eiter et al. (2014) Theorem 5 Theorem 6 Theorems 7 + 8 Table 1: Complexity results of deciding whether a candidate diagnosis is subset-minimal, additionally protected, prioritized-minimal, or an mpm-diagnosis. Problem MCSDMPREF has the same complexity as MCSDPHm,tmax if deciding D D is in CC(M). satisfiable is in NP; given two independent formulas F and G, checking whether both are satisfiable also is in NP since it amounts to checking whether F G is satisfiable. A class C is closed under projection, if intuitively for every problem in C, the decision problem on projected instances (similar as for output-projected equilibria) is contained in C. For example, given a formula F in propositional logic over variables var(F), finding an assignment VA over (projected) variables A var(F) such that (i) there exists an assignment V A to the variables A = var(F) \ A and (ii) VA V A |= F, is as hard as finding an (overall) assignment V over var(F) such that V |= F. For further details we refer to the work of Eiter et al. (2014). Specifically, for CC(M) = ΣP i it holds that MCSDm is in DP i . Furthermore, since DP i is closed under conjunction and projection, it holds that MCSDm is DP i -complete if at least one context in M is complete for ΣP i . 6.2 Overview of Results We now investigate the complexity of our enhanced notions of diagnosis. More specifically, we study the complexity of the following decision problems, given an MCS M, a candidate diagnosis D 2br(M) 2br(M), and depending on the problem additionally given protected bridge rules br P br(M), prioritized bridge rules br H br(M), and tmax br(M): MCSDPm: deciding whether D is a subset-minimal diagnosis with protected bridge rules, i.e., deciding whether D D m(M, br P ) holds. MCSDPH: deciding whether D is a prioritized-minimal diagnosis, i.e., deciding whether D D (M, br P , br H) holds. MCSDPHm,tmax : deciding whether D is an mpm-diagnosis (a subset-minimal prioritizedminimal diagnosis wrt. tmax), i.e., deciding whether D D m,tmax (M, br P , br H) holds. MCSDMPREF: given an arbitrary preference order deciding whether D D m, (M) holds. PREFERENCE-BASED INCONSISTENCY MANAGEMENT IN MULTI-CONTEXT SYSTEMS We show that MCSDPm is not harder than MCSDm, i.e., deciding whether a candidate diagnosis D is a subset-minimal diagnosis with protected bridge rules is not harder than deciding whether D is a subset-minimal diagnosis (Thm. 5). We also demonstrate that the same is true for prioritizedminimal diagnoses, i.e., MCSDPH is as hard as MCSDm (Thm. 6). This notion of diagnosis can be applied to the plain encoding Mpl for total preference orders to select minimal -preferred diagnoses according to a total preference order . The drawback of this approach, however, is the exponential number of bridge rules in Mpl . Since the clone encoding M incurs no exponential blow-up of bridge rules, it is reasonable to expect that the computational complexity of MCSDPHm,tmax is higher than the one of MCSDm. Indeed, for context complexity CC(M) in ΣP i we prove that MCSDPHm,tmax is in ΠP i+1 while MCSDm is in DP i (Thm. 7). Specifically, for CC(M) in NP the complexity of MCSDPHm,tmax is ΠP 2 while MCSDm is in DP 1 . Since deciding t(D) D m,tmax (M , br P , br H) only serves to decide D D m, (M), we also investigate the lower bound for the latter problem, i.e., MCSDMPREF. We prove that it is ΠP 2 -hard (Thm. 8) if CC(M) is in P; hence we obtain that the clone encoding using M and D m,tmax (M , br P , br H) is in fact worst-case optimal. Furthermore, we also show that MCSDMPREF is hard for ΠP i+1 if CC(M) is hard for ΣP i . Table 1 summarizes the results for the introduced notions of diagnosis and for context complexity being in one of several complexity classes. Note that the results for PSPACE and EXPTIME in the last column follow from the fact that co NPPSPACE = PSPACE and co NPEXPTIME = EXPTIME for membership while hardness can be shown using a trivial MCS where the acceptability function of some context is hard for PSPACE resp. EXPTIME. Our results are derived using several reductions and a genuine algorithm, which are presented in the remainder of this section; proofs can be found in the appendix. 6.3 Derivation of Results For the problem of recognizing minimal diagnoses with protected bridge rules we have the following result. Theorem 5. MCSDPm is equivalent to MCSDm under polynomial-time reductions. Indeed, MCSDPm is polynomially reducible to MCSDm, by simply checking first whether the candidate diagnosis contains protected bridge rules and then solve MCSDm to check whether it is subset-minimal. A formal reduction is provided in the proof of Theorem 5. Conversely, every instance of MCSDm is an instance of MCSDPm with br P = , and thus MCSDm trivially reduces to MCSDPm in polynomial time. Next we consider the problem MCSDPH. We will show that this problem has the same complexity as MCSDPm. To this end we first present a polynomial-time many-one reduction DPH2DPm from MCSDPH to MCSDPm. We remark that a direct membership proof would be simpler, but the reduction is of interest in its own right. 6.3.1 UNDERLYING IDEA OF DPH2DPm Given an MCS M with protected bridge rules br P and prioritized bridge rules br H, we simulate the modifications of regular bridge rules inside the resulting MCS. The set Rreg of regular (nonprioritized, non-protected) bridge rules is Rreg = br(M) \ br H \ br P and their modifications can EITER & WEINZIERL d1(r2) d2(r2) Mmr(θ,Kp) M r1 : (2 : b) (1 : a). r2 : (3 : d) (2 : c). kbn+1 = removedr1 not not removedr1. removedr2 not not removedr2. kbn+2 = not removedr1 not removedr1. removedr1 not not removedr1. uncondr1 not not uncondr1. not uncondr1 not uncondr1. Figure 6: The reduction from MCSDPH to MCSDPm exemplified on an MCS M = (C1, C2, C3) with two bridge rules br(M) = {r1, r2}. Shown are the MCS M M employed in the reduction DPH2DPm (components are indicated in gray), bridge rules of M, and the knowledge bases of Cn+1 and Cn+2. be simulated by using a meta-reasoning transformation Mmr(θ,Kp) = (C1, . . . , Cn+1), where the bridge rules of Cn+1 correspond to modifications of bridge rules in Rreg. They take their values from an additional context Cn+2 that generates all possible modifications, i.e., every possible modification corresponds to an acceptable belief set of Cn+2. We protect in the resulting MCS M = (C1, . . . , Cn+2) all bridge rules except those that correspond to modifications of bridge rules in br H, i.e., every diagnosis of M corresponds to one (or more) diagnoses of M, but the diagnoses of M only contain bridge rules corresponding to subsets of br H. Consequently, any minimal diagnosis of M is br H-minimal wrt. M. To ensure that the diagnosis indeed is -minimal, we further add a copy of M, i.e., the resulting MCS is M M where M ensures minimality wrt. br H and M ensures minimality wrt. . An illustration of the resulting MCS is given in Figure 6 for a concrete MCS that is considered later in Example 17 below in detail. PREFERENCE-BASED INCONSISTENCY MANAGEMENT IN MULTI-CONTEXT SYSTEMS 6.3.2 FORMAL DETAILS OF DPH2DPm Given an MCS M and a set Rreg br(M), let Kp = and let θ be such that for all D1, D2 br(M) the property θ(D1, D2, ) holds. We craft an MCS based on the meta-reasoning MCS Mmr(θ,Kp) = (C1, . . . , Cn, Cn+1) to obtain an MCS where the modification of all bridge rules in Rreg is hidden in the set of possible belief states. To this end, we introduce another context Cn+2 without bridge rules whose acceptable belief sets encode all respective modifications of bridge rules of Rreg. Formally, Cn+2 = (Lasp Σ , kbn+2, ) where kbn+2 = not removedr not removedr. removedr not not removedr. uncondr not not uncondr. not uncondr not uncondr. Observe that for every D1, D2 Rreg, there is a belief set Sn+2 with Sn+2 {not removedr, uncondr | r Rreg} = {not removedr | r Rreg \ D1} {uncondr | r D2}. In addition to that, since Cn+2 has no bridge rules, it follows that Sn+2 ACCn+2(kbn+2 app(brn+2, S )) holds for all belief states S = (S 1, . . . , S n+2) where S n+2 = Sn+2. Recall that all bridge rules of Cn+1 are either of the form (n + 1 : not removedr) . or (n + 1 : uncondr) . where r br(M). Let Cn+1 = (L, kbn+1, brn+1); then C n+1 = (L, kbn+1, br n+1) where br n+1 = {(n + 1 : not removedr) (n + 2 : not removedr). | r br(M), r Rreg} (11) {(n + 1 : uncondr) (n + 2 : uncondr). | r br(M), r Rreg} (12) {(n + 1 : not removedr) . | r br(M), r / Rreg} (13) {(n + 1 : uncondr . | r br(M), r / Rreg}. (14) Intuitively, C n+1 equals Cn+1 but the bridge rules occurring in Rreg refer to Cn+2. Similar to the meta-reasoning encoding, we denote by d1(r) and d2(r) the corresponding bridge rule of the form in (13) and in (14), respectively. We extend these notions to sets of bridge rules and let di(R) = {di(r) | r R} for any R br(M) and i = 1, 2. For example, d1(br(M) \ R1) denotes all bridge rules of line (13). Finally, we call M = (C1, . . . , Cn, C n+1, Cn+2) the meta-guessing MCS for M and Rreg. The effect of the redirection to Cn+2 is that the acceptable belief sets of Cn+2 guess all possible modifications. The rest of M behaves like an ordinary meta-reasoning encoding, where protected bridge rules of M are br P = br M \ (d1(br(M) \ Rreg) d2(br(M) \ Rreg)), i.e., all bridge rules are protected except those in Cn+1 that do not correspond to bridge rules in Rreg. Now the reduction DPH2DPm from MCSDPH to MCSDPm is as follows: (M, (D1, D2), br P , br H) 7 (M M, (D 1, D 2), br P ) where M is the meta-guessing MCS wrt. Rreg = br(M) \ br P \ br H and br P = br P I(br P ) where I is the mapping wrt. M M and br P is the set of protected bridge rules of the metaguessing MCS M ; furthermore D 1 = I(D1) d1(D1 br H) and D 2 = I(D2) d2(D2 br H), i.e., (D 1, D 2) contains a candidate diagnosis of M and a candidate diagnosis over br H with modifications to the remaining bridge rules of M being simulated by M . EITER & WEINZIERL Observe that the size of (M M, (D 1, D 2), br P ) is polynomial in the size of (M, (D1, D2), br P , br H), because M M only has four times as many bridge rules as M and all other sets are subsets of these bridge rules. Furthermore, (M M, (D 1, D 2), br P ) can be computed in polynomial time in the size of (M, (D1, D2), br P , br H); more precisely, even in linear time. Example 17. We illustrate the reduction DPH2DPm and the MCS resulting from on a simple MCS M = (C1, C2, C3) with three contexts and two bridge rules br(M) = {r1, r2} as follows: r1 : (2 : b) (1 : a). r2 : (3 : d) (2 : c). No bridge rule is protected, i.e., br P = , and r2 is prioritized, i.e., br H = {r2}, thus Rreg = {r1}. Figure 6 illustrates M (on the right) and the meta-guessing MCS M for M and Rreg (on the left); their combination M M (the overall Figure 6), is the MCS constructed in the reduction DPH2DPm. It also shows a possible realization of the contexts Cn+1 and Cn+2 using ASP. Since Cn+1 stems from the meta-reasoning encoding where θ holds for all potential diagnoses, the two rules in kbn+1 are sufficient to exhibit the observed modifications of r1 and r2 as beliefs. Intuitively, the rules in kbn+2 guess all potential modifications of r1 and exhibit them to Cn+1 as beliefs. The following lemma shows that DPH2DPm indeed is a correct reduction from MCSDPH to MCSDPm. Lemma 4. DPH2DPm is a polynomial-time reduction from MCSDPH to MCSDPm. On the other hand, one can easily reduce MCSDPm to MCSDPH. We thus obtain that MCSDPH indeed has the same complexity as deciding D D m(M, br P ) and hence whether D D m(M) holds. Theorem 6. MCSDPH is equivalent to MCSDPm under polynomial-time reductions. 6.3.3 FURTHER COMPLEXITY RESULTS A stepping stone for analyzing MCSDPHm,tmax is the decision problem MCSDPHtmax , which we consider next. MCSDPHtmax is defined as follows: given an MCS M, a candidate diagnosis D 2br(M) 2br(M) with D = (D1, D2), protected bridge rules br P br(M), prioritized bridge rules br H br(M), and tmax br(M); decide whether (i) tmax D2 and (ii) for all T D m(M, br P ) it holds that T br H D T =br H D. Notice that MCSDPHtmax basically amounts to checking the presence of tmax in a candidate diagnosis of MCSDPH. As the following lemma shows, former is not harder than the latter. Lemma 5. MCSDPHtmax is polynomial-time reducible to MCSDPH and thus in the complexity class C, if MCSDPH is in C and C is closed under polynomial reductions. Note that all classes in Section 6.1 above are closed under polynomial-time reductions. We use an MCSDPHtmax -oracle in Alg. 1 to obtain membership results of MCSDPHm,tmax . Theorem 7. If MCSDPH is in C, then MCSDPHm,tmax is in co NPC. PREFERENCE-BASED INCONSISTENCY MANAGEMENT IN MULTI-CONTEXT SYSTEMS Algorithm 1: Deciding whether (D1, D2) D m,tmax (M, br P , br H) holds. Input : MCS M, (D1, D2), br P , and br H with D1, D2 br(M), br P , br H br(M). Output: YES if (D1, D2) D m,tmax (M, br P , br H) 1 if oracle MCSD P Htmax (D1, D2), M, br P , br H = NO then output YES 2 guess T1, T2 br(M) 3 if oracle MCSD P Htmax (T1, T2), M, br P , br H = YES (T1, T2) = (D1, D2) (T1, T2) br(M)\br H (D1, D2) (T1, T2) =br(M)\br H (D1, D2) then output YES Proof. Algorithm 1 decides whether (D1, D2) D m,tmax (M, br P , br H) holds using an oracle for MCSDPHtmax . Intuitively, (D1, D2) is not an mpm-diagnosis if it either is no subset-minimal prioritized-minimal containing tmax, which is checked in the first line using the oracle, or if there exists a subset-minimal prioritized-minimal diagnosis (T1, T2) (D1, D2) that also contains tmax. In the second line such a (T1, T2) is guessed and in the third line it is verified that the guessed candidate indeed has the above properties. Checking whether (D1, D2) D m,tmax (M, br P , br H) holds is possible by Algorithm 1 and negating its output. By assumption MCSDPH is in C, thus by Lemma 5 it holds that MCSDPHtmax is in C, i.e., the complexity of the oracle in Algorithm 1 is in C. Since Algorithm 1 uses a polynomial-size guess for (T1, T2) its complexity clearly is NPC. Consequently, deciding whether (D1, D2) D m,tmax (M, br P , br H) holds is in co NPC. The previous decision problems arise from our approach to realize the selection of preferred and filtered diagnoses of an MCS. To give a full picture, we also investigate the complexity of the basic problem, i.e., of MCSDMPREF. As the following theorem shows, MCSDMPREF itself is ΠP 2 -hard even if both the context complexity and deciding whether D D holds are tractable. This result also shows that our approach of realizing the selection of minimal -preferred diagnoses is worst-case optimal. Theorem 8. If CC(M) is hard for ΣP i (ΠP i ) then MCSDMPREF is hard for ΠP i+1 (ΠP i+2) with i 0. Moreover, MCSDMPREF is ΠP 2 -hard even if both CC(M) and deciding D D are in P. For establishing completeness of MCSDMPREF, we use the clone encoding of the previous section as a polynomial-time reduction to MCSDPHm,tmax . Corollary 1. Let M be an MCS with CC(M) = ΣP i , i 0 (resp., CC(M) = PSPACE, CC(M) = EXPTIME), and a preference order such that deciding D D is in ΣP i (resp., PSPACE, EXPTIME). Then MCSDMPREF is complete for ΠP i+1 (resp., PSPACE, EXPTIME). In particular, MCSDMPREF is ΠP i+1-complete if deciding D D is in P and CC(M) = ΣP i , i 0. Examples of preference orders as hard as PSPACE are CP-nets in general while restricted variants are in NP or even P (cf. Section 3.2.1). We can also use the clone encoding to show the completeness of MCSDPHm,tmax . Corollary 2. MCSDPHm,tmax is ΠP i+1-complete if CC(M) = ΣP i , i 1, and ΠP 2 -complete if CC(M) = P or CC(M) = NP. EITER & WEINZIERL The hardness result of ΠP i+2 for MCSDMPREF with CC(M) = ΠP i might seem to contradict Corollary 2, which shows, using the clone encoding, that MCSDMPREF is in ΠP i+1 for CC(M) = ΣP i . However this is no contradiction since the basic problem of recognizing minimal diagnoses, i.e., MCSDm, is not known to be in ΣP i for CC(M) = ΠP i . In the work of Eiter et al. (2014) it is shown that MCSDm is in D(C) if C is closed under conjunction and projection, which presumably is not the case for ΠP i , i 0 (while it is for ΣP i ). Hence for CC(M) = ΠP i , MCSDm is not in D(ΠP i ), thus MCSDPHtmax is presumably not in ΠP i+1. On the other hand, ΠP i is in ΣP i+1, consequently MCSDm is in D(ΣP i+1) and MCSDPHtmax in ΠP i+2. 7. Discussion and Related Work In this section we first discuss options for decomposing the central observation context of the metareasoning transformation and then consider related work. 7.1 Decomposing the Central Observation Context A key strength of MCS is the capability of integrating different knowledge bases in a decentralized manner. Accordingly, scenarios for MCS where a centralized specification of preferences on diagnoses may be unwanted, e.g., if different companies agree to share data, their preferences might expose some information they are actually not willing to share. The approaches presented here use a central observation context that knows all bridge rules, or more specifically, that knows the labels of all bridge rules, and for each of them whether and how it is modified. The observer, however, does neither know the structure, i.e., the contents of the head and body, of the bridge rules, nor the actual status of the information exchange, and it cannot see any beliefs of any context. Hence, our approach supports almost full information hiding and only decentralization is lost. Criteria for decomposing a context have been investigated by Weinzierl (2014). The results there can be applied to the meta-reasoning transformation that we described in Section 5.1 in order to decompose the observation context of the filter encoding Mf. If the underlying filter can be broken up, the central observation context thus may be replaced with several contexts, each covering only a partition of the bridge rules in br(M). If there is a partition br(M) = A B (where A, B are disjoint and nonempty) such that a given filter f satisfies that for all D1, D2 br(M) it holds that f(D1, D2) = 1 iff f(D1 A, D2 A) = 1 and f(D1 B, D2 B) = 1, then the observation context of Mf is decomposable. Informally, f is such that the modifications of bridge rules in A can be checked independently from those in B and vice versa. Notice that for any reasonable logical formalism which realizes f, checking whether f(D1 A, D2 A) = 1 resp. f(D1 B, D2 B) = 1 can be realized by two (independent) knowledge bases; the latter are the decomposition of the observation context. Depending on f, this decomposition may be repeated several times, where each time one context is decomposed into two independent contexts until the observation of diagnoses is fully decentralized. Example 18. Consider the MCS Mf = (C1, C2, C3) of Example 11 realizing the filter f on the MCS M whose bridge rules are br(M) = {r1, r2, r3}. Recall that f is defined by: f(D1, D2) = 0 if r3 D1, r2 / D1 or r3 / D1, r2 D1, 0 if r3 D2, r2 / D2 or r3 / D2, r2 D2, 1 otherwise. PREFERENCE-BASED INCONSISTENCY MANAGEMENT IN MULTI-CONTEXT SYSTEMS Obviously, br(M) can be partitioned into A = {r2, r3} and B = {r1}, because for all D1, D2 br(M) holds that f(D1 B, D2 B) = 1 and f(D1 A, D2 A) = f(D1, D2). The resulting decomposition of bridge rules in C3 is: br A 3 = {d1(r2), d2(r2), d1(r3), d2(r3)} and br B 3 = {d1(r1), d2(r1)}. Since the knowledge base kb3 of Mf uses ASP, we can easily get the knowledge bases kb A 3 and kb B 3 by partitioning kb3: removedr2 not not removedr2. removedr3 not not removedr3. removedr3, not removedr2. not removedr3, removedr2. uncondr3, not uncondr2. not uncondr3, uncondr2.} kb B 3 = {removedr1 not not removedr1.} The resulting decomposed MCS is M = (C 1, C 2, CA 3 , CB 3 ), where all bridge rules from C3 either belong to CA 3 or CB 3 and all beliefs of C3 that are referred to in other bridge rules of Mf either refer to CA 3 or CB 3 in M . The diagnoses of M correspond one-to-one to those of Mf. As diagnoses with protected bridge rules are directly based on ordinary diagnoses, these results thus extend to diagnoses with protected bridge rules. The MCS M can be used to obtain minimal filtered diagnoses of M, where the filter itself is realized in a decentralized way. In principle, decomposition may also be applied to the clone encoding M , but the bridge rule tmax disallows a simple decomposition. Nonetheless, it seems possible to achieve decomposition using additional protected bridge rules for information exchange between the decomposed contexts; a formal result, however, remains to be established. 7.2 Related Work We now briefly consider further, previous work and then discuss related work on multi-context systems and other KR formalisms. 7.2.1 PREVIOUS WORK In the work of Weinzierl (2014) several of the notions presented here have been investigated and exemplified in more depth; among others, formal results on the decomposition method introduced in Section 7.1 above. While in this article fully-compatible CP-nets are shown as sample formalism to specify preferences over diagnoses, there are other possibilities of using CP-nets to compare diagnoses, e.g. by assigning each bridge rule r only one variable V r and a domain of {unmodified, removed, condition-free}. This kind of CP-nets, however, cannot represent a candidate diagnosis (D1, D2) with r D1 D2, i.e., where a bridge rule is both removed and conditionfree, while fully compatible CP-nets can represent all candidate diagnoses. There is another sample instantiation of preference orders that is based on units of modified bridge rules. The idea is that bridge rules are grouped according to the information they carry; e.g. in Example 4 there are two units: health-related information (r1 and r2) and billing-related information (r3, r4, and r5). A preference relation over diagnoses is established by considering how many such units are modified (hence potentially broken); preferred are those diagnoses modifying the least number of units. Two transformations for meta-reasoning on diagnoses in an MCS M were developed, where the first merely adds bridge rules and contexts to observe the information exchange between contexts of M. The disadvantage of this transformation is that there are concrete MCS for which the observation EITER & WEINZIERL cannot identify each diagnosis correctly. The second transformation, which is the one presented in this article, is more general and allows for the correct identification of diagnoses for all MCS; however, this comes at the price of rewriting the bridge rules. Below we discuss two closely related approaches that rely on preference to ensure consistency of MCS and a third approach that integrates preferences into MCS contexts directly. We also sketch how our approach can be applied to further extensions of the MCS framework and we relate our approach to preference-based inconsistency management in other KR formalisms. An extended discussion is available in the work of Weinzierl (2014). 7.2.2 PREFERENTIAL MCS In the work of Mu, Wang, and Wen (2015) an approach at preference-based inconsistency management in MCS is introduced: Preferential Multi-Context Systems (PMCS) are similar to ordinary MCS where an additional preference order s restricts the information flow. The relation s is a total preorder on a partitioning of the contexts of M, i.e., s compares sets of contexts and all contexts in the same set are treated as equally preferred. The information flow then is restricted from more preferred to less-or-equally preferred contexts, i.e., a PMCS is stratified. Note that this total preorder differs from our notion of a total preference, since we consider preference over candidate diagnoses, not over sets of contexts. Based on the ordering, one may ask for a maximal consistent section, which is the maximal initial segment of the ordering of preferred contexts that still admit an equilibrium. Furthermore, the notion of a c-diagnosis is introduced, which is a diagnosis that does not modify bridge rules of the maximal consistent section. Note that Mu et al. (2015) only consider diagnoses that remove bridge rules, i.e., diagnoses of the form (D1, ). In the same work, it is noted that a filter f on diagnoses may be used to select c-diagnoses, by simply filtering out all diagnoses that modify bridge rules of the maximal consistent section. This however, requires to know the maximal consistent section in advance. Intuitively, c-diagnoses can be fully captured by preference orders as follows. We recall the notation of an i-cut for PMCS first: given a PMCS M with total preorder s on sets of contexts of M, the i-cut of M, denoted by M(i) contains all contexts that are in the i-th and lower stratum according to s. For example, M(1) contains the most preferred contexts, M(2) contains contexts of M(1) and all that are less preferred than the ones in M(1) but more preferred than any other contexts, and so on. Notice that M(2) M(1) holds, i.e., M(i) contains all contexts of M(j) for j i. Now a preference order is defined on candidate diagnoses as follows: (D1, D2) (D 1, D 2) iff D2 = and for every 1 i m such that D1 {r brℓ| Cℓ M(i)} = , it holds that D 1 {r brℓ| Cℓ M(i)} = . The intuition is that prefers (D1, D2) over (D 1, D 2) if every i-cut M(i) that is modified by the former is also modified by the latter. This effectively guarantees that the most preferred diagnoses according to only modify bridge rules from less preferred contexts. In fact, no most preferred diagnosis modifies any bridge rule of the maximal consistent section, because such a diagnosis is always preferred. Thus, the set of most preferred diagnoses according to should coincide with the set of c-diagnoses. Clarifying this and a more extensive comparison to PMCS remains for future work. Another approach for handling inconsistency in MCS based on a preference order was presented by Caire, Bikakis, and Traon (2013). The notion of conviviality stemming from multi-agent systems is used to model and measure information dependencies in MCS: intuitively, conviviality measures PREFERENCE-BASED INCONSISTENCY MANAGEMENT IN MULTI-CONTEXT SYSTEMS how much contexts exchange information with each other. Every ordinary diagnosis D of an inconsistent MCS M is then associated with the conviviality of the resulting MCS where D is applied, i.e., the conviviality of M[D]. A diagnosis is regarded as being optimal, if its associated conviviality is maximal. Suppose that Conv(M) is the conviviality of an MCS M, we can capture the approach by selecting -preferred diagnoses where is a preference on diagnoses as follows: D D iff Conv(M[D]) Conv(M[D ]). Subsequently, D (M) is the set of optimal diagnoses according to Caire et al. (2013). 7.2.3 MULTI-CONTEXT SYSTEMS WITH PREFERENCES Le, Son, and Pontelli (2015) recently extended the abstract logics of MCS with ranking information to ranked logics and defined an equilibrium semantics for the ensuing Multi-Context Systems with Preferences (MCSP). Formally, a ranked logic is a tuple L = (KBL, BSL, ACCL,