CV Courseversity

Ontologies and Semantic Technologies

Covers taxonomies, description logics, and the W3C semantic web stack — RDF triples, OWL ontologies, and SPARQL queries — as the standards that let machines share and reason over structured knowledge.

“When Wikidata and a hospital's internal patient database both store the fact that a person "treats" a disease, one calls the relation treats and the other calls it prescribes_for — to a machine, these look like two unrelated facts about two unrelated worlds, even though a human reads them as the same claim. RDF gives every such fact a common triple shape addressed by global identifiers; OWL lets an engineer formally declare that treats and prescribes_for are the same relation, or systematically different; and SPARQL lets an analyst ask, in one query, a question that spans both databases as though they were one. That is the promise, and the very real engineering difficulty, of the semantic web.”

Taxonomies, Ontologies, and Description Logics · 15 min

Thomas Gruber's widely cited 1993 characterization defines an ontology, in the AI knowledge-sharing sense, as a specification of a representational vocabulary for a shared domain of discourse — definitions of classes, relations, functions, and other objects. Gruber developed this definition in the context of building shared, reusable knowledge bases, where the practical problem was getting independently developed AI systems to actually agree on what their terms meant well enough to exchange knowledge usefully. This is a deliberately broader notion than a bare taxonomy, which is only an is-a hierarchy of category names arranged from general to specific: a full ontology also states axioms relating those categories to one another — what properties they have, what relations can hold between their instances, what follows logically from an object belonging to one category rather than another. That extra layer of axioms is what lets systems built independently by different teams interoperate over a genuinely shared vocabulary, rather than merely a shared set of labels that each system is free to interpret differently behind the scenes.

Description logics are a family of decidable fragments of first-order logic purpose-built for exactly this ontology-engineering job. A description-logic knowledge base is organized around atomic concepts (unary predicates denoting sets of individuals) and atomic roles (binary predicates expressing relationships between individuals), combined into more complex concept and role expressions using a controlled set of constructors. The knowledge base splits into a TBox, which holds general terminological axioms defining and relating concepts, and an ABox, which holds assertions about specific named individuals — a split that closely mirrors the TELL and ASK structure of a knowledge-based agent, except organized specifically around class and instance information rather than arbitrary sentences. The central reasoning task is subsumption — checking whether one concept expression always denotes a subset of another — which lets a reasoner automatically classify an entire concept hierarchy from a set of axioms, rather than requiring an engineer to state that hierarchy by hand and risk getting it wrong, leaving it incomplete, or leaving it outright inconsistent as the ontology grows and changes over time.

OWL 2's formal Direct Semantics is defined to be compatible with the model-theoretic semantics of SROIQ, an expressive description logic, which lets OWL tooling draw directly on decades of description-logic research into reasoning algorithms and their computational complexity, rather than starting the theory of ontology reasoning from scratch. Because full expressiveness and guaranteed-efficient reasoning trade off against each other — the more an ontology language lets an engineer say, the more expensive it tends to become to automatically reason over what has been said — OWL 2 also defines restricted profiles that give up some expressiveness in exchange for computational guarantees. EL supports polynomial-time algorithms for all the standard reasoning tasks and suits applications with very large ontologies containing many classes; QL supports conjunctive query answering in LogSpace using standard relational database technology, suiting applications with very large numbers of individual data records; and RL supports polynomial-time reasoning using rule-extended database technologies that operate directly on RDF triples. Choosing among the full language and its three profiles is an explicit engineering decision, made up front, about how much expressiveness an ontology genuinely needs against how expensive it can afford for reasoning over it to become.

RDF: The Data Model of the Semantic Web · 14 min

RDF's basic unit of information is the triple: a subject, a predicate, and an object, such as (:Aspirin, :treats, :Headache). An RDF graph is simply a set of such triples, forming a labeled directed graph in which the nodes are subjects and objects and the edges are predicates — the same triple can be read equally well as a single fact or as one edge of a much larger graph describing everything currently known. Every subject, predicate, and typed object in that graph is drawn, where possible, from a global namespace via an IRI (an Internationalized Resource Identifier), which is what gives different systems a way to refer unambiguously to the same real-world thing or the same relation without first agreeing on a shared database schema in advance — the identifier itself carries the agreement, since any two systems that happen to use the same IRI are automatically talking about the same thing.

RDF recognizes three kinds of terms that can appear in a triple. IRIs name resources or relations globally, and are the only term type that can appear as a predicate. Literals represent values such as strings and numbers, each carrying a lexical form together with a datatype IRI and, optionally, a language tag, so that the literal "23" typed as an integer is distinguished from the plain string "23". Blank nodes act as locally scoped placeholders for resources that need to be referenced within a graph without being given a global name, useful for describing structured values that have no independent identity worth naming. Because an RDF graph is nothing more than a set of triples, a small number of triples about one resource compose naturally into a fuller description of it, and graphs published independently by different sources can be merged simply by taking the union of their triples — any triples that happen to share an IRI automatically connect the two graphs at that point, without either publisher needing to coordinate with the other in advance.

RDF is deliberately minimal: on its own, it says nothing about which predicates are legal for which kinds of subjects, nothing about which classes a resource is allowed to belong to, and nothing about what new facts logically follow from a given set of triples beyond the triples that were explicitly written down. That gap is exactly what RDF Schema and OWL exist to fill, layering a vocabulary for classes and properties, and then a full description-logic-based formal semantics with its own notion of entailment, on top of RDF's bare graph structure. RDF supplies the universal data shape — a common triple format any domain can be poured into — while RDF Schema and OWL supply the meaning that a reasoner can act on, turning a plain graph of assertions into a knowledge base that supports genuine logical inference, the same kind of inference examined earlier in this course in the context of propositional and first-order logic.

SPARQL and Semantic Queries · 14 min

SPARQL is the W3C query language for RDF graphs, and its core building block is the triple pattern — a triple in which any of the subject, predicate, or object may be a variable instead of a fixed value, written conventionally with a leading question mark, as in (?drug, :treats, :Headache). A basic graph pattern combines several triple patterns, and matching that pattern against a target RDF graph means finding every assignment of the pattern's variables that makes all of its triples simultaneously present in the graph. This behaves much like a join across relational tables, in that variables shared between two triple patterns must be bound consistently across both, except that it operates over a schema-flexible graph rather than a fixed set of tables and columns, so a single query can traverse data whose structure was never fixed in advance by any single designer.

SPARQL defines four distinct query forms, each returning a different kind of result: SELECT returns a table of variable bindings that satisfy the pattern, much like the result set of a relational query; CONSTRUCT builds and returns a brand-new RDF graph from a template, letting one query transform data from one shape into another; ASK returns a simple boolean indicating whether the pattern matches the data at all, without returning any bindings; and DESCRIBE returns a graph describing a given resource, useful when a client wants "everything known about" something without stating exactly which predicates to ask for. Beyond basic graph patterns, SPARQL supports OPTIONAL matching for data that may or may not be present, UNION of alternative patterns, FILTER conditions that restrict bindings by value, property paths for traversing chains of relations of arbitrary length in a single expression, and solution modifiers such as ORDER BY, LIMIT, and DISTINCT alongside aggregate functions including COUNT, SUM, MIN, MAX, and GROUP_CONCAT.

Because SPARQL queries can be issued against a single RDF graph or federated across multiple independently hosted SPARQL endpoints using the SERVICE keyword, a single query can span knowledge graphs that were published by entirely different organizations and never designed to be queried together in the first place. Answering "which drugs treat conditions that also appear in a genomics database published by an unrelated research group" becomes, in principle, a single federated SPARQL query rather than a bespoke data-integration project involving custom code to reconcile two incompatible schemas by hand. This is precisely the interoperability scenario that motivates building on RDF and OWL from the outset, rather than maintaining isolated, incompatible databases that each speak their own private vocabulary and require manual, one-off translation work every time two organizations need to combine what they separately know — the same underlying promise of a shared, machine-readable vocabulary that opened this module's essential question about a hospital's patient records and Wikidata.

Practice

An RDF Triple Graph

RDF Graph: Three Triples :Aspirin :Headache :Drug :Condition :treats rdf:type rdf:type

Two rdf:type triples classify Aspirin as a Drug and Headache as a Condition, while a treats triple links them — three simple triples that together form a small, machine-queryable knowledge graph.

  • RDF's only structural commitment is the triple — subject, predicate, object — which is expressive enough that any two independently published graphs sharing IRIs can be merged simply by taking the union of their triples.
  • OWL adds a formal, description-logic-based semantics on top of RDF's bare graph structure, so a reasoner can automatically derive a class hierarchy or detect inconsistency instead of an engineer stating every consequence by hand.
  • SPARQL treats a query as a graph pattern with variables, matched against the RDF graph much like a join across tables — but because RDF has no fixed schema, that pattern can span data that was never designed to be queried together.

Recall Practice

Ontology definitionClick to reveal
How did Gruber characterize an ontology in his influential 1993 paper?
As a specification of a representational vocabulary for a shared domain — definitions of classes, relations, functions, and other objects — intended to let independently built systems share and reuse knowledge.
RDF triplesClick to reveal
What are the three parts of an RDF triple, and what does a set of triples form?
A subject, a predicate, and an object; a set of RDF triples forms an RDF graph, in which the same IRI used as a subject in one triple and an object in another links the two statements together.
OWL and description logicClick to reveal
What formal logic underlies OWL 2's Direct Semantics, and why does that matter?
OWL 2's Direct Semantics is defined to be compatible with the SROIQ description logic, which matters because it lets OWL reuse decades of description-logic research on reasoning algorithms and their computational complexity.
SPARQL query formsClick to reveal
Name two of SPARQL's four query forms and what each returns.
SELECT returns a table of variable bindings matching a graph pattern, and ASK returns a simple boolean true or false for whether a pattern matches at all (CONSTRUCT returns a new RDF graph and DESCRIBE returns a graph describing a resource).

Glossary

Ontology
A specification of a shared vocabulary of classes, relations, and axioms for a domain, intended to let independently built systems interoperate.
RDF triple
The basic RDF statement, consisting of a subject, a predicate, and an object, that together forms one edge of an RDF graph.
IRI
An Internationalized Resource Identifier, used in RDF to name resources and relations globally and unambiguously.
TBox / ABox
In description logics, the TBox holds general terminological axioms about classes and roles, and the ABox holds assertions about specific named individuals.
OWL
The Web Ontology Language, a W3C standard for expressing ontologies with description-logic-based formal semantics on top of RDF.
SPARQL
The W3C standard query language for RDF, which matches graph patterns containing variables against an RDF graph.
Practical Activity

Modeling a Mini-Ontology on Paper

A fully paper-based, simulated exercise: define two OWL-style classes (Drug and Condition) and one object property (treats) for a tiny medical vocabulary, write three RDF triples by hand describing one drug and one condition, and write out — in plain text, without running any software — the triple pattern a SPARQL SELECT query would use to ask 'which drugs treat which conditions.'

Ready to test yourself?

5 questions on this module.

Start Quiz