Cartesian closed 2-categories and rewriting Aurore Alcolei A brief presentation of Tom Hirschowitz s paper, Cartesian closed 2-categories and permutation equivalence in higher-order rewriting June 7, 2014 2-CCCAT and HORS June 7, 2014 1 / 21
Context Context Construction Représentation du λ-calcul par valeur 2-CCCAT and HORS June 7, 2014 2 / 21
Context Context A lot of calculi : λ-calcul in cbv, cbn, lazy, optimal, λ-calcul with let rec / refs / call/cc, π-calcul, etc. same kind of proofs again and again a common point: the abstractions (binding) Aim: Having a framework to specify the semantic of (any) programming language with binding. providing tools to specify/automate proofs and construction for these languages 2-CCCAT and HORS June 7, 2014 3 / 21
Context Previous Works What s already there: Higher-Order Rewrite Systems (HRSs) from T.Nipkow no notion of model, does not express reduction steps (binary relation) Categorical approach using Cartesian Closed Categories (CCC) by J.Lambek no notion of reductions, model for equational theories. Ideas: Making signatures for HRSs into a category (Sig) Adding a dimension to Lambek s approach using 2-Cartesian Closed Categories. 2-CCCAT and HORS June 7, 2014 4 / 21
Context In a nutshell Programming language/rewriting systems with binding as a 2-category where objects are types morphisms (1-cells) are terms morphisms between parallel morphisms (2-cells) are reductions What would that mean? l t t t t t t t. ev β a 2-CCCAT and HORS June 7, 2014 5 / 21
Construction Context Construction Représentation du λ-calcul par valeur 2-CCCAT and HORS June 7, 2014 6 / 21
Construction An example Pure λ-calculus: grammar: M, N Λ(Γ) = x Γ λx.m MN (Γ set of variables) reduction rules: (β) (λx.m)n M[N/x] (ξ) M M λx.m λx.m (R) N N MN MN (L) M M MN M N 2-CCCAT and HORS June 7, 2014 7 / 21
Construction Signature Example: 2-signature for pure λ-calculus Σ Λ = ({t}, { l [tt ] t a [t, t] t Three sets : 1. Basic types (sorts): X 0 = {t}. 2. Operations, l and a, with their type. }, { β a l x, y x(y) } ) 3. Rules β. redex and reduction are of the same type. H Sig 2-CCCat W 2-CCCAT and HORS June 7, 2014 8 / 21
Construction Step 1: 1-Signature Types of a signature: obtained by applying (the monad) on X 0 1-signature: L 0 Sets Sets X {A, B = x X 0 A B 1 B A } sequent := element of S 0 (X ) = L 0 (X ) L 0 (X ) 1-signature := (X 0,X 1 ) with ϕ 1 X 1 S 0 (X ) c (dom(c), cod(c)) 2-CCCAT and HORS June 7, 2014 9 / 21
Construction Step 2: 2-Signature (1) Terms of a signature: generated by + simply typed λ-calculus + pairing and projections +... Γ M i i... Γ c M 1,..., M n A c X 1 (,A) modulo β η reduction ( ) Examples: λx.m = l λx. M MN = a M, N x = x ( ) to get a structure close to the CCC 2-CCCAT and HORS June 7, 2014 10 / 21
Construction Step 2: 2-Signature (2) monad L 1 Sig 1 Sig 1 such that L 1 (X ) 0 = X 0 and L 1 (X ) 1 = terms of the signature L 1 (X ) := set of pairs of terms with same type 2-signature : (X,X 2 ) where X is a 1-signature and X 2 is equipped with ϕ 2 X 2 L 1 (X ) r (a term, its reduction by r) Ex : β (a l x, y, x[y]) L 1 (Sigma) 2-CCCAT and HORS June 7, 2014 11 / 21
Construction Step 3: The adjunction A similar approach: Defining a monad L over Sig Reductions are generated by a 2λ-calculus: Context rules : Γ, x A, x x x A Γ, x A P M N B Γ (λx A.P) λx A.M λx A.N B A Γ P 1 M 1 N 1 G 1... Γ P n M n N n G n Γ c P 1,..., P n c M 1,..., M n c N 1,..., N n A (c X1(G A))... Special rule :... Γ P i M i N i G i... Γ r P 1,..., P n M[M 1,..., M n ] N[N 1,..., N n ] A (r X (G M,N A)) Modulo some equations... to get a structure close to the 2-CCC 2-CCCAT and HORS June 7, 2014 12 / 21
Construction Example of equation Equivalence rules := β and η equivalences, equivalence by permutation,... (λx.m)n Example: (λx.m )N M[x N] M [x N ] Left reduction: a l λx t.p, Q ; β λx t.m, N β λx t.p, Q β λx t.m, N ; (λx t.p)q β λx t.m, N ; P[x Q] : Right reduction. 2-CCCAT and HORS June 7, 2014 13 / 21
Construction What we get An adjunction: H Sig 2-CCCat models for Σ : morphisms H(Σ) C in 2-CCCat What does that mean? l t W t t t t t t. ev β a 2-CCCAT and HORS June 7, 2014 14 / 21
Some Details composition of maps 2-CCCAT and HORS June 7, 2014 15 / 21
Représentation du λ-calcul par valeur Context Construction Représentation du λ-calcul par valeur 2-CCCAT and HORS June 7, 2014 16 / 21
Représentation du λ-calcul par valeur 2-Signature du λ-calcul en CBV Σ Λ = ({t}, { l [tt ] t a [t, t] t Σ ΛCBV = ({t, v}, restreindre β l [t v ] v a [t, t] t r [v] t }, { β a l x, y x(y) } ), { β a r l x, r y x(y) }) valeur type v Λ(n) v Λ(n) constructeur r t v v l v v v r r ev β t t a t 2-CCCAT and HORS June 7, 2014 17 / 21
Représentation du λ-calcul par valeur Représentations équivalentes? Ce qu il fallait montrer 1. Λ CBV (n) L 1 (Σ ΛCBV ) 1 (x 1 v,..., x n v, t) et Λ v CBV (n) L 1(Σ ΛCBV ) 1 (x 1 v,..., x n v, v) 2. Commutativité avec la substitution par valeur 3. Fidélité à la réduction : bissimulation 2-CCCAT and HORS June 7, 2014 18 / 21
Sources T. Hirschowitz, Cartesian closed 2-categories and permutation equivalence in higher-order rewriting HAL : hal-00540205, version 2 (2011) R. Crole Categories for Types, Cambridge Mathematical Textbooks (1993) Chap.1-2,3-4 S. Awodey, Category Theory, Oxford Logic Guides 52 (2010) 2-CCCAT and HORS June 7, 2014 19 / 21
Idées Idée 1 Utiliser un cadre catégorique pour spécifier la sémantique des langages. Idée 2 Utiliser un λ-calcul simplement typé, paramétré, comme support de construction. D où on part : Spécification des syntaxes avec lieurs Syntaxe avec lieurs λ-calcul simplement typé paramétré par une 1-signature Catégorie Sig 1 de 1-signatures Monade L 1 sur Sig 1 : termes engendrés Ce qu on propose : Spécification des systèmes de récriture avec lieurs raffiner les 1-signatures 2-signatures Réductions 2λ-calcul simplement typé paramétré par Σ Catégories, monades, etc. 2-CCCAT and HORS June 7, 2014 20 / 21
Retour sur l exemple Plus de termes dans L 1 (Σ) que dans Λ Repose sur la correspondance: Exemples: λx.m = l λx. M Termes du λ-calcul pur avec n variables libres Termes sur Σ tels que x 1 t,..., x n t M t MN = a M, N x = x 2-CCCAT and HORS June 7, 2014 21 / 21