A sequence $e_0,e_1,\ldots$ of edit operations in a string $T$ is called ephemeral if operation $e_i$ constructing string $T^i$, for all $i=2k$ with $k\in\mathbb{N}$, is reverted by operation $e_{i+1}$ that reconstructs $T$. Such a sequence arises when processing a stream of independent edits or testing hypothetical edits. We introduce text indexing with ephemeral substring edits, a new version of text indexing. Our goal is to design a data structure over a given text that supports subsequent pattern matching queries with ephemeral substring insertions, deletions, or substitutions in the text; we require insertions and substitutions to be of constant length. In particular, we preprocess a text $T=T[0\mathinner{.\,.} n)$ over an integer alphabet $Σ=[0,σ)$ with $σ=n^{\mathcal{O}(1)}$ in $\mathcal{O}(n)$ time. Then, we can preprocess any arbitrary pattern $P=P[0\mathinner{.\,.} m)$ given online in $\mathcal{O}(m\log\log m)$ time and $\mathcal{O}(m)$ space and allow any ephemeral sequence of edit operations in $T$. Before reverting the $i$th operation, we report all Occ occurrences of $P$ in $T^i$ in $\mathcal{O}(\log\log n + \text{Occ})$ time. We also introduce pattern matching with ephemeral edits. In particular, we preprocess two strings $T$ and $P$, each of length at most $n$, over an integer alphabet $Σ=[0,σ)$ with $σ=n^{\mathcal{O}(1)}$ in $\mathcal{O}(n)$ time. Then, we allow any ephemeral sequence of edit operations in $T$. Before reverting the $i$th operation, we report all Occ occurrences of $P$ in $T^i$ in the optimal $\mathcal{O}(\text{Occ})$ time. Along our way to this result, we also give an optimal solution for pattern matching with ephemeral block deletions.
翻译:若字符串 $T$ 上的编辑操作序列 $e_0,e_1,\ldots$ 满足:对于所有 $i=2k$(其中 $k\in\mathbb{N}$),操作 $e_i$ 构造出字符串 $T^i$,而随后的操作 $e_{i+1}$ 将其恢复为原始文本 $T$,则称该序列为瞬态编辑序列。此类序列在处理独立编辑流或测试假设性编辑时出现。本文提出了一种支持瞬态子串编辑的文本索引新范式。我们的目标是设计一种数据结构,使其能在给定文本上支持后续伴随瞬态子串插入、删除或替换的模式匹配查询;其中要求插入与替换操作具有恒定长度。具体而言,我们在 $\mathcal{O}(n)$ 时间内对定义在整数字母表 $Σ=[0,σ)$(其中 $σ=n^{\mathcal{O}(1)}$)上的文本 $T=T[0\mathinner{.\,.} n)$ 进行预处理。随后,对于任意在线给定的模式 $P=P[0\mathinner{.\,.} m)$,我们可在 $\mathcal{O}(m\log\log m)$ 时间与 $\mathcal{O}(m)$ 空间内完成预处理,并允许对 $T$ 执行任意瞬态编辑操作序列。在撤销第 $i$ 次操作前,我们能够以 $\mathcal{O}(\log\log n + \text{Occ})$ 时间报告 $P$ 在 $T^i$ 中所有 Occ 次出现。本文同时提出了支持瞬态编辑的模式匹配方法。具体而言,我们在 $\mathcal{O}(n)$ 时间内对两个定义于整数字母表 $Σ=[0,σ)$(其中 $σ=n^{\mathcal{O}(1)}$)且长度不超过 $n$ 的字符串 $T$ 与 $P$ 进行预处理。随后,我们允许对 $T$ 执行任意瞬态编辑操作序列。在撤销第 $i$ 次操作前,我们能够以最优的 $\mathcal{O}(\text{Occ})$ 时间报告 $P$ 在 $T^i$ 中所有 Occ 次出现。在实现该结果的过程中,我们还给出了瞬态块删除模式下模式匹配问题的最优解。