Formal Semantics for an Abstract Agent Programming Language PowerPoint PPT Presentation

presentation player overlay
1 / 40
About This Presentation
Transcript and Presenter's Notes

Title: Formal Semantics for an Abstract Agent Programming Language


1
Formal Semantics for an Abstract Agent
Programming Language
  • K.V. Hindriks, Ch. Mayer et al.
  • Lecture Notes In Computer Science, Vol. 1365, 1997

http//www.nue.ci.i.u-tokyo.ac.jp/duc/ppt/abstra
ct-apl.ppt M1. Nguyen Tuan Duc (duc_at_nue)
2
Source
  • Formal Semantics for an Abstract Agent
    Programming Language
  • Authors K.V.Hindriks, F.S. de Boer, W. van der
    Hock, J.Ch. Mayer (Dept. of Computer Science,
    Utrecht Univ., the Netherlands)
  • Lecture Notes In Computer Science Vol. 1365,
    1997, pp 215 229
  • Proceedings of the 4th International Workshop on
    Intelligent Agents IV, Agent Theories,
    Architectures, and Languages

3
1.Introduction
  • There exist many agent programming languages
  • AGENT-0, AgentSpeak(L)
  • Lack a clear and formally defined semantics,
    difficult to formalize the design, specification
    and verification
  • Need for an agent programming model based on
    existing programming concepts
  • Logic programming, imperative programming
  • Operational semantics

4
Agenda
  • Introduction
  • Programming BDI-agents
  • Abstract agent programming language
  • Operational semantics
  • Comparison with existing APLs
  • Conclusions

5
2.Programming BDI-agents
  • BDI-agents agents have
  • Explicit goals (Desires)
  • A set of plans to achieve a goal (Intensions)
  • Information about the environment (Belief)
  • Based on Human practical reasoning theory
    (Michael Bratman)
  • Many agent programming languages (APLs) based on
    this model
  • AGENT-0, AgentSpeak(L),
  • However, APL is still disconnected from theory

6
Characteristics of BDI-agents
  • Complex internal mental state changes over time
  • Beliefs, Desires, Plans, Intentions
  • Pro-active and reactive
  • Goal-directed (proactive)
  • Respond to changes in environment in a timely
    manner (reactive)
  • Reflective
  • Meta-level reasoning capabilities (e.g. goal
    revision)
  • Agent goal-directed, belief-transforming entity

7
Requirement for APL
  • Theoretically, APL must have features for
  • Belief updating (for newly observed, communicated
    data, )
  • Goal updating (for goal revision)
  • Practical reasoning (for finding the means to
    achieve a goal)
  • Practically, APL should contain all the familiar
    constructs from imperative programming
  • Sequential composition, tests, parallel
    execution, etc.

8
3. An abstract agent programming language
(3APL)
  • An APL provides mechanism for
  • Belief updating
  • Goal updating (goal revision)
  • Practical reasoning (rule / plan to achieve a
    goal)

9
Belief
  • Beliefs are represented as First-order logic
    formulae from a language L.
  • P, F, C, A
  • P set of predicate symbols
  • F set of function symbols
  • C set of constant
  • A set of action symbols (not used in Belief)
  • Basic elements of L are given by a signature (S)
  • S ltP, C, F, Agt
  • Term T x f(t, t,..., t) (x?TVar,
    variable f?F)
  • Formulae B P(t, t,..., t) not B B?B B?B
    ?x.P(x)
  • At the set of atoms ( constants, primitive
    predicates, )

10
Example 1 robot Greedy
  • Robot Diamond
  • Diamond may randomly appear / disappear
  • Rocks are obstacles
  • Basic predicates
  • diam( d, x, y ) diamond d at (x, y)
  • robot( r, x, y ) robot r at (x, y)
  • rock( x, y ) rock at (x, y)
  • Basic functions
  • xc( x, y ) x of nearest diamond from (x, y)
  • yc( x, y )
  • Perfect knowledge

11
Goals and actions
  • Goal set of objectives agent tries to achieve
  • Goal to do some action
  • Goal to achieve some state of affairs
  • Signature S ltP, F, C, Agt, Gvar global
    variables, set of goal Lg
  • A?Lg (basic actions)
  • At ? Lg
  • F?L ? f? ? Lg
  • Gvar ? Lg
  • p1, p2 ? Lg ? p1 p2, p1 p2, p1 p2 ?Lg
  • Rule for composition of goal
  • Basic goals basic actions, achievement goals
    (P(t)?At), test goal (f?)
  • Basic actions are update operators on belief base
  • pickup( Greedy, d ) ? delete diam( d, x, y )
    from s (belief base)

12
Goal variables
  • The language contains variables range over Goals
  • Reflective reasoning
  • Communication (parameter passing)
  • Receive request to establish some goal in a goal
    variable

13
Example 2 Actions and goal of Greedy
  • west, east, north, south move a step
  • pickup( r, d ) robot r pickup diamond d
  • Goal max_diam
  • User defined predicate
  • Usually given in a procedure definition

14
Practical reasoning rules
  • To achieve its goals, agent has to
  • Find the means for achieving them
  • Revise its goal (in case of failure)
  • ? Practical reasoning
  • Practical reasoning rules Lp
  • f?L, p,p?Lg ? p ? f p ? Lp
  • p head of the rule
  • p body of the rule
  • f guard
  • Global variables of the rule Free variables in
    p
  • Local variables variables in the rule except
    global one
  • Practical reasoning rule (PR) serves two
    functions
  • Mean, recipe to achieve a goal (plan rule)
  • Goal revision
  • Frepresents condition to apply the rule
  • Or used to retrieve data from B (by unifying
    predicates)

15
Plan rules procedural knowledge
  • Plan rules rules with head is a basic goal P(t)
  • P(t) may be viewed as procedure calls to plans to
    achieve the goal
  • Plan rules encode procedural knowledge of an agent

16
Example 3 plan rules
  • max_diam ? robot( Greedy, x0, y0 ) ? x xc( x0,
    y0 ) ? y yc( x0, y0 ) robot( Greedy, x, y )
    diam( z, x, y )? pickup( Greedy, z ) max_diam
  • Implementing greedy algorithm repeat the
    following action go to nearest diamond, take it

17
max_diam
0 1 2 3
  • x0 0, y0 0
  • x 1, y 1
  • robot(Greedy, 1, 1)
  • diam(z, 1, 1)?
  • pickup(Greedy, z)
  • x0 1, y0 1
  • x 3, y 2
  • robot(Greedy, 3, 2)
  • diam(z, 3, 2)?
  • pickup(Greedy, z)

0 1 2
18
robot( r, x, y )
  • robot( r, x, y ) ? robot( r, x0, y0 )
  • (x x0 ? y y0 )? (x lt x0)? west (x0 lt
    x)? east (y gt y0)? south (y0 gt y)? north
    robot( r, x, y)
  • robot( r, x0, y0 ) to retrieve current position
  • robot( r, x, y ) (in body) sub-goal

0 1 2 3
0 1 2
19
Revision of goals reflective rules
  • Rules with head contains an arbitrary programs
    (including goal variables)
  • Goal revise in case
  • Found a more optimal strategy
  • Failure

20
Example 4 More optimal strategy
  • Diamond suddenly appeared as nearer position
  • X robot( r, x, y ) ? robot( r, x0, y0 ) ?not( x
    xc( x0, y0 ) ? y yc(x0, y0) ) robot( r, xc(
    x0, y0 ), yc( x0, y0) )

21
Example 5 Failure
  • rock as (x0-1, y0)
  • west robot( r, x, y ) ? robot( r, x0, y0 ) ?
    rock( x0 1, y0 ) (ylty0)? north (y0 lt
    y)? south robot( r, x, y )

22
Three levels of agent programming
  • Action
  • Goal execution
  • Goal revision (self-modifying program)

23
Agent programs
  • Agent goal directed, belief transforming entity
  • Beliefs are updated by Actions
  • Goals are updated by execution and revision
  • An agent changes its beliefs and goals (PR and
    basic actions are fixed)

24
Mental state
  • Mental state lt?, sgt, where
  • ??Lg is a goal base (set of goals)
  • s? L is a belief base (set of beliefs)
  • Thus, the changing components in previous slide
  • Denote B set of belief bases, G PR-base
  • The behavior of an agent is fully specified if
  • The semantics of basic actions is given
  • The mechanism for executing goals and applying
    rules are defined

25
Some definitions
  • Free vs. bounded variables
  • P(x, d) ??x. Q(y, x) ? ?z. G(a, b, z)
  • Alpha conversion P(x, d) ??x1. Q(y, x1)??z.
    G(a,b,z)
  • Free(e) x x is free in e
  • Substitution x/5 f(x) f(5)
  • Unifier if t1, t2, are terms then unifier of
    t1, t2,, tn is a substitution ?such that
  • ?(t1) ?(t2) ?(tn)
  • Ex f(x, x) and f(y, z) ? ? x/z, y/z
  • Most general unifier (MGU) ?
  • ???unifier??? ? ??
  • In the above example x/c, y/c z/cx/z,
    y/z

26
Basic action transitions
  • Semantics of basic actions A is given by a
    transition function T B x B ? P(A)
  • P(A) is variant of A
  • If a ? T(s,s) then denoted by lts,sgta
  • lt, robot(Greedy, n, m), not(rock(n-1,m)),,
    , robot(Greedy, n-1, m), not(rock(n-1, m))gt
    west
  • lt, diam(d,n,m), robot(Greedy, n, m), , ,
    robot(Greedy, n, m), not(diam(d, n, m), gt
    pickup(Greedy, d)
  • By observing the environment, agent knows action
    has succeeded or failed

27
Agent program
  • An agent program is a quadruple ltT, ?0, s0, Ggt
  • T a basic transition function (specifying the
    effect of basic actions)
  • ?0 initial goal base
  • s0 initial belief base
  • G PR-base
  • Thus, to program an agent is to
  • specify its initial mental state
  • define semantics of basic actions
  • write a set of PR

28
Example 6 Agent program for Greedy
  • Basic actions
  • lt, robot(Greedy, n, m), not(rock(n-1,m)),,
    , robot(Greedy, n-1, m), not(rock(n-1, m))gt
    west
  • north, south, east
  • lt, diam(d,n,m), robot(Greedy, n, m), , ,
    robot(Greedy, n, m), not(diam(d, n, m), gt
    pickup(Greedy, d)
  • ?0 max_diam
  • s0 robot(Greedy, 0, 0), rock(1,5), rock(3,3),
    rock(2,1), diam(d, 2, 2)
  • PR-base in example 4, 5

29
4. Operational semantics
  • Operational semantics
  • Specify how a program can transform the system
    state
  • A transition system is a deductive system which
    allows to derive the transition of a program.
  • Transition rules specify the meaning of each
    programming construct.
  • Transition rules transform configuration
  • In APL, configuration is mental state lt?,sgt

30
4.1. Practical reasoning rule
  • V set of global variables in goal base
  • PR-rule application
  • p ? f p ? G ? s ?(f??)
  • ____________________________________
  • ltp, sgt V ? ?? ltp??, sgt
  • Where,
  • ?(p) ?(p), p??
  • A ? Gmeans A is a variant of a PR-rule (alpha
    conversion)
  • ?is a substitution such that no variable x
    ?(x)?V (retrieves parameter values from s)
  • ? Perform alpha-conversion to avoid interference
    of local and global parameters
  • ? followed by ?? to record the substitution
    process

31
Example 7 goal revision
0 1 2 3
  • Suppose that ? east robot( Greedy, 3, 2 ), s
    robot(Greedy, 0, 0), diam(d, 3, 2),
    diam(d,2,2)
  • Apply rule X robot( r, x, y ) ? robot( r, x0,
    y0 ) ?not( x xc( x0, y0 ) ? y yc(x0, y0) )
    robot( r, xc( x0, y0 ), yc( x0, y0) )
  • ? X/east, r/Greedy, x/3, y/2
  • ? f? robot(Greedy, x0, y0)?not( 3 xc(x0, y0)
    ?2 yc(x0, y0) )
  • ? x0/0, y0/0
  • p?? robot(Greedy, xc(0, 0), yc(0, 0))
    robot(Greedy, 2, 2)

32
4.2. Execution rules
  • E denotes termination
  • E p p
  • E p p
  • .
  • Execution rule 1 basic actions
  • lts, sgta
  • ____________________________
  • lta, sgtV ?F ltE, sgt
  • F is an identity substitution
  • Thus, basic action means changing the state
    according to transition function and stop
    execution

33
First-order tests
  • Check if some condition follows from s
  • s ?(f?)
  • ____________________
  • ltf?, sgtV ?? ltE, sgt
  • Ex diam(z, x, y)? pickup(Greedy, z)
  • ? z/d, x/2, y/2
  • After first-order test, goal becomes
    pickup(Greedy, d)

34
Sequential composition
  • ltp1, sgtV ?? ltp1, sgt
  • ________________________________
  • ltp1p2, sgtV ? ? ltp1 p2?, sgt
  • Ex in previous slide
  • p1 diam(z, x, y)?, p1 E
  • ? z/d, x/2, y/2
  • p2 pickup(Greedy, z)
  • p1p2? E pickup(Greedy, d) pickup(Greedy, d)

35
Non-deterministic choice
  • ltp1, sgtV ?? ltp1, sgt
  • _____________________________
  • ltp1 p2, sgtV ?? ltp1, sgt
  • ltp2, sgtV ?? ltp2, sgt
  • _____________________________
  • ltp1 p2, sgtV ?? ltp2, sgt

36
Parallel composition
  • ltp1, sgtV ?? ltp1, sgt
  • ____________________________________
  • ltp1 p2, sgtV ?? ltp1 p2?, sgt
  • (similar rule for p2)

37
Goal execution
  • Let ? p0, , pi, pi1, ?Lg,
  • V Free(?)
  • Goal execution
  • ltpi, sgtV ?? ltpi, sgt
  • __________________________________________________
  • lt p0, , pi, pi1, , sgtV ? lt p0, , pi,
    pi1, , sgt
  • There is no ? in the consequence
  • This is because the mental state is the top level
    of execution. At this level, various goal are
    executed in a parallel fashion without
    communication

38
Computations of an agent program
  • A computation of an agent program is a finite or
    infinite sequence of configurations lt?0, s0gt,
    lt?1, s1gt, lt?2, s2gt, such that, for each i lt?i,
    sigt ? lt?i1, si1gt

39
5. Comparison with existing APLs
  • AGENT-0
  • Only executes basic, primitive actions or skills
    of agent
  • Goal revision is restricted to removing
    infeasible commitments and uses built-in
    mechanism
  • 3APL allows much more general revision rule
  • AgentSpeak(L)
  • Quite similar to the proposed language
  • 3APL provides more general and high-level
    programming construct then AgentSpeak(L)

40
6. Conclusions
  • A transition system is a suitable formalism for
    specifying the operational semantics of APL
  • An abstract APL is proposed
  • Includes all the regular programming constructs
    from imperative programming and logic-programming
  • Future work
  • Extensions to multi-agent systems with
    communication
  • Mechanism for failure recovery
  • Apply notions of standard concurrency theory
    (p-calculus)
Write a Comment
User Comments (0)
About PowerShow.com