Another example

Consider the following action rule:
   p(X,Y), {event(X,O),event(Y,O)} => write(O).
An agent, which is attached to both X and Y, echoes the event object when the agent is activated by an event. The following gives several sample queries and their expected outputs:

# Query Output
1 p(X,Y),post_event(X,a) a
2 p(X,Y),post_event(Y,b) b
3 p(X,Y),post_event(X,a),post_event(Y,b) ab
4 p(X,Y),post_event(X\/Y,c) c
5 p(X,Y),post_event(X/\Y,c) c
6 p(X,Y),p(U,V),post_event(X\/U,c) cc
7 p(X,Y),p(U,V),post_event(X/\U,c)  
8 p(X,Y),p(U,V),X=U,post_event(X/\U,c) cc

Query number 7 does not generate output, since no agent is attached to either of the channels X and U. When two channels are unified, the younger variable is set to reference the older one,12.2 and all of the agents that are attached to the younger variable are copied to the older one. So, in query number 8, after X=U, X and U become one variable, and the two agents p(X,Y) and p(U,V) become attached to the variable. Therefore, after post_event(X/\U,c), both of the agents are activated. In the examples, the queries will give the same outputs if post_event_df is used instead of post_event. This is generally not the case, if an action rule also posts events.

Neng-Fa Zhou 2013-01-25