PARIKH MATRICES AND STRONG M-EQUIVALENCE WEN CHEAN TEH 5 1 0 2 Abstract. Parikh matrices have been a powerful tool in arithmetizing n words by numerical quantities. However, the dependence on the ordering u of the alphabet is inherited by Parikh matrices. Strong M-equivalence is J proposed as a canonical alternative to M-equivalence to get rid of this un- 3 desirable property. Some characterization of strong M-equivalence for a 2 restricted class of words is obtained. Finally, the existential counterpart of strong M-equivalence is introduced as well. ] O C 1. introduction . h Parikh matrices were introduced in [7] as an extension of the Parikh vec- t a tors [9]. The definition of Parikh matrices is ingenious, natural, intuitive and m amazingly simple. Still, Parikh matrices prove to be a powerful tool in studying [ (scattered) subword occurrences, for example, see [5,8,11,13,14]. Nevertheless, 2 due to the limited number of entries in a Parikh matrix, not every word is v 4 uniquely determined by its Parikh matrix. Two words are M-equivalent iff 5 they have the same Parikh matrix and a word is M-unambiguous iff it is not 3 M-equivalent to another distinct word. The characterization of M-equivalence, 7 0 as well as, M-ambiguity has been the most actively researched problem in this . 1 area, for example, see [1–4,6,12,15–20]. 0 Inherent in the definition of Parikh matrices is the dependency on the order- 5 ing of the alphabet. Because of this, the words acb and cab are M-equivalent 1 : with respect to a b c but they are not M-equivalent with respect to v { < < } i a c b . This undesirable property hasled us to proposethe notionofstrong X { < < } M-equivalence, one that is absolute in the sense that not only dependency on r a the ordering of the alphabet is avoided, independency from the alphabet is also achieved. This notionisin facta natural combinatorial propertybetween words that does not rely on Parikh matrices. The remainder of this paper is structured as follows. Section 2 provides the basic definitions and terminology. The next section introduces the no- tion of strong M-equivalence and a strictly weaker notion of MSE-equivalence. However, MSE-equivalence is shown to coincide with strong M-equivalence for sufficiently simple ternary words in the subsequent section. As a side result, relatively simple counterexamples witnessing the fact that ME-equivalence is strictly weaker than M-equivalence are shown to exist, as opposed to the mys- terious counterexample of length 15 provided in [16]. The following section sees the introduction of the opposite notionof “weakly M-related”. Our conclusions follow after that, highlighting some future problems. 2000 Mathematics Subject Classification. 68R15, 68Q45,05A05. Key words and phrases. Parikhmatrices,subword, M-equivalence,strong M-equivalence. 1 PARIKH MATRICES AND STRONG M-EQUIVALENCE 2 2. Subwords and Parikh Matrices The cardinality of a set X is denoted by X . ∣ ∣ Suppose Σ is a finite alphabet. The set of words over Σ is denoted by Σ∗. The empty word is denoted by λ. Let Σ+ denote the set Σ∗ λ . If v,w Σ∗, /{ } ∈ the concatenation of v and w is denoted by vw. An ordered alphabet is an alphabet Σ a1,a2,...,as with an ordering on it. For example, if a1 a2 = { } < < as, then we may write Σ a1 a2 as . On the other hand, if ⋯ < = { < < ⋯ < } Σ a1 a2 as is an ordered alphabet, then the underlying alphabet is = { < < ⋯ < } a1,a2,...,as . For 1 i j s, let ai,j denote the word aiai+1 aj. Frequently, { } ≤ ≤ ≤ ⋯ we will abuse notation and use Σ to stand for both the ordered alphabet and its underlying alphabet, for example, as in “w Σ∗”, when Σ is an ordered ∈ alphabet. If w Σ∗, then w is the length of w. Suppose Γ Σ. The projective morphism πΓ Σ∈∗ →Γ∗ is d∣efi∣ned by ⊆ ∶ a, if a Γ πΓ a ∈ ( )={λ, otherwise. We may write π for π . a,b {a,b} Definition 2.1. A word w′ is a subword of a word w Σ∗ iff there exist ∈ x1,x2,...,xn,y0,y1,...,yn Σ∗, some of them possibly empty, such that ∈ w′ x1x2 xn and w y0x1y1 yn−1xnyn. = ⋯ = ⋯ In the literature, our subwords are usually called “scattered subwords”. The number of occurrences of a word u as a subword of w is denoted by w . u ∣ ∣ Two occurrences of u are considered different iff they differ by at least one position of some letter. For example, aabab 5 and baacbc 2. By ab abc ∣ ∣ = ∣ ∣ = convention, w 1 for all w Σ∗. The support of w, denoted supp w , is the λ ∣ ∣ = ∈ ( ) set a Σ w 0 . Note that the support of w is independent of Σ. The a { ∈ ∣ ∣ ∣ ≠ } reader is referred to [10] for language theoretic notions not detailed here. For any integer k 2, let M denote the multiplicative monoid of k k upper k ≥ × triangular matrices with nonnegative integral entries and unit diagonal. Definition 2.2. Suppose Σ a1 a2 as is an ordered alphabet. The = { < < ⋯ < } Parikh matrix mapping, denoted ΨΣ, is the monoid morphism ΨΣ Σ∗ →Ms+1 ∶ defined as follows: if ΨΣ aq mi,j 1≤i,j≤s+1, then mi,i 1 for each 1 i s 1, mq,q+1 1 and all ( ) = ( ) = ≤ ≤ + = other entries of the matrix ΨΣ aq are zero. Matrices of the form ΨΣ w for ( ) ( ) w Σ∗ are called Parikh matrices. ∈ Theorem 2.3. [7] Suppose Σ a1 a2 as is an ordered alphabet and = { < < ⋯ < } w Σ∗. The matrix ΨΣ w mi,j 1≤i,j≤s+1 has the following properties: ∈ ( )=( ) m 1 for each 1 i s 1; i,i ● = ≤ ≤ + m 0 for each 1 j i s 1; i,j ● = ≤ < ≤ + ● mi,j+1 =∣w∣ai,j for each 1≤i≤j ≤s. The Parikh vector Ψ w w , w ,..., w of a word w Σ∗ is embed- ( )=(∣ ∣a1 ∣ ∣a2 ∣ ∣as) ∈ ded in the second diagonal of the Parikh matrix ΨΣ w . ( ) PARIKH MATRICES AND STRONG M-EQUIVALENCE 3 Example 2.4. Suppose Σ a b c and w babcc. Then ={ < < } = ΨΣ w ΨΣ b ΨΣ a ΨΣ b ΨΣ c ΨΣ c ( )= ( ) ( ) ( ) ( ) ( ) 1 0 0 0 1 1 0 0 1 0 0 0 ⎛0 1 1 0⎞⎛0 1 0 0⎞ ⎛0 1 0 0⎞ ⎜ ⎟⎜ ⎟ ⎜ ⎟ =⎜0 0 1 0⎟⎜0 0 1 0⎟⋯⎜0 0 1 1⎟ ⎜ ⎟⎜ ⎟ ⎜ ⎟ 0 0 0 1 0 0 0 1 0 0 0 1 ⎝ ⎠⎝ ⎠ ⎝ ⎠ 1 1 1 2 1 w w w a ab abc ⎛0 1 2 4⎞ ⎛0 ∣ 1∣ ∣w∣ ∣w∣ ⎞ ⎜ ⎟ ⎜ ∣ ∣b ∣ ∣bc⎟. =⎜0 0 1 2⎟=⎜0 0 1 w c ⎟ ⎜ ⎟ ⎜ ∣ ∣ ⎟ 0 0 0 1 0 0 0 1 ⎝ ⎠ ⎝ ⎠ Definition 2.5. Suppose Σ a1 a2 as is an ordered alphabet. ={ < <⋯< } (1) Two words w,w′ Σ∗ are M-equivalent, denoted w M w′, iff ΨΣ w ∈ ≡ ( ) = ΨΣ w′ . ( ) (2) A word w Σ∗ is M-unambiguous iff no distinct word is M-equivalent ∈ to w. Otherwise, w is said to be M-ambiguous. Note that the notion of M-equivalence, as well as M-ambiguity, depends on the ordered alphabet Σ. However, for the various relations that we will encounter in this article, the reference to the respective ordered/unordered al- phabet often will be suppressed, assuming it is understood from the context. The following are two elementary rules for deciding whether two words are M-equivalent. Suppose Σ a1 a2 as and w,w′ Σ∗. ={ < <⋯< } ∈ E1. If w xa a y and w′ xa a y for some x,y Σ∗ and k l 2, then k l l k = = ∈ ∣ − ∣ ≥ w w′. M ≡ E2. If w xakak+1yak+1akz and w′ xak+1akyakak+1z for some 1 k s 1, = = ≤ ≤ − x,z Σ∗, and y Σ ak−1,ak+2 ∗, then w M w′. ∈ ∈( /{ }) ≡ RuleE1isobviouslyvalidbyTheorem2.3. Inother words, theParikhmatrix of a word w is not sensitive to the mutual ordering of any two consecutive dis- tinct letters in w that are not consecutive in the ordered alphabet. Meanwhile, Rule E2 is sufficient to characterize M-equivalence for the binary alphabet. Theorem 2.6. [1,6] Suppose Σ is a binary ordered alphabet and w,w′ Σ∗. ∈ Then w and w′ are M-equivalent if and only if w′ can be obtained from w by finitely many applications of Rule E2 (more precisely, the rewriting rule implicitly stated in Rule E2). Example 2.7. Applying Rule E2, w baaabbba → abababba → abbaabab w′. = = Hence, w and w′ are M-equivalent with respect to a b . { < } Definition 2.8. Suppose Σ is an ordered alphabet and w,w′ Σ∗. We say that ∈ w and w′ are 1-equivalent, denoted w 1 w′, iff w′ can be obtained from w by ≡ finitely many applications of Rule E1. We say that w and w′ are elementarily matrix equivalent (ME-equivalent), denoted w w′, iff w′ can be obtained ME ≡ from w by finitely many applications of Rule E1 and Rule E2. The term ME-equivalence is due to Salomaa [15]. Historically, it was claimed in [2] that ME-equivalence characterizes M-equivalence for any alphabet. How- ever, it was overturned in [16] through the counterexample babcbabcbabcbab and PARIKH MATRICES AND STRONG M-EQUIVALENCE 4 bbacabbcabbcbba. The two words are M-equivalent with respect to a b c { < < } but neither Rule E1 nor Rule E2 can be applied to the former word. Finally, a simple lemma relating Parikh matrices to morphisms induced by permutationsontheorderedalphabetisneeded. SupposeΣ a1 a2 as ={ < <⋯< } is an ordered alphabet. Let Sym s denote the symmetric group of order s ( ) and σ Sym s . Then σ induces a morphism σ′ from Σ∗ onto Σ∗ defined by ∈ ( ) σ′ a a for1 i s. Forsimplicity, wemayidentifyσ′ withσ andwriteσw i σ(i) ( )= ≤ ≤ for σ′ w . Let σΣ denote the ordered alphabet aσ−1(1) aσ−1(2) aσ−1(s) . ( ) { < <⋯< } Lemma 2.9. Suppose Σ a1 a2 as and σ Sym s . Then ΨΣ σw ={ < <⋯< } ∈ ( ) ( )= ΨσΣ w for all w Σ∗. ( ) ∈ Proof. Since ΨΣ, ΨσΣ and σ are morphisms, the lemma holds since for 1 q s, ΨΣ σaq ΨσΣ aq , which follows because σaq aσ(q) and aq aσ−1(σ(q))≤. ≤(cid:3) ( )= ( ) = = 3. Strong M-equivalence The core object ofthis study will nowbe formallyintroduced. As a reminder, unless explicitly stated, an alphabet does not come with an ordering on it. Definition 3.1. Suppose Σ is an alphabet. Two words w,w′ Σ∗ are strongly s ∈ M-equivalent, denoted w w′, iff w and w′ are M-equivalent with respect to M ≡ any ordered alphabet with underlying alphabet Σ. s Proposition 3.2. Suppose Σ is an alphabet. The relation is an equivalence M ≡ s relation on Σ∗ that is left invariant (respectively right invariant), meaning w M s s ≡ w′ if and only if vw vw′ (respectively wv w′v) for all w,w′,v Σ∗. M M ≡ ≡ ∈ Proof. This follows because M-equivalence has such properties. (cid:3) Generally, strong M-equivalence is strictly stronger than M-equivalence. However, if w and w′ are M-equivalent with respect to a b , then w and w′ { < } are M-equivalent with respect to b a as well by Theorem 2.3 and the iden- { < } tity v v v v . Hence, for the binary alphabet, strong M-equivalence ab ba a b ∣ ∣ +∣ ∣ =∣ ∣ ∣ ∣ is nothing more than M-equivalence. Theorem 3.3. Suppose Σ is an alphabet and w,w′ Σ∗. Then w and w′ are ∈ strongly M-equivalent if and only if for every v Σ∗ such that v 1 for all a ∈ ∣ ∣ ≤ a Σ, we have w w′ . v v ∈ ∣ ∣ =∣ ∣ (cid:3) Proof. This is immediate from Theorem 2.3 and the definition. Theorem 3.3 should put to rest any doubt on the significance of strong M-equivalence. It shows that strong M-equivalence is indeed avery naturaland symmetrical combinatorial property between words. Futhermore, the property does not invoke Parikh matrices and thus need not factor in the ordering of the alphabet. In fact, this could have taken to be the defining property of strong M-equivalence. Furthermore, unlike M-equivalence, strong M-equivalence is absolute in the sense that it is independent from the alphabet, as provided by the next propo- sition. Hence, we can simply say that two words are strongly M-equivalent without implicitly/explicitly referring to any specific alphabet. PARIKH MATRICES AND STRONG M-EQUIVALENCE 5 Proposition 3.4. Suppose Σ and Γ are alphabets and w,w′ Σ Γ ∗. Then ∈ ( ∩ ) w and w′ are strongly M-equivalent with respect to Σ if and only if they are strongly M-equivalent with respect to Γ. Proof. Itsuffices toproveanyonedirection. Assume w isstronglyM-equivalent to w′ with respect to Σ. Fix v Γ∗ such that v 1 for all a Γ. If v Σ∗, then a ∈ ∣ ∣ ≤ ∈ ∉ clearly w 0 w′ . Otherwise, w w′ by Theorem 3.3. Therefore, w v v v v and w′ a∣ re∣ s=tron=gl∣y M∣ -equivalent wi∣th∣ re=sp∣ ec∣t to Γ by Theorem 3.3 again. (cid:3) From the definition, two words are strongly M-equivalent if and only if they are indistinguishable by any Parikh matrix mapping with respect to some or- dering on the alphabet. However, we can still cast strong M-equivalence in terms of a single Parikh matrix mapping. Proposition 3.5. Suppose Σ is an ordered alphabet and w,w′ Σ∗. ∈ (1) Then w and w′ are strongly M-equivalent if and only if ΨΣ σw ( ) = ΨΣ σw′ for all σ Sym Σ . ( ) ∈ (∣ ∣) (2) If w and w′ are strongly M-equivalent, then σw and σw′ are strongly M-equivalent for all σ Sym Σ . ∈ (∣ ∣) (3) If w and w′ are strongly M-equivalent, then πΓ w and πΓ w′ are ( ) ( ) strongly M-equivalent for all Γ Σ. ⊆ Proof. Part 1 follows from Lemma 2.9 while Part 2 follows from Part 1. Part 3 follows from Theorem 3.3 because πΓ w v w v for all w Σ∗ and v Γ∗. (cid:3) ∣ ( )∣ =∣ ∣ ∈ ∈ Clearly, if w′ is obtained from w by swapping some two consecutive distinct letters, then w and w′ are not strongly M-equivalent. The following rule is an analogue of Rule E2 for strong M-equivalence. The next proposition shows that it is a sound rule. Suppose Σ is an alphabet and w,w′ Σ∗. ∈ SE. If w xαβyβαz and w′ xβαyαβz for some α,β Σ, x,z Σ∗, and = = ∈ ∈ y α,β ∗, then w and w′ are strongly M-equivalent. ∈{ } Remark 3.6. For the binary alphabet, Rule SE coincides with Rule E2. Definition 3.7. Suppose Σ is an alphabet and w,w′ Σ∗. We say that w ∈ and w′ are strongly elementarily matrix equivalent (MSE-equivalent), denoted w w′, iff w′ results from w by finitely many applications of Rule SE. MSE ≡ Proposition 3.8. Suppose Σ is an alphabet and w,w′ Σ∗. If w and w′ are ∈ MSE-equivalent, then they are strongly M-equivalent. Proof. We may assume that w′ is obtained from w by a single application of rule SE because of transitivity of strong M-equivalence. Suppose w xαβyβαz = and w′ xβαyαβz for some α,β Σ, x,z Σ∗, and y α,β ∗. Suppose Γ is = ∈ ∈ ∈ { } any ordered alphabet with underlying alphabet Σ. By Rule E1 and Rule E2, w is M-equivalent to w′ with respect to Γ, regardless of whether α and β are consecutive or not in Γ. Hence, w is strongly M-equivalent to w′. (cid:3) JustasME-equivalencefailstocharacterizeM-equivalence, MSE-equivalance doesnotcharacterizestrongM-equivalenceeither(seeExample4.3). Motivated by the historical development accounted after Definition 2.8, our next section is the outcome of our attempt to address the following question. PARIKH MATRICES AND STRONG M-EQUIVALENCE 6 Question 3.9. How complicated a counterexample witnessing the fact that MSE-equivalence (respectively ME-equivalence) is strictly weaker than strong M-equivalence (respectively M-equivalence) has to be? 4. Some Characterization Results Some simple analysis should convince the reader of the following remark. Remark 4.1. Suppose Σ a,b,c and w Σ∗. ={ } ∈ (1) w abc 0 if and only if w w1w2w3 for some w1 b,c ∗, w2 a,c ∗ ∣ ∣ = = ∈ { } ∈ { } and w3 a,b ∗. ∈{ } (2) w abc 1 if and only if w w1aw2bw3cw4 for some unique w1 b,c ∗, ∣ ∣ = = ∈ { } w2 c∗, w3 a∗ and w4 a,b ∗. ∈ ∈ ∈{ } Theorem 4.2. Suppose Σ a,b,c and w,w′ Σ∗ with w w′ 1. abc abc s = { } ∈ ∣ ∣ = ∣ ∣ ≤ Then w w′ if and only if w w′. M MSE ≡ ≡ Proof. By Proposition 3.8, it remains to prove the forward direction. Assume w is strongly M-equivalent to w′. First, consider the case w w′ 0. abc abc ∣ ∣ =∣ ∣ = By Remark 4.1, w w1w2w3 and w′ w1′w2′w3′ for some w1,w1′ b,c ∗, = = ∈ { } w2,w2′ a,c ∗ and w3,w3′ a,b ∗. Notice that w2 ac w ac w′ac w2′ ac ∈ { } ∈ { } ∣ ∣ = ∣ ∣ = ∣ ∣ = ∣ ∣ and w1b w2 ac w bac w′ bac w1′ b w2′ ac. Thus w1 b w1′ b andso w3 b w3′ b ∣ ∣ ∣ ∣ =∣ ∣ =∣ ∣ =∣ ∣ ∣ ∣ ∣ ∣ =∣ ∣ ∣ ∣ =∣ ∣ as well. s Since w w′, by Proposition 3.5(3), π w π w′ with respect to M b,c M b,c ≡ ( ) ≡ ( ) b c , π w π w′ with respect to a c , and π w π w′ a,c M a,c a,b M a,b { < } ( ) ≡ ( ) { < } ( ) ≡ ( ) with respect to a b . { < } Let α w1 c w1′ c and β w3 a w3′ a. There are altogether four (non- = ∣ ∣ −∣ ∣ = ∣ ∣ −∣ ∣ mutually exclusive) cases depending on the nonpositivity or nonnegativity of α and β. By interchanging w and w′, it suffices to consider the following two cases. Case 1. α 0 and β 0. ≥ ≥ Since w1πc w2 πb w3 πb,c w M πb,c w′ w1′πc w2′ πb w3′ with respect ( ) ( ) = ( ) ≡ ( ) = ( ) ( ) to b c and w3 b w3′ b, itfollowsthatw1 M w1′ c c withrespectto b c . { < } ∣ ∣ =∣ ∣ ≡ ⋯ { < } α°times Similarly, c c w2 a a M w2′ withrespectto a c andw3 M a a w3′ with ⋯ ⋯ ≡ { < } ≡ ⋯ α°times β±times β±times respect to a b . Therefore, by Theorem 2.6 and Remark 3.6, { < } w w w w′ c c w w w′ c c w a a w′ w′w′w′. 1 2 3 MSE 1 2 3 MSE 1 2 3 MSE 1 2 3 ≡ ⋯ ≡ ⋯ ⋯ ≡ α°times α°times β±times Case 2. α 0 and β 0. ≥ ≤ In this case, c c w2 M w2′ a a with respect to a c and a a w3 M w3′ ⋯ ≡ ⋯ { < } ⋯ ≡ α°times β±times β±times with respect to a b . Therefore, { < } w w w w′ c c w w w′w′ a a w w′w′w′. 1 2 3 MSE 1 2 3 MSE 1 2 3 MSE 1 2 3 ≡ ⋯ ≡ ⋯ ≡ α°times β±times Now, consider the case w w′ 1. abc abc ∣ ∣ =∣ ∣ = PARIKH MATRICES AND STRONG M-EQUIVALENCE 7 By Remark 4.1, w w1aw2bw3cw4 and w′ w1′aw2′bw3′cw4′ for some w1,w1′ = = ∈ b,c ∗, w2,w2′ c∗, w3,w3′ a∗ and w4,w4′ a,b ∗. { } ∈ ∈ ∈{ } Claim. w1 b w1′ b, w2 w2′, w3 w3′, and w4 b w4′ b. ∣ ∣ =∣ ∣ = = ∣ ∣ =∣ ∣ To prove the claim, without loss of generality, assume w1b w1′ b 1. Note ∣ ∣ ≥ ∣ ∣ + that w bac w1 b aw2bw3cac w3 w1 b w ac w3 . Hence, w bac w1b w ac ∣ ∣ = ∣ ∣ ∣ ∣ +∣ ∣ = ∣ ∣ ∣ ∣ +∣ ∣ ∣ ∣ ≥ ∣ ∣ ∣ ∣ ≥ w′ 1 w′ . However, w′ w′ . It follows that w w′ w′ w′ 1 b ac ac 3 bac 1 b ac 3 (∣ ∣ + )∣ ∣ ∣ ∣ >∣ ∣ ∣ ∣ >∣ ∣ ∣ ∣ +∣ ∣= w′ bac, a contradiction. Therefore, w1b w1′ b. The rest of the claim follows ∣ ∣ ∣ ∣ = ∣ ∣ easily from here. Since π w π w′ with respect to b c , using the claim and the b,c M b,c ( ) ≡ ( ) { < } right invariance of M-equivalence, it follows that w1 M w1′ with respect to ≡ b c . Similarly, w4 M w4′ with respect to a b . Therefore, { < } ≡ { < } w aw bw cw w′aw bw cw w′aw bw cw′ w′aw′bw′cw′ 1 2 3 4 MSE 1 2 3 4 MSE 1 2 3 4 1 2 3 4 ≡ ≡ = (cid:3) and the proof is complete. Example 4.3. Let w bccaabcba and w′ cbabccaab. It is easy to verify that = = they are strongly M-equivalent. However, Rule SE cannot be applied to either of them. Therefore, w and w′ are not MSE-equivalent. Since w 2, this abc ∣ ∣ = shows that Theorem 4.2 is optimal. Similarly, ME-equivalence can be compared against M-equivalence. Theorem 4.4. Suppose Σ a b c and w,w′ Σ∗ and w w′ 0. abc abc = { < < } ∈ ∣ ∣ = ∣ ∣ = Then w w′ if and only if w w′. M ME ≡ ≡ Proof. It suffices to prove the forwarddirection as ME-equivalence immediately implies M-equivalence. Assume w is M-equivalent to w′. By Remark 4.1, w 1 ≡ w1w2 andw′ 1 w1′w2′, wherew1,w1′ b,c ∗ andw2,w2′ a,b ∗. Sincew M w′, ≡ ∈{ } ∈{ } ≡ it follows that w1 bc w1′ bc and w1c w1′ c. Without loss of generality, let ∣ ∣ = ∣ ∣ ∣ ∣ = ∣ ∣ w1 b w1′ b w2′ b w2 b α 0. Then w1 M w′ bb b with respect to b c . ∣ ∣ −∣ ∣ =∣ ∣ −∣ ∣ = ≥ ≡ ⋯ { < } α±times Similarly, bb b w2 M w2′ with respect to a b . Therefore, by Theorem 2.6, ⋯ ≡ { < } α±times w ME w1w2 ME w1′ bb b w2 ME w1′w2′ ME w′ as required. (cid:3) ≡ ≡ ⋯ ≡ ≡ α±times Example 4.5. Consider w cbbabcab and w′ bcabcbba. Then w and w′ are = = M-equivalent but not ME-equivalent with respect to a b c . These are { < < } simpler than the counterexample of length 15 mentioned before. Furthermore, since w 1, it shows that Theorem 4.4 is optimal. abc ∣ ∣ = Remark 4.6. Inanolderversionofthisarticle,itwassuggestedthatExample 4.5 provides a counterexample of the shortest length. This was confirmed by an anonymous referee, who wrote a program to exhaustively check all the 9841 ternary words of length at most eight. It was found out that there are 2729 M-equivalence classes compared with 2732 ME-equivalence classes. In a certain way, the next theorem allows generation of pairs of M-equivalent ternary words that are not ME-equivalent. In fact, it strongly suggests that when the length of words gets bigger, a pair of M-equivalent words are less likely to be ME-equivalent. PARIKH MATRICES AND STRONG M-EQUIVALENCE 8 Theorem 4.7. Suppose Σ a b c and w,w′ Σ∗ with w w′ 1. abc abc = { < < } ∈ ∣ ∣ =∣ ∣ = Then w M w′ if and only if w 1 w1abcw2 and w′ 1 w1′abcw2′ for some unique ≡ ≡ ≡ w1,w1′ b,c ∗ and w2,w2′ a,b ∗ such that Ψ{b<c} w1bc Ψ{b<c} w1′bc ∈ { } ∈ { } ( ) − ( ) = 0 α 0 0 0 0 ⎛0 0 0⎞ and Ψ{a<b} abw2 Ψ{a<b} abw2′ ⎛0 0 α⎞, where α w1b ⎜ ⎟ ( ) − ( ) = ⎜ − ⎟ = ∣ ∣ − 0 0 0 0 0 0 ⎝ ⎠ ⎝ ⎠ w′ . Furthermore, w and w′ are in fact ME-equivalent if and only if addition- 1 b ∣ ∣ ally α is zero. Proof. By Remark 4.1, w 1 w1abcw2 and w′ 1 w1′abcw2′ for some unique ≡ ≡ w1,w1′ b,c ∗ and w2,w2′ a,b ∗. Then the first conclusion arrives by some ∈ { } ∈ { } simple analysis. For the second conclusion, if α is zero, then w1 M w1′ with respect to b c ≡ { < } and w2 M w2′ with respect to a b ; hence, w ME w′ by Theorem 2.6. ≡ { < } ≡ Conversely, observe that any application of Rule E2 on words of the form v1av2bv3cv4, where v1 b,c ∗, v2 c∗, v3 a∗, and v4 a,b ∗, must be applied ∈{ } ∈ ∈ ∈{ } either on v1 or on v2. Hence, if w1′abcw2′ is to be ME-equivalent to w1abcw2, it must follow that w1′ b w1 b. Therefore, if w is in fact ME-equivalent to w′, then α 0. ∣ ∣ = ∣ ∣ (cid:3) = 5. Weakly M-related If strong M-equivalence is the universal form of M-equivalence, now the existential counterpart will be introduced. Definition 5.1. Suppose Σ is an alphabet. Two words w,w′ Σ∗ are weakly ∈ M-related, denoted w w′, iff w and w′ are M-equivalent with respect to M ∽ some ordered alphabet with underlying alphabet Σ. Clearly, ab is not weakly M-related to ba with respect to a,b but they are { } with respect to a (strictly) larger alphabet. In fact, the following is true. Remark 5.2. If the alphabet has size at least three, then any swapping of two consecutive distinct letters results in a weakly M-related word. Example 5.3. Suppose Σ a,b,c . Then acb and cab are weakly M-related. = { } Also, cab and cba are weakly M-related. Assume acb and cba are M-equivalent with respect to some ordered alphabet Γ with underlying alphabet Σ. Then a and b cannnot be consecutive in Γ. Similarly, a and c cannnot be consecutive in Γ. There is no such Γ. Therefore, acb and cba cannot be weakly M-related. Example 5.3 shows that the relation is not transitive. Thus is not an M M ∽ ∽ equivalence relation, explaining our choice of “weakly M-related”, rather than “weakly M-equivalent”. The next theorem says that the transitive closure of is identical to the Parikh equivalence. M ∽ Theorem 5.4. Suppose Σ is an alphabet of size at least three and w,w′ Σ∗. ∈ Then w and w′ are equivalent under the transitive closure of if and only if M ∽ w and w′ have the same Parikh vector. Proof. Ifw w′, thenw andw′ havethesameParikhvector. Bythedefinition M ∽ of transitive closure, the forward direction is immediate. Conversely, assume PARIKH MATRICES AND STRONG M-EQUIVALENCE 9 w and w′ have the same Parikh vector. Clearly, w can be transformed into w′ by making a sequence of swappings between two consecutive distinct letters. Hence, it suffices to note that each such swapping results in a weakly M-related (cid:3) word, and this is true by Remark 5.2. The relation is not absolute. Any two words having the same Parikh M ∽ vector become weakly M-related simply by expanding their common. In fact, the following theorem says that there is a bound to the number of auxiliary letters that should be added for that to happen. Theorem 5.5. Suppose w and w′ have the same Parikh vector. Then w and w′ are weakly M-related with respect to any alphabet having size at least 2 supp w 1 that includes supp w . ∣ ( )∣− ( ) Proof. Suppose Σ is any alphabet of size at least 2 supp w 1 that includes ∣ ( )∣− supp w . Let Γ be any ordered alphabet with underlying alphabet Σ such ( ) that the letters belonging to supp w are not consecutive in Γ. Obviously, this ( ) is possible because Σ 2 supp w 1. By Theorem 2.3, ΨΓ w ΨΓ w′ ∣ ∣ ≥ ∣ ( )∣ − ( ) = ( ) as all entries above the second diagonal are zero due to the choice of Γ and Ψ w Ψ w′ . Therefore, w and w′ are weakly M-related. (cid:3) ( )= ( ) 6. Conclusions Strong M-equivalence, as highlighted by Theorem 3.3, is a natural and in- teresting notion on its own. As the characterization of M-equivalence for the ternary alphabet has been a decade-old problem, it remains to be seen whether strong M-equivalence would be as formidable. However, Theorem 4.2 says that strong M-equivalence can be characterized by MSE-equivalence for the first two “layers” of ternary words. It is intriguing which canonical extension of MSE-equivalence may characterize strong M-equivalence for the next layer of ternary words. Next, it is natural to study the strong version of M-ambiguity. A word is strongly M-unambiguous iff it is not strongly M-equivalent to another distinct word. Every M-unambiguous word is strongly M-unambiguous but not vice versa. The characterization of M-unambiguous ternary words in the form of a long list was obtained by Serbˇanutaˇ in [17]. Although more ternary words are strongly M-unambiguous, the characterization of such words could be given by a shorter list due to the symmetrical nature of strong M-equivalence. Finally, since is not an equivalence relation, together with Theorems 5.4 M ∽ and 5.5, the notion of “weakly M-related” appears to be uninteresting. How- ever, it may lead to other interesting combinatorial questions. Acknowledgment Thenotionof“weaklyM-related”wassuggestedbyKiamHeongKwa. Sound suggestions fromananonymous referee have partially led tothe improvement of this article. Furthermore, the computational justification offered in Remark 4.6 is due to the same referee. Finally, the author gratefully acknowledges support forthisresearch byashort termgrantNo. 304/PMATHS/6313077ofUniversiti Sains Malaysia. PARIKH MATRICES AND STRONG M-EQUIVALENCE 10 References [1] A.Atanasiu,Binaryamiablewords,Internat. J. Found. Comput. Sci.18(2)(2007)387– 400. [2] A. Atanasiu, R. Atanasiu and I. Petre, Parikh matrices and amiable words, Theoret. Comput. Sci. 390(1) (2008) 102–109. [3] A. Atanasiu, Parikh matrix mapping and amiability over a ternary alphabet, Discrete Mathematics and Computer Science. In Memoriam Alexandru Mateescu (1952-2005)., (2014), pp. 1–12. [4] A. Atanasiu, C. Mart´ın-Vide and A. Mateescu, On the injectivity of the Parikh matrix mapping, Fund. Inform. 49(4) (2002) 289–299. [5] C. Ding and A. Salomaa, On some problems of Mateescu concerning subword occur- rences, Fund. Inform. 73 (2006) 65–79. [6] S. Foss´e and G. Richomme, Some characterizations of Parikh matrix equivalent binary words, Inform. Process. Lett. 92(2) (2004) 77–82. [7] A. Mateescu, A. Salomaa,K. Salomaa and S. Yu, A sharpening of the Parikhmapping, Theor. Inform. Appl. 35(6) (2001) 551–564. [8] A.Mateescu,A.SalomaaandS.Yu,SubwordhistoriesandParikhmatrices,J. Comput. System Sci. 68(1) (2004) 1–21. [9] R. J. Parikh, On context-free languages, J. Assoc. Comput. Mach. 13 (1966) 570–581. [10] G. Rozenberg and A. Salomaa (eds.), Handbook of formal languages. Vol. 1 (Springer- Verlag, Berlin, 1997). [11] A.Salomaa,Connectionsbetweensubwordsandcertainmatrixmappings,Theoret.Com- put. Sci. 340(2) (2005) 188–203. [12] A. Salomaa, On the injectivity of Parikh matrix mappings, Fund. Inform. 64 (2005) 391–404. [13] A.Salomaa,Independenceofcertainquantitiesindicatingsubwordoccurrences,Theoret. Comput. Sci. 362 (2006) 222–231. [14] A. Salomaa, Subword histories and associated matrices, Theoret. Comput. Sci. 407 (2008) 250–257. [15] A. Salomaa, Criteria for the matrix equivalence of words, Theoret. Comput. Sci. 411 (2010) 1818–1827. [16] V. N. S¸erba˘nu¸t˘a, On Parikh matrices, ambiguity, and prints, Internat. J. Found. Com- put. Sci. 20(1) (2009) 151–165. [17] V. N. S¸erba˘nu¸t˘a and T. F. S¸erba˘nu¸t˘a, Injectivity of the Parikh matrix mappings revis- ited, Fund. Inform. 73 (2006) 265–283. [18] W.C.Teh,OncorewordsandtheParikhmatrixmapping,Internat.J. Found. Comput. Sci. 26(1) (2015) 123–142. [19] W. C. Teh, Parikh matrices and Parikh rewriting systems, axXiv:1506.06476. [20] W.C.TehandK.H.Kwa,CorewordsandParikhmatrices,Theoret. Comput. Sci.582 (2015) 60–69. School of Mathematical Sciences, Universiti Sains Malaysia, 11800 USM, Malaysia E-mail address: [email protected]