Chapter 5

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

What do the passenger on the London underground, the fox, the louse, the Mars explorer and the thermostat have in common? It certainly isn’t the way they dress, the company they keep, or their table manners.

 

It is that they are continually being challenged by the world around them, presenting them both with threats to be avoided and with opportunities to be exploited. They are forced to act, to change the world in return, both to maintain their well-being and to prolong their existence. For this reason, to emphasise this shared need to interact appropriately with the world, they are often called actors or agents.

 

An agent’s interaction with the world can be modeled by an abstraction of the production system cycle:

 

To cycle,

observe,

act,

cycle again.

 

 

An observer, who is external to the agent, might form a connection between the changes she sees taking place in the world and the actions she sees being performed by the agent. She might even describe these connections by sentences of the form:

 

If agent makes observation then agent does action.

 

However, as we have noted before, it doesn’t follow that the agent itself also uses such sentences, either in logical form or in condition-action rule form, to generate its own behaviour.

 

Nor does it follow that the agent’s actions are actually connected with the observations it makes in the same cycle. The actions could be delayed reactions to observations made in earlier cycles. Or they could be actions that the agent generates proactively in pursuit of its own goals, independently of the changes taking place at that time in the world around it.

Conscious and subconscious levels of thought

So how does an agent determine the actions it performs? Does it use logic, as in our characterisation of the fox in the story of the fox and crow? A production system, as in the case of our Mars explorer? A nervous system, as in our wood louse? Or an electrical or mechanical device, as in a thermostat?

 

In fact, from a computer science perspective, it could be any and all of these. The same behaviour can be implemented, at different levels, in different programming languages, and in software or in hardware.  It can be implemented first in a high-level language, such as logic, and then compiled into a lower-level language, such as condition-action rules. The condition-action rules can also be compiled, in turn, into a still lower level language, until the behaviour finally ends up implemented in hardware.

 

Executing a program written in a high level language is like thinking about what you are doing, consciously. After doing the same thing over and over again, you eventually begin to perform the activity more efficiently, without thinking about it, subconsciously. For example, when you first learn a new skill, like typing or driving a car, you need to pay attention, consciously, to virtually every detail. But once you have learned the skill, you practice it, for the most part, subconsciously, without paying attention to what you are doing. This is like compiling a high level program into a lower level one.

 

In computer science, the reverse process is also possible. Low level programs can sometimes be decompiled into equivalent higher level programs. This is useful when you need to debug a program when it goes wrong or when you need to modify the program when the environment changes. It is easier to understand and modify a program if you can decompile first it and view it higher level terms.

 

Decompiling a lower level program also has an analogue in human thinking. It is sometimes possible to analyse subconscious, tacit knowledge and express it in conscious, explicit terms. This is what a linguist does, for example, when she constructs a grammar for a language. The native speaker of the language knows the grammar tacitly and subconsciously. The linguist formulates the grammar explicitly and consciously. Teachers can use the explicit grammar to help teach the language to students. With sufficient practice, the students may eventually compile the grammar into their own subconscious, and speak the language more efficiently as a result.

 

In computer science, it is generally considered desirable to program initially at as high a level as possible, and then to compile high level programs into lower level ones to obtain greater efficiency. Arguably, human thinking is similar. When you are solving a new and unfamiliar problem, it is generally better to think consciously about what you are doing, and to leave it to your subconscious only later when the problem becomes routine.

Logic as the higher-level language of thought

It is for this reason that we focus on logic in this book. When problems are unfamiliar or sufficiently complex, we can not rely on our instincts alone. We need to reduce our problems to simpler, more familiar sub-problems that are easier to solve. We need to consider and evaluate alternative ways of reducing problems to sub-problems. And we need to make sure that when we focus on one sub-problem we don’t loose track of any other sub-problems that also need to be solved.

 

But we also need to be open to changes that are taking place in the world around us, and to react to those changes appropriately and in a timely manner. When time allows, we need to think about and monitor the possible consequences of our proposed actions and reactions. We need to determine whether they might have any unintended and undesirable consequences, as well as whether they might contribute to the achievement of any other goals that are not the current focus of our attention.

 

To do these things, we need to do more than simply combine the goal-reduction approach to problem-solving with the condition-action rule approach to changes in the world. We need to embed both approaches in a more general, more logical framework, in which the same beliefs can be used, both backwards for problem-reduction, and also forwards to monitor both observations and sub-goals for their logical consequences.

 

In this general framework, logic plays the role of the higher-level language of thought. It is the level at which thoughts are explicit and conscious, either after or before they are decompiled from or compiled into lower-level tacit routines of behaviour. It is at this higher level that it can both help us to solve problems more effectively and to deal with the threats and opportunities presented by the world around us.

The cycle of thought

The biggest problem with traditional logic is that it is closed to the world. To serve as the highest level thinking component of an intelligent agent, logic needs to be open to changes in the world. This need can be satisfied by embedding logic in a cycle, which at the top-most level is indistinguishable from the production system cycle:

 

 

To cycle,

 

observe the world,

 

think,

decide what actions to perform,

act,

cycle again.

 

The cycle is general enough to accommodate both higher-level logical thinking and lower-level kinds of thinking at the same time. It is also neutral with respect to different kinds of decision making strategies.

The logic of goals and beliefs

Traditional logic does not pay much attention to the distinction between goals and beliefs. But for an intelligent agent, the distinction is essential.

 

An agent’s goals represent its view of the future, of the world as it would like it to be. They include actions that the agent can perform, to change the world and to make it more like its vision of the future. They also include generalised condition-action rules, to maintain the agent in a harmonious relationship with the world around it.

 

 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 implications, both to define abstract concepts and to

represent hypotheses about the laws of nature.

 

Beliefs can be used to reason backwards, to reduce goals to sub-goals. They can also be used to reason forwards, to derive consequences both from observations and from sub-goals.

Back on the underground

It is better to illustrate these ideas with a concrete example than it is to try to understand them completely in the abstract. Remember our last version of the London underground 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.

 

Instead of writing the first sentence with an imperative conclusion, we can write it as a declarative sentence, but indicate that it expresses a goal rather than a belief:

 

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

 

We can understand this goal as a maintenance goal, one which aims to maintain the agent in a satisfactory relationship with the changing world. When a relevant change takes place, one that the agent observes and interprets as an emergency, then the maintenance goal is triggered and a specific achievement goal is generated.

 

In the general case, a maintenance goal has the form:

 

                        If condition then conclusion.

 

Where the condition describes some state of the world, and the conclusion describes some future state of the world as an achievement goal. Typically the condition part of a maintenance goal can reoccur in different states of the world, giving rise to different occurrences of the achievement goal.

 

The generation of an achievement goal from a maintenance goal can be understood in logical terms as a case of forward reasoning[1]. In the general case, an agent uses forward reasoning both to derive the condition of the maintenance goal, from an observation and other beliefs, and to derive the achievement goal, from the maintenance goal and its condition. The general pattern is this:

 

 

Observation:                                        Something happens.

Consequence of the observation:       Condition holds.

Maintenance goal:                               If condition then conclusion.

Achievement goal:                              Achieve conclusion!

 

To solve the achievement goal, the agent uses backwards reasoning, to reduce it

to action sub-goals. To solve the action sub-goals, it needs to execute them successfully.

 

Thus, in its simplest terms, the use of logic for thinking combines forward reasoning from observations with backward reasoning from goals. Forward reasoning generalises condition–action rules, whereas backward reasoning generalises goal-reduction procedures.

 

Later, we will see other uses of forward reasoning, including its use to monitor sub-goals, for desirable and undesirable consequences.

Reasoning as the need arises

We can reason with goals and beliefs as the need arises, or we can reason with them in advance, as we did in the wood louse designer example. Suppose, in the London underground example, that we reason with the goal and beliefs as they are and that we do so only when we need to.

 

Now suppose that you traveling on the underground and you observe a fire:

 

Observation:                There is a fire.

 

You record the observation in your memory. But, given only the goal and beliefs you have, the observation has no meaning for you. To recognise that there is an emergency, you need an additional belief, such as:

 

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

 

And to play it safe, it would be useful for you to have some other beliefs, to recognise other emergencies on other occasions. For example:

 

Beliefs:                        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.

 

With the new belief, in two steps of forward reasoning, you can derive the achievement goal of getting help[2]. Then in two steps of backward reasoning, you can reduce the achievement goal to the action sub-goal of pressing the alarm signal button.

 

Observation:                                        There is a fire.

Consequence of the observation:        There is an emergency.

Achievement goal:                              You get help!

Achievement sub-goal:                       You alert the driver!

Action:                                                You press the alarm signal button!

Reasoning in advance

Instead of reasoning only when you need to, you can anticipate the need before it arises. In the undergound example, if you perform two steps of backward reasoning in advance, reducing the conclusion of the maintenance goal to an action sub-goal, then you can transform the maintenance goal into a new one, which is a declarative version of a condition-action rule:

 

            If there is an emergency then you press the alarm signal button.

 

The new maintenance goal is more efficient than the original goal and beliefs, but it is not as flexible. In particular, it has lost the connection between pressing the alarm signal button and getting help, which was explicit in the original formulation. If there were an emergency and you pressed the alarm signal button and something went wrong, then you might not realise there was a problem.

 

Also, if technology improves, and there are new and better ways of alerting the driver or of getting help directly without the intervention of the driver, then you will find it harder to adapt to the changes.

 

However, if you insist on reasoning in advance, there is no reason to stop now. You can also perform the various steps of forward reasoning needed to recognise an emergency:

 

            If there is a fire then you press the alarm signal button.

            If one person attacks another then you press the alarm signal button.

            If someone becomes seriously ill then you press the alarm signal button.

            If there is an accident then you press the alarm signal button.

           

Not only is the content of the new goals rather tedious, but they use up a lot more memory. This is an example of the classic computer science space-time trade-off. You can trade memory space for processing time, or vice versa.

The best of both worlds

Fortunately, there is no need to have it all one way or the other. It is possible to have the best of both worlds – to combine reasoning in advance with reasoning when you need to. You can compile higher-level representations into lower-level ones, to execute them more efficiently; and you can decompile them back to their original high-level form, to correct them when they go wrong and to modify them when the environment changes. You can then recompile the corrected or modified goals and beliefs, and start all over again.

 

The advantage of using logic, to move back and forth between levels, is that you don’t need to change languages, but simply to change levels of representation in the same language. Moreover, the same inference rules are used both “at run time”, to process observations when they arise, as well as “at compile time”, to transform higher-level goals and beliefs into more efficient, lower-level form.

Controlling our thoughts

Logical thinking isn’t just about knowing how to apply forward and backward inference rules correctly. It’s also about knowing when to think about what, and when not to think about anything, but to observe or act instead.

 

There are normally so many things happening around us, that we rarely have time to take them all in. We have to juggle our thoughts, so that we keep our priorities straight, both dealing with problems that need our urgent attention, and attending to those whose ultimate payoff is long term.

 

This control we need to have over our thoughts is similar in many respects to the control we need to have over our actions. In both cases we need to decide between alternatives. Sometimes we have to abandon an alternative altogether. Sometimes we can just schedule it for later.

 

In both cases, there are three issues that need to be considered in making a decision:

 

            Urgency.

            How long do we have to pursue a line of thought or a line of action before it is too late?

 

            Utility.

            How useful is the goal to be achieved?

 

            Probability.

            How likely is it that the other conditions necessary for achieving the goal

            will also be achieved?

 

These issues are the concern of Decision Theory, which addresses them in the context of deciding what actions to perform. We will have more to say about them later.

 



[1] Forward reasoning is the classic example of an inference rule. The ancients called it modus ponens.

 

[2] Notice that, although we have written the new beliefs backwards, which is consistent with our earlier convention, we use them forwards here. In general, the declarative nature of beliefs expressed in logical form means that they can be used to reason backwards or forwards, independently of the way they are written.