Chapter 4

A Logical Framework for Combining Goal-reduction, Condition-action Rules and More

What do the passenger on the London underground, the fox, the wood louse, the Mars explorer and even the heating thermostat have in common? It certainly isn’t the way they dress, the company they keep, or their table manners. It’s that they are all engaged in a constant struggle with the changing world - a struggle that sometimes threatens their existence, and that other times provides them with opportunities to thrive and prosper.

 

For logic to be relevant in such a world, it needs first to overcome one main problem – that traditional logic, as normally understood, is closed to changes in the world. To be relevant, it needs to be put in its proper place, in the thinking component of the agent cycle:

 

To cycle,

 

observe the world,

                                                                                                                         

think,

                       

decide what actions to perform,

                                                                                                                         

act,

                                                                                                                         

cycle again.

 

At this top-most level, the agent cycle is the same as the production system cycle, but it is general enough to accommodate other kinds of thinking, including logical reasoning. Embedded as the thinking component in the agent cycle, logic is open both to inputs that the agent receives from the world and to outputs that the agent uses to change the world in return.

The logic of goals and beliefs

Another shortcoming of traditional logic is that it does not pay adequate attention to the distinction between an agent’s goals and its beliefs. But for an intelligent agent, the distinction is fundamental to its survival.

 

An agent’s goals represent its view of the world as it would like it to be. They include actions that the agent can perform. They also include achievement goals, to attain some desired future state, maintenance goals, to maintain the agent in some desired relationship with the changing state of the world, and constraints, to prevent undesirable states. I will argue that condition-action rules can be understood as maintenance goals, and that goals in general can be expressed naturally in logical form.

 

 An agent’s beliefs, on the other hand, represent its view of the world as it really is, whether it likes it or not. They include atomic sentences that record the agent’s observations. They also include its beliefs about the laws of nature, as well as definitions and taxonomies that the agent uses to classify and organise its experience. I will argue that many, perhaps all beliefs can be expressed naturally in logic programming form.

The story of the fox and crow revisited

The story in Chapter 2 begins when the fox has the goal of having the crow’s cheese. But where did the fox’s goal come from?

 

Perhaps, like a spoiled child, the fox wants to have anything she sees anyone else have. Or perhaps she’s simply looking for her next meal. In either case, the fox’s goal of having the cheese comes from a higher-level goal – either the goal of possessing anything she sees anyone else have, or the goal of having food to eat whenever she becomes hungry.

 

Thus, the fox’s goal of having the cheese can be viewed as a goal of achieving some future state of the world, in response to observing a change in the world that triggers a higher-level goal of maintaining some relationship to the world around her.

 

Let’s give the fox the benefit of the doubt and assume that she wants to have the cheese simply because she is hungry, and not because she has a personality defect. This can be represented, by the higher-level goal:

 

            If I become hungry, then I need to have food and eat the food.

 

This goal can be paraphrased in many different ways. For example, in the imperative:

 

            If I become hungry, then have food and eat the food.

 

This imperative formulation resembles a condition-action rule, except the conclusion contains a goal “have food” instead of a simple action.

 

Alternatively, the goal can be stated in the declarative mood, but with an indication that the statement is a goal, rather than a belief:

 

Goal:   If I become hungry, then I have food and I eat the food.

 

The advantage of expressing the goal as a declarative statement, is that then it has a logical form.  The logical form can be tested for truth or falsity, and it can take part in logical deductions, using forward, backward and other kinds of logical reasoning. The fact that it is a goal rather than a belief means that the agent needs to make it become true.

 

To show that an implication:

 

            If conditions then conclusion.

 

is true, it is necessary to show that whenever the conditions are true, then the conclusion is true. Whether it is a goal or a belief is irrelevant.

 

However, to make an implication become true, because it is a goal, not only is it necessary to make the conclusion come true when the conditions become true, but it is sufficient to do so. In theory, it would be possible to make the implication true by making both the conditions and the conclusion true. However, making the conditions true creates unnecessary work. In practice, therefore, to minimise its work, an agent does not attempt to make conditions of implicational goals become true unnecessarily. Either the world makes them true, whether it likes it or not, or the agent makes them true for some other purpose[1].

 

In an open world, which is always changing, it may not be possible to make an implication true once and for all. It may be necessary, instead, to maintain its truth indefinitely, dealing with individual instances of the conditions as they arise, on separate occasions. On each such occasion, it is necessary to make that instance of the implication true. The entire process consists of the following three steps:

 

  • forward reasoning, matching new observations with some conditions of the implication, generating an instance of the implication,
  • forward and/or backward reasoning, verifying any remaining conditions of this instance of the implication,
  • deriving the new goal of making the conclusion true.

 

The new goal is a sub-goal of the higher-level maintenance goal. Typically it is an achievement goal, to attain some future state of affairs

 

Let’s see how this derivation of an achievement goal from a maintenance goal works in this version of the story of the fox and the crow:

 

Goal:               If I become hungry, then I have food and I eat it.

 

Beliefs:           The crow has the cheese.

 

                                                                       

An animal has an object

if the animal is near the object

and the animal picks up the object.

 

                                                                       

I am I am near the cheese

 if the crow has the cheese

 and the crow sings.

 

                                                                         

The crow sings if I praise the crow.

 

                        Cheese is a kind of food,

                        Food is a kind of object.

 

To make the story work, the fox needs to have the taxonomic knowledge that cheese is a kind of food and that food is a kind of object. This knowledge can be represented in a number of different ways, and there are even specialised logics for this purpose. However, for the simple purpose of retelling the story, these details are unimportant. It suffices to recognise that this knowledge is needed simply to assist with the reasoning, as we will see below.

 

To see how the derivation of an achievement goal from a maintenance goal works in this example, suppose the fox has the goal and beliefs presented above and suddenly her body tells her that she has just become hungry:

 

Observe:         I become hungry.

 

Since her body is a part of the world, she becomes aware of her hunger by means of an observation. The observation triggers the top-level goal, and forward reasoning derives the sub-goals:

 

Sub-goals:      I have food and I eat the food.

 

Thus, the real achievement goal is not specifically to have the crow’s cheese, but more generally to have any kind of food. And this achievement goal is only half the story. The other half is that the fox also needs to eat the food. Having the food without eating it is useless.

 

The derivation of achievement sub-goals from a higher-level maintenance goal generalises the derivation of actions from a condition-action rule, because the sub-goals can include atomic actions. However, in the general case, they might themselves be goals that need to be reduced to lower-level sub-goals. It generalises condition-action rules also because the derived achievement sub-goals might need to be achieved at a future time and not simply at the next moment in time.

The time factor

Our new version of the story of the fox and crow is still an oversimplification, mainly because it ignores the issue of time. It does not distinguish between different occurrences of becoming hungry at different times. Nor does it indicate how much time can elapse between becoming hungry and eating. For that matter, it does not even indicate that the fox needs to have the food before she can eat it.

 

This oversight has been deliberate, because common-sense reasoning about time is much more complicated than it seems. We will come back to this problem later. In the meanwhile we will continue to use our simplified representation of the story without time, both to simplify the example and to focus on how the fox interleaves its reasoning with its observations and actions in the context of the agent cycle.

Embedding the story in the agent cycle

Let’s retell the story, starting this time at the point where the fox becomes hungry. To make the story more interesting, we assume that the fox has only enough time to perform one step of reasoning in a single cycle. We also assume that the fox observes whether her actions succeed or fail.

 

The first cycle.

Observation:                                                 I become hungry.

Forward reasoning, sub-goals:                    I have food and I eat the food.

No candidate action.

This is the classic case of an observation triggering a maintenance goal and deriving an achievement goal.

 

The second cycle.

No observation.        

Backward reasoning, new sub-goals:  I am near food and I pick up the food                                                                                  and I eat the food.

No candidate action.

The only thinking that the fox can do in this cycle is to reason backwards, to reduce the sub-goal of having food to the sub-goal of being near the food and picking it up.  This reasoning involves the taxonomic reasoning of matching “food” with “object”.

 

The third cycle.

Observation:                                                 The crow has cheese.

Forward reasoning, nIew belief:                   I am near the cheese if the crow sings.

No candidate action.

In this cycle, the fox has a choice of continuing to reason backwards from its current sub-goals or of reasoning forwards from its new observation. Normally, it is a good idea to give priority to reasoning with new observations, just in case there is an emergency that needs to be dealt with immediately or an opportunity that can’t be missed.

 

The observation matches one of the conditions of her belief:

 

I am                        I am near the cheese if the crow has the cheese and the crow sings.

 

Because the belief is expressed in logical form, it can be used to reason both forward and backward. Using it to reason forward, as in this case, it gives rise to a new belief.

 

The fourth cycle.

No observation.

Backward reasoning, new sub-goals:  the crow sings and I pick up the cheese                                                                                           and I eat the cheese.

No candidate action.

The fox uses the new belief backwards, to reduce the goal of being near food to the sub-goal of making the crow sing. To do so, she matches “food” with “the cheese”. This has a side effect of finding out what the food is going to be if the new sub-goal succeeds.

 

The fifth cycle.

No observation.  

Backward reasoning, new sub-goals:  I praise the crow and I pick up the cheese                                                                                     and I eat the cheese.

Action:                                                           I praise the crow.

The fox reduces the goal of making the crow sing to the sub-goal of praising the crow. She attempts to solve this new sub-goal by successfully performing it as an action. There are no other actions she can perform at this time, so there is no conflict resolution to perform.

 

The sixth cycle.

Observe:                                                         I praise the crow.

Forward reasoning, new sub-goals:             I pick up the cheese and I eat the cheese.

Action:                                                           I pick up the cheese.

The fox observes the result of the action she performed in the previous cycle. The observation, which confirms the success of her action, solves the first of the three action sub-goals, leaving the remaining two sub-goals. The next of these two sub-goals is also an action, and there are no other candidate actions that she can perform at this time.

 

 The seventh cycle.

Observe:                                                         I do not pick up the cheese.

No thinking.

Action:                                                           I pick up the cheese.

The fox observes the result of her action. However, this time, we assume that it fails, either because the crow has not yet started singing, because the cheese has not yet reached the ground, or because she is physically inept[2]. We assume that the fox can try the same action again[3].

 

The eighth cycle.

Observe:                                                         I pick up the cheese.

Forward reasoning, new sub-goals:            I eat the cheese.

Action:                                                           I eat the cheese.

The fox observes that this time the action was successful. The observation solves the associated action sub-goal, leaving only the last action sub-goal, which the fox decides to perform in this cycle:

 

The ninth cycle.

Observe:                     I eat the cheese.

The observation solves the last of the action sub-goals. However, the maintenance goal still remains, to be triggered on other, future occasions.

 

The general pattern of reasoning in this example, spread out over several cycles and possibly interleaved with other observations and actions, is something like this:

 

Observation:                                      An event happens.

Forward reasoning:                          The event matches the condition of a                                                                                                 maintenance goal or of a belief.

Achievement goal:                             Eventually the conclusion of some maintenance                                                                             goal is derived as an achievement goal.

Backward reasoning:                        Beliefs are used to reduce the achievement goal                                                                                    to actions.

Actions:                                              Action sub-goals are selected for execution.

Observation:                                      The agent observes whether the actions succeed                                                                            or fail.

 

 

This pattern is not exceptional. A similar pattern arises in the London underground example.

The underground revisited

Remember our last version of the example:

 

                        If there is an emergency then get help.

            You get help if you alert the driver.

            You alert the driver if you press the alarm signal button.

 

The first sentence expresses a maintenance goal. We can rewrite it as a declarative sentence, indicating that it is a goal rather than a belief. To better capture the intended meanings of the second and third sentences, we replace the second person “you” by the third person:

 

Goal:               If there is an emergency then I get help.

 

Beliefs:           A person gets help if the person alerts the driver.

            A person alerts the driver if the person presses the alarm signal button.

 

 

To recognise when there is an emergency, we need additional beliefs. For example:

 

Beliefs:                       There is an emergency if there is a fire.

                                    There is an emergency if one person attacks another.

                                    There is an emergency if someone becomes seriously ill.

                                    There is an emergency if there is an accident.

 

We could continue this reduction of abstract, higher-level concepts to more concrete, lower-level ones, down to any level of detail. For example, in the case of recognising fire, we might add:

 

Additional beliefs:     There is a fire if there are flames.

                                    There is a fire if there is smoke.

 

However, we would soon find it increasingly difficult to define the lower-level concepts in linguistic terms. Eventually, there must come a point at which there is a lowest level, which is irreducible and which is the level at which the agent’s sensory system transforms the sensations it receives from the environment into observations that can be represented in conceptual terms.

 

Suppose in this example that the concept of recognising there is smoke is such a lowest level of concept directly observed in the environment. Suppose, moreover, that you are traveling on the underground and you observe smoke:

 

Observation:                                                  There is smoke.

Forward reasoning, new belief:                   There is a fire.

Forward reasoning, new belief:                   There is an emergency.

Forward reasoning, achievement goal:    I get help!

Backward reasoning, sub-goal:                   I alert the driver!

Backward reasoning, action:                       I press the alarm signal button!

 

In three steps of forward reasoning, you derive the achievement goal of getting help. In the first step you recognise that there is a fire, in the second you recognise that there is an emergency, and in the third you use the maintenance goal to derive the achievement goal of getting help. Then in two steps of backward reasoning, you reduce the goal of getting help to the action sub-goal of pressing the alarm signal button.

 

The action of pressing the alarm signal button, like the observation of an emergency, can be reduced to lower-level terms - for example, by first moving your finger to the button and then pushing the button with your finger. Moving your finger to the button can also be reduced, in turn, to still lower-level sub-goals, like first moving your arm to the vicinity of the button and then moving your finger to the button. But eventually, there has to be a point where your body takes over from your mind and performs the actions directly on its own.

 

All of this thinking takes time, during which you may have to record other observations and perform other actions. Scheduling these so that everything is dealt with in a timely manner is a task for the decision making component of the agent cycle. We have kept the examples in this chapter deliberately simple, so that no such decisions need to be made. However, we will address some of the issues involved in making decisions in the next chapter.

Summary

The examples in this chapter illustrate how logic can be used in the context of an agent’s observation-thought-decision-action cycle. Placed in this context, logic is used for the higher levels of thought - both to reason forwards from observations, triggering maintenance goals and deriving achievement goals, and to reason backwards to reduce achievement goals to actions.

 

Below the logical level, perceptual processes transform raw sensation into observations and motor processes transform conceptual representations of actions into raw physical activity.

 

This can be pictured in the following form:


 

Highest level maintenance goals                                             Achievement goals

                                                         Forward reasoning

 

                        Forward reasoning                                                   Backward reasoning

 

 

Intermediate level consequences                                            Intermediate level sub-goals

 


                                                                                                           

                        Forward reasoning                                                   Backward reasoning

 

 

Observations                                                                           Actions

 


                        Perceptual processing                                          Motor processing

 

 

 

                                   

                                                            The world

 

 

 

We have seen that forward reasoning with implicational goals generalises condition–action rules, whereas backward reasoning with implicational beliefs generalises goal-reduction procedures. In the next chapter, we will see how backward reasoning can be used to search for solutions and how forward reasoning can be used to infer consequences of solutions. We will also see how this combination of search plus inference helps to inform the next, decision-making stage in the cycle, so that different candidate solutions can be compared, and so that better informed decisions can be made.

 

 

 



[1] It is also possible to make an implication become true by making its conditions become false. In the case of the fox, she could also satisfy her goal by trying to prevent herself from becoming hungry.

[2] This complication draws attention to a shortcoming of our formulation of the agent cycle: There is no explicit check in the cycle to determine whether or not lower-level actions actually achieve their higher-level goals. The cycle checks whether or not atomic actions succeed, but it does not check whether their success leads to the success of the higher-level goals they were meant to achieve. If the beliefs that were used to reduce these goals to sub-goals were guaranteed to be true, then such checks would be unnecessary. Thus, one way to rectify the shortcoming is to add to the cycle a general learning, truth-testing component. We need to come back to this later.

[3] This assumes that there is an associated time by which the action needs to be performed and that that time is not yet used up. We will see how this works in greater detail later, when we look more closely at the representation of time.