Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to main content

Toward Neural-Network-Guided Program Synthesis and Verification

  • Conference paper
  • First Online:
Static Analysis (SAS 2021)

Abstract

We propose a novel framework of program and invariant synthesis called neural network-guided synthesis. We first show that, by suitably designing and training neural networks, we can extract logical formulas over integers from the weights and biases of the trained neural networks. Based on the idea, we have implemented a tool to synthesize formulas from positive/negative examples and implication constraints, and obtained promising experimental results. We also discuss an application of our method for improving the qualifier discovery in the framework of ICE-learning-based CHC solving, which can in turn be applied to program verification and inductive invariant synthesis. Another potential application is to a neural-network-guided variation of Solar-Lezama’s program synthesis by sketching.

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

Access this chapter

Subscribe and save

Springer+ Basic
$34.99 /Month
  • Get 10 units per month
  • Download Article/Chapter or eBook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 69.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 89.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

Similar content being viewed by others

Notes

  1. 1.

    Since neural networks can also be expressed as programs, we call ordinary programs written without using neural networks classical, to distinguish them from programs containing NNs.

  2. 2.

    These design details can affect the efficacy of our program expression extraction, as discussed later.

  3. 3.

    According to the experimental results reported later, however, the three-layer NN as depicted in Fig. 1 also seems to be a good alternative. It is left for future work to test whether NNs with more than four layers are useful for our task.

  4. 4.

    We actually used \(-\log (\max (1-|o_i-\ell _i|,\epsilon ))\) for a small positive number \(\epsilon \), to avoid the overflow of floating point arithmetic.

  5. 5.

    We plan to replace this with a more standard one based on continued fraction expansion.

  6. 6.

    The current implementation uses an ad hoc, greedy method, which will be replaced by a more standard one for Boolean decision tree construction.

  7. 7.

    https://github.com/LaurentMazare/ocaml-torch.

  8. 8.

    We have excluded out instances where \(A\) or \(B\) is subsumed by the other, and those where the set of positive or negative examples is too small.

  9. 9.

    We have actually tested our tool also with a larger number of nodes, but we omit those results since they were the same as the case for 4:4 and 4 shown in the table: 100% success rate and 100% qualifiers found.

  10. 10.

    After the generation, we have manually excluded instances that have simpler equivalent formulas (e.g. \((x+y>1\wedge x+y>0)\vee (x-y>1\wedge x-y>0)\) is equivalent to \(x+y>1\vee x-y>1\), hence removed), and regenerated formulas.

  11. 11.

    In the implementation, we approximated \( loss _{e}\) by \(-\log \max (\epsilon ,1-\prod _{i=1}^k o_{a_i}\cdot \prod _{j=1}^\ell (1-o_{b_j}))\) for a small positive number \(\epsilon \) in order to avoid an overflow of the floating point arithmetic.

  12. 12.

    The tool r_type was used to extract CHCs. The source programs have been slightly modified to remove Boolean arguments from predicates.

  13. 13.

    Recall that our benchmark set collects only the problems that plain HoIce cannot solve: although many of those problems can be solved by Z3 [14] much more quickly, there are also problems that Z3 cannot solve but (plain) HoIce can.

References

  1. Anderson, G., Verma, A., Dillig, I., Chaudhuri, S.: Neurosymbolic reinforcement learning with formally verified exploration. In: Advances in Neural Information Processing Systems 33: Annual Conference on Neural Information Processing Systems 2020, NeurIPS 2020 (2020)

    Google Scholar 

  2. Arrieta, A.B., et al.: Explainable artificial intelligence (XAI): concepts, taxonomies, opportunities and challenges toward responsible AI. Inf. Fusion 58, 82–115 (2020). https://doi.org/10.1016/j.inffus.2019.12.012

    Article  Google Scholar 

  3. Bjørner, N., Gurfinkel, A., McMillan, K., Rybalchenko, A.: Horn clause solvers for program verification. In: Beklemishev, L.D., Blass, A., Dershowitz, N., Finkbeiner, B., Schulte, W. (eds.) Fields of Logic and Computation II. LNCS, vol. 9300, pp. 24–51. Springer, Cham (2015). https://doi.org/10.1007/978-3-319-23534-9_2

    Chapter  Google Scholar 

  4. Champion, A., Chiba, T., Kobayashi, N., Sato, R.: ICE-based refinement type discovery for higher-order functional programs. J. Autom. Reason. 64(7), 1393–1418 (2020). https://doi.org/10.1007/s10817-020-09571-y

    Article  MathSciNet  MATH  Google Scholar 

  5. Ezudheen, P., Neider, D., D’Souza, D., Garg, P., Madhusudan, P.: Horn-ICE learning for synthesizing invariants and contracts. In: Proceedings ACM Programming Language 2 (OOPSLA), pp. 131:1–131:25 (2018). https://doi.org/10.1145/3276501

  6. Garg, P., Löding, C., Madhusudan, P., Neider, D.: ICE: a robust framework for learning invariants. In: Biere, A., Bloem, R. (eds.) CAV 2014. LNCS, vol. 8559, pp. 69–87. Springer, Cham (2014). https://doi.org/10.1007/978-3-319-08867-9_5

    Chapter  Google Scholar 

  7. Garg, P., Neider, D., Madhusudan, P., Roth, D.: Learning invariants using decision trees and implication counterexamples. In: Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2016, pp. 499–512. ACM (2016). https://doi.org/10.1145/2837614.2837664

  8. Gehr, T., Mirman, M., Drachsler-Cohen, D., Tsankov, P., Chaudhuri, S., Vechev, M.T.: AI2: safety and robustness certification of neural networks with abstract interpretation. In: 2018 IEEE Symposium on Security and Privacy. SP 2018, Proceedings, pp. 3–18. IEEE Computer Society (2018). https://doi.org/10.1109/SP.2018.00058

  9. Hojjat, H., Rümmer, P.: The eldarica horn solver. In: 2018 Formal Methods in Computer Aided Design (FMCAD), pp. 1–7 (2018)

    Google Scholar 

  10. Huang, X., Kwiatkowska, M., Wang, S., Wu, M.: Safety verification of deep neural networks. In: Majumdar, R., Kunčak, V. (eds.) CAV 2017. LNCS, vol. 10426, pp. 3–29. Springer, Cham (2017). https://doi.org/10.1007/978-3-319-63387-9_1

    Chapter  Google Scholar 

  11. Katz, G., Barrett, C., Dill, D.L., Julian, K., Kochenderfer, M.J.: Reluplex: an efficient SMT solver for verifying deep neural networks. In: Majumdar, R., Kunčak, V. (eds.) CAV 2017. LNCS, vol. 10426, pp. 97–117. Springer, Cham (2017). https://doi.org/10.1007/978-3-319-63387-9_5

    Chapter  Google Scholar 

  12. Kingma, D.P., Ba, J.: Adam: a method for stochastic optimization. In: 3rd International Conference on Learning Representations, ICLR 2015, Conference Track Proceedings (2015). http://arxiv.org/abs/1412.6980

  13. Kobayashi, N., Sekiyama, T., Sato, I., Unno, H.: Toward neural-network-guided program synthesis and verification. CoRR abs/2103.09414 (2021). https://arxiv.org/abs/2103.09414

  14. Komuravelli, A., Gurfinkel, A., Chaki, S.: SMT-based model checking for recursive programs. Formal Methods Syst. Des. 48(3), 175–205 (2016). https://doi.org/10.1007/s10703-016-0249-4

    Article  MATH  Google Scholar 

  15. Martius, G., Lampert, C.H.: Extrapolation and learning equations. In: 5th International Conference on Learning Representations, ICLR 2017, Toulon, France, 24–26 April 2017, Workshop Track Proceedings. OpenReview.net (2017). https://openreview.net/forum?id=BkgRp0FYe

  16. Narodytska, N., Kasiviswanathan, S.P., Ryzhyk, L., Sagiv, M., Walsh, T.: Verifying properties of binarized deep neural networks. In: Proceedings of the Thirty-Second AAAI Conference on Artificial Intelligence, (AAAI-18), the 30th innovative Applications of Artificial Intelligence (IAAI-18), and the 8th AAAI Symposium on Educational Advances in Artificial Intelligence (EAAI-18), pp. 6615–6624. AAAI Press (2018)

    Google Scholar 

  17. Padhi, S., Millstein, T., Nori, A., Sharma, R.: Overfitting in synthesis: theory and practice. In: Dillig, I., Tasiran, S. (eds.) CAV 2019. LNCS, vol. 11561, pp. 315–334. Springer, Cham (2019). https://doi.org/10.1007/978-3-030-25540-4_17

    Chapter  Google Scholar 

  18. Padhi, S., Sharma, R., Millstein, T.D.: Data-driven precondition inference with learned features. In: Krintz, C., Berger, E. (eds.) Proceedings of the 37th ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI 2016, Santa Barbara, CA, USA, June 13–17, 2016. pp. 42–56. ACM (2016), https://doi.org/10.1145/2908080.2908099

  19. Pavlinovic, Z., Su, Y., Wies, T.: Data flow refinement type inference. In: Proceedings ACM Programming Language 5(POPL), pp. 1–31 (2021). https://doi.org/10.1145/3434300

  20. Petersen, B.K., Landajuela, M., Mundhenk, T.N., Santiago, C.P., Kim, S.K., Kim, J.T.: Deep symbolic regression: recovering mathematical expressions from data via risk-seeking policy gradients. In: Proceedings of the International Conference on Learning Representations (2021)

    Google Scholar 

  21. Pulina, L., Tacchella, A.: An abstraction-refinement approach to verification of artificial neural networks. In: Touili, T., Cook, B., Jackson, P. (eds.) CAV 2010. LNCS, vol. 6174, pp. 243–257. Springer, Heidelberg (2010). https://doi.org/10.1007/978-3-642-14295-6_24

    Chapter  Google Scholar 

  22. Ryan, G., Wong, J., Yao, J., Gu, R., Jana, S.: CLN2INV: learning loop invariants with continuous logic networks. In: 8th International Conference on Learning Representations, ICLR 2020. OpenReview.net (2020)

    Google Scholar 

  23. Sahoo, S., Lampert, C., Martius, G.: Learning equations for extrapolation and control. In: Dy, J., Krause, A. (eds.) Proceedings of the 35th International Conference on Machine Learning. Proceedings of Machine Learning Research, vol. 80, pp. 4442–4450. PMLR, Stockholmsmässan, Stockholm Sweden, 10–15 July 2018. http://proceedings.mlr.press/v80/sahoo18a.html

  24. Satake, Y., Unno, H., Yanagi, H.: Probabilistic inference for predicate constraint satisfaction. In: The Thirty-Fourth AAAI Conference on Artificial Intelligence, AAAI 2020, The Thirty-Second Innovative Applications of Artificial Intelligence Conference, IAAI 2020, The Tenth AAAI Symposium on Educational Advances in Artificial Intelligence. EAAI 2020, pp. 1644–1651. AAAI Press (2020)

    Google Scholar 

  25. Sharma, R., Nori, A.V., Aiken, A.: Interpolants as classifiers. In: Madhusudan, P., Seshia, S.A. (eds.) CAV 2012. LNCS, vol. 7358, pp. 71–87. Springer, Heidelberg (2012). https://doi.org/10.1007/978-3-642-31424-7_11

    Chapter  Google Scholar 

  26. Si, X., Dai, H., Raghothaman, M., Naik, M., Song, L.: Learning loop invariants for program verification. In: Advances in Neural Information Processing Systems 31: Annual Conference on Neural Information Processing Systems 2018. NeurIPS 2018, pp. 7762–7773 (2018)

    Google Scholar 

  27. Solar-Lezama, A.: Program synthesis by sketching. Ph.D. thesis, University of California, Berkeley (2008)

    Google Scholar 

  28. Verma, A., Murali, V., Singh, R., Kohli, P., Chaudhuri, S.: Programmatically interpretable reinforcement learning. In: Proceedings of the 35th International Conference on Machine Learning, ICML 2018. Proceedings of Machine Learning Research, vol. 80, pp. 5052–5061. PMLR (2018)

    Google Scholar 

  29. Yao, J., Ryan, G., Wong, J., Jana, S., Gu, R.: Learning nonlinear loop invariants with gated continuous logic networks. In: Proceedings of the 41st ACM SIGPLAN International Conference on Programming Language Design and Implementation. PLDI 2020, pp. 106–120. ACM (2020). https://doi.org/10.1145/3385412.3385986

  30. Zhao, H., Zeng, X., Chen, T., Liu, Z., Woodcock, J.: Learning safe neural network controllers with barrier certificates (2020)

    Google Scholar 

  31. Zhu, H., Magill, S., Jagannathan, S.: A data-driven CHC solver. In: Proceedings of the 39th ACM SIGPLAN Conference on Programming Language Design and Implementation. PLDI 2018, pp. 707–721. ACM (2018). https://doi.org/10.1145/3192366.3192416

  32. Zhu, H., Xiong, Z., Magill, S., Jagannathan, S.: An inductive synthesis framework for verifiable reinforcement learning. In: Proceedings of the 40th ACM SIGPLAN Conference on Programming Language Design and Implementation. PLDI 2019, pp. 686–701. ACM (2019). https://doi.org/10.1145/3314221.3314638

Download references

Acknowledgments

We would like to thank anonymous referees for useful comments. This work was supported by JSPS KAKENHI Grant Numbers JP20H05703, JP20H04162, and JP19K22842, and ERATO HASUO Metamathematics for Systems Design Project (No. JPMJER1603), JST.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Naoki Kobayashi .

Editor information

Editors and Affiliations

Appendices

Appendix

A Additional Information for Sect. 2

1.1 A.1 On Three-Layer vs Four-Layer NNs

As reported in Sect. 2.2, three-layer NNs with a sufficient number of nodes performed well in the experiment on learning formulas \((A\wedge B)\vee (C\wedge D)\), contrary to our expectation. This section reports our analysis to find out the reason.

We used the instance shown on the left-hand side of Fig. 8, and compared the training results of three-layer and four-layer NNs. To make the analysis easier, we tried to train the NNs with a minimal number of hidden nodes in the second layer. For the four-layer-case, the training succeeded for only two hidden nodes in the second layer (plus eight hidden nodes in the third layer), and only relevant quantifiers of the form \(x>c, x<c, y>c, y<c\) for \(c\in \{-2,1,0,1\}\) were generated. In contrast, for the three-layer case, 12 hidden nodes were required for the training to succeed. The right-hand side of Fig. 8 shows the lines \(b_i+w_{i,x}x + w_{i,y}y=0\; (i\in \{1,\ldots ,12\})\) where \(w_{i,x}, w_{i,y}\) and \(b_i\) are the weights and bias for the \(i\)-th hidden node. We can see that the lines that are (seemingly) irrelevant to the original formula are recognized by the hidden nodes. Removing any hidden node (e.g., the node corresponding to line 1) makes the NN fail to properly separate positive and negative examples. Thus, the three-layer NN is recognizing positive and negative examples in a manner quite different from the original formula; it is performing a kind of patchwork to classify the examples. Nevertheless, even in that patchwork, there are lines close to the horizontal and vertical lines \(y=0\) and \(x=0\). Thus, if we use the trained NN only to extract qualifier candidates (rather than to recover the whole formula by inspecting also the weights of the third layer), three-layer NNs can be useful, as already observed in the experiments in Sect. 2.2.

Fig. 8.
figure 8

Problem instance for learning \((x\ge 0\wedge y\ge 0)\vee (x\le 0\wedge y\le 0)\) (left) and lines recognized by Three-Layer NNs for problem instance \((x\ge 0\wedge y\ge 0)\vee (x\le 0\wedge y\le 0)\) (right).

1.2 A.2 On Activation Functions

To justify our choice of the sigmoid function as activation functions, we have replaced the activation functions with ReLU (\(f(x)=x\) for \(x\ge 0\) and \(f(x)=0\) for \(x<0\)) and Leaky ReLU (\(f(x)=x\) for \(x\ge 0\) and \(f(x)=-0.01x\) for \(x<0\)) and conducted the experiments for synthesizing \((A\wedge B)\vee (C\wedge D)\) by using the same problem instances as those used in Sect. 2.2. Here are the results.

activation

#nodes

#retry

%success

%qualifiers

#candidates

time (sec.)

ReLU

32:32

15

18.3%

66.7%

72.4

55.9

Leaky ReLU

32:32

32

61.7%

88.8%

64.4

52.8

sigmoid

32:32

10

85.0%

91.7%

40.4

39.9

In this experiment, we have used the mean square error function as the loss function (since the log loss function assumes that the output belongs to \([0,1]\), which is not the case here). For comparison, we have re-shown the result for the sigmoid function (with the mean square error loss function).

As clear from the table above, the sigmoid function performs significantly better than ReLU and Leaky ReLU, especially in %success (the larger is better) and #candidates (the smaller is better). This confirms our expectation that the use of the sigmoid function helps us to ensure that only information about \(b+w_1\,x_1+\cdots +w_k\,x_k>c\) for small \(c\)’s may be propagated to the output of the second layer, so that we can find suitable qualifiers by looking at only the weights and biases for the hidden nodes in the second layer. We do not report experimental results for the tanh function (\(\texttt {tanh}(x) = 2\sigma (x)-1\)), but it should be as good as the sigmoid function, as it has similar characteristics.

1.3 A.3 On Biases

As for the biases in the second later, we have actually removed them and instead added a constant input \(1\), so that the weights for the constant input play the role of the biases (thus, for two-dimensional input \((x,y)\), we actually gave three-dimensional input \((x,y,1)\)). This is because, for some qualifier that requires a large constant (like \(x+y-150>0\)), adding additional constant inputs such as \(100\) (so that inputs are now of the form \((x,y,1,100)\)) makes the NN training easier to succeed. Among the experiments reported in this paper, we added an additional constant input \(10\) for the experiments in Sect. 2.3.

Similarly, we also observed (in the experiments not reported here) that, when the scales of inputs vary extremely among different dimensions (like \((x,y) = (1, 100), (2, 200), ...\)), then the normalization of the inputs helped the convergence of training.

B Additional Information for Sect. 3

Here we provide more details about our experiments on the CHC problem xyz, which shows a general pitfall of the ICE-based CHC solving approach of HoIce (rather than that of our neural network-guided approach). Here is the source program of xyz written in OCaml (we have simplified the original program, by removing redundant arguments).

figure a

Here is (a simplified version of) the corresponding CHC generated by r_type.

$$\begin{aligned} x< 10\wedge loopa (x+1, z-2, r)\Rightarrow & {} loopa (x, z, r) \end{aligned}$$
(1)
$$\begin{aligned} x\ge 10\Rightarrow & {} loopa (x, z, z) \end{aligned}$$
(2)
$$\begin{aligned} x>0 \wedge loopb (x,z)\Rightarrow & {} loopb (x-1,z+2) \end{aligned}$$
(3)
$$\begin{aligned} x\le 0 \wedge loopb (x,z)\Rightarrow & {} z>-1 \end{aligned}$$
(4)
$$\begin{aligned} loopa (0,0,r)\Rightarrow & {} loopb (10,r) \end{aligned}$$
(5)

When we ran HoIce for collecting learning data, we observed that no positive examples for \( loopb \) and no negative examples for \( loopa \) were collected. Thus NeuGuS returns a trivial solution such as \( loopa (x,z,r)\equiv \mathtt {true}\) and \( loopb (x,z)\equiv \mathtt {false}\). The reason why HoIce generates no positive examples for \( loopb \) is as follows. A positive example of \( loopb \) can only be generated from the clause (5), only when a positive example of the form \( loopa (0,0,r)\) is already available. To generate a positive example of the form \( loopa (0,0,r)\), however, one needs to properly instantiate the clauses (2) and (1) repeatedly; since HoIce generates examples only lazily when a candidate model returned by the learner does not satisfy the clauses. In short, HoIce must follow a very narrow sequence of non-deterministic choices to generate the first positive example of \( loopb \). Negative examples of \( loopa \) are rarely generated for the same reason.

Another obstacle is that even if HoIce can generate a negative counterexample through clause (5) with a luck, it is only of the form \( loopa (0,0,r)\). Although further negative examples can be generated through (1), the shape of the resulting negative examples are quite limited.

Rights and permissions

Reprints and permissions

Copyright information

© 2021 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Kobayashi, N., Sekiyama, T., Sato, I., Unno, H. (2021). Toward Neural-Network-Guided Program Synthesis and Verification. In: Drăgoi, C., Mukherjee, S., Namjoshi, K. (eds) Static Analysis. SAS 2021. Lecture Notes in Computer Science(), vol 12913. Springer, Cham. https://doi.org/10.1007/978-3-030-88806-0_12

Download citation

  • DOI: https://doi.org/10.1007/978-3-030-88806-0_12

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-88805-3

  • Online ISBN: 978-3-030-88806-0

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics