Anutoc
Anutoc
MANAGEMENT
(Autonomous Under VTU)
Opp. Art of Living, Udayapura, Kanakapura Road, Bangalore- 560082
IQAC, DSATM
(Affiliated to Visvesvaraya Technological University, Belagavi and Approved by AICTE, New
Delhi) CE, CSE, ECE, EEE, ISE and ME are Accredited by NBA, New Delhi
NAAC Accredited with A+ Grade
Submitted by
Ms. Surabhi K R
Assistant Professor
Dept. of ISE, DSATM Bangalore.
3
1. L = {w {a, b}* : every a region in w is of even length}
We need to design a Finite Automaton (FA) or NFA (Non-deterministic Finite Automaton) that
accepts strings where every contiguous sequence of 'a's (a-region) has an even length. We can approach
this by keeping track of the even-length 'a' regions.
Approach:
o q0 (even count of 'a's): Starting state and accepting state when the number of
'a's is even.
o q1 (odd count of 'a's): A non-accepting state when the number of 'a's is odd.
• Transitions:
o From q0:
o From q1:
4
2. Design an NFA with ∑ = {a, b} accepts all string starting with a.
The goal is to create a NFA that accepts all strings starting with 'a'. This NFA will only reject
strings that start with 'b'.
Approach:
o q0: The starting state. If the first symbol is 'a', we will accept.
o q1: This is an accepting state where we have already encountered an 'a', so we can
accept the rest of the string.
• Transitions:
o From q0:
▪ On 'a', go to q1.
▪ On 'b', go to a dead state (we will not accept strings starting with 'b').
o From q1:
5
3. Obtain the Regular Expression for L = {w: n_a(w) mod 3 = 0, w
∈ (a,b)*}
We want a regular expression for strings where the number of 'a's is a multiple of 3 (i.e.,
na(w)mod 3=0n_a(w) \mod 3 = 0na(w)mod3=0).
Approach:To construct a regular expression for this, we need a pattern that ensures the
number of 'a's is a multiple of 3. The simplest way to achieve this is by having groups of
exactly three 'a's, with any number of 'b's in between.
6
• aaa: A single 'a'.
7
4. Construct PDA to accept the following language: L = {a^n b^n| n≥0}
which consists of strings with the same number of 'a's followed by the same number of 'b's, we
can define the PDA as follows
1. States:
Transition Function δ:
δ(q0,a,Z0)=(q0,AZ0)
δ(q0,a,A)=(q0,AA)
o On reading a b, if the stack is not empty (i.e., there are symbols A in the stack), pop an A
and move to state q1.
δ(q0,b,A)=(q1,ϵ)
δ(q1,b,A)=(q1,ϵ)
o If we encounter the end of the input string and the stack has only the initial symbol Z0,
move to the accepting state qf.
δ(q1,ϵ,Z0)=(qf,Z0)
3. Accepting State:
o qf is the accepting state, which indicates that the input string has been processed
successfully.
8
5.Turing machine for L = {a nb n c n }. Add seven states
to the screen, setting the initial state to be q0 and the final
state to be q6.
Steps to Construct a Turing Machine in JFLAP
9
o Click on the workspace to create states. Each state will appear as a circle
with a unique identifier (e.g., q0, q1).
o Add as many states as needed for your Turing Machine.
4. Set the Start State:
o Right-click on the state where your Turing Machine computation should
begin.
o Select "Set as Initial" from the context menu. An arrow pointing to this
state will appear.
5. Set Accepting and Rejecting States:
o Right-click on a state that should serve as an accepting state, then select
"Set as Final". The state will be marked with a double-circle outline.
o Optionally, designate a rejecting state to indicate strings that should be
rejected.
6. Add Transitions:
o Click the "Create Transition" button (arrow icon).
o Click on the source state, drag to the destination state, and release the
mouse.
o A dialog box will appear where you define the transition
10
11
LEARNING OUTCOMES
12
CONCLUSION
In conclusion, the exploration of formal languages, automata theory, and their associated
constructs—such as NFAs, regular expressions, context-free grammars, and pushdown
automata— provides a foundational understanding of how computational systems recognize
and process languages.
Through the design and analysis of various automata and grammars, learners gain valuable
insights into the principles of computation, including the relationships between different types
of languages and the computational models that recognize them. This knowledge not only
enhances theoretical understanding but also equips learners with practical problem-solving
skills applicable in various domains, such as programming language design, compiler
construction, and text processing.
Moreover, the ability to construct and manipulate these theoretical models fosters critical
thinking and analytical skills,
REFERENCE
Books:
• This text covers the fundamentals of automata theory, formal languages, and their
applications in computer science.
• "Elements of the Theory of Computation" by Harry R. Lewis and
Christos H. Papadimitriou
• This book offers a clear introduction to the theory of computation, including detailed
discussions on automata and formal languages.
13