Title: DALI Multiagent System
1DALI Multiagent System
2How to create and use a DALI Agent Summary
- How the DALI Interpreter starts
- (provided you have installed Sicstus Prolog)
- How to create an agent
- the DALI initialization file
- How to write a DALI logic program
- Architecture of the DALI Interpreter
- Examples
3How the DALI Interpreter starts
active_dali.pl/ active_dali.exe
active_server.pl/ active_server.exe
. . .
active_user.pl/ active_user.exe
active_dali.pl/ active_dali.exe
In order to start the DALI Multiagent System its
necessary to activate the server, next the user
module, finally one or several DALI agents.
4active_server.pl/ active_server.exe
How the Server starts
bin
demo
program
We can activate the DALI server either by
invoking the the executable file
active_server.exe or, via the Sicstus Prolog
shell, by loading the file active_server.pl.
This is the command to load the server, that you
can fond in the demo directory load_files('C/Pr
ogrammi/SICStus Prolog 3.11.1/bin/demo/active_serv
er.pl').
5active_user.pl/ active_user.exe
How the User Module starts
We can activate the DALI user module either by
using the active_user.exe executable file or,
via the Sicstus Prolog shell, by loading the file
active_user.pl. This is the command to load
the file that you can find in the demo
directory load_files('C/Programmi/SICStus
Prolog 3.11.1/bin/demo/active_user.pl'). The
user module opens a user window for communicating
with DALI agents, as explained later on.
The name of the Receiver agent
The language of the message
The list of terms useful to interprete a message
The name of the Sender agent
The content of the message
6active_dali.pl/ active_dali.exe
How the DALI Interpreter starts
We can activate the DALI Interpreter either by
using the executable file acive_dali.exe or,
via the Sicstus Prolog shell, by loading the file
active_dali.pl. This is the command to load
the file that you can find in the demo
directory load_files('C/Programmi/SICStus
Prolog 3.11.1/bin/demo/active_dali.pl'). The
interpreter will ask the name of the
initialization file Insert the path and the
name of the initialization file
'demo/help.txt'. And, after this information,
the agent will be activated ..................
Actived Agent ...................
DALI logic program
In this way it is possible to activate several
DALI agents having different names and logic
programs.
7DALI initialization file
- The initialization file ltinitgt.txt must be in the
directory demo, and contains the following
informations - The name of the file that contains the DALI logic
program - The name of the agent
- The adopted ontology (a txt file)
- The adopted language (Italian,English,) in the
communication acts - The name of the file containing the tell/told
communication constraints - The name of the communication library
- The agents abilities ( kind of work, hobbies,)
- These parameters are grouped in a string with
prefix agent, according to the above order,
with the syntax exemplified below.
8DALI initialization file example
- Example content of the initialization file
- agent('demo/program/italian',gino,
- 'demo/pippo_ontology.txt',italian,
- 'demo/communication',
- 'demo/communication_fipa',tourist).
- The path is specified starting either from the
directory bin - if we use the Sicstus Prolog shell or starting
from the - directory where the interpreter is if we use the
DALI - executable file.
9DALI initialization file example
- Precisely
- gino is the name of the agent,
- ontology.txt is the ontology file in the
directory demo - and Italian is the language spoken by the agent.
- Finally, communication is the file
communication.con in the directory demo
containing the tell/told constraints and
communication_fipa is the library with the fipa
communications primitives. - The last papameter suggests that the agent is a
tourist. - At this point, we can write a DALI logic program
with .txt extension and put it in the directory
program.
10Generate a DALI initialization file
- In the initialization string (see above) we put
the initialization file under the - directory demo and the DALI logic program file
file_dali.txt in the directory program
bin
demo
program
11active_user.pl/ active_user.exe
How the User Module works
The user module allows the user to communicate
with an existing DALI agents, by means of the
DALI primitive send_message(Content,Sender) where
Senderuser and Content is an external event we
want the agent to perceive. will ask the
following arguments Insert name of addressee
pippo.
Insert Language
italian.
Insert Ontology
. Insert From user. Insert message
send_message(danger,user).
The name of the Receiver agent
The language of the message
The list of terms useful to interprete a message
The name of the Sender agent
The content of the message
12How to use Ontologies in the User Module (simple
way, to be further developed)
If we have for instance, in the DALI logic
program, the following reactive
rule dangerEgtonce(ask_for_help). ask_for_help-
call_policeA. call_policelthave_a_phoneP. ask_for_
help-screamA. If we tell the agent that
pericolo is equivalent to danger, we can
then send the message send_message(pericolo,user).
Insert name of addressee pippo.
Insert Language italian.
Insert Ontology danger. this is to be
replaced in place of the following event Insert
From user. Insert message
send_message(pericolo,user).
13Write DALI logic program
A Dali program is a file txt whose content is a
DALI program. Now we shortly recall the main
features of this language by writing a DALI
agent
External events The external events are
syntactically indicated by the postfix E. When an
event enters the agent from its external world,
she can perceive it and decide to react. The
reaction is defined by a reactive rule which has
in its head that external event. The special
token gt, used instead of -, indicates that the
reactive rule performs forward reasoning. If we
write in the txt file this simple reactive
rule alarm_clock_ringsEgtstand_upA the agent
observes the following behavior. We use the user
module to send to the agent the external event
alarm_clock_rings.
14Write DALI logic programExternal Event
Insert name of addressee pippo. Insert
Language italian. Insert Ontology
. Insert From user. Insert message
send_message(alarm_clock_rings,user).
Nome file alarm.txt
The DALI agent will do the action contained in
the body of the reactive rule.
15Write DALI logic programInternal Event
Internal events The internal events define a
kind of individuality of a DALI agent, making her
proactive independently of the environment, of
the user and of the other agents, and allowing
her to manipulate and revise her knowledge. An
internal event is syntactically indicated by the
postfix I, and its description is composed of two
rules. The first one contains the conditions
(knowledge, past events, procedures, etc.) that
must be true so that the reaction (in the second
rule) may happen. If we write in the txt file
those two rules i_am_lazy-alarm_clock_ringsP
not(stand_upP) i_am_lazyIgt
i_take_a_vacation_dayA. the agent exhibits the
following behavior. We use the user module to
send to the agent the past event
alarm_clock_ringsP but this past event could be
the past form of the external event as specified
in the previous paragraph, and arrived
before.
16Write DALI logic programExternal Event
Insert name of addressee pippo. Insert
Language italian. Insert Ontology
. Insert From user. Insert message
confirm(alarm_clock_rings,user).
Nome file alarm_clock.txt
The DALI agent will make the action contained in
the reaction of the internal event.
17Write DALI logic programPresent Event
Present events When an agent perceives an event
from the external world it does not necessarily
react to it immediately she has the possibility
of reasoning on the event, before (or instead of)
triggering a reaction. Reasoning also allows a
proactive behavior. In this situation, the event
is called present event and is indicated by the
suffix N. arrives_someone-bell_ringsN. arrives_s
omeoneIgtget_dressedA. get_dressedlt
get_undressedP. bell_ringsEgtopen_the_doorA. In
this case, when we send the external event
bell_rings to the agent, she makes the actions
get_dressed and open_the_door if the internal
event has been processed before the external
event. Else, she does only the action
open_the_door. In small DALI programs is unlikely
to observe the reaction to the internal event,
because the processing of the external events is
faster and the interpreter, after the action
open_the_door, erases the reaction to the
internal event.
18Write DALI logic programPresent Events
Insert name of addressee pippo. Insert
Language italian. Insert Ontology
. Insert From user. Insert message
send_message(bell_rings,user).
Nome file wear.txt
19Write DALI logic programActions
Actions
- Simple actions
- The action in the DALI program is specified
as actionA. - For example i_go_to_bedA, i_take_the_busA,
- When the agent does an action, on the
prolog shell you can observe make(action). -
- Messages as actions
- From a DALI program, a message can be sent
by writing -
- messageA(To, Content)
- where To is the name of the agent that
must receive the communication act and Content
is the DALI/FIPA primitive.
20Write DALI logic programActions
- We now describe the primitives used in a DALI
program. - Sender is the agent that sends the message.
- send_message(External_event, Sender)
- this primitive is used to call an external
event within a reactive rule - confirm(Assertion, Sender)
- this primitive is used to assert a fact
within a DALI agent - disconfirm(Assertion, Sender)
- this primitive is used to retract a fact
within a DALI agent - propose(Action, List_Conditions,Sender)
- this primitive is used to propose an agent
to do an action contained within a DALI program.
The agent can respond by accepting to do the
action (accept_proposal) or by rejecting the
proposal (reject_proposal) if the conditions in
the message are false. When the agent decides to
make the action, she verifies if the conditions
of the action rule are true. In this case, the
agent does the action or else she sends to the
other agent a failure message.
21Write DALI logic programActions
- execute_proc(Head, Sender)
- this primitive is used to invoke the head of
a generic rule (procedure) in the DALI program - query_ref(Fact, N, Sender)
- this primitive is used to answer an agent on
some information about a not ground Fact. N is
the number of the requested matchings - agree(Fact, Sender)
- this primitive is used to answer an agent
knowing a ground Fact - cancel(Action, Sender)
- this primitive is used to communicate to an
agent to cancel a requested action. Also in this
case, it is difficult to see the effect of this
primitive because the agent does immediately the
action. To see the effect, the queue of actions
must contain several items.
22Write DALI logic program Goals
A goal is an objective that an agent must reach.
In the DALI language, a goal is a particular
internal event that the interpreter begins to
attempt when it is invoked. The goal has a
postfix G.
How it works
Environment State
...,goal1G,... goal1- condition11,...,condition1
k subgoal11G,...,subgoal1NG, subgoalP11,...,subgoa
lP1N. ... goal1-conditionm1,...,conditionmk subg
oalGm1,...,subgoalGmN, subgoalP11,...,subgoalP1N.
goal1Igtaction1,...,goal2G,...,actionk.
PLANNER
Goal
Plan to reach a goal
Actions
23Write DALI logic program Goals
We consider a simple example an agent must wear
socks and shoes.
goEgtput_shoesG. put_shoes-put_right_shoeG,put_le
ft_shoeG,right_shoe_onP, left_shoe_onP. put_shoesI
gtleft_and_right_shoes_onA, retractall(past(_,_,_)
). put_right_shoe-put_right_sockG,right_sock_onP
. put_right_shoeIgtright_shoe_onA. put_left_shoe
-put_left_sockG,left_sock_onP. put_left_shoeIgtlef
t_shoe_onA. put_right_sock-have_right_sockP. put
_right_sockIgtright_sock_onA. put_left_sock-have
_left_sockP. put_left_sockIgtleft_sock_onA.
24Write DALI logic program Goals
Insert name of addressee pippo. Insert
Language italian. Insert Ontology
. Insert From user. Insert message
confirm(have_left_sock,user).
Insert name of addressee pippo. Insert
Language italian. Insert Ontology
. Insert From user. Insert
message confirm(have_right_sock,user).
Insert name of addressee pippo. Insert
Language italian. Insert Ontology
. Insert From user. Insert message
send_message(go,user).
Nome file shoes.txt
25Write DALI logic program Past events
- Past events
- A past event, indicated by the suffix P, is
- an external or internal event after a reaction
- an executed action
- a reached goal or subgoal
- a fact communicated using a confirm primitive.
-
Insert name of addressee pippo. Insert
Language italian. Insert Ontology
. Insert From user. Insert message
confirm(rain,user).
past(rain,timestamp, user) is recorded within
DALI shell. This past event is called using the
string with postfix P. For example, rainP.
26The architecture of a DALI agent
Pre-processing
file.txt
Processing Events Actions Goals
Communication module
Communication module
27The files that the interpreter generates from
DALI txt file
28A simple txt DALI file
We use this txt file to show how the interpreter
works creating ple, plf and pl files. In order to
show the naming process we use a new example
containing variables.
External event
dangerEgtonce(ask_for_help). ask_for_help-call_po
liceA. call_policelthave_a_phoneP. ask_for_help-s
creamA. remain_at_home-dangerP,call_policeP. rem
ain_at_homeIgtgo_to_bathroomA,
close_the_doorA. go_out-dangerP,sc
reamP. go_outIgtgo_to_neighbourA.
Reaction rule
Past event
Action rule
Action
Internal event
29What the Interpreter records in the ple file
External events
danger. remain_at_home,go_out,external_refuse
d_action_propose(A,Ag), refused_message(AgM,Con).
call_police,scream,go_to_bathroom,close_the_do
or,go_to_neighbour,message(Ag,inform(query_ref(X,N
),values(L),A)),message(Ag,refuse(query_ref(variab
le),motivation(refused_variables),A)),message(Ag,i
nform(query_ref(X,N),motivation(no_values),A)),mes
sage(Ag,inform(agree(X),values(yes),A)),message(Ag
,inform(agree(X),values(no),A)). call_police
. . . .
Internal events
Conditions
Actions
Present events
Goals to reach
This file is used by the interpreter to manage
the behavior of the agent through the classes of
the events, the actions, goals,
Goals to test
30The naming of variables in the pl file
Dali pl program with reified variables
eve(predator_attacks(var_X))-
once(try_to_escape(var_X)).try_to_escape(var_X)-
a(fly(var_X)).try_to_escape(var_X)-
a(run(var_X)).cd(fly(var_X))-
evp(bird(var_X)),
not(evp(abnormal(var_X))).
Interpreter work
Dali txt program
predator_attacksE(X)gt once(try_to_escape(X)). try
_to_escape(X)-flyA(X). try_to_escape(X)-runA(X).
fly(X)ltbirdP(X),not(abnormalP(X)).
The interpreter generates a pl file where all
rules are subjected to naming process. All
variables has been transformed to costants using
the suffix var_.
31The directives of plf file
We use this file to set some parameters that
determine the behavior of the agent relatively
to external, internal, past events and actions .
External event We can decide if an external
event must be processed with a normal or high
priority external_event(Event,normal). external
_event(Event,high).
Past event We can decide how long or until
which condition a past event must be kept in the
memory of an agent past_event(Event,Seconds).
(the past event is kept in memory some
Seconds) past_event(Event,forever). (the past
event is kept in memory forever) past_event(Event
,until(Cond)). (the past event is kept in memory
until Condition)
Action We can decide if an action must be
processed with a normal or high
priority action(Action,normal). action(Action,h
igh).
Action/Message We can decide if to submit a
message to tell the tell check mod(Action,
check).
32The directives of plf file
Now we examine the directives on internal events.
- Internal event
- We can set several parameters for an internal
event in order to tune the - Interpreter behaviour
- the frequency(seconds) with which the
interpreter attempts the internal event - how many times the agent must react if the
internal event is true (1,2,..,forever) - when the agent must react this parameter is
true if the reaction must happen - forever or else we can link the reaction to
some past events belonging to body - of the first rule of the internal event when
the past event inside a change list - is modified the agent will be able to react
again. - For example, if we have the internal event
-
- think-rainP, go_outP,buy_umbrellaP.
- thinkIgtopen_the_umbrellaA.
- we can set parameters as
33Some directives of plf example file
action(call_police,normal). action(scream,normal).
action(go_to_bathroom,normal). action(close_the_d
oor,normal). action(go_to_neighbour,normal). exter
nal_event(danger,normal). past_event(danger,20).
past_event(remain_at_home,20). past_event(go_out,2
0). past_event(call_police,20). past_event(scream,
20). past_event(go_to_bathroom,20). past_event(clo
se_the_door,20). past_event(go_to_neighbour,20).
internal_event(remain_at_home,3,forever,true,unt
il_cond(past(remain_at_home))). internal_event(go_
out,3,forever,true,until_cond(past(go_out))). mod
(message(_,inform(_,motivation(refused_message),_)
),check).
The action is put in the queue with normal
priority
This past event is kept in memory 20 seconds
This internal event is attempted every 3 seconds
The agent will react forever
We specify no conditions
This internal event is attempted until the past
event remain_at_home becomes true
This message is submitted to tell check
34The Communication architecture
Incoming message
The message passes this level only if the
corresponding told rule is true.
TOLD CHECK
If the agent doesnt know the content of the
message, she calls the meta-level and uses the
ontology and/or other properties in order to
understand the communication act.
META LEVEL
DALI INTERNAL INTERPRETER
The message, submitted to tell check, is sent
only if the corresponding tell rule is true.
TELL CHECK
Outcoming message
35The Told Check level
Each DALI agent has a con file, specified in
the initialization file, that contains the
told/tell rules. These rules, external to
interpreter, can be modified by the user. The
structure of a told rule is told(Sender,Content)
-constraint1,,constraintn. In this example, an
agent receives a message, using the primitive
send_message, only if the Sender agent isnt an
enemy told(Ag,send_message(_))-not(enemyP(Ag))
. A message that does not go through the told
level is eliminated. The agent Sender receives
an inform message asserted as a past event.
36The Meta-Level
META LEVEL
Each DALI agent uses an (optional) meta procedure
written in the communication.con file that
specifies how the entity can interprete an
unknown message. This procedure can be modified
by the user. In the initialization file the user
can specify the ontology txt file that the agent
must use. This file contains some strings with
the following prefix and parameters ontology(Age
nt_name, Term1,Term2). where Agent_name is the
name of the agent that can use the association of
terms Term1 and Term2. In this file the user
can write some properties of terms useful to
meta-procedure. For example symmetric(love(juli
e,tom)). specifies that the term love is
symmetric.
37The Tell Check level
TELL CHECK
Outcoming message
The user can set the mod string in the plf file
in order to submit a message to tell check. In
this case, the message is actually sent only if
the corresponding tell rule is true. The tell
rules can be modified by the user. The structure
of a tell rule is tell(Receiver,Sender,Content)
-constraint1,,constraintn. In this example, an
agent sends a message, using the primitive
send_message, only if she has a trust greater
than 4 in the Receiver agent tell(To,_,send_mess
age(_))-trustP(_,To,N),Ngt4. A message that does
not go through the tell level is eliminated.
38Examples A dangerous situation
One Agent!
39Examples A dangerous situation
Initialization file name help.txt DALI logic
file name help.txt
bin
demo
program
40Examples A dangerous situation
DALI logic program help.txt
dangerEgtonce(ask_for_help). ask_for_help-call_po
liceA. call_policelthave_a_phoneP. ask_for_help-s
creamA. remain_at_home-dangerP,call_policeP. rem
ain_at_homeIgtgo_to_bathroomA,
close_the_doorA. go_out-dangerP,sc
reamP. go_outIgtgo_to_neighbourA.
41Examples A dangerous situation
Run the DALI logic program
Inserire il percorso ed il nome del file di
inizializzazione 'demo/help.txt'.
Insert name of addressee pippo. Insert
Language italian. Insert Ontology
. Insert From user. Insert message
send_message(danger,user).
.................. Actived Agent
................... make(scream) make(go_to_neigh
bour)
42Examples A dangerous situation
If the agent has a phone
New message Insert name of addressee pippo.
Insert Language italian.
Insert Ontology .
Insert From user. Insert
message confirm(have_a_phone,user). New
message Insert name of addressee pippo.
Insert Language italian.
Insert Ontology .
Insert From user.
Insert message send_message(danger,user).
she reacts differently!
.................. Actived Agent
................... make(call_police) make(go_to_
bathroom) make(close_the_door)
43Examples Error Recovery planning
Two Agents!
44Examples Error Recovery planning
Initialization file name recovery.txt and
sensor.txt DALI logic file name recovery.txt and
sensor.txt
bin
demo
program
45Examples Error Recovery planning
DALI logic program recovery.txt
error_recovery(M,M1)-go_rightP(_,M),goal(M),infor
mP(reality(M,M1),sensor),M\M1. error_recovery(M,M
1)-go_leftP(_,M),goal(M),informP(reality(M,M1),se
nsor),M\M1. error_recovery(M,M1)-go_forwardP(_,M
),goal(M),informP(reality(M,M1),sensor),M\M1. err
or_recoveryI(M,M1)gtrecovery_errorA(M,M1),drop_pas
tA(reality(M,M1)). reached_goal(M)-go_rightP(_,M
),goal(M). reached_goal(M)-go_leftP(_,M),goal(M).
reached_goal(M)-go_forwardP(_,M),goal(M). reache
d_goalI(M)gtclause(agent(Ag),_),
messageA(sensor,send_message(what_about_my_positi
on(M,Ag),Ag)). right(exit1,bank1). right(exit2,b
ank2). left(bank1,hospital1). forward(bank2,bank1)
. goal(hospital1).
46Examples Error Recovery planning
DALI logic program sensor.txt
what_about_my_positionE(M,Ag)gtonce(examine_positi
on(M,Ag,_)). examine_position(M,Ag,M1)-messageA(
Ag,inform(reality(M,M1),sensor)),wrong_positionA(M
,Ag). message(_,inform(reality(M,M1),sensor))lterr
orP(M,M1). examine_position(M,Ag,_)-right_positi
onA(M,Ag).
47Error Recovery planning
The environment
Hospital
Bank2
Bank1
Exit1
Exit2
STATION
48Error Recovery planning
First situation the agent exits from Exit1 and
goes to Hospital1
Hospital
Bank2
Bank1
Exit1
Exit2
make(go_right(exit1,bank1)) make(go_left(bank1,hos
pital1))
confirm(i_am_at_exit(exit1),user)
STATION
49Examples Error Recovery planning
Run the DALI logic programs recovery.txt and
sensor.txt
Insert name of addressee pippo. Insert
Language italian. Insert Ontology
. Insert From user. Insert message
confirm(i_am_at_exit(exit1),user).
sensor
.................. Actived Agent
................... make(right_position(hospital1,
pippo))
robot pippo
.................. Actived Agent
................... make(go_right(exit1,bank1)) ma
ke(go_left(bank1,hospital1)) send_message_to(senso
r,send_message(what_about_my_position(hospital1,pi
ppo), pippo),italian,)
50Error Recovery planning
Second situation the agent exits from Exit2 and
goes to Hospital1
Hospital
Bank2
Bank1
make(go_right(exit2,bank2)) make(go_forward(bank2,
bank1)) make(go_left(bank1,hospital1))
Exit1
Exit2
confirm(i_am_at_exit(exit2),user)
STATION
51Examples Error Recovery planning
Run the DALI logic programs recovery.txt and
sensor.txt
Insert name of addressee pippo. Insert
Language italian. Insert Ontology
. Insert From user. Insert message
confirm(i_am_at_exit(exit2),user).
sensor
.................. Actived Agent
................... make(right_position(hospital1,
pippo))
robot pippo
.................. Actived Agent
................... make(go_right(exit2,bank2)) ma
ke(go_forward(bank2,bank1)) make(go_left(bank1,hos
pital1)) send_message_to(sensor,send_message(what_
about_my_position(hospital1,pippo), pippo),italian
,)
52Error Recovery planning
Hospital1
Hospital1
?
Bank2
Bank1
Exit1
Exit2
make(go_right(exit1,bank1)) make(go_left(bank1,hos
pital1)) make(recovery_error(hospital1,bank2)) mak
e(go_forward(bank2,bank1)) make(go_left(bank1,hosp
ital1))
Third situation the agent thinks to be at
Exit1 while really she is at Exit2. When she is
at Hospital1/Bank2 a planner recognizes the
error and modifies the plan.
STATION
53Examples Error Recovery planning (step1)
Run the DALI logic programs recovery.txt and
sensor.txt
Insert name of addressee sensor. Insert
Language italian. Insert Ontology
. Insert From user. Insert message
confirm(error(hospital1,bank2),user).
sensor
.................. Actived Agent
...................
54Examples Error Recovery planning (step2)
Run the DALI logic programs recovery.txt and
sensor.txt
Insert name of addressee sensor. Insert
Language italian. Insert Ontology
. Insert From user. Insert message
confirm(i_am_at_exit(exit1),user).
sensor
.................. Actived Agent...............
send_message_to(pippo,inform(reality(hospital1, b
ank2),sensor),italian,) make(wrong_position(hosp
ital1,pippo))
robot pippo
.................. Actived Agent
................... make(go_right(exit1,bank1)) ma
ke(go_left(bank1,hospital1)) send_message_to(senso
r,send_message(what_about_my_position(hospital1,pi
ppo),pippo), italian,) make(recovery_error(hospi
tal1,bank2)) make(go_forward(bank2,bank1)) make(go
_left(bank1,hospital1))
55Examples Informations and Meta-reasoning
Two Agents!
56Examples Informations and Meta-reasoning
Initialization file name agent1.txt and
agent2.txt DALI logic file name agent1.txt and
agent2.txt
bin
demo
program
57Examples Informations and Meta-reasoning
We will consider two simple agents. We are
interested in showing how the communication
primitives query_ref and agree use the meta-level
reasoning.
DALI logic program agent1.txt
rainE-open_the_umbrellaA.
DALI logic program agent2.txt
i_am_illEgtgo_to_family_doctorA.
58Examples Informations and Meta-reasoning
We will communicate to agent1 the fact
ama(james,julia). In the ontology that the agent
pippo adopts there is the fact ontology(pippo,
ama,love).
Run the DALI logic program agent1.txt
Insert name of addressee pippo. Insert
Language italian. Insert Ontology
. Insert From user. Insert message
confirm(ama(james,julia),user).
59Examples Informations and Meta-reasoning
Agent2 will ask agent1 about the james/julia
love. The agent2 pino will use the
communication primitives query_ref and agree.
Run the DALI logic program agent2.txt
New message Insert name of addressee pippo.
Insert Language italian.
Insert Ontology .
Insert From pino.
Insert message query_ref(ama(julia,Y),1,pino).
.................. Actived Agent
................... send_message_to(pino,inform(qu
ery_ref(ama(julia,fdvar_9),1),values(ama(james,ju
lia)), pippo),italian,)
(fdvar is the reification method of the Sicstus
Prolog)
60Examples Informations and Meta-reasoning
New message Insert name of addressee pippo.
Insert Language italian.
Insert Ontology .
Insert From pino.
Insert message query_ref(love(julia,Y),1,pino)
.
.................. Actived Agent
................... send_message_to(pino,inform(qu
ery_ref(love(julia,fdvar_10),1),values(ama(james,
julia)),pippo),italian,)
61Examples Informations and Meta-reasoning
New message Insert name of addressee pippo.
Insert Language italian.
Insert Ontology .
Insert From pino.
Insert message agree(love(julia,james),pino).
.................. Actived Agent
................... send_message_to(pino,inform(ag
ree(love(julia,james)),values(yes),pippo),italian,
)
62Examples Cooperation and Ontology
Three Agents!
63Examples Cooperation and Ontology
Initialization file name italian.txt,
english.txt and translator.txt DALI logic file
name italian.txt, english.txt and
translator.txt
64Examples Cooperation and Ontology
DALI logic program italian.txt
questionE(Q,L,M)gtagente(A,_,_,_),
once(examine_question(Q,L,M,A)). examine_question
(Q,_,M,A)-messageA(M,send_message(know(Q,A),A)).
message(_,send_message(know(Q,A),A))ltclause(know(
Q,A),_)knowP(Q,A). examine_question(Q,L,M,A)-me
ssageA(translator,send_message(translate(Q,L,M,A),
A)). message(translator,send_message(translate(_,L
,_,_),_))lt Lenglish. examine_question(Q,L,M,A)
-messageA(M,send_message(not_know(Q,L,A),A)). mess
age(_,send_message(not_know(_,L,_),_))lt
Litalian. know(io,gino). know(amo,gino). know
(odio,gino).
ITALIAN
65Examples Cooperation and Ontology
DALI logic program italian.txt
questionE(Q,L,M)gtagente(A,_,_,_),
once(examine_question(Q,L,M,A)). examine_question
(Q,_,M,A)-messageA(M,send_message(know(Q,A),A)).
message(_,send_message(know(Q,A),A))ltclause(know(
Q,A),_)knowP(Q,A). examine_question(Q,L,M,A)-me
ssageA(translator,send_message(translate(Q,L,M,A),
A)). message(translator,send_message(translate(_,L
,_,_),_))lt Lenglish. know(io,gino). know(amo
,gino). know(odio,gino).
ITALIAN
66Examples Cooperation and Ontology
DALI logic program english.txt
questionE(Q,L,M)gtagente(A,_,_,_),
once(examine_question(Q,L,M,A)). examine_question
(Q,_,M,A)-messageA(M,send_message(know(Q,A),A)).
message(_,send_message(know(Q,A),A))ltclause(know(
Q,A),_)knowP(Q,A). examine_question(Q,L,M,A)-me
ssageA(translator,send_message(translate(Q,L,M,A),
A)). message(translator,send_message(translate(_,L
,_,_),_))lt Litalian. know(i,susy). know(love
,susy). know(hate,susy). know(you,susy).
67Examples Cooperation and Ontology
DALI logic program translator.txt
translateE(Q,L,M,A)gtonce(examine_translation(Q,L,
M,A)). examine_translation(Q,_,M,A)-clause(transl
ated(Q,Tr),_),
messageA(A,send_message(question(Tr,italian,M),tra
nslator)). examine_translation(Q,_,M,A)-translat
edP(Q,Tr),
messageA(A,send_message(question(Tr,italian,M),tra
nslator)). examine_translation(Q,_,M,A)-clause(t
ranslated(Tr,Q),_),
messageA(A,send_message(question(Tr,english,M),tra
nslator)). translated(i,io). translated(love,a
mo). translated(hate,odio). translated(you,te).
68Cooperation and Ontology
The environment
ITALIAN
questionE(Term,Language,From)
ITALIAN
ENGLISH
know(i,susy). know(love,susy). know(hate,susy). kn
ow(you,susy).
know(io,gino). know(amo,gino). know(odio,gino). kn
ow(te,gino).
TRANSLATOR
translated(i,io). translated(love,amo). translated
(hate,odio). translated(you,te).
69Cooperation and Ontology
ITALIAN
ITALIAN
ENGLISH
know(io,_)
know(i,_)
know(amo,_)
know(love,_)
know(te,_)
know(you,_)
evviva_loves_me(susy)
70Examples Cooperation and Ontology
Run the DALI logic programs italian.txt
Insert the path and the name of the
initialization file 'demo/italian.txt'.
Insert name of addressee gino. Insert
Language italian. Insert Ontology
. Insert From susy. Insert message
send_message(question(i,english,susy),susy).
Insert the path and the name of the
initialization file 'demo/english.txt'.
Insert the path and the name of the
initialization file 'demo/translator.txt'.
Insert name of addressee gino. Insert
Language italian. Insert Ontology
. Insert From susy. Insert message
send_message(question(love,english,susy),susy).
Insert name of addressee gino. Insert
Language italian. Insert Ontology
. Insert From susy. Insert message
send_message(question(you,english,susy),susy).
71Examples Cooperation and Ontology
italian/gino
.................. Actived Agent...............
send_message_to(translator,send_message(translate
(i,english,susy,gino),gino),italian,) send_messa
ge_to(susy,send_message(know(io,gino),gino),italia
n,) send_message_to(translator,send_message(tran
slate(love,english,susy,gino),gino),italian,) se
nd_message_to(susy,send_message(know(amo,gino),gin
o),italian,) send_message_to(translator,send_mes
sage(translate(you,english,susy,gino),gino),italia
n,) send_message_to(susy,send_message(know(te,gi
no),gino),italian,) make(evviva_loves_me(susy))
english/susy
.................. Actived Agent...............
make(comprehension) make(comprehension) make(comp
rehension)
translator
.................. Actived Agent
................... send_message_to(gino,send_mess
age(question(io,italian,susy),translator),italian,
) send_message_to(gino,send_message(question(amo
,italian,susy),translator),italian,) send_messag
e_to(gino,send_message(question(te,italian,susy),t
ranslator),italian,)
72Cooperation and Ontology
ITALIAN
ITALIAN
ENGLISH
know(io,_)
know(i,_)
know(odio,_)
know(hate,_)
know(te,_)
know(you,_)
i_will_not_speak_with(susy)
add_pastA(enemy(susy))
told(Ag,send_message(_))-not(enemyP(Ag)).
know(you,_)
Eliminated message
73Examples Cooperation and Ontology
Insert name of addressee gino. Insert
Language italian. Insert Ontology
. Insert From susy. Insert message
send_message(question(hate,english,susy),susy).
Insert name of addressee gino. Insert
Language italian. Insert Ontology
. Insert From susy. Insert message
send_message(question(i,english,susy),susy).
Insert name of addressee gino. Insert
Language italian. Insert Ontology
. Insert From susy. Insert message
send_message(question(you,english,susy),susy).
74Examples Cooperation and Ontology
italian/gino
.................. Actived Agent...............
send_message_to(translator,send_message(translate
(you,english,susy,gino),gino),italian,) send_mes
sage_to(susy,send_message(know(te,gino),gino),ital
ian,) send_message_to(translator,send_message(tr
anslate(i,english,susy,gino),gino),italian,) sen
d_message_to(susy,send_message(know(io,gino),gino)
,italian,) send_message_to(translator,send_messa
ge(translate(hate,english,susy,gino),gino),italian
,) send_message_to(susy,send_message(know(odio,g
ino),gino),italian,) make(i_will_not_speak_with(
susy)) Eliminated messageconditions not verified
for send_message(question(hate,english,susy),susy
) Fromsusyarianna1075LanguageitalianOntology
send_message_to(susy,inform(send_message(questio
n(hate,english,susy),susy),motivation(refused_mess
age),gino),italian,)
english/susy
translator
........ Actived Agent........ make(comprehensi
on) make(comprehension) make(comprehension) make(c
omprehension)
............. Actived Agent
.......... send_message_to(gino,send_message(quest
ion(te,italian,susy),translator),italian,)
75Cooperation and Ontology
ITALIAN
ITALIAN
ENGLISH
send_message(give_present(A),A)
accept_presentA, drop_pastA(enemy(A))
(the filter accepts the messages as
give_present(_))
Susy,after the present, isnt an enemy and the
communication is again authorized by the filter.
76Examples Cooperation and Ontology
recovery_friendship(Ag)-informP(_,motivation(refu
sed_message),Ag). recovery_friendshipI(Ag)gtclause
(agent(A),_),
messageA(Ag,send_message(give_present(A),A)).
italian/gino
.................. Actived Agent...............
make(accept_present) send_message_to(translator,s
end_message(translate(hate,english,susy,gino),gino
),italian,) send_message_to(susy,send_message(kn
ow(odio,gino),gino),italian,)
english/susy
..................
Actived Agent............... send_message_to(gin
o,send_message(give_present(susy),susy),italian,
) make(comprehension)