This repository contains an implementation of concepts from first-order logic, mainly to test my understanding as I work through Christopher C. Leary's "A Friendly Introduction to Mathematical Logic".
Definition 1.8.1. Suppose that $u$ is a term, $x$ is a varable, and $t$ is a term. We define the term $u_t^x$ (" $u$ with $x$ replaced by $t$") as follows:
If $u$ is a variable not equal to $x$, then $u_t^x$ is $u$.
If $u$ is $x$, then $u_t^x$ is $t$.
If $u$ is a constant symbol, then $u_t^x$ is $u$.
If $u:\equiv fu_1u_2\dots u_n$, where $f$ is an $n$-ary function symbol and the $u_i$ are terms, then $u_t^x$ is $f(u_1)^x_t(u_2)^x_t\dots(u_n)^x_t$.
Definition 1.8.2. Suppose that $\phi$ is an $\cal L$-formula, $t$ is a term, and $x$ is a variable. We define the formula $\phi_t^x$ as follows:
If $\phi:\equiv=u_1u_2$, then $\phi_t^x$ is $=(u_1)^x_t(u_2)^x_t$.
If $\phi:\equiv Ru_1u_2\dots u_n$, then $\phi^x_t$ is $R(u_1)^x_t(u_2)^x_t\dots(u_n)^x_t$.
If $\phi:\equiv(\neg\alpha)$, then $\phi_t^x$ is $(\neg\alpha_t^x)$.
If $\phi:\equiv(\alpha\vee\beta)$, then $\phi_t^x$ is $(\alpha^x_t\vee\beta^x_t)$.
Definition 1.8.3. Suppose that $\phi$ is an $\cal L$-formula, $t$ is a term, and $x$ is a variable. We say that $t$ is substitutable for $x$ in $\phi$ if:
$\phi$ is atomic, or
$\phi:\equiv(\neg\alpha)$ and $t$ is substitutable for $x$ in $\alpha$, or
$\phi:\equiv(\alpha\vee\beta)$ and $t$ is substitutable for $x$ in both $\alpha$ and $\beta$, or
$\phi:\equiv(\forall y)(\alpha)$ and either
a. $x$ is not free in $\phi$, or
b. $y$ does not occur in $t$ and $t$ is substitutable for $x$ in $\alpha$
Definition 1.8.1. Suppose that $u$ is a term, $x$ is a varable, and $t$ is a term. We define the term $u_t^x$ (" $u$ with $x$ replaced by $t$") as follows:
Definition 1.8.2. Suppose that $\phi$ is an $\cal L$-formula, $t$ is a term, and $x$ is a variable. We define the formula $\phi_t^x$ as follows:
Definition 1.8.3. Suppose that $\phi$ is an $\cal L$-formula, $t$ is a term, and $x$ is a variable. We say that $t$ is substitutable for $x$ in $\phi$ if: