Using Coalgebras and the Giry Monad for Interpreting Game Logics — A Tutorial 7 Ernst-Erich Doberkat∗ 1 Math ++ Software, Bochum, Germany 0 [email protected] 2 n January 3, 2017 a J 1 ] O Contents L s. 1 Objectives 2 c [ 2 Coalgebras 2 1 v 3 The $-Functor 4 0 8 4 The Giry Monad 9 2 0 5 Playing Around with Morphisms 15 0 . 1 6 Bisimulations 18 0 7 7 Expressivity of Kripke Models 23 1 v: 8 Stochastic Effectivity Functions 28 i X 9 What To Do Next 38 r a A The π-λ-Theorem 39 B The Souslin Operation 39 Abstract ThestochasticinterpretationofParikh’sgamelogicshouldnotfollowtheusualpatternof Kripkemodels,whichinturnarebasedontheKleislimorphismsfortheGirymonad,rather, aspecificandmoregeneralapproachtoprobabilisticnondeterminismisrequired. Weoutline this approach together with its probabilistic and measure theoretic basis, introducing in a leisurelypacetheGirymonadandtheirKleislimorphismstogetherwithimportanttechniques for manipulating them. Proof establishing specific techniques are given, and pointers to the extant literature are provided. After working through this tutorial, the reader should find it easier to follow the original literature in this and related areas, and it should be possible for her or him to appreciate measuretheoreticargumentsfororiginalworkintheareasofMarkovtransitionsystems,and stochastic effectivity functions. ∗SomeoftheresultswereobtainedwhiletheauthorheldtheChairforSoftwareTechnologyatTechnischeUni- versit¨at Dortmund; they were funded inpart by Deutsche Forschungsgemeinschaft, Koalgebraische Eigenschaften stochastischer Relationen,grantDO263/12-1. 1 Page 2 Tutorial on Coalgebras and Game Logics AMS subject classification: 03B45,18C15, 18C20 Computing Reviews Classification: F.4.1, I.2.3, I.2.4, G.3 1 Objectives Aminimalcategorialframeworkisintroducedinordertoformulatecoalgebrasandmonads(which come here in their disguise as Kleisli tripels). We specialize then to the category of measurable spaces, discussing here in particular the Giry monad, with occasional side glances to the upper closedfunctor. Thisiscomplementedbyadiscussionofmorphismsforstochasticcoalgebras(which willalso be usedfor the interpretationofvariousmodallogics),givingamongothers congruences, which will be put to use when discussing the expressivity of Kripke models. But before doing so, wehaveafairlygenerallookatbisimulationsfor varioustransitionmodels,pointing atdifficulties arisingforstochasticcoalgebras. Weexpandthenourscenariobyintroducingstochasticeffectivity functions, which we will briefly investigate, and which will be used for an interpretation of game logics. Not all topics can be treated in depth due to limitations in space, but proofs are provided here and there, mostly for illustrating some techniques. Two appendices are provided, one discusses a technical device (the Souslin operation), the other one gives the important π-λ-Theorem from Boolean σ-algebras. The classic reference to coalgebras is the paper by Rutten [21], the survey paper by Venema [26] focusses on representation issues, see also [15]. The present discussion is based on [9, 8, 10]. References to extant pieces of literature are given when needed. 2 Coalgebras Fix a categoryC with anendofunctor F (I assume that the readerknows what a categoryis, and what a functor does). Definition 2.1 An F-coalgebra (a,f) over C is an object a of C together with a morphism Coalgebra f:a Fa. → Example 2.2 Let C be the category of sets with maps as morphisms, the functor is the power set functor 22−. (A,f) is an 22−-coalgebra iff f : A 22A is a map. This is in 1-1-correspondence Category of with binary relations: sets → hx,x′i∈R iff x′ ∈f(x). ✌ Through this, transition systems are studied. Example 2.3 LetXresp. Y betheinputsandtheoutputsofanautomatonwithoutputs. Define Automata F:= (−×Y)X over the category of sets. The (A,f) is an F-coalgebra iff it is an automaton with states A: Since f:A (A×Y)X, we have f(a)(x)∈A×Y, say, f(a)(x)=ha′,yi, hence a′ is the new state of the automaton, y its output upon input x in state a. → January 3, 2017 E.-E. Doberkat Page 3 Tutorial on Coalgebras and Game Logics Conversely,let(X,Y,A,δ)beanautomatonwithoutput,i.e.,δ:A×X A×Y isamap. Currying ✌ gives a map f:A (A×Y)X throughf(a)(x):=δ(a,x). This means that f is an F-coalgebra. → Example 2.4 Pu→tFA:={∗}∪A×Awith∗anewsymbol. (A,f)isanF-coalgebraifffcorresponds Trees toabinarytreeoverA. Putf(a):=∗iffaisaleaf,andf(a)=ha ,a iiffa anda areoffsprings 1 2 1 2 ✌ of a. The tree may be infinite, though. Fix in what follows both C and F. Definition 2.5 Let (a ,f ) and (a ,f ) be F-coalgebras. A C-morphism ϕ : a a is a Coalgebra 1 1 2 2 1 2 coalgebra morphism (a ,f ) (a ,f ) iff f ◦ϕ=Fϕ◦f . This means that the diagram morphism 1 1 2 2 2 1 → → ϕ // a a 1 2 f1 f2 (cid:15)(cid:15) (cid:15)(cid:15) Fa //Fa 1 Fϕ 2 commutes. Proposition 2.6 F-coalgebras form a category with coalgebra morphisms as morphisms; compo- sition is inherited from C. ⊣ Example 2.7 Consider the coalgebras corresponding to transition systems from Example 2.2. Then ϕ:(A ,f ) (A ,f ) is a coalgebra morphisms iff these conditions are satisfied: 1 1 2 2 1. a′ ∈f (a )→implies ϕ(a′)∈f (a ). 1 1 1 1 2 1 2. If a′ ∈f (ϕ(a )), then there exists a′ ∈f (a ) with ϕ(a′)=a′. 2 2 1 1 1 1 1 2 In fact, assume that ϕ is a coalgebra morphism. Then we note that 22ϕ(W) = ϕ W , and that (cid:2) (cid:3) we have this commuting diagram ϕ // A A 1 2 f1 (cid:15)(cid:15) (cid:15)(cid:15)f2 22A1 // 22A2 22ϕ Assume that a′ ∈f(a ), then 1 1 ϕ(a′)∈ϕ f (a ) =22ϕ(f (a ))=f (ϕ(a )). 1 (cid:2) 1 1 (cid:3) 1 1 2 1 This gives us the first condition. On the other hand, let a′ ∈ f (ϕ(a )) = 22ϕ(f (a )), thus 2 2 1 1 1 a′ ∈ ϕ f (a ) . But this implies that we can find a′ ∈ f (a ) with ϕ(a′) = a′. This provides 2 (cid:2) 1 1 (cid:3) 1 1 1 1 2 us with the second condition. The converse direction offers itself as an exercise. Bounded These morphisms are called bounded morphisms in the theory of transition systems. In fact, morphisms reformulate a′ ∈ f (a) as a a′, similarly b′ ∈ f (b) as b b′. In this notation, the 1 1 2 2 conditions above read → → January 3, 2017 E.-E. Doberkat Page 4 Tutorial on Coalgebras and Game Logics 1. a a′ implies ϕ(a ) ϕ(a′). 1 1 1 1 2 1 2. If ϕ→(a ) a′, then the→re exists a′ with a a′ such that ϕ(a′)=a′. 1 2 2 1 1 1 1 1 2 ✌ → → This indicates an interesting connection between coalgebras and transition systems. Upper Example 2.8 Take the functor EE of all upper closed subsets of 22−. We did not yet define how closed EE acts on maps, hence we have to transform f:A B to EE(f):EE(A) EE(B). Let’s see how to do this. → → Let G ∈ EE(A), then G ⊆ 22A is upper closed. Thus the set {H ⊆ B | f−1 H ∈ G} ⊆ 22B is also (cid:2) (cid:3) upper closed (if H ⊆ H and f−1 H ∈ G, we note that f−1 H ⊆ f−1 H , and since G is 1 2 1 1 2 (cid:2) (cid:3) (cid:2) (cid:3) (cid:2) (cid:3) upper closed, this implies that f−1 H ∈G). With this in mind, we put 2 (cid:2) (cid:3) EE(f)(G):={H⊆B|f−1 H ∈G}. (cid:2) (cid:3) It can be shown that EE(g◦f)=EE(g)◦EE(f) (see [9, 2.3.14]). What do morphisms for EE look like? Let’s try: ϕ // A A 1 2 f1 f2 (cid:15)(cid:15) (cid:15)(cid:15) EE(A ) // EE(A ) 1 EE(ϕ) 2 Let H=f (ϕ(a ))= EE(ϕ)◦f (a ), thus 2 1 1 1 (cid:0) (cid:1) H∈H iff H∈EE(ϕ) f (a ) iff ϕ−1 H ∈f (a ). 1 1 1 1 (cid:0) (cid:1) (cid:2) (cid:3) Consequently we have f (ϕ(a ))={H⊆B|ϕ−1 H ∈f (a )} 2 1 1 1 (cid:2) (cid:3) ✌ as a qualifying condition for ϕ:A A to become a EE-morphism. 1 2 → 3 The $-Functor Beforeenteringtheadiscussionontheprobabilityfunctor,weneedtoknowalittlebitmoreabout measurable spaces. Recall that a measurable space (X,A) is a set X together with a Boolean σ- algebra A on X, the σ indicating here that the Boolean algebra is closed under countable unions (and, by implication, under countable intersections). Definition 3.1 Let X be a set, A⊆22X be a family of subsets of X. Then σ(A) σ(A):= {B|A⊆B,B is a σ−algebra} \ is the smallest σ-algebra on X which contains A. A is called a generator of σ(A). January 3, 2017 E.-E. Doberkat Page 5 Tutorial on Coalgebras and Game Logics It is clear that σ(A) is always a σ-algebra (check the properties). Also, A ⊆ 22X, the latter one being a σ-algebra. Note that σ:22X 22X is a closure operator, thus we have • if A⊆B, then σ(A)⊆σ(B), → • A⊆σ(A), • σ(σ(A))=σ(A). In particular, σ(A)=A, whenever A is a σ-algebra. Example 3.2 The Borel sets B(R)aredefinedas the smallestσ-algebraonR whichcontainsthe Borel sets open (or the closed) sets. We claim that B(R)=σ [r,+ [|r∈R =:Q. (cid:0) (cid:1) (cid:8) (cid:9) ∞ In fact • Q⊆B(R), since [r,+ [= ]r− 1, [, Tn∈N n the latter sets are in B(R), since they∞are open. ∞ • [r,s[∈Q for r<s, since [r,s[=[r, [\[s, [. • ]r,s[∈Q, since ]r,s[= [r+1/∞n,s[. ∞ Sn∈N • All open sets in R are in Q, because each open set can be written as the union of countably many open intervals (and the open intervals are in Q). • All closedsets are in Q as well, since Q is closedunder complementation. Hence B(R)⊆Q. ✌ The reals R are always assumed to have the Borel σ-algebra. In what follows, we will usually write down measurable spaces without their σ-algebras,unless we have to. Definition 3.3 Let (X,A) and (Y,B) be measurable spaces. A map f : X Y is called A-B- measurable iff f−1 B ∈A for all B∈B. Measurability (cid:2) (cid:3) → Note the similarity to continuity (inverse images of open sets are open is the general definition), and to uniform continuity (resp. inverse images of neighborhoods are neighborhoods). Note also thatameasurablemapisnotnecessarilyaBooleanhomomorphismoftheBooleanalgebrasAand B (constant maps are always measurable, but are rarely homomorphisms of Boolean algebras). We should convince ourselves that we did indeed create a category. Proposition 3.4 Measurable spaces with measurable maps form a category. Proof We need only to show: if f : X Y and g : Y Z are measurable, so is g◦f : X Z. LetA, B,andC be the correspondingσ-algebras,thenweobtainfromthe measurabilityofgthat → → → g−1 C ∈BforC∈C,thusf−1 g−1 C ∈A,sincefisalsomeasurable. But(g◦f)−1 =f−1◦g−1, (cid:2) (cid:3) (cid:2) (cid:2) (cid:3)(cid:3) so the assertion follows. ⊣ January 3, 2017 E.-E. Doberkat Page 6 Tutorial on Coalgebras and Game Logics This is a helpful criterion for measurability, since it permits testing only on a generator, which is usually more readily available than the whole σ-algebra. Lemma 3.5 Let (X,A) and (Y,B) be measurable spaces, f : X Y a map, and assume that B is generated by B . Then f is A-B-measurable iff f−1 B ∈A for all B∈B . 0 (cid:2) (cid:3) → 0 Proof 1. The condition is clearly necessary for measurability, since B ⊆B. Principle of 0 2. Thecriterionis alsosufficient. We showthis throughthe principle of good sets (see [9, Remark good sets after Theorem 1.6.30]). It works like this. We want to show that f−1 B ∈A holds for all B∈B. (cid:2) (cid:3) Consider the set G of all “good sets”, G :={B⊆Y |f−1 B ∈A}. (cid:2) (cid:3) Then 1. G is a σ-algebra. This is so because f−1 is compatible with all the Boolean operations, e.g., f−1 B )= f−1 B . (cid:2)Si∈I i(cid:3) Si∈I (cid:2) i(cid:3) 2. B ⊆G by assumption. 0 Thus σ(B )⊆σ(G)=G. 0 Hence B = σ(B ) ⊆ G, but this means that f−1 B ∈ A for all B ∈ B. Hence f is in fact 0 (cid:2) (cid:3) A-B-measurable. ⊣ This is an easy consequence from Lemma 3.5 together with Example 3.2: Lemma 3.6 A map f:X R is measurable iff {x∈x|f(x)≥r} is a measurable subset of X for all r∈R. ⊣ → Note that we can replace the sets {f ≥ r} by {f ≤ r}, by {f > r} or by {f < r}, since there are easy ways to compute one through the other using only countable operations (such as {f > r} = {f≥r+1/n}), and so on. Sn∈N Indicator Example 3.7 Let χ be the indicator function of A⊆X, thus function A χ (x):=if x∈A then 1 else 0 fi. A Then χ is a measurable function iff A is a measurable set. This becomes evident from A ∅, r>1, {x∈X|χA(x)≥r}=A, 0<r≤1, X, r≤0 ✌ January 3, 2017 E.-E. Doberkat Page 7 Tutorial on Coalgebras and Game Logics A measurable space induces a measurable structure on the space $(X):={µ|µ is a probability on (the σ-algebra of) X} in the following way. Define first β(A,q):={µ∈$(X)|µ(A)≥q} as the set of measures the value of which at event A is not smaller than q. Definition 3.8 Given a measurable space X, its *-σ-algebra is the smallest σ-algebra on $(X) *-σ-algebra which contains the sets {β(A,q)|A⊆X measurable, q∈R}. Thusthe*-σ-algebraisthesmallestσ-algebraon$(X)whichproducesmeasurablemapsfromthe evaluation at events. Example 3.9 Define for the measurable space X the embedding η : X $(X) upon setting X η (x)(A) := χ (x). Then η is a measurable map. In fact, by Lemma 3.5 and the definition of X A X → the *-σ-algebra we have to show that the set η −1 β(A,q) ={x∈X|η (x)∈β(A,q)} X X (cid:2) (cid:3) is measurable for each measurable set A⊆X and each q∈R. But we have η (x)∈β(A,q) iff χ (x)≥q, X A so that the set in question is measurable by Example 3.7. η is usually called the Dirac kernel, η (x) the Dirac measure on x∈X, which is usually denoted by δ , when the measurable space X X x is understood. ✌ Reformulating, we see that η :X $X is a morphism in the category of measurable spaces. X → We define now $ for a measurable map and show that this yields a measurable map again. This is the basis for 1. showing that $ is an endofunctor on the category of measurable spaces, 2. establishing the properties of the Giry monad. Allora: Definition 3.10 Let X and Y be measurable spaces, f : X Y be a measurable map. Define for µ∈$(X) and for B⊆Y measurable → $(f)(µ)(B):=µ f−1 B . (cid:0) (cid:2) (cid:3)(cid:1) Image This is called the image measure for µ under f. measure January 3, 2017 E.-E. Doberkat Page 8 Tutorial on Coalgebras and Game Logics The first step towards showing that $ is an endofunctor consists in showing that $ transforms measurable maps into measurable maps again (albeit on another space). Lemma 3.11 Given X, Y and f as above, $(f) : $(X) $(Y) is measurable with respect to the *-σ-algebras. → Proof 0. We have to establish first that ($f)(µ) is a measure on Y, provided µ ∈ $X. This is fairly straightforward,let’s have a look: 1. $(f)(µ)(∅)=µ(f−1 ∅ )=µ(∅)=0, and $(f)(µ)(Y)=µ(f−1 Y )=µ(X)=1. (cid:2) (cid:3) (cid:2) (cid:3) 2. Let A and B be disjoint measurable subsets of Y, then f−1 A and f−1 B are disjoint as (cid:2) (cid:3) (cid:2) (cid:3) well, thus $(f)(µ)(A∪B)=µ(f−1 A∪B ) (cid:2) (cid:3) =µ(f−1 A ∪f−1 B ) (cid:2) (cid:3) (cid:2) (cid:3) =µ(f−1 A )+µ(f−1 B ) (cid:2) (cid:3) (cid:2) (cid:3) =$(f)(µ)(A)+$(f)(µ)(B). 3. If (B ) is an increasing sequence of measurable sets in Y with B := B , then n n∈N Sn∈N n f−1 B is an increasing sequence of measurable subsets of X, and f−1 B equals (cid:0) (cid:2) n(cid:3)(cid:1)n∈N (cid:2) (cid:3) f−1 B , thus Sn∈N (cid:2) n(cid:3) $(f)(µ)(B)=µ(f−1 B )= supµ(f−1 B )= sup$(f)(µ)(B ). n n (cid:2) (cid:3) (cid:2) (cid:3) n∈N n∈N 1. We establishmeasurabilitybyshowingthatthe inverseimageofageneratorto the *-σ-algebra in Y is a *-σ-measurable subset of $(X). Then the assertion will follow from Lemma 3.5. In fact, let B⊆Y be measurable, then we claim that ($f)−1 β (B,q) =β (f−1 B ,q) Y X (cid:2) (cid:3) (cid:2) (cid:3) holds. This is so because µ∈($f)−1 β (B,q) $(f)(µ)∈β (B,q) Y Y (cid:2) (cid:3) ⇔$(f)(µ)(B)≥q ⇔µ(f−1 B )≥q (cid:2) (cid:3) ⇔µ∈βX(f−1 B ,q). (cid:2) (cid:3) ⇔ ⊣ This yields as an immediate consequence Proposition 3.12 $ is an endofunctor on the category of measurable spaces. ⊣ January 3, 2017 E.-E. Doberkat Page 9 Tutorial on Coalgebras and Game Logics 4 The Giry Monad We want to determine the coalgebras for $. Given a measurable space X, a $-coalgebra (X,K) is a measurable map K : X $X. It will be necessary to proceed a bit more general, and to characterize measurable maps X $(Y) first. → → Example 4.1 Let X and Y be measurable spaces, and K : X $(Y) be a measurable map (remember: $(Y) carries the *-σ-algebra). Thus → 1. K(x) is for every x∈X a probability measure on (the measurable subsets of) Y. 2. Since K−1 β (B,q) = {x∈ X | K(x)(B) ≥ q}, we see that the map x 7 K(x)(B) is measur- Y (cid:2) (cid:3) able for any fixed measurable set B⊆Y. → Conversely, if we know that x 7 K(x)(B) is measurable for any fixed measurable set B ⊆ Y, and that K(x) is always a probability measure on Y, then the identity → K−1 β (B,q) ={x∈X|K(x)(B)≥q} Y (cid:2) (cid:3) shows that K is a measurable map X $Y. Coalgebras Thus we have in particular identified the coalgebras (X,K) for the $-functor as maps K:X×A for $ → [0,1] such that → 1. K(x) is a probability measure on X, 2. x7 K(x)(A) is a measurable map for each measurable set A. → (here A is the σ-algebra on X). K is also known in probabilistic circles as a Markov kernel or a transition probability. In terms of transition systems: K(x)(A) is the probability of making a ✌ transition from x to an element of the measurable set A. Example 4.2 We identify the morphisms for these coalgebras now. Let (X,K) and (Y,L) be $- coalgebras. A morphism ϕ for these coalgebras must be a measurable map ϕ : X Y, which is compatible with the coalgebraic structure. This means in our case that → ϕ // X Y K L (cid:15)(cid:15) (cid:15)(cid:15) // $X $Y $ϕ commutes. Thus L(ϕ(x))(B) = L◦ϕ (x)(B)= $(ϕ)◦K (x)(B)=$(ϕ)(K(x))(B)=K(x)(ϕ−1 B ), (cid:0) (cid:1) (cid:0) (cid:1) (cid:2) (cid:3) meaningthattheprobabilityofhittinganelementofBfromϕ(x)isthesameashittinganelement ✌ of ϕ−1 B from x. (cid:2) (cid:3) January 3, 2017 E.-E. Doberkat Page 10 Tutorial on Coalgebras and Game Logics For proceeding further, we need the integral of a bounded measurable function. Having this at ourdisposal,wecaninvestigatetheGirymonadandputitintocontextwithotherknownmonads by identifying common properties. Fix for the moment a measurable space X with σ-algebra A. Definition 4.3 Denote by F(X,A)=F(X) the set of all bounded measurable functions on X. The algebraic structure of F(X) is easily identified. Lemma 4.4 F(X) is a real vector space with χ ∈F(X) iff A∈A. A Proof 0. We know already from Example 3.7 that χ constitutes a measurable function iff the A set A is measurable. 1. Itis sufficientto show thatF(X) is closedunder additionandunder scalarmultiplication. The latter property is fairly easy established through Lemma 3.6, so let’s try our hand on the sum. We have for r∈R and f,g∈F(X) {x∈X|f(x)+g(x)<r}= {x∈X|f(x)+g(x)<q} [ q∈Q,q<r = {x|f(x)<a }∩{x|g(x)<a } [ (cid:16) [ (cid:0) 1 2 (cid:1)(cid:17) q∈Q,q<r a1,a2∈Q,a1+a2≤q Because both {x | f(x) < a } and {x | g(x) < a } are measurable sets, it follows that {x ∈ 1 2 X | f(x)+g(x) < r} is a measurable set, since Q is countable. The assertion now follows from Lemma 3.6. ⊣ It is also not difficult to show with the available tools that limn→∞fn defines a member of F(X), provided (f ) ⊆ F(X) such that |f (x)| ≤ B for alln ∈ N and x ∈ X, where B ∈ R (the latter n n∈N n condition is necessary for making the limit a bounded function). This permits us to define the integral of a bounded measurable function. The elaborate process is somewhat technical and drawn out in great detail in [9, Section 4.8]; we restrict ourselves to presenting the result. Proposition 4.5 Let µ ∈ $(X) be a probability measure on X. There exists a unique map Φ : F(X) R with these properties: 1. Φ→(a·f+b·g)=a·Φ(f)+b·Φ(g), whenever a,b∈R and f,g∈F(X) (linearity). 2. Φ(f)≥0, provided f≥0, hence Φ is monotone (positivity). 3. Φ(χ )=µ(A) for all measurable sets A⊆X (extension). A 4. If (fn)n∈N is a sequence of bounded measurable functions such that the limit limn→∞fn is bounded, then Φ( lim f )= lim Φ(f ). n→∞ n n→∞ n This is usually referred to as continuity. ⊣ January 3, 2017 E.-E. Doberkat