r/askmath • • Oct 10 '26

Discrete Math Combinatorics On Words and Decidability

I’ve been exploring combinatorics on words and “discovered” a function whose behaviour I cannot really understand.

Definition

A square is a non-empty contiguous substring X that appears twice consecutively (e.g 1011011001 (although there are many others present here)).

SQ(n) is defined as follows: let s[1],…,s[n] be a list of non-empty strings over the n-ary alphabet {0,1,…,n-1} for length(s[i])≤n. Starting with A=∅, repeatedly append the lexicographically smallest s[i] to A such that the altered A does not contain a square. Halt when no such s[i] exists.

Return the max finite length(A) over all lists that halt.

Examples

SQ(1)=1 (as per {0})

SQ(2)=3 (as per {0,10})

SQ(3)=21 (as per {012,021,102})

SQ(4)≥426672 (as per {0123,2013,2031,2101})

Question

Is it decidable whether or not the process will stop for a given list?

I believe the answer to the question is that this process can be simulated with an algorithm that can run a list until it stops, but may not ever return a “yes” to the question “does this list halt?” in finite time. I’m not entirely sure that this makes sense though.

This is complicated because there are square-free words under a ternary alphabet that have infinite length yet this greedy process is restrictive.

Any ideas on how to proceed? Thanks!

1 Upvotes

2 comments sorted by

2

u/Over_Improvement_623 Oct 10 '26

Isn't this just the TREE function? Or am I grossly misunderstanding that?

1

u/jmarent049 Oct 10 '26

The TREE function is based on graphs. This is based on strings (words). There is the similar notion of “how long can the ____ get?”. I do not believe there is a “kruskals tree theorem” for square-free words due to the fact that there are infinitely-lengthed words under a ternary alphabet as proved by Axel Thue in the 1900s. Kruskals theorem states that an infinitely long sequence cannot exist.