Turing Machines
Chapter overview: Turing machines provide a simple mathematical model of general computation. Several apparently different models—including RAM machines, Post systems, lambda calculus, and Markov algorithms—can express the same broad class of effectively computable functions.
5.1 Turing Machines
Introduction / Definition
A Turing machine consists of finite control, an unbounded tape, a read/write head, and transition rules. A standard formal model is M=(Q,Σ,Γ,δ,q₀,q_accept,q_reject). The tape acts as unbounded memory and the machine can read, write, and move left or right.
Syntax / Structure / Formula
δ(q,a) = (p,b,D)
D ∈ {L,R}
M=(Q,Σ,Γ,δ,q₀,q_accept,q_reject)
Detailed Explanation
A simple machine can scan a binary string and replace every 0 with 1. It reads the current symbol, writes the replacement, moves right, and eventually enters an accepting state.
Example
Input: 00101
Transitions replace 0→1 and keep 1→1
Output / Result
Output tape: 11011.
Important Points / Notes
- Tape provides unbounded storage in the idealized model.
- Transition function controls read/write/move behavior.
- Turing machines define a foundational notion of algorithmic computability.
Mini Practice Question
List the four main actions/components involved when a Turing machine processes a tape cell.
5.2 RAM Cost Models
Introduction / Definition
A Random Access Machine (RAM) model is an abstract computer model in which memory locations can be accessed directly by address. RAM models are useful for analyzing algorithmic time more closely than a simple Turing-machine step count. Different cost models assign different costs to arithmetic, memory access, and word operations.
Syntax / Structure / Formula
- Cost(T) = Σ cost(operation_i)
Detailed Explanation
In a unit-cost RAM model, a basic arithmetic or memory operation may be treated as O(1). In more realistic bit-cost models, operations on large integers may cost more because their bit lengths grow.
Example
Loop performing n constant-time RAM operations:
T(n) = c·n = O(n)
Output / Result
The running time is linear under the stated unit-cost assumptions.
Important Points / Notes
- Cost depends on the model.
- Unit-cost and bit-cost models can differ.
- RAM models are useful for practical algorithm analysis.
Mini Practice Question
Why might multiplication of very large integers not be treated as O(1) in a bit-cost model?
5.3 Post Systems
Introduction / Definition
A Post system is a formal rewriting model of computation based on strings and production rules. It was developed as an alternative formalism for defining effective computation. The system repeatedly applies permitted rules to transform strings.
Syntax / Structure / Formula
- String + production rules → sequence of rewritten strings
Detailed Explanation
A rule may replace a substring with another string. By carefully designing rules, a Post system can encode general computations. Its importance is theoretical because it provides a model independent of conventional machine architecture.
Example
Rule: AB → BA
Start: AABB
AABB → ABAB → BAAB → BABA ...
Output / Result
The string changes according to the available rewriting rule.
Important Points / Notes
- Post systems are rewriting-based.
- They are equivalent in broad computability power to other general models.
- They help demonstrate that computation is not tied to one machine architecture.
Mini Practice Question
What makes a rewriting system computational rather than merely textual substitution?
5.4 Lambda Calculus
Introduction / Definition
Lambda calculus is a formal system based on functions, application, and substitution. It provides a mathematical foundation for studying computation and functional programming. A lambda expression can represent a function without naming it explicitly.
Syntax / Structure / Formula
λx.E
Application: (λx.E) A
β-reduction: (λx.E) A → E[x:=A]
Detailed Explanation
The expression λx.x represents the identity function. Applying it to y substitutes y for x, producing y. Lambda calculus can encode numbers, booleans, recursion, and general computation.
Example
(λx.x) y → y
Output / Result
Result: y.
Important Points / Notes
- Core operations are abstraction and application.
- β-reduction models function application.
- Lambda calculus is computationally equivalent in expressive power to Turing machines.
Mini Practice Question
Reduce (λx.x+1) 4.
5.5 Markov Algorithms
Introduction / Definition
Markov algorithms are string-rewriting systems that use an ordered list of production rules. The algorithm searches for an applicable rule and applies the first applicable rule according to its control convention. They provide another formal model of computation.
Syntax / Structure / Formula
Rule 1: pattern → replacement
Rule 2: pattern → replacement
...
Apply the first applicable rule.
Detailed Explanation
The ordering of rules is important. A terminating rule can explicitly signal completion. Markov algorithms can represent general computations despite their simple string-based mechanism.
Example
Rules:
AB → C
A → D
Input: AAB
Output / Result
The first applicable rule is selected according to the system's matching convention, producing a sequence of rewrites.
Important Points / Notes
- Rule ordering matters.
- They are based on string transformations.
- They are equivalent in computability power to standard general computation models.
Mini Practice Question
Why does rule ordering matter in a Markov algorithm?
5.6 Mutual Equivalences
Introduction / Definition
Several formal computational models have been shown to have the same broad class of computable functions. Turing machines, lambda calculus, recursive functions, Post systems, and other suitable general mechanisms can simulate one another. This is evidence that computability is a robust mathematical concept rather than an artifact of one notation.
Syntax / Structure / Formula
Turing machines ≡ λ-calculus ≡ recursive functions ≡ Post-style systems
(in computability power)
Detailed Explanation
Equivalence here means same class of effectively computable functions, not equal syntax, memory usage, or running time. A translation or simulation can encode one model inside another.
Example
Algorithm A represented as a TM
↔ encoded as a lambda term
↔ represented by recursive functions
Output / Result
The same computable input-output behavior can be represented in different formalisms.
Important Points / Notes
- Computability equivalence does not imply complexity equivalence.
- Simulations may incur overhead.
- Different models are useful for different proofs or programming styles.
Mini Practice Question
Does computational equivalence mean two models always run an algorithm in the same amount of time? Explain.
5.7 Non-von-Neumann Languages
Introduction / Definition
Non-von-Neumann languages and computational models emphasize programming or computation styles that do not mirror the traditional sequential stored-program architecture. Examples include dataflow, logic programming, functional programming, and rewriting-based approaches. Their importance lies in alternative ways to express computation and exploit concurrency or declarative structure.
Syntax / Structure / Formula
Traditional: instructions + mutable memory
Alternative: values/dataflow/rules/functions
Detailed Explanation
A functional program describes transformations of values; a dataflow system can fire operations when their input data is available. These approaches can expose parallelism or simplify reasoning about state.
Example
Functional style:
result = map(square, [1,2,3,4])
Output / Result
Result: [1,4,9,16].
Important Points / Notes
- Different language models can have the same computational power.
- Programming model and machine architecture are separate concepts.
- Functional and logic languages often reduce explicit mutable state.
Mini Practice Question
Name one programming style that differs substantially from sequential imperative programming.