# Today I Learned

Some of the things I've learned every day since Oct 10, 2016

## 203: The Unit Type

In type theory, a unit type is a type which can take on only one value. With its underlying set being a (the) singleton set, values of this type contain no information within its scope. (Contrast with the boolean type, which has 2 values, and where the value T does carry information because it is not F.)

This doesn’t mean the type itself can’t carry information in a larger scope, however. For instance, in programming languages it’s common to have a unit type and use its single value for representing a lack of a value. Python has the ‘None’, Java has ‘void’/’null’, and Haskell has ‘()’, to give a few examples. This value is useless within the scope of its type, but useful when other types are in scope.

## 110: Combining Has-a and Is-a (Pseudo-Transitivity)

There’s a property of the interaction between the has-a and is-a relations when they are over the same set, which is somewhat similar in form — superficially, at least — to the property of transitivity. Recall that the property of transitivity says of a relation $\rightarrow$ that if $a \rightarrow b$ and $b \rightarrow c$, then $a \rightarrow c$.

Now denote is-a as $\rightarrow$ and has-a as $\dashrightarrow$. Then this property of interaction between the two relations, which I don’t know of a name for, states

1. If $a \rightarrow b$ and $b \dashrightarrow c$, then $a \dashrightarrow c$.
2. If $a \dashrightarrow b$ and $b \rightarrow c$, then $a \dashrightarrow c$.

If you interpret what this means in plain English then the truth of this property is evident. The problem is I’ve never come across formal systems for allowing these sorts of interactions between relations, so I’m not sure if it’s something that’s already been developed. Will be looking into it more.

## 109: Composition vs Aggregation in Has-a Relationships

There are two different types of has-a relationships, composition and aggregation, distinguished by whether the child object belonging to the parent object can belong to more than just that parent. In essence, composition implies ownership while aggregation does not.

For example, a university has departments. These departments belong to no other university and if the university is ceases to exist, so do they. This exemplifies a composition relation.

By contrast, a department has professors, but a given professor may belong to more than one department and will usually not cease to exist when the department does. This is instead an aggregation relation.