0% found this document useful (0 votes)
11 views14 pages

Aattoc

The document outlines the conversion of an Epsilon NFA to a standard NFA, detailing the steps involved and providing an example with states and transitions. It also describes the construction of a DFA that accepts strings with consecutive pairs of characters, along with its transition table. Additionally, the document discusses normalization of Context-Free Grammar (CFG), the closure of context-free languages under Kleene-star, and provides insights into Turing Machines and their significance in computation.

Uploaded by

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

Aattoc

The document outlines the conversion of an Epsilon NFA to a standard NFA, detailing the steps involved and providing an example with states and transitions. It also describes the construction of a DFA that accepts strings with consecutive pairs of characters, along with its transition table. Additionally, the document discusses normalization of Context-Free Grammar (CFG), the closure of context-free languages under Kleene-star, and provides insights into Turing Machines and their significance in computation.

Uploaded by

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

ASSIGNMENT

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.

Figure – Vertex v1 and Vertex v2 having an epsilon move


Step-1: Consider the two vertexes having the epsilon move. Here in Fig.1 we
have vertex v1 and vertex v2 having epsilon move from v1 to v2.
Step-2: Now find all the moves to any other vertex that start from vertex
v2 (other than the epsilon move that is considering). After finding the moves,
duplicate all the moves that start from vertex v2, with the same input to start
from vertex v1 and remove the epsilon move from vertex v1 to vertex v2.
Step-3: See that if the vertex v1 is a start state or not. If vertex v1 is a start state,
then we will also make vertex v2 as a start state. If vertex v1 is not a start state,
then there will not be any change.
Step-4: See that if the vertex v2 is a final state or not. If vertex v2 is a final
state, then we will also make vertex v1 as a final state. If vertex v2 is not a final
state, then there will not be any change. Repeat the steps(from step 1 to step
4) until all the epsilon moves are removed from the NFA. Now, to explain this
conversion, let us take an example.
Example: Convert epsilon-NFA to NFA. Consider the example having states
q0, q1, q2, q3, and q4.

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 – –

According to the transition table above,


 state q0 on getting input 1 goes to state q1.
 State q0 on getting input as a null move (i.e. an epsilon move) goes to
state q2.
 State q1 on getting input 1 goes to state q0.
 Similarly, state q2 on getting input 0 goes to state q3, state q2 on getting
input 1 goes to state q4.
 Similarly, state q3 on getting input 0 goes to state q2.
 Similarly, state q4 on getting input 0 goes to state q2.
We can see that we have an epsilon move from state q0 to state q2, which is to
be removed. To remove epsilon move from state q0 to state q1, we will follow
the steps mentioned below.
Step-1: Considering the epsilon move from state q0 to state q2. Consider the
state q0 as vertex v1 and state q2 as vertex v2.

Figure – State q0 as vertex v1 and state q2 as vertex v2


Step-2: Now find all the moves that starts from vertex v2 (i.e. state q2). After
finding the moves, duplicate all the moves that start from vertex v2 (i.e state
q2) with the same input to start from vertex v1 (i.e. state q0) and remove the
epsilon move from vertex v1 (i.e. state q0) to vertex v2 (i.e. state q2). Since
state q2 on getting input 0 goes to state q3. Hence on duplicating the move, we
will have state q0 on getting input 0 also to go to state q3.
Similarly state q2 on getting input 1 goes to state q4. Hence on duplicating the
move, we will have state q0 on getting input 1 also to go to state q4.
So, NFA after duplicating the moves is:

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:

Figure – NFA after


making state q2 as a start state
Step-4: Since vertex v2 (i.e. state q2) is a final state. Hence we will also make
vertex v1 (i.e. state q0) as a final state. Note that state q0 will also remain as a
start state as we had initially. After making state q0 also as a final state, the
resulting NFA is:
Figure –Resulting NFA (state q0 as a final state)The
transition table for the above resulting NFA 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

q1 1 q3 1 breaks the consecutive rule.


q2 1 q0 Complete a pair of 1s.
q2 0 q3 0 breaks the consecutive rule.
q3 0/1 q3 Dead state, stays invalid.
Acceptance
 The DFA accepts if it ends in q0 after processing all input characters.

4. State Pumping Lemma for Regular Languages with a suitable example.


A)
5. Define Normalization of CFG? What is the use of Normalization?
Explain different types of normal forms.
A) Normalization of Context-Free Grammar (CFG)
Normalization of a Context-Free Grammar (CFG) refers to the process of
converting a given CFG into an equivalent grammar that follows specific
structural rules or formats. The equivalent grammar generates the same
language as the original grammar but has a more constrained and systematic
form.

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.

You might also like