23
University of Jyväskylä Semantic Agent Programming Language (S-APL): A Middleware Platform for the Semantic Web Artem Katasonov and Vagan Terziyan University of Jyväskylä, Finland MSW at ICSC, Santa Clara August 4, 2008

University of Jyväskylä Semantic Agent Programming Language (S-APL): A Middleware Platform for the Semantic Web Artem Katasonov and Vagan Terziyan University

  • View
    218

  • Download
    0

Embed Size (px)

Citation preview

Page 1: University of Jyväskylä Semantic Agent Programming Language (S-APL): A Middleware Platform for the Semantic Web Artem Katasonov and Vagan Terziyan University

University of Jyväskylä

Semantic Agent Programming Language (S-APL):A Middleware Platform for the Semantic Web

Artem Katasonov and Vagan Terziyan

University of Jyväskylä, Finland

MSW at ICSC, Santa Clara

August 4, 2008

Page 2: University of Jyväskylä Semantic Agent Programming Language (S-APL): A Middleware Platform for the Semantic Web Artem Katasonov and Vagan Terziyan University

University of Jyväskylä

2

Ontological coordination problemTwo robots meet on Mars. If there is a need for

cooperation or at least coordination: Assume both follow FIPA’s Agent

Communication Language (ACL): can exchange messages, understand INFORM, REQUEST, REJECT, etc.

Assume both follow Beliefs-Desires-Intentions (BDI) architecture: share meaning of “I intend”, “My goal is”.

Both designed for Mars – hopefully have similar domain ontology concepts: “surface”, “rock” (labels may be different though).

Assume the US robot has a “jet pack” and thus can “fly”, while the EU robot has no idea about possibility of moving in third dimension.

How the US robot can communicate its movement intentions, so that two can coordinate?

Page 3: University of Jyväskylä Semantic Agent Programming Language (S-APL): A Middleware Platform for the Semantic Web Artem Katasonov and Vagan Terziyan University

University of Jyväskylä

3

Ontologies that need to be shared

ExtOnt(A)ExtOnt(A) - properties of the - properties of the external worldexternal world

MentOnt(A)MentOnt(A) - internal mental - internal mental properties of the agentproperties of the agent

BodyOnt(A)BodyOnt(A) - properties of the - properties of the agent's (physical) bodyagent's (physical) body

InOnt(A)InOnt(A) - properties of the sensory input- properties of the sensory input- properties of the - properties of the communication inputcommunication input

OutOnt(A)OutOnt(A) - properties of the action output- properties of the action output- properties of the - properties of the communication outputcommunication output

Domain ontologyDomain ontology

E.g. BDI modelE.g. BDI model

Available sensors Available sensors and actuatorsand actuators

Sensing vocabularySensing vocabulary

E.g. FIPAE.g. FIPA’’s ACLs ACL

Acting vocabularyActing vocabulary

E.g. FIPAE.g. FIPA’’s ACLs ACL

Are nottreated

To have effective coordination, agents have to share:

Impossible to standardize, so should enable ontological modelling

So that ”jet pack” and ”fly” would have accessible and interpretable descriptions

Page 4: University of Jyväskylä Semantic Agent Programming Language (S-APL): A Middleware Platform for the Semantic Web Artem Katasonov and Vagan Terziyan University

University of Jyväskylä

4

UBIWARE project

UBIWARE (2007 - 2010): Smart Semantic Middleware for Ubiquitous Computing.

Work towards the Semantic Web of Things interconnecting Web Services, humans, and physical entities.

A

Example: industrial maintenance case

Each resource has a proxy (representative) – a software agent:

To adapt between the data formats and protocols.

To enable new interactions (business processes).

Agents are controlled (programmed) in semantic RDF-based language - S-APL.

Page 5: University of Jyväskylä Semantic Agent Programming Language (S-APL): A Middleware Platform for the Semantic Web Artem Katasonov and Vagan Terziyan University

University of Jyväskylä

5

Semantic Agent Programming Language (S-APL)

Motivation: Need to be able to ontologically describe not only the domain, but the agents themselves, to enable interaction without pre-programming each agent about all possible capabilities and behaviors of other agents.

Similar to the challenge of semantic description of Web Services, but going beyond usage interfaces.

Our approach: RDF-based (more precisely, Notation 3) agent programming language.

In a nutshell:– Let’s start treating agents’ programs as data.– If it is data, let’s use the semantic data model (advantages are well-known).– Use Notation 3 (extension of RDF by Tim Berners-Lee) to overcome limitations of

basic RDF and make code human-readable/writable.

Page 6: University of Jyväskylä Semantic Agent Programming Language (S-APL): A Middleware Platform for the Semantic Web Artem Katasonov and Vagan Terziyan University

University of Jyväskylä

6

S-APL

It is a hybrid of semantic reasoners like Berners-Lee’s CWM and agent programming languages (APL) like AgentSpeak, AFAPL.

From APLs point of view: S-APL is a language that provides all the features (and more) as normal APLs, while being RDF based and thus providing advantages of semantic data model and reasoning.

From semantic reasoning point of view: S-APL is CWM extended with common APL features such as:– Beliefs-Desires-Intentions (BDI) architecture, i.e. ability to describe

goals and commitments - data items presence of which leads to some executable behavior, and

– Ability to link to sensors and actuators implemented in a procedural language, namely Java.

Page 7: University of Jyväskylä Semantic Agent Programming Language (S-APL): A Middleware Platform for the Semantic Web Artem Katasonov and Vagan Terziyan University

University of Jyväskylä

7

S-APL Agent Architecture

RA

BR

AB

RA

BR

AB

RA

BR

AB

RA

BR

AB

BlackboardBlackboard

DataData RulesRules

Beliefs storageBeliefs storage

Behavior EngineBehavior Engine

Pool of Pool of Atomic Atomic

BehavioursBehaviours c

S-APL S-APL RepositoryRepository

RAB: Reusable Atomic Behavior

Page 8: University of Jyväskylä Semantic Agent Programming Language (S-APL): A Middleware Platform for the Semantic Web Artem Katasonov and Vagan Terziyan University

University of Jyväskylä

8

Levels of semantics in S-APL use

The developers of a specific agent can decide how “semantic” they want it to be:– Semantic Reasoning. S-APL rules operating on N3 semantic

data.– Semantic Data. RABs (i.e. Java components) operating on N3

semantic data.– Workflow management. RABs operating on Java blackboard

objects, with S-APL used only as workflow management tool, specifying what RABs are engaged and when.

– Any combination of above.

Page 9: University of Jyväskylä Semantic Agent Programming Language (S-APL): A Middleware Platform for the Semantic Web Artem Katasonov and Vagan Terziyan University

University of Jyväskylä

9

Examples of S-APL syntax

Unconditional commitment to an action:{sapl:I sapl:do

java:ubiware.shared.MessageSenderBehavior}sapl:configuredAs { p:receiver sapl:is :John. p:content sapl:is

{:get :temperatureIn :room1}. sapl:Success sapl:add {:John :informs

:temperature}}

Rules:{ {?room :hasTemperature ?temp} :measuredBy ?sensor.

?temp > 30 }=> {...}

Page 10: University of Jyväskylä Semantic Agent Programming Language (S-APL): A Middleware Platform for the Semantic Web Artem Katasonov and Vagan Terziyan University

University of Jyväskylä

10

Non-semantic data transformation

OriginalData

Data Transformation

ScriptData-model-ontology

S-APLData-model-

ontologyN3

Domain-ontology

N3Standard RAB

First, the original data from the resource is transformed into a Notation 3 representation based on the ontology of the data model of the original data (e.g. “table”-“row”-“column” ontology for tables). This transformation is performed by a Reusable Atomic Behavior (RAB).

Second, the data from the data-model-ontology N3 is transformed into the final domain-ontology N3 using S-APL own means, i.e. rules.

Our platform includes a set of standard RABs such as TextTableReader, SQLReader, XMLReader, XMLWriter, etc.

Page 11: University of Jyväskylä Semantic Agent Programming Language (S-APL): A Middleware Platform for the Semantic Web Artem Katasonov and Vagan Terziyan University

University of Jyväskylä

11

SCADA events in CSV

RAB: TextTableReader SCADA agent Operator agent

Data Transformation

Semantic Reasoning

Ontology

RAB: XMLWriter

RAB: HTTPResponseSender

XHTML generationRule: Send every new event

to the Operator agent

Example application architecture

Page 12: University of Jyväskylä Semantic Agent Programming Language (S-APL): A Middleware Platform for the Semantic Web Artem Katasonov and Vagan Terziyan University

University of Jyväskylä

12

S-APL as communication content language

We use S-APL also as inter-agent communication content language:– One agent sends a query as

sapl:I sapl:want { {sapl:You sapl:answer {..query..} }} , the other answers with the matching part of its beliefs.

– One agent requests another agent to perform an action plan by sending the plan with

sapl:I sapl:want { sapl:You sapl:do {..plan..} }

Such interaction is easily programmed with S-APL itself. Our platform includes a set of “standard” S-APL models: Listener, Believer, Informer and Follower.

Page 13: University of Jyväskylä Semantic Agent Programming Language (S-APL): A Middleware Platform for the Semantic Web Artem Katasonov and Vagan Terziyan University

University of Jyväskylä

Example application architecture 2

Note: data processing is performed by DB agent, but the code for that is sent to it by User agent

RAB: SQLReader

DB agent User agent

Data Transformation

RAB: XMLWriter

RAB: HTTPResponseSender

XHTML generation

Oracle Event Log Follower

Informer Data access,

processing

List

Count

Page 14: University of Jyväskylä Semantic Agent Programming Language (S-APL): A Middleware Platform for the Semantic Web Artem Katasonov and Vagan Terziyan University

University of Jyväskylä

14

Policies in S-APL (example)

:ActionCommitment sapl:is {{sapl:I sapl:do ?behavior} sapl:configuredAs ?parameters

}.:Action rdfs:subClassOf :ActionCommitment;

sbac:restriction {sapl:I owl:sameAs ?subject. sapl:I owl:sameAs ?object}.:Print rdfs:subClassOf :Action;

sbac:restriction {?behavior = :Print. ?parameters sapl:hasMember {p:print sapl:is ?print}}.

:Swear rdfs:subClassOf :Print; sbac:restriction {:BadWord sapl:is ?word. sapl:true = "contains(?print,?word)"}.

Then, can specify a policy as e.g.{fg:Employee :Swear fg:Employee} sapl:is sbac:Prohibition

The platform includes the standard S-APL model SBACReasoner that enforces such access control policies.

Example of use: define an ontology of communicative acts and define a policy so that e.g. a ‘Follower’ agent obeys orders of only a certain class of agents.

Page 15: University of Jyväskylä Semantic Agent Programming Language (S-APL): A Middleware Platform for the Semantic Web Artem Katasonov and Vagan Terziyan University

University of Jyväskylä

15

Conclusions

It is not only that the Semantic Web needs agents as active software components to interconnect heterogeneous Web resources, but also agents need the Semantic Web technologies to enable open flexible coordination among them.

By no means, we do not claim that our work has solved either of these challenges.

We believe, however, that the S-APL language and other our related solutions provide a proper foundation for building middleware platforms for the Semantic Web.

Page 16: University of Jyväskylä Semantic Agent Programming Language (S-APL): A Middleware Platform for the Semantic Web Artem Katasonov and Vagan Terziyan University

University of Jyväskylä

16

Backup slides

Page 17: University of Jyväskylä Semantic Agent Programming Language (S-APL): A Middleware Platform for the Semantic Web Artem Katasonov and Vagan Terziyan University

University of Jyväskylä

17

UBIWARE project

Current project of Industrial Ontologies Group (IOG) lead by Vagan Terziyan (Professor in Distributed Systems at MIT department).

IOG now: Vagan + 2 PhDs + 2 PhD students + 1 MSc student + 1 BSc student.

UBIWARE (2007 - 2010): Smart Semantic Middleware for Ubiquitous Computing. Previous project: SmartResource (2004-2007).

Runs in Agora Center. Funded 80% by Tekes (Finnish National Agency for Technology and Innovation) and 20% by a set of companies:– Metso (paper industry), ABB and Fingrid (power networks), Inno-W

(software), Nokia (telecommunications).

– In SmartResource participated : TeliaSonera (telecommunications) and Tietoenator (software).

Page 18: University of Jyväskylä Semantic Agent Programming Language (S-APL): A Middleware Platform for the Semantic Web Artem Katasonov and Vagan Terziyan University

University of Jyväskylä

18

S-APL data modelG

_C1 accordingTo John

_C1

_C2 implies _C3

_C2

Time is Summer

_C3

Sun is Shining

RDF compliant. Statements are reified and linked to resources of type ContextContainer through hasMember predicate (and inverse memberOf).

Possibility of efficient object-oriented implementation inside the agent’s behavior engine:

• HashMap<String, SemanticStatement> and HashMap<String, ContextContainer>• ContextContainer objects hold links to their member SemanticStatements

Page 19: University of Jyväskylä Semantic Agent Programming Language (S-APL): A Middleware Platform for the Semantic Web Artem Katasonov and Vagan Terziyan University

University of Jyväskylä

19

S-APL: Rules

Conditional commitment:– {:John :loves ?x} => {...}

=> is the shorthand for sapl:implies. If the left side of => is truth (beliefs are connected with AND), the right side is copied into G. The commitment is removed after that (as fulfilled). Otherwise, it stays in beliefs and checked again and again until becomes true.

Persistent behavior rule (not removed upon execution)– { {...} => {...} } sapl:is sapl:Rule

Conditional action– {...} -> {...}; sapl:else {}

-> is the shorthand for sapl:impliesNow. Such a condition will be checked only once and will be removed even if the condition was false. Adding gb:else block defines what should be added to beliefs if the condition was false.

Page 20: University of Jyväskylä Semantic Agent Programming Language (S-APL): A Middleware Platform for the Semantic Web Artem Katasonov and Vagan Terziyan University

University of Jyväskylä

20

S-APL: Rules (2)

Exclusive condition:– {:John :Loves ?x .

sapl:I sapl:doNotBelieve {?x .. ..}

} => {...}

If the object of sapl:doNotBelieve matches G, the left side of => is false. If there are several sapl:doNotBelieve, they are connected with OR

Commitment with a guard condition:– { {...} => {...} } sapl:is sapl:true ;

sapl:existsWhile {...}

If the object of sapl:existsWhile is false, its subject is removed – in this case, the commitment is dropped.

Page 21: University of Jyväskylä Semantic Agent Programming Language (S-APL): A Middleware Platform for the Semantic Web Artem Katasonov and Vagan Terziyan University

University of Jyväskylä

21

S-APL: Action commitments

Unconditional commitment to an action:– {sapl:I sapl:do

java:ubiware.shared.MessageSenderBehavior} sapl:configuredAs

{p:receiver sapl:is :John . p:content sapl:is “bla bla” . sapl:Success sapl:add

{:John :was :notified} }

Special statements to add or remove beliefs: the subject can be sapl:Start, sapl:End, sapl:Success, and sapl:Fail. The predicate is either sapl:add or sapl:remove.

Sequential plan:– {sapl:I sapl:do ...} sapl:configuredAs

{ ... sapl:Success sapl:add {sapl:I sapl:do ...} }

Page 22: University of Jyväskylä Semantic Agent Programming Language (S-APL): A Middleware Platform for the Semantic Web Artem Katasonov and Vagan Terziyan University

University of Jyväskylä

22

S-APL: Querying constructs

{?man :loves ?girl. ?girl :age ?age} sapl:All ?girl.

{?person :age ?age. ?age <= 25} sapl:All ?person.

{?person :age ?age. {?person :loves ?x} sapl:is sapl:Optional} sapl:All ?person.

{{:John :loves ?girl} sapl:or {:Bill :loves ?girl}} sapl:All ?girl.

{?person :age ?age} sapl:OrderBy ?age.

sapl:OrderByDescending, sapl:Limit and sapl:Offset are also available. As in SPARQL

Page 23: University of Jyväskylä Semantic Agent Programming Language (S-APL): A Middleware Platform for the Semantic Web Artem Katasonov and Vagan Terziyan University

University of Jyväskylä

23

S-APL: statements and containers

After query ?x :accordingTo :Bill, can do:– { ... {?x sapl:is sapl:true} :accordingTo :John } => {...}– ?x sapl:is sapl:true– sapl:I sapl:add ?x– sapl:I sapl:remove ?x (used as pattern for removal)– sapl:I sapl:erase ?x (removed itself)– ?x sapl:hasMember {:room1 :hasTemperature 25} (new member added)

Can get ID of a statement with (then, can do most of above):– { {* :hasTemperature 25} sapl:ID ?x } :accordingTo :Bill– {?x rdf:predicate :hasTemperature} :accordingTo :Bill– {?x sapl:is sapl:true} :accordingTo :Bill– ?c :accordingTo :Bill. ?c sapl:hasMember ?x

Can do query like: { {?x sapl:is sapl:true} :according to :Bill. {?x sapl:is sapl:true} :accordingTo :John } => {...}