 PatternCanonicalForm - Maple Help

StringTools

 PatternEquivalent
 determine whether two strings determine equivalent patterns
 PatternCanonicalForm
 compute the pattern canonical form of a string Calling Sequence PatternEquivalent( s, t ) PatternCanonicalForm( s ) PatternCanonicalForm( s, 'base' = ch ) Parameters

 s - Maple string t - Maple string ch - character; Maple character (string of length equal to one) Description

 • The PatternEquivalent command determines whether the two strings s and t define equivalent (isomorphic) patterns. Two strings s and t are pattern equivalent if they have the same length and if, for all indices i and j with $1<=i one has ${s}_{i}={s}_{j}$ if, and only if, ${t}_{i}={t}_{j}$.
 • The PatternCanonicalForm command computes the pattern canonical form of the string s. This is defined to be the lexicographically least string pattern equivalent to s. Note that two strings are pattern equivalent precisely when they have the same pattern canonical form.
 • Since the numerically least character that can appear in a Maple string has ASCII value equal to $1$, and low ASCII values are generally not printable, the PatternCanonicalForm command takes a 'base' = ch option, which allows you to specify the numerically least character you would like to appear in the output string. In the presence of this option, the pattern canonical form is computed using the specified character rather than the character Char( 1 ). This option is intended mainly for interactive use and debugging. The PatternCanonicalForm command runs measurably faster in the absence of the base option.
 • All of the StringTools package commands treat strings as (null-terminated) sequences of $8$-bit (ASCII) characters.  Thus, there is no support for multibyte character encodings, such as unicode encodings. Examples

 > $\mathrm{with}\left(\mathrm{StringTools}\right):$
 > $\mathrm{PatternEquivalent}\left("abc","xyz"\right)$
 ${\mathrm{true}}$ (1)
 > $\mathrm{PatternEquivalent}\left("abc","xyx"\right)$
 ${\mathrm{false}}$ (2)
 > $\mathrm{Visible}\left(\mathrm{PatternCanonicalForm}\left("abc"\right)\right)$
 ${"\1\2\3"}$ (3)
 > $\mathrm{PatternCanonicalForm}\left("abc",'\mathrm{base}'="a"\right)$
 ${"abc"}$ (4)
 > $\mathrm{PatternCanonicalForm}\left("xyz",'\mathrm{base}'="a"\right)$
 ${"abc"}$ (5)
 > $\mathrm{PatternCanonicalForm}\left("xyx",'\mathrm{base}'="a"\right)$
 ${"aba"}$ (6)