pattern matching
30 papers tagged with this keyword
Smallest Suffixient Sets: Effectiveness, Resilience, and Calculation
A suffixient set is a novel combinatorial object that captures the essential information of repetitive strings in a way that, provided with a random access mechanism, supports various forms of pattern matching. In this paper, we study the size $χ$ of the smallest suffixient set as a repetitiveness measure: we place it between known measures and study its sensitivity to various string operations. As a corollary of our results, we give simple online algorithms to compute smallest suffixient sets.
On the size of the neighborhoods of a word
The d-neighborhood of a word W in the Levenshtein distance is the set of all words at distance at most d from W. Generating the neighborhood of a word W, or related sets of words such as the condensed neighborhood or the super-condensed neighborhood has applications in the design of approximate pattern matching algorithms. It follows that bounds on the maximum size of the neighborhood of words of a given length can be used in the complexity analysis of such approximate pattern matching algorithms. In this note, we present exact formulas for the size of the condensed and super condensed neighborhoods of a unary word, a novel upper bound for the maximum size of the condensed neighborhood of an arbitrary word of a given length, and we prove a conjectured upper bound again for the maximum size of the condensed neighborhood of an arbitrary word of a given length.
$k$-local Graphs
In 2017 Day et al. introduced the notion of locality as a structural complexity-measure for patterns in the field of pattern matching established by Angluin in 1980. In 2019 Casel et al. showed that determining the locality of an arbitrary pattern is NP-complete. Inspired by hierarchical clustering, we extend the notion to coloured graphs, i.e., given a coloured graph determine an enumeration of the colours such that colouring the graph stepwise according to the enumeration leads to as few clusters as possible. Next to first theoretical results on graph classes, we propose a priority search algorithm to compute the $k$-locality of a graph. The algorithm is optimal in the number of marking prefix expansions, and is faster by orders of magnitude than an exhaustive search. Finally, we perform a case study on a DBLP subgraph to demonstrate the potential of $k$-locality for knowledge discovery.
Scalable Pattern Matching in Computation Graphs
Published in EPTCS 417, 2025, pp. 71-95
• View Publication
• BIB
Graph rewriting is a popular tool for the optimisation and modification of graph expressions in domains such as compilers, machine learning and quantum computing. The underlying data structures are often port graphs - graphs with labels at edge endpoints. A pre-requisite for graph rewriting is the ability to find graph patterns. We propose a new solution to pattern matching in port graphs. Its novelty lies in the use of a pre-computed data structure that makes the pattern matching runtime complexity independent of the number of patterns. This offers a significant advantage over existing solutions for use cases with large sets of small patterns.
Our approach is particularly well-suited for quantum superoptimisation. We provide an implementation and benchmarks showing that our algorithm offers a 20x speedup over current implementations on a dataset of 10000 real world patterns describing quantum circuits.
The Subgraph Isomorphism Problem for Port Graphs and Quantum Circuits
We study a variant of the subgraph isomorphism problem that is of high interest to the quantum computing community. Our results give an algorithm to perform pattern matching in quantum circuits for many patterns simultaneously, independently of the number of patterns. After a pre-computation step in which the patterns are compiled into a decision tree, the running time is linear in the size of the input quantum circuit.
More generally, we consider connected port graphs, in which every edge $e$ incident to $v$ has a label $L_v(e)$ unique in $v$. Jiang and Bunke showed that the subgraph isomorphism problem $H \subseteq G$ for such graphs can be solved in time $O(|V(G)| \cdot |V(H)|)$. We show that if in addition the graphs are directed acyclic, then the subgraph isomorphism problem can be solved for an unbounded number of patterns simultaneously. We enumerate all $m$ pattern matches in time $O(P)^{P+3/2} \cdot |V(G)| + O(m)$, where $P$ is the number of vertices of the largest pattern. In the case of quantum circuits, we can express the bound obtained in terms of the maximum number of qubits $N$ and depth $δ$ of the patterns : $O(N)^{N + 1/2} \cdot δ\log δ\cdot |V(G)| + O(m)$.
On the Erdős-Purdy problem and the Zarankiewitz problem for semialgebraic graphs
Erdős and Purdy, and later Agarwal and Sharir, conjectured that any set of $n$ points in $\mathbb R^{d}$ determine at most $Cn^{d/2}$ congruent $k$-simplices for even $d$. We obtain the first significant progress towards this conjecture, showing that this number is at most $C n^{3d/4}$ for $k<d$. As a consequence, we obtain an upper bound of $C n^{3d/4+2}$ for the number of similar $k$-simplices determined by $n$ points in $\mathbb R^d$, which improves the results of Agarwal, Apfelbaum, Purdy and Sharir. This problem is motivated by the problem of exact pattern matching.
We also address Zarankiewicz-type questions of finding the maximum number of edges in semi-algebraic graphs with no $K_{u,u}$. Here, we improve the previous result of Fox, Pach, Sheffer, Suk, and Zahl, and Do for $d\le 4$, as well as for any $d$ and moderately large $u$. We get an improvement of their results for any $d$ and $u$ for unit-distance graphs, which was one of the main applications of their results.
From a more general prospective, our results are proved using classical cutting techniques. In the recent years, we saw a great development of the polynomial partitioning method in incidence geometry that followed the breakthrough result by Guth and Katz. One consequence of that development is that the attention of the researchers in incidence geometry swayed in polynomial techniques. In this paper, we argue that there is a number of open problems where classical techniques work better.
Griddings of permutations and hardness of pattern matching
We study the complexity of the decision problem known as Permutation Pattern Matching, or PPM. The input of PPM consists of a pair of permutations $τ$ (the `text') and $π$ (the `pattern'), and the goal is to decide whether $τ$ contains $π$ as a subpermutation. On general inputs, PPM is known to be NP-complete by a result of Bose, Buss and Lubiw. In this paper, we focus on restricted instances of PPM where the text is assumed to avoid a fixed (small) pattern $σ$; this restriction is known as Av($σ$)-PPM. It has been previously shown that Av($σ$)-PPM is polynomial for any $σ$ of size at most 3, while it is NP-hard for any $σ$ containing a monotone subsequence of length four.
In this paper, we present a new hardness reduction which allows us to show, in a uniform way, that Av($σ$)-PPM is hard for every $σ$ of size at least 6, for every $σ$ of size 5 except the symmetry class of $41352$, as well as for every $σ$ symmetric to one of the three permutations $4321$, $4312$ and $4231$. Moreover, assuming the exponential time hypothesis, none of these hard cases of Av($σ$)-PPM can be solved in time $2^{o(n/\log n)}$. Previously, such conditional lower bound was not known even for the unconstrained PPM problem.
On the tractability side, we combine the CSP approach of Guillemot and Marx with the structural results of Huczynska and Vatter to show that for any monotone-griddable permutation class C, PPM is polynomial when the text is restricted to a permutation from C.
Asymptotic normality for $m$-dependent and constrained $U$-statistics, with applications to pattern matching in random strings and permutations
Published
• View Publication
• BIB
We study (asymmetric) $U$-statistics based on a stationary sequence of $m$-dependent variables; moreover, we consider constrained $U$-statistics, where the defining multiple sum only includes terms satisfying some restrictions on the gaps between indices. Results include a law of large numbers and a central limit theorem. Special attention is paid to degenerate cases where, after the standard normalization, the asymptotic variance vanishes; in these cases non-normal limits occur after a different normalization.
The results are motivated by applications to pattern matching in random strings and permutations. We obtain both new results and new proofs of old results.
Pattern Matching in Set Partitions is NP-Complete
In this note we show that pattern matching in permutations is polynomial time reducible to pattern matching in set partitions. In particular, pattern matching in set partitions is NP-Complete.
A Complexity Dichotomy for Permutation Pattern Matching on Grid Classes
Permutation Pattern Matching (PPM) is the problem of deciding for a given pair of permutations P and T whether the pattern P is contained in the text T. Bose, Buss and Lubiw showed that PPM is NP-complete. In view of this result, it is natural to ask how the situation changes when we restrict the pattern P to a fixed permutation class C; this is known as the C-Pattern PPM problem.
Grid classes are special kind of permutation classes, consisting of permutations admitting a grid-like decomposition into simpler building blocks. Of particular interest are the so-called monotone grid classes, in which each building block is a monotone sequence. Recently, it has been discovered that grid classes, especially the monotone ones, play a fundamental role in the understanding of the structure of general permutation classes. This motivates us to study the hardness of C-Pattern PPM for a (monotone) grid class C.
We provide a complexity dichotomy for C-Pattern PPM when C is taken to be a monotone grid class. Specifically, we show that the problem is polynomial-time solvable if a certain graph associated with C, called the cell graph, is a forest, and it is NP-complete otherwise. We further generalize our results to grid classes whose blocks belong to classes of bounded grid-width. We show that the C-Pattern PPM for such a grid class C is polynomial-time solvable if the cell graph of C avoids a cycle or a certain special type of path, and it is NP-complete otherwise.
Implementing Suffix Array Algorithm Using Apache Big Table Data Implementation
In this paper we will describe a new approach on the well-known suffix-array algorithm using Big Table Data Technology. We will demonstrate how it is possible to refactor a well-known algorithm coupled by taking advantage of an high-performance distributed datastore, to illustrate the advantages of using datastore cloud related technology for storing large text sequences and retrieving them. A case study using DNA strings, considered one of the most difficult pattern matching problem, will be described and evaluated to demonstrate the potentiality of this implementation. Further discussion on performances and other big data related issues will be described as well as new possible lines of research in big data technology for precise medical applications.
On Prefix Normal Words
Published in G. Mauri and A. Leporati (Eds.): DLT 2011, LNCS 6795, pp. 228--238, 2011
• View Publication
• BIB
We present a new class of binary words: the prefix normal words. They are defined by the property that for any given length $k$, no factor of length $k$ has more $a$'s than the prefix of the same length. These words arise in the context of indexing for jumbled pattern matching (a.k.a. permutation matching or Parikh vector matching), where the aim is to decide whether a string has a factor with a given multiplicity of characters, i.e., with a given Parikh vector. Using prefix normal words, we give the first non-trivial characterization of binary words having the same set of Parikh vectors of factors. We prove that the language of prefix normal words is not context-free and is strictly contained in the language of pre-necklaces, which are prefixes of powers of Lyndon words. We discuss further properties and state open problems.
On Prefix Normal Words and Prefix Normal Forms
Published in Theoretical Computer Science, 659: 1-13, 2017
• View Publication
• BIB
A $1$-prefix normal word is a binary word with the property that no factor has more $1$s than the prefix of the same length; a $0$-prefix normal word is defined analogously. These words arise in the context of indexed binary jumbled pattern matching, where the aim is to decide whether a word has a factor with a given number of $1$s and $0$s (a given Parikh vector). Each binary word has an associated set of Parikh vectors of the factors of the word. Using prefix normal words, we provide a characterization of the equivalence class of binary words having the same set of Parikh vectors of their factors.
We prove that the language of prefix normal words is not context-free and is strictly contained in the language of pre-necklaces, which are prefixes of powers of Lyndon words. We give enumeration results on $\textit{pnw}(n)$, the number of prefix normal words of length $n$, showing that, for sufficiently large $n$, \[ 2^{n-4 \sqrt{n \lg n}} \le \textit{pnw}(n) \le 2^{n - \lg n + 1}. \]
For fixed density (number of $1$s), we show that the ordinary generating function of the number of prefix normal words of length $n$ and density $d$ is a rational function. Finally, we give experimental results on $\textit{pnw}(n)$, discuss further properties, and state open problems.
Hardness of Permutation Pattern Matching
Permutation Pattern Matching (or PPM) is a decision problem whose input is a pair of permutations $π$ and $τ$, represented as sequences of integers, and the task is to determine whether $τ$ contains a subsequence order-isomorphic to $π$. Bose, Buss and Lubiw proved that PPM is NP-complete on general inputs.
We show that PPM is NP-complete even when $π$ has no decreasing subsequence of length 3 and $τ$ has no decreasing subsequence of length 4. This provides the first known example of PPM being hard when one or both of $π$ and $σ$ are restricted to a proper hereditary class of permutations.
This hardness result is tight in the sense that PPM is known to be polynomial when both $π$ and $τ$ avoid a decreasing subsequence of length 3, as well as when $π$ avoids a decreasing subsequence of length 2. The result is also tight in another sense: we will show that for any hereditary proper subclass C of the class of permutations avoiding a decreasing sequence of length 3, there is a polynomial algorithm solving PPM instances where $π$ is from C and $τ$ is arbitrary.
We also obtain analogous hardness and tractability results for the class of so-called skew-merged patterns.
From these results, we deduce a complexity dichotomy for the PPM problem restricted to $π$ belonging to $Av(ρ)$, where $Av(ρ)$ denotes the class of permutations avoiding a permutation $ρ$. Specifically, we show that the problem is polynomial when $ρ$ is in the set {1, 12, 21, 132, 213, 231, 312}, and it is NP-complete for any other $ρ$.
An Estimation of the Size of Non-Compact Suffix Trees
A suffix tree is a data structure used mainly for pattern matching. It is known that the space complexity of simple suffix trees is quadratic in the length of the string. By a slight modification of the simple suffix trees one gets the compact suffix trees, which have linear space complexity. The motivation of this paper is the question whether the space complexity of simple suffix trees is quadratic not only in the worst case, but also in expectation.
Paired patterns in lattice paths
Published
• View Publication
• BIB
Let $\mathcal{L}_n$ denote the set of all paths from $[0,0]$ to $[n, n]$ which consist of either unit north steps $N$ or unit east steps $E$ or, equivalently, the set of all words $L \in \{E,N\}^*$ with $n$ $E$'s and $n$ $N$'s. Given $L \in \mathcal{L}_n$ and a subset $A$ of $[n] = \{1, \ldots, n\}$, we let $ps_{L}(A)$ denote the word that results from $L$ by removing the $i^{th}$ occurrence of $E$ and the $i^{th}$ occurrence of $N$ in $L$ for all $i \in [n]-A$, reading from left to right. Then we say that a paired pattern $P \in \mathcal{L}_k$ occurs in $L$ if there is some $A \subseteq [n]$ of size $k$ such that $ps_L(A) = P$. In this paper, we study the generating functions of paired pattern matching in $\mathcal L_n$.
Pattern matching in $(213,231)$-avoiding permutations
Published
• View Publication
• BIB
Given permutations $σ\in S_k$ and $π\in S_n$ with $k<n$, the \emph{pattern matching} problem is to decide whether $π$ matches $σ$ as an order-isomorphic subsequence. We give a linear-time algorithm in case both $π$ and $σ$ avoid the two size-$3$ permutations $213$ and $231$. For the special case where only $σ$ avoids $213$ and $231$, we present a $O(max(kn^2,n^2\log(\log(n)))$ time algorithm. We extend our research to bivincular patterns that avoid $213$ and $231$ and present a $O(kn^4)$ time algorithm. Finally we look at the related problem of the longest subsequence which avoids $213$ and $231$.
The Complexity of Pattern Matching for $321$-Avoiding and Skew-Merged Permutations
Published in Discrete Mathematics & Theoretical Computer Science, Vol. 18 no. 2, Permutation Patterns 2015, Permutation Patterns (December 21, 2016) dmtcs:1308
• View Publication
• BIB
The Permutation Pattern Matching problem, asking whether a pattern permutation $π$ is contained in a permutation $τ$, is known to be NP-complete. In this paper we present two polynomial time algorithms for special cases. The first algorithm is applicable if both $π$ and $τ$ are $321$-avoiding; the second is applicable if $π$ and $τ$ are skew-merged. Both algorithms have a runtime of $O(kn)$, where $k$ is the length of $π$ and $n$ the length of $τ$.
On Searching Zimin Patterns
Published in Theoretical Computer Science, Vol. 571 (2015), 50-57
• View Publication
• BIB
In the area of pattern avoidability the central role is played by special words called Zimin patterns. The symbols of these patterns are treated as variables and the rank of the pattern is its number of variables. Zimin type of a word $x$ is introduced here as the maximum rank of a Zimin pattern matching $x$. We show how to compute Zimin type of a word on-line in linear time. Consequently we get a quadratic time, linear-space algorithm for searching Zimin patterns in words. Then we how the Zimin type of the length $n$ prefix of the infinite Fibonacci word is related to the representation of $n$ in the Fibonacci numeration system. Using this relation, we prove that Zimin types of such prefixes and Zimin patterns inside them can be found in logarithmic time. Finally, we give some bounds on the function $f(n,k)$ such that every $k$-ary word of length at least $f(n,k)$ has a factor that matches the rank $n$ Zimin pattern.
Normal, Abby Normal, Prefix Normal
Published in LNCS 8496, pages 74-88 (2014)
• View Publication
• BIB
A prefix normal word is a binary word with the property that no substring has more 1s than the prefix of the same length. This class of words is important in the context of binary jumbled pattern matching. In this paper we present results about the number $pnw(n)$ of prefix normal words of length $n$, showing that $pnw(n) =Ω\left(2^{n - c\sqrt{n\ln n}}\right)$ for some $c$ and $pnw(n) = O \left(\frac{2^n (\ln n)^2}{n}\right)$. We introduce efficient algorithms for testing the prefix normal property and a "mechanical algorithm" for computing prefix normal forms. We also include games which can be played with prefix normal words. In these games Alice wishes to stay normal but Bob wants to drive her "abnormal" -- we discuss which parameter settings allow Alice to succeed.