arXiv:2608.25032cs.DSAug 2026

Manuscript Offprint

arXiv:2608.25032

Fuzzy Pattern Matching in Ordered Structures

Armen Kostanyan, Arevik Harmandayan

Armen Kostanyan c^{c}

American University of Armenia

Yerevan, Armenia

armko@aua.am

Arevik Harmandayan

American University of Armenia

Yerevan, Armenia

arevik.harmandayan@gmail.com

Abstract. The problem of pattern matching, that is, finding all occurrences of a given pattern in a string, is one of the fundamental problems in computer science that has applications in many areas.

In this paper, we consider fuzzy patterns, defined as sequences of fuzzy properties over the basic alphabet. We first consider fuzzy pattern matching for sequences of elements of the basic alphabet and then extend the problem to partially ordered sets of nodes labeled by elements of the basic alphabet. For sequences, we seek segments that match the pattern, whereas for partially ordered structures, we seek saturated chains of nodes that match the pattern.

The key concept underlying the solutions to these problems is the notion of a trajectory, which generalizes the concept of the prefix function used in the Knuth–Morris–Pratt (KMP) algorithm. A trajectory is processed together with the corresponding data structure, allowing the proposed algorithms to be represented as transition systems whose states are trajectories for sequences and trajectories associated with nodes for partially ordered structures. The trajectory-based approach provides a unified framework for fuzzy pattern matching in various data structures.

Keywords: Fuzzy pattern matching, Approximate string matching, KMP-string matching

c^{c}Corresponding author

1. Introduction

String matching, also referred to as pattern matching, is a fundamental problem in computer science. Given a pattern P and a text T, the exact string-matching problem consists of finding all occurrences of P in T. Efficient algorithms for string matching are widely used in applications such as plagiarism detection, cybersecurity, natural language processing, and bioinformatics [1].

In many practical situations, however, exact matching is too restrictive. A pattern may occur in a text with a small number of errors caused by misspellings, mutations, or other variations. This motivates approximate string matching, in which a text segment is considered an occurrence of a pattern if the distance between the two strings does not exceed a given threshold. Two classical models are Hamming-distance matching, which allows a bounded number of character substitutions, and edit-distance matching, which additionally allows insertions and deletions [2].

A related notion is fuzzy string matching, which generally refers to matching techniques that allow a degree of similarity or uncertainty in determining whether two strings correspond. Unlike exact matching and, in some formulations, distance-based approximate matching, fuzzy matching may represent the degree to which a matching condition is satisfied rather than relying solely on a binary match/mismatch criterion or a fixed number of editing operations. Fuzzy string matching has applications in entity resolution, search and information retrieval, and the automatic classification of noisy textual data [3, 4]. Fuzzy approaches have also been investigated in bioinformatics, where uncertainty and variability in biological sequences can make rigid character-by-character comparison inadequate [5].

The distinction between approximate and fuzzy matching is not always made consistently in the literature, and the two terms are sometimes used interchangeably. In this paper, we use the term fuzzy matching in a more specific sense. We consider fuzzy patterns to be sequences of fuzzy properties associated with pattern symbols. Thus, a pattern does not necessarily specify an exact character for each pattern symbol; instead, each pattern symbol specifies a property that the corresponding text character is required to satisfy to a prescribed degree. The matching problem is therefore to find all text segments whose characters satisfy the corresponding fuzzy properties to the specified degree.

Our previous works have addressed several problems in exact and fuzzy string matching. In [6], pattern periodicity was exploited to improve the efficiency of the preprocessing phase of the finite-automaton method and the Knuth–Morris–Pratt (KMP) algorithm. In [7], a nondeterministic transition system was constructed to describe the possible ways of processing a given text in order to find all occurrences of a fuzzy pattern. In [8], an efficient algorithm was proposed for finding all occurrences of a fuzzy pattern in a text, following the principles of the KMP algorithm and using a two-dimensional prefix table. In [9, 10], a different formulation of fuzzy patterns was considered, in which fuzzy properties were associated with text segments. The corresponding problem of finding segmentations of the text—i.e., decompositions into adjacent segments—such that the resulting segments match a fuzzy pattern to a specified degree was investigated.

This paper considers the fuzzy pattern matching problem in two settings.

The first setting extends classical pattern matching to fuzzy pattern matching, where a text segment is the search object. The second generalizes this setting by extending the search space to a finite partially ordered set of nodes, where a saturated chain of nodes serves as the search object. The solutions to both problems are based on the notion of a trajectory, which generalizes the prefix function used in the KMP algorithm by maintaining information about the compatibility of suffixes of the processed sequence with prefixes of the fuzzy pattern.

The paper is organized as follows. Section 2 introduces the basic concepts and definitions. Section 3 presents a solution to the fuzzy pattern matching problem for linear structures. The solution takes the form of an algorithm whose control component follows the structure of the KMP algorithm, while its operational component processes a trajectory object. Section 4 presents a solution to the fuzzy pattern matching problem for hierarchical structures represented by finite ordered rooted trees. The control component of the algorithm traverses the tree in preorder, while its operational component computes the trajectory object at each visited node. Finally, Section 5 concludes the paper and summarizes the main results.