Presentation is loading. Please wait.

Presentation is loading. Please wait.

Slides 04 1 Deducibility in TA λ Definition (2A9) Let  be a type-context. If there is a TA -deduction of a formula  ' ↦ M:  for some  '   we shall.

Similar presentations


Presentation on theme: "Slides 04 1 Deducibility in TA λ Definition (2A9) Let  be a type-context. If there is a TA -deduction of a formula  ' ↦ M:  for some  '   we shall."— Presentation transcript:

1 Slides 04 1 Deducibility in TA λ Definition (2A9) Let  be a type-context. If there is a TA -deduction of a formula  ' ↦ M:  for some  '   we shall say  ⊢ M: . In the special case  =  we shall write ⊢ M:  which can be read as "M has type  in TA " or "  is a type of M in TA ".

2 Slides 04 2 "↦" and "⊢" are different! "↦" is part of the language of TA and it serves merely to separate two parts of a formula. But "⊢" is part of the meta-language in which TA is described, and it asserts the existence of a TA -deduction; it is a deducibility symbol in Hindley's book.

3 Slides 04 3 Consider these two statements: 1.the formula  ↦ M:  is deducible 2.  ⊢ M:  Statement (2) has the weakening property, as in Lemma 2A9.1, but Statement (1) does not. The rules of TA have been formulated so that if Statement (1) holds then the subjects of  coincide exactly with the free variables of M, and we can not modify a deduction of  ↦ M:  to make a deduction of  + ↦ M:  if  +  . See Lemma (2A10) and Lemma (2A11).

4 Slides 04 4 Lemma (2A9.1: Weakening)  ⊢ M: ,  +     + ⊢ M: . Lemma (2A10) If  ↦ M:  is deducible in TA then Subjects(  ) = FV(M). Lemma (2A11) i.  ⊢ M:  iff Subjects(  )  FV(M) and there exists a TA -deduction of the formula  ↾M ↦ M: . ii.(∃  )(  ⊢ M:  )  (∃  ){  is an M-context and  ⊢ M:  }. iii.For closed terms M, (∃  )(  ⊢ M:  )  ⊢ M: .

5 Slides 04 5 the subject-construction theorem One very important property of deductions in TA is that the tree-structure of a deduction of  ↦ M:  follows the tree-structure of M exactly. Example: Consider again the deduction of a type-assignment for B  xyz  x(yz) in Slide 03.23. If all but the subject is erased from each formula in this deduction, the result is the following tree:

6 Slides 04 6 zy xyz x(yz) z  x(yz) yz  x(yz) xyz  x(yz)

7 Slides 04 7 Subject-construction Theorem (2B2) Let  be a TA -deduction of a formula  ↦ M: . i.If we remove from each formula in  everything except its subject,  changes to a tree of terms which is exactly the construction-tree for M. ii.If M is an atom, say M  x, then  = {x:  } and  contains only one formula, namely the axiom x:  ↦ x: . iii.If M  PQ the last step in  must be an application of (  E) to two formulas with the form  ↾P ↦ P: ,  ↾Q ↦ Q:  for some . iv.If M  x.P then  must have the form  ; further, if x  FV(P) the last step in  must be an application of (  I) main to , x:  ↦ P: , and if x  FV(P) the last step in  must be an application of (  I) vac to  ↦ P: .

8 Slides 04 8 In general, deductions are not unique. Given M, let  be a deduction of  ↦ M: . By the subject-construction theorem the structure of M determines both the tree- structure of  and the terms at all the nodes in . But this does not mean that the whole of  is completely determined by its conclusion, because there is some freedom of choice of the types assigned to terms at non-bottom nodes in .

9 Slides 04 9 Example: The type  in the following deduction can be arbitrary, so this deduction is not unique. y:a ↦ y:a  (  I) ↦ ( y  y):a  a z:  ↦ z:   (  I)  (  I) ↦ ( xy  y):(  )  a  a ↦ ( z  z):   (  E) ↦ ( xy  y)( z  z):a  a

10 Slides 04 10 Uniqueness of deductions for nf's Lemma (2B3) Let M be a  -nf and  a TA -deduction of  ↦ M: . Then i.every type in  has an occurrence in  or in a type in , ii.  is unique, i.e. if  ' is also a deduction of  ↦ M:  then  '  .

11 Slides 04 11 subject reduction and expansion Besides avoiding logical paradoxes another main purpose of type-theories is to avoid errors of mismatching in programming. If a term P has a type , in some sense P is "safe". If P represents a stage in some computation which continues by βη-reducing P, we want to know that all later stages in the computation are just as safe as P.

12 Slides 04 12 Subject-reduction Theorem (2C1) If  ⊢ P:  and P ⊳ βη Q then  ⊢ Q: . Example: ↦ ( xy  y)( z  z):a  a ↦ ( y  y):a  a P  ( xy  y)( z  z), Q  ( y  y)

13 Slides 04 13 Definition (1D5) A β-contraction ( x  M)N ⊳ 1β [N/x]M is said to cancel N iff x does not occur free in M; it is said to duplicate N iff x has at least two free occurrences in M. A β-reduction is non-duplicating iff none of its contractions duplicates; it is non-cancelling iff none cancels.

14 Slides 04 14 Subject-expansion Theorem (2C2) If  ⊢ Q:  and P ⊳ β Q by non-duplicating and non-cancelling contractions, then  ⊢ P: .

15 Slides 04 15 Example (1): P ⊳ 1β Q by a cancelling contraction and Q has a type but P has no type: P  ( uv  v)( x  xx), Q  ( v  v). We have seen that ⊢ Q:a  a. But there is no TA -deduction for ↦ P: , because such a deduction would have to contain a deduction of ↦ ( x  xx):  for some  which is impossible.

16 Slides 04 16 Example (2): P ⊳ 1β Q by a duplicating contraction and Q has a type but P has no type: P  ( x  xx)I, Q  II, I  ( y  y). We have seen that ⊢ Q:a  a. But P has no type because x  xx has none.

17 Slides 04 17 Example (3): P ⊳ 1β Q by a cancelling contraction, P and Q both have types, but Q has a more general type than P: P  xyz  ( u  y)(xz), Q  xyz  y ⊢ P:(c  d)  b  c  b ⊢ Q:a  b  c  b

18 Slides 04 18 Definition (2C3) If M is closed, we define Types(M) to be the set of all  such that ⊢ M: . We see later that Types(M) is either empty or infinite. Lemma (2C3.1) Let P be closed. Then i.P ⊳ β Q  Types(P)  Types(Q), ii.if P ⊳ β Q by a non-cancelling and non- duplicating reduction, then Types(P) = Types(Q).

19 Slides 04 19 conversion-invariance in TA ? not always Examples in slides 15, 16, and 17 show that M = β N  Types(M) = Types(N) is not always true. In other words, Types(M) is not invariant under conversion.

20 Slides 04 20 Typable Terms TA divides the -terms into two complementary classes: those which can receive types, such as xyz  x(yz), and those which cannot, such as x  xx. Definition (2D1) A term M is called TA -typable iff there exist  and  such that  ⊢ M: .

21 Slides 04 21 Lemma (2D2) The class of all TA - typable terms is closed under the following operations: i.taking subterms (i.e. all subterms of a typable term are typable); ii.βη-reduction; iii.non-cancelling and non-duplicating β- expansion; iv. -abstraction (i.e. if M is typable so is x  M).

22 Slides 04 22 Theorem (2D3) The class of all TA - typable terms is decidable; that is, there is an algorithm which decides whether a given term is typable in TA. The principal-type algorithm, to be learned next, is such an algorithm.


Download ppt "Slides 04 1 Deducibility in TA λ Definition (2A9) Let  be a type-context. If there is a TA -deduction of a formula  ' ↦ M:  for some  '   we shall."

Similar presentations


Ads by Google