Skip to main content
Log in

Automatic B-model repair using model checking and machine learning

  • Published:
Automated Software Engineering Aims and scope Submit manuscript

Abstract

The B-method, which provides automated verification for the design of software systems, still requires users to manually repair faulty models. This paper proposes B-repair, an approach that supports automated repair of faulty models written in the B formal specification language. After discovering a fault in a model using the B-method, B-repair is able to suggest possible repairs for the fault, estimate the quality of suggested repairs and use a suitable repair to revise the model. The suggestion of repairs is produced using the Isolation method, which suggests changing the pre-conditions of operations, and the Revision method, which suggests changing the post-conditions of operations. The estimation of repair quality makes use of machine learning techniques that can learn the features of state transitions. After estimating the quality of suggested repairs, the repairs are ranked, and a best repair is selected according to the result of ranking and is used to revise the model. This approach has been evaluated using a set of finite state machines seeded with faults and a case study. The evaluation has revealed that B-repair is able to repair a large number of faults, including invariant violations, assertion violations and deadlock states, and gain high accuracies of repair. Using the combination of model checking and machine learning-guided techniques, B-repair saves development time by finding and repairing faults automatically during design.

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

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Institutional subscriptions

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Fig. 6
Fig. 7
Fig. 8
Fig. 9
Fig. 10
Fig. 11

Similar content being viewed by others

Notes

  1. In the following equations, \( \varvec{x} \) is an input vector, \( \varvec{y} \) is an output vector, \( \varvec{W} \) is a weight matrix, and \( \varvec{b} \) is a bias vector.

  2. The dataset is available at https://github.com/cchrewrite/B-ALTC-36.

  3. The ProB Public Examples Repository was downloaded from https://www3.hhu.de/stups/downloads/prob/source/.

References

  • Abreu, R., Zoeteweij, P., Golsteijn, R., van Gemund, A.J.C.: A practical evaluation of spectrum-based fault localization. J. Syst. Softw. 82(11), 1780–1792 (2009)

    Article  Google Scholar 

  • Abrial, J.: The B-book—Assigning Programs to Meanings. Cambridge University Press, Cambridge (2005)

    MATH  Google Scholar 

  • Abrial, J., Butler, M.J., Hallerstede, S., Hoang, T.S., Mehta, F., Voisin, L.: Rodin: an open toolset for modelling and reasoning in Event-B. Int. J. Softw. Tools Technol. Transfer 12(6), 447–466 (2010)

    Article  Google Scholar 

  • Alrajeh, D., Craven, R.: Automated error-detection and repair for compositional software specifications. In: 12th International Conference Software Engineering and Formal Methods, SEFM 2014, Grenoble, France, September 1–5, 2014. Proceedings, pp. 111–127 (2014)

  • Baader, F., Nipkow, T.: Term Rewriting and All That. Cambridge University Press, Cambridge (1998)

    Book  MATH  Google Scholar 

  • Babin, G., Ameur, Y.A., Singh, N.K., Pantel, M.: A system substitution mechanism for hybrid systems in Event-B. In: Proceedings 18th International Conference on Formal Engineering Methods Formal Methods and Software Engineering, ICFEM 2016, Tokyo, Japan, November 14–18, 2016, pp. 106–121 (2016)

  • Bagaria, J.: Set theory. In: Zalta, E.N. (ed.) The Stanford Encyclopedia of Philosophy, winter 2017 edn. Stanford University, Stanford (2017)

    Google Scholar 

  • Barbosa, H., Déharbe, D.: Formal verification of PLC programs using the B method. In: Abstract State Machines, Alloy, B, VDM, and Z—Proceedings Third International Conference, ABZ 2012, Pisa, Italy, June 18–21, 2012, pp. 353–356 (2012)

  • Behm, P., Benoit, P., Faivre, A., Meynadier, J.: Météor: A successful application of B in a large project. In: FM’99 - Formal Methods, World Congress on Formal Methods in the Development of Computing Systems, Toulouse, France, September 20–24, 1999, Proceedings, Volume I, pp. 369–387 (1999)

  • Benaïssa, N., Bonvoisin, D., Feliachi, A., Ordioni, J.: The PERF approach for formal verification. In: Reliability, Safety, and Security of Railway Systems. Modelling, Analysis, Verification, and Certification—First International Conference, RSSRail 2016, Paris, France, June 28-30, 2016, Proceedings, pp. 203–214 (2016)

  • Bottou, L.: Stochastic gradient descent tricks. In: Montavon, G. (ed.) Neural Networks: Tricks of the Trade, 2nd edn, pp. 421–436. Springer, Berlin (2012)

    Chapter  Google Scholar 

  • Boulanger, J.L., Aljer, A., Mariano, G.: Formalization of digital circuits using the b method. WIT Trans. Built Environ. https://doi.org/10.1002/9781119002727.ch6 (2002)

  • Breiman, L., Friedman, J.H., Olshen, R.A., Stone, C.J.: Classification and Regression Trees. Routledge, Wadsworth (1984)

    MATH  Google Scholar 

  • Burch, J.R., Clarke, E.M., McMillan, K.L., Dill, D.L., Hwang, L.J.: Symbolic model checking: 10–20 states and beyond. Inf. Comput. 98(2), 142–170 (1992)

    Article  MathSciNet  MATH  Google Scholar 

  • Cai, C., Sun, J., Dobbie, G.: B-repair: Repairing B-models using machine learning. In: 23rd International Conference on Engineering of Complex Computer Systems, ICECCS 2018, Melbourne, Australia, December 12–14, 2018, pp. 31–40 (2018)

  • Cimatti, A., Clarke, E.M., Giunchiglia, F., Roveri, M.: NUSMV: A new symbolic model verifier. In: 11th International Conference Computer Aided Verification, CAV ’99, Trento, Italy, July 6-10, 1999, Proceedings, pp. 495–499 (1999)

  • Clarke, E.M., Emerson, E.A.: Design and synthesis of synchronization skeletons using branching-time temporal logic. In: Logics of Programs, Workshop, Yorktown Heights, New York, USA, May 1981, pp. 52–71 (1981)

  • Cox, D.R.: The regression analysis of binary sequences. J. R. Stat. Soc. Ser. B (Methodol.) 20, 215–242 (1958)

    MathSciNet  MATH  Google Scholar 

  • D’Silva, V., Kroening, D., Weissenbacher, G.: A survey of automated techniques for formal software verification. IEEE Trans. CAD Integrated Circuits Syst. 27(7), 1165–1178 (2008)

    Article  Google Scholar 

  • Fadil, H., Koning, J.: A formal approach to model multiagent interactions using the B formal method. In: Advanced Distributed Systems: 5th International School and Symposium, ISSADS 2005, Guadalajara, Mexico, January 24–28, 2005, Revised Selected Papers, pp. 516–528 (2005)

  • Gazzola, L., Micucci, D., Mariani, L.: Automatic software repair: a survey. IEEE Trans. Softw. Eng. 45(1), 34–67 (2019)

    Article  Google Scholar 

  • Glorot, X., Bordes, A., Bengio, Y.: Deep sparse rectifier neural networks. In: Proceedings of the Fourteenth International Conference on Artificial Intelligence and Statistics, AISTATS 2011, Fort Lauderdale, USA, April 11-13, 2011, pp. 315–323 (2011)

  • Gopinath, D., Malik, M.Z., Khurshid, S.: Specification-based program repair using SAT. In: 17th International Conference, TACAS 2011, Held as Part of the Joint European Conferences on Theory and Practice of Software Tools and Algorithms for the Construction and Analysis of Systems, ETAPS 2011, Saarbrücken, Germany, March 26–April 3, 2011. Proceedings, pp. 173–188 (2011)

  • Harel, D., Katz, G., Marron, A., Weiss, G.: Non-intrusive repair of safety and liveness violations in reactive programs. Trans. Comput. Collective Intell. 16, 1–33 (2014)

    Google Scholar 

  • He, K., Zhang, X., Ren, S., Sun, J.: Deep residual learning for image recognition. In: 2016 IEEE Conference on Computer Vision and Pattern Recognition, CVPR 2016, Las Vegas, NV, USA, June 27–30, 2016, pp. 770–778 (2016)

  • Ho, T.K.: Random decision forests. In: Third International Conference on Document Analysis and Recognition, ICDAR 1995, August 14–15, 1995, Montreal, Canada. Volume I, pp. 278–282 (1995)

  • Hoffmann, S., Haugou, G., Gabriele, S., Burdy, L.: The b-method for the construction of microkernel-based systems. In: B 2007: Formal Specification and Development in B, 7th International Conference of B Users, Besançon, France, January 17–19, 2007, Proceedings, pp. 257–259 (2007)

  • Huth, M., Ryan, M.D.: Logic in Computer Science—Modelling and Reasoning About Systems, 2nd edn. Cambridge University Press, Cambridge (2004)

    Book  MATH  Google Scholar 

  • Jha, S., Gulwani, S., Seshia, S.A., Tiwari, A.: Oracle-guided component-based program synthesis. In: Proceedings of the 32nd ACM/IEEE International Conference on Software Engineering—Volume 1, ICSE 2010, Cape Town, South Africa, 1-8 May 2010, pp. 215–224 (2010)

  • Ke, Y., Stolee, K.T., Le Goues, C., Brun, Y.: Repairing programs with semantic code search (T). In: 30th IEEE/ACM International Conference on Automated Software Engineering, ASE 2015, Lincoln, NE, USA, November 9-13, 2015, pp. 295–306 (2015)

  • Krings, S., Leuschel, M.: SMT solvers for validation of B and Event-B models. In: Integrated Formal Methods—12th International Conference, IFM 2016, Reykjavik, Iceland, June 1-5, 2016, Proceedings, pp. 361–375 (2016)

  • Kurt, I., Ture, M., Kurum, A.T.: Comparing performances of logistic regression, classification and regression tree, and neural networks for predicting coronary artery disease. Expert Syst. Appl. 34(1), 366–374 (2008)

    Article  Google Scholar 

  • Le, X.D., Chu, D., Lo, D., Le Goues, C., Visser, W.: S3: syntax- and semantic-guided repair synthesis via programming by examples. In: Proceedings of the 2017 11th Joint Meeting on Foundations of Software Engineering, ESEC/FSE 2017, Paderborn, Germany, September 4–8, 2017, pp. 593–604 (2017)

  • Le, X.D., Le, Q.L., Lo, D., Le Goues, C.: Enhancing automated program repair with deductive verification. In: 2016 IEEE International Conference on Software Maintenance and Evolution, ICSME 2016, Raleigh, NC, USA, October 2–7, 2016, pp. 428–432 (2016a)

  • Le, X.D., Lo, D., Le Goues, C.: History driven program repair. In: IEEE 23rd International Conference on Software Analysis, Evolution, and Reengineering, SANER 2016, Suita, Osaka, Japan, March 14–18, 2016—Volume 1, pp. 213–224 (2016b)

  • Le Goues, C., Forrest, S., Weimer, W.: Current challenges in automatic software repair. Software Qual. J. 21(3), 421–443 (2013)

    Article  Google Scholar 

  • Le Goues, C., Nguyen, T., Forrest, S., Weimer, W.: Genprog: a generic method for automatic software repair. IEEE Trans. Softw. Eng. 38(1), 54–72 (2012)

    Article  Google Scholar 

  • Leuschel, M., Butler, M.J.: ProB: an automated analysis toolset for the B method. Int. J. Softw. Tools Technol. Transfer 10(2), 185–203 (2008)

    Article  Google Scholar 

  • Leuschel, M., Cansell, D., Butler, M.J.: Validating and animating higher-order recursive functions in B. In: Rigorous Methods for Software Construction and Analysis, Essays Dedicated to Egon Börger on the Occasion of His 60th Birthday, pp. 78–92 (2009)

  • Loh, W.: Classification and regression trees. Wiley Interdisc. Rew. Data Min. Knowl. Discov. 1(1), 14–23 (2011)

    Article  Google Scholar 

  • Nipkow, T., Paulson, L.C., Wenzel, M.: Isabelle/HOL—A Proof Assistant for Higher-Order Logic. Lecture Notes in Computer Science, vol. 2283. Springer, Berlin (2002)

    MATH  Google Scholar 

  • Pnueli, A.: The temporal logic of programs. In: 18th Annual Symposium on Foundations of Computer Science, Providence, Rhode Island, USA, 31 October–1 November 1977, pp. 46–57 (1977)

  • Schmidt, J., Krings, S., Leuschel, M.: Interactive model repair by synthesis. In: Abstract State Machines, Alloy, B, TLA, VDM, and Z—5th International Conference, ABZ 2016, Linz, Austria, May 23–27, 2016, Proceedings, pp. 303–307 (2016)

  • Schmidt, J., Krings, S., Leuschel, M.: Repair and generation of formal models using synthesis. In: Integrated Formal Methods—14th International Conference, IFM 2018, Maynooth, Ireland, September 5–7, 2018, Proceedings, pp. 346–366 (2018)

  • Siekmann, J.H.: Unification theory. J. Symb. Comput. 7(3/4), 207–274 (1989)

    Article  MathSciNet  MATH  Google Scholar 

  • Turian, J.P., Ratinov, L., Bengio, Y.: Word representations: a simple and general method for semi-supervised learning. In: ACL 2010, Proceedings of the 48th Annual Meeting of the Association for Computational Linguistics, July 11–16, 2010, Uppsala, Sweden, pp. 384–394 (2010)

  • Wen, M., Chen, J., Wu, R., Hao, D., Cheung, S.: Context-aware patch generation for better automated program repair. In: Proceedings of the 40th International Conference on Software Engineering, ICSE 2018, Gothenburg, Sweden, May 27–June 03, 2018, pp. 1–11 (2018)

  • Wilkerson, J.L., Tauritz, D.R.: Coevolutionary automated software correction. In: Genetic and Evolutionary Computation Conference, GECCO 2010, Proceedings, Portland, Oregon, USA, July 7–11, 2010, pp. 1391–1392 (2010)

  • Yang, G., Khurshid, S., Kim, M.: Specification-based test repair using a lightweight formal method. In: FM 2012: Formal Methods—18th International Symposium, Paris, France, August 27–31, 2012. Proceedings, pp. 455–470 (2012)

Download references

Acknowledgements

We would like to thank the anonymous reviewers, whose valuable comments have contributed to the clarification of many ideas presented in the paper.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Cheng-Hao Cai.

Additional information

Publisher's Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

This work is supported by the State Scholarship Fund sponsored by the China Scholarship Council [Grant Number: 201708060334].

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Cai, CH., Sun, J. & Dobbie, G. Automatic B-model repair using model checking and machine learning. Autom Softw Eng 26, 653–704 (2019). https://doi.org/10.1007/s10515-019-00264-4

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s10515-019-00264-4

Keywords

Navigation