···36363737%Introduce prolog
38383939-2APL language is an agent-oriented programming language that realizes an integration of declarative and imperative style programming. The declarative style programming supports the implementation of the mental state of agents allowing them to reason about their mental states and update them accordingly. The imperative style programming supports the implementation of processes allowing programming constructs to implement both the flow of control as well as mechanisms such as procedure call, recursion, plan revision, and interface to existing imperative programming languages. In this section, we will proceed illustrating the sytanx of the language and both the operational and formal semantics. We will conclude the section discussing the execution of a multi-agent system and the 2APL deliberation process.
3939+2APL language is an agent-oriented programming language that realizes an integration of declarative and imperative style programming. The declarative style programming supports the implementation of the mental state of agents allowing them to reason about their mental states and update them accordingly. The imperative style programming supports the implementation of processes allowing programming constructs to implement both the flow of control as well as mechanisms such as procedure call, recursion, plan revision, and interface to existing imperative programming languages. In this section, we will proceed illustrating the syntax of the language and both the operational and formal semantics. We will conclude the section discussing the execution of a multi-agent system and the 2APL deliberation process.
404041414242\subsection{Syntax and operational semantics} %%%%%%% FABRIZIO HERE
43434444-There are 2 distinguished set of programming constructs for specifying a multi-agent system and individual agents. Our approach will be to illustrate the formal syntax little by little providing the examplaination of operational semantics throught simple fragments of code.
4444+There are 2 distinguished set of programming constructs for specifying a multi-agent system and individual agents. Our approach will be to illustrate the formal syntax little by little providing the explanation of operational semantics through simple fragments of code.
45454646\subsubsection{Multi-agent system specification} %%%%%%% FABRIZIO HERE
4747···9797\label{fig:ebnf_agent}
9898\end{figure}
9999100100-The basic building elements of the language are \texttt{<atom>} that denotes a Prolog like atomic formula starting with a lowercase letter used for stating Prolog atomic formulas, \texttt{<Atom>} that, again, denotes a Prolog like atomic formula starting with a capital letter but, in this case, it is used for invoking functions, \texttt{<ground\_atom>} that denotes a Prolog ground atomic formula\footnote{Prolog formula that does not contain any free occurence of variables}, \texttt{<Var>} that denotes as a string with a capital letter and it is used for variables and, finally, \texttt{<ident>} that denotes a string with a lowercase letter and it used for identifiers.
100100+The basic building elements of the language are \texttt{<atom>} that denotes a Prolog like atomic formula starting with a lowercase letter used for stating Prolog atomic formulas, \texttt{<Atom>} that, again, denotes a Prolog like atomic formula starting with a capital letter but, in this case, it is used for invoking functions, \texttt{<ground\_atom>} that denotes a Prolog ground atomic formula\footnote{Prolog formula that does not contain any free occurrence of variables}, \texttt{<Var>} that denotes as a string with a capital letter and it is used for variables and, finally, \texttt{<ident>} that denotes a string with a lowercase letter and it used for identifiers.
101101102102\paragraph{Beliefs and Goals}
103103···155155\label{fig:example_goalbase}
156156\end{figure}
157157158158-It is worth noting that having a goal ``\texttt{a and b}'' is different than having two goals ``\texttt{a, b}''. In the former the agent is pursuing the goal of achiving both the goal \texttt{a} and the goal \texttt{b} together, while in the latter the agent has two different goals \texttt{a} and \texttt{b} to achieve. Morover, it is important to state that a goal base is actually an ordered list such that the goals are ordered by a priority. The first goal in the list is the one with highest priority, while the last goal in the list is the one with the lowest priority.
158158+It is worth noting that having a goal ``\texttt{a and b}'' is different than having two goals ``\texttt{a, b}''. In the former the agent is pursuing the goal of achieving both the goal \texttt{a} and the goal \texttt{b} together, while in the latter the agent has two different goals \texttt{a} and \texttt{b} to achieve. Moreover, it is important to state that a goal base is actually an ordered list such that the goals are ordered by a priority. The first goal in the list is the one with highest priority, while the last goal in the list is the one with the lowest priority.
159159160160\paragraph{Basic Actions}
161161···197197\label{fig:ebnf_beliefupdate}
198198\end{figure}
199199200200-Figure~\ref{fig:example_beliefupdate} provides an excerpt of belief update actions available in agent \texttt{harry}. For instance, the agent can pickup a bomb if the agent believes it does not already carrying a bomb and, if the action will succedd, the agent will believe that it is carrying a bomb. %It important to see that the agent cannot pickup a bomb consecutively.
200200+Figure~\ref{fig:example_beliefupdate} provides an excerpt of belief update actions available in agent \texttt{harry}. For instance, the agent can pickup a bomb if the agent believes it does not already carrying a bomb and, if the action will succeed, the agent will believe that it is carrying a bomb. %It important to see that the agent cannot pickup a bomb consecutively.
201201202202\begin{figure}[htp]
203203\begin{verbatim}
···264264\label{fig:ebnf_testaction}
265265\end{figure}
266266267267-Let imagine that, for instance, an agent has a certain belief \texttt{p(a)} and it is pursing the goal of achieving a situation \texttt{q(b)} and we are querying first for \texttt{B(p(X)) \& G(q(X))} and then for \texttt{B(p(X)) \& G(q(Y) or r(X))}. In the first case the query will fail since no substituion is possible, while in the second case the query will succedd by the substituion $\rho=\{X/a, Y/b\}$.
267267+Let imagine that, for instance, an agent has a certain belief \texttt{p(a)} and it is pursing the goal of achieving a situation \texttt{q(b)} and we are querying first for \texttt{B(p(X)) \& G(q(X))} and then for \texttt{B(p(X)) \& G(q(Y) or r(X))}. In the first case the query will fail since no substitution is possible, while in the second case the query will succeed by the substitution $\rho=\{X/a, Y/b\}$.
268268269269-\emph{Goal dynamics action} are used to adopt and drop goals to and from an agent's goal base. The adopt goal action has two forms, the first one for adopting a goal giving it the maximum priority and another one for giving it the least priority. Also, the drop goal action has three different forms tha are used to drop from an agent’s goal base, respectively, exactly the goal specified, all goals that are subgoal of the goal specificied and all goals that have the goal specified as a subgoal. The formal syntax is provided in Figure~\ref{fig:ebnf_goalactions}.
269269+\emph{Goal dynamics action} are used to adopt and drop goals to and from an agent's goal base. The adopt goal action has two forms, the first one for adopting a goal giving it the maximum priority and another one for giving it the least priority. Also, the drop goal action has three different forms they are used to drop from an agent’s goal base, respectively, exactly the goal specified, all goals that are subgoal of the goal specified and all goals that have the goal specified as a subgoal. The formal syntax is provided in Figure~\ref{fig:ebnf_goalactions}.
270270271271\begin{figure}[htp]
272272\begin{verbatim}
···506506process all events received from the external environment, all internal events indicating the failure of plans, and all messages received from other agents, respectively. An event from external environment is processed by applying the first applicable PC-rule to it. An internal event, which identifies a failed plan, is processed by applying the first applicable PR-rule to the failed plan. A received message is then processed by applying the first applicable PC-rule to it. It is worth noting that the application of rules
507507to process events generates and add plans to the corresponding agent’s plan base.
508508509509-If in a deliberation cycle no rule could be applied, no plan could be executed, and no event could be processed, then it makes no sense to try again a new cycleof deliberation steps, except when a new event or message has arrived.
509509+If in a deliberation cycle no rule could be applied, no plan could be executed, and no event could be processed, then it makes no sense to try again a new cycle of deliberation steps, except when a new event or message has arrived.
510510511511-The predefined deliberation cycle has the two following properties: first, if the execution of a plan fails, then the plan will either be repaired in the same deliberation cycle or get re-executed in the next deliberation cycle, since plans are executed before internal events are processed. Second, if the first action fails and there is no plan repair rule for it, then the failed plan may be successfully executed in the next deliberation cycle, since the belief and agoal bases can be modified in one deliberation cycle such that belief and goal test actions may be executed successfully in the next cycle.
511511+The predefined deliberation cycle has the two following properties: first, if the execution of a plan fails, then the plan will either be repaired in the same deliberation cycle or get re-executed in the next deliberation cycle, since plans are executed before internal events are processed. Second, if the first action fails and there is no plan repair rule for it, then the failed plan may be successfully executed in the next deliberation cycle, since the belief and a goal bases can be modified in one deliberation cycle such that belief and goal test actions may be executed successfully in the next cycle.
512512513513\section{2APL Platform and Tools} %%%%%%% BORJA+MARCOS HERE
514514
+1-1
docs/2apl-pres.tex
···10531053\frame{
10541054 \frametitle{Formal Semantics}
1055105510561056- % the objective of the formal semantics is to valitade the program across the specifications
10561056+ % the objective of the formal semantics is to validate the program across the specifications
10571057 With formal semantics, it is possible to verify whether agent programs
10581058 satisfy their (formal) specifications.
10591059