## Programming Languages and Dimensions (1996)

### Cached

### Download Links

Citations: | 35 - 3 self |

### BibTeX

@TECHREPORT{Kennedy96programminglanguages,

author = {Andrew John Kennedy and Francis Davey and Jean Goubault and Barney Hilken and Jean-pierre Jouannaud and Mikael Rittri and Claudio Rosso and Ian Stark and Mads Tofte In Particular},

title = {Programming Languages and Dimensions},

institution = {},

year = {1996}

}

### Years of Citing Articles

### OpenURL

### Abstract

Scientists and engineers must ensure that the equations and formulae which they use are dimensionally consistent, but existing programming languages treat all numeric values as dimensionless. This thesis investigates the extension of programming languages to support the notion of physical dimension. A type system is presented similar to that of the programming language ML but extended with polymorphic dimension types. An algorithm which infers most general dimension types automatically is then described and proved correct. The semantics of the language is given by a translation into an explicitlytyped language in which dimensions are passed as arguments to functions. The operational semantics of this language is specified in the usual way by an evaluation relation defined by a set of rules. This is used to show that if a program is well-typed then no dimension errors can occur during its evaluation. More abstract properties of the language are investigated using a denotational semantics: these include a notion of invariance under changes in the units of measure used, analogous to parametricity in the polymorphic lambda calculus. Finally the dissertation is summarised and many possible directions for future research in dimension types and related type systems are described. i ii

### Citations

1562 | The Definition of Standard ML
- Miller, Tofte, et al.
- 1990
(Show Context)
Citation Context ...he example programs used in this dissertation, in order to motivate the more formal study of dimensions and programming languages in subsequent chapters. All these programs are written in Standard ML =-=[43, 51]-=-, and a subset of this language forms the basis for theoretical investigations. Clearly all of the ideas would apply to any functional language in the style of ML: these include Haskell, Miranda and H... |

945 | A machine-oriented logic based on the resolution principle - Robinson - 1965 |

539 | A Syntactic Approach to Type Soundness
- Wright, Felleisen
- 1994
(Show Context)
Citation Context ...tions which ‘get stuck’ and never reach a value). Wright and Felleisen take this approach, which they call syntactic type soundness; they also produce a good survey of other research into the problem =-=[70]-=-. The addition of a wrong value is a nasty complication, and reduction semantics is too fine-grained for our purposes. Instead, we introduce the idea of erasing dimensions from types and expressions a... |

397 |
LCF considered as a programming language
- Plotkin
- 1977
(Show Context)
Citation Context ...f f(0) �= ⊥, por fg= [0] if g(0) �= ⊥, ⎪⎩ ⊥ otherwise. Then [[e1]] ⋆ (∅)(por ) = [0] whereas [[e2]] ⋆ (∅)(por )=⊥ so [[e1]] ⋆ �=[[e2]] ⋆ . This example is standard for typed lambda calculi such as Λδ =-=[52]-=-. Intuitively, there are functions such as por in the denotational semantics which ‘evaluate their arguments in parallel’, and which correspond to no expression in the operational semantics. In fact, ... |

366 |
ML for the Working Programmer
- Paulson
- 1991
(Show Context)
Citation Context ...he example programs used in this dissertation, in order to motivate the more formal study of dimensions and programming languages in subsequent chapters. All these programs are written in Standard ML =-=[43, 51]-=-, and a subset of this language forms the basis for theoretical investigations. Clearly all of the ideas would apply to any functional language in the style of ML: these include Haskell, Miranda and H... |

364 |
Towards a theory of type structure
- Reynolds
- 1974
(Show Context)
Citation Context ... τ ::= bool booleans | real δ dimensioned reals | τ1 → τ2 function types | ∀d.τ dimension quantification Figure 5.1: Dimensions and types in Reynolds’ polymorphic lambda calculus or Girard’s System F =-=[56, 17]-=-. We call this second-order language Λδ. One advantage of this approach is that we do not need to consider the semantics of a let construct explicitly. Instead, let constructs can be translated into t... |

345 | How to make ad-hoc polymorphism less ad hoc
- Wadler, Blott
- 1989
(Show Context)
Citation Context ...ML is taking (for example in ML-2000). The other is to generalise the idea of equality types from Standard ML to a system of type classes: these are the most innovative aspect of the language Haskell =-=[25, 67]-=-. A type class declaration prescribes certain operations which must be available on any type belonging to that class. For example, the class Eq of equality types requires that for every type τ in the ... |

329 | Theorems for free
- Wadler
- 1989
(Show Context)
Citation Context ...f f which can be inferred purely from its type: that for any function k, where the function k 2 is given by f(k(x)) = k 2 (f(x)) k 2 (x, y) =(k(x),k(y)). Wadler calls such results ‘theorems for free’ =-=[66]-=- because it is not necessary to know anything about f other than its type. Consider also a function g in ML with the type g : ∀t1.∀t2.t1 → t2. This time, the only function with this type is the non-te... |

191 |
An Introduction to the Theory of Numbers
- Niven, Zuckerman, et al.
- 1991
(Show Context)
Citation Context ...ication can be seen to be equivalent to the problem of finding all solutions in integers z1,... ,zm to the linear equation x1z1 + ···+ xmzm + g =0. There are standard algorithms to solve this problem =-=[48, 32]-=-; we use Knuth’s, which is essentially an adaptation of Euclid’s greatest common divisor algorithm. Lankford, Butler and Brady were the first to apply such algorithms to unification in Abelian groups ... |

153 |
Integral Matrices
- Newman
- 1972
(Show Context)
Citation Context ... of invertible substitutions shown below. Each substitution in the diagram is a single iteration † This example is a translation of the integer matrix on page 16 of Newman’s book on integral matrices =-=[46]-=-s3.3 Simplification of types 57 SimplifyScheme(∀� d.τ) = ∀� d0.U(τ) where U = Simplify(V,τ), V = fdv(τ) \ � d �d0 = fdv(U(τ)) \V. Figure 3.6: Algorithm SimplifyScheme of DimSimplify, processing the di... |

141 |
Type systems for programming languages
- Mitchell
- 1990
(Show Context)
Citation Context ...gram e it is the case that [[e]] ⋆ (∅) =[r] implies ⊢ e ⇓〈r, 1〉. This is more difficult to prove as we need something stronger than the denotation given in Figure 6.3. We construct a logical relation =-=[44]-=- between values in the denotational semantics and values in the operational semantics. The relation A V τ ⊆ [[τ]] ⋆ × Val(V,τ) is defined inductively by: •A V bool (b, b′ ) holds if and only if b = b ... |

108 |
Unification theory
- Siekmann
- 1989
(Show Context)
Citation Context ... unifier if it exists, or report failure if it does not. Before describing this algorithm, it is worth mentioning that some survey papers on unification classify Abelian group unification as finitary =-=[60]-=-. However, this refers to unification in the presence of arbitrary free constants, which may include function symbols. Consider the unification problem x · (y ⊕ z) ? =D w · (a ⊕ b) where w, x, y and z... |

97 | Type Theory and Functional Programming
- Thompson
- 1991
(Show Context)
Citation Context ...chapter as a powerful tool for reasoning about programs in Λδ. 6.1 Motivation Typesasproperties One way of viewing a type is as a property; this idea is taken to its logical conclusion in type theory =-=[63]-=- where the type of a program type is a complete specification of its behaviour. In the ML type system, and in the dimension type system presented here, a type represents a partial specification. Consi... |

93 |
Polymorphic type schemes and recursive definitions
- Mycroft
- 1984
(Show Context)
Citation Context .... More examples can be found in Rittri’s article [58]. The ordinary ML typing rules can be extended to allow polymorphism inside recursive definitions. The rule shown below, first proposed by Mycroft =-=[45]-=-, is for a call-by-name language with a fixed-point construct rec x.e. Our (letrec) rule could be modified similarly. Γ[x : σ] ⊢ e : σ (polyrec) Γ ⊢ rec x.e : σ Unfortunately, it has been shown by Hen... |

93 | Operational Semantics and Polymorphic Type Inference
- Tofte
- 1988
(Show Context)
Citation Context ...r language paradigms—in fact, to any language with a secure type system. There are the usual intricacies of assignment in the presence of polymorphism to deal with (considered by Tofte amongst others =-=[64]-=-), but dimensions do not introduce any new problems here. 1.1 Dimensions Units vs dimensions Physical quantities are measured with reference to a unit of scale. When we say that something is ‘6 metres... |

73 | Type inference for records in a natural extension of ML
- Remy
- 1991
(Show Context)
Citation Context ...6]. There are few other type inference algorithms which apply equational unification. Thatte’s application to type coercions is one such [62]; another is Rémy’s type inference with extensible records =-=[54]-=-. Order-sorted unification has been applied to the problem of type inference for Haskell’s type classes [47]. Rémy has also studied ‘equational’ type inference more generally [55]. However, he restric... |

57 | Implementation of the typed call-byvalue λ-calculus using a stack of regions
- Tofte, Talpin
- 1994
(Show Context)
Citation Context ...ion over rows. There are also potential applications in providing a better understanding of some type-based program analyses. For example, Tofte’s analysis of memory allocation in functional programs =-=[65]-=- employs quantification over regions; again, this is predicative. In general, we have some equational theory E which induces an equivalence between types =E. Then a logical relation R τ is defined ove... |

34 | Extending ML type system with a sorted equational theory. Research Report 1766, Institut de Recherche en Informatique et en Automatique
- Remy
- 1992
(Show Context)
Citation Context ...h extensible records [54]. Order-sorted unification has been applied to the problem of type inference for Haskell’s type classes [47]. Rémy has also studied ‘equational’ type inference more generally =-=[55]-=-. However, he restricts his presentation to regular equational theories. To the author’s knowledge, dimension inference is the first application of a non-regular equational theory to type inference, a... |

28 |
Type Classes and Overloading Resolution via Order-Sorted Unification
- Nipkow, Snelting
- 1991
(Show Context)
Citation Context ...o type coercions is one such [62]; another is Rémy’s type inference with extensible records [54]. Order-sorted unification has been applied to the problem of type inference for Haskell’s type classes =-=[47]-=-. Rémy has also studied ‘equational’ type inference more generally [55]. However, he restricts his presentation to regular equational theories. To the author’s knowledge, dimension inference is the fi... |

23 | Correspondence between operational and denotational semantics: the full abstraction problem for PCF. Handbook of logic in computer science (vol. 4): semantic modelling
- Ong
- 1995
(Show Context)
Citation Context ...o semantics 95 This is known as full abstraction. Our semantics is not fully abstract—it is a very difficult problem to find such a semantics for ‘sequential’ languages such as the one discussed here =-=[50]-=-. However, equivalences do match up in one direction, that is, [[e1]] ⋆ =[[e2]] ⋆ ⇒ e1 ≈ e2. This property is a simple consequence of the adequacy of the semantics. It is enough for our purposes, as w... |

18 | Automatic Dimensional Inference
- Wand, O’Keefe
- 1991
(Show Context)
Citation Context ...ection is so obvious that already there have been many proposals for dimension checking in programming languages [29, 24, 16, 40, 15, 3] including two along similar lines to the system discussed here =-=[68, 18]-=-. There has even been some work on applying dimension checking to formal specification of software [22]. Nevertheless, some of the usual arguments in favour of static type checking do not apply to dim... |

10 |
Coercive type isomorphism
- Thatte
- 1991
(Show Context)
Citation Context ...ventional ML type inference. This use of equational unification in a type inference algorithm is unusual; another example is in Thatte’s automatic generation of coercions between data representations =-=[62]-=-. Syntactic vs semantic unification The problem of syntactic, or free, unification is the following. Given two terms τ1 and τ2, find a substitution S such that S(τ1) =S(τ2). This substitution is calle... |

9 | Dimension inference under polymorphic recursion
- Rittri
- 1995
(Show Context)
Citation Context ...=fv(τ) \ fv(Γ). Unfortunately this obvious approach has some subtle problems (NGen stands for “naive generalisation”), noted also by Rittri in his article on polymorphic recursion for dimension types =-=[58]-=-. Consider the assignment Γ = {x : real d1 · d2} and the type τ = real d1 → real d2. Then by the rule given above, NGen(Γ,τ)=real d1 → real d2 which introduces no polymorphism. Intuitively, though, th... |

9 | Tutorial: Languages for Collection Types
- Tannen
- 1994
(Show Context)
Citation Context ...red too. It is sometimes remarked that database systems would benefit from a dose of type theory, and much progress has been made recently on typed programming languages for database query and update =-=[61]-=-. Dimension types would be even better. The ‘dimension’ of commerce is money, so the salaries stored in a commercial database would have the dimension money/time. All the usual physical dimensions hav... |

3 | Semi-unification of two terms in Abelian groups
- Rittri
- 1994
(Show Context)
Citation Context ...hing substitution Ri for each inequation giving Ri(S(τi)) =D S(τ ′ i ) for all i. Rittri has shown that for a single inequation this problem is decidable, and he presents an algorithm which solves it =-=[57]-=-. However, in order to use semi-unification to perform type inference in the presence of polymorphic recursion, it might be necessary to solve several inequations. For unification, the problem of solv... |

2 |
The Formal Semantics of Programming Languages: An Introduction
- Winksel
- 1993
(Show Context)
Citation Context ...o values in E. An interpreter for the language is likely to use a similar mechanism. The alternative is to define a subset of the expressions which represent fully-evaluated expressions or canonicals =-=[69, 19]-=-. Then instead of an environment in which free variables are looked up, arguments are substituted directly into the body of an abstraction (beta reduction). Figure 5.5 gives an inductive definition of... |

1 |
Putting type annotations to work (preliminary). Presented at Newton
- Odersky, Läufer
- 1995
(Show Context)
Citation Context ...a value of type τ1 may be used in place of a value of type τ2” is analogous to our interpretation of specialisation. Indeed, recent work on combining Hindley-Milner type inference with System F types =-=[49]-=- uses the same notation as here. Our decision to identify type schemes up to renaming of bound variables is usefully employed in the following lemma, which states that the specialisation relation is p... |