Sound and Complete Flow Typing with Unions, Intersections and Negations

  • David J. Pearce
Part of the Lecture Notes in Computer Science book series (LNCS, volume 7737)

Abstract

Flow typing is becoming a popular mechanism for typing existing programs written in untyped languages (e.g. JavaScript, Racket, Groovy). Such systems require intersections for the true-branch of a type test, negations for the false-branch, and unions to capture the flow of information at meet points. Type systems involving unions, intersections and negations require a subtype operator which is non-trivial to implement. Frisch et al. demonstrated that this problem was decidable. However, their proof was not constructive and does not lend itself naturally to an implementation. In this paper, we present a sound and complete algorithm for subtype testing in the presence of unions, intersections and negations.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Cartwright, R., Fagan, M.: Soft typing. In: Proceedings of the ACM Conference on Programming Language Design and Implementation (PLDI), pp. 278–292 (1991)Google Scholar
  2. 2.
    Ancona, D., Ancona, M., Cuni, A., Matsakis, N.D.: RPython: a step towards reconciling dynamically and statically typed OO languages. In: Proceedings of the Dynamic Languages Symposium (DLS), pp. 53–64 (2007)Google Scholar
  3. 3.
    Ousterhout, J.K.: Scripting: Higher-level programming for the 21st century. IEEE Computer 31(3), 23–30 (1998)CrossRefGoogle Scholar
  4. 4.
    Spinellis, D.: Java makes scripting languages irrelevant? IEEE Software 22(3), 70–71 (2005)CrossRefGoogle Scholar
  5. 5.
    Loui, R.P.: In praise of scripting: Real programming pragmatism. IEEE Computer 41(7), 22–26 (2008)CrossRefGoogle Scholar
  6. 6.
    Bloom, B., Field, J., Nystrom, N., Östlund, J., Richards, G., Strnisa, R., Vitek, J., Wrigstad, T.: Thorn: robust, concurrent, extensible scripting on the JVM. In: Proceedings of the ACM Conference on Object-Oriented Programming, Systems, Languages and Applications (OOPSLA), pp. 117–136 (2009)Google Scholar
  7. 7.
    Hindley, J.R.: The principal type-scheme of an object in combinatory logic. Transactions of the AMS 146, 29–60 (1969)MathSciNetMATHGoogle Scholar
  8. 8.
    Milner, R.: A theory of type polymorphism in programming. Journal of Computer and System Sciences 17, 348–375 (1978)MathSciNetMATHCrossRefGoogle Scholar
  9. 9.
    The Scala programming language, http://lamp.epfl.ch/scala/
  10. 10.
    Bierman, G., Meijer, E., Torgersen, M.: Lost in translation: formalizing proposed extensions to C#. In: Proceedings of the ACM Conference on Object-Oriented Programming, Systems, Languages and Applications (OOPSLA), pp. 479–498 (2007)Google Scholar
  11. 11.
    Remy, D., Vouillon, J.: Objective ML: An effective object-oriented extension to ML. Theory And Practice of Object Systems 4(1), 27–50 (1998)CrossRefGoogle Scholar
  12. 12.
    Foster, J.S., Terauchi, T., Aiken, A.: Flow-sensitive type qualifiers. In: Proceedings of the ACM Conference on Programming Language Design and Implementation (PLDI), pp. 1–12 (2002)Google Scholar
  13. 13.
    Ekman, T., Hedin, G.: Pluggable checking and inferencing of non-null types for Java. Journal of Object Technology 6(9), 455–475 (2007)CrossRefGoogle Scholar
  14. 14.
    Male, C., Pearce, D.J., Potanin, A., Dymnikov, C.: Java bytecode verification for @NonNull types. In: Proceedings of the Confererence on Compiler Construction (CC), pp. 229–244 (2008)Google Scholar
  15. 15.
    Fähndrich, M., Leino, K.R.M.: Declaring and checking non-null types in an object-oriented language. In: Proceedings of the ACM Conference on Object-Oriented Programming, Systems, Languages and Applications (OOPSLA), pp. 302–312 (2003)Google Scholar
  16. 16.
    Myers, A.C.: JFlow: Practical mostly-static information flow control. In: Proceedings of the ACM symposium on the Principles Of Programming Languages (POPL), pp. 228–241 (1999)Google Scholar
  17. 17.
    Hunt, S., Sands, D.: On flow-sensitive security types. In: Proceedings of the ACM Symposium on the Principles Of Programming Languages (POPL), pp. 79–90 (2006)Google Scholar
  18. 18.
    Russo, A., Sabelfeld, A.: Dynamic vs. static flow-sensitive security analysis. In: Proc. CSF, pp. 186–199 (2010)Google Scholar
  19. 19.
    Pearce, D.J.: JPure: A Modular Purity System for Java. In: Knoop, J. (ed.) CC 2011. LNCS, vol. 6601, pp. 104–123. Springer, Heidelberg (2011)CrossRefGoogle Scholar
  20. 20.
    Foster, J.S., Fähndrich, M., Aiken, A.: A theory of type qualifiers. In: Proceedings of the ACM conference on Programming Language Design and Implementation (PLDI), pp. 192–203 (1999)Google Scholar
  21. 21.
    Pominville, P., Qian, F., Vallée-Rai, R., Hendren, L., Verbrugge, C.: A Framework for Optimizing Java Using Attributes. In: Wilhelm, R. (ed.) CC 2001. LNCS, vol. 2027, pp. 334–554. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  22. 22.
    Andreae, C., Noble, J., Markstrum, S., Millstein, T.: A framework for implementing pluggable type systems. In: Proceedings of the ACM Conference on Object-Oriented Programming, Systems, Languages and Applications (OOPSLA), pp. 57–74 (2006)Google Scholar
  23. 23.
    Tobin-Hochstadt, S., Felleisen, M.: The design and implementation of typed Scheme. In: Proceedings of the ACM Symposium on the Principles Of Programming Languages (POPL), pp. 395–406 (2008)Google Scholar
  24. 24.
    Tobin-Hochstadt, S., Felleisen, M.: Logical types for untyped languages. In: Proceedings of the ACM International Conference on Functional Programming (ICFP), pp. 117–128 (2010)Google Scholar
  25. 25.
    Guha, A., Saftoiu, C., Krishnamurthi, S.: Typing Local Control and State Using Flow Analysis. In: Barthe, G. (ed.) ESOP 2011. LNCS, vol. 6602, pp. 256–275. Springer, Heidelberg (2011)CrossRefGoogle Scholar
  26. 26.
    Winther, J.: Guarded type promotion: eliminating redundant casts in Java. In: Proceedings of the Workshop on Formal Techniques for Java-like Programs, pp. 6:1–6:8 (2011)Google Scholar
  27. 27.
    What’s new in Groovy 2.0?, http://www.infoq.com/articles/new-groovy-20
  28. 28.
    The Whiley programming language, http://whiley.org
  29. 29.
    Pearce, D., Noble, J.: Implementing a language with flow-sensitive and structural typing on the JVM. Electronic Notes in Computer Science 279(1), 47–59 (2011)Google Scholar
  30. 30.
    Pearce, D.J., Cameron, N., Noble, J.: Whiley: a language with flow-typing and updateable value semantics. Technical Report ECSTR12-09, Victoria University of Wellington (2012)Google Scholar
  31. 31.
    Lindholm, T., Yellin, F.: The Java Virtual Machine Specification, 2nd edn. Addison-Wesley (1999)Google Scholar
  32. 32.
    Leroy, X.: Java bytecode verification: algorithms and formalizations. Journal of Automated Reasoning 30(3/4), 235–269 (2003)MathSciNetMATHCrossRefGoogle Scholar
  33. 33.
    Frisch, A., Castagna, G., Benzaken, V.: Semantic subtyping: Dealing set-theoretically with function, union, intersection, and negation types. Journal of the ACM 55(4), 19:1–19:64 (2008)Google Scholar
  34. 34.
    Aiken, A., Wimmers, E.L.: Type inclusion constraints and type inference. In: Proc. FPCA, pp. 31–41 (1993)Google Scholar
  35. 35.
    Damm, F.M.: Subtyping with Union Types, Intersection Types and Recursive Types. In: Hagiya, M., Mitchell, J.C. (eds.) TACS 1994. LNCS, vol. 789, pp. 687–706. Springer, Heidelberg (1994)CrossRefGoogle Scholar
  36. 36.
    Castagna, G., Frisch, A.: A Gentle Introduction to Semantic Subtyping. In: Caires, L., Italiano, G.F., Monteiro, L., Palamidessi, C., Yung, M. (eds.) ICALP 2005. LNCS, vol. 3580, pp. 30–34. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  37. 37.
    Frisch, A., Castagna, G., Benzaken, V.: Semantic subtyping. In: Proceedings of the ACM/IEEE Symposium on Logic In Computer Science (LICS), pp. 137–146 (2002)Google Scholar
  38. 38.
    Garey, M.R., Johnson, D.S.: Computers and intractability; a guide to the theory of NP-completeness. W.H. Freeman (1979)Google Scholar
  39. 39.
    Umans, C.: The minimum equivalent DNF problem and shortest implicants. Journal of Computer and System Sciences 63 (2001)Google Scholar
  40. 40.
    Buchfuhrer, D., Umans, C.: The complexity of boolean formula minimization. Journal of Computer and System Sciences 77(1), 142–153 (2011)MathSciNetMATHCrossRefGoogle Scholar
  41. 41.
    Pearce, D.J.: Sound and complete flow typing with unions, intersections and negations. Technical Report ECSTR12-20, Victoria University of Wellington (2012)Google Scholar
  42. 42.
    Goldberg, A.: A specification of Java loading and bytecode verification. In: Proc. CCS, pp. 49–58 (1998)Google Scholar
  43. 43.
    Pusch, C.: Proving the Soundness of a Java Bytecode Verifier Specification in Isabelle/HOL. In: Cleaveland, W.R. (ed.) TACAS 1999. LNCS, vol. 1579, pp. 89–103. Springer, Heidelberg (1999)CrossRefGoogle Scholar
  44. 44.
    Büchi, M., Weck, W.: Compound types for java. In: Proceedings of the ACM conference on Object-Oriented Programming, Systems, Languages and Applications (OOPSLA), pp. 362–373 (1998)Google Scholar
  45. 45.
    Igarashi, A., Nagira, H.: Union types for object-oriented programming. In: Proceedings of the Symposium on Applied Computing (SAC), pp. 1435–1441 (2006)Google Scholar
  46. 46.
    Plümicke, M.: Intersection types in java. In: Proceedings of the Conference on Principles and Practices of Programming in Java (PPPJ), pp. 181–188. ACM, New York (2008)Google Scholar
  47. 47.
    Hosoya, H., Pierce, B.C.: XDuce: A statically typed XML processing language. ACM Transactions on Internet Technology 3(2), 117–148 (2003)CrossRefGoogle Scholar
  48. 48.
    Benzaken, V., Castagna, G., Frisch, A.: CDuce: An XML-centric general-purpose language. In: Proceedings of the ACM International Conference on Functional Programming (ICFP), pp. 51–63 (2003)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2013

Authors and Affiliations

  • David J. Pearce
    • 1
  1. 1.Victoria University of WellingtonWellingtonNew Zealand

Personalised recommendations