1. Define Turing Machine. Explain the Components of a Turing Machine.
A Turing Machine (TM) is a theoretical computational model introduced by Alan Turing in 1936. It
provides a framework for defining what can be computed and serves as the foundation of modern
computation.
Formal Definition
A Turing Machine is a 7-tuple:
M=(Q,Σ,Γ,δ,q0,qaccept,qreject)M = (Q, \Sigma, \Gamma, \delta, q_0, q_{accept},
q_{reject})M=(Q,Σ,Γ,δ,q0,qaccept,qreject)
Where:
1. QQQ: Finite set of states.
2. Σ\SigmaΣ: Input alphabet.
3. Γ\GammaΓ: Tape alphabet (Σ⊆Γ\Sigma \subseteq \GammaΣ⊆Γ).
4. δ\deltaδ: Transition function δ:Q×Γ→Q×Γ×{L,R}\delta: Q \times \Gamma \to Q \times \
Gamma \times \{L, R\}δ:Q×Γ→Q×Γ×{L,R}.
5. q0q_0q0: Initial state.
6. qacceptq_{accept}qaccept: Accept state.
7. qrejectq_{reject}qreject: Reject state.
Components of Turing Machine
1. Tape:
o The tape is infinite and divided into cells.
o Each cell contains a symbol from the tape alphabet Γ\GammaΓ.
o Blank symbols BBB fill unused cells.
2. Head:
o The head performs three actions:
Reads the symbol on the tape.
Writes a symbol (modifies content).
Moves left LLL or right RRR one cell at a time.
3. State Register:
o Keeps track of the machine's current state.
o States include:
Initial state q0q_0q0: Starting point.
Accept state qacceptq_{accept}qaccept: Halts the computation and accepts
input.
Reject state qrejectq_{reject}qreject: Halts and rejects input.
4. Transition Function δ\deltaδ:
o A function that defines the machine's movement.
o Example: δ(q1,a)=(q2,X,R)\delta(q_1, a) = (q_2, X, R)δ(q1,a)=(q2,X,R).
In state q1q_1q1, on reading aaa, write XXX, move right, and go to state
q2q_2q2.
5. Input Alphabet Σ\SigmaΣ:
o The set of allowed symbols in the input.
6. Tape Alphabet Γ\GammaΓ:
o Includes the input alphabet Σ\SigmaΣ plus additional symbols like blanks.
7. Blank Symbol BBB:
o Denotes the empty or unused portion of the tape.
Working of Turing Machine
1. Initialization: The TM starts in q0q_0q0 with the head on the first symbol of the input tape.
2. Read-Write-Move: Based on δ\deltaδ, the machine reads a symbol, writes a symbol, and
moves left/right.
3. State Transition: Moves to a new state based on the transition rules.
4. Halting: The machine stops when it reaches qacceptq_{accept}qaccept or
qrejectq_{reject}qreject.
Universal Turing Machine (UTM)
The Universal Turing Machine (UTM) is a theoretical Turing Machine that can simulate the behavior
of any other Turing Machine. It was introduced by Alan Turing in 1936 and plays a critical role in the
foundations of computability theory.
Definition
A Universal Turing Machine is a Turing Machine UUU that takes as input:
1. Description of another Turing Machine MMM (encoded as a string).
2. Input string www for MMM.
The UTM UUU then simulates the operation of MMM on www and produces the same output as
MMM would.
Formal Explanation
The UTM works as follows:
It reads the description of MMM encoded on its input tape.
It simulates each step of MMM on the input www.
The UTM halts if MMM halts and produces the same output.
Thus, the UTM behaves like a general-purpose computer that can execute any algorithm, provided
the algorithm (TM MMM) is described as input.
Components of UTM
1. Input:
o The input tape of UUU contains the following:
A description of the Turing Machine MMM (instructions for MMM).
The input string www to be processed by MMM.
2. Encoding:
o The description of MMM is encoded in a specific format (e.g., as strings of 0's and
1's).
3. Simulation:
o UUU uses the description of MMM to simulate its transitions step-by-step.
Working of Universal Turing Machine
1. Input Encoding:
o MMM's description and the input string www are concatenated and provided as
input to UUU.
o The description of MMM includes its states, tape alphabet, input alphabet, and
transition function.
2. Simulation Process:
o UUU scans the input tape and interprets MMM's description.
o UUU uses MMM's transition rules to simulate the head movement, symbol writing,
and state transitions.
3. Execution:
o UUU continues to execute MMM's steps until MMM halts (either accept or reject
state).
o If MMM halts, UUU produces the same output as MMM.
Significance of UTM
1. Foundation of Modern Computers:
o The concept of UTM laid the groundwork for modern general-purpose computers.
o Modern computers act as a UTM because they can execute any program.
2. Computability:
o UTM proves that a single machine can simulate any other machine, highlighting the
universality of computation.
3. Stored-Program Concept:
o In a UTM, both the program (description of MMM) and data (input www) are
provided as input, mirroring the stored-program architecture in modern computers.
4. Turing-Completeness:
o UTM establishes the concept of Turing-completeness, meaning any computational
system that can simulate a UTM is as powerful as any other computational model.
Example of UTM
Suppose there is a Turing Machine MMM that adds 1 to a binary number:
MMM's description includes states, symbols, and transitions to perform the addition.
The input www is "101" (binary 5).
The UTM UUU takes the description of MMM and input www on its tape.
UUU simulates MMM's operation, and the output becomes "110" (binary 6).
Diagram of UTM
Draw a diagram illustrating the input tape containing:
1. Encoded description of MMM.
2. Input string www.
Show the head movement and state transitions as UUU simulates MMM.
Conclusion
The Universal Turing Machine is a significant theoretical model that demonstrates the power of
computation. It shows that a single machine can simulate any other machine, which forms the basis
for modern computers and programming languages.
1. Deterministic Turing Machine (DTM)
Definition: A DTM has a single, unambiguous transition for each state and input symbol.
Characteristics: Predictable behavior with no ambiguity in transitions.
Example: A DTM that recognizes the language L={anbn∣n≥1}L = \{a^n b^n | n \geq
1\}L={anbn∣n≥1} processes each symbol in a fixed sequence.
2. Non-Deterministic Turing Machine (NDTM)
Definition: An NDTM can have multiple possible transitions for a given state and input
symbol.
Characteristics: Allows for multiple computation paths; accepts input if any path leads to an
accept state.
Example: An NDTM that recognizes the language L={anbncn∣n≥1}L = \{a^n b^n c^n | n \geq
1\}L={anbncn∣n≥1} can "guess" the correct positions of symbols.
3. Multi-Tape Turing Machine (MTTM)
Definition: An MTTM has multiple tapes and heads, enabling parallel processing.
Characteristics: Each tape can hold separate information, allowing simultaneous operations.
Example: An MTTM can use one tape for aaa's and another for bbb's to compare them in
parallel.
4. Linear Bounded Automaton (LBA)
Definition: An LBA is a restricted Turing Machine with tape space limited to a linear function
of the input size.
Characteristics: Operates within space constraints; recognizes context-sensitive languages.
Example: An LBA can recognize the language L={anbn∣n≥1}L = \{a^n b^n | n \geq
1\}L={anbn∣n≥1} by using linear space to compare counts of aaa's and bbb's.
5. Universal Turing Machine (UTM)
Definition: A UTM can simulate any other Turing Machine on any input.
Characteristics: Serves as a model for general-purpose computation; forms the basis of
modern computers.
Example: A UTM can simulate a DTM that adds two numbers by processing the appropriate
instructions.
Post Correspondence Problem (PCP)
The Post Correspondence Problem (PCP) is a well-known undecidable problem in computability
theory. It was introduced by Emil Post in 1946 and is important in understanding the limits of
algorithmic decision-making.
Definition
The Post Correspondence Problem consists of a set of pairs of strings. The task is to determine if
there is a sequence of these pairs that can be concatenated in such a way that the strings on the top
of the pairs match the strings on the bottom after concatenation.
Formally:
You are given a set {(u1,v1),(u2,v2),…,(un,vn)}\{(u_1, v_1), (u_2, v_2), \dots, (u_n, v_n)\}{(u1
,v1),(u2,v2),…,(un,vn)}, where each uiu_iui and viv_ivi are strings (made up of symbols,
usually from a finite alphabet).
The goal is to find a sequence of indices i1,i2,…,iki_1, i_2, \dots, i_ki1,i2,…,ik such that:
ui1ui2…uik=vi1vi2…viku_{i_1} u_{i_2} \dots u_{i_k} = v_{i_1} v_{i_2} \dots v_{i_k}ui1ui2…uik
=vi1vi2…vik In other words, the concatenation of the top strings uuu's should be equal to the
concatenation of the bottom strings vvv's.
If such a sequence exists, we say the instance of PCP is solvable; otherwise, it's not.
Example of PCP
Consider the following set of pairs of strings:
(u1,v1)=(ab,a)(u_1, v_1) = (ab, a)(u1,v1)=(ab,a)
(u2,v2)=(b,ab)(u_2, v_2) = (b, ab)(u2,v2)=(b,ab)
(u3,v3)=(a,b)(u_3, v_3) = (a, b)(u3,v3)=(a,b)
We are tasked with finding a sequence of indices that satisfies the condition ui1ui2…uik=vi1vi2…
viku_{i_1} u_{i_2} \dots u_{i_k} = v_{i_1} v_{i_2} \dots v_{i_k}ui1ui2…uik=vi1vi2…vik.
Step-by-Step Solution:
1. Start with the pair (u1,v1)=(ab,a)(u_1, v_1) = (ab, a)(u1,v1)=(ab,a).
o We have u1=abu_1 = abu1=ab and v1=av_1 = av1=a.
2. Next, consider (u2,v2)=(b,ab)(u_2, v_2) = (b, ab)(u2,v2)=(b,ab).
o u2=bu_2 = bu2=b and v2=abv_2 = abv2=ab.
3. Finally, take (u3,v3)=(a,b)(u_3, v_3) = (a, b)(u3,v3)=(a,b).
o u3=au_3 = au3=a and v3=bv_3 = bv3=b.
Now, we try to build sequences using these pairs.
Let’s try using pair 1, pair 2, and pair 3.
Start by taking u1=abu_1 = abu1=ab and v1=av_1 = av1=a.
o Current concatenation of uuu's: ababab
o Current concatenation of vvv's: aaa
Then, add u2=bu_2 = bu2=b and v2=abv_2 = abv2=ab.
o New concatenation of uuu's: ab+b=abbab + b = abbab+b=abb
o New concatenation of vvv's: a+ab=aaba + ab = aaba+ab=aab
Finally, add u3=au_3 = au3=a and v3=bv_3 = bv3=b.
o New concatenation of uuu's: abb+a=abbaabb + a = abbaabb+a=abba
o New concatenation of vvv's: aab+b=aabbaab + b = aabbaab+b=aabb
At this point, the concatenated top strings uuu's (abbaabbaabba) and bottom strings vvv's
(aabbaabbaabb) are not equal.
Let's try another approach.
First, choose pair 1: u1=abu_1 = abu1=ab and v1=av_1 = av1=a.
o Current top string: ababab
o Current bottom string: aaa
Add pair 2: u2=bu_2 = bu2=b and v2=abv_2 = abv2=ab.
o New top string: ab+b=abbab + b = abbab+b=abb
o New bottom string: a+ab=aaba + ab = aaba+ab=aab
Add pair 1 again: u1=abu_1 = abu1=ab and v1=av_1 = av1=a.
o New top string: abb+ab=abbababb + ab = abbababb+ab=abbab
o New bottom string: aab+a=aabaaab + a = aabaaab+a=aaba
Now we see that the top and bottom strings match:
u1u2u1u_1 u_2 u_1u1u2u1 (i.e., ab,b,abab, b, abab,b,ab) gives abbababbababbab
v1v2v1v_1 v_2 v_1v1v2v1 (i.e., a,ab,aa, ab, aa,ab,a) gives aabaaabaaaba
This sequence does not work.
Undecidability
In computability theory, undecidability refers to problems or decision problems that cannot be
solved by any algorithm. In other words, there is no Turing Machine (or equivalent computational
model) that can determine the solution for all possible inputs within a finite amount of time.
What makes a problem undecidable?
A problem is undecidable if there is no algorithm that can always provide a correct "yes" or "no"
answer for every possible input in a finite amount of time. This means that there is no systematic,
mechanical procedure that works for all cases.
Example: The Halting Problem
One of the most famous examples of an undecidable problem is the Halting Problem.
The Halting Problem:
The problem asks: "Given a program and its input, will the program eventually halt (stop running),
or will it run forever?"
More formally, the Halting Problem can be described as follows:
Given a Turing Machine MMM and an input www, we need to determine whether MMM will
halt when run on input www.
Why is it Undecidable?
In 1936, Alan Turing proved that there is no algorithm (i.e., no Turing Machine) that can solve the
Halting Problem for all possible program-input pairs. Here's a simplified explanation of why:
Suppose there exists a machine HHH that can decide whether any program MMM halts on
input www. That means for every program MMM and input www, HHH would tell us "yes,
MMM halts on www" or "no, MMM does not halt on www".
Now, let's create a new program DDD that uses HHH and behaves in this way:
o DDD takes a program MMM as input.
o It runs HHH on MMM with MMM as its own input.
o If HHH says "yes" (i.e., MMM halts on input MMM), then DDD goes into an infinite
loop.
o If HHH says "no" (i.e., MMM does not halt on input MMM), then DDD halts
immediately.
Now, what happens when we run DDD with itself as input? Let's analyze it:
If HHH says that DDD halts when run on DDD, then DDD should go into an infinite loop (by its
design), which is a contradiction.
If HHH says that DDD doesn't halt on DDD, then DDD halts immediately, which is also a
contradiction.
This paradox shows that no such algorithm HHH can exist. Therefore, the Halting Problem is
undecidable.
Conclusion
Undecidable problems are those for which no algorithm can be written to solve all instances of the
problem. The Halting Problem is a classic example, where no algorithm can determine whether any
given program will halt or run forever.
1. The Halting Problem
The Halting Problem asks whether there is an algorithm that can determine, for any given program
PPP and input III, whether PPP will halt (finish execution) or run forever.
Why is it important?
The Halting Problem was proven to be undecidable by Alan Turing. This means there is no general
algorithm that can solve the problem for all possible programs and inputs.
Turing's Proof (Simplified):
1. Assume there is an algorithm HHH that can decide if a program halts or not.
2. Create a program DDD that, given a program PPP, runs H(P,P)H(P, P)H(P,P):
o If HHH says "Yes" (program halts), DDD goes into an infinite loop.
o If HHH says "No" (program doesn’t halt), DDD halts immediately.
3. Now, ask what happens when DDD is given itself as input. The paradox arises because DDD
cannot behave consistently in both cases, leading to the conclusion that no such algorithm
HHH exists. Thus, the Halting Problem is undecidable.
2. Linear Bounded Automaton (LBA)
A Linear Bounded Automaton (LBA) is a type of Turing Machine with a space limit: it can only use a
tape size proportional to the input size.
Key Features:
Space constraint: An LBA can use only a linear amount of tape in relation to the input size.
Context-sensitive languages: LBAs can recognize context-sensitive languages, which require
a Turing Machine with limited tape but are more complex than regular and context-free
languages.
Example:
Consider the language L={anbn∣n≥1}L = \{ a^n b^n | n \geq 1 \}L={anbn∣n≥1}. An LBA can decide this
language by comparing the number of aaa's and bbb's, using a tape size proportional to the input.
Conclusion:
LBAs are less powerful than general Turing Machines (which have unlimited tape) but can still
recognize certain complex languages, specifically context-sensitive languages.
Recursive Language and Recursively Enumerable Language
1. Recursive Language (Decidable Languages)
A recursive language (also known as a decidable language) is a language for which there exists a
Turing Machine that will always halt and decide whether a given string belongs to the language or
not. In other words, the Turing Machine will accept the string if it is in the language and reject it if it
is not, and it will always halt (finish) in both cases.
Key Property: A recursive language is decidable because a Turing Machine can decide
membership in the language in finite time for any input.
Example:
o Consider the language L={w∣w is a binary string of even length}L = \{ w | w \text{ is a
binary string of even length} \}L={w∣w is a binary string of even length}.
o A Turing Machine can check if the string has an even number of symbols by scanning
the string and counting the symbols, ensuring it halts after reading all symbols. If the
number is even, it accepts; otherwise, it rejects.
2. Recursively Enumerable Language (Turing-Recognizable Language)
A recursively enumerable language (also known as a Turing-recognizable language) is a language for
which there exists a Turing Machine that will accept any string in the language, but may not halt for
strings that are not in the language. In other words, the Turing Machine can recognize strings in the
language, but it might run indefinitely for strings outside the language.
Key Property: A recursively enumerable language is Turing-recognizable, meaning there
exists a Turing Machine that can recognize if a string belongs to the language, but it may not
halt if the string is not part of the language.
Example:
o Consider the language
L={w∣w is a valid mathematical proof of a theorem in a formal system}L = \{ w | w \
text{ is a valid mathematical proof of a theorem in a formal
system} \}L={w∣w is a valid mathematical proof of a theorem in a formal system}.
o A Turing Machine can check if a string is a valid proof by attempting to verify the
proof step by step. If the proof is valid, it will eventually halt and accept the string.
However, if the proof is invalid or incomplete, the machine may run forever, as it
can’t always determine when the proof ends.
Difference Between Recursive and Recursively Enumerable Languages:
Recursive languages are a subset of recursively enumerable languages. All recursive
languages are recursively enumerable, but not all recursively enumerable languages are
recursive.
The key difference is that for recursive languages, the Turing Machine always halts, while for
recursively enumerable languages, the Turing Machine may not halt for some strings (those
not in the language).