Skip to content →

Category: math

From Mamuth to Elephant

Here, MaMuTh stands for Mathematical Music Theory which analyses the pitch, timing, and structure of works of music.

The Elephant is the nickname for the ‘bible’ of topos theory, Sketches of an Elephant: A Topos Theory Compendium, a two (three?) volume book, written by Peter Johnstone.

How can we get as quickly as possible from the MaMuth to the Elephant, musical illiterates such as myself?

What Mamuth-ers call a pitch class (sounds that are a whole number of octaves apart), is for us a residue modulo $12$, as an octave is usually divided into twelve (half)tones.

We’ll just denote them by numbers from $0$ to $11$, or view them as the vertices of a regular $12$-gon, and forget the funny names given to them, as there are several such encodings, and we don’t know a $G$ from a $D\#$.



Our regular $12$-gon has exactly $24$ symmetries. Twelve rotations, which they call transpositions, given by the affine transformations
\[
T_k~:~x \mapsto x+k~\text{mod}~12 \]
and twelve reflexions, which they call involutions, given by
\[
I_k~:~x \mapsto -x+k~\text{mod}~12 \]
What for us is the dihedral group $D_{12}$ (all symmetries of the $12$-gon), is for them the $T/I$-group (for transpositions/involutions).

Let’s move from individual notes (or pitch classes) to chords (or triads), that is, three notes played together.

Not all triples of notes sound nice when played together, that’s why the most commonly played chords are among the major and minor triads.

A major triad is an ordered triple of elements from $\mathbb{Z}_{12}$ of the form
\[
(n,n+4~\text{mod}~12,n+7~\text{mod}~12) \]
and a minor triad is an ordered triple of the form
\[
(n,n+3~\text{mod}~12,n+7~\text{mod}~12) \]
where the first entry $n$ is called the root of the triad (or chord) and its funny name is then also the name of that chord.

For us, it is best to view a triad as an inscribed triangle in our regular $12$-gon. The triangles of major and minor triads have edges of different lengths, a small one, a middle, and a large one.

Starting from the root, and moving clockwise, we encounter in a major chord-triangle first the middle edge, then the small edge, and finally the large edge. For a minor chord-triangle, we have first the small edge, then the middle one, and finally the large edge.

On the left, two major triads, one with root $0$, the other with root $6$. On the right, two minor triads, also with roots $0$ and $6$.



(Btw. if you are interested in the full musical story, I strongly recommend the alpof blog by Alexandre Popoff, from which the above picture is taken.)

Clearly, there are $12$ major triads (one for each root), and $12$ minor triads.

From the shape of the triad-triangles it is also clear that rotations (transpositions) send major triads to major triads (and minors to minors), and that reflexions (involutions) interchange major with minor triads.

That is, the dihedral group $D_{12}$ (or if you prefer the $T/I$-group) acts on the set of $24$ major and minor triads, and this action is transitive (an element stabilising a triad-triangle must preserve its type (so is a rotation) and its root (so must be the identity)).

Can we hear the action of the very special group element $T_6$ (the unique non-trivial central element of $D_{12}$) on the chords?

This action is not only the transposition by three full tones, but also a point-reflexion with respect to the center of the $12$-gon (see two examples in the picture above). This point reflexion can be compositionally meaningful to refer to two very different upside-down worlds.

In It’s $T_6$-day, Alexandre Popoff gives several examples. Here’s one of them, the Ark theme in Indiana Jones – Raiders of the Lost Ark.

“The $T_6$ transformation is heard throughout the map room scene (in particular at 2:47 in the video): that the ark is a dreadful object from a very different world is well rendered by the $T_6$ transposition, with its inherent tritone and point reflection.”

Let’s move on in the direction of the Elephant.

We saw that the only affine map of the form $x \mapsto \pm x + k$ fixing say the major $0$-triad $(0,4,7)$ is the identity map.

But, we can ask for the collection of all affine maps $x \mapsto a x + b$ fixing this major $0$-triad set-wise, that is, such that
\[
\{ b, 4a+b~\text{mod}~12, 7a+b~\text{mod}~2 \} \subseteq \{ 0,4,7 \} \]

A quick case-by-case analysis shows that there are just eight such maps: the identity and the constant maps
\[
x \mapsto x,~x \mapsto 0,~x \mapsto 4, ~x \mapsto 7 \]
and the four maps
\[
\underbrace{x \mapsto 3x+7}_a,~\underbrace{x \mapsto 8x+4}_b,~x \mapsto 9x+4,~x \mapsto 4x \]

Compositions of such maps again preserve the set $\{ 0,4,7 \}$ so they form a monoid, and a quick inspection with GAP learns that $a$ and $b$ generate this monoid.


gap> a:=Transformation([10,1,4,7,10,1,4,7,10,1,4,7]);;
gap> b:=Transformation([12,8,4,12,8,4,12,8,4,12,8,4]);;
gap> gens:=[a,b];;
gap> T:=Monoid(gens);
gap> Size(T);
8

The monoid $T$ is the triadic monoid of Thomas Noll’s paper The topos of triads.

The monoid $T$ can be seen as a one-object category (with endomorphisms the elements of $T$). The corresponding presheaf topos is then the category of all sets equipped with a right $T$-action.

Actually, Noll considers just one such presheaf (and its sub-presheaves) namely $\mathcal{F}=\mathbb{Z}_{12}$ with the action of $T$ by affine maps described before.

He is interested in the sheafifications of these presheaves with respect to Grothendieck topologies, so we have to describe those.

For any monoid category, the subobject classifier $\Omega$ is the set of all right ideals in the monoid.

Using the GAP sgpviz package we can draw its Cayley graph (red coloured vertices are idempotents in the monoid, the blue vertex is the identity map).


gap> DrawCayleyGraph(T);



The elements of $T$ (vertices) which can be connected by oriented paths (in both ways) in the Cayley graph, such as here $\{ 2,4 \}$, $\{ 3,7 \}$ and $\{ 5,6,8 \}$, will generate the same right ideal in $T$, so distinct right ideals are determined by unidirectional arrows, such as from $1$ to $2$ and $3$ or from $\{ 2,4 \}$ to $5$, or from $\{ 3,7 \}$ to $6$.

This gives us that $\Omega$ consists of the following six elements:

  • $0 = \emptyset$
  • $C = \{ 5,6,8 \} = a.T \wedge b.T$
  • $L = \{ 2,4,5,6,8 \}=a.T$
  • $R = \{ 3,7,5,6,8 \}=b.T$
  • $P = \{ 2,3,4,5,6,7,8 \}=a.T \vee b.T$
  • $1 = T$

As a subobject classifier $\Omega$ is itself a presheaf, so wat is the action of the triad monoid $T$ on it? For all $A \in \Omega$, and $s \in T$ the action is given by $A.s = \{ t \in T | s.t \in A \}$ and it can be read off from the Cayley-graph.

$\Omega$ is a Heyting algebra of which the inclusions, and logical operations can be summarised in the picture below, using the Hexboards and Heytings-post.



In this case, Grothendieck topologies coincide with Lawvere-Tierney topologies, which come from closure operators $j~:~\Omega \rightarrow \Omega$ which are order-increasing, idempotent, and compatible with the $T$-action and with the $\wedge$, that is,

  • if $A \leq B$, then $j(A) \leq j(B)$
  • $j(j(A)) = j(A)$
  • $j(A).t=j(A.t)$
  • $j(A \wedge B) = j(A) \wedge j(B)$

Colouring all cells with the same $j$-value alike, and remaining cells $A$ with $j(A)=A$ coloured yellow, we have six such closure operations $j$, that is, Grothendieck topologies.



The triadic monoid $T$ acts via affine transformations on the set of pitch classes $\mathbb{Z}_{12}$ and we’ve defined it such that it preserves the notes $\{ 0,4,7 \}$ of the major $(0,4,7)$-chord, that is, $\{ 0,4,7 \}$ is a subobject of $\mathbb{Z}_{12}$ in the topos of $T$-sets.

The point of the subobject classifier $\Omega$ is that morphisms to it classify subobjects, so there must be a $T$-equivariant map $\chi$ making the diagram commute (vertical arrows are the natural inclusions)
\[
\xymatrix{\{ 0,4,7 \} \ar[r] \ar[d] & 1 \ar[d] \\ \mathbb{Z}_{12} \ar[r]^{\chi} & \Omega} \]

What does the morphism $\chi$ do on the other pitch classes? Well, it send an element $k \in \mathbb{Z}_{12} = \{ 1,2,\dots,12=0 \}$ to

  • $1$ iff $k \in \{ 0,4,7 \}$
  • $P$ iff $a(k)$ and $b(k)$ are in $\{ 0,4,7 \}$
  • $L$ iff $a(k) \in \{ 0,4,7 \}$ but $b(k)$ is not
  • $R$ iff $b(k) \in \{ 0,4,7 \}$ but $a(k)$ is not
  • $C$ iff neither $a(k)$ nor $b(k)$ is in $\{ 0,4,7 \}$

Remember that $a$ and $b$ are the transformations (images of $(1,2,\dots,12)$)

a:=Transformation([10,1,4,7,10,1,4,7,10,1,4,7]);;
b:=Transformation([12,8,4,12,8,4,12,8,4,12,8,4]);;

so we see that

  • $0,1,4$ are mapped to $1$
  • $3$ is mapped to $P$
  • $8,11$ are mapped to $L$
  • $1,6,9,10$ are mapped to $R$
  • $2,5$ are mapped to $C$

Finally, we can compute the sheafification of the sub-presheaf $\{ 0,4,7 \}$ of $\mathbb{Z}$ with respect to a Grothendieck topology $j$: it consists of the set of those $k \in \mathbb{Z}_{12}$ such that $j(\chi(k)) = 1$.

The musically interesting Grothendieck topologies are $j_P, j_L$ and $j_R$ with corresponding sheaves:

  • For $j_P$ we get the sheaf $\{ 0,3,4,7 \}$ which Mamuth-ers call a Major-Minor Mixture as these are the notes of both the major and minor $0$-triads
  • For $j_L$ we get $\{ 0,3,4,7,8,11 \}$ which is an example of an Hexatonic scale (six notes), here they are the notes of the major and minor $0,~4$ and $8$-triads
  • For $j_R$ we get $\{ 0,1,3,4,6,7,9,10 \}$ which is an example of an Octatonic scale (eight notes), here they are the notes of the major and minor $0,~3,~6$ and $9$-triads

We could have played the same game starting with the three notes of any other major triad.

Those in the know will have noticed that so far I’ve avoided another incarnation of the dihedral $D_{12}$ group in music, namely the $PLR$-group, which explains the notation for the elements of the subobject classifier $\Omega$, but this post is already way too long.

(to be continued…)

Leave a Comment

Hexboards and Heytings

A couple of days ago, Peter Rowlett posted on The Aperiodical: Introducing hexboard – a LaTeX package for drawing games of Hex.

Hex is a strategic game with two players (Red and Blue) taking turns placing a stone of their color onto any empty space. A player wins when they successfully connect their sides together through a chain of adjacent stones.

Here’s a short game on a $5 \times 5$ board (normal play uses $11\times 11$ boards), won by Blue, drawn with the LaTeX-package hexboard.



As much as I like mathematical games, I want to use the versability of the hexboard-package for something entirely different: drawing finite Heyting algebras in which it is easy to visualise the logical operations.

Every full hexboard is a poset with minimal cell $0$ and maximal cell $1$ if cell-values increase if we move horizontally to the right or diagonally to the upper-right. With respect to this order, $p \vee q$ is the smallest cell bigger than both $p$ and $q$, and $p \wedge q$ is the largest cell smaller than $p$ and $q$.



The implication $p \Rightarrow q$ is the largest cell $r$ such that $r \wedge p \leq q$, and the negation $\neg p$ stands for $p \Rightarrow 0$. With these operations, the full hexboard becomes a Heyting algebra.

Now the fun part. Every filled area of the hexboard, bordered above and below by a string of strictly increasing cells from $0$ to $1$ is also a Heyting algebra, with the induced ordering, and with the logical operations defined similarly.



Note that this mustn’t be a sub-Heyting algebra as the operations may differ. Here, we have a different value for $p \Rightarrow q$, and $\neg p$ is now $0$.

If you’re in for an innocent “Where is Wally?”-type puzzle: $W = (\neg \neg p \Rightarrow p)$.



Click on the image to get the solution.

The downsets in these posets can be viewed as the open sets of a finite topology, so these Heyting algebra structures come from the subobject classifier of a topos.

There are more interesting toposes with subobject classifier determined by such hex-Heyting algebras.

For example, the Topos of Triads of Thomas Noll in music theory has as its subobject classifier the hex-Heyting algebra (with cell-values as in the paper):



Note to self: why not write a couple of posts on this topos?

Another example: the category of all directed graphs is the presheaf topos of the two object category ($V$ for vertices, and $E$ for edges) with (apart from the identities) just two morphisms $s,t : V \rightarrow E$ (for start- and end-vertex of a directed edge).

The subobject classifier $\Omega$ of this topos is determined by the two Heyting algebras $\Omega(E)$ and $\Omega(V)$ below.



These ‘hex-Heyting algebras’ are exactly what Eduardo Ochs calls ‘planar Heyting algebras’.

Eduardo has a very informative research page, containing slides and handouts of talks in which he tries to explain topos theory to “children” (using these planar Heyting algebras) including:

Perhaps now is a good time to revive my old sga4hipsters-project.

Leave a Comment

Learners’ logic

In the Learners and Poly-post we’ve seen that learners from $A$ to $B$ correspond to set-valued representations of a directed graph $G$ and therefore form a presheaf topos.

Any topos comes with its Mitchell-Benabou language, allowing us to speak of formulas, propositions and their truth values. Two objects play a special role in this: the terminal object $\mathbf{1}$, and the subobject classifier $\mathbf{\Omega}$. It is a fun exercise to determine these special learners.

$T$ is the free rooted tree with branches sprouting from every node $n \in T_0$ for each element in $A \times B$. $C$ will be our set of colours, one for each element of $Maps(A,B) \times Maps(A \times B,A)$.

For every map $\lambda : T_0 \rightarrow C$ we get a coloured rooted tree $T_{\lambda}$, and for each branch $(a,b)$ from the root we get another rooted sub-tree $T_{\lambda}(a,b)$ which is again of the form $T_{\mu}$ for a certain map $\mu : T_0 \rightarrow C$.

The directed graph $G$ has a vertex $v_{\lambda} \in V$ for each coloured rooted tree $T_{\lambda}$ and a directed edge $v_{\lambda} \rightarrow v_{\mu}$ if $T_{\mu}$ is the isomorphism class of coloured rooted trees of the subtree $T_{\lambda}(a,b)$ for some $(a,b) \in A \times B$.

There are exactly $\# A \times B$ directed edges leaving every vertex in $G$, but there may be (many) more incoming edges. We can colour each vertex $v_{\lambda}$ with the colour of the root of $T_{\lambda}$.



The coloured directed graph $G$ depicts the learning process in a neural network, being trained to find a suitable map $A \rightarrow B$. The colour of a vertex $v_{\lambda}$ gives a map $f \in Maps(A,B)$ (and a request function). If the network now gives as output $b \in B$ for a given input $a \in A$, we can move on to the end-vertex $v_{\mu}$ of the directed edge labeled $(a,b)$ out of $v_{\lambda}$. The colour of $v_{\mu}$ gives us a new (hopefully improved) map $f_{new} \in Maps(A,B)$ (and a new request function). A new training data $(a’,b’)$ brings us to a new vertex and map, and so on.

Clearly, some parts of $G$ are more efficient to find the desired map than others, and the aim of the game is to distinguish efficient from inefficient learners. A first hint that Grothendieck topologies and their corresponding sheafifications will turn out to be important.

We’ve seen that a learner, that is a morphism $Py^P \rightarrow C y^{A \times B}$ in $\mathbf{Poly}$, assigns a set $P_{\lambda}$ to every vertex $v_{\lambda}$ (this set may be empty) and a map $P_{\lambda} \rightarrow P_{\mu}$ to every directed edge $v_{\lambda} \rightarrow v_{\mu}$ in $G$.

The terminal object $\mathbf{1}$ in this setting assigns to each vertex a singleton $\{ \ast \}$, and the obvious maps for each directed edge. In $\mathbf{Poly}$-speak, the terminal object is the morphism
\[
\mathbf{1}~:~V y^V \rightarrow C y^{A \times B} \]
which sends each vertex $v_{\lambda} \in V$ to its colour $c \in C$, and where the backtrack map $\varphi^{\#}_{v_{\lambda}}[c]$ maps $(a,b)$ to $v_{\mu}$ if this is the end-vertex of the edge labelled $(a,b)$ out of $v_{\lambda}$. That is, $\mathbf{1}$ contains all information about the coloured directed graph $G$.

The subobject classifier $\mathbf{\Omega}$ assigns to each vertex $v_{\lambda}$ the set $\mathbf{\Omega}(v_{\lambda})$ of all subsets $S$ of directed paths in $G$, starting at $v_{\lambda}$, such that if $p \in S$ then also all prolongated paths belong to $S$. Note that the emptyset $\emptyset$ satisfies this requirement, so is an element of this vertex set. Another special element in $\mathbf{\Omega}(v_{\lambda})$ is the set $\mathbf{1}_{\lambda}$ of all oriented paths starting at $v_{\lambda}$.

$\mathbf{\Omega}(v_{\lambda})$ is an Heyting algebra with $1=\mathbf{1}_{\lambda}$, $0 = \emptyset$, partially ordered via inclusion, and logical operations $\wedge$ (intersection), $\vee$ (union), $\neg$ (with $\neg S$ the largest $S’ \in \mathbf{\Omega}(v_{\lambda})$ disjoint from $S$) and $\Rightarrow$ defined by $S \Rightarrow S’$ is the union of all $S” \in \mathbf{\Omega}(v_{\lambda})$ such that $S” \cap S \subseteq S’$.



$S \wedge \neg S$ is not always equal to $1$. Here, the union misses the left edge from the root. So, we will not be able to prove things by contradiction.

If $v_{\lambda} \rightarrow v_{\mu}$ is the directed edge labeled $(a,b)$, then the corresponding map $\mathbf{\Omega}(v_{\lambda}) \rightarrow \mathbf{\Omega}(v_{\mu})$ takes an $S \in \mathbf{\Omega}(v_{\lambda})$, drops all paths which do not pass through $v_{\mu}$ and removes from those who do the initial edge $(a,b)$. If no paths in $S$ pass through $v_{\mu}$ then $S$ is mapped to $\emptyset \in \mathbf{\Omega}(v_{\mu})$.

If $\Omega = \bigsqcup_{\lambda} \mathbf{\Omega}(v_{\lambda})$ then the subobject classifier is the morphism in $\mathbf{Poly}$
\[
\mathbf{\Omega}~:~\Omega y^{\Omega} \rightarrow C y^{A \times B} \]
sending a path starting in $v_{\lambda}$ to the colour of $v_{\lambda}$ and the backtrack map of $(a,b)$ the image of the path under the map $\mathbf{\Omega}(v_{\lambda}) \rightarrow \mathbf{\Omega}(v_{\mu})$.

Ok, let’s define the Learner’s Mitchell-Benabou language.

We’ll view a learner $Py^P \rightarrow C y^{A \times B}$ as a set-valued representation $P$ of the directed graph $G$ with vertex set $P_{\lambda}$ placed at vertex $v_{\lambda}$.

A formula $\phi(p)$ of the language with a free variable $p$ is a morphism (of representations of $G$) from a learner $P$ to the subobject classifier
\[
\phi~:~P \rightarrow \mathbf{\Omega} \]
Such a morphism determines a sub-representation of $P$ which we can denote $\{ p | \phi(p) \}$ with vertex sets
\[
\{ p | \phi(p) \}_{\lambda} = \{ p \in P_{\lambda}~|~\phi(v_{\lambda})(p) = \mathbf{1}_{\lambda} \} \]

On formulas we can apply logical connectives to get more formulas. For example, the formula $\phi(p) \Rightarrow \psi(q)$ is the composition
\[
P \times Q \rightarrow^{\phi \times \psi} \mathbf{\Omega} \times \mathbf{\Omega} \rightarrow^{\Rightarrow} \mathbf{\Omega} \]

By quantifying all free variables we get a formula without free variables, and those correspond to morphisms $\mathbf{1} \rightarrow \mathbf{\Omega}$, that is, to sub-representations of the terminal object $\mathbf{1}$.

For example, if $\phi(p)$ is the formula with free variable $p$ corresponding to the morphism $\phi : P \rightarrow \mathbf{\Omega}$, then we have
\[
\forall p : \phi(p) = \{ v_{\lambda} \in V~|~\{ p | \phi(p) \}_{\lambda} = P_{\lambda} \} \]
and
\[
\exists p : \phi (p) = \{ v_{\lambda} \in V~|~\{ p | \phi(p) \}_{\lambda} \not= \emptyset \} \]

Sub-representations of $\mathbf{1}$ again form a Heyting-algebra in the obvious way, so we can assign a “truth-value” to a formula without free variables as that sub-object of $\mathbf{1}$.

There’s a lot more to say, so perhaps this will be continued.

Leave a Comment