Intelligence 2E

foundations of computational agents

The third edition of Artificial Intelligence: foundations of computational agents, Cambridge University Press, 2023 is now available (including full text).

The propositional bottom-up proof procedure can be extended to Datalog by using ground instances of the clauses. A ground instance of a clause is obtained by uniformly substituting constants for the variables in the clause. The constants required are those appearing in the knowledge base or in the query. If there are no constants in the knowledge base or the query, one must be invented.

Suppose the knowledge base is

${q}{}{(}{a}{)}{.}$ | ||

${q}{}{(}{b}{)}{.}$ | ||

${r}{}{(}{a}{)}{.}$ | ||

${s}{}{(}{W}{)}{\leftarrow}{}{r}{}{(}{W}{)}{.}$ | ||

${p}{}{(}{X}{,}{Y}{)}{\leftarrow}{}{q}{}{(}{X}{)}{\wedge}{}{s}{}{(}{Y}{)}{.}$ |

The set of all ground instances is

${q}{}{(}{a}{)}{.}$ | ||

${q}{}{(}{b}{)}{.}$ | ||

${r}{}{(}{a}{)}{.}$ | ||

${s}{}{(}{a}{)}{\leftarrow}{}{r}{}{(}{a}{)}{.}$ | ||

${s}{}{(}{b}{)}{\leftarrow}{}{r}{}{(}{b}{)}{.}$ | ||

${p}{}{(}{a}{,}{a}{)}{\leftarrow}{}{q}{}{(}{a}{)}{\wedge}{}{s}{}{(}{a}{)}{.}$ | ||

${p}{}{(}{a}{,}{b}{)}{\leftarrow}{}{q}{}{(}{a}{)}{\wedge}{}{s}{}{(}{b}{)}{.}$ | ||

${p}{}{(}{b}{,}{a}{)}{\leftarrow}{}{q}{}{(}{b}{)}{\wedge}{}{s}{}{(}{a}{)}{.}$ | ||

${p}{}{(}{b}{,}{b}{)}{\leftarrow}{}{q}{}{(}{b}{)}{\wedge}{}{s}{}{(}{b}{)}{.}$ |

The propositional bottom-up proof procedure of Section 5.3.2 can be applied to the grounding to derive ${q}{\mathit{}}{\mathrm{(}}{a}{\mathrm{)}}$, ${q}{\mathit{}}{\mathrm{(}}{b}{\mathrm{)}}$, ${r}{\mathit{}}{\mathrm{(}}{a}{\mathrm{)}}$, ${s}{\mathit{}}{\mathrm{(}}{a}{\mathrm{)}}$, ${p}{\mathit{}}{\mathrm{(}}{a}{\mathrm{,}}{a}{\mathrm{)}}$, and ${p}{\mathit{}}{\mathrm{(}}{b}{\mathrm{,}}{a}{\mathrm{)}}$ as the ground instances that are logical consequences.

Suppose the knowledge base is

${p}{}{(}{X}{,}{Y}{)}{.}$ | ||

${g}{\leftarrow}{}{p}{}{(}{W}{,}{W}{)}{.}$ |

The bottom-up proof procedure for query “${\text{\U0001d5ba\U0001d5cc\U0001d5c4}}{\mathit{\text{}}}{\mathit{}}{g}$” must invent a new constant symbol, say ${c}$. The set of all ground instances is then

${p}{}{(}{c}{,}{c}{)}{.}$ | ||

${g}{\leftarrow}{}{p}{}{(}{c}{,}{c}{)}{.}$ |

The propositional bottom-up proof procedure will derive ${p}{\mathit{}}{\mathrm{(}}{c}{\mathrm{,}}{c}{\mathrm{)}}$ and ${g}$.

If the query were “${\text{\U0001d5ba\U0001d5cc\U0001d5c4}}{\mathit{\text{}}}{\mathit{}}{p}{\mathit{}}{\mathrm{(}}{b}{\mathrm{,}}{d}{\mathrm{)}}$” the set of ground instances would change to reflect the constants ${b}$ and ${d}$.

The bottom-up proof procedure applied to the grounding of the knowledge base is sound, because each instance of each rule is true in every model. This procedure is essentially the same as the variable-free case, but it uses the set of ground instances of the clauses, all of which are true because the variables in a clause are universally quantified.

This bottom-up procedure will eventually halt for Datalog because there are only finitely many grounded atoms, and one ground atom is added to the consequence set each time through the loop.

This procedure is also complete for ground atoms. That is, if a ground atom is a consequence of the knowledge base, it will be derived. To prove this, as in the propositional case, we construct a particular generic model. Recall that a model specifies the domain, what the constants denote, and what is true. A Herbrand interpretation is an interpretation where the domain is symbolic and consists of all constants of the language. A constant is invented if there are no constants in the knowledge base or the query. In a Herbrand interpretation, each constant denotes itself. Thus, in the definition of an interpretation, $D$ and $\varphi $ are fixed for a given program, and all that needs to be specified is $\pi $, which defines the predicate symbols.

Consider the Herbrand interpretation where the true atoms are the ground instances of the relations that are eventually derived by the bottom-up procedure. It is easy to see that this Herbrand interpretation is a model of the rules given. As in the variable-free case, it is a minimal model in that it has the fewest true atoms of any model. If $KB\vDash g$ for ground atom $g$, then $g$ is true in the minimal model and, thus, is eventually derived.

Consider the clauses of Figure 13.2. The bottom-up proof procedure can immediately derive each instance of ${i}{\mathit{}}{m}{\mathit{}}{m}{\mathit{}}{\mathrm{\_}}{\mathit{}}{w}{\mathit{}}{e}{\mathit{}}{s}{\mathit{}}{t}$ given as a fact. The algorithm can then add the ${i}{\mathit{}}{m}{\mathit{}}{m}{\mathit{}}{\mathrm{\_}}{\mathit{}}{e}{\mathit{}}{a}{\mathit{}}{s}{\mathit{}}{t}$ atoms to the consequence set:

${i}{}{m}{}{m}{}{\mathrm{\_}}{}{e}{}{a}{}{s}{}{t}{}{(}{r}{}{103}{,}{r}{}{101}{)}$ | ||

${i}{}{m}{}{m}{}{\mathrm{\_}}{}{e}{}{a}{}{s}{}{t}{}{(}{r}{}{105}{,}{r}{}{103}{)}$ | ||

${i}{}{m}{}{m}{}{\mathrm{\_}}{}{e}{}{a}{}{s}{}{t}{}{(}{r}{}{107}{,}{r}{}{105}{)}$ | ||

${i}{}{m}{}{m}{}{\mathrm{\_}}{}{e}{}{a}{}{s}{}{t}{}{(}{r}{}{109}{,}{r}{}{107}{)}$ | ||

${i}{}{m}{}{m}{}{\mathrm{\_}}{}{e}{}{a}{}{s}{}{t}{}{(}{r}{}{111}{,}{r}{}{109}{)}$ | ||

${i}{}{m}{}{m}{}{\mathrm{\_}}{}{e}{}{a}{}{s}{}{t}{}{(}{r}{}{129}{,}{r}{}{131}{)}$ | ||

${i}{}{m}{}{m}{}{\mathrm{\_}}{}{e}{}{a}{}{s}{}{t}{}{(}{r}{}{127}{,}{r}{}{129}{)}$ | ||

${i}{}{m}{}{m}{}{\mathrm{\_}}{}{e}{}{a}{}{s}{}{t}{}{(}{r}{}{125}{,}{r}{}{127}{)}$ |

Next, the ${n}{\mathit{}}{e}{\mathit{}}{x}{\mathit{}}{t}{\mathit{}}{\mathrm{\_}}{\mathit{}}{d}{\mathit{}}{o}{\mathit{}}{o}{\mathit{}}{r}$ relations that follow can be added to the set of consequences, including

${n}{}{e}{}{x}{}{t}{}{\mathrm{\_}}{}{d}{}{o}{}{o}{}{r}{}{(}{r}{}{101}{,}{r}{}{103}{)}$ | ||

${n}{}{e}{}{x}{}{t}{}{\mathrm{\_}}{}{d}{}{o}{}{o}{}{r}{}{(}{r}{}{103}{,}{r}{}{101}{)}$ |

The ${t}{\mathit{}}{w}{\mathit{}}{o}{\mathit{}}{\mathrm{\_}}{\mathit{}}{d}{\mathit{}}{o}{\mathit{}}{o}{\mathit{}}{r}{\mathit{}}{\mathrm{\_}}{\mathit{}}{e}{\mathit{}}{a}{\mathit{}}{s}{\mathit{}}{t}$ relations can be added to the set of consequences, including

${t}{}{w}{}{o}{}{\mathrm{\_}}{}{d}{}{o}{}{o}{}{r}{}{\mathrm{\_}}{}{e}{}{a}{}{s}{}{t}{}{(}{r}{}{105}{,}{r}{}{101}{)}$ | ||

${t}{}{w}{}{o}{}{\mathrm{\_}}{}{d}{}{o}{}{o}{}{r}{}{\mathrm{\_}}{}{e}{}{a}{}{s}{}{t}{}{(}{r}{}{107}{,}{r}{}{103}{)}$ |

Finally, the ${w}{\mathit{}}{e}{\mathit{}}{s}{\mathit{}}{t}$ relations that follow can be added to the set of consequences.