Efficient Inference of Object Types

Efficient Inference of Object Types

Information and Computation  IC2582 information and computation 126, 103104 (1996) article no. 0038 ERRATUM Volume 123, Number 2 (1995), in the art...

130KB Sizes 0 Downloads 50 Views

Information and Computation  IC2582 information and computation 126, 103104 (1996) article no. 0038

ERRATUM Volume 123, Number 2 (1995), in the article ``Efficient Inference of Object Types'' by Jens Palsberg, pages 198209: On page 203, after the proof of Lemma 4.2, the following lemma and example were missing: Lemma 4.3. Solvability of AC-systems is logspacereducible to the type inference problem. Proof. Let C be an AC-system. Recall that for an inequality WW$ in C, both W and W$ are of the forms V or [l i : V i i # 1 .. n ], where V, V 1 , ..., V n are variables. Define a C =[ l V lR m R , lj

l WW$

= "(x)(x . l V ) for each variable V in C = "(x)[l i ="( y)(x .l Vi ) i # 1 .. n ] for each R in C of the form [l i : V i i # 1 .. n ] = "(x)((x . l Vj o "( y)(x . l R . l j ) . l R ) for each R in C of the form [l i : V i i # 1 .. n ] and for each j # 1 ..n = "(x)((x . l W$ o "( y)(x . l W )) . l W ) for each inequality WW$ in C

L(V) = M(x) a l V

v Property 1. If V is a variable in C, then M(x) a l V is defined. v Property 2. For each R in C of the form [l i : V i i # 1 .. n ], we have M(x) a l R =[l i : (M(x) a l Vi ) i # 1 .. n ].

Notice that a C can be generated in log space. We first prove that if C is solvable then a C is typable. Suppose C has solution L. Define

l WW$

We will proceed by first showing the two properties and then showing that C has solution L. To see Property 1, notice that in the body of the method l V we have the expression x . l V . Since M is a solution of C(a C ), we have from the rules (8) and (11) that M satisfies

: L(V ) : L(R) : L(R)

for each variable V in C for each R in C of the form [l i : V i i # 1 .. n ] for each R in C of the form [l i : V i i # 1 .. n ] and for each j # 1 .. n : L(W ) for each inequality WW$ in C

x x [l V : ( x. l V ) ]. We conclude that M(x) a l V =M(( x .l V ) ) is defined. To see Property 2, let R be an occurrence in C of the form [l i : V i i # 1 .. n ]. In the body of the method l R have the expression [l i ="( y)(x . l Vi ) i # 1 .. n ]. Since M is a solution of C(a C ), we have from the rules (10), (9), (8), (11), and (12) that M satisfies

].

Define also d = [ lV lR m R , lj

l WW$

for each variable V in C.

The definition is justified by Property 1 below.

].

A = [ lV lR m R . lj

Clearly, d is an annotated version of a C and < & | d : A is derivable. We then prove that if a C is typable, then C is solvable. Suppose a C is typable. From Lemma 4.2 we get a solution M of C(a C ). Notice that each method in a C binds a variable x. Each of these variables corresponds to a distinct type variable in C(a C ). Since M is a solution of C(a C ), and C(a C ) contains constraints of the form x=[ . . . ] for each method in a C (from rule (10)), all those type variables are mapped by M to the same type. Thus, we can think of all the bound variables in a C as being related to the same type variable, which we will write as x. Define

= "(x : A)(x . l V ) for each variable V in C = "(x : A)[l i ="( y :L(R))(x . l Vi ) i # 1 .. n ] for each R in C of the form [l i : V i i # 1 .. n ] = "(x: A)((x . l Vj o "( y : A)(x. l R . l j )) . l R ) for each R in C of the form [l i : V i i # 1 .. n ] and for each j # 1 .. n = "(x: A)((x . l W$ o "( y : A)(x . l W )) . l W ) for each inequality WW$ in C

x = [ . . . l R : [l i ="( y)(x . l Vi ) i # 1 .. n ] . .. ] (17) [l i : x . l Vi

i # 1 .. n

]  [l i ="( y)(x . l Vi ) i # 1 .. n ]

x x  [l Vi : ( x . l Vi )

i # 1 .. n

]

(18)

for each i # 1.. n (19)

( x . l Vi )  x . l Vi

].

for each i # 1.. n.

(20)

103 Copyright  1996 by Academic Press, Inc. All rights of reproduction in any form reserved.

File: 643J 258201 . By:CV . Date:04:06:96 . Time:16:17 LOP8M. V8.0. Page 01:01 Codes: 5314 Signs: 3090 . Length: 60 pic 11 pts, 257 mm

104

ERRATUM

Thus, for each i # 1 .. n, M(x) a l Vi = M((x . l Vi ) )

from (19) from (20)

 M( x . l Vi) = M( [l i ="( y)(x .l Vi )

i # 1 .. n

] ) a l i

= M(x) a l R a l i

from (18)

We will now show that C has solution L. Consider an inequality WW$ in C. The body of the method l WW$ contains the expression x$ . l W$ o "( y)(x . l W ), where we, for clarity, have written the first occurrence of x as x$. Since M is a solution of C(a C ), we have from rules (8), (15), (8), (11), and (12) that M satisfies

from (17).

For each j # 1 .. n, in the body of the method m R , lj , we have the expression x$ .l Vj o "( y)(x . l R . l j ) where we, for clarity, have written the first occurrence of x as x$. Since M is a solution of C(a C ), we have from the rules (8), (15), (8), (11), (12), (11), and (12) that M satisfies

x x$  [l W$ : x . l W ]

(26)

x x  [l W : ( x .l W ) ]

(27)

( x . l W )  x .l W.

(28)

We conclude that

x x$  [l Vj : x . l R . l j ]

(21)

x x  [l R : ( x . l R ) ]

(22)

= M((x . l W ) )

from (27)

( x . l R )  x . l R

(23)

 M( x . l W)

from (28)

(24)

= M(x) a l W$

from (26)

(25)

= L(W$)

from Property 3. K

x . l R  [l j : ( x. l R . l j ) ] ( x. l R . l j )  x . l R .l j. Thus,

L(W) = M(x) a l W

from Property 3

from (22)

For example, let C be the AC-system consisting of the single constraint

= M( x . l R ) a l j

from (23)

V[l : W ].

= M(( x . l R . l j ) )

from (24)

 M( x . l R . l j)

from (25)

= M(x) a l Vj

from (21).

M(x) a l R a l j = M(( x . l R ) ) a l j

We then get a C =[ l V ="(x)(x. l V ) l W ="(x)(x . l W )

We conclude that for each i # 1 .. n, M(x) a l R a l i = M(x) a l Vi . From this, (17), and (18) we get Property 2. We can summarize Properties 1 and 2 as follows. v Property 3. If W is a left-hand side or a right-hand side of an inequality in C, then M(x) a l W is defined and L(W )=M(x) a l W .

Printed in Belgium

File: 643J 258202 . By:CV . Date:04:06:96 . Time:16:13 LOP8M. V8.0. Page 01:01 Codes: 3065 Signs: 1657 . Length: 56 pic 0 pts, 236 mm

l [l : W ] ="(x)[l="( y)(x . l W )] m [l : W ] , l ="(x)((x . l o "( y)(x . l [l : W ] . l)). l [l : W ] ) l V [l : W ] ="(x)((x . l [l : W ] o "( y)(x . l V )) . l V ) ].