Graphical Linear Algebra PhD Open, University of Warsaw Pawel - - PowerPoint PPT Presentation

graphical linear algebra
SMART_READER_LITE
LIVE PREVIEW

Graphical Linear Algebra PhD Open, University of Warsaw Pawel - - PowerPoint PPT Presentation

Graphical Linear Algebra PhD Open, University of Warsaw Pawel Sobocinski University of Southampton joint work with Filippo Bonchi, and Fabio Zanasi important contributions from Dusko Pavlovic, Fabio Gadducci, Aleks Kissinger, Brendan Fong and


slide-1
SLIDE 1

Graphical Linear Algebra

Pawel Sobocinski University of Southampton

graphicallinearalgebra.net

joint work with Filippo Bonchi, and Fabio Zanasi

PhD Open, University of Warsaw

important contributions from Dusko Pavlovic, Fabio Gadducci, Aleks Kissinger, Brendan Fong and Paolo Rapisarda

slide-2
SLIDE 2

What will you get out of this?

  • An introduction to symmetric monoidal categories and diagrammatic reasoning, an important tool in
  • quantum computing and quantum information (Abramsky, Coecke, Pavlovic, Duncan, Kissinger, …)
  • asynchronous circuits (Ghica)
  • signal flow graphs (Bonchi, S., Zanasi)
  • linear time-invariant dynamical systems (Baez, Erbele, Fong, Rapisarda, S.)
  • A different way to think about several concepts of linear algebra!
  • linear algebra is everywhere (quantum, machine learning, systems and control theory, graph theory, …)
  • a different language means different ways to think about applications, and it is sometimes more efficient

than the classical concepts of matrices, bases, etc.

  • a nice calculus for recurrence relations
  • An introduction to several algebraic structures that are quite common in computational models
  • e.g. monoids, comonoids, Frobenius monoids, bimonoids, Hopf algebras, …
slide-3
SLIDE 3

More generally: 2-dim syntax

  • Ordinary, tree-like syntax, together with its operations (tuples,

substitution) is good in situations where all operations have a coarity 1

  • i.e. operations of the form X

n → X

  • This often goes together with the implicit assumption that the resources

in X are copyable and discardable

  • In many situations (e.g. quantum, many kinds of circuits) we have to be

more careful with resources — here tree-like syntax can be less natural

  • the language of symmetric monoidal categories provides the

algebra for this syntax

  • the language of string diagrams provides a nice notation
slide-4
SLIDE 4

What I will not assume

  • That you know about category theory
  • we will introduce categorical notions only when

needed

  • we will concentrate, in particular, on the class of

categories called strict symmetric monoidal categories

slide-5
SLIDE 5

Plan

  • symmetric monoidal categories and string diagrams
  • algebra of magic Lego
  • categories
  • monoidal categories
  • string diagrams
  • symmetric monoidal categories
  • algebraic theories
  • symmetric monoidal theories
  • props
  • theory of natural number matrices (bimonoids) and integer matrices (Hopf monoids)
  • theory of linear relations (interacting Hopf monoids)
  • distributive laws
  • linear algebra, diagrammatically
  • an application: generating functions and signal flow graphs
slide-6
SLIDE 6

Algebra of magic Lego

⊕ -

stacking one on top of the other

= ⊕ = ⊕

associative but not commutative

;

  • plugging the first into

the second

; = ; =

associative but not commutative

“stacking things and plugging them together”

slide-7
SLIDE 7

Combining operations

(

) ;

(

) =

⊕ ⊕ = ;

( (

) )

slide-8
SLIDE 8

A simple type system

: (2, 2) : (4, 4) : (2, 0)

X : (k, l) Y : (m, n) X⊕Y : (k+m, l+n)

X : (k, l) Y : (l, m) X;Y : (k, m)

number of holes number of studs

slide-9
SLIDE 9

The magic in magic Lego

X : (k, l) Y : (m, n) X⊕Y : (k+m, l+n)

⊕ = X : (k, l) Y : (l, m) X;Y : (k, m)

; = ?

; =

Pieces stretch and shrink as needed — the only important thing is the type (number of holes, number of studs)

slide-10
SLIDE 10

The mathematics of magic Lego

  • “stacking things on top of each other” and

“plugging things together” are very common

  • perations in science and mathematics
  • the mathematical structure that’s behind these
  • perations is called a (strict) monoidal category
  • let’s start with categories…
slide-11
SLIDE 11

Categories

  • A category C, seen as a mathematical structure,

consists of two sets: objects and arrows

  • think of objects as types
  • think of arrows as operations
  • every arrow C has two associated objects k, m,

called domain and codomain, written C : k → m

slide-12
SLIDE 12
  • Every object has an identity arrow (think of this as

a trivial “do-nothing” operation) Ik : k → k

slide-13
SLIDE 13

Operations on arrows

  • There is a partial operation or arrows ; called

composition

C : k → l D: l → m C ; D : k → m

— like the plugging in magic Lego

slide-14
SLIDE 14

Associativity

  • Composition is associative, i.e.

C : k → l D : l → m E : m → n (C ; D) ; E = C ; (D ; E) : k → n

slide-15
SLIDE 15

Composing identities

  • Composing with identity arrows on both sides does

not change the arrow, i.e. C : m → n Im ; C = C = C ; In

slide-16
SLIDE 16

Examples of (small) categories

  • 0 - the empty category
  • 1 - the category with one object * and one arrow
  • Exercise: check that everything works
  • 2 - the category with objects {0,1}, one non-identity arrow 0 → 1.
  • Exercise: check that everything works
  • Any preorder is a category with
  • objects the elements of X, and at most one arrow between any 2 objects:

x→y iff x≤y.

  • conversely, any category with at most one arrow from any object to another

is a preorder.

slide-17
SLIDE 17

Examples of (big) categories

  • Set
  • Objects: sets
  • Arrows: functions
  • Setf
  • Objects: finite sets
  • Arrows: functions
  • Rel
  • Objects: sets
  • Arrows: relations
  • Mon
  • Objects: monoids
  • Arrows: homomorphisms
  • Top
  • Objects: topological spaces
  • Arrows: continuous functions
  • Cat
  • Objects: categories
  • Arrows: functors
slide-18
SLIDE 18

Monoidal categories

  • A (strict) monoidal category C, seen as a mathematical

structure, consists of two sets: objects and arrows

  • think of objects as (products of) types
  • think of arrows as operations
  • every arrow C has two associated objects k, m,

called domain and codomain, written C : k → m

  • there is an associative operation on objects ⊕ called

monoidal product

(k ⊕ m) ⊕ n = k ⊕ (m ⊕ n)

slide-19
SLIDE 19
  • Every object has an identity arrow (think of this as

a trivial “do-nothing” operation)

  • There is an identity object I for monoidal product

(think of this as a unit type). This makes the set of

  • bject a monoid.

Ik : k → k k ⊕ I = I ⊕ k = k

slide-20
SLIDE 20

Operations on arrows

  • There is a partial operation or arrows ; called

composition

  • There is a total operation on arrows ⊕ (abusing notation)

also called monoidal product.

C : k → l D: l → m C ; D : k → m

— like the plugging in magic Lego

C : k → l D: m → n C ⊕ D : k ⊕ m → l ⊕ n

— like the stacking in magic Lego

slide-21
SLIDE 21

Associativity

  • Composition is associative, i.e.
  • Monoidal product is associative also on arrows, i.e.

C : k → l D : l → m E : m → n (C ; D) ; E = C ; (D ; E) : k → n C : m → n D : m’ → n’ E : m’’ → n’’ (C ⊕ D) ⊕ E = C ⊕ (D ⊕ E) : m⊕m’⊕m’’ → n⊕n’⊕n’’

slide-22
SLIDE 22

Monoidal product and functoriality

  • The monoidal product is actually a functor, a morphism of categories
  • Functors consist of two functions, one each for objects and arrows,

and preserve domains and codomains (c.f. morphism of digraphs)

  • as well as composition and identities

F: X → Y C : m → n F(C) : F(m) → F(n) F(C ; D) = F(C) ; F(D) F(Ik) = IF(k)

slide-23
SLIDE 23

How is monoidal product a functor?

  • A monoid is a set M equipped with a function
  • … with a unit element, satisfying associativity
  • Similarly, a strict monoidal category is a category C

equipped with a functor

  • … with a unit object, satisfying associativity

⋅ : M × M → M ⊕ : C × C → C

(M×M is the cartesian product of sets) (C×C is the cartesian product of categories)

slide-24
SLIDE 24
  • Suppose that C and D are categories. How do we

define of the cartesian product C×D of C and D?

  • What are the objects?
  • What are the arrows?
  • How does composition work?
  • What are the identity arrows?

Exercise

slide-25
SLIDE 25

Monoidal product and composition

  • Suppose that A can be composed with C, and B

can be composed with D. Then since ⊕, being a functor, preserves composition, we have: ⊕(A;B, C;D) = ⊕( (A,C) ; (B,D) ) = ⊕(A,C) ; ⊕(B,D) i.e. (A ; B) ⊕ (C ; D) = (A ⊕ C) ; (B ⊕ D)

This equation is sometimes called “middle-four interchange”

slide-26
SLIDE 26

Exercise

  • Suppose that A: p →q and B: r → s. Show that

( A ⊕ Ir ) ; (Iq ⊕ B) = A ⊕ B = (Ip ⊕ B) ; (Is ⊕ A)

slide-27
SLIDE 27

Composing identities

  • Since ⊕ must preserve identities, we also require

⊕(I(m,n)) = ⊕(Im, In) = Im⊕n i.e. Im ⊕ In = Im⊕n C: m → n Im ; C = C = C ; In

  • Composing with identity arrows on both sides does

not change the arrow, i.e.

slide-28
SLIDE 28

Examples of monoidal categories

  • Setf with × (cartesian product) or with + (disjoint union) as monoidal product
  • it’s not quite strict… e.g. monoidal product is not associative on the nose
  • it is a (non-strict) monoidal category, where associativity is up to coherent isomorphism
  • F - the strict monoidal version of Setf
  • Objects: finite ordinals m := {1,2,…,m}
  • Arrows: functions
  • Monoidal product 1: disjoint union, on objects m + n := m + n
  • what is the monoidal identity object?
  • how to define monoidal product on morphisms?
  • Monoidal product 2: cartesian product, on objects m × n := m × n
  • what is the monoidal identity object?
  • how to define monoidal product on morphisms?
slide-29
SLIDE 29

Magic Lego

  • Is a monoidal category with
  • Objects: natural numbers (keeping track of

numbers of holes and studs)

  • Arrows: lego constructions
slide-30
SLIDE 30

String diagrams

  • A graphical notation for the arrows of monoidal

categories

  • We have been writing C: m → n
  • We will now draw

C m n

slide-31
SLIDE 31

Composition

C : k → l D: l → m C ; D : k → m

C k l D m

slide-32
SLIDE 32

Monoidal product

C : k → l D: m → n C ⊕ D : k ⊕ m → l ⊕ n

C k l m D n

slide-33
SLIDE 33

Perks of the notation I

C : k → l D : l → m E : m → n (C ; D) ; E = C ; (D ; E) : k → n

k l m C D E n

slide-34
SLIDE 34

Perks of the notation II

C : m → n D : m’ → n’ E : m’’ → n’’ (C ⊕ D) ⊕ E = C ⊕ (D ⊕ E) : m ⊕ m’⊕ m’’ → n ⊕ n’⊕ n’’

C D E m m' m'' n n' n''

slide-35
SLIDE 35

Perks of the notation III

(A ; B) ⊕ (C ; D) = (A ⊕ C) ; (B ⊕ D)

A B C D

slide-36
SLIDE 36

Diagrammatic reasoning I

  • Identity on m is simply drawn as a wire

Stretching

m

C : m → n Im ; C = C = C ; In

= C = C C m n m n m n

slide-37
SLIDE 37

Diagrammatic reasoning II

( A ⊕ Ir ) ; (Iq ⊕ B) = A ⊕ B = (Ip ⊕ B) ; (Is ⊕ A) Sliding

A B = = A B A B p q r s p q r s p q r s

slide-38
SLIDE 38

General story

  • A strict monoidal category is the same thing as a 2-category with one
  • bject, a particularly simple kind of higher category
  • string diagrams are a kind of graph theoretical dual, i.e.
  • zero dimensional things (objects) become two dimensional things
  • one dimensional things (arrows in a 2-cat = objects in a strict

monoidal cat) stay as one dimensional things — wires

  • two dimensional things (2-cells in a 2-cat = arrows in a strict

monoidal cat) become zero dimensional things (points, or boxes as we have been drawing)

  • See Globular (Vicary, Kissinger, Bar): http://globular.science
slide-39
SLIDE 39

Symmetric monoidal categories

  • When wiring things up using the algebra of

connecting and stacking, we often want to permute the wires

  • Mathematically, this means moving from monoidal

categories to symmetric monoidal categories

  • In a symmetric monoidal category, for any two objects

m, n, there is a symmetry, or twist

twm,n: m⊕n → n⊕m

slide-40
SLIDE 40

Example - Crema di Mascarpone

Crack Egg egg yolk white Whisk white white whisked whites yolk yolk sugar Beat yolky paste yolky paste mascarpone Stir thick paste whisked whites thick paste Fold crema di mascarpone Crack Egg egg white yolk Crack Egg egg white yolk Beat Whisk whisked whites thick paste mascarpone Stir crema di mascarpone sugar Fold yolky paste

slide-41
SLIDE 41

Example - Crema di Mascarpone

Crack Egg egg yolk white Whisk white white whisked whites yolk yolk sugar Beat yolky paste yolky paste mascarpone Stir thick paste whisked whites thick paste Fold crema di mascarpone Crack Egg egg white yolk Crack Egg egg white yolk Beat Whisk whisked whites thick paste mascarpone Stir crema di mascarpone sugar Fold yolky paste

(C ⊕ C ⊕ id2) ; (id ⊕ tw ⊕ id3) ; (W ⊕ B ⊕ id) ; (id ⊕ S) ; F

slide-42
SLIDE 42

Natural transformations

  • We have seen categories, and functors: morphisms between categories
  • A natural transformation is a morphism between functors
  • A natural transformation α : F ⇒ G is a collection of arrows of Y, one for each object in m ∈ X
  • These must satisfy a condition with respect to the arrows of X, namely for each arrow C: m→n

F ⇒ G: X → Y αm : Fm → Gm Fm Gm Fn Gn

FC

GC

αm αn

commutes.

These are sometimes called naturality squares

slide-43
SLIDE 43

Aside — string diagrams for Cat

  • Cat is a 2-category
  • Objects (0-morphisms): categories
  • Arrows (1-morphisms): functors
  • 2-cells (2-morphisms): natural transformations
  • Suppose that F: C→D has right adjoint G: D→C, then the triangle equations can be drawn as

follows, using string diagrams:

η ε F G F = F η ε G F G = G

F FGF

F

εF

G GFG

ηG Gε

G

slide-44
SLIDE 44

Symmetry as natural transformation

  • For a monical category C, there are actually two

functors C×C → C given by ⊕

  • tw is a natural transformation from the first to the

second, with components twm,n : m⊕n→ n⊕m ⊕ = –1⊕–2: C×C → C ⊕’ = –2⊕–1: C×C → C

– stack the first on the second – stack the second on the first

slide-45
SLIDE 45

Drawing twists

twm,n: m⊕n → n⊕m

m m n n

slide-46
SLIDE 46

Diagrammatic reasoning III

p⊕n n⊕p q⊕n n⊕q

C⊕n

n⊕C

twp,n twq,n

C n n p q C n n p q =

naturality = sliding across twists m⊕p p⊕m m⊕q q⊕m

m⊕C

C⊕m

twm,p twm,q

C p q m m C p q m m =

slide-47
SLIDE 47

Diagrammatic reasoning IV

  • In any symmetric monoidal category, the twist is

invertible, and has itself as inverse, in the following sense

tightening (without wires tangling) twm,n ; twn,m= Im⊕n : m⊕n → m⊕n

=

m m m n n n m n In a braided monoidal category, the twist is invertible, but it is not, in general, it’s own inverse

slide-48
SLIDE 48

Symmetric monoidal categories

  • A strict symmetric monoidal category C, is a strict

monoidal category with a natural family of arrows twm,n : m⊕n → n⊕m, indexed by pairs of objects of C, such that twm,n ; twn,m= Im⊕n : m⊕n → m⊕n twm⊕n, p = (Im ⊕ twn,p) ; (twp,m ⊕ In): m⊕n⊕p→ p⊕m⊕n twp, m⊕n = (twp,m ⊕ In); (Im ⊕ twp,n): p⊕m⊕n→ m⊕n⊕p twI,m = Im = twm,I

slide-49
SLIDE 49
  • Exercise: The famous Yang-Baxter equation is an

instance of naturality of the twist

  • tegether with

Yang-Baxter

=

=

we get that “pure” wiring diagrams t⊕m → t⊕m are in 1-1 correspondence with permutations of the m-element set

slide-50
SLIDE 50

The category of permutations

  • Objects: finite ordinals m = {1,…,m}
  • Arrows: no arrows from m to n if m≠n, otherwise the

permutations

  • Strict symmetric monoidal, with m⊕n := m+n
slide-51
SLIDE 51

Algebraic theories

  • An algebraic theory is a pair (Σ, E) where
  • Σ is a set of generators (or operations), each with an arity, a

natural number

  • E is a set of equations (or relations), between Σ-terms built up

from generators and variables

Example 1 - monoids Example 2 - abelian groups

ΣM = { ⋅:2, e:0 }

EM = { ⋅( ⋅(x, y), z ) = ⋅( x, ⋅(y, z) ), ⋅(x, e) = x, ⋅(e, x) = x }

ΣG = ΣM ∪ { i:1 }

EG = EM ∪ { ⋅(x, y) = ⋅(y, x), ⋅(x, i(x)) = e }

Universal Algebra

slide-52
SLIDE 52

Σ - terms (cartesian)

x ∈ Var x t1 t2 … tm σ ∈ Σ ar(σ) = m σ(t1, t2, …, tm) i.e. terms a trees with internal nodes labelled by the generators and the leaves labelled by variables

slide-53
SLIDE 53

Models - classically

  • To give a model of an algebraic theory, choose a set X
  • for each operation σ : k in Σ, choose a function [[σ]] : X

k → X

  • now for each term t, given an assignment of variables α, we can

recursively compute the element of [[t]]α ∈ X which is the “meaning” of t

  • We need to ensure that for every assignment of variables α, and every

equation t1 = t2 in E, we have [[t1]]α = [[t2]]α as elements of X

  • To give a model of the algebraic theory of monoids is to give a monoid
  • To give a model of the theory of abelian groups is to give an abelian group
  • etc..
slide-54
SLIDE 54

Algebraic theories, categorically

  • There is a nice way to think of algebraic theories

categorically, due to Lawvere in the 1960s

  • get rid of “countably infinite set of variables”,

“variable assignments” etc.

  • relies on the notion of categorical product
slide-55
SLIDE 55

Categorical product

  • Suppose that X, Y are objects in a category C. Then X and Y have a

product if ∃ object X×Y and arrows π1: X×Y → X, π2: X×Y → Y so that the following universal property holds

  • Example: in the category Set of sets and functions, the cartesian

product satisfies the universal property

  • Any category with (binary) categorical products is monoidal, with

the categorical product as monoidal product

X×Y Z X Y

π1 π2

f g h

for any object Z and arrows f: Z → X, g: Z → Y, ∃ unique h: Z → X×Y s.t. h ; π1 = f and h ; π2 = g

slide-56
SLIDE 56
  • If X is a preorder, considered as a category, what

does it mean if X has (binary) categorical products?

  • In Set, the categorical product is the cartesian

product

  • What is the product in the category of categories

and functors?

  • What is the product in the category of monoids

and homomorphisms?

Exercise

slide-57
SLIDE 57

Lawvere categories

  • Suppose that (Σ, E) is an algebraic theory
  • Define a category L(Σ,E) with
  • Objects: natural numbers
  • Arrows from m to n: n tuples of Σ-terms, each using possibly m variables x1,

x2, …, xm, modulo the equations of E

  • Composition is substitution

Examples in the theory of monoids 2 1

It is also possible (and elegant) to view L(Σ,E) as the free category with products on the data specified in (Σ,E)

(x1⋅x2)

2 1

(x2⋅x1)

1 1

(x1⋅e)

= 1 1

(x1)

slide-58
SLIDE 58
  • Lawvere categories have (binary) categorial products:

m×n := m+n.

  • Q1. What are the projections?
  • In any category with binary products there is a

canonical arrow Δ: X→X×X called the diagonal.

  • Q2. How is it defined?
  • Q3. What is L(∅,∅)? Can you find a simple way of

describing it?

Exercise

slide-59
SLIDE 59

Models categorically (Functorial semantics)

  • A functor F: C → D is product-preserving if

F(X×Y) = F(X) × F(Y)

  • Theorem. To give a model of (Σ,E) is to give a product-

preserving functor F: L(Σ,E) → Set Proof idea: since m = 1+1+…+1 (m times), to give a product preserving functor F from L(Σ,E) it is enough to say what F(1) is.

  • By changing Set to other categories, we obtain a nice

generalisation of classical universal algebra, with examples such as topological groups, etc.

slide-60
SLIDE 60

Limitations of algebraic theories

  • Copying and discarding built in
  • But in computer science (and elsewhere), we often

need to be more careful with resources

  • Consequently, there are also no bona fide
  • perations with coarities other than one

1 2

(x1, x1)

2 1 (x1) 2 1 (x2) 1 2

c

= 1 2

(c1,c2)

slide-61
SLIDE 61

Symmetric monoidal theories

  • Most of our work will concern symmetric monoidal

theories (SMTs) which give rise to special kinds of symmetric monoidal categories called props

  • Symmetric monoidal theories generalise algebraic

theories, a classical concept of universal algebra, but

  • No built in copying and discarding
  • Able to consider operations with coarities other

than 1

slide-62
SLIDE 62

Symmetric monoidal theories

  • A symmetric monoidal theory is a pair (Σ, E) where
  • Σ is a set of generators (or operations), each with an arity, and coarity,

both natural numbers

  • E is a set of equations (or relations), between compatible Σ-terms
  • Since generators can have coarities, and since we need to be careful with

resources, we can’t use the standard notion of term (tree).

  • Instead, terms are arrows in a certain symmetric monoidal category, which

we will construct a la magic Lego

slide-63
SLIDE 63

Generators and terms

: (2, 1) Running example: the SMT of commutative monoids : (0, 1) we always have the following “basic tiles” around : (1, 1) : (2, 2)

slide-64
SLIDE 64

Some string diagrams

  • String diagrams: constructions built up from the generators

and basic tiles, with the two operations of magic Lego

⊕ =

⊕ =

; =

slide-65
SLIDE 65

Recall: diagrammatic reasoning

  • diagrams can slide along wires
  • wires don’t tangle, i.e.
  • sub-diagrams can be replaced with equal diagrams (compositionality)

A k l C m n A k l C m n = = A k l C m n

functoriality

A k l m m l = A k l m m k

naturality

i.e. pure wiring obeys the same equations as permutations

=

=

slide-66
SLIDE 66

Σ - Terms (monoidal)

  • Are thus the arrows of the free symmetric monoidal

category SΣ on Σ

  • Objects: natural numbers
  • Arrows from m to n: string diagrams constructed

from generators, identity and twist, modulo diagrammatic reasoning

  • Monoidal product, on objects: m⊕n := m+n
slide-67
SLIDE 67

Equations

x y z x + y (x + y) + z

x y z y + z x + (y + z)

=

(Assoc)

x y x+y

x y y+x

=

(Comm)

x 0 + x

=

(Unit)

Note that all equations are of the form t1 = t2 : (m, n), that is, t1 and t2 must agree on domain and codomain

slide-68
SLIDE 68

The SMT of commutative monoids

=

=

=

Equations Generators

Let’s call this SMT M, for monoid

slide-69
SLIDE 69

Diagrammatic reasoning example

= = = =

=

=

slide-70
SLIDE 70

Another SMT: commutative comonoids

Equations Generators

=

=

=

slide-71
SLIDE 71

From SMTs to symmetric monoidal categories

  • Every symmetric monoidal theory (Σ,E) yields a free strict

symmetric monoidal category S(Σ,E)

  • Object: natural numbers
  • Arrows: monoidal Σ-terms, taken modulo equations in E
  • Such categories are an instance of props (product and

permutation categories)

slide-72
SLIDE 72

props

  • A prop (product and permutation category) is
  • strict symmetric monoidal
  • objects = natural numbers
  • monoidal product on objects = addition
  • i.e. m⊕n = m+n
slide-73
SLIDE 73

Examples

  • 1. Any symmetric monoidal theory gives us a prop
  • 2. The strict symmetric monoidal category F
  • arrows from m to n are all functions from the m element

set {0, …, m-1} to the n element set {0, … , n-1} 3.The free strict symmetric monoidal category on one

  • bject, the category P of permutations
  • 4. The category I with precisely one arrow from any m to n is

a prop

slide-74
SLIDE 74

Morphisms of props

  • A morphism of props F: X→Y is an identity on objects

symmetric monoidal functor

  • identity-on-objects: F(m) = m
  • strict: F(C ⊕ D) = F(C) ⊕ F(D)
  • symmetric monoidal: F(twm,n) = twm,n
  • functor F(Im)=Im, F(C ; D) = F(C) ; F(D)
  • In other words, all the structure is simply preserved on the

nose — easy peasy

slide-75
SLIDE 75

Models

  • Recall: models of algebraic theories are finite product preserving functors,
  • ften to Set
  • We can define models of an SMT to be symmetric monoidal functors, a

generalisation of the notion of finite product preserving

  • Some computer science intuitions:
  • SMTs, like M, are a syntax
  • props like F are a semantics
  • homomorphisms map syntax to semantics
  • when the map is an isomorphisms, we have an equational characterisation,

and a sound and fully complete proof system to reason about things in F

slide-76
SLIDE 76

Example

  • So M is an equational characterisation of F
  • or the “commutative monoids is the theory of functions”

The prop F is not an SMT

The prop M is an SMT As props, M is isomorphic to F

slide-77
SLIDE 77

Morphisms from (props obtained from) SMTs

  • Let us define a morphism [[-]] : M → F
  • M is obtained from a symmetric monoidal theory (Σ, E),

thus its arrows are constructed inductively

  • To define [[-]] it thus suffices to
  • say where the generators in Σ are mapped
  • check that the equations in hold in F
  • This is a general pattern when defining morphisms from

a prop obtained from an SMT

slide-78
SLIDE 78

[[-]]: M → F

7 ! 7 ! {} → {1} {1,2} → {1}

=

(Assoc)

=

(Comm)

=

(Unit)

Simple exercise: check the following hold in F

slide-79
SLIDE 79

Soundness

  • Simple observation: the fact that we have a

homomorphism [[–]] : M → F means that diagrammatic reasoning in M is sound for F

  • Q1. What property of [[–]] do we need to ensure

completeness?

  • Q2. If we have soundness and completeness, is this

enough for [[–]] to be an isomorphism? (i.e. invertible)

slide-80
SLIDE 80

Full and faithful

  • To show that a morphism of props F: X→Y is an

isomorphism it suffices to show that it is full and faithful

  • full: for every arrow g of Y there exists an arrow f of

X such that F(f) = g

  • faithful: given arrows f, f’ in X, if F(f)=F(f’) then f = f’

So full and faithful functor from a (free PROP on an) SMT = sound and fully complete equational charaterisation

slide-81
SLIDE 81

[[–]] : M → F

  • full: every function between finite sets can be

constructed from the two basic building blocks together with permutations

  • faithful: every diagram in M can be written as

multiplications followed by units, which corresponds to a factorisation of a function as an surjection followed by an injection. This factorisation is unique “up-to-permutation”.

slide-82
SLIDE 82

Free things

  • A free “something on X” is one that satisfies a universal

property — it’s the “smallest” thing that contains X which satisfies the properties of “something”

  • e.g. free “monoid on a set Σ” is the set of finite words Σ*

X F G

slide-83
SLIDE 83

Free strict symmetric monoidal category on one object

  • Any ideas?
  • Recall: there is a category 1 with one object and one arrow
  • Let X be the free symmetric monoidal category on 1
  • There should be a functor from 1 to X
  • For any functor to a strict symmetric monoidal category Y, there should be a

strict symmetric monoidal functor X to Y such that the diagram below commutes

1 X Y functor functor

strict symmetric monoidal functor

slide-84
SLIDE 84

Plan

  • symmetric monoidal categories and string diagrams
  • theory of natural number matrices (bimonoids) and integer matrices

(Hopf monoids)

  • bimonoids and matrices of natural numbers
  • Hopf monoids and matrices of integers
  • theory of linear relations (interacting Hopf monoids)
  • distributive laws
  • linear algebra, diagrammatically
  • an application: signal flow graphs
slide-85
SLIDE 85
  • Combines generators and equations of the SMTs of

monoids and comonoids

  • Intuition: “numbers” travel on wires from left to right

The monoid structure acts as addition/zero The comonoid structure acts as copying/discarding

x y x+y

x x x

x

The SMT of bimonoids

slide-86
SLIDE 86

Adding meets copying

  • The way that adding and copying interact is

responsible for all linear algebra

  • In the next slide we will introduce the theory of

bimonoids, the equations of which show some of the ways that the interactions happen

slide-87
SLIDE 87

The SMT of bimonoids

  • all the generators we have seen so far
  • monoid and comonoid equations
  • “adding meets copying” - equations compatible with intuition

= =

=

=

=

= =

=

=

=

slide-88
SLIDE 88

Mat

  • A PROP where arrows m to n are n×m matrices of natural

numbers

  • e.g.
  • Composition is matrix multiplication
  • Monoidal product is direct sum
  • Symmetries are permutation matrices

5 : 2 → 1

✓ 3 15 ◆ : 1 → 2

✓ 1 2 3 4 ◆ : 2 → 2

A1 ⊕ A2 = ✓ A1 A2 ◆

slide-89
SLIDE 89
  • Theorem. B is isomorphic to the Mat
  • ie. bimonoids is the theory of natural number matrices
  • natural numbers themselves can be seen as certain (1,1)

diagrams, with the recursive definition below

  • as we will see, the algebra (rig) of natural numbers follows

:=

k+1

:=

k

B and Mat

+1 is “add one path”

slide-90
SLIDE 90

m n m+n

=

m n nm

=

m m m

=

m m m

=

Exercise

:=

k+1

:=

k

Given , prove 1. 2. 3. 4.

slide-91
SLIDE 91

Proof B≅Mat

1 1 : 2 → 1

() : 0 → 1 ✓ 1 1 ◆ : 1 → 2 () : 1 → 0

7! 7! 7! 7!

Full - easy! Recursively define a syntactic sugar for matrices

Faithful - harder Use the fact that equations are a presentation of a distributive law, obtain factorisation of diagrams as comonoid structure followed by monoid structure - normal form

Recall: Since B is an SMT, suffices to say where generators go (and check that equations hold in the codomain)

slide-92
SLIDE 92

Normal form for B

  • Every diagram can be put in the form
  • comonoid ; monoid
  • Centipedes
slide-93
SLIDE 93

Matrices

  • To get the ijth entry in the matrix, count the paths

from the jth port on the left to the ith port on the right

  • Example:

2 3 4

✓ 1 2 3 4 ◆

slide-94
SLIDE 94
  • Q1. Show that the monoidal product in B≅Mat is the categorical product
  • Q2. The categorical coproduct of X, Y, if it exists satisfies the following universal property

show that the monoidal product in B≅Mat is the categorical coproduct. When a monoidal product satisfies both the universal properties of products and coproducts, we say that it is a biproduct. In fact B≅Mat is the free category with biproducts on one object. Q3 (challenging). Given a category C, describe the free category with biproducts on C.

Exercise

X+Y Z X Y

i1 i2

f g h

for any object Z and arrows f: X → Z, g: Y → Z, ∃ unique h: X+Y → Z s.t. i1 ; h = f and i2 ; h = g

slide-95
SLIDE 95

Lawvere categories with string diagrams

(i.e. how ordinary syntax looks, with string diagrams)

σ . . .

(σ ∈ Σ)

=

=

=

and what else?

slide-96
SLIDE 96

In particular, notice that B is isomorphic (as a symmetric monoidal category) to the Lawvere category of commutative monoids!

σ . . . = . . . σ σ . . . . . .

σ . . . = . . .

Exercise: show that the monoidal product now becomes a categorical product

slide-97
SLIDE 97

Putting the n in ring: Hopf monoids

  • generators of bimonoids + antipode
  • think of this as acting as -1
  • equations of bimonoids and the following

=

=

=

=

=

slide-98
SLIDE 98
  • 1 ⋅ -1 = 1

= = = = = = = =

slide-99
SLIDE 99

The ring of integers

  • Simple induction:
  • Recall: in B, the arrows 1→1 were in one-to-one

correspondence with natural numbers

  • In H, the arrows 1→1 are in one-to-one

correspondence with the integers

n n

=

:=

k+1

:=

k

  • n

:=

n

slide-100
SLIDE 100
  • Verify that, in H, for all integers m, n we have

Exercise

m n m+n

=

m n nm

=

slide-101
SLIDE 101
  • Arrows m to n are n×m matrices of integers
  • composition is matrix multiplication
  • monoidal product is direct sum
  • MatZ is equivalent to the category of finite dimensional

free Z-modules

  • SMT H is isomorphic to the PROP MatZ

MatZ

slide-102
SLIDE 102

Path counting in MatZ

  • To get the ijth entry in the matrix, count the
  • positive paths from the jth port on the left to the ith port on the right (where

antipode appears an even number of times)

  • negative paths between these two ports (where antipode appears an odd

number of times)

  • subtract the negative paths from the positive paths
  • Example:

✓ −1 1 ◆

slide-103
SLIDE 103

Proof H≅MatZ

  • Fullness easy
  • Faithfulness more challenging: put diagrams in the form
  • 1

1

  • : 2 → 1

() : 0 → 1 ✓ 1 1 ◆ : 1 → 2 () : 1 → 0

7! 7! 7! 7!

copying ; antipode ; adding

7!

(−1) : 1 → 1

slide-104
SLIDE 104
  • We saw that B is the isomorphic, as a symmetric

monoidal category, to the Lawvere category of commutative monoids.

  • Which Lawvere category is H isomorphic to?

Exercise

slide-105
SLIDE 105

Plan

  • basic theory of string diagrams
  • theory of natural number matrices (bimonoids) and integer matrices (Hopf monoids)
  • theory of linear relations (interacting Hopf monoids)
  • intuition upgrade
  • Frobenius monoids
  • the equations of IH
  • linear relations
  • rational numbers, diagrammatically
  • distributive laws
  • linear algebra, diagrammatically
  • an application: signal flow graphs
slide-106
SLIDE 106

Intuition upgrade

  • We have been saying that numbers go from left to right in diagrams
  • this is a functional, input/output interpretation
  • J.C. Willems - Behavioural approach in control theory
  • Engineers create functional behaviour from non-functional

components

  • The physical world is NOT functional
  • Functional thinking is fundamentally non-compositional
  • From now on, we will take a relational point of view, a diagram is a

contract that allows certain numbers to appear on the left and on the right

slide-107
SLIDE 107

Intuition upgrade

  • We have been saying that numbers go from left to right in diagrams
  • this is a functional, input/output interpretation
  • J.C. Willems - Behavioural approach in control theory
  • Engineers create functional behaviour from non-functional

components

  • The physical world is NOT functional
  • Functional thinking is fundamentally non-compositional
  • From now on, we will take a relational point of view, a diagram is a

contract that allows certain numbers to appear on the left and on the right

The input/output framework is totally inappropriate for dealing with all but the most special system interconnections. [The input/output representation] often needlessly complicates matters, mathematically and conceptually. A good theory of systems takes the behavior as the basic notion. J.C. Willems, Linear systems in discrete time, 2009

slide-108
SLIDE 108

Intuition upgrade

  • Intuition so far is this as a function +: D×D→D
  • From now it will be as a relation of type DxD → D
  • Composition is relational composition
slide-109
SLIDE 109

Mirror images

x y , x+y () , 0 x , x x x , ()

slide-110
SLIDE 110

Mirror images

x y , x+y () , 0 x , x x x , () x y x+y , 0 , () x x , x () , x

slide-111
SLIDE 111

Adding meets adding

p q r p+q r p q+r

x y z x+y z x y+z

x = p+q z = q+r p=x+y r=y+z

Provided addition yields abelian group (i.e. there are additive inverses), the two are the same relation

y=-q

slide-112
SLIDE 112

More adding meets adding

x+y x y x+y

since x and y are free, this is the identity relation

x

empty relation

slide-113
SLIDE 113

Copying meets copying

x x x x x x x x x x

clearly both give the same relation

x x x x

identity relation

x

empty relation

slide-114
SLIDE 114

Two Frobenius structures

=

= = =

+ special / strongly separable equations + “bone” equations

= =

slide-115
SLIDE 115

Frobenius monoids

=

= = = = = =

Frobenius monoid

slide-116
SLIDE 116

Snakes

= =

Snake lemma

=

(Frob)

=

(Unit)

=

(Counit)

Proof: “cup” “cap”

slide-117
SLIDE 117

Normal forms

  • In B, we saw that every

diagram can be factorised into comonoid structure ; monoid structure, this gave us centipedes

  • In Frob, every diagram

can be factored into monoid structure ; comonoid structure, these are often referred to as spiders

= = = = = = =

Special Frobenius monoid =

slide-118
SLIDE 118

Spiders in special Frobenius monoids 1

  • In a special Frobenius monoid every connected

diagram is equal to one of the form

  • which suggests the “spider notation”

. . . . . .

1 2 m 1 2 n

. . . . . .

1 2 m 1 2 n

slide-119
SLIDE 119

Spiders in special Frobenius monoids 2

  • In general, diagrams are collections of spiders
  • when two spiders connect, they fuse into one
  • i.e. any connected diagram of type m→n is equal
slide-120
SLIDE 120

Black and white cups and caps

=

{( ✓ x y ◆ , ()) | x + y = 0 } {( ✓ x x ◆ , ())}

=

slide-121
SLIDE 121

Scalars meet scalars

if multiplication on the left by p is injective (e.g. if p ≠ 0 in a field)

p

x px

p

px =

if multiplication on the left by p is surjective (e.g. if p ≠ 0 in a field)

p p

x px=py y =

slide-122
SLIDE 122

Interacting Hopf Monoids

(Bonchi, S., Zanasi, ’13, ’14)

= = =

Copying

= = =

Copyingop

= = =

Adding

= = = =

Adding meets Copying

= = =

Addingop

= = = =

Addingop meets Copyingop Antipode = = = = = Antipodeop = = = = =

H Hop

slide-123
SLIDE 123

White monoid (adding) Black comonoid (copying) White comonoid (adding-op) Black monoid (copying-op)

Hopf Hopf Frobenius

Frobenius

= = = = = = = = = = = =

slide-124
SLIDE 124

The antipode cheat

= =

The antipodes in H and Hop are formally different but we were slightly naughty with notation.

slide-125
SLIDE 125

Interacting Hopf Monoids

Adding meets Addingop

=

= = Copying meets Copyingop

=

= = = = Cups and Caps

p p p p (p ≠ 0)

= = Scalars

  • cf. ZX-calculus (Coecke, Duncan)
slide-126
SLIDE 126

= = =

Copying

= = =

Copyingop

= = =

Adding

= = = =

Adding meets Copying

= = =

Addingop

= = = =

Addingop meets Copyingop Antipode = = = = = Antipodeop = = = = = Adding meets Addingop

=

= = Copying meets Copyingop

=

= = = = Cups and Caps

p p p p (p ≠ 0)

= = Scalars

Symmetry 1 - colour inversion Symmetry 2 - mirror image

IH

slide-127
SLIDE 127

Redundancy

  • Generators are expressible in terms of other

generators, e.g. Lemma

= = = =

so

= =

slide-128
SLIDE 128

Linear subspaces

  • Suppose that V is a vector space over field k
  • A linear subspace U⊆V is a subset that
  • contains the zero vector, 0∈V
  • closed under addition, if u,u’ ∈ U then u+u’ ∈ U
  • closed under scalar multiplication, if u ∈ U and p ∈ k

then p⋅u ∈ U

  • e.g. R2 is an R-vector space. What are the linear

subspaces?

slide-129
SLIDE 129
  • Suppose that U, V, W are k vector spaces,
  • R ⊆ U×V is a subspace and
  • S ⊆ V×W is a subspace
  • Show that the relational composition R;S⊆U×W is a

subspace

Exercise

slide-130
SLIDE 130
  • PROP of linear relations over the rationals
  • arrows m to n are subspaces of Qm × Qn
  • composed as relations
  • monoidal product is direct sum
  • IH is isomorphic to LinRel

LinRel

slide-131
SLIDE 131

Where did the rationals come from?

  • Recall
  • in B, the (1,1) diagrams were the natural numbers
  • in H, the (1,1) diagrams were the integers
  • In IH, the (1,1) diagrams include the rationals p/q

p q

slide-132
SLIDE 132

Some Lemmas

if q ≠ 0:

p q p q

=

q q

=

q q q p

=

q p

q q

=

q q q q

=

q q q q q

=

q

suppose q,s ≠ 0:

p q r s

=

sp = qr

p s

=

p q q s r s q s r q s s

= =

r q

=

p q

=

p q s s

=

r q q s

=

r q s q r s

=

slide-133
SLIDE 133

Rational arithmetic

(q,s ≠ 0)

p q r s

=

p q r s s s q q sp sq qr qs sp qr sq

= = =

sp+qr sq

p q r s

=

p r s q

=

rp sq

slide-134
SLIDE 134

Keep calm and divide by zero

  • it’s ok, nothing blows up
  • of course, arithmetic with 1/0 is not quite as nice

as with proper rationals.

  • two ways of interpreting 0/0 (0 · /0 or /0 · 0)

= =

= =

slide-135
SLIDE 135

Projective arithmetic++

  • Projective arithmetic identifies numbers with one-

dimensional spaces (lines) of Q

2

  • one for each rational p : { (x,px) | x ∈ Q }
  • and “infinity” : { (0, x) | x ∈ Q }
  • The extended system includes all the subspaces of

Q

2, in particular:

  • the unique zero dimensional space { (0, 0) }
  • the unique two dimensional space { (x,y) | x,y ∈ Q }

(x, 1/2 x) (x, 2x)

slide-136
SLIDE 136

Dividing by zero

Edalat and Potts suggested that two extra ‘numbers’, ∞ = 1/0 and ⊥ = 0/0, be adjoined to the set of real numbers (thus obtaining what in domain theory is called the ‘lifting’ of the real projective line) in order to make division always possible. In a seminar, Martin-Löf proposed that one should try to include these ‘numbers’ already in the construction of the rationals from the integers, by allowing not

  • nly non-zero denominators, but arbitrary denominators, thus ending up not

with a field, but with a field with two extra elements.

Here we have three extra “numbers”!

Jesper Carlström, Wheels, On Division by Zero, 2001

:=

:=

:=

slide-137
SLIDE 137

Plan

  • basic theory of string diagrams
  • theory of natural number matrices (bimonoids) and

integer matrices (Hopf monoids)

  • theory of linear relations (interacting Hopf monoids)
  • distributive laws
  • linear algebra, diagrammatically
  • an application: signal flow graphs
slide-138
SLIDE 138

Distributive laws of PROPs

  • Proof IH ≅ LinRel relies on the notion of distributive law of PROPs

(Lack, Composing PROPs, 2004)

  • a variant of distributive laws of monads
  • monads can be considered in any 2-category (R. Street, Formal

Theory of Monads, 1972)

  • categories = monads in Span(Set)
  • strict monoidal categories = monads in Span(Mon)
  • small technical complications for PROPs because of symmetries
slide-139
SLIDE 139

Categories = Monads??

  • What is a monad in Span(Set)?
  • endo 1-cell
  • multiplication
  • unit
  • satisfying associativity & unit laws

O

δ0

← − A

δ1

− → O A ×O A ✏ / A

δ1

✏ A

δ0

/ O A ×O A

µ

− → A O

η

− → A

let’s call it “composition” let’s call it “identity”

slide-140
SLIDE 140

Distributive laws of PROPs

P

Green PROP P

Q

Purple PROP Q

When can we understand P;Q as a PROP?

Q P P Q

λ

P Q P Q

PλQ

P P Q Q

slide-141
SLIDE 141

Distributive law of Monads

  • Given monads T, U, a

distributive law is a 2-cell

  • that is compatible with

multiplication and units in T and U in the obvious way (see diags)

  • gives a monad structure
  • n TU

λ : UT ⇒ TU

UUT

µUT

/

✏ UT

λ

✏ UTU

λU / TUU T µU

/ TU UTT

UµT

/

λT

✏ UT

λ

✏ TUT

T λ / TTU µT U / TU

T

ηUT

}| | | | | | | |

T ηU

! B B B B B B B B UT

λ

/ TU

U

UηT

}{ { { { { { { {

ηT U

! C C C C C C C C UT

λ

/ TU

slide-142
SLIDE 142

SMT of Spans

  • The bicategory Span(Set) has spans of functions as 1-cells and span morphisms as 2-cells
  • composition is by pullback
  • we obtain the category of spans by identifying isomorphic spans
  • We already have the SMT of functions (commutative monoids) and “backwards

functions” (commutative comonoids)

  • Pullback defines a distributive law of PROPs - implied by the universal property
= = = = = = = = = = = =

Pullback!

slide-143
SLIDE 143
  • the theory of bimonoids is a presentation of this distributive law
  • so B ≅ Mat ≅ Span(F)
  • for details see Steve Lack’s paper

2 × 2

π1

}zzzzzzzz ! D D D D D D D D

π2

! D D D D D D D D 2 " D D D D D D D D D 2 |zzzzzzzzz 1

slide-144
SLIDE 144
  • the theory of bimonoids is a presentation of this distributive law
  • so B ≅ Mat ≅ Span(F)
  • for details see Steve Lack’s paper

2 × 2

π1

}zzzzzzzz ! D D D D D D D D

π2

! D D D D D D D D 2 " D D D D D D D D D 2 |zzzzzzzzz 1

(0,0) (0,1) (1,0) (1,1) 1 1

slide-145
SLIDE 145
  • the theory of bimonoids is a presentation of this distributive law
  • so B ≅ Mat ≅ Span(F)
  • for details see Steve Lack’s paper

2 × 2

π1

}zzzzzzzz ! D D D D D D D D

π2

! D D D D D D D D 2 " D D D D D D D D D 2 |zzzzzzzzz 1

(0,0) (0,1) (1,0) (1,1) 1 1

slide-146
SLIDE 146
  • the theory of bimonoids is a presentation of this distributive law
  • so B ≅ Mat ≅ Span(F)
  • for details see Steve Lack’s paper

2 × 2

π1

}zzzzzzzz ! D D D D D D D D

π2

! D D D D D D D D 2 " D D D D D D D D D 2 |zzzzzzzzz 1

(0,0) (0,1) (1,0) (1,1) 1 1

=

slide-147
SLIDE 147

SMT of Cospans

  • The bicategory Cospan(Set) has cospans of functions as 1-cells

and cospan morphisms as 2-cells

  • composition is by pushout
  • pushout defines a distributive law
  • obtain theory strongly separable Frobenius monoids — the theory
  • f cospans!

= =

slide-148
SLIDE 148

Proof of IH≅LinRel (outline)

  • Two distributive laws
  • slight generalisation of Lack’s notion
  • MatZ has both pullbacks and pushouts
  • it is equivalent to the category of free f.d. Z-modules
  • since Z is a PID, this category has pullbacks
  • because of transpose, MatZ also has pushouts
  • We thus obtain two distributive laws:
  • one from pullbacks, giving spans of matrices
  • one from pushouts, giving cospans of matrices
slide-149
SLIDE 149

Spans of matrices

p p

=

IRSp ≅ Span(MatZ)

= =

=

= = =

(p ≠ 0)

IRSp

r r

=

r r r

=

r

slide-150
SLIDE 150

Cospans of matrices

IRCsp ≅ Cospan(MatZ) IRCsp

(p ≠ 0) p p

=

= = = = = =

r r

=

r r r

=

r

slide-151
SLIDE 151

The cube - back faces

MatZ + MatZ

  • p

H + Hop Span(MatZ) IHSpan IHCospan Cospan(MatZ)

slide-152
SLIDE 152

The cube

MatZ + MatZ

  • p

H + Hop Span(MatZ) IHSpan IHCospan Cospan(MatZ) LinRel IH

slide-153
SLIDE 153

Corollary

  • The proof gives us some useful facts
  • every diagram in IH can be factorised in two ways
  • as a span
  • as a cospan
  • every mono in MatZ satisfies
  • every epi in MatZ satisfies

A B

m n k

C D

m n l

A A

m m n = m

A A

n n m = n

slide-154
SLIDE 154

Plan

  • basic theory of string diagrams
  • theory of natural number matrices (bimonoids) and

integer matrices (Hopf monoids)

  • theory of linear relations (interacting Hopf monoids)
  • distributive laws
  • linear algebra, diagrammatically
  • an application: signal flow graphs
slide-155
SLIDE 155

Factorisations

  • Every diagram can be factorised as a span or a cospan of matrices
  • This gives us the two different ways one can think of spaces

solutions of a list of homogeneous equations

linear combinations

  • f basis vectors

x+y=0 x y z 2y-z=0

2

x y z

x+y=0 2y-z=0

2

x y z

a[1, -1, 0] a

b[0, 1, 2]

2

b

a[1, -1, 0]+b[0,1,2]

2

a b

slide-156
SLIDE 156

Factorisations

  • Every diagram can be factorised as a span or a cospan of matrices
  • This gives us the two different ways one can think of spaces

solutions of a list of homogeneous equations

linear combinations

  • f basis vectors

x+y=0 x y z 2y-z=0

2

x y z

x+y=0 2y-z=0

2

x y z

Cospans

a[1, -1, 0] a

b[0, 1, 2]

2

b

a[1, -1, 0]+b[0,1,2]

2

a b

slide-157
SLIDE 157

Factorisations

  • Every diagram can be factorised as a span or a cospan of matrices
  • This gives us the two different ways one can think of spaces

solutions of a list of homogeneous equations

linear combinations

  • f basis vectors

x+y=0 x y z 2y-z=0

2

x y z

x+y=0 2y-z=0

2

x y z

Cospans

a[1, -1, 0] a

b[0, 1, 2]

2

b

a[1, -1, 0]+b[0,1,2]

2

a b

Spans

slide-158
SLIDE 158

Image and kernel

  • Definition
  • The kernel of A is
  • The cokernel of A is
  • The image of A is
  • The coimage of A is

A A

AT AT

slide-159
SLIDE 159

Injectivity

Injective matrices are the monos in MatZ

  • Theorem. A is injective iff

A A

=

⇒ ⇐

A F A G

= ⇒

A F A G

=

A A

F

=

G

    

  • ?

? ? ? ?

A

  • ?

? ? ? ?

A

    

is pullback in MatZ

A F A G

= ⇒

F

=

G

slide-160
SLIDE 160

Surjectivity

  • Surjective matrices are the epis in MatZ, i.e.
  • Theorem. A is surjective iff

A A

= A A F G

= ⇒

F

=

G

Proof: Bizarro of last slide

slide-161
SLIDE 161

Injectivity and kernel

  • Theorem. A is injective iff ker A = 0

⇒ ⇐

A A

=

A A

=

A A

=

A

= =

A

=

A A

=

slide-162
SLIDE 162

Surjectivity and image

  • Theorem. A is surjective iff im(A)=codomain

A A

=

A

=

Proof: bizarro of last slide

slide-163
SLIDE 163

Invertible matrices

  • Theorem: A is invertible with inverse B iff

A B

=

⇒ ⇐

so A is injective

A B A A

= =

bizarro argument yields other half

A A B B

= =

A A B

= =

slide-164
SLIDE 164

Summary

  • We have done a bit of linear algebra without mentioning
  • vectors, vector spaces and bases
  • linear dependence/independence, spans of a vector list
  • dimensions
  • Similar stories can be told for other parts of linear algebra:

decompositions, eigenvalues/eigenspaces, determinants

  • much of this is work in progress: check out the blog! :)
slide-165
SLIDE 165

Plan

  • basic theory of string diagrams
  • theory of natural number matrices (bimonoids) and

integer matrices (Hopf monoids)

  • theory of linear relations (interacting Hopf monoids)
  • distributive laws
  • linear algebra, diagrammatically
  • an application: signal flow graphs
slide-166
SLIDE 166

Generalising (slightly)

  • It is straightforward to generalise from Z to arbitrary

PID R

  • We can build the theory HR by adding enough scalars

to the graphical syntax together with equations

  • The equations of IHR are the same as before

r1 r2 r1+r2

=

r1 r2

=

r2r1

1

= =

slide-167
SLIDE 167

Application: infinite series

  • Diagrammatic calculus for spaces over the field of fractions of Q[x]

(polynomials with one variable, a PID) is especially interesting

  • polynomial fractions = nice syntax for many infinite series

(generatingfunctionology!)

  • formally: there is an embedding of fields from polynomial fractions

(syntax) to Laurent series (semantics)

  • Moreover: diagrams are very closely related to signal flow graphs
  • invented by Shannon in the 40s, reinvented by Mason in the 50s,

foundational structure in control and signal processing

  • useful circuit-like syntax for linear time-invariant dynamical systems
slide-168
SLIDE 168

The cube (with extra level!)

MatQ[x] + MatQ[x]

  • p

HQ[x] + HQ[x]

  • p

Span(MatQ[x]) IHQ[x] Span IHQ[x] Cospan Cospan(MatQ[x]) LinRelQ(x) IHQ(x) MatQ[[x]] + MatQ[[x]]

  • p

Cospan(MatQ[[x]]) Span(MatQ[[x]]) LinRelQ((x))

isomorphisms faithful homomorphisms

In particular, IHQ[x] is sound and complete as a theory for LinRelQ((x))

slide-169
SLIDE 169

Example

1-x-x2 x

As linear relation over Q(x) is the space generated by

As linear relation over Q((x)) is the space generated by

(1 , x/(1-x-x2)) (1,0,0,… , 0,1,1,2,3,5,8,…)

slide-170
SLIDE 170

Operational semantics

k

− − →

k k k

− →

k

l

− − →

kl

k

x

l

k

− →

l

x

k

k l

− − →

k+l

− →

k k

− − →

k

− →

k

k

kl

− − →

l

k

x

l

l

− →

k

x

k

k+l

− − − →

k l

− →

k

− →

k k l

− − →

l k

s

u

− →

v

s0 t

v

− →

w t0

s ; t

u

− →

w s0 ; t0

s

u1

− − →

v1

s0 t

u2

− − →

v2

t0 s ⊕ t

u1 u2

− − − − →

v1 v2

s0 ⊕ t0

Bonchi, S., Zanasi, Full abstraction for signal flow graphs, POPL ‘15

Important point: all executions start with all registers initialised with 0!

slide-171
SLIDE 171

Example

:=

:=

x x

1 1 1 1

x x

1 2 1 1 2

x x

2 3 1 1 3

slide-172
SLIDE 172

Operational Semantics vs Denotational Semantics

Operational semantics closely related to denotational semantics [linear relations over Q((x))] with some “implementation issues” in diagrams where signal flow is inconsistent e.g.

x x x x

k k

x x

1 2

x x

1 2

slide-173
SLIDE 173

Realisability and Full Abstraction

  • Realisability Every diagram can be put in a form

where the direction of signal flow is consistent

  • Full abstraction Operational equality (in terms of

behaviour, given by operational semantics) coincides with denotational equality (the denoted linear relation)

  • n diagrams with consistent signal flow
slide-174
SLIDE 174

Turning generating functions into signal flow graphs

1,2,3,4,…

Generating function Diagram Signal flow graph

1 (1 − x)2

x x (1-x)2

0,-4,0,-8,..

−4x (1 − x2)2

1,-2,3,-4,…

1 (1 + x)2

x x x x

  • 4

x (1-x2)2

  • 4x

(1+x)2 x x

slide-175
SLIDE 175

Fibonacci

(C 1170 - C 1250)

1 2 3 5 8 13 21 34 55 89 144 233 377 A certain man had one pair of rabbits together in a certain enclosed place, and one wishes to know how many are created from the pair in one year when it is the nature of them in a single month to bear another pair, and in the second month those born to bear also. You can indeed see in the margin how we operated, namely that we added the first number to the second, namely the 1 to the 2, and the second to the third, and the third to the fourth, and the fourth to the fifth, and thus one after another until we added the tenth to the eleventh, namely the 144 to the 233, and we had the above written sum of rabbits, namely 377, and thus you can in order find it for an unending number of months.

(extract from Liber Abaci, chapter 12, translated from Latin by Lawrence Sigler)

slide-176
SLIDE 176

The Fibonacci sequence

and recurrence relations 1, 2, 3, 5, 8, 13, … in modern presentations often given as

1, 1, 2, 3, 5, 8, …

  • r

0, 1, 1, 2, 3, 5, …

is an example of a recurrence relation here Fn+2 = Fn+1 + Fn

more generally, the nth term can be obtain as an expression featuring previous terms

slide-177
SLIDE 177

Code for Fibonacci

val ffib : int list -> int list = <fun> # ffib [1;0;0;0;0;0;0;0];;

  • : int list = [1; 2; 3; 5; 8; 13; 21; 34]

# ffib [1;1;1;1;1;1;1;1];;

  • : int list = [1; 3; 6; 11; 19; 32; 53; 87]

# ffib [1;1;-3;1;-2;-4;1];;

  • : int list = [1; 3; 2; 3; 4; 1; 2]

Generalise the Fibonacci rabbit breeding rule from a sequence to a function of type

slide-178
SLIDE 178

Sustainable rabbit breeding

  • Suppose that we want a sustainable rabbit farm, keeping 4

pairs in the rabbit pen at all times.

  • Is it possible?
  • If so, how many rabbits must we add and remove, in which

months? If the Fibonacci rule gives us a function of type to solve the sustainable rabbit breeding problem we could try to write the inverse

ffib: int list -> int list bfib: int list -> int list

slide-179
SLIDE 179

Bibliography

  • Bonchi, S., Zanasi - Interacting Bialgebras are Frobenius, FoSSaCS ’14
  • Bonchi, S., Zanasi - Interacting Hopf Algebras, J Pure Applied Algebra 221:144–184, 2017
  • Bonchi, S., Zanasi - The Calculus of Signal Flow Diagrams I: Linear Relations on Streams, Inf Comput 252:2–29, 2017
  • Bonchi, S., Zanasi - A categorical semantics of signal flow graphs, CONCUR 2013
  • Bonchi, S., Zanasi - Full abstraction for signal flow graphs, PoPL 2016
  • Zanasi - Interacting Hopf Algebras: The theory of linear systems, PhD Thesis, ENS Lyon, 2015
  • Bonchi, S., Zanasi - Lawvere Theories as composed PROPs, CMCS 2016
  • Fong, Rapisarda, S. - A categorical approach to open and interconnected dynamical systems, LiCS 2016
  • Bonchi, Gadducci, Kissinger, S. - Rewriting modulo symmetric monoidal structure, LiCS 2016
  • Bonchi, Gadducci, Kissinger, S. - Confluence of Graph Rewriting with Interfaces, ESOP 2017

graphicallinearalgebra.net