+ All Categories
Home > Documents > Slides 04 1 Deducibility in TA λ Definition (2A9) Let be a type-context. If there is a TA...

Slides 04 1 Deducibility in TA λ Definition (2A9) Let be a type-context. If there is a TA...

Date post: 22-Dec-2015
Category:
View: 214 times
Download: 0 times
Share this document with a friend
22
Slides 04 Slides 04 1 Deducibility in TA 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 ".
Transcript

Slides 04Slides 0411

Deducibility in TADeducibility 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".

Slides 04Slides 0422

"↦" and "⊢" are different!"↦" 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.

Slides 04Slides 0433

• Consider these two statements:1. the formula ↦ M: is deducible2. ⊢ 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).

Slides 04Slides 0444

• Lemma (2A9.1: Weakening) ⊢ M:, + + ⊢ M:.

• Lemma (2A10) If ↦ M: is deducible in TA then Subjects() = FV(M).

• Lemma (2A11) ⊢ M: iff Subjects() FV(M) and there

exists a TA-deduction of the formula ↾M ↦ M:.

(∃)( ⊢ M:) (∃){ is an M-context and ⊢ M:}.

For closed terms M, (∃)( ⊢ M:) ⊢ M:.

Slides 04Slides 0455

the subject-construction the subject-construction theoremtheorem

• 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 xyzx(yz) in Slide 03.23. If all but the subject is erased from each formula in this deduction, the result is the following tree:

Slides 04Slides 0466

zy

x yz

x(yz)

zx(yz)

yzx(yz)

xyzx(yz)

Slides 04Slides 0477

• 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 .

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:.

Slides 04Slides 0488

• 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 .

Slides 04Slides 0499

• Example: The type in the following deduction can be arbitrary, so this deduction is not unique.

y:a ↦ y:a (I)

↦ (yy):aa z: ↦ z: (I) (I)

↦ (xyy):()aa ↦ (zz): (E)

↦ (xyy)(zz):aa

Slides 04Slides 041010

Uniqueness of deductions for Uniqueness of deductions for nf'snf'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 ' .

Slides 04Slides 041111

subject reduction and subject reduction and expansionexpansion

• 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.

Slides 04Slides 041212

• Subject-reduction Theorem (2C1)If ⊢ P: and P ⊳βη Q then ⊢ Q:.

• Example:↦ (xyy)(zz):aa↦ (yy):aa

P (xyy)(zz), Q (yy)

Slides 04Slides 041313

• Definition (1D5) A β-contraction (xM)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.

Slides 04Slides 041414

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

Slides 04Slides 041515

• Example (1): P ⊳1β Q by a cancelling contraction and Q has a type but P has no type:

P (uvv)(xxx), Q (vv).

We have seen that ⊢ Q:aa. But there is no TA-deduction for ↦ P:, because such a deduction would have to contain a deduction of ↦ (xxx): for some which is impossible.

Slides 04Slides 041616

• Example (2): P ⊳1β Q by a duplicating contraction and Q has a type but P has no type:

P (xxx)I, Q II, I (yy).

We have seen that ⊢ Q:aa. But P has no type because xxx has none.

Slides 04Slides 041717

• 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(uy)(xz), Q xyzy

⊢ P:(cd)bcb

⊢ Q:abcb

Slides 04Slides 041818

• 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).

Slides 04Slides 041919

conversion-invariance in conversion-invariance in TA TA? ? not alwaysnot 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.

Slides 04Slides 042020

Typable TermsTypable Terms

• TA divides the -terms into two complementary classes: those which can receive types, such as xyzx(yz), and those which cannot, such as xxx.

• Definition (2D1) A term M is called TA-typable iff there exist and such that ⊢ M:.

Slides 04Slides 042121

• 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

xM).

Slides 04Slides 042222

• 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.


Recommended