English

The complexity of some regex crossword problems

Computational Complexity 2014-12-01 v2 Formal Languages and Automata Theory

Abstract

In a typical regular expression (regex) crossword puzzle, you are given two nonempty lists R1,,RmR_1,\ldots,R_m and C1,,CnC_1,\ldots,C_n of regular expressions over some alphabet, and your goal is to fill in an m×nm\times n grid with letters from that alphabet so that the string formed by the iith row is in L(Ri)L(R_i), and the string formed by the jjth column is in L(Cj)L(C_j), for all 1im1\le i\le m and 1jn1\le j\le n. Such a grid is a solution to the puzzle. It is known that determining whether a solution exists is NP-complete. We consider a number of restrictions and variants to this problem where all the RiR_i are equal to some regular expression RR, and all the CjC_j are equal to some regular expression CC. We call the solution to such a puzzle an (R,C)(R,C)-crossword. Our main results are the following: 1. There exists a fixed regular expression CC over the alphabet {0,1}\{0,1\} such that the following problem is NP-complete: "Given a regular expression RR over {0,1}\{0,1\} and positive integers mm and nn given in unary, does an m×nm\times n (R,C)(R,C)-crossword exist?" This improves the result mentioned above. 2. The following problem is NP-hard: "Given a regular expression EE over {0,1}\{0,1\} and positive integers mm and nn given in unary, does an m×nm\times n (E,E)(E,E)-crossword exist?" 3. There exists a fixed regular expression CC over {0,1}\{0,1\} such that the following problem is undecidable (equivalent to the Halting Problem): "Given a regular expression RR over {0,1}\{0,1\}, does an (R,C)(R,C)-crossword exist (of any size)?" 4. The following problem is undecidable (equivalent to the Halting Problem): "Given a regular expression EE over {0,1}\{0,1\}, does an (E,E)(E,E)-crossword exist (of any size)?"

Keywords

Cite

@article{arxiv.1411.5437,
  title  = {The complexity of some regex crossword problems},
  author = {Stephen A. Fenner},
  journal= {arXiv preprint arXiv:1411.5437},
  year   = {2014}
}

Comments

25 pages, 3 figures; three references added with explanation, citation added to Corollary 5, more detail in proof of Theorem 8, other minor corrections (results unchanged)

R2 v1 2026-06-22T07:05:23.779Z