Table of Contents
Fetching ...

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$.

Balancing Two-Dimensional Straight-Line Programs

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 productions deriving a two-dimensional string of size , a structure capable of providing random access to any character of . For one-dimensional strings, it is now known how to build a structure of size that provides random access in time. In fact, it is known that this can be obtained by building an equivalent SLP of size and depth [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 described by a 2D SLP of size such that any 2D SLP describing the same string of depth must be of size . We complement this with an upper bound showing how to construct such a 2D SLP of size . 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 deriving a string of size , we can construct a 2D SLP with holes of depth and size . This allows us to conclude that there is a structure of size providing random access in time for such a 2D SLP. Further, this can be extended (analogously as for a 1D SLP) to obtain a structure of size providing random access in time, for any .

Paper Structure

This paper contains 14 sections, 16 theorems, 10 equations, 7 figures.

Key Result

Lemma 2.1

Given a set $S$ of $k$ integers from $[U]$, one can build in time $\mathcal{O}(k)$ a data structure of size $\mathcal{O}(k)$, called a fusion tree, that allows predecessor queries in $\mathcal{O}(\log k / \log\log U)$ time.

Figures (7)

  • Figure 1: 2D SLP with holes allows horizontal concatenation $A\mathbin{\hbox{o}rigin=c]{90}{$⊖$}} B$, vertical concatenation $A \ominus B$, and substitution $A(B)$. The gray rectangle represents the hole that might be present in at most one argument of a concatenation, and might be present in $B$ (and needs to be present in $A$) for a substitution $A(B)$. Further, the corresponding dimensions always need to match.
  • Figure 2: Left: $\mathsf{Bin}_{8}$, right: $\mathsf{ShiftBin}_8$ (the gray area is all $0$'s).
  • Figure 3: A demonstration of $C_{N,M}$. Each rectangle with a diagonal pattern is a copy of $\mathsf{ShiftBin}_{M'}$ (the diagonal pattern corresponds to the shifted copies of $\mathsf{Bin}_{M'}$ within $\mathsf{ShiftBin}_{M'}$). The gray areas are the padding $0$ used to "shift" the second vertical block, and the extra vertical padding at the bottom to complement the height of each vertical block to $N$.
  • Figure 4: A demonstration of the string $S$ obtained by the described grammar. The grammar composes rotated copies of $C_{N,M}$ in a spiral pattern. The narrow dimension of each gadget is always $\Delta = \frac{N}{8c\log N}$, and the wide dimension of the gadgets decreases as the spiral swirls inwards.
  • Figure 5: A visualization of the proof of \ref{['lem:lowerbound']}. The outer rectangle represents the expansion of $X'$. The indices depicted to the left and above the outer rectangle represent absolute positions of the corresponding substrings within $S$. The dashed horizontal cut represents the derivation rule of $X'$. Due to $X'$ being the last nonterminal containing $L_{2(i+1)}$ (represented as a light gray square), this cut must intersect $L_{2(i+1)}$, as depicted. The gray rectangles represent the $C_{N',M'}$ gadgets that form the frame of $L_{2i}$. Since the cut intersects $L_{2(i+1)}$, it intersects a vertical $C_{N',M'}$ gadget of $L_{2i}$ not-too-close to the boundaries ($L_{2i +1}$ functions as a 'buffer' layer between the $L_{2i}$ and $L_{2(i+1)}$, assuring that the cut is not within the first of the last $2\Delta$ rows of $L_{2i}$). The dark gray row is a row of some $C_{N',M'}$ gadget which is a substring of the bottom row of $B'$ (and the $\tilde{z}$-th row of the gadget).
  • ...and 2 more figures

Theorems & Definitions (30)

  • Lemma 2.1: DBLP:conf/stoc/FredmanW90
  • Theorem 3.1
  • Proposition 3.2: Concatenation gadget
  • Lemma 3.3
  • proof
  • Theorem 3.4: DBLP:journals/jacm/GanardiJL21
  • Lemma 3.5: Folklore
  • proof
  • Theorem 4.1
  • Definition 4.2: See \ref{['fig:Examples1']}
  • ...and 20 more