Towards a Flowchart Diagrammatic Language or Monad-based Semantics Julian Jakob Friedrich-Alexander-Universität Erlangen-Nürnberg julian.jakob@au.de 21.06.2016
Introductory Examples 1 2 + 3 3 9 36 4 while do What is the most general ormalization or such diagrams?
Overview 1 Basic Deinitions 2 Traces, Fixpoints and Iteration 3 Algebraic Operations and Generic Eects
Diagrammatic Language edges: nodes: crossing: eedback node: strict node:
Deinition Deinition as in algebraic type theory: edges = base edge base edge parallel to edge nodes = base node crossing eedback node node sequential to base node strict nodes
Categories In short, a category C is given by: Collection o objects Ob(C) Collection o morphisms Hom(C) Two operations assigning to each morphism its source src( ) Ob(C) and its target tar( ) Ob(C), written : src( ) tar( ). There is an operation assigning to each pair o composable morphisms and g their composition which is a morphism denoted by g or just g and such that src(g ) = src( ) and tar(g ) = tar(g). There is also an operation assigning to each object A Ob(C) an identity morphism id A : A A. These operations are required to be unitary and associative.
Diagrams or Categories Object A: A Morphism : A B: Identity id A : A A: A A B Composition g : A C or : A B and g : B C: A B C g
Formal Descriptions Deinition (Selinger (2011), Signature) A simple categorical signature Σ consists o a set Σ 0 o object variables, a set Σ 1 o morphism variables, and a pair o unctions dom, cod : Σ 1 Σ 0. Object variables are usually written A,B,C,..., morphism variables are usually written,g,h,..., and we write : A B i dom( ) = A and cod( ) = B. Deinition (Selinger (2011), Interpretation) An interpretation i o a signature Σ a category C consists o a unction i 0 : Σ 0 Ob(C), and or any Σ 1 a morphism i 1 ( ) : i 0 (cod( )) i 0 (dom( )).
Coherence Deinition (Selinger (2011), Coherence) A graphical language is coherent, i it is sound and complete. It is sound, i all the axioms o the category are automatically satisied in the graphical language up to isomorphism o diagrams. It is complete i the ollowing condition is true: every equation that is true in the graphical language is a consequence o the axioms.
Soundness o the Diagrammatic Language or Categories Let Identity: A B A = B Right Identity: A B A = B Associativity: A B C D g h A B C D = g h
Monoidal Categories A monoidal category M has additional structure: A unctor : M M M called the tensor product. An object 1 Ob(M) called the unit object. A natural isomorphism a x,y,z : (x y) z x (y z) called the associator. A natural isomorphism λ x : 1 x x called the let unitor. A natural isomorphism ρ x : x 1 x called the right unitor.
Diagrammatic Language or Monoidal Categories Tensor product A B: A Tensor product g : A C B D: Unit object I : A C B g B D
Coherence or Monoidal Categories Theorem (Joyal/Street (1991), Coherence or Monoidal Categories) A well-ormed equation between morphism terms in the language o monoidal categories ollows rom the axioms o monoidal categories i and only i it holds, up to planar isotopy, in the graphical language.
Symmetry A symmetric monoidal category additionally is equipped with a natural isomorphism, called symmetry B x,y : x y y x Symmetry B A,B : A B B A
Coherence or Symmetric Monoidal Categories Theorem (Selinger (2011), Coherence or Symmetric Monoidal Categories) A well-ormed equation between morphisms in the language o symmetric monoidal categories ollows rom the axioms o symmetric monoidal categories i and only i it holds, up to isomorphism o diagrams, in the graphical language.
Traced Monoidal Categories Deinition (Traced Monoidal Categories) A symmetric monoidal category (C,, 1, b) (where b is the symmetry) is said to be traced i it is equipped with a natural amily o unctions TrA,B : C(A, B ) C(A, B) satisying ive axioms: it is natural in A and B (let/right tightening), and dinatural in (sliding) vanishing: Tr Y A,B ( ) = Tr A,B (Tr A Y,B ( ))( : A Y B Y ) superposing: TrC A,C B (id C ) = id C TrA,B ( )( : A B ) yanking: Tr, (b, ) = id
Axioms or Traced Categories Trace: Naturality (Let Tightening): h = h Naturality (Right Tightening): h = h
Axioms or Traced Categories Dinaturality (Sliding): h = h Vanishing(I): = I Vanishing ( ): =
Axioms or Traced Categories Superposing: = Yanking: =
Coherence or Traced Categories Theorem (Joyal/Street (1991), Coherence or Traced Monoidal Categories) A well-ormed equation between morphisms in the language o symmetric traced categories ollows rom the axioms o symmetric traced categories i and only i it holds in the graphical language up to isomorphism o diagrams.
Strictness Deinition (Hasegawa (2003), Strictness) Consider a traced monoidal category C with trace Tr. We say h : Y is strict in C (with respect to the trace Tr) i the ollowing condition holds: For any : A B and g : A Y B Y, (id B h) = g (id A g) : A B Y A B A Y id A h g B Y id B h implies TrA,B ( ) = Tr A,B Y (g) : A B.
Strictness Strictness: A B A Y h = Y h g B Y A B A B = g
Uniormity Deinition (Hasegawa (2003), Uniormity) Let C be a traced monoidal category with trace Tr, and S be a class o arrows o C. We say Tr is uniorm (or: Tr satisies the uniormity principle) or S i, or any h : Y o S, the condition o strictness holds.
Trace-Fixpoint Correspondence Theorem (Hasegawa (1997), Conway Operator Correspondence to Traces) For any category with inite products, to give a Conway operator is to give a trace (where inite products are taken as the monoidal structure). : A = Tr A, ( ) : A g : A B Tr A,B (g) = π B, (g (id A π B, )) : A B
Diagrammatic Language or Product Categories A inite product category can be described as a symmetric monoidal category, together with natural amilies o copy and erase maps, with a number o axioms (omitted here, see Selinger (2011)). A : A A A (copy) A A A! A : A 1 (erase) A
Some Axioms or the Graphical Language = = = =
Coherence or Traced Product Categories Theorem (Selinger (2011), Coherence or Traced Product Categories) A well-ormed equation between morphism terms in the language o traced product categories ollows rom the respective axioms i and only i it holds in the graphical language, up to isomorphism o diagrams, and the diagrammatic manipulations corresponding to the axioms.
Conway Operators Deinition (Simpson/Plotkin (2000), Conway Operator) A parameterized ixpoint operator on C is a amily o unctions ( ) : C(A, ) C(A, ) which is natural in A and satisies the ixpoint equation = id A, : A or : A. A Conway operator on C is a parameterized ixpoint operator ( ) which satisies dinaturality: ( st A,, g ) = id A, (g st A,Y, ) : A or : A Y and g : A Y diagonal property: ( (id A )) = ( ) : A or : A.
Uniormity or Conway Operators Deinition (Hasegawa (2003), Plotkin s Principle) Let ( ) be a parameterized ixpoint operator on a category with inite products. We say h : Y is strict (with respect to ( ) ) i the ollowing condition holds: For any : A and g : A Y Y,h = g (id A h) A A Y id A h implies g = h : A Y. g Y h
Dualities Products are dual to coproducts. Traced coproduct categories can be constructed in the same way as product categories, i.e. a symmetric monoidal category plus maps A : A + A A and! A : 0 A (given a coproduct structure). The axioms are dual to the axioms or traced product categories. The distinction does not matter or deinitions o Conway operators or similar notions.
Monads Deinition (Moggi (1991), Kleisli Triple) A Kleisli triple over a category C is a triple (T ; η; ), where T : Ob(C) Ob(C), η A : A TA or A Ob(C), : TA TB or : A TB and the ollowing equations hold: ηa = id TA (1) η A = or : A TB (2) g = (g ) or : A TB and g : B TC (3)
Elgot Monads Deinition (Complete Elgot Monad) A monad T over C is a complete Elgot monad i it possesses an operator, called iteration, sending any : T (Y + ) to : TY satisying the ollowing conditions: ixpoint: [η, ] = ; naturality: g = ([T (inl) g, η inr] ) or any g : Y TZ; codiagonal: (T ([id, inr]) g) = g or any g : T ((Y + ) + ); uniormity: h = T (id h) g h = g or any g : Z T (Y + Z) and h : Z
Elgot Monads Fixpoint: Y = Y Y Naturality: Y g Z = g Y Z
Elgot Monads Uniormity: Z h Y Z = g h Y Z Z h Y Z = g Y Z
Elgot Monads Codiagonal: g Y = g Y
Elgot Monads g Y = g Y = g Y = g Y
Elgot Monads g Y = g Y
Algebraic Operations Deinition (Algebraic Operation) Given a monad T on a symmetric monoidal category C, an algebraic operation α on T is a amily o maps (T ) v (T ) w, demanding that the exponentials (T ) v and (T ) w exist in C, such that ( ) id α = α Y ( ) id : T ( Y ) w T ( Y ) w. Further, the ollowing interaction between exponentials and the strength must commute: τ w (id α Y ) = α v τ v : TY T ( Y ) w, where τ z = curry(τ(id ev) assoc) : A TB z T (A B) z or any z, assoc being the obvious associativity o the tensor.
Algebraic Operations (T ) v α (T ) w ( ) id ( ) id (TY ) v TY v α Y id α Y (TY ) w TY w τ v τ w T ( Y ) v α v T ( Y ) w
Example: Nondeterminism To express nondeterminism we can use the powerset monad T = P. The algebraic operation is v : (T ) 2 T with v(u, v) = u v. This means, or two possible continuations both are possible or put dierently one is chosen nondeterministically.
Generic Eect Deinition (Generic Eect) Given an monad T, a generic eect is any Kleisli morphism : n Tm. Equivalently, i C = Sets, and n N, : n Tm is given by a tuple ( 1 Tm,..., n Tm).
Generic Eects or the Nondeterminism Monad In nondeterminism the generic eects are: stop : 1 T 0 toss : 1 T 2 Our monad is the powerset monad, so T 0 = P0 corresponds to the set with the single element being the empty set and T 2 = P2 is the powerset o the set {1, 2}, which is {, {1}, {2}, {1, 2}}.
Diagrammatic Representation or Generic Eects Example: Nondeterminism. From toss : 1 T 2, where T 2 = T (1 + 1), one can construct Toss : T ( + ) in the ollowing way id toss τ 1 T 2 T ( (1 + 1)) T dist T ( (1 + 1)) T ( + ) Toss: Toss
Duality Theorem (Duality) To construct an algebraic operation α x : (T ) v (T ) w rom a generic eect g : w Tv, there is the sequence id,id uncurry(α v curry(η snd)) w w w Tv with curry(η snd) w (Tv) v α v (Tv) w uncurried. To ind a term α x : (T ) v (T ) w given g : w Tv, we need to curry the ollowing: (T ) v id g w (T ) v τ Tv T ((T ) v ev v) T
Proo For the proo the ollowing equations have been veriied: α x = curry(ev τ(id g)) g = uncurry(α v curry(η snd)) id, id ( ) id curry(ev τ(id g)) = curry(ev τ(id g)) ( ) id τ w (id curry(ev τ(id g))) = curry(ev τ(id g))τ v
Reerences Peter Selinger (2011) A Survey o Graphical Languages or Monoidal Categories New Structures or Physics Lecture Notes in Physics Volume 813, pp 289-355. Springer Verlag. Andre Joyal, Ross Street (1991) The geometry o tensor calculus I Advances in Mathematics 88(1), pp 55-112. Masahito Hasegawa (2003) The Uniormity Principle on Traced Monoidal Categories Electronic Notes in Theoretical Computer Science Volume 69, pp 137-155. Masahito Hasegawa (1997) Recursion rom cyclic sharing: traced monoidal categories and models o cyclic lambda calculi Proc. Typed Lambda Calculi and Applications (TLCA?97) Springer Lecture Notes in Computer Science 1210, pp 196?213.. Eugenio Moggi (1991) Notions o Computation and Monads Inormation and Computation Volume 93, pp 55-92. Alex Simpson, Gordon Plotkin (2000) Complete axioms or categorical ixed-point operators Proc. 15th Logic in Computer Science LICS 2000, pp 30?41.
The End