Skip to content

hexhex/mcsieplugin

Repository files navigation

dlvhex - mcsequilibrium plugin (0.0.1)
    
    enables dlvhex to calculate Equilibrium-semantics of Multi Context Systems.
    This Plugin provide an Interface to implement arbitrary contexts, as well
    there is a implementation to use ASP-Programs as contexts.
    
* Requirements:
    
    - dlvhex (version >= 1.7)
    
* Installation:

    - ./bootstrap.sh    
    - ./configure
      (use switch --enable-userinstall to install plugin into home directory)
    - make install
    
* Testing:
    
    - make check
    
* Usage:

    - Input file for Multi Context System description:

        Bridgerules are of the form

            (1:a) :- (2:bcd), (3:e), not (1:b).

        where the number is the ID of the Context, that is defined also in
        the Input file.

        Facts can be of the form

            (1:a).

        or

            (1:a) :- .

        Context descriptions are of the form

            #context(<num>,"<extatom>","<param>").

        e. g. for ASP contexts

            #context(2,"dlv_asp_context_acc","ctx.dlv").

        -> uses dlv and program "ctx.dlv" to implement context 2's semantics.

        e. g. for User-implemented contexts

            #context(3,"user_named_context_acc","parameter").

        -> uses the User-implemented ContextInterfaceAtom user_named_context_acc
           to implement context 3's semantics.

    - Implement a Context:

        to use a self implemented context, you have to include 2 Interface-header

            #include <ContextInterfaceAtom.h>
            #include <ContextInterfacePlugin.h>

        Then name your Plugin, by using the defined preprocessor directive

            DLVHEX_MCSEQUILIBRIUM_PLUGIN(YourPluginClassName,0,1,0)

        where the 3 numbers are the major, minor and micro number of 
        your Plugin version.

        After that, it's recommended to write the following in a
        anonym namespace.

        Now you have to define your Context and Implement the
        accept function. Here you also use a defined preprocessor
        directive

            DLVHEX_MCSEQUILIBRIUM_CONTEXT(YourContextClassName,"user_named_context_acc")

        Where YourContextClassName is the Class name of the Context and
        user_named_context_acc is tha name of the External Atom that is
        used in the Input file. 

        then implement the acc function

            std::set<std::set<std::string> >
            YourContextClassName::acc(const std::string& param, 
                                      const std::set<std::string>& input) {
            ...
            }

        this function should return the accepted set of beliefsets.

        You can define and implement in your Plugin as much Contexts
        as you like. They only have to have a unique Classname and
        different names for the External Atom.

	After that you defined your Contexts, you have to register them
        to your Plugin. For that you have to implement the function

           registerAtoms()

        of your defined Plugin. That looks like

           void YourPluginClassName::registerAtoms() {
             registerAtom<YourContextClassName>();
             ...
           }

	where calling for every defined Context the 
        registerAtom<BaseContext>().

	when running dlvhex with the Plugin loaded and a
	MCS-description as Input file, you get Equilibria of the form

           ({a,b},{},{c})

        There is for every Context a set of beliefs that are in equilibrium.