<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="stabgan.github.io/aima-website-6/aima-website-6/feed.xml" rel="self" type="application/atom+xml" /><link href="stabgan.github.io/aima-website-6/aima-website-6/" rel="alternate" type="text/html" /><updated>2026-03-14T12:46:54+00:00</updated><id>stabgan.github.io/aima-website-6/aima-website-6/feed.xml</id><title type="html">AIMA EXERCISE</title><subtitle>Exercises</subtitle><entry><title type="html">Bayes net Exercise</title><link href="stabgan.github.io/aima-website-6/aima-website-6/Bayes_Net_Exercise/" rel="alternate" type="text/html" title="Bayes net Exercise" /><published>2018-03-14T00:00:00+00:00</published><updated>2018-03-14T00:00:00+00:00</updated><id>stabgan.github.io/aima-website-6/aima-website-6/Bayes_Net_Exercise</id><content type="html" xml:base="stabgan.github.io/aima-website-6/aima-website-6/Bayes_Net_Exercise/"><![CDATA[<h1 id="14-probabilistic-reasoning">14. Probabilistic Reasoning</h1>

<p><strong>14.1</strong> We have a bag of three biased coins $a$, $b$, and $c$ with probabilities
of coming up heads of 20%, 60%, and 80%, respectively. One coin is drawn
randomly from the bag (with equal likelihood of drawing each of the
three coins), and then the coin is flipped three times to generate the
outcomes $X_1$, $X_2$, and $X_3$.</p>

<ol>
  <li>
    <p>Draw the Bayesian network corresponding to this setup and define the
necessary CPTs.</p>
  </li>
  <li>
    <p>Calculate which coin was most likely to have been drawn from the bag
if the observed flips come out heads twice and tails once.</p>
  </li>
</ol>

<p><strong>14.2</strong> We have a bag of three biased coins $a$, $b$, and $c$ with probabilities
of coming up heads of 30%, 60%, and 75%, respectively. One coin is drawn
randomly from the bag (with equal likelihood of drawing each of the
three coins), and then the coin is flipped three times to generate the
outcomes $X_1$, $X_2$, and $X_3$.</p>

<ol>
  <li>
    <p>Draw the Bayesian network corresponding to this setup and define the
necessary CPTs.</p>
  </li>
  <li>
    <p>Calculate which coin was most likely to have been drawn from the bag
if the observed flips come out heads twice and tails once.</p>
  </li>
</ol>

<p><strong>14.3</strong> [cpt-equivalence-exercise]
Equation (<a href="#/">parameter-joint-repn-equation</a>) on
page <a href="#/">parameter-joint-repn-equation</a> defines the joint distribution represented by a
Bayesian network in terms of the parameters
$\theta(X_i{Parents}(X_i))$. This exercise asks you to derive
the equivalence between the parameters and the conditional probabilities
${\textbf{ P}}(X_i{Parents}(X_i))$ from this definition.</p>

<ol>
  <li>
    <p>Consider a simple network $X\rightarrow Y\rightarrow Z$ with three
Boolean variables. Use
Equations (<a href="#/">conditional-probability-equation</a>) and (<a href="#/">marginalization-equation</a>)
(pages <a href="#/">conditional-probability-equation</a> and <a href="#/">marginalization-equation</a>)
to express the conditional probability $P(zy)$ as the ratio of two sums, each over entries in the
joint distribution ${\textbf{P}}(X,Y,Z)$.</p>
  </li>
  <li>
    <p>Now use Equation (<a href="#/">parameter-joint-repn-equation</a>) to
write this expression in terms of the network parameters
$\theta(X)$, $\theta(YX)$, and $\theta(ZY)$.</p>
  </li>
  <li>
    <p>Next, expand out the summations in your expression from part (b),
writing out explicitly the terms for the true and false values of
each summed variable. Assuming that all network parameters satisfy
the constraint
$\sum_{x_i} \theta(x_i{parents}(X_i))1$, show
that the resulting expression reduces to $\theta(zy)$.</p>
  </li>
  <li>
    <p>Generalize this derivation to show that
$\theta(X_i{Parents}(X_i)) = {\textbf{P}}(X_i{Parents}(X_i))$
for any Bayesian network.</p>
  </li>
</ol>

<p><strong>14.4</strong> The <strong>arc reversal</strong> operation of in a Bayesian network allows us to change the direction
of an arc $X\rightarrow Y$ while preserving the joint probability
distribution that the network represents @Shachter:1986. Arc reversal
may require introducing new arcs: all the parents of $X$ also become
parents of $Y$, and all parents of $Y$ also become parents of $X$.</p>

<ol>
  <li>
    <p>Assume that $X$ and $Y$ start with $m$ and $n$ parents,
respectively, and that all variables have $k$ values. By calculating
the change in size for the CPTs of $X$ and $Y$, show that the total
number of parameters in the network cannot decrease during
arc reversal. (<em>Hint</em>: the parents of $X$ and $Y$ need
not be disjoint.)</p>
  </li>
  <li>
    <p>Under what circumstances can the total number remain constant?</p>
  </li>
  <li>
    <p>Let the parents of $X$ be $\textbf{U} \cup \textbf{V}$ and the parents of $Y$ be
$\textbf{V} \cup \textbf{W}$, where $\textbf{U}$ and $\textbf{W}$ are disjoint. The formulas for the
new CPTs after arc reversal are as follows: \(\begin{aligned}
{\textbf{P}}(Y\textbf{U},\textbf{V},\textbf{W}) &amp;=&amp; \sum_x {\textbf{P}}(Y\textbf{V},\textbf{W}, x) {\textbf{P}}(x\textbf{U}, \textbf{V}) \\
{\textbf{P}}(X\textbf{U},\textbf{V},\textbf{W}, Y) &amp;=&amp; {\textbf{P}}(YX, \textbf{V}, \textbf{W}) {\textbf{P}}(X\textbf{U}, \textbf{V}) / {\textbf{P}}(Y\textbf{U},\textbf{V},\textbf{W})\ .\end{aligned}\)
Prove that the new network expresses the same joint distribution
over all variables as the original network.</p>
  </li>
</ol>

<p><strong>14.5</strong> Consider the Bayesian network in
Figure <a href="#/">burglary-figure</a>.</p>

<ol>
  <li>
    <p>If no evidence is observed, are ${Burglary}$ and ${Earthquake}$
independent? Prove this from the numerical semantics and from the
topological semantics.</p>
  </li>
  <li>
    <p>If we observe ${Alarm}{true}$, are ${Burglary}$ and
${Earthquake}$ independent? Justify your answer by calculating
whether the probabilities involved satisfy the definition of
conditional independence.</p>
  </li>
</ol>

<p><strong>14.6</strong> Suppose that in a Bayesian network containing an unobserved variable
$Y$, all the variables in the Markov blanket ${MB}(Y)$ have been
observed.</p>

<ol>
  <li>
    <p>Prove that removing the node $Y$ from the network will not affect
the posterior distribution for any other unobserved variable in
the network.</p>
  </li>
  <li>
    <p>Discuss whether we can remove $Y$ if we are planning to use (i)
rejection sampling and (ii) likelihood weighting.</p>
  </li>
</ol>

<center>
<b id="handedness-figure">Figure [handedness-figure]</b> Three possible structures for a Bayesian network describing genetic inheritance of handedness.
</center>

<p><img src="http://nalinc.github.io/aima-exercises/Jupyter%20notebook/figures/handedness1.svg" alt="handedness-figure" /></p>

<p><strong>14.7</strong> [handedness-exercise] Let $H_x$ be a random variable denoting the
handedness of an individual $x$, with possible values $l$ or $r$. A
common hypothesis is that left- or right-handedness is inherited by a
simple mechanism; that is, perhaps there is a gene $G_x$, also with
values $l$ or $r$, and perhaps actual handedness turns out mostly the
same (with some probability $s$) as the gene an individual possesses.
Furthermore, perhaps the gene itself is equally likely to be inherited
from either of an individual’s parents, with a small nonzero probability
$m$ of a random mutation flipping the handedness.</p>

<ol>
  <li>
    <p>Which of the three networks in
Figure <a href="#handedness-figure">handedness-figure</a> claim that
$ {\textbf{P}}(G_,G_,G_) = {\textbf{P}}(G_){\textbf{P}}(G_){\textbf{P}}(G_)$?</p>
  </li>
  <li>
    <p>Which of the three networks make independence claims that are
consistent with the hypothesis about the inheritance of handedness?</p>
  </li>
  <li>
    <p>Which of the three networks is the best description of the
hypothesis?</p>
  </li>
  <li>
    <p>Write down the CPT for the $G_$ node in network (a), in
terms of $s$ and $m$.</p>
  </li>
  <li>
    <p>Suppose that
$P(G_l)=P(G_l)=q$. In
network (a), derive an expression for $P(G_l)$
in terms of $m$ and $q$ only, by conditioning on its parent nodes.</p>
  </li>
  <li>
    <p>Under conditions of genetic equilibrium, we expect the distribution
of genes to be the same across generations. Use this to calculate
the value of $q$, and, given what you know about handedness in
humans, explain why the hypothesis described at the beginning of
this question must be wrong.</p>
  </li>
</ol>

<p><strong>14.8</strong> [markov-blanket-exercise] The <strong>Markov
blanket</strong> of a variable is defined on page <a href="#/">markov-blanket-page</a>.
Prove that a variable is independent of all other variables in the
network, given its Markov blanket and derive
Equation (<a href="#/">markov-blanket-equation</a>)
(page <a href="#/">markov-blanket-equation</a>).</p>

<center>
<b id="car-starts-figure">Figure [car-starts-figure]</b> A Bayesian network describing some features of a car's electrical system and engine. Each variable is Boolean, and the *true* value indicates that the corresponding aspect of the vehicle is in working order.
</center>

<p><img src="http://nalinc.github.io/aima-exercises/Jupyter%20notebook/figures/car-starts.svg" alt="car-starts-figure" /></p>

<p><strong>14.9</strong> Consider the network for car diagnosis shown in
Figure <a href="#car-starts-figure">car-starts-figure</a>.</p>

<ol>
  <li>
    <p>Extend the network with the Boolean variables ${IcyWeather}$ and
${StarterMotor}$.</p>
  </li>
  <li>
    <p>Give reasonable conditional probability tables for all the nodes.</p>
  </li>
  <li>
    <p>How many independent values are contained in the joint probability
distribution for eight Boolean nodes, assuming that no conditional
independence relations are known to hold among them?</p>
  </li>
  <li>
    <p>How many independent probability values do your network tables
contain?</p>
  </li>
  <li>
    <p>The conditional distribution for ${Starts}$ could be described as
a <strong>noisy-AND</strong> distribution. Define this
family in general and relate it to the noisy-OR distribution.</p>
  </li>
</ol>

<p><strong>14.10</strong> Consider a simple Bayesian network with root variables ${Cold}$,
${Flu}$, and ${Malaria}$ and child variable ${Fever}$, with a
noisy-OR conditional distribution for ${Fever}$ as described in
Section <a href="#/">canonical-distribution-section</a>. By adding
appropriate auxiliary variables for inhibition events and fever-inducing
events, construct an equivalent Bayesian network whose CPTs (except for
root variables) are deterministic. Define the CPTs and prove
equivalence.</p>

<p><strong>14.11</strong> [LG-exercise] Consider the family of linear Gaussian networks, as
defined on page <a href="#/">LG-network-page</a>.</p>

<ol>
  <li>
    <p>In a two-variable network, let $X_1$ be the parent of $X_2$, let
$X_1$ have a Gaussian prior, and let
${\textbf{P}}(X_2X_1)$ be a linear
Gaussian distribution. Show that the joint distribution $P(X_1,X_2)$
is a multivariate Gaussian, and calculate its covariance matrix.</p>
  </li>
  <li>
    <p>Prove by induction that the joint distribution for a general linear
Gaussian network on $X_1,\ldots,X_n$ is also a
multivariate Gaussian.</p>
  </li>
</ol>

<p><strong>14.12</strong> [multivalued-probit-exercise] The probit distribution defined on
page <a href="#/">probit-page</a> describes the probability distribution for a Boolean
child, given a single continuous parent.</p>

<ol>
  <li>
    <p>How might the definition be extended to cover multiple continuous
parents?</p>
  </li>
  <li>
    <p>How might it be extended to handle a <em>multivalued</em>
child variable? Consider both cases where the child’s values are
ordered (as in selecting a gear while driving, depending on speed,
slope, desired acceleration, etc.) and cases where they are
unordered (as in selecting bus, train, or car to get to work).
(<em>Hint</em>: Consider ways to divide the possible values
into two sets, to mimic a Boolean variable.)</p>
  </li>
</ol>

<p><strong>14.13</strong> In your local nuclear power station, there is an alarm that senses when
a temperature gauge exceeds a given threshold. The gauge measures the
temperature of the core. Consider the Boolean variables $A$ (alarm
sounds), $F_A$ (alarm is faulty), and $F_G$ (gauge is faulty) and the
multivalued nodes $G$ (gauge reading) and $T$ (actual core temperature).</p>

<ol>
  <li>
    <p>Draw a Bayesian network for this domain, given that the gauge is
more likely to fail when the core temperature gets too high.</p>
  </li>
  <li>
    <p>Is your network a polytree? Why or why not?</p>
  </li>
  <li>
    <p>Suppose there are just two possible actual and measured
temperatures, normal and high; the probability that the gauge gives
the correct temperature is $x$ when it is working, but $y$ when it
is faulty. Give the conditional probability table associated with
$G$.</p>
  </li>
  <li>
    <p>Suppose the alarm works correctly unless it is faulty, in which case
it never sounds. Give the conditional probability table associated
with $A$.</p>
  </li>
  <li>
    <p>Suppose the alarm and gauge are working and the alarm sounds.
Calculate an expression for the probability that the temperature of
the core is too high, in terms of the various conditional
probabilities in the network.</p>
  </li>
</ol>

<p><strong>14.14</strong> [telescope-exercise] Two astronomers in different parts of the world
make measurements $M_1$ and $M_2$ of the number of stars $N$ in some
small region of the sky, using their telescopes. Normally, there is a
small possibility $e$ of error by up to one star in each direction. Each
telescope can also (with a much smaller probability $f$) be badly out of
focus (events $F_1$ and $F_2$), in which case the scientist will
undercount by three or more stars (or if $N$ is less than 3, fail to
detect any stars at all). Consider the three networks shown in
Figure <a href="#telescope-nets-figure">telescope-nets-figure</a>.</p>

<ol>
  <li>
    <p>Which of these Bayesian networks are correct (but not
necessarily efficient) representations of the preceding information?</p>
  </li>
  <li>
    <p>Which is the best network? Explain.</p>
  </li>
  <li>
    <p>Write out a conditional distribution for
${\textbf{P}}(M_1N)$, for the case where
$N{1,2,3}$ and $M_1{0,1,2,3,4}$. Each
entry in the conditional distribution should be expressed as a
function of the parameters $e$ and/or $f$.</p>
  </li>
  <li>
    <p>Suppose $M_11$ and $M_23$. What are the
<em>possible</em> numbers of stars if you assume no prior
constraint on the values of $N$?</p>
  </li>
  <li>
    <p>What is the <em>most likely</em> number of stars, given these
observations? Explain how to compute this, or if it is not possible
to compute, explain what additional information is needed and how it
would affect the result.</p>
  </li>
</ol>

<p><strong>14.15</strong> Consider the network shown in
Figure <a href="#telescope-nets-figure">telescope-nets-figure</a>(ii), and assume that the
two telescopes work identically. $N{1,2,3}$ and
$M_1,M_2{0,1,2,3,4}$, with the symbolic CPTs as described
in Exercise <a href="#/">telescope-exercise</a>. Using the enumeration
algorithm (Figure <a href="#/">enumeration-algorithm</a> on
page <a href="#/">enumeration-algorithm</a>), calculate the probability distribution
${\textbf{P}}(NM_12,M_22)$.</p>

<center>
<b id="telescope-nets-figure">Figure [telescope-nets-figure]</b> Three possible networks for the telescope problem.
</center>

<p><img src="http://nalinc.github.io/aima-exercises/Jupyter%20notebook/figures/telescope-nets.svg" alt="telescope-nets-figure" /></p>

<center>
<b id="politics-figure">Figure [politics-figure]</b> A simple Bayes net with
Boolean variables B = {BrokeElectionLaw}, I = {Indicted}, M = {PoliticallyMotivatedProsecutor}, G= {FoundGuilty}, J = {Jailed}.
</center>

<p><img src="http://nalinc.github.io/aima-exercises/Jupyter%20notebook/figures/politics.svg" alt="politics-figure" /></p>

<p><strong>14.16</strong> Consider the Bayes net shown in Figure <a href="#politics-figure">politics-figure</a>.</p>

<ol>
  <li>
    <p>Which of the following are asserted by the network
<em>structure</em>?</p>

    <ol>
      <li>
        <p>${\textbf{P}}(B,I,M) = {\textbf{P}}(B){\textbf{P}}(I){\textbf{P}}(M)$.</p>
      </li>
      <li>
        <p>${\textbf{P}}(JG) = {\textbf{P}}(JG,I)$.</p>
      </li>
      <li>
        <p>${\textbf{P}}(MG,B,I) = {\textbf{P}}(MG,B,I,J)$.</p>
      </li>
    </ol>
  </li>
  <li>
    <p>Calculate the value of $P(b,i,\lnot m,g,j)$.</p>
  </li>
  <li>
    <p>Calculate the probability that someone goes to jail given that they
broke the law, have been indicted, and face a politically
motivated prosecutor.</p>
  </li>
  <li>
    <p>A <strong>context-specific independence</strong> (see
page <a href="#/">CSI-page</a>) allows a variable to be independent of some of
its parents given certain values of others. In addition to the usual
conditional independences given by the graph structure, what
context-specific independences exist in the Bayes net in
Figure <a href="#politics-figure">politics-figure</a>?</p>
  </li>
  <li>
    <p>Suppose we want to add the variable
$P{PresidentialPardon}$ to the network; draw the new
network and briefly explain any links you add.</p>
  </li>
</ol>

<p><strong>14.17</strong> Consider the Bayes net shown in Figure <a href="#politics-figure">politics-figure</a>.</p>

<ol>
  <li>
    <p>Which, if any, of the following are asserted by the network
<em>structure</em> (ignoring the CPTs for now)?</p>

    <ol>
      <li>
        <p>${\textbf{P}}(B,I,M) = {\textbf{P}}(B){\textbf{P}}(I){\textbf{P}}(M)$.</p>
      </li>
      <li>
        <p>${\textbf{P}}(JG) = {\textbf{P}}(JG,I)$.</p>
      </li>
      <li>
        <p>${\textbf{P}}(MG,B,I) = {\textbf{P}}(MG,B,I,J)$.</p>
      </li>
    </ol>
  </li>
  <li>
    <p>Calculate the value of $P(b,i,m,\lnot g,j)$.</p>
  </li>
  <li>
    <p>Calculate the probability that someone goes to jail given that they
broke the law, have been indicted, and face a politically
motivated prosecutor.</p>
  </li>
  <li>
    <p>A <strong>context-specific independence</strong> (see
page <a href="#/">CSI-page</a>) allows a variable to be independent of some of
its parents given certain values of others. In addition to the usual
conditional independences given by the graph structure, what
context-specific independences exist in the Bayes net in
Figure <a href="#politics-figure">politics-figure</a>?</p>
  </li>
  <li>
    <p>Suppose we want to add the variable
$P{PresidentialPardon}$ to the network; draw the new
network and briefly explain any links you add.</p>
  </li>
</ol>

<p><strong>14.18</strong> [VE-exercise] Consider the variable elimination algorithm in
Figure <a href="#/">elimination-ask-algorithm</a> (page <a href="#/">elimination-ask-algorithm</a>).</p>

<ol>
  <li>
    <p>Section <a href="#/">exact-inference-section</a> applies variable
elimination to the query
\({\textbf{P}}({Burglary}{JohnCalls}{true},{MaryCalls}{true})\ .\)
Perform the calculations indicated and check that the answer
is correct.</p>
  </li>
  <li>
    <p>Count the number of arithmetic operations performed, and compare it
with the number performed by the enumeration algorithm.</p>
  </li>
  <li>
    <p>Suppose a network has the form of a <em>chain</em>: a sequence
of Boolean variables $X_1,\ldots, X_n$ where
${Parents}(X_i){X_{i-1}}$ for $i2,\ldots,n$.
What is the complexity of computing
${\textbf{P}}(X_1X_n{true})$ using
enumeration? Using variable elimination?</p>
  </li>
  <li>
    <p>Prove that the complexity of running variable elimination on a
polytree network is linear in the size of the tree for any variable
ordering consistent with the network structure.</p>
  </li>
</ol>

<p><strong>14.19</strong> [bn-complexity-exercise] Investigate the complexity of exact inference
in general Bayesian networks:</p>

<ol>
  <li>
    <p>Prove that any 3-SAT problem can be reduced to exact inference in a
Bayesian network constructed to represent the particular problem and
hence that exact inference is NP-hard. (<em>Hint</em>:
Consider a network with one variable for each proposition symbol,
one for each clause, and one for the conjunction of clauses.)</p>
  </li>
  <li>
    <p>The problem of counting the number of satisfying assignments for a
3-SAT problem is #P-complete. Show that exact inference is at least
as hard as this.</p>
  </li>
</ol>

<p><strong>14.20</strong> [primitive-sampling-exercise] Consider the problem of generating a
random sample from a specified distribution on a single variable. Assume
you have a random number generator that returns a random number
uniformly distributed between 0 and 1.</p>

<ol>
  <li>
    <p>Let $X$ be a discrete variable with
$P(Xx_i)p_i$ for
$i{1,\ldots,k}$. The <strong>cumulative distribution</strong> of $X$ gives the probability
that $X{x_1,\ldots,x_j}$ for each possible $j$. (See
also Appendix [math-appendix].) Explain how to
calculate the cumulative distribution in $O(k)$ time and how to
generate a single sample of $X$ from it. Can the latter be done in
less than $O(k)$ time?</p>
  </li>
  <li>
    <p>Now suppose we want to generate $N$ samples of $X$, where $N\gg k$.
Explain how to do this with an expected run time per sample that is
<em>constant</em> (i.e., independent of $k$).</p>
  </li>
  <li>
    <p>Now consider a continuous-valued variable with a parameterized
distribution (e.g., Gaussian). How can samples be generated from
such a distribution?</p>
  </li>
  <li>
    <p>Suppose you want to query a continuous-valued variable and you are
using a sampling algorithm such as LIKELIHOODWEIGHTING to do the inference. How would
you have to modify the query-answering process?</p>
  </li>
</ol>

<p><strong>14.21</strong> Consider the query
${\textbf{P}}({Rain}{Sprinkler}{true},{WetGrass}{true})$
in Figure <a href="#/">rain-clustering-figure</a>(a)
(page <a href="#/">rain-clustering-figure</a>) and how Gibbs sampling can answer it.</p>

<ol>
  <li>
    <p>How many states does the Markov chain have?</p>
  </li>
  <li>
    <p>Calculate the <strong>transition matrix</strong>
${\textbf{Q}}$ containing
$q({\textbf{y}} \rightarrow ‘})$
for all ${\textbf{y}}$, ${\textbf{y}}’$.</p>
  </li>
  <li>
    <p>What does ${\textbf{ Q}}^2$, the square of the
transition matrix, represent?</p>
  </li>
  <li>
    <p>What about ${\textbf{Q}}^n$ as $n\to \infty$?</p>
  </li>
  <li>
    <p>Explain how to do probabilistic inference in Bayesian networks,
assuming that ${\textbf{Q}}^n$ is available. Is this a
practical way to do inference?</p>
  </li>
</ol>

<p><strong>14.22</strong> [gibbs-proof-exercise] This exercise explores the stationary
distribution for Gibbs sampling methods.</p>

<ol>
  <li>
    <p>The convex composition $[\alpha, q_1; 1-\alpha, q_2]$ of $q_1$ and
$q_2$ is a transition probability distribution that first chooses
one of $q_1$ and $q_2$ with probabilities $\alpha$ and $1-\alpha$,
respectively, and then applies whichever is chosen. Prove that if
$q_1$ and $q_2$ are in detailed balance with $\pi$, then their
convex composition is also in detailed balance with $\pi$.
(<em>Note</em>: this result justifies a variant of GIBBS-ASK in which
variables are chosen at random rather than sampled in a
fixed sequence.)</p>
  </li>
  <li>
    <p>Prove that if each of $q_1$ and $q_2$ has $\pi$ as its stationary
distribution, then the sequential composition
$q q_1 \circ q_2$ also has $\pi$ as its
stationary distribution.</p>
  </li>
</ol>

<p><strong>14.23</strong> [MH-exercise] The <strong>Metropolis–Hastings</strong> algorithm is a member of the MCMC family; as such,
it is designed to generate samples $\textbf{x}$ (eventually) according to target
probabilities $\pi(\textbf{x})$. (Typically we are interested in sampling from
$\pi(\textbf{x})P(\textbf{x}\textbf{e})$.) Like simulated annealing,
Metropolis–Hastings operates in two stages. First, it samples a new
state $\textbf{x’}$ from a <strong>proposal distribution</strong> $q(\textbf{x’}\textbf{x})$, given the current state $\textbf{x}$.
Then, it probabilistically accepts or rejects $\textbf{x’}$ according to the <strong>acceptance probability</strong>
\(\alpha(\textbf{x'}\textbf{x}) = \min\ \left(1,\frac{\pi(\textbf{x'})q(\textbf{x}\textbf{x'})}{\pi(\textbf{x})q(\textbf{x'}\textbf{x})}  \right)\ .\)
If the proposal is rejected, the state remains at $\textbf{x}$.</p>

<ol>
  <li>
    <p>Consider an ordinary Gibbs sampling step for a specific variable
$X_i$. Show that this step, considered as a proposal, is guaranteed
to be accepted by Metropolis–Hastings. (Hence, Gibbs sampling is a
special case of Metropolis–Hastings.)</p>
  </li>
  <li>
    <p>Show that the two-step process above, viewed as a transition
probability distribution, is in detailed balance with $\pi$.</p>
  </li>
</ol>

<p><strong>14.24</strong> [soccer-rpm-exercise]Three soccer teams $A$, $B$, and $C$, play each
other once. Each match is between two teams, and can be won, drawn, or
lost. Each team has a fixed, unknown degree of quality—an integer
ranging from 0 to 3—and the outcome of a match depends probabilistically
on the difference in quality between the two teams.</p>

<ol>
  <li>
    <p>Construct a relational probability model to describe this domain,
and suggest numerical values for all the necessary
probability distributions.</p>
  </li>
  <li>
    <p>Construct the equivalent Bayesian network for the three matches.</p>
  </li>
  <li>
    <p>Suppose that in the first two matches $A$ beats $B$ and draws with
$C$. Using an exact inference algorithm of your choice, compute the
posterior distribution for the outcome of the third match.</p>
  </li>
  <li>
    <p>Suppose there are $n$ teams in the league and we have the results
for all but the last match. How does the complexity of predicting
the last game vary with $n$?</p>
  </li>
  <li>
    <p>Investigate the application of MCMC to this problem. How quickly
does it converge in practice and how well does it scale?</p>
  </li>
</ol>]]></content><author><name></name></author><summary type="html"><![CDATA[14. Probabilistic Reasoning]]></summary></entry><entry><title type="html">Knowledge and Logic Exercise</title><link href="stabgan.github.io/aima-website-6/aima-website-6/Knowledge_Logic_Exercise/" rel="alternate" type="text/html" title="Knowledge and Logic Exercise" /><published>2018-03-14T00:00:00+00:00</published><updated>2018-03-14T00:00:00+00:00</updated><id>stabgan.github.io/aima-website-6/aima-website-6/Knowledge_Logic_Exercise</id><content type="html" xml:base="stabgan.github.io/aima-website-6/aima-website-6/Knowledge_Logic_Exercise/"><![CDATA[<h1 id="7-logical-agents">7. Logical Agents</h1>

<p><strong>7.1</strong> Suppose the agent has progressed to the point shown in
Figure <a href="#/">wumpus-seq35-figure</a>(a), page <a href="#/">wumpus-seq35-figure</a>,
having perceived nothing in [1,1], a breeze in [2,1], and a stench
in [1,2], and is now concerned with the contents of [1,3], [2,2],
and [3,1]. Each of these can contain a pit, and at most one can
contain a wumpus. Following the example of
Figure <a href="#/">wumpus-entailment-figure</a>, construct the set of
possible worlds. (You should find 32 of them.) Mark the worlds in which
the KB is true and those in which each of the following sentences is
true:</p>

<p>$\alpha_2$ = “There is no pit in [2,2].”</p>

<p>$\alpha_3$ = “There is a wumpus in [1,3].”</p>

<p>Hence show that ${KB} {\models}\alpha_2$ and
${KB} {\models}\alpha_3$.</p>

<p><strong>7.2</strong> (Adapted from @Barwise+Etchemendy:1993 .) Given the following, can you prove that the unicorn is
mythical? How about magical? Horned?</p>

<blockquote>
  <p>If the unicorn is mythical, then it is immortal, but if it is not
mythical, then it is a mortal mammal. If the unicorn is either
immortal or a mammal, then it is horned. The unicorn is magical if it
is horned.</p>
</blockquote>

<p><strong>7.3</strong> [truth-value-exercise] Consider the problem of deciding whether a
propositional logic sentence is true in a given model.</p>

<ol>
  <li>
    <p>Write a recursive algorithm PL-True?$ (s, m )$ that returns ${true}$ if and
only if the sentence $s$ is true in the model $m$ (where $m$ assigns
a truth value for every symbol in $s$). The algorithm should run in
time linear in the size of the sentence. (Alternatively, use a
version of this function from the online code repository.)</p>
  </li>
  <li>
    <p>Give three examples of sentences that can be determined to be true
or false in a <em>partial</em> model that does not specify a
truth value for some of the symbols.</p>
  </li>
  <li>
    <p>Show that the truth value (if any) of a sentence in a partial model
cannot be determined efficiently in general.</p>
  </li>
  <li>
    <p>Modify your algorithm so that it can sometimes judge truth from
partial models, while retaining its recursive structure and linear
run time. Give three examples of sentences whose truth in a partial
model is <em>not</em> detected by your algorithm.</p>
  </li>
  <li>
    <p>Investigate whether the modified algorithm makes $TT-Entails?$ more efficient.</p>
  </li>
</ol>

<p><strong>7.4</strong> Which of the following are correct?</p>

<ol>
  <li>
    <p>${False} \models {True}$.</p>
  </li>
  <li>
    <p>${True} \models {False}$.</p>
  </li>
  <li>
    <p>$(A\land B)  \models (A{\;\;{\Leftrightarrow}\;\;}B)$.</p>
  </li>
  <li>
    <p>$A{\;\;{\Leftrightarrow}\;\;}B \models A \lor B$.</p>
  </li>
  <li>
    <p>$A{\;\;{\Leftrightarrow}\;\;}B \models \lnot A \lor B$.</p>
  </li>
  <li>
    <p>$(A\land B){:\;{\Rightarrow}:\;}C \models (A{:\;{\Rightarrow}:\;}C)\lor(B{:\;{\Rightarrow}:\;}C)$.</p>
  </li>
  <li>
    <p>$(C\lor (\lnot A \land \lnot B)) \equiv ((A{:\;{\Rightarrow}:\;}C) \land (B {:\;{\Rightarrow}:\;}C))$.</p>
  </li>
  <li>
    <p>$(A\lor B) \land (\lnot C\lor\lnot D\lor E) \models (A\lor B)$.</p>
  </li>
  <li>
    <p>$(A\lor B) \land (\lnot C\lor\lnot D\lor E) \models (A\lor B) \land (\lnot D\lor E)$.</p>
  </li>
  <li>
    <p>$(A\lor B) \land \lnot(A {:\;{\Rightarrow}:\;}B)$ is satisfiable.</p>
  </li>
  <li>
    <p>$(A{\;\;{\Leftrightarrow}\;\;}B) \land (\lnot A \lor B)$
is satisfiable.</p>
  </li>
  <li>
    <p>$(A{\;\;{\Leftrightarrow}\;\;}B) {\;\;{\Leftrightarrow}\;\;}C$ has
the same number of models as $(A{\;\;{\Leftrightarrow}\;\;}B)$ for
any fixed set of proposition symbols that includes $A$, $B$, $C$.</p>
  </li>
</ol>

<p><strong>7.5</strong> Which of the following are correct?</p>

<ol>
  <li>
    <p>${False} \models {True}$.</p>
  </li>
  <li>
    <p>${True} \models {False}$.</p>
  </li>
  <li>
    <p>$(A\land B)  \models (A{\;\;{\Leftrightarrow}\;\;}B)$.</p>
  </li>
  <li>
    <p>$A{\;\;{\Leftrightarrow}\;\;}B \models A \lor B$.</p>
  </li>
  <li>
    <p>$A{\;\;{\Leftrightarrow}\;\;}B \models \lnot A \lor B$.</p>
  </li>
  <li>
    <p>$(A\lor B) \land (\lnot C\lor\lnot D\lor E) \models (A\lor B\lor C) \land (B\land C\land D{:\;{\Rightarrow}:\;}E)$.</p>
  </li>
  <li>
    <p>$(A\lor B) \land (\lnot C\lor\lnot D\lor E) \models (A\lor B) \land (\lnot D\lor E)$.</p>
  </li>
  <li>
    <p>$(A\lor B) \land \lnot(A {:\;{\Rightarrow}:\;}B)$ is satisfiable.</p>
  </li>
  <li>
    <p>$(A\land B){:\;{\Rightarrow}:\;}C \models (A{:\;{\Rightarrow}:\;}C)\lor(B{:\;{\Rightarrow}:\;}C)$.</p>
  </li>
  <li>
    <p>$(C\lor (\lnot A \land \lnot B)) \equiv ((A{:\;{\Rightarrow}:\;}C) \land (B {:\;{\Rightarrow}:\;}C))$.</p>
  </li>
  <li>
    <p>$(A{\;\;{\Leftrightarrow}\;\;}B) \land (\lnot A \lor B)$
is satisfiable.</p>
  </li>
  <li>
    <p>$(A{\;\;{\Leftrightarrow}\;\;}B) {\;\;{\Leftrightarrow}\;\;}C$ has
the same number of models as $(A{\;\;{\Leftrightarrow}\;\;}B)$ for
any fixed set of proposition symbols that includes $A$, $B$, $C$.</p>
  </li>
</ol>

<p><strong>7.6</strong> [deduction-theorem-exercise] Prove each of the following assertions:</p>

<ol>
  <li>
    <p>$\alpha$ is valid if and only if ${True}{\models}\alpha$.</p>
  </li>
  <li>
    <p>For any $\alpha$, ${False}{\models}\alpha$.</p>
  </li>
  <li>
    <p>$\alpha{\models}\beta$ if and only if the sentence
$(\alpha {:\;{\Rightarrow}:\;}\beta)$ is valid.</p>
  </li>
  <li>
    <p>$\alpha \equiv \beta$ if and only if the sentence
$(\alpha{\;\;{\Leftrightarrow}\;\;}\beta)$ is valid.</p>
  </li>
  <li>
    <p>$\alpha{\models}\beta$ if and only if the sentence
$(\alpha \land \lnot \beta)$ is unsatisfiable.</p>
  </li>
</ol>

<p><strong>7.7</strong> Prove, or find a counterexample to, each of the following assertions:</p>

<ol>
  <li>
    <p>If $\alpha\models\gamma$ or $\beta\models\gamma$ (or both) then
$(\alpha\land \beta)\models\gamma$</p>
  </li>
  <li>
    <p>If $(\alpha\land \beta)\models\gamma$ then $\alpha\models\gamma$ or
$\beta\models\gamma$ (or both).</p>
  </li>
  <li>
    <p>If $\alpha\models (\beta \lor \gamma)$ then $\alpha \models \beta$
or $\alpha \models \gamma$ (or both).</p>
  </li>
</ol>

<p><strong>7.8</strong> Prove, or find a counterexample to, each of the following assertions:</p>

<ol>
  <li>
    <p>If $\alpha\models\gamma$ or $\beta\models\gamma$ (or both) then
$(\alpha\land \beta)\models\gamma$</p>
  </li>
  <li>
    <p>If $\alpha\models (\beta \land \gamma)$ then $\alpha \models \beta$
and $\alpha \models \gamma$.</p>
  </li>
  <li>
    <p>If $\alpha\models (\beta \lor \gamma)$ then $\alpha \models \beta$
or $\alpha \models \gamma$ (or both).</p>
  </li>
</ol>

<p><strong>7.9</strong> Consider a vocabulary with only four propositions, $A$, $B$, $C$, and
$D$. How many models are there for the following sentences?</p>

<ol>
  <li>
    <p>$B\lor C$.</p>
  </li>
  <li>
    <p>$\lnot A\lor \lnot B \lor \lnot C \lor \lnot D$.</p>
  </li>
  <li>
    <p>$(A{:\;{\Rightarrow}:\;}B) \land A \land \lnot B \land C \land D$.</p>
  </li>
</ol>

<p><strong>7.10</strong> We have defined four binary logical connectives.</p>

<ol>
  <li>
    <p>Are there any others that might be useful?</p>
  </li>
  <li>
    <p>How many binary connectives can there be?</p>
  </li>
  <li>
    <p>Why are some of them not very useful?</p>
  </li>
</ol>

<p><strong>7.11</strong> [logical-equivalence-exercise]Using a method of your choice, verify
each of the equivalences in
Table [logical-equivalence-table] (page <a href="#/">logical-equivalence-table</a>).</p>

<p><strong>7.12</strong> [propositional-validity-exercise]Decide whether each of the following
sentences is valid, unsatisfiable, or neither. Verify your decisions
using truth tables or the equivalence rules of
Table [logical-equivalence-table] (page <a href="#/">logical-equivalence-table</a>).</p>

<ol>
  <li>
    <p>${Smoke} {:\;{\Rightarrow}:\;}{Smoke}$</p>
  </li>
  <li>
    <p>${Smoke} {:\;{\Rightarrow}:\;}{Fire}$</p>
  </li>
  <li>
    <p>$({Smoke} {:\;{\Rightarrow}:\;}{Fire}) {:\;{\Rightarrow}:\;}(\lnot {Smoke} {:\;{\Rightarrow}:\;}\lnot {Fire})$</p>
  </li>
  <li>
    <p>${Smoke} \lor {Fire} \lor \lnot {Fire}$</p>
  </li>
  <li>
    <p>$(({Smoke} \land {Heat}) {:\;{\Rightarrow}:\;}{Fire})
        {\;\;{\Leftrightarrow}\;\;}(({Smoke} {:\;{\Rightarrow}:\;}{Fire}) \lor ({Heat} {:\;{\Rightarrow}:\;}{Fire}))$</p>
  </li>
  <li>
    <p>$({Smoke} {:\;{\Rightarrow}:\;}{Fire}) {:\;{\Rightarrow}:\;}(({Smoke} \land {Heat}) {:\;{\Rightarrow}:\;}{Fire}) $</p>
  </li>
  <li>
    <p>${Big} \lor {Dumb} \lor ({Big} {:\;{\Rightarrow}:\;}{Dumb})$</p>
  </li>
</ol>

<p><strong>7.13</strong> [propositional-validity-exercise]Decide whether each of the following
sentences is valid, unsatisfiable, or neither. Verify your decisions
using truth tables or the equivalence rules of
Table [logical-equivalence-table] (page <a href="#/">logical-equivalence-table</a>).</p>

<ol>
  <li>
    <p>${Smoke} {:\;{\Rightarrow}:\;}{Smoke}$</p>
  </li>
  <li>
    <p>${Smoke} {:\;{\Rightarrow}:\;}{Fire}$</p>
  </li>
  <li>
    <p>$({Smoke} {:\;{\Rightarrow}:\;}{Fire}) {:\;{\Rightarrow}:\;}(\lnot {Smoke} {:\;{\Rightarrow}:\;}\lnot {Fire})$</p>
  </li>
  <li>
    <p>${Smoke} \lor {Fire} \lor \lnot {Fire}$</p>
  </li>
  <li>
    <p>$(({Smoke} \land {Heat}) {:\;{\Rightarrow}:\;}{Fire})
        {\;\;{\Leftrightarrow}\;\;}(({Smoke} {:\;{\Rightarrow}:\;}{Fire}) \lor ({Heat} {:\;{\Rightarrow}:\;}{Fire}))$</p>
  </li>
  <li>
    <p>${Big} \lor {Dumb} \lor ({Big} {:\;{\Rightarrow}:\;}{Dumb})$</p>
  </li>
  <li>
    <p>$({Big} \land {Dumb}) \lor \lnot {Dumb}$</p>
  </li>
</ol>

<p><strong>7.14</strong> [cnf-proof-exercise] Any propositional logic sentence is logically
equivalent to the assertion that each possible world in which it would
be false is not the case. From this observation, prove that any sentence
can be written in CNF.</p>

<p><strong>7.15</strong> Use resolution to prove the sentence $\lnot A \land \lnot B$ from the
clauses in Exercise <a href="#/">convert-clausal-exercise</a>.</p>

<p><strong>7.16</strong> [inf-exercise] This exercise looks into the relationship between
clauses and implication sentences.</p>

<ol>
  <li>
    <p>Show that the clause $(\lnot P_1 \lor \cdots \lor \lnot P_m \lor Q)$
is logically equivalent to the implication sentence
$(P_1 \land \cdots \land P_m) {\;{\Rightarrow}\;}Q$.</p>
  </li>
  <li>
    <p>Show that every clause (regardless of the number of
positive literals) can be written in the form
$(P_1 \land \cdots \land P_m) {\;{\Rightarrow}\;}(Q_1 \lor \cdots \lor Q_n)$,
where the $P$s and $Q$s are proposition symbols. A knowledge base
consisting of such sentences is in implicative normal form or <strong>Kowalski
form</strong> @Kowalski:1979.</p>
  </li>
  <li>
    <p>Write down the full resolution rule for sentences in implicative
normal form.</p>
  </li>
</ol>

<p><strong>7.17</strong> According to some political pundits, a person who is radical ($R$) is
electable ($E$) if he/she is conservative ($C$), but otherwise is not
electable.</p>

<ol>
  <li>
    <p>Which of the following are correct representations of this
assertion?</p>

    <ol>
      <li>
        <p>$(R\land E)\iff C$</p>
      </li>
      <li>
        <p>$R{:\;{\Rightarrow}:\;}(E\iff C)$</p>
      </li>
      <li>
        <p>$R{:\;{\Rightarrow}:\;}((C{:\;{\Rightarrow}:\;}E) \lor \lnot E)$</p>
      </li>
    </ol>
  </li>
  <li>
    <p>Which of the sentences in (a) can be expressed in Horn form?</p>
  </li>
</ol>

<p><strong>7.18</strong> This question considers representing satisfiability (SAT) problems as
CSPs.</p>

<ol>
  <li>
    <p>Draw the constraint graph corresponding to the SAT problem
\((\lnot X_1 \lor X_2) \land (\lnot X_2 \lor X_3) \land \ldots \land (\lnot X_{n-1} \lor X_n)\)
for the particular case $n5$.</p>
  </li>
  <li>
    <p>How many solutions are there for this general SAT problem as a
function of $n$?</p>
  </li>
  <li>
    <p>Suppose we apply {Backtracking-Search} (page <a href="#/">backtracking-search-algorithm</a>) to find <em>all</em>
solutions to a SAT CSP of the type given in (a). (To find
<em>all</em> solutions to a CSP, we simply modify the basic
algorithm so it continues searching after each solution is found.)
Assume that variables are ordered $X_1,\ldots,X_n$ and ${false}$
is ordered before ${true}$. How much time will the algorithm take
to terminate? (Write an $O(\cdot)$ expression as a function of $n$.)</p>
  </li>
  <li>
    <p>We know that SAT problems in Horn form can be solved in linear time
by forward chaining (unit propagation). We also know that every
tree-structured binary CSP with discrete, finite domains can be
solved in time linear in the number of variables
(Section <a href="#/">csp-structure-section</a>). Are these two
facts connected? Discuss.</p>
  </li>
</ol>

<p><strong>7.19</strong> This question considers representing satisfiability (SAT) problems as
CSPs.</p>

<ol>
  <li>
    <p>Draw the constraint graph corresponding to the SAT problem
\((\lnot X_1 \lor X_2) \land (\lnot X_2 \lor X_3) \land \ldots \land (\lnot X_{n-1} \lor X_n)\)
for the particular case $n4$.</p>
  </li>
  <li>
    <p>How many solutions are there for this general SAT problem as a
function of $n$?</p>
  </li>
  <li>
    <p>Suppose we apply {Backtracking-Search} (page <a href="#/">backtracking-search-algorithm</a>) to find <em>all</em>
solutions to a SAT CSP of the type given in (a). (To find
<em>all</em> solutions to a CSP, we simply modify the basic
algorithm so it continues searching after each solution is found.)
Assume that variables are ordered $X_1,\ldots,X_n$ and ${false}$
is ordered before ${true}$. How much time will the algorithm take
to terminate? (Write an $O(\cdot)$ expression as a function of $n$.)</p>
  </li>
  <li>
    <p>We know that SAT problems in Horn form can be solved in linear time
by forward chaining (unit propagation). We also know that every
tree-structured binary CSP with discrete, finite domains can be
solved in time linear in the number of variables
(Section <a href="#/">csp-structure-section</a>). Are these two
facts connected? Discuss.</p>
  </li>
</ol>

<p><strong>7.20</strong> Explain why every nonempty propositional clause, by itself, is
satisfiable. Prove rigorously that every set of five 3-SAT clauses is
satisfiable, provided that each clause mentions exactly three distinct
variables. What is the smallest set of such clauses that is
unsatisfiable? Construct such a set.</p>

<p><strong>7.21</strong> A propositional <em>2-CNF</em> expression is a conjunction of
clauses, each containing <em>exactly 2</em> literals, e.g.,
\((A\lor B) \land (\lnot A \lor C) \land (\lnot B \lor D) \land (\lnot
  C \lor G) \land (\lnot D \lor G)\ .\)</p>

<ol>
  <li>
    <p>Prove using resolution that the above sentence entails $G$.</p>
  </li>
  <li>
    <p>Two clauses are <em>semantically distinct</em> if they are not
logically equivalent. How many semantically distinct 2-CNF clauses
can be constructed from $n$ proposition symbols?</p>
  </li>
  <li>
    <p>Using your answer to (b), prove that propositional resolution always
terminates in time polynomial in $n$ given a 2-CNF sentence
containing no more than $n$ distinct symbols.</p>
  </li>
  <li>
    <p>Explain why your argument in (c) does not apply to 3-CNF.</p>
  </li>
</ol>

<p><strong>7.22</strong> Prove each of the following assertions:</p>

<ol>
  <li>
    <p>Every pair of propositional clauses either has no resolvents, or all
their resolvents are logically equivalent.</p>
  </li>
  <li>
    <p>There is no clause that, when resolved with itself, yields
(after factoring) the clause $(\lnot P \lor \lnot Q)$.</p>
  </li>
  <li>
    <p>If a propositional clause $C$ can be resolved with a copy of itself,
it must be logically equivalent to $ True $.</p>
  </li>
</ol>

<p><strong>7.23</strong> Consider the following sentence:
\([ ({Food} {\:\;{\Rightarrow}\:\;}{Party}) \lor ({Drinks} {\:\;{\Rightarrow}\:\;}{Party}) ] {\:\;{\Rightarrow}\:\;}[ ( {Food} \land {Drinks} )  {\:\;{\Rightarrow}\:\;}{Party}]\ .\)</p>

<ol>
  <li>
    <p>Determine, using enumeration, whether this sentence is valid,
satisfiable (but not valid), or unsatisfiable.</p>
  </li>
  <li>
    <p>Convert the left-hand and right-hand sides of the main implication
into CNF, showing each step, and explain how the results confirm
your answer to (a).</p>
  </li>
  <li>
    <p>Prove your answer to (a) using resolution.</p>
  </li>
</ol>

<p><strong>7.24</strong> [dnf-exercise] A sentence is in disjunctive normal form(DNF) if it is the disjunction of
conjunctions of literals. For example, the sentence
$(A \land B \land \lnot C) \lor (\lnot A \land C) \lor (B \land \lnot C)$
is in DNF.</p>

<ol>
  <li>
    <p>Any propositional logic sentence is logically equivalent to the
assertion that some possible world in which it would be true is in
fact the case. From this observation, prove that any sentence can be
written in DNF.</p>
  </li>
  <li>
    <p>Construct an algorithm that converts any sentence in propositional
logic into DNF. (<em>Hint</em>: The algorithm is similar to
the algorithm for conversion to CNF iven in
Sectio <a href="#/">pl-resolution-section</a>.)</p>
  </li>
  <li>
    <p>Construct a simple algorithm that takes as input a sentence in DNF
and returns a satisfying assignment if one exists, or reports that
no satisfying assignment exists.</p>
  </li>
  <li>
    <p>Apply the algorithms in (b) and (c) to the following set of
sentences:</p>
  </li>
</ol>

<blockquote>
  <p>$A {\Rightarrow} B$</p>
</blockquote>

<blockquote>
  <p>$B {\Rightarrow} C$</p>
</blockquote>

<blockquote>
  <p>$C {\Rightarrow} A$</p>
</blockquote>

<ol>
  <li>Since the algorithm in (b) is very similar to the algorithm for
conversion to CNF, and since the algorithm in (c) is much simpler
than any algorithm for solving a set of sentences in CNF, why is
this technique not used in automated reasoning?</li>
</ol>

<p><strong>7.25</strong> [convert-clausal-exercise] Convert the following set of sentences to
clausal form.</p>

<blockquote>
  <p>S1: $A {\;\;{\Leftrightarrow}\;\;}(B \lor E)$.</p>
</blockquote>

<blockquote>
  <p>S2: $E {:\;{\Rightarrow}:\;}D$.</p>
</blockquote>

<blockquote>
  <p>S3: $C \land F {:\;{\Rightarrow}:\;}\lnot B$.</p>
</blockquote>

<blockquote>
  <p>S4: $E {:\;{\Rightarrow}:\;}B$.</p>
</blockquote>

<blockquote>
  <p>S5: $B {:\;{\Rightarrow}:\;}F$.</p>
</blockquote>

<blockquote>
  <p>S6: $B {:\;{\Rightarrow}:\;}C$</p>
</blockquote>

<p>Give a trace of the execution of DPLL on the conjunction of these
clauses.</p>

<p><strong>7.26</strong> [convert-clausal-exercise] Convert the following set of sentences to
clausal form.</p>

<blockquote>
  <p>S1: $A {\;\;{\Leftrightarrow}\;\;}(C \lor E)$.</p>
</blockquote>

<blockquote>
  <p>S2: $E {:\;{\Rightarrow}:\;}D$.</p>
</blockquote>

<blockquote>
  <p>S3: $B \land F {:\;{\Rightarrow}:\;}\lnot C$.</p>
</blockquote>

<blockquote>
  <p>S4: $E {:\;{\Rightarrow}:\;}C$.</p>
</blockquote>

<blockquote>
  <p>S5: $C {:\;{\Rightarrow}:\;}F$.</p>
</blockquote>

<blockquote>
  <p>S6: $C {:\;{\Rightarrow}:\;}B$</p>
</blockquote>

<p>Give a trace of the execution of DPLL on the conjunction of these
clauses.</p>

<p><strong>7.27</strong> Is a randomly generated 4-CNF sentence with $n$ symbols and $m$ clauses
more or less likely to be solvable than a randomly generated 3-CNF
sentence with $n$ symbols and $m$ clauses? Explain.</p>

<p><strong>7.28</strong> [minesweeper-exercise] Minesweeper, the well-known computer game, is
closely related to the wumpus world. A minesweeper world is
a rectangular grid of $N$ squares with $M$ invisible mines scattered
among them. Any square may be probed by the agent; instant death follows
if a mine is probed. Minesweeper indicates the presence of mines by
revealing, in each probed square, the <em>number</em> of mines
that are directly or diagonally adjacent. The goal is to probe every
unmined square.</p>

<ol>
  <li>
    <p>Let $X_{i,j}$ be true iff square $[i,j]$ contains a mine. Write down
the assertion that exactly two mines are adjacent to [1,1] as a
sentence involving some logical combination of
$X_{i,j}$ propositions.</p>
  </li>
  <li>
    <p>Generalize your assertion from (a) by explaining how to construct a
CNF sentence asserting that $k$ of $n$ neighbors contain mines.</p>
  </li>
  <li>
    <p>Explain precisely how an agent can use {DPLL} to prove that a given square
does (or does not) contain a mine, ignoring the global constraint
that there are exactly $M$ mines in all.</p>
  </li>
  <li>
    <p>Suppose that the global constraint is constructed from your method
from part (b). How does the number of clauses depend on $M$ and $N$?
Suggest a way to modify {DPLL} so that the global constraint does not need
to be represented explicitly.</p>
  </li>
  <li>
    <p>Are any conclusions derived by the method in part (c) invalidated
when the global constraint is taken into account?</p>
  </li>
  <li>
    <p>Give examples of configurations of probe values that induce
<em>long-range dependencies</em> such that the contents of a
given unprobed square would give information about the contents of a
far-distant square. (<em>Hint</em>: consider an
$N\times 1$ board.)</p>
  </li>
</ol>

<p><strong>7.29</strong> [known-literal-exercise] How long does it take to prove
${KB}{\models}\alpha$ using {DPLL} when $\alpha$ is a literal <em>already
contained in</em> ${KB}$? Explain.</p>

<p><strong>7.30</strong> [dpll-fc-exercise] Trace the behavior of {DPLL} on the knowledge base in
Figure <a href="#/">pl-horn-example-figure</a> when trying to prove $Q$,
and compare this behavior with that of the forward-chaining algorithm.</p>

<p><strong>7.31</strong> Write a successor-state axiom for the ${Locked}$ predicate, which
applies to doors, assuming the only actions available are ${Lock}$ and
${Unlock}$.</p>

<p><strong>7.32</strong> Discuss what is meant by <em>optimal</em> behavior in the wumpus
world. Show that the {Hybrid-Wumpus-Agent} is not optimal, and suggest ways to improve it.</p>

<p><strong>7.33</strong> Suppose an agent inhabits a world with two states, $S$ and $\lnot S$,
and can do exactly one of two actions, $a$ and $b$. Action $a$ does
nothing and action $b$ flips from one state to the other. Let $S^t$ be
the proposition that the agent is in state $S$ at time $t$, and let
$a^t$ be the proposition that the agent does action $a$ at time $t$
(similarly for $b^t$).</p>

<ol>
  <li>
    <p>Write a successor-state axiom for $S^{t+1}$.</p>
  </li>
  <li>
    <p>Convert the sentence in (a) into CNF.</p>
  </li>
  <li>
    <p>Show a resolution refutation proof that if the agent is in $\lnot S$
at time $t$ and does $a$, it will still be in $\lnot S$ at time
$t+1$.</p>
  </li>
</ol>

<p><strong>7.34</strong> [ss-axiom-exercise] Section <a href="#/">successor-state-section</a>
provides some of the successor-state axioms required for the wumpus
world. Write down axioms for all remaining fluent symbols.</p>

<p><strong>7.35</strong> [hybrid-wumpus-exercise]Modify the {Hybrid-Wumpus-Agent} to use the 1-CNF logical state
estimation method described on page <a href="#/">1cnf-belief-state-page</a>. We noted on that page
that such an agent will not be able to acquire, maintain, and use more
complex beliefs such as the disjunction $P_{3,1}\lor P_{2,2}$. Suggest a
method for overcoming this problem by defining additional proposition
symbols, and try it out in the wumpus world. Does it improve the
performance of the agent?</p>]]></content><author><name></name></author><summary type="html"><![CDATA[7. Logical Agents]]></summary></entry><entry><title type="html">You’re up and running!</title><link href="stabgan.github.io/aima-website-6/aima-website-6/Hello-World/" rel="alternate" type="text/html" title="You’re up and running!" /><published>2014-03-03T00:00:00+00:00</published><updated>2014-03-03T00:00:00+00:00</updated><id>stabgan.github.io/aima-website-6/aima-website-6/Hello-World</id><content type="html" xml:base="stabgan.github.io/aima-website-6/aima-website-6/Hello-World/"><![CDATA[<p>This is a test post . 
Kaustabh Ganguly .
fii fuu foo fuum .</p>]]></content><author><name></name></author><summary type="html"><![CDATA[This is a test post . Kaustabh Ganguly . fii fuu foo fuum .]]></summary></entry></feed>