betaFeedback

WorksComputer Science

Sublinear-space recognition for Boolean grammars

Abstract

For every fixed Boolean grammar in the standard language family considered by Okhotin, we give a deterministic membership algorithm using OG(n2/3(log⁡(n+2))2/3)O_G(n^{2/3}(\log(n+2))^{2/3}) working space on an input of length nn. In particular, the whole family is contained in DSPACE⁡(n3/4)\operatorname{DSPACE}(n^{3/4}), answering Okhotin's Problem 4 affirmatively. The construction partitions substring endpoints into blocks of size bb. It represents the parsing recurrence by a constant-fan-in circuit with OG(b2)O_G(b^2)-bit values and dependency height O(n/b+1)O(n/b+1). Splits in the endpoint blocks are resolved locally, and an ordering of the remaining splits controls the height even when a split is highly unbalanced. Applying the Cook–Mertz tree-evaluation algorithm to the implicitly unfolded circuit gives the space bound.

Introduction

Boolean grammars extend context-free grammars by allowing conjunction and negation in production rules [1]. Their standard recognition algorithms exploit the dependence of a substring’s syntactic properties on properties of its proper substrings. In his 2007 list of open problems, Okhotin asked whether the entire family of Boolean languages is contained in DSPACE(n1−ε)(n^{1-\varepsilon}) for some constant ε>0\varepsilon> 0 [2 Section 3.4, Problem 4]. The question concerns working space, permits a different recognizer for each fixed grammar, and allows a tradeoff in time.

Theorem 1.1. Let GG be a fixed Boolean grammar in the standard family of [2]. There is a deterministic algorithm deciding membership in L(G)L(G), with read-only access to its input, using

OG(n2/3(log⁡(n+2))2/3)O_G\left(n^{2/3}(\log(n+2))^{2/3}\right)

bits of working space on every input of length nn.

Corollary 1.2. The family of Boolean languages is contained in DSPACE(n3/4)(n^{3/4}). More generally, it is contained in DSPACE(n1−ε)(n^{1-\varepsilon}) for every fixed 0<ε<1/30 < \varepsilon< 1/3.

All constants implicit in OGO_G may depend on GG. The proof uses the normal-form substring recurrence together with Cook–Mertz tree evaluation [5]. Williams’s expanded author version [6 Theorem 2.2 and Appendix A] makes explicit the variable-height trees and implicit access used here. The contribution is a block circuit for the grammar recurrence whose value length and dependency height can be balanced.

Normal form and the interval recurrence

We use the standard Boolean-language family of [2 Definitions 6 and 7]. In that presentation, the semantics are defined through strongly unique solutions of the associated language equations. A grammar in this family admits an equivalent binary normal form [1, 3]. Its nonterminal set NN and terminal alphabet Σ\Sigma are finite, and its rules have the forms

A→B1C1&⋯&BpCp&¬D1E1&⋯&¬DqEq&¬ε,p≥1, q≥0,A→a,a∈Σ.(1)\begin{aligned} A &\to B_1C_1 \mathbin{\&} \cdots\mathbin{\&} B_pC_p \mathbin{\&} \neg D_1E_1 \mathbin{\&} \cdots\mathbin{\&} \neg D_qE_q \mathbin{\&} \neg\varepsilon, && p \ge1,\ q \ge0,\\ A &\to a, && a \in\Sigma. \tag*{(1)} \end{aligned}

There may also be a rule S→εS \to\varepsilon, with the start symbol SS absent from all right-hand sides. Membership of the empty word is handled separately. The condition ¬ε\neg\varepsilon in (1) is automatic on nonempty substrings.

Fix an input w=w1⋯wnw = w_1 \cdots w_n, where n>1n > 1. For A∈NA \in N and $0 \le i < j \le n$, define

XA(i,j)=1⟺wi+1⋯wj∈LG(A).X_A(i,j)=1 \Longleftrightarrow w_{i+1}\cdots w_j \in L_G(A).

Let P⊆N×N\mathcal{P} \subseteq N \times N consist of the ordered nonterminal pairs that occur in positive or negative binary conjuncts. For each (B,C)∈P(B,C) \in\mathcal{P}, put

YBC(i,j)=⋁i<k<j(XB(i,k)∧XC(k,j))(2)Y_{BC}(i,j)=\bigvee_{i<k<j}\left(X_B(i,k)\land X_C(k,j)\right) \tag*{(2)}

For j−i≥2j-i \ge2, there is a fixed Boolean function FA:{0,1}P→{0,1}F_A:\{0,1\}^{\mathcal{P}}\to\{0,1\} such that

XA(i,j)=FA((YBC(i,j))(B,C)∈P).(3)X_A(i,j)=F_A\left(\left(Y_{BC}(i,j)\right)_{(B,C)\in\mathcal{P}}\right). \tag*{(3)}

Explicitly, FAF_A disjoins the alternatives for AA, conjoining positive pair flags and complemented negative pair flags within each alternative. For j−i=1j-i=1, the value is determined by the terminal rules.

Equations (2) and (3) are the usual binary-normal-form recognition recurrence [3 Section 2, pp. 4–5]. Every interval used on the right of (2) is strictly shorter. In particular, the negation in (3) is applied after the complete disjunction over splits has been computed.

The block circuit

Choose an integer b≥1b \ge1 and partition the endpoint set {0,…,n}\{0,\ldots,n\} into consecutive blocks

I0,I1,…,Im−1,m=⌈n+1b⌉,I_0,I_1,\ldots,I_{m-1},\qquad m=\left\lceil\frac{n+1}{b}\right\rceil,

each of size at most bb, with all but the last of size bb. For $0 \le r \le s < m$, a chart word Tr,sT_{r,s} encodes

(XA(i,j):A∈N, i∈Ir, j∈Is, i<j).\left(X_A(i,j): A\in N,\ i\in I_r,\ j\in I_s,\ i<j\right).

Fix a coordinate order and use zero padding so that every value in the circuit has the same bit length

W=cGb2,W=c_Gb^2,

where the fixed positive integer cGc_G is large enough for either a chart word or a word with one flag for each (B,C,i,j)∈P×Ir×Is(B,C,i,j)\in\mathcal{P}\times I_r\times I_s. Padding coordinates are ignored by each gate function.

Diagonal words

For each rr, Tr,rT_{r,r} is a leaf whose value can be generated on demand. Compute all intervals with endpoints in IrI_r in increasing length, using (2) and (3). Every smaller interval needed remains in the same block. Store the partial chart and a constant number of flags. The resulting space requirement is

OG(b2+log⁡(n+2)).(4)O_G\left(b^2+\log(n+2)\right). \tag*{(4)}

A terminal query uses a logarithmic-size position counter and a scan of the read-only input.

Proper intermediate blocks

For r<t<sr<t<s, let Qr,s,tQ_{r,s,t} be a gate with inputs Tr,tT_{r,t} and Tt,sT_{t,s}. Its output coordinate (B,C,i,j)(B,C,i,j) is

⋁k∈It(XB(i,k)∧XC(k,j)).(5)\bigvee_{k\in I_t}\left(X_B(i,k)\land X_C(k,j)\right). \tag*{(5)}

Every such kk is an eligible split because the blocks are consecutive and r<t<sr<t<s. Both input chart words have strictly smaller block span than s−rs-r. The output is computed by loops over the designated coordinates and split positions, in the space (4).

To aggregate these products, fix r<sr < s, put d=s−rd = s - r, and list the interior indices as t1,…,td−1t_1, \ldots, t_{d-1} in increasing order of min⁡(t−r,s−t)\min(t-r, s-t), breaking ties by increasing tt. Let Ur,s,dU_{r,s,d} be the zero word and define

Ur,s,a=Qr,s,ta∨Ur,s,a+1,1≤a<d,(6)U_{r,s,a} = Q_{r,s,t_a} \lor U_{r,s,a+1}, \qquad1 \le a < d, \tag*{(6)}

where ∨\lor acts componentwise. The aggregate is Ur,s,1U_{r,s,1}. For d=1d = 1, this is the zero leaf, since there are no proper intermediate blocks.

Completing a cross-block word

The gate for Tr,sT_{r,s}, where r<sr < s, takes the three inputs

Ur,s,1,Tr,r,Ts,s.U_{r,s,1}, \quad T_{r,r}, \quad T_{s,s}.

It fills its output coordinates in increasing interval length. For a cell (i,j)∈Ir×Is(i,j) \in I_r \times I_s and each (B,C)∈P(B,C) \in P, start with the aggregate flag and include by OR exactly those splits with i<k<ji < k < j and k∈Ir∪Isk \in I_r \cup I_s.

If k∈Irk \in I_r, then XB(i,k)X_B(i,k) is in the supplied diagonal word, and XC(k,j)X_C(k,j) is an already computed cell of the current output. If k∈Isk \in I_s, then XB(i,k)X_B(i,k) is an already computed output cell, and XC(k,j)X_C(k,j) is in the other diagonal word. In both cases the output cell used has strictly smaller interval length. Once all pair flags for (i,j)(i,j) have been accumulated, apply (2.3). A length-one cell is filled from the terminal rules, including when its endpoints lie in adjacent blocks.

This is a total Boolean function of its three input words. Even when the inputs are arbitrary bit strings, the local computation has no circular dependency. The output chart, temporary flags, and loop counters fit in (3.1). To obtain length order, one may loop through all global lengths and inspect the cells with endpoints in Ir×IsI_r \times I_s. Only space is being bounded.

Lemma 3.1. The circuit is acyclic and computes all chart words correctly. Every gate has fan-in at most three and is evaluable on arbitrary Boolean arguments in the space (3.1).

Proof. Product gates use chart words of smaller block span. At a fixed span, the aggregate gates form the finite chain (3.3). The cross-block gate uses that aggregate and two diagonal words. These observations give acyclicity.

Induct on the block span. The diagonal case is the ordinary recurrence. For a cross-block word, induct also on interval length within the word. The possible split positions partition into the left endpoint block, the proper intermediate blocks, and the right endpoint block. The product and aggregate gates compute exactly the intermediate contribution. The local procedure supplies exactly the two endpoint contributions using known shorter cells. Thus the pair flags agree with (2.2), and (2.3) gives the correct membership bits. The descriptions of the gates give the fan-in and space bounds.

Height of the circuit

Height counts edges on a path from a gate toward a leaf.

Lemma 3.2. Every path from Tr,sT_{r,s} to a leaf has length at most 4(s−r)4(s-r). The circuit required for the membership bit XS(0,n)X_S(0,n) has height O(m)O(m).

Proof. The diagonal words are leaves. Suppose d=s−r≥1d = s-r \ge1. Consider a path that leaves Tr,sT_{r,s} through the aggregate and reaches Qr,s,taQ_{r,s,t_a}. Put

u=min⁡(ta−r,s−ta).u = \min(t_a-r, s-t_a).

There are at most two interior blocks at each distance from the nearer endpoint. The prescribed ordering therefore gives a≤2ua \le2u. The path to either input chart word of the product uses a+2a+2 edges. Since u≥1u \ge1,

a+2≤2u+2≤4u.a+2 \le2u+2 \le4u.

Either input chart word has block span at most d−ud-u. By induction, the remainder of the path has length at most 4(d−u)4(d-u), so the total is at most 4d4d. The route from Tr,sT_{r,s} to the aggregate zero leaf has length dd, and its direct routes to diagonal leaves have length one. These exhaust the possibilities and complete the induction. An additional constant-fan-in gate can move the desired bit into the first coordinate of the output, increasing the height by only a constant. □

Space-efficient uniform evaluation

We use the following established evaluation bound. For a tree with WW-bit node values, maximum height HH, and fan-in at most three, Cook–Mertz evaluation uses

O(W+Hlog⁡(W+2))(7)O(W + H \log(W + 2)) \tag*{(7)}

bits [5 Theorem 7]. The bound applies to variable-height trees and smaller arities, as described in the expanded author version of [6 Theorem 2.2 and Appendix A].

Here the tree is represented implicitly by unfolding the circuit backward from the output. Multiple occurrences of a circuit gate are treated as separate tree nodes. This preserves the output and the height bound.

Lemma 4.1. The unfolded block circuit can be evaluated in deterministic working space

OG(W+Hlog⁡(W+2)+log⁡(n+2)).O_G\bigl(W + H \log(W + 2) + \log(n + 2)\bigr).

Proof. We verify the access operations needed by the evaluator. A circuit gate name consists of its type and a constant number of block indices or aggregation ranks. It requires O(log⁡(n+2))O(\log(n + 2)) bits. Given a gate name and a child choice, the child name is computable in the same space. In particular, the rank-aa interior index can be found by enumerating distances from the nearer endpoint and emitting the two corresponding indices in increasing order, with a coincident midpoint emitted once.

The evaluator stores a tree node as its sequence of child choices from the root. To recover the associated circuit gate, replay that sequence from the output, keeping only the current gate name and a position counter. This uses O(log⁡(n+2))O(\log(n + 2)) additional bits beyond the stored path.

We give explicit parameters for the packed interpolation in [6 Appendix A]. Set D=3D = 3 and supply zero-valued dummy leaves at gates of smaller arity, with those arguments ignored. Let KK be a field of characteristic two and choose

ℓ=⌈log⁡2(8D(W+1))⌉,∣K∣=22ℓ,t=⌈Wℓ⌉.\ell= \left\lceil\log_2\bigl(8D(W + 1)\bigr) \right\rceil, \qquad|K| = 2^{2\ell}, \qquad t = \left\lceil\frac{W}{\ell} \right\rceil.

Using the polynomial-basis representation of KK, let SS be the subset whose last ℓ\ell binary coordinates are zero. Thus ∣S∣=2ℓ|S| = 2^\ell, and an element of SS encodes ℓ\ell bits. Extend each gate to words of tℓt\ell bits by ignoring the extra input bits and zeroing the extra output bits. Its jj-th output block defines a total function gv,j:SDt→Sg_{v,j}: S^{Dt} \to S, for 1≤j≤t1 \le j \le t.

For a∈Sa \in S, define the Lagrange polynomial

La(z)=∏c∈S∖{a}z−ca−c.L_a(z) = \prod_{c \in S \setminus\{a\}} \frac{z - c}{a - c}.

All denominators are nonzero. An extension of the output-block function is

g~v,j(z1,…,zDt)=∑aˉ∈SDtgv,j(aˉ)∏h=1DtLah(zh).(8)\widetilde{g}_{v,j}(z_1,\ldots,z_{Dt}) = \sum_{\bar{a}\in S^{Dt}} g_{v,j}(\bar{a}) \prod_{h=1}^{Dt} L_{a_h}(z_h). \tag*{(8)}

It agrees with gv,jg_{v,j} on SDtS^{Dt}, and its total degree is at most

Dt(2ℓ−1)≤D(W+1)(2ℓ−1)≤2ℓ(2ℓ−1)8<∣K∣−1.Dt(2^\ell- 1) \le D(W + 1)(2^\ell- 1) \le\frac{2^\ell(2^\ell- 1)}{8} < |K| - 1.

This is the degree condition needed in the Cook–Mertz averaging step. Indeed, for any PP of total degree less than ∣K∣−1|K|-1,

∑λ∈Kλ≠0P(λx⃗+y⃗)=P(y⃗).\sum_{\substack{\lambda\in K\\\lambda\ne0}} P(\lambda\vec{x}+\vec{y})=P(\vec{y}).

To check the identity, expand in λ\lambda. The positive powers have zero sum over K×K^\times, and the constant term is repeated an odd number of times in characteristic two. Thus this choice of SS and extension supports the same packed evaluation procedure.

Each of the D+1D+1 shared registers holds tt field elements and occupies 2ℓt=O(W)2\ell t=O(W) bits. A recursion frame stores a counter over field elements, a child choice, and a constant-size program counter in O(log⁡(W+2))O(\log(W+2)) bits. Field arithmetic can be implemented in O(log⁡∣K∣)O(\log|K|) space [5 Proposition 2]. A polynomial representation and a primitive element can also be found by enumeration within this space. In particular, the interpolation parameters do not require storing a table of field elements.

To compute (8), enumerate a⃗\vec{a}, store one tuple in Dtℓ=O(W)Dt\ell=O(W) bits, and accumulate its interpolation weight by looping over hh and cc. Decode the tuple, evaluate the named Boolean gate, and extract its jj-th block. Lemma 3.1 bounds this gate computation by OG(W+log⁡(n+2))O_G(W+\log(n+2)) scratch bits even on arbitrary decoded inputs. All remaining arithmetic uses O(log⁡(W+2))O(\log(W+2)) scratch bits. Leaf words obey the same bound by (4).

These local queries make no recursive calls to other tree nodes. Their scratch is reused and cleared before each recursive call of the evaluator, while the shared registers and the recursion stack are preserved. Consequently it contributes only one additive OG(W+log⁡(n+2))O_G(W+\log(n+2)) term to (7), establishing the lemma. □

Proof of Theorem 1.1. Lemmas 3.2 and 4.1, together with W=cGb2W=c_Gb^2, give working space

OG(b2+(nb+1)log⁡(b+2)+log⁡(n+2)).(9)O_G\left(b^2+\left(\frac{n}{b}+1\right)\log(b+2)+\log(n+2)\right). \tag*{(9)}

Choose

b=⌈((n+1)⌈log⁡2(n+2)⌉)1/3⌉.b=\left\lceil\left((n+1)\left\lceil\log_2(n+2)\right\rceil\right)^{1/3}\right\rceil.

This integer can be computed using logarithmic working space, for example by testing successive integer cubes against the displayed integer target. Substitution into (9) gives OG(n2/3(log⁡(n+2))2/3)O_G(n^{2/3}(\log(n+2))^{2/3}) for all sufficiently large nn. The finitely many remaining lengths and the empty word are handled in finite control. The root bit decides membership. □

Proof of Corollary 1.2. For each fixed 0<ε<1/30<\varepsilon<1/3,

(log⁡(n+2))2/3=O(n1/3−ε).(\log(n+2))^{2/3}=O(n^{1/3-\varepsilon}).

Apply Theorem 1.1. Taking ε=1/4\varepsilon=1/4 gives the stated common exponent. □

Relation to earlier work

The binary normal form and the interval recurrence are established parts of Boolean-grammar theory [1, 3]. The known deterministic linear-space recognition bound is discussed in [2, 4]. The proposed improvement uses a different organization of the recurrence, with local completion of the endpoint blocks and a distance-ordered aggregation of the intermediate blocks.

Grandjean, Grénte, and Terrier characterize Boolean languages by SCYK automata [7] and give corresponding characterizations for conjunctive and context-free subclasses. This supplies a parallel view of the substring recurrence. The result here instead organizes that recurrence into bounded endpoint blocks and controls the dependency height of their aggregation in order to obtain the sequential working-space bound of Theorem 1.1.

The evaluator itself is due to Cook and Mertz [5]. The proof uses the implicit-tree implementation explained by Williams [6]. No new tree-evaluation theorem is needed.

Email address: [email protected]

Email address: [email protected]

Email address: [email protected]

Email address: [email protected]

References

  1. [1]A. Okhotin, Boolean grammars, Information and Computation 194 (2004), no. 1, 19–48. doi:10.1016/j.ic.2004.03.006.DOI
  2. [2]A. Okhotin, Nine open problems on conjunctive and Boolean grammars, Bulletin of the EATCS 91 (2007), 96–119. Publisher PDF.
  3. [3]A. Okhotin and C. Reitwießner, Parsing unary Boolean grammars using online convolution, Dagstuhl Seminar Proceedings 10501 (2011), 1–11. doi:10.4230/DagSemProc.10501.3.DOI
  4. [4]M. Barash and A. Okhotin, Linear-space recognition for grammars with contexts, Theoretical Computer Science 719 (2018), 73–85. doi:10.1016/j.tcs.2017.11.006.DOI
  5. [5]J. Cook and I. Mertz, Tree evaluation is in space O(log n · log log n), Proceedings of the 56th Annual ACM Symposium on Theory of Computing (STOC 2024), 1268–1278. doi:10.1145/3618260.3649664.DOI
  6. [6]R. R. Williams, Simulating time with square-root space, Proceedings of the 57th Annual ACM Symposium on Theory of Computing (STOC 2025), 13–23. doi:10.1145/3717823.3718225. Expanded author version, 25 February 2025, arXiv:2502.17779v1 (including Appendix A).DOI
  7. [7]É. Grandjean, T. Grente, and V. Terrier, Context-free, conjunctive and Boolean grammars and SCYK automata, in M.-P. Béal and P. Caron (eds.), Developments in Language Theory (DLT 2026), Lecture Notes in Computer Science 16578, Springer, 2026, 139–152. doi:10.1007/978-3-032-28404-4_11.DOI

Paper details

vlnc:W_779xfud2
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
  • Computer Science

OpenAI Codex

View statement
Looking for related papers…
Contents