Knowledge Graph Academy · Modules 3 to 5 · one rule, two models

Requires, Two Ways

"An electric guitar requires an amplifier." Modelled with SKOS concepts as values, and modelled with no SKOS at all. The same facts, the same question, two places for the rule to live.

read six sections, then twelve questionsscore 0/12
1 · The sentence

One sentence hides a rule and a fact

"An electric guitar requires an amplifier" says two things. The rule is about every electric guitar there will ever be: each one needs some amplifier. The fact is about one guitar: Dana's 1962 Stratocaster is played through Dana's Fender Deluxe. The fact is the same in both models below, an object property between two things you can hold. The rule is what changes between them.

# the fact, identical in both models: thing to thing, in the ABox
data:dana-strat io:requires data:dana-deluxe .
Prefixes on this pageinst: is the Instruments concept scheme, io: the classes and properties, data: the things. Your own file binds the scheme to the empty prefix; the names after the colon are the same.
2 · The types

With SKOS the types are values; without SKOS the types are classes

With SKOS as values

Electric Guitar is a concept in the Instruments scheme. Its hierarchy is skos:broader. A concept is never the subject of a relation of your own and never the object of rdf:type. Everything you can hold is typed with one of two classes, Instrument or Musical Accessory, and says which entry in the scheme it is through a property whose range is skos:Concept.

inst:ElectricGuitar a skos:Concept ;
    skos:prefLabel "Electric Guitar"@en ;
    skos:broader inst:Guitar .

io:hasInstrumentType a owl:ObjectProperty ;
    rdfs:domain io:Instrument ;
    rdfs:range  skos:Concept .

Without SKOS

Electric Guitar is a class. Its hierarchy is rdfs:subClassOf, and a reasoner propagates membership up it. The words go on rdfs:label and rdfs:comment. A thing says what it is with rdf:type alone; there is no second property for the type.

io:ElectricGuitar a owl:Class ;
    rdfs:subClassOf io:Guitar ;
    rdfs:label "Electric Guitar"@en .

io:Guitar a owl:Class ;
    rdfs:subClassOf io:StringInstrument .

Adding a baritone guitar is one concept in the scheme on the left, no schema edit. On the right it is a new class, and the schema changes. With forty instrument types the right-hand tree has forty classes; that is a list, not a product, so it is not the explosion from Why the TBox Stays Small. It is still the ontologist's file every time a type is added.

3 · The rule

With SKOS the rule is a thing with two values; without SKOS it is a restriction on the class

With SKOS as values

A concept cannot be the subject of a relation, so the rule cannot be written on Electric Guitar. It becomes an individual of a class made for rules, Accessory Requirement, with two properties whose values are concepts. The rules are rows in a table; the scheme supplies the words. They live in the ABox and are entered as data.

io:AccessoryRequirement a owl:Class .
io:forInstrumentType     a owl:ObjectProperty ;
    rdfs:domain io:AccessoryRequirement ; rdfs:range skos:Concept .
io:requiresAccessoryType a owl:ObjectProperty ;
    rdfs:domain io:AccessoryRequirement ; rdfs:range skos:Concept .

data:req-1 a io:AccessoryRequirement ;
    io:forInstrumentType     inst:ElectricGuitar ;
    io:requiresAccessoryType inst:Amplifier .

Without SKOS

Electric Guitar is a class, so the rule is a statement about the class: every member requires some Amplifier. That is an OWL restriction, written once on the class with owl:someValuesFrom. It lives in the TBox and is written by the ontologist.

io:Amplifier a owl:Class ;
    rdfs:subClassOf io:MusicalAccessory .

io:ElectricGuitar rdfs:subClassOf [
    a owl:Restriction ;
    owl:onProperty      io:requires ;
    owl:someValuesFrom  io:Amplifier ] .

The yellow lines are the rule. On the left it is three triples about a new individual. On the right it is an anonymous class, "things that require some amplifier", and Electric Guitar is declared a subclass of it.

4 · The things

Dana's gear is typed through a property on the left and through rdf:type on the right

With SKOS as values

data:dana-strat a io:Instrument ;
    schema:name "Dana's 1962 Stratocaster" ;
    io:hasInstrumentType inst:ElectricGuitar ;
    io:requires data:dana-deluxe .

data:dana-deluxe a io:MusicalAccessory ;
    schema:name "Dana's Fender Deluxe Reverb" ;
    io:hasAccessoryType inst:Amplifier .

Without SKOS

data:dana-strat a io:ElectricGuitar ;
    schema:name "Dana's 1962 Stratocaster" ;
    io:requires data:dana-deluxe .

data:dana-deluxe a io:Amplifier ;
    schema:name "Dana's Fender Deluxe Reverb" .

Two classes and a value on the left; one class each on the right. The fact, io:requires from the guitar to the amplifier, is the same triple in both.

5 · The reasoner

Each model lets a reasoner infer something different, and neither flags a missing cable

With SKOS as values

A property chain follows the guitar to its type, the type back to the rule, and the rule to the accessory type. The reasoner then adds data:dana-strat io:needsAccessoryType inst:Amplifier. Nobody types it in. Without a reasoner the same walk is one SPARQL query.

io:needsAccessoryType a owl:ObjectProperty ;
    owl:propertyChainAxiom (
        io:hasInstrumentType
        [ owl:inverseOf io:forInstrumentType ]
        io:requiresAccessoryType ) .

Without SKOS

From rdf:type io:ElectricGuitar the reasoner adds Guitar, String Instrument, Instrument and Music Equipment. The restriction tells it that some amplifier exists for the Stratocaster, and that is all it concludes. It never says which amplifier, and it never complains when none is listed.

# inferred from the subclass tree
data:dana-strat a io:Guitar, io:StringInstrument,
                  io:Instrument, io:MusicEquipment .
Open world, both sidesDana's Stratocaster lists an amplifier and no cable. An OWL reasoner treats the missing cable as unknown, not absent, in either model. The gap is found by a query, or by a SHACL shape, never by the reasoner.
# the gap query, SKOS-as-values model: which required accessory type has no matching accessory?
SELECT ?accessoryType WHERE {
  data:dana-strat io:hasInstrumentType ?type .
  ?rule io:forInstrumentType ?type ; io:requiresAccessoryType ?accessoryType .
  FILTER NOT EXISTS { data:dana-strat io:requires ?a . ?a io:hasAccessoryType ?accessoryType }
}
# the same question, no-SKOS model: read the restrictions up the class tree
SELECT ?accessoryClass WHERE {
  data:dana-strat a ?type . ?type rdfs:subClassOf* ?c .
  ?c rdfs:subClassOf [ owl:onProperty io:requires ; owl:someValuesFrom ?accessoryClass ] .
  FILTER NOT EXISTS { data:dana-strat io:requires ?a . ?a a ?accessoryClass }
}
6 · Side by side

Eight rows decide between the models

QuestionWith SKOS as valuesWithout SKOS
What is Electric Guitar?a concept, a valuea class
Where is the hierarchy?skos:broader, climbed by a queryrdfs:subClassOf, propagated by a reasoner
How does a thing say its type?rdf:type io:Instrument plus io:hasInstrumentType inst:ElectricGuitarrdf:type io:ElectricGuitar
Where does the rule live?ABox an Accessory Requirement individual with two valuesTBox a restriction on the class
Who writes the rule?whoever enters datathe ontologist
What does a reasoner add?the needed accessory type, through a property chainthe superclasses of the thing
Adding an instrument typeone concept, no schema editone class, a schema edit
Labels, synonyms, definitionsskos:prefLabel, skos:altLabel, skos:definition, one preferred label per languagerdfs:label, rdfs:comment; synonyms need extra labels with no rule about them
Where is the fact?ABox data:dana-strat io:requires data:dana-deluxe, the same in both

Choose the SKOS model when the list of types is long, changes often, has synonyms, or is maintained by people who do not edit ontologies. Choose the pure OWL model when the types are few and stable and the rules about them must be read by a reasoner from the class alone. The music graph in this course uses the first; a small, fixed domain can use the second.

7 · Knowledge check

Twelve questions, one point each

Some questions ask which model a statement belongs to. Pick an answer; the explanation appears at once.