Professional Documents
Culture Documents
1975 - General Context-Free Recognition in Less Than Cubic Time
1975 - General Context-Free Recognition in Less Than Cubic Time
1975 - General Context-Free Recognition in Less Than Cubic Time
1974
This Technical Report is brought to you for free and open access by the School of Computer Science at Research Showcase @ CMU. It has been
accepted for inclusion in Computer Science Department by an authorized administrator of Research Showcase @ CMU. For more information, please
contact research-showcase@andrew.cmu.edu.
NOTICE WARNING CONCERNING COPYRIGHT RESTRICTIONS:
The copyright law of the United States (title 17, U.S. Code) governs the making
of photocopies or other reproductions of copyrighted material. Any copying of this
document without permission of its author may be prohibited by law.
GENERAL CONTEXT-FREE RECOGNITION
IN LESS THAN CUBIC TIME
Leslie G. Valiant
January 1974
HUNT LIBRARY
CAflNEGIE-MELLON UNIVERSITY
ABSTRACT
i
INTRODUCTION
text-free recognition can be carried out at} least as fast as Boolean matrix
2 81
multiplication. Since the latter is known to be computable in 0(n * ) bit
operation by means of Strassen's algorithm for matrix multiplication in a
2 81
of the best previously known recognition schemes (Kasami [5], Younger [8],
3
Earley [2]), all of which require 0(n ) time in the worst case.
-2-
PRELIMINARIES
one in Chomsky normal form [1], we need only consider grammars that are
terminals« and P is a set of productions, each of which has one of the fol-
lowing forms:
(i) A i - A j A k ,
N N r 2 = {A |3 j € N
i
A
p Aj^ 6 N 2 such that
(A. - A A ) 6 P}. j k
In terms of this we can define some operations on matrices that have subsets
b of suitable size, as
n
c. = U a...b,. .
a +
= a ( 1 )
U a ( 2 )
U ...
where a =V (i)
a ^ . a ^ and a ( 1 )
= a.
j=1
-3-
however, the significant difference that while the Boolean "and" operator is
For any algorithm we can define a complexity funption that relates the
(for worst case inputs). M(n) and T(n) will denote such functions for al-
A i -» w
b
i,i+i =
^ l (
\ - x
i > a n d
\ y- 0 for j + i+1
* +
We can therefore determine whether A^ -> x^...x by computing a = b n and
2
THEOREM 1. R(n) £ T(n+1) + 0(n ) . •
REDUCING TRANSITIVE CLOSURE TO MULTIPLICATION
the special case of Boolean matrix multiplication are known ([3], [4], [6]).
However, these all assume associativity, and are therefore not applicable
joint parts, we now require a more complex procedure based on "splitting with
overlaps . 11
Fortunately, and perhaps surprisingly, the extra cost involved
b^j where r < i £ s or r < j £ s, (ii) compute the transitive closure of the
remaining (n+r-s) X (n+r-s) matrix, and (iii) expand the matrix back to its
original size by restoring the elements that were removed to their rightful
place.
b +
= (b U b . b ) + ( r : s )
.
the submatrix [1 £ i £ r, s < j ^ n ] , and that (ii) all the new contributions
that can arise directly from a pair of elements both outside this submatrix,
can be obtained by squaring b just once. (N.B. An item at (i,j) can only
matrices [1 ^ i,j ^ n-n/k] and [n/k < i,j ^ n] are already closed. We
P :
2 (i) Apply P 2 to submatrix [n/4 < i,j £ 3n/4]
P:
3 (i) Compute b U b.b
T (n) £ M ( n )
3 + T (2n/3)
2 + 0 ( n ) , and 2
T (n)^M(n)
4 + T (n/2)
2 + 0(n ). 2
2 ^ 8 n
o(2-Y)m
(n) <• G(n log n) + 3M(n) . S 2 .
m=0
-7-
00
Since 2 m converges if |x| < 1, we conclude that if there is a suitable
x"
Y > 2, then
and
[1 < i,j £ n/2] and[n/2 < i,j ^ n ] , and then applying P . 2 This gives
Assuming now that T 2 is also well behaved (i.e. that there is a 6 * 2 such that
9
l o g n
H Mm
T(n) £ o(n ) + T (n) • S
2 2~™
KI 0J
<: T (n).const.
2
m= 0
If n is not a power of 2, we can pad the matrix with null sets to in-
crease its size to the next power of two, and then apply the above procedure.
Tlog nl 2
that the above obtained bounds also hold for arbitrary n. We therefore con-
THEOREM 2. If M(n) and T (n) are well behaved (in the senses stated above), then,
2
T(n) ^ M(n).const.,
n < j £ 2n] and [n < i <; 2n,2n < j ^ 3n],gives the product of these parti-
tions. This is clearly applicable here also and provides a converse inequality
M'(n) £ T(3n) + 0 ( n ) .
2
the tight bounds of Theorem 2. A looser bound, that still leads to a sub-
cubic recognition algorithm, can be obtained from the following simpler pro-
J /.\ i_ (2n/3,n)
+
, ,+(0,n/3) /» • \ ^, . r- ^.t
cedure: (I) compute b and b 7
' , ( n ) square the union of the
results of (i), and (iii) apply +(n/3, 2n/3) to the union of the results of
n
C
ii " U a
i k * ki-
b
First compute the Boolean matrices a',(hnxn), and b ,(nxhn), from a and b 1
a 1
=1 iff A. £ a for i = p mod h and r = f p / h l , and
pq l rq r
b 1
= 1 iff A. € b for i = q mod h and r » [q/hl.
pq l pr
By definition therefore
tion on them, and abstracting c from the result according to the above relation.,
2
Since only the multiplication can require more than 0(n ) time, we can deduce
SUMMARY
the complexity functions grow uniformly as assumed then the problem of com-
To reach our main conclusion we use the known fact that Boolean matrix
3
multiplication does not require time 0(n ) . Treating the Boolean elements as
integers modulo n+1, applying Strassen's algorithm [7], and reducing the non-
2 81
zero elements to one in the result gives the Boolean product in 0(n * ) bit
operations [3]. We can therefore deduce from Theorems 1 , 2 , and 3 that
2 81
context-free languages can be recognized in time 0(n * ) .
known.
ACKNOWLEDGMENT
REFERENCES
HURT LIBRARY
WMNE61E-MELL0H UNIVERSITY