An ontology goes wrong just as software does. It never crashes, though, so it tends to stay wrong for a long time. Checking happens at three levels: is the logic sound, does it answer the questions it was built for, and does it follow the conventions that make it easy for others to use.
1. Logic: ask a reasoner
| Problem | Meaning | Example |
|---|---|---|
| Inconsistency | Not everything stated can be true at once | Nabi is a cat and a dog, and the two are declared disjoint |
| Unsatisfiable class | A class that can never have a member | A subclass of two disjoint classes |
| Unintended inference | Not a contradiction, yet not a conclusion you wanted | A domain classifies Seoul as a person |
ex:Cat owl:disjointWith ex:Dog .
ex:CatDog rdfs:subClassOf ex:Cat , ex:Dog . # a class that can never have a member
ex:nabi a ex:CatDog . # this line makes the whole ontology inconsistentAn unsatisfiable class on its own is not yet a contradiction. The moment one individual is stated to belong to it, the whole ontology becomes inconsistent. Anything at all follows from an inconsistent ontology, so no inference from it can be trusted. A reasoner finds these two. The third row, unintended inference, only shows up when a person reads the results.
2. Requirements: competency questions as tests
Keep the questions written first in the design lesson as SPARQL files, and run them again every time the ontology changes. Written as ASK, the answer is true or false, which is a pass or a fail as it stands.
PREFIX ex: <https://example.org/>
ASK {
?d a ex:Dataset ;
ex:measuredBy ?s .
?s a ex:Sensor .
}
"Is there a dataset measured by a sensor" written as an ASK. The answer is false. The file never says that ex:dataset1 is a dataset or that ex:thermo7 is a sensor.
Not a character of the file changed, and the test passes. Domain and range inferred the type of both things. A test result depends on whether inference runs as well as on the ontology, so run it under the same conditions as real use.
The same approach finds things that must not be there. Any row in the result is something to fix.
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?class WHERE {
?property rdfs:domain|rdfs:range ?class .
FILTER NOT EXISTS { ?class rdfs:label ?label . }
This check fails when a row comes out. Of the classes used as a domain or range, ex:Dataset is caught for having no label. ex:Sensor has one and does not appear.
3. Conventions: a list of common mistakes
| Mistake | Why it matters | The fix |
|---|---|---|
| Terms with no label or definition | Users guess at the meaning | Give every term a label and a definition |
| A part written as a subclass | If "wheel is a subclass of car", every wheel is a car | Connect them with a property such as ex:partOf |
| An individual written as a class | There cannot be several "Seoul"s | Ask whether there can be many examples of it |
| Narrow domains and ranges | They infer rather than check, so odd classifications appear | Keep them broad or leave them out, and check with SHACL |
| A hierarchy that loops | If A is under B and B is under A, the two become the same class | If intended, write owl:equivalentClass |
| No disjointness declared | Misclassified data never shows up as a contradiction | Declare sibling classes that cannot overlap as disjoint |
| Re-creating a term that exists | More IRIs for one meaning, and data that does not merge | Search first, then reuse |
Tools check lists like this automatically. OOPS! takes an ontology on the web and reports common mistakes, and ROBOT, widely used for life-science ontologies, has a report command of the same kind.
Data quality is a separate matter
Everything so far checks the blueprint itself. Whether data that follows it has its required values and the right kinds of value is checked with shapes, as in the SHACL lesson. A sound blueprint can have wrong data, and the reverse is true as well.
Common misunderstandings
- The reasoner finished without errors, so the ontology is right.
- It means only that no declarations clash. Whether it matches reality and answers the questions needed is settled by competency questions and by people reviewing it.
- A contradiction only arises when bad data gets in.
- Class definitions can clash with each other too. An unsatisfiable class can be found before a single line of data exists.
- Disjointness declarations are not really needed.
- Without them a reasoner has no clash to catch. Data saying something is both a cat and a dog passes quietly.
A reasoner looks at the logic, competency questions at the requirements, and the mistake list at the conventions. Run all three together on every change.