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.
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.
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.
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).
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.
OWL distinguishes two layers of an ontology:
naruto:Ninja rdfs:subClassOf naruto:Character is a TBox statement.naruto:NarutoUzumaki a naruto:Ninja is an ABox statement.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.
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.
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.
OWL properties carry characteristics that tell the reasoner how to behave when it encounters triples using that property.
| Characteristic | Declares | Reasoner derives | Naruto example |
|---|---|---|---|
owl:SymmetricProperty | A P B ↔ B P A | the reverse triple | naruto:rivalOf |
owl:TransitiveProperty | A P B, B P C → A P C | the transitive closure | (none — see traps section) |
owl:FunctionalProperty | A P B, A P C → B = C | identity of objects | useful for unique keys |
owl:InverseFunctionalProperty | A P C, B P C → A = B | identity of subjects | useful for unique identifiers |
owl:AsymmetricProperty | A P B → NOT(B P A) | a consistency violation if broken | naruto:senseiOf could be asymmetric |
owl:inverseOf | P inverse Q | reverse direction triple | senseiOf / 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.
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:
owl:someValuesFrom — existential restriction: "at least one value of this property must be of this type." A Ninja must have at least one memberOfVillage value that is a Village.owl:allValuesFrom — universal restriction: "every value of this property must be of this type." If a Ninja has any hasJutsu value, it must be a Jutsu. (Note: this does not require having any jutsu — it just constrains what jutsu values are permitted.)# 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.
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.
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.
Polynomial-time reasoning. Designed for large biomedical ontologies (SNOMED CT uses it). Supports existential restrictions; no universal restrictions, no cardinality.
Query rewriting; reasoning in LOGSPACE. Optimized for conjunctive query answering over large ABoxes. No existential restrictions in the TBox.
Rule-based reasoning; polynomial-time. Maps well onto rule engines and SQL. Good for data integration when reasoning needs to scale.
Description logic. The "standard" expressive profile. Decidable but EXPTIME-complete in the worst case. What most Protégé tutorials use. HermiT implements OWL DL.
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.
naruto:familyOf even though family relationships are conceptually transitive, because the reasoning cost outweighs the benefit. Before declaring transitivity, ask: what does the full transitive closure of this property look like, and how large could it get?
owl:sameAs collapse. owl:sameAs asserts that two IRIs refer to the same individual — and a reasoner merges all their properties. If you assert naruto:NarutoUzumaki owl:sameAs wikidata:Q25362, every triple about the Wikidata item transfers to your Naruto individual and vice versa. This includes Wikidata's schema:description, its image, its Wikipedia link, and anything else. Unless you actually want full property merging, use skos:exactMatch (Submodule 1.3) which asserts conceptual equivalence without property inheritance.
naruto:Ninja owl:someValuesFrom naruto:Village, a reasoner does not conclude that Ninja who lack a village triple are invalid. It concludes there must be some village somewhere that they belong to, possibly unasserted. This "existential introduction" can cause unexpected inferences downstream. SHACL (Submodule 2.3) is the answer.
owl:AnnotationProperty (metadata, not used in reasoning) from owl:ObjectProperty (used in reasoning). rdfs:label, rdfs:comment, and dcterms:description are annotation properties. If you use them as object properties in restrictions, the reasoner will ignore the restriction. Always check whether a property is an annotation property before writing a restriction over it.
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.
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.
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.
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).
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.
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.
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
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
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
PREFIX naruto: <https://sensemaking-ai.com/ns/naruto#> CONSTRUCT { ?a naruto:rivalOf ?b . ?b naruto:rivalOf ?a . } WHERE { ?a naruto:rivalOf ?b . }
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)
Chapter 7 introduces OWL DL; Chapter 8 covers modeling patterns including n-ary relations and time-indexed situations. Read before Exercise 2.3.
The most readable entry point to OWL 2. Section 4 (property characteristics) and Section 5 (restrictions) are the most relevant for this submodule.
Formal definitions of EL, QL, RL, and DL. The introductory section is enough; the formal grammar is reference material.
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.
Design methodology, SHACL for closed-world validation, and REUSE.md practice. The primary project — naruto-ontology-1.0.0.ttl — is Exercise 2.3.
If the TBox / ABox distinction or the property characteristics are unclear, this submodule covers the RDFS foundations that OWL builds on.