401,233 research outputs found
Matching of Compressed Patterns with Character-Variables
We consider the problem of finding an instance of a string-pattern s in a given string under compression by straight line programs (SLP). The variables of the string pattern can be instantiated by single characters. This is a generalisation of the fully compressed pattern match, which is the task of finding a compressed string in another compressed string, which is known to have a polynomial time algorithm.
We mainly investigate patterns s that are linear in the variables, i.e. variables occur at most once in s, also known as partial words.
We show that fully compressed pattern matching with linear patterns can be performed in polynomial time. A polynomial-sized representation of all matches and all substitutions is also computed.
Also, a related algorithm is given that computes all periods of a compressed linear pattern in polynomial time. A technical key result on the structure of partial words shows that an overlap of h+2 copies of a partial word w with at most h holes implies that w is strongly periodic
Matching Patterns with Variables Under Simon's Congruence
We introduce and investigate a series of matching problems for patterns with
variables under Simon's congruence. Our results provide a thorough picture of
these problems' computational complexity
Matching Patterns with Variables Under Edit Distance
A pattern is a string of variables and terminal letters. We say that
matches a word , consisting only of terminal letters, if can be
obtained by replacing the variables of by terminal words. The matching
problem, i.e., deciding whether a given pattern matches a given word, was
heavily investigated: it is NP-complete in general, but can be solved
efficiently for classes of patterns with restricted structure. If we are
interested in what is the minimum Hamming distance between and any word
obtained by replacing the variables of by terminal words (so matching
under Hamming distance), one can devise efficient algorithms and matching
conditional lower bounds for the class of regular patterns (in which no
variable occurs twice), as well as for classes of patterns where we allow
unbounded repetitions of variables, but restrict the structure of the pattern,
i.e., the way the occurrences of different variables can be interleaved.
Moreover, under Hamming distance, if a variable occurs more than once and its
occurrences can be interleaved arbitrarily with those of other variables, even
if each of these occurs just once, the matching problem is intractable. In this
paper, we consider the problem of matching patterns with variables under edit
distance. We still obtain efficient algorithms and matching conditional lower
bounds for the class of regular patterns, but show that the problem becomes, in
this case, intractable already for unary patterns, consisting of repeated
occurrences of a single variable interleaved with terminals
Matching Patterns with Variables Under Hamming Distance
A pattern ? is a string of variables and terminal letters. We say that ? matches a word w, consisting only of terminal letters, if w can be obtained by replacing the variables of ? by terminal words. The matching problem, i.e., deciding whether a given pattern matches a given word, was heavily investigated: it is NP-complete in general, but can be solved efficiently for classes of patterns with restricted structure. In this paper, we approach this problem in a generalized setting, by considering approximate pattern matching under Hamming distance. More precisely, we are interested in what is the minimum Hamming distance between w and any word u obtained by replacing the variables of ? by terminal words. Firstly, we address the class of regular patterns (in which no variable occurs twice) and propose efficient algorithms for this problem, as well as matching conditional lower bounds. We show that the problem can still be solved efficiently if we allow repeated variables, but restrict the way the different variables can be interleaved according to a locality parameter. However, as soon as we allow a variable to occur more than once and its occurrences can be interleaved arbitrarily with those of other variables, even if none of them occurs more than once, the problem becomes intractable
Matching Logic
This paper presents matching logic, a first-order logic (FOL) variant for
specifying and reasoning about structure by means of patterns and pattern
matching. Its sentences, the patterns, are constructed using variables,
symbols, connectives and quantifiers, but no difference is made between
function and predicate symbols. In models, a pattern evaluates into a power-set
domain (the set of values that match it), in contrast to FOL where functions
and predicates map into a regular domain. Matching logic uniformly generalizes
several logical frameworks important for program analysis, such as:
propositional logic, algebraic specification, FOL with equality, modal logic,
and separation logic. Patterns can specify separation requirements at any level
in any program configuration, not only in the heaps or stores, without any
special logical constructs for that: the very nature of pattern matching is
that if two structures are matched as part of a pattern, then they can only be
spatially separated. Like FOL, matching logic can also be translated into pure
predicate logic with equality, at the same time admitting its own sound and
complete proof system. A practical aspect of matching logic is that FOL
reasoning with equality remains sound, so off-the-shelf provers and SMT solvers
can be used for matching logic reasoning. Matching logic is particularly
well-suited for reasoning about programs in programming languages that have an
operational semantics, but it is not limited to this
Efficient Pattern Matching in Python
Pattern matching is a powerful tool for symbolic computations. Applications
include term rewriting systems, as well as the manipulation of symbolic
expressions, abstract syntax trees, and XML and JSON data. It also allows for
an intuitive description of algorithms in the form of rewrite rules. We present
the open source Python module MatchPy, which offers functionality and
expressiveness similar to the pattern matching in Mathematica. In particular,
it includes syntactic pattern matching, as well as matching for commutative
and/or associative functions, sequence variables, and matching with
constraints. MatchPy uses new and improved algorithms to efficiently find
matches for large pattern sets by exploiting similarities between patterns. The
performance of MatchPy is investigated on several real-world problems
Pattern matching with variables: Efficient algorithms and complexity results
A pattern α (i. e., a string of variables and terminals) matches a word w, if w can be obtained by uniformly replacing the variables of α by terminal words. The respective matching problem, i. e., deciding whether or not a given pattern matches a given word, is generally NP-complete, but can be solved in polynomial-time for restricted classes of patterns. We present efficient algorithms for the matching problem with respect to patterns with a bounded number of repeated variables and patterns with a structural restriction on the order of variables. Furthermore, we show that it is NP-complete to decide, for a given number k and a word w, whether w can be factorised into k distinct factors. As an immediate consequence of this hardness result, the injective version (i. e., different variables are replaced by different words) of the matching problem is NP-complete even for very restricted clases of patterns
- …