Prolag is defined as standard Prolog extended with communication
capabilities and with safe
state updates.
Two predicates allow an agent to update its state.
assert_state(Fact) asserts Fact to the agent's state.
Its implementation is safe since, when the predicate is backtracked,
the previously asserted fact is removed from the state.
retract_state(Fact) removes the first fact in the agent's state
that unifies with Fact. If it is backtracked, the fact is
re-asserted.
Three predicates allow an agent to
inspect its mail-box and read messages from it.
sync_receive(Message) blocks the calling agent until a message
unifying with Message enters the mail-box.
async_receive_one(Msg_input, Msg_output) searches the
calling agent's mail-box for a message unifying with Msg_input.
If such a message is present, Msg_output is unified with it, otherwise
Msg_output unifies with the atom no_message.
async_receive_all(List_of_messages) fetches all the messages
in the the mail-box of the calling agent. These messages are unified with
List_of_messages.
One predicate allows an agent to send a message.
send(Receiver, Message) sends Message from the
calling agent to the agent Receiver.
The send predicate is implemented using the safe update predicates
assert_state and
retract_state. These predicates are actually called to execute
updates to the agents' mail-boxes.