Dynamic Typing: Syntax and Proof Theory

We present the dynamically typed A-calculus, an extension of the statically typed I-calculus with a special type Dyn and explicit dynamic type coercions corresponding to run-time type tagging and type check-and-untag operations. Programs in run-time typed languages can be interpreted in the dynamically typed L-calculus via a nondeterministic completion process that inserts explicit coercions and type declarations such that a well-typed term results. We characterize when two different completions of the same run-time typed program are coherent with an equational theory that is independent of an underlying I-theory. This theory is refined by orienting some equations to define safety and minimality of completions. Intuitively, a safe completion is one that does not produce an error at run-time which another completion would have avoided, and a minimal completion is a safe completion that executes fewest tagging and check-and-untag operations amongst all safe completions. We show that every untyped A-term has a safe completion at any type and that it is unique modulo a suitable congruence relation. Furthermore, we present a rewriting system for generating minimal completions. Assuming strong normalization of this rewriting system we show that every U-term has a minimal completion at any type, which is furthermore unique modulo equality in the dynamically typed A-calculus.

[1]  Harry G. Mairson,et al.  The Complexity of Type Inference for Higher-Order Typed lambda Calculi , 1994, J. Funct. Program..

[2]  Satish R. Thatte,et al.  Type Inference with Partial Types , 1988, Theor. Comput. Sci..

[3]  Mitchell Wand,et al.  Type Inference for Partial Types is Decidable , 1992, ESOP.

[4]  Robert Cartwright,et al.  Soft typing , 2004, SIGP.

[5]  Gerard Huet,et al.  Conflunt reductions: Abstract properties and applications to term rewriting systems , 1977, 18th Annual Symposium on Foundations of Computer Science (sfcs 1977).

[6]  Jens Palsberg,et al.  Efficient inference of partial types , 1992, Proceedings., 33rd Annual Symposium on Foundations of Computer Science.

[7]  Fritz Henglein,et al.  Global tagging optimization by type inference , 1992, LFP '92.

[8]  Satish R. Thatte Quasi-static typing , 1989, POPL '90.

[9]  Martín Abadi,et al.  Dynamic typing in a statically-typed language , 1989, POPL '89.

[10]  Didier Rémy,et al.  Type checking records and variants in a natural extension of ML , 1989, POPL '89.

[11]  Gérard P. Huet,et al.  Confluent Reductions: Abstract Properties and Applications to Term Rewriting Systems , 1980, J. ACM.

[12]  Carsten K. Gomard Partial type inference for untyped functional programs , 1990, LISP and Functional Programming.

[13]  Fritz Henglein Dynamic Typing , 1992, ESOP.

[14]  Thierry Coquand,et al.  Inheritance and explicit coercion , 1989, [1989] Proceedings. Fourth Annual Symposium on Logic in Computer Science.

[15]  Xavier Leroy,et al.  Dynamics in ML , 1991, Journal of Functional Programming.

[16]  Giorgio Ghelli,et al.  Coherence of Subsumption , 1990, CAAP.

[17]  HuetGérard Confluent Reductions: Abstract Properties and Applications to Term Rewriting Systems , 1980 .

[18]  Martín Abadi,et al.  Dynamic typing in polymorphic languages , 1995, Journal of Functional Programming.

[19]  Thierry Coquand,et al.  Inheritance as Implicit Coercion , 1991, Inf. Comput..

[20]  Harry G. Mairson,et al.  The complexity of type inference for higher-order lambda calculi , 1991, POPL '91.