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

basic operational preorders for algebraic effects in
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 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

slide-2
SLIDE 2

Context

slide-3
SLIDE 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. P1 ⊑ctxt P2 iff in any context C, the behaviour of C[P1]

approximates the behaviour of C[P2].

1

slide-4
SLIDE 4

”Generic Operational Metatheory” Ideas

[Johann et al., 2010a] Why ? Operational semantics works great but needs to be adapted in each case

2

slide-5
SLIDE 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

slide-6
SLIDE 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 TreesNat

(!)

2

slide-7
SLIDE 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 TreesNat

(!) Result ? Generic operational definition of contextual preorder

2

slide-8
SLIDE 8

Contextual preorders

Morris-style Input: A peorder for type Nat Output: P1 ⊑ctxt P2 ⇐ ⇒ ∀C[−] context, |C[P1]| |C[P2]| (1)

3

slide-9
SLIDE 9

Contextual preorders

Morris-style Input: A peorder for type Nat Output: P1 ⊑ctxt P2 ⇐ ⇒ ∀C[−] context, |C[P1]| |C[P2]| (1) GOM Input: A peorder for type Nat Output: A logical relation (!) on programs that characterises contextual preorder (Morris-Style)

3

slide-10
SLIDE 10

Effect trees

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

4

slide-11
SLIDE 11

Preorders

What are the conditions on in GOM ? Admissible If ti t′

i and (ti)i, (t′ i )i are an ascending chains then

  • i

ti

  • i

t′

i

(2) Compatible with least upper bounds Compositional If t t′ and ρ ρ′ (pointwise) then tρ t′ρ′ Compositional reasoning is possible

5

slide-12
SLIDE 12

Contributions

General Identify three different ways to produce well-behaved preorders

6

slide-13
SLIDE 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

slide-14
SLIDE 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

slide-15
SLIDE 15

Well-behaved preorders

slide-16
SLIDE 16

Methods for defining preorders

Following three common approaches to semantics

  • From some operational construction
  • p
  • From a denotation ·

den

  • From axiomatic definitions

ax

7

slide-17
SLIDE 17

Combined scheduler

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

  • r

pr 1 2 3

8

slide-18
SLIDE 18

Operationally defined preorders

slide-19
SLIDE 19

The natural operations ... ... MDP

Compare Markov Decision Processes pointwise, where a point is a goal set X ⊆ Nat : t badOp t′ ⇐ ⇒ ∀X ⊆ Nat, inf

π Eπ(t ∈ X) ≤ inf π Eπ(t′ ∈ X) 9

slide-20
SLIDE 20

The natural operations ... ... Counter example

The issue

  • 1. The following trees are equated
  • r

pr 1 2 3 ≃badOp pr

  • r

1 3

  • r

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

slide-21
SLIDE 21

The solution

Compare Markov Decision Processes pointwise, where a point is a payoff function h : Nat → R+ : t op t′ ⇐ ⇒ ∀h : Nat → R+, inf

π Eπ(h(t)) ≤ inf π Eπ(h(t′))

Proposition The preorder op is admissible and compositional Remark The proof requires some topological arguments...

11

slide-22
SLIDE 22

Denotationally defined preorders

slide-23
SLIDE 23

Denotationally defined preorders

The idea Input

  • 1. Continuous Σ-algebra D
  • 2. ·: N⊥ → D continuous Σ-algebra homomorphism

Output The preorder den N D Trees(N)

j i ·

t den t′ ⇐ ⇒ t ≤D t′ (5)

12

slide-24
SLIDE 24

Denotationally defined preorders

Properties of den

  • 1. Automatically admissible

(continuity)

  • 2. Automatically compatible

(Σ-algebra)

  • 3. Not always compositional !

13

slide-25
SLIDE 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.

N D D

j f h

f

Idea We then have tσ = hσ(t) which is continuous in t with a fixed σ.

14

slide-26
SLIDE 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

slide-27
SLIDE 27

Applying to the running example

Using Kegelpsitze [Keimel and Plotkin, 2017] V≤1X ω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 ⊇.

  • r(A, B) = Conv(A ∪ B)

(6) pr(A, B) = 1 2a + 1 2b | a ∈ A, b ∈ B

  • (7)

16

slide-28
SLIDE 28

Axiomatically defined preorders

slide-29
SLIDE 29

Generic definition

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

17

slide-30
SLIDE 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

slide-31
SLIDE 31

Axioms for Pr and Nd

Bot: ⊥ ≤ x

18

slide-32
SLIDE 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

slide-33
SLIDE 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

slide-34
SLIDE 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

slide-35
SLIDE 35

The coincidence theorem

slide-36
SLIDE 36

Coincidence

For probability and non-determinism

  • p = 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

slide-37
SLIDE 37

Summary and limitations

slide-38
SLIDE 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

slide-39
SLIDE 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.

slide-40
SLIDE 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.

slide-41
SLIDE 41

References iii

Tix, R., Keimel, K., and Plotkin, G. (2009). Semantic domains for combining probability and non-determinism. Electronic Notes in Theoretical Computer Science, 222:3–99. Varacca, D. (2003). Probability, nondeterminism and concurrency: two denotational models for probabilistic computation. Citeseer.