SequentialAndLink

From OpenCog
(Redirected from SequentialAnd)

The SequentialAndLink and SequentialOrLink are a type of Link which are used to group a set of Atoms in a sequential manner, such as in the case of action execution (aka "behavior trees") in embodiment (i.e. robot control).

Evaluation of a SequentialAndLink wrapped inside a SatisfactionLink will proceed in sequential order, one by one, until the first clause that evaluates to false. In this case, the SatisfactionLink returns false as well; if all clauses succeed, the SatisfactionLink returns true.

Evaluation of a SequentialOrLink proceeds similarly, except that termination halts with the first successful evaluation. Thus, SequentialOr is a kind of fallback device. It is logically equivalent to (NotLink (SequentialAndLink (NotLink ...))).

The behavior tree page shows an example of using a SequentialAndLink to trigger a series of actions; the actions are run in order; the next action is not performed unless the previous action returned TRUE_TV. Multiple examples can be found in the /examples directory. A large application can be found in the ROS behavior tree code. ROS is the well-known "Robot Operating System"; this application demonstrates how Atomese can be integrated with ROS sensory/perception systems as well as action (motor-control) systems.

PLN Semantics

In PLN a SequentialAndLink is used in temporal reasoning. The PLN book definition (Chapter 14) is somewhat erroneous and thus another definition is provided here.

Let's assume two temporal predicates A and B. By temporal predicate is meant that one of its arguments lives in the temporal domain. An example of such temporal predicate could be

tall(p, t)

telling if person p is tall, perhaps to some degree, at time t.

Let's assume a temporal predicate transformer, called Lagged for lack of a better name yet, that takes a temporal predicate and shifts the temporal axis by some offset. Formally, Lagged is defined as follows

Lagged(A, T)
:=
Lambda
 p, t
 A(p, t-T)

Thus

Lagged(A, T)(p, t) = A(p, t-T)

meaning Lagged(A, T) is the past of A, T units of time ago. We have introduced a LaggedLink corresponding to that predicate transformer.

Given that we can define SequentialAndLink with two variations

1. A lookback variant

BackSequentialAndLink
  T
  A
  B
:=
AndLink
  LaggedLink
    A
    T
  B

2. A lookahead variant

ForeSequentialAndLink
  T
  A
  B
:=
AndLink
  A
  LaggedLink
    B
    -T

It's not clear to me which variant, lookback or lookahead, should be the default so I'm letting that decision open for now. The advantage of a lookback definition is that for a particular instantiation of SequentialAnd, that is for some p and t, then if t is the current time, we likely have in the atomspace the data to calculate if it is true. For the lookahead variant if t is the current time, then we need to wait for T units of time before such calculation becomes possible. Of course if t is some t'+T where t' is the current time then we don't need to wait. So it's really just a matter of convention, but still one might turn out to better than the other. I suggest to select that default after more conceptual and practical development about temporal reasoning has taken place. For future references we'll call the lookback variant BackSequentialAndLink, and the lookahead variant ForeSequentialAndLink.

Note that, unlike in the PLN book, no use of Initiation or Termination is made in that definition. That is because I believe it is better to use these explicitly rather than implicitly. For instance if one wants to express that A starts before B ends, one can write

SequentialAnd
  T
  Initiation(A)
  Termination(B)

This is more flexible, and if frequent combinations emerge, shorthands can always be defined on top of it.

Temporizing Predicates

If the predicates involved are not explicitly temporal, i.e. do not have a temporal dimension in their input arguments, but have a temporal record, using for instance AtTimeLink, and do indeed change over time, we can temporize them as follows. For instance if A is a predicate with only argument p, we can defined a temporized version

TA
:=
Lambda
  p, t
  AtTime
    A(p)
    t

where TA can then be used instead of A as arguments of temporal constructs such as SequentialAndLink. We might want to introduce some conventions to avoid having to define TA explicitly but for now I think it is better to not make any commitment and wait till more development has taken place.

Notations

For more concise notation, we can use ≺ as an infix operator for SequentialAnd (lookback or lookahead variants). For instance

SequentialAndLink
  T
  A
  B

can be denoted

A≺TB

≺ has been selected as symbol because it is

\prec

in LaTeX, which probably means precede.

Obsolete Definitions

For an old and erroneous definition, you may (likely not) want to see Temporal_Reasoning#SequentialAnd for more info.

See also