content/incompleteness/arithmetization-syntax/arithmetization-syntax.tex
1% Part: incompleteness2% Chapter: arithmetization-syntax34\documentclass[../../../include/open-logic-chapter]{subfiles}56\begin{document}78\olchapter{inc}{art}{Arithmetization of Syntax}910\begin{editorial}11 Note that arithmetization for signed tableaux is not yet available.12\end{editorial}1314\olimport{introduction}1516\olimport{coding-symbols}1718\olimport{coding-terms}1920\olimport{coding-formulas}2122\olimport{substitution}2324\iftag{prfSC}{%25 \olimport{proofs-in-lk}26}{}2728\iftag{prfND}{%29 \olimport{proofs-in-nd}30}{}3132\iftag{prfAX}{33 \olimport{proofs-in-ax}34}{}3536\OLEndChapterHook3738\end{document}
content/incompleteness/arithmetization-syntax/introduction.tex
1% Part: incompleteness2% Chapter: arithmetization-syntax3% Section: introduction45\documentclass[../../../include/open-logic-section]{subfiles}67\begin{document}89\olfileid{inc}{art}{int}10\olsection{Introduction}1112In order to connect computability and logic, we need a way to talk13about the objects of logic (symbols, terms, !!{formula}s,14!!{derivation}s), operations on them, and their properties and15relations, in a way amenable to computational treatment. We can do16this directly, by considering computable functions and relations on17symbols, sequences of symbols, and other objects built from them.18Since the objects of logical syntax are all finite and built from19!!a{enumerable} sets of symbols, this is possible for some models of20computation. But other models of computation---such as the recursive21functions----are restricted to numbers, their relations and functions.22Moreover, ultimately we also want to be able to deal with syntax23within certain theories, specifically, in theories formulated in the24language of arithmetic. In these cases it is necessary to25\emph{arithmetize} syntax, i.e., to represent syntactic objects,26operations on them, and their relations, as numbers, arithmetical27functions, and arithmetical relations, respectively. The idea, which28goes back to Leibniz, is to assign numbers to syntactic objects.2930It is relatively straightforward to assign numbers to symbols as their31``codes.'' Some symbols pose a bit of a challenge, since, e.g., there32are infinitely many !!{variable}s, and even infinitely many33!!{function}s of each arity~$n$. But of course it's possible to assign34numbers to symbols systematically in such a way that, say, $\Obj v_2$35and $\Obj v_3$ are assigned different codes. Sequences of symbols36(such as terms and !!{formula}s) are a bigger challenge. But if we can37deal with sequences of numbers purely arithmetically (e.g., by the38powers-of-primes coding of sequences), we can extend the coding of39individual symbols to coding of sequences of symbols, and then further40to sequences or other arrangements of !!{formula}s, such as41!!{derivation}s. This extended coding is called ``G\"odel numbering.''42Every term, !!{formula}, and !!{derivation} is assigned a G\"odel43number.4445By coding sequences of symbols as sequences of their codes, and by46choosing a system of coding sequences that can be dealt with using47computable functions, we can then also deal with G\"odel numbers using48computable functions. In practice, all the relevant functions will be49primitive recursive. For instance, computing the length of a sequence50and computing the $i$-th element of a sequence from the code of the51sequence are both primitive recursive. If the number coding the52sequence is, e.g., the G\"odel number of !!a{formula}~$!A$, we53immediately see that the length of !!a{formula} and the (code of the)54$i$-th symbol in !!a{formula} can also be computed from the G\"odel55number of~$!A$. It is a bit harder to prove that, e.g., the property56of being the G\"odel number of a correctly formed term or of a correct57!!{derivation} is primitive recursive. It is nevertheless possible,58because the sequences of interest (terms, !!{formula}s,59!!{derivation}s) are inductively defined.6061As an example, consider the operation of substitution. If $!A$ is a62formula, $x$ a variable, and $t$ a term, then $\Subst{!A}{t}{x}$ is63the result of replacing every free occurrence of~$x$ in~$!A$ by~$t$.64Now suppose we have assigned G\"odel numbers to $!A$, $x$, $t$---say,65$k$, $l$, and $m$, respectively. The same scheme assigns a G\"odel66number to $\Subst{!A}{t}{x}$, say,~$n$. This mapping---of $k$, $l$,67and $m$ to $n$---is the arithmetical analog of the substitution68operation. When the substitution operation maps $!A$, $x$, $t$ to69$\Subst{!A}{t}{x}$, the arithmetized substitution functions maps the70G\"odel numbers $k$, $l$, $m$ to the G\"odel number~$n$. We will see71that this function is primitive recursive.7273Arithmetization of syntax is not just of abstract interest, although74it was originally a non-trivial insight that languages like the75language of arithmetic, which do not come with mechanisms for76``talking about'' languages can, after all, formalize complex77properties of expressions. It is then just a small step to ask what a78theory in this language, such as Peano arithmetic, can \emph{prove}79about its own language (including, e.g., whether !!{sentence}s are80provable or true). This leads us to the famous limitative theorems of81G\"odel (about unprovability) and Tarski (the undefinability of82truth). But the trick of arithmetizing syntax is also important in83order to prove some important results in computability theory, e.g.,84about the computational power of theories or the relationship between85different models of computability. The arithmetization of syntax86serves as a model for arithmetizing other objects and properties. For87instance, it is similarly possible to arithmetize configurations and88computations (say, of Turing machines). This makes it possible to89simulate computations in one model (e.g., Turing machines) in another90(e.g., recursive functions).9192\end{document}
content/incompleteness/arithmetization-syntax/coding-symbols.tex
1% Part: incompleteness2% Chapter: arithmetization-syntax3% Section: coding-symbols45\documentclass[../../../include/open-logic-section]{subfiles}67\begin{document}89\olfileid{inc}{art}{cod}10\olsection{Coding Symbols}1112The basic language~$\Lang L$ of first order logic makes use of the symbols13\[14\lfalse \quad \lnot \quad \lor \quad \land \quad \lif \quad \lforall15\quad \lexists \quad \eq \quad ( \quad ) \quad ,16\]17together with !!{enumerable} sets of variables and !!{constant}s, and18!!{enumerable} sets of !!{function}s and !!{predicate}s of arbitrary19arity. We can assign \emph{codes} to each of these symbols in such a20way that every symbol is assigned a unique number as its code, and no21two different symbols are assigned the same number. We know that this22is possible since the set of all symbols is !!{enumerable} and so23there is !!a{bijection} between it and the set of natural numbers.24But we want to make sure that we can recover the symbol (as well as25some information about it, e.g., the arity of !!a{function}) from its26code in a computable way. There are many possible ways of doing this,27of course. Here is one such way, which uses primitive recursive28functions. (Recall that $\tuple{n_0, \dots, n_k}$ is the number29coding the sequence of numbers $n_0$, \dots, $n_k$.)3031\begin{defn}32If $s$ is a symbol of~$\Lang L$, let the \emph{symbol code}~$\scode s$ be33defined as follows:34\begin{enumerate}35\item If $s$ is among the logical symbols, $\scode s$ is given by the36 following table:37\[38\begin{array}{cccccccccc}39 \lfalse & \lnot & \lor & \land & \lif & \lforall \\40\tuple{0, 0} & \tuple{0, 1} & \tuple{0, 2} & \tuple{0, 3} &41\tuple{0, 4} & \tuple{0, 5} \\42\lexists & \eq & ( & ) & ,\\43\tuple{0, 6} & \tuple{0, 7} &44\tuple{0, 8} & \tuple{0, 9} & \tuple{0, 10}45\end{array}46\]47\item If $s$ is the $i$-th variable $\Obj v_i$, then $\scode s = \tuple{1, i}$.48\item If $s$ is the $i$-th !!{constant}~$\Obj c_i$, then49 $\scode s = \tuple{2, i}$.50\item If $s$ is the $i$-th $n$-ary !!{function}~$\Obj f_i^n$, then51 $\scode s = \tuple{3, n, i}$.52\item If $s$ is the $i$-th $n$-ary !!{predicate}~$\Obj P_i^n$, then53 $\scode s = \tuple{4, n, i}$.54\end{enumerate}55\end{defn}5657\begin{prop}58The following relations are primitive recursive:59\begin{enumerate}60\item $\fn{Fn}(x, n)$ iff $x$ is the code of $\Obj f^n_i$ for61 some~$i$, i.e., $x$ is the code of an $n$-ary !!{function}.62\item $\fn{Pred}(x, n)$ iff $x$ is the code of $\Obj P^n_i$ for63 some~$i$ or $x$ is the code of $\eq$ and $n = 2$, i.e., $x$ is the64 code of an $n$-ary !!{predicate}.65\end{enumerate}66\end{prop}6768\begin{defn}69If $s_0, \dots, s_{n-1}$ is a sequence of symbols, its \emph{G\"odel70 number} is $\tuple{\scode{s_0}, \dots, \scode{s_{n-1}}}$.71\end{defn}7273\begin{explain}74Note that \emph{codes} and \emph{G\"odel numbers} are different75things. For instance, the variable~$\Obj v_5$ has a code~$\scode{\Obj76 v_5} = \tuple{1, 5} = 2^2\cdot 3^6$. But the variable~$\Obj v_5$77considered as a term is also a sequence of symbols (of78length~$1$). The \emph{G\"odel number}~$\Gn{\Obj v_5}$ of the79\emph{term}~$\Obj v_5$ is $\tuple{\scode{\Obj v_5}} = 2^{\scode{\Obj80 v_5} + 1} = 2^{2^2\cdot 3^6 + 1}$.81\end{explain}8283\begin{ex}84Recall that if $k_0$, \dots, $k_{n-1}$ is a sequence of numbers, then85the code of the sequence $\tuple{k_0, \dots, k_{n-1}}$ in the86power-of-primes coding is87\[882^{k_0+1}\cdot3^{k_1+1}\cdot \dots \cdot p_{n-1}^{k_{n-1}+1},89\]90where $p_i$ is the $i$-th prime (starting with $p_0 = 2$). So for91instance, the formula $\eq[\Obj v_0][\Obj 0]$, or, more explicitly,92${\eq}(\Obj v_0,\Obj c_0)$, has the G\"odel number93\[94\tuple{\scode{\eq},\scode{(},\scode{\Obj v_0},\scode{,}, \scode{\Obj95 c_0},\scode{)}}.96\]97Here, $\scode{\eq}$ is $\tuple{0,7} = 2^{0+1}\cdot983^{7+1}$, $\scode{\Obj v_0}$ is $\tuple{1,0} = 2^{1+1}\cdot3^{0+1}$,99etc. So $\Gn{=(\Obj v_0,\Obj c_0)}$ is100\begin{multline*}1012^{\scode{=} + 1}\cdot 3^{\scode{(}+1}\cdot 5^{\scode{\Obj v_0}+1}102\cdot 7^{\scode{,} + 1} \cdot 11^{\scode{\Obj c_0}+1} \cdot10313^{\scode{)}+1} = \\1042^{2^1\cdot 3^8 + 1}\cdot 3^{2^1\cdot 3^9+1}\cdot 5^{2^2\cdot 3^1+1}105\cdot 7^{2^1\cdot 3^{11} + 1} \cdot 11^{2^3\cdot3^1+1} \cdot10613^{2^1\cdot3^{10}+1} = \\1072^{13\,123}\cdot 3^{39\,367}\cdot 5^{13}\cdot 7^{354\,295}\cdot11^{25}\cdot13^{118\,099}.108\end{multline*}109\end{ex}110111\end{document}
content/incompleteness/arithmetization-syntax/coding-terms.tex
1% Part: incompleteness2% Chapter: arithmetization-syntax3% Section: coding-terms45\documentclass[../../../include/open-logic-section]{subfiles}67\begin{document}89\olfileid{inc}{art}{trm}10\olsection{Coding Terms}1112\begin{explain}13A term is simply a certain kind of sequence of symbols: it is built up14inductively from constants and variables according to the formation15rules for terms. Since sequences of symbols can be coded as16numbers---using a coding scheme for the symbols plus a way to code17sequences of numbers---assigning G\"odel numbers to terms is not18difficult. The challenge is rather to show that the property a number19has if it is the G\"odel number of a correctly formed term is20computable, or in fact primitive recursive.21\end{explain}2223!!^{variable}s and !!{constant}s are the simplest terms, and testing24whether $x$ is the G\"odel number of such a term is easy:25$\fn{Var}(x)$ holds if $x$ is $\Gn{\Obj v_i}$ for some~$i$. In other words,26$x$~is a sequence of length~$1$ and its single element $(x)_0$ is the27code of some !!{variable}~$\Obj v_i$, i.e., $x$ is $\tuple{\tuple{1, i}}$ for28some~$i$. Similarly, $\fn{Const}(x)$ holds if $x$ is $\Gn{\Obj c_i}$ for29some~$i$. Both of these relations are primitive recursive, since if30such an $i$ exists, it must be $< x$:31\begin{align*}32 \fn{Var}(x) & \defiff \bexists{i<x}{x = \tuple{\tuple{1, i}}}\\33 \fn{Const}(x) & \defiff \bexists{i<x}{x = \tuple{\tuple{2, i}}}34\end{align*}3536\begin{prop}37\ollabel{prop:term-primrec}38The relations $\fn{Term}(x)$ and $\fn{ClTerm}(x)$ which hold iff $x$39is the G\"odel number of a term or a closed term, respectively, are40primitive recursive.41\end{prop}4243\begin{proof}44A sequence of symbols~$s$ is a term iff there is a sequence~$s_0$,45\dots, $s_{k-1} = s$ of terms which records how the term~$s$ was formed46from !!{constant}s and !!{variable}s according to the formation rules47for terms. To express that such a putative formation sequence follows48the formation rules it has to be the case that, for each $i < k$, either49\begin{enumerate}50\item $s_i$ is !!a{variable}~$\Obj v_j$, or51\item $s_i$ is !!a{constant}~$\Obj c_j$, or52\item $s_i$ is built from $n$ terms $t_1$, \dots, $t_n$ occurring53 prior to place~$i$ using an $n$-place !!{function}~$\Obj f^n_j$.54\end{enumerate}55To show that the corresponding relation on G\"odel numbers is56primitive recursive, we have to express this condition primitive57recursively, i.e., using primitive recursive functions, relations, and58bounded quantification.5960Suppose $y$ is the number that codes the sequence $s_0$, \dots, $s_{k-1}$,61i.e., $y = \tuple{\Gn{s_0}, \dots, \Gn{s_{k-1}}}$. It codes a formation62sequence for the term with G\"odel number~$x$ iff for all $i < k$:63\begin{enumerate}64\item $\fn{Var}((y)_i)$, or65\item $\fn{Const}((y)_i)$, or66\item there is an $n$ and a number~$z = \tuple{z_1, \dots, z_n}$ such67 that each $z_l$ is equal to some $(y)_{i'}$ for $i' < i$ and68\[69(y)_i = \Gn{\Obj f^n_j(} \concat \fn{flatten}(z) \concat \Gn{)},70\]71\end{enumerate}72and moreover $(y)_{k-1} = x$. (The function $\fn{flatten}(z)$ turns73the sequence $\tuple{\Gn{t_1}, \dots, \Gn{t_n}}$ into $\Gn{t_1, \dots,74 t_n}$ and is primitive recursive.)7576The indices $j$, $n$, the G\"odel numbers $z_l$ of the terms $t_l$,77and the code~$z$ of the sequence~$\tuple{z_1, \dots, z_n}$, in (3) are78all less than~$y$. We can replace $k$ above with $\len{y}$. Hence we79can express ``$y$ is the code of a formation sequence of the term with80G\"odel number~$x$'' in a way that shows that this relation is81primitive recursive.8283We now just have to convince ourselves that there is a primitive84recursive bound on~$y$. But if $x$ is the G\"odel number of a term,85it must have a formation sequence with at most $\len{x}$ terms (since86every term in the formation sequence of~$s$ must start at some place87in~$s$, and no two subterms can start at the same place). The G\"odel88number of each subterm of~$s$ is of course $\le x$. Hence, there89always is a formation sequence with code $\le p_{k-1}^{k(x+1)}$, where90$k=\len{x}$.9192For $\fn{ClTerm}$, simply leave out the clause for !!{variable}s.93\end{proof}9495\begin{prob}96Show that the function $\fn{flatten}(z)$, which turns the sequence97$\tuple{\Gn{t_1}, \dots, \Gn{t_n}}$ into $\Gn{t_1, \dots, t_n}$, is98primitive recursive.99\end{prob}100101\begin{prop}\ollabel{prop:num-primrec}102 The function $\fn{num}(n) = \Gn{\num{n}}$ is primitive recursive.103\end{prop}104105\begin{proof}106 We define $\fn{num}(n)$ by primitive recursion:107 \begin{align*}108 \fn{num}(0) & = \Gn{\Obj 0}\\109 \fn{num}(n+1) & = \Gn{\prime(} \concat \fn{num}(n) \concat \Gn{)}.110 \end{align*}111\end{proof}112113\end{document}
content/incompleteness/arithmetization-syntax/coding-formulas.tex
1% Part: incompleteness2% Chapter: arithmetization-syntax3% Section: coding-formulas45\documentclass[../../../include/open-logic-section]{subfiles}67\begin{document}89\olfileid{inc}{art}{frm}10\olsection{Coding \printtoken{P}{formula}}1112Once we have defined the relation $\fn{Term}(x)$ primitive13recursively, we can use it to define the corresponding relation for14!!{formula}s, $\fn{Frm}(x)$ primitive recursively.1516\begin{prop}17The relation $\fn{Atom}(x)$ which holds iff $x$ is the G\"odel number18of an atomic !!{formula}, is primitive recursive.19\end{prop}2021\begin{proof}22The number $x$ is the G\"odel number of an atomic !!{formula} iff23one of the following holds:24\begin{enumerate}25\item There are $n$, $j < x$, and $z < x$ such that for each $i < n$,26 $\fn{Term}((z)_i)$ and $x = $27\[28\Gn{\Obj P^n_j(} \concat \fn{flatten}(z) \concat \Gn{)}.29\]30\item There are $z_1, z_2 < x$ such that $\fn{Term}(z_1)$,31 $\fn{Term}(z_2)$, and $x = $32\[33\Gn{{\eq}(} \concat z_1 \concat \Gn{,} \concat z_2 \concat{\Gn{)}}.34\]35 \tagitem{prvFalse}{$x = \Gn{\lfalse}$.}{}36 \tagitem{prvTrue}{$x = \Gn{\ltrue}$.}{}37\end{enumerate}38\end{proof}3940\begin{prop}41\ollabel{prop:frm-primrec}42The relation $\fn{Frm}(x)$ which holds iff $x$ is the G\"odel number43of !!a{formula} is primitive recursive.44\end{prop}4546\begin{proof}47A sequence of symbols~$s$ is !!a{formula} iff there is formation48sequence~$s_0$, \dots, $s_{k-1} = s$ of !!{formula} which records49how~$s$ was formed from atomic !!{formula}s according to the50formation rules. The code for each $s_i$ (and indeed of the code of51the sequence $\tuple{s_0, \dots, s_{k-1}}$) is less than the code~$x$52of~$s$.53\end{proof}5455\begin{prob}56Give a detailed proof of \olref[inc][art][frm]{prop:frm-primrec} along57the lines of the first proof of58\olref[inc][art][trm]{prop:term-primrec}.59\end{prob}6061\begin{prop}62\ollabel{prop:freeocc-primrec}63The relation $\fn{FreeOcc}(x, z, i)$, which holds iff the $i$-th64symbol of the formula with G\"odel number~$x$ is a free occurrence of65the variable with G\"odel number~$z$, is primitive recursive.66\end{prop}6768\begin{proof}69Exercise.70\end{proof}7172\begin{prob}73Prove \olref[inc][art][frm]{prop:freeocc-primrec}. You may make use74of the fact that any substring of !!a{formula} which is !!a{formula}75is a sub-!!{formula} of it.76\end{prob}7778\begin{prop}79The property $\fn{Sent}(x)$ which holds iff $x$~is the G\"odel80number of !!a{sentence} is primitive recursive.81\end{prop}8283\begin{proof}84A !!{sentence} is !!a{formula} without free occurrences of85!!{variable}s. So $\fn{Sent}(x)$ holds iff86\begin{multline*}87\bforall{i<\len{x}}{\bforall{z<x}{}}\\88(\bexists{j<z}{z=\Gn{\Obj v_j}} \lif \lnot\fn{FreeOcc}(x,z,i)).89\end{multline*}90\end{proof}919293\end{document}
content/incompleteness/arithmetization-syntax/substitution.tex
1% Part: incompleteness2% Chapter: arithmetization-syntax3% Section: substitution45\documentclass[../../../include/open-logic-section]{subfiles}67\begin{document}89\olfileid{inc}{art}{sub}10\olsection{Substitution}1112Recall that substitution is the operation of replacing all free13occurrences of !!a{variable}~$u$ in !!a{formula}~$!A$ by a term~$t$,14written $\Subst{!A}{t}{u}$. This operation, when carried out on15G\"odel numbers of !!{variable}s, !!{formula}s, and terms, is16primitive recursive.1718\begin{prop}\ollabel{prop:subst-primrec}19There is a primitive recursive function $\fn{Subst}(x, y, z)$ with the20property that21\[22\fn{Subst}(\Gn{!A}, \Gn{t}, \Gn{u}) = \Gn{\Subst{!A}{t}{u}}.23\]24\end{prop}2526\begin{proof}27We can then define a function $\fn{hSubst}$ by primitive recursion as28follows:29\begin{multline*}30\begin{aligned}31\fn{hSubst}(x, y, z, 0) & = \emptyseq \\32\fn{hSubst}(x, y, z, i+1) & =33\end{aligned}\\34\begin{cases}35\fn{hSubst}(x, y, z, i) \concat y & \text{if $\fn{FreeOcc}(x, z, i)$} \\36\fn{append}(\fn{hSubst}(x, y, z, i), (x)_{i}) & \text{otherwise.}37\end{cases}38\end{multline*}39$\fn{Subst}(x, y, z)$ can now be defined as $\fn{hSubst}(x, y, z, \len{x})$.40\end{proof}4142\begin{prop}43\ollabel{prop:free-for}44The relation $\fn{FreeFor}(x, y, z)$, which holds iff the term with45G\"odel number~$y$ is !!{free for} the variable with G\"odel46number~$z$ in the formula with G\"odel number~$x$, is primitive47recursive.48\end{prop}4950\begin{proof} Exercise. \end{proof}5152\begin{prob}53Prove \olref[inc][art][sub]{prop:free-for}54\end{prob}5556\end{document}
content/incompleteness/arithmetization-syntax/proofs-in-lk.tex
1% Part: incompleteness2% Chapter: arithmetization-syntax3% Section: proofs-in-lk45\documentclass[../../../include/open-logic-section]{subfiles}67\begin{document}89\olfileid{inc}{art}{plk}10\olsection{\usetoken{P}{derivation} in $\Log{LK}$}1112\begin{explain}13In order to arithmetize !!{derivation}s, we must represent14!!{derivation}s as numbers. Since !!{derivation}s are trees of sequents15where each inference carries also a label, a recursive16representation is the most obvious approach: we represent a17!!{derivation} as a tuple, the components of which are the18end-sequent, the label, and the representations of the19sub-!!{derivation}s leading to the premises of the last inference.20\end{explain}2122\begin{defn}23If $\Gamma$ is a finite sequence of !!{sentence}s, $\Gamma =24\tuple{!A_1, \dots, !A_n}$, then $\Gn{\Gamma} = \tuple{\Gn{!A_1},25 \dots, \Gn{!A_n}}$.2627If $\Gamma \Sequent \Delta$ is a sequent, then a G\"odel number of28$\Gamma \Sequent \Delta$ is29\[30\Gn{\Gamma \Sequent \Delta} = \tuple{\Gn{\Gamma}, \Gn{\Delta}}31\]3233If $\pi$ is !!a{derivation} in $\Log{LK}$, then $\Gn{\pi}$ is defined34as follows:35\begin{enumerate}36\item If $\pi$ consists only37 of the initial sequent $\Gamma \Sequent \Delta$, then $\Gn{\pi}$ is 38 \[39 \tuple{0, \Gn{\Gamma \Sequent \Delta}}.40 \]41\item If $\pi$ ends in an inference with one or two premises, has42 $\Gamma \Sequent \Delta$ as its conclusion, and $\pi_1$ and $\pi_2$ are the immediate subproof ending43 in the premise of the last inference, then $\Gn{\pi}$ is 44 \begin{align*}45 & \tuple{1, \Gn{\pi_1}, \Gn{\Gamma \Sequent \Delta}, k} \text{ or}\\ 46 & \tuple{2, \Gn{\pi_1}, \Gn{\pi_2}, \Gn{\Gamma \Sequent \Delta}, k}, 47 \end{align*}48 respectively, where $k$ is given by the following table according to49 which rule was used in the last inference:5051 \begin{tabular}{lccccccc}52 \text{Rule:} & \LeftR{\Weakening} & \RightR{\Weakening} &53 \LeftR{\Contraction} & \RightR{\Contraction} &54 \LeftR{\Exchange} & \RightR{\Exchange} \\55 $k$: & 1 & 2 & 3 & 4 & 5 & 6 \\[2ex]56 \text{Rule:} & \LeftR{\lnot} & \RightR{\lnot} &57 \LeftR{\land} & \RightR{\land} & 58 \LeftR{\lor} & \RightR{\lor} \\59 $k$: & 7 & 8 & 9 & 10 & 11 & 12 \\[2ex]60 \text{Rule:} & \LeftR{\lif} & \RightR{\lif} &61 \LeftR{\lforall} & \RightR{\lforall} &62 \LeftR{\lexists} & \RightR{\lexists} \\63 $k$: & 13 & 14 & 15 & 16 & 17 & 18 \\[2ex]64 \text{Rule:} & \Cut & = \\65 $k$: & 19 & 2066 \end{tabular}67\end{enumerate}68\end{defn}6970\begin{ex}71 Consider the very simple !!{derivation}72 \begin{prooftree}73 \Axiom$!A \fCenter !A$74 \RightLabel{\LeftR{\land}}75 \UnaryInf$!A \land !B \fCenter !A$76 \RightLabel{\RightR{\lif}}77 \UnaryInf$\fCenter (!A \land !B) \lif !A$78 \end{prooftree}79 The G\"odel number of the initial sequent would be $p_0 = \tuple{0,80 \Gn{!A \Sequent !A}}$. The G\"odel number of the !!{derivation}81 ending in the conclusion of~$\LeftR{\land}$ would be $p_1 =82 \tuple{1, p_0, \Gn{!A \land !B \Sequent !A}, 9}$ ($1$ since83 $\LeftR{\land}$ has one premise, the G\"odel number of the84 conclusion~$!A \land !B \Sequent !A$, and $9$ is the number coding85 $\LeftR{\land}$). The G\"odel number of the entire !!{derivation} then86 is $\tuple{1, p_1, \Gn{\Sequent (!A \land !B) \lif !A)}, 14}$, i.e.,87 \[88 \tuple{1, \tuple{1, \tuple{0, \Gn{!A \Sequent !A)}}, \Gn{!A \land !B \Sequent !A}, 9},89 \Gn{\Sequent (!A \land !B) \lif !A}, 14}.90 \]91\end{ex}9293\begin{explain}94Having settled on a representation of !!{derivation}s, we must also95show that we can manipulate such !!{derivation}s primitive recursively,96and express their essential properties and relations so. Some97operations are simple: e.g., given a G\"odel number~$p$ of98!!a{derivation}, $\fn{EndSeq}(p) = (p)_{(p)_0+1}$ gives us the G\"odel99number of its end-sequent and $\fn{LastRule}(p) = (p)_{(p)_0+2}$ the100code of its last rule. The property $\fn{Sequent}(s)$ defined by101\[102 \len{s} = 2 \land \bforall{i<\len{(s)_0} + \len{(s)_1}}{\fn{Sent}(((s)_0 \concat (s)_1)_i)}103\]104holds of $s$ iff $s$ is the G\"odel number of a sequent consisting of105!!{sentence}s. Some are much harder. We'll at least sketch how to do106this. The goal is to show that the relation ``$\pi$ is107!!a{derivation} of~$!A$ from~$\Gamma$'' is a primitive recursive108relation of the G\"odel numbers of $\pi$ and~$!A$.109\end{explain}110111\begin{prop}\ollabel{prop:followsby}112 The property $\fn{Correct}(p)$ which holds iff the last inference in113 the !!{derivation}~$\pi$ with G\"odel number~$p$ is correct, is114 primitive recursive.115\end{prop}116117\begin{proof}118 $\Gamma \Sequent \Delta$ is an initial sequent if either there119 is !!a{sentence}~$!A$ such that $\Gamma \Sequent \Delta$ is $!A120 \Sequent !A$, or there is a term~$t$ such that $\Gamma \Sequent121 \Delta$ is $\emptyset \Sequent \eq[t][t]$. In terms of G\"odel122 numbers, $\fn{InitSeq}(s)$ holds iff123 \begin{align*}124 \bexists{x < s}{} (\fn{Sent}(x) & \land125 s = \tuple{\tuple{x},\tuple{x}})126 \lor {}\\127 \bexists{t<s}{} (\fn{Term}(t) & \land128 s = \tuple{0, \tuple{\Gn{{\eq}(} \concat t \concat \Gn{,} \concat t \concat \Gn{)}}}).129 \end{align*}130131 We also have to show that for each rule of inference~$R$ the132 relation $\fn{FollowsBy}_R(p)$ is primitive recursive, where133 $\fn{FollowsBy}_R(p)$ holds iff $p$ is the G\"odel number of134 !!{derivation}~$\pi$, and the end-sequent of~$\pi$ follows135 by a correct application of~$R$ from the immediate136 sub-!!{derivation}s of~$\pi$.137138 A simple case is that of the \RightR{\land} rule. If $\pi$ ends in139 a correct $\RightR{\land}$ inference, it looks like this:140 \begin{prooftree}141 \AxiomC{}142 \RightLabel{$\pi_1$}143 \Deduce$\Gamma \fCenter \Delta, !A$144 145 \AxiomC{}146 \RightLabel{$\pi_2$}147 \Deduce$\Gamma \fCenter \Delta, !B$148149 \RightLabel{\RightR\land}150 \BinaryInf$\Gamma \fCenter \Delta, !A \land !B$151 \end{prooftree}152 So, the last inference in the !!{derivation} $\pi$153 is a correct application of $\RightR{\land}$ iff154 there are sequences of !!{sentence}s $\Gamma$ and $\Delta$155 as well as two !!{sentence}s $!A$ and~$!B$ such that156 the end-sequent of $\pi_1$ is $\Gamma \Sequent \Delta, !A$,157 the end-sequent of $\pi_2$ is $\Gamma \Sequent \Delta, !B$,158 and the end-sequent of $\pi$ is $\Gamma \Sequent \Delta, !A \land !B$.159 We just have to translate this into G\"odel160 numbers. If $s = \Gn{\Gamma \Sequent \Delta}$ then $(s)_0 =161 \Gn{\Gamma}$ and $(s)_1 = \Gn{\Delta}$. So,162 $\fn{FollowsBy}_{\RightR{\land}}(p)$ holds iff163\begin{align*}164& \bexists{g < p}{\bexists{d < p}{\bexists{a < p}{\bexists{b < p}{\quad}}}} \\165& \qquad \fn{EndSequent}(p) = 166 \tuple{g, d \concat 167 \tuple{\Gn{(} \concat a \concat \Gn{\land} \concat b \concat \Gn{)}}} \land {} \\168& \qquad \fn{EndSequent}((p)_1) = \tuple{g, d \concat \tuple{a}} \land {}\\169& \qquad \fn{EndSequent}((p)_2) = \tuple{g, d \concat \tuple{b}} \land {}\\170& \qquad (p)_0 = 2 \land \fn{LastRule}(p) = 10.171\end{align*}172The individual lines express, respectively, ``there is a173sequence~($\Gamma$) with G\"odel number~$g$, there is a174sequence~($\Delta$) with G\"odel number~$d$, !!a{formula}~($!A$) with175G\"odel number~$a$, and !!a{formula}~($!B$) with G\"odel number~$b$,''176such that ``the end-sequent of $\pi$ is $\Gamma \Sequent \Delta, !A177\land !B$,'' ``the end-sequent of $\pi_1$ is $\Gamma \Sequent \Delta,178!A$,'' ``the end-sequent of $\pi_2$ is $\Gamma \Sequent \Delta, !B$,''179and ``$\pi$ has two immediate subderivations and the last inference180rule is $\RightR\land$ (with number~$10$).''181182The last inference in~$\pi$ is a correct application of183$\RightR\lexists$ iff there are sequences $\Gamma$ and $\Delta$,184!!a{formula}~$!A$, a variable~$x$, and a term~$t$, such that185the end-sequent of $\pi$ is $\Gamma \Sequent \Delta, \lexists[x][!A]$186and the end-sequent of $\pi_1$ is $\Gamma \Sequent \Delta,187\Subst{!A}{t}{x}$. So in terms of G\"odel numbers, we have188$\fn{FollowsBy}_{\RightR\lexists}(p)$189iff190\begin{align*}191 & \bexists{g<p}{\bexists{d<p}{\bexists{a<p}{\bexists{x<p}{\bexists{t<p}{\quad}}}}}\\192 & \qquad \fn{EndSequent}(p) = 193 \tuple{194 g,195 d \concat \tuple{\Gn{\lexists} \concat x \concat a}196 } \land {}\\197 & \qquad \fn{EndSequent}((p)_1) = 198 \tuple{199 g,200 d \concat \tuple{\fn{Subst}(a, t, x)}201 } \land {}\\202 & \qquad (p)_0 = 1 \land \fn{LastRule}(p) = 18.203\end{align*}204We then define $\fn{Correct}(p)$ as205\begin{multline*}206 \fn{Sequent}(\fn{EndSequent}(p)) \land {}\\ 207 [(\fn{LastRule}(p) = 1 \land 208 \fn{FollowsBy}_{\LeftR\Weakening}(p)) \lor \dots \lor {}\\209 (\fn{LastRule}(p) = 20 \land \fn{FollowsBy}_{\eq}(p)) \lor {}\\210 (p)_0 = 0 \land \fn{InitialSeq}(\fn{EndSequent}(p))]211\end{multline*}212The first line ensures that the end-sequent of~$d$ is actually a213sequent consisting of !!{sentence}s. The last line covers the case214where $p$ is just an initial sequent.215\end{proof}216217\begin{prob}218 Define the following properties as in219 \olref[inc][art][plk]{prop:followsby}:220 \begin{enumerate}221 \item $\fn{FollowsBy}_{\Cut}(p)$,222 \item $\fn{FollowsBy}_{\LeftR\lif}(p)$,223 \item $\fn{FollowsBy}_{\eq}(p)$,224 \item $\fn{FollowsBy}_{\RightR{\lforall}}(p)$.225 \end{enumerate}226 For the last one, you will have to also show that you can test227 primitive recursively if the last inference of the228 !!{derivation} with G\"odel number~$p$ satisfies the eigenvariable229 condition, i.e., the eigenvariable~$a$ of the $\RightR{\lforall}$230 does not occur in the end-sequent.231 \end{prob}232 233234\begin{prop}235 \ollabel{prop:deriv}236 The relation $\fn{Deriv}(p)$ which holds if $p$ is the G\"odel237 number of a correct !!{derivation}~$\pi$, is primitive recursive.238\end{prop}239240\begin{proof}241 !!^a{derivation}~$\pi$ is correct if every one of its inferences242 is a correct application of a rule, i.e., if every one of its243 sub-!!{derivation}s ends in a correct inference. So, $\fn{Deriv}(d)$244 iff245 \[246 \bforall{i<\len{\fn{SubtreeSeq}(p)}}{\fn{Correct}((\fn{SubtreeSeq}(p))_i}.247 \]248\end{proof}249250251\begin{prop}252Suppose $\Gamma$ is a primitive recursive set of !!{sentence}s. Then253the relation $\Prf[\Gamma](x, y)$ expressing ``$x$ is the code of254!!a{derivation}~$\pi$ of $\Gamma_0 \Sequent !A$ for some finite255$\Gamma_0 \subseteq \Gamma$ and $y$ is the G\"odel number of~$!A$'' is256primitive recursive.257\end{prop}258259\begin{proof}260Suppose ``$y \in \Gamma$'' is given by the primitive recursive261predicate~$R_\Gamma(y)$. We have to show that $\Prf[\Gamma](x, y)$262which holds iff $y$ is the G\"odel number of a sentence~$!A$ and263$x$~is the code of an $\Log{LK}$-!!{derivation} with end-sequent264$\Gamma_0 \Sequent !A$ is primitive recursive.265266By the previous proposition, the property $\fn{Deriv}(x)$ which holds267iff $x$ is the code of a correct !!{derivation}~$\pi$ in $\Log{LK}$ is268primitive recursive. If $x$ is such a code, then $\fn{EndSequent}(x)$269is the code of the end-sequent of~$\pi$, and so270$(\fn{EndSequent}(x))_0$ is the code of the left side of the end271sequent and $(\fn{EndSequent}(x))_1$ the right side. So we can272express ``the right side of the end-sequent of~$\pi$ is~$!A$'' as273$\len{(\fn{EndSequent}(x))_1} = 1 \land ((\fn{EndSequent}(x))_1)_0 =274x$. The left side of the end-sequent of $\pi$ is of course275automatically finite, we just have to express that every sentence in276it is in~$\Gamma$. Thus we can define $\Prf[\Gamma](x, y)$ by277\begin{align*}278\Prf[\Gamma](x, y) \defiff {}&279\fn{Deriv}(x) \land {} \\280& \bforall{i <281 \len{(\fn{EndSequent}(x))_0}}{R_\Gamma(((\fn{EndSequent}(x))_0)_i)} \land {}\\282& \len{(\fn{EndSequent}(x))_1} = 1 \land ((\fn{EndSequent}(x))_1)_0 = y.283\end{align*}284\end{proof}285286\end{document}
content/incompleteness/arithmetization-syntax/proofs-in-nd.tex
1% Part: incompleteness2% Chapter: arithmetization-syntax3% Section: proofs-in-nd45\documentclass[../../../include/open-logic-section]{subfiles}67\begin{document}89\olfileid{inc}{art}{pnd}10\olsection{\usetoken{P}{derivation} in Natural Deduction}1112\begin{explain}13In order to arithmetize !!{derivation}s, we must represent14!!{derivation}s as numbers. Since !!{derivation}s are trees of15!!{formula}s where each inference carries one or two labels, a16recursive representation is the most obvious approach: we represent a17!!{derivation} as a tuple, the components of which are the number of18immediate sub-!!{derivation}s leading to the premises of the last19inference, the representations of these sub-!!{derivation}s, and the20end-!!{formula}, the discharge label of the last inference, and a21number indicating the type of the last inference.22\end{explain}2324\begin{defn}25 If $\delta$ is !!a{derivation} in natural deduction, then $\Gn{\delta}$ is26 defined inductively as follows:27 \begin{enumerate}28 \item 29 If $\delta$ consists only of the assumption~$!A$, then $\Gn{\delta}$30 is $\tuple{0, \Gn{!A}, n}$. The number~$n$ is~$0$ if it is an31 !!{undischarged} assumption, and the numerical label otherwise.32 \item 33 If $\delta$ ends in an inference with zero, one, two, or three premises,34 then $\Gn{\delta}$ is35 \begin{align*}36 & \tuple{0, \Gn{!A}, n, k}, \\37 & \tuple{1, \Gn{\delta_1}, \Gn{!A}, n, k}, \\38 & \tuple{2, \Gn{\delta_1}, \Gn{\delta_2}, \Gn{!A}, n, k}, \text{ or}\\39 & \tuple{3, \Gn{\delta_1}, \Gn{\delta_2}, \Gn{\delta_3}, \Gn{!A}, n,40 k},41 \end{align*}42 respectively. Here $\delta_1$, $\delta_2$, $\delta_3$ are the43 sub-!!{derivation}s ending in the premise(s) of the last inference44 in $\delta$, $!A$ is the conclusion of the last inference45 in~$\delta$, $n$ is the discharge label of the last inference ($0$46 if the inference does not discharge any assumptions), and $k$~is47 given by the following table according to which rule was used in the48 last inference.49 50 \begin{tabular}{lccccccc}51 \text{Rule:} & \Intro{\land} & \Elim{\land} & \Intro{\lor} & \Elim{\lor} \\52 $k$: & 1 & 2 & 3 & 4 \\[1.5ex]53 \text{Rule:} & \Intro{\lif} & \Elim{\lif} & \Intro{\lnot} & \Elim{\lnot} \\54 $k$: & 5 & 6 & 7 & 8 \\[1.5ex]55 \text{Rule:} & \FalseInt & \FalseCl & \Intro{\lforall} & \Elim{\lforall} \\56 $k$: & 9 & 10 & 11 & 12 \\[1.5ex]57 \text{Rule:} & \Intro{\lexists} & \Elim{\lexists} & \Intro{\eq} & \Elim{\eq} \\58 $k$: & 13 & 14 & 15 & 16 59 \end{tabular}60 \end{enumerate}61\end{defn}6263\begin{ex}64 Consider the very simple !!{derivation}65 \begin{prooftree}66 \AxiomC{$\Discharge{!A \land !B}{1}$}67 \RightLabel{\Elim{\land}}68 \UnaryInfC{$!A$}69 \DischargeRule{\Intro{\lif}}{1}70 \UnaryInfC{$(!A \land !B) \lif !A$}71 \end{prooftree}72 The G\"odel number of the assumption would be $d_0 = \tuple{0,73 \Gn{!A \land !B}, 1}$. The G\"odel number of the !!{derivation}74 ending in the conclusion of~$\Elim{\land}$ would be $d_1 = \tuple{1,75 d_0, \Gn{!A}, 0, 2}$ ($1$ since $\Elim{\land}$ has one premise,76 the G\"odel number of conclusion~$!A$, $0$ because no assumption is77 discharged, and $2$ is the number coding $\Elim{\land}$). The G\"odel78 number of the entire !!{derivation} then is79 $\tuple{1, d_1, \Gn{((!A \land !B) \lif80 !A)}, 1, 5}$, i.e.,81 \[82 \tuple{1, \tuple{1, \tuple{0, \Gn{(!A \land !B)}, 1}, \Gn{!A}, 0, 2},83 \Gn{((!A \land !B) \lif !A)}, 1, 5}.84 \]85\end{ex}8687\begin{explain}88Having settled on a representation of !!{derivation}s, we must also89show that we can manipulate G\"odel numbers of such !!{derivation}s90primitive recursively, and express their essential properties and91relations. Some operations are simple: e.g., given a G\"odel92number~$d$ of !!a{derivation}, $\fn{EndFmla}(d) = (d)_{(d)_0+1}$93gives us the G\"odel number of its end-!!{formula},94$\fn{DischargeLabel}(d) = (d)_{(d)_0 + 2}$ gives us the discharge95label and $\fn{LastRule}(d) = (d)_{(d)_0 + 3}$ the number indicating96the type of the last inference. Some are much harder. We'll at least97sketch how to do this. The goal is to show that the relation98``$\delta$ is !!a{derivation} of~$!A$ from~$\Gamma$'' is a primitive99recursive relation of the G\"odel numbers of $\delta$ and~$!A$.100\end{explain}101102\begin{prop}103 The following relations are primitive recursive:104 \begin{enumerate}105 \item $!A$ occurs as an assumption in~$\delta$ with label~$n$.106 \item All assumptions in $\delta$ with label~$n$ are of the form~$!A$107 (i.e., we can !!{discharge} the assumption~$!A$ using label~$n$108 in~$\delta$).109 \end{enumerate}110\end{prop}111112\begin{proof}113 We have to show that the corresponding relations between G\"odel114 numbers of !!{formula}s and G\"odel numbers of !!{derivation}s are115 primitive recursive.116 \begin{enumerate}117 \item We want to show that $\fn{Assum}(x, d, n)$, which holds if $x$118 is the G\"odel number of an assumption of the !!{derivation} with119 G\"odel number~$d$ labelled~$n$, is primitive recursive. This is120 the case if the !!{derivation} with G\"odel number~$\tuple{0, x,121 n}$ is a sub-!!{derivation} of~$d$. Note that the way we code122 !!{derivation}s is a special case of the coding of trees introduced in123 \olref[cmp][rec][tre]{sec}, so the primitive recursive function124 $\fn{SubtreeSeq}(d)$ gives a sequence of G\"odel numbers of all125 sub-!!{derivation}s of~$d$ (of length at most $d$). So we can126 define127 \[128 \fn{Assum}(x, d, n) \defiff \bexists{i<d}{(\fn{SubtreeSeq}(d))_i =129 \tuple{0, x, n}}.130 \]131 \item We want to show that $\fn{Discharge}(x, d, n)$, which holds if132 all assumptions with label~$n$ in the !!{derivation} with G\"odel133 number~$d$ all are the !!{formula} with G\"odel number~$x$. But134 this relation holds iff $\bforall{y<d}{(\fn{Assum}(y, d, n) \lif y135 = x)}$.136 \end{enumerate}137\end{proof}138139\begin{prop}140 \ollabel{prop:followsby}141 The property $\fn{Correct}(d)$ which holds iff the last inference in142 the !!{derivation}~$\delta$ with G\"odel number~$d$ is correct, is143 primitive recursive.144\end{prop}145146\begin{proof}147 Here we have to show that for each rule of inference~$R$ the148 relation $\fn{FollowsBy}_R(d)$ is primitive recursive, where149 $\fn{FollowsBy}_R(d)$ holds iff $d$ is the G\"odel number of150 !!{derivation}~$\delta$, and the end-!!{formula} of~$\delta$ follows151 by a correct application of~$R$ from the immediate152 sub-!!{derivation}s of~$\delta$.153154 A simple case is that of the \Intro{\land} rule. If $\delta$ ends in155 a correct $\Intro{\land}$ inference, it looks like this:156 \begin{prooftree}157 \AxiomC{}158 \RightLabel{$\delta_1$}159 \DeduceC{$!A$}160 161 \AxiomC{}162 \RightLabel{$\delta_2$}163 \DeduceC{$!B$}164165 \RightLabel{\Intro\land}166 \BinaryInfC{$!A \land !B$}167 \end{prooftree}168 Then the G\"odel number~$d$ of~$\delta$ is $\tuple{2, d_1, d_2,169 \Gn{(!A \land !B)}, 0, k}$ where $\fn{EndFmla}(d_1) = \Gn{!A}$,170 $\fn{EndFmla}(d_2) = \Gn{!B}$, $n=0$, and $k=1$. So we can define171 $\fn{FollowsBy}_{\Intro\land}(d)$ as172 \begin{multline*}173 (d)_0 = 2 \land \fn{DischargeLabel}(d) = 0 \land \fn{LastRule}(d) = 1 \land {}\\174 \fn{EndFmla}(d) = {}\\175 \Gn{(} \concat \fn{EndFmla}((d)_1) \concat \Gn{\land}176 \concat \fn{EndFmla}((d)_2) \concat \Gn{)}.177 \end{multline*}178179 Another simple example is the $\Intro\eq$ rule. This has no premises,180 so $(d)_0 = 0$, like assumptions. It also has no discharge label,181 i.e., $n=0$. However, $!A$ must be of the form $\eq[t][t]$, for a182 closed term~$t$. Here, a primitive recursive definition is183 \begin{multline*}184 (d)_0 = 0 \land \fn{DischargeLabel}(d) = 0 \land {}\\185 \bexists{t<d}{(\fn{ClTerm}(t) \land 186 \fn{EndFmla}(d) = {}\\187 \Gn{{\eq}(} \concat t \concat \Gn{,} \concat t \concat \Gn{)})}.188 \end{multline*}189190 For a more complicated example, $\fn{FollowsBy}_{\Intro{\lif}}(d)$191 holds iff the end-!!{formula} of~$\delta$ is of the form $(!A \lif192 !B)$, where the end-!!{formula} of $\delta_1$ is~$!B$, and any193 assumption in~$\delta$ labelled~$n$ is of the form~$!A$. We can194 express this primitive recursively by195 \begin{multline*}196 (d)_0 = 1 \land {}\\197 \bexists{a<d}{(\fn{Discharge}(a, (d)_1, \fn{DischargeLabel}(d)) \land {}}\\198 \fn{EndFmla}(d) = (\Gn{(} \concat a \concat \Gn{\lif}199 \concat \fn{EndFmla}((d)_1) \concat \Gn{)}))200 \end{multline*}201 (Think of $a$ as the G\"odel number of~$!A$).202203 For another example, consider \Intro{\lexists}. Here, the last204 inference in~$\delta$ is correct iff there is !!a{formula}~$!A$, a205 closed term~$t$ and !!a{variable}~$x$ such that $\Subst{!A}{t}{x}$206 is the end-!!{formula} of the !!{derivation}~$\delta_1$ and207 $\lexists[x][!A]$ is the conclusion of the last inference. So,208 $\fn{FollowsBy}_{\Intro{\lexists}}(d)$ holds iff209 \begin{multline*}210 (d)_0 = 1 \land \fn{DischargeLabel}(d) = 0 \land {} \\211 \bexists{a < d}{\bexists{x<d}{\bexists{t<d}{212 (\fn{ClTerm}(t) \land \fn{Var}(x) \land {}}}}\\213 \fn{Subst}(a,t,x) = \fn{EndFmla}((d)_1) \land214 \fn{EndFmla}(d) = (\Gn{\lexists} \concat x \concat a)).215 \end{multline*}216217 We then define $\fn{Correct}(d)$ as218 \begin{multline*}219 \fn{Sent}(\fn{EndFmla}(d)) \land {}\\220 (\fn{LastRule}(d) = 1 \land221 \fn{FollowsBy}_{\Intro\land}(d)) \lor \dots \lor {}\\222 (\fn{LastRule}(d) = 16 \land \fn{FollowsBy}_{\Elim\eq}(d)) \lor {}\\223 \bexists{n<d}{\bexists{x<d}{(d = \tuple{0, x, n})}}.224 \end{multline*}225 The first line ensures that the end-!!{formula} of~$d$ is a226 sentence. The last line covers the case where $d$ is just an227 assumption.228\end{proof}229230\begin{prob}231 Define the following properties as in232 \olref[inc][art][pnd]{prop:followsby}:233 \begin{enumerate}234 \item $\fn{FollowsBy}_{\Elim{\lif}}(d)$,235 \item $\fn{FollowsBy}_{\Elim{\eq}}(d)$,236 \item $\fn{FollowsBy}_{\Elim{\lor}}(d)$,237 \item $\fn{FollowsBy}_{\Intro{\lforall}}(d)$.238 \end{enumerate}239 For the last one, you will have to also show that you can test240 primitive recursively if the last inference of the241 !!{derivation} with G\"odel number~$d$ satisfies the eigenvariable242 condition, i.e., the eigenvariable~$a$ of the $\Intro{\lforall}$243 inference occurs neither in the end-!!{formula} of~$d$ nor in an244 open assumption of~$d$. You may use the primitive recursive245 predicate $\fn{OpenAssum}$ from246 \olref[inc][art][pnd]{prop:openassum} for this.247\end{prob}248249\begin{prop}250 \ollabel{prop:deriv}251 The relation $\fn{Deriv}(d)$ which holds if $d$ is the G\"odel252 number of a correct !!{derivation}~$\delta$, is primitive recursive.253\end{prop}254255\begin{proof}256 !!^a{derivation}~$\delta$ is correct if every one of its inferences257 is a correct application of a rule, i.e., if every one of its258 sub-!!{derivation}s ends in a correct inference. So, $\fn{Deriv}(d)$259 iff260 \[261 \bforall{i<\len{\fn{SubtreeSeq}(d)}}{\fn{Correct}((\fn{SubtreeSeq}(d))_i)}262 \]263\end{proof}264265\begin{prop}266 \ollabel{prop:openassum} The relation $\fn{OpenAssum}(z, d)$ that267 holds if $z$ is the G\"odel number of !!a{undischarged} assumption~$!A$268 of the !!{derivation}~$\delta$ with G\"odel number~$d$, is primitive269 recursive.270\end{prop}271272\begin{proof}273 An occurrence of an assumption is !!{discharged} if it occurs with274 label~$n$ in a sub-!!{derivation} of~$\delta$ that ends in a rule275 with discharge label~$n$. So $!A$ is !!a{undischarged} assumption276 of~$\delta$ if at least one of its occurrences is not !!{discharged}277 in~$\delta$. We must be careful: $\delta$ may contain both278 !!{discharged} and !!{undischarged} occurrences of~$!A$.279280 Consider a sequence $\delta_0$, \dots, $\delta_k$ where $\delta_0 =281 \delta$, $\delta_k$ is the assumption $\Discharge{!A}{n}$282 (for some~$n$), and $\delta_{i+1}$ is an immediate sub-!!{derivation}283 of~$\delta_i$. If such a sequence exists in which no $\delta_i$284 ends in an inference with discharge label~$n$, then $!A$ is285 !!a{undischarged} assumption of~$\delta$.286287 The primitive recursive function $\fn{SubtreeSeq}(d)$ provides us288 with a sequence of G\"odel numbers of all sub-!!{derivation}s289 of~$\delta$. Any sequence of G\"odel numbers of sub-!!{derivation}s290 of~$\delta$ is a subsequence of it. Being a subsequence of is a291 primitive recursive relation: $\fn{Subseq}(s, s')$ holds iff292 $\bforall{i<\len{s}}{\lexists[j<\len{s'}][(s)_i = (s')_j]}$. Being an293 immediate sub-!!{derivation} is as well: $\fn{Subderiv}(d, d')$ iff294 $\bexists{j<(d')_0}{d = (d')_j}$. So we can define295 $\fn{OpenAssum}(z, d)$ by296 \begin{multline*}297 \bexists{s<\fn{SubtreeSeq}(d)}{(\fn{Subseq}(s, \fn{SubtreeSeq}(d))298 \land (s)_0 = d \land {}} \\299 \bexists{n<d}{((s)_{\len{s} \tsub 1} = \tuple{0, z, n} \land {}}\\300 \bforall{i<(\len{s} \tsub 1)}{(\fn{Subderiv}((s)_{i+1}, (s)_i) \land {}}\\301 \fn{DischargeLabel}((s)_i) \neq n))).302 \end{multline*}303\end{proof}304305\begin{prop}306 \ollabel{prop:prf-prim-rec}307 Suppose $\Gamma$ is a primitive recursive set of !!{sentence}s.308 Then the relation $\Prf[\Gamma](x, y)$ expressing ``$x$ is the code309 of !!a{derivation}~$\delta$ of $!A$ from !!{undischarged}310 assumptions in~$\Gamma$ and $y$ is the G\"odel number of~$!A$'' is311 primitive recursive.312\end{prop}313314\begin{proof}315 Suppose ``$y \in \Gamma$'' is given by the primitive recursive316 predicate~$R_\Gamma(y)$. We have to show that $\Prf[\Gamma](x, y)$317 which holds iff $y$ is the G\"odel number of a sentence~$!A$ and318 $x$~is the code of a natural deduction !!{derivation} with end319 !!{formula}~$!A$ and all !!{undischarged} assumptions in~$\Gamma$ is320 primitive recursive.321322 By \olref{prop:deriv}, the property $\fn{Deriv}(x)$ which holds iff323 $x$ is the G\"odel number of a correct !!{derivation}~$\delta$ in324 natural deduction is primitive recursive. Thus we can define325 $\Prf[\Gamma](x, y)$ by326 \begin{align*}327 \Prf[\Gamma](x, y) \defiff {}328 & \fn{Deriv}(x) \land \fn{EndFmla}(x) = y \land {} \\329 & \bforall{z < x}{(\fn{OpenAssum}(z, x) \lif R_\Gamma(z))}.330 \end{align*}331\end{proof}332333\end{document}
content/incompleteness/arithmetization-syntax/proofs-in-ax.tex
1% Part: incompleteness2% Chapter: arithmetization-syntax3% Section: proofs-in-ax45\documentclass[../../../include/open-logic-section]{subfiles}67\begin{document}89\olfileid{inc}{art}{pax}10\olsection{Axiomatic \usetoken{P}{derivation}}1112\begin{explain}13In order to arithmetize axiomatic !!{derivation}s, we must represent14!!{derivation}s as numbers. Since !!{derivation}s are simply sequences15of !!{formula}s, the obvious approach is to code every !!{derivation}16as the code of the sequence of codes of !!{formula}s in it.17\end{explain}1819\begin{defn}20If $\delta$ is an axiomatic !!{derivation} consisting of !!{formula}s21$!A_1$, \dots,~$!A_n$, then $\Gn{\delta}$ is22\[23\tuple{\Gn{!A_1}, \dots, \Gn{!A_n}}.24\]25\end{defn}2627\begin{ex}28 Consider the very simple !!{derivation}:29 \begin{derivation}30 1. & $!B \lif (!B \lor !A)$ \\31 2. & $(!B \lif (!B \lor !A)) \lif (!A \lif (!B \lif (!B \lor !A)))$\\32 3. & $!A \lif (!B \lif (!B \lor !A))$33 \end{derivation}34 The G\"odel number of this !!{derivation} would be35 \begin{align*}36 \openTuple\, 37 & \Gn{!B \lif (!B \lor !A)}, \\38 &\Gn{(!B \lif (!B \lor !A)) \lif (!A \lif (!B \lif (!B \lor !A)))},\\39 & \Gn{!A \lif (!B \lif (!B \lor !A))} \,\closeTuple.40 \end{align*}41\end{ex}4243\begin{explain}44Having settled on a representation of !!{derivation}s, we must also45show that we can manipulate such !!{derivation}s primitive recursively, and46express their essential properties and relations so. Some operations47are simple: e.g., given a G\"odel number~$d$ of !!a{derivation},48$(d)_{\len{d}-1}$ gives us the G\"odel number of its end-!!{formula}. Some are49much harder. We'll at least sketch how to do this. The goal is to50show that the relation ``$\delta$ is !!a{derivation} of~$!A$51from~$\Gamma$'' is primitive recursive in the G\"odel numbers of52$\delta$ and~$!A$.53\end{explain}5455\begin{prop}56\ollabel{prop:followsby}57The following relations are primitive recursive:58\begin{enumerate}59\item $!A$ is an axiom.60\item The $i$-th line in $\delta$ is justified by modus ponens61\item The $i$-th line in $\delta$ is justified by \QR.62\item $\delta$ is a correct !!{derivation}.63\end{enumerate}64\end{prop}6566\begin{proof}67We have to show that the corresponding relations between G\"odel68numbers of !!{formula}s and G\"odel numbers of !!{derivation}s 69are primitive recursive.70\begin{enumerate}71\item We have a given list of axiom schemas, and $!A$ is an axiom if72 it is of the form given by one of these schemas. Since the list of73 schemas is finite, it suffices to show that we can test primitive74 recursively, for each axiom schema, if $!A$ is of that form. For75 instance, consider the axiom schema76 \[77 !B \lif (!C \lif !B).78 \]79 $!A$ is an instance of this axiom schema if there are !!{formula}s80 $!B$ and $!C$ such that we obtain $!A$ when we concatenate `$($'81 with $!B$ with `$\lif$' with `$($' with $!C$ with `$\lif$' with $!B$82 and with~`$))$'. We can test the corresponding property of the83 G\"odel number $n$ of~$!A$, since concatenation of sequences is84 primitive recursive and the G\"odel numbers of $!B$ and $!C$ must85 be smaller than the G\"odel number of~$!A$, since when the relation86 holds, both $!B$ and $!C$ are sub-!!{formula}s of~$!A$. Hence, we87 can define:88 \begin{multline*}89 \fn{IsAx}_{!B \lif (!C \lif !B)}(n) \defiff \bexists{b< n}{90 \bexists{c < n}{(\fn{Sent}(b) \land \fn{Sent}(c) \land {}}}\\ n =91 \Gn{(} \concat b \concat \Gn{\lif} \concat \Gn{(} \concat c \concat92 \Gn{\lif} \concat b \concat \Gn{))}).93 \end{multline*}94 If we have such a definition for each axiom schema, their95 disjunction defines the property $\fn{IsAx}(n)$, ``$n$~is the96 G\"odel number of an axiom.''97\item The $i$-th line in $\delta$ is justified by modus ponens iff there98 are lines $j$ and $k < i$ where the !!{sentence} on line~$j$ is some99 formula $!A$, the sentence on line~$k$ is $!A \lif !B$, and the100 sentence on line~$i$ is~$!B$.101 \begin{multline*}102 \fn{MP}(d, i) \defiff \bexists{j < i}{\bexists{k < i}{}}\\103 (d)_k = \Gn{(} \concat (d)_j104 \concat \Gn{\lif} \concat (d)_i \concat \Gn{)}105 \end{multline*}106 Since bounded quantification, concatenation, and $=$ are primitive107 recursive, this defines a primitive recursive relation. 108\item A line in $\delta$ is justified by \QR{} if it is of the form109 $!B \lif \lforall[x][!A(x)]$, a preceding line is $!B \lif !A(c)$110 for some !!{constant}~$c$, and $c$ does on occur in~$!B$. This is111 the case iff112 \begin{enumerate}113 \item there is !!a{sentence}~$!B$ and114 \item !!a{formula}~$!A(x)$ with a single variable~$x$ free so that115 \item line $i$ contains $!B \lif \lforall[x][!A(x)]$116 \item some line $j < i$ contains $!B \lif \Subst{!A}{c}{x}$ for a constant~$c$117 \item which does not occur in~$!B$.118 \end{enumerate}119 All of these can be tested primitive recursively, since the G\"odel120 numbers of $!B$, $!A(x)$, and $x$ are less than the G\"odel number of the121 formula on line~$i$, and that of $a$ less than the G\"odel number of the122 formula on line~$j$:123 \begin{multline*}124 \fn{QR}_1(d, i) \defiff \bexists{b < (d)_i}{\bexists{x <125 (d)_i}{\bexists{a < (d)_i}{\bexists{c < (d)_j}{(}}}}126 \\ \fn{Var}(x) \land \fn{Const}(c) \land {} \\127 (d)_i = \Gn{(} \concat128 b \concat \Gn{\lif} \concat \Gn{\lforall} \concat x \concat a129 \concat \Gn{)} \land {}\\130 (d)_j = \Gn{(} \concat b \concat131 \Gn{\lif} \concat \fn{Subst}(a,c,x) \concat \Gn{)} \land {}\\ \fn{Sent}(b)132 \land \fn{Sent}(\fn{Subst}(a,c,x)) \land {} \bforall{k <133 \len{b}}{(b)_k \neq (c)_0})134 \end{multline*}135 Here we assume that $c$ and $x$ are the G\"odel numbers of the136 variable and constant considered as terms (i.e., not their symbol137 codes). We test that $x$ is the only free variable of~$!A(x)$ by138 testing if $\Subst{!A(x)}{c}{x}$ is !!a{sentence}, and ensure that139 $c$ does not occur in $!B$ by requiring that every symbol of~$!B$ is140 different from~$c$.141142 We leave the other version of \QR{} as an exercise.143\item $d$ is the G\"odel number of a correct !!{derivation} iff every144 line in it is an axiom, or justified by modus ponens or~\QR. Hence:145 \[146 \fn{Deriv}(d) \defiff \bforall{i < \len{d}}{(\fn{IsAx}((d)_i) \lor147 \fn{MP}(d,i) \lor \fn{QR}(d, i))}148 \]149\end{enumerate}150\end{proof}151152\begin{prob}153Define the following relations as in154\olref[inc][art][pax]{prop:followsby}:155\begin{enumerate}156\item $\fn{IsAx}_{!A \lif (!B \lif (!A \land !B))}(n)$,157\item $\fn{IsAx}_{\lforall[x][!A(x)] \lif !A(t)}(n)$,158\item $\fn{QR}_{2}(d, i)$ (for the other version of \QR).159\end{enumerate}160\end{prob}161162\begin{prop}163Suppose $\Gamma$ is a primitive recursive set of !!{sentence}s. Then164the relation $\Prf[\Gamma](x, y)$ expressing ``$x$ is the code of165!!a{derivation}~$\delta$ of $!A$ from~$\Gamma$ and $y$ is the G\"odel166number of~$!A$'' is primitive recursive.167\end{prop}168169\begin{proof}170Suppose ``$y \in \Gamma$'' is given by the primitive recursive171predicate~$R_\Gamma(y)$. We have to show that the relation172$\Prf[\Gamma](x, y)$ is primitive recursive, where $\Prf[\Gamma](x,173y)$ holds iff $y$ is the G\"odel number of !!a{sentence}~$!A$ and174$x$~is the code of !!a{derivation} of~$!A$ from $\Gamma$.175176By the previous proposition, the property $\fn{Deriv}(x)$ which holds177iff $x$ is the code of a correct !!{derivation}~$\delta$ is primitive178recursive. However, that definition did not take into account the set179$\Gamma$ as an additional way to justify lines in the !!{derivation}. Our180primitive recursive test of whether a line is justified by \QR{} also181left out of consideration the requirement that the constant~$c$ is not182allowed to occur in~$\Gamma$. It is possible to amend our definition so183that it takes into account $\Gamma$ directly, but it is easier to use184$\fn{Deriv}$ and the deduction theorem. $\Gamma \Proves !A$ iff185there is some finite list of !!{sentence}s $!B_1$, \dots, $!B_n \in186\Gamma$ such that $\{!B_1, \dots, !B_n\} \Proves !A$. And by the187deduction theorem, this is the case if $\Proves (!B_1 \lif (!B_2 \lif188\cdots (!B_n \lif !A)\cdots))$. Whether !!a{sentence} with G\"odel189number~$z$ is of this form can be tested primitive recursively. So,190instead of considering $x$ as the G\"odel number of !!a{derivation} of191the !!{sentence} with G\"odel number~$y$ \emph{from $\Gamma$}, we consider192$x$ as the G\"odel number of !!a{derivation} of a nested conditional193of the above form from~$\emptyset$.194195First, if we have a sequence of !!{sentence}s, we can primitive196recursively form the conditional with all these sentences as197antecedents and given !!{sentence} as consequent:198\begin{align*}199 \fn{hCond}(s, y, 0) & = y \\200 \fn{hCond}(s, y, n+1) & = \Gn{(} \concat (s)_{n} \concat \Gn{\lif}201 \concat \fn{Cond}(s, y, n) \concat \Gn{)}\\202 \fn{Cond}(s, y) & = \fn{hCond}(s, y, \len{s})\\203 \intertext{So we can define $\Prf[\Gamma](x, y)$ by}204 \Prf[\Gamma](x, y) & \defiff \bexists{s < \fn{sequenceBound}(x,x)}{(} \\205 &\qquad (x)_{\len{x}-1} = \fn{Cond}(s,y) \land {} \\206 &\qquad\bforall{i<\len{s}}{(s)_i \in \Gamma} \land {} \\207 &\qquad\fn{Deriv}(x)).208\end{align*}209The bound on~$s$ is given by considering that each $(s)_i$ is the210G\"odel number of a sub-!!{formula} of the last line of the !!{derivation},211i.e., is less than $(x)_{\len{x}-1}$. The number of antecedents $!B212\in \Gamma$, i.e., the length of~$s$, is less than the length of the213last line of~$x$.214\end{proof}215216\end{document}