130 likes | 225 Views
Interaction Example (Recap). General. Specific. a(requester, A) ::= ask(X) => a(informer, B) query_from(X, B) then tell(X) <= a(informer, B) then a(requester, A) a(informer, B) ::= ask(X) <= a(requester, A) then tell(X) => a(requester, B)
E N D
Interaction Example (Recap) General Specific a(requester, A) ::= ask(X) => a(informer, B) query_from(X, B) then tell(X) <= a(informer, B) then a(requester, A) a(informer, B) ::= ask(X) <= a(requester, A) then tell(X) => a(requester, B) know(X) a(requester, a1) ::= ask(p(Y)) => a(informer, a2) then tell(p(Y)) <= a(informer, a2) then a(requester, a1) Agent a1 Agent a2 ask(p(Y)) query_from(p(Y), a2)
Interaction Example (Recap) Specific General a(requester, A) ::= ask(X) => a(informer, B) query_from(X, B) then tell(X) <= a(informer, B) then a(requester, A) a(informer, B) ::= ask(X) <= a(requester, A) then tell(X) => a(requester, B) know(X) a(requester, a1) ::= ask(p(Y)) => a(informer, a2) then tell(p(Y)) <= a(informer, a2) then a(requester, a1) a(informer, a2) ::= ask(p(Y)) <= a(requester, a1) then tell(p(Y)) => a(requester, a1) know(p(Y)) Agent a1 Agent a2 ask(p(Y))
Interaction Example (Recap) General Specific a(requester, A) ::= ask(X) => a(informer, B) query_from(X, B) then tell(X) <= a(informer, B) then a(requester, A) a(informer, B) ::= ask(X) <= a(requester, A) then tell(X) => a(requester, B) know(X) a(requester, a1) ::= ask(p(Y)) => a(informer, a2) then tell(p(Y)) <= a(informer, a2) then a(requester, a1) a(informer, a2) ::= ask(p(a)) <= a(requester, a1) then tell(p(a)) => a(requester, a1) Agent a1 Agent a2 tell(p(a)) know(p(a))
Interaction Example (Recap) Specific General a(requester, A) ::= ask(X) => a(informer, B) query_from(X, B) then tell(X) <= a(informer, B) then a(requester, A) a(informer, B) ::= ask(X) <= a(requester, A) then tell(X) => a(requester, B) know(X) a(requester, a1) ::= ask(p(a)) => a(informer, a2) then tell(p(a)) <= a(informer, a2) then a(requester, a1) ::= ask(X) => a(informer, B) query_from(X, B) then tell(X) <= a(informer, B) then a(requester, a1) a(informer, a2) ::= ask(p(a)) <= a(requester, a1) then tell(p(a)) => a(requester, a1) Agent a1 Agent a2 tell(p(a))
Protocol Rewriting Example (1) a(requester, A) ::= c(ask(X) => a(informer, B)) then tell(X) <= a(informer, B) then a(requester, A) a(requester, A) ::= ask(X) => a(informer, B) query_from(X, B) then tell(X) <= a(informer, B) then a(requester, A) ask(X) => a(informer, B) query_from(X, B) c(ask(X) => a(informer, B)) (and the appropriate message is sent)
Protocol Rewriting Example (2) a(requester, A) ::= c(ask(X) => a(informer, B)) then tell(X) <= a(informer, B) then a(requester, A) a(requester, A) ::= c(ask(X) => a(informer, B)) then c(tell(X) <= a(informer, B)) then a(requester, A) tell(X) <= a(informer, B) c(tell(X) <= a(informer, B)) (if the appropriate message has been received)
Protocol Rewriting Example (3) a(requester, A) ::= c(ask(X) => a(informer, B)) then c(tell(X) <= a(informer, B)) then a(requester, A) ::= ask(X) => a(informer, B) query_from(X, B) then tell(X) <= a(informer, B) then a(requester, A) a(requester, A) ::= c(ask(X) => a(informer, B)) then c(tell(X) <= a(informer, B)) then a(requester, A) a(requester, A) ::= …. a(requester, A)
Protocol Rewriting Role ::= Def Role ::= E Def E A or _ E A E _ or B E B E A then B E then B A E A then B A then E closed(A), B E C M <= A c(M <= A) message_in(M), k(C). M => A C c(M => A) k(C), message_out(M). a(R,X) C a(R,X) ::= Def k(C), pclause(a(R,X) ::= Def). null C c(null) k(C). closed(X) means that part X of the protocol has been completed. message_in(M) means that the agent has received message M message_out(M) puts message M in the agent’s output buffer. k(C) means C is believed by the agent.
Protocol Rewriting expand(Role ::= Def, Role ::= E) :- expand(Def, E). expand(A or _, E) :- expand(A, E). expand(_ or B, E) :- expand(B, E). expand(A then B, E then B) :- expand(A, E). expand(A then B, A then E) :- closed(A), expand(B, E). expand(C M <= A, c(M <= A)) :- message_in(M), k(C). expand(M => A C, c(M => A)) :- k(C), message_out(M). expand(a(R,X) C, a(R,X) ::= Def) :- k(C), pclause(a(R,X) ::= Def). expand(null C, c(null)) :- k(C).
Exhaustive Rewriting expansion(Clause, Final) :- expand(Clause, Expanded), expansion(Expanded, Final). expansion(Clause, Clause) :- \+ expand(Clause, _).
Deciding when a Protocol is Closed closed(c(_)). closed(A or _) :- closed(A). closed(_ or B) :- closed(B). closed(A then B) :- closed(A), closed(B). closed(_ ::= Def) :- closed(Def).
Satisfying a Constraint (Example) k(A and B) :- !, k(A), k(B). k(X) :- meta_pred(X, Call), !, Call. k(X) :- \+ meta_pred(X, _), call_direct(X), X. meta_pred(not(X), \+ k(X)). meta_pred(setof(E,G,S), setof(E,k(X),S)). call_direct(X) :- (predicate_property(X, built_in) ; predicate_property(X, interpreted) ; predicate_property(X, imported_from(_))), !.
Asynchronous Interaction Constraint solver Protocol expander Send to server Fetch from server Linda server Agent a2 Agent a1 out in tuple space holds Prolog clauses can add or remove blocking/unblocking read