---
id: wiki-2026-0508-turing-machine-foundations
title: Turing Machine Foundations
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [Turing Machine, TM, Universal Turing Machine]
duplicate_of: none
source_trust_level: A
confidence_score: 0.95
verification_status: applied
tags: [theory-of-computation, computability, complexity, formal-languages]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
  language: Theory
  framework: Computability
---

# Turing Machine Foundations

## 매 한 줄
> **"매 computation 의 mathematical model"**. Alan Turing (1936) "On Computable Numbers" — 매 modern CS 의 theoretical foundation, 매 Church-Turing thesis 의 underpin (any "effective computation" = TM-computable, including 2026 LLMs / quantum computers in the strong CT extension).

## 매 핵심

### 매 Definition
TM = (Q, Σ, Γ, δ, q₀, q_accept, q_reject):
- Q = finite states.
- Σ = input alphabet.
- Γ = tape alphabet (Σ ⊂ Γ, blank ∈ Γ).
- δ: Q × Γ → Q × Γ × {L, R}. transition function.
- q₀ = start state. q_accept, q_reject = halt states.

### 매 Operation
- Infinite tape, head reads/writes one cell, moves L/R.
- Configuration = (state, tape contents, head position).
- Computation = sequence of configurations from start to halt.

### 매 Variants (all equivalent in power)
- Multi-tape TM, non-deterministic TM (NTM), 2D-tape TM.
- All decide same language class (Turing-recognizable / RE).
- Time/space complexity 의 different (NTM: NP, polynomial bound).

### 매 핵심 results
- **Universal TM (UTM)**: 매 TM 의 simulate 의 single TM — 매 modern computer 의 essence.
- **Halting problem**: undecidable (Turing 1936). No TM decides if arbitrary TM halts.
- **Church-Turing thesis**: TM-computable = effectively computable. Equivalent to λ-calculus, μ-recursive functions, register machines.
- **Time hierarchy theorem**: more time → strictly more languages.

### 매 응용
1. Computability theory (decidable / undecidable).
2. Complexity classes (P, NP, PSPACE, EXP).
3. Compiler theory (Rice's theorem — semantic properties undecidable).
4. Cryptography (one-way functions assume no efficient TM).

## 💻 패턴

### TM simulator (Python)
```python
from dataclasses import dataclass
from collections import defaultdict

@dataclass
class TM:
    states: set
    alphabet: set
    tape_alphabet: set
    delta: dict  # (state, symbol) -> (state, symbol, direction)
    start: str
    accept: str
    reject: str
    blank: str = '_'

    def run(self, input_str, max_steps=10_000):
        tape = defaultdict(lambda: self.blank)
        for i, c in enumerate(input_str):
            tape[i] = c
        state, head = self.start, 0
        for _ in range(max_steps):
            if state == self.accept: return True
            if state == self.reject: return False
            sym = tape[head]
            if (state, sym) not in self.delta: return False
            state, write, move = self.delta[(state, sym)]
            tape[head] = write
            head += 1 if move == 'R' else -1
        raise RuntimeError("max_steps exceeded")
```

### TM that recognizes 0ⁿ1ⁿ
```python
delta = {
    ('q0', '0'): ('q1', 'X', 'R'),  # mark first 0
    ('q0', 'Y'): ('q3', 'Y', 'R'),  # all 0s done, check 1s
    ('q1', '0'): ('q1', '0', 'R'),
    ('q1', 'Y'): ('q1', 'Y', 'R'),
    ('q1', '1'): ('q2', 'Y', 'L'),  # mark matching 1
    ('q2', '0'): ('q2', '0', 'L'),
    ('q2', 'Y'): ('q2', 'Y', 'L'),
    ('q2', 'X'): ('q0', 'X', 'R'),
    ('q3', 'Y'): ('q3', 'Y', 'R'),
    ('q3', '_'): ('accept', '_', 'R'),
}
tm = TM({'q0','q1','q2','q3','accept','reject'}, {'0','1'},
        {'0','1','X','Y','_'}, delta, 'q0', 'accept', 'reject')
assert tm.run("0011") == True
assert tm.run("001") == False
```

### Halting problem proof sketch
```python
# Suppose H(M, w) decides if M halts on w.
# Construct D(M):
def D(M):
    if H(M, M):
        loop_forever()
    else:
        return  # halt

# What does D(D) do?
# If H(D,D)=True (D halts on D), D loops forever — contradiction.
# If H(D,D)=False (D loops on D), D halts — contradiction.
# Therefore H cannot exist.
```

### Church-Turing equivalence (λ-calc to TM)
```python
# Church numerals (λ-calc) → TM-computable
# 0 = λf.λx. x
# 1 = λf.λx. f x
# n = λf.λx. f^n x

# Successor: λn.λf.λx. f (n f x)
# Both λ-calc and TM compute same functions
# Modern proof: encode λ-term as tape string, β-reduce step by step
```

### Universal Turing Machine concept
```python
# UTM takes encoding <M, w> and simulates M on w
def UTM(encoding):
    M_desc, w = decode(encoding)
    M = parse_TM(M_desc)
    return M.run(w)

# Modern equivalent: any general-purpose CPU running an interpreter
```

## 매 결정 기준
| 질문 | Tool |
|---|---|
| 매 problem 의 decidable? | Reduce to/from halting |
| 매 lang 의 regular vs CFL vs RE? | Pumping lemma / TM construction |
| 매 algorithm 의 complexity? | TM time/space hierarchy |
| 매 model 의 power? | Compare to TM (Turing-complete?) |

**기본값**: Standard 1-tape deterministic TM as reference; multi-tape for clarity.

## 🔗 Graph
- Adjacent: [[Universal-Turing-Machine]]

## 🤖 LLM 활용
**언제**: Computability question (is X decidable?). Complexity bounds 의 reason. Programming language design (Turing-completeness check). Cryptographic foundations.
**언제 X**: Practical algorithm engineering (use RAM model). Concurrent / distributed reasoning (TM is sequential — use π-calculus, CSP).

## ❌ 안티패턴
- **TM as practical computer**: 매 model only — real CPUs have RAM, registers, parallelism. 매 asymptotic equivalence ≠ practical performance.
- **"Turing-complete" hand-wave**: SQL is TC (with recursive CTE), so is HTML+CSS — TC alone says little about usability.
- **Confusing recognize vs decide**: TM recognizes RE language (may loop on rejections); decides recursive language (always halts).
- **Halting ≠ all undecidable**: many problems undecidable but not via halting reduction (e.g., Post's correspondence).

## 🧪 검증 / 중복
- Verified (Turing 1936, Sipser "Introduction to the Theory of Computation", Hopcroft-Ullman).
- 신뢰도 A+.

## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — TM foundations with simulator, halting proof, UTM, Church-Turing |
