Basic Terminologies of Theory of Computation: Symbol
Basic Terminologies of Theory of Computation: Symbol
Basic Terminologies of Theory of Computation: Symbol
Symbol:
A symbol (often also called a character) is the smallest building block, which
can be any alphabet, numbers, or picture.
Alphabets (Σ):
Alphabets are a set of symbols, which are always finite.
String:
A string is a finite sequence of useful symbols from some alphabet. A string
is generally denoted as w and the length of a string is denoted as |w|.
Empty string is the string with zero occurrence of symbols,
represented as ε.
Number of Strings (of length 2)
that can be generated over the alphabet {a, b}:
- -
a a
a b
b a
b b
1
For alphabet {a, b} with length n, number of
strings can be generated = 2 n.
Empty String
Examples
Substring
Examples
Take the string 472828. Then ∧, 282, 4, and 472828 are all substrings of
472828.
2
Proper Prefix of a string: prefix other than the string itself is known as
proper prefix of a string.
Proper Suffix of a string: the suffix other than the string itself
is known as suffix of a string.
EXAMPLE: A= {0,1}
2A=[{},{0},{1},{0,1}]
Σ * = εL
3
Example:
Regular expression for language accepting all combination of g's over
Σ={g}:
L = g*
L={ε,g,gg,ggg,gggg,ggggg,...}
*******************************
Kleen Plus –
The set ∑+ is the infinite set of all possible strings of all possible lengths over ∑
excluding ε.
4
Chomsky hierarchy
According to Chomsky hierarchy grammar is divided into 4 types as
follows:
1. Type 0 is known as unrestricted grammar.
2. Type 1 is known as context-sensitive grammar.
3. Type 2 is known as a context-free grammar.
4. Type 3 Regular Grammar.
In type 0 there must be at least one variable on the Left side of production.
For example:
abS --> ba
A --> S
Here, Variables are S, A, and Terminals a, b.
5
Type 1: Context-Sensitive Grammar
Type-1 grammars generate context-sensitive languages. The language generated
by the grammar is recognized by the Linear Bound Automata
In Type 1
• First of all Type 1 grammar should be Type 0.
• Grammar Production in the form of
⍺ --> β
|⍺| <= |β|
That is the count of symbol in ⍺ is less than or equal to β
+
Also β ∈ (V + T)
i.e. β can not be ε
For Example:
S --> AB
AB --> abc
B --> b
6
S --> ab
A --> aaaaabbbbbbA
B --> abB
S --> ab
A --> Bab
B --> Sab
Finite Automata(FA):
Input tape: It is a linear tape having some number of cells. Each input symbol is placed
in each cell.
Finite control: The finite control decides the next state on receiving particular input
from input tape. The tape reader reads the cells one by one from left to right, and at a
time only one input symbol is read.
7
Σ : set of Input Symbols.
q : Initial state.
F : set of Final States.
δ : Transition Function.
Formal specification of machine is { Q, Σ, q, F, δ }
FA is characterized into two types:
1) Deterministic Finite Automata (DFA):
DFA consists of 5 tuples {Q, Σ, q, F, δ}.
Q : set of all states.
Σ : set of input symbols. ( Symbols which machine takes as input )
q : Initial state. ( Starting state of a machine )
F : set of final state.
δ : Transition Function, defined as δ : Q X Σ --> Q.
In a DFA, for a particular input character, the machine goes to one state only. A transition
function is defined on every state for every input symbol. Also in DFA null (or ε) move is
not allowed, i.e., DFA cannot change state without any input character.
For example, construct a DFA which accept a language of all strings ending with ‘a’.
Given: Σ = {a,b}, q = {q0}, F={q1}, Q = {q0, q1}
First, consider a language set of all the possible acceptable strings in order to construct
an accurate state transition diagram.
L = {a, aa, aaa, aaaa, aaaaa, ba, bba, bbbaa, aba, abba, aaba, abaa…….}
Above is simple subset of the possible acceptable strings there can many other strings
which ends with ‘a’ and contains symbols {a,b}.
8
⇣State \Symbol⇢ a b
q0 q1 q0
q1 q1 q0
One important thing to note is, there can be many possible DFAs for a pattern. A DFA
with a minimum number of states is generally preferred.
⇣State \Symbol⇢ a b
q0 {q0,q1} q0
9
⇣State \Symbol⇢ a b
q1 ∅ ∅
One important thing to note is, in NFA, if any path for an input string leads
to a final state, then the input string is accepted. For example, in the
above NFA, there are multiple paths for the input string “aa”. Since one of
the paths leads to a final state, “aa” is accepted by the above NFA.
DFA NFA
For each input symbol, there is For each input symbol, there may be
only one state transition in DFA. many state transition in NFA.
δ: QxΣ -> Q i.e. next possible δ: Qx(Σ U ε) -> 2^Q i.e. next possible
state belongs to Q. state belongs to power set of Q.
10
Output depends only upon the Output depends on the present state
present state. as well as present input.
Has more or the same states as that Has fewer or the same states as that
of the Mealy machine. of the Moore machine.
Pushdown Automata
Pushdown Automata is a finite automata with extra memory called stack
which helps Pushdown automata to recognize Context Free Languages.
• PDA Components:
• Input tape: The input tape is divided in many cells or symbols. The input head
is read-only and may only move from left to right, one symbol at a time.
• Finite control: The finite control has some pointer which points the current
symbol which is to be read.
• Stack: The stack is a structure in which we can push and remove the items from
one end only. It has an infinite size. In PDA, the stack is used to store the items
temporarily.
12
DPDA(Deterministic Pushdown NPDA(Non-deterministic
Automata) Pushdown Automata)
13
If it reaches an accept state, the computation is considered successful; if it
reaches a reject state, the computation is considered unsuccessful.
A turing machine consists of a tape of infinite length on which read and
writes operation can be performed. The tape consists of infinite cells on
which each cell either contains input symbol or a special symbol called
blank. It also consists of a head pointer which points to cell currently being
read and it can move in both directions.
14
Recursive language
Recursively enumerable language
accept Reject
accept Reject
Halt Halt
Halt May
/not
Halt
15
Properties of Recursive and Recursively enumerable language:
1. The complement of recursive language is recursive.
2. The union of two recursive language is recursive.
3. The union of two recursively enumerable language is recursively enumerable.
4. If a language L and its complement L are both recursively enumerable then both (L and L)
are recursive.
5. If L is a recursive language, then Σ *-L is recursive
16
Properties 2: The union of two recursive language is recursive.
1. If L1 and L2 are recursive language then there exists Turing machine M1 and M2
accepting L1 and L2 respectively and their halting is guaranteed as shown in fig.
17
Properties 3: The union of two recursively Enumerable language is
recursively enumerable.
1. If L1 and L2 are recursive enumerable language then there exists Turing machine
M1 and M2 accepting L1 and L2 respectively as shown in fig.
18
Properties 4: If a language L and its complement L are both
recursively enumerable then L is recursive.
1. If L and L are recursively enumerable language then there exists Turing machine M1
and M2 accepting L and L respectively as shown in fig.
2. We can construct a Turing machine M which takes w as string.
3. M1 simulates M1and M2 on w and halt as shown in fig.
4. If M1 accepts w then M accepts w if M2 accept w then M reject w
5. Thus, M will always say either “yes” or “no” but will never say both “yes” or both “no”.
6. Since L and L are complementary language w will be either in L or in L and hence it
will be either accepted to L or L. Thus halting of M is guaranteed and it is cleared that
M accepts L.
7. We concludes that it is always possible to construct Turing machine accepting L , it
follows that L is recursive.
8. Since L is recursive, L is also recursive.
9. Let L and L ne the pair of complementary language. Then either:
a. Both L and L are recursive
b. Both L and L are recursive enumerable
c. One of L and L is recursively enumerable, but not recursive, the other is not
recursively enumerable.
Undecidable problem:
The problems for which we can’t construct an algorithm that can answer the
problem correctly in the infinite time are termed as Undecidable Problems in
the theory of computation (TOC).
19
A problem is undecidable if there is no Turing machine that will always halt an
infinite amount of time to answer as ‘yes’ or ‘no’.
Examples
The examples of undecidable problems are explained below. Here, CFG refers
to Context Free Grammar.
• Whether two CFG L and M equal − Since, we cannot determine all the strings of any
CFG, we can predict that two CFG are equal or not.
• Given a context-free language, there is no Turing machine (TM) that will always halt
an infinite amount of time and give an answer to whether language is ambiguous or
not.
• Given two context-free languages, there is no Turing machine that will always halt an
infinite amount of time and give an answer whether two context-free languages are
equal or not.
• Whether CFG will generate all possible strings of the input alphabet (∑*) is
undecidable.
• A k-track Turing machine(for some k>0) has k-tracks and one R/W
head that reads and writes all of them one by one.
20
• A k-track Turing Machine can be simulated by a single track Turing
machine
21
A Multi-tape Turing machine can be formally described as a 6-
tuple (Q, X, B, δ, q0, F) where −
22
23
24
5. Multi-dimensional Tape Turing Machine:
25
[note: write down same tuple as that of turing machine]
Ackermann function
In computability theory, the Ackermann function, named after Wilhelm
Ackermann, is one of the simplest and earliest-discovered examples of a
total computable function that is not primitive recursive.
For example: 1
Compute the value of A(1,2)
A(1,2)= A(0, A(1, 1))
=A(0, A(0, A(1,0)))
=A(0,A(0,A(0,1)))
=A(0,A(0,2))
=A(0,3)
=4
26
Ex.2:
A(2,1)
Ex 3:
A(2,2)
"The Post's correspondence problem consists of two lists of string that are of equal
length over the input. The two lists are A = w1, w2, w3, .... , wn and B = x1, x2, x3, .... xn then
there exists a non empty set of integers i1, i2, i3, .... , in such that,
w1, w2, w3, .... wn = x1, x2, x3, .... xn"
To solve the post correspondence problem we try all the combinations of i 1, i2, i3, .... ,
in to find the w1 = x1 then we say that PCP has a solution.
For example 1:
Find whether the lists M=(abb,aa,aaa) and N=(bba,aaa,aa) have a poste
correspondence problem.
Solution:
x1 x2 x3
M abb aa aaa
N bba aaa aa
y1 y2 y3
x2x1x3=aaabbaaa
y2y1y3=aaabbaaa
as we can see , x2x1x3= y2y1y3
x=2; y=1;Z=3
For example 2:
Find whether the lists A=(10, 011,101) and N=(101,11,011) have a post
correspondence problem.
Ans : 2113
For example 3:
27
Fine whether the losts M= (ab,bab,bbaaa)
And N=(a,ba,bab) have a post correspondence solution for x2x1x3 Δ y2y1y3
Ans:
X1 X2 X3
List M ab bab bbaaa
List N a ba bab
Y1 Y2 Y3
x2x1x3=bababbbaaa
y2y1y3=baabab
In this case therer is no solution because x2x1x3 != y2y1y3 the length aren’t
same . so the problem is undecidable.
For example 4:
Prove that PCP with two list x=(0 1 1), y=(102,,10, 12) has no solution.
[ans: home work]
*********************************************************************************
Modified post correspondence problem:
The modified PCP (MPCP) has one additional requirement than PCP First pair in the
solution is the first pair in the list remaining sequence in the solution cab be in any
order.
The MPC problem is to determine whether there exist a sequence of one or more
integer
i1, i2, …, im such that w1wi1 wi2 … wim = x1xi1 xi2 … xim.
Example:
List A (10,11,110)
List B (10,011,11)
X1 X2 X3
List A 10 11 110
List B 10 011 11
Y1 Y2 Y3
X1X3X2 Y1= 10 110 11
Y3Y2=10 11 011
as we can see , X1X3X2=Y1Y3Y2
28
x=1; y=3; z=2
29