Balancing Two-Dimensional Straight-Line Programs
Itai Boneh, Estéban Gabory, Paweł Gawrychowski, Adam Górkiewicz
TL;DR
The work investigates random access on two-dimensional straight-line programs and proves that, unlike 1D SLPs, balancing standard 2D SLPs to depth O(log N) necessarily incurs a multiplicative size blow-up in general. It introduces 2D SLPs with holes (and their balanced counterparts as 2D TSLPs) and leverages a general balancing framework to attain size O(|G|) with depth O(log N) (and NM in the overall height/width scale), yielding random access in logarithmic time. By unwinding and using fusion-tree techniques, the authors also obtain near-optimal bounds of O(|G|·log^ε NM) space with O(log NM / log log NM) access time, matching the best-known 1D results in spirit and improving the 2D landscape. Overall, the paper delineates the limitations of standard 2D SLP balancing and demonstrates how hole-enabled generalizations can restore efficient random access with strong size/depth guarantees.
Abstract
We consider building, given a straight-line program (SLP) consisting of $g$ productions deriving a two-dimensional string $T$ of size $N\times N$, a structure capable of providing random access to any character of $T$. For one-dimensional strings, it is now known how to build a structure of size $\mathcal{O}(g)$ that provides random access in $\mathcal{O}(\log N)$ time. In fact, it is known that this can be obtained by building an equivalent SLP of size $\mathcal{O}(g)$ and depth $\mathcal{O}(\log N)$ [Ganardi, Jeż, Lohrey, JACM 2021]. We consider the analogous question for two-dimensional strings: can we build an equivalent SLP of roughly the same size and small depth? We show that the answer is negative: there exists an infinite family of two-dimensional strings of size $N\times N$ described by a 2D SLP of size $g$ such that any 2D SLP describing the same string of depth $\mathcal{O}(\log N)$ must be of size $Ω(g\cdot N/\log^{3}N)$. We complement this with an upper bound showing how to construct such a 2D SLP of size $\mathcal{O}(g\cdot N)$. Next, we observe that one can naturally define a generalization of 2D SLP, which we call 2D SLP with holes. We show that a known general balancing theorem by [Ganardi, Jeż, Lohrey, JACM 2021] immediately implies that, given a 2D SLP of size $g$ deriving a string of size $N\times N$, we can construct a 2D SLP with holes of depth $\mathcal{O}(\log N)$ and size $\mathcal{O}(g)$. This allows us to conclude that there is a structure of size $\mathcal{O}(g)$ providing random access in $\mathcal{O}(\log N)$ time for such a 2D SLP. Further, this can be extended (analogously as for a 1D SLP) to obtain a structure of size $\mathcal{O}(g \log^εN)$ providing random access in $\mathcal{O}(\log N/\log \log N)$ time, for any $ε>0$.
