# 5.11 Exercises

Some of these exercises can use AILog, a simple logical reasoning system that implements all of the reasoning discussed in this chapter. It is available from the book website (http://artint.info). Many of these can also be done in Prolog.

1. 1.

Suppose we want to be able to reason about an electric kettle plugged into one of the power outlets for the electrical domain of Figure 5.2. Suppose a kettle must be plugged into a working power outlet, it must be turned on, and it must be filled with water, in order to heat.

Write axioms in terms of definite clauses that let the system determine whether kettles are heating. AILog code for the electrical environment is available from the book website.

You must

• give the intended interpretation of all symbols used

• write the clauses so they can be loaded into AILog

• show that the resulting knowledge base runs in AILog.

2. 2.

Consider the domain of house plumbing shown in Figure 5.13.

In this diagram, $p_{1}$, $p_{2}$, and $p_{3}$ are cold water pipes; $t_{1}$, $t_{2}$, and $t_{3}$ are taps; $d_{1}$, $d_{2}$, and $d_{3}$ are drainage pipes.

Suppose you have the following atoms

• $\mbox{pressurized\_p}_{i}$ is true if pipe $p_{i}$ has mains pressure in it

• $\mbox{on\_t}_{i}$ is true if tap $t_{i}$ is on

• $\mbox{off\_t}_{i}$ is true if tap $t_{i}$ is off

• wet_b is true if $b$ is wet ($b$ is either the sink, bath or floor)

• $\mbox{flow\_p}_{i}$ is true if water is flowing through $p_{i}$

• plugged_sink is true if the sink has the plug in

• plugged_bath is true if the bath has the plug in

• unplugged_sink is true if the sink does not have the plug in

• unplugged_bath is true if the bath does not have the plug in.

A definite-clause axiomatization for how water can flow down drain $d_{1}$ if taps $t_{1}$ and $t_{2}$ are on and the bath is unplugged is

 $\displaystyle{\mbox{pressurized\_p}_{1}.}$ $\displaystyle{\mbox{pressurized\_p}_{2}\leftarrow\mbox{}\mbox{on\_t}_{1}\wedge% \mbox{}\mbox{pressurized\_p}_{1}.}$ $\displaystyle{\mbox{flow\_shower}\leftarrow\mbox{}\mbox{on\_t}_{2}\wedge\mbox{% }\mbox{pressurized\_p}_{2}.}$ $\displaystyle{\mbox{wet\_bath}\leftarrow\mbox{}\mbox{flow\_shower}.}$ $\displaystyle{\mbox{flow\_d}_{2}\leftarrow\mbox{}\mbox{wet\_bath}\wedge\mbox{}% \mbox{unplugged\_bath}.}$ $\displaystyle{\mbox{flow\_d}_{1}\leftarrow\mbox{}\mbox{flow\_d}_{2}.}$ $\displaystyle{\mbox{on\_t}_{1}.}$ $\displaystyle{\mbox{on\_t}_{2}.}$ $\displaystyle{\mbox{unplugged\_bath}.}$
1. (a)

Finish the axiomatization for the sink in the same manner as the axiomatization for the bath. Test it in AILog.

2. (b)

What information would you expect the a resident of a house to be able to provide that the plumber who installed the system, who is not at the house, cannot? Change the axiomatization so that questions about this information are asked of the user.

3. (c)

Axiomatize how the floor is wet if the sink overflows or the bath overflows. They overflow if the plug is in and water is flowing in. You may invent new atomic propositions as long as you give their intended interpretation. (Assume that the taps and plugs have been in the same positions for one hour; you do not have to axiomatize the dynamics of turning on the taps and inserting and removing plugs.) Test it in AILog.

4. (d)

Suppose a hot water system is installed to the left of tap $t_{1}$. This has another tap in the pipe leading into it and supplies hot water to the shower and the sink (there are separate hot and cold water taps for each). Add this to your axiomatization. Give the denotation for all propositions you invent. Test it in AILog.

3. 3.

Consider the following knowledge base:

 $\displaystyle{a\leftarrow\mbox{}b\wedge\mbox{}c.}$ $\displaystyle{a\leftarrow\mbox{}e\wedge\mbox{}f.}$ $\displaystyle{b\leftarrow\mbox{}d.}$ $\displaystyle{b\leftarrow\mbox{}f\wedge\mbox{}h.}$ $\displaystyle{c\leftarrow\mbox{}e.}$ $\displaystyle{d\leftarrow\mbox{}h.}$ $\displaystyle{e.}$ $\displaystyle{f\leftarrow\mbox{}g.}$ $\displaystyle{g\leftarrow\mbox{}c.}$
1. (a)

Give a model of the knowledge base.

2. (b)

Give an interpretation that is not a model of the knowledge base.

3. (c)

Give two atoms that are logical consequences of the knowledge base.

4. (d)

Give two atoms that are not logical consequences of the knowledge base.

4. 4.

Consider the knowledge base $KB$:

 $\displaystyle{a\leftarrow b\wedge c.}$ $\displaystyle{b\leftarrow d.}$ $\displaystyle{b\leftarrow e.}$ $\displaystyle{c.}$ $\displaystyle{d\leftarrow h.}$ $\displaystyle{e.}$ $\displaystyle{f\leftarrow g\wedge b.}$ $\displaystyle{g\leftarrow c\wedge k.}$ $\displaystyle{j\leftarrow a\wedge b.}$
1. (a)

Show how the bottom-up proof procedure works for this example. Give all logical consequences of $KB$.

2. (b)

$f$ is not a logical consequence of $KB$. Give a model of $KB$ in which $f$ is false.

3. (c)

$a$ is a logical consequence of $KB$. Give a top-down derivation for the query $\mbox{{ask}~{}}~{}a$.

5. 5.

A bottom-up proof procedure can incorporate an ask-the-user mechanism by asking the user about every askable atom. How can a bottom-up proof procedure still guarantee proof of all (non-askable) atoms that are a logical consequence of a definite-clause knowledge base without asking the user about every askable atom?

6. 6.

This question explores how having an explicit semantics can be used to debug programs. The file elect_bug2.ail in the AILog distribution on the book website is an axiomatization of the electrical wiring domain of Figure 5.2, but it contains a buggy clause (one that is false in the intended interpretation shown in the figure). The aim of this exercise is to use AILog to find the buggy clause, given the denotation of the symbols given in Example 5.7. To find the buggy rule, you do not even need to look at the knowledge base! (You can look at the knowledge base to find the buggy clause if you like, but that will not help you in this exercise.) All you must know is the meaning of the symbols in the program and what is true in the intended interpretation.

The query $lit\_l_{1}$ can be proved, but it is false in the intended interpretation. Use the $how$ questions of AILog to find a clause whose head is false in the intended interpretation and whose body is true. This is a buggy rule.

7. 7.

Consider the following knowledge base and assumables aimed to explain why people are acting suspiciously:

 $\displaystyle{\mbox{goto\_forest}\leftarrow\mbox{}\mbox{walking}.}$ $\displaystyle{\mbox{get\_gun}\leftarrow\mbox{}\mbox{hunting}.}$ $\displaystyle{\mbox{goto\_forest}\leftarrow\mbox{}\mbox{hunting}.}$ $\displaystyle{\mbox{get\_gun}\leftarrow\mbox{}\mbox{robbing}.}$ $\displaystyle{\mbox{goto\_bank}\leftarrow\mbox{}\mbox{robbing}.}$ $\displaystyle{\mbox{goto\_bank}\leftarrow\mbox{}\mbox{banking}.}$ $\displaystyle{\mbox{fill\_withdrawal\_form}\leftarrow\mbox{}\mbox{banking}.}$ $\displaystyle{\mbox{false}\leftarrow\mbox{}\mbox{banking}\wedge\mbox{}\mbox{% robbing}.}$ $\displaystyle{\mbox{false}\leftarrow\mbox{}\mbox{wearing\_good\_shoes}\wedge% \mbox{}\mbox{goto\_forest}.}$ $\displaystyle{\mbox{{assumable}}~{}\mbox{walking},\mbox{hunting},\mbox{robbing% },\mbox{banking}.}$
1. (a)

Suppose get_gun is observed. What are all of the minimal explanations for this observation?

2. (b)

Suppose $\mbox{get\_gun}\wedge\mbox{goto\_bank}$ is observed. What are all of the minimal explanations for this observation?

3. (c)

Is there something that could be observed to remove one of these as a minimal explanation? What must be added to be able to explain this?

4. (d)

What are the minimal explanations of goto_bank?

5. (e)

What are the minimal explanations of $\mbox{goto\_bank}\wedge\mbox{}\mbox{get\_gun}\wedge\mbox{}\mbox{fill\_% withdrawal\_form}$?

8. 8.

Suppose there are four possible diseases a particular patient may have: $p$, $q$, $r$, and $s$. $p$ causes spots. $q$ causes spots. Fever could be caused by one (or more) of $q$, $r$, or $s$. The patient has spots and fever. Suppose you have decided to use abduction to diagnose this patient based on the symptoms.

1. (a)

Show how to represent this knowledge using Horn clauses and assumables.

2. (b)

Show how to diagnose this patient using abduction. Show clearly the query and the resulting answer(s).

3. (c)

Suppose also that $p$ and $s$ cannot occur together. Show how that changes your knowledge base from part (a). Show how to diagnose the patient using abduction with the new knowledge base. Show clearly the query and the resulting answer(s).

9. 9.

Consider the following clauses and integrity constraints:

 $\displaystyle{\mbox{false}\leftarrow a\wedge\mbox{}b.}$ $\displaystyle{\mbox{false}\leftarrow c.}$ $\displaystyle{a\leftarrow d.}$ $\displaystyle{a\leftarrow e.}$ $\displaystyle{b\leftarrow d.}$ $\displaystyle{b\leftarrow g.}$ $\displaystyle{b\leftarrow h.}$ $\displaystyle{c\leftarrow h.}$

Suppose the assumables are $\{d,e,f,g,h,i\}$. What are the minimal conflicts?

10. 10.

Deep Space One (http://nmp.jpl.nasa.gov/ds1/) was a spacecraft launched by NASA in October 1998 that used AI technology for its diagnosis and control. For more details, see Muscettola et al. [1998] or http://ti.arc.nasa.gov/tech/asr/planning-and-scheduling/remote-agent/ (although these references are not necessary to complete this question).

Figure 5.14 depicts a part of the actual DS1 engine design. To achieve thrust in an engine, fuel and oxidizer must be injected. The whole design is highly redundant to ensure its operation even in the presence of multiple failures (mainly stuck or inoperative valves). Note that whether the valves are black or white, and whether or not they have a bar are irrelevant for this question.

Each valve can be ok (or not) and can be open (or not). The aim of this question is to axiomatize the domain so that we can do two tasks.

1. (a)

Given an observation of the lack of thrust in an engine and given which valves are open, using consistency-based diagnosis, determine what could be wrong.

2. (b)

Given the goal of having thrust and given the knowledge that some valves are ok, determine which valves should be opened.

For each of these tasks, you must think about what the clauses are in the knowledge base and what is assumable.

The atoms should be of the following forms

• open_V is true if valve $V$ is open. This the atoms should be $\mbox{open\_v}_{1}$, $\mbox{open\_v}_{2}$, and so on.

• ok_V is true if valve $V$ is working properly.

• pressurized_V is true if the output of valve $V$ is pressurized with gas. You should assume that $\mbox{pressurized\_t}_{1}$ and $\mbox{pressurized\_t}_{2}$ are true.

• thrust_E is true if engine $E$ has thrust.

• thrust is true if no thrust exists in either engine.

• nothrust is true if there is no thrust.

To make this manageable, only write rules for the input into engine $e_{1}$. Test your code using AILog on a number of examples.

11. 11.

Consider using abductive diagnosis on the problem in the previous question, with the following elaborations.

• Valves can be open or closed. Some of valves may be specified as open or closed.

• A valve can be ok, in which case the gas will flow if the valve is open and not if it is closed; broken, in which case gas never flows; stuck, in which case gas flows independently of whether the valve is open or closed; or leaking, in which case gas flowing into the valve leaks out instead of flowing through.

• There are three gas sensors that can detect gas leaking (but not which gas); the first gas sensor detects gas from the rightmost valves ($v_{1},\dots,v_{4}$), the second gas sensor detects gas from the center valves ($v_{5},\dots,v_{12}$), and the third gas sensor detects gas from the leftmost valves ($v_{13},\dots,v_{16}$).

1. (a)

Axiomatize the domain so the system can explain thrust or no thrust in engine $e_{1}$ and the presence of gas in one of the sensors. For example, it should be able to explain why $e_{1}$ is thrusting. It should be able to explain why $e_{1}$ is not thrusting and there is a gas detected by the third sensor.

2. (b)

Test your axiomatization on some non-trivial examples.

3. (c)

Some of the queries have many explanations. Suggest how the number of explanations could be reduced or managed so that the abductive diagnoses are more useful.

12. 12.

AILog has askables, which are atoms that are asked of the user, and assumables, which are collected in an answer.

Imagine you are axiomatizing the plumbing in your home and you have an axiomatization similar to that of Exercise 2. You are axiomatizing the domain for a new tenant who is going to sublet your home and may want to determine what may be going wrong with the plumbing (before calling you or the plumber).

There are some atoms that you will know the rules for, some that the tenant will know, and some that neither will know. Divide the atomic propositions into these three categories, and suggest which should be made askable and which should be assumable. Show what the resulting interaction will look like under your division.

13. 13.

This question explores how integrity constraints and consistency-based diagnosis can be used in a purchasing agent that interacts with various information sources on the web. The purchasing agent will ask a number of the information sources for facts. However, information sources are sometimes wrong. It is useful to be able to automatically determine which information sources may be wrong when a user gets conflicting information.

This question uses meaningless symbols such as $a$, $b$, $c,$ $\ldots$, but in a real domain there will be meaning associated with the symbols, such as $a$ meaning “there is skiing in Hawaii” and $z$ meaning “there is no skiing in Hawaii” or $a$ meaning “butterflies do not eat anything” and $z$ meaning “butterflies eat nectar”. We will use meaningless symbols in this question because the computer does not have access to the meanings and must simply treat them as meaningless symbols.

Suppose the following information sources and associated information are provided.

Source $s_{1}$:

Source $s_{1}$ claims the following clauses are true:

 $\displaystyle{a\leftarrow\mbox{}h.}$ $\displaystyle{d\leftarrow\mbox{}c.}$
Source $s_{2}$:

Source $s_{2}$ claims the following clauses are true:

 $\displaystyle{e\leftarrow\mbox{}d.}$ $\displaystyle{f\leftarrow\mbox{}k.}$ $\displaystyle{z\leftarrow\mbox{}g.}$ $\displaystyle{j.}$
Source $s_{3}$:

Source $s_{3}$ claims the following clause is true:

 $\displaystyle{h\leftarrow\mbox{}d.}$
Source $s_{4}$:

Source $s_{4}$ claims the following clauses are true:

 $\displaystyle{a\leftarrow\mbox{}b\wedge\mbox{}e.}$ $\displaystyle{b\leftarrow\mbox{}c.}$
Source $s_{5}$:

Source $s_{5}$ claims the following clause is true:

 $\displaystyle{g\leftarrow\mbox{}f\wedge\mbox{}j.}$
Yourself:

Suppose that you know that the following clauses are true:

 $\displaystyle{false\leftarrow\mbox{}a\wedge\mbox{}z.}$ $\displaystyle{c.}$ $\displaystyle{k.}$

Not every source can be believed, because together they produce a contradiction.

1. (a)

Code the knowledge provided by the users into AILog using assumables. To use a clause provided by one of the sources, you must assume that the source is reliable.

2. (b)

Use the program to find the conflicts about what sources are reliable. (To find conflicts you can just ask  $false$.)

3. (c)

Suppose you would like to assume that as few sources as possible are unreliable. Which single source, if it was unreliable, could account for a contradiction (assuming all other sources were reliable)?

4. (d)

Which pairs of sources could account for a contradiction (assuming all other sources are reliable) such that no single one of them could account for the contradiction?

14. 14.

Suppose you have a job at a company that is building online teaching tools. Because you have taken an AI course, your boss wants to know your opinion on various options under consideration.

They are planning on building an intelligent tutoring system for teaching elementary physics (e.g., mechanics and electromagnetism). One of the things that the system must do is to diagnose errors that a student may be making.

For each of the following, answer the explicit questions and use proper English. Answering parts not asked or giving more than one answer when only one is asked for will annoy the boss. The boss also does not like jargon, so please use straightforward English.

The boss has heard of consistency-based diagnosis and abductive diagnosis but wants to know what they involve in the context of building an intelligent tutoring system for teaching elementary physics.

1. (a)

Explain what knowledge (about physics and about students) is required for consistency-based diagnosis.

2. (b)

Explain what knowledge (about physics and about students) is required for abductive diagnosis.

3. (c)

What is the main advantage of using abductive diagnosis over consistency-based diagnosis in this domain?

4. (d)

What is the main advantage of consistency-based diagnosis over abductive diagnosis in this domain?

15. 15.

Consider the bottom-up negation-as-failure proof procedure of Figure 5.11. Suppose we want to allow for incremental addition and deletion of clauses. How does $C$ change as a clause is added? How does $C$ change if a clause is removed?

16. 16.

Suppose you are implementing a bottom-up Horn clause explanation reasoner and you want to incrementally add clauses or assumables. When a clause is added, how are the minimal explanations affected? When an assumable is added, how are the minimal explanations affected?

17. 17.

Figure 5.15 shows a simplified redundant communication network between an unmanned spacecraft (sc) and a ground control center (gc). There are two indirect high-bandwidth (high-gain) links that are relayed through satellites ($s_{1}$, $s_{2}$) to different ground antennae ($a_{1}$, $a_{2}$). Furthermore, there is a direct, low-bandwidth (low-gain) link between the ground control center’s antenna ($a_{3}$) and the spacecraft. The low-gain link is affected by atmospheric disturbances – it works if there are no disturbances (no_dist) – and the spacecraft’s low-gain transmitter (sc_lg) and antenna 3 are ok. The high-gain links always work if the spacecraft’s high-gain transmitter (sc_hg), the satellites’ antennae ($s_{1}\mbox{\_ant}$, $s_{2}\mbox{\_ant}$), the satellites’ transmitters ($s_{1}\mbox{\_trans}$, $s_{2}\mbox{\_trans}$), and the ground antennae ($a_{1}$, $a_{2}$) are ok.

To keep matters simple, consider only messages from the spacecraft going through these channels to the ground control center.

The following knowledge base formalizes the part of the communication network we are interested in:

 $\displaystyle{\mbox{send\_signal\_lg\_sc}\leftarrow\mbox{ok\_sc\_lg}\wedge% \mbox{alive\_sc}.}$ $\displaystyle{\mbox{send\_signal\_hg\_sc}\leftarrow\mbox{ok\_sc\_hg}\wedge% \mbox{alive\_sc}.}$ $\displaystyle{\mbox{get\_signal\_s}_{1}\leftarrow\mbox{send\_signal\_hg\_sc}% \wedge\mbox{ok\_s}_{1}\mbox{\_ant}.}$ $\displaystyle{\mbox{get\_signal\_s}_{2}\leftarrow\mbox{send\_signal\_hg\_sc}% \wedge\mbox{ok\_s}_{2}\mbox{\_ant}.}$ $\displaystyle{\mbox{send\_signal\_s}_{1}\leftarrow\mbox{get\_signal\_s}_{1}% \wedge\mbox{ok\_s}_{1}\mbox{\_trans}.}$ $\displaystyle{\mbox{send\_signal\_s}_{2}\leftarrow\mbox{get\_signal\_s}_{2}% \wedge\mbox{ok\_s}_{2}\mbox{\_trans}.}$ $\displaystyle{\mbox{get\_signal\_gc}\leftarrow\mbox{send\_signal\_s}_{1}\wedge% \mbox{ok\_a}_{1}.}$ $\displaystyle{\mbox{get\_signal\_gc}\leftarrow\mbox{send\_signal\_s}_{2}\wedge% \mbox{ok\_a}_{2}.}$ $\displaystyle{\mbox{get\_signal\_gc}\leftarrow\mbox{send\_signal\_lg\_sc}% \wedge\mbox{ok\_a}_{3}\wedge\mbox{no\_dist}.}$

Ground control is worried, because it has not received a signal from the spacecraft (no_signal_gc). It knows for sure that all ground antennae are ok (i.e., $\mbox{ok\_a}_{1}$, $\mbox{ok\_a}_{2}$, and $\mbox{ok\_a}_{3}$) and satellite $s_{1}$’s transmitter is ok ($\mbox{ok\_s}_{1}\mbox{\_trans}$). It is not sure about the state of the spacecraft, its transmitters, the satellites’ antennae, $s_{2}$’s transmitter, and atmospheric disturbances.

1. (a)

Specify a set of assumables and an integrity constraint that model the situation.

2. (b)

Using the assumables and the integrity constraints from part (a), what is the set of minimal conflicts?

3. (c)

What is the consistency-based diagnosis for the given situation? In other words, what are the possible combinations of violated assumptions that could account for why the control center cannot receive a signal from the spacecraft?

18. 18.
1. (a)

Explain why NASA may want to use abduction rather than consistency-based diagnosis for the domain of Exercise 17.

2. (b)

Suppose that an atmospheric disturbance dist could produce static or no signal in the low-bandwidth signal. To receive the static, antenna $a_{3}$ and the spacecraft’s low-bandwidth transmitter sc_lg must be working. If $a_{3}$ or sc_lg are not working or sc is dead, there is no signal. What rules and assumables must be added to the knowledge base of Exercise 17 so that we can explain the possible observations no_signal_gc, get_signal_gc, or static_gc? You may ignore the high-bandwidth links. You may invent any symbols you need.