Document Open Access Logo

Encoding Hard String Problems with Answer Set Programming

Author Dominik Köppl

Thumbnail PDF


  • Filesize: 1.03 MB
  • 21 pages

Document Identifiers

Author Details

Dominik Köppl
  • Department of Computer Science, Universität Münster, Germany


We thank Mutsunori Banbara for drawing our attention to the ASP language.

Cite AsGet BibTex

Dominik Köppl. Encoding Hard String Problems with Answer Set Programming. In 34th Annual Symposium on Combinatorial Pattern Matching (CPM 2023). Leibniz International Proceedings in Informatics (LIPIcs), Volume 259, pp. 17:1-17:21, Schloss Dagstuhl - Leibniz-Zentrum für Informatik (2023)


Despite the simple, one-dimensional nature of strings, several computationally hard problems on strings are known. Tackling hard problems beyond sizes of toy instances with straight-forward solutions is infeasible. To solve these problems on datasets of even small sizes, effort has to be put into the conception of algorithms leveraging profound characteristics of the input. Finding these characteristics can be eased by rapidly creating and evaluating prototypes of new concepts in how to tackle hard problems. Such a rapid-prototyping method for hard problems is answer set programming (ASP). In this light, we study the application of ASP on five NP-hard optimization problems in the field of strings. We provide MAX-SAT and ASP encodings, and empirically reason about the merits and flaws when working with ASP solvers.

Subject Classification

ACM Subject Classification
  • Theory of computation
  • Computing methodologies → Artificial intelligence
  • Theory of computation → Discrete optimization
  • Hardware → Theorem proving and SAT solving
  • optimization problems
  • answer set programming
  • MAX-SAT encoding
  • NP-hard string problems


  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    PDF Downloads


  1. Hideo Bannai, Keisuke Goto, Masakazu Ishihata, Shunsuke Kanda, Dominik Köppl, and Takaaki Nishimoto. Computing NP-hard repetitiveness measures via MAX-SAT. In Proc. ESA, volume 244 of LIPIcs, pages 12:1-12:16, 2022. URL:
  2. Manu Basavaraju, Fahad Panolan, Ashutosh Rai, M. S. Ramanujan, and Saket Saurabh. On the kernelization complexity of string problems. Theor. Comput. Sci., 730:21-31, 2018. URL:
  3. Riccardo Bertolucci, Alessio Capitanelli, Carmine Dodaro, Nicola Leone, Marco Maratea, Fulvio Mastrogiovanni, and Mauro Vallati. An ASP-based framework for the manipulation of articulated objects using dual-arm robots. In Proc. LPNMR, volume 11481 of LNCS, pages 32-44, 2019. URL:
  4. Manuel Bichler, Bernhard Bliem, Marius Moldovan, Michael Morak, and Stefan Woltran. Treewidth-preserving modeling in ASP. Technical Report DBAI-TR-2016-97, Technische Universität Wien, 2016. Google Scholar
  5. Guillaume Blin, Laurent Bulteau, Minghui Jiang, Pedro J. Tejada, and Stéphane Vialette. Hardness of longest common subsequence for sequences with bounded run-lengths. In Proc. CPM, volume 7354 of LNCS, pages 138-148, 2012. URL:
  6. Christian Blum. ILP-based reduced variable neighborhood search for large-scale minimum common string partition. Electron. Notes Discret. Math., 66:15-22, 2018. URL:
  7. Christian Blum, José Antonio Lozano, and Pedro Pinacho Davidson. Iterative probabilistic tree search for the minimum common string partition problem. In Proc. HM, volume 8457 of LNCS, pages 145-154, 2014. URL:
  8. Christina Boucher and Kathleen P. Wilkie. Why large closest string instances are easy to solve in practice. In Proc. SPIRE, volume 6393 of LNCS, pages 106-117, 2010. URL:
  9. Laurent Bulteau, Falk Hüffner, Christian Komusiewicz, and Rolf Niedermeier. Multivariate algorithmics for np-hard string problems. Technical report, European Association for Theoretical Computer Science, 2014. Google Scholar
  10. Laurent Bulteau, Mark Jones, Rolf Niedermeier, and Till Tantau. An FPT-algorithm for longest common subsequence parameterized by the maximum number of deletions. In Proc. CPM, volume 223 of LIPIcs, pages 6:1-6:11, 2022. URL:
  11. Laurent Bulteau and Christian Komusiewicz. Minimum common string partition parameterized by partition size is fixed-parameter tractable. In Proc. SODA, pages 102-121, 2014. URL:
  12. Francesco Calimeri, Wolfgang Faber, Martin Gebser, Giovambattista Ianni, Roland Kaminski, Thomas Krennwallner, Nicola Leone, Marco Maratea, Francesco Ricca, and Torsten Schaub. ASP-core-2 input language format. Theory Pract. Log. Program., 20(2):294-309, 2020. URL:
  13. Markus Chimani, Matthias Woste, and Sebastian Böcker. A closer look at the closest string and closest substring problem. In Proc. ALENEX, pages 13-24, 2011. URL:
  14. Milos Chromý and Markus Sinnl. On solving the minimum common string partition problem by decision diagrams. In Proc. ICORES, pages 177-184, 2022. URL:
  15. Thomas H Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. Introduction To Algorithms. MIT Press, 2009. Google Scholar
  16. Federico Della Croce and Fabio Salassa. Improved lp-based algorithms for the closest string problem. Comput. Oper. Res., 39(3):746-749, 2012. URL:
  17. Marek Cygan, Alexander S. Kulikov, Ivan Mihajlin, Maksim Nikolaev, and Grigory Reznikov. Minimum common string partition: Exact algorithms. In Proc. ESA, volume 204 of LIPIcs, pages 35:1-35:16, 2021. URL:
  18. Warley Gramacho da Silva, Tiago da Silva Almeida, Rafael Lima de Carvallho, Edeilson Milhomem da Silva, Ary Henrique de Oliveira, Glenda Michele Botelho, and Glêndara Aparecida de Souza Martins. Two classic chess problems solved by answer set programming. International Journal of Advanced Engineering Research and Science, 6(4):1-5, 2019. URL:
  19. Esra Erdem, Michael Gelfond, and Nicola Leone. Applications of answer set programming. AI Magazine, 37(3):53-68, 2016. URL:
  20. Andreas A. Falkner, Gerhard Friedrich, Konstantin Schekotihin, Richard Taupe, and Erich Christian Teppan. Industrial applications of answer set programming. Künstliche Intell., 32(2-3):165-176, 2018. URL:
  21. Carlos Farkas, Andy Mella, Maxime Turgeon, and Jody J Haigh. A novel sars-cov-2 viral sequence bioinformatic pipeline has found genetic evidence that the viral 3' untranslated region (utr) is evolving and generating increased viral diversity. Frontiers in microbiology, 12(665041):1-14, 2021. URL:
  22. S. M. Ferdous and M. Sohel Rahman. Solving the minimum common string partition problem with the help of ants. Math. Comput. Sci., 11(2):233-249, 2017. URL:
  23. S. M. Ferdous and Mohammad Sohel Rahman. An integer programming formulation of the minimum common string partition problem. PLOS ONE, 10(7):1-16, 2015. URL:
  24. Moti Frances and Ami Litman. On covering problems of codes. Theory Comput. Syst., 30(2):113-119, 1997. URL:
  25. John Gallant, David Maier, and James A. Storer. On finding minimal length superstrings. J. Comput. Syst. Sci., 20(1):50-58, 1980. URL:
  26. Martin Gebser, Roland Kaminski, Benjamin Kaufmann, Max Ostrowski, Torsten Schaub, and Philipp Wanko. Theory solving made easy with clingo 5. In Proc. ICLP, volume 52 of OASIcs, pages 2:1-2:15, 2016. URL:
  27. Martin Gebser, Roland Kaminski, Benjamin Kaufmann, and Torsten Schaub. Multi-shot ASP solving with clingo. Theory Pract. Log. Program., 19(1):27-82, 2019. URL:
  28. Martin Gebser, Marco Maratea, and Francesco Ricca. The seventh answer set programming competition: Design and results. Theory Pract. Log. Program., 20(2):176-204, 2020. URL:
  29. Avraham Goldstein, Petr Kolman, and Jie Zheng. Minimum common string partition problem: Hardness and approximations. Electron. J. Comb., 12, 2005. URL:
  30. Luis C. González, Heidi J. Romero, and Carlos A. Brizuela. A genetic algorithm for the shortest common superstring problem. In Proc. GECCO, volume 3103 of LNCS, pages 1305-1306, 2004. URL:
  31. Jens Gramm. Closest substring. In Encyclopedia of Algorithms, pages 324-326. Springer, 2016. URL:
  32. Jens Gramm, Rolf Niedermeier, and Peter Rossmanith. Fixed-parameter algorithms for CLOSEST STRING and related problems. Algorithmica, 37(1):25-42, 2003. URL:
  33. Dan Gusfield, Gad M. Landau, and Baruch Schieber. An efficient algorithm for the all pairs suffix-prefix problem. Inf. Process. Lett., 41(4):181-185, 1992. URL:
  34. Brenda Hinkemeyer and Bryant A. Julstrom. A genetic algorithm for the longest common subsequence problem. In Proc. GECCO, pages 609-610, 2006. URL:
  35. Hoang Xuan Huan, Dong Do Duc, and Nguyen Manh Ha. An efficient two-phase ant colony optimization algorithm for the closest string problem. In Proc. SEAL, volume 7673 of LNCS, pages 188-197, 2012. URL:
  36. Robert W. Irving and Campbell Fraser. Two algorithms for the longest common subsequence of three (or more) strings. In Proc. CPM, volume 644 of LNCS, pages 214-229, 1992. URL:
  37. Tom Kelsey and Lars Kotthoff. Exact closest string as a constraint satisfaction problem. In ProcİCCS, volume 4 of Procedia Computer Science, pages 1062-1071, 2011. URL:
  38. Dusan Knop, Martin Koutecký, and Matthias Mnich. Combinatorial n-fold integer programming and applications. Math. Program., 184(1):1-34, 2020. URL:
  39. J. Kevin Lanctôt, Ming Li, Bin Ma, Shaojiu Wang, and Louxin Zhang. Distinguishing string selection problems. Inf. Comput., 185(1):41-55, 2003. URL:
  40. Vladimir Lifschitz. Answer Set Programming. Springer, 2019. URL:
  41. Liu Liu. The Performance Optimization of ASP Solving Based on Encoding. PhD thesis, University of Kentucky, 2022. Google Scholar
  42. Liu Liu and Miroslaw Truszczynski. Encoding selection for solving hamiltonian cycle problems with ASP. In Proc. ICLP, volume 306 of EPTCS, pages 302-308, 2019. URL:
  43. Xiaolan Liu, Shenghan Liu, Zhifeng Hao, and Holger Mauch. Exact algorithm and heuristic for the closest string problem. Comput. Oper. Res., 38(11):1513-1520, 2011. URL:
  44. Domingo López-Rodríguez and Enrique Mérida Casermeiro. Shortest common superstring problem with discrete neural networks. In Proc. ICANNGA, volume 5495 of LNCS, pages 62-71, 2009. URL:
  45. David Maier. The complexity of some problems on subsequences and supersequences. J. ACM, 25(2):322-336, 1978. URL:
  46. Dániel Marx. The closest substring problem with small distances. In Proc. FOCS, pages 63-72, 2005. URL:
  47. Holger Mauch. Closest substring problem - results from an evolutionary algorithm. In Proc. ICONIP, volume 3316 of LNCS, pages 205-211, 2004. URL:
  48. Rolf Niedermeier. Ubiquitous parameterization - invitation to fixed-parameter algorithms. In Proc. MFCS, volume 3153 of LNCS, pages 84-103, 2004. URL:
  49. Hannu Peltola, Hans Söderlund, Jorma Tarhio, and Esko Ukkonen. Algorithms for some string matching problems arising in molecular genetics. In Proc. IFIP, pages 59-64, 1983. Google Scholar
  50. Shyong Jian Shyu and Chun-Yuan Tsai. Finding the longest common subsequence for multiple biological sequences by ant colony optimization. Comput. Oper. Res., 36(1):73-91, 2009. URL:
  51. James A. Storer and Thomas G. Szymanski. Data compression via textural substitution. J. ACM, 29(4):928-951, 1982. URL:
  52. Krister M. Swenson, Mark Marron, Joel V. Earnest-DeYoung, and Bernard M. E. Moret. Approximating the true evolutionary distance between two genomes. ACM J. Exp. Algorithmics, 12:3.5:1-3.5:17, 2008. URL:
  53. Jorma Tarhio and Esko Ukkonen. A greedy approximation algorithm for constructing shortest common superstrings. Theor. Comput. Sci., 57:131-145, 1988. URL:
  54. Jean P. Tremeschin Torres and Edna Ayako Hoshino. Lp-based heuristics for the distinguishing string and substring selection problems. Ann. Oper. Res., 316(2):1205-1234, 2022. URL:
  55. Omar Vilca and Rosiane de Freitas. An efficient algorithm for the closest string problem. In Anais do I Encontro de Teoria da Computação, pages 879-882, Porto Alegre, RS, Brasil, 2016. URL:
  56. Robert A. Wagner and Michael J. Fischer. The string-to-string correction problem. J. ACM, 21(1):168-173, 1974. URL:
  57. Lusheng Wang, Ming Li, and Bin Ma. Closest string and substring problems. In Encyclopedia of Algorithms, pages 321-324. Springer, 2016. URL:
  58. Neng-Fa Zhou. In pursuit of an efficient SAT encoding for the Hamiltonian cycle problem. In Proc. CP, volume 12333 of LNCS, pages 585-602, 2020. URL:
Questions / Remarks / Feedback

Feedback for Dagstuhl Publishing

Thanks for your feedback!

Feedback submitted

Could not send message

Please try again later or send an E-mail