From Logic to Computation
- Propositional Logic: Formulas, truth tables, CNF/DNF normal forms
- Inference Rules: Modus Ponens, Modus Tollens, Hypothetical Syllogism
- The SAT Problem: Given a CNF formula, is there a satisfying assignment?
- Proof Techniques: Mathematical induction, formal step-by-step proofs
The Natural Next Question
\( p \to q, \quad p \quad \therefore \quad q \)
Each step is mechanicalβwe apply a fixed rule to derive new truths. This raises a profound question:
"Can we build a machine that automatically discovers proofs for any mathematical statement?"
Think of it this way: Given a formula like \( \forall x (P(x) \to Q(x)) \), can a machine tell us if it's always true?
This is exactly what Turing Machines were invented to answer!
From SAT to Computation
\( (p \lor \neg q) \land (\neg p \lor r) \land (q \lor \neg r) \)
Is there an assignment of truth values that makes it true?
Observation: We can verify a solution mechanically (just substitute and evaluate), but finding a solution seems harder. How hard? Turing Machines help us precisely answer this!
π The Bridge: Proofs β Algorithms β Computation
Lecture 2-3: We learned that proofs are sequences of logical steps.
Key Insight: Each inference rule (Modus Ponens, etc.) is like an instruction.
Natural Question: What if we had infinitely many instructions? What can be computed?
Lecture 4: Turing Machines give us a precise definition of "algorithm" and "computable."
Why Turing Machines in a Mathematics Course?
- Decidability: Which mathematical questions can be answered by algorithms?
- Computability: Which functions can be computed mechanically?
- Complexity: Even if solvable, how much time/space does a solution require?
Turing's answer to the Entscheidungsproblem was negativeβnot all logical truths can be decided algorithmically! This fundamental result shapes modern computer science and mathematics.
In this lecture, we'll define Turing Machines formally and see how they capture the intuitive notion of "mechanical computation." Later, we'll use TMs to prove that certain problems (like the Halting Problem) are undecidableβno algorithm exists to solve them!
Introduction to Mechanical Computation
Connection to Proofs: Just as we chain inference rules (Modus Ponens β Simplification β Modus Tollens) to build proofs, an algorithm chains elementary operations to solve problems.
Alan Turing and the 1936 Paper
In 1936, Alan Turing introduced the "Automatic Machine" (now called the Turing Machine). His goal was to answer Hilbert's Entscheidungsproblem (the Decision Problem) that we discussed in the previous tab.
- Physical Intuition: Turing modeled his machine on a human "computer" (a person performing calculations) with a pencil, paper, and a set of instructionsβmuch like following inference rules!
- Simplicity: By reducing computation to the simplest possible steps (reading/writing a symbol, moving a head), he provided a rigorous foundation for what "mechanical" means.
This negative result is actually liberatingβit tells us exactly where the boundaries of mechanical reasoning lie.
The Universality of Turing Machines
Note: This is a thesis, not a mathematical theorem, because it connects an informal concept to a formal one. To date, no model of computation has been found that is more powerful than a Turing Machine.
π Why Universal?
Before UTMs, machines were built for specific tasks. Turing's insight was that data and instructions are the same thing. If you can encode a machine's behavior as symbols on a tape, then another machine can read those symbols and act accordingly.
Formal Definition of a DTM
- \( Q \): A finite set of states.
- \( \Sigma \): A finite set of input symbols (subset of \( \Gamma \setminus \{B\} \)).
- \( \Gamma \): A finite set of tape symbols.
- \( \delta \): The transition function: \( Q \times \Gamma \to Q \times \Gamma \times \{L, R\} \).
- \( q_0 \): The initial state (\( q_0 \in Q \)).
- \( B \): The blank symbol (\( B \in \Gamma \), but \( B \notin \Sigma \)).
- \( F \): The set of final or accepting states (\( F \subseteq Q \)).
Understanding the Transition Function
- Change state to \( p \).
- Write symbol \( b \) on the current cell (replacing \( a \)).
- Move the head in direction \( D \) (\( L \) for Left, \( R \) for Right).
The Tape and Head Mechanism
π The Infinite Tape
The tape is divided into cells, each capable of holding one symbol from \( \Gamma \). It is infinite in both directions (or semi-infinite in some models). Initially, the tape contains the input string followed by infinite "Blank" ($B$) symbols.
- It **reads** the symbol at the current cell.
- It **writes** a new symbol (can be the same).
- It **moves** one cell to the left or right.
For any given state and symbol, there is at most one transition possible. This means the path of computation is a single line, never branching.
Interactive TM Simulation
- $Q$ = $\{q_0, q_1, q_2, q_3, q_{\text{accept}}, q_{\text{reject}}\}$ β Set of states
- $\Sigma$ = $\{0, 1\}$ β Input alphabet
- $\Gamma$ = $\{0, 1, X, Y, B\}$ β Tape alphabet ($X$, $Y$ are markers, $B$ is blank)
- $\delta$ = Transition function (defined below)
- $q_0$ = Initial state
- $B$ = Blank symbol
- $F$ = $\{q_{\text{accept}}\}$ β Accepting states
The TM repeatedly "crosses off" matching pairs of $0$s and $1$s:
- Find leftmost unmarked $0$ β Mark it with $X$
- Scan right past all $0$s and $Y$s to find the leftmost unmarked $1$
- Mark the $1$ with $Y$
- Scan left back to the $X$ just placed, then move right to find next unmarked $0$
- Repeat until all $0$s are marked as $X$s
- Verify that only $Y$s remain (no leftover $1$s) β Accept
State Descriptions
$q_0$ β Start/Scan for 0
Look for leftmost unmarked $0$. If found, mark it $X$ and go to $q_1$. If we see $Y$, skip right to check for completion.
$q_1$ β Scan Right for 1
Move right, skipping $0$s and $Y$s. When we find a $1$, mark it $Y$ and switch to $q_2$.
$q_2$ β Return Left
Move left, skipping $0$s and $Y$s. When we hit $X$, move right and return to $q_0$.
$q_3$ β Verify Completion
All $0$s are marked. Scan right to ensure only $Y$s and blanks remain. If so, accept.
Complete Transition Function $\delta$
Format: $\delta(\text{state}, \text{read}) = (\text{new state}, \text{write}, \text{move})$
| Current State | Read Symbol | Write Symbol | Move | Next State | Explanation |
|---|---|---|---|---|---|
| $q_0$ | $0$ | $X$ | R | $q_1$ | Mark leftmost 0, start searching for matching 1 |
| $q_0$ | $Y$ | $Y$ | R | $q_3$ | No more 0s; verify all 1s are marked |
| $q_0$ | $B$ | $B$ | R | $q_{\text{accept}}$ | Empty input $\varepsilon$ is valid ($0^0 1^0$) |
| $q_1$ | $0$ | $0$ | R | $q_1$ | Skip over remaining 0s |
| $q_1$ | $Y$ | $Y$ | R | $q_1$ | Skip over previously marked 1s |
| $q_1$ | $X$ | $X$ | R | $q_1$ | Skip over marked 0s |
| $q_1$ | $1$ | $Y$ | L | $q_2$ | Found matching 1; mark it Y, go back |
| $q_1$ | $B$ | $B$ | L | $q_{\text{reject}}$ | Ran out of 1s before matching all 0s |
| $q_2$ | $0$ | $0$ | L | $q_2$ | Move left past 0s |
| $q_2$ | $Y$ | $Y$ | L | $q_2$ | Move left past marked 1s |
| $q_2$ | $X$ | $X$ | R | $q_0$ | Reached last marked 0; restart from next cell |
| $q_3$ | $Y$ | $Y$ | R | $q_3$ | Skip past marked 1s |
| $q_3$ | $B$ | $B$ | R | $q_{\text{accept}}$ | All 1s matched; accept! |
| $q_3$ | $0$ | $0$ | R | $q_{\text{reject}}$ | Leftover 0s (shouldn't happen in valid path) |
| $q_3$ | $1$ | $1$ | R | $q_{\text{reject}}$ | Leftover 1s; more 1s than 0s |
Example Computation Trace
Configuration format: tape content with underline showing head position, state in
parentheses
- $(q_0)$ 0011B β Write X, move R β $X$011B
- $(q_1)$ X011B β Skip 0, move R β X011B
- $(q_1)$ X011B β Write Y, move L β X0Y1B
- $(q_2)$ X0Y1B β Skip 0, move L β X0Y1B
- $(q_2)$ X0Y1B β Found X, move R β X0Y1B
- $(q_0)$ X0Y1B β Write X, move R β XXY1B
- $(q_1)$ XXY1B β Skip Y, move R β XXY1B
- $(q_1)$ XXY1B β Write Y, move L β XXYYB
- $(q_2)$ XXYYB β Skip Y, move L β XXYYB
- $(q_2)$ XXYYB β Found X, move R β XXYYB
- $(q_0)$ XXYYB β No more 0s, enter $q_3$ β XXYYB
- $(q_3)$ XXYYB β Skip Y, move R β XXYYB
- $(q_3)$ XXYYB β Blank reached β ACCEPT!
Try It Yourself
π― Test the TM
Enter a string of 0s and 1s below. Valid strings in $L$ include: "", "01", "0011", "000111", etc.
Try an invalid string like "0111" or "0010" to see rejection!