1 the method of coalgebra
play

1. The Method of Coalgebra Jan Rutten CWI Amsterdam & Radboud - PowerPoint PPT Presentation

1. The Method of Coalgebra Jan Rutten CWI Amsterdam & Radboud University Nijmegen IMS, Singapore - 15 September 2016 Overview of Lecture one 1. Category theory (where coalgebra comes from) 2. Algebras and coalgebras 3. Induction and


  1. Duality, formally The opposite category C op of a category C has: - the same objects as C - precisely one arrow f : B → A for every arrow f : A → B in C . The principle of duality now says that we can dualize any statement about a category C by making the same statement about C op . For instance, the notions of monic and epic are dual, since: f is epic in C op . Proposition: f is monic in C iff

  2. Duality, formally The opposite category C op of a category C has: - the same objects as C - precisely one arrow f : B → A for every arrow f : A → B in C . The principle of duality now says that we can dualize any statement about a category C by making the same statement about C op . For instance, the notions of monic and epic are dual, since: f is epic in C op . Proposition: f is monic in C iff

  3. Duality, formally The opposite category C op of a category C has: - the same objects as C - precisely one arrow f : B → A for every arrow f : A → B in C . The principle of duality now says that we can dualize any statement about a category C by making the same statement about C op . For instance, the notions of monic and epic are dual, since: f is epic in C op . Proposition: f is monic in C iff

  4. � � � � � � � � � Duality: products and coproducts The product of A and B : ∀ C g f � f , g � � B A A × B π 1 π 2 The coproduct of A and B : ∀ C g f [ f , g ] A A + B B κ 1 κ 2 O is coproduct in C op . Proposition: O is product in C iff

  5. � � � � � � � � � Duality: products and coproducts The product of A and B : ∀ C g f � f , g � � B A A × B π 1 π 2 The coproduct of A and B : ∀ C g f [ f , g ] A A + B B κ 1 κ 2 O is coproduct in C op . Proposition: O is product in C iff

  6. � � � � � � � � � Duality: products and coproducts The product of A and B : ∀ C g f � f , g � � B A A × B π 1 π 2 The coproduct of A and B : ∀ C g f [ f , g ] A A + B B κ 1 κ 2 O is coproduct in C op . Proposition: O is product in C iff

  7. � � � � � � � � � Duality: products and coproducts The product of A and B : ∀ C g f � f , g � � B A A × B π 1 π 2 The coproduct of A and B : ∀ C g f [ f , g ] A A + B B κ 1 κ 2 O is coproduct in C op . Proposition: O is product in C iff

  8. Duality: initial and final objects An object A in a category C is . . . - initial if for any object B there exists a unique arrow ! � B A - final if for any object B there exists a unique arrow ! � A B A is final in C op . Proposition: A is initial in C iff

  9. Duality: initial and final objects An object A in a category C is . . . - initial if for any object B there exists a unique arrow ! � B A - final if for any object B there exists a unique arrow ! � A B A is final in C op . Proposition: A is initial in C iff

  10. 2. Algebras and Coalgebras

  11. � 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.

  12. � 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.

  13. � 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.

  14. � Algebra Classically, algebras are sets with operations. Ex. Prog × Prog α Prog with α ( P 1 , P 2 ) = P 1 ; P 2 .

  15. � Algebra, categorically For a functor F : C → C , an F -algebra is a pair ( A , α ) with F ( X ) α X We call F the type and α the structure map of ( A , α ) . The structure map α tells us how the elements of A are constructed from other elements in A . E.g., a ∗ ; b is constructed from the expressions a ∗ and b by applying the operation of concatenation.

  16. � Algebra, categorically For a functor F : C → C , an F -algebra is a pair ( A , α ) with F ( X ) α X We call F the type and α the structure map of ( A , α ) . The structure map α tells us how the elements of A are constructed from other elements in A . E.g., a ∗ ; b is constructed from the expressions a ∗ and b by applying the operation of concatenation.

  17. � Algebra, categorically For a functor F : C → C , an F -algebra is a pair ( A , α ) with F ( X ) α X We call F the type and α the structure map of ( A , α ) . The structure map α tells us how the elements of A are constructed from other elements in A . E.g., a ∗ ; b is constructed from the expressions a ∗ and b by applying the operation of concatenation.

  18. � � Algebra homomorphisms A homomorphism of F-algebras is an arrow f : A → B such that F ( f ) � F ( B ) F ( A ) α β � B A f Note: functoriality ! Homomorphisms are for algebras what functions are for sets: they allow us to express how algebras interact with other algebras.

  19. � � Algebra homomorphisms A homomorphism of F-algebras is an arrow f : A → B such that F ( f ) � F ( B ) F ( A ) α β � B A f Note: functoriality ! Homomorphisms are for algebras what functions are for sets: they allow us to express how algebras interact with other algebras.

  20. � � Algebra homomorphisms A homomorphism of F-algebras is an arrow f : A → B such that F ( f ) � F ( B ) F ( A ) α β � B A f Note: functoriality ! Homomorphisms are for algebras what functions are for sets: they allow us to express how algebras interact with other algebras.

  21. � Coalgebra, dually For a functor F : C → C , an F -coalgebra is a pair ( A , α ) with X α F ( X ) We call F the type and α the structure map of ( A , α ) .

  22. � Our favourite example: streams N ω � head , tail � N × N ω where head ( σ ) = σ ( 0 ) tail ( σ ) = ( σ ( 1 ) , σ ( 2 ) , σ ( 3 ) , . . . ) for any stream σ = ( σ ( 0 ) , σ ( 1 ) , σ ( 2 ) , . . . ) ∈ N ω . Here the structure map tells us how streams are decomposed into a natural number and a stream.

  23. � Our favourite example: streams N ω � head , tail � N × N ω where head ( σ ) = σ ( 0 ) tail ( σ ) = ( σ ( 1 ) , σ ( 2 ) , σ ( 3 ) , . . . ) for any stream σ = ( σ ( 0 ) , σ ( 1 ) , σ ( 2 ) , . . . ) ∈ N ω . Here the structure map tells us how streams are decomposed into a natural number and a stream.

  24. � � Coalgebra homomorphisms A homomorphism of F-coalgebras is an arrow f : A → B with f � B A α β � F ( B ) F ( A ) F ( f ) Note: functoriality ! Homomorphisms are for coalgebras what functions are for sets: they allow us to express the interaction between coalgebras.

  25. � � Coalgebra homomorphisms A homomorphism of F-coalgebras is an arrow f : A → B with f � B A α β � F ( B ) F ( A ) F ( f ) Note: functoriality ! Homomorphisms are for coalgebras what functions are for sets: they allow us to express the interaction between coalgebras.

  26. � � Coalgebra homomorphisms A homomorphism of F-coalgebras is an arrow f : A → B with f � B A α β � F ( B ) F ( A ) F ( f ) Note: functoriality ! Homomorphisms are for coalgebras what functions are for sets: they allow us to express the interaction between coalgebras.

  27. � � � ✤ � � Example of a homomorphism h � Y X � A × Y A × X id × h b b h � x 1 � x 2 � x 3 x 0 y 0 � y 1 a a b a The homomorphism h identifies behaviourally equivalent states.

  28. 3. Induction and coinduction - initial algebra - final coalgebra - congruence - bisimulation - induction - coinduction - least fixed point - greatest fixed point

  29. � � Initial algebra The natural numbers are an example of an initial algebra : � 1 + S 1 + N [ zero , succ ] ∀ β � S N ∃ ! h Inductive definitions are based on the (unique) existence of h . Inductive proofs are based on the uniqueness of h .

  30. � � Initial algebra The natural numbers are an example of an initial algebra : � 1 + S 1 + N [ zero , succ ] ∀ β � S N ∃ ! h Inductive definitions are based on the (unique) existence of h . Inductive proofs are based on the uniqueness of h .

  31. � � Initial algebra The natural numbers are an example of an initial algebra : � 1 + S 1 + N [ zero , succ ] ∀ β � S N ∃ ! h Inductive definitions are based on the (unique) existence of h . Inductive proofs are based on the uniqueness of h .

  32. � � Final coalgebra Streams are an example of a final coalgebra : ∃ ! h � N ω S β � head , tail � ∀ � N × N ω N × S (Note: instead of N , we could have taken any set.) Coinductive definitions are based on the existence of h . Coinductive proofs are based on the uniqueness of h .

  33. � � Final coalgebra Streams are an example of a final coalgebra : ∃ ! h � N ω S β � head , tail � ∀ � N × N ω N × S (Note: instead of N , we could have taken any set.) Coinductive definitions are based on the existence of h . Coinductive proofs are based on the uniqueness of h .

  34. � � Final coalgebra Streams are an example of a final coalgebra : ∃ ! h � N ω S β � head , tail � ∀ � N × N ω N × S (Note: instead of N , we could have taken any set.) Coinductive definitions are based on the existence of h . Coinductive proofs are based on the uniqueness of h .

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

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

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

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

  39. � � � � 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 1 + N 1 + R γ [ zero , succ ] [ zero , succ ] ∃ � � N N R π 1 π 2 for some function γ : 1 + R → R .

  40. � � � � 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 1 + N 1 + R γ [ zero , succ ] [ zero , succ ] ∃ � � N N R π 1 π 2 for some function γ : 1 + R → R .

  41. � � � � � � � Initial algebras and congruences Theorem: induction proof principle Every congruence R ⊆ N × N contains the diagonal : ∆ ⊆ R where ∆ = { ( n , n ) | n ∈ N } . Proof: Because ( N , [ zero , succ ]) is an initial algebra, � 1 + N 1 + N 1 + R γ [ zero , succ ] [ zero , succ ] ∃ � ! ! � R � N N π 1 π 2 we have π 1 ◦ ! = id = π 2 ◦ ! , which implies !( n ) = ( n , n ) , all n ∈ N .

  42. � � � � � � � Initial algebras and congruences Theorem: induction proof principle Every congruence R ⊆ N × N contains the diagonal : ∆ ⊆ R where ∆ = { ( n , n ) | n ∈ N } . Proof: Because ( N , [ zero , succ ]) is an initial algebra, � 1 + N 1 + N 1 + R γ [ zero , succ ] [ zero , succ ] ∃ � ! ! � R � N N π 1 π 2 we have π 1 ◦ ! = id = π 2 ◦ ! , which implies !( n ) = ( n , n ) , all n ∈ N .

  43. 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 !

  44. 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 !

  45. 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 !

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

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

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

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

  50. � � � � � 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 π 1 π 2 � N ω N ω R γ � head , tail � � head , tail � ∃ � N × N ω N × N ω N × R for some function γ : R → N × R .

  51. � � � � � 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 π 1 π 2 � N ω N ω R γ � head , tail � � head , tail � ∃ � N × N ω N × N ω N × R for some function γ : R → N × R .

  52. � � � � � Final coalgebras and bisimulations Theorem: coinduction proof principle Every bisimulation R ⊆ N ω × N ω is contained in the diagonal: R ⊆ ∆ where ∆ = { ( σ, σ ) | σ ∈ N ω } . Proof: Because ( N ω , � head , tail � ) is a final coalgebra, π 1 π 2 � N ω R N ω γ � head , tail � � head , tail � ∃ � N × N ω N × N ω N × R we have π 1 = π 2 , which implies σ = τ , for all ( σ, τ ) ∈ N ω .

  53. � � � � � Final coalgebras and bisimulations Theorem: coinduction proof principle Every bisimulation R ⊆ N ω × N ω is contained in the diagonal: R ⊆ ∆ where ∆ = { ( σ, σ ) | σ ∈ N ω } . Proof: Because ( N ω , � head , tail � ) is a final coalgebra, π 1 π 2 � N ω R N ω γ � head , tail � � head , tail � ∃ � N × N ω N × N ω N × R we have π 1 = π 2 , which implies σ = τ , for all ( σ, τ ) ∈ N ω .

  54. � � � � � � � � � Congruences and bisimulations: dual? R ⊆ N × N is a congruence if � 1 + N 1 + N 1 + R γ [ zero , succ ] [ zero , succ ] ∃ � � N N R π 1 π 2 R ⊆ N ω × N ω is a bisimulation if π 1 π 2 � N ω N ω R γ � head , tail � � head , tail � ∃ � N × N ω N × N ω N × R

  55. � � � � � � � � � Congruences and bisimulations R ⊆ S × T is an F -congruence if � F ( T ) F ( S ) F ( R ) γ α ∃ � β � T S R π 1 π 2 R ⊆ S × T is an F -bisimulation if π 1 π 2 � T S R γ α ∃ β � F ( T ) F ( S ) F ( R )

  56. Induction and coinduction For every congruence relation R ⊆ N × N , ∆ ⊆ R For every bisimulation relation R ⊆ N ω × N ω , R ⊆ ∆

  57. Induction and coinduction For every congruence relation R on an initial algebra : ∆ ⊆ R For every bisimulation relation R on a final coalgebra : R ⊆ ∆

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

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

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

  61. � � � � An aside: fixed points Any preorder ( P , ≤ ) is a category, with arrows: p → q ≡ p ≤ q Any monotone map is a functor: p → q �→ f ( p ) → f ( q ) Lfp induction and gfp coinduction become: � f ( p ) � ν f f ( µ f ) p � p � f ( ν f ) µ f f ( p )

  62. � � � � An aside: fixed points Any preorder ( P , ≤ ) is a category, with arrows: p → q ≡ p ≤ q Any monotone map is a functor: p → q �→ f ( p ) → f ( q ) Lfp induction and gfp coinduction become: � f ( p ) � ν f f ( µ f ) p � p � f ( ν f ) µ f f ( p )

  63. � � � � An aside: fixed points Any preorder ( P , ≤ ) is a category, with arrows: p → q ≡ p ≤ q Any monotone map is a functor: p → q �→ f ( p ) → f ( q ) Lfp induction and gfp coinduction become: � f ( p ) � ν f f ( µ f ) p � p � f ( ν f ) µ f f ( p )

  64. � � � � � � � � Fixed point (co)induction = initiality and finality � f ( p ) � ν f f ( µ f ) p � p � f ( ν f ) µ f f ( p ) ∃ ! � F ( S ) � Z F ( A ) S � S � F ( Z ) A F ( S ) ∃ !

  65. � � � � � � � � Fixed point (co)induction = initiality and finality � f ( p ) � ν f f ( µ f ) p � p � f ( ν f ) µ f f ( p ) ∃ ! � F ( S ) � Z F ( A ) S � S � F ( Z ) A F ( S ) ∃ !

  66. 4. The method of coalgebra

  67. Summarizing the coalgebraic method • The study of any class of coalgebras begins with the definition of its type , that is, a functor F : C → C . Often, C = Set. • The approach, which is essentially categorical, will be to describe what coalgebras do , rather than to specify what they are . • The basis of the local behaviour of each coalgebra ( S , α ) is its structure map α : S → F ( S ) , which defines its local dynamics and outputs.

  68. Summarizing the coalgebraic method • The global behaviour of a coalgebra ( S , α ) is then given by its interaction with other coalgebras, that is, by homomorphisms between ( S , α ) and other coalgebras. • The unique homomorphism into the final F -coalgebra assigns to every state a canonical representation of its global behaviour. • Homomorphisms are structure preserving functions. Similarly, bisimulations are structure preserving relations. They are used in the formulation of the coinduction proof principle.

  69. � � � � � � � Examples of coalgebraic types S S S γ α β S A A S S S S S γ α β δ 2 × S A S A × S A + S

  70. Where coalgebra is used • logic, set theory • automata • control theory • combinatorics • data types • dynamical systems • games

Recommend


More recommend