To show that the challenge is NP-hard, we reduce from 3SAT. Let φ be a formula with m clauses and n variables. We create an UltraGo board with m rows and n columns. For each clause cj of φ, if variable xi appears in a literal of cj , we place a stone at row j and column i. If xi appears negated,the stone is black; otherwise, it is white. (WLOG, we can discard any clause in which xj appears both negated and non-negated, since such a clause is trivially satisfified by any truth assignment.) Clearly,this construction can be completed in time proportional to the number of clauses.
Claim: φ is satisfifiable iffff our constructed UltraGo board has a challenge solution.
Pf: (→) let A be a satisfying assignment to φ. In each clause cj of φ, choose any one literal made true by A and leave its stone in place; remove the other two stones from row j. A makes every clause true,so this process will leave (exactly) one stone in every row.
A makes every variable either true or false, so no two clauses can have true literals xi and ¬xi . Hence,every occurrence of a stone in row i is either white (if A sets xi true) or black (if A sets xi false).
Hence, the board has a solution to the challenge.
(←) suppose our board has a solution to the challenge. For each variable xi of φ, if the solution leaves only white stones in row i, set xi true; if it leaves only black stones, set xi false; if no stones are left in row i, set xi arbitrarily.
We fifirst note that the resulting truth assignment makes every variable either true or false. Moreover,every row has at least one stone. By construction, a stone is placed in cell (j, i) only if the specified assignment to variable xi makes the corresponding clause cj true. Hence, if there is a stone remaining in each row, then each clause has at least one true literal, and so φ is satisfified.
We fifirst argue that this problem, CRAWL, is in NP. A certifificate for a true instance is a crawl,represented as a list of bars visited in order. This crawl has size at most that of the input graph. To validate the certifificate, we check that it starts and ends with the correct pubs, that it does match some simple path in the graph, and that, for each forbidden pair of bars, the path does not include both of them. The total cost of the validator is bounded asymptotically by the number of conflflicting pairs times the graph size, which is polynomial in the input size.
We now argue that 3-SAT ≤p CRAWL. Given an instance φ of 3-SAT, we construct a graph G and forbidden pairs for CRAWL as follows. Suppose φ has m clauses, and let Ci be the ith clause of φ with literals ` i1 , `i2 , `i3 . We add to the graph three vertices v1i , vi2, vi3. We also add two distinguished vertices s and t to the graph. We add edges from every vertex built from Ci to every vertex built from Ci+1,as well as from s to every vertex built from C1 and from every vertex built from Cm to t. This graph is clearly a DAG of size proportional to |φ| and can be built in time proportional to its size.
We designate as a forbidden pair any two vertices v, v0 whose corresponding literals `, `0 are logical negations of each other. There are at most |φ|2 such pairs, which can be found in time proportional to their number.
Claim 1: if φ is satisfifiable, then there is a crawl through graph G of length m + 2 that does not use any forbidden pair.
Pf: Let A be a satisfying assignment for φ. A makes at least one literal of every clause true. Choose true literals ` 1 . . . `m, one from each clause. The corresponding crawl in G is s, v1 . . . vm, t, where vj is the vertex corresponding to literal ` j . This is clearly a valid path from s to t in G. Moreover,since A simultaneously makes all the literals ` 1 . . . `m true, no two of these literals can be logically contradictory, and so the path has no forbidden pairs.
Claim 2: if G has a crawl of length m+2 with no forbidden pairs, then there is a satisfying assignment for φ.
Pf: Let π be the crawl through G of the given length. By the structure of G, π has the form s, v1 . . . vm, t, where vj is a vertex corresponding to a literal ` j from clause Cj . Construct a truth assignment A by choosing the variables so as to make every literal ` j from this path true (setting any remaining variables arbitrarily). Because A induces one true literal in each clause of φ, it satisfifies φ.
Moreover, A must exist because path π uses no forbidden pairs, and so no two literals induced by the path are logically contradictory.