Credo di aver trovato una riduzione dal percorso hamiltoniano , dimostrando così il problema NP-difficile.
Chiama la parola w ∈ Σ ∗ un testimone per A , se soddisfa la condizione della domanda (per ogni L ∈ A , c'è m ≥ 1 tale che { w m + i ∣ 0 ≤ i < | L | } = L ) .w∈Σ∗AL∈Am≥1{wm+i∣0≤i<|L|}=L
Considera la versione di decisione del problema originale, cioè decidi se per alcuni A e k ≥ 0 , c'è un testimone per A di lunghezza al massimo k . Questo problema può essere risolto usando il problema originale come oracolo nel tempo polinomiale (trova il testimone più breve, quindi confronta la sua lunghezza con k ).Ak≥0Akk
Ora per il nucleo della riduzione. Sia G = ( V , E ) un grafico semplice, non orientato, connesso. Per ogni v ∈ V , lascia che L v = { v } ∪ { e ∈ E ∣ v ∈ e } sia l'insieme contenente il vertice v e tutti i suoi bordi adiacenti. Impostare Σ = E e A = { L v ∣ v ∈ V } . Quindi GG=(V,E)v∈VLv={v}∪{e∈E∣v∈e}vΣ=EA={Lv∣v∈V}G has a Hamiltonian path if and only if there is a witness for AA of length at most 2|E|+12|E|+1.
Proof. Let v1e1v2…en−1vnv1e1v2…en−1vn be a Hamiltonian path in GG and H={e1,e2,…,en−1}H={e1,e2,…,en−1} the set of all edges on the path. For each vertex vv, define the set Uv=Lv∖HUv=Lv∖H. Choose an arbitrary ordering αvαv for each UvUv. The word w=αv1e1αv2e2…en−1αvnw=αv1e1αv2e2…en−1αvn is a witness for AA, since Lv1Lv1 is represented by the substring α1e1α1e1, LvnLvn by en−1αnen−1αn, and for each vivi, i∉{1,n}i∉{1,n}, LviLvi is represented by ei−1uvieiei−1uviei. Furthermore, each edge in EE occurs twice in ww with the exception of |V|−1|V|−1 edges in HH, which occur once, and each vertex in VV occurs once, giving |w|=2|E|+1|w|=2|E|+1.
For the other direction, let ww be an arbitrary witness for AA of length at most 2|E|+12|E|+1. Clearly, each e∈Ee∈E and v∈Vv∈V occurs in ww at least once. Without loss of generality, assume that each e∈Ee∈E occurs in ww at most twice and each v∈Vv∈V occurs exactly once; otherwise a shorter witness can be found by removing elements from ww.
Let H⊆EH⊆E be the set of all edges occurring in ww exactly once. Given the assumptions above, it holds that |w|=2|E|−|H|+|V||w|=2|E|−|H|+|V|.
Consider a contiguous substring of ww of the form ue1e2…ekvue1e2…ekv, where u,v∈Vu,v∈V, ei∈Eei∈E. We say that u,vu,v are adjacent. Notice that if ei∈Hei∈H, then ei={u,v}ei={u,v}, because eiei occurs only once, yet it is adjacent to two vertices in GG. Therefore, at most one of eiei can be in HH. Similarly, no edge in HH can occur in ww before the first vertex or after the last vertex.
Now, there are |V||V| vertices, therefore |H|≤|V|−1|H|≤|V|−1. From there, it follows that |w|≥2|E|+1|w|≥2|E|+1. Since we assume |w|≤2|E|+1|w|≤2|E|+1, we get equality. From there we get |H|=|V|−1|H|=|V|−1. By pigeonhole principle, there is an edge from HH between each pair of vertices adjacent in ww. Denote h1h2…hn−1h1h2…hn−1 all elements from HH in the order they appear in w. It follows that v1h1v2h2…hn−1vn is a Hamiltonian path in G. ◻
Since the problem of deciding the existence of Hamiltonian path is NP-hard and the above reduction is polynomial, the original problem is NP-hard too.