Hostname: page-component-8448b6f56d-wq2xx Total loading time: 0 Render date: 2024-04-24T15:44:40.869Z Has data issue: false hasContentIssue false

VeriFly: On-the-fly Assertion Checking via Incrementality

Published online by Cambridge University Press:  02 November 2021

MIGUEL A. SANCHEZ-ORDAZ
Affiliation:
IMDEA Software Institute and Universidad Politécnica de Madrid (UPM) (e-mails: ma.sanchez.ordaz@imdea.org, isabel.garcia@imdea.org, victor.perez@imdea.org, josef.morales@imdea.org)
ISABEL GARCIA-CONTRERAS
Affiliation:
IMDEA Software Institute and Universidad Politécnica de Madrid (UPM) (e-mails: ma.sanchez.ordaz@imdea.org, isabel.garcia@imdea.org, victor.perez@imdea.org, josef.morales@imdea.org)
VICTOR PEREZ
Affiliation:
IMDEA Software Institute and Universidad Politécnica de Madrid (UPM) (e-mails: ma.sanchez.ordaz@imdea.org, isabel.garcia@imdea.org, victor.perez@imdea.org, josef.morales@imdea.org)
JOSÉ F. MORALES
Affiliation:
IMDEA Software Institute and Universidad Politécnica de Madrid (UPM) (e-mails: ma.sanchez.ordaz@imdea.org, isabel.garcia@imdea.org, victor.perez@imdea.org, josef.morales@imdea.org)
PEDRO LOPEZ-GARCIA
Affiliation:
IMDEA Software Institute and Spanish Council for Scientific Research (CSIC) (e-mail: pedro.lopez@imdea.org)
MANUEL V. HERMENEGILDO
Affiliation:
IMDEA Software Institute and Universidad Politécnica de Madrid (UPM) (e-mail: manuel.hermenegildo@imdea.org)

Abstract

Assertion checking is an invaluable programmer’s tool for finding many classes of errors or verifying their absence in dynamic languages such as Prolog. For Prolog programmers, this means being able to have relevant properties, such as modes, types, determinacy, nonfailure, sharing, constraints, and cost, checked and errors flagged without having to actually run the program. Such global static analysis tools are arguably most useful the earlier they are used in the software development cycle, and fast response times are essential for interactive use. Triggering a full and precise semantic analysis of a software project every time a change is made can be prohibitively expensive. This is specially the case when complex properties need to be inferred for large, realistic code bases. In our static analysis and verification framework, this challenge is addressed through a combination of modular and incremental (context- and path-sensitive) analysis that is responsive to program edits, at different levels of granularity. In this tool paper, we present how the combination of this framework within an integrated development environment (IDE) takes advantage of such incrementality to achieve a high level of reactivity when reflecting analysis and verification results back as colorings and tooltips directly on the program text – the tool’s VeriFly mode. The concrete implementation that we describe is Emacs-based and reuses in part off-the-shelf “on-the-fly” syntax checking facilities (flycheck). We believe that similar extensions are also reproducible with low effort in other mature development environments. Our initial experience with the tool shows quite promising results, with low latency times that provide early, continuous, and precise assertion checking and other semantic feedback to programmers during the development process. The tool supports Prolog natively, as well as other languages by semantic transformation into Horn clauses.

Type
Original Article
Copyright
© The Author(s), 2021. Published by Cambridge University Press

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Footnotes

*

Research partially funded by MINECO MICINN PID2019-108528RB-C21 ProCode project, FPU grant 16/04811, the Madrid M141047003 N-GREENS and P2018/TCS-4339 BLOQUES-CM programs, and the Tezos foundation. We are also grateful to the anonymous reviewers for their comments.

References

Bueno, F., Cabeza, D., Hermenegildo, M. V. and Puebla, G. 1996. Global analysis of standard prolog programs. In ESOP.10.1007/3-540-61055-3_32CrossRefGoogle Scholar
Bueno, F., Carro, M., Hermenegildo, M. V., Lopez-Garcia, P. and (Eds.), J. M. 2021. The Ciao System. Ref. Manual (v1.20). Tech. rep. April. URL: http://ciao-lang.org.Google Scholar
Bueno, F., Deransart, P., Drabent, W., Ferrand, G., Hermenegildo, M. V., Maluszynski, J. and Puebla, G. 1997. On the role of semantic approximations in validation and diagnosis of constraint logic programs. In Proc. of the 3rd Int’l. WS on Automated Debugging–AADEBUG. U. Linköping Press, 155–170.Google Scholar
Cousot, P. and Cousot, R. 1977. Abstract interpretation: a unified lattice model for static analysis of programs by construction or approximation of fixpoints. In ACM Symposium on Principles of Programming Languages (POPL’77). ACM Press, 238–252.Google Scholar
De Angelis, E., Fioravanti, F., Gallagher, J. P., Hermenegildo, M. V., Pettorossi, A. and Proietti, M. 2021. Analysis and transformation of constrained Horn clauses for program verification. Theory and Practice of Logic Programming.Please provide volume and page number for “De Angelis et al. (2021).”10.1017/S1471068421000211CrossRefGoogle Scholar
De Angelis, E., Fioravanti, F., Pettorossi, A. and Proietti, M. 2017. Semantics-based generation of verification conditions via program specialization. Science of Computer Programming 147, 78–108.Google Scholar
Dumortier, V., Janssens, G., Simoens, W. and García de la Banda, M. 1993. Combining a definiteness and a freeness abstraction for CLP languages. In Workshop on LP Synthesis and Transformation.Google Scholar
Flanagan, C. 2006. Hybrid type checking. In 33rd ACM POPL, 245–256.Google Scholar
Gallagher, J., Hermenegildo, M. V., Kafle, B., Klemen, M., Lopez-Garcia, P. and Morales, J. 2020. From big-step to small-step semantics and back with interpreter specialization. In VPT 2020. EPTCS. Open Publishing Association, 50–65.Google Scholar
Garcia-Contreras, I., Morales, J. and Hermenegildo, M. V. 2020. Incremental analysis of logic programs with assertions and open predicates. In LOPSTR’19. LNCS, vol. 12042. Springer, 36–56.Google Scholar
Garcia-Contreras, I., Morales, J. F. and Hermenegildo, M. V. 2021. Incremental and modular context-sensitive analysis. TPLP 21, 2, 196243.Google Scholar
Gómez-Zamalloa, M., Albert, E. and Puebla, G. 2009. Decompilation of java bytecode to Prolog by partial evaluation. JIST 51, 14091427.Google Scholar
Grebenshchikov, S., Gupta, A., Lopes, N. P., Popeea, C. and Rybalchenko, A. 2012. HSF(C): a software verifier based on Horn clauses. In TACAS, 549–551.10.1007/978-3-642-28756-5_46CrossRefGoogle Scholar
Gurfinkel, A., Kahsai, T., Komuravelli, A. and Navas, J. A. 2015. The SeaHorn verification framework. In CAV, 343–361.Google Scholar
Henriksen, K. S. and Gallagher, J. P. 2006. Abstract interpretation of PIC programs through logic programming. In SCAM’06. IEEE Computer Society, 184–196.Google Scholar
Hermenegildo, M., Puebla, G., Bueno, F. and Garcia, P. L. 2005. Integrated program debugging, verification, and optimization using abstract interpretation (and the Ciao system preprocessor). Science of Computer Programming 58, 1–2, 115–140.Google Scholar
Hermenegildo, M. V., Bueno, F., Carro, M., Lopez-Garcia, P., Mera, E., Morales, J. and Puebla, G. 2011. The Ciao approach to the dynamic vs. static language dilemma. In Proc. Int’l. WS on Scripts to Programs, STOP’11. ACM.Google Scholar
Hermenegildo, M. V., Bueno, F., Carro, M., Lopez-Garcia, P., Mera, E., Morales, J. and Puebla, G. 2012. An overview of Ciao and its design philosophy. Theory and Practice of Logic Programming 12, 1–2, 219252.10.1017/S1471068411000457CrossRefGoogle Scholar
Hermenegildo, M. V., Puebla, G. and Bueno, F. 1999. Using global analysis, partial specifications, and an extensible assertion language for program validation and debugging. In The Logic Programming Paradigm: A 25–Year Perspective. Springer-Verlag, 161–192.Google Scholar
Hermenegildo, M. V., Puebla, G., Marriott, K. and Stuckey, P. 2000. Incremental analysis of constraint logic programs. ACM TOPLAS 22, 2, 187223.10.1145/349214.349216CrossRefGoogle Scholar
Hill, P. and Lloyd, J. 1994. The Goedel Programming Language. MIT Press.Google Scholar
Klemen, M., Stulova, N., Lopez-Garcia, P., Morales, J. F. and Hermenegildo, M. V. 2018. Static performance guarantees for programs with run-time checks. In PPDP. ACM.10.1145/3236950.3236970CrossRefGoogle Scholar
Lakshman, T. and Reddy, U. 1991. Typed Prolog: a semantic reconstruction of the Mycroft-O’Keefe type system. In International Logic Programming Symposium. MIT Press.Google Scholar
Lopez-Garcia, P., Darmawan, L., Klemen, M., Liqat, U., Bueno, F. and Hermenegildo, M. V. 2018. Interval-based resource usage verification by translation into Horn clauses and an application to energy consumption. TPLP 18, 2, 167–223.Google Scholar
Marriott, K. and Søndergaard, H. 1993. Precise and efficient groundness analysis for logic programs. Technical report 93/7, University of Melbourne.Google Scholar
Méndez-Lojo, M., Navas, J. and Hermenegildo, M. 2007. A flexible (C)LP-based approach to the analysis of object-oriented programs. In LOPSTR. LNCS, vol. 4915. Springer-Verlag, 154–168.Google Scholar
Mycroft, A. and O’Keefe, R. A. 1984. A polymorphic type system for Prolog. Artificial Intelligence 23, 3, 295307.10.1016/0004-3702(84)90017-1CrossRefGoogle Scholar
Navas, J., Bueno, F. and Hermenegildo, M. V. 2006. Efficient top-down set-sharing analysis using cliques. In 8th PADL. LNCS, vol. 2819. Springer, 183–198.Google Scholar
Peralta, J., Gallagher, J. and Sağlam, H. 1998. Analysis of imperative programs through analysis of constraint logic programs. In Static Analysis. 5th International Symposium, SAS’98, Pisa, G. Levi, Ed. LNCS, vol. 1503, 246–261.Google Scholar
Perez-Carrasco, V., Klemen, M., Lopez-Garcia, P., Morales, J. and Hermenegildo, M. V. 2020. Cost analysis of smart contracts via parametric resource analysis. In Static Aanalysis Simposium (SAS’20). LNCS, vol. 12389. Springer, 7–31.Google Scholar
Pfenning, F., Ed. 1992. Types in Logic Programming. MIT Press.Google Scholar
Pietrzak, P., Correas, J., Puebla, G. and Hermenegildo, M. V. 2006. Context-sensitive multivariant assertion checking in modular programs. In LPAR’06. LNCS, vol. 4246. Springer-Verlag, 392–406.Google Scholar
Puebla, G., Bueno, F. and Hermenegildo, M. V. 2000a. An assertion language for constraint logic programs. In Analysis and Visualization Tools for Constraint Programming. LNCS, vol. 1870. Springer-Verlag, 23–61.Google Scholar
Puebla, G., Bueno, F. and Hermenegildo, M. V. 2000b. Combined static and dynamic assertion-based debugging of constraint logic programs. In Proc. of LOPSTR’99. LNCS, vol. 1817. Springer-Verlag, 273–292.Google Scholar
Puebla, G. and Hermenegildo, M. V. 1996. Optimized algorithms for the incremental analysis of logic programs. In SAS’96. LNCS, vol. 1145. Springer, 270–284.Google Scholar
Rastogi, A., Swamy, N., Fournet, C., Bierman, G. and Vekris, P. 2015. Safe & efficient gradual typing for TypeScript. In 42nd POPL. ACM, 167–180.Google Scholar
Rustan, K., Leino, M. and Wüstholz, V. 2015. Fine-grained caching of verification results. In CAV, Kroening, D. and Pasareanu, C. S., Eds. LNCS, vol. 9206. Springer, 380–397.Google Scholar
Schrijvers, T., Santos Costa, V., Wielemaker, J. and Demoen, B. 2008. Towards typed Prolog. In ICLP’08. LNCS, vol. 5366. Springer, 693–697.Google Scholar
Siek, J. G. and Taha, W. 2006. Gradual typing for functional languages. In Scheme and Functional Programming Workshop, 81–92.Google Scholar
Somogyi, Z., Henderson, F. and Conway, T. 1996. The execution algorithm of mercury: an efficient purely declarative logic programming language. JLP 29, 1–3, 1764.10.1016/S0743-1066(96)00068-4CrossRefGoogle Scholar
Stulova, N., Morales, J. F. and Hermenegildo, M. V. 2018a. Exploiting term hiding to reduce run-time checking overhead. In Int’l. Symp. on Practical Aspects of Declarative Languages (PADL). LNCS, vol. 10702. Springer-Verlag, 99–115.Google Scholar
Stulova, N., Morales, J. F. and Hermenegildo, M. V. 2018b. Some trade-offs in reducing the overhead of assertion run-time checks via static analysis. Science of Computer Programming 155, 3–26. Highest ranked paper.10.1016/j.scico.2017.12.006CrossRefGoogle Scholar
Tschannen, J., Furia, C. A., Nordio, M. and Meyer, B. 2011. Usable verification of object-oriented programs by combining static and dynamic techniques. In SEFM. LNCS, vol. 7041. Springer, 382–398.Google Scholar
Wingen, I. and Körner, P. 2020. Effectiveness of annotation-based static type inference. In WS on Functional and Constraint Logic Programming. LNCS, vol. 12560. Springer, 74–93.Google Scholar