From OpenCog
Jump to: navigation, search

Predicate Schematization

In this section we treat the process called predicate schematization, by which declarative knowledge about how to carry out actions may be translated into Combo trees embodying specific procedures for carrying out actions. This process is straightforward and automatic in some cases, but in other cases requires significant contextually-savvy inference.

To proceed with predicate schematization, we need the notion of an "executable predicate".

Some predicates are executable in the sense that they correspond to executable schemata, others are not. There are executable atomic predicates (represented by individual PredicateNodes), and executable compound predicates (which are link structures). In general, a predicate may be turned into a schema if it is an atomic executable predicate, or if it is a compound link structure that consists entirely of executable atomic predicates (e.g. pick_up, walk_to, can_do, etc.) and temporal links (e.g. ANDSimultaneous, PredictiveImplication, etc.)

Records of predicate execution may then be made using ExecutionLinks, e.g.

ExecutionLink pick_up ( me, ball_7)

is a record of the fact that the schema corresponding to the pick_up predicate was executed on the arguments (me, ball_7).

It is also useful to introduce some special (executable) predicates related to schema execution:

  • can_do, which represents the system's perceived ability to do something
  • do, which denotes the system actually doing something; this is used to mark actions as opposed to perceptions
  • just_done, which is true of a schema if the schema has very recently been executed.

The general procedure used in figuring out what predicates to schematize, in order to create a procedure achieving a certain goal, is: Start from the goal and work backwards, following PredictiveImplications and EventualPredictiveImplications and treating can_do's as transparent, stopping when you find something that can currently be done, or else when the process dwindles due to lack of links or lack of sufficiently certain links.

In this process, an ordered list of perceptions and actions will be created. The Atoms in this perception/action-series (PA-series) are linked together via temporal-logical links.

The subtlety of this process, in general, will occur because there may be many different paths to follow. One has the familiar combinatorial explosion of backward-chaining inference, and it may be hard to find the best PA-series among all the mess. Experience-guided pruning is needed here just as with backward-chaining inference.

Specific rules for translating temporal links into executable schemata, used in this process, are as follows. All these rule-statements assume that B is in the selected PA-series. All node variables not preceded by do or can_do are assumed to be perceptions. The ==> symbol denotes the transformation from predicates to executable schemata.

EventualPredictiveImplicationLink (do A) B


Repeat (do A) Until B

EventualPredictiveImplicationLink (do A) (can_do B)

    do A
    do B
    Evaluation just_done B

// the understanding being that the agent may try to do B and fail,
// and then try again the next time around the loop

PredictiveImplicationLink (do A) (can_do B) <time-lag T>


do A
wait T
do B

SimultaneousImplicationLink A (can_do B)


if A then do B

SimultaneousImplicationLink (do A) (can_do B)


do A
do B

PredictiveImplicationLink A (can_do B)


if A then do B

SequentialAndLink A1 … An



SequentialAndLink A1 … An <time_lag T>


Wait T
Wait T
Wait T
SimultaneousAndLink A1 … An



Note how all instances of can_do are stripped out upon conversion from predicate to schema, and replaced with instances of do.

A Concrete Example

For a specific example of this process, consider the knowledge that: "If I walk to the teacher while whistling, and then give the teacher the ball, I'll get rewarded."

This might be represented by the predicates

// walk to the teacher while whistling

A_1 :=
    do Walk_to
        ExOutLink locate teacher
    EvaluationLink do whistle

// If I walk to the teacher while whistling, eventually I will be next to the teacher

    Evaluation next_to teacher

// While next to the teacher, I can give the teacher the ball

    EvaluationLink next_to teacher
        EvaluationLink give (teacher, ball)

// If I give the teacher the ball, I will get rewarded

        EvaluationLink done give (teacher, ball)
    Evaluation reward

Via goal-driven predicate schematization, these predicates would become the schemata

// walk toward the teacher while whistling

    do WalkTo
        ExOut locate teacher
    do Whistle
    Evaluation give(teacher, ball)          

// if next to the teacher, give the teacher the ball

    Evaluation next_to teacher
    do give(teacher, ball)

Carrying out these two schemata will lead to the desired behavior of walking toward the teacher while whistling, and then giving the teacher the ball when next to the teacher.

Note that, in this example:

  • The walk_to, whistle, locate and give used in the example schemata are procedures corresponding to the executable predicates walk_to, whistle, locate and give used in the example predicates
  • Next_to is evaluated rather than executed because (unlike the other atomic predicates in the overall predicate being made executable) it has no "do" or "can_do" next to it

(This process was implemented in the Novamente Cognition Engine in 2005, by Ari Heljakka, with details slightly different than those described here, but the essence of the process is the same. This work was reported in a couple papers focused on making NCE play Fetch, one of which is in the proceedings of the 2006 AGI workshop).