Continuing Artem's answer, here is a proof of the general representation. As Artem shows, there is an integer matrix A and two vectors x,y such that
sL(n)=xTAny.
(The vector
x is the characteristic vector of the start state, the vector
y is the characteristic vector of all accepting state, and
Aij is equal to the number of transitions from state
i to state
j in a DFA for the language.)
Jordan's theorem states that over the complex numbers, A is similar to a matrix with blocks of one of the forms
(λ),(λ01λ),⎛⎝⎜λ001λ001λ⎞⎠⎟,⎛⎝⎜⎜⎜λ0001λ0001λ0001λ⎞⎠⎟⎟⎟,…
If
λ≠0, then the
nth powers of these blocks are
(λn),(λn0nλn−1λn),⎛⎝⎜λn00nλn−1λn0(n2)λn−2nλn−1λn⎞⎠⎟,⎛⎝⎜⎜⎜⎜λn000nλn−1λn00(n2)λn−2nλn−1λn0(n3)λn−3(n2)λn−2nλn−1λn⎞⎠⎟⎟⎟⎟,…
Here's how we got to these formulas: write the block as
B=λ+N. Successive powers of
N are successive secondary diagonals of the matrix. Using the binomial theorem (using the fact that
λ commutes with
N),
Bn=(λ+n)N=λn+nλn−1N+(n2)λn−2N2+⋯.
When
λ=0, the block is nilpotent, and we get the following matrices (the notation
[n=k] is
1 if
n=k and
0 otherwise):
([n=0]),([n=0]0[n=1][n=0]),⎛⎝⎜[n=0]00[n=1][n=0]0[n=2][n=1][n=0]⎞⎠⎟,⎛⎝⎜⎜⎜⎜[n=0]000[n=1][n=0]00[n=2][n=1][n=0]0[n=3][n=2][n=1][n=0]⎞⎠⎟⎟⎟⎟
Summarizing, every entry in An is either of the form (nk)λn−k or of the form [n=k], and we deduce that
sL(n)=∑ipi(n)λi(n)+∑jcj[n=j],
for some complex
λi,cj and complex polynomials
pi. In particular, for large enough
n,
sL(n)=∑ipi(n)λi(n).