Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

toc_report_final

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

TABLE OF CONTENTS

SL. No Particulars Page No.

1 Introduction 01
2 Finite Automaton (DFA): Atleast 2 a’s in a string 01 – 03
3 Pushdown Automaton (PDA) for an bn and n>1 03 – 05
4 Turing Machine for an bn and n>=1 06 – 10
5 Conclusion & References 10
Introduction
JFLAP is software for experimenting with formal languages topics including nondeterministic
finite automata, nondeterministic pushdown automata, multi-tape Turing machines, several
types of grammars, parsing, and L-systems. In addition to constructing and testing examples
for these, JFLAP allows one to experiment with construction proofs from one form to another,
such as converting an NFA to a DFA to a minimal state DFA to a regular expression or regular
grammar.
In this report, we demonstrate the use of JFLAP to design and execute the following
computational models:
1. Deterministic Finite Automaton (DFA): Accepts atleast 2 ‘a’s in a string.
2. Pushdown Automaton (PDA): Accepts strings of the form ‘a^n b^n’ where n > 1.
3. Turing Machine (TM): Accepts strings of the form ‘a^n b^n’ where n >= 1.
This report serves as a practical guide for understanding these computational models and their
implementation in JFLAP.

Finite Automaton (DFA): Atleast 2 a’s in a string


A finite automaton can be defined as a tuple:
{ Q, Σ, q, F, δ }, where:
 Q: Finite set of states
 Σ: Set of input symbols
 q: Initial state
 F: Set of final states
 δ: Transition function

Language:
L= {aa, aaaa, baab, ababba…..}
Components:
 States: {q0,q1,q2}
 Alphabet: {a,b}
 Transitions:
o q0 (a)→q1
o q0 (b)→q0
o q1 (a)→q2

1
o q1 (b)→q1
o q2 (a,b)→q2
 Start state: q0
 Final state: q1

Steps in JFLAP
1. Open JFLAP and select "Finite Automaton" from the main menu.
2. Add three states: q0, q1 and q2.
3. Mark q0 as the start state and q2 as the final state.
4. Add transitions:
o From q0 to q1 on input a.
o From q0 to itself on input b.
o From q1 to q2 on input a.
o From q1 to itself on input b.
o From q2 to itself on input a and b.
5. Test the DFA with inputs such as ab, aa, and b.

2
Pushdown Automaton (PDA) for a^n b^n and n>1
A Pushdown Automata (PDA) can be defined as :
 Q is the set of states
 ∑is the set of input symbols
 Γ is the set of pushdown symbols (which can be pushed and popped from the stack)
 q0 is the initial state
 Z is the initial pushdown symbol (which is initially present in the stack)
 F is the set of final states
 δ is a transition function that maps Q x {Σ ∪ ∈} x Γ into Q x Γ*. In a given state, the
PDA will read the input symbol and stack symbol (top of the stack) move to a new state,
and change the symbol of the stack.
Language:
 L= {ab, aabb, aaabbb,……}
Components:
 States: {q0,q1,q2}
 Alphabet: {a,b}
 Stack alphabet: {a,Z}

3
 Transitions:
o (q0, a, Z)→ q0, aZ
o (q0, a, a)→ q0, aaZ
o (q0, b, a)→ q1, aZ
o (q1, b, a)→ q1, Z
o (q1, E, Z)→ q2, E
 Start state: q0
 Final state: q1
 First alphabet of the stack: Z

Steps in JFLAP:
1. Open JFLAP: Start by opening the JFLAP tool and selecting the Pushdown
Automaton option from the main menu.
2. Create States:
o Create an initial state q0 where the machine begins reading the input.
o Create a final state q1 where the machine will end if the string is accepted.
3. Transition for 'a':
o From state q0, add a transition for reading 'a'.
o The transition goes from q0 to itself, and for each 'a', push an 'Z' onto the stack.
o This signifies the PDA's action of storing the 'a' on the stack.
4. Transition for 'b':
o From state q0q_0q0, add a transition for reading 'b'.
o This transition will pop a 'Z' from the stack, matching the 'b' with a previous 'a'.
o The PDA will move to a new state (or stay in the same state) as long as there is
a 'Z' on the stack to pop.
5. Final Acceptance:
o After processing all 'a's and 'b's, the PDA will move to state q1 if the stack is
empty (indicating an equal number of 'a's and 'b's).
o The machine accepts the input if it reaches the final state with no remaining 'Z'
symbols on the stack.
6. Simulation: In JFLAP, simulate the PDA with various strings like "ab", "aabb", and
"aaabbb" to verify that the PDA correctly accepts valid strings and rejects invalid ones.

4
5
Turing Machine for a^n b^n and n>=1
What is a Turing Machine?
A Turing Machine (TM) is a theoretical model of computation introduced by Alan Turing in
1936. It is used to define what is computable in a formal and mathematical way. A Turing
Machine consists of:
 A tape: An infinite, linear sequence of cells that can hold symbols. The tape acts as both
input and memory storage for the computation.
 A head: A read/write head that moves left or right across the tape and can read or modify
the symbols in the tape cells.
 A state machine: A finite set of states that the Turing Machine can be in at any given
time, including an initial state and one or more final (accepting) states.
 Transition function: A set of rules that dictate how the Turing Machine moves between
states, based on the symbol it reads from the tape. The transition function also dictates
the symbol to write on the tape and the direction (left or right) to move the head.
The Turing Machine is considered a universal model of computation, meaning that any
computation that can be performed by a computer can also be modeled by a Turing Machine.
It is a powerful and versatile machine, capable of solving any problem that can be
algorithmically described, given sufficient time and memory.

Language:
L = {ab, aabb, aaabbb,…..}
Components:
 States: {q0,q1,q2,q3,q4}
 Alphabet: {a,b}
 Stack alphabet: {a,b,x,y,B}
 Transitions:
o (q0, a)→ q1, x, R
o (q1, a)→ q1, a, R
o (q1, y)→ q1, y, R
o (q1, b)→ q2, y, L
o (q2, y)→ q2, y, L
o (q2, a)→ q2, a, L
o (q2, x)→ q0, x, R
o (q0, y)→ q3, y, R

6
o (q3, y)→ q3, y, R
o (q3, B)→ q4, B
 Start state: q0
 Final state: q4
 Blank space: B
Steps to Design Turing Machine in JFLAP:
Step 1: Understanding the Language
 The language consists of strings where the number of 'a's is equal to the number of 'b's,
and the 'a's precede the 'b's (no 'b' before 'a').
 The string must not be empty; hence, n≥1n \geq 1n≥1.
Step 2: Design Overview
We need to:
1. Mark the first 'a' in the input by replacing it with a special symbol (e.g., 'X').
2. Find the corresponding 'b' on the right side of the string and mark it as well (e.g., replace
it with 'Y').
3. Repeat the process until all 'a's and 'b's are marked.
4. If we find any mismatch (extra 'a's, extra 'b's, or wrong order), the machine should reject
the input.
5. If we successfully mark all characters and the tape has no unmarked 'a' or 'b', the
machine should accept.
Step 3: Define the States
We will define several states to accomplish the task:
 q0: Start state. Initially, the machine will look for the first 'a' to mark.
 q1: After marking an 'a', move to the right to find the corresponding 'b'.
 q2: Mark the first 'b' after finding it, then move to the left to look for the next 'a'.
 q3: After marking the 'b', move left to find the next 'a'.
 q4: If an 'a' is found after the right end is reached, check if it's still valid.
 q_accept: The accepting state, reached when all symbols are marked and the string is
valid.
 q_reject: Reject state, reached if there's an error (extra 'a', extra 'b', or mismatched
order).

7
Step 4: Transition Function
Here is an overview of the transitions:
1. From q0 (Start state):
o If the current symbol is 'a', mark it with 'X' and move right to state q1.
o If the current symbol is not 'a' (such as 'b' or blank), reject.
2. From q1 (Finding corresponding 'b'):
o If the current symbol is 'b', mark it with 'Y' and move left to state q2.
o If the current symbol is 'a' or 'X' (a marked 'a'), continue moving right to find
the next 'b'.
o If a blank is encountered before finding a 'b', reject.
3. From q2 (Moving left to find the next 'a'):
o If the current symbol is 'Y', continue moving left.
o If the current symbol is 'X', move right to state q0 (to start marking the next 'a').
o If a blank is encountered, check if all 'a's and 'b's are marked. If so, accept. If
not, reject.
4. From q3 (Reaching the left side after marking a 'b'):
o Similar logic as in q2, ensuring all symbols are properly marked.
5. Final Check (In q_accept or q_reject):
o Once all symbols are checked, if the string follows the pattern, the machine
transitions to the accept state.
o If at any point an invalid configuration (like extra 'a's or 'b's) is detected, the
machine moves to the reject state.
Step 5: Creating the TM in JFLAP
1. Open JFLAP and select "Turing Machine."
2. Create the States: Add the states q0, q1, q2, q3, q_accept, and q_reject.
3. Define Transitions: Click on transitions to add the state-to-state moves. Define the
symbols to be read, write, and move directions (Left or Right).
o For instance, from q0 on reading 'a', write 'X', move right, and transition to q1.
o From q1 on reading 'b', write 'Y', move left, and transition to q2.
o Continue adding transitions following the logic described in Step 4.
4. Set the Start and Accept States: Make sure q0 is the start state and q_accept is the
accepting state.

8
5. Test the TM: Once the transitions are set, you can test the Turing machine by inputting
strings such as "aab", "aaabbb", "a", and "ab" in the JFLAP simulator.
Example Transitions
 q0 → (on 'a', write 'X', move right, go to q1)
 q1 → (on 'b', write 'Y', move left, go to q2)
 q2 → (on 'X', move right, go to q0)
 q2 → (on blank, if all are marked, go to q_accept)
Step 6: Finalize and Test
Once you have designed and tested the transitions in JFLAP, you should be able to test various
input strings and confirm that the machine accepts strings of the form anbna^n b^nanbn and
rejects others.

9
Conclusion:
In conclusion, JFLAP is a valuable tool for learning and exploring concepts in formal
languages and automata theory. By allowing users to design, simulate, and visualize different
types of automata—such as finite automata, pushdown automata, Turing machines, and more—
JFLAP provides an interactive and intuitive environment for understanding complex theoretical
concepts. It bridges the gap between abstract computational theory and practical application,
making it easier for students and researchers to experiment with and test various automata
models.
Through exercises like designing Turing Machines for operations like 1's complement or
recognizing specific languages, JFLAP helps solidify the understanding of key computational
models and their operations. The tool’s user-friendly interface and real-time simulation
capabilities allow for immediate feedback, which enhances learning and fosters deeper insights
into the nature of computation. Overall, JFLAP is an indispensable resource for anyone
studying formal languages, automata theory, and the foundations of computation.

References:
* https://www.jflap.org/tutorial/
* https://www.jflap.org/modules/

10

You might also like