In the mathematical study of combinatorics on words, a parameter word is a string over a given alphabet having some number of wildcard characters.[1] The set of strings matching a given parameter word is called a parameter set or combinatorial cube. Parameter words can be composed, to produce smaller subcubes of a given combinatorial cube. They have applications in Ramsey theory and in computer science in the detection of duplicate code.

Definitions and notation

edit

Formally, a  -parameter word of length  , over a given alphabet  , is a sequence of   characters, some of which may be drawn from   and the others of which are   distinct wildcard characters  . Each wildcard character is required to appear at least once, but may appear multiple times, and the wildcard characters must appear in the order given by their indexes: the first wildcard character in the word must be  , the next one that is different from   must be  , etc. As a special case, a word over the given alphabet, without any wildcard characters, is said to be a 0-parameter word. For 1-parameter words, the subscripts may be omitted, as there is no ambiguity between different wildcard characters. The set of all  -parameter words over  , of length  , is denoted  .[1]

A  -parameter word represents a set of   strings (0-parameter words), obtained by substituting a symbol of   for each wildcard character. This set of strings is called a parameter set of combinatorial cube, and   is called its dimension. A one-dimensional combinatorial cube may be called a combinatorial line.[1]

In a combinatorial cube, each copy of a particular wildcard character must have the same replacement. A generalization of parameter words allows different copies of the same wildcard character to be replaced by different characters from the alphabet, in a controlled way. If   is an alphabet and   is a group with an action on  , then a  -labeled parameter word is a  -parameter word together with an assignment of a group element to each wildcard character in the word. The first occurrence of each wildcard character must be assigned the identity element of the group. Then, the strings represented by a labeled parameter word are obtained by choosing a character of   for each wildcard character, and substituting the result of combining that character with the group element labeling each copy of that character. The set of all  -labeled  -parameter words over  , of length  , is denoted  .[1]

Example

edit

In the game of tic-tac-toe, the cells of the game board can be given two integer coordinates   from the alphabet  . Concatenating these two coordinates produces a string representing each cell, one of the nine strings   or  . There are seven one-parameter words of length two over this alphabet, the words   and  . The corresponding combinatorial lines form seven of the eight lines of three cells in a row of the tic-tac-toe board; for instance, the one-parameter word   corresponds to the combinatorial line  , and the one-parameter word   corresponds to the combinatorial line  .[2]

However, one of the eight winning lines of the tic-tac-toe game is missing from this set of combinatorial lines: the antidiagonal line  . It is possible to obtain this line as a combinatorial line (without including any other combinations of cells that would be invalid for tic-tac-toe) by using a group with two elements, and an action in which the non-identity element swaps the alphabet letters   and   while leaving the element   in place. There are eight labeled one-parameter words of length two for this action, seven of which are obtained from the unlabeled one-parameter words by using the identity label for all wildcards. These seven have the same combinatorial lines as before. The eighth labeled word consists of the word   labeled by the identity element for its first   and the reversing non-identity element for the second  ; its combinatorial line is the final winning line of the tic-tac-toe board,  .[2]

Composition

edit

For three given integer parameters  , it is possible to combine two parameter words,   and  , to produce another parameter word  . To do so, simply replace each copy of the  th wildcard symbol in   by the  th character in  . This will necessarily produce a word of length   that uses each of the wildcard symbols in   at least once, in ascending order, so it produces a valid  -parameter word of length  . This notion of composition can also be extended to composition of labeled parameter words (both using the same alphabet and group action), by applying the group action to the non-wildcard substituted characters and composing the group labels for the wildcard substituted characters. A subset of a combinatorial cube is a smaller combinatorial cube if it can be obtained by a composition in this way.[1]

Combinatorial enumeration

edit

The number of parameter words in   for an alphabet of size   is an  -Stirling number of the second kind  . These numbers count the number of partitions of the integers in the range   into   non-empty subsets such that the first   integers belong to distinct subsets. Partitions of this type can be placed into a bijective equivalence with the parameter words, by creating a word with a character for each of the   integers in the range  , setting this character value to be either an integer in   belonging to the same subset of the partition, or a wildcard character for each subset of the partition that does not contain an integer in  . The  -Stirling numbers obey a simple recurrence relation by which they may easily be calculated.[3][4]

Applications

edit

In Ramsey theory, parameter words and combinatorial cubes may be used to formulate the Graham–Rothschild theorem, according to which, for every finite alphabet and group action, and every combination of integer values  ,  , and  , there exists a sufficiently large number   such that if each  -dimensional combinatorial cube over strings of length   is assigned one of   colors, then there exists a  -dimensional combinatorial cube all of whose  -dimensional subcubes have the same color. This result is a key foundation for structural Ramsey theory, and is used to define Graham's number, an enormous number used to estimate the value of   for a certain combination of values.[1]

In computer science, in the problem of searching for duplicate code, the source code for a given routine or module may be transformed into a parameter word by converting it into a sequence of tokens, and for each variable or subroutine name, replacing each copy of the same name with the same wildcard character. If code is duplicated, the resulting parameter words will remain equal even if some of the variables or subroutines have been renamed. More sophisticated searching algorithms can find long duplicate code sections that form substrings of larger source code repositories, by allowing the wildcard characters to be substituted for each other.[5]

An important special case of parameter words, well-studied in the combinatorics of words, is given by the partial words. These are strings with wildcard characters that may be substituted independently of each other, without requiring that some of the substituted characters be equal or controlled by a group action. In the language of parameter words, a partial word may be described as a parameter word in which each wildcard symbol appears exactly once. However, because there is no repetition of wildcard symbols, partial words may be written more simply by omitting the subscripts on the wildcard symbols.[6]

See also

edit

References

edit
  1. ^ a b c d e f Prömel, Hans Jürgen (2002), "Large numbers, Knuth's arrow notation, and Ramsey theory", Synthese, 133 (1–2): 87–105, doi:10.1023/A:1020879709125, JSTOR 20117296, MR 1950045
  2. ^ a b Prömel, Hans Jürgen (2013), "Hales–Jewett's Theorem", Ramsey Theory for Discrete Structures, Springer International Publishing, pp. 41–51, doi:10.1007/978-3-319-01315-2_4
  3. ^ Broder, Andrei Z. (1984), "The  -Stirling numbers", Discrete Mathematics, 49 (3): 241–259, doi:10.1016/0012-365X(84)90161-4, MR 0743795
  4. ^ Benzait, A.; Voigt, B. (1989), "A combinatorial interpretation of  ", Proceedings of the Oberwolfach Meeting "Kombinatorik" (1986), Discrete Mathematics, 73 (1–2): 27–35, doi:10.1016/0012-365X(88)90130-6, MR 0974810
  5. ^ Baker, Brenda S. (1997), "Parameterized duplication in strings: algorithms and an application to software maintenance", SIAM Journal on Computing, 26 (5): 1343–1362, doi:10.1137/S0097539793246707, MR 1471985
  6. ^ Blanchet-Sadri, Francine (2008), Algorithmic Combinatorics on Partial Words, Discrete Mathematics and its Applications, Boca Raton, Florida: Chapman & Hall/CRC, ISBN 978-1-4200-6092-8, MR 2384993