AI Course · Week 13

Knowledge Representation & Ontologies

How machines store what they know. Semantic networks, ontologies, and RDF triples let an AI hold facts and reason new ones from them.

By Arj Symbolic AI Est. reading time: 14 minutes

The machine learning of the last few weeks learns patterns from data but cannot really tell you what it knows. There is an older, complementary tradition in AI: writing knowledge down explicitly, as facts and relationships a machine can store and reason over. This is knowledge representation, and its modern form is the ontology, the technology behind knowledge graphs like the panels you see in Google search. The payoff is that a machine holding structured knowledge can infer new facts it was never directly told, and this page shows exactly how.

1

Why represent knowledge

There are two broad ways to get knowledge into a machine. One is to learn it from data, as neural networks do; the knowledge ends up buried in millions of weights that no human can read. The other is to write it down explicitly as symbols and relationships the machine can store, share, and reason over. This second approach is knowledge representation, and it is the heart of what is called symbolic AI.

Explicit knowledge has real advantages. It is transparent (you can inspect exactly what the system believes), it is reusable across applications, and crucially it supports reasoning: deriving new facts from known ones by following logical rules. The challenge is designing a structure that captures messy real-world knowledge precisely enough for a computer.

Two traditions, one goal
Machine learning is great at perception and pattern-finding but opaque. Symbolic knowledge representation is transparent and can reason, but must be built by hand. Modern systems increasingly combine both, learned perception feeding structured knowledge.
2

Semantic networks

The simplest and oldest structure is the semantic network: a graph where nodes are concepts and labelled edges are relationships between them. "A dog is a mammal", "a bird has wings", and "Fido is a dog" all become nodes joined by labelled links.

The two most important link types appear again and again:

  • is-a links a specific thing to a more general category (Dog is-a Mammal). These build the hierarchy.
  • has-a or other property links attach features (Bird has-a Wings).

A related idea is the frame, which packages everything known about one concept into a labelled record of slots and values, like a form: a Dog frame with slots for legs (4), sound (bark), and category (Mammal). Frames and semantic networks describe the same knowledge in different shapes.

You already know graphs
A semantic network is just a labelled graph, the same structure you met in search and constraint problems. Here the nodes are ideas and the edges are meanings, but the machinery is familiar.
3

Ontologies

An ontology is a formal, shared, and much more rigorous version of a semantic network. It is a precise specification of the concepts in a domain and the relationships between them, agreed so that different systems can use the same vocabulary and mean the same thing. Its building blocks:

  • Classes: categories of things, like Animal, Mammal, Dog.
  • Instances: specific individuals, like Fido, who belong to a class.
  • Properties (or relations): the ways classes and instances connect, like "is a subclass of" or "has legs".

The difference from a loose semantic network is formality. An ontology is written in a strict language (such as OWL) with defined meanings, so a machine can reason over it reliably and two organisations can share it without ambiguity. Ontologies power search knowledge panels, medical terminologies, and the semantic web.

Taxonomy vs ontology
A taxonomy is just a hierarchy of categories, a tree of is-a links, like a biological classification. An ontology is richer: it adds many kinds of relationship and rules, not only "is a kind of". Every taxonomy is a simple ontology, but an ontology is far more than a taxonomy.
4

RDF triples

How is this knowledge actually written for a machine? The standard is the RDF triple, and it is wonderfully simple. Every fact is broken into three parts:

subject predicate object Fido is-a Dog Dog subclassOf Mammal Fido hasColour brown

A triple is one small statement: a subject, a relationship (the predicate), and an object. Any body of knowledge, however large, is just a huge collection of these three-part facts. Because every fact has the same shape, machines can store, merge, and query billions of them, which is exactly how a knowledge graph is built.

Worked example: a sentence as triples

"Tweety is a robin, robins are birds, and Tweety is coloured red." As RDF triples:

( Tweety , is-a , Robin ) ( Robin , subclassOf , Bird ) ( Tweety , hasColour , red )
Three triples capture the whole sentence as machine-readable facts
5

Inference and inheritance

Here is the real payoff of representing knowledge properly. A machine can infer facts it was never explicitly told, by following the relationships. The most important example is inheritance down is-a links.

Suppose the ontology contains only these facts: Fido is-a Dog, Dog is-a Mammal, Mammal is-a Animal, and Mammal has-property warm-blooded. No one stated that Fido is an animal or that Fido is warm-blooded. Yet a reasoner can derive both:

Given: Fido is-a Dog, Dog is-a Mammal, Mammal is-a Animal Infer: Fido is-a Mammal, Fido is-a Animal (is-a is transitive) Given: Mammal has warm-blooded, Fido is-a Mammal Infer: Fido has warm-blooded (inherited property)

This is enormously powerful. You state a property once, high in the hierarchy, and every instance below it inherits that property automatically. Store facts about a few thousand classes and a reasoner can answer millions of questions that were never written down. That is what makes ontologies more than just tidy filing.

6

Explore a knowledge graph

Below is a small ontology drawn as a graph. Solid arrows are is-a links pointing to more general classes. Click any node to see the facts stated directly about it. Then press "Run inference" to watch the reasoner derive new is-a links (dashed) and inherited properties that were never stated but follow logically.

Interactive Ontology graph and inference

Click a node to inspect it. Run inference to derive facts nobody stated directly.

class instance stated is-a inferred
Click a node to see its facts, then press Run inference.
Click Fido, then Run inference: the reasoner adds Fido is-a Mammal and Fido is-a Animal, and works out that Fido is warm-blooded and breathes, none of which was written down.
7

Key points and practice

  • Knowledge representation writes facts down explicitly so a machine can store and reason over them, unlike opaque learned models.
  • A semantic network is a graph of concept nodes joined by labelled relationship edges; frames package a concept's slots and values.
  • An ontology is a formal, shared specification of classes, instances, and properties in a domain.
  • An RDF triple states one fact as subject, predicate, object; knowledge graphs are built from many of them.
  • Inference, especially inheritance down is-a links, lets a reasoner derive facts that were never stated.
  • A taxonomy is a plain hierarchy; an ontology adds richer relationships and rules.
3 marks
Q1. What is a semantic network, and what do its nodes and edges represent?
Model answer

A semantic network is a way of representing knowledge as a graph. Its nodes represent concepts or objects, such as Dog or Fido, and its edges are labelled relationships between them, such as is-a or has-a. For example, a node Fido joined by an is-a edge to a node Dog states that Fido is a dog. It captures knowledge as concepts linked by meaningful relationships.

4 marks
Q2. Explain what an RDF triple is and give the difference between a taxonomy and an ontology.
Model answer

An RDF triple states a single fact in three parts: a subject, a predicate (the relationship), and an object, for example (Fido, is-a, Dog). Knowledge graphs are built from large collections of such triples. A taxonomy is simply a hierarchy of categories connected by is-a links, like a classification tree. An ontology is richer: it formally specifies classes, instances, and many kinds of relationship and rule, not only "is a kind of", so it can represent far more than a taxonomy and support reliable reasoning.

4 marks
Q3. Using inheritance, explain how a reasoner can conclude that Fido is warm-blooded if it is only told that Fido is a dog, dogs are mammals, and mammals are warm-blooded.
Model answer

The is-a relationship is transitive, so from "Fido is-a Dog" and "Dog is-a Mammal" the reasoner infers "Fido is-a Mammal". Properties stated on a class are inherited by everything below it in the hierarchy, so because "Mammal has-property warm-blooded" and Fido is a mammal, the reasoner concludes "Fido is warm-blooded", even though this fact was never stated directly. This inheritance of properties down is-a links is a core form of inference in ontologies.

When knowledge is uncertain
Ontologies handle facts that are definitely true. But much of the world is uncertain. The final topic, probabilistic reasoning, shows how AI reasons with probability and Bayes' theorem.
Probabilistic reasoning
Scroll to Top