Skip to main content

MiniZinc with Strings

  • Conference paper
  • First Online:
Logic-Based Program Synthesis and Transformation (LOPSTR 2016)

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 10184))

Abstract

Strings are extensively used in modern programming languages and constraints over strings of unknown length occur in a wide range of real-world applications such as software analysis and verification, testing, model checking, and web security. Nevertheless, practically no constraint programming solver natively supports string constraints. We introduce string variables and a suitable set of string constraints as builtin features of the MiniZinc modelling language. Furthermore, we define an interpreter for converting a MiniZinc model with strings into a FlatZinc instance relying only on integer variables. This conversion is obtained via rewrite rules, and does not require any extension of the existing FlatZinc specification. This provides a user-friendly interface for modelling combinatorial problems with strings, and enables both string and non-string solvers to actually solve such problems.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    This library, called nostrings.mzn, is publicly available at https://bitbucket.org/jossco/gecode-string.

  2. 2.

    Details at http://www.minizinc.org/doc-lib/doc-globals-extensional.html.

  3. 3.

    sunny-cp is available at https://github.com/CP-Unibo/sunny-cp. We actually took advantage of its architecture for running and evaluating the solvers in Table 2.

  4. 4.

    We assume a flattening time of \(T = 600\) seconds when the conversion time exceeded the time limit T. This happened only for MZN/Gurobi.

References

  1. Abdulla, P.A., Atig, M.F., Chen, Y.-F., Holík, L., Rezine, A., Rümmer, P., Stenman, J.: Norn: an SMT solver for string constraints. In: Kroening, D., Păsăreanu, C.S. (eds.) CAV 2015. LNCS, vol. 9206, pp. 462–469. Springer, Cham (2015). doi:10.1007/978-3-319-21690-4_29

    Chapter  Google Scholar 

  2. Amadini, R., Gabbrielli, M., Mauro, J.: A multicore tool for constraint solving. In: IJCAI, pp. 232–238. AAAI Press (2015)

    Google Scholar 

  3. Beldiceanu, N., Carlsson, M., Demassey, S., Petit, T.: Global constraint catalogue: past, present and future. Constraints 12(1), 21–62 (2007). http://sofdem.github.io/gccat/

  4. Belov, G., Stuckey, P.J., Tack, G., Wallace, M.: Improved linearization of constraint programming models. In: Rueher, M. (ed.) CP 2016. LNCS, vol. 9892, pp. 49–65. Springer, Cham (2016). doi:10.1007/978-3-319-44953-1_4

    Chapter  Google Scholar 

  5. Bisht, P., Hinrichs, T.L., Skrupsky, N., Venkatakrishnan, V.N.: WAPTEC: whitebox analysis of web applications for parameter tampering exploit construction. In: CCS, pp. 575–586. ACM (2011)

    Google Scholar 

  6. Björdal, G.: String variables for constraint-based local search. Master’s thesis, Department of Information Technology, Uppsala University, Sweden, August 2016. http://urn.kb.se/resolve?urn=urn:nbn:se:uu:diva-301501

  7. Björdal, G., Monette, J.-N., Flener, P., Pearson, J.: A constraint-based local search backend for MiniZinc. Constraints 20(3), 325–345 (2015)

    Article  MathSciNet  MATH  Google Scholar 

  8. Bjørner, N., Tillmann, N., Voronkov, A.: Path feasibility analysis for string-manipulating programs. In: Kowalewski, S., Philippou, A. (eds.) TACAS 2009. LNCS, vol. 5505, pp. 307–321. Springer, Heidelberg (2009). doi:10.1007/978-3-642-00768-2_27

    Chapter  Google Scholar 

  9. Bofill, M., Suy, J., Villaret, M.: A system for solving constraint satisfaction problems with SMT. In: Strichman, O., Szeider, S. (eds.) SAT 2010. LNCS, vol. 6175, pp. 300–305. Springer, Heidelberg (2010). doi:10.1007/978-3-642-14186-7_25

    Chapter  Google Scholar 

  10. Chu, G.: Improving Combinatorial Optimization. Ph.D. thesis, Department of Computing and Information Systems, University of Melbourne, Australia (2011)

    Google Scholar 

  11. Costantini, G., Ferrara, P., Cortesi, A.: A suite of abstract domains for static analysis of string values. Softw. Pract. Exp. 45(2), 245–287 (2015)

    Article  Google Scholar 

  12. De Landtsheer, R., Ponsard, C.: OscaR.cbls: an open source framework for constraint-based local search. In: ORBEL-27, the 27th Annual Conference of the Belgian Operational Research Society (2013). http://www.orbel.be/orbel27/pdf/abstract293.pdf; The OscaR.cbls solver https://bitbucket.org/oscarlib/oscar/wiki/CBLS

  13. Emmi, M., Majumdar, R., Sen, K.: Dynamic test input generation for database applications. In: ISSTA, pp. 151–162. ACM (2007)

    Google Scholar 

  14. Fu, X., Powell, M.C., Bantegui, M., Li, C.: Simple linear string constraints. Formal Aspects Comput. 25(6), 847–891 (2013)

    Article  MathSciNet  MATH  Google Scholar 

  15. Fujiwara, T.: iZplus description (2016). http://www.minizinc.org/challenge2016/description_izplus.txt

  16. Ganesh, V., Minnes, M., Solar-Lezama, A., Rinard, M.: Word equations with length constraints: what’s decidable? In: Biere, A., Nahir, A., Vos, T. (eds.) HVC 2012. LNCS, vol. 7857, pp. 209–226. Springer, Heidelberg (2013). doi:10.1007/978-3-642-39611-3_21

    Chapter  Google Scholar 

  17. Gange, G., Navas, J.A., Stuckey, P.J., Søndergaard, H., Schachte, P.: Unbounded model-checking with interpolation for regular language constraints. In: Piterman, N., Smolka, S.A. (eds.) TACAS 2013. LNCS, vol. 7795, pp. 277–291. Springer, Heidelberg (2013). doi:10.1007/978-3-642-36742-7_20

    Chapter  Google Scholar 

  18. Gecode Team. Gecode: generic constraint development environment (2016). http://www.gecode.org

  19. Grinchtein, O., Carlsson, M., Pearson, J.: A constraint optimisation model for analysis of telecommunication protocol logs. In: Blanchette, J.C., Kosmatov, N. (eds.) TAP 2015. LNCS, vol. 9154, pp. 137–154. Springer, Cham (2015). doi:10.1007/978-3-319-21215-9_9

    Chapter  Google Scholar 

  20. Gurobi Optimization, Inc., Gurobi Optimizer Reference Manual (2016). http://www.gurobi.com

  21. He, J., Flener, P., Pearson, J., Zhang, W.M.: Solving string constraints: the case for constraint programming. In: Schulte, C. (ed.) CP 2013. LNCS, vol. 8124, pp. 381–397. Springer, Heidelberg (2013). doi:10.1007/978-3-642-40627-0_31

    Chapter  Google Scholar 

  22. Hooimeijer, P., Weimer, W.: StrSolve: solving string constraints lazily. Autom. Softw. Eng. 19(4), 531–559 (2012)

    Article  Google Scholar 

  23. Kiezun, A., Ganesh, V., Artzi, S., Guo, P.J., Hooimeijer, P., Ernst, M.D.: HAMPI: a solver for word equations over strings, regular expressions, and context-free grammars. ACM Trans. Softw. Eng. Methodol. 21(4), 25 (2012)

    Article  Google Scholar 

  24. Kieżun, A., Ganesh, V., Guo, P.J., Hooimeijer, P., Ernst, M.D.: HAMPI: a solver for string constraints. In: ISSTA 2009, pp. 105–116. ACM (2009)

    Google Scholar 

  25. Kim, S.-W., Chin, W., Park, J., Kim, J., Ryu, S.: Inferring grammatical summaries of string values. In: Garrigue, J. (ed.) APLAS 2014. LNCS, vol. 8858, pp. 372–391. Springer, Cham (2014). doi:10.1007/978-3-319-12736-1_20

    Google Scholar 

  26. Li, G., Ghosh, I.: PASS: string solving with parameterized array and interval automaton. In: Bertacco, V., Legay, A. (eds.) HVC 2013. LNCS, vol. 8244, pp. 15–31. Springer, Cham (2013). doi:10.1007/978-3-319-03077-7_2

    Chapter  Google Scholar 

  27. Liang, T., Reynolds, A., Tinelli, C., Barrett, C., Deters, M.: A DPLL(T) theory solver for a theory of strings and regular expressions. In: Biere, A., Bloem, R. (eds.) CAV 2014. LNCS, vol. 8559, pp. 646–662. Springer, Cham (2014). doi:10.1007/978-3-319-08867-9_43

    Google Scholar 

  28. Madsen, M., Andreasen, E.: String analysis for dynamic field access. In: Cohen, A. (ed.) CC 2014. LNCS, vol. 8409, pp. 197–217. Springer, Heidelberg (2014). doi:10.1007/978-3-642-54807-9_12

    Chapter  Google Scholar 

  29. Michel, L.D., Van Hentenryck, P.: Constraint satisfaction over bit-vectors. In: Milano, M. (ed.) CP 2012. LNCS, pp. 527–543. Springer, Heidelberg (2012). doi:10.1007/978-3-642-33558-7_39

  30. Nethercote, N., Stuckey, P.J., Becket, R., Brand, S., Duck, G.J., Tack, G.: MiniZinc: towards a standard CP modelling language. In: Bessière, C. (ed.) CP 2007. LNCS, vol. 4741, pp. 529–543. Springer, Heidelberg (2007). doi:10.1007/978-3-540-74970-7_38

    Chapter  Google Scholar 

  31. Ohrimenko, O., Stuckey, P.J., Codish, M.: Propagation via lazy clause generation. Constraints 14(3), 357–391 (2009)

    Article  MathSciNet  MATH  Google Scholar 

  32. Saxena, P., Akhawe, D., Hanna, S., Mao, F., McCamant, S., Song, D.: A symbolic execution framework for JavaScript. In: S&P, pp. 513–528. IEEE Computer Society (2010)

    Google Scholar 

  33. Scott, J.D.: Other Things Besides Number: Abstraction, Constraint Propagation, and String Variable Types. Ph.D. thesis, Department of Information Technology, Uppsala University, Sweden (2016). http://urn.kb.se/resolve?urn=urn:nbn:se:uu:diva-273311

  34. Scott, J.D., Flener, P., Pearson, J.: Bounded strings for constraint programming. In: ICTAI, pp. 1036–1043. IEEE Computer Society (2013)

    Google Scholar 

  35. Scott, J.D., Flener, P., Pearson, J.: Constraint solving on bounded string variables. In: Michel, L. (ed.) CPAIOR 2015. LNCS, vol. 9075, pp. 375–392. Springer, Cham (2015). doi:10.1007/978-3-319-18008-3_26

    Google Scholar 

  36. Scott, J.D., Flener, P., Pearson, J., Schulte, C.: Design and implementation of bounded-length sequence variables. In: Salvagnin, D., Lombardi, M. (eds.) CPAIOR 2017. LNCS, vol. 10335, pp. 51–67. Springer, Cham (2017). doi:10.1007/978-3-319-59776-8_5

    Chapter  Google Scholar 

  37. Stuckey, P.J., Tack, G.: MiniZinc with functions. In: Gomes, C., Sellmann, M. (eds.) CPAIOR 2013. LNCS, vol. 7874, pp. 268–283. Springer, Heidelberg (2013). doi:10.1007/978-3-642-38171-3_18

    Chapter  Google Scholar 

  38. Subramanian, S., Berzish, M., Zheng, Y., Tripp, O., Ganesh, V.: A solver for a theory of strings and bit-vectors. CoRR, abs/1605.09446 (2016)

    Google Scholar 

  39. Trinh, M., Chu, D., Jaffar, J.: S3: a symbolic string solver for vulnerability detection in web applications. In: SIGSAC, pp. 1232–1243. ACM (2014)

    Google Scholar 

  40. Yu, F., Alkhalaf, M., Bultan, T.: Stranger: an automata-based string analysis tool for PHP. In: Esparza, J., Majumdar, R. (eds.) TACAS 2010. LNCS, vol. 6015, pp. 154–157. Springer, Heidelberg (2010). doi:10.1007/978-3-642-12002-2_13

    Chapter  Google Scholar 

  41. Zheng, Y., Ganesh, V., Subramanian, S., Tripp, O., Dolby, J., Zhang, X.: Effective search-space pruning for solvers of string equations, regular expressions and length constraints. In: Kroening, D., Păsăreanu, C.S. (eds.) CAV 2015. LNCS, vol. 9206, pp. 235–254. Springer, Cham (2015). doi:10.1007/978-3-319-21690-4_14

    Chapter  Google Scholar 

  42. Zheng, Y., Zhang, X., Ganesh, V.: Z3-str: a Z3-based string solver for web application analysis. In: SIGSOFT, pp. 114–124. ACM (2013)

    Google Scholar 

  43. Zhou, N.-F., Kjellerstrand, H.: The Picat-SAT compiler. In: Gavanelli, M., Reppy, J. (eds.) PADL 2016. LNCS, vol. 9585, pp. 48–62. Springer, Cham (2016). doi:10.1007/978-3-319-28228-2_4

    Chapter  Google Scholar 

Download references

Acknowledgements

The authors from the University of Melbourne are supported by the Australian Research Council (ARC) through Linkage Project Grant LP140100437. The authors in Sweden are supported by the Swedish Research Council (VR) through Project Grant 2015-04910. Many thanks to Gustav Björdal for having run the experiments on his local-search backend [7] for MiniZinc. Many thanks also to all the referees and to the audience of LOPSTR 2016 for their thoughtful feedback.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Roberto Amadini .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2017 Springer International Publishing AG

About this paper

Cite this paper

Amadini, R., Flener, P., Pearson, J., Scott, J.D., Stuckey, P.J., Tack, G. (2017). MiniZinc with Strings. In: Hermenegildo, M., Lopez-Garcia, P. (eds) Logic-Based Program Synthesis and Transformation. LOPSTR 2016. Lecture Notes in Computer Science(), vol 10184. Springer, Cham. https://doi.org/10.1007/978-3-319-63139-4_4

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-63139-4_4

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-63138-7

  • Online ISBN: 978-3-319-63139-4

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics