98
Gedistribueerde AI: Overview • Concurrency - Communicating Sequential Processes - Concurrent Constraint Programming • Agent-Oriented Programming - 3APL

Gedistribueerde AI: Overview

  • Upload
    cyma

  • View
    33

  • Download
    2

Embed Size (px)

DESCRIPTION

Gedistribueerde AI: Overview. Concurrency - Communicating Sequential Processes - Concurrent Constraint Programming Agent-Oriented Programming - 3APL. Evolution. Mastering Complexity : From Operating Systems (mutual exclusion, scheduling) To Global Computing - PowerPoint PPT Presentation

Citation preview

Page 1: Gedistribueerde AI: Overview

Gedistribueerde AI: Overview

• Concurrency - Communicating Sequential Processes - Concurrent Constraint Programming

• Agent-Oriented Programming - 3APL

Page 2: Gedistribueerde AI: Overview

EvolutionMastering Complexity:

From Operating Systems (mutual exclusion, scheduling)To Global Computing Bioinformatics Multi-Agent Systems (negotiation, human interactions)

Page 3: Gedistribueerde AI: Overview

Abstraction

Procedures Classes (Objects) Agents (Subjects)

Page 4: Gedistribueerde AI: Overview

Concurrency

Main Features• Communication• Coordination• Real-Time• Non-determinism• Deadlock• Livelock

Page 5: Gedistribueerde AI: Overview

Founding Fathers• E.W. Dijkstra: - Guarded Command Language - Weakest Precondition Calculus - Semaphores (Mutual Exclusion)• T. Hoare - Hoare Logic - Communicating Sequential Processes (CSP) - Monitors• R. Milner - Calculus of Commincating Systems (CCS) - PI-calculus (mobility)• V. Saraswatt - Concurrent Constraint Programming (CCP)

Page 6: Gedistribueerde AI: Overview

CSP

Process consists of

• Internal Computation• Interface - Static (Signature) - Dynamic (Behavior)

Page 7: Gedistribueerde AI: Overview

A Coffee MachineEvents: coffee, theeA machine with buttons (menu)

coffee

thee

Page 8: Gedistribueerde AI: Overview

Interfaces in OO

Class Stack

push

pop

Events: push(v), pop(v)Behavior: ?

Page 9: Gedistribueerde AI: Overview

Operational Semantics

Labeled Transitions: P Q

• P,Q: Processes =a,b,c,.. , - a,b,c,..: External Events

- : Termination - : Internal action

Page 10: Gedistribueerde AI: Overview

Computation

P1 P2 P2 …1 2 3

• Finite - successfull termination - deadlock •Infinite - fairness (strong, weak)

Page 11: Gedistribueerde AI: Overview

The STOP-Process

The process

models inaction

STOP

STOP

Page 12: Gedistribueerde AI: Overview

Performing Events

Event Prefixing:

Intuitive meaning: do first a then PFormally

(a P) Pa

a P

Page 13: Gedistribueerde AI: Overview

A Light Bulbonoff(on (off stop)) (off stop)

(off stop) stop

on

off

Page 14: Gedistribueerde AI: Overview

Finite Automata

P0 P1 stopon off

P1 = on (off stop))

P1=(off stop)

Page 15: Gedistribueerde AI: Overview

Making Choices(what’s life all about, isn’t it?)

Choice Construct

Meaning choose aA and continue with P(a)Formally

x: A P(x)(with A)

(x:A P) P(a)for a A

a

Page 16: Gedistribueerde AI: Overview

Example

x : coffee,chocolate P(x)

P(coffee) = x : milk,black stop

P(chocolate) = x : hot, cold stop

Page 17: Gedistribueerde AI: Overview

Example (Cont’d)

(x : coffee,chocolate P(x))

(x : milk,black stop)stop

coffee

milk

Page 18: Gedistribueerde AI: Overview

Example (Cont’d)

P0

P1

P2

stop

coffee

chocolate

hot cold

milk

black

Page 19: Gedistribueerde AI: Overview

Compound Events

Communication EventsC.V

C: Channel V: Value

C!V P

C?x P(x)

C.V P(C!V P)

P(V)(C?x P(x)) C.V

output

input

syntax behavior

Page 20: Gedistribueerde AI: Overview

Example: A Simple Filter

in?x out!op(x) stop

opin out

Page 21: Gedistribueerde AI: Overview

Unix-Shell Scripts

ECHO ! “please enter your name”

READ ? name

ECHO ! “welcome name” stop

Page 22: Gedistribueerde AI: Overview

RecursionN=P

N: nameP: process

Example: light = on (off light)

P Q

N QN=P

Page 23: Gedistribueerde AI: Overview

The Light Bulb (again)

(on (off light)) (off light)on

light on (off light)

lighton

P

off

Page 24: Gedistribueerde AI: Overview

The Dining Philospher

P=think leftfork rightfork eat P

Page 25: Gedistribueerde AI: Overview

Cognitive Robotics

Sense-Act Cycle

Cycle= x: Events Act(x)

Act(x) = a(x) Cycle

Page 26: Gedistribueerde AI: Overview

Deriving Transitions

Proof Rules

1P1 Q1 Pn Qn1…

P Q

Page 27: Gedistribueerde AI: Overview

Mutual Recursion

Example

LIGHT=on ON

ON=off LIGHT

Page 28: Gedistribueerde AI: Overview

Counter Example

inc

dec

count(0) = inc count(1)count(n+1) = x:{inc,dec} P(x)P(inc) = count(n+2)P(dec) = count(n)

Page 29: Gedistribueerde AI: Overview

Computation Graph

count(1) count(2)

inc inc

dec

count(0) count(3)

inc

dec…

dec

Page 30: Gedistribueerde AI: Overview

External Choice

Syntax

Semantics

P Q

aP P'

P Q P' a P Q P' Q

P P'

Page 31: Gedistribueerde AI: Overview

Fifo Buffer

bufferin out

B() = in?x B(<x>)

B(<v>.s) = in?x B(<x,v>.s) out!v B(s)

Page 32: Gedistribueerde AI: Overview

Internal Choice

Syntax

Semantics

P Q

P Q P

Page 33: Gedistribueerde AI: Overview

Tossing a Coin

Toss = (head Toss) (tail Toss )

toss P

Q

headtail

Page 34: Gedistribueerde AI: Overview

Termination

The process

indicates successful termination:

SKIP

SKIP STOP

Page 35: Gedistribueerde AI: Overview

Sequential Composition

Syntax

Semantics

P;Q

P P'

P ; Q P';Q P ; Q Q

P P'

Page 36: Gedistribueerde AI: Overview

Purchase

Purchase=Choose;Pay

Select= select (SKIP return Select)

Pay= cash receipt SKIP

card swipe (receipt sign SKIP reject Pay)

Page 37: Gedistribueerde AI: Overview

A One-Time Stack

A Finite Representation

Push = in?x (Push; (out!xSKIP)) pop SKIP

Page 38: Gedistribueerde AI: Overview

A Computation

PushPush; (out!5 SKIP) Push;(out!3SKIP); (out!5 SKIP)SKIP;(out!3SKIP); (out!5 SKIP)(out!3SKIP); (out!5 SKIP)SKIP; (out!5 SKIP)out!5 SKIPSKIP

in.5in.3pop

out.3

out.5

Page 39: Gedistribueerde AI: Overview

Concurrency

Communication:

MessageSender Receiver

• Synchronous• Asynchronous• Broadcast

Page 40: Gedistribueerde AI: Overview

Rendez-Vous

Caller Calleeparameters

result

suspended methodsynchronization

Page 41: Gedistribueerde AI: Overview

Parallel Composition

• Interleaving• Synchronization on common actions

P | Q

Page 42: Gedistribueerde AI: Overview

Architecture

P Qb b

ba c

Interface(P) = {a,b}Interface(Q) = {b,c}

Page 43: Gedistribueerde AI: Overview

Semantics

Interleaving

Synchronization

P P'

P || Q P' || Q

P || Q P' || Q '

P Q'P P'

Page 44: Gedistribueerde AI: Overview

A Skating Race

Syntax

A Run

start finish1 STOP || start finish2 STOP

start finish1 STOP || start finish2 STOPstart

finish1 STOP || finish2 STOP finish1

STOP || finish2 STOP finish2

STOP || STOP

Page 45: Gedistribueerde AI: Overview

Modeling a False Start

Pi= start finish1 STOP + starti Pi

Page 46: Gedistribueerde AI: Overview

Interleaving

Syntax

SemanticsP P'

P ||| Q P' ||| Q

P ||| Q

Page 47: Gedistribueerde AI: Overview

The Counter Example Revisited

Count= inc (dec STOP) ||| Count)

dec STOP dec STOP

(dec STOP) ||| Count dec STOP ||| Count

Page 48: Gedistribueerde AI: Overview

Dynamic Process Creation

Count

(dec STOP) ||| Count

(dec STOP) ||| (dec STOP) ||| Count

inc

inc

Page 49: Gedistribueerde AI: Overview

A Bag

Syntax

A computation stepBag

Bag = in?x (out!x STOP) ||| Bag)

in.3 (out!3 STOP) ||| Bag)

Page 50: Gedistribueerde AI: Overview

Buffers

One-place Buffers

A Pipeline

Synchronization on events:

P= c?x d!x PQ= d?x e!x Q

P || Q

d.v

Page 51: Gedistribueerde AI: Overview

Semantics

c?x d!x P || d?x e!x Q

d!v1 P || d?x e!x Q

P || e!v1 Q

c.v1

d.v1

e.v1c.v2

P|| Q

d!v2 P || e!v1 Q

Page 52: Gedistribueerde AI: Overview

Deadlock

Peter and David

Peter= lift-piano Peter lift-table Peter

David= lift-piano David lift-table David

Peter || David

Page 53: Gedistribueerde AI: Overview

Peter and David in Action

Peter decides to lift the piano:

(lift-piano Peter lift-table Peter) lift-piano Peter

Peter lift-piano Peter

But David decides to lift the table:

David lift-table Peter

So: Peter || David lift-piano Peter || David

Page 54: Gedistribueerde AI: Overview

Abstraction

Syntax

Semantics

P \ A

P \ A P' \ A

P P'a

a

aAP \ A P' \ A

P P'a

aA

Page 55: Gedistribueerde AI: Overview

On Her Majesty’s Secret Service

The Spy

The Master

Hiding

Spy=listen?x relay!x Spy

Master=relay?x log!x Master

(Spy || Master) \ {relay.m| m M}

Page 56: Gedistribueerde AI: Overview

Renaming

Syntax

Semantics

f (P)

f

P f(P')

P P'a

f(a)P f(P')

P P'

Page 57: Gedistribueerde AI: Overview

Generic Descriptions

Copy=in?x out!x Copy

fi(Copy)=ci?x ci+1!x Copy

fi(in.m)=ci.mfi(out.m)=ci+1.m

Page 58: Gedistribueerde AI: Overview

Set

Set

The Interface

query

addanswer

Page 59: Gedistribueerde AI: Overview

The Implementation

Node(x) i:Set

query

add

answer

i.query

i.add

i.answer

Set

Page 60: Gedistribueerde AI: Overview

The Process Definition

Set= query?x answer!no Set add?x (Node(x) || f (Set)) \ I

f(query.v)=i. query, f(add.v)=i. add.v, f(answer.v)=i.answer.vI={i.query.v, i.add.v, i.answer.v| vV}

Page 61: Gedistribueerde AI: Overview

Node(x)

Node(x) = query?y if y=x then answer!yes Node(x) else i.query!y i.answer?z answer!z Node(x) fi

add?y if yx then i. add!y Node(x) fi

Page 62: Gedistribueerde AI: Overview

A Computation

Set (Node(0) || f(Set)) \ I(i.add(5) Node(0) || f(Set)) \ I(Node(0) || f ( (Node(5) || f(Set)) \I )) \ I

add.0

add.5

Page 63: Gedistribueerde AI: Overview

Justification

add.5 (Node(5) || f(Set)) \I

f(Set) i.add.5 f ( (Node(5) || f(Set)) \I )

Set

Page 64: Gedistribueerde AI: Overview

Justification (Cont’d)

i.add.5

f ( (Node(5) || f(Set)) \I )Node(0) ||i.add(5) Node(0) || f(Set))

(i.add(5) Node(0) || f(Set))) \I

(Node(0) || f ( (Node(5) || f(Set)) \I )) \ I

Page 65: Gedistribueerde AI: Overview

The Computation Cont’d

(Node(0) || f ( (Node(5) || f(Set)) \I )) \ I

(i.query!y i.answer?z answer!z Node(x) ||

f ( (Node(5) || f(Set)) \I ) ) \ I

(i.answer?z answer!z Node(x) ||

f ( (answer!yes Node(5) || f(Set)) \I ) ) \ I

query.5

Page 66: Gedistribueerde AI: Overview

External Choice Revisited

Given

Compare

c?x STOP d?x STOP

(c?x STOP d?x STOP) || d!v STOP

(c?x STOP d?x STOP) || (c!v STOP d!w STOP)

Page 67: Gedistribueerde AI: Overview

Multi-Party Communication

Analyze

c!v STOP || c!w STOP || c?x P(x) || c?x Q(x)

Page 68: Gedistribueerde AI: Overview

Analyzing Processes

Trace =Sequence of Events

Page 69: Gedistribueerde AI: Overview

Trace Semantics

Trace(P)={ s | P } s

P

P a Q Q s

P a.s

P Q Q s

P s

Page 70: Gedistribueerde AI: Overview

Compositionality

Trace( op(P1, ... ,Pn) = op(Trace(P1), ... ,Trace(Pn))

syntax semantics

Page 71: Gedistribueerde AI: Overview

Event Prefixing

Trace(a P)= { } a Trace (P)

Page 72: Gedistribueerde AI: Overview

Parallel Composition

Trace(P || Q)= { s| sA Trace(P ) sB Trace(Q ) }

A=Interface(P)B=Interface(Q)

Page 73: Gedistribueerde AI: Overview

Example

Trace(P || Q)= { , a, ab, abc }

P=a b STOPQ=b c STOP

Page 74: Gedistribueerde AI: Overview

Deadlock

Trace(P || Q)= { }

P=a b STOPQ=b a STOP

Page 75: Gedistribueerde AI: Overview

Communication

Trace(P || Q)= { , c.v }

P=c!v STOPQ=c?x STOP

Trace(P)={, c.v }Trace(Q)={} {c.w| w Val}

Page 76: Gedistribueerde AI: Overview

Recursion

Trace(N) = a*

N= a N

Trace(N) = { } a Trace (N)

Page 77: Gedistribueerde AI: Overview

Finite Approximations

N(0) = STOPN(k+1) = a N(k)

N(0) = STOPN(1) = a STOPN(2) = a a STOPN(3) = a a a STOP

N(0) = STOPN(k+1) = a N(k)

Page 78: Gedistribueerde AI: Overview

Choice

Trace(P+Q) = Trace(P) Trace(Q)

a

b c

a a

b c

Page 79: Gedistribueerde AI: Overview

Bisimulation

A (binary) relation R is a bisimulation

if P R Q then

for some

P P'u implies Q Q'u

Q' such that P' R Q'

Page 80: Gedistribueerde AI: Overview

Bisimulation (Cont’d)

u

P

P'

R Q

u

Q'R

Page 81: Gedistribueerde AI: Overview

Ready Semantics

Compare

a a

b db e

c e

a a

b db e

c e

b

e c

P Q

Page 82: Gedistribueerde AI: Overview

Ready Semantics Formally

Ready(P) contains all pairs (s,R) such that

• P • not Q• Q

s Q

a for a in R

Page 83: Gedistribueerde AI: Overview

Maximal Traces

MTrace(P) contains all traces s such that

• P • not Q

Compare

s Qu for any action u

aSTOP a b STOP

a b STOP

Page 84: Gedistribueerde AI: Overview

MTrace is not Compositional

Counter Exanple

MTrace(ab STOP a cSTOP ) =MTrace(a(b STOP cSTOP ))

MTrace(ab STOP a cSTOP || ab STOP ) MTrace(a(b STOP cSTOP ) || ab STOP ))

Page 85: Gedistribueerde AI: Overview

Failure Semantics

Fail(P) contains all pairs (s,F) such that

• P • Q

s Qu for any action u in F {}

Page 86: Gedistribueerde AI: Overview

Example I

Fail(ab STOP a cSTOP ) = {(,) , (,{b}) , (,{c}) , (,{b,c}) , (a, ) , (a,{a}) , (a,{b}), (a,{c}) , (a,{a,b}), (a,{a,c}), (ab, ) , (ab,{a}) , (ab,{b}), (ab,{c}), ... }

Page 87: Gedistribueerde AI: Overview

Example II

Fail(a(b STOP cSTOP )) = {(,) , (,{b}) , (,{c}) , (a, ) , (a,{a}) , (ab, ) , (ab,{a}) , (ab,{b}), (ab,{c}), ... }

Page 88: Gedistribueerde AI: Overview

Ready Failure

Compare

a a

b c cb b c

a a a

Page 89: Gedistribueerde AI: Overview

The Semantic Hierarchy

Bisimulation Ready Failure Trace

Page 90: Gedistribueerde AI: Overview

Proof-Theory

Proving semantical equivalences:

P=Q

Page 91: Gedistribueerde AI: Overview

Equational Logic

Reflexivity P=PAssociativity P=Q Q=R P=RSymmetry P=Q Q=PCongruence P=Q C[P]=C[Q]

Page 92: Gedistribueerde AI: Overview

Axioms for External Choice

Idempotency P P= PAssociativity P (Q R) = (P Q) RSymmetry P Q = Q PNeutral Element P STOP = STOP

Page 93: Gedistribueerde AI: Overview

Axioms for Parallel Composition

Associativity P || (Q || R) = (P || Q) || RSymmetry P || Q = Q || P Interleaving P || Q= P Q Q R P|QLeft Merge a P Q =a (P || Q) for aI(P)\I(Q) a P Q = STOP for aI(P) I(Q)

Page 94: Gedistribueerde AI: Overview

Parallel Composition (cont’d)

Left Distributivity (P Q) R= P R Q RSynchronization Left Distributivity (P Q) | R= P |R Q |RSynchronization a P | a Q = a (P ||Q) a P | b Q = STOP

Page 95: Gedistribueerde AI: Overview

Property-Oriented Specification

where is a property in some logic

P sat

Page 96: Gedistribueerde AI: Overview

Trace Logic

Example

Count sat inc(t) dec(t)

inc()=0 dec()=0inc( inc.t)= inc(t)+1 dec( dec.t)= dec(t)+1inc(dec.t)=inc(t) dec( inc.t)=dee(t)

Page 97: Gedistribueerde AI: Overview

Modal Logic

Fornulas

true | false | [a] | ... Example <a>true means there exists an a transition

Page 98: Gedistribueerde AI: Overview

Model-CheckingCheck P sat

directly in terms of the semantics of PIn practice: is a temporal property (Computation Tree Logic, CTL)• The semantics of P is a (finite-state) automaton ( 10 to the power 20 states!)

For more info see Appendix B.