Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Asperti A.Categories,types,and structures.1991

.pdf
Скачиваний:
36
Добавлен:
23.08.2013
Размер:
1.68 Mб
Скачать

 

 

 

 

 

 

 

 

 

 

 

 

8. Formulae, Types, and Objects

 

 

 

 

 

 

D1:

 

 

 

 

 

 

 

 

 

 

 

 

 

D2:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Γ |- M: AB Γ1 |- N: A

 

 

 

 

 

Γ |- M: AB

 

 

 

 

Γ2, y: B |- P: C

 

 

_____________________

 

 

 

 

 

_____________________________

 

 

 

 

Γ, Γ1* |- [M/v1]N: A

 

 

 

 

 

 

 

 

Γ, Γ2*, y: B |- [M/v2]P: C

If v

1

(v

2

) is empty, and thus

Γ

1

= Γ

1

*

(Γ

2

 

= Γ

2

*), let

D (D

2

) be as follows:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1

 

 

 

 

 

 

 

 

D1:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

D2:

 

 

 

 

 

 

 

 

 

 

 

 

 

Γ1 |- N: A

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Γ2, y: B |- P: C

 

 

 

 

 

__________

 

 

 

 

 

 

 

 

 

 

 

 

 

____________

 

 

 

 

 

weakenings

 

 

 

 

 

 

 

 

 

 

 

 

 

weakenings

 

 

 

 

 

___________

 

 

 

 

 

 

 

 

 

 

 

 

 

_______________

 

 

 

 

 

Γ, Γ

* |- N: A

 

 

 

 

 

 

 

 

 

 

 

 

 

Γ, Γ

2

*, y: B |- P: C

 

 

 

 

 

 

1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

The grade of

D1 and D2

is the same as that of

D, namely

 

 

g(AB). Moreover, rankl(D1) =

rankl(D1) = rankl(D), and

rankr(D1) = rankr(D1) = rankr(D) - 1. Hence, by induction hypothesis,

there exist two derivations

D1'

and

D2'

respectively ending in the sequents

 

 

Γ, Γ * |- N : A

 

 

 

 

 

with N

 

β-normal form of [M/v

1

]N: A

 

 

 

 

1

1

 

 

 

 

 

 

 

 

 

1

 

 

 

 

 

 

 

 

 

 

 

 

Γ, Γ2*, y: B |- P1: C

 

 

 

 

with

P1

 

β-normal form of

 

[M/v2]P: C.

Let

w be the vector of variables in

Γ,

and let

w', w"

be two vectors of fresh variables of the

same length.

Let

Γ' = [w'/w]Γ,

Γ" =[w"/w]Γ be the sequences of assumptions obtained by

renaming the variables in

Γ. Let also N1' [w'/w]N1

and

P1' [w'/w]P1 be the results of the

same operation on the two terms N1 and P1.

 

 

 

 

 

 

 

 

 

 

Consider the derivation

D'

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Γ', Γ1* |- N1': A

 

Γ", Γ2*, y: B |- P1': C

 

 

 

 

 

 

 

 

 

 

_______________________________________

 

 

 

 

Γ |- M: AB

 

 

 

Γ', Γ1*, Γ", Γ2*, z: AB |- [z(N1')/y](P1'): C

 

 

 

 

_________________________________________________________

 

 

 

 

 

 

Γ, Γ', Γ1*, Γ", Γ2* |- [M/z][zN1'/y]P1': C.

 

 

The grade of

D'

is the same of

 

D, namely,

g(AB). Moreover,

rankl(D') = rankl(D), and

rankr(D') = 1,

since z: AB

is the only cut formula. We can apply again the induction hypothesis,

getting a mix-free derivation of the final sequent

 

 

 

 

 

 

 

 

 

 

 

 

Γ, Γ', Γ1*, Γ", Γ2* |-

P2: C

 

 

with

 

P2

β-normal form of [M/z][zN1'/y]P1'.

Identifying by means of contractions (and exchanges) the variables in

 

Γ, Γ', Γ", we get a mix-free

derivation of

Γ, Γ1*, Γ2* |-

P3: C , where

P3 is a β-normal form of

 

[w/w'][w/w"]P2.

Note now that:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

[w/w'][w/w"]P2

=

[w/w'][w/w"][M/z][zN1'/y]P1'

 

 

 

 

 

 

 

 

 

 

 

 

[M/z][z([w/w']N1')/y]([w/w"]P1')

 

 

 

184

8.Formulae, Types, and Objects

[M/z][zN1/y]P1

= [M/z][z([M/v1]N)/y]([M/v2]P)

[M/z][M/v1][M/v2][zN/y]P

[M/x][zN/y]P: C.

2.2.rankl(D) > 1 (and rankr(D) = 1)

This case is proved in the same way as is 2.1 above.

This completes the proof of lemma 8.4.4 and, hence, of the cut-elimination theorem. ♦

8.5 Categorical Semantics of Derivations

In this section we will study the categorical semantics of the intuitionistic proof theory developed in the last section. The main idea is that a formula A is interpreted as an object I(A) in a category C. A provable sequent B1,..., Bn |- A is then associated with a morphism f: I(B1) ... I(Bn)I(A), where : C×CC is a suitable bifunctor that gives meaning to the comma in the l.h.s. of the sequent. Since the comma is associative and commutative, is a symmetric tensor product. Moreover, we need some sort of projections for the weakening rule, and a diagonal map in the

contraction rule. Actually, all these morphisms, together with a few reasonable equations, turn into a categorical product.

Since C |- A B iff C, A |- B, it is natural to interpret the implication as the right adjoint to the functor .

Also the binary connective × is bifunctor of the category. In particular, the fact that C |- A×B iff (C |- A and C |- B) suggests that × should be interpreted as a categorical product. As a consequence and × coincide to within isomorphism, that is consistent with the well-known fact that the comma in the l.h.s. of a sequent has the same logical meaning of a conjunction. Anyway, since they are different concept, we prefer to maintain the distinction at the semantical level.

8.5.1 Definition A categorical model of the positive intuitionistic calculus is a pair (C,IAt), where C is a Cartesian closed category (possibly with two specified products and × ), and IAt is a map that takes every atomic formula to an object of C.

Notation In the rest of this chapter, we shall use the same symbols and × for indicating both the connectives of the calculus and the associated functors of the category: the intended meaning is clear from the context.

185

8. Formulae, Types, and Objects

The analysis of the cut-elimination theorem will provide a more convincing justification for the

previous notion of model. Now we concentrate on the interpretation.

I is extended to all the formulae in the following way: I(A) = IAt(A) if A is atomic

I(A C) = I(A) I(C)

I(A×C) = I(A)×I(C)

The categorical interpretation does not give meanings to sequents, but to derivations. Every derivation D whose final sequent is B1, . . . , Bn |- A is interpreted by a morphism

I(D) = f: I(B1) . . . I(Bn) I(A)

Before giving the details of the interpretation, we recall a few results about Cartesian closed categories, and fix the notation.

We call weak-lA,B: A B→B, weak-rA,B: A B→A the projections associated with the product, and fstA,B: A×B→B, sndA,B: A×B→A the projections associated with the product ×.

We have the natural isomorphisms assocA,B,C: (A B) C→ A (B C) and exchA,B: A B→B A, given by the symmetric monoidal structure associated with . Moreover, we have a diagonal map ∆A = <idA,idA>: A→A A and an the evaluation map evalA,C: (A C) A→C.

The interpretation is given by induction on the length of the derivation. We define it in a somewhat informal but suggestive (and concise) way, associating with every inference rule of the calculus in 8.3.4 a respective semantic rule. This will be enough as for the categorical meaning of the intuitionistic system in section 8.3.

8.5.2 Interpretation

 

(axiom)

idA : A → A

 

f: A (B C) → D

(associativity)

_________________________

 

f ° assocA,B,C: (A B) C → D

 

f: B A → C

(exchange)

___________________

 

f ° exchA,B: A B → C

 

f: B → C

(weakening)

_____________________

 

 

f ° weak-lA,B: A B → C

186

 

8. Formulae, Types, and Objects

 

f: (Α Α) B C

(contraction)

____________________

 

 

f ° A idB: A B C

 

f: B A g: Α D C

(cut)

______________________

 

g ° f idD : B D C

 

f: B Α → C

(, r) _____________

 

Λ(f): B A C

 

f: C → Α g: C B

(×, r)

__________________

 

 

<f,g>: C A×B

f: E A g: C D

(, l ) _____________________________

g ° evalA,C ° id f: (A C) E D

f: A C D

(×, l, 1) _________________________

f ° fstA,B idC: (A×B) C D

f:B C D

(×, l, 2) __________________________

f ° sndA,B idC: (A×B) C D.

8.6 The Cut-Elimination Theorem Revisited

In this section, we look at the cut elimination theorem from the categorical point of view. Our goal is to provide a more convincing justification of the categorical notion of model, not a further proof of cut-elimination. Indeed the notion of CCC imposes some identifications between derivations that are not evident at the logical level of the inference rules. The fact is that we are not interested in giving semantics to the provability relation among formulae, but more generally to the whole proof system, with its associated normalization procedures. The point is that the equalities, which define CCC's, reflect the identity of derivations up to normalization. In particular, we have the following result.

8.6.1 Theorem (The Cut-Elimination Theorem) Let D be a derivation of the sequent A |- B. Then there exists a cut-free derivation D' whose final sequent is A |- B, and such that in every model I(D) = I(D').

We do not prove the previous result, but instead analyze in detail some examples of derivations identified by the cut-elimination process. Our aim is to show that the Cartesian closed structure is imposed by this identification of proofs up to normalization. The examples are instrumental to this.

187

8.Formulae, Types, and Objects

8.6.2Example If in the following derivation the left upper sequent A |- A is an initial sequent, the cut is eliminated by taking the derivation of the right upper sequent

A |- A A |- B

____________________

A |- B

At the semantic level, we have the situation:

idA: A A f: A B

_____________________

f ° idA: A B

thus a model must satisfy the equation f ° idA = f . Analogously, when the right upper sequent is an axiom, we derive the equation idA ° f = f

8.6.3 Example Consider a derivation whose final part looks like

B |- C

________

D |- A A, B |- C

___________________

D, B |- C

the cut is eliminated in the following way:

B |- C

________

D, B |- C

At the semantic level we have the following situation:

 

f: B C

 

 

_____________________

 

g: D A

f ° weak-lA,B: A B C

 

__________________________________

 

f ° weak-lA,B ° g idB: D B C

 

and

 

 

 

f: B C

 

 

_____________________

 

 

f ° weak-lD,B: D B C

 

thus, for every g: DA, we must have

 

weak-lD,B = weak-lA,B ° g idB : D BC

(*)

188

8. Formulae, Types, and Objects

The previous equation is clearly true if is a categorical product, and weak-lD,B is the associated right projection.

8.6.4 Example Consider a derivation whose final part looks like

A, A |- B

________

D |- A A |- B

__________________

D |- B

This is the annoying case of the contraction. With the help of a mix rule, the derivation reduces to

D |- A A, A |- B

___________________

D |- B

Regarding the mix as a simple abbreviation of a series of cuts and structural inferences, the previous

derivation is logically equivalent to

D |- A

A, A |- B

___________________

D |- A

D, A |- B

___________________

D, D |- B

_________

D |- B

At the semantic level we have

f: A A B

______________

g: D A f ° A : A B

________________________

f ° A ° g: DB

which reduces to

g: D A f: A A B

________________________

g: D A f ° g idA : D A B

___________________________________

f ° g idA ° idA g : D D B

__________________________

f ° g g ° D : D D B

189

 

8. Formulae, Types, and Objects

 

This implies that in a model we expect

 

 

A ° g = g g ° D

(+)

that is the naturality of .

 

 

8.6.5 Example Consider the derivation

 

B, Α |- C

E |- A C |- D

 

________

_____________

 

B |- A C

(A C), E |- D

 

________________________________

B, E |- D

The last cut is eliminated by introducing two other cuts of lesser grade, namely

 

B, Α |- C C |- D

 

________________

E |- A

B, A |- D

______________________________

B, E |- D

At the semantic level this gives

 

 

h: B Α → C

f: E A

g: C D

_____________

_____________________________

Λ(h): B A C g ° evalA,C ° id f: (A C) E D

________________________________________________

g ° evalA,C ° id f ° Λ(h) id: B E D

that reduces to

 

h: B Α → C g: C D

 

______________________

f: E A

g ° h : B Α → D

_______________________________________

g ° h ° id f : B, E D

Note that in a Cartesian closed category, by the β-axiom of exponents, one has

g ° evalA,C ° id f ° Λ(h) id = g ° evalA,C ° Λ(h) id ° id f = g ° h ° id f.

This completes the observation that the Cartesian closure may be described in terms of equivalence of proofs, up to normalization.

190

8.Formulae, Types, and Objects

8.7Categorical Semantics of the Simply Typed Lambda Calculus

In sections 8.3 and 8.4, we have investigated the relation between typed lambda calculus and intuitionistic logic, and in sections 8.5 and 8.6 we have established the connection between intuitionistic logic and Cartesian closed categories. In this section we want now to “fill the triangle” among typed lambda calculus, intuitionistic logic and Cartesian closed categories, studying the missing edge - namely the categorical semantics of the Typed Lambda Calculus, over CCC's.

The main idea of the categorical semantics of the typed lambda calculus is to interpret types as objects and terms as morphisms of a category C. In particular, the reader has probably noted some analogy between the axioms of λβηπt and the axioms defining products and exponents in Cartesian closed categories. The relation is quite evident in the case of products: fstσ×τ→σ and sndσ×τ→τ are easily understood as the projections associated with the categorical product of σ and τ. Apart from the problem of switching from “application” to “composition,” the axioms of λβηπt regarding

the product are essentially identical to the axioms in definition 1.3.3 of categorical product. Less immediate is the connection between β (and η) and the rules defining the exponents of a CCC: the

main problem is that the definition in the calculus is based on the process of substitution, for which we do not have any immediate equivalent in Category Theory. Let us look a little closer at our

tentative interpretation: the intuitive idea is that a term Mτ with free variables among x σ1, ...,x

σn

1

n

should be interpreted as a morphism Mτ from ∆ = σ1×...×σn to τ.

Suppose now that we have

two terms

Mτ and Nγ, such that the free variables of [Nγ/ xγ]Mτ

are in

∆= σ1×...×σn. Then

look at Mτ

like an arrow from

∆×γ to τ, and at

Nγ like an arrow from

to

γ. The effect of

substituting

Nγ for xγ in Mτ

is simply achieved

by composing Mτ

with

< id

, Nγ >.

 

 

 

 

 

 

These considerations are formalized in substitution lemma 8.7.6 below, which plays a central role in the semantics of functional languages. Note now that in every CCC, one has

(βcat) eval ° <Λ(f),g> = eval ° Λ(f)×id ° <id,g> = f ° <id,g>

which, by our interpretation of substitution, is just the categorical equivalent of β-conversion in λ- calculus.

191

8. Formulae, Types, and Objects

We now begin a formal discussion on the categorical interpetation of typed λ-calculus, by outlining a simple and very intuitive, set-theoretic definition of model for λβηπt. This is just a definition and will be instrumental to the categorical characterization below. In particular, it will allow us to relate the category-theoretic approach to the Tarskian view in semantics. For a more direct connection between λβηπt and CCC's, see the references.

The collection Tp of types over a set At of ground types has been defined in section 8.2. As

types will be largely used as indexes (of terms), in this section we go back to the use of small greek

letters

σ,τ.... as metavariables for types.

8.7.1

Definition Let

C = {Ci | i At} be a collection of sets. Then TSC = {Cσ}σ Tp is a

type structure over C

iff, for all σ,τ Tp,

 

Cσ→τ Cσ Cτ (= Set[Cσ,Cτ])

 

Cσ×τ = Cσ×Cτ .

8.7.2 Definition A type structure TSA = ({Aσ}σ Tp, [ ]) is a model of typed λ-calculus (with

products) iff

[ ] yields an interpretation for λβη(π)t. That is, for any environment h: Var

Uσ Tp (Aσ} with h(xσ) Aσ, one has

[Mρ]h Aρ, for each

ρ Tp and for [ ] defined by

Var.

[xσ] = h(xσ)

 

 

 

 

 

 

 

h

 

 

 

 

 

 

 

App.

[Mσ→τNσ]h = [Mσ→τ]h ([Nσ]h)

 

 

 

 

β.

[λxσ.Mτ]h(a) = [Mτ]h[a/xσ] for a Aσ

 

 

π.

[ fstσ×τ→στ]

h

= p

, [ sndσ×τ→στ]

h

= p

2

 

 

1

 

 

 

where p1, p2

are the set-theoretic projections (of proper types).

 

This is a good definition of model, i.e., the axioms and rules are realized and, given a model TSA λβη(π)t, one actually has

λβη(π)t | Mσ = Nσ TSA |= Mσ = Nσ.

Indeed, the reader will be asked to check the validity of axiom (β) in the exercise before 8.7.7. Note also that, in a model, axiom (η) and rule (ξ) trivially hold, since λ-terms are interpreted as

functions in extenso and, hence, one has

η. a

[λyσ.Mσ→τyσ]h(a) = [Mσ→τ]h(a) , for yσ FV(Mσ→τ), and

ξ. a

[Mτ]h[a/xσ] = [Nτ]h[a/xσ] [λxσ.Mτ]h = [λxσ.Nτ]h ,

by (β) and by [λxσ.Pτ]h Aσ→τ AσAτ.

The properties of projections and pairing, in case one considers λβηπt, are trivially realized by the definition of product.

Thus a type-structure TSA is a model of λβη(π)t iff

λβη(π)t | Mσ = Nσ TSA |= Mσ = Nσ.

192

8. Formulae, Types, and Objects

Since the previous definition of model is set-theoretic, a suitable notion of “concreteness” for categories can help in studying categories as models. The minor loss of generality, in this case, is balanced by the gain in intuition.

In general, concrete categories are widely used in denotational semantics; they are (usually) defined by an “enough points” requirement.

8.7.3 Definition. Let C be a category. t ObC is a generator iff for all a,b ObC and all f,g C[a,b], f g h C[t,a] f°h g°h .

C has enough points if there exists a generator t that is terminal in the given category.

The terminology derives from the idea that the arrows in C[t,a], when t is terminal, may be understood as the points (or elements) of a. Indeed, we can associate with each category C having enough points a category of sets Cset as follows. For a,b ObC and t terminal

objects: |a| = C[t,a]

morphisms: f Cset[|a|,|b|] iff f' C[a,b] f = f'° _ . Observe that f' is unique once f is given.

8.7.4

Proposition.

If C is a CCC with enough points, then Cset is also a CCC with enough

points.

 

 

Proof If cσ→τ and

cσ×τ are the exponent and product objects, in C, of cσ and cτ, then |cσ→τ|

and

|c

| are the exponent and product objects, in Cset, of |c

| and |c |. As for the exponent, just

 

 

σ×τ

σ

τ

set

evalset = eval°_ , and Λset(f) = Λ(f')°_ , where f' defines f

as above. The rest is easy.

Note that one obtains type structures from all categories with enough points That is, let K be a CCC with enough points and C = {ki | i At} ObK. Let also kσ→τ and kσ×τ be the exponent and product objects, in K, of kσ and kτ. Then KC = {K[T,kσ] | σ Tp } is the type structure generated by K and C.

Examples. The simplest type structures are the “full” type-structures and the “term model” of λβη(π)t . That is, SetC, where C is a collection of sets, and Term = ({Termσ}σ Tp, [ ] ), where Termσ is the set of terms of type σ modulo βη convertibility.

8.7.5 Definition Let C be a CCC, with terminal object t and projections

fst, snd. Suppose one

has a map I

associating every atomic type A with an object of C.

Then the categorical

interpretation is as follows:

 

 

- Types:

[σ] = I(σ)

if σ is atomic

 

 

[σ→τ] = [τ][σ]

 

193

Соседние файлы в предмете Электротехника