Modèles des langages de programmation Domaines, catégories, jeux. Programme de cette seconde séance:

Similar documents
1 Categorical Background

Quantum groupoids and logical dualities

Category Theory (UMV/TK/07)

Enriched Categories. Stephen Fitz

Project: Construction of the Fundamental Group

1 Categories, Functors, and Natural Transformations. Discrete categories. A category is discrete when every arrow is an identity.

PART I. Abstract algebraic categories

A Taste of Categorical Logic Tutorial Notes

Categories and functors

Algebras. Larry Moss Indiana University, Bloomington. TACL 13 Summer School, Vanderbilt University

Adjunctions! Everywhere!

Category Theory. Categories. Definition.

3. Categories and Functors We recall the definition of a category: Definition 3.1. A category C is the data of two collections. The first collection

INTRODUCTION TO CATEGORY THEORY FOR FUNCTIONAL PROGRAMMING

CATEGORICAL GROTHENDIECK RINGS AND PICARD GROUPS. Contents. 1. The ring K(R) and the group Pic(R)

Cartesian closed 2-categories and rewriting

9 Direct products, direct sums, and free abelian groups

Theories With Duality DRAFT VERSION ONLY

MacLane s coherence theorem expressed as a word problem

Complete Partial Orders, PCF, and Control

Adjoints, naturality, exactness, small Yoneda lemma. 1. Hom(X, ) is left exact

Lecture 15: Duality. Next we spell out the answer to Exercise It is part of the definition of a TQFT.

A brief Introduction to Category Theory

Category Theory. Course by Dr. Arthur Hughes, Typset by Cathal Ormond

FUNCTORS AND ADJUNCTIONS. 1. Functors

A Taste of Categorical Logic Tutorial Notes

From Categories with Families to Locally Cartesian Closed Categories. Pierre Clairambault June 12, 2006

Elements of Category Theory

Review of category theory

CATEGORY THEORY. Cats have been around for 70 years. Eilenberg + Mac Lane =. Cats are about building bridges between different parts of maths.

A completeness theorem for symmetric product phase spaces

A categorical model for a quantum circuit description language

Cartesian Closed Topological Categories and Tensor Products

A quoi ressemblerait une géométrie du raisonnement?

Assume the left square is a pushout. Then the right square is a pushout if and only if the big rectangle is.

SM CATEGORIES AND THEIR REPRESENTATIONS

Categories, Proofs and Programs

Category Theory. Travis Dirle. December 12, 2017

1 Cartesian bicategories

sset(x, Y ) n = sset(x [n], Y ).

Recall: a mapping f : A B C (where A, B, C are R-modules) is called R-bilinear if f is R-linear in each coordinate, i.e.,

COMMUTATIVE ALGEBRA LECTURE 1: SOME CATEGORY THEORY

A Linear/Producer/Consumer model of Classical Linear Logic

Direct Limits. Mathematics 683, Fall 2013

NON-SYMMETRIC -AUTONOMOUS CATEGORIES

arxiv: v2 [math.ra] 14 Sep 2016

A Grothendieck site is a small category C equipped with a Grothendieck topology T. A Grothendieck topology T consists of a collection of subfunctors

Categories, Functors, Natural Transformations

IndCoh Seminar: Ind-coherent sheaves I

ENTROPIC HOPF ALGEBRAS AND MODELS OF NON-COMMUTATIVE LOGIC

Serre A -functors. Oleksandr Manzyuk. joint work with Volodymyr Lyubashenko. math.ct/ Notation. 1. Preliminaries on A -categories

arxiv: v1 [math.ct] 7 Feb 2011

Monads and More: Part 4

Quantizations and classical non-commutative non-associative algebras

Universal Algebra and Diagrammatic Reasoning

Parameterizations and Fixed-Point Operators on Control Categories

Algebraic Geometry

1 Introduction. 2 Categories. Mitchell Faulk June 22, 2014 Equivalence of Categories for Affine Varieties

The Universal Coefficient Theorem

Mathematical Synthesis of Equational Deduction Systems. Marcelo Fiore. Computer Laboratory University of Cambridge

M, N ::= x λp : A.M MN (M, N) () c A. x : b p x : b

Discrete Random Variables Over Domains

Category Theory for Linear Logicians

Categories and Quantum Informatics

DEFINITIONS: OPERADS, ALGEBRAS AND MODULES. Let S be a symmetric monoidal category with product and unit object κ.

Analysis and Construction of Logical Systems: A Category-Theoretic Approach

Topos Theory. Lectures 21 and 22: Classifying toposes. Olivia Caramello. Topos Theory. Olivia Caramello. The notion of classifying topos

Thus we get. ρj. Nρj i = δ D(i),j.

Categorical Aspects of Galois Theory

Endomorphism Semialgebras in Categorical Quantum Mechanics

MTH 428/528. Introduction to Topology II. Elements of Algebraic Topology. Bernard Badzioch

The tensor product of commutative monoids

Cellularity, composition, and morphisms of algebraic weak factorization systems

OPERAD BIMODULE CHARACTERIZATION OF ENRICHMENT. V2

C2.7: CATEGORY THEORY

Lectures on Homological Algebra. Weizhe Zheng

University of Oxford, Michaelis November 16, Categorical Semantics and Topos Theory Homotopy type theor

Representation of monoids in the category of monoid acts. 1. Introduction and preliminaries

Category Theory. Steve Awodey. Carnegie Mellon University

Boolean Algebras, Boolean Rings and Stone s Representation Theorem

Dual Adjunctions Between Algebras and Coalgebras

The category of open simply-typed lambda terms

MATH 101B: ALGEBRA II PART A: HOMOLOGICAL ALGEBRA 23

Category Theory 1 Categories and functors

Universal Properties

What is a Model for a Semantically Linear λ-calculus?

Locally cartesian closed categories

OMEGA-CATEGORIES AND CHAIN COMPLEXES. 1. Introduction. Homology, Homotopy and Applications, vol.6(1), 2004, pp RICHARD STEINER

Interpreting the Second-Order Lambda Calculus using Qualitative Domains

TENSOR-TRIANGULATED CATEGORIES AND DUALITIES

The dual homomorphism to f : A B is the homomorphism f : Hom(A, G) Hom(B, G)

1. Introduction and preliminaries

Conceptual Connections of Circularity and Category Theory

Brief notes on category theory

arxiv:math/ v1 [math.qa] 3 Jun 2002

Categories and Functors (Lecture Notes for Midlands Graduate School, 2013) Uday S. Reddy The University of Birmingham

NOTES ON ATIYAH S TQFT S

Introduction to Chiral Algebras

Math Homotopy Theory Spring 2013 Homework 13 Solutions

EXAMPLES AND EXERCISES IN BASIC CATEGORY THEORY

Transcription:

Modèles des langages de programmation Domaines, catégories, jeux Programme de cette seconde séance: Modèle ensembliste du lambda-calcul ; Catégories cartésiennes fermées 1

Synopsis 1 the simply-typed λ-calculus, 2 the set-theoretic model of the λ-calculus, 3 categories and functors 4 cartesian categories 5 cartesian closed categories 6 interprétation of the simply-typed λ-calculus in a ccc 2

The simply-typed λ-calculus 3

The pure λ-calculus Terms M ::= x M N łx. M The β-reduction: (λx.m) N M [x := N] The η-expansion: M λx. (M x) Remark: every term is considered up to renaming α of the bound variables, typically: λx.λy.x α λz.λy.z 4

The simply-typed λ-calculus The simple types A, B are constructed by the grammar: A, B ::= α A B. A typing context Γ is a finite sequence Γ = (x 1 : A 1,..., x n : A n ) where each x i is a variable and each A i is a simple type. A sequent is a triple where x 1 : A 1,..., x n : A n P : B x 1 : A 1,..., x n : A n is a typing context, P is a λ-term and B is a simple type. 5

The simply-typed λ-calculus Variable Abstraction Application Weakening Contraction Exchange x : A x : A Γ, x : A P : B Γ λx.p : A B Γ P : A B Γ, PQ : B Γ P : B Γ, x : A P : B Q : A Γ, x : A, y : A P : B Γ, z : A P[x, y z] : B Γ, x : A, y : B, P : C Γ, y : B, x : A, P : C 6

Subject reduction A λ-term P is simply typed when there exists a sequent Γ P : A which may be obtained by a derivation tree. One establishes that the set of simply typed λ-terms is closed under β-réduction: Subject Reduction: If Γ P : A and P β Q, then Γ Q : A. 7

The set-theoretic interpretation of the λ-calculus 8

Interprétation ensembliste To each atomic type α is associated a set X α Then, one extends the interpretation to every type: [[α]] = X α [[A B]] = [[B]] [[A]] = Set ([[A]], [[B]]) A sequent x 1 : A 1,..., x n : A n M : B is interpreted as a function [[A 1 ]] [[A n ]] [[B]] 9

Soundness theorem Theorem. The interpretation provides an invariant of λ-terms modulo β and η. if Γ (λx.m) : A B and N : A, then [[Γ, (λx.m)n : B]] = [[Γ, M[x := N] : B]] if Γ M : A B then [[Γ (λx.mx) : A B]] = [[Γ M : A B]] 10

Categories and functors 11

Categories A category C is given by [0] a class of objects [1] a set Hom(A, B) of morphisms f : A B for every pair of objects (A, B) [2] a composition law : Hom(B, C) Hom(A, B) Hom(A, C) [2] an identity morphism for every object A, id A : A A 12

Categories satisfying the following properties: [3] the composition law is associative: f Hom(A, B) g Hom(B, C) h Hom(C, D) f (g h) = ( f g) h [3] the morphisms id are neutral elements f Hom(A, B) f id A = f = id B f 13

Examples 1. the category Set of sets and functions 2. the category Ord of partial orders and monotone functions 3. the category Dom of domains and continuous functions 4. the category Coh of coherence spaces and linear maps 5. every partial order 6. every monoid 14

Opposite category The opposite of a category C is the category noted C op whose morphisms f : A B are defined as the morphisms f : B A of the original category C. 15

Product category The product A B of two categories is the category A B whose objects are the pairs (A, B) of objects of A and B, whose morphisms (A, B) (A, B ) are the pairs of morphisms f : A A g : B B 16

Product category with composition and identities defined as expected: (A, B) id (A,B) (A, B) = (A, B) (id A,id B ) (A, B) (A, B) ( f,g) (A, B ) ( f,g ) (A, B ) = (A, B) ( f f,g g) (A, B ) 17

Functors A functor between categories is defined as the following data: F : C D [0] an object FA of D for every object A of C, [1] a function F A,B : Hom C (A, B) Hom D (FA, FB) for every pair of objects (A, B) of the category C. 18

Functors One requires moreover [2] that F preserves composition FA F f FB Fg FC = FA F(g f ) FC [2] that F preserves the identities FA Fid A FA = FA id FA FA 19

Illustration [ orders ] Every ordered set (X, ) defines a category [X, ] whose objects are the elements of X whose hom-sets are defined as { Hom(x, y) = { } if x y otherwise In this category, there exists at most one map between two objects 20

Illustration [ orders ] Exercise: given two ordered sets (X, ) (Y, ) a functor F : [X, ] [Y, ] is the same thing as a monotonic function F : (X, ) (Y, ) between the underlying ordered sets. 21

Illustration [ monoids ] A monoid (M,, e) is a set M equipped with a binary operation : M M M and a neutral element e : { } M satisfying the two properties below: Associativity law x, y, z M, (x y) z = x (y z) Unit law x M, x e = x = e x. 22

Illustration [ monoids ] Key observation: between there is a one-to-one relationship (M,, e) Σ (M,, e) monoids categories with one object obtained by defining Σ(M,, e) as the category with unique hom-set Σ(M,, e) (, ) = M and composition law and unit defined as g f = g f id = e 23

Illustration [ monoids ] Key observation: given two monoids (M,, e) (N,, u) a functor F : Σ (M,, e) Σ (N,, u) is the same thing as a homomorphism f : (M,, e) (N,, u) between the underlying monoids. Recall that a homomorphism is a function f such that x, y M, f (x y) = f (x) f (y) f (e) = u 24

Transformations A transformation θ : F G between two functors F, G : A B is a family of morphisms (θ A : FA GA) A Obj(A) of the category B indexed by the objects of the category A. 25

Natural transformations A transformation θ : F G : A B is natural when the diagram F f FA FB θ A θ B GA G f GB commutes for every morphism f : A B. 26

Isomorphism In a category C, a morphism f : A B is called an isomorphism when there exists a morphism satisfying g : B A g f = id A et f g = id B. Exercise. Show that g f : A C is an isomorphism when f : A B and g : B C are isomorphisms. Exercise. Show that every functor F : C D transports an isomorphism of C into an isomorphism of D. 27

Bifunctors A bifunctor F from C and D to E is given by: a functor F(A, ) : D E for every object A of the category C a functor F(, B) : C E for every object B of the category D such that the diagram F(A, B) F(A,g) F(A, B ) F( f,b) F( f,b ) F(A, B) F(A,g) F(A, B ) commutes for all morphisms f : A A in C and g : B B in D. 28

Cartesian categories 29

Products The product of two objects A and B in a category C is an object A B equipped with two morphisms π 1 : A B A π 2 : A B B such that for every diagram X f π 1 A B A g there exists a unique morphism h : X A B making the diagram X h f π 2 π 1 A B B A commute. g π 2 B 30

Illustrations 1. The cartesian product in the category Set, 2. The lub a b of two elements a and b in an ordered set (X, ), 3. The cartesian product in the category Dom, 31

Terminal object An object 1 is terminal in a category C when Hom(A, 1) is a singleton for all objects A. One may consider 1 as the nullary product in C. Example 1. the singleton { } in the categories Set and Dom, Example 2. the maximum of an ordered set (X, ) 32

Cartesian category A cartesian category is a category C equipped with a product A B for all pairs A, B of objects, and of a terminal object 1 33

Cartesian categories In every cartesian category, one finds weakening maps ɛ A : A 1, diagonal maps δ A : A A A obtained as id A A A δ A A A π 1 id A π 2 A symmetry maps γ A,B : A B B A obtained as π 2 B A B γ A,B B A π 1 π 1 π 2 A Exercise: Show that ( ) defines a bifunctor C C C. 34

Cartesian closed categories First definition 35

Ccc A cartesian closed category is a cartesian category (C,, 1) together with the following data for all objects A and B: of an object A B of a morphism eval A,B : A (A B) B such that for every object X and morphism f : A X B there exists a unique morphism h : X A B making the diagram A (A B) eval A,B B commute. A h A X f 36

Cartesian closed category Second definition 37

Adjunction An adjunction is a triple consisting of two functors and a family of bijections L : A B R : B A φ A,B : Hom B (LA, B) Hom A (A, RB) natural in A and B, for all pairs of objects A, B of A and B. LA B B A A RB φ A,B One writes L R and one says that L is left adjoint to R. 38

Example: the free vector space Set L R Vect where A = Set : the category of sets and functions B = Vect : the category of vector spaces on a field k R : the «forgetful» functor V U(V) L : the «free vector space» functor X kx kx := { x X λ x x λ x k null almost everywhere. } 39

Illustration: the free monoid Set L R Mon where A = Set : the category of sets and functions B = Mon : the category of monoids and homomorphisms, R : the «forgetful» functor M U(M). L : the «free monoid» functor A A. A := n N A n 40

What does natural bijection φ exactly mean? By φ natural, one means that the two families of sets Hom B (LA, B) Hom A (A, RB) define functors Hom B (L, ) : A op B Set Hom A (, R ) : A op B Set and that the family of bijections φ defines a natural transformation φ : Hom B (L, ) Hom A (, R ) : A op B Set between them. 41

What does natural bijection φ exactly mean? Natural in A and B thus means that every commutative diagram LA g B Lh A h B LA is transformed into a commutative diagram f B A φ A,B (g) RB h A A φ A,B ( f ) RB Rh B 42

Cartesian exponentiation Consider an object A in a cartesian category(c,, 1). A cartesian exponentiation of A is a pair consisting of a functor (A ) : C C and of a family of bijections φ A,B,C : Hom(A B, C) Hom(B, A C) natural in B and C. In other words, it is an adjunction between the functors A A 43

What natural bijection means in that case Naturality in B and C means that the family of bijections φ A,B,C : Hom(A B, C) Hom(B, A C) transforms every commutative diagram A B g C A h B A B into a commutative diagram f C h C B φ A,B,C (g) A C h B B φ A,B,C ( f ) A h C A C 44

Cartesian closed category Definition. A cartesian closed category (ccc) is a cartesian category (C,, 1) equipped with a cartesian exponentation A B C B A C for every object A of the category. φ A,B,C 45

Parameter theorem We have seen that the cartesian product defines a bifoncteur A, B A B : C C C in every cartesian category. In the same way, Parameter theorem [MacLane] The family of cartesian exponentiations (A ) A : C C defines a unique bifunctor A, B A B : C op C C such that the bijections φ A,B,C are natural in A, B, C. 46

Parameter theorem Here, natural in A, B, C means that the family of bijections (φ A,B,C ) A,B,C : Hom(A B, C) Hom(B, A C) transforms every commutative diagram A B g C h A h B A B in a commutative diagram: f C h C B φ A,B,C (g) A C h B B φ A,B,C ( f ) h A h C A C 47

Interpretation of the simply-typed λ-calculus in a CCC 48

The simply-typed λ-calculus The simple types A, B are constructed by the grammar: A, B ::= α A B. A typing context Γ is a finite sequence Γ = (x 1 : A 1,..., x n : A n ) where each x i is a variable and each A i is a simple type. A sequent is a triple where x 1 : A 1,..., x n : A n P : B x 1 : A 1,..., x n : A n is a typing context, P is a λ-term and B is a simple type. 49

The simply-typed λ-calculus Variable Abstraction Application Weakening Contraction Exchange x : A x : A Γ, x : A P : B Γ λx.p : A B Γ P : A B Γ, PQ : B Γ P : B Γ, x : A P : B Q : A Γ, x : A, y : A P : B Γ, z : A P[x, y z] : B Γ, x : A, y : B, P : C Γ, y : B, x : A, P : C 50

Interpretation of the λ-calculus Step 1. We suppose given a function ξ : α ξ(α) which associates an object ξ(α) to every type variable α. Step 2. Every type A is then interpreted as an object [[A]] of the cartesian closed category by structural induction: [[α]] = ξ(α) [[A B]] = [[A]] [[B]] [[A B]] = [[A]] [[B]] 51

Interpretation of the λ-calculus Step 3. Every sequent x 1 : A 1,..., x n : A n t : B is interpreted as a morphism [[t]] : [[A 1 ]] [[A n ]] [[B]] by structural induction on the derivation tree which produced it. 52

The logical rules Variable: [[A]] id [[A]] [[A]] Lambda: A Γ f B becomes Γ φ A,Γ,B ( f ) A B Application: Γ f A and g A B become Γ f g A (A B) eval A,B B 53

The structural rules Contraction: A A Γ f B becomes A Γ δ A Γ A A Γ f B Weakening: Γ f B becomes A Γ ε A Γ 1 Γ Γ f B Permutation: Γ A B becomes Γ B A Γ γ A,B Γ A B f B f B 54

Soundness theorem Theorem. In every cartesian closed category C, the interpretation [[ ]] is an invariant modulo β, η. If Γ (λx.m) : A B and N : A, then [[Γ, (λx.m)n : B]] = [[Γ, M[x := N] : B]] If Γ M : A B then [[Γ (λx.mx) : A B]] = [[Γ M : A B]] Exercise. Establish the soundness theorem. 55