Skip to main content

Sound and Complete Flow Typing with Unions, Intersections and Negations

  • Conference paper

Part of the book series: Lecture Notes in Computer Science ((LNTCS,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.

This is a preview of subscription content, log in via an institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  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. 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. Ousterhout, J.K.: Scripting: Higher-level programming for the 21st century. IEEE Computer 31(3), 23–30 (1998)

    Article  Google Scholar 

  4. Spinellis, D.: Java makes scripting languages irrelevant? IEEE Software 22(3), 70–71 (2005)

    Article  Google Scholar 

  5. Loui, R.P.: In praise of scripting: Real programming pragmatism. IEEE Computer 41(7), 22–26 (2008)

    Article  Google Scholar 

  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. Hindley, J.R.: The principal type-scheme of an object in combinatory logic. Transactions of the AMS 146, 29–60 (1969)

    MathSciNet  MATH  Google Scholar 

  8. Milner, R.: A theory of type polymorphism in programming. Journal of Computer and System Sciences 17, 348–375 (1978)

    Article  MathSciNet  MATH  Google Scholar 

  9. The Scala programming language, http://lamp.epfl.ch/scala/

  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. Remy, D., Vouillon, J.: Objective ML: An effective object-oriented extension to ML. Theory And Practice of Object Systems 4(1), 27–50 (1998)

    Article  Google Scholar 

  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. Ekman, T., Hedin, G.: Pluggable checking and inferencing of non-null types for Java. Journal of Object Technology 6(9), 455–475 (2007)

    Article  Google Scholar 

  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. 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. 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. 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. Russo, A., Sabelfeld, A.: Dynamic vs. static flow-sensitive security analysis. In: Proc. CSF, pp. 186–199 (2010)

    Google Scholar 

  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)

    Chapter  Google Scholar 

  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. 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)

    Chapter  Google Scholar 

  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. 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. 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. 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)

    Chapter  Google Scholar 

  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. What’s new in Groovy 2.0?, http://www.infoq.com/articles/new-groovy-20

  28. The Whiley programming language, http://whiley.org

  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. 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. Lindholm, T., Yellin, F.: The Java Virtual Machine Specification, 2nd edn. Addison-Wesley (1999)

    Google Scholar 

  32. Leroy, X.: Java bytecode verification: algorithms and formalizations. Journal of Automated Reasoning 30(3/4), 235–269 (2003)

    Article  MathSciNet  MATH  Google Scholar 

  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. Aiken, A., Wimmers, E.L.: Type inclusion constraints and type inference. In: Proc. FPCA, pp. 31–41 (1993)

    Google Scholar 

  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)

    Chapter  Google Scholar 

  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)

    Chapter  Google Scholar 

  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. Garey, M.R., Johnson, D.S.: Computers and intractability; a guide to the theory of NP-completeness. W.H. Freeman (1979)

    Google Scholar 

  39. Umans, C.: The minimum equivalent DNF problem and shortest implicants. Journal of Computer and System Sciences 63 (2001)

    Google Scholar 

  40. Buchfuhrer, D., Umans, C.: The complexity of boolean formula minimization. Journal of Computer and System Sciences 77(1), 142–153 (2011)

    Article  MathSciNet  MATH  Google Scholar 

  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. Goldberg, A.: A specification of Java loading and bytecode verification. In: Proc. CCS, pp. 49–58 (1998)

    Google Scholar 

  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)

    Chapter  Google Scholar 

  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. 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. 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. Hosoya, H., Pierce, B.C.: XDuce: A statically typed XML processing language. ACM Transactions on Internet Technology 3(2), 117–148 (2003)

    Article  Google Scholar 

  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 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2013 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Pearce, D.J. (2013). Sound and Complete Flow Typing with Unions, Intersections and Negations. In: Giacobazzi, R., Berdine, J., Mastroeni, I. (eds) Verification, Model Checking, and Abstract Interpretation. VMCAI 2013. Lecture Notes in Computer Science, vol 7737. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-35873-9_21

Download citation

  • DOI: https://doi.org/10.1007/978-3-642-35873-9_21

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-642-35872-2

  • Online ISBN: 978-3-642-35873-9

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics