对于L = A ∗,问题是NP-难的,其中A是包含以下单词的有限语言:L=A∗A
- x 111, x 000,x111x000
- y 100, y 010, y 001,y100y010y001
- 00 Ç 11, 01 Ç 10, 10 Ç 01,和 11 Ç 0000c1101c1010c0111c00
减少来自问题图定向(Graph Orientation),该问题众所周知是NP难的(请参阅https://link.springer.com/article/10.1007/s00454-017-9884-9)。在这个问题中,我们给出了3定期无向图,其中每个顶点要么标记为“ { 1 } ”或“ { 0 ,3 } ”。目标是确定图形的边缘,使每个顶点的出学位位于标记该顶点的集合中。{1}{0,3}
约简需要将“图形方向”实例作为输入,并生成三元组列表作为输出。通过这种减少,我们输出的三元组将始终满足某些约束。这些约束在下面列出,并且当且仅当它们满足以下约束时,我们才会将三元组列表视为有效:
- 仅给字符x,y和c包含一个索引的间隔。换句话说,无论何时放置这些字符,它们都将放置在特定位置。xyc
- 对于每一个三重(我,升,- [R )存在于该实例与我∈ { 0 ,1 },三(1 - 我,升,- [R )也存在。(i,l,r)i∈{0,1}(1−i,l,r)
- 如果(α ,升,- [R )和(α ',升',- [R ')存在于例如两个三元组然后要么升< 升' ≤ [R ' < - [R ,或升' < 升≤ [R < - [R ',或{ α ,α ' } = { 0 ,1 }与升= 升(α,l,r)(α′,l′,r′)l<l′≤r′<rl′<l≤r<r′{α,α′}={0,1}' < r = r '。l=l′<r=r′
- 如果(α ,升,- [R )是一个三然后三元组的数量(α ',升',- [R ')与升≤ 升' ≤ [R ' ≤ [R正是- [R - 升+ 1。(α,l,r)(α′,l′,r′)l≤l′≤r′≤rr−l+1
请注意本文结尾处证明的以下引理。
Lemma: for a valid list of triples, the characters xx, yy, and cc must be placed exactly as indicated by the triples, and for any pair of triples (0,l,r)(0,l,r) and (1,l,r)(1,l,r), the two characters for that triple must be placed at indices ll and rr.
Then the idea of the reduction is the following.
We use pairs of triples (0,l,r)(0,l,r), and (1,l,r)(1,l,r) to represent edges. The edge goes between endpoints at index ll and at index rr. Assuming we produce a valid list of triples, the characters from these two triples must be placed at ll and rr, so we can treat the order in which they are placed as indicating the direction of the edge. Here 11 is the "head" of the edge and 00 is the "tail". In other words, if the 11 is placed at rr then the edge points from ll to rr and if the 11 is placed at ll then the edge points from rr to ll.
To represent vertices, we place an xx or yy character at an index and use the next three characters as the endpoints of the three edges which touch the vertex. Note that if we place an xx, all three edges at the vertex must point in the same direction (all into the vertex or all out of the vertex) simply due to the strings that are in finite language AA. Such vertices have outdegree 00 or 33, so we place an xx exactly for the vertices labeled {0,3}{0,3}. If we place a yy, exactly one of the three edges at the vertex must point in the same direction due to the strings in AA. Such vertices have outdegree 11, so we place a yy exactly for the vertices labeled {1}{1}.
In some sense, we are done. In particular, the correspondence between solving this instance and solving the Graph Orientation instance should be clear. Unfortunately, the list of triples we produce may not be valid, and so the "edges" described may not work as intended. In particular, the list of triples might not be valid because the condition that the intervals from the triples must always contain each other might not hold: the intervals from two edges may overlap without one containing the other.
To combat this, we add some more infrastructure. In particular, we add "crossover vertices". A crossover vertex is a vertex of degree 44 whose edges are paired such that within each pair one edge must point into the crossover vertex and one out. In other words, a crossover vertex will behave the same as just two "crossing" edges. We represent a crossover vertex by placing the character cc at some index ii. Then note that the language AA constrains the characters at i−1i−1 and i+2i+2 to be opposite (one 00 and one 11) and the characters at i−2i−2 and i+1i+1 to be opposite. Thus, if we use these indices as the endpoints for the four edges at the crossover vertex, the behavior is exactly as described: the four edges are in pairs and among every pair one points in and one points out.
How do we actually place these crossovers? Well suppose we have two intervals (l,r)(l,r) and (l′,r′)(l′,r′) which overlap. WLOG, l<l′<r<r′l<l′<r<r′. We add the crossover character into the middle (between l′l′ and rr). (Let's say that all along we spaced everything out so far that there's always enough space, and at the end we will remove any unused space.) Let the index of the crossover character be ii. Then we replace the four triples (0,l,r)(0,l,r), (1,l,r)(1,l,r), (0,l′,r′)(0,l′,r′), and (1,l′,r′)(1,l′,r′) with eight triples with two each (one with character 00 and one with character 11) for the following four intervals (l,i−1)(l,i−1), (i+2,r)(i+2,r), (l′,i−2)(l′,i−2), (i+1,r′)(i+1,r′). Notice that the intervals don't overlap in the bad way anymore! (After this change, if two intervals overlap, one is strictly inside the other.) Furthermore, the edge from ll to rr is replaced by an edge from ll to the crossover vertex followed by the edge from there to rr; these two edges are paired at the crossover vertex in such a way that one is pointed in and one is pointed out; in other words, the two edges together behave just like the one edge they are replacing.
In some sense, putting in this crossover vertex "uncrossed" two edges (whose intervals were overlapping). It is easy to see that adding the crossover vertex can't cause any additional edges to become crossed. Thus, we can uncross every pair of crossing edges by inserting enough crossover vertices. The end result still corresponds to the Graph Orientation instance, but now the list of triples is valid (the properties are all easy to verify now that we have "uncrossed" any crossing edges), so the lemma applies, the edges must behave as described, and the correspondence is actually an equivalence. In other words, this reduction is correct.
proof of lemma
Lemma: for a valid list of triples, the characters xx, yy, and cc must be placed exactly as indicated by the triples, and for any pair of triples (0,l,r)(0,l,r) and (1,l,r)(1,l,r), the two characters for that triple must be placed at indices ll and rr.
proof:
We proceed by induction on the triples by interval length. In particular, our statement is the following: for any kk if some triple has interval length kk then the character in that triple must be placed as described in the lemma.
Base case: for k=0k=0, the triple must be placing a character xx, yy, or cc at the single index inside the interval. This is exactly as described in the lemma.
Inductive case: assume the statement holds for any kk less than some k′k′. Now consider some triple with interval length k′k′. Then that triple must be of the form (i,l,r)(i,l,r) with r=l+k′−1r=l+k′−1 and i∈{0,1}i∈{0,1}. The triple (1−i,l,r)(1−i,l,r) must also be present. The number of triples (α′,l′,r′)(α′,l′,r′) with l≤l′≤r′≤rl≤l′≤r′≤r is exactly r−l+1=k′r−l+1=k′. These triples include triples (0,l,r)(0,l,r) and (1,l,r)(1,l,r) but also k′−2k′−2 other triples of the form (α′,l′,r′)(α′,l′,r′) with l<l′≤r′<rl<l′≤r′<r. These other triples all have interval length smaller than k′k′, so they all must place their characters as specified in the lemma. The only way for this to occur is if these triples place characters in every index starting at index l+1l+1 and ending at index r+1r+1. Thus, our two triples (0,l,r)(0,l,r) and (1,l,r)(1,l,r) must place their characters at indices ll and rr, as described in the lemma, concluding the inductive case.
By induction, the lemma is correct.