### My Logic Notes

#### Introduction

• A formal logical system consists of a formal language for encoding arguments and a deductive system. Arguments consist of formulae. Arguments usually start with it a set of formulae consist of premises. Arguments seek to prove a formula, called the conclusion.
• The deductive system uses axioms and rules of inference to derive new formulae from existing formulae.

#### Propositional Logic

• Propositional logic is branch of mathematical logic, studying truth-false value propositions, constructed from other propositions.
• Propositional logic "strips away real world context". It is a formal language. Formal languages are made of two things: syntax and semantics. The syntax of propositional logic is made of a set of variables and a set of logical connectives. We may also additional add propositional constants to our language. Valid strings in our language are known as formulae.
• The language of propositional logic can be defined with a context-free grammar; it is a context-free language.
• We shall use the logical connectives: $\left\{\wedge ,\vee ,¬,\to ,↔\right\}$, standing for conjunction, disjunction, negation, implication and bi-implication.
• A truth assignment of a formulae is a mapping between variables and truth/falsity.
• Note that $p\to q$ can be rewritten as $q\vee ¬p$. This makes intuitive sense, as if $p\to q$, and $q$ isn't true, this means $p$ can't be true. Also note that $p↔q$ can be written as $\left(p\to q\right)\wedge \left(q\to p\right)$.
• A set of logical connectives are adequate if they can represent all logical connectives. $\left\{\wedge ,¬\right\}$ is an example of an adequate set.
• The set $\left\{↑\right\}$ is also an adequate set. This is the symbol for NAND (which has an opposite truth table to conjunction).
• The set $\left\{↓\right\}$ is also an adequate set. This is the the symbol for NOR (which has an opposite truth table to disjunction).
• The symbols $\top$ and $\perp$ are the symbols for falsity and truth respectively; these are 0-arity logical connectives (also known as propositional constants). They can also be used to create adequate sets.
• The logical connectives $\left\{\wedge ,\vee \right\}$ are truth-preserving, this means whenever all parameters to the connectives are $\top$, the connectives map to $\top$. This means that they cannot alone be an adequate set, as it would be impossible to create Boolean functions which are not truth-preserving by only the composition of these functions.
• Another set $\left\{\to ,¬\right\}$ is also adequate, which can be proven with the identity for $\to$ and De Morgan's laws.
• Some other properties $\left\{\wedge ,\vee \right\}$ have are associativity, commutativity and idempotent. These are properties that $\left\{\to \right\}$ does not have.
• Two formulae in propositional logic are equivalent if they have the same value under every truth assignment.
• A literal is a propositional variable or a negation.
• Conjunctive normal form is a conjunction of zero or more disjunctions made of one or more literals e.g. $\left(A\vee B\right)\wedge \left(¬B\vee C\right)$.
• Disjunctive normal form is a disjunction of zero of more conjunctions made of one or more literals e.g. $\left(A\wedge B\right)\vee \left(¬B\wedge C\right)$.
• A tautology is a formula that is true in every circumstance e.g. $p\to \left(q\to p\right)$.
• A contradiction is a formula that is true in no circumstances.

#### Logical Consequence

• If $\varphi$ is a set of formulae, and $\psi$ is a formula, then it is the case that $\varphi \models \psi$ if whenever every formula in $\varphi$ holds then $\psi$ holds.
• This is a semantic concept as it relies on the meaning of $\varphi$ and $\psi$, as opposed to a syntactic concept.
• If $\models \psi$ then $\psi$ is a tautology.
• If $\phi \not\models \psi$ then $\psi$ does not necessarily hold whenever all the formulae in $\varphi$ hold, $\not\models \psi$ means that $\psi$ is not a tautology.
• If $\varphi \models \perp$ means that $\varphi$ is a contradiction, as there are no circumstances in which $\varphi$ holds.
• If $\varphi \models \psi$, then $\models \left(\varphi \to \psi \right)$.
• If $\varphi$ is satisfiable there is some truth assignment for which all the formulae in $\varphi$ hold.

#### Hilbert Calculus

• Hilbert Calculus is a possible deductive system for propositional logic.
• The rule of inference used is called modus ponens and is that if $\varphi \to \psi$ and $\varphi$, then $\psi$.
• The three axioms used are:
1. $\varphi \to \left(\psi \to \varphi \right)$
2. $\left(\varphi \to \left(\psi \to \theta \right)\right)\to \left(\left(\varphi \to \psi \right)\to \left(\varphi \to \theta \right)\right)$
3. $\left(\left(¬\varphi \to ¬\psi \right)\to \left(\psi \to \varphi \right)\right)$
• In propositional logic, Hilbert calculus can within a finite number of application of the above rules on the premises of an argument, derive all valid statements that are true about them. If $\varphi ⊢\psi$ then we say the conclusion $\psi$ is derivable from the premises $\varphi$, or $\psi$ is a theorem of $\varphi$. Similarly if $\phi \not\vdash \psi$ then $\psi$ is not a theorem of $\varphi$.
• When talking about propositional logic with Hilbert calculus deriving $\psi$ from $\varphi$, we may use $\varphi {⊢}_{H}\psi$.
• Propositional logic with Hilbert calculus is a sound formal system. A formal system is sound if $\varphi {⊢}_{H}\psi$ means $\varphi \models \psi$, in other words only true statements can be proven.
• Propositional logic with Hilbert calculus is a complete formal system. A formal system is complete if $\varphi \models \psi$ means that $\varphi {⊢}_{H}\psi$ in other words all true statements can be proven.
• The axioms in Hilbert calculus are also known as axiom schemata. An axiom schema is a propositional formula whose variables can be substituted by any valid formula and the formula is assumed to hold.
• Here is an example of a Hilbert calculus derivation:
Proposition: $\left\{¬¬B\right\}\underset{H}{⊢}B$ Proof: $\begin{array}{ccc}\hfill \mathrm{\text{(1)}}\phantom{\rule{0.333em}{0ex}}& \left(¬¬B\right)\to \left(¬¬¬¬B\to ¬¬B\right)\hfill & \mathrm{\text{Ax 1}}\\ \hfill \mathrm{\text{(2)}}\phantom{\rule{0.333em}{0ex}}& ¬¬B\hfill & \mathrm{\text{Ass}}\\ \hfill \mathrm{\text{(3)}}\phantom{\rule{0.333em}{0ex}}& \left(¬¬¬¬B\to ¬¬B\right)\hfill & \mathrm{\text{MP 1,2}}\\ \hfill \mathrm{\text{(4)}}\phantom{\rule{0.333em}{0ex}}& \left(¬¬¬¬B\to ¬¬B\right)\to \left(¬B\to ¬¬¬B\right)\hfill & \mathrm{\text{Ax 3}}\\ \hfill \mathrm{\text{(5)}}\phantom{\rule{0.333em}{0ex}}& \left(¬B\to ¬¬¬B\right)\hfill & \mathrm{\text{MP 4,3}}\\ \hfill \mathrm{\text{(6)}}\phantom{\rule{0.333em}{0ex}}& \left(¬B\to ¬¬¬B\right)\to \left(¬¬B\to B\right)\hfill & \mathrm{\text{Ax 3}}\\ \hfill \mathrm{\text{(7)}}\phantom{\rule{0.333em}{0ex}}& \left(¬¬B\to B\right)\hfill & \mathrm{\text{MP 5,6}}\\ \hfill \mathrm{\text{(8)}}\phantom{\rule{0.333em}{0ex}}& B\hfill & \mathrm{\text{MP 2,7}}\end{array}$

#### First-order Logic

• First-order logic is an extension of propositional logic that includes quantified variables. A first-order language consists of functions and predicates. Predicates may be 0-ary in which case they are analogous to propositional variables. All other variables in first-order logic are quantified variables, referring to the domain of discourse. A first-order language may exist without functions, however without predicates, with an arity greater than 0, the first-order language is essentially a propositional language. Predicates go hand-in-hand with quantification, since the quantified variables must be arguments to predicate to be of use.
• In is important however to note in a first-order language, functions and predicates only exist syntactically and have no meaning. A structure of a first-order language provides the semantic meaning to a first-order language. It contains a non-empty set that is the domain, from which quantified variables emerge. (If the domain were empty, then $\left(\exists x\phantom{\rule{0.278em}{0ex}}\top \right)\vee ¬\left(\exists x\phantom{\rule{0.278em}{0ex}}\top \right)$ would be $\perp$).
• A structure for a first-order language also provides "interpretations" for the functions and predicates.
• A first-order theory consists of a set of axioms for a first-order language. These axioms are assumed as true. For a structure to be a model of a theory, its interpretation of the functions and predicates must satisfy the axioms.
• The functions and predicates of a first-order language are said to be the signature of the first-order language, bearing in mind that they are merely symbols.
• It is also possible to construct a first-order language with an infinite number of functions and an infinite number of predicates. This means that the first-order language can be used with whatever structure is needed to axiomatise a concept.

#### Properties of Formal Systems

• As stated before propositional logic is both sound and complete. There is another notion of completeness, however, known as negation completeness. A formal system is negation complete if either $\varphi$ or $¬\varphi$ can be derived for all $\varphi$. Propositional logic is not negation complete. This can be shown by using a single propositional variable. There is not enough information, to say whether this one propositional variable, holds or not.
• First-order logic is also sound and complete. Kurt Gödel, an Austrian and later American, logician showed the latter in Gödel's completeness theorem.
• This is not necessarily a problem with first-order logic, as it is possible to restrict the predicates and functions as well as add axioms to ensure everything is derivable. This means that it may be possible, and it is indeed, possible to create first-order languages that are negation complete.
• If it is possible to decide whether a formula in some first-order language is universally valid or not, then the formal system is decidable.
• Propositional logic is decidable, by truth tables, although this is highly inefficient in the worst cases.
• Note that if a first-order language is negation complete, this means that it must be decidable, since all possible proofs can be enumerated over, until either a proof of some proposition $\varphi$ or its negation is found.
• However, a first-order language sufficiently powerful to express arithmetic cannot be negation complete. This was shown in Gödel's incompleteness theorem. Of course, it is still possible that there exists a general decision procedure for all first-order languages, however this was shown not to be the case by, Alonzo Church through Lambda Calculus, and Alan Turing through Turing machines.
• It is also the case that since first-order languages are, generally undecidable, if we can show a particular first-order language as undecidable, we can also show it as negation incomplete.
• It is also important to note that even though first-order languages are generally undecidable, there are restricted first-order languages such as monadic first-order logic, that is decidable.

#### Proofs

• Here is a proof of the soundness of propositional logic with Hilbert calculus:

Proposition: If $\varphi {⊢}_{H}\psi$, then $\varphi \models \psi$.

Proof: We shall use induction on the length of the derivation. The base case will be for the first line of the derivation. We shall refer to the propositions on each line of the derivation as ${\psi }_{1},{\psi }_{2}...{\psi }_{n}$.

Base Case: The first line of our derivation, can either arise as an axiom or an assumption. All axioms are tautologies so must be true, so if ${\psi }_{1}$ is an application of an axiom, the $\varphi \models {\psi }_{1}$. Similarly, if it is an assumption then ${\psi }_{1}\in \varphi$, so $\varphi \models {\psi }_{1}$.

Inductive Case: Assume $\varphi \models {\psi }_{1}...{\psi }_{i-1}$. If ${\psi }_{i}$ is an axiom then, it is a tautology, so $\varphi \models {\psi }_{i}$. if is an assumption then ${\psi }_{i}\in \varphi$ so $\varphi \models {\psi }_{i}$. Finally if ${\psi }_{i}$ is an application of the modus ponens inference rule, then there must be some $k$, such that $k and that $\left({\psi }_{k}\to {\psi }_{i}\right)$ and ${\psi }_{k}$ appear in the derivation previously. If ${\psi }_{k}$ appears in the derivation then ${\psi }_{k}$ must be true. Since ${\psi }_{k}\to {\psi }_{i}$ appears in the derivation, then that must also be true. Because of the truth table for implication, ${\psi }_{i}$ must also be true, so $\varphi \models {\psi }_{i}$.

Conclusion: If $\varphi \models {\psi }_{i-1}$ then $\varphi \models {\psi }_{i}$. Since $\varphi \models {\psi }_{1}$, $\varphi \models {\varphi }_{k}$, where $1\le k\le n$. Since $\psi$ must appear in its derivation, if $\varphi {⊢}_{H}\psi$, then $\varphi \models \psi$.
• Here is a proof of the negation incompleteness of first-order logic able to express a sufficient amount of arithmetic i.e. Gödel's incompleteness theorem:

Proposition: The first-order theory of Peano arithmetic is negation incomplete.

Proof: We shall show this by introduce the notion of Gödel numbering. We shall assign a distinct numeric value to every symbol in our first-order language. Then we shall show that any statement in our first-order language consisting of $n$ symbols can be encoded as a natural number, by matching them with the first $n$ prime numbers. The product of each prime number raised to the power of the numeric value of its respective symbol, is a unique representation of the string as a natural number. This is because the result can be prime factorised, to get the symbols in their original positions. For instance, the first symbol will the exponent of 2 (as a numeric value), in the prime factorisation of the result. This is what is meant by Gödel numbering, every statement in our first-order language is a natural number; or to put it another way, every proof in our first order language can be expressed a natural number.

Note to represent quantified variables, e.g. $\exists x$ and $\forall y$ a unary notation can be used to represent different variables. E.g. ${x}_{1}$, ${x}_{11}$, ${x}_{111}$. This can be extended to represent as many quantified variables as needed, with a finite number of symbols.

The proof resets on a single predicate $\mathsf{\text{Proof(x, y, z)}}$, however note that this predicate is not really a predicate (unless you want to it to be). This is because the predicate is really a short-hand for a very long expression in our first-order language. Optionally, you can say there exists a bi-implication in the form $\mathsf{\text{Proof(x, y, z)}}↔\varphi$, where $\varphi$ is a placeholder for this really long expression, in other words, $\mathsf{\text{Proof(x, y, z)}}$ is not necessary. Either the way the predicate relies on a very important notion: all computable functions can be expressed solely with the Peano axioms (well provided the Church-Turing thesis holds). In any case, the predicate $\mathsf{\text{Proof(x, y, z)}}$ holds if $x$ is the Gödel-encoded proof of the Gödel-encoded statement $y$ with integer $z$ substituted in it. Now, we shall make a new short-hand predicate, $\mathsf{\text{Prf(y)}}↔¬\exists x\phantom{\rule{0.278em}{0ex}}\mathsf{\text{Proof(x, y, y)}}$, $\mathsf{\text{Prf(y)}}$ holds when there doesn't exist a proof of the Gödel-encoded statement $y$ with $y$ substituted in it. Now let $g$ be the Gödel number of that predicate. Does $\mathsf{\text{Prf(g)}}$ hold? If it does hold there isn't a proof of $\mathsf{\text{Prf(g)}}$. But if it does hold, there must be a proof of $\mathsf{\text{Prf(g)}}$. Contradiction. If it doesn't hold, then that means there is a proof of $\mathsf{\text{Prf(g)}}$. But since it doesn't hold, there can't be. Contradiction. Both contradictions are due to the completeness of first-order logic, shown by Gödel previously. In other words there is neither a proof of $\mathsf{\text{Prf(g)}}$ or $¬\mathsf{\text{Prf(g)}}$. Hence there are some statements, for which neither $\varphi$ nor $¬\varphi$ hold in the first-order theory of arithmetic.

• Here is a proof of the undecidability of first-order logic:

Proposition: There is no general procedure to verify whether a set of formulae in first-order logic are universally valid.

Proof: In order to prove the aforementioned proposition, we will show there are propositions $\varphi$ for which either $\varphi$ or $¬\varphi$ must hold, and there does not exist a general procedure to determine whether $\varphi$ or $¬\varphi$ are universally valid. To do this we shall show to how to axiomatise Turing machines, a first-order theory, I shall call $\mathcal{\text{𝒯}}$. The Turing machine we will axiomatise will be represented by the quintuple $\left(Q,\Sigma ,B,\Gamma ,\delta ,{q}_{0},F\right)$. Note that the Turing machine, for convenience will have a semi-infinite tape, however, this is equivalent to Turing machine with a two-way infinite tape. $\mathcal{\text{𝒯}}$ shall have the following functions:

• A 0-ary constant, $0$
• A 1-ary successor functions, $s$

$\mathcal{\text{𝒯}}$ shall have the following predicates:

• $\forall q\in Q,{M}_{q}\left(x,y\right)$ which holds when the Turing machine is in state $q$ after $x$ steps, and scanning the $y$ square.
• $\forall \sigma \in \Sigma ,{N}_{\sigma }\left(x,y\right)$ which holds when the Turing machine has symbol $\sigma$ after $x$ steps on the $y$ square.
• A 2-ary equals predicate

$\mathcal{\text{𝒯}}$ shall have the following basic axioms in addition to the axioms for equality:

• $\forall x\phantom{\rule{0.278em}{0ex}}\forall y\phantom{\rule{0.278em}{0ex}}\left(s\left(x\right)=s\left(y\right)\right)\to x=y\right)$ i.e. the successor function is injective
• $¬\exists x\phantom{\rule{0.278em}{0ex}}s\left(x\right)=0$ i.e. 0 does not have a successor
• $\forall x\phantom{\rule{0.278em}{0ex}}¬\left(x=0\right)\to \exists y\phantom{\rule{0.278em}{0ex}}s\left(y\right)=x$ i.e. all numbers other than 0 have predecessors

$\mathcal{\text{𝒯}}$ shall also have the following axioms for the Turing machine's initial configuration:

• ${M}_{{q}_{0}}\left(0,0\right)$
• Where ${\theta }_{1}...{\theta }_{n}$ are the initial symbols on the Turing machine's tape, ${N}_{{\theta }_{1}}\left(0,0\right)...{N}_{{\theta }_{n}}\left(0,n-1\right)$. Bearing in mind that $n-1$ is to be written formally as the application $s$ to 0, $n-1$ times.
• All other tape symbols are blank: $\forall x\phantom{\rule{0.278em}{0ex}}\left(\underset{i\in \left\{1..n\right\}}{\bigwedge }¬\left(x=i\right)\right)\to \left({N}_{B}\left(0,x\right)\right)$

$\mathcal{\text{𝒯}}$ also needs axioms to represent state transitions in the form, $\delta \left(q,\sigma \right)=\left(qʹ,\sigma ʹ,L\right)$ or $\delta \left(q,\sigma \right)=\left(qʹ,\sigma ʹ,R\right)$.

• To represent $\delta \left(q,\sigma \right)=\left(qʹ,\sigma ʹ,L\right)$:

$\forall x\phantom{\rule{0.278em}{0ex}}\exists y\phantom{\rule{0.278em}{0ex}}\left({M}_{q}\left(x,y\right)\wedge {N}_{\sigma }\left(x,y\right)\right)\to \left({M}_{qʹ}\left(s\left(x\right),s\left(y\right)\right)\wedge {N}_{\sigma ʹ}\left(s\left(x\right),y\right)\right)$

• To represent $\delta \left(q,\sigma \right)=\left(qʹ,\sigma ʹ,R\right)$:

$\forall x\phantom{\rule{0.278em}{0ex}}\exists y\phantom{\rule{0.278em}{0ex}}\left({M}_{q}\left(x,s\left(y\right)\right)\wedge {N}_{\sigma }\left(x,s\left(y\right)\right)\right)\to \left({M}_{qʹ}\left(s\left(x\right),y\right)\wedge {N}_{\sigma ʹ}\left(s\left(x\right),s\left(y\right)\right)\right)$

• To represent non-changed tape symbols, for all $\sigma \in \Sigma$:

$\forall x\phantom{\rule{0.278em}{0ex}}\forall y\phantom{\rule{0.278em}{0ex}}\left(¬{M}_{\sigma }\left(x,y\right)\to {N}_{\sigma }\left(s\left(x\right),y\right)\right)$

To represent whether the machine halts the following sentence can be used, where $X$ represents pairs of $\left(q,\sigma \right)$ for which $\delta$ is undefined:

$\exists x\phantom{\rule{0.278em}{0ex}}\exists y\phantom{\rule{0.278em}{0ex}}\left(\underset{\left(q,\sigma \right)\in X}{\bigvee }\left({M}_{q}\left(x,y\right)\wedge {N}_{\sigma }\left(x,y\right)\right)\right)$

Clearly, because the halting problem is unsolvable, there cannot be an algorithm to decide whether the above proposition holds for a Turing machine. However, clearly there must exist a truth value to the above proposition. Therefore, first-order logic is undecidable.

#### Bibliography

• Stanford's online Coursera course on Automata Theory. The course is no longer available, but the video lectures have been put on YouTube.
• New Turing Omnibus by A. K. Dewdney
• The Annotated Turing by Charles Petzold
• Logic by Wilfrid Hodges
• Predicate and Propositional Logic: A Model of Argument by Derek Goldrei
• Representing Turing Machines, available here.