research-article

Correct blame for contracts: no more scapegoating

Published:26 January 2011Publication History

Abstract

Behavioral software contracts supplement interface information with logical assertions. A rigorous enforcement of contracts provides useful feedback to developers if it signals contract violations as soon as they occur and if it assigns blame to violators with preciseexplanations. Correct blame assignment gets programmers started with the debugging process and can significantly decrease the time needed to discover and fix bugs.

Sadly the literature on contracts lacks a framework for making statements about the correctness of blame assignment and for validating such statements. This paper fills the gap and uses the framework to demonstrate how one of the proposed semantics for higher-order contracts satisfies this criteria and another semantics occasionally assigns blame to the wrong module.

Concretely, the paper applies the framework to the lax enforcement of dependent higher-order contracts and the picky one. A higher-order dependent contract specifies constraints for the domain and range of higher-order functions and also relates arguments and results in auxiliary assertions. The picky semantics ensures that the use of arguments in the auxiliary assertion satisfies the domain contracts and the lax one does not. While the picky semantics discovers more contract violations than the lax one, it occasionally blames the wrong module. Hence the paper also introduces a third semantics, dubbed indy, which fixes the problems of the picky semantics without giving up its advantages.

Supplemental Material

19-mpeg-4.mp4

References

  1. H. P. Barendregt. phThe Lambda Calculus -- Its Syntax and Semantics, volume 103 of phStudies in Logic and the Foundations of Mathematics. North-Holland, 1984.Google ScholarGoogle Scholar
  2. M. Barnett, K. R. M. Leino, and W. Schulte. The Spec# programming system: an overview. In Construction and Analysis of Safe, Secure and Interoperable Smart Devices, pages 49--69, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. A. Beugnard, J.-M. Jézéquel, N. Plouzeau, and D. Watkins. Making components contract aware. IEEE Computer, 32 (7): 38--45, July 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. M. Blume and D. McAllester. Sound and complete models of contracts. Journal of Functional Programming, 16 (4--5): 375--414, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. R. Bose and J. Frew. Lineage retrieval for scientific data processing: a survey. ACM Computing Survey, 37 (1): 1--28, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. J. Cheney, S. Chong, N. Foster, M. Seltzer, and S. Vansummeren. Provenance: a future history. In Proceeding of the 24th ACM SIGPLAN Conference Companion on Object Oriented Programming Systems Languages and Applications: Onward! Session (OOPSLA Onward!), pages 957--964, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. O. Chitil, D. McNeill, and C. Runciman. Lazy assertions. In Revised Papers of the 15th International Workshop on Implementation of Functional Languages (IFL), pages 1--19, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. M. Degen, P. Thiemann, and S. Wehr. Eager and delayed contract monitoring for call-by-value and call-by-name evaluation. Journal of Logic and Algebraic Programming, page to appear, 2010.Google ScholarGoogle Scholar
  9. D. E. Denning. A lattice model of secure information flow. Communications of the ACM, 19 (5): 236--243, 1976. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. D. L. Detlefs, K. R. M. Leino, G. Nelson, and J. B. Saxe. Extended static checking. Technical Report 158, Compaq SRC Research Report, 1998.Google ScholarGoogle Scholar
  11. C. Dimoulas and M. Felleisen. On contract satisfaction in a higher-order world. ACM Transactions on Programming Languages and Systems. accepted (with revisions) for publication. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. M. Felleisen, R. B. Findler, and M. Flatt. Semantics Engineering with PLT Redex. MIT Press, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. R. B. Findler and M. Blume. Contracts as pairs of projections. In Proceedings of the 8th International Symposium on Functional and Logic Programming (FLOPS), pages 226--241, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. R. B. Findler and M. Felleisen. Contracts for higher-order functions. In Proceedings of the 7th ACM SIGPLAN International Conference on Functional Programming (ICFP), pages 48--59, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. R. B. Findler, J. Clements, C. Flanagan, M. Flatt, S. Krishnamurthi, P. Steckler, and M. Felleisen. DrScheme: A programming environment for Scheme. J. Funct. Program., 12 (2): 159--182, Mar. 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. R. B. Findler, M. Felleisen, and M. Blume. An investigation of contracts as projections. Technical Report TR-2004-02, University of Chicago, Computer Science Department, 2004.Google ScholarGoogle Scholar
  17. C. Flanagan. Hybrid type checking. In Proceedings of the 33th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), pages 245--256, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. M. Flatt and PLT. Reference: Racket. Technical Report PLT-TR-2010-1, PLT Inc., 2010. http://racket-lang.org/tr1/.Google ScholarGoogle Scholar
  19. M. Greenberg, B. C. Pierce, and S. Weirich. Contracts made manifest. In Proceedings of the 37th Annual ACM SIGPLAN-SIGACT Symposium on Programming Languages (POPL), pages 353--364, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. J. Gronski and C. Flanagan. Unifying hybrid types and contracts. In Proceedings of the 8th Symposium on Trends in Functional Programming (TFP), pages 54--69, 2007.Google ScholarGoogle Scholar
  21. R. Hinze, J. Jeuring, and A. Löh. Typed contracts for functional programming. In In Proceedings of the 8th International Symposium on Functional and Logic Programming (FLOPS), pages 208--235, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. K. Knowles, A. Tomb, J. Gronski, S. N. Freund, and C. Flanagan. Sage: Unified hybrid checking for first-class types, general refinement types, and dynamic, 2006. URL http://sage.soe.ucsc.edu/.Google ScholarGoogle Scholar
  23. G. T. Leavens, A. L. Baker, and C. Ruby. JML: A notation for detailed design. In H. Kilov, B. Rumpe, and I. Simmonids, editors, Behavioral Specifications of Businesses and Systems, pages 175--188. Kluwer Academic Publishers, 1999.Google ScholarGoogle ScholarCross RefCross Ref
  24. B. Meyer. Design by contract. In Advances in Object-Oriented Software Engineering, pages 1--50. Prentice Hall, 1991.Google ScholarGoogle Scholar
  25. B. Meyer. Eiffel: The Language. Prentice Hall, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. B. Meyer. Object-oriented Software Construction. Prentice Hall, 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. G. D. Plotkin. Call-by-name, call-by-value, and the λ-calculus. Theoretical Computer Science, 1 (2): 125--159, 1975.Google ScholarGoogle ScholarCross RefCross Ref
  28. G. D. Plotkin. LCF considered as a programming language. Theoretical Computer Science, 5 (3): 223--255, 1977.Google ScholarGoogle ScholarCross RefCross Ref
  29. A. Rudich, A. Darvas, and P. Müller. Checking well-formedness of pure-method specifications. In Proceedings of the 15th International Symposium on Formal Methods (FM), pages 68--83, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. D. S. Scott. Data types as lattices. SIAM Journal of Computing, 5 (3): 522--587, 1976.Google ScholarGoogle ScholarCross RefCross Ref
  31. Y. L. Simmhan, B. Plale, and D. Gannon. A survey of data provenance in e-science. ACM SIGMOD Record, 34 (3): 31--36, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. T. S. Strickland and M. Felleisen. Contracts for first-class modules. In Proceedings of the 5th Symposium on Dynamic Languages (DLS), pages 27--38. ACM, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. S. Tobin-Hochstadt and M. Felleisen. Logical types for untyped languages. In Proceedings of the 15th ACM SIGPLAN Internation Conference on Functional Programming (ICFP), pages 117--128, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. S. Tobin-Hochstadt and M. Felleisen. The design and implementation of Typed Scheme. In Proceedings of the 35th Annual ACM SIGPLAN-SIGACT Symposium on the Pronciples of Programming Languages (POPL), pages 395--407, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. D. Xu, S. Peyton Jones, and K. Claessen. Static contract checking for Haskell. In Proceedings of the 36th Annual ACM SIGPLAN-SIGACT Symposium on Programming Languages (POPL), pages 41--52, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. S. Zdancewic, D. Grossman, and G. Morrisett. Principals in programming languages: A syntactic proof technique. In Proceedings of the 4th ACM SIGPLAN International Conference on Functional Programming (ICFP), pages 197--207, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Correct blame for contracts: no more scapegoating

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in

        Full Access

        • Published in

          cover image ACM SIGPLAN Notices
          ACM SIGPLAN Notices  Volume 46, Issue 1
          POPL '11
          January 2011
          624 pages
          ISSN:0362-1340
          EISSN:1558-1160
          DOI:10.1145/1925844
          Issue’s Table of Contents
          • cover image ACM Conferences
            POPL '11: Proceedings of the 38th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages
            January 2011
            652 pages
            ISBN:9781450304900
            DOI:10.1145/1926385

          Copyright © 2011 ACM

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 26 January 2011

          Check for updates

          Qualifiers

          • research-article

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader
        About Cookies On This Site

        We use cookies to ensure that we give you the best experience on our website.

        Learn more

        Got it!