Table of Contents

Basic operation

TRILL is about running a query against a knowledge base. It can handle SHOQ knowledge bases writtend in RDF/XML format or using a OWL Functional Syntax like format.

TRILL is a tableau reasoner written in Prolog, the queries available are listed in TRILL manual section. The query goes into the bottom-right editor and the program into the left editor.

A query can be executed by hitting RETURN if the query is complete and the caret is behind the '.' that terminates the query or by using the Run! button. At this moment, the following happens:

  1. The interface creates a runner in the top-right window that controls the execution of the query.
  2. The runner collects the text from the top-left editor (if any) and the query and sends this to the server, which creates a Pengine (Prolog Engine).
  3. The Pengine compiles the program into a temporary private module.
  4. The Pengine assesses whether executing the query can compromise the server. If this fails, an error is displated. See the help topic Caveats ... for details.
  5. If the query is considered safe, it executes the query and communicates with the runner about the results using JSON messages. The runner interaction is described in the help topic Runner ...

Note that you do not have to save your program to execute it. If your are not satisfied with the answer to a query, you can simply edit the program and use Run! again. The new query is executed in a completely new environment. In particular, data that you asserted in a previous query is not available in the next.

Use Ctrl-Enter to insert a newline in a complete query

Embedding examples in the program text

If you include example goals inside comments as shown below, they will be used to populate the example menu and make the first goal show in the Goal input field.

/** <examples>

?- instanceOf("http://my.ontology.org/ontologies/foo#myClass","http://my.ontology.org/ontologies/foo#myIndividual",ListExpl).

*/

The examples blocks can be defined also in RDF/XML part surrounded by XML standard comment.

<!--
/** <examples>

?- instanceOf("http://my.ontology.org/ontologies/foo#myClass","http://my.ontology.org/ontologies/foo#myIndividual",ListExpl).

*/
-->

If a complex string containing special characters (s.a. #), surround it with single or double quote, also escaped if needed (\'). See TRILL manual section for a list of possible queries.

Save or share your program

The menu File/Save ... can be used to save your program. There are several options:

The Info & History ... menu can be used to examine and use old versions of the program.

Using File/Collaborate ..., you create a TogetherJS session that provides shared editing, chat and voice communication.

Preload TRILL on SWISH with data

You can make TRILL on SWISH start with a loaded program using the URL http://trill.lamping.unife.it/swish/ and providing the parameters below. The URL accepts both `GET` and `POST` requests.

code
The value can be either the KB or a URL from which the KB is available and downloadable.
q
The query to set in the query pane.

The URL below opens TRILL on SWISH on a file from GitHub with a default query.

http://my.url/trill_on_swish/?code=https://github.com/friguzzi/trill-on-swish/raw/master/examples/BRCA.owl

Download query results as CSV

After running a query, the complete result set for the query can be downloaded as a CSV (Comma Separated Values) document by clicking the button at the top-right of a runner window or using the Download answers as CSV option from the button on notebook query cells. This causes a dialogue to appear that allows for specifying the columns, optionally the detailed result format (if the server provides multiple result formats), whether only distinct results should be returned and the maximum number of results to return. The latter is by default set to 10 000 to avoid sending huge documents by accident. The field can be cleared to return all results.

TRILL manual

TRILL ("Tableau Reasoner for descrIption Logics in Prolog") implements a tableau algorithm in Prolog to compute the set of all the explanations of a query. After generating the explanations, TRILL can computes the probability of the query. The management of the tableau rules' non-determinism is delegated to the Prolog language.

TRILL can compute the probability of queries using the commands shown below:

prob_instanceOf(Class,Individual,Prob)
Concept membership queries.
prob_sub_class(Class1,Class2,Prob)
Subsumption queries.
prob_unsat(ClassExpression,Prob)
Unsatifiability of a concept.
prob_inconsistent_theory(Prob)
Inconsistency of the knowledge base.
TRILL can test entailment or find an explanation Expl using the queries below:
instanceOf(Class,Individual), instanceOf(Class,Individual,Expl)
Concept membership queries.
sub_class(Class1,Class2), sub_class(Class1,Class2,Expl)
Subsumption queries.
unsat(ClassExpression), unsat(ClassExpression,Expl)
Unsatifiability of a concept.
inconsistent_theory, inconsistent_theory(Expl)
Inconsistency of the knowledge base.

Writing knowledge bases

A knowledge base consists of a set of possibly annotated axioms. An axiom is a proposition that models an information of the domain. There are several different axioms:

Concept membership axioms
An individual belongs to a certain class.
Role membership axioms
Two individuals are connected through a certain role.
Transitivity axioms
The role is transitive.
Role inclusion axioms
Hierarchy between roles.
Concept inclusion axioms
Hierarchy between concepts.

Regarding the definition of knowledge bases, TRILL allows the use of two different syntaxes used together or individually:

RDF/XML syntax can be used by exploiting the predicate owl_rdf/1. For example:
owl_rdf('
<?xml version="1.0"?>

<!DOCTYPE rdf:RDF [
    <!ENTITY owl "http://www.w3.org/2002/07/owl#" >
    <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
    <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
    <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
]>

<rdf:RDF xmlns="http://here.the.IRI.of.your.ontology#"
     xml:base="http://here.the.IRI.of.your.ontology"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:owl="http://www.w3.org/2002/07/owl#"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
    <owl:Ontology rdf:about="http://here.the.IRI.of.your.ontology"/>

    <!-- 
    Axioms
    -->

</rdf:RDF>
').
For a brief introduction on RDF/XML syntax see RDF/XML syntax and tools section below.

Note that each single owl_rdf/1 must be self contained and well formatted, it must start and end with rdf:RDF tag and contain all necessary declarations (namespaces, entities, ...).

An example of the combination of both syntaxes is shown below. It models that john is an employee and that employees are workers, which are in turn people (modeled by the concept person).

owl_rdf('<?xml version="1.0"?>
<rdf:RDF xmlns="http://example.foo#"
     xml:base="http://example.foo"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:owl="http://www.w3.org/2002/07/owl#"
     xmlns:xml="http://www.w3.org/XML/1998/namespace"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
    <owl:Ontology rdf:about="http://example.foo"/>

    <!-- Classes -->
    <owl:Class rdf:about="http://example.foo#worker">
        <rdfs:subClassOf rdf:resource="http://example.foo#person"/>
    </owl:Class>

</rdf:RDF>').

subClassOf('employee','worker').

owl_rdf('<?xml version="1.0"?>
<rdf:RDF xmlns="http://example.foo#"
     xml:base="http://example.foo"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:owl="http://www.w3.org/2002/07/owl#"
     xmlns:xml="http://www.w3.org/XML/1998/namespace"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
    <owl:Ontology rdf:about="http://example.foo"/>
    
    <!-- Individuals -->
    <owl:NamedIndividual rdf:about="http://example.foo#john">
        <rdf:type rdf:resource="http://example.foo#employee"/>
    </owl:NamedIndividual>
</rdf:RDF>').

TRILL Syntax

Declarations

TRILL syntax allows, as in standard OWL, the declaration of classes, properties, etc.

class("classIRI").
datatype("datatypeIRI").
objectProperty("objectPropertyIRI").
dataProperty("dataPropertyIRI").
annotationProperty("annotationPropertyIRI").
namedIndividual("individualIRI").
However, TRILL properly works also in their absence.

TRILL syntax allows also the declaration of aliases for namespaces by using the kb_prefix/2 predicate.
kb_prefix("foo","http://example.foo#").
After this declaration, the prefix foo is available, thus, instead of http://example.foo#john, one can write foo:john. It is possible to define also an empty prefix as
kb_prefix("","http://example.foo#").
or as
kb_prefix([],"http://example.foo#").
In this way http://example.foo#john can be written only as john.

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.

Axioms

Axioms are modeled using the following predicates

subClassOf("subClass","superClass").
equivalentClasses([list,of,classes]).
disjointClasses([list,of,classes]).
disjointUnion([list,of,classes]).

subPropertyOf("subProperty","superProperty").
equivalentProperties([list,of,properties]).
propertyDomain("propertyIRI","domainIRI").
propertyRange("propertyIRI","rangeIRI").
transitiveProperty("propertyIRI").

sameIndividual([list,of,individuals]).
differentIndividuals([list,of,individuals]).

classAssertion("classIRI","individualIRI").
propertyAssertion("propertyIRI","subjectIRI","objectIRI").
annotationAssertion("annotationIRI",axiom,literal('value')).
For example, for asserting that employee is subclass of worker one can use
subClassOf(employee,worker).
while the assertion worker is equal to workingman can be defined as
equivalentClasses([worker,workingman]).

Annotation assertions can be defined, for example, as

annotationAssertion(foo:myAnnotation,subClassOf(employee,worker),'myValue').

In particular, an axiom can be annotated with a probability which defines the degree of belief in the truth of the axiom. See [1] for details.

Below, an example of an probabilistic axiom, following the TRILL syntax.

annotationAssertion('disponte:probability',subClassOf(employee,worker),literal('0.6')).

Concepts descriptions

Complex concepts can be defined using different operators.

Existential and universal quantifiers
someValuesFrom("propertyIRI","classIRI").
allValuesFrom("propertyIRI","classIRI").
Union and intersection of concepts
unionOf([list,of,classes]).
intersectionOf([list,of,classes]).
Cardinality descriptions
exactCardinality(cardinality,"propertyIRI").
exactCardinality(cardinality,"propertyIRI","classIRI").
maxCardinality(cardinality,"propertyIRI").
maxCardinality(cardinality,"propertyIRI","classIRI").
minCardinality(cardinality,"propertyIRI").
minCardinality(cardinality,"propertyIRI","classIRI").
Complement of a concept
complementOf("classIRI").
Nominal concept
oneOf([list,of,classes]).
For example, the class workingman is the intersection of worker with the union of man and woman. It can be defined as:
equivalentClasses([workingman,intersectionOf([worker,unionOf([man,woman])])]).

RDF/XML syntax and tools

As said before, TRILL is able to automatically translate RDF/XML knowledge bases when passed as a string using the preticate owl_rdf/1.

Consider the following axioms

classAssertion(Cat,fluffy)
subClassOf(Cat,Pet)
propertyAssertion(hasAnimal,kevin,fluffy)

The first axiom states that fluffy is a Cat. The second states that every Cat is also a Pet. The third states that the role hasAnimal links together kevin and fluffy.

RDF (Resource Descritpion Framework) is a standard W3C. See here the syntax specification. 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.

<owl:NamedIndividual rdf:about="fluffy">
  <rdf:type rdf:resource="Cat"/>
</owl:NamedIndividual>

<owl:Class rdf:about="Cat">
  <rdfs:subClassOf rdf:resource="Pet"/>
</owl:Class>

<owl:ObjectProperty rdf:about="hasAnimal"/>
<owl:NamedIndividual rdf:about="kevin">
 <hasAnimal rdf:resource="fluffy"/>
</owl:NamedIndividual>

Annotations are assertable using an extension of RDF/XML. For example the annotated axiom below, defined using the TRILL sintax

annotationAssertion('disponte:probability',subClassOf('Cat','Pet'),literal('0.6')).
is modeled using RDF/XML syntax as
<owl:Class rdf:about="Cat">
 <rdfs:subClassOf rdf:resource="Pet"/>
</owl:Class>
<owl:Axiom>
 <disponte:probability rdf:datatype="&xsd;decimal">0.6</disponte:probability>
 <owl:annotatedSource rdf:resource="Cat"/>
 <owl:annotatedTarget rdf:resource="Pet"/>
 <owl:annotatedProperty rdf:resource="&rdfs;subClassOf"/>
</owl:Axiom>
If you define the annotated axiom in the RDF/XML part, the annotation must be declared in the knowledge base as follow
<!DOCTYPE rdf:RDF [
 ...
 <!ENTITY disponte "https://sites.google.com/a/unife.it/ml/disponte#" >
]>

<rdf:RDF
 ...
 xmlns:disponte="https://sites.google.com/a/unife.it/ml/disponte#"
 ...>

 ...
 <owl:AnnotationProperty rdf:about="&disponte;probability"/>
 ...
</rdf:RDF>

There are many editors for developing knowledge bases, some of them are listed here.

[1] Zese, R.: Reasoning with Probabilistic Logics. ArXiv e-prints 1405.0915v3. An extended abstract / full version of a paper accepted to be presented at the Doctoral Consortium of the 30th International Conference on Logic Programming (ICLP 2014), July 19-22, Vienna, Austria.