Programming Languages in String Diagrams. [ four ] Local stores. Paul-André Melliès. Oregon Summer School in Programming Languages June 2011

Similar documents
An introduction to Yoneda structures

Local states in string diagrams

A categorical view of computational effects

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

MONADS WITH ARITIES AND THEIR ASSOCIATED THEORIES

Towards a Formal Theory of Graded Monads

Quantum groupoids and logical dualities

Algebraic theories in the presence of binding operators, substitution, etc.

arxiv:math/ v1 [math.ct] 1 Apr 2004

Completed power operations for Morava E-theory

MacLane s coherence theorem expressed as a word problem

What are Sifted Colimits?

Categories and functors

arxiv: v1 [math.ct] 11 May 2018

Notions of Computation Determine Monads

Category Theory. Categories. Definition.

PART I. Abstract algebraic categories

Algebra and local presentability: how algebraic are they? (A survey)

SOME PROBLEMS AND RESULTS IN SYNTHETIC FUNCTIONAL ANALYSIS

Applications of 2-categorical algebra to the theory of operads. Mark Weber

Logical connections in the many-sorted setting

Effect Algebras, Presheaves, Non-locality, Contextuality

Semantics for algebraic operations

Derived Algebraic Geometry III: Commutative Algebra

LOCAL VS GLOBAL DEFINITION OF THE FUSION TENSOR PRODUCT

Infinite-dimensionality in quantum foundations

Categories and Modules

Lecture 9: Sheaves. February 11, 2018

Theories With Duality DRAFT VERSION ONLY

LECTURE X: KOSZUL DUALITY

Logic for Computational Effects: work in progress

Congruence Boolean Lifting Property

Axiomatics for Data Refinement in Call by Value Programming Languages

On the Construction of Free Algebras for Equational Systems

ON THE HOMOTOPY THEORY OF ENRICHED CATEGORIES

An introduction to locally finitely presentable categories

Derived Algebraic Geometry IX: Closed Immersions

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

1. Introduction. Let C be a Waldhausen category (the precise definition

Homotopical versions of Hall algebras

Sheaves of C*-Algebras

Derived Algebraic Geometry I: Stable -Categories

FUNCTORS AND ADJUNCTIONS. 1. Functors

Multitopes are the same as principal ordered face structures

ALGEBRAIC THEORIES A CATEGORICAL INTRODUCTION TO GENERAL ALGEBRA. J. Adámek, J. Rosický, E. M. Vitale. With a Foreword by F. W.

FOUNDATIONS OF ALGEBRAIC GEOMETRY CLASS 2

Second-Order Algebraic Theories

PART II.2. THE!-PULLBACK AND BASE CHANGE

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

What are Iteration Theories?

Programming Languages in String Diagrams. [ one ] String Diagrams. Paul-André Melliès. Oregon Summer School in Programming Languages June 2011

in path component sheaves, and the diagrams

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

Abstracting away from cell complexes

Boolean Algebras, Boolean Rings and Stone s Representation Theorem

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

Category Theory. Travis Dirle. December 12, 2017

PART II.1. IND-COHERENT SHEAVES ON SCHEMES

PART III.3. IND-COHERENT SHEAVES ON IND-INF-SCHEMES

FAMILIAL 2-FUNCTORS AND PARAMETRIC RIGHT ADJOINTS

IndCoh Seminar: Ind-coherent sheaves I

Polynomial functors and trees

Fock Spaces. Part 1. Julia Singer Universität Bonn. From Field Theories to Elliptic Objects Winterschule Schloss Mickeln

MORITA EQUIVALENCE OF MANY-SORTED ALGEBRAIC THEORIES

COMBINATORICS OF POLYHEDRA FOR n-categories

Direct Limits. Mathematics 683, Fall 2013

Second-Order Equational Logic

What are Iteration Theories?

POSTNIKOV EXTENSIONS OF RING SPECTRA

Instances of computational effects: an algebraic perspective

CGP DERIVED SEMINAR GABRIEL C. DRUMMOND-COLE

C2.7: CATEGORY THEORY

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.,

New York Journal of Mathematics. Directed algebraic topology and higher dimensional transition systems

A few bridges between operational and denotational semantics of programming languages

Cellularity, composition, and morphisms of algebraic weak factorization systems

arxiv:math/ v4 [math.ct] 14 Jun 2007

Symbol Index Group GermAnal Ring AbMonoid

On a Categorical Framework for Coalgebraic Modal Logic

LOCALIZATIONS, COLOCALIZATIONS AND NON ADDITIVE -OBJECTS

The algebraicity of the lambda-calculus

Higher-Dimensional Algebra III: n-categories and the Algebra of Opetopes John C. Baez and James Dolan

Equivariant Trees and G-Dendroidal Sets

Second-Order Equational Logic

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

Operads. Spencer Liang. March 10, 2015

Topological algebra based on sorts and properties as free and cofree universes

Complex Systems from the Perspective of Category. Theory: II. Covering Systems and Sheaves

Sheaf models of type theory

Higher Categories, Homotopy Theory, and Applications

NOTES ON ATIYAH S TQFT S

arxiv: v2 [math.ct] 12 Oct 2016

Dual Adjunctions Between Algebras and Coalgebras

Higher Prop(erad)s. Philip Hackney, Marcy Robertson*, and Donald Yau UCLA. July 1, 2014

Kleisli Category and Database Mappings

FROM COHERENT TO FINITENESS SPACES

Categories and Natural Transformations

Symmetric monoidal sketches

Morita-equivalences for MV-algebras

Mix Unitary Categories

Transcription:

Programming Languages in String iagrams [ four ] Local stores Paul-André Melliès Oregon Summer School in Programming Languages June 2011

Finitary monads A monadic account of algebraic theories

Algebraic presentations of effects We want to reason about programs with effects like states, exceptions... Computational monads: A pimpurep B = A ppurep T (B) Algebraic theories: operations : A n A and equations

A useful correspondence Recall that a monad T : Set Set is finitary when it preserves the filtered colimit. Important fact. There is an equivalence of categories the category of algebraic theories the category of finitary monads 4

Finitary monads Alternative definition. A monad T : Set Set is finitary when the diagram FinSet Set T i id i T Set exhibits the functor T as a left Kan extension of T i along i. 5

Finitary monad A monad T on the category Set is finitary when every map [1] TA factors as [1] e T [p] T f TA for a pair of maps [1] T [p] [p] A. 6

Finitary monad Moreover, the factorization should be unique up to zig-zag: [1] e 1 e 2 T [p] T f 1 Tu T [q] T f 2 TA 7

The Kleisli category of a monad The Kleisli category Set T associated to a monad T : Set Set has sets as objects, and functions f : A T(B) as morphisms from A to B. An alternative formulation of the category of free algebras. 8

The Lawvere theory of a monad The Lawvere theory Θ T associated to a monad T : Set Set is the full subcategory of Set T with finite ordinals [p] = { 0, 1,..., p 1 } as objects. Remark. The category Θ T has finite sums. 9

Algebras of a monad A set A equipped with a function alg : TA A making the two diagrams below commute: TTA T ( alg ) TA µ alg TA alg A A η A TA id alg A 10

Key theorem [ originating from Lawvere ] The category of T-algebras is equivalent to the category of finite product preserving functors Θ op T Set This property holds for every finitary monad T. 11

Finitary monads as saturated theories The finitary monad describes the equational classes of the theory : Tn = terms with n variables modulo equations where n = x 0, x 1,, x n 1 The monad often reveals a canonical form for the equational theory.

Mnemoids An algebraic presentation of the state monad

The state monad A program accessing one register with a finite set V of values A impure B is interpreted as a function V A pure V B thus as a function A pure V (V B) Hence, the state monad T : A V (V A) 14

What is an algebra of the state monad? An elegant answer by Plotkin and Power [2002]

Mnemoids A mnemoid is a set A equipped with a V-ary operation lookup : A V A and a unary operation update val : A A for each value val V. 16

Mnemoids Typically, the lookup operation on the boolean space V = { false, true } is binary : lookup : A A A The intuition is that lookup (u, v) = { u v when the register is false when the register is true 17

Annihilation lookup update update V A A V lookup id A term = lookup val update val term 18

Annihilation lookup update Here, the map update V : A A V is the V-ary vector update 0,, update V 1 also noted val update val 19

Annihilation lookup update x = x x true false 20

Interaction update update update val2 A A update val2 update val1 A update val1 update val 2 = update val2 21

Interaction update update val 2 val 1 = val 2 22

Interaction update lookup A V lookup A A val update val A update val A update val lookup x term(x) = update val term(val) 23

Interaction update lookup x y = true x true 24

Key theorem [ Plotkin & Power ] the category of mnemoids is equivalent to the category of algebras of the state monad Provides an algebraic presentation of the state monad 25

A proof in three steps 1. establish that the state monad T is finitary [easy] 2. construct a functor [easy] ι : Θ M Θ T starting from the Lawvere theory Θ M of mnemoids by interpreting the update and lookup operations and by checking that the equations are valid in Θ T 3. show that the functor ι is full and faithful [rewriting] 26

Store with several locations Algebraic presentation of the state monad

The global state monad The state monad is generally defined as T : A S (S A) for a set of states S = V L induced by a set L of locations and a finite set V of values. 28

Global store [Plotkin & Power ] A global store is a family of compatible mnemoidal structures lookup loc : A V A update loc,val : A A one for each location loc L. A tensor product of algebraic theories 29

Annihilation lookup update update loc,v A A V id A lookup loc lookup loc val update loc,val term = term 30

Annihilation lookup update x true x = x false 31

Interaction update update update loc,val A A update loc,val update loc,val A update loc,val1 update loc,val 2 = update loc,val2 32

Interaction update update val 1 val 2 = val 2 33

Interaction update lookup A V lookup loc A A val update loc,val A update loc,val A update loc,val lookup loc x term(x) = update loc,val term(val) 34

Interaction update lookup x true = x true y 35

Interaction update lookup x false = y false y 36

Commutation update update A update loc,val A update loc,val update loc,val A update loc,val A update loc,v update loc,v x = update loc,v update loc,v x when loc loc 37

Commutation update update val = val val val 38

Corollary [ Plotkin & Power ] the category of objects with a global store is equivalent to the category of algebras of the state monad 39

Graded monads A stratified version of finitary monads

Presheaf models Key idea: interpret a type A as a family of sets A [0] A [1] A [n] indexed by natural numbers, where each set A [n] contains the programs of type A which have access to n variables. 41

Presheaf models This defines a covariant presheaf A [n] : Inj Set on the category Inj of natural numbers and injections. The action of the injections on A are induced by the operations defined for 0 loc n. collect loc : A [n] A [n+1] 42

Local stores [Plotkin Power] The slightly intimidating monad TA : n S [n] p Inj S [p] A [p] Inj(n, p) on the presheaf category [Inj, Set] where the contravariant presheaf S [p] = V p describes the states available at degree p. 43

Graded arities A graded arity is defined as a finite sum of representables [ p 0,, p n ] = 0 + + 0 } {{ } p 0 times + + n + + n } {{ } p n times where each representable presheaf n : Inj Set is defined as n = p Inj(n, p) 44

Graded arities This defines a full and faithful functor Σ Inj op Inj op which generalizes the full and faithful functor FinSet Set encountered in the case of finitary monads. 45

Graded monads efinition. A monad T : [Inj, Set] [Inj, Set] is graded when the diagram Σ Inj op T i [Inj, Set] id i T [Inj, Set] exhibits the functor T as a left Kan extension of T i along i. 46

Graded monad A monad T on the category [Inj, Set] is graded when every map n TA factors as n e T [p 0,..., p k ] T f TA for a pair of maps n T [p 0,..., p k ] [p 0,..., p k ] A. 47

Graded monad Moreover, the factorization should be unique up to zig-zag: n e 1 e 2 T [p 0,, p i ] Tu T [q 0,, q j ] T f 1 T f 2 TA 48

Motivating example Theorem. The local state monad TA : n S [n] p Inj S [p] A [p] Inj(n, p) is a graded monad on the presheaf category [Inj, Set]. 49

Graded theories A stratified version of algebraic theories

The Lawvere theory of a graded monad The Lawvere theory Θ T associated to a graded monad T : [Inj, Set] [Inj, Set] is the full subcategory of [Inj, Set] T with the graded arities [ p 0,, p n ] as objects. Remark. The category Θ T has finite sums. 51

Modules over the category Inj An Inj-module is a category A equipped with an action : Inj A A (m, A) m A satisfying the expected properties: (p + q) A = p (q A) 0 A = A 52

Modules over the category Inj A category A equipped with an endofunctor : A A and two natural transformations permute : collect : Id depicted as follows in the language of string diagrams: 53

Yang-Baxter equation = 54

Symmetry = 55

Interaction dispose permute = = 56

Graded theories A graded theory is a category with finite products with objects [ p 0,, p n ] = 0 0 } {{ } p 0 times n n } {{ } p n times equipped with an action of the category Inj satisfying (A B) A B (1) 1 In particular [ p 0,, p n ] = [ 0, p 0,, p n ] 57

The trivial graded theory Σ Inj op is the free Inj-module with finite sums such that (A + B) A + B (0) 0 Π Inj is the free Inj-module with finite products such that (A B) A B (1) 1 58

The graded theory of local stores Let מ be the graded theory associated to the monad of local stores. Fact. מ is the free Inj-module with finite sums such that (A + B) A + B (0) 0 such that is a dynamic mnemoid. 59

ynamic mnemoids A dynamic mnemoid is a pair of sets A [0] A [1] equipped with the following operations lookup : A V [1] A [1] update val : A [1] A [1] fresh val : A [1] A [0] collect : A [0] A [1] satisfying a series of basic equations. 60

Garbage collect : fresh dispose val = id 61

Interaction fresh update val 2 val 1 = val 2 62

Interaction fresh lookup x y = true x true x y = false y false 63

Model of a graded theory A model of a graded theory מ is a functor M : מ [Inj, Set] which preserves the finite products and the action of. A stratified version of the usual algebraic theories 64

The graded theory of local mnemoids Main theorem [after Plotkin and Power] The category of models of the theory מ of local mnemoids is equivalent to the category of algebras of the local state monad 65

Local stores in string diagrams A graphical account of memory calls

Annihilation lookup update x true x = x false The equation (A B) A B means that space commutes with time ramification!!!

Interaction update update val 1 val 2 = val 2 68

Interaction update lookup x true = x true y 69

Interaction update lookup x false = y false y 70

Interaction fresh dispose val = 71

Interaction fresh update val 2 = val 1 val 2 72

Interaction fresh lookup x true = y true y 73

Interaction fresh lookup x false = y false y 74

Interaction fresh permutation val = val 75

The Segal condition A basic tool in higher dimensional algebra 76

In higher dimensional algebra Exactly the same categorical combinatorics!!! 77

In higher dimensional algebra A globular set is defined as a contravariant presheaf over the category defined by the equations 0 s t 1 s t 2 s t s s = s t t s = t t An ω-category is then defined as an algebra of a particular monad T. Is the notion of ω-category equational? 78

Level 1 : the free category monad A category C is a graph where every path A 0 f 1 A 1 f 2 A 2 f 3 f n A n defines an edge A 0 n ( f 1,, f n ) A n where the operations n are required to be associative. the arities of the theory are finite paths rather than finite sets

Category with arities A fully faithful and dense functor where Θ 0 is a small category. i 0 : Θ 0 A Typical example: the full subcategory Θ 0 of linear graphs [n] = 0 1 n in the category Graph. 80

The nerve functor This induces a fully faithful functor nerve : A Θ 0 which transports every object A of the category A into the presheaf nerve : Θ 0 Set p A( i 0 p, A ) 81

The nerve functor

efinition of a monad T with arity the functor T is the left kan extension of T i 0 along the functor i 0 T i 0 A id T Θ 0 i 0 A This enables to reconstruct T from its restriction to the arities 83

Monads with arities this left kan extension is preserved by the nerve functor: Θ 0 nerve T i 0 A id T Θ 0 i 0 A 84

A purely combinatorial formulation For every object A, the canonical morphism p Θ0 A(i0 n, Ti 0 p) A(i 0 p, A) A(i 0 n, TA) is an isomorphism. 85

Unique factorization up to zig-zag Every map n TA in the category A decomposes as n e Tp T f TA A finite number of words encounters a finite number of letters A finite path in the free category TA encounters a finite path in A 86

Unique factorization up to zig-zag The factorization should be unique up to zig-zag of i 0 n e 1 e 2 Ti 0 p Ti 0 q T f 1 Ti 0 u T f 2 TA 87

Model of an algebraic theory A model A of a Lawvere theory L is a presheaf A : Θ op L such that the induced presheaf Set Θ op 0 i 0 Θ op L A Set is representable along i 0. 88

Key theorem The category of T-modules is equivalent to the category of models of the theory Θ T This property holds for every monad T with arities Θ 0. 89

Algebraic theories with arities A 2-dimensional approach to Lawvere theories 90

Algebraic theory with arities An algebraic theory L with arities i 0 : Θ 0 A is an identity-on-object functor L : Θ 0 Θ L such that... 91

Algebraic theories with arities... there exists a functor F : A A making the diagram Θ 0 L ΘL L Θ0 nerve nerve A F A commute up natural isomorphism. 92

Algebraic theories with arities nerve(a) Set Θ op 0 L left Kan extension Θ op L This simply means that the free construction works... 93

Theorem the category of algebraic theories with arity (A, i 0 ) is equivalent to the category of monads with arity (A, i 0 ) This generalizes the traditional correspondence algebraic theories finitary monads Also extends the result by Power on enriched Lawvere theories 94