Let $A,B$ be nonempty strings over some finite alphabet and let $\cdot$ denote the concatenation operator. Let $s^{k}$ denote the string $s \cdot s \cdot s ... \cdot s$ concatenated itself exactly $k$ times.
If it is known that $A \cdot B = B \cdot A$, then show that there is a nonempty string $s$ such that $A = s^{k}$,$B = s^{j}$ for some positive integers $k,j$.
I believe the statement is true. In particular, I'm pretty sure the first $d = gcd(a,b)$ characters of $A$ must match that of $B$ and that it divides both strings evenly, but I'm not sure how to prove this hunch.
Let’s make all strings $0$-indexed for convenience.
Denote the length of $A$ and $B$ to be $a$ and $b$, respectively.
Denote $C = A \cdot B$. Then its length, denoted $n$, equals $a + b$.
From $A \cdot B = B \cdot A$ we can obtain, $C = \operatorname{rot}_b(C)$ where $\operatorname{rot}_k$ means a circular shift by $k$ to the right.
That is, $C_i = C_{(i + b) \bmod n}$ for all $i \in [0, n)$. Manipulate this relation to form equivalence classes, invoking results in number theory, we obtain $C_i = C_{i \bmod \gcd(b, n)}$ and hence the prefix of length $\gcd(b, n)$ is a repetend. Of course, $\gcd(b, n) = \gcd(a, b)$.