# Mechanics: Fundamentals – Extra – Getting Ontological

So what the hell exactly is a hierarchical ontology?

In the previous article (Mechanics: Fundamentals – Extra – Set Theory 101), I made an implication that they are, for some reason, really important. And I’ll try to break this down bit by bit, starting with the term itself, moving on to some examples and then some applications.

Before we start with hierarchical ontologies, let’s begin with partial orders. So what’s a partial order? It’s a mathematical relation on a set of items. In our case, this set is the universe we are working with at the moment. Let’s use the sign ≤ to denote two elements in our universe that are in this relation (if you want to look at it as a boolean function – if the elements are in the relation the function returns true). Thus, a ≤ b means that a is in a partial order arrangement with b.

The relation must then possess the following properties:

• a ≤ a (partial order is reflexive, an element is ordered relative to itself)
• a ≤ b ∧ b ≤ a ⇒ a = b (which means that a partial order is antisymmetric, in practice, this means that no loops may exist in a partial order)
• a ≤ b ∧ b ≤ c ⇒ a ≤ c (making the partial order transitive and really… to me this is what orders an order)

Do note that there is no requirement for any two elements of the set to be ordered. That is to say that a ≰ b ⤃ b ≤ a.

Got that?

## Now, what does this have to do with ontological hierarchies?

From a formal point of view, a hierarchy is a preorder, which is a concept similar to a partial order, merely lacking antisymmetry. For the sake of what I’m trying to describe here, it’s best to additionally require this property, as it removes cycles from the relation. And that helps to keep things well organised and unambiguous. Hence I’m going to slightly narrow down the definition here.

## But where does the ontology part come in?

Consider this to be a very brief summary of a pretty extensive topic. But an ontology can be formally defined as a pair (Ω, ℝ) – a universe and a set of relations. Not just any kind of random relation though, these relations have to have a semantic meaning attached to them. To put it simply, the relation has to carry a meaning that is human-understandable, generally defined as a short natural language phrase. “A novel is a story” for example. “Is” is the relation in question, and our understanding of the words is the semantic meaning of two objects being in that relation.

A hierarchical ontology is one where all relations defined for the universe are themselves hierarchical relations. In our case, we’re extending this to partial orders of course.

Time to throw in an example.

This is a hierarchical ontology of drinks I might want to implement into the game. While I might not make any fancy charts for most of them (and this one is just a limited example), I do go through this little mental exercise of assembling this kind of structure. Even if it just stays in my head.

The first important step is identifying the root. In this case, it’s the “drink” part of the chart. From there I can follow down all of the paths to get all possible combinations from the root down the partial orders, in other words, we’re looking for sets of elements such that each of the items is in a partial order relationship with all the other ones. From that we get:

{Drink}
{Drink, Coffee}
{Drink, Tea}
{Drink, Tea, Black tea}
{Drink, Tea, Green tea}

And from there we have to see what else we can do, we get to the sugar and creamer, they are, in essence, separate relations that link up with the coffee and black tea elements. Because they are distinct relations, we can extend them together… or separately. So using coffee as an example:

{Drink, Coffee}
{Drink, Coffee, Creamer}
{Drink, Coffee, Creamer, Milk}
{Drink, Coffee, Creamer, Non-dairy}
{Drink, Coffee, Sugar}
{Drink, Coffee, Sugar, Creamer}
{Drink, Coffee, Sugar, Creamer, Milk}
{Drink, Coffee, Sugar, Creamer, Non-dairy}

In total:

{Drink}
{Drink, Coffee}
{Drink, Coffee, Creamer}
{Drink, Coffee, Creamer, Milk}
{Drink, Coffee, Creamer, Non-dairy}
{Drink, Coffee, Sugar}
{Drink, Coffee, Sugar, Creamer}
{Drink, Coffee, Sugar, Creamer, Milk}
{Drink, Coffee, Sugar, Creamer, Non-dairy}
{Drink, Tea}
{Drink, Tea, Black tea}
{Drink, Tea, Black tea, Creamer}
{Drink, Tea, Black tea, Creamer, Milk}
{Drink, Tea, Black tea, Creamer, Non-dairy}
{Drink, Tea, Black tea, Sugar}
{Drink, Tea, Black tea, Sugar, Creamer}
{Drink, Tea, Black tea, Sugar, Creamer, Milk}
{Drink, Tea, Black tea, Sugar, Creamer, Non-dairy}
{Drink, Tea, Green tea}

And that’s a lot, isn’t it? If I wanted to write texts (especially multiple texts) that cover all of this that might be… quite a hassle. Even for a simple scheme like this, there’s quite a lot of possible paths through the graph that “make sense” (that is to say, in the context of the semantics ascribed to relations we find in it).

However, it’s possible to draw out some simplifications here, and part of it has to do with the set based logic from the article before. As I don’t think it would be a good idea to jump into it right now since this article is long enough as is.

So next time: how to prune options using set-based logic and hierarchical ontologies!