Recursive Program Schemes with Effects Daniel Schwencke, 28th March - - PowerPoint PPT Presentation
Recursive Program Schemes with Effects Daniel Schwencke, 28th March - - PowerPoint PPT Presentation
Recursive Program Schemes with Effects Daniel Schwencke, 28th March 2010 Outline 1 Introduction 2 Preliminaries and Definitions 3 A Solution Theorem 4 Future Work D. Schwencke: Recursive Program Schemes with Effects RPSs Idea: define new
Outline
1 Introduction 2 Preliminaries and Definitions 3 A Solution Theorem 4 Future Work
- D. Schwencke: Recursive Program Schemes with Effects
RPSs
Idea: define new operations using given operations and recursion Definition (RPS without effects, classical) disjoint finite sets F – given operation symbols Φ – new operation symbols X – variables φ(x1, . . . , xn) ≈ tφ(x1, . . . , xn) for all φ ∈ Φn, tφ term in F ∪ Φ
- D. Schwencke: Recursive Program Schemes with Effects
RPSs
Idea: define new operations using given operations and recursion Definition (RPS without effects, classical) disjoint finite sets F – given operation symbols Φ – new operation symbols X – variables φ(x1, . . . , xn) ≈ tφ(x1, . . . , xn) for all φ ∈ Φn, tφ term in F ∪ Φ Example ([Milius Moss 06]) φ(x) ≈ f (x, φ(gx)) ψ(x) ≈ f (φ(gx), ggx)
- D. Schwencke: Recursive Program Schemes with Effects
RPSs
Idea: define new operations using given operations and recursion Definition (RPS without effects, classical) disjoint finite sets F – given operation symbols Φ – new operation symbols X – variables φ(x1, . . . , xn) ≈ tφ(x1, . . . , xn) for all φ ∈ Φn, tφ term in F ∪ Φ Example ([Milius Moss 06]) φ(x) ≈ f (x, φ(gx)) ψ(x) ≈ f (φ(gx), ggx) Generalising category-theoretic approach in [Ghani L¨ uth de Marchi 03, Milius Moss 06]
- D. Schwencke: Recursive Program Schemes with Effects
ND-RPSs
Idea: add non-deterministic choice on rhs of formal equations special binary operation symbol or ∈ F ∪ Φ terms tφ in F ∪ Φ ∪ {or} see [Arnold Nivat 77]
- D. Schwencke: Recursive Program Schemes with Effects
ND-RPSs
Idea: add non-deterministic choice on rhs of formal equations special binary operation symbol or ∈ F ∪ Φ terms tφ in F ∪ Φ ∪ {or} see [Arnold Nivat 77] Example pow(x) ≈ x or (x · pow(x))
- D. Schwencke: Recursive Program Schemes with Effects
ND-RPSs
Idea: add non-deterministic choice on rhs of formal equations special binary operation symbol or ∈ F ∪ Φ terms tφ in F ∪ Φ ∪ {or} see [Arnold Nivat 77] Example pow(x) ≈ x or (x · pow(x)) More generally: RPSs with effects partiality non-determinism probabilism
- D. Schwencke: Recursive Program Schemes with Effects
A Starting Point
Assumptions (M, ηM, µM) monad on Set H, V finitary Set-functors distributive laws λ : HM → MH and ν : VM → MV ⇒ induced distributive law ρ : (H + V )M → M(H + V )
- D. Schwencke: Recursive Program Schemes with Effects
A Starting Point
Assumptions (M, ηM, µM) monad on Set H, V finitary Set-functors distributive laws λ : HM → MH and ν : VM → MV ⇒ induced distributive law ρ : (H + V )M → M(H + V ) Meaning: M – effect, e. g. + 1, P, D H, V – “signatures” of given/new operations λ, ν, ρ – extension of operations to parameters with effects
- D. Schwencke: Recursive Program Schemes with Effects
A First Lemma
Notation: (F G, ηG, µG) free monad on G universal natural transformation κG : G → F G T monad, σ : G → T. Then σ# : F G → T unique monad morphism such that σ# · κG = σ
- D. Schwencke: Recursive Program Schemes with Effects
A First Lemma
Notation: (F G, ηG, µG) free monad on G universal natural transformation κG : G → F G T monad, σ : G → T. Then σ# : F G → T unique monad morphism such that σ# · κG = σ Lemma If G has free algebras, every distributive law δ : GM → MG induces a distributive law δ′ : F GM → MF G. ⇒ composite monad (MF G, ηMF G · ηG, (µM ∗ µG) · Mδ′F G)
- D. Schwencke: Recursive Program Schemes with Effects
RPSs with Effects
Definition M-RPS e : V → MF H+V guarded if e ≡ V
e0
− → M(HF H+V + Id) ... − → MF H+V (uninterpreted) solution of e e† : V → MF H such that e† = µMF H · M[ηMF H · ηH, e†]# · e
- D. Schwencke: Recursive Program Schemes with Effects
RPSs with Effects
Definition M-RPS e : V → MF H+V guarded if e ≡ V
e0
− → M(HF H+V + Id) ... − → MF H+V (uninterpreted) solution of e e† : V → MF H such that e† = µMF H · M[ηMF H · ηH, e†]# · e Example For pow(x) ≈ x or (x · pow(x)) take M = P, V = Id, H = Id2 eX(x) = {x, x · pow(x)} guarded since x ∈ Id(X) and x · pow(x) ∈ HF H+V X e†
X(x) = {x, x · x, x · (x · x), x · (x · (x · x)), . . . } is a solution
- D. Schwencke: Recursive Program Schemes with Effects
What We Would Like to Prove. . .
Question Does every guarded M-RPS have a (unique) solution?
- D. Schwencke: Recursive Program Schemes with Effects
What We Would Like to Prove. . .
Question Does every guarded M-RPS have a (unique) solution? From H, M, λ and ρ′ we obtain a functor H = H · + Id on [Set, Set];
- D. Schwencke: Recursive Program Schemes with Effects
What We Would Like to Prove. . .
Question Does every guarded M-RPS have a (unique) solution? From H, M, λ and ρ′ we obtain a functor H = H · + Id on [Set, Set]; a monad M = (M · , ηM , µM ) on [Set, Set];
- D. Schwencke: Recursive Program Schemes with Effects
What We Would Like to Prove. . .
Question Does every guarded M-RPS have a (unique) solution? From H, M, λ and ρ′ we obtain a functor H = H · + Id on [Set, Set]; a monad M = (M · , ηM , µM ) on [Set, Set]; a distributive law Λ = [Minl, Minr] · (λ + ηM) : HM → MH;
- D. Schwencke: Recursive Program Schemes with Effects
What We Would Like to Prove. . .
Question Does every guarded M-RPS have a (unique) solution? From H, M, λ and ρ′ we obtain a functor H = H · + Id on [Set, Set]; a monad M = (M · , ηM , µM ) on [Set, Set]; a distributive law Λ = [Minl, Minr] · (λ + ηM) : HM → MH; equivalently, a lifting ¯ H of H to [Set, Set]M;
- D. Schwencke: Recursive Program Schemes with Effects
What We Would Like to Prove. . .
Question Does every guarded M-RPS have a (unique) solution? From H, M, λ and ρ′ we obtain a functor H = H · + Id on [Set, Set]; a monad M = (M · , ηM , µM ) on [Set, Set]; a distributive law Λ = [Minl, Minr] · (λ + ηM) : HM → MH; equivalently, a lifting ¯ H of H to [Set, Set]M; the canonical functor J : [Set, Set] → [Set, Set]M;
- D. Schwencke: Recursive Program Schemes with Effects
What We Would Like to Prove. . .
Question Does every guarded M-RPS have a (unique) solution? From H, M, λ and ρ′ we obtain a functor H = H · + Id on [Set, Set]; a monad M = (M · , ηM , µM ) on [Set, Set]; a distributive law Λ = [Minl, Minr] · (λ + ηM) : HM → MH; equivalently, a lifting ¯ H of H to [Set, Set]M; the canonical functor J : [Set, Set] → [Set, Set]M; a monad HF H+V with distributive law over M.
- D. Schwencke: Recursive Program Schemes with Effects
Second Order Substitution with Effects
Definition For a guarded M-RPS e let ¯ e be the unique monad mor- phism such that the diagram commutes: H + V
κH+V
- [Jinl·HηH+V ,e0]
M(HF H+V + Id)
F H+V
¯ e
- D. Schwencke: Recursive Program Schemes with Effects
Second Order Substitution with Effects
Definition For a guarded M-RPS e let ¯ e be the unique monad mor- phism such that the diagram commutes: H + V
κH+V
- [Jinl·HηH+V ,e0]
M(HF H+V + Id)
F H+V
¯ e
- Remarks
¯ e performs second order substitution with effect handling ¯ e is an ¯ H-coalgebra
- D. Schwencke: Recursive Program Schemes with Effects
Sufficient Conditions for a Solution
Notation: φH = µH · κHF H : HF H → F H
- D. Schwencke: Recursive Program Schemes with Effects
Sufficient Conditions for a Solution
Notation: φH = µH · κHF H : HF H → F H Two facts: [φH, ηH] : HF H → F H is initial H-algebra.
- D. Schwencke: Recursive Program Schemes with Effects
Sufficient Conditions for a Solution
Notation: φH = µH · κHF H : HF H → F H Two facts: [φH, ηH] : HF H → F H is initial H-algebra. If
1 J[φH, ηH]−1 : F H → ¯
HF H is final ¯ H-coalgebra and
2 the unique ¯
H-coalgebra homomorphism h : F H+V → MF H between ¯ e and J[φH, ηH]−1 is a monad morphism
then h · κH+V · inr : V → MF H is a solution of e.
- D. Schwencke: Recursive Program Schemes with Effects
A Result for CPO-enriched SetM
Assumptions SetM CPO-enriched with strict composition λ strict ¯ H locally continuous
- D. Schwencke: Recursive Program Schemes with Effects
A Result for CPO-enriched SetM
Assumptions SetM CPO-enriched with strict composition λ strict ¯ H locally continuous Theorem Under the above assumptions, every guarded M-RPS has a solution.
- D. Schwencke: Recursive Program Schemes with Effects
A Result for CPO-enriched SetM (ctd.)
Theorem Under the above assumptions, every guarded M-RPS has a solution. Proof.
1 J[φH, ηH]−1 final ¯
H-coalgebra: use techniques of [Hasuo Jacobs Sokolova 07]
- D. Schwencke: Recursive Program Schemes with Effects
A Result for CPO-enriched SetM (ctd.)
Theorem Under the above assumptions, every guarded M-RPS has a solution. Proof.
1 J[φH, ηH]−1 final ¯
H-coalgebra: use techniques of [Hasuo Jacobs Sokolova 07]
2 h monad morphism: unit easy, multiplication very technical
- D. Schwencke: Recursive Program Schemes with Effects
A Result for CPO-enriched SetM (ctd.)
Theorem Under the above assumptions, every guarded M-RPS has a solution. Proof.
1 J[φH, ηH]−1 final ¯
H-coalgebra: use techniques of [Hasuo Jacobs Sokolova 07]
2 h monad morphism: unit easy, multiplication very technical
Examples ([Milius Palm S 09]) Monads + 1, P or D with analytic H and canonical λ
- D. Schwencke: Recursive Program Schemes with Effects
Future Work
1 uniqueness of solutions
- D. Schwencke: Recursive Program Schemes with Effects
Future Work
1 uniqueness of solutions 2 generalise M-RPS-definition to allow CIMs
[Arnold Nivat 77]-setting category-theoretic environment monad (−)E
- D. Schwencke: Recursive Program Schemes with Effects
Future Work
1 uniqueness of solutions 2 generalise M-RPS-definition to allow CIMs
[Arnold Nivat 77]-setting category-theoretic environment monad (−)E
3 interpreted solutions using [Milius Palm S 09]
- D. Schwencke: Recursive Program Schemes with Effects
Literature
◮ A. Arnold and M. Nivat. Non Deterministic Recursive Program Schemes. In Fundamentals of Computation Theory – Proc. Int. Conf. Pozna´ n-K´
- rnik,
Lecture Notes in Comput. Sci. 56 (1977), pp. 12–21. ◮ N. Ghani, C. L¨ uth and F. de Marchi. Solving Algebraic Equations using Coalgebra.
- Vol. 37 of Theor. Inform. Appl. (2003), pp. 301–314.
◮ I. Hasuo, B. Jacobs and A. Sokolova. Generic Trace Semantics via Coinduction.
- Vol. 3 of Log. Methods Comput. Sci. (2007), pp. 1–36.
◮ S. Milius and L. S. Moss. The Category Theoretic Solution of Recursive Program Schemes.
- Vol. 366 of Theoret. Comput. Sci. (2006), pp. 3–59.
◮ S. Milius, T. Palm and D. Schwencke. Complete Iterativity for Algebras with Effects. In: A. Kurz, M. Lenisa, A. Tarlecki (eds.), Proc. CALCO Udine, Lecture Notes in
- Comput. Sci. 5728 (2009), pp. 34–48.
- D. Schwencke: Recursive Program Schemes with Effects
Thank you. . . . . . for your attention!
schwencke@iti.cs.tu-bs.de
- D. Schwencke: Recursive Program Schemes with Effects