Top Banner
Behavioral Computation Theory: Tutorial Yuri Gurevich (Microsoft Research) WoLLIC 2006
54

Behavioral Computation Theory: Tutorial

Jan 17, 2016

Download

Documents

halia

Behavioral Computation Theory: Tutorial. Yuri Gurevich (Microsoft Research) WoLLIC 2006. Agenda. Sequential algorithms Interactive algorithms. Part 1: Sequential algorithms. Intuition Axiomatic definition Behavioral equivalence Sequential abstract state machines - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Behavioral Computation Theory: Tutorial

Behavioral Computation Theory: Tutorial

Yuri Gurevich (Microsoft Research)

WoLLIC 2006

Page 2: Behavioral Computation Theory: Tutorial

2

Agenda

1. Sequential algorithms 2. Interactive algorithms

Page 3: Behavioral Computation Theory: Tutorial

3

Part 1: Sequential algorithms

IntuitionAxiomatic definition Behavioral equivalence

Sequential abstract state machinesSequential Characterization Theorem Algorithms are ASMs, and vice versa,

as far as behavior is concerned.

Page 4: Behavioral Computation Theory: Tutorial

4

Example: Euclid’s algorithm

1.If a = 0, set d = b and halt.

2.Set a = b mod a, set b = a,and go to 1.

Page 5: Behavioral Computation Theory: Tutorial

5

Example: Euc

Initially t = 0; a(0), b(0) well defined.

1.If a(t) = 0, set d = b(t) and halt.

2.Set a(t+1)= b(t) mod a(t),set b(t+1) = a(t), increment t, and go to 1.

Page 6: Behavioral Computation Theory: Tutorial

6

A run of Euc

t = 0, a(0) = 6, b(0) = 9

t = 1, a(1) = 3, b(1) = 6

t = 2, a(2) = 0, b(2) = 3

t,a,b unchanged, d = 3

Page 7: Behavioral Computation Theory: Tutorial

7

Which algos are sequential?

Negative characterization: neither parallel nor distributedPositive characterization is our goal. But we cannot rely on the formal notion of algorithm, so the notion that we have to define is that of sequential algorithms.

Page 8: Behavioral Computation Theory: Tutorial

8

Seq Time Postulate

Every algorithm is associated witha nonempty set Statesa nonempty subset Initial Statesa transition function Next : States States

Page 9: Behavioral Computation Theory: Tutorial

9

Intuition on states

States are comprehensive. What are states of a Turing machine? What are states of a C program?

Page 10: Behavioral Computation Theory: Tutorial

10

Behavior Equivalence

Two algorithms are behaviorally equivalent if they have the same states, initial states and transition function. The equivalence relation is

semantical:the programs may be different indeed.

Page 11: Behavioral Computation Theory: Tutorial

11

What else can be said of seq algos

in full generality?

Constructive (tangible) inputs Not necessarily

Finite Programs Sure, but syntax is messy.

Small (local, bounded-work) step But what’s local? How to measure work?

Page 12: Behavioral Computation Theory: Tutorial

12

Bounded work vs. bounded change

Bounded work bounded change, but

bounded change ↛ bounded work, e.g.

if xy({x,y} E) then output := false

else output := true

Page 13: Behavioral Computation Theory: Tutorial

13

Abstract State Postulate

The states are structures of the same vocabulary.Base(Next(X)) = Base(X).If is an isomorphism from a state X to a structure Y, then Y is a state and is an isomorphism from Next(X) to Next(Y).

Page 14: Behavioral Computation Theory: Tutorial

14

Without loss of generality

A state comes with the equality relation = true, false and the standard

propositional connectives undef

Page 15: Behavioral Computation Theory: Tutorial

15

Euc’s states (non-logic part)

A Euclidean domain E (with mod) including the set N of natural numbers with 0 and successor +1

Unary dynamic functions a, b : N E

Nullary dynamic functions d,t

Page 16: Behavioral Computation Theory: Tutorial

16

Euc’s associates

States: as described above.A state is initial if d = undef, t = 0.Next is given by the program.

Page 17: Behavioral Computation Theory: Tutorial

17

Euc’s vocabulary (non-logic part)

Static part In principle, the vocabulary of

Euclidean domains (with mod) In fact, Euc uses only 0, +1, mod

Dynamic part Unary function symbols a,b Nullary function symbols d,t

Page 18: Behavioral Computation Theory: Tutorial

18

Actions

Locations and their contents = (f,a1,..,aj)

Content() = f(a1,..,aj)

Updates (,v)

The update set at state X is

(X) = { (,v) : v = Content() in Next(X)

Content() in X }

Page 19: Behavioral Computation Theory: Tutorial

19

Euc’s locations and actions

Dynamic locations: (a,.), (b,.), t, d.If a(0) = 6, b(0) = 9 at X then(X) = { (t,1),((a,1),3) , ((b,1),6) }

(Next(X)) = {(t,2), ((a,2),0) , ((b,2)3)}(Next(Next(X))) = { (d,3) }

Page 20: Behavioral Computation Theory: Tutorial

20

Element Accessibility

The only way to refer to an element a is via a term that evaluates to a.A finite program can refer to only boundedly many elements

Page 21: Behavioral Computation Theory: Tutorial

21

Bounded Exploration Postulate

There is a finite set T of termssuch that for all states X,Y

if ValX(t) = ValY(t) for t ∈ T

then (X) = (Y).

Page 22: Behavioral Computation Theory: Tutorial

22

A bounded exploration witness for Euc

true, false, undef

Terms a(t)=0, a(t+1), b(t) mod a(t), b(t+1), d,

and their subterms

Page 23: Behavioral Computation Theory: Tutorial

23

Definition

A sequential algorithm is any object that satisfies the postulates:sequential time,abstract state, bounded-exploration.

Is this definition too general?

Page 24: Behavioral Computation Theory: Tutorial

24

Seq ASM Rules

Syntax Semantics = ?

f(t1,..,tj):= t0 {(,a0)} where =(f,(a1,..,aj)) and each ai = Val(ti)

do in parallel R1 … Rk

(R1) … (Rk)

if t then R1 else R2

if Val(t) = true then (R1) else (R2)

Page 25: Behavioral Computation Theory: Tutorial

25

Seq Abstract State Machines

A program is just a rule (to be iterated)

An ASM of vocabulary V is given by a program of vocabulary V a non-empty set of V-structures (the states)

closed under isomorphism and the transition function defined by the program

a non-empty subset of initial statesclosed under isomorphism

Page 26: Behavioral Computation Theory: Tutorial

26

Every seq ASM is a seq algo

Sequential time: obviousAbstract state: obviousBounded exploration: take all the terms in the program all their subterms all logical constants

Page 27: Behavioral Computation Theory: Tutorial

27

Seq Characterization Theorem

For every sequential algorithm A,there exists a sequential ASM behaviorally equivalent to A. In particular, the ASM simulates A step

for step.

Page 28: Behavioral Computation Theory: Tutorial

28

An ASM program for Euc

if a(t) = 0 then d := b(t)else [do in-parallel] a(t+1) := b(t) mod a(t) b(t+1) := a(t) t := t+1

Page 29: Behavioral Computation Theory: Tutorial

29

Euclid

if a = 0 then d := belse a := b mod a b := a

Page 30: Behavioral Computation Theory: Tutorial

30

Euclid with sessions

if a(s)=0 then

d(s) := b(s)

s := s+1

else

a(s) := b(s) mod a(s) b(s) := a(s)

Page 31: Behavioral Computation Theory: Tutorial

31

Reference

ACM Trans. on Computational Logicvol. 1, no. 1 (July 2000), p. 77-111.#141 in Annotated Articles athttp://research/microsoft/~gurevich

Page 32: Behavioral Computation Theory: Tutorial

32

Homework

Write an ASM program for your favorite sequential algorithm. If you want to execute it, go tohttp://research.microsoft.com/foundations/AsmL/

Page 33: Behavioral Computation Theory: Tutorial

33

Part 2: Interactive Algorithms

Page 34: Behavioral Computation Theory: Tutorial

34

Collaborators

Andreas Blass, Dean Rosenzweig, Benjamin RossmanRefs: #166, #170, #171, #176

Page 35: Behavioral Computation Theory: Tutorial

35

Time permitting, plan would be

IntuitionAxiomatic definition Behavioral equivalence

Interactive ASMsInteractive Characterization Theorem Algorithms are ASMs, and vice versa,

as far as behavior is concerned.

Page 36: Behavioral Computation Theory: Tutorial

36

More realistic plan

Motivation, clarification, small examples

Page 37: Behavioral Computation Theory: Tutorial

37

Interstep vs. intrastep

Sequential algorithms and ASMs are interstep interactive.The sequential characterization theorem generalizes to interstep interaction.From now on, by default, interaction is intrastep. But is there intrastep interaction?

Page 38: Behavioral Computation Theory: Tutorial

38

Import

A Turing machine with tape that is only potentially infinite How does it create new cells?

Object creation in object oriented programming Who creates the objects?

Import is a manifestation of interaction.

Page 39: Behavioral Computation Theory: Tutorial

39

Seq ASMs with import

if Move=R, H+1 = undef, … then import x x := H+1 H := x …

ReserveBackground

Page 40: Behavioral Computation Theory: Tutorial

40

Nondeterministic algorithms

A contradiction in termsYogi Berra: “When you come to a fork in the road, take it.”Explanation: nondeterminism is a manifestation of interactionNondeterministic FSMNondeterministic algorithms E.g. bipartite matching

Page 41: Behavioral Computation Theory: Tutorial

41

Nondeterministic ASMs

q := (any x: x in (q,a))Alternative syntax:choose x in (q,a) q := x …

Case of (q,a) =

Page 42: Behavioral Computation Theory: Tutorial

42

More examples

Input, remote procedure calls x := f(17)+2

In the case of parallel algorithms Receiving and sending mail Ping Print

Page 43: Behavioral Computation Theory: Tutorial

43

A more involved example

To paint a picture, an application calls an outside paint method.A paint agent is created and repeatedly calls back: which color for this detail?Consider making two such paint calls in parallel. This is viewed best as a single step.

Page 44: Behavioral Computation Theory: Tutorial

44

What is it all about?

Distributed computations from the point of view of a single agent. Setup: one algorithm interacts with the environment. From the algorithm’s point of view, the interaction is by means of messages only; there are no locations shared by the algorithm and the environment.

Page 45: Behavioral Computation Theory: Tutorial

45

What is environment?

It is everything that can affect the computation of the algorithm but is neither in the algorithm's state nor in its program.This may include other (silicon or carbon) agents, some central authority (think internet poker), OS, communication interfaces (think TCP/IP).

Page 46: Behavioral Computation Theory: Tutorial

46

Various Interaction Mechanisms

RPCMessagesSingle-answer queriesMultiple-answer queriesEtc.

Is there one universal mechanism? Yes.

Page 47: Behavioral Computation Theory: Tutorial

47

Queries

Getting input, printing outputReceiving and sending messagesNon-deterministic choicesNew objectsCalling an external function (in ASMs)Implicit queries

Page 48: Behavioral Computation Theory: Tutorial

48

What’s a message(in the algorithm’s view)?

A query or reply to a query.What if interaction is initiated from outside? The algorithm needs to pay attention

in order to notice an incoming message.

Paying attention is a (possibly implicit) query.

Page 49: Behavioral Computation Theory: Tutorial

49

Are queries blocking?

Not necessarily. It may be blocking: if p! then x:=1

A query may be blocking or not depending on history:if (p ⋎ q) then x:=1An algorithm is patient if all its queries are blocking.

Page 50: Behavioral Computation Theory: Tutorial

50

Is the environment info limited to query replies?

Almost. We argue that the only extra info is the order the replies are received.The broker example.The order of replies is quasi linear.An algorithm is time-insensitive if the order is immaterial.

Page 51: Behavioral Computation Theory: Tutorial

51

Ordinary algorithms

An algorithm is ordinary if it is patient and time-insensitive. Patient: all queries are blocking. Time-insensitive: the order of replies

is immaterial.

Page 52: Behavioral Computation Theory: Tutorial

52

An impatient, time-sensitive algorithm

do in parallel

if α ≺ β then x := -1

if α β then x := 0 if α ≻ β then x := 1

Page 53: Behavioral Computation Theory: Tutorial

53

Characterization Theorem

For every interactive algorithm A,there exists an interactive ASM behaviorally equivalent to A. In particular, the ASM simulates A

step for step.

Page 54: Behavioral Computation Theory: Tutorial

54

Questions?