Académique Documents
Professionnel Documents
Culture Documents
r
X
i
v
:
0
7
0
8
.
3
2
2
4
v
1
[
c
s
.
D
M
]
2
3
A
u
g
2
0
0
7
The Frobenius Problem in a Free Monoid
Jui-Yi Kao, Jerey Shallit, and Zhi Xu
School of Computer Science
University of Waterloo
Waterloo, Ontario N2L 3G1
CANADA
Eric.Kao@tdsecurities.com
shallit@graceland.uwaterloo.ca
z5xu@cs.uwaterloo.ca
February 1, 2008
Abstract
The classical Frobenius problem is to compute the largest number g not repre-
sentable as a non-negative integer linear combination of non-negative integers x
1
, x
2
, . . . , x
k
,
where gcd(x
1
, x
2
, . . . , x
k
) = 1. In this paper we consider generalizations of the Frobe-
nius problem to the noncommutative setting of a free monoid. Unlike the commutative
case, where the bound on g is quadratic, we are able to show exponential or subexpo-
nential behavior for an analogue of g, depending on the particular measure chosen.
1 Introduction
Let x
1
, x
2
, . . . , x
k
be positive integers. It is well-known that every suciently large inte-
ger can be written as a non-negative integer linear combination of the x
i
if and only if
gcd(x
1
, x
2
, . . . , x
k
) = 1.
The Frobenius problem (so-called because, according to Brauer [2], Frobenius mentioned
it occasionally in his lectures) is the following:
Given positive integers x
1
, x
2
, . . . , x
k
with gcd(x
1
, x
2
, . . . , x
k
) = 1, nd the largest pos-
itive integer g(x
1
, x
2
, . . . , x
k
) which cannot be represented as a non-negative integer linear
combination of the x
i
.
Example 1. The Chicken McNuggets Problem ([29, pp. 19-20, 233234], [22]). If Chicken
McNuggets can be purchased at McDonalds only in quantities of 6, 9, or 20 pieces, what is
the largest number of McNuggets that cannot be purchased? The answer is g(6, 9, 20) = 43.
1
Although it seems simple at rst glance, the Frobenius problem on positive integers has
many subtle and intriguing aspects that continue to elicit study. A recent book by Ramrez
Alfonsn [24] lists over 400 references on this problem. Applications to many dierent elds
exist: to algebra [19]; the theory of matrices [11], counting points in polytopes [1]; the
problem of ecient sorting using Shellsort [16, 25, 30, 26]; the theory of Petri nets [28]; the
liveness of weighted circuits [8]; etc.
Generally speaking, research on the Frobenius problem can be classied into three dif-
ferent areas:
Formulas or algorithms for the exact computation of g(x
1
, . . . , x
k
), including formulas
for g where the x
i
obey certain relations, such as being in arithmetic progression;
The computational complexity of the problem;
Good upper or lower bounds on g(x
1
, . . . , x
k
).
For k = 2, it is folklore that
g(x
1
, x
2
) = x
1
x
2
x
1
x
2
; (1)
this formula is often attributed to Sylvester [27], although he did not actually state it. Eq. (1)
gives an ecient algorithm to compute g for two elements. For k = 3, ecient algorithms
have been given by Greenberg [14] and Davison [10]; if x
1
< x
2
< x
3
, these algorithms run in
time bounded by a polynomial in log x
3
. Kannan [17, 18] gave a very complicated algorithm
that runs in polynomial time in log x
k
if k is xed, but is wildly exponential in k. However,
Ramrez Alfonsn [23] proved that the general problem is NP-hard, under Turing reductions,
by reducing from the integer knapsack problem. So it seems very likely that there is no
simple formula for computing g(x
1
, x
2
, . . . , x
k
) for arbitrary k. Nevertheless, recent work
by Einstein, Lichtblau, Strzebonski, and Wagon [12] shows that in practice the Frobenius
number can be computed relatively eciently, even for very large numbers, at least for k 8.
Another active area of interest is estimating how big g is in terms of x
1
, x
2
, . . . , x
k
for
x
1
< x
2
< < x
k
. It is known, for example, that g(x
1
, x
2
, . . . , x
k
) < x
2
k
. This follows from
Wilfs algorithm [31]. Many other bounds are known.
One can also study variations on the Frobenius problem. For example, given positive
integers x
1
, x
2
, . . . , x
k
with gcd(x
1
, x
2
, . . . , x
k
) = 1, what is the number f(x
1
, x
2
, . . . , x
k
) of
positive integers not represented as a non-negative integer linear combination of the x
i
?
Sylvester, in an 1884 paper [27], showed that f(x
1
, x
2
) =
1
2
(x
1
1)(x
2
1).
Our goal in this paper is to generalize the Frobenius problem to the setting of a free
monoid. In this framework, we start with a nite, nonempty alphabet , and consider the
set of all nite words
and x
1
x
2
x
k
. Actually, we consider several additional
generalizations, which vary according to how we measure the size of the input, conditions on
the input, and measures of the size of the result. For an application of the noncommutative
Frobenius problem, see Clement, Duval, Guaiana, Perrin, and Rindone [9].
2
In order to motivate our denitions, we consider the easiest case rst: where = {0}, a
unary alphabet.
2 The unary case
Suppose x
i
= 0
a
i
, for 1 i k. The Frobenius problem is evidently linked to many
problems over unary languages. It gures, for example, in estimating the size of the smallest
DFA equivalent to a given NFA [7].
If L
, by L we mean
is
co-nite if and only gcd(a
1
, a
2
, . . . , a
k
) = 1. Furthermore, if S
is g(a
1
, a
2
, . . . , a
k
), and | S
| = f(a
1
, a
2
, . . . , a
k
).
This result suggests that one appropriate noncommutative generalization of the condi-
tion gcd(a
1
, a
2
, . . . , a
k
) = 1 is that S
= {x
1
, x
2
, . . . , x
k
}
.
But there are other possible generalizations. Instead of measuring the length of the
longest omitted word, we could instead consider the state complexity of S
. By the state
complexity of a regular language L, written sc(L), we mean the number of states in the
(unique) minimal deterministic nite automaton (DFA) accepting L. In the unary case, this
alternate measure has a nice expression in terms of the ordinary Frobenius function:
Theorem 3. Let gcd(a
1
, a
2
, . . . , a
k
) = 1. Then
sc({0
a
1
, 0
a
2
, . . . , 0
a
k
}
) = g(a
1
, a
2
, . . . , a
k
) + 2.
Proof. Since gcd(a
1
, a
2
, . . . , a
k
) = 1, every word of length > g(a
1
, a
2
, . . . , a
k
) will be in
the set {0
a
1
, 0
a
2
, . . . , 0
a
k
}
) g(a
1
, a
2
, . . . , a
k
) + 2.
To see sc({0
a
1
, 0
a
2
, . . . , 0
a
k
}
) g(a
1
, a
2
, . . . , a
k
) + 2, we show that the words
, 0, 0
2
, . . . , 0
g(a
1
,...,a
k
)+1
are pairwise inequivalent under the Myhill-Nerode equivalence relation. Pick 0
i
and 0
j
,
0 i < j g(a
1
, . . . , a
k
) + 1. Let L = {0
a
1
, 0
a
2
, . . . , 0
a
k
}
. Choose z = 0
g(a
1
,...,a
k
)i
. Then
0
i
z = 0
g(a
1
,...,a
k
)
L, while 0
j
z = 0
g(a
1
,...,a
k
)+ji
L, since j > i.
Corollary 4. Let gcd(a
1
, . . . , a
k
) = d. Then
sc({0
a
1
, 0
a
2
, . . . , 0
a
k
}
) = d(g(a
1
/d, a
2
/d, . . . , a
k
/d) + 1) + 1.
Hence it follows that sc({0
a
1
, 0
a
2
, . . . , 0
a
k
}
) = O(a
2
k
). Furthermore, this bound is essen-
tially optimal; since g(n, n+1) = n
2
n1, there exist examples with sc({0
a
1
, 0
a
2
, . . . , 0
a
k
}
) =
(a
2
k
).
3
3 The case of larger alphabets
We now turn to the main results of the paper. Given as input a list of words x
1
, x
2
, . . . , x
k
,
not necessarily distinct, and dening S = {x
1
, x
2
, . . . , x
k
, we can measure the size of the
input in a number of dierent ways:
(a) k, the number of words;
(b) n = max
1ik
|x
i
|, the length of the longest word;
(c) m =
1ik
|x
i
|, the total number of symbols;
(d) sc({x
1
, x
2
, . . . , x
k
}), the state complexity of the language represented by the input.
(e) nsc({x
1
, x
2
, . . . , x
k
}), the nondeterministic state complexity of the language represented
by the input.
We may impose various conditions on the input:
(i) Each x
i
is dened over the unary alphabet;
(ii) S
= {x
1
, x
2
, . . . , x
k
}
is co-nite
(iii) k = 2;
(iv) k is xed.
And nally, we can explore various measures on the size of the result:
1. L = max
x
S
|x|, the length of the longest word not in S
;
2. K = max
x
1
x
2
x
k
|x|, the length of the longest word not in x
1
x
2
x
k
;
3. S = sc(S
;
4. N = nsc(S
;
5. M = |
;
6. S
= sc(x
1
x
2
x
k
);
7. N
= nsc(x
1
x
2
x
k
)
Clearly not every combination results in a sensible question to study. In order to study
L, the length of the longest word omitted by S
be co-nite.
We now study under what conditions it makes sense to study K = max
x
1
x
2
x
k
|x|,
the length of the longest word not in x
1
x
2
x
k
.
4
Theorem 5. Let x
1
, x
2
, . . . , x
k
+
. Then L = x
1
x
2
x
k
is co-nite if and only if || = 1
and gcd(|x
1
|, . . . , |x
k
|) = 1.
Proof. If || = 1 and gcd(|x
1
|, . . . , |x
k
|) = 1, then a unary word of every suciently long
length can be attained by concatenations of the x
i
, so L is co-nite.
For the other direction, suppose L is co-nite. If || = 1, let gcd(|x
1
|, . . . , |x
k
|) = d. If
d > 1, L contains only words of length divisible by d, and so is not-conite. So d = 1.
Hence assume || 2, and let a, b be distinct letters in . Let l = max
1ik
|x
i
|, the
length of the longest word. Let L
= ((a
2l
b
2l
)
k
)
+
. Then we claim that L
L = . For
if none of the x
i
consist of powers of a single letter, then the longest block of consecutive
identical letters in any word in L is < 2l, so no word in L
. Thus L is not
co-nite, as it omits all the words in L
.
4 State complexity results
In this section we study the measures S = sc(S
), N = nsc(S
), and S
= sc(x
1
x
2
x
k
).
consider some results on state complexity. First we review previous results.
Yu, Zhuang, and Salomaa [32] showed that if L is accepted by a DFA with n states, then
L
needs 2
n1
+ 2
n2
states. This latter result
was given previously by Maslov [21].
Campeanu, Culik, Salomaa, and Yu [3, 5] showed that if a DFA with n states accepts
a nite language L, then L
) mk + 1.
(b) sc({x
1
, x
2
, . . . , x
k
}
) 2
mk+1
.
5
(c) If no x
i
is a prex of any other x
j
, then sc({x
1
, x
2
, . . . , x
k
}
) mk + 2.
Proof. (a) Form an NFA from the trie for the words x
1
, . . . , x
k
, sharing a common initial
state q
0
, and having the transition on the last letter of each word go back to q
0
. This
NFA will have mk + 1 nodes.
(b) Take the NFA from part (a) and apply the subset construction.
(c) If no x
i
is a prex of any other x
j
, then the NFA constructed in part (a) is actually a
DFA. One extra state is needed as a dead state.
We now consider an example providing a lower bound for the state complexity of {x
1
, x
2
, . . . , x
k
}
.
Let t be an integer 2, and dene words as follows:
y := 01
t1
0
x
i
:= 1
ti1
01
i+1
, 0 i t 2 .
Let S
t
:= {0, x
0
, x
1
, . . . , x
t2
, y}.
Thus, for example,
S
6
:= {0, 1111101, 1111011, 1110111, 1101111, 1011111, 0111110}.
Theorem 7. S
t
has state complexity 3t2
t2
+ 2
t1
.
The proof of this theorem is rather complicated, so we give a proof of the following
slightly weaker result:
Theorem 8. sc(S
t
) 2
t2
.
Proof. First, we create an NFA M
t
with 3t 1 states that accepts S
t
. This NFA has states
Q = {p
0
, p
1
, . . . , p
t
, q
1
, q
2
, . . . , q
t1
, r
1
, r
2
, . . . , r
t1
}
with only one nal state F = {p
0
}.
For example, here is the NFA M
6
.
6
1
0 0 0
1 1 1
1
1
0
0 0
1 1 1
1
1
1 0 1
0
r
5
r
4 r
3
r
2
r
1
q
5
q
4 q
3
q
2
q
1
p
6
p
5
p
4
p
3
p
2
p
1
p
0
1 1
Figure 1: The NFA M
6
We now determine (q, z) for each state q of M
t
and each element of z S
t
. The reader
can verify that
(p
0
, y) = {r
t1
, p
0
}
(p
0
, x
i
) = {p
0
}, 1 i t 2
(p
i
, x
j
) =
_
q
i
, if j = i 1;
, otherwise.
(p
t
, y) = {r
t1
}
(q
1
, y) = {p
0
, p
1
}
(q
i
, y) = {r
i1
}, 2 i t 1
(q
i
, x
j
) =
_
q
i
, if j i;
, otherwise.
for 1 i t 1, 0 j t 2
(r
i
, y) = , 1 i t 1
(r
i
, x
j
) =
_
_
{q
i
, p
j+1
}, if j = i 1;
{r
i
}, if j < i 1;
, otherwise.
for 1 i t 1, 0 j t 2
From these relations, we deduce that
7
({q
i
, q
i+1
, . . . , q
t1
, p
t
, p
0
}, y) = {r
i1
, r
i
, . . . , r
t1
, p
0
}
({r
i+1
, r
i+2
, . . . , r
t1
, p
0
}, x
i
) = {q
i+1
, p
i+2
, r
i+2
, r
i+3
, . . . , r
t1
, p
0
}
({q
i
, q
i+1
, . . . , q
j
, p
j+1
, r
j+1
, r
j+2
, . . . , r
t1
, p
0
}, x
j
) = {q
i
, q
i+1
, . . . , q
j+1
, p
j+2
, r
j+2
, r
j+3
, . . . , r
t1
, p
0
},
if i j t 3
({q
i
, q
i+1
, . . . , q
t2
, p
t1
, r
t1
, p
0
}, x
j
) = {q
i
, q
i+1
, . . . , q
t1
, p
t
, r
t1
, p
0
}
Let T be any subset of {r
1
, r
2
, . . . , r
t2
}, and write T = {r
i
1
, r
i
2
, . . . , r
i
j
} for j indices
1 i
1
< i
2
< < i
j
t 2.
We claim that the 2
t2
words
y x
t2
y x
t3
x
t2
y x
t4
x
t3
x
t2
y x
1
x
2
x
t2
y x
i
1
x
i
2
x
i
j
y
where
1 i
1
< i
2
< < i
j
t 2,
are pairwise inequivalent under the Myhill-Nerode equivalence relation.
To show this, we rst argue that any subset of states of the form T
:= {p
0
, r
t1
} T,
where T is as in the previous paragraph, is reachable from p
0
. From the relations above we
see that the following path reaches T
:
{p
0
}
y
{p
0
, r
t1
}
x
t2
{q
t1
, p
t
, p
0
}
y
{r
t2
, r
t1
, p
0
}
x
t3
{q
t2
, p
t1
, r
t1
, p
0
}
x
t2
{q
t2
, q
t1
, p
t
, p
0
}
y
{r
t3
, r
t2
, r
t1
, p
0
}
x
t4
{q
t3
, p
t2
, r
t2
, r
t1
, p
0
}
x
t3
{q
t3
, q
t2
, p
t1
, r
t1
, p
0
}
x
t2
{q
t3
, q
t2
, q
t1
, p
t
, p
0
}
y
{r
t4
, r
t3
, r
t2
, r
t1
, p
0
}
x
1
x
2
x
t2
y
{p
0
, r
1
, r
2
, . . . , r
t1
}
x
i
1
x
i
2
x
i
j
y
{r
i
1
, r
i
2
, . . . , r
i
j
, r
t1
, p
0
}.
Finally, we argue that each of these subsets of states is inequivalent. This is because
given two distinct such subsets, say T
and T
, there must be an r
i
, 1 i t 2, that is
contained in one (say T
to p
0
, but
not T
.
Corollary 9. There exists a family of sets S
t
, each consisting of t + 1 words of length
t + 1, such that sc(S
t
) = 2
(t)
. If m is the total number of symbols in these words, then
sc(S
t
) = 2
(
m
.
8
Using the ideas in the previous proof, we can also create an example achieving subexpo-
nential state complexity for x
1
x
2
x
k
.
Theorem 10. As before, dene
y := 01
t1
0
x
i
:= 1
ti1
01
i+1
, 0 i t 2 .
Let L = (0
1
x
2
x
n1
y
)
e
where e = (t + 1)(t 2)/2 + 2t. Then sc(L) 2
t2
.
Proof. Dene A = {x
0
, x
1
, . . . , x
t2
, y, 0} and T = {x
1
, x
2
, . . . , x
t2
}. For any subset S of T,
say {s
1
, s
2
, . . . , s
j
} with s
1
< s
2
< s
j
dene
x(S) = yx
t2
yx
t3
x
t2
y yx
1
x
2
x
t2
yx
s
1
x
s
2
x
s
j
y.
Note that x(S) contains t copies of y and at most (t 2)(t 1)/2 + t 2 = (t + 1)(t 2)/2
xs. Thus |x(S)| (t + 1)(t + (t + 1)(t 2)/2) and |x(S)|
0
2t + (t + 1)(t 2)/2.
To get the bound sc(L) 2
t2
, we exhibit 2
t2
pairwise distinct word under the Myhill-
Nerode equivalence relation. Pick two distinct subsets of T, say R and S. Since R = S,
there exists an element in one not contained in the other. Without loss of generality, let
m R, m S. By the proof of Theorem 8 we have x(R)1
tm
A
but x(S)1
tm
A
.
Since L A
, x(S)1
tm
L. It remains to see x(R)1
tm
L.
Since x(R)1
tm
A
1
x
k
) = 2
(t)
.
We now turn to an upper bound on the state complexity of S
)
2
2||1
(2
n
||
n
1).
Proof. The idea is to create a DFA M = (Q, , , q
0
, F) that records the last n 1 symbols
seen, together with the set of the possible positions inside those n 1 symbols where the
factorization of the input into elements of S could end.
Our set of states Q is dened by {[w, T] : |w| < n, S {0, 1, . . . , |w|}. The intent is
that the DFA reaches state [x, T] on input y = y
1
y
2
y
i
if and only if |x| = max(n 1, i),
x is a sux of y, and
T = {a : 0 a x and y
1
y
2
y
na
S
}.
The initial state is [, {0}] and the set of nal states is {[x, T] : 0 T}.
To maintain the invariant, we dene our transition function as follows:
If |x| < n 1, then ([x, T], a) = [xa, U] where
U =
_
(T + 1) {0}, if a sux of length i + 1 of xa is in S for some i T;
(T + 1), otherwise.
If |x| = n 1, then ([bx, T], a) = [xa, U] where
U =
_
((T + 1) {n}) {0}, if a sux of length i + 1 of bxa is in S for some i T;
(T + 1) {n}, otherwise.
Verication that the construction works is left to the reader. The number of states is
0i<n
||
i
2
i+1
=
2
2||1
(2
n
||
n
1).
5 State complexity for two words
In this section we develop formulas bounding the state complexity of {w, x}
and w
.
Here, as usual, g(x
1
, x
2
) denotes the Frobenius function introduced in Section 1.
We need the following lemma, which is of independent interest and which generalizes a
classical theorem of Fine and Wilf [13].
Lemma 13. Let w and x be nonempty words. Let y w{w, x}
and z x{w, x}
. Then
the following conditions are equivalent:
(a) y and z agree on a prex of length |w| +|x| gcd(|w|, |x|);
(b) wx = xw;
(c) y = z.
Furthermore, the bound in (a) is optimal, in the sense that for all pairs of lengths (m, n)
there exists a pair of words (|w|, |x|) such that w
and x
= z.
(c) = (a): Trivial.
For the optimality statement, the words constructed in the paper [6] suce.
Theorem 14. Let w, x
+
. Then
sc({w, x}
) =
_
|w| +|x|, if wx = xw;
d(g(|w|/d, |x|/d) + 1) + 2, if wx = xw and d = gcd(|w|, |x|) .
Furthermore, this bound is tight.
Proof. If wx = xw, then by a classical theorem of Lyndon and Sch utzenberger [20], we know
there exists a word z and integers i, j 1 such that w = z
i
, x = z
j
. Thus {w, x}
= {z
i
, z
j
}
.
Let e = gcd(i, j). Then L = {z
i
, z
j
}
and x = pbx
| +|x
| + 1 |w| +|x|.
11
Finally, suppose |w| |x| and w is a prex of x. We claim it suces to bound the longest
common prex between any word of w{w, x}
and x{w, x}
) =
_
|w| + 2|x|, if wx = wx;
d(g(|w|/d, |x|/d) + 1) + 2, if wx = xw and d = gcd(|w|, |x|) .
Proof. Similar to the proof of the previous theorem. Omitted.
6 Longest word omitted
In this section we assume that S = {x
1
, x
2
, . . . , x
k
} for nite words x
1
, x
2
, . . . , x
k
, and S
is
co-nite. We rst obtain an upper bound on the length of the longest word not in S
.
Theorem 16. Suppose |x
i
| n for all i. Then if S
is <
2
2||1
(2
n
||
n
1).
Proof. Given S, construct the DFA accepting S
can be
exponentially long in n. We need several preliminary results rst.
We say that x is a proper prex of a word y if y = xz for a nonempty word z. Similarly,
we say x is a proper sux of y if y = zx for a nonempty word z.
Proposition 17. Let S be a nite set of nonempty words such that S
is co-nite, and
S
, or vice
versa.
Proof. Let x S. Since S
, there exists v S
. Since S
is co-nite, S
x v is
nonempty. Let i 0 be the smallest integer such that x
i
v S
. Since x
i
v S
, there exist y
1
, y
2
, . . . , y
j
S such that x
i
v = y
1
y
2
. . . y
j
. Now y
1
= x,
for otherwise by cancelling an x from both sides, we would have x
i1
v S
, contradicting
the minimality of i. If |x| < |y
1
|, then x is a proper prex of y
1
, while if |x| > |y
1
|, then y
1
is a proper prex of x.
A similar argument applies for the result about suxes.
12
Next, we give two lemmas that characterize those sets S such that S
is co-nite, when
S is a set S containing words of no more than two distinct lengths.
Lemma 18. Suppose S
m
n
, 0 < m < n, and S
is co-nite. Then
m
S.
Proof. If S
would
omit x. So assume S
.
Let x
m
. Then S
is nonempty, since S
is co-nite. Then
l
S
, where l = m||
nm
+ n m.
Proof. Let x be a word of length l that is not in S
i+1k||
nm
z
k
y
k
_
_
.
Note that |y
j
z
j
| = |z
k
y
k
| = m. From Lemma 18, each term in this factorization is in S.
Hence x S
.
Now let uv
k
w = x
1
x
2
x
j
be a factorization into elements of S. Then x
1
is a word of
length m or n. If |x
1
| = n, then comparing lengths gives x
1
= y
0
z
0
y
1
. But by (3) we know
y
0
z
1
y
1
S. So |x
1
| = m, and comparing lengths gives x
1
= y
0
z
0
. By similar reasoning we see
that x
2
= y
1
z
1
, and so on. Hence x
j
= y
||
nm
1
z
||
nm
1
y
||
nm S. But this contradicts
(3).
Thus, our assumption that x S
is co-nite. Then
S
is g(m, l) = ml m l, where
l = m||
nm
+ n m.
Proof. Any word in S
is not
co-nite, contrary to the hypothesis. Thus gcd(m, n) = 1. Then S
.
By Lemmas 18 and 19, we have
m
l
S
, where l = m||
nm
+ n m. Hence
S
is co-nite i
m
S and
l
S
, where l = m||
nm
+ n m.
Proof. If S
. On the
other hand, if
m
S and
l
S
, so S
is co-nite.
We need one more technical lemma.
Lemma 22. Suppose S
m
n
, where 0 < m < n < 2m, and S
is co-nite. Let
be a word not in S
(
m
)
i1
= for
1 i < m.
Proof. As before, since S
L
i
= by induction on i.
The base case is i = 1. Then L
i
= L
1
= {}. But S
.
Now suppose we have proved the result for some i, i m 2, and we want to prove it
for i + 1. First we show that S
nm
L
i
= . Assume that uw S
for some u
nm
and w L
i
. Then there is a factorization
uw = y
1
y
2
y
t
(4)
where y
h
S for 1 h t. Now |uw| = n m + (n + jm + m)(i 1) + n + jm =
n(i + 1) + m(ji + i 2). Since 0 < i + 1 < m, m does not divide |uw|. Thus at least one of
14
the y
h
is of length n, for otherwise (4) could not be a factorization of uw into elements of S.
Let r be the smallest index such that |y
r
| = n. Then we have
uw =
all of length m
..
y
1
y
2
y
r1
of length n
..
y
r
y
r+1
y
t
.
Hence |y
1
y
2
y
r
| = m(r 1) +n = mr +n m. Since, by Lemma 18 we have
m
S, we
can write y
1
y
r
= uz
1
z
r
, where z
h
S for 1 h r. Thus
uw = y
1
y
r1
y
r
y
r+1
y
t
= uz
1
z
r
y
r+1
y
t
;
and, cancelling the u on both sides, we get w = z
1
z
r
y
r+1
y
t
. But each term on the
right is in S, so w S
L
i
= .
So now we know that
S
nm
L
i
= ; (5)
well use this fact below.
Now assume that S
L
i+1
= . Sincej L
i+1
=
m
L
i
, there exists
m
and w L
i
such that w S
. Write w = g
1
g
2
g
p
, where g
h
S for 1 h p. We claim that
g
h
m
for 1 h j + 1. For if not, let k be the smallest index such that |g
k
| = n. Then
by comparing lengths, we have
each of length m
..
g
1
g
2
g
k1
of length n
..
g
k
each of length m
..
g
1
g
2
g
jk+1
for some g
1
, g
2
, . . . , g
jk+1
m
. But this shows S
, a contradiction.
Now either g
j+2
m
or g
j+2
n
. In the former case, by comparing lengths, we see
that g
j+3
g
p
nm
L
i
. But this contradicts (5). In the latter case, by comparing lengths,
we see g
j+3
g
p
L
i
, contradicting our inductive hypothesis. Thus our assumption that
S
L
i+1
= was wrong, and the lemma is proved.
Now we are ready to give a class of examples achieving the bound in Theorem 20. We
dene r(n, k, l) to be the word of length l representing n in base k, possibly with leading
zeros. For example, r(11, 2, 5) = 01011. For integers 0 < m < n, we dene
T(m, n) = {r(i, ||, n m)0
2mn
r(i + 1, ||, n m) : 0 i ||
nm
2}.
For example, over a binary alphabet we have T(3, 5) = {00001, 01010, 10011}.
Theorem 23. Let m, n be integers with 0 < m < n < 2m and gcd(m, n) = 1, and let
S =
m
n
T(m, n). Then S
are of length
g(m, l), where l = m||
nm
+ n m.
15
Proof. First, lets prove that S
is co-nite. Since
m
S, by Corollary 21 it suces to
show that
l
S
, where l = m||
nm
+ n m.
Let x
l
, and write
x = y
0
z
0
y
1
z
1
y
||
nm
1
z
||
nm
1
y
||
nm
where y
i
nm
for 0 i ||
nm
, and z
i
2mn
for 0 i < ||
nm
.
If y
i
z
i
y
i+1
T(m, n) for all i, 0 i < ||
nm
, then since the base-k expansions are forced
to match up, we have y
i
= r(i, ||, n m) for 0 i < ||
nm
. But the longest such word is
of length m||
nm
+ n 2m < l, a contradiction. Hence y
i
z
i
y
i+1
S for some i. Thus
x =
_
0j<i
y
j
z
j
_
y
i
z
i
y
i+1
_
_
i+1k||
nm
z
k
y
k
_
_
.
Note that |y
j
z
j
| = |z
k
y
k
| = m. Since
m
S, this gives a factorization of x S
. Since x
was arbitrary, we have
l
S
.
Now we will prove that S
, where
:= r(0, ||, n m)0
2mn
r(1, ||, n m)0
2mn
r(||
nm
1, ||, n m).
Note that || = ||
nm
(n m) + (||
nm
1)(2m n) = m||
nm
+ n 2m = l m.
Suppose there exists a factorization = w
1
w
2
w
t
, where w
i
S for 1 i t. Since
|| is not divisible by m, at least one of these terms is of length n. Let k be the smallest
index such that w
k
n
. then = w
1
w
k1
w
k
w
k+1
w
t
. By comparing lengths, we get
w
i
= r(i 1, ||, nm)0
2mn
for 1 i < k. Thus w
k
= r(k 1, ||, nm)0
2mn
r(k, ||, n
m) S
n
. But r(k 1, ||, n m)0
2mn
r(k, ||, n m) T(m, n), a contradiction.
Thus S
.
We may now apply Lemma 22 to get that S
is of length (n
2
2
n/2
).
Proof. Choose m = (n + 1)/2 and apply Theorem 23.
Example 25. Let m = 3, n = 5, = {0, 1}. Then S =
3
+
5
{00001, 01010, 10011}.
Then a longest word not in S
,
and replacing the condition gcd(x
1
, . . . , x
k
) = 1 with the requirement that {x
1
, . . . , x
k
}
be
co-nite.
We have already studied this in the case of a unary alphabet in Section 2, so let us assume
that has at least two letters.
Theorem 26. Let x
1
, x
2
, . . . , x
k
be such that |x
i
| n for 1 i n. Let S =
{x
1
, x
2
, . . . , x
k
} and suppose S
is co-nite. Then
M = |
|
||
q
1
|| 1
,
where q =
2
2||1
(2
n
||
n
1).
Proof. From Theorem 16, we know that if S
is
co-nite and S
omits at least 2
||
nm
||
nm
1 words.
Proof. Similar to that of Theorem 23.
8 Conclusion
We have generalized the classical Frobenius problem on integers to the noncommutative
setting of a free monoid. Many problems remain, including improving the upper and lower
bounds presented here, and examining the computational complexity of the associated deci-
sion problems. We will examine these problems in a future paper.
References
[1] M. Beck, R. Diaz, and S. Robins. The Frobenius problem, rational polytopes, and
Fourier-Dedekind sums. J. Number Theory 96 (2002), 121.
[2] A. Brauer. On a problem of partitions. Amer. J. Math. 64 (1942), 299312.
[3] C. Campeanu, K. Culik II, K. Salomaa, and S. Yu. State complexity of basic opera-
tions on nite languages. In Automata Implementation: 4th International Workshop on
Implementing Automata, WIA99, Vol. 2214 of Lecture Notes in Computer Science, pp.
6070, 2001.
17
[4] C. Campeanu and W. H. Ho. The maximum state complexity for nite languages. J.
Automata, Languages, and Combinatorics 9 (2004), 189202.
[5] C. Campeanu, K. Salomaa, and S. Yu. State complexity of regular languages: nite ver-
sus innite. In C. S. Calude and G. Paun, editors, Finite Versus Innite: Contributions
to an Eternal Dilemma, pp. 5373. Springer-Verlag, 2000.
[6] S. Cautis, F. Mignosi, J. Shallit, M.-w. Wang, and S. Yazdani. Periodicity, morphisms,
and matrices. Theoret. Comput. Sci. 295 (2003), 107121.
[7] M. Chrobak. Finite automata and unary languages. Theoret. Comput. Sci. 47 (1986),
149158. Errata, 302 (2003), 497498.
[8] P. Chrzastowski-Wachtel and M. Raczunas. Liveness of weighted circuits and the Dio-
phantine problem of Frobenius. In Z.
Esik, editor, Fundamentals of Computation The-
ory, 9th International Conference, FCT 93, Vol. 710 of Lecture Notes in Computer
Science, pp. 171180. Springer-Verlag, 1993.
[9] J. Clement, J.-P. Duval, G. Guaina, D. Perrin, and G. Rindone. Parsing with a nite
dictioanry. Theoret. Comput. Sci. 340 (2005), 432442.
[10] J. L. Davison. On the linear diophantine problem of Frobenius. J. Number Theory 48
(1994), 353363.
[11] A. L. Dulmage and N. S. Mendelsohn. Gaps in the exponent set of primitive matrices.
Illinois J. Math. 8 (1964), 642656.
[12] D. Einstein, D. Lichtblau, A. Strzebonski, and S. Wagon. Frobenius numbers by lattice
point enumeration. Integers 7 (2007), A15 (electronic).
[13] N. J. Fine and H. S. Wilf. Uniqueness theorems for periodic functions. Proc. Amer.
Math. Soc. 16 (1965), 109114.
[14] H. Greenberg. Solution to a linear Diophantine equation for nonnegative integers. J.
Algorithms 9 (1988), 343353.
[15] M. Holzer and M. Kutrib. Nondeterministic descriptional complexity of regular lan-
guages. Internat. J. Found. Comp. Sci. 14 (2003), 10871102.
[16] J. Incerpi and R. Sedgewick. Improved upper bounds on shellsort. J. Comput. System
Sci. 31 (1985), 210224.
[17] R. Kannan. Solution of the Frobenius problem. Technical Report CMU-CS-89-204,
Carnegie-Mellon University, Dept. of Computer Science, November 1989. Extended
abstract in C. E. Veni Madhavan, ed., Proc. 9th Conf. Found. Software Tech. Theor.
Comput. Sci., Lecture Notes in Computer Science, Vol. 405, pp. 242251.
18
[18] R. Kannan. Lattice translates of a polytope and the Frobenius problem. Combinatorica
12 (1992), 161177.
[19] E. Kunz. The value-semigroup of a one-dimensional Gorenstein ring. Proc. Amer. Math.
Soc. 25 (1970), 748751.
[20] R. C. Lyndon and M. P. Sch utzenberger. The equation a
M
= b
N
c
P
in a free group.
Michigan Math. J. 9 (1962), 289298.
[21] A. N. Maslov. Estimates of the number of states of nite automata. Dokl. Akad. Nauk.
SSSR 194 (1970), 12661268. In Russian. English translation in Soviet Math. Dokl. 11
(1970), 13731375.
[22] R. W. Owens. An algorithm to solve the Frobenius problem. Math. Mag. 76 (2003),
264275.
[23] J. L. Ramrez-Alfonsn. Complexity of the Frobenius problem. Combinatorica 16 (1996),
143147.
[24] J. L. Ramrez-Alfonsn. The Diophantine Frobenius Problem. Oxford University Press,
2005.
[25] R. Sedgewick. A new upper bound for shellsort. J. Algorithms 7 (1986), 159173.
[26] E. S. Selmer. On shellsort and the Frobenius problem. BIT 29 (1989), 3740.
[27] J. J. Sylvester. Problem 7382. Math. Quest. Sol. Educ. Times 41 (1884), ix, 21.
[28] E. Teruel, P. Chrzastowski-Wachtel, J. M. Colom, and M. Silva. On weighted T-systems.
In K. Jensen, editor, Application and Theory of Petri Nets 1992, 13th International
Conference, Vol. 616 of Lecture Notes in Computer Science, pp. 348367. Springer-
Verlag, 1992.
[29] I. Vardi. Computational Recreations in Mathematica. Addison-Wesley, 1991.
[30] M. A. Weiss, R. Sedgewick, E. Hentschel, and A. Pelin. Shellsort and the Frobenius
problem. Congr. Numer. 65 (1988), 253260.
[31] H. S. Wilf. A circle-of-lights algorithm for the money-changing problem. Amer. Math.
Monthly 85 (1978), 562565.
[32] S. Yu, Q. Zhuang, and K. Salomaa. The state complexities of some basic operations on
regular languages. Theoret. Comput. Sci. 125 (1994), 315328.
19