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).

Datalog requires a name, using a constant, for every individual about which the system reasons. Often it is simpler to identify an individual in terms of its components, rather than requiring a separate constant for each individual.

In many domains, you want to be able to refer to a time as an individual. You may want to say that some course is held at 11:30 a.m. You do not want a separate constant for each possible time, although this is possible. It is better to define times in terms of, say, the number of hours past midnight and the number of minutes past the hour. Similarly, you may want to reason with facts about particular dates. You cannot give a constant for each date, as there are infinitely many possible dates. It is easier to define a date in terms of the year, the month, and the day.

Using a constant to name each individual means that the knowledge base can only represent a finite number of individuals, and the number of individuals is fixed when the knowledge base is built. However, you may want to reason about a potentially infinite set of individuals.

Suppose you want to build a system that takes questions in English and answers them by consulting an online database. In this case, each sentence is an individual. You do not want to have to give each sentence its own name, because there are too many English sentences to name them all. It may be better to name the words and then to specify a sentence in terms of the sequence of words in the sentence. This approach may be more practical because there are far fewer words to name than sentences, and each word has its own natural name. You may also want to specify the words in terms of the letters in the word or in terms of their constituent parts.

You may want to reason about lists of students. For example, you may be required to derive the average mark of a class of students. A list of students is an individual that has properties, such as its length and its seventh element. Although it may be possible to name each list, it is very inconvenient to do so. It is much better to have a way to describe lists in terms of their elements.

Function symbols allow you to describe individuals indirectly. Rather than using a constant to describe an individual, an individual is described in terms of other individuals.

Syntactically a function symbol is a word starting with a lower-case letter. We extend the definition of a term so that a term is either a variable, a constant, or of the form $f({t}_{1},\mathrm{\dots},{t}_{n})$, where $f$ is a function symbol and each ${t}_{i}$ is a term. Apart from extending the definition of terms, the language stays the same.

Terms only appear within predicate symbols. You do not write clauses that imply terms. You may, however, write clauses that include atoms that use function symbols.

The semantics of Datalog must be expanded to reflect the new syntax. The definition of $\varphi $ is extended so that $\varphi $ also assigns to each n-ary function symbol a function from ${D}^{n}$ into $D$. A constant can be seen as a 0-ary function symbol (i.e., one with no arguments). Thus, $\varphi $ specifies which individual is denoted by each ground term.

Suppose you want to define dates, such as 20 July 1969, which is the date the first time a human was on the moon. You can use the function symbol ${c}{\mathit{}}{e}$ (common era) so that ${c}{\mathit{}}{e}{\mathit{}}{\mathrm{(}}{Y}{\mathrm{,}}{M}{\mathrm{,}}{D}{\mathrm{)}}$ denotes a date with year ${Y}$, month ${M}$ and day ${D}$. For example, ${c}{\mathit{}}{e}{\mathit{}}{\mathrm{(}}{\mathrm{1969}}{\mathrm{,}}{j}{\mathit{}}{u}{\mathit{}}{l}{\mathrm{,}}{\mathrm{20}}{\mathrm{)}}$ may denote 20 July 1969. Similarly, you can define the symbol ${b}{\mathit{}}{c}{\mathit{}}{e}$ to denote the date before the common era.

The only way to use the function symbol is to write clauses that define relations using the function symbol. There is no notion of defining the ${c}{\mathit{}}{e}$ function; dates are not in a computer any more than people are.

To use function symbols, you can write clauses that are quantified over the arguments of the function symbol. For example, Figure 13.6 defines the ${b}{\mathit{}}{e}{\mathit{}}{f}{\mathit{}}{o}{\mathit{}}{r}{\mathit{}}{e}{\mathit{}}{\mathrm{(}}{{D}}_{{\mathrm{1}}}{\mathrm{,}}{{D}}_{{\mathrm{2}}}{\mathrm{)}}$ relation that is true if date ${{D}}_{{\mathrm{1}}}$ is before date ${{D}}_{{\mathrm{2}}}$ in a day.

% ${b}{}{e}{}{f}{}{o}{}{r}{}{e}{}{(}{{D}}_{{1}}{,}{{D}}_{{2}}{)}$ is true if date ${{D}}_{{1}}$ is before date ${{D}}_{{2}}$

${b}{}{e}{}{f}{}{o}{}{r}{}{e}{}{(}{c}{}{e}{}{(}{Y}{}{1}{,}{M}{}{1}{,}{D}{}{1}{)}{,}{c}{}{e}{}{(}{Y}{}{2}{,}{M}{}{2}{,}{D}{}{2}{)}{)}{\leftarrow}$ | ||

$$ | ||

${b}{}{e}{}{f}{}{o}{}{r}{}{e}{}{(}{c}{}{e}{}{(}{Y}{,}{M}{}{1}{,}{D}{}{1}{)}{,}{c}{}{e}{}{(}{Y}{,}{M}{}{2}{,}{D}{}{2}{)}{)}{\leftarrow}$ | ||

${\mathrm{}}{\mathit{\hspace{1em}\hspace{1em}\u2006}}{m}{}{o}{}{n}{}{t}{}{h}{}{(}{M}{}{1}{,}{N}{}{1}{)}{\wedge}$ | ||

${\mathrm{}}{\mathit{\hspace{1em}\hspace{1em}\u2006}}{m}{}{o}{}{n}{}{t}{}{h}{}{(}{M}{}{2}{,}{N}{}{2}{)}{\wedge}$ | ||

$$ | ||

${b}{}{e}{}{f}{}{o}{}{r}{}{e}{}{(}{c}{}{e}{}{(}{Y}{,}{M}{,}{D}{}{1}{)}{,}{c}{}{e}{}{(}{Y}{,}{M}{,}{D}{}{2}{)}{)}{\leftarrow}$ | ||

$$ |

% ${m}{}{o}{}{n}{}{t}{}{h}{}{(}{M}{,}{N}{)}$ is true if month ${M}$ is the ${N}$th month of the year.

${m}{}{o}{}{n}{}{t}{}{h}{}{(}{j}{}{a}{}{n}{,}{1}{)}{.}$ | ||

${m}{}{o}{}{n}{}{t}{}{h}{}{(}{f}{}{e}{}{b}{,}{2}{)}{.}$ | ||

${m}{}{o}{}{n}{}{t}{}{h}{}{(}{m}{}{a}{}{r}{,}{3}{)}{.}$ | ||

${m}{}{o}{}{n}{}{t}{}{h}{}{(}{a}{}{p}{}{r}{,}{4}{)}{.}$ | ||

${m}{}{o}{}{n}{}{t}{}{h}{}{(}{m}{}{a}{}{y}{,}{5}{)}{.}$ | ||

${m}{}{o}{}{n}{}{t}{}{h}{}{(}{j}{}{u}{}{n}{,}{6}{)}{.}$ | ||

${m}{}{o}{}{n}{}{t}{}{h}{}{(}{j}{}{u}{}{l}{,}{7}{)}{.}$ | ||

${m}{}{o}{}{n}{}{t}{}{h}{}{(}{a}{}{u}{}{g}{,}{8}{)}{.}$ | ||

${m}{}{o}{}{n}{}{t}{}{h}{}{(}{s}{}{e}{}{p}{,}{9}{)}{.}$ | ||

${m}{}{o}{}{n}{}{t}{}{h}{}{(}{o}{}{c}{}{t}{,}{10}{)}{.}$ | ||

${m}{}{o}{}{n}{}{t}{}{h}{}{(}{n}{}{o}{}{v}{,}{11}{)}{.}$ | ||

${m}{}{o}{}{n}{}{t}{}{h}{}{(}{d}{}{e}{}{c}{,}{12}{)}{.}$ |

This assumes the predicate “$$” represents the relation “less than” between integers. This could be represented in terms of clauses, but is often predefined, as it is in Prolog. The months are represented by constants that consist of the first three letters of the month.

A knowledge base consisting of clauses with function symbols can compute any computable function. Thus, a knowledge base can be interpreted as a program, called a logic program. Logic programs are Turing complete; they can compute any function computable on a digital computer.

This expansion of the language has a major impact. With just one function symbol and one constant, the language contains infinitely many ground terms and infinitely many ground atoms. The infinite number of terms can be used to describe an infinite number of individuals.

Function symbols are used to build data structures, as in the following example.

A tree is a useful data structure. You could use a tree to build a syntactic representation of a sentence for a natural language processing system. You could decide that a labeled tree is either of the form ${n}{\mathit{}}{o}{\mathit{}}{d}{\mathit{}}{e}{\mathit{}}{\mathrm{(}}{N}{\mathrm{,}}{L}{\mathit{}}{T}{\mathrm{,}}{R}{\mathit{}}{T}{\mathrm{)}}$ or of the form ${l}{\mathit{}}{e}{\mathit{}}{a}{\mathit{}}{f}{\mathit{}}{\mathrm{(}}{L}{\mathrm{)}}$. Thus, ${n}{\mathit{}}{o}{\mathit{}}{d}{\mathit{}}{e}$ is a function from a name, a left tree, and a right tree into a tree. The function symbol ${l}{\mathit{}}{e}{\mathit{}}{a}{\mathit{}}{f}$ denotes a function from the label of a leaf node into a tree.

The relation ${a}{\mathit{}}{t}{\mathit{}}{\mathrm{\_}}{\mathit{}}{l}{\mathit{}}{e}{\mathit{}}{a}{\mathit{}}{f}{\mathit{}}{\mathrm{(}}{L}{\mathrm{,}}{T}{\mathrm{)}}$ is true if label ${L}$ is the label of a leaf in tree ${T}$. It can be defined by

${a}{}{t}{}{\mathrm{\_}}{}{l}{}{e}{}{a}{}{f}{}{(}{L}{,}{l}{}{e}{}{a}{}{f}{}{(}{L}{)}{)}{.}$ | ||

${a}{}{t}{}{\mathrm{\_}}{}{l}{}{e}{}{a}{}{f}{}{(}{L}{,}{n}{}{o}{}{d}{}{e}{}{(}{N}{,}{L}{}{T}{,}{R}{}{T}{)}{)}{\leftarrow}$ | ||

${\mathrm{}}{\mathit{\hspace{1em}\hspace{1em}\u2006}}{a}{}{t}{}{\mathrm{\_}}{}{l}{}{e}{}{a}{}{f}{}{(}{L}{,}{L}{}{T}{)}{.}$ | ||

${a}{}{t}{}{\mathrm{\_}}{}{l}{}{e}{}{a}{}{f}{}{(}{L}{,}{n}{}{o}{}{d}{}{e}{}{(}{N}{,}{L}{}{T}{,}{R}{}{T}{)}{)}{\leftarrow}$ | ||

${\mathrm{}}{\mathit{\hspace{1em}\hspace{1em}\u2006}}{a}{}{t}{}{\mathrm{\_}}{}{l}{}{e}{}{a}{}{f}{}{(}{L}{,}{R}{}{T}{)}{.}$ |

This is an example of a structural recursive program. The rules cover all of the cases for each of the structures representing trees.

The relation ${i}{\mathit{}}{n}{\mathit{}}{\mathrm{\_}}{\mathit{}}{t}{\mathit{}}{r}{\mathit{}}{e}{\mathit{}}{e}{\mathit{}}{\mathrm{(}}{L}{\mathrm{,}}{T}{\mathrm{)}}$, which is true if label ${L}$ is the label of an interior node of tree ${T}$, can be defined by

${i}{}{n}{}{\mathrm{\_}}{}{t}{}{r}{}{e}{}{e}{}{(}{L}{,}{n}{}{o}{}{d}{}{e}{}{(}{L}{,}{L}{}{T}{,}{R}{}{T}{)}{)}{.}$ | ||

${i}{}{n}{}{\mathrm{\_}}{}{t}{}{r}{}{e}{}{e}{}{(}{L}{,}{n}{}{o}{}{d}{}{e}{}{(}{N}{,}{L}{}{T}{,}{R}{}{T}{)}{)}{\leftarrow}$ | ||

${\mathrm{}}{\mathit{\hspace{1em}\hspace{1em}\u2006}}{i}{}{n}{}{\mathrm{\_}}{}{t}{}{r}{}{e}{}{e}{}{(}{L}{,}{L}{}{T}{)}{.}$ | ||

${i}{}{n}{}{\mathrm{\_}}{}{t}{}{r}{}{e}{}{e}{}{(}{L}{,}{n}{}{o}{}{d}{}{e}{}{(}{N}{,}{L}{}{T}{,}{R}{}{T}{)}{)}{\leftarrow}$ | ||

${\mathrm{}}{\mathit{\hspace{1em}\hspace{1em}\u2006}}{i}{}{n}{}{\mathrm{\_}}{}{t}{}{r}{}{e}{}{e}{}{(}{L}{,}{R}{}{T}{)}{.}$ |

A list is an ordered sequence of elements. You can reason about lists using just function symbols and constants, without the notion of a list being predefined in the language. A list is either the empty list or an element followed by a list. You can invent a constant to denote the empty list. Suppose you use the constant ${n}{\mathit{}}{i}{\mathit{}}{l}$ to denote the empty list. You can choose a function symbol, say ${c}{\mathit{}}{o}{\mathit{}}{n}{\mathit{}}{s}{\mathit{}}{\mathrm{(}}{H}{\mathit{}}{d}{\mathrm{,}}{T}{\mathit{}}{l}{\mathrm{)}}$, with the intended interpretation that it denotes a list with first element ${H}{\mathit{}}{d}$ and rest of the list ${T}{\mathit{}}{l}$. The list containing the elements ${a}$, ${b}$, ${c}$ would then be represented as

$${c}{}{o}{}{n}{}{s}{}{(}{a}{,}{c}{}{o}{}{n}{}{s}{}{(}{b}{,}{c}{}{o}{}{n}{}{s}{}{(}{c}{,}{n}{}{i}{}{l}{)}{)}{)}{.}$$ |

To use lists, one must write predicates that do something with them. For example, the relation ${a}{\mathit{}}{p}{\mathit{}}{p}{\mathit{}}{e}{\mathit{}}{n}{\mathit{}}{d}{\mathit{}}{\mathrm{(}}{X}{\mathrm{,}}{Y}{\mathrm{,}}{Z}{\mathrm{)}}$ that is true when ${X}$, ${Y}$, and ${Z}$ are lists, such that ${Z}$ contains the elements of ${X}$ followed by the elements of ${Z}$, can be defined recursively by

${a}{}{p}{}{p}{}{e}{}{n}{}{d}{}{(}{n}{}{i}{}{l}{,}{L}{,}{L}{)}{.}$ | ||

${a}{}{p}{}{p}{}{e}{}{n}{}{d}{}{(}{c}{}{o}{}{n}{}{s}{}{(}{H}{}{d}{,}{X}{)}{,}{Y}{,}{c}{}{o}{}{n}{}{s}{}{(}{H}{}{d}{,}{Z}{)}{)}{\leftarrow}$ | ||

${\mathrm{}}{\mathit{\hspace{1em}\hspace{1em}\u2006}}{a}{}{p}{}{p}{}{e}{}{n}{}{d}{}{(}{X}{,}{Y}{,}{Z}{)}{.}$ |

There is nothing special about ${c}{\mathit{}}{o}{\mathit{}}{n}{\mathit{}}{s}$ or ${n}{\mathit{}}{i}{\mathit{}}{l}$; we could have just as well used ${f}{\mathit{}}{o}{\mathit{}}{o}$ and ${b}{\mathit{}}{a}{\mathit{}}{r}$.

First-Order and Second-Order Logic

First-order predicate calculus is a logic that extends propositional calculus to include atoms with function symbols and logical variables. All logical variables must have explicit quantification in terms of “for all” ($\colorbox[rgb]{1,1,0.701960784313725}{$\forall $}$) and “there exists” ($\colorbox[rgb]{1,1,0.701960784313725}{$\exists $}$). The semantics of first-order predicate calculus is like the semantics of logic programs presented in this chapter, but with a richer set of operators.

The language of logic programs forms a pragmatic subset of first-order predicate calculus, which has been developed because it is useful for many tasks. First-order predicate calculus can be seen as a language that adds disjunction and explicit quantification to logic programs.

First-order logic is first order because it allows quantification over individuals in the domain. First-order logic allows neither predicates as variables nor quantification over predicates.

Second-order logic allows for quantification over first-order relations and predicates whose arguments are first-order relations. These are second-order relations. For example, the second-order logic formula

$$\colorbox[rgb]{1,1,0.701960784313725}{$\forall $}\colorbox[rgb]{1,1,0.701960784313725}{$R$}\colorbox[rgb]{1,1,0.701960784313725}{$s$}\colorbox[rgb]{1,1,0.701960784313725}{$y$}\colorbox[rgb]{1,1,0.701960784313725}{$m$}\colorbox[rgb]{1,1,0.701960784313725}{$m$}\colorbox[rgb]{1,1,0.701960784313725}{$e$}\colorbox[rgb]{1,1,0.701960784313725}{$t$}\colorbox[rgb]{1,1,0.701960784313725}{$r$}\colorbox[rgb]{1,1,0.701960784313725}{$i$}\colorbox[rgb]{1,1,0.701960784313725}{$c$}\colorbox[rgb]{1,1,0.701960784313725}{$($}\colorbox[rgb]{1,1,0.701960784313725}{$R$}\colorbox[rgb]{1,1,0.701960784313725}{$)$}\colorbox[rgb]{1,1,0.701960784313725}{$\iff $}\colorbox[rgb]{1,1,0.701960784313725}{$($}\colorbox[rgb]{1,1,0.701960784313725}{$\forall $}\colorbox[rgb]{1,1,0.701960784313725}{$X$}\colorbox[rgb]{1,1,0.701960784313725}{$\forall $}\colorbox[rgb]{1,1,0.701960784313725}{$Y$}\colorbox[rgb]{1,1,0.701960784313725}{$R$}\colorbox[rgb]{1,1,0.701960784313725}{$($}\colorbox[rgb]{1,1,0.701960784313725}{$X$}\colorbox[rgb]{1,1,0.701960784313725}{$,$}\colorbox[rgb]{1,1,0.701960784313725}{$Y$}\colorbox[rgb]{1,1,0.701960784313725}{$)$}\colorbox[rgb]{1,1,0.701960784313725}{$\to $}\colorbox[rgb]{1,1,0.701960784313725}{$R$}\colorbox[rgb]{1,1,0.701960784313725}{$($}\colorbox[rgb]{1,1,0.701960784313725}{$Y$}\colorbox[rgb]{1,1,0.701960784313725}{$,$}\colorbox[rgb]{1,1,0.701960784313725}{$X$}\colorbox[rgb]{1,1,0.701960784313725}{$)$}\colorbox[rgb]{1,1,0.701960784313725}{$)$}$$ |

defines the second-order relation $\colorbox[rgb]{1,1,0.701960784313725}{$s$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$y$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$m$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$m$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$e$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$t$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$r$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$i$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$c$}$, which is true if its argument is a symmetric relation.

Second-order logic seems necessary for many applications because transitive closure is not first-order definable. For example, suppose you want $\colorbox[rgb]{1,1,0.701960784313725}{$b$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$e$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$f$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$o$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$r$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$e$}$ to be the transitive closure of $\colorbox[rgb]{1,1,0.701960784313725}{$n$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$e$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$x$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$t$}$, where $\colorbox[rgb]{1,1,0.701960784313725}{$n$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$e$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$x$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$t$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$($}\colorbox[rgb]{1,1,0.701960784313725}{$X$}\colorbox[rgb]{1,1,0.701960784313725}{$,$}\colorbox[rgb]{1,1,0.701960784313725}{$s$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$($}\colorbox[rgb]{1,1,0.701960784313725}{$X$}\colorbox[rgb]{1,1,0.701960784313725}{$)$}\colorbox[rgb]{1,1,0.701960784313725}{$)$}$ is true. Think of $\colorbox[rgb]{1,1,0.701960784313725}{$n$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$e$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$x$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$t$}$ meaning the “next millisecond” and $\colorbox[rgb]{1,1,0.701960784313725}{$b$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$e$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$f$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$o$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$r$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$e$}$ denoting “before.” The natural first-order definition would be the definition

$$\colorbox[rgb]{1,1,0.701960784313725}{$\forall $}\colorbox[rgb]{1,1,0.701960784313725}{$X$}\colorbox[rgb]{1,1,0.701960784313725}{$\forall $}\colorbox[rgb]{1,1,0.701960784313725}{$Y$}\colorbox[rgb]{1,1,0.701960784313725}{$b$}\colorbox[rgb]{1,1,0.701960784313725}{$e$}\colorbox[rgb]{1,1,0.701960784313725}{$f$}\colorbox[rgb]{1,1,0.701960784313725}{$o$}\colorbox[rgb]{1,1,0.701960784313725}{$r$}\colorbox[rgb]{1,1,0.701960784313725}{$e$}\colorbox[rgb]{1,1,0.701960784313725}{$($}\colorbox[rgb]{1,1,0.701960784313725}{$X$}\colorbox[rgb]{1,1,0.701960784313725}{$,$}\colorbox[rgb]{1,1,0.701960784313725}{$Y$}\colorbox[rgb]{1,1,0.701960784313725}{$)$}\colorbox[rgb]{1,1,0.701960784313725}{$\iff $}\colorbox[rgb]{1,1,0.701960784313725}{$($}\colorbox[rgb]{1,1,0.701960784313725}{$Y$}\colorbox[rgb]{1,1,0.701960784313725}{$=$}\colorbox[rgb]{1,1,0.701960784313725}{$s$}\colorbox[rgb]{1,1,0.701960784313725}{$($}\colorbox[rgb]{1,1,0.701960784313725}{$X$}\colorbox[rgb]{1,1,0.701960784313725}{$)$}\colorbox[rgb]{1,1,0.701960784313725}{$\vee $}\colorbox[rgb]{1,1,0.701960784313725}{$b$}\colorbox[rgb]{1,1,0.701960784313725}{$e$}\colorbox[rgb]{1,1,0.701960784313725}{$f$}\colorbox[rgb]{1,1,0.701960784313725}{$o$}\colorbox[rgb]{1,1,0.701960784313725}{$r$}\colorbox[rgb]{1,1,0.701960784313725}{$e$}\colorbox[rgb]{1,1,0.701960784313725}{$($}\colorbox[rgb]{1,1,0.701960784313725}{$s$}\colorbox[rgb]{1,1,0.701960784313725}{$($}\colorbox[rgb]{1,1,0.701960784313725}{$X$}\colorbox[rgb]{1,1,0.701960784313725}{$)$}\colorbox[rgb]{1,1,0.701960784313725}{$,$}\colorbox[rgb]{1,1,0.701960784313725}{$Y$}\colorbox[rgb]{1,1,0.701960784313725}{$)$}\colorbox[rgb]{1,1,0.701960784313725}{$)$}\colorbox[rgb]{1,1,0.701960784313725}{$.$}$$ | (13.1) |

This expression does not accurately capture the definition, because, for example,

$$\colorbox[rgb]{1,1,0.701960784313725}{$\forall $}\colorbox[rgb]{1,1,0.701960784313725}{$X$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$\forall $}\colorbox[rgb]{1,1,0.701960784313725}{$Y$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$b$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$e$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$f$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$o$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$r$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$e$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$($}\colorbox[rgb]{1,1,0.701960784313725}{$X$}\colorbox[rgb]{1,1,0.701960784313725}{$,$}\colorbox[rgb]{1,1,0.701960784313725}{$Y$}\colorbox[rgb]{1,1,0.701960784313725}{$)$}\colorbox[rgb]{1,1,0.701960784313725}{$\to $}\colorbox[rgb]{1,1,0.701960784313725}{$\exists $}\colorbox[rgb]{1,1,0.701960784313725}{$W$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$Y$}\colorbox[rgb]{1,1,0.701960784313725}{$=$}\colorbox[rgb]{1,1,0.701960784313725}{$s$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$($}\colorbox[rgb]{1,1,0.701960784313725}{$W$}\colorbox[rgb]{1,1,0.701960784313725}{$)$}$$ |

does not logically follow from Formula (13.1), because there are nonstandard models of Formula (13.1) with $\colorbox[rgb]{1,1,0.701960784313725}{$Y$}$ denoting infinity. To capture the transitive closure, you require a formula stating that $\colorbox[rgb]{1,1,0.701960784313725}{$b$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$e$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$f$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$o$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$r$}\colorbox[rgb]{1,1,0.701960784313725}{$$}\colorbox[rgb]{1,1,0.701960784313725}{$e$}$ is the minimal predicate that satisfies the definition. This can be stated using second-order logic.

First-order logic is semi-decidable, which means that a sound and complete proof procedure exists in which every true statement can be proved, but it may not halt. Second-order logic is undecidable; no sound and complete proof procedure can be implemented on a Turing machine.