SLIDE 1
Basic operational preorders for algebraic effects in general, and - - PowerPoint PPT Presentation
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 2
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
”Generic Operational Metatheory” Ideas
[Johann et al., 2010a] Why ? Operational semantics works great but needs to be adapted in each case
2
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
”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
”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
Contextual preorders
Morris-style Input: A peorder for type Nat Output: P1 ⊑ctxt P2 ⇐ ⇒ ∀C[−] context, |C[P1]| |C[P2]| (1)
3
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
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
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
Contributions
General Identify three different ways to produce well-behaved preorders
6
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
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
Well-behaved preorders
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
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
Operationally defined preorders
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
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
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
Denotationally defined preorders
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
Denotationally defined preorders
Properties of den
- 1. Automatically admissible
(continuity)
- 2. Automatically compatible
(Σ-algebra)
- 3. Not always compositional !
13
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
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
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
Axiomatically defined preorders
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
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
Axioms for Pr and Nd
Bot: ⊥ ≤ x
18
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
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
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
The coincidence theorem
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
Summary and limitations
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
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
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