Correct-by-Construction Concurrency

In the modern, multi-threaded, multi-core programming environment, correctly managing system resources such as locks and shared variables can be especially difficult and error-prone. A simple error, such as forgetting to release a lock, can have major consequences on the correct operation of the program (e.g. deadlock), often at a time and location that is isolated from the original error. While there have been many previous proposals for managing locks and resources, these often arise from the systems arena, and are therefore often only loosely integrated with the host programming language. Such approaches therefore do not generally provide the strong formal guarantees of correctness-by-construction that we would prefer for all fundamental properties of our programs. In this paper, we propose a new type-based approach to resource management, based on the use of dependent types to construct a Domain-Specific Embedded Language (DSEL) whose typing rules enforce the properties we require. We illustrate our approach by implementing a DSEL for concurrent programming and demonstrate its applicability with reference to concurrent transactions on a bank account.

[1]  Chris Hawblitzel,et al.  Linear types for aliased resources , 2005 .

[2]  Walid Taha,et al.  Multi-Stage Programming: Its Theory and Applications , 1999 .

[3]  Wouter Swierstra,et al.  Beauty in the Beast A Functional Semantics for the Awkward Squad , 2007 .

[4]  Martin Hofmann,et al.  Static prediction of heap space usage for first-order functional programs , 2003, POPL '03.

[5]  Walid Taha,et al.  Tagless staged interpreters for typed languages , 2002, ICFP '02.

[6]  Tim Sheard,et al.  WHAT IS A PROOF , 2005 .

[7]  Uday S. Reddy,et al.  Imperative functional programming , 1996, CSUR.

[8]  Krzysztof Czarnecki,et al.  DSL Implementation in MetaOCaml, Template Haskell, and C++ , 2003, Domain-Specific Program Generation.

[9]  Arie Shoshani,et al.  System Deadlocks , 1971, CSUR.

[10]  P. J. Landin,et al.  The next 700 programming languages , 1966, CACM.

[11]  Peter Hancock,et al.  Interactive Programs in Dependent Type Theory , 2000, CSL.

[12]  Edwin Brady,et al.  Ivor, a Proof Engine , 2006, IFL.

[13]  David Walker,et al.  A type system for expressive security policies , 2000, POPL '00.

[14]  Wei-Ngan Chin,et al.  A type system for resource protocol verification and its correctness proof , 2004, PEPM '04.

[15]  Edwin Brady,et al.  A Dependently Typed Framework for Static Analysis of Program Execution Costs , 2005, IFL.

[16]  Simon L. Peyton Jones,et al.  Simple unification-based type inference for GADTs , 2006, ICFP '06.

[17]  Edwin Brady,et al.  A verified staged interpreter is a verified compiler , 2006, GPCE '06.

[18]  Peter J. Stuckey,et al.  Resource Usage Verification , 2003, APLAS.

[19]  Conor McBride,et al.  Inductive Families Need Not Store Their Indices , 2003, TYPES.

[20]  Edwin Brady,et al.  Practical implementation of a dependently typed functional programming language , 2005 .

[21]  Simon L. Peyton Jones,et al.  Composable memory transactions , 2005, CACM.

[22]  Carolyn L. Talcott,et al.  A foundation for actor computation , 1997, Journal of Functional Programming.

[23]  Jifeng He,et al.  Towards a truly concurrent model for processes sharing resources , 2005, Third IEEE International Conference on Software Engineering and Formal Methods (SEFM'05).

[24]  Peter Amey,et al.  Correctness By Construction: Better Can Also Be Cheaper , 2002 .

[25]  Atsushi Igarashi,et al.  Resource usage analysis , 2002, POPL '02.

[26]  Naoki Kobayashi,et al.  Type-Based Analysis of Deadlock for a Concurrent Calculus with Interrupts , 2007, ESOP.

[27]  P. Medawar A view from the left , 1984, Nature.

[28]  Conor McBride,et al.  Simply Easy! An Implementation of a Dependently Typed Lambda Calculus , 2007 .

[29]  David Walker,et al.  Policy enforcement via program monitoring , 2006 .

[30]  Greg J. Michaelson,et al.  Hume: A Domain-Specific Language for Real-Time Embedded Systems , 2003, GPCE.

[31]  Naoki Kobayashi,et al.  A Type System for Lock-Free Processes , 2002, Inf. Comput..