[comp.lang.misc] Type systems with dimensional units

robison@brazil (Arch D. Robison) (01/22/91)

I am looking for references on languages that incorporate ``units checking''
into their type system.  For example, such languages would allow 
``2 kg + 3 kg'', but should flag ``2 kg + 3 meters'' as a compile-time
error.  References to any type theory supporting such a language would 
also be appreciated.  I know I've seen at least two papers suggesting
the addition of ``units checking'' to languages, but I can't remember
where I saw them.  Please mail responses to me.  I will post a summary
if there is sufficient interest.

Arch D. Robison				robison@shell.com
Bellaire Research Center 		(713)-663-2240
Shell Development Company 		

pgh@stl.stc.co.uk (P.G.Hamer) (01/28/91)

In the referenced article robison@brazil (Arch D. Robison) writes:
>I am looking for references on languages that incorporate ``units checking''
>into their type system. 

Tried to e-mail but it bounced.


Sorry, no good reference  - but I seem to remember an article in a very old
ACM comms (or just possibly BCS) - late 60's or early 70's.

I assume that you are going to allow mixed expressions (area = x * y), so 
I you will presumably want an intermediate representation that keeps powers
of the fundamental dimensions of space time (length, time, mass, ...).

As I remember my physics, it gets a bit dodgy in the area of electrical
units.

It also does not identify when dimensionless contants are missing. Superficially
this seems OK, but it can cause problems in several areas. First, it dousn't
spot things like missing multiples of pi in electrical formula (a fairly common
mistake), as the need for them is a function of the measurement system chosen
they seem sort of dimensional. Second, missing out 'cosmological' constants
(eg Plank's constant).  Third, things like revs (as in revs per second) and
counts (as in counts per second) are normally considered dimensionless -- but
should [usually?] balance in an equation. Fourth, some measurements don't have
very useful dimensions (eg one measure of viscosity is reported in seconds!).

Please post (or e-mail) any good references you find. As a general problem it 
seems quite difficult, although most problem domains would probably be well
served by a fairly simple solution using a few fundamental dimensions. 

Regards, Peter

salomon@ccu.umanitoba.ca (Dan Salomon) (01/29/91)

In article <1991Jan21.225221.5598@shell.shell.com> robison@brazil (Arch D. Robison) writes:
>I am looking for references on languages that incorporate ``units checking''
>into their type system.
>

I tried to reply by mail, but it bounced.

Here are my collection of references references (I would be interested
in any additions):

Narain Gehani
Units of Measure as a Data Attribute.
Computer  Languages, Vol 2, No 3
pp 93-111, Pergamon Press, Great Britain 1977

Paul N. Hilfinger
Abstraction Mechanisms and Language Design.
ACM Distinguished Dissertations
MIT Press, Cambridge, Mass. (1983)
(A section of this thesis shows how to use Ada's existing type
mechanism to incorporate units of measure into a program.)

R.T. House
A Proposal for an Extended Form of Type Checking.
The Computer Journal, Vol. 26, No. 4
pp 366-374, Wiley Heyden Ltd. (1983)

Michael Karr and David B. Loveman III
Incorporation of Units Into Programming Languages.
Communications of the ACM, Vol. 21, No. 5, pp 385-391 (May 1978)

R. Manner
Strong Typing and Physical Units.
ACM SIGPLAN Notices, Vol. 21, No. 3, pp 11-20 (Mar 1986)
-- 

Dan Salomon -- salomon@ccu.UManitoba.CA
               Dept. of Computer Science / University of Manitoba
	       Winnipeg, Manitoba, Canada  R3T 2N2 / (204) 275-6682

evan@hplabs.hpl.hp.com (Evan Kirshenbaum) (01/31/91)

In article <1991Jan28.210253.24818@ccu.umanitoba.ca> salomon@ccu.umanitoba.ca (Dan Salomon) writes:
#In article <1991Jan21.225221.5598@shell.shell.com> robison@brazil (Arch D. Robison) writes:
#>I am looking for references on languages that incorporate ``units checking''
#>into their type system.
#>
#
#I tried to reply by mail, but it bounced.

So did mine.

This is an area of interest of mine.  A dump of my database on the
subject follows.  Gehani seems to have the best ideas on the subject.
I would be extremely interested in pointers to any papers not on the list.

Evan Kirshenbaum
    HP Laboratories
    3500 Deer Creek Road, Building 26U
    Palo Alto, CA  94304

    kirshenbaum@hplabs.hp.com
    (415)857-7572

------------
A: baldwin:1987
t- Implementation of Physical Units
a-  Baldwin, Geoff
o-  Baldwin Information Processing
j-  Sigplan Notices
vn- 22 8
my- August 1987
p- 45-50
k-  Units
k-  Programming Languages
--
A: biedl:1977
t- An Extension of Programming Languages for Clerical Computation in
t- Science and Engineering with Special Reference to Pascal 
a-  Biedl, Albrecht
o-  Technishe Universitaet Berlin
j-  Sigplan Notices
my- April 1977
p- 31-33
k-  Programming Languages
k-  Units
--
A: cmelik:1988
t- Dimensional Analysis with C++
o-  Bell Laboratories
a-  Cmelik, Robert F.
a-  Gehani, Narain
j-  IEEE Software
my- May 1988
p- 21-27
k-  Units
k-  Programming Languages
k-  Object-Oriented Programming
--
A: dreiheller:1986
t- PHYSCAL
st- Prgramming Pascal with Physical Units
o-  Universitat Erlangen-Nurnberg [Universit\:at Erlangen N\:urnberg]
a-  Dreiheller, A.
a-  Moerschbacher, M.
a-  Mohr, B.
j-  Sigplan Notices
vn- 21 12
my- December 1986
p- 114-123
k-  Units
--
TR: gehani:1976
t- Units of Measure
st- A New Data Attribute
o-  State University of New York at Buffalo
a-  Gehani, Narain
my- March 1976
rn- 106
-Practice and Experience
vn- 15 6
my- June 1985
p- 555-569
k-  Units
k-  Programming Languages
--
A: grosberg:1988
t- Object-Oriented Dimensional Units
a-  Grosberg, John A.
o-  Motorola Corp.
j-  Dr. Dobb's Journal
my- September 1988
p- 52-62, 94-99
k-  Units
k-  Object-Oriented Programming
--
A: hilfinger:1988
t- An Ada Package for Dimensional Analysis
a-  Hilfinger, Paul N.
o-  University of California, Berkeley
j-  Transactions on Programming Languages and Systems
vn- 10 2
my- April 1988
p- 189-203
k-  Units
--
A: karr:1978
t- Incorporation of Units into Programming Languages
o-  Massachusetts Computer Associates
a-  Karr, Michael
a-  Loveman, David B., III
j-  Communications of the ACM
vn- 21 5
my- May 1978
p- 385-391
k-  Units
k-  Programming Languages
--
A: okeefe:1985
t- Alternatives to Keyword Parameters
a-  O'Keefe, Richard A. 
o-  University of Edinburgh
j-  Sigplan Notices
vn- 20 6
my- June 1985
p- 26-32
k-  Programming Languages
k-  Data Types
k-  Units
--


Evan Kirshenbaum
    HP Laboratories
    3500 Deer Creek Road, Building 26U
    Palo Alto, CA  94304

    kirshenbaum@hplabs.hp.com
    (415)857-7572

pgh@stl.stc.co.uk (P.G.Hamer) (02/12/91)

Another reference that might be of interest

Qualitative Physics Using Dimensional Analysis
R.Bhaskar & A.Nigam
(Journal of) Artificial Intelligence
Sept 1990, vol 45 numbers 1-2
pp73-111

Regards, Peter