Toc Unit-1 Notes
Toc Unit-1 Notes
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).
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}
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
c b c
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.
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}.
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.
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.
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 → .......… → ϵ
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.
UNIT-3
PUSHDOWN AUTOMATA
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.
UNIT-4
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.