158
Lecture one: The Method of Coalgebra – in some detail – Jan Rutten CWI Amsterdam & Radboud University Nijmegen IPM, Tehran - 13 January 2016

Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Lecture one:

The Method of Coalgebra– in some detail –

Jan Rutten

CWI Amsterdam & Radboud University Nijmegen

IPM, Tehran - 13 January 2016

Page 2: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Acknowledgements

My esteemed co-authors

- Marcello Bonsangue (Leiden, CWI)- Helle Hansen (Delft)- Alexandra Silva (City College London)- Milad Niqui- Clemens Kupke (Glasgow)- Prakash Panangaden (McGill, Montreal)- Filippo Bonchi (ENS, Lyon)- Joost Winter (Warsaw), Jurriaan Rot (ENS, Lyon)- and many others.

Samson Abramsky (Oxford)Damien Pous (ENS, Lyon)

Page 3: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Acknowledgements

My esteemed co-authors

- Marcello Bonsangue (Leiden, CWI)- Helle Hansen (Delft)- Alexandra Silva (City College London)- Milad Niqui- Clemens Kupke (Glasgow)- Prakash Panangaden (McGill, Montreal)- Filippo Bonchi (ENS, Lyon)- Joost Winter (Warsaw), Jurriaan Rot (ENS, Lyon)- and many others.

Samson Abramsky (Oxford)Damien Pous (ENS, Lyon)

Page 4: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Overview of todays lectures

Lecture one: The method of coalgebra

Lecture two: A coinductive calculus of streams

Lecture three: Automata and the algebra-coalgebra duality

Lecture four: Coalgebraic up-to techniques

Page 5: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Overview of Lecture one

1. Category theory (where coalgebra comes from)

2. Duality (where coalgebra comes from)

3. How coalgebra works (the method in slogans)

4. Duality: induction and coinduction

5. What coalgebra studies (its subject)

6. Discussion

Page 6: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

1. Category theory(where coalgebra comes from)

Page 7: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Why categories?

From Samson Abramsky’s tutorial:

Categories, why and how?

(Dagstuhl, January 2015)

Page 8: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Why categories?

For logicians: gives a syntax-independent view of thefundamental structures of logic, opens up new kinds of modelsand interpretations.

For philosophers: a fresh approach to structuralist foundationsof mathematics and science; an alternative to the traditionalfocus on set theory.

For computer scientists: gives a precise handle onabstraction, representation-independence, genericity and more.Gives the fundamental mathematical structures underpinningprogramming concepts.

Page 9: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Why categories?

For mathematicians: organizes your previous mathematicalexperience in a new and powerful way, reveals new connectionsand structure, allows you to “think bigger thoughts”.

For physicists: new ways of formulating physical theories in astructural form. Recent applications to Quantum Informationand Computation.

For economists and game theorists: new tools, bringingcomplex phenomena into the scope of formalisation.

Page 10: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Category Theory in 10 Slogans1. Always ask: what are the types?

2. Think in terms of arrows rather than elements.

3. Ask what mathematical structures do, not what they are.

4. Categories as mathematical contexts.

5. Categories as mathematical structures.

6. Make definitions and constructions as general as possible.

7. Functoriality!

8. Naturality!

9. Universality!

10. Adjoints are everywhere.

Page 11: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Category Theory in 10 Slogans1. Always ask: what are the types?

2. Think in terms of arrows rather than elements.

3. Ask what mathematical structures do, not what they are.

4. Categories as mathematical contexts.

5. Categories as mathematical structures.

6. Make definitions and constructions as general as possible.

7. Functoriality!

8. Naturality!

9. Universality!

10. Adjoints are everywhere.

Page 12: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Category Theory in 10 Slogans1. Always ask: what are the types?

2. Think in terms of arrows rather than elements.

3. Ask what mathematical structures do, not what they are.

4. Categories as mathematical contexts.

5. Categories as mathematical structures.

6. Make definitions and constructions as general as possible.

7. Functoriality!

8. Naturality!

9. Universality!

10. Adjoints are everywhere.

Page 13: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Category Theory in 10 Slogans1. Always ask: what are the types?

2. Think in terms of arrows rather than elements.

3. Ask what mathematical structures do, not what they are.

4. Categories as mathematical contexts.

5. Categories as mathematical structures.

6. Make definitions and constructions as general as possible.

7. Functoriality!

8. Naturality!

9. Universality!

10. Adjoints are everywhere.

Page 14: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Category Theory in 10 Slogans1. Always ask: what are the types?

2. Think in terms of arrows rather than elements.

3. Ask what mathematical structures do, not what they are.

4. Categories as mathematical contexts.

5. Categories as mathematical structures.

6. Make definitions and constructions as general as possible.

7. Functoriality!

8. Naturality!

9. Universality!

10. Adjoints are everywhere.

Page 15: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Category Theory in 10 Slogans1. Always ask: what are the types?

2. Think in terms of arrows rather than elements.

3. Ask what mathematical structures do, not what they are.

4. Categories as mathematical contexts.

5. Categories as mathematical structures.

6. Make definitions and constructions as general as possible.

7. Functoriality!

8. Naturality!

9. Universality!

10. Adjoints are everywhere.

Page 16: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Category Theory in 10 Slogans1. Always ask: what are the types?

2. Think in terms of arrows rather than elements.

3. Ask what mathematical structures do, not what they are.

4. Categories as mathematical contexts.

5. Categories as mathematical structures.

6. Make definitions and constructions as general as possible.

7. Functoriality!

8. Naturality!

9. Universality!

10. Adjoints are everywhere.

Page 17: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Category Theory in 10 Slogans1. Always ask: what are the types?

2. Think in terms of arrows rather than elements.

3. Ask what mathematical structures do, not what they are.

4. Categories as mathematical contexts.

5. Categories as mathematical structures.

6. Make definitions and constructions as general as possible.

7. Functoriality!

8. Naturality!

9. Universality!

10. Adjoints are everywhere.

Page 18: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Category Theory in 10 Slogans1. Always ask: what are the types?

2. Think in terms of arrows rather than elements.

3. Ask what mathematical structures do, not what they are.

4. Categories as mathematical contexts.

5. Categories as mathematical structures.

6. Make definitions and constructions as general as possible.

7. Functoriality!

8. Naturality!

9. Universality!

10. Adjoints are everywhere.

Page 19: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Category Theory in 10 Slogans1. Always ask: what are the types?

2. Think in terms of arrows rather than elements.

3. Ask what mathematical structures do, not what they are.

4. Categories as mathematical contexts.

5. Categories as mathematical structures.

6. Make definitions and constructions as general as possible.

7. Functoriality!

8. Naturality!

9. Universality!

10. Adjoints are everywhere.

Page 20: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Categories: basic definitions

A category C consists of

- Objects A,B,C, . . .

- Morphisms/arrows: for each pair of objects A,B, a set ofmorphisms C(A,B) with domain A and codomain B

- Composition of morphisms: g ◦ f :

A

g ◦ f

66f // B

g// C

- Axioms:

h ◦ (g ◦ f ) = (h ◦ g) ◦ f f ◦ id = f = id ◦ f

Page 21: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Categories: basic definitions

A category C consists of

- Objects A,B,C, . . .

- Morphisms/arrows: for each pair of objects A,B, a set ofmorphisms C(A,B) with domain A and codomain B

- Composition of morphisms: g ◦ f :

A

g ◦ f

66f // B

g// C

- Axioms:

h ◦ (g ◦ f ) = (h ◦ g) ◦ f f ◦ id = f = id ◦ f

Page 22: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Categories: basic definitions

A category C consists of

- Objects A,B,C, . . .

- Morphisms/arrows: for each pair of objects A,B, a set ofmorphisms C(A,B) with domain A and codomain B

- Composition of morphisms: g ◦ f :

A

g ◦ f

66f // B

g// C

- Axioms:

h ◦ (g ◦ f ) = (h ◦ g) ◦ f f ◦ id = f = id ◦ f

Page 23: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Categories: basic definitions

A category C consists of

- Objects A,B,C, . . .

- Morphisms/arrows: for each pair of objects A,B, a set ofmorphisms C(A,B) with domain A and codomain B

- Composition of morphisms: g ◦ f :

A

g ◦ f

66f // B

g// C

- Axioms:

h ◦ (g ◦ f ) = (h ◦ g) ◦ f f ◦ id = f = id ◦ f

Page 24: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Categories: basic definitions

A category C consists of

- Objects A,B,C, . . .

- Morphisms/arrows: for each pair of objects A,B, a set ofmorphisms C(A,B) with domain A and codomain B

- Composition of morphisms: g ◦ f :

A

g ◦ f

66f // B

g// C

- Axioms:

h ◦ (g ◦ f ) = (h ◦ g) ◦ f f ◦ id = f = id ◦ f

Page 25: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Categories: examples

• Any kind of mathematical structure, together with structurepreserving functions, forms a category. E.g.

- sets and functions- groups and group homomorphisms- monoids and monoid homomorphisms- vector spaces over a field k , and linear maps- topological spaces and continuous functions- partially ordered sets and monotone functions

• Monoids are one-object categories

• algebras, and algebra homomorphisms

• coalgebras, and coalgebra homomorphisms

Page 26: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Categories: examples

• Any kind of mathematical structure, together with structurepreserving functions, forms a category. E.g.

- sets and functions- groups and group homomorphisms- monoids and monoid homomorphisms- vector spaces over a field k , and linear maps- topological spaces and continuous functions- partially ordered sets and monotone functions

• Monoids are one-object categories

• algebras, and algebra homomorphisms

• coalgebras, and coalgebra homomorphisms

Page 27: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Categories: examples

• Any kind of mathematical structure, together with structurepreserving functions, forms a category. E.g.

- sets and functions- groups and group homomorphisms- monoids and monoid homomorphisms- vector spaces over a field k , and linear maps- topological spaces and continuous functions- partially ordered sets and monotone functions

• Monoids are one-object categories

• algebras, and algebra homomorphisms

• coalgebras, and coalgebra homomorphisms

Page 28: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Categories: examples

• Any kind of mathematical structure, together with structurepreserving functions, forms a category. E.g.

- sets and functions- groups and group homomorphisms- monoids and monoid homomorphisms- vector spaces over a field k , and linear maps- topological spaces and continuous functions- partially ordered sets and monotone functions

• Monoids are one-object categories

• algebras, and algebra homomorphisms

• coalgebras, and coalgebra homomorphisms

Page 29: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Categories: examples

• Any kind of mathematical structure, together with structurepreserving functions, forms a category. E.g.

- sets and functions- groups and group homomorphisms- monoids and monoid homomorphisms- vector spaces over a field k , and linear maps- topological spaces and continuous functions- partially ordered sets and monotone functions

• Monoids are one-object categories

• algebras, and algebra homomorphisms

• coalgebras, and coalgebra homomorphisms

Page 30: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Categories: examples

• Any kind of mathematical structure, together with structurepreserving functions, forms a category. E.g.

- sets and functions- groups and group homomorphisms- monoids and monoid homomorphisms- vector spaces over a field k , and linear maps- topological spaces and continuous functions- partially ordered sets and monotone functions

• Monoids are one-object categories

• algebras, and algebra homomorphisms

• coalgebras, and coalgebra homomorphisms

Page 31: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Categories: examples

• Any kind of mathematical structure, together with structurepreserving functions, forms a category. E.g.

- sets and functions- groups and group homomorphisms- monoids and monoid homomorphisms- vector spaces over a field k , and linear maps- topological spaces and continuous functions- partially ordered sets and monotone functions

• Monoids are one-object categories

• algebras, and algebra homomorphisms

• coalgebras, and coalgebra homomorphisms

Page 32: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Categories: examples

• Any kind of mathematical structure, together with structurepreserving functions, forms a category. E.g.

- sets and functions- groups and group homomorphisms- monoids and monoid homomorphisms- vector spaces over a field k , and linear maps- topological spaces and continuous functions- partially ordered sets and monotone functions

• Monoids are one-object categories

• algebras, and algebra homomorphisms

• coalgebras, and coalgebra homomorphisms

Page 33: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Categories: examples

• Any kind of mathematical structure, together with structurepreserving functions, forms a category. E.g.

- sets and functions- groups and group homomorphisms- monoids and monoid homomorphisms- vector spaces over a field k , and linear maps- topological spaces and continuous functions- partially ordered sets and monotone functions

• Monoids are one-object categories

• algebras, and algebra homomorphisms

• coalgebras, and coalgebra homomorphisms

Page 34: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Categories: examples

• Any kind of mathematical structure, together with structurepreserving functions, forms a category. E.g.

- sets and functions- groups and group homomorphisms- monoids and monoid homomorphisms- vector spaces over a field k , and linear maps- topological spaces and continuous functions- partially ordered sets and monotone functions

• Monoids are one-object categories

• algebras, and algebra homomorphisms

• coalgebras, and coalgebra homomorphisms

Page 35: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Arrows rather than elementsA function f : X → Y (between sets) is:

- injective if

∀x , y ∈ X , f (x) = f (y)⇒ x = y

- surjective if∀y ∈ Y , ∃x ∈ X , f (x) = y

- monic if∀g,h, f ◦ g = f ◦ h⇒ g = h

- epic if∀g,h, g ◦ f = h ◦ f ⇒ g = h

Proposition

• m is injective iff m is monic.• e is surjective iff e is epic.

Page 36: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Arrows rather than elementsA function f : X → Y (between sets) is:

- injective if

∀x , y ∈ X , f (x) = f (y)⇒ x = y

- surjective if∀y ∈ Y , ∃x ∈ X , f (x) = y

- monic if∀g,h, f ◦ g = f ◦ h⇒ g = h

- epic if∀g,h, g ◦ f = h ◦ f ⇒ g = h

Proposition

• m is injective iff m is monic.• e is surjective iff e is epic.

Page 37: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Arrows rather than elementsA function f : X → Y (between sets) is:

- injective if

∀x , y ∈ X , f (x) = f (y)⇒ x = y

- surjective if∀y ∈ Y , ∃x ∈ X , f (x) = y

- monic if∀g,h, f ◦ g = f ◦ h⇒ g = h

- epic if∀g,h, g ◦ f = h ◦ f ⇒ g = h

Proposition

• m is injective iff m is monic.• e is surjective iff e is epic.

Page 38: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Arrows rather than elementsA function f : X → Y (between sets) is:

- injective if

∀x , y ∈ X , f (x) = f (y)⇒ x = y

- surjective if∀y ∈ Y , ∃x ∈ X , f (x) = y

- monic if∀g,h, f ◦ g = f ◦ h⇒ g = h

- epic if∀g,h, g ◦ f = h ◦ f ⇒ g = h

Proposition

• m is injective iff m is monic.• e is surjective iff e is epic.

Page 39: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Arrows rather than elementsA function f : X → Y (between sets) is:

- injective if

∀x , y ∈ X , f (x) = f (y)⇒ x = y

- surjective if∀y ∈ Y , ∃x ∈ X , f (x) = y

- monic if∀g,h, f ◦ g = f ◦ h⇒ g = h

- epic if∀g,h, g ◦ f = h ◦ f ⇒ g = h

Proposition

• m is injective iff m is monic.• e is surjective iff e is epic.

Page 40: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Arrows rather than elementsA function f : X → Y (between sets) is:

- injective if

∀x , y ∈ X , f (x) = f (y)⇒ x = y

- surjective if∀y ∈ Y , ∃x ∈ X , f (x) = y

- monic if∀g,h, f ◦ g = f ◦ h⇒ g = h

- epic if∀g,h, g ◦ f = h ◦ f ⇒ g = h

Proposition

• m is injective iff m is monic.• e is surjective iff e is epic.

Page 41: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Arrows rather than elementsA function f : X → Y (between sets) is:

- injective if

∀x , y ∈ X , f (x) = f (y)⇒ x = y

- surjective if∀y ∈ Y , ∃x ∈ X , f (x) = y

- monic if∀g,h, f ◦ g = f ◦ h⇒ g = h

- epic if∀g,h, g ◦ f = h ◦ f ⇒ g = h

Proposition

• m is injective iff m is monic.• e is surjective iff e is epic.

Page 42: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Arrows rather than elementsA function f : X → Y (between sets) is:

- injective if

∀x , y ∈ X , f (x) = f (y)⇒ x = y

- surjective if∀y ∈ Y , ∃x ∈ X , f (x) = y

- monic if∀g,h, f ◦ g = f ◦ h⇒ g = h

- epic if∀g,h, g ◦ f = h ◦ f ⇒ g = h

Proposition

• m is injective iff m is monic.• e is surjective iff e is epic.

Page 43: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Arrows rather than elementsDefining the Cartesian product . . .

- with elements:

A× B = { 〈a,b〉 | a ∈ A, b ∈ B }

where〈a,b〉 = {{a,b}, b}

- with arrows (expressing a universal property):

∀Cf

��

g

��

〈f ,g〉��

A A× Bπ1oo

π2// B

Page 44: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Arrows rather than elementsDefining the Cartesian product . . .

- with elements:

A× B = { 〈a,b〉 | a ∈ A, b ∈ B }

where〈a,b〉 = {{a,b}, b}

- with arrows (expressing a universal property):

∀Cf

��

g

��

〈f ,g〉��

A A× Bπ1oo

π2// B

Page 45: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Arrows rather than elementsDefining the Cartesian product . . .

- with elements:

A× B = { 〈a,b〉 | a ∈ A, b ∈ B }

where〈a,b〉 = {{a,b}, b}

- with arrows (expressing a universal property):

∀Cf

��

g

��

〈f ,g〉��

A A× Bπ1oo

π2// B

Page 46: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

2. Duality (where coalgebra comes from)

An additional slogan for categories: duality is omnipresent

- epi - mono

- product - sum

- initial object - final object

- algebra - coalgebra

Page 47: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

2. Duality (where coalgebra comes from)

An additional slogan for categories: duality is omnipresent

- epi - mono

- product - sum

- initial object - final object

- algebra - coalgebra

Page 48: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Duality: monos and epis

- f is monic:∀g,h, f ◦ g = f ◦ h⇒ g = h

•g

''

h77 • f // •

- f is epic:∀g,h, g ◦ f = h ◦ f ⇒ g = h

• •h

gg

gww •foo

Proposition: f is monic in C iff f is epic in Cop.

Page 49: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Duality: monos and epis

- f is monic:∀g,h, f ◦ g = f ◦ h⇒ g = h

•g

''

h77 • f // •

- f is epic:∀g,h, g ◦ f = h ◦ f ⇒ g = h

• •h

gg

gww •foo

Proposition: f is monic in C iff f is epic in Cop.

Page 50: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Duality: monos and epis

- f is monic:∀g,h, f ◦ g = f ◦ h⇒ g = h

•g

''

h77 • f // •

- f is epic:∀g,h, g ◦ f = h ◦ f ⇒ g = h

• •h

gg

gww •foo

Proposition: f is monic in C iff f is epic in Cop.

Page 51: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Duality: monos and epis

- f is monic:∀g,h, f ◦ g = f ◦ h⇒ g = h

•g

''

h77 • f // •

- f is epic:∀g,h, g ◦ f = h ◦ f ⇒ g = h

• •h

gg

gww •foo

Proposition: f is monic in C iff f is epic in Cop.

Page 52: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Duality: products and coproducts

The product of A and B:

∀Cf

��

g

��

〈f ,g〉��

A A× Bπ1oo

π2// B

The coproduct of A and B:

∀C

A κ1//

f22

A + B

[f ,g]

OO

Bκ2oo

gll

Proposition: O is product in C iff O is coproduct in Cop.

Page 53: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Duality: products and coproducts

The product of A and B:

∀Cf

��

g

��

〈f ,g〉��

A A× Bπ1oo

π2// B

The coproduct of A and B:

∀C

A κ1//

f22

A + B

[f ,g]

OO

Bκ2oo

gll

Proposition: O is product in C iff O is coproduct in Cop.

Page 54: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Duality: products and coproducts

The product of A and B:

∀Cf

��

g

��

〈f ,g〉��

A A× Bπ1oo

π2// B

The coproduct of A and B:

∀C

A κ1//

f22

A + B

[f ,g]

OO

Bκ2oo

gll

Proposition: O is product in C iff O is coproduct in Cop.

Page 55: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Duality: products and coproducts

The product of A and B:

∀Cf

��

g

��

〈f ,g〉��

A A× Bπ1oo

π2// B

The coproduct of A and B:

∀C

A κ1//

f22

A + B

[f ,g]

OO

Bκ2oo

gll

Proposition: O is product in C iff O is coproduct in Cop.

Page 56: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Duality: initial and final objects

An object A in a category C is . . .

- initial if for any object B there exists a unique arrow

A ! // B

- final if for any object B there exists a unique arrow

B ! // A

Proposition: A is initial in C iff A is final in Cop.

Proposition: Initial and final objects are unique up-toisomorphism.

Page 57: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Duality: initial and final objects

An object A in a category C is . . .

- initial if for any object B there exists a unique arrow

A ! // B

- final if for any object B there exists a unique arrow

B ! // A

Proposition: A is initial in C iff A is final in Cop.

Proposition: Initial and final objects are unique up-toisomorphism.

Page 58: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Duality: initial and final objects

An object A in a category C is . . .

- initial if for any object B there exists a unique arrow

A ! // B

- final if for any object B there exists a unique arrow

B ! // A

Proposition: A is initial in C iff A is final in Cop.

Proposition: Initial and final objects are unique up-toisomorphism.

Page 59: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Duality: initial and final objects

An object A in a category C is . . .

- initial if for any object B there exists a unique arrow

A ! // B

- final if for any object B there exists a unique arrow

B ! // A

Proposition: A is initial in C iff A is final in Cop.

Proposition: Initial and final objects are unique up-toisomorphism.

Page 60: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Duality: initial and final objects

An object A in a category C is . . .

- initial if for any object B there exists a unique arrow

A ! // B

- final if for any object B there exists a unique arrow

B ! // A

Proposition: A is initial in C iff A is final in Cop.

Proposition: Initial and final objects are unique up-toisomorphism.

Page 61: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Duality: initial and final objects

An object A in a category C is . . .

- initial if for any object B there exists a unique arrow

A ! // B

- final if for any object B there exists a unique arrow

B ! // A

Proposition: A is initial in C iff A is final in Cop.

Proposition: Initial and final objects are unique up-toisomorphism.

Page 62: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Where coalgebra comes from

By duality. From algebra!

Classically, algebras are sets with operations.

Ex. (N, 0, succ), with 0 ∈ N and succ : N→ N.

Equivalently,1 + N

[zero, succ]��

N

where 1 = {∗} and zero(∗) = 0.

Page 63: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Where coalgebra comes from

By duality. From algebra!

Classically, algebras are sets with operations.

Ex. (N, 0, succ), with 0 ∈ N and succ : N→ N.

Equivalently,1 + N

[zero, succ]��

N

where 1 = {∗} and zero(∗) = 0.

Page 64: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Where coalgebra comes from

By duality. From algebra!

Classically, algebras are sets with operations.

Ex. (N, 0, succ), with 0 ∈ N and succ : N→ N.

Equivalently,1 + N

[zero, succ]��

N

where 1 = {∗} and zero(∗) = 0.

Page 65: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Algebra

Classically, algebras are sets with operations.

Ex.Prog × Prog

�

Prog

with α(P1,P2) = P1; P2.

Page 66: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Algebra, categorically

F (X )

�

X

where F is the type of the algebra.

Page 67: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Coalgebra, dually

X

�

F (X )

where F is the type of the coalgebra.

Page 68: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Example: streams

Streams are our favourite example of a coalgebra:

〈head, tail〉��

N× Nω

where

head(σ) = σ(0)

tail(σ) = (σ(1), σ(2), σ(3), . . .)

for any stream σ = (σ(0), σ(1), σ(2), . . .) ∈ Nω.

Page 69: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

3. How coalgebra works (its method in slogans)

• be precise about types

• ask what a system does rather than what it is

• functoriality

• interaction through homomorphisms

• aim for universality

Note that all these slogans are part of the categorical approach.

Page 70: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

3. How coalgebra works (its method in slogans)

• be precise about types

• ask what a system does rather than what it is

• functoriality

• interaction through homomorphisms

• aim for universality

Note that all these slogans are part of the categorical approach.

Page 71: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Starting point: the system’s type

A coalgebra of type F is a pair (X , α) with

α : X → F (X )

For instance, non-deterministic transition systems:

X

�

X

�

X

�

X

�

Pf (A×X ) Pf (X )A P(X )A 2× P(X )A

Formally, the type F of a coalgebra/system is a functor.

Page 72: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

The importance of knowing the system’s type

The type F of a coalgebra/system

α : X → F (X )

determines

- a canonical notion of system equivalence: bisimulation

- a canonical notion of minimization

- a canonical interpretation: final coalgebra semantics

- (a canonical logic)

Page 73: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Doing versus being

Doing > Being

Behaviour > Construction

Systems as black boxes (with internal states)

Behavioural specification

Page 74: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Doing versus being

Doing > Being

Behaviour > Construction

Systems as black boxes (with internal states)

Behavioural specification

Page 75: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Doing versus being

Doing > Being

Behaviour > Construction

Systems as black boxes (with internal states)

Behavioural specification

Page 76: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Doing versus being

Doing > Being

Behaviour > Construction

Systems as black boxes (with internal states)

Behavioural specification

Page 77: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Doing versus being

Doing > Being

Behaviour > Construction

Systems as black boxes (with internal states)

Behavioural specification

Page 78: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Example: the shuffle product of streams

Being:

(σ ⊗ τ) (n) =n∑

k=0

(nk

)· σ(k) · τ(n − k)

Doing:

σ ⊗ τσ(0) · τ(0)

// (σ′ ⊗ τ) + (σ ⊗ τ ′)

Page 79: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Example: the shuffle product of streams

Being:

(σ ⊗ τ) (n) =n∑

k=0

(nk

)· σ(k) · τ(n − k)

Doing:

σ ⊗ τσ(0) · τ(0)

// (σ′ ⊗ τ) + (σ ⊗ τ ′)

Page 80: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Example: the shuffle product of streams

Being:

(σ ⊗ τ) (n) =n∑

k=0

(nk

)· σ(k) · τ(n − k)

Doing:

σ ⊗ τσ(0) · τ(0)

// (σ′ ⊗ τ) + (σ ⊗ τ ′)

Page 81: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Example: the Hamming numbers

Being:

The increasing stream h of all natural numbers that are divisibleby only 2, 3, or 5:

h = (1,2,3,4,5,6,8,9,10,12,15,16,18,20,24, . . . )

h(n) = ?

Doing:

h 1 // (2 · h) ‖ (3 · h) ‖ (5 · h)

Page 82: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Example: the Hamming numbers

Being:

The increasing stream h of all natural numbers that are divisibleby only 2, 3, or 5:

h = (1,2,3,4,5,6,8,9,10,12,15,16,18,20,24, . . . )

h(n) = ?

Doing:

h 1 // (2 · h) ‖ (3 · h) ‖ (5 · h)

Page 83: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Example: the Hamming numbers

Being:

The increasing stream h of all natural numbers that are divisibleby only 2, 3, or 5:

h = (1,2,3,4,5,6,8,9,10,12,15,16,18,20,24, . . . )

h(n) = ?

Doing:

h 1 // (2 · h) ‖ (3 · h) ‖ (5 · h)

Page 84: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Example: the Hamming numbers

Being:

The increasing stream h of all natural numbers that are divisibleby only 2, 3, or 5:

h = (1,2,3,4,5,6,8,9,10,12,15,16,18,20,24, . . . )

h(n) = ?

Doing:

h 1 // (2 · h) ‖ (3 · h) ‖ (5 · h)

Page 85: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Homomorphisms

X

�

h // Y

�

F (X )F (h)

// F (Y )

. . . are for systems/coalgebras what functions are for sets.

. . . are behaviour preserving functions.

Page 86: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Functoriality

X

�

h // Y

�

F (X )F (h)

// F (Y )

Note that for the definition of homomorphism,

the type F needs to be a functor:

F acts on sets: F (X ), F (Y ) and on functions: F (h)

Page 87: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Example of a homomorphism

X

��

h // Y

��

O × Xid × h

// O × Y

x0 a// x1 b

// x2 a// x3

bww h // y0

a88y1

bxx

Minimization through (canonical) homomorphism.

Page 88: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Universality

Always aim at universal/canonical formulations.

For instance: final coalgebras

In final coalgebras: Being = Doing

⇒ coinduction (to be discussed shortly)

⇒ semantics

Page 89: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Universality

Always aim at universal/canonical formulations.

For instance: final coalgebras

In final coalgebras: Being = Doing

⇒ coinduction (to be discussed shortly)

⇒ semantics

Page 90: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Universality

Always aim at universal/canonical formulations.

For instance: final coalgebras

In final coalgebras: Being = Doing

⇒ coinduction (to be discussed shortly)

⇒ semantics

Page 91: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Universality

Always aim at universal/canonical formulations.

For instance: final coalgebras

In final coalgebras: Being = Doing

⇒ coinduction (to be discussed shortly)

⇒ semantics

Page 92: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Universality

Always aim at universal/canonical formulations.

For instance: final coalgebras

In final coalgebras: Being = Doing

⇒ coinduction (to be discussed shortly)

⇒ semantics

Page 93: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Universality

Always aim at universal/canonical formulations.

For instance: final coalgebras

In final coalgebras: Being = Doing

⇒ coinduction (to be discussed shortly)

⇒ semantics

Page 94: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Semantics by finality: streamsThe final homomorphism into the set of streams:

X

��

∃! h // Oω

��

O × Xid × h

// O ×Oω

maps any system X to its minimization: e.g.,

x0 a// x1 b

// x2 a// x3

bww h // (ab)ω

a44(ba)ω

btt

x0, x2� h // (ab)ω x1, x3

� h // (ba)ω

Page 95: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

4. Duality: induction and coinduction

- initial algebra - final coalgebra

- congruence - bisimulation

- induction - coinduction

- least fixed point - greatest fixed point

Page 96: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Initial algebra

The natural numbers are an example of an initial algebra:

1 + N

[zero, succ]��

// 1 + S

β∀��

N∃ !

// S

Note: any two homomorphisms from N to S are equal.

Note: id : N→ N is a homomorphism.

Note: [zero, succ] : 1 + N ∼= N.

Page 97: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Initial algebra

The natural numbers are an example of an initial algebra:

1 + N

[zero, succ]��

// 1 + S

β∀��

N∃ !

// S

Note: any two homomorphisms from N to S are equal.

Note: id : N→ N is a homomorphism.

Note: [zero, succ] : 1 + N ∼= N.

Page 98: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Initial algebra

The natural numbers are an example of an initial algebra:

1 + N

[zero, succ]��

// 1 + S

β∀��

N∃ !

// S

Note: any two homomorphisms from N to S are equal.

Note: id : N→ N is a homomorphism.

Note: [zero, succ] : 1 + N ∼= N.

Page 99: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Initial algebra

The natural numbers are an example of an initial algebra:

1 + N

[zero, succ]��

// 1 + S

β∀��

N∃ !

// S

Note: any two homomorphisms from N to S are equal.

Note: id : N→ N is a homomorphism.

Note: [zero, succ] : 1 + N ∼= N.

Page 100: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Final coalgebra

Streams are an example of a final coalgebra:

S

β∀��

∃ ! // Nω

〈head, tail〉��

N× S // N× Nω

(Note: instead of N, we could have taken any set.)

Note: any two homomorphisms from S to Nω are equal.

Note: id : Nω → Nω is a homomorphism.

Note: 〈head, tail〉 : Nω ∼= N× Nω.

Page 101: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Final coalgebra

Streams are an example of a final coalgebra:

S

β∀��

∃ ! // Nω

〈head, tail〉��

N× S // N× Nω

(Note: instead of N, we could have taken any set.)

Note: any two homomorphisms from S to Nω are equal.

Note: id : Nω → Nω is a homomorphism.

Note: 〈head, tail〉 : Nω ∼= N× Nω.

Page 102: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Final coalgebra

Streams are an example of a final coalgebra:

S

β∀��

∃ ! // Nω

〈head, tail〉��

N× S // N× Nω

(Note: instead of N, we could have taken any set.)

Note: any two homomorphisms from S to Nω are equal.

Note: id : Nω → Nω is a homomorphism.

Note: 〈head, tail〉 : Nω ∼= N× Nω.

Page 103: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Final coalgebra

Streams are an example of a final coalgebra:

S

β∀��

∃ ! // Nω

〈head, tail〉��

N× S // N× Nω

(Note: instead of N, we could have taken any set.)

Note: any two homomorphisms from S to Nω are equal.

Note: id : Nω → Nω is a homomorphism.

Note: 〈head, tail〉 : Nω ∼= N× Nω.

Page 104: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Algebra and induction

Induction = definition and proof principle for algebras.

Ex. mathematical induction: for all P ⊆ N,

( P(0) and (∀n : P(n)⇒ P(succ(n))) ) ⇒ ∀n : P(n)

(Other examples: transfinite, well-founded, tree, structural, etc.)

We show that induction is a property of initial algebras.

Page 105: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Algebra and induction

Induction = definition and proof principle for algebras.

Ex. mathematical induction: for all P ⊆ N,

( P(0) and (∀n : P(n)⇒ P(succ(n))) ) ⇒ ∀n : P(n)

(Other examples: transfinite, well-founded, tree, structural, etc.)

We show that induction is a property of initial algebras.

Page 106: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Algebra and induction

Induction = definition and proof principle for algebras.

Ex. mathematical induction: for all P ⊆ N,

( P(0) and (∀n : P(n)⇒ P(succ(n))) ) ⇒ ∀n : P(n)

(Other examples: transfinite, well-founded, tree, structural, etc.)

We show that induction is a property of initial algebras.

Page 107: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Algebra and induction

Induction = definition and proof principle for algebras.

Ex. mathematical induction: for all P ⊆ N,

( P(0) and (∀n : P(n)⇒ P(succ(n))) ) ⇒ ∀n : P(n)

(Other examples: transfinite, well-founded, tree, structural, etc.)

We show that induction is a property of initial algebras.

Page 108: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Algebras and congruences (ex. natural numbers)

We call R ⊆ N× N a congruence if

(i) (0,0) ∈ R and(ii) (n,m) ∈ R ⇒ (succ(n), succ(m)) ∈ R

(Note: R is not required to be an equivalence relation.)

Equivalently, R ⊆ N× N is a congruence if

1 + N

[zero, succ]��

1 + R

γ∃��

oo // 1 + N

[zero, succ]��

N Rπ1oo

π2// N

for some function γ : 1 + R → R.

Page 109: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Algebras and congruences (ex. natural numbers)

We call R ⊆ N× N a congruence if

(i) (0,0) ∈ R and(ii) (n,m) ∈ R ⇒ (succ(n), succ(m)) ∈ R

(Note: R is not required to be an equivalence relation.)

Equivalently, R ⊆ N× N is a congruence if

1 + N

[zero, succ]��

1 + R

γ∃��

oo // 1 + N

[zero, succ]��

N Rπ1oo

π2// N

for some function γ : 1 + R → R.

Page 110: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Initial algebras and congruences

Theorem: induction proof principleEvery congruence R ⊆ N× N contains the diagonal:

∆ ⊆ R

where ∆ = {(n,n) | n ∈ N}.

Proof: Because (N, [zero, succ]) is an initial algebra,

1 + N

[zero, succ]��

++

1 + R

γ∃��

oo // 1 + N

[zero, succ]��

ss

N!

)) Rπ1oo

π2// N

!uu

we have π1◦! = id = π2◦!, which implies !(n) = (n,n), all n ∈ N.

Page 111: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Initial algebras and congruences

Theorem: induction proof principleEvery congruence R ⊆ N× N contains the diagonal:

∆ ⊆ R

where ∆ = {(n,n) | n ∈ N}.

Proof: Because (N, [zero, succ]) is an initial algebra,

1 + N

[zero, succ]��

++

1 + R

γ∃��

oo // 1 + N

[zero, succ]��

ss

N!

)) Rπ1oo

π2// N

!uu

we have π1◦! = id = π2◦!, which implies !(n) = (n,n), all n ∈ N.

Page 112: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Initial algebras and induction

Theorem: The following are equivalent:

1. For every congruence relation R ⊆ N× N,

∆ ⊆ R

2. For every predicate P ⊆ N,

( P(0) and (∀n : P(n)⇒ P(succ(n))) ) ⇒ ∀n : P(n)

Proof: Exercise.

In other words: two equivalent formulations of induction!

Page 113: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Initial algebras and induction

Theorem: The following are equivalent:

1. For every congruence relation R ⊆ N× N,

∆ ⊆ R

2. For every predicate P ⊆ N,

( P(0) and (∀n : P(n)⇒ P(succ(n))) ) ⇒ ∀n : P(n)

Proof: Exercise.

In other words: two equivalent formulations of induction!

Page 114: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Initial algebras and induction

Theorem: The following are equivalent:

1. For every congruence relation R ⊆ N× N,

∆ ⊆ R

2. For every predicate P ⊆ N,

( P(0) and (∀n : P(n)⇒ P(succ(n))) ) ⇒ ∀n : P(n)

Proof: Exercise.

In other words: two equivalent formulations of induction!

Page 115: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Coalgebra and coinduction

Coinduction = definition and proof principle for coalgebras.

Coinduction is dual to induction, in a very precise way.

Categorically, coinduction is a property of final coalgebras.

Algorithmically, coinduction generalises Robin Milner’s

bisimulation proof method.

Page 116: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Coalgebra and coinduction

Coinduction = definition and proof principle for coalgebras.

Coinduction is dual to induction, in a very precise way.

Categorically, coinduction is a property of final coalgebras.

Algorithmically, coinduction generalises Robin Milner’s

bisimulation proof method.

Page 117: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Coalgebra and coinduction

Coinduction = definition and proof principle for coalgebras.

Coinduction is dual to induction, in a very precise way.

Categorically, coinduction is a property of final coalgebras.

Algorithmically, coinduction generalises Robin Milner’s

bisimulation proof method.

Page 118: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Coalgebra and coinduction

Coinduction = definition and proof principle for coalgebras.

Coinduction is dual to induction, in a very precise way.

Categorically, coinduction is a property of final coalgebras.

Algorithmically, coinduction generalises Robin Milner’s

bisimulation proof method.

Page 119: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Coalgebras and bisimulations (ex. streams)

We call R ⊆ Nω × Nω a bisimulation if, for all (σ, τ) ∈ R,

(i) head(σ) = head(τ) and(ii) (tail(σ), tail(τ)) ∈ R

Equivalently, R ⊆ Nω × Nω is a bisimulation if

〈head, tail〉��

Rγ∃��

π1ooπ2 // Nω

〈head, tail〉��

N× Nω N× Roo // N× Nω

for some function γ : R → N× R.

Page 120: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Coalgebras and bisimulations (ex. streams)

We call R ⊆ Nω × Nω a bisimulation if, for all (σ, τ) ∈ R,

(i) head(σ) = head(τ) and(ii) (tail(σ), tail(τ)) ∈ R

Equivalently, R ⊆ Nω × Nω is a bisimulation if

〈head, tail〉��

Rγ∃��

π1ooπ2 // Nω

〈head, tail〉��

N× Nω N× Roo // N× Nω

for some function γ : R → N× R.

Page 121: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Final coalgebras and bisimulations

Theorem: coinduction proof principleEvery bisimulation R ⊆ Nω × Nω is contained in the diagonal:

R ⊆ ∆

where ∆ = {(σ, σ) | σ ∈ Nω}.

Proof: Because (Nω, 〈head, tail〉) is a final coalgebra,

〈head, tail〉��

Rγ∃��

π1ooπ2 // Nω

〈head, tail〉��

N× Nω N× Roo // N× Nω

we have π1 = π2, which implies σ = τ , for all (σ, τ) ∈ Nω.

Page 122: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Final coalgebras and bisimulations

Theorem: coinduction proof principleEvery bisimulation R ⊆ Nω × Nω is contained in the diagonal:

R ⊆ ∆

where ∆ = {(σ, σ) | σ ∈ Nω}.

Proof: Because (Nω, 〈head, tail〉) is a final coalgebra,

〈head, tail〉��

Rγ∃��

π1ooπ2 // Nω

〈head, tail〉��

N× Nω N× Roo // N× Nω

we have π1 = π2, which implies σ = τ , for all (σ, τ) ∈ Nω.

Page 123: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Final coalgebras and coinduction

The following are equivalent:

1. For every bisimulation relation R ⊆ Nω × Nω,

R ⊆ ∆

2. ??

In other words: no obvious equivalent formulation ofcoinduction!

Page 124: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Final coalgebras and coinduction

The following are equivalent:

1. For every bisimulation relation R ⊆ Nω × Nω,

R ⊆ ∆

2. ??

In other words: no obvious equivalent formulation ofcoinduction!

Page 125: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Final coalgebras and coinduction

The following are equivalent:

1. For every bisimulation relation R ⊆ Nω × Nω,

R ⊆ ∆

2. ??

In other words: no obvious equivalent formulation ofcoinduction!

Page 126: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Congruences and bisimulations: dual?

R ⊆ N× N is a congruence if

1 + N

[zero, succ]��

1 + R

γ∃��

oo // 1 + N

[zero, succ]��

N Rπ1oo

π2// N

R ⊆ Nω × Nω is a bisimulation if

〈head, tail〉��

Rγ∃��

π1ooπ2 // Nω

〈head, tail〉��

N× Nω N× Roo // N× Nω

Page 127: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Congruences and bisimulations: dual?

R ⊆ S × T is an F -congruence if

F (S)

�

F (R)

γ∃��

oo // F (T )

�

S Rπ1oo

π2// T

R ⊆ S × T is an F -bisimulation if

S

�

R

γ∃��

π1ooπ2 // T

�

F (S) F (R)oo // F (T )

Page 128: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Induction and coinduction: dual?

For every congruence relation R ⊆ N× N,

∆ ⊆ R

For every bisimulation relation R ⊆ Nω × Nω,

R ⊆ ∆

Page 129: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Induction and coinduction: dual?

For every congruence relation R on an initial algebra:

∆ ⊆ R

For every bisimulation relation R on a final coalgebra:

R ⊆ ∆

Page 130: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

An aside: fixed points

Let (P,≤) be a preorder and f : P → P a monotone map.

Classically, least fixed point induction is:

∀p ∈ P : f (p) ≤ p ⇒ µf ≤ p

Classically, greatest fixed point coinduction is:

∀p ∈ P : p ≤ f (p) ⇒ p ≤ νf

Page 131: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

An aside: fixed points

Let (P,≤) be a preorder and f : P → P a monotone map.

Classically, least fixed point induction is:

∀p ∈ P : f (p) ≤ p ⇒ µf ≤ p

Classically, greatest fixed point coinduction is:

∀p ∈ P : p ≤ f (p) ⇒ p ≤ νf

Page 132: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

An aside: fixed points

Let (P,≤) be a preorder and f : P → P a monotone map.

Classically, least fixed point induction is:

∀p ∈ P : f (p) ≤ p ⇒ µf ≤ p

Classically, greatest fixed point coinduction is:

∀p ∈ P : p ≤ f (p) ⇒ p ≤ νf

Page 133: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

An aside: fixed points

Any preorder (P,≤) is a category, with arrows:

p → q ≡ p ≤ q

Any monotone map is a functor:

p → q 7→ f (p)→ f (q)

Lfp induction and gfp coinduction become:

f (µf )

��

// f (p)

��

µf // p

p

��

// νf

��

f (p) // f (νf )

Page 134: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

An aside: fixed points

Any preorder (P,≤) is a category, with arrows:

p → q ≡ p ≤ q

Any monotone map is a functor:

p → q 7→ f (p)→ f (q)

Lfp induction and gfp coinduction become:

f (µf )

��

// f (p)

��

µf // p

p

��

// νf

��

f (p) // f (νf )

Page 135: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

An aside: fixed points

Any preorder (P,≤) is a category, with arrows:

p → q ≡ p ≤ q

Any monotone map is a functor:

p → q 7→ f (p)→ f (q)

Lfp induction and gfp coinduction become:

f (µf )

��

// f (p)

��

µf // p

p

��

// νf

��

f (p) // f (νf )

Page 136: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Fixed point (co)induction = initiality and finality

f (µf )

��

// f (p)

��

µf // p

p

��

// νf

��

f (p) // f (νf )

F (A)

��

// F (S)

��

A∃ !

// S

S

��

∃ ! // Z

��

F (S) // F (Z )

Page 137: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Fixed point (co)induction = initiality and finality

f (µf )

��

// f (p)

��

µf // p

p

��

// νf

��

f (p) // f (νf )

F (A)

��

// F (S)

��

A∃ !

// S

S

��

∃ ! // Z

��

F (S) // F (Z )

Page 138: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

5. What coalgebra studies

• the behaviour of – often infinite, circular – systems

(their equivalence, minimization, synthesis)

• rather: the universal principles underlying this behaviour

• these days applied in many different scientific disciplines

Page 139: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

5. What coalgebra studies

• the behaviour of – often infinite, circular – systems

(their equivalence, minimization, synthesis)

• rather: the universal principles underlying this behaviour

• these days applied in many different scientific disciplines

Page 140: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

5. What coalgebra studies

• the behaviour of – often infinite, circular – systems

(their equivalence, minimization, synthesis)

• rather: the universal principles underlying this behaviour

• these days applied in many different scientific disciplines

Page 141: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

5. What coalgebra studies

• the behaviour of – often infinite, circular – systems

(their equivalence, minimization, synthesis)

• rather: the universal principles underlying this behaviour

• these days applied in many different scientific disciplines

Page 142: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Example: dynamical systems

A dynamical system is:

set of states X and a transition function t : X → X

Notation for transitions:

x → y ≡ t(x) = y

Examples:

x // y // z

��

poo r // s

q

@@

Page 143: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Example: systems with output

A system with output:

〈o, t〉 : X → O × X

Notation: x a // y ≡ o(x) = a and t(x) = y .

x0 a// x1 b

// x2 a// x3

bww

y0

a88y1

bxx

Page 144: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Example: infinite data types

For instance, streams of natural numbers:

Nω = {σ | σ : N→ N }

The behaviour of streams:

(σ(0), σ(1), σ(2), . . .)σ(0)

// (σ(1), σ(2), σ(3), . . .)

where we call

σ(0): the initial value (= head)

σ′ = (σ(1), σ(2), σ(3), . . .): the derivative (= tail)

Page 145: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Example: streams

(1,1,1, . . .) 1 // (1,1,1, . . .) 1 // (1,1,1, . . .) 1 // · · ·

(1,1,1, . . .)

1��

Page 146: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Example: streams

(1,1,1, . . .) 1 // (1,1,1, . . .) 1 // (1,1,1, . . .) 1 // · · ·

(1,1,1, . . .)

1��

Page 147: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Example: streams

(1,2,3, . . .) 1 // (2,3,4, . . .) 2 // (3,4,5, . . .) 3 // · · ·

(1,2,3, . . .) 1 // (2,3,4, . . .) = (1,2,3, . . .) + (1,1,1, . . .)

(1,2,3, . . .) 1 //

1��

(1,1,1, . . .)

1��

Page 148: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Example: streams

(1,2,3, . . .) 1 // (2,3,4, . . .) 2 // (3,4,5, . . .) 3 // · · ·

(1,2,3, . . .) 1 // (2,3,4, . . .) = (1,2,3, . . .) + (1,1,1, . . .)

(1,2,3, . . .) 1 //

1��

(1,1,1, . . .)

1��

Page 149: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Example: streams

(1,2,3, . . .) 1 // (2,3,4, . . .) 2 // (3,4,5, . . .) 3 // · · ·

(1,2,3, . . .) 1 // (2,3,4, . . .) = (1,2,3, . . .) + (1,1,1, . . .)

(1,2,3, . . .) 1 //

1��

(1,1,1, . . .)

1��

Page 150: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Example: non-well-founded sets

Historically important: Peter Aczel’s book.

x = {x} y = {y}

x,, y rr

x = {y} y = {z} z = {x , y}

x // y // zyy

``

Page 151: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Example: non-well-founded sets

Historically important: Peter Aczel’s book.

x = {x} y = {y}

x,, y rr

x = {y} y = {z} z = {x , y}

x // y // zyy

``

Page 152: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Example: non-well-founded sets

Historically important: Peter Aczel’s book.

x = {x} y = {y}

x,, y rr

x = {y} y = {z} z = {x , y}

x // y // zyy

``

Page 153: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Example: automata

A deterministic automaton

// x

b��

a// z

bzz

a}}

y

b

OO

a

JJ

• initial state: x • final states: y and z

• L(x) = {a,b}∗ a

Page 154: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Example: automata

A deterministic automaton

// x

b��

a// z

bzz

a}}

y

b

OO

a

JJ

• initial state: x • final states: y and z

• L(x) = {a,b}∗ a

Page 155: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Example: automata

A deterministic automaton

// x

b��

a// z

bzz

a}}

y

b

OO

a

JJ

• initial state: x • final states: y and z

• L(x) = {a,b}∗ a

Page 156: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

All these examples: circular behaviour

// x

b��

a// z

bzz

a}}

y

b

OO

a

JJ

y0

a88y1

bxx

(1,2,3, . . .) 1 //

1��

(1,1,1, . . .)

1��

Page 157: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

Where coalgebra is used

• logic, set theory• automata• control theory• data types• dynamical systems• games• economy• ecology

Page 158: Lecture one: The Method of Coalgebra in some detailcs.ipm.ac.ir/asoc2016/Resources/Jan-lecture one.pdf · focus on set theory. For computer scientists: gives a precise handle on abstraction,

6. Discussion

• New way of thinking – give it time

• Extensive example: streams (Lecture two)

• Algebra and coalgebra (Lecture three and four)

- bisimulation up-to- cf. CALCO

• Algorithms, tools (Lecture four)

- Cf. Hacking nondeterminism with induction and coinductionBonchi and Pous, Comm. ACM Vol. 58(2), 2015