Sequences
Linear Order
In a sequence, each element directly follows at most one element and precedes at most one other, forming a linear chain. We can visualise this through nodes of directed graphs that are connected using directed edges that represent the linear order between consecutive elements.
The English word “sequence” (which is an ordered sequence of the eight consecutive elements s, e, q, u, e, n, c, e), for example, can be visualised using a directed graph:
Full sentences can also be seen as sequences of ordered symbols. As an example, we have the sentence “This is a visualisation of linear order”. Spaces are also considered elements of the sequence, but we slightly reduce the opacity of their nodes for readability:
We can drop the node labels to visualise the same sentence as:
Order in sequences matters, and these sequences are not restricted to written language. Other examples include sequences of actions (e.g., the sequence of actions that you perform to pour yourself a cup of coffee, as you can’t brew coffee before turning on the machine) or music (e.g., the consecutive notes that make up a specific melody, as swapping the notes around gives us another melody).
Hierarchically Nested Matchings
Many structures also have a natural hierarchical organisation (e.g., we can group words into sentences, paragraphs, sections, and so on). For this reason, we also want a way to describe and visualise hierarchical structure.
This is the visualisation of the linear order in the sequence “nested word”:
We know that the sequence “nested word” can naturally be split into two contiguous subsequences: “nested” and “word”. If we add symbols “⟨” and “⟩” that respectively denote the start and end of a word, we get the following:
We name the “start of a word” a call position and “the end of that same word” its matching return position. All other elements are internal positions. These matches give rise to different nestings.
We represent call and return positions using differently-coloured nodes, and represent matches using dashed directed edges from nodes representing call positions to nodes representing matching return positions:
Nested Words
More formally, a nested word1 is a sequence of elements $w = s_{1} \ldots s_{\ell}$ together with a matching relation, which is a set of matches $i \rightsquigarrow j$ that connect call positions $i$ to their return positions $j$.
For all matches $i \rightsquigarrow j$:
- Nestings only go forward: $i < j$
- No two nestings share positions: $|\{ i \mid i \rightsquigarrow j \}| \leq 1$ and $|\{ j \mid i \rightsquigarrow j \}| \leq 1$
- No two nestings cross: if $i \rightsquigarrow j$ and $i’ \rightsquigarrow j’$, we cannot have $i < i’ < j < j'$
Visualising Nestings
If we visualise “this is a visualisation of linear order”, we get:
Trying out different graph layouts, we get:
Visualising the palindromic phrase2 “⟨⟨⟨Lived⟩ ⟨on⟩ ⟨decaf⟩;⟩ ⟨⟨faced⟩ ⟨no⟩ ⟨devil⟩.⟩⟩”, for example, gives us some nice symmetries (as we have two groups, each with three words, that each respectively have five, two, and five elements):
Nested Substitution Rules
Reading through Stephen Wolfram’s ruliology, I wondered what kind of nested structures we could obtain using simple substitution rules (like repeatedly changing internal positions labelled a with a nesting ⟨aaa⟩).
Example #1
Initial Condition
a
Replacement Rule
a → ⟨aaa⟩
Looping Visualisation (6 steps)
Example #2
Initial Condition
ab
Replacement Rule
a → bb
b → ⟨aa⟩
Looping Visualisation (9 steps)
Visualising this post
Finally, we can apply nested word visualisation to this post itself by treating the post’s structure as a nested word: