The Multi-context system (MCS) formalism allows to represent interlinking of knowledge bases (Brewka and Eiter 2007). An MCS consists of contexts, each with a knowledge base, a logic, and bridge rules which import knowledge from other contexts. The logic used for reasoning in each context can be individually chosen for each context, this allows to represent heterogeneous systems.
Semantics in MCSs is defined in terms of stable system states which are called equilibria. If some MCS has no equilibrium, it is called inconsistent.
The purpose of MCS-IE is to explain reasons for inconsistency in MCSs, using the notions of Diagnosis and Inconsistency Explanation that were introduced in (Eiter et al. 2010).
The MCS-IE plugin encapsulate the reasoning within contexts by using external atoms. As input, the plugin gets a master file which specifies the MCS architecture. Depending on commandline options, the output of the plugin contains
The main input file for dlvhex contains the MCS topology:
Contexts are specified as follows:
#context(<i>,"<xatom>","<param>").
Bridge rules are specified as follows:
<name>: (<tgtctx>:<input>) :- (<ctx1>:<bel1>), ... not (<ctx2>:<bel2>), ... .
Bridge rule facts are specified as follows:
<name>: (<tgtctx>:<input>).(see above)
Example input for the MCS used in (Eiter et al. 2010):
#context(1,"dlv_asp_context_acc", "kb1.dlv"). #context(2,"dlv_asp_context_acc", "kb2.dlv"). #context(3,"dlv_asp_context_acc", "kb3.dlv"). #context(4,"dlv_asp_context_acc", "kb4.dlv"). r1: (3:pneumonia) :- (2:xray_pneumonia). r2: (3:marker) :- (2:blood_marker). r3: (4:need_ab) :- (3:pneumonia). r4: (4:need_strong) :- (3:atyppneumonia). r5: (4:allow_strong_ab) :- not (1:allergy_strong_ab).
[ master.hex kb1.dlv kb2.dlv kb3.dlv kb4.dlv ]
The command line options are:
--ieenable
--ieexplain={D,Dm,E,Em}
--ienoprintopeq
--iebenchmark
--ieuseKR2010rewriting
The MCS-IE system is realized as a plugin to dlvhex, therefore executing MCS-IE is done like executing dlvhex, but with additional command-line arguments.
If you want have checked out, built and "make check"-ed MCS-IE as shown above, you can execute our medical example manually as follows:
$ cd examples/ $ dlvhex --plugindir=../src/ --ieenable medExample/master.hex
This will not return anything, as there are no equilibria and no explanation mode was specified.
The following invocation will output the sets of minimal explanations and minimal diagnoses.
$ dlvhex --plugindir=../src/ medExample/master.hex --ieenable --ieexplain=Dm,Em Em:({r1,r2,r4},{r5}) Dm:EQ:({r1},{}):({allergy_strong_ab},{blood_marker,xray_pneumonia},{}) Dm:EQ:({r2},{}):({allergy_strong_ab},{blood_marker,xray_pneumonia},{pneumonia},{}) Dm:EQ:({r4},{}):({allergy_strong_ab},{blood_marker,xray_pneumonia},{atyppneumonia,pneumonia},{}) Dm:EQ:({},{r5}):({allergy_strong_ab},{blood_marker,xray_pneumonia},{atyppneumonia,pneumonia},{})
If make check
has been executed, the examples' dlvhex plugins have been built,
including Context3.cpp
as shown above.
To test this external plugin, the invocation must specify an additional path where to find plugin libraries. The following invocation should yield the same set of diagnoses and inconsistency explanations as above.
$ dlvhex --plugindir=../src/:./ medExample/master_cppcontext3.hex --ieenable --ieexplain=Dm,Em Em:({r1,r2,r4},{r5}) Dm:EQ:({r1},{}):({allergy_strong_ab},{blood_marker,xray_pneumonia},{}) Dm:EQ:({r2},{}):({allergy_strong_ab},{blood_marker,xray_pneumonia},{pneumonia},{}) Dm:EQ:({r4},{}):({allergy_strong_ab},{blood_marker,xray_pneumonia},{atyppneumonia,pneumonia},{}) Dm:EQ:({},{r5}):({allergy_strong_ab},{blood_marker,xray_pneumonia},{atyppneumonia,pneumonia},{})
Depending on the specified command line options, the output contains lines of the following format:
EQ:(<S1>,<S2>,...)Where
<Si>
is the set of beliefs at the context with index i.EQ:({tweedy_is_penguin},{},{do_nothing})
D:EQ:(<D1>,<D2>):(<S1>,<S2>,...)Where
<D1>
, and <D2>
are the sets of bridge rules
which must be removed, and added unconditionally, to get an equilibrium.D:EQ:({r1},{r3,r5}):({allergy_strong_ab},{blood_marker,xray_pneumonia},{},{})
D:(<D1>,<D2>)
Dm:EQ:(<D1>,<D2>):(<S1>,<S2>,...)
Dm:(<D1>,<D2>)Example:
Dm:({r1},{})
E:(<E1>,<E2>)Where
<E1>
, and <E2>
are the sets of bridge rules
which must be present, and must not be added unconditionally, to get inconsistency.E:({r1,r2,r4},{r1,r2,r3,r4,r5})
Em:(<E1>,<E2>)Example:
Em:({r1,r2,r4},{r5})
All external atoms which can be used for context semantics have the following signature:
#context
input directive.The atom returns true if, using the logic implemented in the atom, the knowledge base (indicated possibly by Param) plus the formulas Heads accepts a belief set such that the intersection of that belief set with beliefs specified by Outputs is equal to the beliefs specified by Beliefs.
The MCS-IE plugin provides one external atom which allows to use DLV programs as contexts. This external atom is used by the example input files above.
The input from bridge rules - Heads - will be appended to the program as facts. For each acceptance check, dlv will be called.
For contexts other than ASP programs, new external atoms can be created using a library provided by MCS-IE.
The way to write such an external atom is shown by the following example C++ source:
#include "ContextInterfaceAtom.h" #include "ContextInterfacePlugin.h" DLVHEX_MCSEQUILIBRIUM_PLUGIN(MedExamplePluginContext3,0,1,0) namespace { DLVHEX_MCSEQUILIBRIUM_CONTEXT(Context3,"ontology_context3_acc") std::set<std::set<std::string> > Context3::acc( const std::string& param, const std::set<std::string>& input) { std::set<std::set<std::string> > ret; // accept all input std::set<std::string> s(input.begin(),input.end()); //s.insert(input.begin(), input.end()); if( input.count("pneumonia") == 1 && input.count("marker") == 1 ) { // additionally accept atyppneumonia s.insert("atyppneumonia"); } ret.insert(s); return ret; } void MedExamplePluginContext3::registerAtoms() { registerAtom<Context3>(); } } // anonymous namespace
This file can be compiled and linked just like a dlvhex plugin,
the result is a dlvhex plugin which provides an external atom
named ontology_context3_acc
that can be used as a context.
In our example above, we can replace kb3.dlv
by the C++ context implementation above.
We do this by changing the third line of the master input file.
The new master file looks as follows:
#context(1,"dlv_asp_context_acc", "kb1.dlv"). #context(2,"dlv_asp_context_acc", "kb2.dlv"). #context(3,"ontology_context3_acc", ""). #context(4,"dlv_asp_context_acc", "kb4.dlv"). r1: (3:pneumonia) :- (2:xray_pneumonia). r2: (3:marker) :- (2:blood_marker). r3: (4:need_ab) :- (3:pneumonia). r4: (4:need_strong) :- (3:atyppneumonia). r5: (4:allow_strong_ab) :- not (1:allergy_strong_ab).
For more examples and testcases, please see the examples/
directory in SVN,
or view the directory online:
dlvhex SVN Browser: dlvhex-mcs/mcs-ie/trunk/examples/ or
dlvhex Trac: dlvhex-mcs/mcs-ie/trunk/examples/.
(The current example is stored in
medExample/.)
A documentation of the two rewriting techniques which are implemented in MCS-IE is available here: MCS-IE: Comparison of HEX Rewritings (PDF manuscript).
These rewritings transform the input into a HEX program which is then evaluated. Each answer set corresponds to a diagnosis and a witnessing equilibrium.
Offenlegung gemäß § 25 Mediengesetz: Inhaber der Website ist die Fakultät für Informatik an der Technischen Universität Wien, 1040 Wien. Die TU Wien distanziert sich von den Inhalten aller extern gelinkten Seiten und übernimmt diesbezüglich keine Haftung. / Disclaimer.