0% found this document useful (0 votes)
74 views37 pages

Theory of Computation

The document defines important concepts in automata theory and regular languages, including: 1. Deductive proofs proceed from assumptions to conclusions using logic, while inductive proofs handle statements with lower parameter values recursively using mathematical or structural induction. 2. Pumping lemma states that for any regular language L, there exists a constant n such that any string w in L of length at least n can be broken into xyz such that xyiz remains in L for all i. 3. Regular expressions, DFAs, NFAs, epsilon-NFAs and their properties are defined. Regular languages have closure properties like union, concatenation and Kleene star.

Uploaded by

Madhu Bala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views37 pages

Theory of Computation

The document defines important concepts in automata theory and regular languages, including: 1. Deductive proofs proceed from assumptions to conclusions using logic, while inductive proofs handle statements with lower parameter values recursively using mathematical or structural induction. 2. Pumping lemma states that for any regular language L, there exists a constant n such that any string w in L of length at least n can be broken into xyz such that xyiz remains in L for all i. 3. Regular expressions, DFAs, NFAs, epsilon-NFAs and their properties are defined. Regular languages have closure properties like union, concatenation and Kleene star.

Uploaded by

Madhu Bala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 37

APPENDIX - A

IMPORTANT DEFINITIONS

UNIT – I
1. Define Deductive proofs.
These are sequence of statements which are derived from any assumption (hypothesis)
or a given initial statement to a conclusion statement.
The proofs are generated using some facts / accepted logics.

2. Define Inductive Proof.


It has a sequence of recursive / parametrical statements that handle the statement with
lower values of its parameters.
There are two types of inductions, namely -

 Mathematical Induction

 Structural Induction

3. What is the principle of Mathematical Induction


This follows induction principle that follows two steps, namely-

 Basis of Induction: It considers „n‟ of f(n) as the lowest possible integer (n = 0


or 1) and prove the given statement using substitution.

 Inductive step: Assume that the given statement is true for nth value and prove
the statement for n = n+1.
This applies for all integer related statement.

4. What is Structural Induction?


Structural Induction follows the mathematical induction concept but applies for trees
and expressions.
Example: Every tree has one node than it has edges, balancing parenthesis etc.

5. What is Proof by contradiction?


The proof p  q is true, then the method follows a contradictory assumption that
p  q and from the result, it proves the assumption is false and thus proves, p  q.
AA.2 Theory of Computation

Example:
To prove P  Q = Q  P, we first assume that P  Q ≠ Q  P.
Now consider an element, x from P that is also in Q.
x ϵ P  Q

Thus all the element of P is taken and compared with that of Q.


Finally , P  Q = Q  P is proved [contradiction to our assumption]

6. Define Proof by Counter Example.


Given a statement, that can be proved to be true for a domain of input instances, and
false for other inputs.
Example: a mod b ≠ b mod a
Let a = 5 and b = 10
a % b = 5 % 10 = 5
b % a = 10 % 5 = 0
Hence a % b  b % a, the statement is true only if a = b.
Thus proved.
7. Define finite automata
FA consist of 5 Tuples,

M  (Q,  , ,q0 , F)

Q  Set of finite states.

  Set of input alphabets


  Transition function [Q    Q]

q 0  Start state

F Set of final states. [F  Q]

8. Define transition diagram and table.


Transition Diagram
It can be directed graph with vertices of a graph corresponding to states and edges
indicates transition from one state to another
Important Definitions AA.3

0 1
q0 q1 q2

Start
Final
state
state

 Start state indicated by circle.

 Start transition indicated by arrow.

 Final state indicated by double circle.


Transition Table
It is a tabular listing of the transition function which by implication tells us, set of
states and input alphabet.
9. Define DFA.
DFA is defined by 5 tuples,

A  (Q,  , ,q0 , F)

where,
Q  Finite set of states.

  Finite set of input symbols.


q 0  Initial state

  Transition function

F Final state / Accepting state

10. What are the properties of DFA?

 There is only one path for an input from current state to next state.

 It contains only one final state.


11. What is the extended transition function of DFA?

 The extended transition function,  takes two parameters, state and string.

 It is a mapping from Q   *  Q
AA.4 Theory of Computation


 Formally  cann be defined as

  (q 0 ,)  q 0
 
 (q0 , a)  ((q 0 , ), a)

12. What is NFA?


A NFA has 5 tuples defined as,

M = ( Q,  , ,q 0 , F)

where,
Q  a finite set of states

  A finite set of inputs


  Transition function from Q    Q

q 0  Start / initial state

F  A set of final / accepting states  F  Q


Subset
13. Differentiate: DFA and NFA

S.NO DFA NFA

1. The transition is deterministic The transition is non-deterministic

2. It has more number of states than It has less number of states.  2Q 


NFA  

3. It provides only one state transition It may lead to more than one states for
for a given input given input

4. It has only one final state It has more than one final states

5. More difficult to design It is easy to design

6. It has a single path for an input It may have several paths for a single
from a state input from a state. Backtracking is
required.
Important Definitions AA.5

14. Define ε – NFA.


A non deterministic FA, M with Є –transition is given by E = (Q, ∑, δ, q0, F), where
Q →finite set of states
∑→finite set of input alphabets
q0 → Initial/ start state
F → F  Q →set of final/accepting states
δ → Transition/ Mapping function from
Q X {∑ U {Є}} → 2Q
15. Define epsilon closure.
Epsilon closure of a state, q is defined as the set of states reachable from q on Є
moves. Є -closure of q0 is denoted as ЄCLOSE (q0).
Example: Obtain Є closure of each state in the following Є – NFA with Є – move.

q0 q1 q2

Є CLOSURE {q0} = {q0, q1, q2}


Є CLOSURE {q1} = {q1, q2}
Є CLOSURE {q2} = {q2}

16. What are the applications of automata theory?


 In compiler construction.
 In switching theory and design of digital circuits.
 To verify the correctness of a program.
 Design and analysis of complex software and hardware systems.
 To design finite state machines such as Moore and mealy machines.
AA.6 Theory of Computation

UNIT – II
1. Define Regular Expressions.
Let ∑ be a given alphabet. Then,
(i) , , and a belongs to ∑, are all regular expressions. [primitive Regular
Expressions]
(ii) If r1 and r2 are regular expressions, then r1+r2, r1r2, r1*, (r1) are also regular
expression if and only if it can be derived from the primitive RE by the
finite number of applications of the rules in (ii).

2. Define equivalent states.


 Let qi and qj are k – equivalent states if and only if no string of length ≤ k can
distinguish them.
 If there exists a string of length k, which can distinguish qi and qj, the states qi and
qj are said to be k – distinguishable.

3. Define Pumping Lemma for Regular Languages.


Let L be a regular language, then there exist a constant n (which depends on L) such
that for every string w in L such that w  n , we can break „w‟ into 3 strings:

w = xyz
such that
(i) y ≠ 

(ii) xy  n

(iii) For all k ≥ 0, the string xykz is also in L.


i.e., we can always find a non – empty string y not too far from the beginning of w that
can be pumped (repeating y any number of times or deleting it keeps the resulting
string in the language, L.
4. What are the closure properties of Regular languages?
Some of the important closure properties of RL are as follows.
1. Union
2. Difference
Important Definitions AA.7

3. Concatenation
4. Intersection
5. Complementation
6. Transpose / Reversal
7. Kleene star
8. Homomorphism
9. Inverse homomorphism
5. Write a RE for the language accepting the strings which are starting with 1 and
ending with 0, over the set ∑ = {0,1}
L = {10, 100, 110, 1000, 10101, 111000 ….s,}
R = 1(0+1)*0
6. Write a RE to denote a language, L over ∑* where ∑ = {a, b} that the third
character from right end of the string is always a.
L = aab, aba, aaa, abb, babb, aaaa,…
R = (a+b)* a(a+b)(a+b)
7. Construct a RE for the language, L which accepts all the strings with at least 2 b’s
over the alphabets ∑ = {a,b}
L = {bb, abb, bba, bab,bbb,bbaa, ababa,…}
R =(a+b)*b(a+b)*b(a+b)*
8. Construct a RE for the language which consist of exactly 2 b’s over the set,
∑ = {a, b}
L = {bb, abb, baba, bba, aaaabab,….}
R = a*ba*ba*
9. Construct a RE which denotes a language, L over the set , ∑ = {0}, having even
length of string.

L = {00,, 0000, 000000,…}

R = (00)*
10. Write a RE which denotes a language, L overt the set, ∑ = {1}, having odd length of
strings
AA.8 Theory of Computation

L = {1, 111, 11111, 1111111,…}


R = (11)*1
11. Write the RE to denote the language, L over ∑ = {a, b}, such that all the strings do
not contain the substring ab.
L = {bbaa, ba, bbbaaa, bb, aa,….}
R = b* a*
12. Write a RE which contains L having the strings which have at least one 0 and 1.
L = {01,001,101,010,011, 10101,10,..}
→ R = (0+1)* 0(0+1)* 1(0+1)* + (0+!)* 1(0+1)*0(0+1)*
13. Describe the following by RE
a) L1 = the set of all strings of 0’s and 1’s ending in 00.
b) L2 = the set of all strings of 0’s and 1’s beginning with 0 and ending with 1
AU MAY 2004
a) R1 = (0+1)* 00
b) R2 = 0(0+1)* 1
14. Find the RE for
a) The language of all strings containing exactly two 0’s
` b) The language of all strings containing at least two 0’s
c) The language of all string that do not end with 01.
Solution
a) R1 = 1* 0 1* 0 1*
b) R2 = 1* 0 1* 0 (1+0)*
c) R3 = (1+0)* (00 + 11 + 10)

15. Show that L = {0n 1n | n ≥ 1} is not regular.


Assume that L is a regular language. Let n be a constant and w = 0n 1n such
that w  n . By pumping lemma, w can be splitted into 3 parts such that w = xyz with
Important Definitions AA.9

(i) y ≠  (i.e y 1 )

(ii) xy  n

(iii) xykz  L  k  0

Since xy  n and y ≠  ,

x= 0n-1
y=0
z = 1n
By pumping lemma, xykz ≥  L for k ≥ 0
When k = 0;
xy0z = xz
0n-1.1n
 L [Comparing the power of 0 and 1 with w]
 L is not a regular language.
AA.10 Theory of Computation

UNIT – III
1. Define grammars.
 A grammar generates a language with the aid of four elements, G=(V,T,P,S) such
as,
o Terminal symbol
o Non terminal symbol
o Start symbol
o Production rules
 Terminal refers to the symbols of the alphabet being used.
o There are several types of terminals namely –
 Binary alphabet  0 and 1
 Uppercase alphabet  A, B, … , Z
 Lowercase alphabet  a, b, … , z
 Decimal alphabets  0, 1, 2, … , 9 etc.
o Most commonly used terminals are binary and lowercase types.
 The non-terminal symbols are those variables that denote/produce some terminals
in-turn.
o Non-terminals are equivalent to the states of automation.
o They are usually represented by uppercase alphabets like. A, B, … , Z.
 The start symbol is a special non-terminal that works similar to the start state of a
finite automation.
o It is represented by an element in variable set.
 The production rules are the translation functions/replacement rules of the
variables.
2. What are the types of grammars?
 Type 0 grammars / unrestricted grammars
 Type 1 grammars / context sensitive grammars
 Type 2 grammars / context free grammars
 Type 3 grammars / regular grammars
Important Definitions AA.11

3. What are Type 0 grammars?


 These are free / unrestricted grammars that have no restrictions on the production
rules.

 All formal grammars belong to this class.

 The grammars, G is defined by four tuples as G = (V, T, P, S) where

V  finite set of variable / non terminals

T  finite set of terminals

P  set of production rules

S  start symbol

 The production rule is of the form,

 | ≠

where ,   can be strings composed of terminals and non-terminals.


4. What are Type 1 grammars?
 The languages that follow type 1 grammars are called as context-sensitive
grammars (CSG).

 A language is said to be context sensitive if the production rules are of the form,

A

  non-empty

,   can be empty
where,
A is a non-terminal symbol

, ,  are any combination of terminals and non-terminals.


5. Define Type 2 grammars.
 Type 2 grammars are context free grammars.

 A grammars, G = (V, T, P, S) is said to be context free if the production rule is of


the form,

A
AA.12 Theory of Computation

The transition allows

A   [i.e.,   ]

where,

A is a non terminal symbol

 is any terminal or non-terminal symbol

6. What are Type 3 grammars?


 Type 3 grammars are regular grammars that describe regular / formal languages.

 These grammars contain production rules consisting of

o only one non-terminal at the left hand side

o the right hand side having a single terminal and may or may not be
followed by non terminals

7. What are the properties of Regular grammars?


 The regular grammars generates regular languages which are closed under,

o Union

o Concatenation

o Intersection

o Complementation

o Difference

o Reversal

o Closure

8. List the Chomsky hierarchy


 The four forms of grammars follows the given hierarchy,

 Type 3 grammar  type 2 grammar  type 1 grammar  type 0 grammar

 Regular grammars  context free grammars  context sensitive grammars 


unrestricted grammars
Important Definitions AA.13

Unrestricted Recursively
Enumerable Grammars
Content-sensitive
Grammars
Content-free
Grammars
Regular
Grammars

Chomsky hierarchy
9. What is CFL?
 The language L(G) of a grammar, G is a set of strings derived from the start
symbol.
 It is denoted as


L(G)  w | w  T * and S  w
*

G 
„*‟ denotes that the grammar, G is applied over S several times.
 If the grammar is applied once, it is denoted as S  w
G

 The language generated from a context - free grammar is called a context - free
language.
10. Define derivations.
 Derivations are the set of strings that are derived from the start symbol, after applying
the production rules, a finite number of times.
*
S  |   T *
G

 There are two types of derivations, namely


o Leftmost derivations
o Rightmost derivations
11. What do you meant by Sentential form?
 Sentential form is the derivation derived from the start symbol, by applying the
rules/productions.
AA.14 Theory of Computation

 Let the G = (V, T, P, S) be a CFG then


*
S 

is in sentential form, where   (TUV) *

12. Define Right and Left Sentential forms.


Left sentential form
 When the derivations are generated by expanding the leftmost symbol is called left
sentential form.
*
 It is denoted as, S 
m

Right sentential form


 The derivation generated by performing substitution on the right most variable is
called right sentential form.
 It is denoted as
*
S 
rm

13. Define parse/derivation trees.


 A set of derivations substituted / applied to generate a string can be represented
using a tree, called parse tree.
 Parse tree provides clear understanding of recursive function, grouping of symbols
especially parenthesis balancing etc.
The parse trees can be constructed by using the following three conditions.
1. The root node of the tree being the start symbol and the interior nodes [non –
leaf nodes] is represented by the variable, V of grammar G.
2. The leaf nodes are labeled by either the terminals T or by .
3. If the interior node is labeled V1 where V1  V, having its children, X1, X2, …
, Xn are the production of V1 which are represented from left to right.
14. What is the Yield of a parse tree?
 The terminals present at the leaf nodes are concatenated from left to right generate
a string, derived from the grammar.
 The generated string is called the yield of a parse tree.
Important Definitions AA.15

15. What are the types of parse trees?


There are two types of parse tree. They are,
 Leftmost derivation tree / left derivation tree
 Rightmost derivation tree / right derivation tree
Leftmost derivation tree
 A derivation tree representing A   is called a leftmost derivation tree if the
production rule is applied only to the leftmost variable at every step.
Rightmost derivation tree
 A derivation / parse tree representing A   is said to be a rightmost derivation
tree if the production rule is applied only to the rightmost variable at every step.
16. Define Ambiguous grammars. How will you remove ambiguity?
 A grammar, G is said to be ambiguous if there exists two different parse trees for at
least one string „‟ where   T*, each parse tree with the same symbol.
 If each string  has at most one parse tree in the grammar, then it is unambiguous
grammar.
Removing ambiguity from grammar
 The only possibility of removing ambiguity from grammar is to introduce one or
more different variables.
17. What are non generating symbols?
*

 A symbol X which is an element of V [variable] is generating symbol if X 


G
,

where  T * .

 Generating symbols are variables that generate a string containing terminals.


 A non generating symbol is one that cannot generate any terminal.
 The presence of production with non-generating symbol is useless.
Example
S  aA | bB | a | b
A  Aa | a
B  bB
AA.16 Theory of Computation

Here B  bB is a recursive grammar that its substitution to S results in endless


derivation and doesnot give lead to any string of terminals.
S  bB  bbB  bbbB  bbbbB  …..
18. What are non reachable symbols?
 A symbol is said to be reachable if and only if it can be reached from the start
symbol.
*
If S  , where  contains X [X  V]
G

 Then X is said to be a reachable symbol.


 If the derivation from the start symbol to a string of terminals does not depend on a
variable X then X is non-reachable symbol.
Example
Let
S  aAa
A  Sb | bCC
C  abb
E  aC
 In the given grammar, S depends on A, A depends on S and C, E depends on C,
and C does not depend on any variable.
 Here E is the only production which is not being depended by any other
productions.
E  Non reachable symbol

19. Define PDA.


 A PDA can be formally defined by 7-tuples.

 The specification of a PDA, P is given by,

P = (Q, ,  , , q0, z0, F )


where,

Q  Finite set of states


Important Definitions AA.17

  Finite set of input symbols [alphabet]

  Finite set of stack symbols


  Transition function

: Q × (    ) ×   Q ×  * defined as,  (q, a, x) = (q1, x1)


where,

q, q1  states in Q

a  input symbol in  or 

x, x1  stack symbol in 

q0  Initial/ start state [q0  Q]

z0  Initial start symbol [z0   ]

f  finite set of final/ accepting states [f ≤ Q ]


20. What is Instantaneous Description of a PDA?
 Instantaneous description of a PDA is an informal notation or description of a
PDA.

 It is a pictorial / diagrammatic representation of a string processed by a PDA.

 This is used to depict the processing of a string by a PDA.


21. What is the language of PDA accepted by final state?
A PDA that accepts its input and enters the final / accepting state is called as a PDA
accepted by final state.

Let the PDA, P = {Q, ,  ,  , q0, z0, F}. Then the language of the PDA, P is L(P)
which is accepted by final state is given by,

*
L(P) = {  | (q0,  , z0 ) (q, , ) }
P
where,

q0  initial state

  input string

z0  initial stack symbol


AA.18 Theory of Computation

q  Q  final state [q  F]

  stack symbols

22. What is the language of PDA accepted by empty stack?


The PDA that accepts its input by emptying the stack is the PDA accepted by empty
stack.

Let P be a PDA defined by {Q, ,  ,  , q0, z0, F}. The language of the PDA accepted
by empty stack is defined by,

*
N(P) = {  | (q0,  , z0 ) (q, , ) }

Final state No input to process Stack empty


where,
q0  initial state
  input string
z0  initial stack symbol
q final state
23. What is DPDA?
DPDA, P is given by

P = (Q, ,  ,  , q0, z0, F)

where,
Q  Finite set of states
  Set of input symbols
  Finite set of stack symbols
  Transition functions given by
 (q, a, x) has at most one transition for any q in Q, a in  or , X in
.
 If  (q, a, x) is non empty for a in , then  (q,  , x) must be empty.
q0  Start state
z0  Initial stack symbol

F  Final state
Important Definitions AA.19

UNIT – IV

1. Define Pumping Lemma for CFG.


Let G be a context free grammar. Then there exists a constant „n‟ such that any string,
  L(G) with ||  n can be rewritten as  = uvxyz, subject to the following
conditions.
(i) |vxy| ≤ n
(ii) vy  
(iii) for all i  0, uv i xy iz is in L
2. What are the Closure properties of CFL?
A context-free language is closed under the following operations.

 Union

 Concatenation

 Kleene star
Context free language is not closed under

 Intersection
 Complementation
 Reversal
3. Define normal forms of CFG.
Let the grammar G = (V, T, P, S) be a context free grammar. If the production rules in
G satisfy some restrictions, then they are said to be in normal form.
 There are two types of normal forms
o Chomsky normal form (CNF)
o Greibach normal form (GNF)
4. What is Greibach Normal Form?

 Greibach normal form is named after Shella Greibach who constructed GNF
grammar initially.

 A grammar G = (V, T, P, S) is said to be in GNF if every production rule is of the


form, X  a
where,
AA.20 Theory of Computation

  T, an element of the set of terminals

  V* a string of non terminals/epsilon


X  V, an element of the set of variables

 The right hand side of every production starts with a terminal, followed by a string
of variables of zero/ more length.
5. What is Chomsky Normal Form?

 A context free grammar, G = (V, T, P, S) is said to be in CNF if each production in


G is of the form, X  YZ; X  , where X, Y, Z  V and   T.

 Every CFG without null productions can be easily converted into its equivalent
CNF.
6. Define Turing machine.
A Turing machine, M is a 7-tuple given by
M = (Q, , , , q0, B, F)
where,
Q  Finite set of states
  Finite set of inputs symbols on input tape
  Finite set of tape symbols [ B] [where B  blank symbol]
  Transition function given by
(q, a) = (q', b, M) [M  movement  left, right, no movement]
q0  Initial state [q0  Q]
B  Blank symbol representing empty cell [B  ]
F  Set of final states [F  Q]
7. Define Multiple tracks Turing machine.

 The input tape of a Turing machine is an infinite single tape divided into individual
cells.

 A multiple track Turing machine is a single tape divided into multiple tracks.

 This is also called as k-dimension tape, where k is the number of „tracks‟.

 Standard Turing machine contains the tape symbol as the elements of .


Important Definitions AA.21

 Multitrack Turing machine contain multiple tracks (k) each with  set of elements
leading to k symbols on the tape.

 The transitions are same in both the types.

… …

Track 1 Track 2 Track i Track k

8. What are Two – way infinite tape turing machines?

 A turing machine, M = (Q, ∑, , , q0, B, F) is said to be a two-way infinite tape


TM if the input tape is infinite to the left and right.

 It can be viewed as a finite sequence of input symbols with infinite sequence of


blank symbols to the left and right of the input.

 B a0 a1 a2 … ai … ak B 

Infinite length at the


leftside of the tape/symbols Input symbols Infinite length at the
rightside of the input

9. Define Multi-head Turing machines.

 A Turing machine with a single tape can have any number of heads to provide
simultaneous accesses over the tape.

… a1 a2 a3 b1 b2 b3 c1 c2 … Input
tape

Head 1 Head 2
Head 3
Finite control

 The finite control posses two or more tape heads to access the input tape for
performing multiple reads/writes in a simultaneous and independent manner.

 The transition behavior of a 2 headed tape is given as

 (q', H1(a), H2(a)) = (q'', H1(b), M1), H2(b), M2))


Where

q', q''  states of Q


AA.22 Theory of Computation

H1(a)  symbol to be processed (read) by H1

H2(a)  symbol to be processed (read) by H2

H1(b)  symbol to be replaced by H1

H2(b)  symbol to be replaced by H2

M1  movement of H1 (L / R / N)

M2  movement of H2 (L / R / N)
10. Define Multi-tape Turing machine

 A multitape TM is finite control with more than one tape for reading/writing
symbols, storing states etc.

 Each tape has „n‟ number of individual cells.

 The first tape is mostly used to store the input symbols of the string, .

 The second and third tapes are normally used to store the states and state-changes.

… … Tape 1

… … Tape 2

… … Tape 3

Head 3 Head 2
Head 1

Finite control

The transition rules of a two tape TM is given as,

 (q, a1, a2) = (q`, H1(b), M1), H2(b), M2)


where,
q  current state to be processed
q`  next state to be reached
a1  symbol read by tape 1
Important Definitions AA.23

a2  symbol read by tape 2


H1(b)  symbol to be written by tape 1
H2(b)  symbol to be written by tape 2
M1  Movement by tape 1 (R / L / N)
M2  Movement by tape 2 (R / L / N)
11. What is Non deterministic TM?
A NTM is defined as

M = (Q, ∑, , , q0, B, F))


where,
Q  Set of states including initial, having rejecting states.
∑  Finite set of input alphabets
  Finite set of tape symbols

  Transition function defined by

 : Q    P(Q    {L, R, N}) where P  power set

q0  initial state

B  blank symbol

F  set of final states (F ≤ Q)

The transition function  takes on the states tape symbols and head movement.
12. What are the properties of RE languages?
The semi-decidable / RE language are closed under
1. Union
2. Intersection
3. But not under complementation
AA.24 Theory of Computation

UNIT - V

1. Define halting problem.

 The halting problem is the problem of finding if the program/machine halts or loop
forever.

 The halting problem is undecidable over Turing machines.


The halting set is represented as,

1 if M halts on input 
h(M, )  
0 otherwise

where,

M  Turing machine

  Input string

2. What are Decidable / solvable problems?


A problem, P is said to be decidable if there exists a turing machine, TM that decides
P.
Thus P is said to be recursive.
Consider a Turing machine, M that halts with either „yes‟ or „no‟ after computing the
input.

YES (if  L)
  ∑* M
NO (if   L)

The machine finally terminates after processing


It is given by the function,

1 if p()
Fp ()  
0 if  p ()

The machine that applies Fp() is said to be turing computable.


3. What are Undecidable problems?
A problem, P is said to be undecidable if there is a Turing machine, TM that doesn‟t
decides P.
Important Definitions AA.25

4. Define Semi decidable / partial solvable / recursively enumerable problems.


A problem, P is said to be semi decidable, if P is recursively enumerate.

A problem is RE if M terminates with „YES‟ if it accepts   L; and doesn‟t halt if 


 L.
Then the problem is said to be partial solvable / Turing acceptable.

YES (if  L)
  ∑* M
LOOP FOREVER (if   L)

Partial solvability of a machine is defined as,

1 if p()
Fp ()  
undefined if  p ()
5. What is Non self Accepting Language?
 NSA is a language that
 the code for the turning machine M is in language , L(M)
 The TM, M does not accept its own encoded code as input.
 NSA can be designed as,
NSA = {w  {0,1}* | w = e(m) for M is a Turing machine that does not accept the
string w and w is not a valid code of any TM, M}
6. Define Self Accepting Language
 The SA is a language that accepts its own encoding scheme.
 The language is described as
o The input string, w which is an encoding scheme for a turning machine , M
o The string, w is accepted by the TM.
 SA can be defined as,
SA = {w є{0,1}* | w = e(M) for the turning machine, M and w L(M)}
 It is a language containing the input string, w which is a code of the turning
machine that accepts its own encoding.
7. What are Solvable / Decidable / Decision Problems?
AA.26 Theory of Computation

Let P be a decision problem over the set of symbols, ∑ then p is solvable or decidable
if the associated language,

Y(P) = {e(I) | I is Yes instance of P) ≤ ∑* is a recursive language and

e → reasonable encoding scheme of P.

DECIDABLE TM

W ∑* YES
M

NO

A decision problem, P is decidable if P halts with either „YES‟ or „NO‟ on every input,
w. A problem is partially decidable / semi decidable if P is recursively enumerable.

The turning machine, M halts with „YES‟ if w is accepted otherwise M loops forever.
A problem that is not decidable / solvable is said to be Undecidable problem
8. Define Post Correspondence Problem.
The input instance of the problem has two lists of non-null strings {α1, α2, ……..αn}
and {β1,β2,………….βn} over an alphabets, Σ. [Σ having at most two symbols].
The task is to find a sequence of integers i1, i2, … ik [ ik for 1 ≤ k ≤ N ] such that
αi, αi2, ……αik = βi1, βi2 = βik
The PCP is a decision problem that whether the above mentioned sequence exists or
not.
9. State Rice’s Theorem
If R is a property of languages that are satisfied by some but not all recursively
enumerable languages, then the decision problem,
PR : Given a TM,M, does L(M) have property, R?
is unsolvable.
Explanation
Consider a language L such that
L = {M | L(M) has some property P}
where,
P is non-trivial of TM,M
Important Definitions AA.27

Then the language L is undecidable.


That is, every non-trivial property of the language of Turing machines is Undecidable
10. Define Recursively Enumerable Language.

A language L   * is recursively enumerable if there exist a Turing machine, M that


accepts every string, w  L and does not accept strings that are not in L.

If the input string is accepted, M halts with the answer, “YES”.


If the string is not an element of L, then M may not halt and enters into infinite loop.

wєL
YES
M
w L Loops Forever

The language, L is Turing Acceptable.


11. What are Recursive Languages?
A language is said to be recursive if there exists of Turing machine, M that accepts
every string, w  L and rejects those strings that are not in L.

If the input is accepted, M halts with the answer,” YES”

wєL
YES
M
w L NO

F the Turing machine doesn‟t accept the string.

If w  L, then M halts with answer, “NO”. This is also called as Turing Decidable
language.
12. Mention the properties of Recursive and RE Languages
1. The Union of two recursively enumerable languages is recursively enumerable.

2. The language L and its complement L are recursively enumerable, then L and I are
recursive.
3. The complement of a recursive language is recursive.
4. The union of two recursive language is recursive.
AA.28 Theory of Computation

5. The intersection of two recursive language is recursive.


6. The intersection of two recursively enumerable language is recursively enumerable
13. Define UTM.

Finite
control

Input <T, w>

Tape of M 0001010000101….

State of M 0000…0BB…

The universal Turing machine, Tu takes over the program and the input set to process
the program.

The program and the inputs are encoded and stored on different tapes of a multi-tape
Turing machine.

The Tu thus takes up T, w where T is the special purpose Turing machine that passes
the program in the form of binary string, w is the data set that is to be processed by T.

14. Definition of Universal Language [Lu]

The universal language, Lu is the set of all binary strings    , where  represents the
ordered pair <T, w> where

T  Turing machine

w  any input string accepted by T

It can also be represented as  = e(T) e(w) .

15. Define Time Complexity of a turing machine.


 The number of transitions/moves taken by the Turing machine to compute the
input is called the time complexity of the TM.
 Let T be a Turing machine, then the time complexity is a function τT(n) is the
maximum number of transitions for computing the input, n using T.
 τT depends on the input size of the problem.
 When „n‟ is larger, τT will be large; when „n‟ is small, then τT will be less.
Important Definitions AA.29

16. What are Tractable problems/languages?


 The languages that can be recognized by a Turing machine in finite time and with
reasonable space constraint is said to be tractable.

 Example: If the language L1  Time (f), then L is tractable and is less complex in
nature

 Example: If L2  Time (f), L2 is complex and cannot be tractable in limited time.

 Tractable problems are those that can be solved in polynomial time period.

17. Define Intractable Problems.

The languages that cannot be recognized by any Turing machine with reasonable space
and time constraint is called intractable problems.

These problems cannot be solved in finite polynomial time. Even problems with
moderate input size cannot achieve feasible solution

18. Define: P and NP

 „P‟ refers to the class of problems that can be solved in polynomial time.

 Example: Searching an element in an ordered list, sorting elements in a lists,


Multiplication of integers , finding all- pair –shortest path, finding minimum
spanning tree of a graph, etc

 Polynomial – time algorithms are efficient ones that can be solved more rapidly.

NP

 „NP‟ refers to the class of problems that are solved by non-deterministic


polynomial time

 Example: Towers of Hanoi, Traveling Salesman problem, Graph colouring


problem, Hamiltonian Circuit problem, Satisfiability Problem, etc.

19. What are NP- Complete Problems?


 A problem is said to be NP- complete if it belongs to NP class problem and can be
solved in polynomial time.

 They are also called polynomial -time reducible problems.

 A NP-complete problem can be transformed into any other in polynomial time.


AA.30 Theory of Computation

20. Define NP-Hard Problem.


 A problem is said to be NP hard if there exists an algorithm for solving it and it can
be translated into one for solving another NP-Problem.

 A Problem P1 is NP-hard if
o the problem is an NP class problem
o For any other problem , P2 in NP, there is a polynomial time reduction of L2 to
L1
21. What is Polynomial Time Reduction?
If L1 and L2 are two languages over the alphabets ∑1 and ∑2 respectively then L1 is
polynomial - time reducible to L2, if there is a function,

f :  1*   * , for any x  * , x  L1 iff f (x)  L2

And f can be computed in polynomial time. It is denoted as L1 p L2


APPENDIX - B
ANNA UNIVERSITY SOLVED QUESTION PAPERS

B.E/B.TECH. DEGREE EXAMINATION, MAY/JUNE 2006


Fifth Semester
COMPUTER SCIENCE AND ENGINEERING
CS 1303 - THEORY OF COMPUTATION
Time: 3 Hours Maximum: 100 Marks
Answer ALL Questions
PART - A (10 × 2 = 20 Marks)

1. Find the language accepted by the DFA given below.


1 0 0,1

q0 0 q2 1 q1

The regular expression is given as


1* 0 0* 1 (0+1)*
We know that,
R+ = RR*
Hence,
R.E. = 1* 0+ 1 (0+1)*
2. Find the ε-closure of the states 1, 2 and 4 in the following transition diagram?
 
2 3 6

1 b

a 
4 5 7

ε - closure {1} = {1, 2, 3, 6, 4}


ε - closure {2} = {2, 3, 6]
ε - closure {4} = {4}
AB.2 Theory of Computation

3. For the grammar SA1B, A0A/ε, B0B/1B/ε give left most and right most
derivation of the following string 00101.
The left most derivation for the string 00101 we get,
S A1B
 0A1B
 00A1B
For the string 00101, the leftmost derivation is given as,
S A1B [Using S  A1B]
 0A1B [Using A  0A]
 00A1B [Using A  0A]
 001B [Using A ]
 0010B [Using B  0B]
 00101B [Using B  1B]
 00101 [Using B ]
Thus the string 00101 ϵ L(G).
The right most derivation for the string 00101is given by
S  A1B [Using S  A1B]
 A10B [Using B  0B]
A101B [Using B1B]
A101 [Using B]
0A101 [Using A  0A]
 00A101 [Using A0B]
 00101 [Using A]
Thus the string 00101 ϵ L(G).
4. Construct CFG to generate,

a b /nε z 
n n t

The given grammar generates equal number of a‟s and b‟s. The grammar is given by,
G = {V, J, P, S}
P={S aSb, S ab}
Anna University Solved Question Paper AB.3

V={S}
T={a, b}
S={S}
5. Is it true that deterministic push down automata and non-deterministic push down
automata are equivalent in the sense of language of acceptances? Justify your
answer?

No, wwR is accepted by a NPDA, but not by any DPDA.


6. Define Instantaneous description of a PDA?
Let the PDA be given by,
   Q, , , ,q 0 , z 0 , F 

The instantaneous description is given by


  q 0 , x, z 0     q1 , x 

q0 is the current state

q1 is the current input symbol

z0 is the current stack symbol

q1 indicates next state

xβrepresents TOP of the stack


Let
Zn is the pushdown automata

Q is the set of states


 is the input set

 is a set of stack symbols


 is a transition (or) mapping function

z0 is the top symbol of the stack

F is he set of final states


Then,

(q, aw, za) M (, w, a) if (q, a, z) contains (, )


AB.4 Theory of Computation

7. Define Basic Turing machine?


A Turing machine, M is a 7-tuple given by
M = (Q, , , , q0, B, F)
where,
Q  Finite set of states
 Finite set of inputs symbols on input tape
 Finite set of tape symbols [B] [where B  blank symbol]
 Transition function given by
(q, a) = (q', b, M) [M  movement  left, right, no movement]
q0 Initial state [q0  Q]
B  Blank symbol representing empty cell [B ]
F  Set of final states [F  Q]
8. Explain the multitape turing machine. Is it more powerfulthan the basic turing
machine? Justify your answer?
 A multitape TM is finite control with more than one tape for reading/writing symbols,
storing states etc.
 Each tape has „n‟ number of individual cells.
 The first tape is mostly used to store the input symbols of the string, .
 The second and third tapes are normally used to store the states and state-changes.

… … Tape 1

… … Tape 2

… … Tape 3

Head 3 Head 2
Head 1

Finite control
Anna University Solved Question Paper AB.5

The transition rules of a two tape TM is given as,

 (q, a1, a2) = (q`, H1(b), M1), H2(b), M2)


where,

q current state to be processed

q` next state to be reached

a1 symbol read by tape 1

a2 symbol read by tape 2

H1(b)  symbol to be written by tape 1

H2(b)  symbol to be written by tape 2

M1 Movement by tape 1 (R / L / N)

M2 Movement by tape 2 (R / L / N)


The multitape TM is more powerful then the basic turing machine. Because finite control
reads more than one input tape and more symbols can be scanned at a time.
9. When a problem is said to be undecidable? Give an example of a decidable problem?

 The problem which can be answered as “yes” are called solvable (or) decidable.

 The problem which can answered as “No” are called undecidable problem.

 A problem, P is said to be undecidable if there is a Turing machine, TM that


doesn‟t decides P.

 Example of undecidable problem: PCP, Halting problem, etc.

 Example of decidable problem: Sorting, Searching etc.


10. Show that union of recursive language is recursive?
Let L1 and L2 be two recursive languages that are accepted by the Turing machines M1 and
M2, given by
L(M1) = L1
L(M2) = L2
Let M3 be the Turing machine constructed by the union of M1 and M2. M3 is constructed as
follows.
AB.6 Theory of Computation

YES
YES
M1 NO

wєΣ*
M3
YES

M2 NO

NO

The Turing machine M3 first simulates M1 with the input string, w.

If w  L1 , then M1 accepts and thus M3 also accepts since L(M3) = L(M1) u L(M2).

If M1 rejects string  w  L1  , then M3 simulates M2. M3 halts with “YES” if M2 accepts „w‟,
else returns “NO”.
Hence M3, M2, M1 halt with either YES or NO on all possible inputs.
Thus the union of two recursive languages is also recursive.
PART - B (5 × 16 = 80 Marks)
11. i) Construct the equivalent Griebach normal form for the CFG G = {A1, A2, A3},
{a,G}, {1, A1} when  consists at the following.

A1  A2 A3

A2  A3 A1 /b

A3  A1 A2 /a

Refer problem – 2 in 2.9.1of UNIT - II


11. ii) Show that the language is not context free?

L = {an bn cn}
Refer problems in 3.7 of UNIT - III
12. a) i) Construct an NFA equivalent to the following regular expression,
((10) + (0 + 1))* 01
Anna University Solved Question Paper AB.7

q3 1 q4 0 q5
 
Start
q1  q2  1
q12 q12 0 q12 q15
q7 0 q8
  

q6 q11

 
q9 1 q10

12. a) ii) Check whether the language is regular or not.

L =  0 n 2 n Z + 

Assume L is a regular we get contradiction. Let n be the number of states in FA and its queting L.

w = 0 n2

|w| = n2> n
Pumping lemma,
w = xyz

|xy| n and |y| > 0

Consider

xy2z. |xy2z| = |x| + 2y + |z| > |x| + |y| + |z| as |y| > 0

n2 = |xyz| = |x| + |y| + |z| < |xy2z| .... (1)

|xy|  n, |y|  n

|xy2z| = |x| + 2|y| + |z|  n2 + n

|xy2z|  (n+1)2 (2)

Here |xy2z| strictly lies between n2 and (n+1)2 but is not equal to any
one of them.

Thus |xy2z| is not a perfect square. So xy2z  L. Hence L is not regular.

You might also like