content/second-order-logic/syntax-and-semantics/syntax-and-semantics.tex
1% Part: second-order-logic2% Chapter: syntax-and-semantics34\documentclass[../../../include/open-logic-chapter]{subfiles}56\begin{document}78\olchapter{sol}{syn}{Syntax and Semantics}910\begin{editorial}11Basic syntax and semantics for SOL covered so far. As a chapter it's12too short. Substitution for second-order variables has to be covered13to be able to talk about !!{derivation} systems for SOL, and there's some14subtle issues there.15\end{editorial}1617\olimport{introduction}1819\olimport{terms-formulas}2021\olimport{satisfaction}2223\olimport{semantic-notions}2425\olimport{expressive-power}2627\olimport{inf-count}2829\OLEndChapterHook3031\end{document}
content/second-order-logic/syntax-and-semantics/introduction.tex
1% Part: second-order-logic2% Chapter: syntax-and-semantics3% Section: introduction45\documentclass[../../../include/open-logic-section]{subfiles}67\begin{document}89\olfileid{sol}{syn}{int}1011\olsection{Introduction}1213In first-order logic, we combine the non-logical symbols of a given14language, i.e., its !!{constant}s, !!{function}s, and !!{predicate}s,15with the logical symbols to express things about first-order16!!{structure}s. This is done using the notion of satisfaction, which17relates !!a{structure}~$\Struct{M}$, together with a variable18assignment~$s$, and !!a{formula}~$!A$: $\Sat{M}{!A}[s]$ holds iff what19$!A$ expresses when its !!{constant}s, !!{function}s, and20!!{predicate}s are interpreted as $\Struct{M}$ says, and its free21variables are interpreted as~$s$ says, is true. The interpretation of22the !!{identity}~$\eq$ is built into the definition of23$\Sat{M}{!A}[s]$, as is the interpretation of~$\lforall$ and24$\lexists$. The former is always interpreted as the identity relation25on the !!{domain}~$\Domain{M}$ of the structure, and the quantifiers26are always interpreted as ranging over the entire !!{domain}. But,27crucially, quantification is only allowed over elements of the28!!{domain}, and so only object !!{variable}s are allowed to follow a29quantifier.3031In second-order logic, both the language and the definition of32satisfaction are extended to include free and bound function and33predicate variables, and quantification over them. These variables34are related to !!{function}s and !!{predicate}s the same way that35object variables are related to !!{constant}s. They play the same36role in the formation of terms and !!{formula}s of second-order logic,37and quantification over them is handled in a similar way. In the38\emph{standard} semantics, the second-order quantifiers range over all39possible objects of the right type ($n$-place functions from40$\Domain{M}$ to~$\Domain{M}$ for function variables, $n$-place41relations for predicate variables). For instance, while42$\lforall[\Obj{v_0}][(\Obj{P^1_0}(\Obj{v_0}) \lor \lnot43 \Obj{P^1_0}(\Obj{v_0}))]$ is a formula in both first- and second-order44logic, in the latter we can also consider45$\lforall[\Obj{V^1_0}][\lforall[\Obj{v_0}][(\Obj{V^1_0}(\Obj{v_0}) \lor46 \lnot \Obj{V^1_0}(\Obj{v_0}))]]$ and47$\lexists[\Obj{V^1_0}][\lforall[\Obj{v_0}][(\Obj{V^1_0}(\Obj{v_0}) \lor48 \lnot \Obj{V^1_0}(\Obj{v_0}))]]$. Since these contain no free variables,49they are !!{sentence}s of second-order logic. Here, $\Obj{V^1_0}$ is a50second-order $1$-place predicate variable. The allowable51interpretations of $\Obj{V^1_0}$ are the same that we can assign to a52$1$-place !!{predicate} like $\Obj{P^1_0}$, i.e., subsets53of~$\Domain{M}$. Quantification over them then amounts to saying that54$\lforall[\Obj{v_0}][(\Obj{V^1_0}(\Obj v_0) \lor \lnot55 \Obj{V^1_0}(v_0))]$ holds for all ways of assigning a subset56of~$\Domain{M}$ as the value of $\Obj{V^1_0}$, or for at least one.57Since every set either contains or fails to contain a given object,58both are true in any !!{structure}.59\end{document}
content/second-order-logic/syntax-and-semantics/terms-formulas.tex
1% Part: second-order-logic2% Chapter: syntax-and-semantics3% Section: terms-formulas45\documentclass[../../../include/open-logic-section]{subfiles}67\begin{document}89\olfileid{sol}{syn}{frm}1011\olsection{Terms and \printtoken{P}{formula}}1213Like in first-order logic, expressions of second-order logic are built14up from a basic vocabulary containing \emph{!!{variable}s},15\emph{!!{constant}s}, \emph{!!{predicate}s} and sometimes16\emph{!!{function}s}. From them, together with logical connectives,17quantifiers, and punctuation symbols such as parentheses and commas,18\emph{terms} and \emph{!!{formula}s} are formed. The difference is19that in addition to variables for objects, second-order logic also20contains variables for relations and functions, and allows21quantification over them. So the logical symbols of second-order logic22are those of first-order logic, plus:2324\begin{enumerate}25\item A !!{denumerable}s set of second-order relation !!{variable}s of26 every arity~$n$: $\Obj V_0^n$, $\Obj V_1^n$, $\Obj V_2^n$, \dots27\item A !!{denumerable}s set of second-order function !!{variable}s:28 $\Obj u_0^n$, $\Obj u_1^n$, $\Obj u_2^n$, \dots29\end{enumerate}3031Just as we use $x$, $y$, $z$ as meta-variables for first-order32variables $\Obj v_i$, we'll use $X$, $Y$, $Z$, etc., as metavariables33for $\Obj V_i^n$ and $u$, $v$, etc., as meta-variables for~$\Obj u_i^n$.3435\begin{explain}36The non-logical symbols of a second-order language are specified the37same way a first-order language is: by listing its !!{constant}s,38!!{function}s, and !!{predicate}s.3940In first-order logic, the !!{identity}~$\eq$ is usually included. In41first-order logic, the non-logical symbols of a language~$\Lang{L}$42are crucial to allow us to express anything interesting. There are of43course !!{sentence}s that use no non-logical symbols, but with44only~$\eq$ it is hard to say anything interesting. In second-order45logic, since we have an unlimited supply of relation and function46variables, we can say anything we can say in a first-order language47even without a special supply of non-logical symbols.48\end{explain}4950\begin{defn}[Second-order Terms]51The set of \emph{second-order terms} of~$\Lang L$, $\TrmSOL[L]$, is52defined by adding to \olref[fol][syn][frm]{defn:terms} the clause53\begin{enumerate}54\item If $u$ is an $n$-place function variable and $t_1$, \dots, $t_n$55 are terms, then $\Atom{u}{t_1, \ldots, t_n}$ is a term.56\end{enumerate}57\end{defn}5859\begin{explain}60So, a second-order term looks just like a first-order term, except61that where a first-order term contains !!a{function}~$\Obj{f^n_i}$, a62second-order term may contain a function variable~$\Obj{u^n_i}$ in its63place.64\end{explain}6566\begin{defn}[Second-order \usetoken{s}{formula}]67The set of \emph{second-order !!{formula}s}~$\FrmSOL[L]$ of the68language~$\Lang L$ is defined by adding to69\olref[fol][syn][frm]{defn:formulas} the clauses70\begin{enumerate}71\item If $X$ is an $n$-place predicate variable and $t_1$, \dots,72 $t_n$ are second-order terms of~$\Lang L$, then73 $\Atom{X}{t_1,\ldots, t_n}$ is an atomic !!{formula}.7475\tagitem{prvAll}{If $!A$ is !!a{formula} and $u$ is a function variable,76 then $\lforall[u][!A]$ is !!a{formula}.}{}7778\tagitem{prvAll}{If $!A$ is !!a{formula} and $X$ is a predicate variable,79 then $\lforall[X][!A]$ is !!a{formula}.}{}8081\tagitem{prvEx}{If $!A$ is !!a{formula} and $u$ is a function variable,82 then $\lexists[u][!A]$ is !!a{formula}.}{}8384\tagitem{prvEx}{If $!A$ is !!a{formula} and $X$ is a predicate variable,85 then $\lexists[X][!A]$ is !!a{formula}.}{}86\end{enumerate}87\end{defn}8889\end{document}
content/second-order-logic/syntax-and-semantics/satisfaction.tex
1% Part: second-order-logic2% Chapter: syntax-and-semantics3% Section: satisfaction45\documentclass[../../../include/open-logic-section]{subfiles}67\begin{document}89\olfileid{sol}{syn}{sat}1011\olsection{Satisfaction}1213\begin{explain}14To define the satisfaction relation $\Sat{M}{!A}[s]$ for second-order15!!{formula}s, we have to extend the definitions to cover second-order16!!{variable}s. The notion of !!a{structure} is the same for second-order17logic as it is for first-order logic. There is only a difference for18variable assignments~$s$: these now must not just provide values for19the first-order !!{variable}s, but also for the second-order !!{variable}s.20\end{explain}2122\begin{defn}[Variable Assignment]23A \emph{variable assignment}~$s$ for !!a{structure}~$\Struct{M}$ is a24function which maps each25\begin{enumerate}26\item object !!{variable}~$\Obj{v_i}$ to an element of~$\Domain M$,27 i.e., $s(\Obj{v_i}) \in \Domain{M}$28\item $n$-place relation variable~$\Obj{V_i^n}$ to an $n$-place29 relation on~$\Domain{M}$, i.e., $s(\Obj{V_i^n}) \subseteq \Domain{M}^n$;30\item $n$-place function variable~$\Obj{u_i^n}$ to an $n$-place31 function from $\Domain{M}$ to $\Domain{M}$, i.e.,32 $s(\Obj{u_i^n})\colon \Domain{M}^n \to \Domain{M}$;33\end{enumerate}34\end{defn}3536\begin{explain}37!!^a{structure} assigns !!a{value} to each !!{constant} and38!!{function}, and a second-order variable assignment assigns objects and39functions to each object and function variable. Together, they let us40assign a value to every term.41\end{explain}4243\begin{defn}[\usetoken{S}{value} of a Term]44If $t$ is a term of the language~$\Lang L$, $\Struct M$ is45!!a{structure} for~$\Lang L$, and $s$ is !!a{variable} assignment46for~$\Struct M$, the \emph{!!{value}}~$\Value{t}{M}[s]$ is defined as47for first-order terms, plus the following clause:48\begin{quote}49\indcase{t}{\Atom{u}{t_1, \ldots, t_n}}{50\[51\Value{\indfrm}{M}[s] = s(u)(\Value{t_1}{M}[s], \ldots,52\Value{t_n}{M}[s]).53\]}54\end{quote}55\end{defn}5657\begin{defn}[$x$-Variant]58If $s$ is !!a{variable} assignment for !!a{structure}~$\Struct M$,59then any !!{variable} assignment $s'$ for $\Struct M$ which differs60from $s$ at most in what it assigns to $x$ is called an61\emph{$x$-variant} of~$s$. If $s'$ is an $x$-variant of $s$ we write62$\varAssign{s'}{s}{x}$. (Similarly for second-order variables $X$ or $u$.)63\end{defn}6465\begin{defn}66 If $s$ is !!a{variable} assignment for !!a{structure}~$\Struct M$67 and $m \in \Domain{M}$, then the assignment~$\Subst{s}{m}{x}$ is the68 !!{variable} assignment defined by69 \[\Subst{s}{m}{y} = \begin{cases}70 m & \text{if } y \ident x\\71 s(y) & \text{otherwise},72 \end{cases}\]73 If $X$ is an $n$-place relation !!{variable} and $M \subseteq74 \Domain{M}^n$, then $\Subst{s}{M}{X}$ is the !!{variable} assignment75 defined by76 \[\Subst{s}{M}{y} = \begin{cases}77 M & \text{if } y \ident X\\78 s(y) & \text{otherwise}. 79 \end{cases}\]80 If $u$ is an $n$-place function !!{variable} and $f\colon \Domain{M}^n81 \to \Domain{M}$, then $\Subst{s}{f}{u}$ is the !!{variable} assignment82 defined by83 \[\Subst{s}{f}{y} = \begin{cases}84 f & \text{if } y \ident u\\85 s(y) & \text{otherwise}.86 \end{cases}\]87 In each case, $y$ may be any first- or second-order !!{variable}.88\end{defn}8990\begin{defn}[Satisfaction]91For second-order !!{formula}s~$!A$, the definition of satisfaction is92like \olref[fol][syn][sat]{defn:satisfaction} with the addition of:93\begin{enumerate}94\item \indcase{!A}{\Atom{X^n}{t_1, \dots, t_n}}{$\Sat{M}{\indfrm}[s]$95 iff $\langle \Value{t_1}{M}[s], \dots, \Value{t_n}{M}[s] \rangle \in96 s(X^n)$.}97\tagitem{prvAll}{%98 \indcase{!A}{\lforall[X][!B]}{$\Sat{M}{\indfrm}[s]$ iff for every $M99 \subseteq \Domain{M}^n$, $\Sat{M}{!B}[\Subst{s}{M}{X}]$.}}{}100101\tagitem{prvEx}{%102 \indcase{!A}{\lexists[X][!B]}{$\Sat{M}{\indfrm}[s]$ iff for at least103 one $M \subseteq \Domain{M}^n$ so that104 $\Sat{M}{!B}[\Subst{s}{M}{X}]$.}}{}105106\tagitem{prvAll}{%107 \indcase{!A}{\lforall[u][!B]}{$\Sat{M}{\indfrm}[s]$ iff for every108 $f\colon \Domain{M}^n \to \Domain{M}$,109 $\Sat{M}{!B}[\Subst{s}{f}{u}]$.}}{}110111\tagitem{prvEx}{%112 \indcase{!A}{\lexists[u][!B]}{$\Sat{M}{\indfrm}[s]$ iff for at least113 one $f\colon \Domain{M}^n \to \Domain{M}$ so that114 $\Sat{M}{!B}[\Subst{s}{f}{u}]$.}}{}115\end{enumerate}116\end{defn}117118\begin{ex}119 Consider the !!{formula} $\lforall[z][(\Atom{X}{z} \liff \lnot120 \Atom{Y}{z})]$. It contains no second-order quantifiers, but does121 contain the second-order !!{variable}s $X$ and~$Y$ (here understood to122 be one-place). The corresponding first-order !!{sentence}123 $\lforall[z][(\Atom{P}{z} \liff \lnot \Atom{R}{z})]$ says that124 whatever falls under the interpretation of~$P$ does not fall under125 the interpretation of~$R$ and vice versa. In !!a{structure}, the126 interpretation of !!a{predicate}~$P$ is given by the127 interpretation~$\Assign{P}{M}$. But for second-order !!{variable}s128 like $X$ and~$Y$, the interpretation is provided, not by the129 !!{structure} itself, but by !!a{variable} assignment. Since the130 second-order !!{formula} is not !!a{sentence} (it includes free131 !!{variable}s $X$ and~$Y$), it is only satisfied relative to132 !!a{structure}~$\Struct{M}$ together with !!a{variable}133 assignment~$s$.134135 $\Sat{M}{\lforall[z][(\Atom{X}{z} \liff \lnot \Atom{Y}{z})]}[s]$136 whenever the !!{element}s of~$s(X)$ are not !!{element}s of~$s(Y)$,137 and vice versa, i.e., iff $s(Y) = \Domain{M} \setminus s(X)$. For138 instance, take $\Domain{M} = \{1, 2, 3\}$. Since no !!{predicate}s,139 !!{function}s, or !!{constant}s are involved, the domain140 of~$\Struct{M}$ is all that is relevant. Now for $s_1(X) = \{1, 2\}$141 and $s_1(Y) = \{3\}$, we have $\Sat{M}{\lforall[z][(\Atom{X}{z}142 \liff \lnot \Atom{Y}{z})]}[s_1]$.143144 By contrast, if we have $s_2(X) = \{1, 2\}$ and $s_2(Y) = \{2, 3\}$,145 $\Sat/{M}{\lforall[z][(\Atom{X}{z} \liff \lnot146 \Atom{Y}{z})]}[s_2]$. That's because 147 $\Sat{M}{\Atom{X}{z}}[\Subst{s_2}{2}{z}]$ (since $2 \in \Subst{s_2}{2}{z}(X)$) but148 $\Sat/{M}{\lnot \Atom{Y}{z}}[\Subst{s_2}{2}{z}]$ (since also $2 \in149 \Subst{s_2}{2}{z}(Y)$).150\end{ex}151152\begin{ex}153 $\Sat{M}{\lexists[Y][(\lexists[y][\Atom{Y}{y}] \land154 \lforall[z][(\Atom{X}{z} \liff \lnot \Atom{Y}{z})])]}[s]$ if there155 is an $N \subseteq \Domain{M}$ such that156 $\Sat{M}{(\lexists[y][\Atom{Y}{y}] \land \lforall[z][(\Atom{X}{z}157 \liff \lnot \Atom{Y}{z})])}[\Subst{s}{N}{Y}]$. And that is the case158 for any $N \neq \emptyset$ (so that159 $\Sat{M}{\lexists[y][\Atom{Y}{y}]}[\Subst{s}{N}{Y}]$) and, as in the160 previous example, $N = \Domain{M} \setminus s(X)$. In other words,161 $\Sat{M}{\lexists[Y][(\lexists[y][\Atom{Y}{y}] \land162 \lforall[z][(\Atom{X}{z} \liff \lnot \Atom{Y}{z})])]}[s]$ iff163 $\Domain{M} \setminus s(X)$ is non-empty, i.e., $s(X) \neq164 \Domain{M}$. So, the !!{formula} is satisfied, e.g., if $\Domain{M}165 = \{1, 2, 3\}$ and $s(X) = \{1, 2\}$, but not if $s(X) = \{1, 2, 3\}166 = \Domain{M}$.167168 Since the !!{formula} is not satisfied whenever $s(X) = \Domain{M}$,169 the !!{sentence}170 \[171 \lforall[X][\lexists[Y][(\lexists[y][\Atom{Y}{y}] \land172 \lforall[z][(\Atom{X}{z} \liff \lnot \Atom{Y}{z})])]]173 \]174 is never satisfied: For any !!{structure}~$\Struct{M}$, the175 assignment~$s(X) = \Domain{M}$ will make the !!{sentence} false. On176 the other hand, the sentence177 \[178 \lexists[X][\lexists[Y][(\lexists[y][\Atom{Y}{y}] \land179 \lforall[z][(\Atom{X}{z} \liff \lnot \Atom{Y}{z})])]]180 \]181 is satisfied relative to any assignment~$s$, since we can always182 find $M \subseteq \Domain{M}$ but $M \neq \Domain{M}$ (e.g., $M = \emptyset$).183\end{ex}184185\begin{ex}186 The second-order !!{sentence}~$\lforall[X][\lforall[y][X(y)]]$ says187 that every $1$-place relation, i.e., every property, holds of every188 object. That is clearly never true, since in every~$\Struct{M}$, for189 a variable assignment~$s$ with $s(X) = \emptyset$, and $s(y) = a \in190 \Domain{M}$ we have $\Sat/{M}{X(y)}[s]$. This means that $!A \lif191 \lforall[X][\lforall[y][X(y)]]$ is equivalent in second-order logic192 to $\lnot !A$, that is: $\Sat{M}{!A \lif193 \lforall[X][\lforall[y][X(y)]]}$ iff $\Sat{M}{\lnot !A}$. In other194 words, in second-order logic we can define $\lnot$ using $\lforall$195 and~$\lif$.196\end{ex}197198\begin{prob}199 Show that in second-order logic $\lforall$ and~$\lif$ can define the other200 connectives:201 \begin{enumerate}202 \item Prove that in second-order logic $!A \land !B$ is equivalent203 to $\lforall[X][(!A \lif (!B \lif \lforall[x][X(x)])\lif204 \lforall[x][X(x)])]$.205 \item Find a second-order formula using only $\lforall$ and $\lif$206 equivalent to $!A \lor !B$.207 \end{enumerate}208\end{prob}209210\end{document}
content/second-order-logic/syntax-and-semantics/semantic-notions.tex
1% Part: second-order-logic2% Chapter: syntax-and-semantics3% Section: semantic-notions45\documentclass[../../../include/open-logic-section]{subfiles}67\begin{document}89\olfileid{sol}{syn}{sem}10\olsection{Semantic Notions}1112\begin{explain}13The central logical notions of \emph{validity}, \emph{entailment}, and14\emph{satisfiability} are defined the same way for second-order logic15as they are for first-order logic, except that the underlying16satisfaction relation is now that for second-order !!{formula}s. A17second-order !!{sentence}, of course, is !!a{formula} in which all18variables, including predicate and function variables, are bound.19\end{explain}2021\begin{defn}[Validity]22A sentence $!A$ is \emph{valid}, $\Entails !A$, iff $\Sat{M}{!A}$ for every23!!{structure}~$\Struct M$.24\end{defn}2526\begin{defn}[Entailment]27A set of sentences~$\Gamma$ \emph{entails} a sentence~$!A$, $\Gamma28\Entails !A$, iff for every !!{structure}~$\Struct M$ with29$\Sat{M}{\Gamma}$, $\Sat{M}{!A}$.30\end{defn}3132\begin{defn}[Satisfiability]33A set of sentences~$\Gamma$ is \emph{satisfiable} if $\Sat{M}{\Gamma}$34for some !!{structure}~$\Struct M$. If $\Gamma$ is not satisfiable it is35called \emph{unsatisfiable}.36\end{defn}3738\end{document}
content/second-order-logic/syntax-and-semantics/expressive-power.tex
1% Part: second-order-logic2% Chapter: syntax-and-semantics3% Section: expressive-power45\documentclass[../../../include/open-logic-section]{subfiles}67\begin{document}89\olfileid{sol}{syn}{exp}10\olsection{Expressive Power}1112\begin{explain}13Quantification over second-order variables is responsible for an14immense increase in the expressive power of the language over that of15first-order logic. Second-order existential quantification lets us16say that functions or relations with certain properties exist. In17first-order logic, the only way to do that is to specify a non-logical18symbol (i.e., !!a{function} or !!{predicate}) for this19purpose. Second-order universal quantification lets us say that all20subsets of, relations on, or functions from the !!{domain} to the21!!{domain} have a property. In first-order logic, we can only say22that the subsets, relations, or functions assigned to one of the23non-logical symbols of the language have a property. And when we say24that subsets, relations, functions exist that have a property, or that25all of them have it, we can use second-order quantification in26specifying this property as well. This lets us define relations not27definable in first-order logic, and express properties of the domain28not expressible in first-order logic.29\end{explain}3031\begin{defn}32If $\Struct{M}$ is !!a{structure} for a language~$\Lang{L}$, a33relation~$R \subseteq \Domain{M}^2$ is \emph{definable} in~$\Lang{L}$34if there is some !!{formula}~$!A_R(x, y)$ with only the variables $x$35and~$y$ free, such that $R(a, b)$ holds (i.e., $\tuple{a,b} \in R$)36iff $\Sat{M}{!A_R(x, y)}[s]$ for $s(x) = a$ and $s(y) = b$.37\end{defn}3839\begin{ex}40In first-order logic we can define the identity41relation~$\Id{\Domain{M}}$ (i.e., $\Setabs{\tuple{a,a}}{a \in42 \Domain{M}}$) by the formula $\eq[x][y]$. In43second-order logic, we can define this relation44\emph{without~$\eq$}. For if $a$ and $b$ are the same !!{element}45of~$\Domain{M}$, then they are !!{element}s of the same subsets46of~$\Domain{M}$ (since sets are determined by their47!!{element}s). Conversely, if $a$ and $b$ are different, then they are48not !!{element}s of the same subsets: e.g., $a \in \{a\}$ but $b49\notin \{a\}$ if $a \neq b$. So ``being !!{element}s of the same50subsets of~$\Domain{M}$'' is a relation that holds of $a$ and $b$ iff51$a = b$. It is a relation that can be expressed in second-order logic,52since we can quantify over all subsets of~$\Domain{M}$. Hence, the53following !!{formula} defines $\Id{\Domain{M}}$:54\[55\lforall[X][(X(x) \liff X(y))]56\]57\end{ex}5859\begin{prob}60Show that $\lforall[X][(X(x) \lif X(y))]$ (note:61$\lif$ not~$\liff$!) defines $\Id{\Domain{M}}$.62\end{prob}6364\begin{ex}65If $R$ is a two-place !!{predicate}, $\Assign{R}{M}$ is a two-place66relation on~$\Domain{M}$. Perhaps somewhat confusingly, we'll use $R$67as the !!{predicate} for~$R$ and for the relation~$\Assign{R}{M}$68itself. The \emph{transitive closure}~$R^*$ of~$R$ is the relation69that holds between $a$ and $b$ iff for some $c_1$, \dots, $c_k$,70$R(a,c_1)$, $R(c_1, c_2)$, \dots, $R(c_k,b)$ holds. This includes the71case if $k = 0$, i.e., if $R(a,b)$ holds, so does $R^*(a,b)$. This72means that $R \subseteq R^*$. In fact, $R^*$ is the smallest relation73that includes~$R$ and that is transitive. We can say in second-order74logic that $X$ is a transitive relation that includes~$R$:75\begin{multline*}76 !B_R(X) \ident \lforall[x][\lforall[y][(R(x,y) \lif X(x, y))]] \land {}\\77\lforall[x][\lforall[y][\lforall[z][((X(x,y) \land X(y,z)) \lif X(x,78 z))]]].79\end{multline*}80The first conjunct says that $R \subseteq X$ and the second81that $X$ is transitive.8283To say that $X$ is the smallest such relation is to say that it is84itself included in every relation that includes $R$ and is85transitive. So we can define the transitive closure of~$R$ by the86!!{formula}87\[88R^*(X) \ident !B_R(X) \land \lforall[Y][(!B_R(Y) \lif89 \lforall[x][\lforall[y][(X(x, y) \lif Y(x,y))]])].90\]91We have $\Sat{M}{R^*(X)}[s]$ iff $s(X) = R^*$. The transitive closure92of~$R$ cannot be expressed in first-order logic.93\end{ex}9495\end{document}
content/second-order-logic/syntax-and-semantics/inf-count.tex
1% Part: second-order-logic2% Chapter: syntax-and-semantics3% Section: size-of-domain45\documentclass[../../../include/open-logic-section]{subfiles}67\begin{document}89\olfileid{sol}{syn}{siz}1011\olsection{Describing Infinite and \usetoken{S}{enumerable}12 \usetoken{P}{domain}}1314A set~$M$ is (Dedekind) infinite iff there is !!a{injective} function~$f\colon M15\to M$ which is not !!{surjective}, i.e., with $\ran{f} \neq M$. In16first-order logic, we can consider a one-place !!{function}~$f$ and17say that the function~$\Assign{f}{M}$ assigned to it in18!!a{structure}~$\Struct{M}$ is !!{injective} and $\ran{f} \neq19\Domain{M}$:20\[21\lforall[x][\lforall[y][(\eq[f(x)][f(y)] \to \eq[x][y])]] \land22\lexists[y][\lforall[x][\eq/[y][f(x)]]].23\]24If $\Struct{M}$ satisfies this !!{sentence}, $\Assign{f}{M}:25\Domain{M} \to \Domain{M}$ is !!{injective}, and so $\Domain{M}$ must26be infinite. If $\Domain{M}$ is infinite, and hence such a function27exists, we can let $\Assign{f}{M}$ be that function and $\Struct{M}$28will satisfy the !!{sentence}. However, this requires that our language29contains the non-logical symbol~$f$ which we use for this purpose. In30second-order logic, we can simply say that such a function31\emph{exists}. This no-longer requires~$f$, and we obtain the32!!{sentence} in pure second-order logic33\[34\fn{Inf} \ident \lexists[u][(\lforall[x][\lforall[y][(\eq[u(x)][u(y)]35 \lif \eq[x][y])]] \land \lexists[y][\lforall[x][\eq/[y][u(x)]]])].36\]37$\Sat{M}{\fn{Inf}}$ iff $\Domain{M}$ is infinite. We can then define38$\fn{Fin} \ident \lnot \fn{Inf}$; $\Sat{M}{\fn{Fin}}$ iff $\Domain{M}$39is finite. No single !!{sentence} of pure first-order logic can40express that the !!{domain} is infinite although an infinite set of41them can. There is no set of !!{sentence}s of pure first-order logic42that is satisfied in !!a{structure} iff its domain is finite.4344\begin{prop}45$\Sat{M}{\fn{Inf}}$ iff $\Domain{M}$ is infinite.46\end{prop}4748\begin{proof}49$\Sat{M}{\fn{Inf}}$ iff50 $\Sat{M}{\lforall[x][\lforall[y][(\eq[u(x)][u(y)] \lif \eq[x][y])]]51 \land \lexists[y][\lforall[x][\eq/[y][u(x)]]]}[s]$ for52 some~$s$. If it does, $s(u)$ is !!a{injective} function, and some $y53 \in \Domain{M}$ is not in the range of~$s(u)$. Conversely, if there54 is !!a{injective} $f\colon \Domain{M} \to \Domain{M}$ with $\ran{f}55 \neq \Domain{M}$, then $s(u) = f$ is such a variable56 assignment.57\end{proof}5859A set $M$ is !!{enumerable} if there is an enumeration60\[61m_0, m_1, m_2, \dots62\]63of its !!{element}s (without repetitions but possibly finite). Such an enumeration exists64iff there is !!a{element} $z \in M$ and a function $f\colon M \to M$65such that $z$, $f(z)$, $f(f(z))$, \dots, are all the !!{element}s of~$M$. For66if the enumeration exists, $z = m_0$ and $f(m_k) = m_{k+1}$ (or67$f(m_k) = m_k$ if $m_k$ is the last !!{element} of the enumeration)68are the requisite !!{element} and function. On the other hand, if such69a $z$ and $f$ exist, then $z$, $f(z)$, $f(f(z))$, \dots, is an70enumeration of~$M$, and $M$ is !!{enumerable}. We can express the71existence of $z$ and~$f$ in second-order logic to produce a72!!{sentence} true in !!a{structure} iff the !!{structure} is73!!{enumerable}:74\[75\fn{Count} \ident76\lexists[z][\lexists[u][\lforall[X][((X(z) \land77 \lforall[x][(X(x) \lif X(u(x)))]) \lif \lforall[x][X(x)])]]]78\]7980\begin{prop}81$\Sat{M}{\fn{Count}}$ iff $\Domain{M}$ is !!{enumerable}.82\end{prop}8384\begin{proof}85Suppose $\Domain{M}$ is !!{enumerable}, and let $m_0$, $m_1$, \dots, be an86enumeration. By removing repetitions we can guarantee that no $m_k$87appears twice. Define $f(m_k) = m_{k+1}$ and let $s(z) = m_0$ and88$s(u) = f$. We show that89\[90\Sat{M}{\lforall[X][((X(z) \land \lforall[x][(X(x) \lif X(u(x)))])91 \lif \lforall[x][X(x)])]}[s]92\]93Suppose $M \subseteq \Domain{M}$ is arbitrary. Suppose further that94$\Sat{M}{(X(z) \land \lforall[x][(X(x) \lif95X(u(x)))])}[\Subst{s}{M}{X}]$. Then $\Subst{s}{M}{X}(z) \in M$ and96whenever $x \in M$, also $(\Subst{s}{M}{X}(u))(x) \in M$. In other97words, since $\varAssign{\Subst{s}{M}{X}}{s}{X}$, $m_0 \in M$ and if98$x \in M$ then $f(x) \in M$, so $m_0 \in M$, $m_1 = f(m_0) \in M$,99$m_2 = f(f(m_0)) \in M$, etc. Thus, $M = \Domain{M}$, and so100$\Sat{M}{\lforall[x][X(x)]}[\Subst{s}{M}{X}]$. Since $M \subseteq101\Domain{M}$ was arbitrary, we are done:102$\Sat{M}{\fn{Count}}$.103104Now assume that $\Sat{M}{\fn{Count}}$, i.e., 105\[106\Sat{M}{\lforall[X][((X(z) \land \lforall[x][(X(x) \lif X(u(x)))])107 \lif \lforall[x][X(x)])]}[s]108\]109for some~$s$. Let $m = s(z)$ and $f = s(u)$ and consider $M = \{m,110f(m), f(f(m)), \dots\}$. $M$ so defined is clearly !!{enumerable}.111Then112\[113\Sat{M}{(X(z) \land \lforall[x][(X(x) \lif X(u(x)))])114 \lif \lforall[x][X(x)]}[\Subst{s}{M}{X}]115\]116by assumption. Also, $\Sat{M}{X(z)}[\Subst{s}{M}{X}]$ since $M \ni m =117\Subst{s}{M}{X}(z)$, and also $\Sat{M}{\lforall[x][(X(x) \lif118X(u(x)))]}[\Subst{s}{M}{X}]$ since whenever $x \in M$ also $f(x) \in119M$. So, since both antecedent and conditional are satisfied, the120consequent must also be: $\Sat{M}{\lforall[x][X(x)]}[\Subst{s}{M}{X}]$. But that121means that $M = \Domain{M}$, and so $\Domain{M}$ is !!{enumerable}122since $M$ is, by definition.123\end{proof}124125\begin{prob}126The !!{sentence} $\fn{Inf} \land \fn{Count}$ is true in all and only127!!{denumerable} domains. Adjust the definition of $\fn{Count}$ so128that it becomes a different !!{sentence} that directly expresses that129the domain is !!{denumerable}, and prove that it does.130\end{prob}131132\end{document}133