on recognizing words that are squares for the shuffle
play

On recognizing words that are squares for the shuffle product - PowerPoint PPT Presentation

On recognizing words that are squares for the shuffle product Laboratoire dInformatique Gaspard-Monge Universit e Paris-Est Marne-la-Vall ee UMR CNRS 8049 Romeo Rizzi & St ephane Vialette Technische Universit at Berlin


  1. On recognizing words that are squares for the shuffle product Laboratoire d’Informatique Gaspard-Monge Universit´ e Paris-Est Marne-la-Vall´ ee UMR CNRS 8049 Romeo Rizzi & St´ ephane Vialette Technische Universit¨ at Berlin November 27, 2013

  2. Shuffle

  3. Shuffle The shuffle u ✁ v of words u and v over A is the finite set of all words obtainable from merging the words u and v from left to right, but choosing the next symbol arbitrarily from u or v . ab ✁ cd = { abcd , acbd , acdb , cabd , cadb , cdab }

  4. Shuffle: Concurrent Execution - Single Processor

  5. Shuffle A large literature is devoted to this matter: ◮ counting shuffles of two words, ◮ shuffle algebras, ◮ automata theory, ◮ . . .

  6. Iterated shuffle The iterated shuffle of u is the language ǫ ∪ u ∪ ( u ✁ u ) ∪ ( u ✁ u ✁ u ) ∪ . . .

  7. Shuffle There are basically two kinds of questions that can be addressed depending on whether or not the shuffled element is given as a part of the input: ◮ ” Given u , v ∈ A ∗ , is u in the iterated shuffle of v? ”, and ◮ ” Given u ∈ A ∗ , is u in the iterated shuffle of some v ∈ A ∗ ? ” For one application of the shuffle product, we obtain: ◮ ” Given u , v ∈ A ∗ , is u ∈ v ✁ v? ”, and ◮ ” Given u ∈ A ∗ , does there exist v ∈ A ∗ such that u ∈ v ✁ v? ”

  8. Dynamic programming for “ u ∈ x ✁ y ”? class String # @return [String] the last character of this string. def last self[-1,1] end # @return [String] all but the last character of this string. def init chop end # @return [Boolean] true if this string is in the shuffle # of x and y, and false otherwise. def shuffle_of?(x, y) # base cases return y == self if x.length.zero? return x == self if y.length.zero? (x.last == last and init.shuffle_of?(x.init, y)) or \ (y.last == last and init.shuffle_of?(x, y.init)) end end

  9. Dynamic programming $ irb 2.0.0-p247 :001 > require ’./shuffle’ => true 2.0.0-p247 :002 > "".shuffle_of?("", "") => true 2.0.0-p247 :003 > "abc".shuffle_of?("abc", "") => true 2.0.0-p247 :004 > "abc".shuffle_of?("ab", "c") => true 2.0.0-p247 :005 > "abc".shuffle_of?("a", "bc") => true 2.0.0-p247 :006 > "abc".shuffle_of?("b", "ac") => true 2.0.0-p247 :007 > "abc".shuffle_of?("", "abc") => true 2.0.0-p247 :008 > "abc".shuffle_of?("ba", "c") => false 2.0.0-p247 :009 > "abc".shuffle_of?("a", "cb") => false 2.0.0-p247 :010 > "abc".shuffle_of?("ca", "b") => false 2.0.0-p247 :011 > $

  10. Some good news ◮ Given words u , v 1 and v 2 , it can be tested in � time whether or not u ∈ v 1 ✁ v 2 1 . � | u | 2 / log( | u | ) O ◮ The shuffle u ✁ v of words u and v can be computed in � �� � | u | + | v | time 2 . O ( | u | + | v | ) | u | ◮ Given words u 1 , u 2 , . . . , u k , the shuffle ✁ k i =1 u i can be �� | u 1 | + | u 2 | + ... + | u k | �� time 3 . computed in O | u 1 | , | u 2 | ,..., | u k | 1 J. van Leeuwen and M. Nivat (1982). In: Information Processing Letters 14.1 2 J.-C. Spehner (1986). In: Theoretical Computer Science 3 C. Allauzen (2000). Tech. rep. Institut Gaspard Monge, Universit´ e Marne-la-Vall´ ee

  11. Some bad news ◮ Given words u , v 1 , v 2 , . . . , v n ∈ A ∗ , it is NP -complete to i =1 v i 4 . decide whether or not u ∈ ✁ k This remains true even if the alphabet has size 3. ◮ For two words u and v , it is NP -complete to decide whether or not u is in the iterated shuffle of v 5 . This remains true even if the alphabet has size 3. 4 A. Mansfield (1983). In: Discrete Applied Mathematics 5 5 M.K. Warmuth and D. Haussler (1984). In: Journal of Computer and System Sciences 28.3

  12. Our main result Theorem Given u ∈ A ∗ , it is NP -complete to decide whether or not u is the shuffle of some word v ∈ A ∗ with itself (i.e., does there exist some v ∈ A ∗ such that u ∈ v ✁ v?). ◮ This result was first claimed by K. Iwama 6 but it turns out that the proof has a serious flaw. ◮ This result was recently proved independently by Buss and Soltys 7 . 6 K. Iwama (1983). In: Proc. 15th Annual ACM Symposium on Theory of Computing (STOC), Boston, Massachusetts, USA 7 S. Buss and M. Soltys (2013). In: Journal of Computer and System Sciences

  13. Stack Exchange discussion board

  14. Turning words into (linear) graphs Let u = u 1 u 2 . . . u n ∈ A n be a word on some alphabet A . ◮ The graph associated to u , denoted V ( G u ), is defined by V ( G u ) = { u 1 , u 2 , . . . , u n } , and E ( G u ) = {{ u i , u j } : i � = j ∧ u i = u j } . We write ( u i , u j ) for an edge of E ( G u ) if it is clear from the context that i < j . ◮ The structure of this underlying graph is linear, i.e. , the set of vertices is equipped with a natural total order < defined by u i < u j if and only if i < j . In other words, the vertices of G u correspond to the letters of u in the left to right order and there is an edge between any two identical distinct letter of u . ◮ Clearly, G u is the disjoint union of cliques, one clique for each distinct letter of u .

  15. Turning words into (linear) graphs u = ababbbaa G u a a a a b b b b

  16. Words, linear graphs, and inclusion-free matchings Let u = u 1 u 2 . . . u n ∈ A n be a word on some alphabet A , and let G u be the linear graph associated to u . ◮ A matching is perfect if it covers all the vertices of the graph. ◮ In case the set of vertices is equipped with a total order, a matching M is said to be inclusion-free if there do not exist (independent) edges ( u i , u j ) and ( u k , u ℓ ) in M such that u i < u k < u ℓ < u j or u k < u i < u j < u ℓ . Lemma Let u ∈ A ∗ for some alphabet A, and G u be the corresponding linear graph. Then, there exists v ∈ A ∗ such that u ∈ v ✁ v if and only if there exists an inclusion-free perfect matching in G u .

  17. Words, linear graphs, and inclusion-free matchings Let u = u 1 u 2 . . . u n ∈ A n be a word on some alphabet A , and let G u be the linear graph associated to u . ◮ A matching is perfect if it covers all the vertices of the graph. ◮ In case the set of vertices is equipped with a total order, a matching M is said to be inclusion-free if there do not exist (independent) edges ( u i , u j ) and ( u k , u ℓ ) in M such that u i < u k < u ℓ < u j or u k < u i < u j < u ℓ . Lemma Let u ∈ A ∗ for some alphabet A, and G u be the corresponding linear graph. Then, there exists v ∈ A ∗ such that u ∈ v ✁ v if and only if there exists an inclusion-free perfect matching in G u .

  18. Linear graph and inclusion-free perfect matching u = a b b a a b b a a a G u b a b a b b a a a a M b b b b

  19. A direct consequence Theorem Let u ∈ A ∗ be such that | u | a ≤ 4 for every letter a ∈ A. It can be decided in polynomial-time whether or not u is the shuffle of some word v ∈ A ∗ with itself.

  20. A direct consequence Theorem Let u ∈ A ∗ be such that | u | a ≤ 4 for every letter a ∈ A. It can be decided in polynomial-time whether or not u is the shuffle of some word v ∈ A ∗ with itself.

  21. A direct consequence Theorem Let u ∈ A ∗ be such that | u | a ≤ 4 for every letter a ∈ A. It can be decided in polynomial-time whether or not u is the shuffle of some word v ∈ A ∗ with itself.

  22. Being a square for the shuffle product Theorem Given u ∈ A ∗ , it is NP -complete to decide whether or not u is the shuffle of some word v ∈ A ∗ with itself. ◮ We propose a polynomial-time reduction from the NP -complete Longest Common Subsequence for binary words 8 : ” Given a collection of words U = { u 1 , u 2 , . . . , u m } such that u i ∈ { 0 , 1 } ∗ for 1 ≤ i ≤ m , and a positive integer k , decide whether there exists a subsequence of size k common to all sequences of U ? ” ◮ Without loss of generality, we may assume that | u i | = | u j | for 1 ≤ i < j ≤ m , and that that we are looking for a common subsequence with p letters 0 and q letters 1, k = p + q . 8 D. Maier (1978). In: Journal of the ACM 25.2

Recommend


More recommend