The Boolean Formula Value Problem Is in Alogtime (Preliminary Version)
The Boolean Formula Value Problem Is in Alogtime (Preliminary Version)
is in ALOGTIME
(Preliminary Version)
Samuel R. Buss∗
Department of Mathematics
University of California, Berkeley
January 1987
Abstract
The Boolean formula value problem is in alternating log time and,
more generally, parenthesis context-free languages are in alternating log
time. The evaluation of reverse Polish notation Boolean formulas is also in
alternating log time. These results are optimal since the Boolean formula
value problem is complete for alternating log time under deterministic
log time reductions. Consequently, it is also complete for alternating log
time under AC 0 reductions.
1. Introduction
The Boolean formula value problem is to determine the truth value of a
variable-free Boolean formula, or equivalently, to recognize the true Boolean
sentences. N. Lynch [11] gave log space algorithms for the Boolean formula
value problem and for the more general problem of recognizing a parenthesis
context-free grammar. This paper shows that these problems have alternating
log time algorithms. This answers the question of Cook [5] of whether the
Boolean formula value problem is log space complete — it is not, unless log
space and alternating log time are identical. Our results are optimal since, for
an appropriately defined notion of log time reductions, the Boolean formula
value problem is complete for alternating log time under deterministic log time
reductions; consequently, it is also complete for alternating log time under AC 0
reductions. It follows that the Boolean formula value problem is not in the log
time hierarchy.
There are two reasons why the Boolean formula value problem is interesting.
First, a Boolean (or propositional) formula is a very fundamental concept
∗ Supported in part by an NSF postdoctoral fellowship.
1
of logic. The computational complexity of evaluating a Boolean formula is
therefore of interest. Indeed, the results below will give a precise characterisation
of the computational complexity of determining the truth value of a Boolean
formula. Second, the existence of an alternating log time algorithm for the
Boolean formula problem implies the existence of log depth, polynomial size
circuits for this problem and hence there are (at least theoretically) good
parallel algorithms for determining the value of a Boolean sentence.
As mentioned above, N. Lynch [11] first studied the complexity of the
Boolean formula problem. It follows from Lynch’s work that the Boolean
formula value problem is in N C 2 , since Borodin [1] showed that LOGSP ACE ⊆
N C 2 . Another early significant result on this problem was due to Spira [17] who
showed that for every formula of size n, there is an equivalent formula of size
O(n2 ) and depth O(log n). An improved construction, which also applied to
the evaluation of rational expressions, was obtained by Brent [2]. Spira’s result
was significant in part because because it implied that there might be a family
of polynomial size, log depth circuits for recognizing true Boolean formulas. In
other words, that the Boolean formula value problem might be in (non-uniform)
N C 1 . However, it was not known if the transformations of formulas defined by
Brent and Spira could be done in N C 1 . Recent progress was made by Miller
and Reif [13] who found improved algorithms for computing rational functions
on PRAM’s in O(log n)-time; however, they did not give improved circuits for
the Boolean formula value problem. Very recently, Cook and Gupta [7] and,
independently, Ramachandran [14] were successful in giving polynomial size,
O(log n log log n)-depth circuits for the Boolean formula value problem.
Our result improves on Cook, Gupta and Ramachandran since alternating
log time is a subset of N C 1 . Indeed, Ruzzo [15] showed that alternating log
time is the same as UE ∗ -uniform N C 1 , where in this setting UE ∗ -uniformity is
a kind of alternating log time uniformity. It is shown below that alternating
log time can also be characterized as the set of decision problems which have
ALOGT IM E-uniform formulas. We do not use Spira’s or Brent’s restructuring
methods but instead give a new algorithm based on a transformation of Boolean
formulas to Postfix-Longer-Operand-First (P LOF ) formulas. It is still open
whether Spira’s and Brent’s original restructuring algorithms are in N C 1 or
ALOGT IM E.
Definition: |α| is the length of α, i.e., the number of symbols in the string α.
2
condition; namely, that for any binary operator, the longer operand must
appear first.
The value of a Boolean or P LOF formula is defined in the usual way, where
0 and 1 represent False and True, respectively.
Main Theorem 1 The problem of determining the truth value of a Boolean
formula (or: P LOF formula) is in alternating log time.
An important area in research in computational complexity is to study the
circuit complexity of various decision problems (see Savage [16] or Cook [5] for
instance). A related, but less popular, approach to computational complexity
is to study the formula complexity of decision problems where a formula is a
circuit with fan-out one. It is well known that in the non-uniform setting a
decision problem has polynomial size, log depth circuits if and only if it has
polynomial size formulas. (One direction of the proof just expands the circuit
to a formula, the other uses the result of Spira mentioned above.) Ruzzo [15]
showed that a decision problem has UE ∗ -uniform polynomial size, log depth
circuits if and only if it is in ALOGT IM E. The Main Theorem 1 plus the
discussion on reductions in §3 allows us to improve this to
Theorem 2 Let D be a decision problem. The following are equivalent:
(a) D is in ALOGT IM E;
(b) D has ALOGT IM E-uniform, polynomial size formulas.
(c) D has ALOGT IM E-uniform, polynomial size, log depth formulas.
Corollary 3 There are polynomial size, log depth, ALOGT IM E-uniform for-
mulas for the Boolean formula value problem.
3
§4 we give an ALOGT IM E reduction of the Boolean formula value problem to
the P LOF formula value problem. Then in §5 an ALOGT IM E algorithm for
the latter problem is given, thus finishing the proof of Main Theorem 1. In §6
we show that recognizing any parenthesis language (in the sense of Lynch) has
an ALOGT IM E algorithm. Finally, §7 discusses various problems which are
complete for alternating log time under deterministic log time reductions.
4
The function Count is in fact in ALOGT IM E as the usual polynomial size,
log depth circuits for ACount are UE ∗ -uniform.
A generalization of the Count function is the summation of a vector of
integers. The function which computes the sum of n integers each n bits long
is also in ALOGT IM E.
(1) If w ∈ {0, 1}∗ , i.e., w is a string of 0’s and 1’s, then xw is a formula in the
wide sense. When w is the dyadic representation of i ∈ N, then xw is the
literal denoting the variable xi .
(2) 0 and 1 are formulas in the wide sense.
(3) If α and β are formulas in the wide sense, then so are (¬α), (α ∧ β) and
(α ∨ β).
We generally refer to formulas in the wide sense as just formulas and let the
context distinguish them from Boolean formulas† . A family of formulas is
an infinite sequence of formulas such that the n-th formula uses only literals
x1 , ..., xn . A given predicate is computed by a family of formulas if and only if
the value of the predicate on inputs n bits long is expressed by the n-th formula
with the literal xi denoting the i-th input bit.
Ruzzo [15] discusses the relationship between a large number of uniformity
conditions on circuits. We shall use a condition called ALOGT IM E-uniformity
for formulas. This is similar in spirit to the UBC -uniformity of Ruzzo, orig-
inally introduced by Borodin and Cook [4]; except that alternating log time
computablility is substituted for log space computability.
5
F (c, i, 0n ) ⇐⇒ “the n-th formula has c as its i-th symbol”.
6
(d) If none of the above apply then the Affirmer wins the game.
It is not difficult to see that the game is correctly designed so that the Affirmer
has a winning strategy if and only if A is a Boolean formula; the Affirmer’s
strategy is to pick j and k so that A[j, k] is the subformula of A with αi as its
outermost logical connective. The game obviously has only O(log n) plays and
since Count is in alternating log time, there is an alternating log time algorithm
for determining which player won.
There is actually a slightly simpler algorithm for recognizing Boolean for-
mulas; however, the point of using the above algorithm was to demonstrate how
alternating log time suffices for parsing Boolean formulas. This technique can
be used to defining many simple syntactic properties of formulas. It should be
clear that the following predicate on a string A = α1 · · · αn is in ALOGT IM E:
are in ALOGT IM E.
Similar predicates for reverse Polish notation formulas are also in alternating
log time. The recognition problem for such formulas is easily solved using
counting: suppose A is a string containing only the symbols 0, 1, ¬, ∨, ∧.
Assign weights to these characters as follows:
−1 if α is ∨ or ∧
k(α) = 0 if α is ¬
1 if α is 0 or 1.
Pn
Then A is a reverse Polish notation formula if and only if (1) i=1 k(αi ) = 1
Pj
and (2) for each 1 ≤ j < n, i=1 k(αi ) > 0. This is easily checked in alternating
log time since the summation of a vector of integers is in alternating log time
(or alternatively, since all the weights are −1, 0 or 1, it can computed by just
using counting).
It is also easy to see that the recognition problem for P LOF formulas is in
ALOGT IM E.
7
3. Log Time Reductions
An important tool for the characterization of the computation complexity
of decision problems is the use of reductions. When A and B are decision
problems, i.e., predicates, a (many-one) reduction from A to B is a unary
function f such that for all x, x ∈ A if and only if f (x) ∈ B.
8
(3) For each move of M which is simulated, N moves the clock tape head one
square to the right. If during the simulation, M enters an accepting or a
rejecting state then N halts and accepts or rejects, respectively. However,
if the clock tape head reaches the delimiting $ then M ’s time has expired
and N halts in a rejecting state.
That completes the description of N . Note that without the use of the clock
tape N might not always halt in O(log n) time since the simulation of M could
guess contradictory input symbols which, if unchallenged, could cause M to
loop. (However, we add parenthetically that there is a general way to add a
clock to log time Turing machines.)
Q.E.D. Theorem 4.
Theorem 5 Suppose B ∈ Σk -LOGT IM E where k ≥ 1.
(a) If there is a deterministic log time reduction from A to B then A is in
Σk+1 -LOGT IM E.
(b) If s ≥ 1 and there is a Σs -LOGT IM E reduction from A to B then A is in
Σk+s -LOGT IM E.
In particular, the log time hierarchy (LH) is closed under LH-reductions.
Proof: It suffices to prove (b) since (a) is a special case of (b) with s = 1.
Suppose M is an alternating Turing machine which recognizes B in time
c · log(n) + c with k alternations. The Turing machine which N which recognizes
A runs as follows:
(1) As in the previous proof, N begins by deterministically setting up the clock
tape to limit the simulation of M to c · log(m∗ ) + c moves.
(2) Before beginning the simulation of M , N predetermines the nondetermin-
istic choices to be made while simulating M . It does this by alternating
k times to choose k blocks of c · log(m∗ ) + c bits. The i-th bit of the
j-th block determines the i-th nondeterministic choice made during the
j-th alternation of M — so the simulation of M is now completely
deterministic.
(3) Then N guesses existentially a string of c · log(m∗ ) + c input symbols and
universally chooses c · log(m∗ ) + c challenge bits. The string of input
symbols is to be the appropriate symbols which M should read from its
input tape during the simulation and the challenge bits specify whether
the input symbols are correct. A challenge bit equal to 1 indicates that
N will halt the simulation of M when the corresponding input symbol
would be used and will then use a Πs -LOGT IM E algorithm for Af to
verify the correctness of the guessed input symbol.
(4) Finally, N deterministically simulates M until either M halts, a challenge
bit is on, or the clock tape indicates that time has expired.
9
That completes the description of N . If k is odd, the algorithm of N is a
Σk+s -LOGT IM E algorithm. If k is even, it would be a Σk+s+1 -LOGT IM E
algorithm; but this case can be improved by modifying step (3) to universally
choose the input symbols and existentially choose the challenge bits and then
later use a Σs -LOGT IM E algorithm for Af to verify the incorrectness of the
universally chosen input symbol. That gives a Σk+s -LOGT IM E algorithm
when k is even.
Q.E.D. Theorem 5.
There are several different natural ways to characterize a decision problem
as complete for alternating log time. The key issue is what type of reduction
between decision problems should be used. The main choices are (a) LH-
reductions, (b) Σk -LOGT IM E reductions for a fixed k ≥ 1 and (c) deterministic
log time reductions. Probably the most natural choice is to use LH-reductions
partly since the property of LH-reducibility is transitive and partly since an
LH-reduction is essentially a uniform version of an AC 0 reduction. To see
this, recall that an AC 0 reduction is one given by a family of constant depth,
polynomial size circuits with unbounded fanin (see Cook [5]). Note that a
Σ1 -LOGT IM E predicate can be expressed as a depth two, polynomial size
circuit with unbounded fanin as follows: the circuit is a disjunction of clauses,
one clause for each potential accepting computation path of the Σ1 -LOGT IM E
Turing machine; each clause is the conjunction of literals corresponding the
input values checked on that computation path. It is easy to extend this
to show that a Σk -LOGT IM E predicate can be expressed as a depth k + 1,
polynomial size circuit with unbounded fanin.
Another but less natural choice of reducibility is Σ1 -LOGT IM E reducibility.
However, we shall use the yet stronger property (c) of deterministic log time
reducibility. Although it is not transitive, it is perhaps the strongest possible
reasonable notion of reducibility. Thus we establish below that the various
forms of the Boolean formula value problem are complete for ALOGT IM E
under deterministic log time reductions. Of course this implies that they are
also complete under AC 0 reductions.
10
Af (c, i, A) ⇐⇒ “there is an αj , the j-th symbol of A, such that
αj is the symbol c and there are i − 1 symbols αk
such that Bef ore(k, j, A)”.
The game Γn is played by the Affirmer who wishes to prove A has Boolean
value 1 (or True) and the Denier who wishes to prove A has value 0. In each
move both players assert the truth value of a subformula of A. The game Γn
11
is “oblivious” of A in that the choice of subformula under consideration in a
given move is independent of A insofar as is possible; thus the game is called
Γn instead of ΓA . The obliviousness is obtained by having a range (Li , Ri ) in
round i of the game — the players must assert the truth value of the subformula
Aki where ki is si -selected by (Li , Ri ). The numbers Li , Ri , and si depend
only on i, n and the prior answers of the players during the game.
Since this “obliviousness” is one of the crucial ideas in the definition of
the alternating log time algorithm, we discuss it further. If we try to base
an algorithm on either Spira’s or Brent’s algorithm for restructuring Boolean
formulas, the following problem arises: after the Affirmer and Denier play a log
time game giving the truth values to subformulas which arise from Spira/Brent
restructuring, it is then apparently impossible to use an alternating log time
algorithm to determine who won the game. The reason for this is that there
is no known alternating log time algorithm for determining which subformula
was being considered at the i-th move of the game, since the subformula at
move i depends on the earlier subformulas which likewise depend on their
earlier subformulas, etc. This would give rise to an alternating O(log2 n)-
time algorithm for finding the i-th subformula. Actually, Ramachandran [14]
improved upon this by showing that Brent restructuring has an alternating
O(log n log log n)-time algorithm and Cook and Gupta [7] obtained the same
result for a variant of Spira’s algorithm.
Our method is to transform the Boolean formula into P LOF formula and
then, instead of using Spira or Brent restructuring, use a different method
of dividing the formula in half, so that a “divide-and-conquer” algorithm will
work. The crucial point is that after the Affirmer and Denier finish the game
there will be an alternating log time algorithm which can determine for any i
what subformula was considered during the i-th move and hence can determine
who won the game. The idea of transforming the Boolean formula to a P LOF
formula was foreshadowed by Lynch’s log space algorithm [11] which evaluates
longer subformulas first.
The moves of the game Γn are grouped into triples — the j-th triple consists
of moves numbered 3j − 2, 3j − 1 and 3j. As mentioned above, each move i has
associated with it numbers Li , Ri , si and ki ; in addition there are numbers li ,
ri , liA and riA . We call (li , ri ) the global range; it is the “publicly acknowledged”
range of disagreement between the Affirmer and Denier. The A-specific range
(liA , riA ) is the actual range of disagreement. The number si is always either 1
or 2. The ranges are defined so that
li ≤ liA < riA ≤ ri
is always guaranteed to hold during any (unfinished) play of Γn for any P LOF
formula A.
The only exception to the moves being grouped in triples is the very first
move numbered 0. The initial move has paramenters L0 = l0 = l0A = 0 and
R0 = r0 = r0A = n. The Affirmer must first answer 1 and the Denier must
answer 0 or they forfeit the game. This initial move is included only to make
the description of the game more uniform.
12
The A-specific range (liA , riA ) is set so that the Affirmer and Denier have
disagreed on the truth value of the subformula AriA but have agreed on the
truth values of subformulas of A which together contain each symbol αm with
m ≤ liA . (This latter fact will require proof.) Each triple of moves halves the
global range (li , ri ); more precisely, for all i = 3j − 2,
¹ º
n
li − ri = j−1 .
2
For notational convenience, set
¹ º ¹ º
n n
Halfj = − j .
2j−1 2
and ¹ º
1
SQuartj = Halfj
2
» ¼
1
LQuartj = Halfj .
2
Thus SQuartj + LQuartj = Halfj ; SQuart and LQuart stand for “small
quarter” and “large quarter”.
Before telling what the values for the parameters li , ri , si , Li , Ri , liA and riA
are during the game, let us first explain what the players Affirmer and Denier
are required to do. The subformula under consideration is Aki where ki is
si -selected by (Li , Ri ) — each player plays a single bit 0 or 1 for False or True,
respectively, according to:
Rule (F): First the Affirmer asserts a value for the subformula Aki . Then
depending on whether ki is in the A-specific range, the Denier plays
according to one of the following three cases:
(a) If liA < ki < riA then the Denier also asserts a value for the subformula
Aki .
(b) If ki ≤ liA then the Denier agrees with the Affirmer by giving the
same answer.
(c) If riA ≤ ki then the Denier disagrees with the Affirmer.
For the next round the A-specific range is set as follows:
• If the Affirmer and Denier agreed, set li+1
A
= max(liA , ki ) and
A A
ri+1 = ri .
• If they disagreed, set li+1
A
= liA and ri+1
A
= min(riA , ki ).
That completes the description of Rule (F) and we are now ready to describe
the details of the game Γn . Move (0) for Γn has already been described. For
move (1) the global and A-specific ranges are set by li = liA = 0 and ri = riA = n.
The parameters for moves (3j − 2), (3j − 1) and (3j) are set as follows: (for
ease in subscripting let m = 3j − 2)
13
Figure 1: Subformulas selected during a triple of moves. (Drawn with correct
relative magnitudes except k3j−2 may be larger than l3j−2 + LQuartj .)
14
(1) If during some move, part (b) or (c) of Rule (F) applied but the Denier
did not properly agree or disagree with the Affirmer.
(2) If during some move, part (a) of Rule (F) applied and the selected
subformula Aki is a literal 0 or 1 but the Denier asserted that it had
value 1 or 0, respectively.
(3) If there are two subformulas Aki and Akm such that Akm is Aki ¬ (so
km = ki + 1) and such that during moves m and i, part (a) of Rule (F)
applied and the Denier answered identically for the truth values of Aki
and Akm in moves i and m.
(d) Similarly for ∧ or ∨; there are three subformulas Aki , Akm and Aks such
that Akm and Aks are the direct subformulas of Aki but the Denier gave
answers during moves i, k and s which contradict the definition of the
operators ∨ and ∧ (and part (a) of Rule (F) applied for moves i, m
and s).
There is an alternating log time algorithm which determines if one of these four
conditions holds; to see this, we need the following ALOGT IM E subroutines:
(i) Compute Halfj , SQuartj and LQuartj as a function of j and A: this is
clearly in alternating log time.
(ii) Compute l3j−2 and r3j−2 as a function of j, A and the plays by the
Affirmer and Denier during the game: For each triple of moves the
global range is changed so that
l3s+1 = l3s−2 + γs
r3s+1 = r3s−2 − δs
where γs is 0 or LQuarts or Halfs and where δs is 0 or SQuarts or
Halfs . Clearly γs and δs are easily computed from the players’ moves in
Γn . (Note: this is where we are using the “obliviousness” of Γn .) So l3j−2
and r3j−2 can be computed by
X
l3j−2 = γs ,
1≤s<j
X
r3j−2 = n − δs
1≤s<j
15
(iv) Determine if part (a), (b) or (c) of Rule (F) applied in move i of Γn — as
a function of i, A and the plays of the Affirmer and Denier during the
game: Check (in alternating log time) the following two conditions
(β) Is there an s < i such that ks ≥ ki and such that the Affirmer and
Denier agreed in move (s)?
(γ) Is there an s < i such that ks ≤ ki and such that the Affirmer and
Denier disagreed in move (s)?
If only (β) holds then part (b) of Rule (F) applied during move i, if only
(γ) holds then part (c) applied, if neither holds then part (a) applied, and
finally, if both hold then the Rule (F) had already been violated earlier
in the game and hence the winner (namely the Affirmer) had already
been determined before move i.
That completes the proof that the winner of the game can be determined
in alternating log time. In order to finish the proof of Theorem 6 and Main
Thoerem 1 we must show that the Affirmer has a winning strategy if and only
if the Boolean formula A is true (has value 1). This will be clear provided we
can prove that during any game in which the Denier has obeyed Rule (F),
the following two conditions hold: (1) for any move i and any symbol αs with
s ≤ liA , the symbol αk occurs in some previously selected subformula Akm with
m < i; and (2) the A-specific range is included in the global range, i.e.,
16
sign (¬) since this would contradict the fact that k3j−1 was 1-selected by
(k3j−2 , r3j−2 − Halfj ). Hence Ak3j−1 is an operand of a binary operator αs and
indeed it is the first operand. The latter statement is shown by noting that
Ak3j−1 being the second operand would violate the definition of k3j−2 , since a
better choice for the value of k3j−2 would have been k3k−1 + 1. Since A is a
P LOF , the first operand of αs is at least as long as its second operand; namely,
2k3j−1 ≥ (s − 1) + k3j−2
> (r3j−2 − Halfj − 1) + (l3j−2 + 1).
Hence
(v − 1) − u ≤ u − k3j−1
and thus
2u ≥ v − 1 + k3j−1
≥ (r3j−2 − SQuartj ) + (l3j−2 + LQuartj ).
We have now completed the proof that the Boolean formula value problem
has an alternating log time algorithm. It should be remarked that some authors
formulate the Boolean formula value problem slightly differently: they allow
variables to appear in the Boolean formula and then the Boolean formula
value problem has as inputs a Boolean formula plus a truth assignment to the
17
variables. It is easy to see that there is an alternating log time reduction from
this alternative formulation to our formulation. Hence there is an alternating
log time algorithm for this alternative formulation.
However, there is another radically different way of formulating the Boolean
formula value problem; namely as a table of nodes with pointers from a node
to its parent and children. In this formulation the formula value problem is
equivalent to the reachability problem and hence is logspace complete — this
was shown by Dowd and Statman [6] and independently by Tompa.
A → (x)
Proof: (Outline) We shall sketch briefly how the proof of Main Theorem 1 can
be extended to handle a general parenthesis language. Let G = (V, T , P, S)
be a parenthesis language. For A ∈ V, let GA be the parenthesis language
(V, T , P, A), i.e., GA is the language generated by starting with the variable A.
We define the G-formulas to be the strings of symbols which are members of
some GA ; note that G-formulas are not necessarily members of the parenthesis
language G.
We shall shift our viewpoint from the recognition of members of G to the
evaluation of G-formulas (this technique is due to McNaughton). The value of
18
a G-formula will be a member of ℘(V), the power set of V (so there is only a
finite number of possible values). Given any string α ∈ (V ∪ T )∗ , the value of
α is the set {A : α ∈ GA }. Thus to determine if α ∈ G one computes the value
of α and checks if it contains the symbol S as a member.
Each production P ∈ P is of the form
A0 → (α1 A1 α2 A2 · · · αn An αn+1 )
A → (α1 A1 α2 · · · αn An αn+1 )
19
Q.E.D. Main Theorem 8.
Main Theorem 9
(a) The Boolean formula value problem is ALOGT IM E-complete under deter-
ministic log time reductions.
(b) The P LOF formula value problem is ALOGT IM E-complete under deter-
ministic log time reductions.
(c) The postfix (reverse Polish) Boolean formula value problem is ALOGT IM E-
complete under deterministic log time reductions.
Corollary 10 The Boolean formula value problem, the P LOF formula value
problem and the postfix notation Boolean formula value problem are each complete
for ALOGT IM E under AC 0 reductions.
Corollary 11 There is a deterministic log time reduction from the (infix no-
tation) Boolean formula value problem to the postfix notation Boolean formula
value problem, and vice-versa.
20
of the proof of Theorem 9(a) is showing that f can be picked so that Af is a
deterministic log time predicate.
We assume without loss of generality that each configuration of M has at
most two possible successor states. For each configuration s of M there are
two successor configurations denoted `(s) and r(s); the degenerate cases are
`(s) = r(s) when s is a deterministic configuration and s = `(s) = r(s) when s
is a halting configuration. More generally, for ρ ∈ {`, r}∗ , we define ρ(s) in the
obvious way so that 0(s) = s and ρr(s) = r(ρ(s)) and ρ`(s) = `(ρ(s)) where 0
is the empty word. Let I(x) denote the initial configuration of M on input x.
We define Boolean formulas α(ρ, x) where |ρ| ≤ c · log(|x|) + c as follows:
Case (1): If |ρ| = c · log(|x|) + c then define α(ρ, x) to be the literal 1 if ρ(I(x))
is an accepting configuration of M and to be the literal 0 otherwise.
Case (2): If |ρ| < c · log(|x|) + c then set φ` = α(ρ`, x) and φr = α(ρr, x)
and define α(ρ, x) to be the formula (φ` ∧ φr ) if ρ(I(x)) is a universally
branching configuration of M and to be (φ` ∨ φr ) otherwise.
The function f is defined by f (x) = α(0, x).
It is clear that f (x) is a variable free Boolean formula which has value 1
(i.e., True) if and only if x ∈ A. To prove Theorem 9(a) it remains to show
that f is a deterministic log time function; or equivalently, that there is a
deterministic log time Turing machine N which on input x and i produces as
output the i-th symbol of f (x). Basically what N needs to do is determine
the location of the i-th symbol of f (x) by determining the string ρ ∈ {`, r}∗
of maximum length such that the i-th symbol of f (x) is in the subformula
α(ρ, x) of f (x). After determining this ρ, N simulates M to determine the
corresponding configuration ρ(I(x)) of M on input x and from this obtains the
correct i-th symbol of f (x).
Lemma 13 (Dowd [6]) There is a deterministic log time Turing machine which,
on input x, outputs the value n = |x| coded in binary.
Proof: The operation of the Turing machine proceeds as follows. First
determine the least value of i such that n < 2i : this is easily done in O(log n)
time since we assume that the index tape and its tape head are unaffected when
the input tape is accessed. Once the value 2i is obtained, written on the input
tape, it is now easy to do a binary search to determine the value of n. Finally
the index tape is copied to the output tape. 2
Input: x, i
21
Step (1): Compute n = |x|.
Step (2): Compute d = c · log n + c. (This is easy since our logarithms are
base two.)
Step (3): If i ≥ 2d+2 − 3, output a blank symbol and halt.
Step (4): Set ρ equal to the empty word.
Set s equal to d + 2.
Set j equal to i.
Step (5): (Loop while s ≥ 2)
Select one case (exactly one must hold):
Case (5a): If j = 0, output “(” and halt.
Case (5b): If 0 < j < 2s−1 − 2, set j = j − 1 and set ρ = ρ`.
Case (5c): If j = 2s−1 − 2, exit to step (6).
Case (5d): If 2s−1 − 2 < j < 2s − 4, set j = j − (2s−1 − 2) and
set ρ = ρr.
Case (5e): If j = 2s − 4, output “)” and halt.
Set s = s − 1.
If s ≥ 2, reiterate step (5) otherwise exit to step (6).
Step (6): Simulate M for |ρ| steps to determine the configuration ρ(I(x)).
If |ρ| < d and ρ(I(x)) is a universally branching state, output
“∧”.
Otherwise, if |ρ| < d, output “∨”.
Otherwise, if ρ(I(x)) is an accepting state, output “1”.
Otherwise, output “0”.
It should be clear by inspection that this algorithm correctly computes the
i-th symbol of f (x). In an iteration of the loop in step (5), it has already been
ascertained that the i-th symbol of f (x) is the j-th symbol of the subformula
α(ρ, x). The subformula α(ρ, x) is of the form (φ` ∗ φr ) where ∗ is either
∨ or ∧; the five cases correspond to the j-th symbol being (a) the initial
parenthesis, (b) in the subformula φ` , (c) the logical connective symbol, (d) in
the subformula φr or (e) the final parenthesis.
Except for step (5), each step in the algorithm takes O(log n) time. In
particular, for step (6), the simulation of M is hardwired and N simulates each
operation of M with only one operation. Step (5), however, is more difficult:
there are O(log n) iterations of the loop and each iteration takes O(log n) time
in a naive implementation — we need each iteration to take constant time.
The reason that each iteration takes O(log n) time is that in case (5d), for
example, to subtract 2s−1 − 2 from j both the high and low order bits of j must
be modified; but j has O(log n) bits so it takes too much time just to move the
tape head from one end of j to the other. Similar problems arise in comparing
j to 2s−1 − 2 and 2s − 4. Also, even when just decrementing j by 1 in case (5b)
it may take O(log n) time to propagate a borrow.
Fortunately all these problems con be avoided by a simple trick. Before
starting step (5), N breaks j into two parts: the low order 2 + log d bits of j
22
are stored on a tape in unary notation; the remaining high order bits of j are
kept on a different tape in binary notation. So to decrement j by 1, N merely
changes one tape square on the unary tape and moves that tape head one
square. To subtract 2s−1 − 2 from j, N need only change two squares on the
unary tape and modify one square of the binary tape (since j ≤ 2s − 4). A
complication arises when there is a carry or borrow out of the (2 + log d)-th
bit position of j. N handles this by allowing the unary tape to overflow (and
cause a carry) or underflow (and cause a borrow). To do this the unary tape
is initialized with a marker indicating where the overflow or underflow occurs;
since the unary part of j is changed by −1 or +2 at most d = c · log n + c times,
at most one marker is needed. During the iterations of the loop in step (5)
N remembers whether or not an underflow/overflow has occurred. N also
initializes the binary tape with a marker which indicates how far the borrow or
carry will propagate.
We can now summarize how N executes step (5) in O(log n) time. First j
is split into binary high-order and unary low-order parts — these are stored on
separate tapes along with borrow/carry information. Then the loop is executed
for s = d + 2 to s = 3 + log d maintaining the value of j in the split binary/unary
form. After these iterations the higher-order, binary portion of j is equal to
zero. The unary portion of j is now converted back to binary notation and the
remaining iterations of the loop with s = 2 + log d to s = 2 are executed in the
normal naive fashion with j in binary notation.
The above proves Theorem 9(a). Theorem 9(b) can be proved by a similar,
somewhat easier, deterministic log time reduction of an arbitrary ALOGT IM E
predicate to the P LOF formula value problem. Theorem 9(c) is a consequence
of 9(b).
8. Conclusion
We have shown that the Boolean formula value problem is complete for
alternating log time under deterministic log time reductions. A variant of
this problem, the postfix notation Boolean formula value problem is also
alternating log time complete under deterministic log time reductions. This
complements the result of Ladner [10] that the circuit value problem is complete
for polynomial time under log space reductions. It is a longstanding open
problem whether for every circuit there is an equivalent formula with the size
of the formula bounded by a polynomial of the size of the circuit; we conclude
that this unlikely to be the case unless P = ALOGT IM E.
Acknowledgments
I have benefited greatly from discussions with Vijaya Ramachandran and
Stephen Cook and from correspondence with Martin Dowd.
23
References
[1] A. Borodin, On relating time and space to size and depth, SIAM J.
Comput., 6 (1977), pp. 733–744.
[13] G. L. Miller and J. H. Reif, Parallel tree contraction and its application,
in Proceedings of the 26th IEEE Symposium on Foundations of Computer
Science, IEEE Computer Society, 1985, pp. 478–489.
24
[17] P. M. Spira, On time hardware complexity tradeoffs for Boolean functions,
in Proceedings of the Fourth Hawaii International Symposium on System
Sciences, 1971, pp. 525–527.
[18] A. C.-C. Yao, Separating the polynomial time hierarchy by oracles, in
Proceedings of the 26th Annual Symposium on Foundations of Computer
Science, IEEE Computer Society, 1985, pp. 1–10.
25