skip to main content
10.1145/3384544.3384587acmotherconferencesArticle/Chapter ViewAbstractPublication PagesicscaConference Proceedingsconference-collections
research-article

Static Code Analysis Using Refinement Types based on Design by Contract

Published: 17 April 2020 Publication History

Abstract

Design by Contract is a programming methodology by which it is possible to annotate program codes with contracts in order to increase the safety of the program. The contracts represent the speci-fication of the software and are categorized into three groups: pre-condition, post-condition, and invariant. The idea of Design by Contract provides the correctness of a program code, satisfying that the caller of each procedure assumes the responsibility for the pre-condition and the callee assumes the responsibility for the post-condition. Findler et al. proposed a formal system based on the typed lambda calculus in which contracts are verified dynamically, that is, in run-time. Flanagan et al. introduced a formal system in which both static and dynamic checking of contracts are possible. In their system, it is possible to represent a contract as static, typing information using refinement type and dependent type. In our paper, we introduce the typed lambda calculus with dependent type and refinement type in the style of Flanagan and study a static analysis in the calculus. The static analysis provides refining of contracts and code optimization based on the contracts. We implement the analyzer using an SMT (Satisfiability Modulo Theory) server.

References

[1]
Abadi, M., and Cardelli, L. A Theory of Objects. Springer-Verlag, 1996.
[2]
Barendregt, H. B. Lambda Calculi with Types, vol.2. Oxford University Press, 1992, pp.117---309.
[3]
Barrett, C., Conway, C. L., Deters, M., Hadarean, L., and Jovanović, D. CVC4. In Computer Aided Verification, CAV 2011 (2011), vol. 6806 of Lecture Notes in Computer Science, Springer, pp. 171--177.
[4]
de Moura, L., and Bjørner, N. Z3: An Efficient SMT Solver. In Tools and Algorithms for the Construction and Analysis of Systems. TACAS 2008 (2008), vol. 4963 of Lecture Notes in Computer Science, Springer, pp. 337---340.
[5]
Eén, N., and Sörensson, N. An Extensible SAT-solver. In SAT 2003 (2004), Lecture Notes in Computer Science, Springer-Verlag, pp. 502---518.
[6]
Findler, R. B., and Felleisen, M. Contracts for higher-order function. In ICFP '02 Proceedings of the seventh ACM SIG-PLAN International Conference on Functional Programming (2002), ACM, pp. 48--59.
[7]
Flanagan, C. Hybrid type checking. In POPL '06, Conference Record of the 33rd ACM SIGPLAN-SIGACT symposium on Principles of Programming Languages (2006), ACM, pp. 245---256.
[8]
Freeman, T., and Pfenning, F. Refinement types for ML. In PLDI '91 Proceedings of the ACM SIGPLAN 1991 conference on Programming Language Design and Implementation (1991), ACM, pp. 268---277.
[9]
Knowles, K., and Flanagan, C. Hybrid type checking. ACM Transaction on Programming Languages and Systems (TOPLAS) 32, 2 (January 2010).
[10]
Matsumoto, S., and Nishizaki, S. An Object Calculus with Remote Method Invocation. In Theory and Practice of Computation (2013), vol. 7 of Proceedings in Information and Communications Technology, Springer Japan, pp. 34---49. DOI=http://dx.doi.org/10.1007/978-4-431-54436-4_3.
[11]
Meyer, B. Applying "Design by Contract." Computer 25, 10 (1992), 40---51.
[12]
Meyer, B. Eiffel: The Language. Prentice-Hall, 1992.
[13]
Narita, K., Nishizaki, S., and Mizuno, T. A simple abstract machine for functional first-class continuations. In Proceedings of the 2010 Tenth International Symposium on Communications and Information Technologies (ISCIT) (2010), IEEE, pp. 111---114. DOI=https://doi.org/10.1109/ISCIT.2010.5664903
[14]
Ohata, T., and Nishizaki, S. Real-time model checking for regulatory compliance. In AIM 2012 (2013), vol. 296 of Communications in Computer and Information Science, Springer, pp. 70--77. DOI= https://doi.org/10.1007/978-3-642-35864-7_10.
[15]
Rondon, P. M., Kawaguci, M., and Jhala, R. Liquid types. In PLDI '08 Proceedings of the 29th ACM SIGPLAN Conference on Programming Languages Design and Implementation (2008), ACM, pp. 159--169.
[16]
Siek, J., and Taha, W. Gradual Typing for Objects. In ECOOP 2007 -- Object-Oriented Programming (2007), vol. 4609, Springer-Verlag, pp. 2--27.
[17]
Vazou, N., Seidel, E. L., Jhala, R., Vytiniotis, D., and Peyton-Jones, S. Refinement types for Haskell. In ICFP '14 Proceedings of the 19th ACM SIGPLAN International Conference on Functional Programming (2014), ACM, pp. 269--282.

Index Terms

  1. Static Code Analysis Using Refinement Types based on Design by Contract

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image ACM Other conferences
    ICSCA '20: Proceedings of the 2020 9th International Conference on Software and Computer Applications
    February 2020
    382 pages
    ISBN:9781450376655
    DOI:10.1145/3384544
    Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 17 April 2020

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. Programming language theory
    2. functional programming language

    Qualifiers

    • Research-article
    • Research
    • Refereed limited

    Conference

    ICSCA 2020

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • 0
      Total Citations
    • 98
      Total Downloads
    • Downloads (Last 12 months)6
    • Downloads (Last 6 weeks)0
    Reflects downloads up to 08 Feb 2025

    Other Metrics

    Citations

    View Options

    Login options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Figures

    Tables

    Media

    Share

    Share

    Share this Publication link

    Share on social media