Sensemaking AI · Sensemaking Semantic Web
Submodule 2.2 · Modeling

OWL essentials.

Classes, individuals, property characteristics, and restrictions. The five OWL profiles and the traps that look right and behave badly — punning, transitivity cascades, and sameAs collapse.

Module 2 · Weeks 4–6 Requires Protégé + Fuseki ~2.5 hours hands-on OWL · HermiT · restrictions · profiles
Checking for Fuseki at localhost:3030…

RDFS gives you inheritance. OWL gives you shape.

RDFS lets you declare that Ninja is a subclass of Character, and that senseiOf has domain Ninja. A reasoner derives new class memberships from these rules. OWL adds the ability to say not just what kind of thing something is, but what it must have, what it can only be, and what combinations are impossible.

RDFS: "Every Ninja is a Character." OWL restriction: "Every Ninja must belong to at least one Village." These are different kinds of statements. The first is an inheritance rule. The second is a shape constraint — a restriction on what a thing must look like to count as a member of the class. Restrictions are where ontology design judgment actually lives.

The key shift

RDFS is schema as inheritance. OWL is schema as shape. RDFS says what things are related to. OWL says what things must have. The Naruto ontology uses both: RDFS for the class hierarchy (Ninja → Character → schema:Person), OWL for the property characteristics (rivalOf is symmetric), and — once you add them in Exercise 2.3 — OWL restrictions for constraints (a Ninja must have a Village).

Prerequisite

This submodule builds directly on the RDFS concepts from Submodule 2.1. The starter ontology (naruto-ontology-starter.ttl) already has class hierarchy and property declarations. The Protégé walkthrough in this submodule adds OWL restrictions — load the same file first.

The TBox / ABox distinction.

OWL distinguishes two layers of an ontology:

In OWL, named individuals are explicitly declared members of the ABox: naruto:NarutoUzumaki a owl:NamedIndividual (implicit in OWL when you assert any class membership). The distinction matters because OWL reasoning operates on the relationship between TBox rules and ABox facts to derive new ABox facts.

The Unique Name Assumption is not default in OWL

In a relational database, two different IDs are always different things. OWL does not assume this by default. Two different IRIs might refer to the same individual unless you explicitly assert owl:differentFrom or owl:AllDifferent. This is one reason that queries returning "all distinct pairs" must use FILTER conditions — the reasoner might otherwise conclude that two apparently different individuals are the same.

The punning trap

OWL 2 allows "punning" — using the same IRI as both a class and an individual. naruto:Genin in the starter ontology is a skos:Concept (an individual in the ABox). If you also tried to use naruto:Genin as a class (so that Genin ninja would be instances of Genin), the reasoner would have to treat the same IRI as both a class and an individual simultaneously. OWL 2 permits this but it produces confusing inferences. The design decision in the starter ontology — use SKOS for ranks rather than OWL classes — avoids this trap entirely. This is why NinjaRank uses skos:Concept, not owl:Class.

What you declare about a property determines what fires.

OWL properties carry characteristics that tell the reasoner how to behave when it encounters triples using that property.

CharacteristicDeclaresReasoner derivesNaruto example
owl:SymmetricPropertyA P B ↔ B P Athe reverse triplenaruto:rivalOf
owl:TransitivePropertyA P B, B P C → A P Cthe transitive closure(none — see traps section)
owl:FunctionalPropertyA P B, A P C → B = Cidentity of objectsuseful for unique keys
owl:InverseFunctionalPropertyA P C, B P C → A = Bidentity of subjectsuseful for unique identifiers
owl:AsymmetricPropertyA P B → NOT(B P A)a consistency violation if brokennaruto:senseiOf could be asymmetric
owl:inverseOfP inverse Qreverse direction triplesenseiOf / studentOf

In naruto-ontology-starter.ttl, only owl:SymmetricProperty and owl:inverseOf are used. Submodule 2.1 demonstrated both through Protégé. Exercise 2.3 asks you to consider whether any additional characteristics belong in the published ontology.

Shaping what a class member must look like.

OWL restrictions constrain what can belong to a class. A restriction on a class C says: to be a C, an individual must satisfy this constraint on some property. Two fundamental restriction types:

# Existential restriction: every Ninja must be in at least one village
naruto:Ninja rdfs:subClassOf [
    a owl:Restriction ;
    owl:onProperty naruto:memberOfVillage ;
    owl:someValuesFrom naruto:Village
] .

# Cardinality restriction: a Team must have at least one member
naruto:Team rdfs:subClassOf [
    a owl:Restriction ;
    owl:onProperty naruto:memberOfTeam ;
    owl:minCardinality "1"^^xsd:nonNegativeInteger
] .

These restrictions are intentionally not in the starter ontology. The Module 2 README says: "resist adding restrictions until you have data to validate against — every premature restriction is a future bug." Exercise 2.3 is where you add them after working through the data and confirming they hold.

Restrictions under the open-world assumption

An OWL existential restriction does not cause a reasoner to reject Gaara just because he has no memberOfVillage triple — under the open-world assumption, the information is simply missing, not contradicted. SHACL (Submodule 2.3) is the mechanism for closed-world validation that will reject Gaara if village membership is required. OWL restrictions and SHACL serve different purposes: OWL restrictions support inference, SHACL shapes support validation.

Five profiles, four tradeoffs.

OWL Full is the most expressive profile — it allows any RDF graph to also be an OWL ontology. But it is undecidable: no algorithm can always compute all its inferences in finite time. The four tractable profiles each carve out a subset of OWL Full that guarantees decidability, at the cost of expressiveness.

OWL EL

Polynomial-time reasoning. Designed for large biomedical ontologies (SNOMED CT uses it). Supports existential restrictions; no universal restrictions, no cardinality.

OWL QL

Query rewriting; reasoning in LOGSPACE. Optimized for conjunctive query answering over large ABoxes. No existential restrictions in the TBox.

OWL RL

Rule-based reasoning; polynomial-time. Maps well onto rule engines and SQL. Good for data integration when reasoning needs to scale.

OWL DL

Description logic. The "standard" expressive profile. Decidable but EXPTIME-complete in the worst case. What most Protégé tutorials use. HermiT implements OWL DL.

OWL Full

Maximum expressiveness. Includes all of RDFS plus all of OWL. Undecidable. Rarely used in production. Mentioned because it explains why DL exists.

The Naruto ontology is designed to stay within OWL DL. Keeping it out of OWL Full means not mixing metaclass and class usage (punning carefully), not allowing arbitrary SPARQL rules as restrictions, and not creating circular class definitions that defeat termination. HermiT can reason over it.

For production systems at scale, EL is the practical choice — Google's Knowledge Graph and the life sciences industry both use EL-profile ontologies. DL is the right choice for a learning project where you want to see the full range of inference behavior.

Where OWL surprises careful designers.

Add a restriction and watch HermiT fire.

This walkthrough adds one OWL restriction to the starter ontology in Protégé, runs HermiT, and observes what changes. Keep the starter TTL open from Submodule 2.1, or reload it.

Protégé walkthrough — open to expand all steps
1 Confirm the starter ontology is loaded and reasoner is off expand

In Protégé, open naruto-ontology-starter.ttl if not already open. Stop any running reasoner: Reasoner → Stop Reasoner. Working with the reasoner off lets you see the difference clearly when you start it after adding the restriction.

Screenshot: Protégé with the starter ontology loaded. Status bar shows no active reasoner. Classes tab is visible with the naruto: hierarchy.
2 Add an existential restriction to naruto:Ninja expand

In the Classes tab, select naruto:Ninja. In the Description panel on the right, find the SubClass Of section. Click the + (Add superclass) button.

In the expression editor, type: naruto:memberOfVillage some naruto:Village

Press Enter or click OK. The restriction should appear in the SubClass Of list under naruto:Ninja. Protégé renders the Manchester Syntax form: memberOfVillage some Village.

Screenshot: Classes tab, naruto:Ninja selected. Description panel shows SubClass Of section with two items: "naruto:Character" and the new restriction "naruto:memberOfVillage some naruto:Village".
3 Run HermiT and observe consistency expand

Reasoner → HermiT → Start Reasoner. Wait for the status bar to show "Reasoner: Synchronized."

If the ontology is consistent, Protégé shows no error messages. Good — all eight ninja in the starter data do have naruto:memberOfVillage triples, so the restriction is satisfied by the existing data.

Now look at the Individuals tab for naruto:Gaara. Under the inferred property assertions, you should see his village membership. Under asserted assertions, he already has it explicitly. No surprise here — but note that if Gaara were missing his village triple, the reasoner would not reject him; it would assume there exists some village he belongs to (open-world assumption, existential introduction).

Screenshot: Reasoner status bar showing "Synchronized." No red ontology node in the class hierarchy (which would indicate inconsistency).
4 Deliberately introduce an inconsistency expand

Stop the reasoner. In the Individuals tab, select any ninja. Add a property assertion: naruto:memberOfVillage naruto:Jutsu — intentionally using the wrong range type.

Now start HermiT again. The reasoner should flag the ontology as inconsistent — because you declared naruto:memberOfVillage rdfs:range naruto:Village, and naruto:Jutsu is not a Village (and there is no path by which it could become one).

In the Class hierarchy panel, if the ontology is inconsistent, you may see owl:Nothing appearing as a superclass of everything — indicating the reasoner concluded the ontology is unsatisfiable. Undo the change (Edit → Undo) and restart the reasoner to restore consistency.

Screenshot: Classes tab with reasoner active showing an inconsistency. Class hierarchy shows "owl:Nothing" highlighted or an error banner indicating the ontology is inconsistent.
5 Save the extended ontology expand

After undoing the inconsistency: File → Save As. Save as naruto-ontology-restricted.ttl in the same artifacts folder. Do not overwrite the starter file — you will use the starter in its pristine form for Submodule 2.3 comparisons.

Inspect the saved TTL. The restriction should appear as a blank-node-based anonymous class expression, which is the Turtle serialization of an OWL restriction. It is valid but verbose — this is what the OWL "anonymous class" pattern looks like in serialized form.

Screenshot: The saved naruto-ontology-restricted.ttl open in a text editor, showing the anonymous class expression for the memberOfVillage restriction under naruto:Ninja.

Five queries — schema inspection and reasoning patterns.

q01
Which properties have OWL characteristics declared?
Pattern: introspecting OWL property declarations · querying the TBox
Open Fuseki ↗
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl:  <http://www.w3.org/2002/07/owl#>

SELECT ?property ?label ?characteristic WHERE {
  ?property a ?type ; rdfs:label ?label .
  VALUES ?type {
    owl:ObjectProperty
    owl:DatatypeProperty
    owl:AnnotationProperty
  }
  VALUES ?characteristic {
    owl:SymmetricProperty
    owl:TransitiveProperty
    owl:FunctionalProperty
    owl:AsymmetricProperty
    owl:InverseFunctionalProperty
  }
  ?property a ?characteristic .
  FILTER (LANG(?label) = "en" || LANG(?label) = "")
}
ORDER BY ?label
q02
Which ninja are Jonin-rank, and who do they teach?
Pattern: rank as SKOS concept · OPTIONAL for students · class property traversal
Open Fuseki ↗
PREFIX skos:   <http://www.w3.org/2004/02/skos/core#>
PREFIX schema: <https://schema.org/>
PREFIX naruto: <https://sensemaking-ai.com/ns/naruto#>

SELECT ?senseiName ?studentName WHERE {
  ?sensei naruto:hasRank naruto:Jonin ;
          naruto:canonicalName ?senseiName .
  OPTIONAL {
    ?sensei naruto:senseiOf ?student .
    ?student naruto:canonicalName ?studentName .
  }
}
ORDER BY ?senseiName
q03
Which ninja appear in all three arcs?
Pattern: GROUP BY · HAVING COUNT = 3 · arc count as a qualification
Open Fuseki ↗
PREFIX naruto: <https://sensemaking-ai.com/ns/naruto#>

SELECT ?name (COUNT(?arc) AS ?arcCount) WHERE {
  ?ninja naruto:canonicalName   ?name ;
         naruto:appearsInArc    ?arc .
}
GROUP BY ?name
HAVING (COUNT(?arc) = 3)
ORDER BY ?name
q04
CONSTRUCT: materialize the symmetric closure of rivalOf.
Pattern: CONSTRUCT · symmetric inference without a reasoner · explicit materialization
Open Fuseki ↗
PREFIX naruto: <https://sensemaking-ai.com/ns/naruto#>

CONSTRUCT {
  ?a naruto:rivalOf ?b .
  ?b naruto:rivalOf ?a .
}
WHERE {
  ?a naruto:rivalOf ?b .
}
q05
Which jutsu are shared by more than one ninja?
Pattern: GROUP BY on shared property values · HAVING COUNT · the "shared knowledge" query
Open Fuseki ↗
PREFIX schema: <https://schema.org/>
PREFIX naruto: <https://sensemaking-ai.com/ns/naruto#>

SELECT ?jutsuName (COUNT(?ninja) AS ?ninjaCount)
       (GROUP_CONCAT(?name; separator=", ") AS ?ninjaNames)
WHERE {
  ?ninja naruto:hasJutsu   ?jutsu ;
         naruto:canonicalName ?name .
  ?jutsu schema:name ?jutsuName .
  FILTER (LANG(?jutsuName) = "en")
}
GROUP BY ?jutsuName
HAVING (COUNT(?ninja) > 1)
ORDER BY DESC(?ninjaCount)

Reading and next steps.

Primary reading

Allemang et al. — Ch 7–8

Chapter 7 introduces OWL DL; Chapter 8 covers modeling patterns including n-ary relations and time-indexed situations. Read before Exercise 2.3.

Specification

W3C OWL 2 Primer

The most readable entry point to OWL 2. Section 4 (property characteristics) and Section 5 (restrictions) are the most relevant for this submodule.

Profiles deep-dive

W3C OWL 2 Profiles

Formal definitions of EL, QL, RL, and DL. The introductory section is enough; the formal grammar is reference material.

Starter data

naruto-ontology-starter.ttl

The base file for Protégé walkthroughs in 2.1 and 2.2. Exercise 2.3 extends this into the 1.0.0 release with restrictions, SHACL shapes, and a populated example dataset.

Next submodule

Submodule 2.3 — Ontology design

Design methodology, SHACL for closed-world validation, and REUSE.md practice. The primary project — naruto-ontology-1.0.0.ttl — is Exercise 2.3.

Prior submodule

Submodule 2.1 — RDFS

If the TBox / ABox distinction or the property characteristics are unclear, this submodule covers the RDFS foundations that OWL builds on.