basic operational preorders for algebraic effects in
play

Basic operational preorders for algebraic effects in general, and - PowerPoint PPT Presentation

Basic operational preorders for algebraic effects in general, and for combined probability and nondeterminism in particular Computer Science Logic 2018 Aliaume Lopez Alex Simpson September 7, 2018 Context Semantics Three approaches to


  1. Basic operational preorders for algebraic effects in general, and for combined probability and nondeterminism in particular Computer Science Logic 2018 Aliaume Lopez Alex Simpson September 7, 2018

  2. Context

  3. Semantics Three approaches to semantics Operational describe evaluation steps Denotational compositional mathematical model Axiomatics axiomatise behaviour Contextual preorder 1. Tied to operational semantics 2. P 1 ⊑ ctxt P 2 iff in any context C , the behaviour of C [ P 1 ] approximates the behaviour of C [ P 2 ]. 1

  4. ”Generic Operational Metatheory” Ideas [Johann et al., 2010a] Why ? Operational semantics works great but needs to be adapted in each case 2

  5. ”Generic Operational Metatheory” Ideas [Johann et al., 2010a] Why ? Operational semantics works great but needs to be adapted in each case Objective ? Give a generic operational semantics for a large class of languages 2

  6. ”Generic Operational Metatheory” Ideas [Johann et al., 2010a] Why ? Operational semantics works great but needs to be adapted in each case Objective ? Give a generic operational semantics for a large class of languages How ? 1. Parametrize with a signature of effect operations Σ 2. Reduce a program to an effect tree 3. Define a � preorder on Trees Nat (!) 2

  7. ”Generic Operational Metatheory” Ideas [Johann et al., 2010a] Why ? Operational semantics works great but needs to be adapted in each case Objective ? Give a generic operational semantics for a large class of languages How ? 1. Parametrize with a signature of effect operations Σ 2. Reduce a program to an effect tree 3. Define a � preorder on Trees Nat (!) Result ? Generic operational definition of contextual preorder 2

  8. Contextual preorders Morris-style Input: A peorder � for type Nat Output: P 1 ⊑ ctxt P 2 ⇐ ⇒ ∀ C [ − ] context , | C [ P 1 ] | � | C [ P 2 ] | (1) 3

  9. Contextual preorders Morris-style Input: A peorder � for type Nat Output: P 1 ⊑ ctxt P 2 ⇐ ⇒ ∀ C [ − ] context , | C [ P 1 ] | � | C [ P 2 ] | (1) GOM Input: A peorder � for type Nat Output: A logical relation (!) on programs that characterises contextual preorder (Morris-Style) 3

  10. Effect trees Example of trees Let Σ = { pr } be a signature containing one binary effect construction. pr pr ⊥ . 1 . . Properties Trees Nat is a DCPO and a continuous Σ-algebra 4

  11. Preorders � What are the conditions on � in GOM ? Admissible If t i � t ′ i and ( t i ) i , ( t ′ i ) i are an ascending chains then � � t ′ t i � (2) i i i Compatible with least upper bounds Compositional If t � t ′ and ρ � ρ ′ (pointwise) then t ρ � t ′ ρ ′ Compositional reasoning is possible 5

  12. Contributions General Identify three different ways to produce well-behaved preorders 6

  13. Contributions General Identify three different ways to produce well-behaved preorders Specific Examine how they apply to a specific signature Σ pr / nd = { pr , or } (3) 6

  14. Contributions General Identify three different ways to produce well-behaved preorders Specific Examine how they apply to a specific signature Σ pr / nd = { pr , or } (3) Coincidence Prove that the three ways of defining � pr / nd lead to the same contextual preorder 6

  15. Well-behaved preorders

  16. Methods for defining preorders Following three common approaches to semantics • From some operational construction � op • From a denotation � · � � den • From axiomatic definitions � ax 7

  17. Combined scheduler Randomised Algorithms with Scheduler Σ coin “pr”, demon “or” � capture the behaviour ... and satisfies the requirements Example of program or (1 pr 2) or 3 pr 3 1 2 8

  18. Operationally defined preorders

  19. The natural operations ... ... MDP Compare Markov Decision Processes pointwise, where a point is a goal set X ⊆ Nat : t � badOp t ′ ⇐ π E π ( t ′ ∈ X ) π E π ( t ∈ X ) ≤ inf ⇒ ∀ X ⊆ Nat , inf 9

  20. The natural operations ... ... Counter example The issue 1. The following trees are equated pr or ≃ badOp pr or or 3 1 2 1 3 2 3 2. If compositionality holds for � badOp then x or( y pr z ) = ( x or y ) pr( x or z ) (4) 3. Which is does not hold for ≃ badOp (easy substitution) 4. And should never hold [Mislove et al., 2004] 10

  21. The solution Compare Markov Decision Processes pointwise, where a point is a payoff function h : Nat → R + : t � op t ′ ⇐ π E π ( h ( t )) ≤ inf π E π ( h ( t ′ )) ⇒ ∀ h : Nat → R + , inf Proposition The preorder � op is admissible and compositional Remark The proof requires some topological arguments... 11

  22. Denotationally defined preorders

  23. Denotationally defined preorders The idea Input 1. Continuous Σ-algebra D 2. � · � : N ⊥ → D continuous Σ-algebra homomorphism Output The preorder � den t � den t ′ ⇐ ⇒ � t � ≤ D � t ′ � j (5) N D i � · � Trees( N ) 12

  24. Denotationally defined preorders Properties of � den 1. Automatically admissible (continuity) 2. Automatically compatible (Σ-algebra) 3. Not always compositional ! 13

  25. Denotationally defined preorders Factorisation The map j : N → D is said to have the factorisation property if, for every function f : N → D , there exists a continuous homomorphism h f : D → D such that f = h f ◦ j . j h f D D N f Idea We then have � t σ � = h σ ( � t � ) which is continuous in t with a fixed σ . 14

  26. Well behaved denotational preorder Proposition If j : N → D has the factorisation property then the relation � D is substitutive, hence it is an admissible compositional precongruence. In practice [Proposition 16] It is usually not necessary to prove the factorisation property directly. Instead it holds as a consequence of the continuous algebra D and map j : Nat → D being derived from a suitable monad. 15

  27. Applying to the running example Using Kegelpsitze [Keimel and Plotkin, 2017] V ≤ 1 X ω CPO of (discrete) subprobability distributions over X . SV ≤ 1 X ω CPO of nonempty Scott-compact convex upper-closed subsets of V ≤ 1 X ordered by reverse inclusion ⊇ . or( A , B ) = Conv( A ∪ B ) (6) � 1 2 a + 1 � pr( A , B ) = 2 b | a ∈ A , b ∈ B (7) 16

  28. Axiomatically defined preorders

  29. Generic definition Theories Equation e ≤ e ′ with e , e ′ ∈ Trees(Vars) Clause (Infinitary) Horn-Clause of equations Theory Set of Horn-Clauses 17

  30. Generic definition Theories Equation e ≤ e ′ with e , e ′ ∈ Trees(Vars) Clause (Infinitary) Horn-Clause of equations Theory Set of Horn-Clauses Axiomatically defined preorder Definition There exists a smallest admissible preorder � ax that models T Property � ax is compositional 17

  31. Axioms for Pr and Nd Bot: ⊥ ≤ x 18

  32. Axioms for Pr and Nd Bot: ⊥ ≤ x Prob: x pr x = x , x pr y = y pr x , ( x pr y ) pr ( z pr w ) = ( x pr z ) pr ( y pr w ) Appr: x pr y ≤ y = ⇒ x ≤ y (!) 18

  33. Axioms for Pr and Nd Bot: ⊥ ≤ x Prob: x pr x = x , x pr y = y pr x , ( x pr y ) pr ( z pr w ) = ( x pr z ) pr ( y pr w ) Appr: x pr y ≤ y = ⇒ x ≤ y (!) Nondet: x or x = x , x or y = y or x , x or ( y or z ) = ( x or y ) or z Dem: x or y ≥ x 18

  34. Axioms for Pr and Nd Bot: ⊥ ≤ x Prob: x pr x = x , x pr y = y pr x , ( x pr y ) pr ( z pr w ) = ( x pr z ) pr ( y pr w ) Appr: x pr y ≤ y = ⇒ x ≤ y (!) Nondet: x or x = x , x or y = y or x , x or ( y or z ) = ( x or y ) or z Dem: x or y ≥ x Dist: x pr ( y or z ) = ( x pr y ) or ( x pr z ) (!) 18

  35. The coincidence theorem

  36. Coincidence For probability and non-determinism � op = � den = � ax Proof sketch 1. Equality on trees without or nodes 2. Equality for trees with finite number of or nodes (!) 3. General equality using finite approximations and admissibility 19

  37. Summary and limitations

  38. Summary and limitations What has been done • Denotational and Axiomatic definitions of preorders • Applied to a specific signature Σ = { pr , or } Limitations • Some effects are not algebraic • The preorder for countable non-determinism is not admissible Thank You! 20

  39. References i Dal Lago, U., Gavazzo, F., and Blain Levy, P. (2017). Effectful Applicative Bisimilarity: Monads, Relators, and Howe’s Method (Long Version). ArXiv e-prints . Goubault-Larrecq, J. (2016). Isomorphism theorems between models of mixed choice. Mathematical Structures in Computer Science . To appear. Johann, P., Simpson, A., and Voigtl¨ ander, J. (2010a). A generic operational metatheory for algebraic effects. In Logic in Computer Science (LICS), 2010 25th Annual IEEE Symposium on , pages 209–218. IEEE.

  40. References ii Johann, P., Simpson, A., and Voigtlnder, J. (2010b). A generic operational metatheory for algebraic effects. In 2010 25th Annual IEEE Symposium on Logic in Computer Science , pages 209–218. Keimel, K. and Plotkin, G. D. (2017). Mixed powerdomains for probability and nondeterminism. Logical Methods in Computer Science , 13(1). Mislove, M., Ouaknine, J., and Worrell, J. (2004). Axioms for probability and nondeterminism. Electronic Notes in Theoretical Computer Science , 96:7–28. Plotkin, G. and Power, J. (2001). Adequacy for algebraic effects. In International Conference on Foundations of Software Science and Computation Structures , pages 1–24. Springer.

Recommend


More recommend