Relation Lifting
Total Page:16
File Type:pdf, Size:1020Kb
Relation Lifting Alexander Kurz University of Leicester with thanks to my coauthors Adriana Balan, Marta Bilkova, Clemens Kupke, Daniela Petrisan, Jiri Velebil, Yde Venema 30. 4. 2014 Overview Topic: Some elements of the category theory of relations 1. Introduction. (Why functors instead of signatures?) 2. Relation lifting over Set, universal property of Rel 3. Monotone relations 4. Many-valued (fuzzy) relations 5. Application: Bisimulation 6. Application: Simulation 7. Application: Coalgebraic logic 8. Conclusion 1 Chapter 1 Why functors instead of signatures? 2 Algebras for a functor One can replace signatures by functors, for example a constant 1 ! X and a binary operation X × X ! X can be assembled into 1 + X × X ! X or, FX ! X An algebra morphism is simply a function f : X ! X0 such that FX / X F f f FX0 / X0 3 Are functors more general than signatures? Example: The powerset functor P takes f : X ! X0 to Pf : PX !PX0 X ⊇ a 7! f[a] P! takes finite subsets only What are powerset algebras? List(X) −! P!X −! X More generally, for every functor T : Set ! Set there is a signature Σ such that a T -algebra TX ! X is an FΣ algebra FΣ ! TX ! X, where FΣ is the functor corresponding to the signature Σ. 4 Coalgebras for a functor A coalgebra is an arrow X ! TX mapping a state to its set of successors. Morphisms are given as X / TX f T f X0 / TX0 and induce a notion of bisimilarity or behavioural equivalence x ' x0 , 9f; f 0 : f(x) = f(x0) The definition of coalgebra is parametric in the category and the functor 5 Example: Tranisition systems ξ X / PX f Pf X0 / PX0 ξ0 8y 2 ξ(x) : 9y0 2 ξ0(x0) : f(y) = y0 8y0 2 ξ0(x0) : 9y 2 ξ(x) : f(y) = y0 6 Initial algebras and final coalgebras TX initial algebra final coalgebra P (well-founded) sets non-well-founded sets 1 + X N N [ f1g A × X ; streams (=infinite lists) 1 + A × X lists over A finite and infinite lists over A 1 + X × X finite binary trees non-well founded binary trees ::: For every functor T : Set ! Set the final coalgebra exists and consists of states up to behavioural equivalence 7 Chapter 2 Relation lifting Aim: Extend (or lift) a functor T : Set ! Set to a functor T¯ : Rel ! Rel (Notation “bar T ” in honour of the construction’s inventer Michael Barr) 8 The category Rel Given relations A R / B and B S / C there is the composition A S·R / C which is defined by having the graph G(S · R) = f(a; c) j 9b 2 B: (a; b) 2 R ^ (b; c) 2 Sg: Relations form a Pos-category: They are partially ordered by inclusion ⊆ 9 Fact 1: Recognise Set inside Rel f : A ! B gives rise to two relations f A ∗ / B has the graph f(a; f(a) j a 2 Ag. f ∗ B / A has the graph f(f(a); a) j a 2 Ag. A relation R is of the form f∗ for some map f iff R is left-adjoint: Id ⊆ S · RR · S ⊆ Id Moreover, S = f ∗. 10 Fact 2: Recover relations from maps Every relation R : A / B can be ‘tabulated as a span’ of maps GR dR cR } ! AB and one recovers the relation from the maps: ∗ R = cR∗ · dR (−)∗ : Set ! Rel together with Facts 1 and 2 provides a very tight relationship between maps and relations 11 Lifting a relation A ! B to a relation TA ! TB Tabulate R as GR dR cR } ! AB and apply T T (GR) T (dR) T (cR) z % TATB ∗ and then reconstruct a relation using (−)∗ and (−) in order to obtain ∗ TR¯ = T (cR)∗ · T (dR) 12 Example T (GR) T (dR) T (cR) z % TATB ∗ TR¯ = T (cR)∗ · T (dR) leads to the explicit formula GTR¯ = f(t; s) 2 TA × TB j 9w 2 T GR : T π1(w) = t; T π2(w) = sg; which can be used to calculate concrete examples: aP¯b , 9w 2 P(GR) : π1[w] = a & π2[w] = b; aP¯b , (8x 2 a : 9y 2 b : xRy)& (8y 2 b : 9x 2 a : xRy) 13 Relation lifting does not need to preserve graphs Important: The last example does not satisfy G(TR¯ ) =∼ T (GR) Solution: Factor spans through an epi e and a mono-span: T GR e T (dR) T (cR) GTR¯ } v dTR¯ cTR¯ ( ! TXTY 14 Fact 3: Lifting is independent of choice of span A relation can be represented by different spans. W e f g R p q XYw ' ∗ ∗ ∗ q∗ · p = g∗ · f iff e epi iff e∗ · e = Id. ∗ ∗ (T g)∗ · (T f) = (T q ◦ T e)∗ · (T p ◦ T e) ∗ ∗ = (T q)∗ · (T e)∗ · (T e) · (T p) ∗ = (T q)∗ · (T p) 15 Fact 4: Preservation of exact squares/weak pullbacks W p q ~ ! A B (1) g f } C ∗ ∗ is exact iff q∗ · p = g · f∗ ∗ ∗ q∗ · p ⊆ g · f∗ iff (1) commutes. ∗ ∗ q∗ · p = g · f∗ iff (1) is a weak pullback. 16 Relation lifting T¯ preserves composition G(RS) O e P dP cP dRS cRS x & GS GR dS cS dR cR | ' w # Thm (Barr, Trnkova, Carboni-Kelly-Wood, Hermida) The relation lifting T¯ satisfies T¯(R · S) ⊆ (TR¯ ) · (TS¯ ) and T¯(R · S) = (TR¯ ) · (TS¯ ) if and only if T preserves weak pullbacks. 17 The facts summarized The functor (−)∗ : Set ! Rel has the following three properties: ∗ 1. (−)∗ preserves maps, that is, every f∗ has a right-adjoint (denoted f ). 2. For every weak pullback (=exact square) W p q ~ ! A B (2) g f } C ∗ ∗ it holds q∗ · p = g · f∗ ∗ 3. It holds e∗ · e = Id for every epi e. 18 Universal property of Rel H / RelO > K The functor (−)∗ is universal: (−) ∗ F Set If K is any Pos-category, to give a locally monotone functor H : Rel !K is the same as to give a functor F : Set !K with the following three properties: 1. Every F f has a right adjoint, denoted by (F f)r. 2. For every weak pullback (2) the equality F q · (F p)r = (F g)r · F f holds. 3. For every epi e it holds F e · (F e)r = Id. Intuitively, Rel is obtained from Set by freely adding adjoints of maps. Works not only for Set but for all regular categories. 19 Chapter 3 Monotone relations 20 Monotone relations Relations R : X ! Y are monotone functions op X × Y ! 2 where X; Y are posets (or preorders) and 2 is the two-chain. Examples: Any relation that is weakening-closed: 0 0 x ≤ x x y y ≤ y x0 y0 the order of a lattice, the turnstile in a sequent calculus, ... 21 Rel(Pos): Composition and Identity A R / B and B S / C gives A S·R / C defined by _ S · R(a; c) = R(a; b) ^ S(b; c) b where W and ^ are taken in the lattice 2. The identity on a poset (preorder) A is given by the order relation and written variously as 0 0 0 Id(a; a ) = A(a; a )= a ≤A a 22 (−)∗ : Pos ! Rel(Pos) co (−)∗ : Pos ! Rel(Pos) A 7! B f : A ! B 7! λa, b :B (fa; b): A ! B f ≤ g 7! g∗ ≤ f∗ co where the indicates that the order between relations gets reversed and op (−)∗ : Pos ! Rel(Pos) A 7! B f : A ! B 7! λa, b :B (b; fa): B ! A f ≤ g 7! f ∗ ≤ g∗ op where the indicates that the order of the relations gets reversed. 23 Maps are adjoints We want to show that _ A(a; a0) ≤ R(a; b) ^ S(b; a0) b and _ S(b; a) ^ R(a; b0) ≤ B(b; b0) a only if R(a; b) = B(fa; b) for some f : A ! B. First consider the special case where A is the one element set. Then R is an upset, S is a downset, and the two inequalities ensure that there is f 2 B such that S = #f and R = "f, or, in our notation, S(b; a) = B(b; f) and R(a; b) = B(f; b). In the general case, the same reasoning gives an fa for each a 2 A with S(b; a) = B(b; fa) and R(a; b) = B(fa; b). 24 Theorem The relation lifting T¯ satisfies T¯(R · S) ⊆ (TR¯ ) · (TS¯ ) if T preserves epis and is functorial T¯(R · S) = (TR¯ ) · (TS¯ ) if and only if T preserves exact squares. The proof follows the same lines as for the discrete case (although some of the details are more intricate). The universal property is also stated and proved similarly. 25 Chapter 4 Many-valued (fuzzy) relations 26 Generalise from 2 to a lattice V of truth values Interesting example (Lawvere) op (lattice of truth values) = (lattice of distances) V = (([0; 1]; ≥R); +; 0) 0 is top, 1 is bottom, join is inf, meet is sup, implication is truncated minus − Instead of Pos or Preord one obtains generalised metric spaces (gms) A gms is a metric space, but distances need not be symmetric. A gms comes equipped with order: x ≤ y , X(x; y) = 0 Example: Finite and infinite words with metric and prefix order in one structure 27 Main idea Tabulate relations R : A ! B as cospans A B " | C(R) where the ‘collage’ C(R) is defined as A + B with homs C(R)(a; a0) = A(a; a0) C(R)(b; b0) = B(b; b0) C(R)(a; b) = R(a; b) C(R)(b; a) = ? 28 Chapter 5 Application: Bisimulation 29 Bisimulation X o R / X0 Aczel-Mendler ξ ρ ξ0 TXTRo / TX0 X o R X0 Relation lifting ξ ⊆ ξ0 ¯ TXTXo TR 0 Post-fixed point R ⊆ (ξ × ξ0)−1T¯(R) 30 Bisimulation Coinduction theorem: If x; x0 are related by some bisimulation, then x = x0 in the semantics.