Aattoc
Aattoc
AAT-II
Course Name: Theory of Computation
Course Code: AITC04
1. Convert NFA with Epsilon to NFA with an example
A) on-deterministic Finite Automata (NFA) is a finite automata having
zero, one, or more than one moves from a given state on a given input
symbol. Epsilon NFA is the NFA that contains epsilon move(s)/Null move(s).
To remove the epsilon move/Null move from epsilon-NFA and to convert it into
NFA, we follow the steps mentioned below.
In the above example, we have 5 states named as q0, q1, q2, q3 and q4. Initially,
we have q0 as start state and q2 as final state. We have q1, q3 and q4 as
intermediate states.
Transition table for the above NFA is:
Input
States/Input Input 0 1 Input epsilon
q0 – q1 q2
q1 – q0 –
q2 q3 q4 –
q3 q2 – –
q4 q2 – –
Figure – NFA on
duplicating moves
Step-3: Since vertex v1 (i.e. state q0) is a start state. Hence we will also make
vertex v2 (i.e. state q2) as a start state. Note that state q2 will also remain as a
final state as we had initially. NFA after making state q2 also as a start state is:
States/
Input Input 0 Input 1
q0 q3 q1,q4
q1 – q0
q2 q3 q4
q3 q2 –
q4 q2 –
2. The set of strings where all characters must appear in consecutive pairs
(i.e. 00 or 11). Examples of strings in the language: ?, 000011, and 11.
Examples of strings not in the language: 11100, 00100, and 11000). ?
Draw a DFA for this language.
A) To construct a Deterministic Finite Automaton (DFA) for the described
language, we need to ensure the following rules are adhered to:
1. Each character in the string must appear in consecutive pairs (e.g., 00,
11).
2. Strings can be empty (ε is accepted).
3. Strings where the characters do not appear in pairs, such as 01, 100, or
11100, are rejected.
Key Observations
The language contains strings of 0s and 1s where every character appears
in pairs.
We can keep track of whether we are in a state that expects:
o The first character of a pair.
o The second character of a pair.
DFA Construction
The DFA will have the following states:
q0 (start state): The string so far is valid, and no characters are expected
yet.
q1: The last character seen was the first 0 of a pair.
q2: The last character seen was the first 1 of a pair.
q3 (dead state): The string is invalid.
Transition Table
Current State Input Next State Explanation
q0 0 q1 Start a pair of 0s.
q0 1 q2 Start a pair of 1s.
q0 ε q0 Accept the empty string.
q1 0 q0 Complete a pair of 0s.
Current State Input Next State Explanation
Use of Normalization
1. Simplicity: Normalized grammars are easier to analyze and manipulate.
2. Algorithmic Parsing: Many parsing algorithms (e.g., CYK parsing)
require grammars in normal forms.
3. Proofs and Theoretical Analysis: Certain theoretical properties of
languages and grammars are easier to prove using normalized forms.
4. Elimination of Ambiguity: Normalization helps remove unnecessary
complexities and may aid in reducing ambiguity in a grammar.
6.Describe a CFG for the languages L={aib j | i<=2j}
A)
7. Prove that the class of context-free languages is closed under Kleene-star
A)
8. Convert the following PDA to CFG M=({q0,q1},{a,b},{z0,za}, ?,q0,z0,?) ? is
given by, ?(q0,a,z0)=(q0,zz) ?(q0,a,z)=(q0,zz0) ?(q0,b,z)=(q1,?) ?
(q1,b,z)=(q1,?) ?(q1,?,z0)=(q1,?)
A)
9. Examine Type 3 and Type 2 grammars with example
A)Type 2 Grammar (Context-Free Grammar)
Definition:
A Type 2 grammar generates context-free languages. The production rules
in a Type 2 grammar allow for more flexibility compared to Type 3:
1. A→αA \rightarrow \alphaA→α, where AAA is a single non-terminal, and
α\alphaα is any string of terminals and non-terminals.
Type 2 grammars can produce languages that cannot be generated by regular
grammars, such as languages with nested structures.
10. Describe a Turing Machine. With a neat diagram explain the working of a
Turing Machine.
A) Turing Machine was invented by Alan Turing in 1936 and it is
used to accept Recursive Enumerable Languages (generated by
Type-0 Grammar).
Turing machines are a fundamental concept in the theory of computation and
play an important role in the field of computer science. They were first
described by the mathematician and computer scientist Alan Turing in 1936 and
provide a mathematical model of a simple abstract computer.
In the context of automata theory and the theory of computation, Turing
machines are used to study the properties of algorithms and to determine what
problems can and cannot be solved by computers. They provide a way to model
the behavior of algorithms and to analyze their computational complexity,
which is the amount of time and memory they require to solve a problem.
A Turing machine is a finite automaton that can read, write, and erase symbols
on an infinitely long tape. The tape is divided into squares, and each square
contains a symbol. The Turing machine can only read one symbol at a time, and
it uses a set of rules (the transition function) to determine its next action based
on the current state and the symbol it is reading.
The Turing machine’s behavior is determined by a finite state machine, which
consists of a finite set of states, a transition function that defines the actions to
be taken based on the current state and the symbol being read, and a set of start
and accept states. The Turing machine begins in the start state and performs the
actions specified by the transition function until it reaches an accept or reject
state. If it reaches an accept state, the computation is considered successful; if it
reaches a reject state, the computation is considered unsuccessful.
Turing machines are an important tool for studying the limits of computation
and for understanding the foundations of computer science. They provide a
simple yet powerful model of computation that has been widely used in research
and has had a profound impact on our understanding of algorithms and
computation.
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.