Guarded monoidal traces, Hoare logic and the Grothendieck construction Sergey Goncharov Oberseminar, TCS, FAU, Erlangen, 27.06.2017
Salvador Dal´ ı, Portrait of Gala with two lamb chops balanced on her shoulder, 1933 “They immediately asked me if it was true that I had just painted a portrait of my wife with a pair of fried chops balanced on her shoulder [...] But why the chops together with your wife? I answered that I liked my wife, and that I liked chops, and that I saw no reason why I should not paint them together.” —Salvador Dal´ ı
Overture
Symmetric Monoidal Categories In categories, we have sequentially composable boxes and wiers: f g id X : X Ñ X X Ý Ñ Y Ý Ñ Z In symmetric monoidal categories, we can additionally tensor boxes: f b g Ñ X 1 b Y 1 X b Y Ý Ý arrange wires in (possibly empty) bunches, and cross them (due to symmetry!)
co-Cartesian Categories A category is co-Cartesian if we can initiate and merge wires: ! X ∇ ∅ Ý Ñ X X ` X Ý Ñ X and equivalently transform diagrams by a bunch of laws, most notably the commutative co-monoid laws: We obtain Cartesian categories by horizontally flipping the diagrams
Adding Effects Generic effects can be viewed as branching connectors “the opposite way around”: For example, binary nondeterminism is captured by the monoid laws:
Adding Effects ... and the laws of interaction with the monoidal structure, like the Hopf identity: The binary effect X Ñ X ` X can be though of as fair coin tossing. E.g. the law states that nondeterminism is idempotent
Monads A monad on a category C consists of a transformation on objects T : | C | Ñ | C | , such that morphisms of the form X Ñ TY again form a category, C T , called Kleisli category under η X : X Ñ TX and ˛ Thus we can lift every f : X Ñ TY to f ‹ “ f ˛ id : TX Ñ TY If C is co-Cartesian then so is C T with ∇ 1 “ η ∇ : X ` X Ñ TX , ! 1 TX “ ! TX : ∅ Ñ TX But C T has effects! E,g. toss : X Ñ T p X ` X q We use shaded boxes to indicate pure morphisms of C T , i.e. the ones coming from C
Monoidal Traces A monoidal category is called traced if we additionally allow for feedback loops: In the conventional one-dimensional speech, we postulate a trace operator tr : Hom p X b Y , Z b Y q Ñ Hom p X , Z q satisfying a bunch of geometrically feasible laws Coherence for traced monoidal categories is the property of these laws saying that two expressions are equivalent if they correspond to the same diagram modulo rearrangement of boxes and wires
Iteration and Recursion Iteration and recursion are obtained by adding co-Cartesian and Cartesian structure correspondingly Iteration Recursion X Ñ Y ` X Y ˆ X Ñ X f : : X Ñ Y f : : Y Ñ X
Trace in Bi-Cartesian Categories What if we have both Cartesian and co-Cartesian structure?
Trace in Bi-Cartesian Categories What if we have both Cartesian and co-Cartesian structure? Then we obtain Kleene iteration (v.s. Elgot iteration): X Ñ X f � : X Ñ X This one: a � “ 1 ` a ` aa ` . . .
Uniformity and Elgot Monads Trace axioms are incomplete w.r.t. standard models of iteration, e.g. they do not imply squaring identity: = Solution: postulate more powerful quasi-equational principle, uniformity: Defintion: a monad T over co-Cartesian C is an Elgot monad if its Kleisli category possesses a uniform trace
Guarded Traces
Generalized Coalgebraic Monad Transform Given an Elgot monad T , the generalized coalgebraic transform of it is an Elgot monad T Σ freely obtained from T by adjoining new uninterpreted effects from a signature Σ Formally: T Σ X “ νγ. T p X ` Σ γ q For example, by combining T “ P ω (finite powerset) and Σ X “ A ˆ X we obtain as T Σ X possibly infinite nondeterministic processes with actions in A and (eventual) final results in X under strong bisimilarity The diagrammatic language becomes extended by adding for each a P A
Guarded v.s. Unguarded Using the fact that T is Elgot we can solve both guarded and unguarded definitions over T : Equation Canonical solution Further solutions a ω “ a . a . . . Guarded X “ a . X — a ω “ a . a . . . a ω ` a ‹ x , for all x Unguarded X “ a . X ` X If T is not Elgot (e.g. nonempty powerset) we can no longer compute solutions of unguarded definitions, but we still can compute solutions of guarded ones More generally, guardedness does not guarantee uniqueness, e.g. under infinite trace equivalence X “ a . X has both a ω and a ω ` a ‹ as solutions
Guardedness for T Σ A be a summand of A , i.e. A is a coproduct of A 1 and Let σ : A 1 some A 2 . This determines a complement ¯ σ : A 2 A of σ We define σ -guarded Kleisli morphisms f : X Ñ σ T Σ A as follows f : X Ñ σ T Σ A iff D g : X Ñ T p A 2 ` Σ T Σ A q . out ˝ f “ T p ¯ σ ` id q ˝ g (where out is the isomorphism T Σ Z Ñ T p Z ` Σ T Σ Z q ) That is, f factors through g which preclude potential unguarded calls via A 1
Guarded Monoidal Categories The relations X Ñ σ Y were axiomatized in the previous work; the axioms are robust and enjoy many nice properties Problem: the axioms are not sufficiently lucid, neither symmetric, hence a generalization to monoidal categories was unclear Solution: instead of X Ñ σ Y we specify X Ñ θ,σ Y defined as follows θ : X 1 Ñ σ Y f ¯ f : X Ñ θ,σ Y iff This directly leads to the desired axiomatization Definition: A symmetric monoidal category C is guarded if it is equipped with distinguished subsets Hom ‚ p A b B , C b D q Ď Hom p A b B , C b D q satisfying following axioms
Weakening A , B , C P Hom ‚ p A b p B b C q , p A b B q b C q α - 1
Stability f b g P Hom ‚ p A b B , C b D q for all f : A Ñ C , g : B Ñ D
Sequencing g P Hom ‚ p A b B , C b D q and f P Hom ‚ p C b D , E b F q imply that g ˝ f P Hom ‚ p A b B , E b F q
Tensoring (Text version omitted)
Results • Coherence (conjecture): f P Hom ‚ p X 2 ` X , Y 2 ` Y 1 q is derivable from the axioms iff in the corresponding diagram, every wire from X 2 to Y 1 runs through at least one guarded output gate • For co-Cartesian categories f : X 2 ` X 1 Ñ inr , inr Y 2 ` Y 1 iff f P Hom ‚ p X 2 ` X 1 , Y 2 ` Y 1 q • The category of complete metric spaces and non-expansive maps is guarded monoidal with b “ ˆ and f P Hom ‚ p A ˆ B , C ˆ D q iff pr 2 ˝ f is contracting in A
Guarded Traced Monoidal Categories We call a guarded monoidal category C traced if it is equipped with a trace operator f P Hom ‚ pp X b A q b B , C b p D b X qq tr p f q P Hom ‚ p A b B , C b D q satisfying the laws of traced monoidal categories For example, Valid Invalid
Fibrations and the Grothendieck Construction
Localizing Guardedness We stick to the case b “ ` in some C T from now on The judgments f : A Ñ θ,σ TB formalize a transition-based idea of guardedness. Can we formulate it as a state-based one? By writing f : p A , θ q Ñ p B , σ q instead of f : A Ñ θ,σ B we obtain something very similar to the Grothendieck construction
Fibrations: Type-Theoretic Intuition Given a type-family p A i q i P I , we can think of it in two ways: 1. as a map sending each i P I to the corresponding type A i , hence drawing on a higher universe hosting all the A i 2. as a map f : A Ñ I where A is the total space of p A i q i P I , i.e. the i A i ; the types A i are identified as fibers f - 1 p i q sum ř Categorically, (1) corresponds to the 2-category Func p C op , Cat q of pseudofunctors C op Ñ Cat , which embeds to the slice category Cat { C corresponding to (2). The essential image of this embedding is the category of Grothendieck fibrations over C : – Γ p C q : Func p C op , Cat q Ý Ý Ñ Fib p C q Ý Ñ Cat { C looooooooooooooooomooooooooooooooooon Grothendieck construction
Fibrations: Set-Theoretic Intuition Let C “ Set . By associating to each X P | Set | the category Pred p X q of predicates and injections, we obtain the subobject fibration: • Objects are pairs p X , X 1 Ď X q • Morphisms from p X , X 1 Ď X q to p Y , Y 1 Ď Y q are those maps f : X Ñ Y for which X 1 Ď f - 1 r Y 1 s In general, p Pred p X qq X P| C | is replaced by an arbitrary family of categories p FX q X P| C | , and f - 1 by a base change functor; the morphisms from p X , X 1 P | FX |q to p Y , Y 1 P | FY |q are pairs p f : X Ñ Y , g : X 1 Ñ F p f qp Y 1 qq
Some Problems The standard idea is to use pullbacks for defining the base change functor. We could consider summands σ : X 1 X as fibers over the corresponding objects of C T , but 1. Pullbacks of summands are not necessarily summands, but just some monics 2. This would be a wrong anyway, because what we really should pull back are the maximal subobjects of TA , through which all σ -guarded morphisms factor Recall, it was T p A 2 ` Σ T Σ A q for T Σ A and σ : A 1 A
Some Solutions We develop the following technology • We postulate an object A σ , such that Hom p X , A σ q – Hom σ p X , TA q naturally in X , i.e. witnessing that the functor X ÞÑ Hom p X , A σ q is representable • A σ becomes a subalgebra of TA under suitable ι σ : A σ Ñ TA • The pullback of ι σ : A σ Ñ TA along any f ‹ : TB Ñ TA is a subalgebra f İ p A σ q of TB • Then: f : B Ñ θ,σ TA iff ι θ Ď β σ in C T { TB : f İ p A σ q A σ ι σ β σ ι θ f ‹ B θ TB TA
Recommend
More recommend