Post on 03-Jun-2018
8/13/2019 Semantics Programmer Guide
1/62
www.francetelecom.com/
Research & Development
Jade Semantics Add-on Programmer's guide
Author: Vincent PAUTRET
Version: 1.
!op"ri#ht $ %'%( )rance Telecom
)rance TelecomResearch & Development
%* av. Pierre +ar,in%%- annion !e0e 2 )rancePhone: 3-- %4( 1 111
SAa
ucapitalde98684
59072-380129866RCSParis
8/13/2019 Semantics Programmer Guide
2/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e % of (%
Table of Contents
1Intrductin!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 41!1Cncepts!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!41!2Se"antic interpretatin al#rit$"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 51!3Pac%a#es &er&ie'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!6
2(ade Se"antic A#ent!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 72!1)$e Se"anticA#ent inter*ace and t$e Se"anticA#ent+ase class!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!72!2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!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!509!4a"ples * se"antic interpretatins!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!519!5a"ple * applicati&e SIPs!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 55
10:se*ul classes!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 5610!1.inder class!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 5610!2)ls class!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!57
8/13/2019 Semantics Programmer Guide
3/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e - of (%
10!3:til class!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 57
11Appendi!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 57
8/13/2019 Semantics Programmer Guide
4/62
+elie*,ase
Standardcust"iatin
Planner
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e 8 of (%
)$is #uide assu"es t$e reader t ,e *a"iliar 'it$ t$e .IPA standards; at least 'it$ t$e AgentManagement speci*icatins
8/13/2019 Semantics Programmer Guide
5/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e of (%
A (ade Se"antic A#ent
8/13/2019 Semantics Programmer Guide
6/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e ( of (%
1.3 Packages overview
)$e se"antics add-n is c"psed * t$e *ll'in# pac%a#es
jadesemantics: parent pac%a#e * t$e se"antics add-n!
D actions:
E E
cntains t$e de*initin * se"antic actins and a set * classes t"ana#e t$e"!
E D operators:
E E
cntains t$e classes t$at de*ine t$e alternati&e and seuence * actinsperatrs!
E F per$ormatives: cntains all t$e .IPA c""unicati&e acts ecept t$e pro%"and t$e
propa&ateacts; '$ic$ 'ill ,e added in a *uture &ersin!D !ehaviours:
E
pac%a#e t$at pr&ides classes t de*ine and "ana#e se"antic,e$a&iurs; and s"e standard ,e$a&iurs!
D interpreter t$is pac%a#e i"ple"ents t$e %ernel * t$e se"antics add-n!
E F sips:
E
cntains all t$e se"antic interpretatin principles needed , a (SA tinterpret crrectl t$e in*r"atins it recei&es!
D '!ase:
E E
cntains a set * #eneric classes t i"ple"ent a ,elie* ,ase *r t$e(SA! It pr&ides an i"ple"entatin * t$is %ind * ,ase ,ased n*ilters!
E D $i#ters:
E E E
su,-pac%a#e t$at pr&ides *ilters de*initin! .ilters are speci*ics t t$epr&ided ,elie* ,ase i"ple"entatin!
E E D assertion: t$is su,-pac%a#e pr&ides classes needed t de*ine assertin *ilters!
E E D uer": t$is su,-pac%a#e pr&ides classes needed t de*ine uer *ilters!
E F o!servers:E
t$is su,-pac%a#e cntains ,ser&ers '$ic$ are used t super&ise t$ec$an#es in a ,elie* ,ase!
D #an&s#:
E E
pac%a#e is pr&ided t $andle S/ /an#ua#e accrdin# t .IPAstandard speci*icatins!
E D content:E E
t$is pac%a#e pr&ides classes t $andle t$e cntents!
E D &rammar:E E E
cntains all t$e classes i"ple"entin# t$e a,stract snta and t$eassciated ,asic "ec$anis"!
E E F operations: t$is su,-pac%a#e cntains all t$e peratins ena,le n t$e #ra""ar!
E D parser:E E
t$is pac%a#e cntains classes t$at i"ple"ent a parser and an unparser*r t$e S/ cncrete snta!
E F too#s:E
t$is pac%a#e pr&ides use*ul tls t $andle S/ *r"ulae!
F p#anner: cntains a (a&a inter*ace t$at all planners s$uld i"ple"ent in rdert ,e readil inte#rated 'it$ t$e se"antics add-n!
8/13/2019 Semantics Programmer Guide
7/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e of (%
)$is #uide is structured as *ll'! C$apter 2 presents (SA and t$e 'a t create it! C$apter 3 details
t$e .IPA-S/ lan#ua#e and t$e assciated tls! )$en 'e descri,e t$e c"pnents * t$e*ra"e'r% t$e Se"antic Representatin ect assciated t t$e se"antic a#ent
t$e &et&ent()"et$d '$ic$ returns t$e (A a#ent crrespndin# t t$is se"antic a#ent!
)$e Semantic&entBaseclass represents a c""n ,ase class *r user de*ined a (SA! )$ere*re;*r" t$e pr#ra""erGs pint * &ie'; a (SA is an instance * a user de*ined (a&a class t$ati"ple"ents t$e inter*ace Semantic&ent; r "re si"pl t$at etends t$e Semantic&entBaseclass!
)$en; t$e si"plest se"antic a#ent is
pu!#ic c#ass M"*S e%tends Semantic&entBase +,
&en i* suc$ an a#ent see"s t ,e e"pt
It aut"aticall ans'ers in&alid "essa#es 'it$ a nt-understd "essa#e
It can; *r ea"ple; interpret t$e cntent * an in*r" "essa#e; and t$en ans'ers ueriesa,ut t$is cntent! .r ea"ple; i* I send an in*r" t t$is a#ent t$e cntent * '$ic$ is
8/13/2019 Semantics Programmer Guide
8/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e 9 of (%
includin# rules t $andle d"ain speci*ic ,elie*s ect used , t$e a#ent t cust"ie t$e SIPs!
)$e Semantic&entBase class uses a de*ault SemanticCapa!i#ities ,>ect pr&idin# t$e"ini"u"
8/13/2019 Semantics Programmer Guide
9/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e 4 of (%
/i%e *r a classical (A a#ent; t$e setup()"et$d * a (SA is t$e pint '$ere an applicatin-
de*ined a#ent acti&it starts! )$e pr#ra""er can rede*ine t$e setup()"et$d as *r a classical(A a#ent; and should call the super method'$ic$ prperl installs t$e se"antic capa,ilities! Int$is case; s$e can si"pl &erride t$e di**erent setup111"et$ds; dependin# * $er$is needs! )$e"anner * de*inin# t$ese "et$ds is descri,ed in t$e sectins crrespndin# t eac$ c"pnent!
)$e SemanticCapa!i#ities class pr&ides "et$ds t access all t$e c"pnents * aSemantic&ent ,elie* ,ase; planner; se"antic interpretatin ta,le; se"antic actin ta,le; usercust"isatin ect is assciated
)$e &et&entName()returns t$e a#ent na"e t '$ic$ t$e se"antic capa,ilities ,>ect isassciated
)$e &etM"/Base()"et$d returns t$e ,elie* ,ase * t$e a#ent
)$e &etM"0#anner()"et$d returns t$e planner
)$e &etM"Semanticction2a!#e() "et$d returns t$e se"antic actin ta,le
)$e &etSemanticInterpreterBehaviour() "et$d returns t$e se"antic interpreter,e$a&iur assciated t t$e a#ent
)$e &etM"SemanticInterpretation2a!#e() "et$d returns t$e se"antic interpretatin
principles ta,le )$e &etM"StandardCustomi-ation() "et$d returns t$e standard cust"isatin ,>ect!
It is t$e 'a t access all t$e parts * a (SA!
)$e SemanticCapa!i#ities class pr&ides "et$ds t si"pl send .IPA-AC/ "essa#es! )$ereare "et$ds t create eac$ %ind * "essa#e; and ne "et$d t send t$e created "essa#e! )$e
para"eters * t$e "et$ds are t$e nes used in t$e "essa#e!
)$e sendCommunicativection(Communicativection) "et$d sends t$e speci*iedc""unicati&e actin!
.r all t$e "et$ds descri,ed ,el'; t$e last para"eter crrespnd t t$e list * t$e recei&ers * t$eact! )' prttpes * "et$d eist t$e *irst ne 'it$ nl ne )er" as last para"eter; and t$esecnd ne 'it$ an arra * )er"s as last para"eter! nl t$e *irst ne is presented in t$isdcu"ent!
)$e createccept0roposa#(ction3%pression4 Formu#a4 2erm) "et$d creates anccept0roposa#act! )$e *irst para"eter is t$e actin epressin dentin# t$e actin t ,edne; and t$e secnd para"eter #i&es t$e cnditins * t$e a#ree"ent
)$e create&ree(ction3%pression4 Formu#a4 2erm)"et$d creates an A#ree act!)$e *irst para"eter is t$e actin epressin dentin# t$e actin t ,e dne; and t$e secnd
para"eter #i&es t$e cnditins * t$e a#ree"ent )$e createCance#(ction3%pression4 2erm) "et$d creates a Cancel act! )$e *irst
para"eter is t$e actin epressin dentin# t$e actin t$e *irst a#ent n ln#er $as t$e
8/13/2019 Semantics Programmer Guide
10/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e 1 of (%
intentin t$at secnd a#ent per*r" it
)$e createCF0(ction3%pression4 Identi$"in&3%pression4 2erm)"et$d creates aCall .r Prpsal act! )$e *irst para"eter is t$e actin epressin dentin# t$e actin t ,edne; and t$e secnd para"eter a re*erential epressin de*inin# a sin#le-para"eter
prpsitin '$ic$ #i&e t$e precnditins * t$e actin
)$e createCon$irm(Formu#a4 2erm)"et$d creates a Cn*ir" act! )$e *irst para"eter ist$e cn*ir"ed prpsitin
)$e create5iscon$irm(Formu#a4 2erm) "et$d creates a iscn*ir" act! )$e *irstpara"eter is t$e discn*ir"ed prpsitin
)$e createFai#ure(ction3%pression4 Formu#a4 2erm)"et$d creates a .ailure act!
)$e *irst para"eter is an actin epressin dentin# t$e *ailed actin; and t$e secndpara"eter is a *r"ula dentin# t$e reasn * t$e *ailure
)$e createIn$orm(Formu#a4 2erm)"et$d creates an In*r" act! )$e *irst para"eter is a*r"ula dentin# t$e prpsitin t$e a#ent 'ants t in*r" t$e t$er a#ent
)$e createNot6nderstood(ction3%pression4 Formu#a4 2erm)"et$d creates a t:nderstd act! )$e *irst para"eter is an actin epressin dentin# an nt understdactin; and t$e secnd para"eter is an eplanatr reasn
)$e create0ropose(ction3%pression4 Formu#a4 2erm)"et$d creates a Prpse act!)$e *irst para"eter is an actin epressin dentin# t$e actin t$at t$e sender is prpsin# t
per*r"; and t$e secnd para"eter is a prpsitin representin# t$e precnditins * t$eper*r"ance * t$e actin
)$e create7uer"I$(Formu#a4 2erm)"et$d creates a uerI* act! )$e *irst para"eter ist$e prpsitin t$e a#ent 'ants t %n' i* it is true r nt
)$e create7uer"Re$(Identi$"in&3%pression4 2erm) "et$d creates a uerRe* act!)$e *irst para"eter is t$e descriptin * t$e ueried ,>ect
)$e createRe$use(ction3%pression4 Formu#a4 2erm)"et$d creates a Re*use act!)$e *irst para"eter is an actin epressin dentin# t$e actin re*used t ,e per*r"; and t$esecnd para"eter is t$e reasn *r t$e re*usal
)$e createReject0roposa#(ction3%pression4 Formu#a4 Formu#a4 2erm) "et$dcreates a Re>ect Prpsal act! )$e *irst para"eter and t$e secnd ne cnsist * an actindescriptin and a prpsitin '$ic$ *r"ed t$e ri#inal prpsal ,ein# re>ected
)$e createReuest(ction3%pression4 2erm)"et$d creates a Reuest act! )$e *irstpara"eter is t$e actin t per*r"
)$e createReuest8hen(ction3%pression4 Formu#a4 2erm) "et$d creates aReuest-@$en act! )$e *irst para"eter is t$e actin t ,e per*r" , t$e recei&er '$en a
prpsitin
8/13/2019 Semantics Programmer Guide
11/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e 11 of (%
)$e *irst para"eter is t$e re*erential epressin identi*in# an ,ser&ed ,>ect!
)$e t$ree *ll'in# "et$ds "a%e it pssi,le t create actins 6nsu!scri!e! )$ese actins are ntpresent in .IPA speci*icatins! )$e "a%e it pssi,le t *inis$ prperl t$e entire e**ect * aSu!scri!ec""unicati&e act!
)$e create6nsu!scri!e(Identi$"in&3%pression4 2erm) "et$d creates an6nsu!scri!eact! )$e *irst para"eter is t$e re*erential epressin identi*in# t$e ,ser&ed,>ect! )$is "et$d is used 'it$ t$e pattern ((not (I ??agent (done (action ??receiver(INF!M"!#F :sender ??receiver :receiver (set ??agent$ :content ??ire$$$$$$'$ere ??ireisreplace , t$e *irst para"eter * t$e "et$d
)$e create6nsu!scri!e(ction3%pression4 2erm) "et$d creates an 6nsu!scri!e
act! )$is "et$d is used 'it$ t$e pattern ((not (I ??agent (done ??action$$$$! )$e ??action"eta&aria,le is replaced , t$e *irst para"eter * t$e "et$d
)$e create6nsu!scri!e(ction3%pression4 Formu#a4 2erm )"et$d creates an6nsu!scri!eact! )$is "et$d is used 'it$ t$e pattern ((or (fora%% ?e (not (done ?e (not(& ??receiver ??propert'$$$$$ (or (not (& ??receiver ??propert'$$ (not (I ??agent (done ??
action$$$$$$! )$e "eta&aria,le ??actionis replaced , t$e *irst para"eter * t$e "et$d; andt$e "eta&aria,le ??propert'is replaced , t$e secnd para"eter * t$e "et$d!
* curse; it is nt pssi,le t create an In$ormI$r an In$ormRe$"essa#e! .r ea"ple; in t$ecase * t$e In$ormI$"essa#e; it $as n sense t in*r" ant$er a#ent '$et$er r nt a #i&en
prpsitin is ,elie&ed!
)$e *ll'in# cde s$'s an ea"ple * sendin# a Reject0roposa#"essa#e usin# t$ese "et$ds!
&etSemanticCapa!i#ities()sendCommunicativeAction( &etSemanticCapa!i#ities()create$e%ect&roposal(action4
se#ectedCondition4ne9 2rueNode()4se#ected&ent))
2.3 Adding semantic capabilities to an eisting !ade agent
An eistin# classical (A a#ent can ,e trans*r"ed int a (SA ,
i"ple"entin# t$e Semantic&entinter*ace; and s installin# se"antic capa,ilities in it!
+ut t$is trans*r"atin is nt eas and t$e pr#ra""er "ust pa attentin t &arius pints )$e pr#ra""er "ust identi* '$ic$ "essa#es s$uld nt ,e catc$ed , t$e (SA! I* certain
"essa#es "iss; certain reactins 'ill nt ,e ine&ita,l c$erent 'it$ t$e #l,al ,e$a&iur
8/13/2019 Semantics Programmer Guide
12/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e 1% of (%
3 FIPA SL language andling
3.1 "rammar
.IPA-S/ epressin is t$e "ain data tpe; '$ic$ t$e se"antic interpretatin "ec$anis" relies n!)$e se"antics *ra"e'r% is supprted , an internal JdeK structure ,ased n an a,stract#ra""ar directl de*ined *r" t$e .IPA-S/ cncrete #ra""ar speci*icatin
8/13/2019 Semantics Programmer Guide
13/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e 1- of (%
It is pssi,le t de*ine additinal peratins n eac$ %ind * nde * t$e S/ #ra""ar! ependin# nt$e needs in S/ epressin $andlin#; t$is set * peratins can ,e easil etended! ) date; t$e "sti"prtant nes are
*r t$e .r"ula nde )$e &etsimp#i$iedFormu#a() "et$d c"putes t$e nr"al *r"
8/13/2019 Semantics Programmer Guide
14/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e 18 of (%
)$e addContent3#ement(Node)"et$d adds a ne' ele"ent in t$e cntent )$e setContent3#ements(int)"et$d creates a cntent ele"ent stra#e * t$e #i&en
sie; r; i* it alread eists; clears it )$e content3#ementNum!er() "et$d t$e nu",er * ele"ent in t$e cntent!
*r all ndes )$e toStrin&()"et$d unparses an nde in a Strin# representatin *r"at!
.inall; "eta-peratrs are included int t$e S/ #ra""ar t i"pr&e t$e pattern epressi&eness! )date; nl ne "eta-peratr is de*ined
)$is peratr
8/13/2019 Semantics Programmer Guide
15/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e 1 of (%
cntents and "re #enerall an %ind * nde * t$e S/ #ra""ar=!
)$e S.0atternManipclass "a%es it pssi,le t parseunparse &arius S/ *r"ulas and ter"s
8/13/2019 Semantics Programmer Guide
16/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e 1( of (%
ec$es (B (a&ent@identi$ier :name $oo) (temperature A))
Batc$in# patterns
Formu#a m"0attern ; (B a&ent (9earin& a&ent coat))Formu#a m"Formu#aA ; (B (a&ent@identi$ier :name $oo)
(9earin& (a&ent@identi$ier :name $oo) coat)Formu#a m"Formu#aE ; (B (a&ent@identi$ier :name $oo)
(9earin& (a&ent@identi$ier :name $oo) cap)Formu#a m"Formu#aG ; (B (a&ent@identi$ier :name $oo)
(9earin& (a&ent@identi$ier :name $ooE) coat)
MatchResu#t resu#t ; S.0atternManipmatch(m"0attern4 m"Formu#aA)i$ (resu#t H; nu##)
S"stemoutprint#n(a&ent ; resu#t&et2erm(a&ent))
ec$es a&ent ; (a&ent@identi$ier :name $oo)
resu#t ; S.0atternManipmatch(m"0attern4 m"Formu#aE)i$ (resu#t H; nu##)
S"stemoutprint#n(a&ent ; resu#t&et2erm(a&ent))
ec$es nt$in# ,ecause m"0atternand m"Formu#aEd nt "atc$ and s t$e result *t$e "et$d matchis nu##!
resu#t ; S.0atternManipmatch(m"0attern4 m"Formu#aG)i$ (resu#t H; nu##)S"stemoutprint#n(a&ent ; resu#t&et2erm(a&ent))
ec$es nt$in# ,ecause in m"Formu#aG t$e t' a#ents are di**erent '$ereas in t$epattern m"0atternt$e sa"e a#ent is epected!
)$e instantiatin "ec$anis" cnsists in #i&in# a &alue t eac$ "eta&aria,le! It can ,e dne *r"t' di**erent 'as! .irstl; t$e si"ple 'a; , usin# ne * t$e instantiate"et$ds!
)$e instantiate(Node) "et$d returns a tree representin# t$e instantiated pattern;"eanin# all "eta-&aria,les $a&e ,een replaced , t$eir &alue
)$e instantiate(Node4 Strin&4 Node); instantiate(Node4 Strin&4 Node4Strin&4Node); instantiate(Node4 Strin&4 Node4 Strin&4 Node4 Strin&4 Node); andinstantiate(Node4 Strin&4 Node4 Strin&4 Node4 Strin&4 Node4 Strin&4 Node)
"et$ds return t$e instantiated pattern
8/13/2019 Semantics Programmer Guide
17/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e 1 of (%
ormula result ! (ormula)pattern.getClone()#
S&atternManip.set(result*+agent+* getSemanticCapabilities().getAgent,ame())#
S&atternManip.set(result* +p-i+* p-i)#S&atternManip.substituteMeta$e'erences(result)#
@it$ t$e set(Node4 Strin&4 Node)"et$d sets in t$e result pattern t$e "eta&aria,le desi#ned
, t$e Strin# 'it$ t$e de &alue #i&en as t$ird para"eter t$e su!stituteMetaRe$erences(Node) "et$d su,stitutes in t$e #i&en pattern all t$e
"eta&aria,les 'it$ t$eir crrespndin# &alues!
A) least; it is interestin# t call t$e &etSimp#i$iedFormu#a() "et$d a*ter an instantiatin t ,esure t$at t$e prduced *r"ula is in t$e nr"al *r"! a"ple; t$e *ll'in# cde
Formu#a pattern ; S.0atternManip$romFormu#a((not phi))Formu#a $A ; S.0atternManip$romFormu#a((not p))ormula ' ! (ormula)S&atternManip.instantiate(pat* +p-i+* '/)#i$ (S.0atternManipmatch($E4 S.0atternManip$romFormu#a(p)) H; nu##) + S"stemoutprint#n(Success H), e#se + S"stemoutprint#n(Fai# H),
ec$es Fai#H
t$er'ise; 'it$ t$e &etSimp#i$iedMethod()
Formu#a $E ; ((Formu#a)S.0atternManipinstantiate( pat4 phi4 $A))&etSimp#i$iedFormu#a()
it ec$es Success H
3!3!2 And$ode % &r$ode
)$e pattern "atc$in# is rder independent *r t$e And .r"ula and t$e r *r"ula! .r ea"ple;Formu#a m"0attern ; (or (s A) (and (and (p A) ( E) (and (r A) (t E))))Formu#a m"Formu#aA ; (or (and (t E) (and (and ( E) (p A)) (r A)) (s A))
MatchResu#t resu#t ; S.0atternManipmatch(m"0attern4 m"Formu#aA)i$ (resu#t H; nu##) S"stemoutprint#n(Success H))
ec$es Success H
3!3!3 (uals$ode
)$e pattern "atc$in# ta%e accunt t$e c""utati&it * t$e euals peratr S; t$e *ll'in# cde
Formu#a $A ; (; (p A) ( E))
8/13/2019 Semantics Programmer Guide
18/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e 19 of (%
Formu#a $E ; (; ( E) (p A))
MatchResu#t resu#t ; S.0atternManipmatch($A4 $E)i$ (resu#t H; nu##) S"stemoutprint#n(Success H))
ec$es Success H
3!3!) &*tional *arameters
.inall; it is pssi,le t precise ptinal para"eters in t$e pattern usin# t$e "eta-peratr de*ined int$e pre&ius sectin! .r ea"ple; t$e *ll'in# pattern
2erm pattern ; S.0atternManip$rom2erm((a&ent@identi$ier
(:: :addresses addresses) :name name (:: :reso#vers reso#vers)))
de*ines a ter" 'it$ t' ptinal para"eters addresses and resl&ers! )$is %ind * pattern culd"atc$; *r ea"ple; t$ese ter"s
2erm termA ; S.0atternManip$rom2erm((a&ent@identi$ier :name $oo))2erm termE ; S.0atternManip$rom2erm(
(a&ent@identi$ier :addresses add :name $oo))
3.% &'namic b(ilding of S$ epressionsIt is pssi,le t $andle directl t$e a,stract tree representin# a S/ epressin , addin# ne' ndesr re"&in# eistin# nes! )$e di**erent "et$ds '$ic$ "a%e it pssi,le t $andle t$e ndes * t$etree are s$'n is t$e de $ierarc$ s$'n in t$e Appendi! .r ea"ple; *r t$eModa#.o&icFormu#ande
8/13/2019 Semantics Programmer Guide
19/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e 14 of (%
)$is apprac$ can ,e interestin# in ter" * per*r"ance! )$e J"anualK cnstructin * t$e tree in
particular a&ids parsin# t$e strin#s representin# S/ epressins!
) Semantic +e*resentation
Se"antic Representatins
8/13/2019 Semantics Programmer Guide
20/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e % of (%
Se"anticCapa,ilities instance=; adds t$e *r"ula (wearing 2a coat$in t$e ,ase!
&etSemanticInterpreterBehaviour()interpret(((Formu#a)S.0atternManipinstantiate(S.0atternManip$romFormu#a((B ja (9earin& ja coat)))))
, elief base
)$is sectin descri,es t$e usa#e * t$e +elie* +ase c"pnent supprted , t$e *ra"e'r%! )$e,ase stres *acts ,elie&ed , t$e a#ent accrdin# t t$e speci*ic applicatin d"ain!
@it$ut an pr#ra""in# e**rt; t$is c"pnent can nl stre and retrie&e Jra'K *acts 'it$ut
actuall understandin# ect!t$er'ise ect= t$e "et$d returns nu##
8/13/2019 Semantics Programmer Guide
21/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e %1 of (%
a##; "eanin# Jl% *r all,>ects osatis*in# pK! )$e "et$d returns a list includin# all
t$e ,>ects ot$at can ,e *und suc$ as (po)is true! I* n suc$ ,>ect can ,e *und; itreturns an e"pt list; ,ut ne&er returns nu##
@e intrduce a ne' re*erential peratr
some; "eanin# Jl% *r s"e ,>ects o satis*in# pK! )$e "et$d returns a listincludin# all t$e ,>ects ot$at can ,e *und suc$ as (B jsa(po))is true! I* n suc$,>ect can ,e *und; it returns an e"pt list; ,ut ne&er returns nu##!
Crrect use * t$ese peratrs "a%es it pssi,le t $andle precisel t$e ,elie*s * t$e a#ent!A predicate p is cnsidered as clsed '$en an a#ent %n's t$e &alue t$at "a%es t$e
predicate true; and *r all t$e t$ers &alue "; (not (p "))is true!
/etGs ta%e an ea"pleI* a (SA is in*r"ed t$at (; (iota % (temperature %)) A)is true; t$en its ans'er ta uer-Re* "essa#e a,ut (iota 2 (temperature 2))
8/13/2019 Semantics Programmer Guide
22/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e %% of (%
, t$e *inder! )$is "et$d is deprecated; s pre*er t$e *ll'in# "et$d
)$e retractFormu#a(Formu#a)"et$d retracts all t$e *r"ulae '$ic$ "atc$ t$e #i&en*r"ula
8/13/2019 Semantics Programmer Guide
23/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e %- of (%
,e used t add cnsistenc rules r in*erence rules! .ilters are used t "ana#e t$e accesses t t$e
,elie* ,ase! It is a 'a *r t$e de&elper t tri##er s"e speci*ic cde! )' %inds * *ilters can ,eused
Assert filtersare aut"aticall called '$en assertin# a *act *uer$*ilters are aut"aticall called '$en uerin# *acts r identi*in# epressins!
)$e Fi#ter/Baseinter*ace pr&ides "et$ds t $andle *ilters suc$ as
)$e add/BssertFi#ter(/BssertFi#ter) "et$d adds an assert *ilter t t$e ,elie* ,ase
)$e add/BssertFi#ter(/BssertFi#ter4 int) "et$d adds an assert *ilter at t$especi*ied inde
)$e remove/BssertFi#ter(Finder) "et$d re"&es t$e assert *ilters t$at are identi*ied, t$e speci*ied *inder
)$e add/B7uer"Fi#ter(/B7uer"Fi#ter) "et$d adds a uer *ilter t t$e ,elie* ,ase
)$e add/B7uer"Fi#ter(/B7uer"Fi#ter4 int)"et$d adds a uer *ilter at t$e speci*iedinde
)$e remove/B7uer"Fi#ter(Finder)"et$d re"&es t$e uer *ilters t$at are identi*ied, t$e speci*ied *inder
)$e addFi#ters5e$inition(Fi#ters5e$inition) "et$d adds a list * *ilters t t$e,elie* ,ase
8/13/2019 Semantics Programmer Guide
24/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e %8 of (%
cnsistenc
8/13/2019 Semantics Programmer Guide
25/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e % of (%
.inall; t$e a$terssert(Formu#a) "et$d is called a*ter t$e assertin *r eac$ assert *ilter
in t$e rder de*ined , t$e list! )$e "et$d is called nl i* a ,lean
8/13/2019 Semantics Programmer Guide
26/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e %( of (%
*r t$e ita epressin t$e sin#le ele"ent!
)$e *ilter is applica,le n t$e *r"ulae * t$e *r" (& ??agent (3 (a%% ??4 ??formu%a$ ??set$$r(& ??agent (3 (iota ??4 ??formu%a$ ??set$$! )$e a$terssert"et$d des nt$in#!
/bserverFilter
A*ter t$e assertin * a *r"ula; t$is *ilter c$ec%s all t$e ,ser&ed *r"ulae! I* t$e &alue * t$e,ser&atin ,ec"es true; t$e assciated ,ser&er is nti*ied! )$e app#""et$d des nt$in# int$is *ilter!
-'ample of an applicative filterIn ur ea"ple; 'e use t$e /BssertFi#terdapter t re"&e all pre&ius %n'n *act a,ut t$ete"perature eac$ ti"e a ne' te"perature &alue is asserted! )$e "et$d returns t$e sa"e *r"ula inrder t t$e ra' "ec$anis" * t$e assertin prcess asserts t$e *r"ula! H'e&er; i* t$e *r"ula isalread in t$e ,ase; t$e "et$d returns a 2rueNode*r"ula t a&id t$at t$e ra' "ec$anis" * t$eassertin asserts it a#ain!
((Fi#ter/Base)m"/Base)addKBAssertilter( ne9 KBAssertilterAdapter((B a&ent (temperature %))) + pu!#ic Formu#a doApply(Formu#a $ormu#a) + i$ ((m"/Baseuer"($ormu#a) H; nu##)) +
return ne9 2rueNode() , e#se +
'!aseretractFormu#a(S.0atternManip$romFormu#a((temperature %)))
'!aseretractFormu#a(S.0atternManip$romFormu#a((not (temperature %))))'!aseretractFormu#a(S.0atternManip$romFormu#a((temperature
8/13/2019 Semantics Programmer Guide
27/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e % of (%
a list * MatchResu#ts'$ic$ cntains all t$e MatchResu#t; resultin# * t$e
per*r"ance * t$e *ilter n t$e #i&en *r"ula! ac$ MatchResu#tcntains a list* &alue t$at "a%es truet$e *r"ula #i&en in para"eter! I* t$e list is nu##; t$at"eans t$at t$e ans'er t t$e uer is $a#se!
All t$e uer *ilters are called at t$e ,e#innin# * t$e uer al#rit$"
8/13/2019 Semantics Programmer Guide
28/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e %9 of (%
KK the $i#ter is app#ica!#e4 the !oo#ean o$ the resu#t is set to true
uer"Resu#tsetFi#terpp#ied(true) .istO$MatchResu#ts #ist ; ne9 .istO$MatchResu#ts() KK the method dopp#" returns the #ist o$ MatchResu#t #istadd(dopp#"($ormu#a4 match)) uer"Resu#tsetResu#t(#ist) , return uer"Resu#t,
In t$e case * t$e 7uer"Fi#terdapter ; t$e pr#ra""er $as >ust t rede*ine t$e dopp#""et$d'$ic$ returns t$e list * MatchResu#t!
AndFilter
)$is *ilter is applica,le '$en t$e ueried *r"ula is a cn>unctin in * eac$ MatchResu#tresultin# * t$euer n ??p*iand all MatchResu#tsresultin# * t$e uer n ??psi!
elief0ransferFilter
)$is *ilter is used t c$ec% i* t$e se"antic a#ent is cperati&e t'ards ant$er a#ent re#ardin# aspeci*ic ,elie* r nt! )$is *ilter uses t$e acceptBe#ie$2rans$er "et$d
8/13/2019 Semantics Programmer Guide
29/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e %4 of (%
-'istsFilter
)$is *ilter is applica,le n *r"ulae * t$e *r" (& ??agt (eists ??var ??p*i$$ r (eists ??var(& ??agt ??p*i$$! )$e &aria,le ??varis c$an#ed int Beta&aria,le in t$e *r"ula ??p*i and t$e"et$d uer is called n t$e resultin# *r"ula! )$e result is t$e resultin# list * MatchResu#ts*t$e last uer; in '$ic$ t$e result n t$e &aria,le ??var$as ,een re"&ed!
ForallFilter
)$is *ilter is applica,le n *r"ulae * t$e *r" (fora%% ??var ??p*i$ and i* ??p*i is a "ental
attitude * t$e a#ent! )$e &aria,le??var
is c$an#ed int Beta&aria,le in t$e *r"ula??p*i
and t$e"et$d uer is called n t$e resultin# *r"ula
8/13/2019 Semantics Programmer Guide
30/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e - of (%
temperature "))))
Formu#a IO2
8/13/2019 Semantics Programmer Guide
31/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e -1 of (%
)$e de$ineFi#ter(int4 /BFi#ter)"et$d adds a ne' *ilter in t$e list 'it$ a speci*ied
inde )$e de$ineFi#ter(/BFi#ter) "et$d adds a ne' *ilter at t$e ,e#innin# * t$e list
)$e &et(int)"et$d returns t$e Fi#ter5e$initioninstance at t$e speci*ied inde!
)$e SineNumDa#ue5e$inition class * t$e te"perature de" is a #d ea"ple * use * t$isclass! )$is class de*ines an unspeci*ied predicate; '$ic$ $as nl ne nu"erical &alue as para"eter!
pu!#ic c#ass SineNumDa#ue5e$inition e%tends Fi#ters5e$inition +
55
55&atterns used to manage t-e de'ined predicate 55 Formu#a D.63
8/13/2019 Semantics Programmer Guide
32/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e -% of (%
,)
,,
).2.1.% Adding new filters
Addin# ne' *ilters is dne in t$e setup/!ase()"et$d * t$e class SemanticCapa!i#ities !
pu!#ic void setup/!ase() + supersetup/!ase() ((ilterKBase)myKBase).addKBAssertilter( ne9 /BssertFi#terdapter((B a&ent phi)) +
pu!#ic Formu#a dopp#"(Formu#a $ormu#a) +,
,)
.irst; it is i"prtant t call t$e supersetup/!ase() "et$d t lad all t$e #eneric *ilters used ,t$e (SA! )$en; t$e pr#ra""er can use t$e add/BssertFi#ter; t$e add/B7uer"Fi#ter"et$dst add $is$er 'n applicati&e *ilters!
).2.1.) ,emoving beliefs from the base
)$ere is t' 'as t re"&e ,elie*s , assertin# *r"ulae
)$e *irst 'a is t assert a *r"ula * t$e *r" (not (B jsa phi))'$ere phiis t$e*r"ula t re"&e! In t$is case; t$e *r"ula is si"pl re"&ed *r" t$e ,ase
8/13/2019 Semantics Programmer Guide
33/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e -- of (%
t t$e ,ser&ed *r"ula! @$en a ne' &alue is asserted; t$e &alue is c"pared t t$e stred &alue in
t$e crrespndin# O!servationdependin# * t$e ,ser&ed *r"ula; and; i* necessar; is updated!In case * c$an#e; t$e noti$""et$d is called!
Addin# ne' ,ser&ers is dne in t$e rede*initin * t$e setup/!ase "et$d * t$eSemanticCapa!i#ities class!
pu!#ic void setup/!ase() + supersetup/!ase() getMyKBase().add=bserver(ne" 1ventCreation=bserver(...))#,
* curse; t$e ,ser&ers culd ,e added dna"icall , usin# t$e sa"e "et$d
8/13/2019 Semantics Programmer Guide
34/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e -8 of (%
(and (I &et&entName() (not (9earin& &et&entName() coat)))
(I &et&entName() (not (9earin& &et&entName() cap))))))))
55 level />&etM"/Base()addO!server(ne9 3ventCreationO!server(m"&ent4 S.0atternManip$romFormu#a((B &et&entName() (temperature&etM"/Base()addO!server(ne9 3ventCreationO!server(m"&ent4 S.0atternManip$romFormu#a((B &et&entName() (temperature&etM"/Base()addO!server(ne9 3ventCreationO!server(m"&ent4S.0atternManip$romFormu#a((B &et&entName() (not (temperature
8/13/2019 Semantics Programmer Guide
35/62
8/13/2019 Semantics Programmer Guide
36/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e -( of (%
*r"ula $as c$an#ed! Cnseuentl lts * ueries are dne a*ter eac$ assertin! ) pti"ie t$e
per*r"ance; t$e pr#ra""er $as t deter"ine *r eac$ ,ser&er '$ic$ patterns culd $a&e ane**ect n t$e &alue * t$e ,ser&ed *r"ula! + t$is 'a; '$en a ne' assertin is dne; nl t$ecncerned ,ser&ers are tri##ered! ) reac$ t$is #al; t$e pr#ra""er $as t &erride *r eac$ *iltert$e &etO!server2ri&&er0atterns(Formu#a4 Set) "et$d! )$e *r"ula #i&en in para"eter ist$e ne ,ser&ed , t$e ,ser&er and t$e set #i&en in para"eter cntains all t$e patterns '$ic$tri##ers t$e ,ser&er!
/etGs ta%e an ea"ple
@e cnsider t$e uer *ilter '$ic$ "ana#es t$e temperature
8/13/2019 Semantics Programmer Guide
37/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e - of (%
)$e &et0ersistentFeasi!i#it"0recondition() "et$d returns t$e
persitent.easi,ilitPrecnditin )$e &et0ostCondition() "et$d returns t$e pstcnditin * t$e actin )$e &etBehaviour()"et$d returns t$e ,e$a&iur * t$e actin )$e ne9ction(ction3%pression)"et$d creates a ne' instanced instance * t$e actin
,ased n t$e speci*ied actin epressin )$e ne9ction(Formu#a4 C.Messa&e)"et$d creates a ne' instanced instance * t$e
actin ,ased n t$e speci*ied ratinal e**ect )$e toction3%pression() "et$d returns t$e actin epressin representatin * t$is
actin!
)$e tp * t$e $ierarc$ * se"antic actins is s$'n in t$e net *i#ure
)$ree %inds * se"antic actins are distin#uis$ed t$e peratrs; t$e c""unicati&e actins; and t$entl#ical actins! )$e alternati&e peratr and t$e seuence peratr are cnsidered as J"acr-actinsK; '$ic$ epress s"e c"ple actins , c",inin# se"antic actins! .r ea"ple; t$eIn*r"-I* act is *r"all de*ined as a *inite alternati&e * t' In*r" acts! )$e c""unicati&eactins #at$er all t$e .IPA C""unicati&e Acts! .inall; t$e ntl#ical actins #at$er t$e actinsrelated t a speci*ic applicatin!
-.1 Semantic action table
)$e se"antic actin ta,le #at$ers all t$e se"antic actins! )$e Semanticction2a!#e inter*acepr&ides "et$ds t $andle t$e ta,le
)$e &etSemanticCapa!i#ities() "et$d returns t$e se"antic capa,ilities t$at $ld t$eactin ta,le
)$e addSemanticction(Semanticction) "et$d adds a se"antic actin in t$e ta,le )$e removeSemanticction(Finder) "et$d re"&es t$e se"antic actin identi*ied ,
t$e *inder )$e &etSemanticctionInstance(ction3%pression) "et$d creates an instantiated
Semanticction*r" t$e Semanticctionprttpe 'it$in t$e ta,le crrespndin# t anction3%pression
)$e &etSemanticctionInstance(C.Messa&e) "et$d creates an instantiatedSemanticction*r" t$e Semanticctionprttpe 'it$in t$e ta,le crrespndin# t anAC/ Bessa#e
Se"anticActinQQinter*ace
Se"anticActinI"pl
Alternati&e ntl#icalActin Seuence C""unicati&eActinI"pl
C""unicati&eActinQQinter*ace
8/13/2019 Semantics Programmer Guide
38/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e -9 of (%
)$e &etSemanticctionInstance(rra".ist4 Formu#a4 C.Messa&e)"et$d creates
a list * instantiated se"antic actins *r" t$e Semanticctionprttpes 'it$in t$e ta,le;suc$ t$at eac$ Semanticction$as a speci*ied ratinal e**ect
)$e #oad2a!#e()"et$d lads t$e actins in t$e ta,le )$e si-e()"et$d returns t$e sie * t$e ta,le!
)$e psitin * an actin in t$e ta,le des nt $a&e an i"prtance! )$eSemanticction2a!#eImp# class is t$e i"ple"entatin * t$e Semanticction2a!#e inter*ace
pr&ided , t$e *ra"e'r%! It etends t$e jade#eaprra".ist class!
-.2 Semantic action behavio(rs
)$e de*initin * eac$ se"antic actin "ust pr&ide a se"antic ,e$a&iur i"ple"entin# t$eper*r"ance * t$is actin! A se"antic ,e$a&iur
8/13/2019 Semantics Programmer Guide
39/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e -4 of (%
a ,e$a&iur * t$e seuence returns success! )$e internal state * t$e#ternativeBehaviour is set tsuccess
a ,e$a&iur * t$e seuence returns eecution fai%ure! )$e internal state * t$e#ternativeBehaviour is set t eecution fai%ure
all ,e$a&iurs * t$e seuence return feasi+i%it' fai%ure! )$e internal state * t$e#ternativeBehaviour is set tfeasi+i%it' fai%ure!
Se%uenceehaviour)$is ,e$a&iur etends jadecore!ehavioursSeuentia#Behaviour ! It eecutes its su,-
,e$a&iurs seuentiall and ter"inates '$en a ,e$a&iur * t$e seuence returns feasi+i%it' fai%ure! )$e internal state * t$e
SeuenceBehaviouris set tsuccess a ,e$a&iur * t$e seuence returns eecution fai%ure! )$e internal state * t$e
SeuenceBehaviouris set t eecution fai%ure all ,e$a&iurs * t$e seuence returnsuccess! )$e internal state * t$e SeuenceBehaviour
is set tsuccess!
Semanticehaviourase
)$is a,stract class "dels a ,asic i"ple"entatin * t$e SemanticBehaviourinter*ace! It etendsjadecore!ehavioursBehaviour !
1ommunicativeActionehaviour)$is a,stract class "dels c""unicati&e ,e$a&iurs! )$e action"et$d *ll's t$ese steps
i* t$e current a#ent is t$e ne "a%in# t$e actin tests t$e compute"et$d! )$is "et$d s$uld ,e &erridden i* t$e "et$d returns true
in t$is case; sends t$e AC/ "essa#e crrespndin# t t$e actin stres in t$e ,elie* ,ase t$e pstcnditins * t$e actin stres in t$e ,elie* ,ase t$e ,elie* * t$e a#ent n t$e *act t$at it $as dne
t$e actin sets t$e state * t$e ,e$a&iur tsuccess
i* t$e "et$d returns *alse sets t$e state * t$e ,e$a&iur tfeasi+i%it' fai%ure
n t$e cntrar; des nt$in#!I* an eceptin ccurs; sets t$e state t eecution fai%ure!
InformRefehaviour
)$e In*r"-Re* ,e$a&iur "ainl cnsists in uerin# t$e ,elie* ,ase * t$e a#ent 'it$ t$e uerepressed in t$e cntent! I* t$e cntent is a (a%% ?4 $epressin; t$e uer t t$e ,elie* ,asenecessaril returns a result ; '$ic$ is in *act an S/ ,>ect * tpe JsetK
8/13/2019 Semantics Programmer Guide
40/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e 8 of (%
??condition$$$ instead * sendin# an In$orm"essa#e; a propose"essa#e is sent! )$is case $as
,een intrduced t 'r% arund a ,u# in t$e .IPA speci*icatin!
Primitiveehaviour
+asicall; t$e per*r"ance * a pri"iti&e per*r"ati&e
8/13/2019 Semantics Programmer Guide
41/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e 81 of (%
1onfirm t$e sender in*r"s t$e recei&er t$at a #i&en prpsitin is true; '$ere t$e recei&er
is %n'n t ,e uncertain a,ut t$e prpsitin 2isconfirm t$e sender in*r"s t$e recei&er t$at a #i&en prpsitin is *alse; '$ere t$e
recei&er is %n'n t ,elie&e; r ,elie&e it li%el t$at; t$e prpsitin is true Failure t$e actin * tellin# ant$er a#ent t$at an actin 'as atte"pted ,ut t$e atte"pt
*ailed! .ailure is an a,,re&iatin *r in*r"in# t$at an act 'as cnsidered *easi,le , t$esender; ,ut 'as nt c"pleted *r s"e #i&en reasn! )$e *irst part * t$e cntent is t$eactin nt *easi,le! )$e secnd part is t$e reasn *r t$e *ailure; '$ic$ is represented , a
prpsitin! It "a ,e t$e cnstant true Inform t$e sender in*r"s t$e recei&er t$at a #i&en prpsitin is true! )$e cntent * t$is
actin is a prpsitin Inform If t$e sender in*r"s t$e recei&er '$et$er r nt a #i&en prpsitin is true! )$e
cntent * t$is actin is a prpsitin Inform Ref t$e sender in*r"s t$e recei&er t$e ,>ect '$ic$ crrespnds t a descriptr;
*r ea"ple; a na"e! )$e cntent * t$is actin is an ,>ect prpsitin
8/13/2019 Semantics Programmer Guide
42/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e 8% of (%
prpsitin ,ec"es true and t$erea*ter eac$ ti"e t$e prpsitin ,ec"es true a#ain! )$e
cntent * t$is actin is a t-uple * an actin epressin and a prpsitin Subscribe t$e act * reuestin# a persistent intentin t nti* t$e sender * t$e &alue * a
re*erence; and t nti* a#ain '$ene&er t$e ,>ect identi*ied , t$e re*erence c$an#es!
-.% Adding new actions
)$e pr#ra""er $as t &erride t$e setupSemanticctions "et$d * t$eSemanticCapa!i#ities class! )$e addSemanticction* t$e Semanticction2a!#e inter*ace ist$e "et$d t use t add a ne' actin
pu!#ic void setupSemanticctions() + super.setupSemanticActions()# &etM"Semanticction2a!#e()addSemanticAction(ne9 Onto#o&ica#ction(
&etM"Semanticction2a!#e()4 (062@ON :c#othin& c#othin&)4 S.0atternManip$romFormu#a((9earin& sender c#othin&))4 S.0atternManip$romFormu#a((not (9earin& sender c#othin&)))) + pu!#ic void per$orm(OntoctionBehaviour !ehaviour) + , ,)
...,
It is $i#$l rec""ended t call t$e "et$d supersetupSemanticctions ; '$ic$ "a%es itpssi,le t create a ne' instance * se"antic actins ta,le and t lad t$e c""unicati&e actins!@it$ut it; t$e created a#ent 'ill nt $a&e an c""unicati&e actin i* t$e user des nt lad t$e"eplicitl and t$en t$e (SA is una,le t aut"aticall c""unicate 'it$ t$er a#ents usin# t$e*ra"e'r% "ec$anis"s! S; i* t$e pr#ra""er uses ant$er i"ple"entatin * Se"antic Actinta,le; t$e set-up * t$e ta,le culd ,e
pu!#ic void setupSemanticctions() +mySemanticAction6able ! ne" mySemanticAction6able4mpl(t-is)#
mySemanticAction6able.load6able()#KKOnto#o&ica# actions
,
/ntoloical actions
)$e *ra"e'r% de*ines all t$e actins de*ined , t$e .IPA-AC/ Speci*icatins
8/13/2019 Semantics Programmer Guide
43/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e 8- of (%
t$e pattern used t ,t$ rec#nie S/ *r"ulae representin# t$e ratinal e**ect * t$is actin
and instantiate t$e S/ *r"ula representin# t$e pstcnditin * t$is actin t$e pattern used t instantiate t$e S/ *r"ula representin# t$e precnditin * t$is actin!
)$e net ea"ple s$'s a 'a t create suc$ prttpe
ne9 Onto#o&ica#ction(getMySemanticAction6able()* +(&36;=, clot-ing DDclot-ing)+* S&atternManip.'romormula(+("earing DDsender DDclot-ing)+)* S&atternManip.'romormula(+(not ("earing DDsender DDclot-ing))+)) { pu!#ic void per$orm(OntoctionBehaviour !ehaviour) + ((Man&ent)m"&ent)putOn(&etction0arameter(c#othin&)toStrin&()) !ehavioursetState(SemanticBehaviourS6CC3SS) ,,
All t$e "eta&aria,les * t$ese patterns "ust re*er t S/ ter"s representin# ne * t$e ar#u"ents *t$e actin and "ust use t$e sa"e na"es *r t$ese "eta&aria,les! )$ese patterns "a re*er t t$ereser&ed "etare*erence ???sender?; '$ic$ dentes t$e a#ent * t$e actin! A call t ne * t$ene9ction"et$ds creates instances * t$is ntl#ical actin prttpe!
)$e ,e$a&iur assciated t t$is actin is pr&ided , t$e per$orm"et$d
ne9 Onto#o&ica#ction(&etM"Semanticction2a!#e()4 (062@ON :c#othin& c#othin&)4 S.0atternManip$romFormu#a((9earin& sender c#othin&))4
S.0atternManip$romFormu#a((not (9earin& sender c#othin&)))) + public void per'orm(=ntoActionBe-aviour be-aviour) { ((ManAgent)myAgent).put=n(getAction&arameter(+clot-ing+).toString())# be-aviour.setState(SemanticBe-aviour.S3CC1SS)# },
In t$is ea"ple; t$e per*r" "et$d; '$ic$ $lds t$e (a&a cde * t$e actin; si"pl calls a "et$d* t$e a#ent! )$is "et$d "ust ,e de&elped aln# t$e sa"e 'a as t$e action"et$d * t$e (ade+e$a&iur class! )$is "et$d is called , t$e OntoctionBehaviourassciated t t$e ntl#icalactin!
)$e Onto#o&ica#ctionclass pr&ides se&eral speci*ic "et$ds )$e per$orm(OntoctionBehaviour) "et$d is t$e i"ple"entatin * t$e ,e$a&iur *
t$e ntl#ical actin! )$is "et$d "ust ,e de&elped aln# t$e sa"e 'a as t$e action"et$d * t$e (ade ,e$a&iur! )$is "et$d "ust ,e &erridden in all t$e su,classes
8/13/2019 Semantics Programmer Guide
44/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e 88 of (%
accceptBe#ie$2rans$er(Formu#a4 2erm)
acceptIntention2rans$er(Formu#a4 2erm)In ,t$ cases; t$e 2 ar#u"ents are )$e $ormu#arepresentin# t$e ,elie* t ,e asserted r t$e intentin t ,e adpted )$e a&ent'$ $lds t$e ri#inal ,elie* r intentin!
+ased n t$is in*r"atin; a se"antic a#ent can decide t accept r re>ect ,elie*s and intentins *t$er a#ents! )$e net ea"ple illustrates $' t$e ,elie* trans*er can ,e cust"ied
setM"StandardCustomi-ation(ne9 StandardCustomi-ationdapter() + pu!#ic !oo#eanacceptBelie'6rans'er(Formu#a $ormu#a4 2erm a&ent) + return (S.0atternManipmatch((temperature DDx)4 $ormu#a);;nu##) (S.0atternManipmatch((not (temperature DDx))4 $ormu#a);;nu##) (S.0atternManipmatch((temperaturegt DDx)4 $ormu#a);;nu##)
(S.0atternManipmatch((not (temperaturegt DDx))4 $ormu#a);;nu##) ,,)
)$e acceptBe#ie$2rans$er "et$d * t$e sensr a#ent is i"ple"ented s t$at t$e a#ent nl,elie&es *acts *r" t$er a#ents t$at $a&e nt$in# t d 'it$ t$e te"perature! )$e secnd ea"pleillustrates $' t$e intentin trans*er can ,e cust"ied
setM"StandardCustomi-ation(ne9 StandardCustomi-ationdapter() + pu!#ic !oo#ean accept4ntention6rans'er(Formu#a &oa#4 2erm a&ent) + Strin&mot-er4E; (agent;identi'ier name +Fmot-erA4E.get,ame()F+) return a&enteua#s(S.0atternManip$rom2erm(motherI5)) ,,)
)$e acceptIntention2rans$er * t$e sn a#ent is i"ple"ented s t$at t$e a#ent nl adptsintentin * $is "t$er! Cnseuentl; i* ant$er a#ent reuests $i" t d an actin; $e 'ill re*use!
)$e StandardCustomi-ation,>ect is als t$e "eans t prperl $andle s"e c""unicati&e actsli%e t$e CF0r t$e 0roposeacts! ue t t$e *r"al se"antics * t$ese acts; t$ere is n "eans taut"aticall c"pute t$e (SA reactin! )$e pr&ided "et$ds are t$e *ll'in#
)$e hand#eCF0Iota(Daria!#e4 Formu#a4 ction3%pression4 2erm)"et$d returns alist * ele"ents t$at crrespnds t t$e ans'er t t$e uer! ne and nl ne slutin isa'aited
)$e hand#eCF0n"(Daria!#e4 Formu#a4 ction3%pression4 2erm)"et$d returns alist * ele"ents t$at crrespnds t t$e ans'er t t$e uer! ne slutin is a'aited
)$e hand#eCF0##(Daria!#e4 Formu#a4 ction3%pression4 2erm)"et$d returns alist * ele"ents t$at crrespnds t t$e ans'er t t$e uer! All t$e slutins are a'aited!
)$e hand#eCF0Some(Daria!#e4 Formu#a4 ction3%pression4 2erm)"et$d returns alist * ele"ents t$at crrespnds t t$e ans'er t t$e uer! All slutins are a'aited!
.r t$ese t$ree "et$ds; t$e *irst para"eter is t$e &aria,le used 'it$in t$e *r"ula! )$e secnd*r"ula represents t$e cnditin * t$e C.P! )$e t$ird para"eter is t$e reuested actin t ,e
per*r"ed! )$e last para"eter is t$e a#ent '$ 'ill per*r" t$e actin i* accepted!
)$e hand#eRe$use(2erm4 ction3%pression4 Formu#a) "et$d returns true i* t$is"et$d trap t$e speci*ied *r"ula '$en an a#ent
8/13/2019 Semantics Programmer Guide
45/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e 8 of (%
)$e hand#eReject0roposa#(2erm4 ction3%pression4 Formu#a) returns true i* t$e
speci*ied *r"ula is trapped '$en an a#ent
8/13/2019 Semantics Programmer Guide
46/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e 8( of (%
t insert (a&a cde t realie speci*ic actins related t t$e applicatin! )$e noti$"Su!scri!e(2erm su!scri!er4 Formu#a o!served4 Formu#a &oa#)"et$d
nti*ies t$e a#ent t$at it $as >ust recei&e a su,scri,e *r" t$e su,scri,er n t$e *r"ula?,ser&ed? 'it$ t$e #al ?#al?
)$e noti$"6nsu!scri!e(2erm su!scri!er4 Formu#a o!served4 Formu#a &oa#)"et$d nti*ies t$e a#ent t$at it $as >ust recei&e an unsu,scri,e *r" t$e su,scri,er n t$e*r"ula ?,ser&ed? 'it$ t$e #al ?#al?!
.r ea"ple
55 Sets t-e colour to yello" "-en it receives a subscribepu!#ic void noti$"Su!scri!e(2erm su!scri!er4 Formu#a o!sverved4 Formu#a &oa#) +
((Sensor&ent)m"&ent)setSu!scri!ed(true)
,55Sets t-e colour to gray "-en it receives an unsubscribepu!#ic void noti$"6nsu!scri!e(2erm su!scri!er4 Formu#a o!sverved4 Formu#a &oa#)+
((Sensor&ent)m"&ent)setSu!scri!ed($a#se),
void setSu!scri!ed(!oo#ean su!scri!ed) +i$ ( su!scri!ed ) +
main0ane#setBac'&round(Co#or>3..O8),e#se +
main0ane#setBac'&round(Co#or?R>),
,
)$e StandardCustomi-ationdapter pr&ides a ,asic i"ple"entatin * t$eStandardCustomi-ationinter*ace! + de*ault; eac$ "et$d des nt$in#!
Planner
Planners are used t *ind a plan t$at reac$es a #i&en #al! speci*ic planner is pr&ided , t$e*ra"e'r%! )$e pr#ra""er $as t pr&ide $is$er 'n planner! )$is ne "ust i"ple"ent t$einter*ace 0#anner; '$ic$ de*ines nl ne "et$d $ind0#an(Formu#a4SemanticRepresentation)! )$e "et$d returns a (ade +e$a&iur crrespndin# t t$e eecutin
* a plan '$ic$ "a%es it pssi,le t reac$ t$e #i&en #al!
Semantic inter*retation *rinci*les
)$e Se"antic interpretatin principles
8/13/2019 Semantics Programmer Guide
47/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e 8 of (%
)$e addSemanticInterpretation0rincip#e(SemanticInterpretation0rincip#e)
"et$d adds a ne' se"antic interpretatin principle at t$e end * t$e ta,le! Sets t$e inner sipinde at t$e crrect &alue
)$e addSemanticInterpretation0rincip#e(SemanticInterpretation0rincip#e 4int)"et$d adds a se"antic interpretatin principle in t$e ta,le at t$e speci*ied inde! Setst$e inner sip inde
)$e removeSemanticInterpretation0rincip#e(Finder) "et$d re"&es all t$ese"antic interpretatin principles t$at crrespnd t t$e *inder
)$e &etSemanticInterpretation0rincip#e(int) "et$d returns t$e se"anticinterpretatin principle at t$e speci*ied inde in t$e ta,le
)$e #oad2a!#e(SemanticCapa!i#ities) "et$d lads all t$e se"antic interpretatinprinciples in t$e ta,le *r t$e speci*ied a#ent
)$e si-e() "et$d returns t$e sie * t$e ta,le
)$e removeSemanticInterpretation0rincip#e(int) "et$d re"&es t$e se"anticinterpretatin principle at t$e speci*ied inde!
.2 $ist of generic S/Ps
In t$is sectin standard SIP pr&ided 'it$in t$e *ra"e'r% are presented in t$e rder t$e are in t$eta,le!
And )$is SIP is intended t ,e applied t an A *r"ula * t$e *r" (and 7 8$! Itprduces t' Se"antic Representatins t$e le*t part * t$e cn>unctin unctin
8/13/2019 Semantics Programmer Guide
48/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e 89 of (%
SIPs
ne statin# t$at t$e (ade a#ent ,elie&es t$e persistent *easi,ilit precnditin * t$erecei&ed "essa#e is satis*ied!
ne statin# t$e (ade a#ent ,elie&es t$e intentinal e**ect * t$e recei&ed "essa#e!
t$e last is t$e pstcnditin * an actin; t$e per*r"ance * '$ic$ $as >ust ,een,ser&ed , t$e (ade a#ent!
Alread$Reached5oal )$is SIP traps t$e intentins * t$e se"antic a#ent t$at t$e se"antica#ent alread ,elie&es! )$is t$us "a%es it pssi,le t a&id useless calculatins! )$is SIP isapplica,le n *r"ulae * t$e *r" (I 2a 7$
elief0ransfer
)$is se"antic interpretatin principle epresses a necessar cperatinprinciple * t$e (ade a#ent t'ards t$e ,elie*s t$at t$e sender
8/13/2019 Semantics Programmer Guide
49/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e 84 of (%
adds t$is ,e$a&iur t t$e a#ent! As a,&e; t$is ,e$a&iur is als encapsulated in anIntentiona#Behaviour t$at "e"ries t$e tri##erin# intentin and deletes it *r" t$ea#ent ,elie* ,ase i* it succeeds! I* n (ade ,e$a&iur can ,e *und , t$e plannin#c"pnent; t$is step des nt$in#! )$is SIP is applica,le n *r"ulae * t$e *r" (I agent7$
ActionPerformance t$is SIP pr&ides s"e ,asic plannin# *r #als * t$e *r" (done atrue$; '$ere ais a
8/13/2019 Semantics Programmer Guide
50/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e of (%
under a cnditin! )$is principle "a ,e applied '$en t$e (ade a#ent recei&es an &ree
"essa#e! )$is SIP is applica,le n *r"ulae * t$e *r" (I agent (done (action agent act$7$$! )$e app#" "et$d * t$e SIP calls t$e "et$d hand#e&ree * t$eStandardCustomi-ationclass
Propose )$is principle is intended t ,e applied '$en an a#ent recei&es a Prpse "essa#e!)$is SIP is applica,le n *r"ulae * t$e *r" (& agent1 (or (not (I agent1 (done act 7$$$ (Iagent. (done act 7$$$$! )$e app#""et$d * t$e SIP calls t$e "et$d hand#e0roposa#*t$e StandardCustomi-ationclass
Re%uestWhenever )$is SIP ena,les t$e (ade a#ent t add an ,ser&er t t$e ,elie* ,ase!)$is SIP is applica,le n *r"ulae * t$e *r" (or (not (& agent su+scri+eropert'$$ (or (I
su+scri+er goa%$ (fora%% ?e (not (done ?e (not (& agent su+scri+eropert'$$$$$$$! )$e app#""et$d calls t$e noti$"Su!scri!e "et$d * t$e StandardCustomi-ation class! )$eReuest8heneverclass in$erits t$e Su!scriptionclass
Subscribe )$is SIP ena,les t$e (ade a#ent t add an ,ser&er t t$e ,elie* ,ase! )$is SIP isapplica,le n *r"ulae * t$e *r" (or (I su+scri+er goa%$ (or (fora%% ?' (not (& agent ire$$$(fora%% ?e (not (done ?e (fora%% ?' (not (& agent ire$$$$$$$$$! )$e app#""et$d calls t$enoti$"Su!scri!e "et$d * t$e StandardCustomi-ation class! )$e Su!scri!e classin$erits t$e Su!scriptionclass
4nsubscribe )$is principle is intended t ,e applied '$en an a#ent recei&es an6nSu!scri!e"essa#e! )$is SIP is applica,le n *r"ulae * t$e *r" (& agent (or (not (&agent propert' $$ (or (not (I su+scri+er goa%$$ (fora%% ?e (not (done ?e (not (& agent propert'
$$$$$$$$ r * t$e *r" (& agent (not (I su+scri+er goa%$$$! I* t$e SIP is applica,le; it re"&est$e ,ser&er related t t$e speci*ied prpert! )$e app#" "et$d calls t$enoti$"6nsu!scri!e* t$e StandardCusomi-ation class
4nreachable5oal )$is principle is intended t ,e applied t all intentins t$at $a&e nt,een realised! )$ese intentins are cnsidered as nt *easi,le! I* t$e intentin ,ec"es *r"a reuest * ant$er a#ent; a ne' SR is #enerated in rder t in*r" t$e t$er a#ent; t$at t$eintentin is nt *easi,le! )$e ne' S/ *r"ula is * t$e *r" (I agent (& r (fora%% ?e (not (&agent (feasi+%e ?e 7$$$$$$; "eanin# t$e a#ent agent $as t$e intentin t$at r ,elie&es t$atagentt$in%s t$at t$ere is nt an unspeci*ied e&ent a*ter '$ic$ 7'uld ,e true! )$is SIP isapplica,le n *r"ulae * t$e *r" (I agent 7$!
.3 Adding new S/Ps
)$e pr#ra""er $as t &erride t$e setupSemanticInterpretation0rincip#es "et$d * t$eSemanticCapa!i#ities class
pu!#ic void setupSemantic4nterpretation&rinciples()+ super.setupSemantic4nterpretation&rinciples() &etM"SemanticInterpretation2a!#e()addSemantic4nterpretation&rinciple(ne9 m"SI0(this))
,
It is $i#$l rec""ended t call t$e "et$d
8/13/2019 Semantics Programmer Guide
51/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e 1 of (%
supersetupSemanticInterpretation0rincip#es() ; '$ic$ "a%es it pssi,le t create a ne'
instance * SIP ta,le and t lad t$e #eneric SIPs! @it$ut it; t$e created a#ent 'ill nt $a&e anSIP i* t$e user des nt lad t$e" eplicitl and t$en t$e (SA is una,le t aut"aticallc""unicate 'it$ t$er a#ents usin# t$e *ra"e'r% "ec$anis"s!
)$e SemanticInterpretation0rincip#e2a!#e inter*ace pr&ides t' cnstants t $elp t$eadditin * ne' SIP
Frontis used t add a SIP at t$e ,e#innin# * a list 3ndis used t add a SIP at t$e end * t$e list
Warnin!)$e pr#ra""er "ust ,e &er care*ul i* s$e 'is$es t add a ne' SIP! As t$e ta,le * SIP is
rdered; t$e place '$ere t$e SIP is inserted "ust ,e c$sen 'it$ cautin! .r ea"ple; t$e addedSIP can catc$ *r"ula and t$en stp t$e classical interpretatin "ec$anis" in s"e case it s$uldnt! A SIP t$at $as a *r"ula "re speci*ic t$at ant$er "ust ,e placed ,e*re in t$e list!
In all t$e cases; it is necessar t use t$e addSemanticInterpretation0rincip#e "et$d ust ccurred! In t$e case presented in t$e ea"ple * *i#ure 4; t$e a#ent2a
,elie&es t$at t$e a#entsender$as >ust in*r"ed it t$at t$e te"perature is ten!
)$e SIP inde * SR * an inc"in# "essa#e is al'as 0! )$at "eans t$at t$e SIPs are tested *r"
t$e ,e#innin# * t$e ta,le! )$e *irst SIP tested , t$e SemanticInterpreterBehaviour isctionFeatureSIP! It is applica,le and prduced *ur ne' SRs 'it$ t$eir S/ *r"ula representedin t$e *i#ure and 'it$ a SIP inde set at 0! )$e *easi,ilit precnditin *r"ula is nt represented
,ecause it is ne&er used *urt$er and its 'ritin# 'uld $a&e ,een t lar#e *r t$e *i#ure! SIP isapplica,le n t$e persistent precnditin and t$e pstcnditin! )$ese *r"ulae are t$en asserted int$e ,elie* ,ase! n t$e t$er $and; t$e Be#ie$2rans$erSIP is applica,le n t$e ratinal e**ect*r"ula and prduces a ne' SR
8/13/2019 Semantics Programmer Guide
52/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e % of (%
.i#ure 5s$'s t$e interpretatin prcess *r a Reuest"essa#e! .r t$is purpse; let us cnsidert$e &er si"ple ntl#ical actin 8I2
8/13/2019 Semantics Programmer Guide
53/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e - of (%
.on&parse.on&((&etction0arameter(time)toStrin&()))
, KK in this state the !ehaviour !#oc's itse#$ !#oc'2ime ; 9a'eup2ime @ S"stemcurrent2imeMi##is() i$ (!#oc'2ime ) !ehaviour!#oc'(!#oc'2ime) !ehavioursetState(A) !rea' , case A: + KK in this state the !ehaviour can !e restarted $or t9o reasons KK A the timeout is e#apsed and then the !ehaviour is de$initive#"
KK $inished)KK E a messa&e has arrived $or this a&ent then it !#oc's a&ain
!#oc'2ime ; 9a'eup2ime @ S"stemcurrent2imeMi##is() i$ (!#oc'2ime P; ) +
KK timeout is e%pired !ehavioursetState(SemanticBehaviourS6CC3SS) , e#se !ehaviour!#oc'(!#oc'2ime) !rea' , de$au#t : + KK this case shou#d not occur !ehavioursetState(SemanticBehaviour313C62ION
8/13/2019 Semantics Programmer Guide
54/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e 8 of (%
a
8/13/2019 Semantics Programmer Guide
55/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e of (%
.) 0ample of applicative S/Ps
/et us suppse t$at in an applicatin; an a#ent needs t s$' a p$t in a panel! It is a ,e$a&iuralaspect * t$e a#ent and s s$uld ,e dne , a SIP! .r ea"ple; t$e cde culd ,e t$e *ll'in#
pu!#ic c#ass Die9erSI0Content e%tends SemanticInterpretation0rincip#e + private Formu#a pattern private 0hoto0ane# photo0ane#
pu!#ic Die9erSI0Content(SemanticCapa!i#ities capa!i#ities4 0hoto0ane# pp) + super(capa!i#ities) pattern ; S.0atternManip$romFormu#a((B a&ent (ima&e@content id content)))
photo0ane# ; pp ,
pu!#ic rra".ist app#"(SemanticRepresentation sr) thro9s SemanticInterpretation0rincip#e3%ception + MatchResu#t app#"Resu#t ; S.0atternManipmatch(pattern4sr&etS.Representation()) i$ (app#"Resu#t H; nu##) +
tr" + !"teL !"tes ;((B"teConstantNode)app#"Resu#t&et2erm(content))#%
8/13/2019 Semantics Programmer Guide
56/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e ( of (%
desc) (ima&e@description id desc)) (set))))
photo0ane# ; pp ,
pu!#ic rra".ist app#"(SemanticRepresentation sr) thro9s SemanticInterpretation0rincip#e3%ception + MatchResu#t app#"Resu#t ; S.0atternManipmatch(pattern4sr&etS.Representation()) i$ (app#"Resu#t H; nu##) + tr" + photo0ane#add0hoto5escription(app#"Resu#t&et) rra".ist #ist ; ne9 rra".ist() sr.setSemantic4nterpretation&rinciple4ndex(sr.getSemantic4nterpretation&rinciple4ndex() F /)# list.add(sr)#
return #ist , catch (S.0atternManip8ron&2"pe3%ception 9te) +, , return nu## ,,
In t$is case; t$e cnstructr in t$e sa"e as t$e pre&ius ne *r ant$er pattern!I* t$e SIP is applica,le; t$e list * p$ts is "di*ied! )$e "et$d returns a SR list t indicate t$att$e SIP applied! n t$e t$er $and; t$e sa"e SR is added in t$is list ,ecause it is 'is$ed t$at t$einc"in# *r"ula ,e asserted in t$e ,elie* ,ase ect * t$e list i* it is identi*ied!
8/13/2019 Semantics Programmer Guide
57/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e of (%
1.2 Tools class
)$e 2oo#sclass * t$e jadesemanticsintrepeterpac%a#e pr&ides use*ul "et$ds )$e termEI5(2erm)"et$d returns t$e AI crrespndin# t t$e ter" representin# an
a#ent )$e I5E2erm(I5)"et$d returns t$e ter" representin# an a#ent t t$e crrespndin#
AI )$e isCommunicativectionFromMe2oReceiver(ction3%pression4 2erm4
Semantic&ent) "et$d tests i* t$e actin epressin #i&en in para"eter is ac""unicati&e actin *r" t$e current se"antic a#ent t t$e speci*ied recei&er!
1.3 til class
)$e 6ti#class * t$e jadesemantics#an&s#too#s pac%a#e pr&ides use*ul "et$d t $andleS/ *r"ulas!
)$e !ui#dndNode(.istO$Nodes) "et$d returns a ndNode *r"ula ,uilt 'it$ t$e*r"ulae * t$e #i&en list! I* t$e sie * t$e list euals 1; it returns t$e nl *r"ula * t$e list
8/13/2019 Semantics Programmer Guide
58/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e 9 of (%
= identi$"in&
8/13/2019 Semantics Programmer Guide
59/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e 4 of (%
= predicate
= true = $a#se= eua#s
propositionMBO.
resu#t ; as
8/13/2019 Semantics Programmer Guide
60/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e ( of (%
as
8/13/2019 Semantics Programmer Guide
61/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e (1 of (%
= rea#MBO.
$unctiona#
8/13/2019 Semantics Programmer Guide
62/62
5a0e 6emantics A00'on Pro#rammer7s #ui0e
Pa#e (% of (%
$unctiona#