Contracts as Pairs of Projections

  • Robert Bruce Findler
  • Matthias Blume
Part of the Lecture Notes in Computer Science book series (LNCS, volume 3945)


Assertion-based contracts provide a powerful mechanism for stating invariants at module boundaries and for enforcing them uniformly. In 2002, Findler and Felleisen showed how to add contracts to higher-order functional languages, allowing programmers to assert invariants about functions as values. Following up in 2004, Blume and McAllester provided a quotient model for contracts. Roughly speaking, their model equates a contract with the set of values that cannot violate the contract. Their studies raised interesting questions about the nature of contracts and, in particular, the nature of the any contract.

In this paper, we develop a model for software contracts that follows Dana Scott’s program by interpreting contracts as projections. The model has already improved our implementation of contracts. We also demonstrate how it increases our understanding of contract-oriented programming and design. In particular, our work provides a definitive answer to the questions raised by Blume and McAllester’s work. The key insight from our model that resolves those questions is that a contract that puts no obligation on either party is not the same as the most permissive contract for just one of the parties.


Operational Semantic Functional Programming Error Projection Range Contract Permissive Contract 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Bartetzko, D.: Parallelität und Vererbung beim Programmieren mit Vertrag. Diplomarbeit, Universität Oldenburg (April 1999)Google Scholar
  2. 2.
    Blume, M., McAllester, D.: Sound and complete models of contracts. Journal of Functional Programming (to appear)Google Scholar
  3. 3.
    Carrillo-Castellon, M., Garcia-Molina, J., Pimentel, E., Repiso, I.: Design by contract in Smalltalk. Journal of Object-Oriented Programming 7(9), 23–28 (1996)Google Scholar
  4. 4.
    Cheon, Y.: A runtime assertion checker for the Java Modelling Language. Technical Report 03-09, Iowa State University Computer Science Department (April 2003)Google Scholar
  5. 5.
    Conway, D., Goebel, C.G.: Class:Contract – design-by-contract OO in Perl,
  6. 6.
    Danvy, O., Nielsen, L.R.: Defunctionalization at work. In: International Conference on Principles and Practice of Declarative Programming (2001)Google Scholar
  7. 7.
    Duncan, A., Hölzle, U.: Adding contracts to Java with handshake. Technical Report TRCS98-32, The University of California at Santa Barbara (December 1998)Google Scholar
  8. 8.
    Dybvig, R.K., Hieb, R., Bruggeman, C.: Syntactic abstraction in Scheme. Lisp and Symbolic Computation 5(4), 295–326 (1993)CrossRefGoogle Scholar
  9. 9.
    Felleisen, M., Hieb, R.: The revised report on the syntactic theories of sequential control and state. Theoretical Computer Science, 235–271 (1992)Google Scholar
  10. 10.
    Findler, B., Blume, C., Felleisen, F., Huang, M., McCarthy, S., Press, R., Reppy, R., Spiro, T., Wick: The eighth annual ICFP programming contest,
  11. 11.
    Findler, R.B., Blume, M.: Contracts as pairs of projections. Technical Report TR- 2006-01, University of Chicago Computer Science Department (2006),
  12. 12.
    Findler, R.B., Blume, M., Felleisen, M.: An investigation of contracts as projections. Technical Report TR-2004-02, University of Chicago Computer Science Department (2004)Google Scholar
  13. 13.
    Findler, R.B., Felleisen, M.: Contract soundness for object-oriented languages. In: Object-Oriented Programming, Systems, Languages, and Applications (2001)Google Scholar
  14. 14.
    Findler, R.B., Felleisen, M.: Contracts for higher-order functions. In: Proceedings of ACM SIGPLAN International Conference on Functional Programming (2002)Google Scholar
  15. 15.
    Findler, R.B., Flatt, M., Felleisen, M.: Semantic casts: Contracts and structural subtyping in a nominal world. In: Odersky, M. (ed.) ECOOP 2004. LNCS, vol. 3086, pp. 365–389. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  16. 16.
    Findler, R.B., Latendresse, M., Felleisen, M.: Behavioral contracts and behavioral subtyping. In: Proceedings of ACM Conference Foundations of Software Engineering (2001)Google Scholar
  17. 17.
    Flatt, M.P.: Language manual. Technical Report TR97-280, Rice University (1997),
  18. 18.
    Gray, K.E., Findler, R.B., Flatt, M.: Fine-grained interoperability through contracts and mirrors. In: Object-Oriented Programming, Systems, Languages, and Applications (2005)Google Scholar
  19. 19.
    Jones, S.P., Washburn, G., Weirich, S.: Wobbly types: Practical type inference for generalized algebraic dataypes,
  20. 20.
    Karaorman, M., Hölzle, U., Bruno, J.: jContractor: A reflective java library to support design by contract. In: Cointe, P. (ed.) Reflection 1999. LNCS, vol. 1616, p. 175. Springer, Heidelberg (1999)CrossRefGoogle Scholar
  21. 21.
    Kelsey, R., Clinger, W., Rees, J. (eds.): Revised5 report of the algorithmic language Scheme; Higher-Order and Symbolic Computation 11(1), 7–105 (1998); Also appears in ACM SIGPLAN Notices 33(9) (September 1998)Google Scholar
  22. 22.
    Kiniry, J.R., Cheong, E.: JPP: A Java pre-processor. Technical Report CS-TR-98-15, Department of Computer Science, California Institute of Technology (1998)Google Scholar
  23. 23.
    Kohlbecker, E.E., Friedman, D.P., Felleisen, M., Duba, B.F.: Hygienic macro expansion. In: ACM Symposium on Lisp and Functional Programming, pp. 151–161 (1986)Google Scholar
  24. 24.
    Kramer, R.: iContract: The Java design by contract tool. In: Technology of Object-Oriented Languages and Systems (1998)Google Scholar
  25. 25.
    Launchbury, J.: Projections factorizations in partial evaluation. Cambridge University Press, Cambridge (1991)CrossRefMATHGoogle Scholar
  26. 26.
    Man Machine Systems. Design by contract for Java using JMSAssert (2000),
  27. 27.
    Matthews, J., Findler, R.B.: An operational semantics for R5RS Scheme. In: Workshop on Scheme and Functional Programming (2005)Google Scholar
  28. 28.
    McCarthy, J.: A basis for a mathematical theory of computation. Computer Programming and Formal Systems (1961),
  29. 29.
    McFarlane, K.: Design by contract framework,
  30. 30.
    Meyer, B.E.: The Language. Prentice-Hall, Englewood Cliffs (1992)MATHGoogle Scholar
  31. 31.
    Parnas, D.L.: A technique for software module specification with examples. Communications of the ACM 15(5), 330–336 (1972)CrossRefGoogle Scholar
  32. 32.
    Plösch, R.: Design by contract for Python. In: IEEE Proceedings of the Joint Asia Pacific Software Engineering Conference (1997),
  33. 33.
    Plösch, R., Pichler, J.: Contracts: From analysis to C++ implementation. In: Technology of Object-Oriented Languages and Systems, pp. 248–257 (1999)Google Scholar
  34. 34.
    Plotkin, G.D.: Call-by-name, call-by-value and the λ-calculus. Theoretical Computer Science 1, 125–159 (1975), MathSciNetCrossRefMATHGoogle Scholar
  35. 35.
    PLT. PLT MzLib: Libraries manual. Technical Report PLT-TR05-4-v300, PLT Scheme Inc. (2005),
  36. 36.
    Reynolds, J.C.: Definitional interpreters for higher-order programming languages. Higher- Order and Symbolic Computation 11(4), 363–397 (1998); Reprinted from the proceedings of the 25th ACM National Conference (1972), with a forewordGoogle Scholar
  37. 37.
    Rosenblum, D.S.: A practical approach to programming with assertions. IEEE Transactions on Software Engineering 21(1), 19–31 (1995)CrossRefGoogle Scholar
  38. 38.
    Sabry, A., Felleisen, M.: Reasoning about programs in continuation-passing style. Lisp and Symbolic Computation 6(3/4), 289–360 (1993)CrossRefGoogle Scholar
  39. 39.
    Scott, D.S.: Data types as lattices. Society of Industrial and Applied Mathematics (SIAM) Journal of Computing 5(3), 522–586 (1976)MathSciNetMATHGoogle Scholar
  40. 40.
    The GHC Team. Glasgow Haskell compiler,
  41. 41.
    Wadler, P., Hughes, R.J.M.: Projections for Strictness Analysis. In: Kahn, G. (ed.) FPCA 1987. LNCS, vol. 274, pp. 385–407. Springer, Heidelberg (1987)CrossRefGoogle Scholar
  42. 42.
    Xi, H., Chen, C., Chen, G.: Guarded recursive datatype constructors. In: Proceedings of the ACM Conference Principles of Programming Languages (2003)Google Scholar
  43. 43.
    Yang, Z.: Encoding types in ml-like languages. In: Proceedings of ACM SIGPLAN International Conference on Functional Programming (1998)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2006

Authors and Affiliations

  • Robert Bruce Findler
    • 1
  • Matthias Blume
    • 2
  1. 1.University of ChicagoUSA
  2. 2.Toyota Technological Institute at ChicagoUSA

Personalised recommendations