SLIDE 1 Guarded Traced Categories for Recursion and Iteration
Sergey Goncharova
(joint ongoing work with Lutz Schr¨
- dera and Paul Blain Levyb)
April 2, 2019, Reykjavik TCS Seminar
aFriedrich-Alexander-Universit¨
at Erlangen-N¨ urnberg
bUniversity of Birmingham
SLIDE 2 Context
- Recursion / iteration
- order-theoretic / unguarded
- process-theoretic / guarded
- Generic categorical models:
- Total:
- Axiomatic/synthetic domain theory (Hyland, Fiore, Taylor et al.)
- let-ccc’s with fixpoint objects (Crole/Pitts, Simpson)
- Traced monoidal categories (Joyal/Street/Verity, Hasegawa)
- Elgot monads/theories (Bloom/Esik, Ad´
amek, Milius et al.)
- Partial:
- Completely iterative monads/theories (Bloom/Esik,
Ad´ amek, Milius et al.)
- later-modality (Nakano, Appel, Melli`
es, Benton, Birkedal et al.)
- Partial traced categories (Heghverdi, Scott, Malherbe, Selinger)
- Functorial dagger (Milius, Litak)
SLIDE 3
Context
SLIDE 4
Guarded Fixpoints: Overview
guarded traced categories guarded iteration guarded Elgot monads completely iterative monads process algebra examples (complete) Elgot monads domain-enriched examples guarded recursion topos of trees, total Conway recursion, complete metric spaces 8-dimensional Hilbert spaces
SLIDE 5 Guarded Fixpoints: Overview
FoSSaCS17: G., Schr¨
Rauch, Pir´
and Unguarded Iteration
guarded traced categories guarded iteration guarded Elgot monads completely iterative monads process algebra examples (complete) Elgot monads domain-enriched examples guarded recursion topos of trees, total Conway recursion, complete metric spaces 8-dimensional Hilbert spaces
:-congruent retraction
SLIDE 6 Guarded Fixpoints: Overview
FoSSaCS17: G., Schr¨
Rauch, Pir´
and Unguarded Iteration FoSSaCS18: G., Schr¨
Traced Categories
guarded traced categories guarded iteration guarded Elgot monads completely iterative monads process algebra examples (complete) Elgot monads domain-enriched examples guarded recursion topos of trees, total Conway recursion, complete metric spaces 8-dimensional Hilbert spaces
:-congruent retraction
SLIDE 7
Unguarded Iteration on Monads
SLIDE 8
One Typical Scenario
fac n “ if n ą 0 then n ˚ facpn ´ 1q else 1
SLIDE 9 One Typical Scenario
fac n “ if n ą 0 then n ˚ facpn ´ 1q else 1 Factorial (Recursively) fac : N á N “ ´ pr, gq ÞÑ λn. if n ą 0 then n ˚ gpn ´ 1q else r ¯
:p1q
where p-
- q: is the least fixpoint of g ÞÑ f ˝ xid, gy. Alternatively,
Factorial (Iteratively) fac n “ ´ pk, iq ÞÑ if k ą 0 then inrpk ´ 1, k ˚ iq else pinl iq ¯: pn, 1q where p-
- q: is the least fixpoint of g ÞÑ rid, gs ˝ f
SLIDE 10
Iteration v.s. Recursion
Iteration is dual to (call by name) recursion: f : Y ˆ X á X f: : Y á X (rec) f : X á Y ` X f : : X á Y (iter) E.g. X á Y is the space of partial functions X Ñ YK on Set More generally, X á Y is X Ñ TY where T is a monad
SLIDE 11 Another Typical Scenario
Given an alphabet of actions A “ ta, bu, equations x1 “ a. px2 ` x3q x2 “ a. x1 ` b. x3 x3 “ a. x1 ` specify processes x1, x2, x3 of basic process algebra (BPA) We can think of them as a map X Ñ Pωptu ` ΣXq where X “ tx1, x2, x3u, Σ “ A ˆ p-
- q, and solve them by finding the
unique X Ñ TΣtu in the domain of possibly non-wellfounded trees TΣtu “ νγ. Pωptu ` A ˆ γq (final coalgebra). The original system must be guarded. An unguarded specification, e.g. x “ x may have arbitrary solutions
:Rutten and Turi 1994, Initial algebra and final coalgebra semantics for concurrency
SLIDE 12
Unguarded Iteration
In order to solve an unguarded system like x1 “ x2 ` a. px2 ` x1q x2 “ x1 ` a. x1 ` b. x2 we first need to guard it to obtain x1 “ a. px2 ` x1q x2 “ a. x1 ` b. x2 and solve the result. Equations like x “ x must be replaced by x “ ∅ where ∅ is unproductive divergence This induces a notion of iteration which is neither least nor unique
SLIDE 13 Why Trees Can Not Be (Obviously) Ordered
Convexity Issue: a partial order would identify processes a.a.∅ ` ∅ and a.a.∅ ` a.∅ ` ∅. For ⊑: a.a.∅ ` ∅ “ a.a.∅ ` ∅ ` ∅ ⊑ a.a.∅ ` a.∅ ` ∅ (monotonicity of ` and idempotence of `) For ⊒: a.a.∅ ⊑ a.a.∅ ∅ ⊑ a.∅ a.∅ ⊑ a.a.∅ pmonot. a.´q ∅ ⊑ ∅ a.a.∅ ` a.∅ ` ∅ ⊑ a.a.∅ ` a.a.∅ ` ∅
a.a.∅ ` a.∅ ` ∅ ⊑ a.a.∅ ` ∅
SLIDE 14 Monads
Definition (Monad) A monad over a category C is given by a Kleisli triple T “ pT, η, -
where
- T is an endomap on |C|
- η is a family of morphisms ηX : X Ñ TX, called monad unit
- p-
- q‹ assigns to each f : X Ñ TY a morphism f ‹ : TX Ñ TY
and the following laws hold: η‹ “ id f ‹ ˝ η “ f pf ‹ ˝ gq‹ “ f ‹ ˝ g ‹ This means that the hom-sets HompX, TY q form a category (Kleisli category) under Kleisli composition f ˛ g “ f ‹ ˝ g and ηX P HompX, TXq
SLIDE 15 ω-Continuous Monads
Definition (ω-Continuous Monad) A monad T is ω-continuous if its Kleisli category is enriched over ω-complete partial orders with bottom K and (nonstrict) continuous maps, and f ˛ K “ K K ˝ h “ K For ω-continuous monads we can define iteration f : X Ñ TpY ` Xq f : : X Ñ TY and the lfp of g ÞÑ rη, gs ˛ f Examples TX “ X ` 1 (partiality), TX “ PX (nondeterminism), TX “
( (sub-probability), etc.
SLIDE 16 Axioms for Iteration: Conway Operators
Let T be a monad with an iteration operator -
- : satisfying fixpoint identity
f : “ rη, f :s ˛ f . It is called a Conway operator if it additionally satisfies Dinaturality: g h
X X Y Z Y
= g h g
X Y Z Z Y X Y
Codiagonal: g
X Y X X
= g
X Y X X
SLIDE 17 Axioms for Iteration: Naturality and Uniformty
Naturality is a form of coherence: f g
X X Y Z
= f g
X X Y Z
Uniformity is the only non-equation axiom: h f
Z X Y X
“ g h
Z Z Y X
ó h f
Z X Y X
“ g
Z Z Y
SLIDE 18 Axioms for Iteration: Elgot Monads
Definition A monad T is a Elgot monad if it is equipped with a Conway iteration
- perator, which is natural and uniform
Theorem (´ Esik and Goncharov 2016) Dinaturality is derivable Theorem (Goncharov, Rauch, and Schr¨
ω-continuous monads are Elgot monads Theorem (Goncharov, Rauch, and Schr¨
Let T be a Elgot monad and Σ and endofunctor. Then final coalgebras TΣX “ νγ. TpX ` Σγq defines a Elgot monad TΣ uniquely coherently extending T
SLIDE 19
Guared Iteration on Monads
SLIDE 20 Guarded v.s. Unguarded
Using the fact that T is Elgot we can solve both guarded and unguarded definitions over TΣ. Generally, we have: Canonical fixpoints Unique fixpoints Partial fixpoint operators
- Total fixpoint operators
- —
If T is not Elgot (e.g. nonempty powerset) we can no longer compute solutions of unguarded definitions (think of x “ x), but we still can compute solutions of guarded ones More generally, guardedness does not guarantee uniqueness, e.g. under infinite trace semantics x “ a.x ` 1 has both a‹ and a‹ ` aω as solutions
SLIDE 21 Abstract Guardedness
So, what means “guardedness” anyhow? f : X Ñ Y ` X f : : X Ñ Y f : X ˆ Y Ñ X f: : Y Ñ X Can we make sense of this intuition? :
a
X Z Y
SLIDE 22 Abstract Guardedness
So, what means “guardedness” anyhow? f : X Ñ Y ` X f : : X Ñ Y f : X ˆ Y Ñ X f: : Y Ñ X Can we make sense of this intuition? : Pivotal Idea: Keep the notion
- f guardedness independent of
fixpoint calculations
a
X Z Y
SLIDE 23 Abstract Guardedness for Monads
Abstract guardedness is a relation connecting f : X Ñ TY with coproduct summands σ : Y 1 Y in judgements f : X Ñσ TY , satisfying (vac`) f : X Ñ Z inl f : X Ñinr Z ` Y (par`) f : X Ñσ Z f : Y Ñσ Z rf , gs : X ` Y Ñσ Z (cmp`) f : X Ñinr Y ` Z g : Y Ñσ V h : Z Ñ V rg, hs ˝ f : X Ñσ V For example, X Ñ2 TΣpY ` Zq “ νγ. TppY ` Zq ` Σγq iff
- ut f “ Tpinl `idqg : X Ñ TppY ` Zq ` ΣTΣpY ` Zqq
for suitable g : X Ñ TpY ` ΣTΣpY ` Zqq
SLIDE 24 Guarded Iteration Laws
Iteration: f
X X Y
“
f f
X X X Y Y
Naturality: f g
X X Y Z
“
f g
X X Y Z
SLIDE 25 Guarded Iteration Laws (Continued)
Codiagonal: g
X Y X X
“
g
X Y X X
Uniformity:
h f
Z X Y X
“
g h
Z Z Y X
SLIDE 26 Some Results
- Guarded and unguarded iteration are instances of abstract
guardedness
- Every monad is “vacuously guarded”
- (Unique) guarded iteration propagates along T ÞÑ νγ. Tp-
- `Σγq
- Dinaturality and other laws are derivable
- Guarded iteration is the exact dual of guarded recursion
SLIDE 27 Example: Guarded Recursion
Consider the category CMS of inhabited complete metric spaces and non-expansive maps Let f : X ˆ Y Ñ Z be guarded in Y if for all x P X, f px, -
This makes CMS into a guarded traced monoidal category (fixpoints calculated via Banach’s fixpoint theorem)
SLIDE 28
Going Monoidal
SLIDE 29
Going Monoidal
(We only consider symmetric monoidal categories, think of b “ `, ˆ) Identity id: Composition g ˝ f : Tensor g b f : Symmetry:
SLIDE 30 Trace
Trace pf : U b A Ñ B b Uq ÞÑ ptr U
A,Bf : A Ñ Bq
is the “generalized fixpoint operator”
SLIDE 31 Iteration and Recursion
Iteration and recursion are typically viewed as corner cases:
- With b “ `, we obtain pf : A Ñ B ` Aq: “ trpf ˝ ∇q:
A A B
- With b “ ˆ, we obtain pf : A ˆ B Ñ Aq: “ trp∆ ˝ f q:
A A B
SLIDE 32
Guarded Traced Categories
SLIDE 33 Partially Guarded Morphisms
A monoidal category is guarded if it is equipped with distinguished families Hom‚pA b B, C b Dq Ď HompA b B, C b Dq, drawn as follows
A C D B
where
- A is unguarded input
- B is guarded input
- C is unguarded output
- D is guarded output
The idea is to allow feedback only on pA, Dq, which we call a guardedness profile of f . Hence we introduce axioms:
SLIDE 34
The Axioms
SLIDE 35
Guarded Traced Categories
A guarded category is guarded traced if it is equipped with a trace: satisfying a collection of axioms adapted from the standard case Guarded iteration/recursion operators are obtained analogously to the standard unguarded case
SLIDE 36
Towards Coherence
SLIDE 37
Structural Guardedness v.s. Geometric Guardedness
For guarded categories we have coherence of structural and geometric notions: a term is in Hom‚pA b B, C b Dq iff in the corresponding diagram every path from A to D runs through some atomic box via an unguarded input and a guarded output After adding traces, this is no longer true: Geometrically, this is OK but there is no structured way to derive it!
SLIDE 38
Structural Guardedness v.s. Geometric Guardedness
For guarded categories we have coherence of structural and geometric notions: a term is in Hom‚pA b B, C b Dq iff in the corresponding diagram every path from A to D runs through some atomic box via an unguarded input and a guarded output After adding traces, this is no longer true: Geometrically, this is OK but there is no structured way to derive it! But: The are no natural examples when this actually materializes
SLIDE 39 Failure of Coherence
Differently put, the circuit is not in the free guarded traced category Possible ways to resolve it
- 1. Strengthen the geometric guardedness criterion
- 2. Weaken the definition of the guarded traced category
- 3. Do both 1. and 2.
Both approached have issues we fail to resolve, as of today
SLIDE 40 The Diversity of Further Avenues
- Resolve the pressing coherence issue ñ possibly update the notion
- f guarded traced category
- Rebase on colored props, cover non-monoidal examples
- Deepen the theory of guarded traced categories: expressiveness,
completeness (w.r.t. Hilbert spaces?), Int-construction
- Metalanguages for guarded iteration and recursion
- Comonadic guarded recursion (with Tarmo)
SLIDE 41
Questions?
SLIDE 42 References I
References
- S. Abramsky, R. Blute, and P. Panangaden. Nuclear and trace ideals in
tensored ˚-categories. J. Pure Appl. Algebra, 143:3–47, 1999. Zolt´ an ´ Esik and Sergey Goncharov. Some remarks on Conway and iteration theories. CoRR, abs/1603.00838, 2016. URL http://arxiv.org/abs/1603.00838. Sergey Goncharov, Christoph Rauch, and Lutz Schr¨
recursion on coinductive resumptions. In Mathematical Foundations of Programming Semantics, MFPS 2015, ENTCS, 2015.
SLIDE 43 References II
Sergey Goncharov, Julian Jakob, and Renato Neves. A semantics for hybrid iteration. In Sven Schewe and Lijun Zhang, editors, 29th International Conference on Concurrency Theory (CONCUR 2018),
Stefan Milius and Tadeusz Litak. Guard your daggers and traces: On the equational properties of guarded (co-)recursion. In Fixed Points in Computer Science, FICS 2013, volume 126 of EPTCS, pages 72–86, 2013. Jan Rutten and Daniele Turi. Initial algebra and final coalgebra semantics for concurrency. pages 530–582. Springer-Verlag, 1994.
SLIDE 44 Some (Easy) Observations
- There is a greatest notion of guardedness,
Hom‚pA b B, C b Dq “ HompA b B, C b Dq
- There is a least (vacuous) notion of guardedness,
g h
- Axioms are stable under 1800-rotations, hence C is guarded iff Cop is
guarded, i.e. we maintain duality of recursion and iteration
SLIDE 45 Ideal Guardedness
A particularly common case is ideal guardedness A guarded ideal is a family Hom◮pX, Y q Ď HompX, Y q closed under finite tensors and composition with any morphism on both sides The general form of a partially guarded morphism over a guarded ideal is
1 1 1
n n n
p q
SLIDE 46 Ideal Guardedness
A particularly common case is ideal guardedness A guarded ideal is a family Hom◮pX, Y q Ď HompX, Y q closed under finite tensors and composition with any morphism on both sides The general form of a partially guarded morphism over a guarded ideal is
1 1 1
n n n
p q
In the (co-)Cartesian case this simplifies greatly, generating standard notions, e.g. f : X Ñ2 Y ` Z iff X
h
Ý Ý Ñ Y ` W
rinl,gs
Ý Ý Ý Ý Ý Ñ Y ` Z with some g P Hom◮pW , Y ` Zq and h : X Ñ Y ` W
SLIDE 47 Unguarded Recursion as Guarded Recursion
We consider the following axioms:
A B C A B
g
C B A C B
g
- Squaring (is not a property of Conway recursion but a property of
Conway uniform recursion):
A B A A B A A B
Theorem: There is a bijective correspondence between guarded squarable dinatural operators on C and unguarded squarable dinatural on CT
‹
SLIDE 48 Unguarded Recursion as Guarded Recursion
- A standard way to do recursion with monads is in the category CT
‹
with T-algebras as objects and C-morphisms of carriers as morphisms Example: C = point-free dcpo’s and continuous functions; T = lifting monad X ÞÑ XK
- Alternatively, following [Milius and Litak, 2013], we consider guarded
recursion operators on C where C is ideally guarded over Hom◮pX, Y q “ tf ˝ η | f : TX Ñ Y u Example: with C and T as above, we allow only recursion
SLIDE 49 More Examples..
- The topos of trees (guardedness by later-operator)
- Non-pointed order-enriched monads
(e.g. non-empty powerset, probability distributions)
- Hybrid iteration semantics:
(“guardedness” = “progressiveness”)
1 2 3 4 0.5 1
:Goncharov, Jakob, and Neves 2018, A Semantics for Hybrid Iteration
SLIDE 50
Guarded Traces in Hilbert Spaces
SLIDE 51 Finite-Dimensional Hilbert Spaces
Recall the multiplicative compact closed category of relations pRel, ˆ, 1q Relations can be thought of as Boolean matrices, with transposition p-
and (unparamerized) trace being the trace of the square matrices tr ¨ ˚ ˝ b11 ¨ ¨ ¨ b1n ¨ ¨ ¨ ¨ ¨ ¨ ¨ ¨ ¨ bn1 ¨ ¨ ¨ bnn ˛ ‹ ‚“ ÿ
i
bii Analogously, linear operators on finite-dimensional Hilbert spaces can be represented as matrices over a field – we stick to the field of reals Thus, Hilbert spaces are compact closed with tensors pf b gqpx b yq “ f pxq b gpyq, R as tensor unit, X ‹ “ X on objects, f ‹ as the unique adjoint operator xf pxq, yy “ xx, f ‹pyqy and unit/counit induced by inner products
SLIDE 52 Infinite-Dimensional Hilbert Spaces
More generally, Hilbert spaces are vector spaces with inner products, complete as a normed spaces under the induced norm | |x| | “ a xx, xy Category Hilb:
- Objects are Hilbert spaces
- Morphisms are bounded linear operators, i.e. |
|f pxq| | ď c ¨ | |x| | for a fixed c and every x
- Monoidal structure as before
- Adjointness for operators still works and pf b gq‹ “ f ‹ b g ‹,
f ‹‹ “ f , id‹ “ id, pf ˝ gq‹ “ g ‹ ˝ f ‹
SLIDE 53 Infinite-Dimensional Hilbert Spaces
More generally, Hilbert spaces are vector spaces with inner products, complete as a normed spaces under the induced norm | |x| | “ a xx, xy Category Hilb:
- Objects are Hilbert spaces
- Morphisms are bounded linear operators, i.e. |
|f pxq| | ď c ¨ | |x| | for a fixed c and every x
- Monoidal structure as before
- Adjointness for operators still works and pf b gq‹ “ f ‹ b g ‹,
f ‹‹ “ f , id‹ “ id, pf ˝ gq‹ “ g ‹ ˝ f ‹ But there is no (total) trace, because the trace formula trpf q “ ř
ixf peiq, eiy may diverge (teiui is any orthonormal basis)!
E.g. it diverges with f “ id : X Ñ X with infinite-dimensional X
SLIDE 54 Nontrivial Trace from Vacuous Guardedness
[Abramsky, Blute, and Panangaden, 1999] already give a construction of unparameterized partial traces in Hilb via nuclear ideals. We generalize and reconcile it with our approach by equipping Hilb with the vacuous guardedness structure:
g h g h
What is nontrivial though is that this is independent of the decomposition into g and h! Morphisms f : X Ñ X from the induced guarded ideal are precisely those for which trpf q “ ř
ixf peiq, eiy absolutely converges for any choice of an
- rthonormal basis peiqi; the sum is then independent of the basis