gedistribueerde ai: overview
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 PresentationTRANSCRIPT
Gedistribueerde AI: Overview
• Concurrency - Communicating Sequential Processes - Concurrent Constraint Programming
• Agent-Oriented Programming - 3APL
EvolutionMastering Complexity:
From Operating Systems (mutual exclusion, scheduling)To Global Computing Bioinformatics Multi-Agent Systems (negotiation, human interactions)
Abstraction
Procedures Classes (Objects) Agents (Subjects)
Concurrency
Main Features• Communication• Coordination• Real-Time• Non-determinism• Deadlock• Livelock
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)
CSP
Process consists of
• Internal Computation• Interface - Static (Signature) - Dynamic (Behavior)
A Coffee MachineEvents: coffee, theeA machine with buttons (menu)
coffee
thee
Interfaces in OO
Class Stack
push
pop
Events: push(v), pop(v)Behavior: ?
Operational Semantics
Labeled Transitions: P Q
• P,Q: Processes =a,b,c,.. , - a,b,c,..: External Events
- : Termination - : Internal action
Computation
P1 P2 P2 …1 2 3
• Finite - successfull termination - deadlock •Infinite - fairness (strong, weak)
The STOP-Process
The process
models inaction
STOP
STOP
Performing Events
Event Prefixing:
Intuitive meaning: do first a then PFormally
(a P) Pa
a P
A Light Bulbonoff(on (off stop)) (off stop)
(off stop) stop
on
off
Finite Automata
P0 P1 stopon off
P1 = on (off stop))
P1=(off stop)
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
Example
x : coffee,chocolate P(x)
P(coffee) = x : milk,black stop
P(chocolate) = x : hot, cold stop
Example (Cont’d)
(x : coffee,chocolate P(x))
(x : milk,black stop)stop
coffee
milk
Example (Cont’d)
P0
P1
P2
stop
coffee
chocolate
hot cold
milk
black
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
Example: A Simple Filter
in?x out!op(x) stop
opin out
Unix-Shell Scripts
ECHO ! “please enter your name”
READ ? name
ECHO ! “welcome name” stop
RecursionN=P
N: nameP: process
Example: light = on (off light)
P Q
N QN=P
The Light Bulb (again)
(on (off light)) (off light)on
light on (off light)
lighton
P
off
The Dining Philospher
P=think leftfork rightfork eat P
Cognitive Robotics
Sense-Act Cycle
Cycle= x: Events Act(x)
Act(x) = a(x) Cycle
Deriving Transitions
Proof Rules
1P1 Q1 Pn Qn1…
P Q
Mutual Recursion
Example
LIGHT=on ON
ON=off LIGHT
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)
Computation Graph
count(1) count(2)
inc inc
dec
count(0) count(3)
inc
dec…
dec
External Choice
Syntax
Semantics
P Q
aP P'
P Q P' a P Q P' Q
P P'
Fifo Buffer
bufferin out
B() = in?x B(<x>)
B(<v>.s) = in?x B(<x,v>.s) out!v B(s)
Internal Choice
Syntax
Semantics
P Q
P Q P
Tossing a Coin
Toss = (head Toss) (tail Toss )
toss P
Q
headtail
Termination
The process
indicates successful termination:
SKIP
SKIP STOP
Sequential Composition
Syntax
Semantics
P;Q
P P'
P ; Q P';Q P ; Q Q
P P'
Purchase
Purchase=Choose;Pay
Select= select (SKIP return Select)
Pay= cash receipt SKIP
card swipe (receipt sign SKIP reject Pay)
A One-Time Stack
A Finite Representation
Push = in?x (Push; (out!xSKIP)) pop SKIP
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
Concurrency
Communication:
MessageSender Receiver
• Synchronous• Asynchronous• Broadcast
Rendez-Vous
Caller Calleeparameters
result
suspended methodsynchronization
Parallel Composition
• Interleaving• Synchronization on common actions
P | Q
Architecture
P Qb b
ba c
Interface(P) = {a,b}Interface(Q) = {b,c}
Semantics
Interleaving
Synchronization
P P'
P || Q P' || Q
P || Q P' || Q '
P Q'P P'
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
Modeling a False Start
Pi= start finish1 STOP + starti Pi
Interleaving
Syntax
SemanticsP P'
P ||| Q P' ||| Q
P ||| Q
The Counter Example Revisited
Count= inc (dec STOP) ||| Count)
dec STOP dec STOP
(dec STOP) ||| Count dec STOP ||| Count
Dynamic Process Creation
Count
(dec STOP) ||| Count
(dec STOP) ||| (dec STOP) ||| Count
inc
inc
A Bag
Syntax
A computation stepBag
Bag = in?x (out!x STOP) ||| Bag)
in.3 (out!3 STOP) ||| Bag)
Buffers
One-place Buffers
A Pipeline
Synchronization on events:
P= c?x d!x PQ= d?x e!x Q
P || Q
d.v
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
Deadlock
Peter and David
Peter= lift-piano Peter lift-table Peter
David= lift-piano David lift-table David
Peter || David
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
Abstraction
Syntax
Semantics
P \ A
P \ A P' \ A
P P'a
a
aAP \ A P' \ A
P P'a
aA
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}
Renaming
Syntax
Semantics
f (P)
f
P f(P')
P P'a
f(a)P f(P')
P P'
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
Set
Set
The Interface
query
addanswer
The Implementation
Node(x) i:Set
query
add
answer
i.query
i.add
i.answer
Set
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}
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
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
Justification
add.5 (Node(5) || f(Set)) \I
f(Set) i.add.5 f ( (Node(5) || f(Set)) \I )
Set
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
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
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)
Multi-Party Communication
Analyze
c!v STOP || c!w STOP || c?x P(x) || c?x Q(x)
Analyzing Processes
Trace =Sequence of Events
Trace Semantics
Trace(P)={ s | P } s
P
P a Q Q s
P a.s
P Q Q s
P s
Compositionality
Trace( op(P1, ... ,Pn) = op(Trace(P1), ... ,Trace(Pn))
syntax semantics
Event Prefixing
Trace(a P)= { } a Trace (P)
Parallel Composition
Trace(P || Q)= { s| sA Trace(P ) sB Trace(Q ) }
A=Interface(P)B=Interface(Q)
Example
Trace(P || Q)= { , a, ab, abc }
P=a b STOPQ=b c STOP
Deadlock
Trace(P || Q)= { }
P=a b STOPQ=b a STOP
Communication
Trace(P || Q)= { , c.v }
P=c!v STOPQ=c?x STOP
Trace(P)={, c.v }Trace(Q)={} {c.w| w Val}
Recursion
Trace(N) = a*
N= a N
Trace(N) = { } a Trace (N)
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)
Choice
Trace(P+Q) = Trace(P) Trace(Q)
a
b c
a a
b c
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'
Bisimulation (Cont’d)
u
P
P'
R Q
u
Q'R
Ready Semantics
Compare
a a
b db e
c e
a a
b db e
c e
b
e c
P Q
Ready Semantics Formally
Ready(P) contains all pairs (s,R) such that
• P • not Q• Q
s Q
a for a in R
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
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 ))
Failure Semantics
Fail(P) contains all pairs (s,F) such that
• P • Q
s Qu for any action u in F {}
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}), ... }
Example II
Fail(a(b STOP cSTOP )) = {(,) , (,{b}) , (,{c}) , (a, ) , (a,{a}) , (ab, ) , (ab,{a}) , (ab,{b}), (ab,{c}), ... }
Ready Failure
Compare
a a
b c cb b c
a a a
The Semantic Hierarchy
Bisimulation Ready Failure Trace
Proof-Theory
Proving semantical equivalences:
P=Q
Equational Logic
Reflexivity P=PAssociativity P=Q Q=R P=RSymmetry P=Q Q=PCongruence P=Q C[P]=C[Q]
Axioms for External Choice
Idempotency P P= PAssociativity P (Q R) = (P Q) RSymmetry P Q = Q PNeutral Element P STOP = STOP
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)
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
Property-Oriented Specification
where is a property in some logic
P sat
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)
Modal Logic
Fornulas
true | false | [a] | ... Example <a>true means there exists an a transition
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.