3.2 ConGolog
3.2.3 Extending the Transition Semantics to Procedures
This subsection describes how the transition semantics of ConGolog can be extended to deal with procedures. Extending the semantics to deal with procedures necessitates the use of a second-order definition of Trans and Final, because a recursive procedure may do an arbitrary number of procedure calls before it performs a primitive action or test, and such procedure calls are not viewed as transitions. The material presented in this subsection is quite technical and can be skipped by the reader on a first reading.
A central notion in the definition of the semantics of ConGolog regarding procedures is
the concept of an environment. An environment E is a collection of procedure definitions
proc(P1( ~v1), β1); ...; proc(Pn( ~vn), βn), where Pi is the name of the i-th procedure in E, ~vi are
its formal parameters and βi is its procedure body. A procedure body is a ConGolog program,
possibly including both procedure calls and new procedure definitions.
Formally, to extend the semantics of ConGolog to deal with procedures we have to consider three new program constructs:
3.2. CONGOLOG 51 • {E; σ}, where E is an environment and σ a program extended with procedure calls. This is the {proc(P1( ~v1), β1); ...; proc(Pn( ~vn), βn); σ} construct already listed in Section 3.2.
{E; σ} binds procedure calls in σ to the definitions given in E. The usual notion of free and bound apply, so for example in{proc(P1(), a); [P2, P1]}, P1 is bound but P2 is free.
• P (~t), where P is a procedure name and ~t actual parameters associated to the procedure P ; as usual, the situation argument in the terms constituting ~t is replaced by now . P (~t) denotes a procedure call, which invokes procedure P on the actual parameters ~t evaluated in the current situation.
• [E : P (~t)], where E is an environment, P a procedure name and ~t actual parameters
associated to the procedure P . [E : P (~t)] denotes a procedure call that has been con-
textualized by the environment in which the definition of P is to be looked for is E.
The semantics of ConGolog programs with procedures is specified by providing a second-order definition for both Trans and Final. Trans is defined as follows:
Trans(σ, s, δ, s0)≡ ∀T.[... ⊃ T (σ, s, δ, s0)]. (3.43)
Here, the ellipsis stands for the universal closure of the conjunction of the original set of axioms for Trans modulo textual substitution of Trans with T , together with the following two assertions: T ({E; σ}, s, δ, s0)≡ T (σPi(~t) [E:Pi(~t)], s, δ, s 0); (3.44) T ([E : P (~t)], s, δ, s0)≡ T ({E; βPv~~p t[s]}, s, δ, s 0). (3.45) Here, σPi(~t)
[E:Pi(~t)] denotes the program σ with all procedures bound byE and free in σ replaced
by their contextualized version, and where βPv~~p
t[s] denotes the body of the procedure P in E
with formal parameters ~vp substituted by the actual parameters ~t evaluated in the current
situation. The first of these two axioms says that when a program with an associated en-
vironment E is executed, all procedure calls bound by E are simultaneously substituted by
procedure calls contextualized by the environment of the procedure. The second axiom says that when a contextualized procedure call is executed, the call is replaced by the body of
the procedure, associated with E in order to deal with further procedure calls according to
the lexical (or static) scoping rule. Furthermore, the actual parameters are evaluated in the current situation, and then are substituted for the formal parameters in the procedure bodies, which yields call-by-value parameter passing.
Similarly, Final is defined as follows:
Final(σ, s)≡ ∀F.[... ⊃ F (σ, s)],
where the ellipsis stands for the universal closure of the conjunction of the original set of axioms for Final modulo textual substitution of Final with F , together with the following assertions:
F ({E; σ}, s) ≡ F (σPi(~t)
[E:Pi(~t)], s);
F ([E : P (~t)], s) ≡ F ({E; βPv~~p t[s]}, s).
In [dGLL00], de Giacomo, Lesp´erance and Levesque show the following equivalence (their Theorem 4):
Proposition 2: With respect to programs without procedures, the second order definition of
Trans and Final introduced above is equivalent to the versions introduced in Section 3.2.1. Note that no assertions for uncontextualized procedure calls are present in the defini- tions of Trans and Final: a procedure call which cannot be bound to a procedure definition neither can do transitions nor can be considered successfully completed. In particular, the second-order definition allows to assign a formal semantics to every recursive procedure, in- cluding vicious circular ones. The definition of Trans disallows the (step-wise) execution of such ill-formed procedures, and at the same time through the definition of Final they are not considered as completed. As an example, let us consider the ill-formed program
{proc(P (), P ()); P ()}. We will use E1 as an abbreviation for proc(P (), P ()). The program
{E1; P ()} can do a transition if and only if Trans({E1; P ()}, s, δ, s0) holds for some hs0, δi.
From the second-order definition of Trans and the fact that{E1; P ()} does only involve pro-
cedure definition and invocation follows that Trans({E1; P ()}, s, δ, s0) holds if and only if
T ({E1; P ()}, s, δ, s0) holds for all predicates T that satisfy the two assertions 3.44 and 3.45.
This is equivalent to the following:
T ({E1; P}, s, δ, s0)≡
T ([E1 : P ], s, δ, s0)≡
T ({E1; P}, s, δ, s0).
The above does not cause any implications regarding the truth value of T ({E1; P}, s, δ, s0).
As a result, the second-order definition of Trans yields Trans({proc(P (), P ()); P ()}, s, δ, s0)≡ False. Similarly, it is possible to verify that{proc(P (), P ()); P ()}, s, δ, s0)} is not final. Thus, {proc(P (), P ()); P ()} can neither perform transitions nor is it final.
On the other hand, if we consider programs with well-defined procedures (or without procedures), we obtain clear implications for the predicates T . As an example, let us consider a modification of the coffee delivery example, where the robot plan is specified by a procedure. Let
E2 = proc(Π. deliv(),while(∃r.CoffeeRequest(r),
[gotoRoom(nextRoom), giveCoffee(robotLoc)]). Then, by the new definition of Trans we get:
Trans({E2; Πdeliv()}, s, δ, s0)≡
Trans([E2 : Πdeliv()], s, δ, s0)≡
Trans({E2; while(∃r.CoffeeRequest(r),
[gotoRoom(nextRoom), giveCoffee(robotLoc)])}, s, δ, s0)≡
Trans(while(∃r.CoffeeRequest(r),
[gotoRoom(nextRoom), giveCoffee(robotLoc)]), s, δ, s0).
Thus, we can deduce that the execution of{E2; Πdeliv} in S0 corresponds to the execution of
the procedure body of Πdeliv. From this and the considerations in Section 3.2.2, we can then
conclude:
Γ|= ∃s.Do({E2; Πdeliv}, S0, s)∧
3.3. A PROBABILISTIC, EPISTEMIC SITUATION CALCULUS 53