Nondeterminism as first class citizen for Hidden Logic Daniel Gebler - - PowerPoint PPT Presentation

nondeterminism as first class citizen for hidden logic
SMART_READER_LITE
LIVE PREVIEW

Nondeterminism as first class citizen for Hidden Logic Daniel Gebler - - PowerPoint PPT Presentation

Introduction Nondeterministic Hidden Logic Nondeterministic Hidden Logic with Sharing Conclusion Nondeterminism as first class citizen for Hidden Logic Daniel Gebler and J org Endrullis VU University Amsterdam CMCS 2012, Tallinn 1 / 14


slide-1
SLIDE 1

Introduction Nondeterministic Hidden Logic Nondeterministic Hidden Logic with Sharing Conclusion

Nondeterminism as first class citizen for Hidden Logic

Daniel Gebler and J¨

  • rg Endrullis

VU University Amsterdam

CMCS 2012, Tallinn

1 / 14

slide-2
SLIDE 2

Introduction Nondeterministic Hidden Logic Nondeterministic Hidden Logic with Sharing Conclusion

Table of contents

1

Introduction

2

Nondeterministic Hidden Logic

3

Nondeterministic Hidden Logic with Sharing

4

Conclusion

2 / 14

slide-3
SLIDE 3

Introduction Nondeterministic Hidden Logic Nondeterministic Hidden Logic with Sharing Conclusion

Hidden Logic - Overview

Objective Semantics to OO software engineering Verification & Refinement of Design, not Code Behavioral abstraction Proof automation (Circular Coinduction) Tool support (CIRC) Related Approaches Context induction [Hennicker, 1990] Observational Logic [Bidoit, Hennicker, Kurz, 2002] Observational proofs by rewriting [Bouhoula and Rusinowitch, 2002] Coherent Hidden Algebra [Diaconescu and Futatsugi, 2000]

3 / 14

slide-4
SLIDE 4

Introduction Nondeterministic Hidden Logic Nondeterministic Hidden Logic with Sharing Conclusion

Hidden Logic - Specifications and Semantics

Hidden specifications A hidden specification is a tuple (Σ, Γ, E), where Σ a many-sorted signature with hidden and visible sorts, Γ a many-sorted subsignature of Σ, E is a set of equations. Behavioral semantics Experiments are Γ-terms of visible sort with one “place-holder” Behavioral equivalence is non-distinguishability under experiments Coalgebraic nature GΓ : SetH → SetH GΓ(X)h =

γ∈Γhw,s X Dw s

HAlg(Γ) ≃ GΓ − Coalg

4 / 14

slide-5
SLIDE 5

Introduction Nondeterministic Hidden Logic Nondeterministic Hidden Logic with Sharing Conclusion

Hidden Logic - Example

Sorts Visible sort: N, Hidden sort: Stream Operations head: Stream → N tail: Stream → Stream add: Stream × Stream → Stream . . . Equations head(add(s, s′)) = head(s) + head(s′) tail(add(s, s′)) = add(tail(s), tail(s′)) Experiments head(•), head(tailn(•)) H

zeros

D V

add( , ) tail( ) + head( ) cons( , )

  • perations in Γ

5 / 14

slide-6
SLIDE 6

Introduction Nondeterministic Hidden Logic Nondeterministic Hidden Logic with Sharing Conclusion

Problem Motivation (intuitive)

1) Underspecification vs. Inherent nondeterminism ? vs. 2) Sharing choices between nondeterministic systems

  • vs.

6 / 14

slide-7
SLIDE 7

Introduction Nondeterministic Hidden Logic Nondeterministic Hidden Logic with Sharing Conclusion

Leading example

Specification rand: → Stream dup: Stream → Stream rand = (0 ⊕ 1) : rand dup(σ) = hd(σ) : hd(σ) : dup(tl(σ)) Example 1: Underspecification vs. Inherent nondeterminism add(rand, rand)

?

= Example 2: Sharing choices between nondeterministic systems dup(rand)

?

= hd(rand) : hd(rand) : dup(tl(rand))

7 / 14

slide-8
SLIDE 8

Introduction Nondeterministic Hidden Logic Nondeterministic Hidden Logic with Sharing Conclusion

Behavioral Specification

Nondeterministic Hidden specification A nondeterminsitic hidden specification is a tuple (Σfun, Σrel, Γ, E) Σfun a many-sorted signature of deterministic functions Σrel a many-sorted signature of nondeterministic functions Σ = Σfun ∪ Σrel ∪ {⊕s | s ∈ S} E a set of equations

ℓ · = r (behavioral deterministic) ℓ = r (behavioral nondeterministic)

8 / 14

slide-9
SLIDE 9

Introduction Nondeterministic Hidden Logic Nondeterministic Hidden Logic with Sharing Conclusion

Algebraic and Behavioral Semantics

Nondeterministic Hidden Algebra A nondeterminsitic hidden algebra is a Σ-multialgebra A, · with interpretation f : As1 × . . . × Asn → P+(As) for f ∈ Σs1...sn,s f (a1, . . . , an) singleton for f ∈ Σfun Extension to f : P+(As1) × . . . × P+(Asn) → P+(As) via union Assignment: α : X → A Natural lifting to terms ·α : Ter(Σ, X) → P+(A) s ⊕ tα = sα ∪ tα Behavioral equivalence a ≡ b iff C[∗ : s]∗→a = C[∗ : s]∗→b for every C ∈ Ter(Σ, {∗})v

9 / 14

slide-10
SLIDE 10

Introduction Nondeterministic Hidden Logic Nondeterministic Hidden Logic with Sharing Conclusion

Leading example (II)

Specification zerosOrOnes = zeros ⊕ ones zeros = 0 : zeros push(σ) = (0 ⊕ 1) : σ

  • nes = 1 : ones

tail( ) + head( ) cons( , )

H

zeros

  • nes

blink

D V

push( ) zerosOrOnes

Representation of nondeterministic operations: f : P+(As1) × . . . × P+(Asn) → P+(As) with requirement: f (A1, . . . , An) =

a1∈A1,...,an∈An f ({a1}, . . . , {an})

10 / 14

slide-11
SLIDE 11

Introduction Nondeterministic Hidden Logic Nondeterministic Hidden Logic with Sharing Conclusion

Sharing of terms

rand = (0 ⊕ 1) : rand zeros = 0 : zeros add(x : σ, y : τ) = (x + y) : add(σ, τ) fun(σ) = add(σ, σ) Adding two independent random streams gives a random stream: add(rand, rand) = rand But we have fun(rand) = zeros = add(rand, rand) Idea: sharing to express that both rand’s refer to the same random choice: fun rand add rand = zeros = add rand rand = rand = We introduce sharing during equational reasoning if variable is duplicated.

11 / 14

slide-12
SLIDE 12

Introduction Nondeterministic Hidden Logic Nondeterministic Hidden Logic with Sharing Conclusion

Behavioral Reasoning

rand = (0 ⊕ 1) : rand add(x : σ, y : τ) · = (x + y) : add(σ, τ) zeros · = 0 : zeros with { : , add, zeros, +} ⊆ Σfun and {rand} ⊆ Σrel. add rand · = zeros

12 / 14

slide-13
SLIDE 13

Introduction Nondeterministic Hidden Logic Nondeterministic Hidden Logic with Sharing Conclusion

Behavioral Reasoning

rand = (0 ⊕ 1) : rand add(x : σ, y : τ) · = (x + y) : add(σ, τ) zeros · = 0 : zeros with { : , add, zeros, +} ⊆ Σfun and {rand} ⊆ Σrel. add rand · = zeros equational reasoning

12 / 14

slide-14
SLIDE 14

Introduction Nondeterministic Hidden Logic Nondeterministic Hidden Logic with Sharing Conclusion

Behavioral Reasoning

rand = (0 ⊕ 1) : rand add(x : σ, y : τ) · = (x + y) : add(σ, τ) zeros · = 0 : zeros with { : , add, zeros, +} ⊆ Σfun and {rand} ⊆ Σrel. add : ⊕ 1 rand · = zeros

12 / 14

slide-15
SLIDE 15

Introduction Nondeterministic Hidden Logic Nondeterministic Hidden Logic with Sharing Conclusion

Behavioral Reasoning

rand = (0 ⊕ 1) : rand add(x : σ, y : τ) · = (x + y) : add(σ, τ) zeros · = 0 : zeros with { : , add, zeros, +} ⊆ Σfun and {rand} ⊆ Σrel. add : ⊕ 1 rand · = zeros unsharing of Σfun symbol (deterministic symbols can always be unshared) (hence usual reasoning if Σrel = ∅)

12 / 14

slide-16
SLIDE 16

Introduction Nondeterministic Hidden Logic Nondeterministic Hidden Logic with Sharing Conclusion

Behavioral Reasoning

rand = (0 ⊕ 1) : rand add(x : σ, y : τ) · = (x + y) : add(σ, τ) zeros · = 0 : zeros with { : , add, zeros, +} ⊆ Σfun and {rand} ⊆ Σrel. add : : ⊕ 1 rand · = zeros

12 / 14

slide-17
SLIDE 17

Introduction Nondeterministic Hidden Logic Nondeterministic Hidden Logic with Sharing Conclusion

Behavioral Reasoning

rand = (0 ⊕ 1) : rand add(x : σ, y : τ) · = (x + y) : add(σ, τ) zeros · = 0 : zeros with { : , add, zeros, +} ⊆ Σfun and {rand} ⊆ Σrel. add : : ⊕ 1 rand · = zeros equational reasoning (unsharing was needed) (no equational reasoning across symbols with multiple incoming edges)

12 / 14

slide-18
SLIDE 18

Introduction Nondeterministic Hidden Logic Nondeterministic Hidden Logic with Sharing Conclusion

Behavioral Reasoning

rand = (0 ⊕ 1) : rand add(x : σ, y : τ) · = (x + y) : add(σ, τ) zeros · = 0 : zeros with { : , add, zeros, +} ⊆ Σfun and {rand} ⊆ Σrel. : + add rand ⊕ 1 · = zeros

12 / 14

slide-19
SLIDE 19

Introduction Nondeterministic Hidden Logic Nondeterministic Hidden Logic with Sharing Conclusion

Behavioral Reasoning

rand = (0 ⊕ 1) : rand add(x : σ, y : τ) · = (x + y) : add(σ, τ) zeros · = 0 : zeros with { : , add, zeros, +} ⊆ Σfun and {rand} ⊆ Σrel. : + add rand ⊕ 1 · = zeros case distinction for ⊕

12 / 14

slide-20
SLIDE 20

Introduction Nondeterministic Hidden Logic Nondeterministic Hidden Logic with Sharing Conclusion

Behavioral Reasoning

rand = (0 ⊕ 1) : rand add(x : σ, y : τ) · = (x + y) : add(σ, τ) zeros · = 0 : zeros with { : , add, zeros, +} ⊆ Σfun and {rand} ⊆ Σrel. : + add rand · = zeros : + add rand 1 · = zeros

12 / 14

slide-21
SLIDE 21

Introduction Nondeterministic Hidden Logic Nondeterministic Hidden Logic with Sharing Conclusion

Behavioral Reasoning

rand = (0 ⊕ 1) : rand add(x : σ, y : τ) · = (x + y) : add(σ, τ) zeros · = 0 : zeros with { : , add, zeros, +} ⊆ Σfun and {rand} ⊆ Σrel. : + add rand · = zeros : + add rand 1 · = zeros unsharing of Σfun symbol

12 / 14

slide-22
SLIDE 22

Introduction Nondeterministic Hidden Logic Nondeterministic Hidden Logic with Sharing Conclusion

Behavioral Reasoning

rand = (0 ⊕ 1) : rand add(x : σ, y : τ) · = (x + y) : add(σ, τ) zeros · = 0 : zeros with { : , add, zeros, +} ⊆ Σfun and {rand} ⊆ Σrel. : + add rand · = zeros : + add rand 1 1 · = zeros

12 / 14

slide-23
SLIDE 23

Introduction Nondeterministic Hidden Logic Nondeterministic Hidden Logic with Sharing Conclusion

Behavioral Reasoning

rand = (0 ⊕ 1) : rand add(x : σ, y : τ) · = (x + y) : add(σ, τ) zeros · = 0 : zeros with { : , add, zeros, +} ⊆ Σfun and {rand} ⊆ Σrel. : + add rand · = zeros : + add rand 1 1 · = zeros equational reasoning

12 / 14

slide-24
SLIDE 24

Introduction Nondeterministic Hidden Logic Nondeterministic Hidden Logic with Sharing Conclusion

Behavioral Reasoning

rand = (0 ⊕ 1) : rand add(x : σ, y : τ) · = (x + y) : add(σ, τ) zeros · = 0 : zeros with { : , add, zeros, +} ⊆ Σfun and {rand} ⊆ Σrel. : add rand · = zeros : add rand · = zeros

12 / 14

slide-25
SLIDE 25

Introduction Nondeterministic Hidden Logic Nondeterministic Hidden Logic with Sharing Conclusion

Behavioral Reasoning

rand = (0 ⊕ 1) : rand add(x : σ, y : τ) · = (x + y) : add(σ, τ) zeros · = 0 : zeros with { : , add, zeros, +} ⊆ Σfun and {rand} ⊆ Σrel. : add rand · = zeros : add rand · = zeros equational reasoning

12 / 14

slide-26
SLIDE 26

Introduction Nondeterministic Hidden Logic Nondeterministic Hidden Logic with Sharing Conclusion

Behavioral Reasoning

rand = (0 ⊕ 1) : rand add(x : σ, y : τ) · = (x + y) : add(σ, τ) zeros · = 0 : zeros with { : , add, zeros, +} ⊆ Σfun and {rand} ⊆ Σrel. : add rand · = : zeros : add rand · = : zeros

12 / 14

slide-27
SLIDE 27

Introduction Nondeterministic Hidden Logic Nondeterministic Hidden Logic with Sharing Conclusion

Behavioral Reasoning

rand = (0 ⊕ 1) : rand add(x : σ, y : τ) · = (x + y) : add(σ, τ) zeros · = 0 : zeros with { : , add, zeros, +} ⊆ Σfun and {rand} ⊆ Σrel. : add rand · = : zeros : add rand · = : zeros circular coinduction: heads are equal tails are exactly the equation we started from

12 / 14

slide-28
SLIDE 28

Introduction Nondeterministic Hidden Logic Nondeterministic Hidden Logic with Sharing Conclusion

Behavioral Reasoning

rand = (0 ⊕ 1) : rand add(x : σ, y : τ) · = (x + y) : add(σ, τ) zeros · = 0 : zeros with { : , add, zeros, +} ⊆ Σfun and {rand} ⊆ Σrel. : add rand · = : zeros : add rand · = : zeros circular coinduction: heads are equal tails are exactly the equation we started from qed

12 / 14

slide-29
SLIDE 29

Introduction Nondeterministic Hidden Logic Nondeterministic Hidden Logic with Sharing Conclusion

Equational Reasoning and Sharing

No equational reasoning across symbols with multiple incoming edges push(σ) = (0 ⊕ 1) : σ zeros = 0 : zeros add(x : σ, y : τ) = (x + y) : add(σ, τ) add(push(σ), τ) = push(add(σ, tl(τ))) Σrel = {push} Last equation: if the first bit of the first argument is random, then first bit of outcome is random However, this holds only since the arguments are not shared! add push zeros = zeros = push add tl push zeros

13 / 14

slide-30
SLIDE 30

Introduction Nondeterministic Hidden Logic Nondeterministic Hidden Logic with Sharing Conclusion

Conclusion

Summary Nondeterminism as first class citizen Pointwise lifting of deterministic behavior Sharing allows to replicate choices in nondeterministic systems Nondeterministic and sharing extensions are conservative (Σrel = ∅) Future work Coalgebraic interpretation Formalize Circular Coinduction proof rules for sharing Interplay circular induction and circular coinduction with sharing Implementation CIRC Samples (QoS/Security of P2P networks)

14 / 14