skip to main content
10.1145/2541568.2541574acmconferencesArticle/Chapter ViewAbstractPublication PagespoplConference Proceedingsconference-collections
research-article

Substructural typestates

Published: 11 January 2014 Publication History

Abstract

Finding simple, yet expressive, verification techniques to reason about both aliasing and mutable state has been a major challenge for static program verification. One such approach, of practical relevance, is centered around a lightweight typing discipline where types denote abstract object states, known as typestates.
In this paper, we show how key typestate concepts can be precisely captured by a substructural type-and-effect system, exploiting ideas from linear and separation logic. Building on this foundation, we show how a small set of primitive concepts can be composed to express high-level idioms such as objects with multiple independent state dimensions, dynamic state tests, and behavior-oriented usage protocols that enforce strong information hiding. By exploring the relationship between two mainstream modularity concepts, state abstraction and hiding, we also provide new insights on how they naturally fit together and complement one another.
Technically, our results are based on a typed lambda calculus with mutable references, location-dependent types, and second-order polymorphism. The soundness of our type system is shown through progress and preservation theorems. We also describe a prototype implementation of a type checker for our system, which is available on the web and can be used to experiment with the examples in the paper.

References

[1]
Prototype. https://code.google.com/p/dead-parrot/.
[2]
A. Ahmed, M. Fluet, and G. Morrisett. L3: A linear language with locations. Fundam. Inform., 77 (4): 397--449, 2007.
[3]
N. E. Beckman, K. Bierhoff, and J. Aldrich. Verifying correct usage of atomic blocks and typestate. In OOPSLA'08, pages 227--244. ACM, 2008.
[4]
N. E. Beckman, Y. P. Kim, S. Stork, and J. Aldrich. Reducing stm overhead with access permissions. In IWACO'09, pages 2:1--2:10. ACM, 2009.
[5]
N. E. Beckman, D. Kim, and J. Aldrich. An empirical study of object protocols in the wild. In ECOOP'11, pages 2--26. Springer-Verlag, 2011.
[6]
K. Bierhoff and J. Aldrich. Modular typestate checking of aliased objects. In OOPSLA 2007, pages 301--320, 2007.
[7]
J. Boyland. Alias burying: unique variables without destructive reads. Softw. Pract. Exper., 31 (6): 533--553, May 2001.
[8]
J. Boyland. Checking interference with fractional permissions. In Proc. Static Analysis Symposium, pages 55--72, 2003.
[9]
J. T. Boyland and W. Retert. Connecting effects and uniqueness with adoption. In POPL '05, pages 283--295. ACM, 2005.
[10]
L. Caires and J. a. C. Seco. The type discipline of behavioral separation. In POPL '13, pages 275--286. ACM, 2013.
[11]
C. Calcagno, P. W. O'Hearn, and H. Yang. Local action and abstract separation logic. In Proc. Logic in Computer Science, pages 366--378, 2007.
[12]
A. Chargu�raud and F. Pottier. Functional translation of a calculus of capabilities. In ICFP '08, pages 213--224. ACM, 2008.
[13]
K. Crary, D. Walker, and G. Morrisett. Typed memory management in a calculus of capabilities. In POPL '99, pages 262--275. ACM, 1999.
[14]
R. Davies and F. Pfenning. Intersection types and computational effects. In ICFP '00, pages 198--208. ACM, 2000.
[15]
R. DeLine and M. F�hndrich. Enforcing high-level protocols in low-level software. In PLDI 2001, pages 59--69. ACM, 2001.
[16]
R. DeLine and M. F�hndrich. Typestates for objects. In ECOOP, pages 465--490. Springer, 2004.
[17]
T. Dinsdale-Young, L. Birkedal, P. Gardner, M. Parkinson, and H. Yang. Views: compositional reasoning for concurrent programs. In POPL '13, pages 287--300. ACM, 2013.
[18]
J. Dunfield and F. Pfenning. Type assignment for intersections and unions in call-by-value languages. In FOSSACS '03, pages 250--266. Springer-Verlag LNCS 2620, 2003.
[19]
M. Fahndrich and R. DeLine. Adoption and focus: practical linear types for imperative programming. In PLDI 2002, pages 13--24. ACM, 2002.
[20]
S. J. Gay, V. T. Vasconcelos, A. Ravara, N. Gesbert, and A. Z. Caldeira. Modular session types for distributed object-oriented programming. In POPL, pages 299--312, 2010.
[21]
D. K. Gifford and J. M. Lucassen. Integrating functional and imperative programming. In LFP '86, pages 28--38. ACM, 1986.
[22]
J.-Y. Girard. Linear logic. Theor. Comput. Sci., 50: 1--102, 1987.
[23]
P. Haller and M. Odersky. Capabilities for uniqueness and borrowing. In ECOOP'10, pages 354--378. Springer-Verlag, 2010.
[24]
N. R. Krishnaswami, A. Turon, D. Dreyer, and D. Garg. Superficially substructural types. In ICFP 2012, pages 41--54. ACM, 2012.
[25]
B. H. Liskov and J. M. Wing. A behavioral notion of subtyping. ACM Trans. Program. Lang. Syst., 16 (6): 1811--1841, Nov. 1994.
[26]
K. Mazurak, J. Zhao, and S. Zdancewic. Lightweight linear types in system fo. In TLDI '10, pages 77--88. ACM, 2010.
[27]
F. Milit�o, J. Aldrich, and L. Caires. Aliasing control with view-based typestate. In FTfJP, pages 7:1--7:7. ACM, 2010.
[28]
F. Milit�o, J. Aldrich, and L. Caires. Substructural typestates (technical appendix), 2013. http://www.cs.cmu.edu/ foliveir/papers/plpv14-appendix.pdf
[29]
J. C. Mitchell and G. D. Plotkin. Abstract types have existential type. ACM Trans. Program. Lang. Syst., 10 (3): 470--502, July 1988.
[30]
K. Naden, R. Bocchino, J. Aldrich, and K. Bierhoff. A type system for borrowing permissions. In POPL 2012, pages 557--570. ACM, 2012.
[31]
A. Nanevski, G. Morrisett, and L. Birkedal. Polymorphism and separation in hoare type theory. In ICFP '06, pages 62--73. ACM, 2006.
[32]
A. Nanevski, A. Ahmed, G. Morrisett, and L. Birkedal. Abstract predicates and mutable adts in hoare type theory. In ESOP'07, pages 189--204. Springer-Verlag, 2007.
[33]
M. Parkinson and G. Bierman. Separation logic and abstraction. In POPL, pages 247--258. ACM, 2005.
[34]
X. Qi and A. C. Myers. Masked types for sound object initialization. In POPL, pages 53--65, 2009.
[35]
J. Reynolds. Syntactic control of interference part 2. In G. Ausiello, M. Dezani-Ciancaglini, and S. Rocca, editors, Automata, Languages and Programming, volume 372 of phLecture Notes in Computer Science, pages 704--722. Springer Berlin Heidelberg, 1989.
[36]
J. C. Reynolds. Separation logic: A logic for shared mutable data structures. In Proc. Logic in Computer Science, pages 55--74, 2002.
[37]
P. M. Rondon, M. Kawaguchi, and R. Jhala. Low-level liquid types. In POPL '10, pages 131--144. ACM, 2010.
[38]
A. Sabry and M. Felleisen. Reasoning about programs in continuation-passing style. In Proc. LISP and Functional Programming, pages 288--298, 1992.
[39]
F. Smith, D. Walker, and G. Morrisett. Alias types. In ESOP, pages 366--381. Springer-Verlag, 2000.
[40]
R. E. Strom. Mechanisms for compile-time enforcement of security. In POPL '83, pages 276--284. ACM, 1983.
[41]
R. E. Strom and S. Yemini. Typestate: A programming language concept for enhancing software reliability. IEEE Trans. Software Eng., 12 (1): 157--171, 1986.
[42]
J. Sunshine, K. Naden, S. Stork, J. Aldrich, and E. Tanter. First-class state change in plaid. In OOPSLA '11, pages 713--732. ACM, 2011.
[43]
K. Takeuchi, K. Honda, and M. Kubo. An interaction-based language and its typing system. In Proc. of PARLE Conference on Parallel Architectures and Languages Europe, pages 398--413. Springer-Verlag, 1994.
[44]
J. A. Tov and R. Pucella. Practical affine types. In POPL, pages 447--458. ACM, 2011.
[45]
J. Van Den Bos and C. Laffra. Procol: a parallel object language with protocols. In OOPSLA '89, pages 95--102. ACM, 1989.
[46]
S. van Staden and C. Calcagno. Reasoning about multiple related abstractions with multistar. In OOPSLA '10, pages 504--519. ACM, 2010.
[47]
P. Wadler. Linear types can change the world! In Programming Concepts and Methods. North, 1990.
[48]
D. Walker and J. G. Morrisett. Alias types for recursive data structures. In Selected papers from the Third International Workshop on Types in Compilation, TIC '00, pages 177--206. Springer-Verlag, 2001.

Cited By

View all

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
PLPV '14: Proceedings of the ACM SIGPLAN 2014 Workshop on Programming Languages meets Program Verification
January 2014
66 pages
ISBN:9781450325677
DOI:10.1145/2541568
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]

Sponsors

In-Cooperation

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 11 January 2014

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. aliasing
  2. capabilities
  3. linearity
  4. typestate

Qualifiers

  • Research-article

Conference

POPL '14
Sponsor:

Acceptance Rates

PLPV '14 Paper Acceptance Rate 5 of 7 submissions, 71%;
Overall Acceptance Rate 18 of 25 submissions, 72%

Upcoming Conference

POPL '25

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)4
  • Downloads (Last 6 weeks)1
Reflects downloads up to 19 Oct 2024

Other Metrics

Citations

Cited By

View all
  • (2024)Coconut: Typestates for�Embedded SystemsCoordination Models and Languages10.1007/978-3-031-62697-5_12(219-238)Online publication date: 17-Jun-2024
  • (2015)Integrating Linear and Dependent TypesACM SIGPLAN Notices10.1145/2775051.267696950:1(17-30)Online publication date: 14-Jan-2015
  • (2015)Integrating Linear and Dependent TypesProceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages10.1145/2676726.2676969(17-30)Online publication date: 14-Jan-2015
  • (2014)Rely-Guarantee ProtocolsProceedings of the 28th European Conference on ECOOP 2014 --- Object-Oriented Programming - Volume 858610.1007/978-3-662-44202-9_14(334-359)Online publication date: 1-Aug-2014

View Options

Get Access

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media