, Volume 18, Issue 1, pp 7–37 | Cite as

On the hardness of solving edge matching puzzles as SAT or CSP problems

  • Carlos Ansótegui
  • Ramón Béjar
  • Cèsar Fernández
  • Carles MateuEmail author


Edge matching puzzles have been amongst us for a long time now and traditionally they have been considered, both, a children’s game and an interesting mathematical divertimento. Their main characteristics have already been studied, and their worst-case complexity has been properly classified as a NP-complete problem. It is in recent times, specially after being used as the problem behind a money-prized contest, with a prize of 2US$ million for the first solver, that edge matching puzzles have attracted mainstream attention from wider audiences, including, of course, computer science people working on solving hard problems. We consider these competitions as an interesting opportunity to showcase SAT/CSP solving techniques when confronted to a real world problem to a broad audience, a part of the intrinsic, i.e. monetary, interest of such a contest. This article studies the NP-complete problem known as edge matching puzzle using SAT and CSP approaches for solving it. We will focus on providing, first and foremost, a theoretical framework, including a generalized definition of the problem. We will design and show algorithms for easy and fast problem instances generation, generators with easily tunable hardness. Afterwards we will provide with SAT and CSP models for the problems and we will study problem complexity, both typical case and worst-case complexity. We will also provide some specially crafted heuristics that result in a boost in solving time and study which is the effect of such heuristics.


Constraints SAT CSP Edge matching puzzles Puzzles Phase transition Hardness 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Achlioptas, D., Gomes, C., Kautz, H., Selman, B. (2000). Generating satisfiable problem instances. In Proceedings of the AAAI 2000 (pp. 256–261). AAAI Press/The MIT Press.Google Scholar
  2. 2.
    Achlioptas, D., Jia, H., Moore, C. (2005). Hiding truth assignments: two are better than one. Journal of Artifical Intelligence Research, 24, 623–639.MathSciNetzbMATHGoogle Scholar
  3. 3.
    Achlioptas, D., Naor, A., Peres, Y. (2005). Rigorous location of phase transitions in hard optimization problems. Nature, 435(7043), 759.CrossRefGoogle Scholar
  4. 4.
    Achlioptas, D., & Peres, Y. (2004). The threshold for random k-sat is \(2^k\log{2}-\mathcal{O}(k)\). Journal of the American Mathematical Society, 17(4), 947–973.MathSciNetzbMATHCrossRefGoogle Scholar
  5. 5.
    Alon, N., & Spencer, J.H. (2000). The probabilistic method (2nd ed.). Discrete Mathematics and Optimization. Wiley Inter-Science.Google Scholar
  6. 6.
    Ansótegui, C., Béjar, R., Fernández, C., Gomes, C., Mateu, C. (2011). The impact of balance in a highly structured problem domain. In Proceedings of the AAAI 2006 (pp. 438–443). AAAI Press/The MIT Press.Google Scholar
  7. 7.
    Ansótegui, C., Béjar, R., Fernández, C., Gomes, C., Mateu, C. (2011). Generating highly balanced sudoku problems as hard problems. Journal of Heuristics, 17(5), 589–614. doi: 10.1007/s10732-010-9146-y.CrossRefGoogle Scholar
  8. 8.
    Ansótegui, C., Béjar, R., Fernàndez, C., Mateu, C. (2008). Edge matching puzzles as hard SAT/CSP benchmarks. In CP ’08: proceedings of the 14th international conference on principles and practice of constraint programming. Lecture notes in computer science (Vol. 5202, pp. 560–565). Sydney, Australia: Springer.Google Scholar
  9. 9.
    Ansótegui, C., Béjar, R., Fernández, C., Mateu, C. (2008). How hard is a commercial puzzle: the Eternity II challenge. Frontiers in Artificial Intelligence and Applications - Artificial Intelligence Research and Development, 184, 99–108.Google Scholar
  10. 10.
    Ansótegui, C., del Val, A., Dotú, I., Fernández, C., Manyà, F. (2004). Modelling choices in quasigroup completion: SAT vs CSP. In Proceedings of the AAAI 2004. AAAI Press/The MIT Press.Google Scholar
  11. 11.
    Ansótegui, C., & Manyà, F. (2005). Mapping many-valued CNF formulas to Boolean CNF formulas. In Proceedings of the international symposia on multiple-valued logic (pp. 290–295).Google Scholar
  12. 12.
    Atserias, A., Bulatov, A.A., Dalmau, V. (2007). On the power of k-consistency. In 34th International Colloquium Automata, Languages and Programming, ICALP 2007. of Lecture notes in computer science (Vol. 4596, pp. 279–290). Springer.Google Scholar
  13. 13.
    Béjar, R., Fernàndez, C., Mateu, C., Pascual, N. (2009). Bounding the phase transition on edge matching puzzles. IEEE International Symposium on Multiple-Valued Logic (pp. 80–85).Google Scholar
  14. 14.
    Benoist, T., & Bourreau, E. (2008). Fast global filtering for eternity II. Constraint Programming Letters, 3, 36–49.Google Scholar
  15. 15.
    Bessière, C., & Régin, J.-C. (1996). MAC and combined heuristics: two reasons to forsake FC (and CBJ?) on hard problems. In Principles and practice of constraint programming (pp. 61–75).Google Scholar
  16. 16.
    Cohen, D.A., Jeavons, P., Jefferson, C., Petrie, K.E., Smith, B.M. (2006). Symmetry definitions for constraint satisfaction problems. Constraints, 11(2–3), 115–137.MathSciNetzbMATHCrossRefGoogle Scholar
  17. 17.
    Dechter, R. (2003). Constraint processing. Morgan Kaufmann.Google Scholar
  18. 18.
    Demaine, E.D., & Demaine, M.L. (2007). Jigsaw puzzles, edge matching, and polyomino packing: connections and complexity. Graphs and Combinatorics, 23(s1), 195.MathSciNetzbMATHCrossRefGoogle Scholar
  19. 19.
    Eén, N., & Biere, A. (2005). Effective preprocessing in SAT through variable and clause elimination. In Proceedings of SAT 2005 (pp. 61–75).Google Scholar
  20. 20.
    Eén, N., & Sörensson, N. (2003). An extensible SAT-solver. In Proceedings of SAT 2003. Lecture notes in computer science (Vol. 2919, pp. 502–518). Springer.Google Scholar
  21. 21.
    Eén, N., & Sörensson, N. (2006). Translating pseudo-Boolean constraints into SAT. Journal of Satisfiability, 2, 1–26.zbMATHGoogle Scholar
  22. 22.
    Gent, I.P., Jefferson, C., Miguel, I. (2006). MINION: a fast, scalable, constraint solver. In Proceedings of the 2006 conference on ECAI 2006: 17th European conference on artificial intelligence, 29 Aug–1 Sept 2006, Riva del Garda, Italy (pp. 98–102). Amsterdam, The Netherlands, The Netherlands: IOS Press.Google Scholar
  23. 23.
    Gent, I.P., Jefferson, C., Miguel, I. (2006). Watched literals for constraint propagation in Minion. In Principles and practice of constraint programming (pp. 182–197).Google Scholar
  24. 24.
    Haanpää, H., Järvisalo, M., Kaski, P., Niemelä, I. (2006). Hard satisfiable clause sets for benchmarking equivalence reasoning techniques. Journal on Satisfiability, Boolean Modeling and Computation, 2(1–4), 27–46.zbMATHGoogle Scholar
  25. 25.
    Haralick, R.M., & Elliott, G.L. (1980). Increasing tree search efficiency for constraint satisfaction problems. AI Journal, 14, 263–313.Google Scholar
  26. 26.
    Järvisalo, M. (2006). Further investigations into regular XORSAT. In Proceedings of the AAAI 2006. AAAI Press/The MIT Press.Google Scholar
  27. 27.
    Li, C.M., & Anbulagan, A. (1997). Heuristics based on unit propagation for satisfiability problems. In Proceedings of the International Joint Conference on Artif icial Intelligence, IJCAI 97 (pp. 366–371). Morgan Kaufmann.Google Scholar
  28. 28.
    Monasson, R., Zecchinna, R., Kirkpatrick, S., Selman, B., Troyansky, L. (1999). Determining computational complexity from characteristic phase transitions. Nature, 400, 133–137.MathSciNetCrossRefGoogle Scholar
  29. 29.
    Prosser, P. (1996). An empirical study of phase transitions in binary constraint satisfaction problems. AI Journal, 81, 81–109.MathSciNetGoogle Scholar
  30. 30.
    Régin, J.-C. (1994). A filtering algorithm for constraints of difference in CSPs. In Proceedings of the AAAI 1994 (pp. 362–367). AAAI Press/The MIT Press.Google Scholar
  31. 31.
    Régin, J.-C. (1999). The symmetric alldiff constraint. In Proceedings of the sixteenth International Joint Conference on Artificial Intelligence, IJCAI 99 (pp. 420–425). Morgan Kaufmann.Google Scholar
  32. 32.
    Schaus, P., & Deville, Y. (2008). Hybridization of CP and VLNS for Eternity II. In Quatrime Journes Francophones de Programmation par Contraintes (JFPC’08).Google Scholar
  33. 33.
    Smith, B., & Dyer, M. (1996). Locating the phase transition in binary constraint satisfaction problems. Artificial Intelligence, 81, 155–181.MathSciNetCrossRefGoogle Scholar
  34. 34.
    Takenaga, Y., & Walsh, T. (2006). Tetravex is NP-complete. Information Processing Letters, 99(5), 171–174.MathSciNetzbMATHCrossRefGoogle Scholar
  35. 35.
    Williams, R., Gomes, C.P., Selman, B. (2003). Backdoors to typical case complexity. In IJCAI (pp. 1173–1178).Google Scholar
  36. 36.
    Xu, K., & Li, W. (2000). Exact phase transition in random constraint satisfaction problems. Journal of Artificial Intelligence Research, 12, 93–103.MathSciNetzbMATHGoogle Scholar

Copyright information

© Springer Science+Business Media, LLC 2012

Authors and Affiliations

  • Carlos Ansótegui
    • 1
  • Ramón Béjar
    • 1
  • Cèsar Fernández
    • 1
  • Carles Mateu
    • 1
    Email author
  1. 1.Universitat de LleidaLleidaSpain

Personalised recommendations