Toc Unit-1 Notes

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 11

CS6503-Theory of Computation

UNIT -1
FINITE AUTOMATA
1. Define finite automata.
Deterministic Finite Automaton (DFA)
In DFA, for each input symbol, one can determine the state to which the machine
will move. Hence, it is called Deterministic Automaton. As it has a finite number of
states, the machine is called Deterministic Finite Machine or Deterministic Finite
Automaton.
Formal Definition of a DFA
A DFA can be represented by a 5-tuple (Q, Σ, δ, q0, F) where:
 Q is a finite set of states.
 Σ is a finite set of symbols called the alphabet.
 δ is the transition function where δ: Q × Σ → Q
 q0 is the initial state from where any input is processed (q0 ∈ Q).
 F is a set of final state/states of Q (F ⊆ Q).

2. Write the difference between the + closure and * closure.


Kleene Star
 Definition: The Kleene star, Σ*, is a unary operator on a set of symbols or
strings, Σ, that gives the infinite set of all possible strings of all possible
lengths over Σ including λ.
 Representation: Σ* = Σ0 U Σ1 U Σ2 U……. where Σp is the set of all possible
strings of length p.
 Example: If Σ = {a, b}, Σ*= {λ, a, b, aa, ab, ba, bb,………..}
Kleene Closure / Plus
 Definition: The set Σ+ is the infinite set of all possible strings of all possible
lengths over Σ excluding λ.
 Representation: Σ+ = Σ1 U Σ2 U Σ3 U…….
Σ+ = Σ* − { λ }
 Example: If Σ = { a, b } , Σ+ ={ a, b, aa, ab, ba, bb,………..}

3. Define alphabet, string.

Alphabet
 Definition: An alphabet is any finite set of symbols.
 Example: Σ = {a, b, c, d} is an alphabet set where ‘a’, ‘b’, ‘c’, and ‘d’ are
symbols.
String
 Definition: A string is a finite sequence of symbols taken from Σ.
 Example: ‘cabcad’ is a valid string on the alphabet set Σ = {a, b, c, d}

4. What is a transition table and transition graph?

Graphical Representation of a FA
A FA is represented by digraphs called state diagram.
 The vertices represent the states.
 The arcs labeled with an input alphabet show the transitions.
CS6503-Theory of Computation
 The initial state is denoted by an empty single incoming arc.
 The final state is indicated by double circles.
Example
Let a deterministic finite automaton be 
 Q = {a, b, c},
 Σ = {0, 1},
 q0={a},
 F={c}, and

Transition function δ as shown by the following table:

Present State Next State for Next State for


Input 0 Input 1
a a b
b c a

c b c

Its graphical representation would be as follows:

1
0

a b c
1 0
1
0
FA – Graphical Representation

5. Give the DFA accepting the language over the alphabet 0, 1 that has the set of all
strings beginning with 101.

The r.e has to be formed in which at the beginning, there should be at 101. That means
r.e = 101(any combination of 0’s and1’s)
r.e. = 101(0+1)*
6. Give the DFA accepting the language over the alphabet 0,1 that have the set of all
strings that either begins or end(or both) with 01.

The r.e. can be categorized into two subparts.


R=L1+L2
L1= The strings which begins with 01
L2= The string whioch ends with 01
Let us find pout L1 and L2.
L1=(01)(0+1)* and L2=(0+1)*(01)
R=01(0+1)*+(0+1)*(01)
7. Define NFA
CS6503-Theory of Computation
Non Deterministic Finite Automaton (NDFA)
In NDFA, for a particular input symbol, the machine can move to any combination of the
states in the machine. In other words, the exact state to which the machine moves cannot be
determined. Hence, it is called Non-deterministic Automaton. As it has finite number of states,
the machine is called Non-deterministic Finite Machine or Non-deterministic Finite Automaton.
Formal Definition of an NDFA
An NDFA can be represented by a 5-tuple (Q, Σ, δ, q0, F) where:

 Q is a finite set of states.


 Σ is a finite set of symbols called the alphabets.
 δ is the transition function where δ: Q × Σ → 2Q
 q0 is the initial state from where any input is processed (q0 ∈ Q).
 F is a set of final state/states of Q (F ⊆ Q).

8. Define Grammar give an example.


Grammar
A grammar G can be formally written as a 4-tuple (N, T, S, P) where
 N or VN is a set of variables or non-terminal symbols
 T or  is a set of Terminal symbols
 S is a special variable called the Start symbol, S ∈ N
 P is Production rules for Terminals and Non-terminals. A production rule has
the form 𝛼 → 𝛽, where  and  are strings on 𝑉𝑁 ∪ Σ and least one symbol of
belongs to VN.
Example
Grammar G1:
({S, A, B}, {a, b}, S, {S →AB, A →a, B →b})
Here,
S, A, and B are Non-terminal symbols;
a and b are Terminal symbols
S is the Start symbol, S ∈ N
Productions, P : S →AB, A →a, B →b

9. Define ∈ - closure
The ∈ - closure (p) is a set of all states which are reachable from state p on ∈ - transition
such that :
(i) ∈ - closure(p)=p where p∈Q
(ii) If there exists ∈ - closure(p) –{q} and δ(q,∈) = then ∈ - closure (p)={q,r}.

10. Define Deductive proof


The deductive proof consists of sequences of statements given with logical reasoning in
order to prove the first of initial statements. The initial statement is called hypothesis,

11. Enumerate the difference between DFA and NFA.

DFA NDFA
CS6503-Theory of Computation
The transition from a state is to a single The transition from a state can be to multiple
particular next state for each input symbol. next states for each input symbol. Hence it is
Hence it is called deterministic. called non-deterministic.

Empty string transitions are not seen in DFA. NDFA permits empty string transitions.

Backtracking is allowed in DFA In NDFA, backtracking is not always possible.

Requires more space Requires less space.

A string is accepted by a DFA, if it transits to a A string is accepted by a NDFA, if at least one


final state. of all possible transitions ends in a final state.

UNIT-2
GRAMMARS
1. Define CFG.
A context-free grammar (CFG) consisting of a finite set of grammar rules is a
quadruple (N, T, P, S) where
 N is a set of non-terminal symbols.
 T is a set of terminals where N ∩ T = NULL.
 P is a set of rules
 S is the start symbol
2. Define production rule.

A set of production rules that describe all possible strings in a given formal
language. Production rules are simple replacements. For example, the rule
P = S → SS | aSb | ε
3. Define terminal and non terminal symbols.
Terminals
A terminal is a symbol which does not appear on the left-hand side of any production. A
grammar contains a set of terminal symbols (tokens) such as +, , *, and other tokens
Nonterminals
Nonterminals are the non-leaf nodes in a parse tree. In the Expression grammar, E, T, and
F are nonteminals.

4. Write about the types of grammars.


CS6503-Theory of Computation

5. What is ambiguity?
If a context free grammar G has more than one derivation tree for some string w ∈ L(G), it is
called an ambiguous grammar. There exist multiple right-most or left-most derivations for some
string generated from that grammar.
6. Define parse tree.
A parse tree is an ordered, rooted tree that represents the syntactic structure of a string
according to some context-free grammar.
7. What is a derivation?
A derivation of a string for a grammar is a sequence of grammar rule applications that
transforms the start symbol into the string. A derivation proves that the string belongs to the
grammar's language.
8. What is null production and unit production?
Unit Productions
Any production rule in the form A → B where A, B ∈ Non-terminal is called unit
production.
Null Productions
In a CFG, a non-terminal symbol ‘A’ is a nullable variable if there is a production A → ϵ
or there is a derivation that starts at A and finally ends up with ϵ: A → .......… → ϵ

9. What are the two normal forms of CFG?

Chomsky Normal Form


A CFG is in Chomsky Normal Form if the Productions are in the following forms:
A→a
 A → BC
S→ϵ
where A, B, and C are non-terminals and a is terminal.
Greibach Normal Form
A CFG is in Greibach Normal Form if the Productions are in the following forms:
A→b
A → bD1…Dn
CS6503-Theory of Computation
S→ϵ
where A, D1,....,Dn are non-terminals and b is a terminal.

10. Find out the context free language. S→ aSb | aAb , A→ bAa , A→ ba
The contextfree languagedented by the given CFG is
L={(ambnanbm) ¿ m≥1,n≥1.
This is a languaged consisting of ba at the middle and having even length strings.

11. Let G be grammar S→ aB ¿ bA A→ a ¿ aS ¿ bAA B→ b ¿ bS ¿ aBB . For the string


aaabbabbba, Find LMD and RMD.
LMD RMD
S S
aB aB
aaBB aaBB
aaaBBB aaBbS
aaabBB aaBbbA
aaabbSB aaBbba
aaabbaBB aaaBBbba
aaabbabB aaaBbbba
aaabbabbS aaabSbbba
aaabbabbbA aaabbAbbba
Aaabbabbba aaabbabba

UNIT-3
PUSHDOWN AUTOMATA

1. Define Pushdown Automata.


A pushdown Automata M is a system (Q, Σ, Ґ ,δ ,q0, Z0,F) where
Q is a finite set of states.
Σ is an alphabet called the input alphabet.
Ґ is an alphabet called stack alphabet. q0 in Q is called initial state.
Zo in Ґ is start symbol in stack. F is the set of final states.
δ is a mapping from Q X (Σ U {Є} ) X Ґ to finite subsets of Q X Ґ *.

2. What are the different types of language acceptances by a PDA and define them.
For a PDA M=(Q, Σ ,Ґ ,δ ,q0 ,Z0 ,F ) we define :
Language accepted by final state L(M) as:
{ w | (q0 , w , Z0 ) |--- ( p, Є , γ ) for some p in F and γ in Ґ * }.
Language accepted by empty / null stack N(M) is:
{ w | (q0,w ,Z0) |----( p, Є, Є ) for some p in Q}.
CS6503-Theory of Computation
3. Compare NFA and PDA.

NFA PDA
1.The language accepted by NFA is the The language accepted by PDA is
regular language. Context free language.
PDA is essentially an NFA with
2.NFA has no memory. a stack(memory).
4.
3. It can store only limited amount of It stores unbounded limit
information. of information.
4.A language/string is accepted only It accepts a language either by empty
by reaching the final state. Stack or by reaching a final state.
Specify the two types of moves in PDA.
The move dependent on the input symbol(a) scanned is:
δ(q,a,Z) = { ( p1, γ1 ), ( p2,γ2 ),……..( pm,γm ) }
where q qnd p are states , a is in Σ ,Z is a stack symbol and γi is in Ґ*. PDA is in state q ,
with input symbol a and Z the top symbol on state enter state pi Replace symbol Z by
string γi.
The move independent on input symbol is (Є-move):
δ(q,Є,Z)= { ( p1,γ1 ), ( p2,γ2 ),…………( pm,γm ) }.
Is that PDA is in state q , independent of input symbol being scanned and with
Z the top symbol on the stack enter a state pi and replace Z by γi.

5. Is it true that the language accepted by a PDA by empty stack and final states are
different languages.
No, because the languages accepted by PDA ‘s by final state are exactly the languages
accepted by PDA’s by empty stack.

6. Define Deterministic PDA.


A PDA M =( Q, Σ ,Ґ ,δ ,q0 ,Z0 ,F ) is deterministic if:
For each q in Q and Z in Ґ , whenever δ(q,Є,Z) is nonempty ,then
δ(q,a,Z) is empty for all a in Σ.
For no q in Q , Z in Ґ , and a in Σ U { Є} does δ(q,a,Z) contains more than one element.
(Eg): The PDA accepting {wcwR | w in ( 0+1 ) * }.

7. Define Instantaneous description(ID) in PDA.


ID describe the configuration of a PDA at a given instant.ID is a triple such as (q, w ,γ ) ,
where q is a state , w is a string of input symbols and γ is a string of stack
symbols. If M =( Q, Σ ,Ґ ,δ ,q0 ,Z0 ,F ) is a PDA we say that
(q,aw,Zα) |-----( p, w, βα) if δ(q,a,Z) contains (p, β ).
M‘a’ may be Є or an input symbol.
Example: (q1, BG) is in δ(q1, 0 , G) tells that (q1, 011, GGR )|---- ( q1, 11,BGGR).

8. What is the significance of PDA?


CS6503-Theory of Computation
Finite Automata is used to model regular expression and cannot be used to represent
non regular languages. Thus to model a context free language, a Pushdown Automata is
used.

9. When is a string accepted by a PDA?


The input string is accepted by the PDA if: The final state is reached . The stack is empty.

10. Is NPDA (Nondeterministic PDA) and DPDA (Deterministic PDA)equivalent?


The languages accepted by NPDA and DPDA are not equivalent. For example: wwR is
accepted by NPDA and not by any DPDA.

11. What are the closure properties of CFL?


CFL are closed under union, concatenation and Kleene closure. CFL are closed under
substitution , homomorphism.
CFL are not closed under intersection , complementation.
Closure properties of CFL’s are used to prove that certain languages are not context free.

12. State the pumping lemma for CFLs.


Let L be any CFL. Then there is a constant n, depending only on L, such that if z is in L
and |z| >=n, then z=uvwxy such that :
(i) |vx| >=1
(ii) |vwx| <=n and
(iii) for all i>=0 uviwxiy is in L.

UNIT-4
TURING MACHINES

1. What is a turing machine?


Turing machine is a simple mathematical model of a computer. TM has unlimited and
unrestricted memory and is a much more accurate model of a general purpose computer. The
turing machine is a FA with a R/W Head. It has an infinite tape divided into cells ,each cell
holding one symbol.

2. What are the special features of TM?


In one move ,TM depending upon the symbol scanned by the tape head and state of the
finite control:
 Changes state.
 Prints a symbol on the tape cell scanned, replacing what was written there. Moves the
R/w head left or right one cell.

3. Define Turing machine.


A Turing machine is denoted as M=(Q, Σ, Ґ ,δ ,q0, B,F) Q is a finite set of states.
Σ is set of i/p symbols ,not including B.
Ґ is the finite set of tape symbols. q0 in Q is called start state.
B in Ґ is blank symbol.
F is the set of final states.
CS6503-Theory of Computation
δ is a mapping from Q X Ґ to Q X Ґ X {L,R}.

4. Define Instantaneous description of TM.


The ID of a TM M is denoted as α1q α2 . Here q is the current state of M is in Q;
α1 α2 is the string in Ґ * that is the contents of the tape up to the rightmost nonblank
symbol or the symbol to the left of the head, whichever is the rightmost.

5. What are the applications of TM?


TM can be used as:
 Recognizers of languages.
 Computers of functions on non negative integers. Generating devices.

6. What is the language accepted by TM?


The language accepted by M is L(M) , is the set of words in Σ * that cause M to enter a
final state when placed ,justified at the left on the tape of M, with M at qo and the tape head of
M at the leftmost cell. The language accepted by M is:
{ w | w in Σ * and q0w |--- α1 p α2 for some p in F and α1 ,α2 in Ґ * }.

7. What are the possibilities of a TM when processing an input string?


TM can accept the string by entering accepting state. It can reject the string by entering
non-accepting state.
It can enter an infinite loop so that it never halts.
8. What are the techniques for Turing machine construction?
• Storage in finite control.
• Multiple tracks.
• Checking off symbols.
• Shifting over
• Subroutines.

9. What is a multihead TM?


A k-head TM has some k heads. The heads are numbered 1 through k, and move of the
TM depends on the state and on the symbol scanned by each head. In one move, the heads may
each move independently left or right or remain stationary.

10. Differentiate PDA and TM.


DA TM

1. PDA uses a stack forstorage. 1. TM uses a tape that is infinite .

2.The language accepted by PDA is CFL. 2. Tm recognizes recursively enumerable languages.


CS6503-Theory of Computation
UNIT-5
UNSOLVABLE PROBLEMS AND COMPUTABLE FUNCTIONS
1. When we say a problem is decidable? Give an example of undecidable problem?
A problem whose language is recursive is said to be decidable. Otherwise the problem is
said to be undecidable. Decidable problems have an algorithm that takes as input an instance of
the problem and determines whether the answer to that instance is “yes” or “no”.
eg) of undecidable problems are (1)Halting problem of the TM.

2. Differentiate recursive and recursively enumerable languages.


Recursive languages Recursively enumerable languages

1. A language is said to be recursive if


and only if there exists a membership 1. A language is said to be r.e if there exists
algorithm for it. a TM that accepts it.

2. L is recursively enumerable if there is a


2. A language L is recursive if there is a TM that semi-decides L. (Turing acceptable
TM that decides L. (Turing decidable languages). TMs that semi-decides
languages). TMs that decide languages languages are not algorithms.
are algorithms.

3. What are UTMs or Universal Turing machines?

Universal TMs are TMs that can be programmed to solve any problem, that can be solved by
any Turing machine. A specific Universal Turing machine U is:
Input to U: The encoding “M “ of a Tm M and encoding “w” of a string w. Behavior : U halts on
input “M” “w” if and only if M halts on input w.

4. What properties of recursive enumerable seta are not decidable?


 Emptiness
 Finiteness
 Regularity
 Context-freedom.

5. What is a universal language Lu?


The universal language consists of a set of binary strings in the form of pairs (M,w) where
M is TM encoded in binary and w is the binary input string.
Lu = { < M,w> | M accepts w }.

6. What are the different types of grammars/languages?


• Unrestricted or Phase structure grammar.(Type 0 grammar).(for TMs)

• Context sensitive grammar or context dependent grammar (Type1


CS6503-Theory of Computation
• Context free grammar (Type 2)
• Regular grammar (Type 3) . This hierarchy is called as Chomsky Hierarchy.

7. State the halting problem of TMs.


The halting problem for TMs is: Given any TM M and an input string w, does M halt on
w? This problem is undecidable as there is no algorithm to solve this problem.

8. Define PCP or Post Correspondence Problem.


An instance of PCP consists of two lists , A = w1,w2,….wk and B = x1,…..xk of strings
over some alphabet Σ .This instance of PCP has a solution if there is any sequence of integers
i1,i2,..im with m >=1 such that wi1, wi2,…wim = xi1,xi2 ,…xim
The sequence i1 ,i2 ,…im is a solution to this instance of PCP.

9. What are the concepts used in UTMs?


 Stored program computers.
 Interpretive Implementation of Programming languages.
 Computability.

10. What are(a) recursively enumerable languages (b) recursive sets?


 The languages that is accepted by TM is said to be recursively enumerable (r. e )
languages. Enumerable means that the strings in the language can be enumerated by the
TM. The class of r. e languages include CFL’s.
 The recursive sets include languages accepted by at least one TM that halts on all inputs.
11. When a recursively enumerable language is said to be recursive ? Is it true that the
language accepted by a non-deterministic Turing machine is different from recursively
enumerable language?
A language L is recursively enumerable if there is a TM that accepts L and recursive if
there is a TM that recognizes L. Thus r.e language is Turing acceptable and recursive language
is Turing decidable languages.
No , the language accepted by non-deterministic Turing machine is same as recursively
enumerable language.

You might also like