We introduce the task of out-of-order membership to a formal language L, where the letters of a word w are revealed one by one in an adversarial order. The length |w| is known in advance, but the content of w is streamed as pairs (i, w[i]), received exactly once for each position i, in arbitrary order. We study efficient algorithms for this task when L is regular, seeking tight complexity bounds as a function of |w| for a fixed target language. Most of our results apply to an algebraically defined variant dubbed out-of-order evaluation: this problem is defined for a fixed finite monoid or semigroup S, and our goal is to compute the ordered product of the streamed elements of w. We show that, for any fixed regular language or finite semigroup, both problems can be solved in constant time per streamed symbol and in linear space. However, the precise space complexity strongly depends on the algebraic structure of the target language or evaluation semigroup. Our main contributions are therefore to show (deterministic) space complexity characterizations, which we do for out-of-order evaluation of monoids and semigroups. For monoids, we establish a trichotomy: the space complexity is either Θ(1), Θ(log n), or Θ(n), where n = |w|. More specifically, the problem admits a constant-space solution for commutative monoids, while all non-commutative monoids require Ω(log n) space. We further identify a class of monoids admitting an O(log n)-space algorithm, and show that all remaining monoids require Ω(n) space. For general semigroups, the situation is more intricate. We characterize a class of semigroups admitting constant-space algorithms for out-of-order evaluation, and show that semigroups outside this class require at least Ω(log n) space.
翻译:我们提出了形式语言L的乱序成员判定任务,其中单词w的字母以对抗性顺序逐字符揭示。|w|的长度预先已知,但w的内容通过成对接收的(i,w[i])进行流式传输,每个位置i恰好接收一次,且顺序任意。当L为正则语言时,我们研究该任务的高效算法,针对固定目标语言寻求以|w|为变量的严格复杂度边界。我们的多数结果适用于代数定义的变体——乱序求值:该问题针对固定有限幺半群或半群S定义,目标为计算w的流式元素的有序乘积。我们证明,对于任意固定正则语言或有限半群,这两个问题均可通过每流式符号常数时间与线性空间求解。然而,精确的空间复杂度强烈依赖于目标语言或求值半群的代数结构。因此,我们的主要贡献在于给出(确定性)空间复杂度刻画,这通过幺半群与半群的乱序求值实现。对于幺半群,我们建立三分法定理:空间复杂度为Θ(1)、Θ(log n)或Θ(n)(其中n = |w|)。具体而言,交换幺半群允许常数空间解,而所有非交换幺半群需要Ω(log n)空间。我们进一步识别出一类容许O(log n)空间算法的幺半群,并证明其余幺半群需要Ω(n)空间。对于一般半群,情况更为复杂。我们刻画了一类允许常数空间乱序求值算法的半群,并证明该类之外的半群至少需要Ω(log n)空间。