A.10 Lemma

 < Free Open Study > 



A.10 Lemma

If L <: S and L <: T, then S T = M for some M.

Proof: By induction on the size of S (or, equivalently, T), with a case analysis on the shapes of S and T. If either S or T is Top, then one of the first two cases in the definition applies, and the result is either T or S, respectively. The cases where S and T have different shapes cannot occur, since the inversion lemma for the subtype relation (15.3.2) would make inconsistent demands on the shape of L; for example, if S is an arrow, then so must L be, but if T is a record, then so is L[1] So we have three cases left.

If both S and T are Bool, then the third case in the definition applies and we are finished.

Suppose instead that S = S1S2 and T = T1T2. The totality of the V algorithm tells us that the first recursive call returns some type J1. Also, by the inversion lemma, L must have the form L1L2 with L2 <: S2 and L2 <: T2. That is, L2 is a common lower bound of S2 and T2, so the induction hypothesis applies and tells us that S2 L2 does not fail, but rather returns a type M2. So S T = J1M2.

Finally, suppose that S = {kj:Sj jÎl..m} and T = {li:Ti iÎi..n}. By the inversion lemma, L must be a record type whose labels include all the labels that occur in either of S and T. Moreover, for each label in both S and T, the inversion lemma tells us that the corresponding field in L is a common subtype of the fields in S and T. This assures us that the recursive calls to the algorithm for the common labels all succeed.

Now let us verify that these definitions calculate joins and meets. The argument is divided into two parts: Proposition A.11 shows that the calculated meet is a lower bound of S and T and the join is an upper bound; Proposition A.12 shows that the calculated meet is greater than every common lower bound of S and T and the join less than every common upper bound.

[1]Strictly speaking, Lemma 15.3.2 did not deal with Bool. The additional case for Bool just says that the only subtype of Bool is Bool itself.



 < Free Open Study > 



Types and Programming Languages
Types and Programming Languages
ISBN: 0262162091
EAN: 2147483647
Year: 2002
Pages: 262

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net