\section{Syntax}
\label{syn}
Description Logics (DLs) are knowledge representation formalisms that are at the basis of the Semantic Web \cite{DBLP:conf/dlog/2003handbook,dlchap} and are used for modelling ontologies.
They are represented using a syntax based on concepts, basically sets of individuals of the domain, and roles, sets of pairs of individuals
of the domain. A more formal description can be found in the Appendix \ref{app:dl}.
TRILL allows the use of two different syntaxes used together or individually:
\begin{itemize}
\item RDF/XML
\item Prolog syntax
\end{itemize}
RDF/XML syntax can be used by exploiting the predicate \verb|owl_rdf/1|. For example:
\begin{small}
\begin{verbatim}
owl_rdf('
]>
').
\end{verbatim}
\end{small}
For a brief introduction on RDF/XML syntax see \textit{RDF/XML syntax and tools} section below (Sec. \ref{rdfxml-syn}).
Note that each single \verb|owl_rdf/1| must be self contained and well formatted, it must start and end with \verb|rdf:RDF| tag and contain all necessary declarations (namespaces, entities, ...).
An example of the combination of both syntaxes is shown the example \href{http://trill-sw.eu/example/trill/johnEmployee.pl}{\texttt{johnEmployee.pl}}. It models that \textit{john} is an \textit{employee} and that employees are \textit{workers}, which are in turn people (modeled by the concept \textit{person}).
\begin{small}
\begin{verbatim}
owl_rdf('
').
subClassOf('employee','worker').
owl_rdf('
').
\end{verbatim}
\end{small}
\subsection{Prolog Syntax}
\label{trill-syn}
\subsubsection{Declarations}
Prolog syntax allows, as in standard OWL, the declaration of classes, properties, etc.
\begin{verbatim}
class("classIRI").
datatype("datatypeIRI").
objectProperty("objectPropertyIRI").
dataProperty("dataPropertyIRI").
annotationProperty("annotationPropertyIRI").
namedIndividual("individualIRI").
\end{verbatim}
However, TRILL properly works also in their absence.
Prolog syntax allows also the declaration of aliases for namespaces by using the \verb|kb_prefix/2| predicate.
\begin{verbatim}
kb_prefix("foo","http://example.foo#").
\end{verbatim}
After this declaration, the prefix \verb|foo| is available, thus, instead of \verb|http://example.foo#john|, one can write \verb|foo:john|.
It is possible to define also an empty prefix as
\begin{verbatim}
kb_prefix("","http://example.foo#").
\end{verbatim}
or as
\begin{verbatim}
kb_prefix([],"http://example.foo#").
\end{verbatim}
In this way \verb|http://example.foo#john| can be written only as \verb|john|.
\textbf{Note:} Only one prefix per alias is allowed. Aliases defined in OWL/RDF part have the precedence, in case more than one prefix was assigned to the same alias, TRILL keeps only the first assignment.
\subsubsection{Axioms}
Axioms are modeled using the following predicates
\begin{verbatim}
subClassOf("subClass","superClass").
equivalentClasses([list,of,classes]).
disjointClasses([list,of,classes]).
disjointUnion([list,of,classes]).
subPropertyOf("subPropertyIRI","superPropertyIRI").
equivalentProperties([list,of,properties,IRI]).
propertyDomain("propertyIRI","domainIRI").
propertyRange("propertyIRI","rangeIRI").
transitiveProperty("propertyIRI").
inverseProperties("propertyIRI","inversePropertyIRI").
symmetricProperty("propertyIRI").
sameIndividual([list,of,individuals]).
differentIndividuals([list,of,individuals]).
classAssertion("classIRI","individualIRI").
propertyAssertion("propertyIRI","subjectIRI","objectIRI").
annotationAssertion("annotationIRI",axiom,literal('value')).
\end{verbatim}
For example, for asserting that \textit{employee} is subclass of \textit{worker} one can use
\begin{verbatim}
subClassOf(employee,worker).
\end{verbatim}
while the assertion \textit{worker} is equal to the intersection of \textit{person} and not \textit{unemployed}
\begin{verbatim}
equivalentClasses([worker,
intersectionOf([person,complementOf(unemployed)])]).
\end{verbatim}
Annotation assertions can be defined, for example, as
\begin{verbatim}
annotationAssertion(foo:myAnnotation,
subClassOf(employee,worker),'myValue').
\end{verbatim}
In particular, an axiom can be annotated with a probability which defines the degree of belief in the truth of the axiom. See Section \ref{semantics} for details.
Below, an example of an probabilistic axiom, following the Prolog syntax.
\begin{verbatim}
annotationAssertion('disponte:probability',
subClassOf(employee,worker),literal('0.6')).
\end{verbatim}
\subsubsection{Concepts descriptions}
Complex concepts can be defined using different operators:
\noindent
Existential and universal quantifiers
\begin{verbatim}
someValuesFrom("propertyIRI","classIRI").
allValuesFrom("propertyIRI","classIRI").
\end{verbatim}
Union and intersection of concepts
\begin{verbatim}
unionOf([list,of,classes]).
intersectionOf([list,of,classes]).
\end{verbatim}
Cardinality descriptions
\begin{verbatim}
exactCardinality(cardinality,"propertyIRI").
exactCardinality(cardinality,"propertyIRI","classIRI").
maxCardinality(cardinality,"propertyIRI").
maxCardinality(cardinality,"propertyIRI","classIRI").
minCardinality(cardinality,"propertyIRI").
minCardinality(cardinality,"propertyIRI","classIRI").
\end{verbatim}
Complement of a concept
\begin{verbatim}
complementOf("classIRI").
\end{verbatim}
Nominal concept
\begin{verbatim}
oneOf([list,of,classes]).
\end{verbatim}
For example, the class \textit{workingman} is the intersection of \textit{worker} with the union of \textit{man} and \textit{woman}. It can be defined as:
\begin{verbatim}
equivalentClasses([workingman,
intersectionOf([worker,unionOf([man,woman])])]).
\end{verbatim}
\subsection{RDF/XML syntax and tools}
\label{rdfxml-syn}
As said before, TRILL is able to automatically translate RDF/XML knowledge bases when passed as a string using
the preticate \verb|owl_rdf/1|.
Consider the following axioms
\begin{verbatim}
classAssertion(Cat,fluffy)
subClassOf(Cat,Pet)
propertyAssertion(hasAnimal,kevin,fluffy)
\end{verbatim}
The first axiom states that \textit{fluffy} is a \textit{Cat}. The second states that every \textit{Cat} is also a \textit{Pet}. The third states that the role \textit{hasAnimal} links together \textit{kevin} and \textit{fluffy}.
RDF (Resource Descritpion Framework) is a standard W3C. See the \href{http://www.w3.org/TR/REC-rdf-syntax/}{syntax specification} for more details.
RDF is a standard XML-based used for representing knowledge by means of triples.
A representations of the three axioms seen above is shown below.
\begin{verbatim}
\end{verbatim}
Annotations are assertable using an extension of RDF/XML. For example the annotated axiom below, defined using the Prolog sintax
\begin{verbatim}
annotationAssertion('disponte:probability',
subClassOf('Cat','Pet'),literal('0.6')).
\end{verbatim}
is modeled using RDF/XML syntax as
\begin{verbatim}
0.6
\end{verbatim}
If you define the annotated axiom in the RDF/XML part, the annotation must be declared in the knowledge base as follow
\begin{verbatim}
]>
...
...
\end{verbatim}
There are many \href{http://www.w3.org/2001/sw/wiki/Category:Editor}{editors} for developing knowledge bases.