Wednesday, October 21, 2026

Details about OWL

 To make OWL concrete, it helps to look at it in Turtle (.ttl) format, which is the most human-readable syntax for the W3C semantic stack.

Here is a simple example of an OWL ontology defining a domain for Vehicles and Motorcycles, including classes, properties, and logical constraints that a reasoner can use to infer new knowledge.

OWL Ontology Example (Turtle Syntax)

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix ex: <http://example.org/vehicles#> .

# 1. Define the Ontology Header
ex:VehicleOntology a owl:Ontology ;
    rdfs:comment "A sample OWL ontology for vehicle classification." .

# 2. Define Classes (Taxonomy)
ex:Vehicle a owl:Class ;
    rdfs:label "Vehicle" .

ex:Motorcycle a owl:Class ;
    rdfs:subClassOf ex:Vehicle ;
    rdfs:label "Motorcycle" .

ex:Manufacturer a owl:Class ;
    rdfs:label "Manufacturer" .

# 3. Define Properties (Relationships & Attributes)
ex:manufacturedBy a owl:ObjectProperty ;
    rdfs:domain ex:Vehicle ;
    rdfs:range ex:Manufacturer ;
    rdfs:label "manufactured by" .

ex:engineDisplacementCC a owl:DatatypeProperty, owl:FunctionalProperty ;
    rdfs:domain ex:Motorcycle ;
    rdfs:range xsd:integer ;
    rdfs:label "engine displacement in CC" .

# 4. Define Instances (Individuals) & Automated Reasoning
ex:HeroMotoCorp a ex:Manufacturer ;
    rdfs:label "Hero MotoCorp" .

# Notice we only state that 'Xpulse210' has an engine displacement. 
# Because of the OWL restrictions above, a reasoner automatically knows it is a Motorcycle (and therefore a Vehicle).
ex:Xpulse210 a ex:Motorcycle ;
    ex:manufacturedBy ex:HeroMotoCorp ;
    ex:engineDisplacementCC "210"^^xsd:integer .

How OWL Powers This Example

  1. Taxonomy & Inheritance (rdfs:subClassOf): By defining ex:Motorcycle rdfs:subClassOf ex:Vehicle, any rule or query that applies to a Vehicle automatically cascades down to Motorcycle.
  2. Object vs. Datatype Properties:
    • ex:manufacturedBy is an Object Property because it links a resource (Vehicle) to another resource (Manufacturer).
    • ex:engineDisplacementCC is a Datatype Property because it links a resource to a literal value (210 as an integer).
  3. Logical Inference: Because rdfs:domain specifies that engineDisplacementCC can only belong to a Motorcycle, an OWL reasoner can look at raw data, spot an unclassified object with an engine displacement, and automatically infer that the object must be a Motorcycle and a Vehicle.

No comments:

Post a Comment