测试是否可以安排字母来用普通语言实现单词


23

我将常规语言 L固定L在字母Σ上Σ,并考虑了以下问题,我称其为L的字母调度。非正式地,输入为我提供了n个字母和每个字母的间隔(即最小和最大位置),我的目标是将每个字母放置在其间隔中,以确保没有两个字母映射到相同的位置,从而产生的n个字母词在L中。正式地:LnnL

  • 输入:Ñn三元组一个- [R (ai,li,ri),其中一个∈ ΣaiΣ1 [R Ñ1lirin是整数
  • 输出:是否有一个双射˚F { 1 ... Ñ } { 1 ... Ñ }f:{1,,n}{1,,n}使得˚F [R lif(i)ri对所有i,和一个˚F - 11 一个˚F - 1ñ 大号af1(1)af1(n)L

显然,这个问题在NP中,通过猜测双射ff并在PTIME中检查L的隶属关系L。我的问题:是否有正规语言大号L,使得对于信调度问题大号L是NP难?

初步观察:

  • 似乎在调度中已经研究了类似的问题:我们可以将问题视为在考虑开始和结束日期的同时在一台机器上调度单位成本任务。但是,后一个问题显然是在PTIME中使用贪婪的方法实现的,对于任务被标记并且希望以目标常规语言实现一个单词的情况,我在调度文献中看不到任何东西。
  • 解决该问题的另一种方式是二部最大匹配问题的一种特殊情况(字母和位置之间),但是再次很难表达我们必须属于L的约束L
  • 在特定情况下,LL是某个固定单词u(例如a b )的形式为u 的语言,则L的字母调度问题在PTIME中使用简单的贪婪算法:从左开始构建单词向右移动,并在每个位置放一个相对于L正确且时间r i最小的可用字母。(如果没有可用的正确字母,则失败。)但是,这不能推广到任意常规语言L,因为对于这种语言,我们可以选择使用哪种字母。uu(ab)LLriL
  • 看起来动态算法似乎可以工作,但实际上并不是那么简单:您似乎需要记住到目前为止所用的字母集。确实,当从左到右构建一个单词时,当您到达位置i时i,您的状态取决于您到目前为止所消费的字母。您不能记住整个集合,因为那样会成倍地增加许多状态。但是“汇总”它不是那么容易(例如,使用每个字母的副本数),因为要知道您使用的是哪个副本,似乎需要记住何时使用它们(以后使用时要记住)他们,更多的字母可用)。即使是像语言b | b *(ab|ba),可能已经有很复杂,当你要选择采取限制bab,当你要选择采取b 一个ba取决于哪个字母,你以后需要,当字母变为可用。
  • 但是,由于常规语言LL是固定的并且不能记住太多信息,因此我很难找到可以解决的NP难题。

您可以在PTIME中获得L的NP完全性吗?
Lance Fortnow

3
@LanceFortnow好的。您可以填充3CNF,以便每个变量都以偶数个文字出现,并且每两个连续出现都被取反。将x i编码xi0 i0i1 i1i,然后在字母调度实例中将符号(,),,固定,而其余的分别为半00和半11。在多项式时间内,可以检查字符串是否编码了填充后的3CNF,该填充的3CNF评估为true。
Willard Zhan

您也可以将问题推广到“任意位置”(不限于1..n)。也许更容易证明硬度(如果很难)。
Marzio De Biasi

@MarzioDeBiasi:我不确定我是否理解,您的意思是字母的位置可以是任意子集而不是间隔吗?我不知道这是否很难(它开始有点像完全匹配问题),但是当L = u 时,带间隔的版本允许使用贪婪算法,因此我希望它可能会更容易。L=u
a3nm

@ a3nm:不,我的意思是你可以概括下降的约束[R ñ ; 你问一个字为L,其中有至少一个字母一个在范围[ ř ] ; 换句话说,您不是“构建”长度为n的完整单词,而是要求一个任意长度的单词,其中包含允许范围内的给定字母。我不知道这是否会改变问题的复杂性,但是在这种情况下,您必须面对“索引”,这些索引可能不受输入长度的多项式限制。rinai[li..ri]n
Marzio De Biasi

Answers:


7

对于L = A ,问题是NP-难的,其中A是包含以下单词的有限语言:L=AA

  • x 111 x 000x111x000
  • y 100 y 010 y 001y100y010y001
  • 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}

约简需要将“图形方向”实例作为输入,并生成三元组列表作为输出。通过这种减少,我们输出的三元组将始终满足某些约束。这些约束在下面列出,并且当且仅当它们满足以下约束时,我们才会将三元组列表视为有效:

  • 仅给字符xyc包含一个索引的间隔。换句话说,无论何时放置这些字符,它们都将放置在特定位置。xyc
  • 对于每一个三重- [R 存在于该实例与{ 0 1 },三1 - - [R 也存在。(i,l,r)i{0,1}(1i,l,r)
  • 如果α - [R α ''- [R '存在于例如两个三元组然后要么< '[R ' < - [R ,或' < [R < - [R ',或{ α α ' } = { 0 1 }= (α,l,r)(α,l,r)l<lr<rl<lr<r{α,α}={0,1}' < r = r 'l=l<r=r
  • 如果α - [R 是一个三然后三元组的数量α ''- [R ''[R '[R正是- [R - + 1(α,l,r)(α,l,r)llrrrl+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 i1i1 and i+2i+2 to be opposite (one 00 and one 11) and the characters at i2i2 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<rl<l<r<r. We add the crossover character into the middle (between ll 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,i1)(l,i1), (i+2,r)(i+2,r), (l,i2)(l,i2), (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 kk. Now consider some triple with interval length kk. Then that triple must be of the form (i,l,r)(i,l,r) with r=l+k1r=l+k1 and i{0,1}i{0,1}. The triple (1i,l,r)(1i,l,r) must also be present. The number of triples (α,l,r)(α,l,r) with llrrllrr is exactly rl+1=krl+1=k. These triples include triples (0,l,r)(0,l,r) and (1,l,r)(1,l,r) but also k2k2 other triples of the form (α,l,r)(α,l,r) with l<lr<rl<lr<r. These other triples all have interval length smaller than kk, 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.


Thanks a lot for this elaborate proof, and with a very simple language! I think it is correct, the only thing I'm not sure about is the claim that "adding the crossover vertex can't cause any additional edges to become crossed". Couldn't it be the case that the interval (l,r)(l,r) included some other interval (l,r)(l′′,r′′) with llrrll′′r′′r, and now one of (l,i1)(l,i1) and (i+2,r)(i+2,r) crosses it? It seems like the process still has to converge because the intervals get smaller, but that's not completely clear either because of the insertion of crossover vertices. How should I see it?
a3nm

If l<l<r<rl<l<r<r, then you can insert the new indices for the new crossover vertex immediately to the right of ll. This causes the new indices (i±i± a bit) to be in exactly those intervals that used to contain ll. It should be easy to see that adding a crossover vertex can add a new crossing with some other interval only if the new indices fall in the other interval. If l<l<r<rl<l′′<r′′<r then the new indices do not fall into the interval (l,r)(l′′,r′′). If l<l<r<rl<l′′<r′′<r then the new indices might fall into the interval (l,r)(l′′,r′′), but only if ll already fell into that
Mikhail Rudoy

(continued) interval. In this case, you aren't actually creating a new crossing, just turning an old crossing with the old interval (l,r)(l,r) into a new crossing with the interval (i+something,r)
Mikhail Rudoy

I guess in your second message you meant "with the old interval (l,r)" rather than "(l,r)"? But OK, I see it: when you add the crossing vertex, the only bad case would be an interval I that overlap with a new interval without overlapping with the corresponding interval. This cannot happen for supersets of (l,r) or of (l,r): if they overlap with a new interval then they overlapped with the old one. Likewise for subsets of (l,r) or (l,r) for the reason that you explain. So I agree that this proof looks correct to me. Thanks again!
a3nm

2

@MikhailRudoy was the first to show NP-hardness, but Louis and I had a different idea, which I thought I could outline here since it works somewhat differently. We reduce directly from CNF-SAT, the Boolean satisfiability problem for CNFs. In exchange for this, the regular language L that we use is more complicated.

The key to show hardness is to design a language L that allows us to guess a word and repeat it multiple times. Specifically, for any number k of variables and number m of clauses, we will build intervals that ensure that all words w of L that we can form must start with an arbitrary word u of length k on alphabet {0,1} (intuitively encoding a guess of the valuation of variables), and then this word u is repeated m times (which we will later use to test that each clause is satisfied by the guessed valuation).

To achieve this, we will fix the alphabet A={0,1,#,0,1} and the language: L:=(0|1)(#(00|11))#(0|1). The formal claim is a bit more complicated:

Claim: For any numbers k,mN, we can build in PTIME a set of intervals such that the words in L that can be formed with these intervals are precisely:

{u(#(˜u˜u)#(uu))m#˜uu{0,1}k}

where ˜u denotes the result of reversing the order of u and swapping 0's and 1's, where u denotes the result of adding a prime to all letters in u, and where xy for two words x of y of length p is the word of length 2p formed by taking alternatively one letter from x and one letter from y.

Here's an intuitive explanation of the construction that we use to prove this. We start with intervals that encode the initial guess of u. Here is the gadget for n=4 (left), and a possible solution (right):

choice gadget

It's easy to show the following observation (ignoring L for now): the possible words that we can form with these intervals are exactly u#˜u for u{0,1}k. This is shown essentially like the Lemma in @MikhailRudoy's answer, by induction from the shortest intervals to the longest ones: the center position must contain #, the two neighboring positions must contain one 0 and one 1, etc.

We have seen how to make a guess, now let's see how to duplicate it. For this, we will rely on L, and add more intervals. Here's an illustration for k=3:

duplication gadget

For now take L:=(0|1)(#(00|11))#(0|1). Observe how, past the first #, we must enumerate alternatively an unprimed and a primed letter. So, on the un-dashed triangle of intervals, our observation above still stands: even though it seems like these intervals have more space to the right of the first #, only one position out of two can be used. The same claim holds for the dashed intervals. Now, L further enforces that, when we enumerate an unprimed letter, the primed letter that follows must be the same. So it is easy to see that the possible words are exactly: u#(˜u˜u)#u for u{0,1}k.

Now, to show the claim, we simply repeat this construction m times. Here's an example for k=3 and m=2, using now the real definition of L above the statement of the claim:

duplication gadget, repeated

As before, we could show (by induction on m) that the possible words are exactly the following: u(#˜u˜u#uu)2#˜u for u{0,1}k. So this construction achieves what was promised by the claim.

Thanks to the claim we know that we can encode a guess of a valuation for the variables, and repeat the valuation multiple times. The only missing thing is to explain how to check that the valuation satisfies the formula. We will do this by checking one clause per occurrence of u. To do this, we observe that without loss of generality we can assume that each letter of the word is annotated by some symbol provided as input. (More formally: we could assume that in the problem we also provide as input a word w of length n, and we ask whether the intervals can form a word u such that wu is in L.) The reason why we can assume this is because we can double the size of each interval, and add unit intervals (at the bottom of the picture) at odd positions to carry the annotation of the corresponding even position:

unit annotations

Thanks to this observation, to check clauses, we will define our regular language L to be the intersection of two languages. The first language enforces that the sub-word on even positions is a word in L, i.e., if we ignore the annotations then the word must be in L, so we can just use the construction of the claim and add some annotations. The second language L will check that the clauses are satisfied. To do this, we will add three letters in our alphabet, to be used as annotations: +, , and ϵ. At clause 1im, we add unit intervals to annotate by + the positions in the i-th repetition of u corresponding to variables occurring positively in clause i, and annotate by~ the positions corresponding to negatively occurring variables. We annotate everything else by~ϵ. It is now clear that L can check that the guessed valuation satisfies the formula, by verifying that, between each pair of consecutive # symbols that contain an occurrence of u (i.e., one pair out of two), there is some literal that satisfies the clause, i.e., there must be one occurrence of the subword +1 or of the subword 0.

This concludes the reduction from CNF-SAT and shows NP-hardness of the letter scheduling problem for the language L.

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.