Topological Sorting under Regular Constraints
Antoine Amarilli1,Charles Paperman2 December 7th, 2018
1Télécom ParisTech
2Université de Lille
Constrained Topological Sorting
•
Fix analphabet: e.g.,Σ ={a,b}•
Fix alanguage: e.g.,L= (ab)∗•
We studyconstrained topological sorting:• Input:directed acyclic graph(DAG) with vertices labeled withΣ
• Output: is there atopological sort that falls inL?
•
Question:when is this problemtractable?a
b a b
b a
a b a b a b ... inL!
Constrained Topological Sorting
•
Fix analphabet: e.g.,Σ ={a,b}•
Fix alanguage: e.g.,L= (ab)∗•
We studyconstrained topological sorting:• Input:directed acyclic graph(DAG) with vertices labeled withΣ
• Output: is there atopological sort that falls inL?
•
Question:when is this problemtractable?a
b a b
b a
a b a b a b ... inL!
Constrained Topological Sorting
•
Fix analphabet: e.g.,Σ ={a,b}•
Fix alanguage: e.g.,L= (ab)∗•
We studyconstrained topological sorting:• Input:directed acyclic graph(DAG) with vertices labeled withΣ
• Output: is there atopological sort that falls inL?
•
Question:when is this problemtractable?a
b a b
b a
a b a b a b ... inL!
Constrained Topological Sorting
•
Fix analphabet: e.g.,Σ ={a,b}•
Fix alanguage: e.g.,L= (ab)∗•
We studyconstrained topological sorting:• Input:directed acyclic graph(DAG) with vertices labeled withΣ
• Output: is there atopological sort that falls inL?
•
Question:when is this problemtractable?a
b a b
b a
a b a b a b ... inL!
Constrained Topological Sorting
•
Fix analphabet: e.g.,Σ ={a,b}•
Fix alanguage: e.g.,L= (ab)∗•
We studyconstrained topological sorting:• Input:directed acyclic graph(DAG) with vertices labeled withΣ
• Output: is there atopological sort that falls inL?
•
Question:when is this problemtractable?a
b a b
b a
a b a b a b ... inL!
Constrained Topological Sorting
•
Fix analphabet: e.g.,Σ ={a,b}•
Fix alanguage: e.g.,L= (ab)∗•
We studyconstrained topological sorting:• Input:directed acyclic graph(DAG) with vertices labeled withΣ
• Output: is there atopological sort that falls inL?
•
Question:when is this problemtractable?a
b a b
b a
a
b a b b a ... not inL!
Constrained Topological Sorting
•
Fix analphabet: e.g.,Σ ={a,b}•
Fix alanguage: e.g.,L= (ab)∗•
We studyconstrained topological sorting:• Input:directed acyclic graph(DAG) with vertices labeled withΣ
• Output: is there atopological sort that falls inL?
•
Question:when is this problemtractable?a
b a b
b a
a b
a b b a ... not inL!
Constrained Topological Sorting
•
Fix analphabet: e.g.,Σ ={a,b}•
Fix alanguage: e.g.,L= (ab)∗•
We studyconstrained topological sorting:• Input:directed acyclic graph(DAG) with vertices labeled withΣ
• Output: is there atopological sort that falls inL?
•
Question:when is this problemtractable?a
b a b
b a
a b a
b b a ... not inL!
Constrained Topological Sorting
•
Fix analphabet: e.g.,Σ ={a,b}•
Fix alanguage: e.g.,L= (ab)∗•
We studyconstrained topological sorting:• Input:directed acyclic graph(DAG) with vertices labeled withΣ
• Output: is there atopological sort that falls inL?
•
Question:when is this problemtractable?a
b a b
b a
a b a b
b a ... not inL!
Constrained Topological Sorting
•
Fix analphabet: e.g.,Σ ={a,b}•
Fix alanguage: e.g.,L= (ab)∗•
We studyconstrained topological sorting:• Input:directed acyclic graph(DAG) with vertices labeled withΣ
• Output: is there atopological sort that falls inL?
•
Question:when is this problemtractable?a
b a b
b a
a b a b b
a ... not inL!
Constrained Topological Sorting
•
Fix analphabet: e.g.,Σ ={a,b}•
Fix alanguage: e.g.,L= (ab)∗•
We studyconstrained topological sorting:• Input:directed acyclic graph(DAG) with vertices labeled withΣ
• Output: is there atopological sort that falls inL?
•
Question:when is this problemtractable?a
b a b
b a
a b a b b a
... not inL!
Constrained Topological Sorting
•
Fix analphabet: e.g.,Σ ={a,b}•
Fix alanguage: e.g.,L= (ab)∗•
We studyconstrained topological sorting:• Input:directed acyclic graph(DAG) with vertices labeled withΣ
• Output: is there atopological sort that falls inL?
•
Question:when is this problemtractable?a
b a b
b a
a b a b b a ... not inL!
Constrained Topological Sorting
•
Fix analphabet: e.g.,Σ ={a,b}•
Fix alanguage: e.g.,L= (ab)∗•
We studyconstrained topological sorting:• Input:directed acyclic graph(DAG) with vertices labeled withΣ
• Output: is there atopological sort that falls inL?
•
Question:when is this problemtractable?a
b a b
b a
a b a b a b ... inL!
Constrained Topological Sorting
•
Fix analphabet: e.g.,Σ ={a,b}•
Fix alanguage: e.g.,L= (ab)∗•
We studyconstrained topological sorting:• Input:directed acyclic graph(DAG) with vertices labeled withΣ
• Output: is there atopological sort that falls inL?
•
Question:when is this problemtractable?a
b a b
b a
a
b a b a b ... inL!
Constrained Topological Sorting
•
Fix analphabet: e.g.,Σ ={a,b}•
Fix alanguage: e.g.,L= (ab)∗•
We studyconstrained topological sorting:• Input:directed acyclic graph(DAG) with vertices labeled withΣ
• Output: is there atopological sort that falls inL?
•
Question:when is this problemtractable?a
b a b
b a
a b
a b a b ... inL!
Constrained Topological Sorting
•
Fix analphabet: e.g.,Σ ={a,b}•
Fix alanguage: e.g.,L= (ab)∗•
We studyconstrained topological sorting:• Input:directed acyclic graph(DAG) with vertices labeled withΣ
• Output: is there atopological sort that falls inL?
•
Question:when is this problemtractable?a
b a b
b a
a b a
b a b ... inL!
Constrained Topological Sorting
•
Fix analphabet: e.g.,Σ ={a,b}•
Fix alanguage: e.g.,L= (ab)∗•
We studyconstrained topological sorting:• Input:directed acyclic graph(DAG) with vertices labeled withΣ
• Output: is there atopological sort that falls inL?
•
Question:when is this problemtractable?a
b a b
b a
a b a b
a b ... inL!
Constrained Topological Sorting
•
Fix analphabet: e.g.,Σ ={a,b}•
Fix alanguage: e.g.,L= (ab)∗•
We studyconstrained topological sorting:• Input:directed acyclic graph(DAG) with vertices labeled withΣ
• Output: is there atopological sort that falls inL?
•
Question:when is this problemtractable?a
b a b
b a
a b a b a
b ... inL!
Constrained Topological Sorting
•
Fix analphabet: e.g.,Σ ={a,b}•
Fix alanguage: e.g.,L= (ab)∗•
We studyconstrained topological sorting:• Input:directed acyclic graph(DAG) with vertices labeled withΣ
• Output: is there atopological sort that falls inL?
•
Question:when is this problemtractable?a
b a b
b a
a b a b a b
... inL!
Constrained Topological Sorting
•
Fix analphabet: e.g.,Σ ={a,b}•
Fix alanguage: e.g.,L= (ab)∗•
We studyconstrained topological sorting:• Input:directed acyclic graph(DAG) with vertices labeled withΣ
• Output: is there atopological sort that falls inL?
•
Question:when is this problemtractable?a
b a b
b a
a b a b a b ... inL!
Constrained Topological Sorting
•
Fix analphabet: e.g.,Σ ={a,b}•
Fix alanguage: e.g.,L= (ab)∗•
We studyconstrained topological sorting:• Input:directed acyclic graph(DAG) with vertices labeled withΣ
• Output: is there atopological sort that falls inL?
•
Question:when is this problemtractable?a
b a b
b a
a b a b a b ... inL!
Constrained Topological Sorting
•
Fix analphabet: e.g.,Σ ={a,b}•
Fix alanguage: e.g.,L= (ab)∗•
We studyconstrained topological sorting:• Input:directed acyclic graph(DAG) with vertices labeled withΣ
• Output: is there atopological sort that falls inL?
•
Question:when is this problemtractable?a
b a b
b a
a b a b a b ... inL!
Motivation
•
How wereally ended upstudying this problem:2011 2012 2013 2014 2015 2016 2017 2018
Probabilistic XML XML versioning
•
Whicha-posteriori motivationdid we invent for the problem?→Schedulingwith constraints! →Verification forconcurrent code!
→Computational biology! →Blockchain! (joke)
•
But why do weactually care?→ Naturalproblem and apparentlynothingwas known about it!
Motivation
•
How wereally ended upstudying this problem:2011 2012 2013 2014 2015 2016 2017 2018
Probabilistic XML XML versioning
•
Whicha-posteriori motivationdid we invent for the problem?→Schedulingwith constraints! →Verification forconcurrent code!
→Computational biology! →Blockchain! (joke)
•
But why do weactually care?→ Naturalproblem and apparentlynothingwas known about it!
Motivation
•
How wereally ended upstudying this problem:2011 2012 2013 2014 2015 2016 2017 2018
Probabilistic XML XML versioning
Order-uncertain databases Top-k Aggregate queries
•
Whicha-posteriori motivationdid we invent for the problem?→Schedulingwith constraints! →Verification forconcurrent code!
→Computational biology! →Blockchain! (joke)
•
But why do weactually care?→ Naturalproblem and apparentlynothingwas known about it!
Motivation
•
How wereally ended upstudying this problem:2011 2012 2013 2014 2015 2016 2017 2018
Probabilistic XML XML versioning
Order-uncertain databases Top-k Aggregate queries Possible answers
•
Whicha-posteriori motivationdid we invent for the problem?→Schedulingwith constraints! →Verification forconcurrent code!
→Computational biology! →Blockchain! (joke)
•
But why do weactually care?→ Naturalproblem and apparentlynothingwas known about it!
Motivation
•
How wereally ended upstudying this problem:2011 2012 2013 2014 2015 2016 2017 2018
Probabilistic XML XML versioning
Order-uncertain databases Top-k Aggregate queries Possible answers
DAGs Algebraic language theory?!
•
Whicha-posteriori motivationdid we invent for the problem?→Schedulingwith constraints! →Verification forconcurrent code!
→Computational biology! →Blockchain! (joke)
•
But why do weactually care?→ Naturalproblem and apparentlynothingwas known about it!
Motivation
•
How wereally ended upstudying this problem:2011 2012 2013 2014 2015 2016 2017 2018
Probabilistic XML XML versioning
Order-uncertain databases Top-k Aggregate queries Possible answers
DAGs Algebraic language theory?!
•
Whicha-posteriori motivationdid we invent for the problem?→Schedulingwith constraints! →Verification forconcurrent code!
→Computational biology! →Blockchain! (joke)
•
But why do weactually care?→ Naturalproblem and apparentlynothingwas known about it!
Motivation
•
How wereally ended upstudying this problem:2011 2012 2013 2014 2015 2016 2017 2018
Probabilistic XML XML versioning
Order-uncertain databases Top-k Aggregate queries Possible answers
DAGs Algebraic language theory?!
•
Whicha-posteriori motivationdid we invent for the problem?→Schedulingwith constraints! →Verification forconcurrent code!
→Computational biology! →Blockchain! (joke)
•
But why do weactually care?→ Naturalproblem and apparentlynothingwas known about it!
Motivation
•
How wereally ended upstudying this problem:2011 2012 2013 2014 2015 2016 2017 2018
Probabilistic XML XML versioning
Order-uncertain databases Top-k Aggregate queries Possible answers
DAGs Algebraic language theory?!
•
Whicha-posteriori motivationdid we invent for the problem?→Schedulingwith constraints! →Verification forconcurrent code!
→Computational biology! →Blockchain!
(joke)
•
But why do weactually care?→ Naturalproblem and apparentlynothingwas known about it!
Motivation
•
How wereally ended upstudying this problem:2011 2012 2013 2014 2015 2016 2017 2018
Probabilistic XML XML versioning
Order-uncertain databases Top-k Aggregate queries Possible answers
DAGs Algebraic language theory?!
•
Whicha-posteriori motivationdid we invent for the problem?→Schedulingwith constraints! →Verification forconcurrent code!
→Computational biology! →Blockchain! (joke)
•
But why do weactually care?→ Naturalproblem and apparentlynothingwas known about it!
Motivation
•
How wereally ended upstudying this problem:2011 2012 2013 2014 2015 2016 2017 2018
Probabilistic XML XML versioning
Order-uncertain databases Top-k Aggregate queries Possible answers
DAGs Algebraic language theory?!
•
Whicha-posteriori motivationdid we invent for the problem?→Schedulingwith constraints! →Verification forconcurrent code!
→Computational biology! →Blockchain! (joke)
•
But why do weactually care?→ Naturalproblem and apparentlynothingwas known about it!
Motivation
•
How wereally ended upstudying this problem:2011 2012 2013 2014 2015 2016 2017 2018
Probabilistic XML XML versioning
Order-uncertain databases Top-k Aggregate queries Possible answers
DAGs Algebraic language theory?!
•
Whicha-posteriori motivationdid we invent for the problem?→Schedulingwith constraints! →Verification forconcurrent code!
→Computational biology! →Blockchain! (joke)
•
Formal problem statement
•
Fix aregular languageLon anfinite alphabetΣ•
Constrained topological sortproblemCTS(L):• Input:aDAGGwith vertices labeled by letters ofΣ
• Output:is there atopological sortofGsuch that the sequence of vertex labels is awordofL
•
Special case: theconstrained shuffle problemCSh(L):• Input:a set ofwordsw1, . . . ,wnofΣ∗
• Output:is there ashuffleofw1, . . . ,wnwhich is inL
•
This is likeCTSbut the input DAG is anunion of paths→ Question:What is thecomplexityofCTS(L)andCSh(L), depending on the fixed languageL?
Formal problem statement
•
Fix aregular languageLon anfinite alphabetΣ•
Constrained topological sortproblemCTS(L):• Input:aDAGGwith vertices labeled by letters ofΣ
• Output:is there atopological sortofGsuch that the sequence of vertex labels is awordofL
a
b a b
b a
•
Special case: theconstrained shuffle problemCSh(L):• Input:a set ofwordsw1, . . . ,wnofΣ∗
• Output:is there ashuffleofw1, . . . ,wnwhich is inL
•
This is likeCTSbut the input DAG is anunion of paths→ Question:What is thecomplexityofCTS(L)andCSh(L), depending on the fixed languageL?
Formal problem statement
•
Fix aregular languageLon anfinite alphabetΣ•
Constrained topological sortproblemCTS(L):• Input:aDAGGwith vertices labeled by letters ofΣ
• Output:is there atopological sortofGsuch that the sequence of vertex labels is awordofL
a
b a b
b a
•
Special case: theconstrained shuffle problemCSh(L):• Input:a set ofwordsw1, . . . ,wnofΣ∗
• Output:is there ashuffleofw1, . . . ,wnwhich is inL
•
This is likeCTSbut the input DAG is anunion of paths→ Question:What is thecomplexityofCTS(L)andCSh(L), depending on the fixed languageL?
Formal problem statement
•
Fix aregular languageLon anfinite alphabetΣ•
Constrained topological sortproblemCTS(L):• Input:aDAGGwith vertices labeled by letters ofΣ
• Output:is there atopological sortofGsuch that the sequence of vertex labels is awordofL
a
b a b
b a
•
Special case: theconstrained shuffle problemCSh(L):• Input:a set ofwordsw1, . . . ,wnofΣ∗
• Output:is there ashuffleofw1, . . . ,wnwhich is inL
•
This is likeCTSbut the input DAG is anunion of pathsa a b
b b a
→ Question:What is thecomplexityofCTS(L)andCSh(L), depending on the fixed languageL?
Formal problem statement
•
Fix aregular languageLon anfinite alphabetΣ•
Constrained topological sortproblemCTS(L):• Input:aDAGGwith vertices labeled by letters ofΣ
• Output:is there atopological sortofGsuch that the sequence of vertex labels is awordofL
a
b a b
b a
•
Special case: theconstrained shuffle problemCSh(L):• Input:a set ofwordsw1, . . . ,wnofΣ∗
• Output:is there ashuffleofw1, . . . ,wnwhich is inL
•
This is likeCTSbut the input DAG is anunion of pathsa a b
b b a
→ Question:What is thecomplexityofCTS(L)andCSh(L), depending on the fixed languageL?
Dichotomy
Conjecture
Conjecture
For everyregular language L, exactly one of the following holds:
•
Lhas [some nice property] andCTS(L)isin NL•
Lhas [some nasty property] andCTS(L)isNP-hardHere’s what we actually know:
•
CTSandCShareNP-hardfor some languages, including(ab)∗•
They arein NLforsome language families(monomials, groups)•
Some languages are tractable forseemingly unrelatedreasons→ Very mysterious landscape!(to us)
Dichotomy Conjecture
Conjecture
For everyregular language L, exactly one of the following holds:
•
Lhas [some nice property] andCTS(L)isin NL•
Lhas [some nasty property] andCTS(L)isNP-hardHere’s what we actually know:
•
CTSandCShareNP-hardfor some languages, including(ab)∗•
They arein NLforsome language families(monomials, groups)•
Some languages are tractable forseemingly unrelatedreasons→ Very mysterious landscape!(to us)
Dichotomy Conjecture
Conjecture
For everyregular language L, exactly one of the following holds:
•
Lhas [some nice property] andCTS(L)isin NL•
Lhas [some nasty property] andCTS(L)isNP-hard Here’s what we actually know:•
CTSandCShareNP-hardfor some languages, including(ab)∗•
They arein NLforsome language families(monomials, groups)•
Some languages are tractable forseemingly unrelatedreasons→ Very mysterious landscape!(to us)
Dichotomy Conjecture
Conjecture
For everyregular language L, exactly one of the following holds:
•
Lhas [some nice property] andCTS(L)isin NL•
Lhas [some nasty property] andCTS(L)isNP-hard Here’s what we actually know:•
CTSandCShareNP-hardfor some languages, including(ab)∗•
They arein NLforsome language families(monomials, groups)•
Some languages are tractable forseemingly unrelatedreasons→ Very mysterious landscape!(to us)
Dichotomy Conjecture
Conjecture
For everyregular language L, exactly one of the following holds:
•
Lhas [some nice property] andCTS(L)isin NL•
Lhas [some nasty property] andCTS(L)isNP-hard Here’s what we actually know:•
CTSandCShareNP-hardfor some languages, including(ab)∗•
They arein NLforsome language families(monomials, groups)•
Some languages are tractable forseemingly unrelatedreasons→ Very mysterious landscape!(to us)
Dichotomy Conjecture
Conjecture
For everyregular language L, exactly one of the following holds:
•
Lhas [some nice property] andCTS(L)isin NL•
Lhas [some nasty property] andCTS(L)isNP-hard Here’s what we actually know:•
CTSandCShareNP-hardfor some languages, including(ab)∗•
They arein NLforsome language families(monomials, groups)•
Some languages are tractable forseemingly unrelatedreasons→ Very mysterious landscape!(to us)
Hardness Results
Existing Hardness Result
... but the target is awordwhich isprovided as input!
→ Does not directly apply for us, because wefixthe target language
Existing Hardness Result
... but the target is awordwhich isprovided as input!
→ Does not directly apply for us, because wefixthe target language
Existing Hardness Result
... but the target is awordwhich isprovided as input!
→ Does not directly apply for us, because wefixthe target language
Hardness for CTS
•
We can reduce their problem toCShfor thelanguage(aA+bB)∗•
To determine if the shuffle of aab and bbcontains ababb ...solve theCSh-problem for aab and bband ABABB
→ CSh((aA+bB)∗)isNP-hardand the same holds forCTS
•
Similar technique:CSh((ab)∗)isNP-hard•
Customreduction techniqueto show NP-hardnessHardness for CTS
•
We can reduce their problem toCShfor thelanguage(aA+bB)∗•
To determine if the shuffle of aab and bbcontains ababb ...solve theCSh-problem for aab and bband ABABB
→ CSh((aA+bB)∗)isNP-hardand the same holds forCTS
•
Similar technique:CSh((ab)∗)isNP-hard•
Customreduction techniqueto show NP-hardnessHardness for CTS
•
We can reduce their problem toCShfor thelanguage(aA+bB)∗•
To determine if the shuffle of aab and bbcontains ababb ...solve theCSh-problem for aab and bband ABABB
→ CSh((aA+bB)∗)isNP-hardand the same holds forCTS
•
Similar technique:CSh((ab)∗)isNP-hard•
Customreduction techniqueto show NP-hardnessHardness for CTS
•
We can reduce their problem toCShfor thelanguage(aA+bB)∗•
To determine if the shuffle of aab and bbcontains ababb ...solve theCSh-problem for aab and bband ABABB
→ CSh((aA+bB)∗)isNP-hardand the same holds forCTS
•
Similar technique:CSh((ab)∗)isNP-hard•
Customreduction techniqueto show NP-hardnessHardness for CTS
•
We can reduce their problem toCShfor thelanguage(aA+bB)∗•
To determine if the shuffle of aab and bbcontains ababb ...solve theCSh-problem for aab and bband ABABB
→ CSh((aA+bB)∗)isNP-hardand the same holds forCTS
•
Similar technique:CSh((ab)∗)isNP-hard•
Customreduction techniqueto show NP-hardnessThe reduction technique
G a
b a b
b a
P b c a c b c a c b c a c
•
Say we want to solveCTSfor(ab)∗(NP-hard)•
Say we know how to solveCTSfor(abc)∗•
Take aninstanceGfor(ab)∗, with2nvertices•
Add thepathP: (bcac)n•
A topsort ofG∪Pachieving(abc)∗ gives a topsort ofGachieving(ab)∗•
Conversely, any topsort ofGachieving(ab)∗ extends to a topsort ofG+Pachieving(abc)∗•
Hence,CTS((abc)∗)isNP-hardThe reduction technique
G a
b a b
b a
P b c a c b c a c b c a c
•
Say we want to solveCTSfor(ab)∗(NP-hard)•
Say we know how to solveCTSfor(abc)∗•
Take aninstanceGfor(ab)∗, with2nvertices•
Add thepathP: (bcac)n•
A topsort ofG∪Pachieving(abc)∗ gives a topsort ofGachieving(ab)∗•
Conversely, any topsort ofGachieving(ab)∗ extends to a topsort ofG+Pachieving(abc)∗•
Hence,CTS((abc)∗)isNP-hardThe reduction technique
G a
b a b
b a
P b c a c b c a c b c a c
•
Say we want to solveCTSfor(ab)∗(NP-hard)•
Say we know how to solveCTSfor(abc)∗•
Take aninstanceGfor(ab)∗, with2nvertices•
Add thepathP: (bcac)n•
A topsort ofG∪Pachieving(abc)∗ gives a topsort ofGachieving(ab)∗•
Conversely, any topsort ofGachieving(ab)∗ extends to a topsort ofG+Pachieving(abc)∗•
Hence,CTS((abc)∗)isNP-hardThe reduction technique G
a
b a b
b a
P b c a c b c a c b c a c
•
Say we want to solveCTSfor(ab)∗(NP-hard)•
Say we know how to solveCTSfor(abc)∗•
Take aninstanceGfor(ab)∗, with2nvertices•
Add thepathP: (bcac)n•
A topsort ofG∪Pachieving(abc)∗ gives a topsort ofGachieving(ab)∗•
Conversely, any topsort ofGachieving(ab)∗ extends to a topsort ofG+Pachieving(abc)∗•
Hence,CTS((abc)∗)isNP-hardThe reduction technique G
a
b a b
b a
P b c a c b c a c b c a c
•
Say we want to solveCTSfor(ab)∗(NP-hard)•
Say we know how to solveCTSfor(abc)∗•
Take aninstanceGfor(ab)∗, with2nvertices•
Add thepathP: (bcac)n•
A topsort ofG∪Pachieving(abc)∗ gives a topsort ofGachieving(ab)∗•
Conversely, any topsort ofGachieving(ab)∗ extends to a topsort ofG+Pachieving(abc)∗•
Hence,CTS((abc)∗)isNP-hardThe reduction technique G
a
b a b
b a
P b c a c b c a c b c
•
Say we want to solveCTSfor(ab)∗(NP-hard)•
Say we know how to solveCTSfor(abc)∗•
Take aninstanceGfor(ab)∗, with2nvertices•
Add thepathP: (bcac)n•
A topsort ofG∪Pachieving(abc)∗ gives a topsort ofGachieving(ab)∗•
Conversely, any topsort ofGachieving(ab)∗ extends to a topsort ofG+Pachieving(abc)∗•
Hence,CTS((abc)∗)isNP-hardThe reduction technique G
a
b a b
b a
P b c a c b c a c b c a c
•
Say we want to solveCTSfor(ab)∗(NP-hard)•
Say we know how to solveCTSfor(abc)∗•
Take aninstanceGfor(ab)∗, with2nvertices•
Add thepathP: (bcac)n•
A topsort ofG∪Pachieving(abc)∗ gives a topsort ofGachieving(ab)∗•
Conversely, any topsort ofGachieving(ab)∗ extends to a topsort ofG+Pachieving(abc)∗•
Hence,CTS((abc)∗)isNP-hardThe reduction technique G
a
b a b
b a
P b c a c b c a c b c
•
Say we want to solveCTSfor(ab)∗(NP-hard)•
Say we know how to solveCTSfor(abc)∗•
Take aninstanceGfor(ab)∗, with2nvertices•
Add thepathP: (bcac)n•
A topsort ofG∪Pachieving(abc)∗ gives a topsort ofGachieving(ab)∗•
Conversely, any topsort ofGachieving(ab)∗ extends to a topsort ofG+Pachieving(abc)∗•
Hence,CTS((abc)∗)isNP-hardThe reduction technique G
a
b a b
b a
P b c a c b c a c b c a c
•
Say we want to solveCTSfor(ab)∗(NP-hard)•
Say we know how to solveCTSfor(abc)∗•
Take aninstanceGfor(ab)∗, with2nvertices•
Add thepathP: (bcac)n•
A topsort ofG∪Pachieving(abc)∗ gives a topsort ofGachieving(ab)∗•
Conversely, any topsort ofGachieving(ab)∗ extends to a topsort ofG+Pachieving(abc)∗•
Hence,CTS((abc)∗)isNP-hardFormalizing the reduction
Definition
A languageLshuffle-reducesto a languageL0 if, given anynin unary, we can compute in PTIME a wordPi having the following property:
for any wordwof lengthn, we havew∈L iff the shuffle ofwandPi contains a word ofL0.
Theorem
IfLshuffle-reduces toL0 then:
•
CSh(L)reduces in PTIME toCSh(L0)•
CTS(L)reduces in PTIME toCTS(L0)Formalizing the reduction
Definition
A languageLshuffle-reducesto a languageL0 if, given anynin unary, we can compute in PTIME a wordPi having the following property:
for any wordwof lengthn, we havew∈L iff the shuffle ofwandPi contains a word ofL0.
Theorem
IfLshuffle-reduces toL0 then:
•
CSh(L)reduces in PTIME toCSh(L0)•
CTS(L)reduces in PTIME toCTS(L0)Formalizing the reduction
Definition
A languageLshuffle-reducesto a languageL0 if, given anynin unary, we can compute in PTIME a wordPi having the following property:
for any wordwof lengthn, we havew∈L iff the shuffle ofwandPi contains a word ofL0.
Theorem
IfLshuffle-reduces toL0 then:
•
CSh(L)reduces in PTIME toCSh(L0)•
CTS(L)reduces in PTIME toCTS(L0)Other hard languages
•
The reduction showshardnessfor:• (ab+b)∗(also simpler argument)
• (aa+bb)∗withP2i= (ab)i
• u∗ifucontains two different letters
•
Conjecture:ifFis finite thenCTS(F∗)isNP-hard unless it contains a power of each of its letters• Idea: reason aboutconsumption ratesof letters?
• Not evencompleteforF∗languages, as(aa+bb)∗isNP-hard
Other hard languages
•
The reduction showshardnessfor:• (ab+b)∗(also simpler argument)
• (aa+bb)∗withP2i= (ab)i
• u∗ifucontains two different letters
•
Conjecture:ifFis finite thenCTS(F∗)isNP-hard unless it contains a power of each of its letters• Idea: reason aboutconsumption ratesof letters?
• Not evencompleteforF∗languages, as(aa+bb)∗isNP-hard
Other hard languages
•
The reduction showshardnessfor:• (ab+b)∗(also simpler argument)
• (aa+bb)∗withP2i= (ab)i
• u∗ifucontains two different letters
•
Conjecture:ifFis finite thenCTS(F∗)isNP-hard unless it contains a power of each of its letters• Idea: reason aboutconsumption ratesof letters?
• Not evencompleteforF∗languages, as(aa+bb)∗isNP-hard
Other hard languages
•
The reduction showshardnessfor:• (ab+b)∗(also simpler argument)
• (aa+bb)∗withP2i= (ab)i
• u∗ifucontains two different letters
•
Conjecture:ifFis finite thenCTS(F∗)isNP-hard unless it contains a power of each of its letters• Idea: reason aboutconsumption ratesof letters?
• Not evencompleteforF∗languages, as(aa+bb)∗isNP-hard
Tractability Results
Tractability for Monomials
•
Monomial:language of the formA∗1 a1A∗2 a2 · · · A∗nanA∗n+1 wherea1, . . . ,an∈ΣandA1, . . . ,An+1 ⊆Σ•
Union of monomials:union of finitely many such languages• Example:pattern matchingΣ∗word1Σ∗+ Σ∗word2Σ∗
• Logical interpretation:languages definable inΣ2[<] Theorem
For any union of monomialsL, the problemCTS(L)isin NL
Tractability for Monomials
•
Monomial:language of the formA∗1 a1A∗2 a2 · · · A∗nanA∗n+1 wherea1, . . . ,an∈ΣandA1, . . . ,An+1 ⊆Σ•
Union of monomials:union of finitely many such languages• Example:pattern matchingΣ∗word1Σ∗+ Σ∗word2Σ∗
• Logical interpretation:languages definable inΣ2[<] Theorem
For any union of monomialsL, the problemCTS(L)isin NL
Tractability for Monomials
•
Monomial:language of the formA∗1 a1A∗2 a2 · · · A∗nanA∗n+1 wherea1, . . . ,an∈ΣandA1, . . . ,An+1 ⊆Σ•
Union of monomials:union of finitely many such languages• Example:pattern matchingΣ∗word1Σ∗+ Σ∗word2Σ∗
• Logical interpretation:languages definable inΣ2[<]
Theorem
For any union of monomialsL, the problemCTS(L)isin NL
Tractability for Monomials
•
Monomial:language of the formA∗1 a1A∗2 a2 · · · A∗nanA∗n+1 wherea1, . . . ,an∈ΣandA1, . . . ,An+1 ⊆Σ•
Union of monomials:union of finitely many such languages• Example:pattern matchingΣ∗word1Σ∗+ Σ∗word2Σ∗
• Logical interpretation:languages definable inΣ2[<]
Theorem
For any union of monomialsL, the problemCTS(L)isin NL
Proof Idea for Monomials
•
Tractable languages are clearlyclosed under unionso it suffices to consider a monomial:A∗1 a1A∗2 a2 · · · A∗nanA∗n+1 wherea1, . . . ,an∈ΣandA1, . . . ,An+1 ⊆Σ
•
We canguessthe positions of the individualai•
Check that the other verticescan fitin theA∗i (uses NL = co-NL)• Check that thedescendantsofanare all inAn+1
• Find the vertices thatmustbe enumerated beforean
• Theancestorsof theai
• Theancestorsof vertices with a letternot inAn+1
• Inductively solve the problem for these vertices and A∗1 a1A∗2 a2 · · · A∗n
Proof Idea for Monomials
•
Tractable languages are clearlyclosed under unionso it suffices to consider a monomial:A∗1 a1A∗2 a2 · · · A∗nanA∗n+1 wherea1, . . . ,an∈ΣandA1, . . . ,An+1 ⊆Σ
•
We canguessthe positions of the individualai•
Check that the other verticescan fitin theA∗i (uses NL = co-NL)• Check that thedescendantsofanare all inAn+1
• Find the vertices thatmustbe enumerated beforean
• Theancestorsof theai
• Theancestorsof vertices with a letternot inAn+1
• Inductively solve the problem for these vertices and A∗1 a1A∗2 a2 · · · A∗n
Proof Idea for Monomials
•
Tractable languages are clearlyclosed under unionso it suffices to consider a monomial:A∗1 a1A∗2 a2 · · · A∗nanA∗n+1 wherea1, . . . ,an∈ΣandA1, . . . ,An+1 ⊆Σ
•
We canguessthe positions of the individualai•
Check that the other verticescan fitin theA∗i (uses NL = co-NL)• Check that thedescendantsofanare all inAn+1
• Find the vertices thatmustbe enumerated beforean
• Theancestorsof theai
• Theancestorsof vertices with a letternot inAn+1
• Inductively solve the problem for these vertices and A∗1 a1A∗2 a2 · · · A∗n