\( C \sqsubseteq D \) holds when \( C^\mathcal{I} \subseteq D^\mathcal{I} \). A model satisfies every axiom. An axiom is entailed when it holds in every model.
An entailment, by hand
In every model of the studio:
\( \mathit{contains}(\mathit{kitchen\_corner}, \mathit{sink}) \) and \( \mathit{sink} : \mathit{KitchenSink} \), so the corner is in \( \exists \mathit{contains}.\mathit{KitchenSink} \)
It is also in \( \mathit{Room} \), so it is in the intersection
The TBox puts the intersection inside \( \mathit{Kitchen} \)
The ontology entails \( \mathit{kitchen\_corner} : \mathit{Kitchen} \). Nobody asserted it.
Four tasks, one reasoner
For an ontology \( \mathcal{O} \) and a fresh individual \( b \):
Task
Question
Reduces to
Consistency
Does \( \mathcal{O} \) have any model?
the base case
Instance checking
Is \( a : C \) entailed?
\( \mathcal{O} \cup \{ a : \neg C \} \) is inconsistent
Subsumption
Is \( C \sqsubseteq D \) entailed?
\( \mathcal{O} \cup \{ b : C \sqcap \neg D \} \) is inconsistent
Concept satisfiability
Does some model give \( C \) a member?
\( \mathcal{O} \cup \{ b : C \} \) is consistent
A reasoner that decides consistency decides all four.
An open world
A model may contain anything the axioms do not rule out
Is the sleeping corner a kitchen? The studio does not entail it.
It does not entail the opposite either. Some models give the sleeping corner a kitchen sink nobody recorded.
The answer is unknown. The absence of a fact is not its negation.
The reasoner cannot answer no
ASK { :sleeping_corner a isfr:Kitchen }
On the closure, the answer is false. Here false means not entailed.
The reasoner cannot conclude that the sleeping corner is not a kitchen. Nothing in the studio entails it.
A SELECT reports an unknown as no row
No unique names
Two IRIs may denote one thing unless the ontology says otherwise. isfr:inRoom is functional, so a place is in at most one room.
\( \mathit{Room} \sqcap \exists \mathit{contains}.\mathit{KitchenSink} \sqsubseteq \mathit{Kitchen} \), with a blank node for each unnamed concept.
isfr:contains is a property chain,
\( \mathit{inRoom}^- \circ \mathit{objectAt}^- \sqsubseteq \mathit{contains} \).
A room contains whatever is at one of its places.
The price of OWL 2 DL as a whole
Consistency, class satisfiability, subsumption and instance checking are N2EXPTIME-complete
Decidable, with no useful bound on how long an answer takes
The profiles restrict the language until reasoning takes polynomial time.
OWL 2 Profiles (W3C, 2012), section 5.
Three profiles
Profile
Built for
OWL 2 EL
Ontologies with very large numbers of classes and properties
OWL 2 QL
Very large volumes of instance data, with queries rewritten to run on a relational database
OWL 2 RL
Scalable reasoning that rule-based engines can implement. This course uses it.
In each, ontology consistency, and instance checking against a named class, take polynomial time.
In OWL 2 DL, every beer bottle holds some beer. That beer has no name.
RL is designed to avoid inferring the existence of individuals not explicitly present.
OWL 2 Profiles, sections 4.1 and 4.2.3.
What owlrl did with it
Given this axiom and one beer bottle, owlrl produced no holds triple at all
So the base ontology has no relation from a container to its content
A drink is one individual with two types, its container class and its content class
:beer1 a isfr:Bottle, :Beer .
owlrl reports an inconsistency as data
A Python implementation of the RL rules over an rdflib graph
An inconsistency becomes triples of type err:ErrorMessage in the closure
Add a disjointness to the studio with the lamp from slide 17:
isfr:Room owl:disjointWith isfr:Place .
"Disjoint classes …#Room and …#Place have a common individual …#kitchen_corner"
If your code does not look for those triples, an inconsistent graph looks like any other.
How long a closure takes
Graph
Size
Closure time
A toy graph
41 triples, closed to 212
35 ms
The base ontology alone
104 asserted, 355 inferred
about 0.05 s
The studio example
131 asserted, 423 inferred
0.087 s
The micro-project's reference apartment
649 inferred
about 0.15 s
Measured 2026-10-04 on the instructor's laptop, Apple M4 Max, rdflib 7.6.0, owlrl 7.6.2.
When RL is enough for a robot
This week's ontology uses subclasses, domains and ranges, inverse properties, a property chain, a functional property and an existential on the subclass side. RL has all of them, and disjointness too, as slide 39 showed.
RL never invents an individual. A robot can only fetch a thing it can name.
A closure of about 0.15 s can be recomputed whenever the graph changes
SPARQL
A basic graph pattern
SELECT ?thing WHERE {
?room a isfr:Kitchen ; isfr:contains ?thing .
?thing a :Fruit .
}
A set of triple patterns. Any position may be a variable, written with a leading ?
A solution binds each variable so that every pattern becomes a triple in the graph
Turtle's semicolon works inside a pattern
Before and after reasoning
asserted: 131 triples
closure: 423 triples inferred in 0.087 s
Which rooms are kitchens?
before reasoning: 0 rows; after: 1 rows
+ studio kitchen
Which things are fruit?
before reasoning: 0 rows; after: 2 rows
+ an apple
+ an orange
Which fruit is in a kitchen?
before reasoning: 0 rows; after: 1 rows
+ an orange
Query the closure for answers, and the asserted graph to see what was written.
OPTIONAL keeps a solution when part of the pattern does not match, and leaves that part's variables unbound.
Every object at a place comes back. The orange and the apple have a label. The sink and the bed have none.
FILTER NOT EXISTS
Which room holds no citrus?
SELECT ?room WHERE {
?room a isfr:Room .
FILTER NOT EXISTS { ?room isfr:contains ?fruit . ?fruit a :Citrus . }
}
On the closure, the sleeping corner
On the asserted graph, both rooms
Ask a negative question of the closure, never of the asserted graph.
Negation as failure
NOT EXISTS reads a fact nobody recorded as false
Its answer depends on what was written down
The reasoner works in the open world and concludes nothing from absence
SELECT ?room WHERE { ?room a isfr:Room . FILTER NOT EXISTS { ?room a isfr:Kitchen } }
On the closure, this returns the sleeping corner. The reasoner could not say that on slide 28.
Poole & Mackworth, section 15.9; SPARQL 1.1 Query, section 8.1.1.
Where it misleads
The studio's graph has one person, Sam. Kim and Lee join it. Lee is allergic to citrus, and nothing about allergies is recorded for Sam or Kim.
:sam a isfr:Person .
:kim a isfr:Person .
:lee a isfr:Person ; :allergicTo :Citrus .
SELECT ?person WHERE {
?person a isfr:Person .
FILTER NOT EXISTS { ?person :allergicTo ?anything . }
}
This returns Sam and Kim. Perhaps Sam was asked and has no allergies. Nobody asked Kim.
The right question of the right graph
Ask every question of the closure
Use NOT EXISTS only where a fact nobody recorded can safely count as false
If not asked and asked with no answer differ, record the difference as a fact of its own, and query that
A person with no recorded preference raises the same question. Question 6 of the micro-project asks what it means for the robot.
Modelling the apartment
Competency questions
Write the questions first, in plain language. They are the specification.
Each names the terms the ontology needs and the conclusions it has to support
Once the ontology exists, each becomes a query, and the queries are its tests
The three questions on slide 2 are competency questions. The micro-project gives you six.
Grüninger & Fox (1995), IJCAI-95 Workshop on Basic Ontological Issues in Knowledge Sharing.
Class or individual?
A class is a kind that many things share, and that you will ask about as a kind, such as fridges, rooms or places
An individual is one particular thing. For this robot it is usually something it could drive to or pick up, such as this fridge or the orange on the counter.
When in doubt, ask whether the term could have two members. If it could, it is a class.
A class as a value
Sam prefers citrus, and does not prefer one particular orange.
:sam a isfr:Person ; rdfs:label "Sam" ; isfr:prefers :Citrus .
:Citrus is a class with :Orange beneath it, used here as an individual
OWL 2 admits this. The OWL 2 Primer, section 9, calls it punning.
The two uses are separate in the semantics. In the closure, Sam prefers :Citrus and nothing else.
Extend the base ontology with a drink taxonomy, room types for bathrooms and bedrooms, the nine rooms, furniture, seven drinks and five people
Answer six competency questions with SPARQL, on what you wrote and on the closure
Assert every room as an isfr:Room and nothing more
In exercises/04-ontologies/. answer.py runs every query twice. No Webots.
The household
Ana prefers water.
Ben prefers beer.
Chloé prefers non-alcoholic drinks and avoids fizzy ones.
Eve prefers wine. The apartment holds wine glasses and no wine.
Dev is a guest who has stated nothing.
Seven drinks: three bottles of beer and a can of cola in living_room_1, a bottle of water in the kitchen, and a carafe of water and a carafe of orange juice in living_room_2.
Six questions
Which rooms are kitchens, bathrooms and bedrooms?
Where is each drink, by place and room?
Which alcoholic drinks are in the apartment?
What could the robot bring Chloé?
Who has no preferred drink anywhere in the apartment?
What could the robot bring Dev?
Question 6 has two readings, the drinks Dev prefers and the drinks Dev does not avoid. Two sentences say which the robot should act on.
Next week
The same graph gains places with anchors, a doorway as a gap in the lidar scan or an object the detector names
Edges between places carry coarse relative poses, and a route is a search over them
Before then, read the Description Logic Primer, sections 1, 2.1, 2.2 and 4, and run the example.