Presentation is loading. Please wait.

Presentation is loading. Please wait.

Slides 09 1 Counting the Inhabitants of a Type Given a type , how many closed -terms in  - normal form can receive the type  in TA ? There exists an.

Similar presentations


Presentation on theme: "Slides 09 1 Counting the Inhabitants of a Type Given a type , how many closed -terms in  - normal form can receive the type  in TA ? There exists an."— Presentation transcript:

1 Slides 09 1 Counting the Inhabitants of a Type Given a type , how many closed -terms in  - normal form can receive the type  in TA ? There exists an algorithm (Ben-Yelles 1979, Hirokawa 1993) that will decide in a finite number of steps whether the number of closed  -normal forms that receive the type  is finite or infinite, will compute this number in the finite case, and will list all the relevant terms in both cases.

2 Slides 09 2 Typed Terms Space-hungry deduction-tree diagrams can be replaced by compact typed terms. We shall define a system of typed terms isomorphic to TA -deductions: for each , a set TT(  ) of typed terms will be defined that will encode deductions of formulae of the form  - ↦ M:  (  -   ).

3 Slides 09 3 Definition (5A1) Given a type-context , the set TT(  ) of typed terms relative to  is a set of expressions defined as follows: (i)if  contains x:  then the expression x  is in TT(  ) and is called a typed variable; (ii)if  1   2 is consistent and M   TT(  1 ) and N   TT(  2 ), then (M  N  )   TT(  1   2 ); (iii)if  is consistent with {x:  } and M   TT(  ), then ( x   M  )   TT(  - x). If M  is a typed term (relative to some  ),  is called the type of M .

4 Slides 09 4 Example: ( x a  x a ) a  a  TT(∅) x a  TT(∅) x a  TT({x:a}) (x (a  a)  b ( x a  x a ) a  a ) b  TT({x:(a  a)  b}) (x a  b x a ) b is not a typed term.

5 Slides 09 5 Definition (5A2) The type-erasure M  ' of M  is the untyped term obtained by erasing all types from M . M  ' is the subject of the conclusion of the TA -deduction that M  encodes.

6 Slides 09 6 Inhabitants Definition (8A1) An untyped inhabitant of  is a closed term M such that ⊢ M: . A typed inhabitant of  is a closed typed term M . The sets of all typed and untyped inhabitants of  will be called Habs t (  ) and Habs u (  ) respectively. A  -normal inhabitant of a type is an inhabitant in  -nf.

7 Slides 09 7 The sets of all typed and untyped normal inhabitants of  will be called Nhabs t (  ) and Nhabs u (  ) respectively. A  -normal inhabitant of a type is an inhabitant in  -nf. The sets of all typed and untyped  - normal inhabitants of  will be called Nhabs  (  ). A type with at least one inhabitant is said to be inhabited.

8 Slides 09 8 Our aim is to count  -normal inhabitants. The following lemma shows that it does not matter whether we count typed or untyped inhabitants. Lemma (8A2) If M   Nhabs t (  ) then M  '  Nhabs u (  ); further, the type-erasing mapping is a one-to-one correspondence between the typed and the untyped  - normal inhabitants of  (modulo   ). The same holds for  -normal inhabitants.

9 Slides 09 9 Definition (8A3) The number (0, 1, 2,... or  ) of members of a set S, counted modulo   if S is a set of -terms, is called the cardinality of S or #(S). For #(Nhabs(  )) and #(Nhabs  (  )) we usually say just #(  ) and #  (  ).

10 Slides 09 10 Definition (8A4) A distinction will be made between counting and enumerating a set S of  - normal inhabitants of a type  : (i)to count S means to compute #(S), the cardinality of S, with a finite number of steps (even when #(S) =  ); (ii)to enumerate or list S means to enumerate S in the usual recursion-theoretic sense, i.e. to output a sequence consisting of all the members of S, continuing forever if S is infinite.

11 Slides 09 11 Examples: 1.The type   ((a  b)  a)  a has no inhabitants. 2.The type   (a  b  c)  (a  b)  a  c has exactly one normal inhabitant: xyz  xz(yz) 3.The type   a  a  a has two normal inhabitants: xy  x and xy  y

12 Slides 09 12 The aim of Ben-Yelles' algorithm is to count inhabitants as well as enumerate them. Mere enumeration would be easy: we could simply list all closed typed  -nf's in some standard order and for each one we decide whether it is an inhabitant of the given  by looking at its type. But counting is not so easy: we must find a way of enumerating Nhabs t (  ) which will tell us after only a finite number of steps whether the enumeration will continue forever or not. The strategy of counting will be using the concepts of long  -nf and depth of a term.

13 Slides 09 13 Lemma (8A5: Structure of a typed  -nf) Let  be a type- context. Every  -nf M   TT(  ) can be expressed uniquely in the form

14 Slides 09 14 Definition (8A6) The depth of a typed or untyped  -nf is defined as follows: Examples: Depth( uv.uxvx) = 1 + Max(Depth(x),Depth(v),Depth(x)) = 1 + 0 = 1. Depth(z( w  y)) = 1 + Depth( w  y) = 1 + 0 = 1. Depth( x  x(z( w  y))( uv.uxvx)) = 2. Lemma (8A6.2) Depth(M  ) = Depth(M  ') < |M  '|.

15 Slides 09 15 Definition (8A7: Long  -nf) A typed  -nf M  is called long or maximal iff every variable-occurrence z in M  is followed by the longest sequence of arguments allowed by its type, i.e. iff each component with the form (zP 1...P n ) (n  0) that is not in a function position has atomic type. An untyped  -nf M is called long relative to a type  iff it is the type-erasure of a typed long  -nf M . The sets of all long normal inhabitants of  (typed or untyped) will both be called Long(  ).

16 Slides 09 16 Example: Let   ((a  b)  c)  (a  b)  c. Then the following normal inhabitant of  is not long: M   x (a  b)  c y a  b  x (a  b)  c y a  b because y a  b has a type which needs an argument but none is provided. On the other hand, the following one is long: N   x (a  b)  c y a  b  x (a  b)  c ( z a  y a  b z a ).

17 Slides 09 17 Definition (8A7.2) The sets of all long normal inhabitants of  (typed or untyped) with depth  d will both be called Long( ,d). The following lemma indicates that if we can enumerate long normal inhabitants, the others will be obtainable from these long ones by  -reduction. Lemma (8A8) Every normal inhabitant of  can be  - expanded to a long normal inhabitant of . And this long inhabitant is unique (modulo   ); i.e. {M , N   Long(  ) and M  =  N  }  M    N . Proof:

18 Slides 09 18 Let P   Nhabs(  ). First we must  -expand P  to a term P  +  Long(  ). Then we must show that P  + is unique, i.e. that (1)M   Long(  ) and M  ⊳  P   M    P  +. Suppose P  contains a short component, i.e. a component with the form (yQ 1...Q n ) , where n  0, that is not in function position and whose type  is composite, say    1 ...  k  a(k  1). We choose distinct new variables z 1,..., z k not occurring in P  ' and replace this component by This replacement is an  -expansion and its result is still a  - nf. We make similar replacements until there are no short components left in P . Call the result P  +. This term satisfies (1), by induction on |P  |.

19 Slides 09 19 Definition (8A9) The set of all terms obtained by  - reducing M  is called the  -family of M , or {M  } . Lemma (8A10) (i)The  -families of the long typed normal inhabitants of  partition Nhabs(  ) into non-overlapping finite subsets, each  -family containing just one long member and just one  -nf. (ii)#(  ) is finite or infinite or zero according as #  (  ) is finite or infinite or zero. (iii)#  (  ) = #(Long(  )).

20 Slides 09 20 Definition (8A11: Principal Inhabitants) An untyped inhabitant M of  is called principal iff  is a principal type of M. A typed inhabitant M  of  is called principal iff the deduction of ↦ M  ':  that it encodes is principal. The sets of all principal inhabitants of  (typed or untyped) will both be called Princ(  ). The sets of all principal  -normal inhabitants of  (typed or untyped) will both be called Nprinc(  ).

21 Slides 09 21 Lemma (8A11.1) M  is a typed principal  - normal inhabitant of  iff M  ' is an untyped principal  -normal inhabitant of . Lemma (8A11.2) Let M  + be the unique member of Long(  ) to which M   -expands. Then M   Nprinc(  )  M  +  Nprinc(  ). Proof: The  -expansion in the proof of (8A8) preserves principality because of the way the types given to z 1,..., z k are determined by the type  of the component that is replaced.

22 Slides 09 22 Example (8A12) Three sets of  -nf's have been defined, namely: Nhabs(  ), Long(  ), and Nprinc(  ). The sets of all  - nf's in these sets are called respectively: Nhabs  (  ), Long  (  ), and Nprinc  (  ). The relations between these six sets can be demonstrated with the type   (a  a  a)  a  a  a. For this type, the six sets are all distinct. (i) x a  a  a  x a  a  a  Nhabs  – (Long  Nprinc). This term is a  -nf, but it is not long. It fails to encode a principal deduction for x  x because the PT( x  x) is not the given  but a  a. (ii) x a  a  a y a  (xy) a  a  Nhabs – Nhabs  – (Long  Nprinc). This term is obtained by  -expanding the term in (i). (iii) x a  a  a y a z a  (xyz) a  Long – Nhabs  – Nprinc. This term is obtained by  -expanding the term in (i) until it becomes long.

23 Slides 09 23 (iv) x a  a  a y a  (x(xyy)) a  a  Nprinc  – Long . This term is principal but it is not long because its second x from the right has only one argument. (v) x a  a  a y a z a  (x(xyy)z) a  Nprinc  Long – Nhabs . This term is obtained from (iv) by  -expansion; both occurrences of x now have two arguments. (vi) x a  a  a y a z a  (xz(xyy)) a  Nprinc   Long . This term is like (v) but z and xyy have been reversed to make it an  -nf. (vii) x a  a  a y a z a  (xzy) a  Long  – Nprinc . This term is long. However, its PT is not the given  but (a  b  c)  b  a  c.

24 Slides 09 24 Lemma (8B1) Every type  can be expressed uniquely in the following form, where m  0 and e is an atom:    1 ...  m  e. The occurrences of  1,...,  m and e above are called the premises and conclusion (or tail) of  respectively, and m is called the arity of . Two type-occurrences are called isomorphic iff they are occurrences of the same type. Iff the tail- components of  and  are isomorphic, we say Tail(  ) ≅ Tail(  ).

25 Slides 09 25 The core of the inhabitant counting algorithm is a search algorithm which will seek long normal inhabitants of a type  with increasing depths d = 0, 1, 2,.... The strategy of this search algorithm depends on the following facts about the structure of long typed terms.

26 Slides 09 26 Remark (8B2) Let  be any type; say  has the form    1 ...  m  e(m  0, e an atom) and let M  be any  -nf with type . By (8A5), M  has the form If M  is long, then (i)k = m,(ii)  *  e, (iii)the types of x 1,..., x m coincide with the premises of , (iv)the tail of the type of is isomorphic to that of , (v)if M  is closed then m  1 and is an x i (1  i  m) and  i   1 ...  n  e.

27 Slides 09 27 Example (8B3: a type  with #(  ) = 1) The following type:   (a  b  c)  (a  b)  a  c has exactly one normal inhabitant (which is also both long and principal): S   x a  b  c y a  b z a  xz(yz). Proof: We start by showing that Long(  ) = {S  }. Step 1. By Remark (8B2), for the structure of  we have m = 3, e  c,  1  a  b  c,  2  a  b, and  3  a. Hence any M   Long(  ) must have just three initial abstracted variables, say

28 Slides 09 28 By (8B2(iv)), must be one of x 1, x 2, x 3 whose type's tail is isomorphic to that of . The tail of  is c, and the only  i whose tail is an occurrence of c is  1, so must be x 1. Since  1 has two premises, x 1 must be followed by exactly two arguments. Hence M must have the form Step 2. We search for suitable U a and V b. The type of U a is an atom so U a cannot be an abstraction. Thus U a  (wP 1...P r ) a (r  0) where w is an x i whose type's tail is isomorphic to the tail of the type of U. This tail is an occurrence of a, so the only possibility is w  x 3. Since the type of x 3 has no premises we have r = 0 and hence U a  (x 3 ) a.

29 Slides 09 29 Next we search for V b. Since b is an atom, V b cannot be an abstraction and its head must be an x i whose type's tail is an occurrence of b. The only possibility is x 2, and the type of x 2 allows only one argument, so Step 3. We search for W a. Just as for U a, the only possibility is W a  (x 3 ) a. Conclusion. Modulo   there is at most one term in Long(  ), namely Note that S  is actually in Long(  ) and is  -irreducible. Hence, by (8A10), Nhabs(  ) = {S  }.

30 Slides 09 30 Also, by the PT algorithm,  is a principal type of S  ; hence, Nprinc(  ) = {S  }. Example (8B4: a type  with #(  ) = m) For each m  2 the following type  has exactly m normal inhabitants and all are long and non-principal:   a ...  a  a (m+1 a's). The normal inhabitants are the following m terms (called projectors or selectors): Proof:

31 Slides 09 31 By Remark (8B2), any M   Long(  ) must have the form But the types of x 1,..., x m have no premises, so n = 0. Hence Every such selector is in Long(  ) and  -irreducible. So by (8A10), Nhabs(  ) = Long(  ). Since m  2, by the PT algorithm, no selector is in Nprinc(  ); hence Nprinc(  ) = { }.

32 Slides 09 32 Example (8B5: types  with #(  ) = 0) (i)No atomic type has inhabitants. (ii)No skeletal type has inhabitants. Proof: (i)Every type with an inhabitant has a normal one, by WN (see next slide). But every type with a normal inhabitant has arity m  1, by (8B2(iii)). (ii)Let  be skeletal and let    1 ...  m  e (m  1). If  had inhabitants it would have at least one long normal one, by (8A8); and, by (8B2), this inhabitant would have the form x 1...x m  x i M 1...M n with x i having type  i and the tail of  i being an occurrence of e. But  is skeletal, so e cannot occur in any  i. Hence  has no inhabitants.

33 Slides 09 33 Weak Normalization (WN) Theorem (5C1) Every typed term P  has both a  -nf and a  -nf. Strong Normalization (SN) Theorem (5C2) Let P   TT(  ) for some  ; then, for  -reductions and for  -reductions, (i)all reductions of P  are finite, (ii)there is an algorithm which accepts P  as input and computes a number k(P  ) such that all reductions of P  have length  k(P  ).

34 Slides 09 34 Corollary (8B5.1) Intuitionistic implicational logic is consistent in the sense that not all formulas are provable. Proof: If an atomic formula e were provable it would be the type of a closed term, by (6B7), contradicting (8B5).

35 Slides 09 35 Example (8B6: Peirce's law) The type   ((a  b)  a)  a has no inhabitants. Proof: Suppose M   Long(  ). Then by (8B2), M  must have the form M   x (a  b)  a  U 1...U n (n  0). And  x, since M  is closed. Hence n = 1, since the type of x has only one premise. Thus M   x (a  b)  a  x (a  b)  a U a  b for some U a  b. Since a  b has just one premise, U a  b must have the form U a  b  y a  (wV 1...V r ) b (r  0).

36 Slides 09 36 Since M  is closed, w must be x or y. But w must have a type whose tail is an occurrence of b and neither x nor y has such a type, so no suitable U a  b exists. Thus Long(  ) = { } and hence Nhabs(  ) = { }, by (8A8), and hence Habs(  ) = { }.


Download ppt "Slides 09 1 Counting the Inhabitants of a Type Given a type , how many closed -terms in  - normal form can receive the type  in TA ? There exists an."

Similar presentations


Ads by Google