
                 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                 %         CASE 2: XDIG         %
                 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\section{Case study --- XDIG}
\label{sec:xdig}

% Briefly introduce DIG and DL
% Briefly describe `XDIG: rewriting DIG proxy'
% Show some rules from PION and/or MORE

In \secref{serql} we have discussed the case study how SWI-Prolog is
used for a RDF query system, i.e., a meta-data management and reasoning
system. In this section we describe a Prolog-powered system for ontology
management and reasoning based on Description Logics (DL). DL has
greatly influenced the design of the W3C ontology language OWL. The DL
community, called DIG (DL Implementation Group) have developed a
standard for accessing DL reasoning engines called the DIG description
logic interface\fnurl{http://dl.kr.org/dig/} \cite{dig}, DIG interface
for short. Many DL reasoners like Racer \cite{racer} and FACT
\cite{fact} support the DIG interface, allowing for the construction of
highly portable and reusable DL components or extensions.

In this case study, we describe XDIG, an eXtended DIG Description Logic
interface, which has been implemented on top of the SWI-Prolog Web
libraries. The DIG interface uses an XML-based messaging protocol on top
of HTTP. Clients of a DL reasoner communicate by means of HTTP POST
requests. The body of the request is an XML encoded message which
corresponds to the DL concept language. Where OWL is based on the triple
model described in \secref{rdfdoc}, DIG statements are grounded
directly in XML. \Figref{madcowstatement} shows a DIG statement which
defines the concept \emph{MadCow} as a cow which eats brains, part of
sheep.

\begin{figure}
\figrule
\begin{verbatim}
<equalc>
  <catom name='mad+cow'/>
  <and>
    <catom name='cow'/>
    <some>
      <ratom name='eats'/>
      <and>
        <catom name='brain'/>
        <some>
          <ratom name='part+of'/>
          <catom name='sheep'/>
</some></and></some></and></equalc>
\end{verbatim}
   \caption{a DIG statement on MadCow}
   \label{fig:madcowstatement}
\figrule
\end{figure}


\subsection{Architecture of XDIG}

The XDIG libraries form a framework to build DL reasoners that have
additional reasoning capabilities. XDIG serves as a regular DL reasoner
via its corresponding DIG interface. An intermediate XDIG server can
make systems independent from application specific characteristics. A
highly decoupled infrastructure significantly improves the reusability
and applicability of software components.

\begin{figure}
\centering
\includegraphics[width=0.8\textwidth]{xdig}
\caption{Architecture of XDIG}
\label{fig:xdig}
\end{figure}

The general architecture of XDIG is shown in \figref{xdig}. It consists
of the following components:

\begin{description}
  \item [XDIG Server]
The XDIG server deals with requests from ontology applications. It
supports our extended DIG interface, i.e., it not only supports standard
DIG/DL requests, like 'tell' and 'ask', but also additional processing
features like changing system settings. The library \file{dig_server.pl}
implements the XDIG protocol on top of the Prolog HTTP server described
in \secref{httpd}. The predicate \term{dig_server}{+Request} is called
from the HTTP server to process a client's \arg{Request} as illustrated
in \figref{httpreply}. XDIG server developers have to define the
predicate \term{my_dig_server_processing}{+Data, -Answer, +Options},
where \arg{Data} is the parsed DIG XML requests and \arg{Answer} is term
\term{answer}{-Header, -Reply}. \arg{Reply} is the XML-DOM term
representing the answer to the query.

  \item [DIG Client]
XDIG is designed to rely on an external DL reasoner. It implements a
regular DIG interface client and calls the external DL reasoner to
access the standard DL reasoning capabilities. The predicate
\term{dig_post}{+Data, -Reply, +Options} posts the data to the external
DIG server. The predicates are defined in terms of the predicate
\predref{http_post}{4} and others in the HTTP and XML libraries.

\item [Main Control Component]
The library \file{dig_process.pl} provides facilities to analyse DIG
statements such as finding concepts, individuals and roles, but also
decide of \jargon{satisfiability} of concepts and consistency. Some of
this processing is done by analysing the XML-DOM representation of DIG
statements in the local repository, while satisfiability and consistency
checking is achieved by accessing external DL reasoners through the
DIG client module. 

\item [Ontology Repository]
The Ontology Repository serves as an internal knowledge base (KB), which
is used to store multiple ontologies locally. These ontology statements
are used for further processing when the reasoner receives an `ask'
request. The main control component usually selects parts from the
ontologies to post them to an external DL reasoner and obtain the
corresponding answers. This internal KB is also used to store system
settings.
\end{description}

As DIG statements are XML based, XDIG stores statements in the local
repository using the XML-DOM representation described in
\secref{markupdom}. The tree model of XDIG data has been proved to be
convenient for DIG data management.

\Figref{pioncode} shows a piece of code from the library XDIG
defining the predicate \term{direct_concept_relevant}{+DOM, ?Concept}
which checks if a set of \arg{Statements} is directly relevant to a
\arg{Concept}, namely the \arg{Concept} appears in the body of a
statement in the list. The predicate
\predref{direct_concept_relevant}{2} has been used to develop PION for
reasoning with inconsistent ontologies, and DION for inconsistent
ontology debugging.

\begin{figure}
\figrule
\begin{verbatim}
direct_concept_relevant(element(catom, Atts, _), Concept) :-
    memberchk(name=Concept, Atts).
direct_concept_relevant(element(_, _, Content),  Concept) :-
    direct_concept_relevant(Content, Concept).
direct_concept_relevant([H|T], Concept) :-
    (   direct_concept_relevant(H, Concept)
    ;   direct_concept_relevant(T, Concept)
    ).
\end{verbatim}
    \caption{direct_concept_relevant checks that
    a concept is referenced by a DIG statement}
    \label{fig:pioncode}
    \figrule
\end{figure}

\subsection{Application}

XDIG has been used to develop several DL reasoning services. PION is a
reasoning system that deals with inconsistent
ontologies\fnurl{http://wasp.cs.vu.nl/sekt/pion}
\cite{hu2004,huangijcai05}. MORE is a multi-version ontology
reasoner\fnurl{http://wasp.cs.vu.nl/sekt/more} \cite{huang-iswc05}. DION
is a debugger of inconsistent
ontologies\fnurl{http://wasp.cs.vu.nl/sekt/dion}\cite{sekt361}. With the
support of an external DL reasoner like Racer, DION can serve as an
inconsistent ontology debugger using a bottom-up approach.
                
