Counterexample-Guided Quantifier Instantiation for Synthesis in SMT

  • Andrew ReynoldsEmail author
  • Morgan Deters
  • Viktor Kuncak
  • Cesare Tinelli
  • Clark Barrett
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 9207)


We introduce the first program synthesis engine implemented inside an SMT solver. We present an approach that extracts solution functions from unsatisfiability proofs of the negated form of synthesis conjectures. We also discuss novel counterexample-guided techniques for quantifier instantiation that we use to make finding such proofs practically feasible. A particularly important class of specifications are single-invocation properties, for which we present a dedicated algorithm. To support syntax restrictions on generated solutions, our approach can transform a solution found without restrictions into the desired syntactic form. As an alternative, we show how to use evaluation function axioms to embed syntactic restrictions into constraints over algebraic datatypes, and then use an algebraic datatype decision procedure to drive synthesis. Our experimental evaluation on syntax-guided synthesis benchmarks shows that our implementation in the CVC4 SMT solver is competitive with state-of-the-art tools for synthesis.



We would like to thank Liana Hadarean for helpful discussions on the normal form used in cvc4 for bit vector terms.


  1. 1.
    Alur, R., et al.: Syntax-guided synthesis. To Appear in Marktoberdrof NATO proceedings. (2014). Accessed 06 February 2015
  2. 2.
    Alur, R., Bodík, R., Juniwal, G., Martin, M.M.K., Raghothaman, M., Seshia, S.A., Singh, R., Solar-Lezama, A., Torlak, E., Udupa, A.: Syntax-guided synthesis. In: FMCAD, pp. 1–17. IEEE (2013)Google Scholar
  3. 3.
    Alur, R., Martin, M., Raghothaman, M., Stergiou, C., Tripakis, S., Udupa, A.: Synthesizing finite-state protocols from scenarios and requirements. In: Yahav, E. (ed.) HVC 2014. LNCS, vol. 8855, pp. 75–91. Springer, Heidelberg (2014) Google Scholar
  4. 4.
    Barrett, C., Conway, C.L., Deters, M., Hadarean, L., Jovanović, D., King, T., Reynolds, A., Tinelli, C.: CVC4. In: Gopalakrishnan, G., Qadeer, S. (eds.) CAV 2011. LNCS, vol. 6806, pp. 171–177. Springer, Heidelberg (2011) CrossRefGoogle Scholar
  5. 5.
    Barrett, C., Deters, M., de Moura, L.M., Oliveras, A., Stump, A.: 6 years of SMT-COMP. JAR 50(3), 243–277 (2013)CrossRefGoogle Scholar
  6. 6.
    Barrett, C., Shikanian, I., Tinelli, C.: An abstract decision procedure for satisfiability in the theory of inductive data types. J. Satisfiability Boolean Model. Comput. 3, 21–46 (2007)MathSciNetzbMATHGoogle Scholar
  7. 7.
    Bjørner, N.: Linear quantifier elimination as an abstract decision procedure. In: Giesl, J., Hähnle, R. (eds.) IJCAR 2010. LNCS, vol. 6173, pp. 316–330. Springer, Heidelberg (2010) CrossRefGoogle Scholar
  8. 8.
    Cousot, P.: Proving program invariance and termination by parametric abstraction, lagrangian relaxation and semidefinite programming. In: Cousot, R. (ed.) VMCAI 2005. LNCS, vol. 3385, pp. 1–24. Springer, Heidelberg (2005) CrossRefGoogle Scholar
  9. 9.
    de Moura, L., Bjørner, N.S.: Efficient e-Matching for SMT solvers. In: Pfenning, F. (ed.) CADE 2007. LNCS (LNAI), vol. 4603, pp. 183–198. Springer, Heidelberg (2007) CrossRefGoogle Scholar
  10. 10.
    Detlefs, D., Nelson, G., Saxe, J.B.: Simplify: a theorem prover for program checking. J. ACM, Technical report (2003)Google Scholar
  11. 11.
    Ge, Y., de Moura, L.: Complete instantiation for quantified formulas in satisfiabiliby modulo theories. In: Bouajjani, A., Maler, O. (eds.) CAV 2009. LNCS, vol. 5643, pp. 306–320. Springer, Heidelberg (2009) CrossRefGoogle Scholar
  12. 12.
    Green, C.C.: Application of theorem proving to problem solving. In: Walker, D.E., Norton, L.M. (eds.) IJCAI, pp. 219–240. William Kaufmann, San Francisco (1969)Google Scholar
  13. 13.
    Jacobs, S., Kuncak, V.: Towards complete reasoning about axiomatic specifications. In: Jhala, R., Schmidt, D. (eds.) Verification, Model Checking, and Abstract Interpretation. LNCS, vol. 6538, pp. 278–293. Springer, Heidelberg (2011)CrossRefGoogle Scholar
  14. 14.
    Jha, S., Gulwani, S., Seshia, S.A., Tiwari, A.: Oracle-guided component-based program synthesis. In: Kramer, J., Bishop, J., Devanbu, P.T., Uchitel, S. (eds.) ICSE, pp. 215–224. ACM, New York (2010)Google Scholar
  15. 15.
    Kneuss, E., Kuraj, I., Kuncak, V., Suter, P.: Synthesis modulo recursive functions. In: Hosking, A.L., Eugster, P.T., Lopes, C.V. (eds.) OOPSLA, pp. 407–426. ACM, New York (2013)Google Scholar
  16. 16.
    Kuncak, V., Mayer, M., Piskac, R., Suter, P.: Complete functional synthesis. In: Zorn, B.G., Aiken, A. (eds.) PLDI, pp. 316–329. ACM, New York (2010)Google Scholar
  17. 17.
    Kuncak, V., Mayer, M., Piskac, R., Suter, P.: Software synthesis procedures. CACM 55(2), 103–111 (2012)CrossRefGoogle Scholar
  18. 18.
    Kuncak, V., Mayer, M., Piskac, R., Suter, P.: Functional synthesis for linear arithmetic and sets. STTT 15(5–6), 455–474 (2013)CrossRefGoogle Scholar
  19. 19.
    Madhavan, R., Kuncak, V.: Symbolic resource bound inference for functional programs. In: Biere, A., Bloem, R. (eds.) CAV 2014. LNCS, vol. 8559, pp. 762–778. Springer, Heidelberg (2014) Google Scholar
  20. 20.
    Manna, Z., Waldinger, R.J.: A deductive approach to program synthesis. TOPLAS 2(1), 90–121 (1980)CrossRefGoogle Scholar
  21. 21.
    Monniaux, D.: Quantifier elimination by lazy model enumeration. In: Touili, T., Cook, B., Jackson, P. (eds.) CAV 2010. LNCS, vol. 6174, pp. 585–599. Springer, Heidelberg (2010) CrossRefGoogle Scholar
  22. 22.
    Raghothaman, M., Udupa, A.: Language to specify syntax-guided synthesis problems. In: CoRR, abs/1405.5590 (2014)Google Scholar
  23. 23.
    Reynolds, A., Deters, M., Kuncak, V., Tinelli, C., Barrett, C.W.: On counterexample guided quantifier instantiation for synthesis in CVC4. In: CoRR, abs/1502.04464, 2015.
  24. 24.
    Reynolds, A., Tinelli, C., Goel, A., Krstić, S., Deters, M., Barrett, C.: Quantifier instantiation techniques for finite model finding in SMT. In: Bonacina, M.P. (ed.) CADE 2013. LNCS, vol. 7898, pp. 377–391. Springer, Heidelberg (2013) CrossRefGoogle Scholar
  25. 25.
    Reynolds, A., Tinelli, C., Moura, L.D.: Finding conflicting instances of quantified formulas in SMT. In: Formal Methods in Computer-Aided Design, FMCAD (2014)Google Scholar
  26. 26.
    Reynolds, A.J.: Finite Model Finding in Satisfiability Modulo Theories. Ph.D. thesis, The University of Iowa (2013)Google Scholar
  27. 27.
    Ryzhyk, L., Walker, A., Keys, J., Legg, A., Raghunath, A., Stumm, M., Vij, M.: User-guided device driver synthesis. In: Flinn, J., Levy, H. (eds.) OSDI, pp. 661–676. USENIX Association, Berkeley (2014)Google Scholar
  28. 28.
    Solar-Lezama, A.: Program sketching. STTT 15(5–6), 475–495 (2013)CrossRefGoogle Scholar
  29. 29.
    Solar-Lezama, A., Tancau, L., Bodík, R., Seshia, S.A., Saraswat, V.A.: Combinatorial sketching for finite programs. In: Shen, J.P., Martonosi, M. (eds.) ASPLOS, pp. 404–415. ACM, New York (2006)CrossRefGoogle Scholar
  30. 30.
    Srivastava, S., Gulwani, S., Foster, J.S.: Template-based program verification and program synthesis. STTT 15(5–6), 497–518 (2013)CrossRefGoogle Scholar
  31. 31.
    Stump, A., Sutcliffe, G., Tinelli, C.: StarExec: a cross-community infrastructure for logic solving. In: Demri, S., Kapur, D., Weidenbach, C. (eds.) IJCAR 2014. LNCS, vol. 8562, pp. 367–373. Springer, Heidelberg (2014) Google Scholar
  32. 32.
    Udupa, A., Raghavan, A., Deshmukh, J.V., Mador-Haim, S., Martin, M.M., Alur, R.: Transit: specifying protocols with concolic snippets. In: PLDI, pp. 287–296. ACM (2013)Google Scholar

Copyright information

© Springer International Publishing Switzerland 2015

Authors and Affiliations

  • Andrew Reynolds
    • 1
    Email author
  • Morgan Deters
    • 2
  • Viktor Kuncak
    • 1
  • Cesare Tinelli
    • 3
  • Clark Barrett
    • 2
  1. 1.École Polytechnique Fédérale de Lausanne (EPFL)LausanneSwitzerland
  2. 2.Department of Computer ScienceNew York UniversityNew YorkUSA
  3. 3.Department of Computer ScienceThe University of IowaIowa CityUSA

Personalised recommendations