String Diagrams Paul-Andr Mellis Oregon Summer School in - - PowerPoint PPT Presentation

string diagrams
SMART_READER_LITE
LIVE PREVIEW

String Diagrams Paul-Andr Mellis Oregon Summer School in - - PowerPoint PPT Presentation

Programming Languages in String Diagrams [ one ] String Diagrams Paul-Andr Mellis Oregon Summer School in Programming Languages June 2011 String diagrams A diagrammatic account of logic and programming 2 Semantics in the 1980s


slide-1
SLIDE 1

Programming Languages in String Diagrams [

  • ne

]

String Diagrams

Paul-André Melliès Oregon Summer School in Programming Languages June 2011

slide-2
SLIDE 2

String diagrams

A diagrammatic account of logic and programming

2

slide-3
SLIDE 3

Semantics in the 1980’s

Cartesian-Closed Categories Intuitionistic Logic λ-calculus

3

slide-4
SLIDE 4

Semantics in the 1990’s

Monoidal-Closed Categories Linear Logic Proof-Nets

4

slide-5
SLIDE 5

Where is the flow of logic?

  • Ideography (Frege)
  • Sequent calculus (Gentzen)
  • Natural deduction (Prawitz)
  • Proof nets (Girard)

Looking for a purely mathematical notation for proofs...

5

slide-6
SLIDE 6

Guide : the algebra of Feynman diagrams

We want to see the flow inside our proofs and programs !

slide-7
SLIDE 7

String Diagrams

Categorical Algebra Logic and Language String Diagrams

An algebraic investigation of logic and programming

7

slide-8
SLIDE 8

String Diagrams

Categorical Algebra Logic and Language String Diagrams

A bridge between algebra, physics and low level languages

8

slide-9
SLIDE 9

Compositionality in logic

The reason for introducing categories

9

slide-10
SLIDE 10

Sequent calculus of linear logic

Axiom A ⊢ A Cut Γ ⊢ A Υ1, A, Υ2 ⊢ B Υ1, Γ, Υ2 ⊢ B Left ⊗ Υ1, A, B, Υ2 ⊢ C Υ1, A ⊗ B, Υ2 ⊢ C Right ⊗ Γ ⊢ A ∆ ⊢ B Γ, ∆ ⊢ A ⊗ B Left ⊸ Γ ⊢ A Υ1, B, Υ2 ⊢ C Υ1, Γ, A ⊸ B, Υ2 ⊢ C Right ⊸ A, Γ ⊢ B Γ ⊢ A ⊸ B

10

slide-11
SLIDE 11

Modus Ponens

If the property A is true and the property A ⇒ B is true, then the property B is true.

11

slide-12
SLIDE 12

Modus ponens in the sequent calculus π1 . . . ⊢ A π2 . . . A ⊢ B Cut ⊢ B

12

slide-13
SLIDE 13

Modus ponens in the type system π1 . . . ⊢ P : A π2 . . . x : A ⊢ M : B ⊢ (λx.M) P : B

13

slide-14
SLIDE 14

Modus Ponens

If the property A ⇒ B is true and the property B ⇒ C is true, then the property A ⇒ C is true.

14

slide-15
SLIDE 15

Modus ponens in the sequent calculus π1 . . . A ⊢ B π2 . . . B ⊢ C Cut A ⊢ C

15

slide-16
SLIDE 16

Modus ponens in the type system π1 . . . x : A ⊢ P : B π2 . . . y : B ⊢ M : C x : A ⊢ (λy.M) P : C

16

slide-17
SLIDE 17

The logical graph

Its vertices are the logical formulas and its edges A

π

  • B

are the logical proofs π

. . .

A ⊢ B

17

slide-18
SLIDE 18

Modus ponens in the logical graph

Every pair of edges A

π1

  • B

π2

  • C

induces an edge A

π3

  • C

which may be denoted as π3 = π2

  • π1

18

slide-19
SLIDE 19

Associativity

Given a path A

π1

  • B

π2

  • C

π3

  • D
  • ne would like that the order of composition does not matter:

π3 ◦ ( π2 ◦ π1 ) = ( π3 ◦ π2 ) ◦ π1

19

slide-20
SLIDE 20

Associativity in the sequent calculus

π1

. . .

A ⊢ B π2

. . .

B ⊢ C A ⊢ C π3

. . .

C ⊢ D A ⊢ D = π1

. . .

A ⊢ B π2

. . .

B ⊢ C π3

. . .

C ⊢ D B ⊢ D A ⊢ D

20

slide-21
SLIDE 21

The identity proof Axiom A ⊢ A

21

slide-22
SLIDE 22

Identity

Given A

idA

  • A

π

  • B

idB

  • B
  • ne would like that

idA ◦ π = π = π ◦ idB

22

slide-23
SLIDE 23

Identity in the sequent calculus

Axiom A ⊢ A π

. . .

A ⊢ B Cut A ⊢ B is equal to π

. . .

A ⊢ B is equal to π

. . .

A ⊢ B Axiom B ⊢ B Cut A ⊢ B

23

slide-24
SLIDE 24

The logical graph (bis)

Its vertices are the logical formulas and its edges A

π

  • B

are the logical proofs π

. . .

A ⊢ B modulo symbolic execution.

24

slide-25
SLIDE 25

Definition of a category

A graph equipped with a composition operation A

f

B

g

C

→ A

g◦f

C

and an identity edge for every vertex of the graph A

idA

A

satisfying the associativity h ◦ ( g ◦ f ) = ( h ◦ g ) ◦ f and identity equations: idA ◦ f = f = f

  • idB

25

slide-26
SLIDE 26

What about the conjunction?

Given two proofs π1

. . .

A1 ⊢ A2 π2

. . .

B1 ⊢ B2

  • ne is able to construct the proof:

π1

. . .

A1 ⊢ A2 π2

. . .

B1 ⊢ B2 Right ⊗ A1, B1 ⊢ A2 ⊗ B2 Left ⊗ A1 ⊗ B1 ⊢ A2 ⊗ B2

26

slide-27
SLIDE 27

Tensor product

So, every pair of edges A1

π1

B1

A2

π1

B2

induces an edge A1 ⊗ A2

π3

  • B1 ⊗ B2

which may be denoted as π3 = π1 ⊗ π2

27

slide-28
SLIDE 28

Monoidal Categories

A monoidal category is a category C equipped with a functor: ⊗ : C × C −→ C an object: I and three natural transformations: (A ⊗ B) ⊗ C

α

−→ A ⊗ (B ⊗ C) I ⊗ A

λ

−→ A A ⊗ I

ρ

−→ A satisfying a series of coherence properties.

28

slide-29
SLIDE 29

String Diagrams

A notation by Roger Penrose

29

slide-30
SLIDE 30

String Diagrams

A morphism f : A ⊗ B ⊗ C −→ D ⊗ E is depicted as:

f A B C D E 30

slide-31
SLIDE 31

Composition

The morphism A

f

−→ B

g

−→ C is depicted as

A A C g ◦ f

=

g f A C B

Vertical composition

31

slide-32
SLIDE 32

Tensor product

The morphism (A

f

−→ B) ⊗ (C

g

−→ D) is depicted as

A ⊗ C B ⊗ D f ⊗ g

=

g f A B C D

Horizontal tensor product

32

slide-33
SLIDE 33

Example

f A B D D

f ⊗ idD

33

slide-34
SLIDE 34

Example

g f A B C D

( f ⊗ idD) ◦ (idA ⊗ g)

34

slide-35
SLIDE 35

Example

g f A B C D

(idB ⊗ g) ◦ (f ⊗ idC)

35

slide-36
SLIDE 36

Meaning preserved by deformation

g f A B C D

=

g f A B C D

( f ⊗ idD) ◦ (idA ⊗ g) = (idB ⊗ g) ◦ (f ⊗ idC)

36

slide-37
SLIDE 37

Application to knot theory

A tensor algebra of knots

37

slide-38
SLIDE 38

Braided categories

A monoidal category equipped with braid maps A ⊗ B

γA,B

−→ B ⊗ A

B B A A

B ⊗ A

γ−1

A,B

−→ A ⊗ B

A A B B

38

slide-39
SLIDE 39

Coherence diagram for braids

A ⊗ (B ⊗ C)

γ

(B ⊗ C) ⊗ A

α

  • (A ⊗ B) ⊗ C

α

  • γ⊗C
  • B ⊗ (C ⊗ A)

(B ⊗ A) ⊗ C

α

B ⊗ (A ⊗ C)

B⊗γ

  • 39
slide-40
SLIDE 40

Topological deformation in string diagrams

C B A A C B

=

B A A C B C

40

slide-41
SLIDE 41

Coherence diagram for braids

(A ⊗ B) ⊗ C

γ

C ⊗ (A ⊗ B)

α−1

  • A ⊗ (B ⊗ C)

α−1

  • A⊗γ
  • (C ⊗ A) ⊗ B

A ⊗ (C ⊗ B)

α−1

(A ⊗ C) ⊗ B

γ⊗B

  • 41
slide-42
SLIDE 42

Topological deformation in string diagrams

C B A B A C

=

B A B A C C

42

slide-43
SLIDE 43

Duality

A duality A ⊣ B is a pair of morphisms I

η

−→ A ⊗ B

A A∗ ηA

B ⊗ A

ǫ

−→ I

A A∗ ǫA

43

slide-44
SLIDE 44

Duality

satisfying the two “zig-zag” equalities:

A A

=

A A B B

=

B B

In that case, A is called a left dual of B.

44

slide-45
SLIDE 45

Ribbon category

A braided category in which every object A has a dual A∗ satisfying:

A A∗ A∗∗ A∗ A

=

A A

=

A A∗ A∗∗ A∗ A

45

slide-46
SLIDE 46

Knot invariants

Every ribbon category D induces a knot invariant free-ribbon(C)

[ [−] ]

D

C

  • The free ribbon category is a category of framed tangles

46

slide-47
SLIDE 47

Jones polynomial invariant

  • 2

x2 + 1 x4 + y2 x2

2x2 − x4 + x2y2

A compositional semantics of knots

47

slide-48
SLIDE 48

Can we apply this to proofs and programs?

The topic of the next session...

48

slide-49
SLIDE 49

Monoidal categories with feedback

A definition by Joyal, Street and Verity (1996)

49

slide-50
SLIDE 50

Trace operator

A trace in a symmetric monoidal category C is an operator

A ⊗ U −→ B ⊗ U Tr U

A, B

A −→ B

depicted as feedback in string diagrams:

50

slide-51
SLIDE 51

Trace operator

(

)

f f = A A U B B U U TrU

A,B

51

slide-52
SLIDE 52

Sliding (naturality in U)

u u f f = A A B B V U U V

52

slide-53
SLIDE 53

Tightening (naturality in A, B)

a b a b f f =

53

slide-54
SLIDE 54

Vanishing (monoidality in U)

f f = U ⊗ V V U f f = I 54

slide-55
SLIDE 55

Superposing

g f f g f g = =

55

slide-56
SLIDE 56

Yanking

U U U = = 56

slide-57
SLIDE 57

Fixpoint operator

Given a map f : A ⊗ U −→ U we want to compute a map Fix [f] : A −→ U such that f ( a , Fix[f] (a) ) = Fix[f] (a) Enables to compute recursive definitions

57

slide-58
SLIDE 58

Fixpoints computed from traces

Suppose given a diagonal map U −→ U ⊗ U Then, Fix :

f A U U

∆ f A U U

defines a well-behaved fixpoint operator.

58

slide-59
SLIDE 59

Traces = parametric fixpoints (1)

∆ f A U U

59

slide-60
SLIDE 60

Traces = parametric fixpoints (2)

∆ ∆ f f A U U

60

slide-61
SLIDE 61

Traces = parametric fixpoints (3)

∆ ∆ f f A A U U U

61

slide-62
SLIDE 62

Traces = parametric fixpoints (4)

∆ f ∆ f A A U U U

62

slide-63
SLIDE 63

Traces = parametric fixpoints (5)

∆ f ∆ f A A A U U

63

slide-64
SLIDE 64

Traces = parametric fixpoints (6)

∆ f A U U

=

∆ f ∆ f A U U

64