Balancing Two-Dimensional Straight-Line Programs
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\.z, 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\.z, 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 .
Cite
@article{arxiv.2511.22212,
title = {Balancing Two-Dimensional Straight-Line Programs},
author = {Itai Boneh and Estéban Gabory and Paweł Gawrychowski and Adam Górkiewicz},
journal= {arXiv preprint arXiv:2511.22212},
year = {2025}
}