SlideShare a Scribd company logo
1 of 46
Download to read offline
Unshuffling a Square is NP-hard
Sam Buss and Michael Soltys
February 6, 2013
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Title - 1/27
Shuffle
w is the shuffle of u, v: w = u v
w = 0110110011101000
u = 01101110
v = 10101000
w = 0110110011101000
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Definition - 2/27
Shuffle
w is the shuffle of u, v: w = u v
w = 0110110011101000
u = 01101110
v = 10101000
w = 0110110011101000
w is a shuffle of u and v provided:
u = x1x2 · · · xk
v = y1y2 · · · yk
and w obtained by “interleaving” w = x1y1x2y2 · · · xkyk .
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Definition - 2/27
Square Shuffle
w is a square provided it is equal to a shuffle of a u with itself, i.e.,
∃u s.t. w = u u
The string w = 0110110011101000 is a square:
w = 0110110011101000
and
u = 01101100 = 01101100
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Definition - 3/27
Result
given an alphabet Σ, |Σ| ≥ 7,
Square = {w : ∃u(w = u u)}
is NP-complete.
What we leave open:
What about |Σ| = 2 (for |Σ| = 1, Square is just the set of
even length strings)
What about if |Σ| = ∞ but each symbol cannot occur more
often than, say, 6 times (if each symbol occurs at most 4
times, Square can be reduced to 2-Sat – see P. Austrin
Stack Exchange post bit.ly/WATco3)
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Definition - 4/27
Bipartite graph
w = (c1x3c2)2(c1x2c2)2(c1xc2)2 is a square:
w = u u where u = c1xxxc2xc2c1xc1xc2.
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Definition - 5/27
Bipartite graph
w = (c1x3c2)2(c1x2c2)2(c1xc2)2 is a square:
w = u u where u = c1xxxc2xc2c1xc1xc2.
Bipartite graph G associated with particular solution w = u u:
c1 x x x c2 c1 x x x c2 c1 x x c2 c1 x x c2 c1 x c2 c1 x c2
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Definition - 5/27
Bipartite graph
w = (c1x3c2)2(c1x2c2)2(c1xc2)2 is a square:
w = u u where u = c1xxxc2xc2c1xc1xc2.
Bipartite graph G associated with particular solution w = u u:
c1 x x x c2 c1 x x x c2 c1 x x c2 c1 x x c2 c1 x c2 c1 x c2
We also have w = v v with v = c1x3c2c1x2c2c1xc2
which would have its associated bipartite graph
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Definition - 5/27
Nesting
a b a b a b b a
G has the “non-nesting” property: if G contains an edge from wk
to w and an edge from wp to wq, then it is not the case that
k < p < q <
Claim: There is a complete bipartite graph G of degree one (i.e., a
perfect matching) on the symbols of w which is non-nesting, iff w
can be expressed as a square shuffle.
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Definition - 6/27
Formal languages
Ginsburg & Spanier in ’65
Modelling sequential execution of concurrent processes
Riddle (’73 & ’79), Shaw (’78), Hoare
Shuffle on its own
Mansfield (’82 & ’83; polytime dynamic prog. alg. for
w = u1 u2 · · · uk for constant k; when k varies,
NP-complete)
Warmuth & Haussler (’84; show w = u u · · · u
NP-complete by reduction from 3-Partition)
More complexity
Buss & Yianilos (’98; “Monge condition”)
Erickson (2010; how hard is ∃u, w = u u?); as mentioned,
Austrin gives polytime algorithm when each symbol occurs at
most 4 times. Problem of the year on Stack Exchange.
Soltys (2012; shuffle in AC1
but not AC0
.)
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 History - 7/27
Monge
The Monge condition (or “quasi-convexity” condition) allows
nested edges but prohibits crossing edges; widely studied for
matching and transportation problems.
Many problems that satisfy the Monge condition are known to
have efficient polynomial time algorithms: Buss & Yianilos ’98
Thus, the non-nesting property on our G can be viewed as an
“anti-Monge.” Fewer algorithms for this case:
This is another reason why we find the NP-completeness of the
square problem to be interesting: it provides a hardness result for
anti-Monge matching in a very simple and abstract situation.
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 History - 8/27
PDA
A queue automaton is a PDA but with a queue instead of a stack.
Reads the input w from
left to right.
Queue is initially empty
and supports the
operations push-bottom
and pop-top.
Automaton accepts if its
queue is empty after the
last symbol of w has
been read.
w
Pop
Push
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 9/27
PDA algorithm for Square
Repeatedly do one of the following:
a Read the next input symbol σ and push it onto the
queue, or
b If the next input symbol σ is the same as the symbol
at the top of the queue, read past the input
symbol σ and pop σ from the queue.
We can view an accepting computation as imposing a non-nesting
matching.
When either step a. or b. is performed, we say that the input
symbol σ has been consumed.
In case b., we say that the symbol σ on the queue has been
matched by the input symbol.
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 10/27
w = 0110110011101000
and
u = 01101100 = 01101100
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 11/27
ε 0110110011101000
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 12/27
0 110110011101000
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 12/27
0
1 10110011101000
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 12/27
0
1
1 0110011101000
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 12/27
1
1 110011101000
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 12/27
1 10011101000
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 12/27
ε 0011101000
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 12/27
0 011101000
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 12/27
ε 11101000
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 12/27
1 1101000
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 12/27
ε 101000
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 12/27
1 01000
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 12/27
1
0 1000
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 12/27
0 000
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 12/27
ε 00
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 12/27
0 0
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 12/27
ε ε accepted
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 12/27
Square is NP-complete
Many-one logspace reduction of 3-Partition to Square.
S = ni : 1 ≤ i ≤ 3m such that the ni ’s are given in unary
notation and such that B = ( 3m
i=1 ni )/m is an integer.
The question is: can S be partitioned into m disjoint subsequences
S1, . . . , Sm such that each Sk has exactly three elements with the
sum of the three members of Sk equal to B?
Assume ni given in non-increasing order.
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Proof - 13/27
Reduction
The many-one reduction to Square constructs a string wS over
the alphabet
Σ = {a1, a2, b, e0, e, c1, c2, x, y},
such that wS is a square iff S is a “yes” instance of 3-Partition.
The string wS consists of three parts:
wS := loaderS distributorS verifierS .
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Proof - 14/27
loaderS = e0
m
i=1
(b2B
e)
distributorS = e0
m
i=1
((a1bB
a2)3
e)
verifierS =
3m
k=1
[v4k−3Dkv4k−3v4k−2Dkv4k−2v4k−1Ek v4k−1v4k Fkv4k ]
where
v = c1x y c2
Dk = (a2
1bnk
a2
2)3m−k+1
Ek = (a2
1bB
a2
2)3m−k
(a1bnk
a2)(a2
1bB
a2
2)3m−k
Fk = (a2
1bB
a2
2)2(3m−k)
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Proof - 15/27
Action of loaderS
e0
b2Be
b2Be
...
b2Be
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Proof - 16/27
Action of distributorS
b2Be Q
Q a1bi1 a2
a1bi2 a2
a1bi3 a2
(a1bBa2)3e
where i1 + i2 + i3 = B.
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Proof - 17/27
After loaderS distributorS has been scanned, we have the
following configuration:
3m
k=1
(a1bik
a2) verifierS
The role of the verifier is to check wheter ik
3m
k=1 is a re-ordering
of nk
3m
k=1.
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Proof - 18/27
Correctness
Given any sequence of non-negative integers ik
3m
k=1 such that
∀j ∈ {1, 2, . . . , m}, i3j−2 + i3j−1 + i3j = B, (1)
there exists a computation
ε wS
∗
3m
k=1
(a1bik
a2) verifierS
Conversely, if
ε wS
∗
W verifierS
then W must be of the form 3m
k=1(a1bik a2), so that condition (1)
holds.
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Proof - 19/27
Therefore it suffices to show that
3m
k=1
(a1bik
a2) verifierS
is accepted ⇐⇒
ik
3m
k=1 is a permutation of nk
3m
k=1.
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Proof - 20/27
If ik
3m
k=1 is a permutation of nk
3m
k=1, then it is a matter of
keeping track of lots of details to show that
3m
k=1
(a1bik
a2) verifierS
∗
ε ε,
and hence wS ∈ Square.
The other direction is more complicated because we have to show
that if a computation accepts, then the ik’s must be a permutation
of the nk’s.
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Proof - 21/27
Recall that:
verifierS =
3m
k=1
[v4k−3Dkv4k−3v4k−2Dkv4k−2v4k−1Ek v4k−1v4kFkv4k ]
where
v = c1x y c2
Dk = (a2
1bnk
a2
2)3m−k+1
Ek = (a2
1bB
a2
2)3m−k
(a1bnk
a2)(a2
1bB
a2
2)3m−k
Fk = (a2
1bB
a2
2)2(3m−k)
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Proof - 22/27
The role of the v’s is that of delimiters; they impose a scope on
the edges.
The role of the D’s is to make sure that at each of the k steps, the
remaining ij’s are all less than or equal to the next nk.
The role of the Ek and Fk is to cycle the queue until the right
a1bix
a2 is found for a1bnk a2; i.e., such that ix = nk.
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Proof - 23/27
The main idea is that if n1 corresponds to ix then:
a1bi1 a2 a1bix
a2
a1bi2 aa a1bix+1 a2 a1bix+1 a2 a1bB−i1 a2 a1bi1 a2
...
...
...
...
...
a1bix
a2 a1bi3m a2 a1bi3m a2 a1bB−ix−1 a2 a1bix−1 a2
a1bix+1 a2 a1bB−i1 a2 a1bB−i1 a2 a1bB−ix+1 a2 a1bix+1 a2
...
...
...
...
...
a1bi3m a2 a1bB−ix−1 a2 a1bB−ix−1 a2 a1bB−im
a2 a1bim
a2
The changes to the queue while applying E1, F1 with the
assumption that ix = n1.
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Proof - 24/27
If a computation accepts, then the ik’s must be a permutation of
the nk’s.
Elements of the proof:
If y is consumed by u yielding the resultant z, then y = u z.
u Q
Q z
y
so a subsequence of u has to be a subsequence of y.
A string z has k alternations of the symbols a1, a2 provided
(a1a2)k is a subsequence of z but (a1a2)k+1 is not.
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Proof - 25/27
a1bij a2 Q
Q Zj = a1bB−m1
s=2(a2
2a2
1bB−ms
)a2
Yj = (a2
1bBa2
2) ∈ Ek
where m1 + m2 + · · · + m = ij. Note that Yj and Zj both have
alternations of a1, a2.
Zj = a1bB−m1
s=2(a2
2a2
1bB−ms
)a2 Q
Q a1bij a2
Yj = (a2
1bBa2
2) ∈ Fk
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Proof - 26/27
Buss: bit.ly/Sxsr5I
Soltys: bit.ly/UyD7lh
arXiv: arxiv.org/abs/1211.7161
Stack Exchange Post: bit.ly/TzD7hH
Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Sources - 27/27

More Related Content

Viewers also liked

A formal framework for Stringology
A formal framework for StringologyA formal framework for Stringology
A formal framework for StringologyMichael Soltys
 
Feasible Combinatorial Matrix Theory - MFCS2013
Feasible Combinatorial Matrix Theory - MFCS2013Feasible Combinatorial Matrix Theory - MFCS2013
Feasible Combinatorial Matrix Theory - MFCS2013Michael Soltys
 
Perceptions of Foundational Knowledge by CS students - WCCCE 2012
Perceptions of Foundational Knowledge by CS students - WCCCE 2012Perceptions of Foundational Knowledge by CS students - WCCCE 2012
Perceptions of Foundational Knowledge by CS students - WCCCE 2012Michael Soltys
 
The Proof Complexity of Linear Algebra - LICS 2002
The Proof Complexity of Linear Algebra - LICS 2002The Proof Complexity of Linear Algebra - LICS 2002
The Proof Complexity of Linear Algebra - LICS 2002Michael Soltys
 
Games on Posets - CiE 2008
Games on Posets - CiE 2008Games on Posets - CiE 2008
Games on Posets - CiE 2008Michael Soltys
 
The proof theoretic strength of the Steinitz exchange theorem - EACA 2006
The proof theoretic strength of the Steinitz exchange theorem - EACA 2006The proof theoretic strength of the Steinitz exchange theorem - EACA 2006
The proof theoretic strength of the Steinitz exchange theorem - EACA 2006Michael Soltys
 
Forced repetitions over alphabet lists
Forced repetitions over alphabet listsForced repetitions over alphabet lists
Forced repetitions over alphabet listsMichael Soltys
 
How Safe is your Data?
How Safe is your Data?How Safe is your Data?
How Safe is your Data?Michael Soltys
 
Circuit Complexity of Shuffle - IWOCA 2013
Circuit Complexity of Shuffle - IWOCA 2013Circuit Complexity of Shuffle - IWOCA 2013
Circuit Complexity of Shuffle - IWOCA 2013Michael Soltys
 
An algorithmic view of Computer Science
An algorithmic view of Computer ScienceAn algorithmic view of Computer Science
An algorithmic view of Computer ScienceMichael Soltys
 
Cbh2015 brochure web.pptx
Cbh2015 brochure web.pptxCbh2015 brochure web.pptx
Cbh2015 brochure web.pptxMoses Solemon
 
EDUCATION SCENARIO JULY ISSUE
EDUCATION SCENARIO JULY ISSUEEDUCATION SCENARIO JULY ISSUE
EDUCATION SCENARIO JULY ISSUESerfraz Qadir
 
InfoFlow: January 3rd, 2011
InfoFlow: January 3rd, 2011InfoFlow: January 3rd, 2011
InfoFlow: January 3rd, 2011Ajmal Pictures
 
экопластика.Ppt 2
экопластика.Ppt 2экопластика.Ppt 2
экопластика.Ppt 2Kokossokok
 

Viewers also liked (18)

A formal framework for Stringology
A formal framework for StringologyA formal framework for Stringology
A formal framework for Stringology
 
Feasible Combinatorial Matrix Theory - MFCS2013
Feasible Combinatorial Matrix Theory - MFCS2013Feasible Combinatorial Matrix Theory - MFCS2013
Feasible Combinatorial Matrix Theory - MFCS2013
 
Perceptions of Foundational Knowledge by CS students - WCCCE 2012
Perceptions of Foundational Knowledge by CS students - WCCCE 2012Perceptions of Foundational Knowledge by CS students - WCCCE 2012
Perceptions of Foundational Knowledge by CS students - WCCCE 2012
 
The Proof Complexity of Linear Algebra - LICS 2002
The Proof Complexity of Linear Algebra - LICS 2002The Proof Complexity of Linear Algebra - LICS 2002
The Proof Complexity of Linear Algebra - LICS 2002
 
Intro to Cryptography
Intro to CryptographyIntro to Cryptography
Intro to Cryptography
 
Games on Posets - CiE 2008
Games on Posets - CiE 2008Games on Posets - CiE 2008
Games on Posets - CiE 2008
 
The proof theoretic strength of the Steinitz exchange theorem - EACA 2006
The proof theoretic strength of the Steinitz exchange theorem - EACA 2006The proof theoretic strength of the Steinitz exchange theorem - EACA 2006
The proof theoretic strength of the Steinitz exchange theorem - EACA 2006
 
Forced repetitions over alphabet lists
Forced repetitions over alphabet listsForced repetitions over alphabet lists
Forced repetitions over alphabet lists
 
How Safe is your Data?
How Safe is your Data?How Safe is your Data?
How Safe is your Data?
 
Circuit Complexity of Shuffle - IWOCA 2013
Circuit Complexity of Shuffle - IWOCA 2013Circuit Complexity of Shuffle - IWOCA 2013
Circuit Complexity of Shuffle - IWOCA 2013
 
An algorithmic view of Computer Science
An algorithmic view of Computer ScienceAn algorithmic view of Computer Science
An algorithmic view of Computer Science
 
Krzysztof Szanecki Przelewy24
Krzysztof Szanecki Przelewy24Krzysztof Szanecki Przelewy24
Krzysztof Szanecki Przelewy24
 
Framework
FrameworkFramework
Framework
 
Cbh2015 brochure web.pptx
Cbh2015 brochure web.pptxCbh2015 brochure web.pptx
Cbh2015 brochure web.pptx
 
EDUCATION SCENARIO JULY ISSUE
EDUCATION SCENARIO JULY ISSUEEDUCATION SCENARIO JULY ISSUE
EDUCATION SCENARIO JULY ISSUE
 
InfoFlow: January 3rd, 2011
InfoFlow: January 3rd, 2011InfoFlow: January 3rd, 2011
InfoFlow: January 3rd, 2011
 
Musings_CLSARoadshows
Musings_CLSARoadshowsMusings_CLSARoadshows
Musings_CLSARoadshows
 
экопластика.Ppt 2
экопластика.Ppt 2экопластика.Ppt 2
экопластика.Ppt 2
 

Recently uploaded

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 

Recently uploaded (20)

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 

Unshuffling a square is NP-hard

  • 1. Unshuffling a Square is NP-hard Sam Buss and Michael Soltys February 6, 2013 Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Title - 1/27
  • 2. Shuffle w is the shuffle of u, v: w = u v w = 0110110011101000 u = 01101110 v = 10101000 w = 0110110011101000 Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Definition - 2/27
  • 3. Shuffle w is the shuffle of u, v: w = u v w = 0110110011101000 u = 01101110 v = 10101000 w = 0110110011101000 w is a shuffle of u and v provided: u = x1x2 · · · xk v = y1y2 · · · yk and w obtained by “interleaving” w = x1y1x2y2 · · · xkyk . Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Definition - 2/27
  • 4. Square Shuffle w is a square provided it is equal to a shuffle of a u with itself, i.e., ∃u s.t. w = u u The string w = 0110110011101000 is a square: w = 0110110011101000 and u = 01101100 = 01101100 Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Definition - 3/27
  • 5. Result given an alphabet Σ, |Σ| ≥ 7, Square = {w : ∃u(w = u u)} is NP-complete. What we leave open: What about |Σ| = 2 (for |Σ| = 1, Square is just the set of even length strings) What about if |Σ| = ∞ but each symbol cannot occur more often than, say, 6 times (if each symbol occurs at most 4 times, Square can be reduced to 2-Sat – see P. Austrin Stack Exchange post bit.ly/WATco3) Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Definition - 4/27
  • 6. Bipartite graph w = (c1x3c2)2(c1x2c2)2(c1xc2)2 is a square: w = u u where u = c1xxxc2xc2c1xc1xc2. Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Definition - 5/27
  • 7. Bipartite graph w = (c1x3c2)2(c1x2c2)2(c1xc2)2 is a square: w = u u where u = c1xxxc2xc2c1xc1xc2. Bipartite graph G associated with particular solution w = u u: c1 x x x c2 c1 x x x c2 c1 x x c2 c1 x x c2 c1 x c2 c1 x c2 Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Definition - 5/27
  • 8. Bipartite graph w = (c1x3c2)2(c1x2c2)2(c1xc2)2 is a square: w = u u where u = c1xxxc2xc2c1xc1xc2. Bipartite graph G associated with particular solution w = u u: c1 x x x c2 c1 x x x c2 c1 x x c2 c1 x x c2 c1 x c2 c1 x c2 We also have w = v v with v = c1x3c2c1x2c2c1xc2 which would have its associated bipartite graph Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Definition - 5/27
  • 9. Nesting a b a b a b b a G has the “non-nesting” property: if G contains an edge from wk to w and an edge from wp to wq, then it is not the case that k < p < q < Claim: There is a complete bipartite graph G of degree one (i.e., a perfect matching) on the symbols of w which is non-nesting, iff w can be expressed as a square shuffle. Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Definition - 6/27
  • 10. Formal languages Ginsburg & Spanier in ’65 Modelling sequential execution of concurrent processes Riddle (’73 & ’79), Shaw (’78), Hoare Shuffle on its own Mansfield (’82 & ’83; polytime dynamic prog. alg. for w = u1 u2 · · · uk for constant k; when k varies, NP-complete) Warmuth & Haussler (’84; show w = u u · · · u NP-complete by reduction from 3-Partition) More complexity Buss & Yianilos (’98; “Monge condition”) Erickson (2010; how hard is ∃u, w = u u?); as mentioned, Austrin gives polytime algorithm when each symbol occurs at most 4 times. Problem of the year on Stack Exchange. Soltys (2012; shuffle in AC1 but not AC0 .) Unshuffling - Buss & Soltys Slides - Feb 6, 2013 History - 7/27
  • 11. Monge The Monge condition (or “quasi-convexity” condition) allows nested edges but prohibits crossing edges; widely studied for matching and transportation problems. Many problems that satisfy the Monge condition are known to have efficient polynomial time algorithms: Buss & Yianilos ’98 Thus, the non-nesting property on our G can be viewed as an “anti-Monge.” Fewer algorithms for this case: This is another reason why we find the NP-completeness of the square problem to be interesting: it provides a hardness result for anti-Monge matching in a very simple and abstract situation. Unshuffling - Buss & Soltys Slides - Feb 6, 2013 History - 8/27
  • 12. PDA A queue automaton is a PDA but with a queue instead of a stack. Reads the input w from left to right. Queue is initially empty and supports the operations push-bottom and pop-top. Automaton accepts if its queue is empty after the last symbol of w has been read. w Pop Push Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 9/27
  • 13. PDA algorithm for Square Repeatedly do one of the following: a Read the next input symbol σ and push it onto the queue, or b If the next input symbol σ is the same as the symbol at the top of the queue, read past the input symbol σ and pop σ from the queue. We can view an accepting computation as imposing a non-nesting matching. When either step a. or b. is performed, we say that the input symbol σ has been consumed. In case b., we say that the symbol σ on the queue has been matched by the input symbol. Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 10/27
  • 14. w = 0110110011101000 and u = 01101100 = 01101100 Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 11/27
  • 15. ε 0110110011101000 Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 12/27
  • 16. 0 110110011101000 Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 12/27
  • 17. 0 1 10110011101000 Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 12/27
  • 18. 0 1 1 0110011101000 Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 12/27
  • 19. 1 1 110011101000 Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 12/27
  • 20. 1 10011101000 Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 12/27
  • 21. ε 0011101000 Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 12/27
  • 22. 0 011101000 Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 12/27
  • 23. ε 11101000 Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 12/27
  • 24. 1 1101000 Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 12/27
  • 25. ε 101000 Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 12/27
  • 26. 1 01000 Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 12/27
  • 27. 1 0 1000 Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 12/27
  • 28. 0 000 Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 12/27
  • 29. ε 00 Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 12/27
  • 30. 0 0 Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 12/27
  • 31. ε ε accepted Unshuffling - Buss & Soltys Slides - Feb 6, 2013 PDAs - 12/27
  • 32. Square is NP-complete Many-one logspace reduction of 3-Partition to Square. S = ni : 1 ≤ i ≤ 3m such that the ni ’s are given in unary notation and such that B = ( 3m i=1 ni )/m is an integer. The question is: can S be partitioned into m disjoint subsequences S1, . . . , Sm such that each Sk has exactly three elements with the sum of the three members of Sk equal to B? Assume ni given in non-increasing order. Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Proof - 13/27
  • 33. Reduction The many-one reduction to Square constructs a string wS over the alphabet Σ = {a1, a2, b, e0, e, c1, c2, x, y}, such that wS is a square iff S is a “yes” instance of 3-Partition. The string wS consists of three parts: wS := loaderS distributorS verifierS . Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Proof - 14/27
  • 34. loaderS = e0 m i=1 (b2B e) distributorS = e0 m i=1 ((a1bB a2)3 e) verifierS = 3m k=1 [v4k−3Dkv4k−3v4k−2Dkv4k−2v4k−1Ek v4k−1v4k Fkv4k ] where v = c1x y c2 Dk = (a2 1bnk a2 2)3m−k+1 Ek = (a2 1bB a2 2)3m−k (a1bnk a2)(a2 1bB a2 2)3m−k Fk = (a2 1bB a2 2)2(3m−k) Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Proof - 15/27
  • 35. Action of loaderS e0 b2Be b2Be ... b2Be Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Proof - 16/27
  • 36. Action of distributorS b2Be Q Q a1bi1 a2 a1bi2 a2 a1bi3 a2 (a1bBa2)3e where i1 + i2 + i3 = B. Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Proof - 17/27
  • 37. After loaderS distributorS has been scanned, we have the following configuration: 3m k=1 (a1bik a2) verifierS The role of the verifier is to check wheter ik 3m k=1 is a re-ordering of nk 3m k=1. Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Proof - 18/27
  • 38. Correctness Given any sequence of non-negative integers ik 3m k=1 such that ∀j ∈ {1, 2, . . . , m}, i3j−2 + i3j−1 + i3j = B, (1) there exists a computation ε wS ∗ 3m k=1 (a1bik a2) verifierS Conversely, if ε wS ∗ W verifierS then W must be of the form 3m k=1(a1bik a2), so that condition (1) holds. Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Proof - 19/27
  • 39. Therefore it suffices to show that 3m k=1 (a1bik a2) verifierS is accepted ⇐⇒ ik 3m k=1 is a permutation of nk 3m k=1. Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Proof - 20/27
  • 40. If ik 3m k=1 is a permutation of nk 3m k=1, then it is a matter of keeping track of lots of details to show that 3m k=1 (a1bik a2) verifierS ∗ ε ε, and hence wS ∈ Square. The other direction is more complicated because we have to show that if a computation accepts, then the ik’s must be a permutation of the nk’s. Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Proof - 21/27
  • 41. Recall that: verifierS = 3m k=1 [v4k−3Dkv4k−3v4k−2Dkv4k−2v4k−1Ek v4k−1v4kFkv4k ] where v = c1x y c2 Dk = (a2 1bnk a2 2)3m−k+1 Ek = (a2 1bB a2 2)3m−k (a1bnk a2)(a2 1bB a2 2)3m−k Fk = (a2 1bB a2 2)2(3m−k) Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Proof - 22/27
  • 42. The role of the v’s is that of delimiters; they impose a scope on the edges. The role of the D’s is to make sure that at each of the k steps, the remaining ij’s are all less than or equal to the next nk. The role of the Ek and Fk is to cycle the queue until the right a1bix a2 is found for a1bnk a2; i.e., such that ix = nk. Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Proof - 23/27
  • 43. The main idea is that if n1 corresponds to ix then: a1bi1 a2 a1bix a2 a1bi2 aa a1bix+1 a2 a1bix+1 a2 a1bB−i1 a2 a1bi1 a2 ... ... ... ... ... a1bix a2 a1bi3m a2 a1bi3m a2 a1bB−ix−1 a2 a1bix−1 a2 a1bix+1 a2 a1bB−i1 a2 a1bB−i1 a2 a1bB−ix+1 a2 a1bix+1 a2 ... ... ... ... ... a1bi3m a2 a1bB−ix−1 a2 a1bB−ix−1 a2 a1bB−im a2 a1bim a2 The changes to the queue while applying E1, F1 with the assumption that ix = n1. Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Proof - 24/27
  • 44. If a computation accepts, then the ik’s must be a permutation of the nk’s. Elements of the proof: If y is consumed by u yielding the resultant z, then y = u z. u Q Q z y so a subsequence of u has to be a subsequence of y. A string z has k alternations of the symbols a1, a2 provided (a1a2)k is a subsequence of z but (a1a2)k+1 is not. Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Proof - 25/27
  • 45. a1bij a2 Q Q Zj = a1bB−m1 s=2(a2 2a2 1bB−ms )a2 Yj = (a2 1bBa2 2) ∈ Ek where m1 + m2 + · · · + m = ij. Note that Yj and Zj both have alternations of a1, a2. Zj = a1bB−m1 s=2(a2 2a2 1bB−ms )a2 Q Q a1bij a2 Yj = (a2 1bBa2 2) ∈ Fk Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Proof - 26/27
  • 46. Buss: bit.ly/Sxsr5I Soltys: bit.ly/UyD7lh arXiv: arxiv.org/abs/1211.7161 Stack Exchange Post: bit.ly/TzD7hH Unshuffling - Buss & Soltys Slides - Feb 6, 2013 Sources - 27/27