Table of Contents
Fetching ...

Near-Optimal Property Testers for Pattern Matching

Ce Jin, Tomasz Kociumaka

TL;DR

This work develops near-optimal sublinear testers for the exact pattern matching problem under a $k$-mismatch threshold. It introduces adaptive and non-adaptive property testers that cover the full parameter spectrum, leveraging a novel mismatch-container lemma and structured $p$-periodic sampling with Karp–Rabin fingerprints to achieve sublinear running times. The authors prove unconditional lower bounds matching the upper bounds up to polylog factors, including a separation between adaptive and non-adaptive regimes in the $n=m+o(m)$ setting, and extend the framework to tolerant and reporting variants. Collectively, the results close the gap to folklore and prior sublinear testers, providing a comprehensive, near-tight characterization of the complexity landscape for property testing of pattern matching.

Abstract

The classic exact pattern matching problem, given two strings -- a pattern $P$ of length $m$ and a text $T$ of length $n$ -- asks whether $P$ occurs as a substring of $T$. A property tester for the problem needs to distinguish (with high probability) the following two cases for some threshold $k$: the YES case, where $P$ occurs as a substring of $T$, and the NO case, where $P$ has Hamming distance greater than $k$ from every substring of $T$, that is, $P$ has no $k$-mismatch occurrence in $T$. In this work, we provide adaptive and non-adaptive property testers for the exact pattern matching problem, jointly covering the whole spectrum of parameters. We further establish unconditional lower bounds demonstrating that the time and query complexities of our algorithms are optimal, up to $\mathrm{polylog}\, n$ factors hidden within the $\tilde O(\cdot)$ notation below. In the most studied regime of $n=m+Θ(m)$, our non-adaptive property tester has the time complexity of $\tilde O(n/\sqrt{k})$, and a matching lower bound remains valid for the query complexity of adaptive algorithms. This improves both upon a folklore solution that attains the optimal query complexity but requires $Ω(n)$ time, and upon the only previously known sublinear-time property tester, by Chan, Golan, Kociumaka, Kopelowitz, and Porat [STOC 2020], with time complexity $\tilde O(n/\sqrt[3]{k})$. The aforementioned results remain valid for $n=m+Ω(m)$, where our optimal running time $\tilde O(\sqrt{nm/k}+n/k)$ improves upon the previously best time complexity of $\tilde O(\sqrt[3]{n^2m/k}+n/k)$. In the regime of $n=m+o(m)$, which has not been targeted in any previous work, we establish a surprising separation between adaptive and non-adaptive algorithms, whose optimal time and query complexities are $\tilde O(\sqrt{(n-m+1)m/k}+n/k)$ and $\tilde O(\min(n\sqrt{n-m+1}/k,\sqrt{nm/k}+n/k))$, respectively.

Near-Optimal Property Testers for Pattern Matching

TL;DR

This work develops near-optimal sublinear testers for the exact pattern matching problem under a -mismatch threshold. It introduces adaptive and non-adaptive property testers that cover the full parameter spectrum, leveraging a novel mismatch-container lemma and structured -periodic sampling with Karp–Rabin fingerprints to achieve sublinear running times. The authors prove unconditional lower bounds matching the upper bounds up to polylog factors, including a separation between adaptive and non-adaptive regimes in the setting, and extend the framework to tolerant and reporting variants. Collectively, the results close the gap to folklore and prior sublinear testers, providing a comprehensive, near-tight characterization of the complexity landscape for property testing of pattern matching.

Abstract

The classic exact pattern matching problem, given two strings -- a pattern of length and a text of length -- asks whether occurs as a substring of . A property tester for the problem needs to distinguish (with high probability) the following two cases for some threshold : the YES case, where occurs as a substring of , and the NO case, where has Hamming distance greater than from every substring of , that is, has no -mismatch occurrence in . In this work, we provide adaptive and non-adaptive property testers for the exact pattern matching problem, jointly covering the whole spectrum of parameters. We further establish unconditional lower bounds demonstrating that the time and query complexities of our algorithms are optimal, up to factors hidden within the notation below. In the most studied regime of , our non-adaptive property tester has the time complexity of , and a matching lower bound remains valid for the query complexity of adaptive algorithms. This improves both upon a folklore solution that attains the optimal query complexity but requires time, and upon the only previously known sublinear-time property tester, by Chan, Golan, Kociumaka, Kopelowitz, and Porat [STOC 2020], with time complexity . The aforementioned results remain valid for , where our optimal running time improves upon the previously best time complexity of . In the regime of , which has not been targeted in any previous work, we establish a surprising separation between adaptive and non-adaptive algorithms, whose optimal time and query complexities are and , respectively.
Paper Structure (14 sections, 44 theorems, 45 equations, 3 figures, 2 algorithms)

This paper contains 14 sections, 44 theorems, 45 equations, 3 figures, 2 algorithms.

Key Result

Theorem 4

pr:tester can be solved (correctly with high probability) by a non-adaptive algorithm with time complexity ${\hbox{$\widetilde{\space}$}\mathcal{O}\xspace}\xspace(\sqrt[3]{\tfrac{n^2m}{k}} + \tfrac{n}{k})$. \begin{tikzpicture}[baseline=(t-text.base)]{\pic (t) at (0,0) {hookright={thick,draw=\@dis@cl

Figures (3)

  • Figure 1: The optimal time and query complexities of adaptive (below) and non-adaptive (above) property testers solving \ref{['pr:tester']} for different ranges of $\Delta\coloneqq n-m+1$. (The breakpoints $\frac{m}{k}$ and $k$ drawn on the horizontal axis may switch order depending on whether $k\ge \sqrt{m}$.)
  • Figure 2: Illustration of the execution of the algorithm of ChanGKKP20 for $p = 11$ and $B=\{2,8\}$; see also \ref{['ex:cgkkp']}. The algorithm reads the colorful positions of $P$ and $T$, where each color corresponds to a separate element of the sets $U=\{0,1,2,3\}$ and $V=\{0,4,8\}$. When checking the candidate position $i=17$, the algorithm (implicitly) makes comparisons indicated by arrows. In this example, the comparisons are between the green positions in $P$ (corresponding to $u=2$) and the dark blue positions in $T$ (corresponding to $v=4$). The subsequences $X_u$ of $P$ and $Y_v$ of $T$ are obtained by concatenating positions (of $P$ or $T$, respectively) of the same color. In our example, each position has at most one color; in general, they may have up to $|B|$ colors.
  • Figure 3: Illustration of \ref{['lem:temp-mismatchcontainer']} for sample binary strings $P,T\in\{\mathtt{0},\mathtt{1}\}^{*}$ and $k=2$. In this case, we can set $M^{(P)}=\{0,1,3\}$ and $M^{(T)}=\{8,12,13,15,21\}$; selected positions are highlighted in blue. For each $i\in [0.\,. n-m]$, at least $\min(2, |M_i|)$ mismatches involve a position in $M^{(P)}$ or $M^{(T)}$; the figure illustrates this for $i\in \{0,6,10,19,20\}$, with mismatches drawn in red. For $i=0$, the four mismatches include $P[1]\ne T[1]$ (with $1\in M^{(P)}$) and $P[8]\ne T[8]$ (with $8\in M^{(T)}$); for $i=10$, the only mismatch is $P[2]\ne T[12]$ (with $12\in M^{(T)}$); for $i=19$, the three mismatches include $P[0]\ne T[19]$ (with $0\in M^{(P)}$) and $P[2]\ne T[21]$ (with $21\in M^{(T)}$).

Theorems & Definitions (49)

  • Theorem 4: ChanGKKP20
  • Theorem 5
  • Theorem 6
  • Theorem 7
  • Theorem 8
  • Theorem 12
  • Example 13: see \ref{['fig:cgkkp']}
  • Lemma 14: see the full statement in \ref{['thm:mismatchcontainer']} and an illustration in \ref{['fig:container']}
  • Lemma 15: Fingerprints
  • Theorem 16
  • ...and 39 more