The Method of Coalgebra: Exercises in Coinduction
Total Page:16
File Type:pdf, Size:1020Kb
The Method of Coalgebra: exercises in coinduction Jan Rutten CWI & RU [email protected] Draft d.d. 8 July 2018 (comments are welcome) 2 Draft d.d. 8 July 2018 Contents 1 Introduction 7 1.1 The method of coalgebra . .7 1.2 History, roughly and briefly . .7 1.3 Exercises in coinduction . .8 1.4 Enhanced coinduction: algebra and coalgebra combined . .8 1.5 Universal coalgebra . .8 1.6 How to read this book . .8 1.7 Acknowledgements . .9 2 Categories { where coalgebra comes from 11 2.1 The basic definitions . 11 2.2 Category theory in slogans . 12 2.3 Discussion . 16 3 Algebras and coalgebras 19 3.1 Algebras . 19 3.2 Coalgebras . 21 3.3 Discussion . 23 4 Induction and coinduction 25 4.1 Inductive and coinductive definitions . 25 4.2 Proofs by induction and coinduction . 28 4.3 Discussion . 32 5 The method of coalgebra 33 5.1 Basic types of coalgebras . 34 5.2 Coalgebras, systems, automata ::: ....................... 34 6 Dynamical systems 37 6.1 Homomorphisms of dynamical systems . 38 6.2 On the behaviour of dynamical systems . 41 6.3 Discussion . 44 3 4 Draft d.d. 8 July 2018 7 Stream systems 45 7.1 Homomorphisms and bisimulations of stream systems . 46 7.2 The final system of streams . 52 7.3 Defining streams by coinduction . 54 7.4 Coinduction: the bisimulation proof method . 59 7.5 Moessner's Theorem . 66 7.6 The heart of the matter: circularity . 72 7.7 Discussion . 76 8 Deterministic automata 77 8.1 Basic definitions . 78 8.2 Homomorphisms and bisimulations of automata . 80 8.3 The final automaton of languages . 87 8.4 Regular languages . 91 8.5 Proving language equality by coinduction . 93 8.6 Minimal automata . 98 8.7 Discussion . 105 9 Partial automata 107 9.1 Partiality . 108 9.2 Partial systems with outputs . 111 9.3 Partial automata . 113 9.4 Discussion . 116 10 Non-deterministic automata 117 10.1 The powerset construction . 119 10.2 Language equivalence of non-deterministic automata . 120 10.3 Discussion . 124 11 Stream differential equations 127 11.1 Examples of stream differential equations . 129 11.2 Introducing the syntactic solution method . 132 11.3 GSOS: a general format for stream differential equations . 138 11.4 Behavioural differential equations . 145 11.5 Discussion . 146 12 A calculus of streams 149 12.1 Basic stream operations . 149 12.2 Convolution inverse . 156 12.3 Stream composition . 160 12.4 Shuffle product . 162 12.5 Laplace transform . 166 12.6 Solving analytic differential equations . 169 Contents 5 12.7 Newton transform . 173 12.8 Rational streams and linear systems of SDEs . 179 12.9 Discussion . 186 13 Mealy automata 187 13.1 Causal stream functions . 188 13.2 Constructing minimal Mealy automata . 190 13.3 Moore automata . 192 13.4 A calculus of bitstreams . 193 13.5 Mealy machines for bitstream functions . 197 13.6 Discussion . 201 14 Weighted stream automata 203 14.1 Representing streams by weighted automata . 203 14.2 Splitting stream derivatives . 205 14.3 Weighted automata and linear stream systems . 208 14.4 Rational streams and linear stream systems . 214 14.5 Minimisation of linear stream systems . 218 14.6 Weighted automata with inputs . 222 14.7 Discussion . 223 15 Universal coalgebra 225 15.1 Lambek's Lemma . 225 15.2 Homomorphisms . 227 15.3 Coproducts of coalgebras . 227 15.4 Bisimulation and finality . 229 15.5 Enhanced coinduction . 232 15.6 Discussion . 233 16 Notation and preliminaries 235 16.1 Numbers . 235 16.2 Functions . 235 16.3 Products and sums . 236 16.4 Subsets . 237 16.5 Relations . 237 16.6 Words and languages . 238 16.7 Monoids, semi-rings, rings, integral domains, fields . 239 16.8 Pre-orders and partial orders . 240 16.9 Vector spaces and linear maps . 241 16.10 Functors on sets . 241 16.11 On-line Encyclopedia of Integer Sequences . 242 6 Draft d.d. 8 July 2018 Chapter 1 Introduction So you heard about coalgebra, and maybe you want to know more. Or you know about coalgebra, and maybe you want to hear more still, or you just want to see how things are done here. This is what we will do. 1.1 The method of coalgebra In Chapters 2 { 5, we will briefly sketch our view on the coalgebraic method. The notion of coalgebra arises as the dual, in the theory of categories, of the notion of algebra. So this is what we explain first, in Chapters 2 and 3. Then coalgebras come to life and become relevant, only after one dualises also the notions of congruence relation and induction, two of the essential ingredients of the theory of algebras. This yields the notions of bisimulation and coinduction, explained in Chapter 4. With this in place, we summarise, in Chapter 5, the method of coalgebra as a general formalism for the study of the behaviour { typically infinite, stemming from some form of circularity { of state-based, dynamical systems. 1.2 History, roughly and briefly In the late 1970s, coalgebras occur as the dual of algebras in the work of Arbib and Manes, in their category theoretic approach to dynamical systems and automata [AM75, AM82]. Their textbook [MA86] already presents automata as coalgebras and contains an early proof that the set of formal languages is a final coalgebra (Theorem 152 in Chapter 8 of the present book). Still nothing much happens with coalgebra until (i) Park and Milner invent bisimulation as a notion of behavioural equivalence for concurrent processes [Mil80, Par81, Mil89]; and (ii) Aczel needs a notion of strong extensionality for his theory of non-well-founded sets [Acz88]. To this end, Aczel and Mendler generalise Park and Milner's notion of bisimulation to the level of arbitrary coalgebras [AM89]. With this new notion of coalgebraic bisimulation, it becomes obvious how to formulate a general notion of coinduction for arbitrary coalgebras. And as a consequence, coalgebra becomes a lively field of research from the early 1990s onwards. 7 8 Draft d.d. 8 July 2018 It follows from the above that the foundations of coalgebra consist of a mix of ingredi- ents from mathematics (dynamical systems, category theory), computer science (automata theory, concurrency theory), and logic (axiomatic set theory). The above suggests further that coinduction is the reason why coalgebra might be interesting. 1.3 Exercises in coinduction Each of Chapters 6 - 14 deals with a concrete type of coalgebra. These coalgebras include many familiar mathematical structures, such as dynamical systems, streams (infinite se- quences), and automata. These mathematical structures themselves are the main subject of these chapters, but methodologically, each chapter offers a playground for exercises in coinduction: the coalgebraic method for definitions and proofs. 1.4 Enhanced coinduction: algebra and coalgebra com- bined In the algebraic approach to the analysis of computational behaviour, one uses algebraic operators to represent the structure at hand as a composition of substructures. In this manner, behavioural complexity is reduced to the composition of the smaller complexities of the substructures, a phenomenon sometimes referred to as divide and conquer. In the coalgebraic approach, complexity is typically reduced by exploiting circularity, by observing that after a number of transition steps, essentially the same situation occurs again. As we shall see, the combination of algebra and coalgebra leads to powerful computational proof methods, typically referred to as enhanced coinduction or coinduction up-to, where one constructs bisimulation relations up-to the closure under a given set of algebraic operators. We will present various concrete instances of bisimulation and coinduction up-to. For more general accounts, see the references in Section 15.5. 1.5 Universal coalgebra The classical field of universal algebra deals with general properties of algebras. In universal coalgebra, one studies general properties of coalgebras, and Chapter 15 gives the reader a quick impression of this subject. The present book is about exercises in coinduction with concrete coalgebras. Generality is not our aim here, and so we refer the reader to the literature for systematic treatments of universal coalgebra. 1.6 How to read this book For most of this book, very little background in mathematics is required. The brief sketch of the coalgebraic method in Chapters 2 { 5 may be too technical for some readers but Chapter 1. Introduction 9 then again,.