Gluing Nominal Theories

This permutation-based model has many good properties, which are actually linked with the bijective character of permutations — this allows in particular.
206KB taille 4 téléchargements 324 vues
´ Ecole Normale Sup´erieure de Lyon Master d’Informatique Fondamentale, 1re ann´ee

Gluing Nominal Theories

Florian Hatat with Roy L. Crole University of Leicester June – August 2007

Contents 1 Introduction 1.1 Categorical type theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2 Working with α-equivalence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Nominal algebra and sets 2.1 Nominal algebra . . . . . . . . . . . 2.1.1 Permutation actions . . . . . 2.1.2 Nominal syntax . . . . . . . . 2.1.3 Freshness contexts . . . . . . 2.1.4 Equational theory . . . . . . 2.1.5 α-equivalence . . . . . . . . . 2.2 N-quantifier . . . . . . . . . . . . . . 2.2.1 Finitely supported objects . . 2.2.2 Definition of the N-quantifier 2.2.3 Nominal sets . . . . . . . . . 2.3 λ-calculus as a nominal theory . . . 2.3.1 Simply-typed λ-calculus . . . 2.3.2 Extensions . . . . . . . . . . 2.4 Other approaches . . . . . . . . . . .

2 2 3

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

4 4 4 4 6 6 7 8 8 8 9 9 9 10 11

3 Conservative extensions and gluing constructions 3.1 Gluing construction . . . . . . . . . . . . . . . . . . . . . . 3.2 Freely generated category . . . . . . . . . . . . . . . . . . . 3.3 Proving conservative extensions . . . . . . . . . . . . . . . . 3.3.1 Categorical interpretation of conservative extensions 3.3.2 Gluing theories . . . . . . . . . . . . . . . . . . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

12 12 12 13 13 14

4 Proving conservative extensions of nominal 4.1 Categorical semantics . . . . . . . . . . . . 4.1.1 Categorical structure . . . . . . . . . 4.1.2 Interpretation of nominal terms . . . 4.1.3 Freshness contexts and equations . . 4.2 About substitution . . . . . . . . . . . . . . 4.3 Interpreting axioms . . . . . . . . . . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

15 15 15 16 16 17 17

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . . . . . . . . . .

theories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . .

. . . . . .

. . . . . . . . . . . . . .

. . . . . .

. . . . . .

5 Conclusion

19

Bibliography

20

1

Chapter 1

Introduction 1.1

Categorical type theory

It is a common fact that there is an exact correspondence between some equational theories and categorical structures: • given a sorted equational theory, for example simply-typed λ-calculus, one can interpret types γ as objects JγK of a category C with some structure, terms-in-context Γ ` M : γ as morphisms of C, • if x : γ ` M : δ and θ ` N : γ are two terms, interpreted by two morphisms m : Γ → ∆ and n : Θ → Γ, then the capture-avoiding substitution θ ` M [x 7→ N ] : δ is actually interpreted by the composition m ◦ n : Θ → Γ → ∆, • given a set of axioms, which have the form Γ ` M = N : γ, one can build an equational theory over terms, and equality between two terms is equivalent to equality between morphisms. For example, one can interpret λ-calculus with finite products in a Cartesian closed category: • the product of two types γ × γ 0 is interpreted by the product JγK × Jγ 0 K in the category,

• the type γ → γ 0 is interpreted by the exponential Jγ 0 KJγK ,

• a term-in-context M1 : γ1 , . . . , Mn : γn ` M : γ is interpreted by a morphism

Qn

i=1 Jγi K

→ JγK,

• one can see morphisms in the category as proofs γ1 , . . . , γn ` δ1 , . . . , δm of all goals δi from the hypotheses γj . The previous points show that we in fact only need a model M : T h → C, which is a map from the ground constructions of T h to objects in C: this model can then be inductively extended to the map J K, which interprets types and terms of T h in C. There exists a particular, necessarily unique, category noted Cl(T h), and called the classifying category of T h, such that any model M : T h → C factors through the model T h → Cl(T h) via a functor F : > Cl(T h) Th M

F >

∨ C Therefore, working on models of T h to a category amounts to a problem over Cartesian closed functors between Cl(T h) and C.

2

The classifying category allows us to explicit the exact correspondence between theories and categories: to every theory T h we can associate a category Cl(T h), and conversely, any Cartesian closed category is the classifying category of some theory. This can be summarized by the following diagram: Th > Cl(T h) C

T hC
C0 f0

f ∨ ΓD

Γh

∨ > ΓD0

Let us also mention the obvious projection functor π2 : GL(Γ) → D, which will play a key role in the conservative extension proof. It is a well known fact, albeit not trivial to prove, that GL(Γ), like C, is Cartesian closed. Also, when D is endowed with some structure then π2 often preserves that structure — it is the case when D has products, exponentials [2], or a let-structure [3].

3.2

Freely generated category

Given a structure on a category — we do not explicit this structure, as this construction can be adapted to many different cases —, and a functor F between two categories with that structure, we assume that we can define a property saying that F preserves that structure: this property can be for example one of the standard notions of product, limit preserving functor. We will say that those categories are struc-categories, and F is a struc-preserving functor. 12

Definition 2 (Freely generated category). Let C be a category with finite products: we say that a category FC is freely generated from C when FC is a struc-category, and there exists a product preserving functor I : C → FC such that: • for any struc-category D, every product preserving functor F : C → D factors through I, i.e. there exists a struc-preserving functor F such that this diagram commutes up to a natural isomorphism φ : F ◦ I ∼ = F: F

>D >

C

F

I >

FC 0

• F is unique, that is to say, if there exists another functor F satisfying the same property, 0 0 with φ0 : F ◦ I ∼ = F , then φ0−1 ◦ φ is a natural isomorphism F ∼ = F. When T h is an algebraic theory (corresponding to a category with finite products), and T h0 is the λ×-theory generated from T h (see [2]), then the classifying category Cl(T h0 ) is freely generated from Cl(T h): the structure involved here is the Cartesian closure.

3.3 3.3.1

Proving conservative extensions Categorical interpretation of conservative extensions

Definition 3 (Conservative extension). Let T h and T h0 be two equational theories, and write `T h and `T h0 for judgements in each theory. T h0 is a conservative extension of T h0 if and only if: • for every term N1 : γ1 , . . . , Nn : γn `T h0 M : γ, where γ and all γi are types in T h, then M is provably equal, in T h0 , to a term ∆ `T h N : γ, • when ∆0 `T h N 0 : γ is also equal to M , then one can prove that `T h N = N 0 . This definition can be summarized with the following diagram: = 0 == h = T === == == ==

== == == T h 0 == == == =

Γ `T h0 M : γ

Th ∆ `T h N : γ =========== ∆0 `T h N 0 : γ We can reformulate the previous definition using only categorical notions: let us write C for the classifying category Cl(T h), D = Cl(T h0 ), and J KT h for the function which associates an object in C to each type in T h, and a morphism to each term, and J KT h0 for the corresponding function for T h0 . In order to prove that T h0 is a conservative extension of T h, it is enough to find a full and faithful functor I : C → D which preserves the interpretation of types, that is to say, for every type γ of T h: JγKT h0 = IJγKT h m

> IJγKT h , and since I is full, A term Γ `T h0 M : γ indeed gives rise to a morphism IJΓKT h we can find a morphism n : JΓKT h → JγKT h in C such that m = In. The morphism n corresponds to a term N in T h, and the previous equality on morphisms implies that N is provably equal to M

13

in T h0 . Furthermore, since I is faithful, if there exists another n0 such that m = In = In0 , then, in C, n = n0 which is equivalent to an equality over terms `T h N = N 0 . One should note that we have implicitly used the hypothesis that C and D were the classifying categories of T h and T h0 , since this ensures that any morphism n is actually the interpretation of a term N , and that the equality is complete — meaning that n = n0 if and only if N = N 0 .

3.3.2

Gluing theories

Using the previous interpretation of a conservative extension result, the main difficulty now is to prove the existence of a functor I : Cl(T h) → Cl(T h0 ), which is full and faithful. 1. For λ× or let-theories, one can prove that Cl(T h0 ) is the freely generated category from Cl(T h), via the obvious functor I = J KT h 7→ J KT h0 . 2. Find a category G and a product preserving functor J : C → G, which we can factorize in the following way: J C >G I >

∨ FC

There are some reasons why a category GL(Γ) is a good choice for G: if Γ is a struc-preserving functor between FC and another struc-category, then GL(Γ) will be a struc-category, and the previous factorization can in fact be given by the struc-preserving functor π2 . The choice of the functors Γ and J clearly depends on the underlying theories: for let-theories, op op we can choose for example Γ = SetI ◦ Y : FC → SetF C → SetC , where Y is the Yoneda embedding. 3. It follows that the following diagram commutes up to natural isomorphisms: the upper triangle because FC is freely generated, and the lower triangle is the previous factorization.

I

>

FC ======= FC

C

J

J

∨ > GL(Γ)

Id

I

π2 >

∨ ∨ FC ======= FC

The rectangle commutes because of the third property of a freely generated category: IdF C and π2 ◦ J are two factorizations of I, and are therefore isomorphic. This implies that J is faithful, therefore I is full and faithful if J is: this last part of the proof depends on the choice made for J, and does not involve any more the gluing construction.

14

Chapter 4

Proving conservative extensions of nominal theories 4.1 4.1.1

Categorical semantics Categorical structure

We would like to interpret a nominal theory in a category C, using the usual ideas of categorical type theory: • nominal sorts τ are interpreted by objects Jτ K in the category, • a term M : τ is interpreted by a morphism m : A1 × . . . An → Jτ K, where the Ai ’s are the sorts of free variables in M , • two terms are provably equal in the nominal algebra whenever their associated morphisms are equal in the category. In order to interpret a nominal theory in C, we need, for each atomic sort α, an object Aα , along with a property expressing the fact that Aα is an object of atoms. This property will certainly be related to the abstraction: when T is an object, we need an abstracted object [A]T to interpret the type [A]τ . We could use an exponential, yet this approach has a few drawbacks: • we do not want our category to have all exponentials, since only atoms can be abstracted, • there is no application in nominal syntax: the evaluation map associated with the exponential would be superfluous, • the exponential has no link with freshness assertions, and in particular with the judgement a#[a]M . Yet, the exponential is the right adjoint to the functor × B, so we may use a similar idea here: let us consider a functor, following [10], F : C → C such that: • F 1 is the object A, • F preservers pullbacks, ∗ • there is a natural transformation θ : F → Id, such that for every object X, θX is an isomorphism between the posets Sub(X) and Sub(F X),

• the map ζX = hF !X , θX i is monic, which makes F a subfunctor of A × : that is why we may write A# instead of F .

15

We say that C has abstractions when A# has a right adjoint, written [A] . In the previous paragraphs, we have only considered one sort of atoms: in fact, we need a tuple (Aα , Fα , θα , [Aα ] ) for each atomic sort α. This structure is enough to define a morphism m for each nominal term M , yet we will later want to express freshness judgements in our category: we will therefore consider that C is a topos [8, 9], the Schanuel topos being for example such a topos with all required structure. It is however unclear whether we actually need a topos, or whether we could use a weaker categorical structure: this question is however important, since we already mentioned that we need a completeness property, which does not necessarily hold in a topos. Also, one can think of Cartesian closed categories, in which the equality of morphisms is decidable: this property does not necessarily hold either in a topos. Definition 4 (Structure). In order to interpret nominal terms in C, we need a structure M, which is given by: • an object JδK for every ground type δ, then we can naturally extend the map J K by induction on the syntax of nominal sorts, • a morphism Jf K : Jτ1 K × · · · × Jτn K → Jτ K for every function symbol f : (τ1 , . . . , τn )τ .

4.1.2

Interpretation of nominal terms

Given a structure M, we can define by induction a morphism U → Jτ K for every nominal term M : τ . We use a form of terms-in-context Γ ` M : τ , where Γ is the list of free atoms in M . JΓ ` Mi K = mi : U → Jτi K f : (τ1 , . . . , τn )τ JΓ ` f (M1 , . . . , Mn )K = Jf K ◦ hmi i : U → Jτ K Jaα , Γ ` M K = m : Aα × U → V

(tf)

(abs)

JΓ ` [aα ]M K = m ◦ ζU : U → [Aα ]V JΓ ` Xτ K = idJτ K : Jτ K → Jτ K

(unk)

JΓ, aα , Γ0 ` aα K = π : U × Aα × V → Aα

(atm)

In the rule (abs), m ◦ ζU is a morphism Aα #U → Aα × U → V , and m ◦ ζU is its adjunct, given by Aα # a [Aα ] .

4.1.3

Freshness contexts and equations

Let A(∆) be the set of distinct atoms which appear in the freshness context ∆, and X(∆) the set of distinct (sorted) unknowns. We can certainly find maps a : {1, . . . , n} → A(∆) and X : {1, . . . , n} → X(∆) such that: ∆ = a1 #X1 , . . . , an #Xn For each i ∈ {1, . . . , n}, we will write Ai for the sort of ai , and δi for the sort of Xi . Let Ω be the subobject classifier of C, and ∆ = a1 #X1 , . . . , an #Xn be a freshness context. Using the previous notations, ∆ can be interpreted in C by a morphism J∆K : Ak × W → Ω, where: • k is the cardinal of A(∆), Q • W is the finite product Jδi K, given by the following rules:

16

Ja#XK = char ζX : A × X → Ω J∆K = u : U → Ω J∆0 K = v : V → Ω 0 J∆, ∆ K = u ∧ v : W → Ω Here, Ω is the subobject classifier of C, and the conjunction u ∧ v is given by the internal Heyting algebra. We have interpreted a freshness context as a morphism W → Ω, yet in a topos, this is equivalent to having a subobject m of W , given by the pullback: >1

∆ ∨ m ∨ W

true J∆K

∨ >Ω

Using a direct approach, which would allow us to directly define the subobject m without using the topos structure — i.e. without using the previous pullback — could help us in finding a minimal categorical structure for interpreting nominal syntax and judgements.

4.2

About substitution

A major idea of categorical type theory is to interpret substitution of terms by composition of the corresponding morphisms. In a nominal theory, substitution of unknowns, which is the only meta-level substitution, does not avoid captures, whereas composition of morphisms does: take for example the terms M = aα and N = [aα ]Xα . These would be interpreted by the morphisms m = idAα : Aα → Aα and n = ζAα : Aα → [Aα ]Aα : yet the morphism n ◦ m is the interpretation of [aα ]bα , where bα is an atom. This happens in all cases, since the adjunction A# a [A] is natural: whenever n ◦ ζ is a morphism V → [A]W and m : U → V , the morphism n ◦ ζ ◦ m has a left adjunct n ◦ ζ ◦ A#m, where A#m has type A#U → A#V . Therefore, the abstracted atom in n ◦ ζ appears as fresh for both U and V in m, whereas we actually want it not to be fresh. However, we can use the naturality of the adjunction in a slightly different way to define a capturing substitution: we only show here the basic ideas, since some more work is needed to find out whether this approach actually works, and if so, to explicit the extra structure it involves. We have seen that composition with a morphism n : V → [A]W cannot capture the abstracted atom: yet, if we consider its adjunct n ˆ : A#V → W , we can sometimes find a morphism n0 : A × V → W from n. If it is the case that V is a product V 0 × A × V 00 , then we can certainly define the following morphism, which would be the result of the substitution: A#(V 0 × V 00 )

ζ ∆ n0 > A × V 0 × V 00 > A × V 0 × A × V 00 >W

We should emphasize that we do not want all morphisms A#V → W to be mapped to a morphism A×V → W , since when we consider freshness morphisms, this would allow the existence of A × A → A#A, merely implying that an atom a ((a, a) ∈ A × A) could be fresh in itself ((a, a) ∈ A#A). We could have used binders λX : A × X → [A]X [10] to define the interpretation of abstraction in 4.1.2: then our transformation exists at least for all morphisms defined via the inference rules.

4.3

Interpreting axioms

Our last question concerns the interpretation of axioms: in a nominal equational theory, axioms may have preconditions which take the form of a freshness context. This makes their interpretation

17

more complicated than for an equational theory over λ-calculus: in such a theory, an axiom has the form Γ ` M = N : γ, and is simply interpreted by saying that the morphisms JΓ ` M : γK and JΓ ` N : γK are equal. Composition then ensures that we can substitute variables in M and N and still prove the equality. Yet, in a nominal theory, axioms have the form ∆ ` M = N : γ: ∆ is here a freshness context, which is in fact a precondition rather than the equivalent of a context in λ-calculus. Therefore, we cannot simply identify the morphisms JM K and JN K in the category. This is in fact closely linked with the lack of a proper capturing substitution, which is crucial to embed the rule (axiom).

18

Chapter 5

Conclusion My main work during this training period was to understand the ideas of nominal sets and algebra while having in mind the concepts of categorical type theory. One of our goal was to adapt the gluing construction to a nominal setting, yet this point still seems far from being solved, since finding a good categorical structure for modelling nominal syntax happened to be a more difficult task than first expected. While we managed to adapt the constructions of [10] to define an interpretation of nominal terms in a category, and of freshness assertions in a topos, the minimal structure needed to model the equational theory still seems unclear. Yet this question is important, since a crucial point in the conservative extension proof is the fact that the categorical model is complete: while there exists a completeness theorem for equalities in the Schanuel topos, this does not hold for freshness judgements. This work was, to our knowledge, the first one to try and apply the approach of categorical type theory to nominal syntax. This raised many questions, which we tried to address, although further investigations are certainly needed.

19

Bibliography [1] Roy L. Crole. Programming Metalogics with a Fixpoint Type. PhD thesis, Computer Laboratory, University of Cambridge, 1991. [2] Roy L. Crole. Categories for Types. Cambridge Mathematical Textbooks. Cambridge University Press, 1993. xvii+335 pages, ISBN 0521450926HB, 0521457017PB. [3] Roy L. Crole. On Fixpoint Objects and Gluing Constructions. Applied Categorical Structures, 4(2 & 3):251–281, 1996. [4] Roy L. Crole. Operational Semantics, Abstract Machines and Correctness, 2006. Lecture Notes for the Midlands Graduate School in the Foundations of Computer Science, LaTeX format 91 pages with subject and notation index. [5] Roy L. Crole. Hybrid Adequacy. Submitted for journal publication, 2007. [6] Murdoch J. Gabbay and Aad Mathijssen. Nominal algebra. In Proc. 18th Nordic Workshop on Programming Theory (NWPT’06), 2006. [7] Murdoch J. Gabbay and Andrew M. Pitts. A new approach to abstract syntax with variable binding. Formal Aspects of Computing, 13:341–363, 2001. [8] Saunders Mac Lane. Categories for the Working Mathematician. Graduate Texts in Mathematics. Springer, second edition, 1998. [9] Saunders Mac Lane and Ieke Moerdijk. Sheaves in Geometry and Logic: A First Introduction to Topos Theory. Universitext. Springer-Verlag, 1992. [10] Mat´ıas Menni. About N-quantifiers. Applied Categorical Structures, 11:421–445, 2003. [11] Andrew M. Pitts. Alpha-structural recursion and induction. ??, ?? [12] Andrew M. Pitts. Notes on categorical logic. Lecture Notes for a graduate course in the University of Cambridge Computer Laboratory, 78pp typescript, Lent Term 1989. [13] Andrew M. Pitts. Nominal logic, a first order theory of names and binding. Information and Computation, 186:165–193, 2003. [14] Andrew M. Pitts. Lectures on nominal syntax and semantics. International Summer School on Applied Semantics, Fauenchiemsee, Germany, September 2005. [15] Christian Urban, Andrew M. Pitts, and Murdoch J. Gabbay. Nominal unification. Theoretical Computer Science, 323:473–497, 2004.

20