AUTOMATA REPORT
-
Upload
mohamed-fahrulnizam -
Category
Documents
-
view
79 -
download
6
Transcript of AUTOMATA REPORT
CSC701
(AUTOMATA THEORY AND FORMAL LANGUAGE)
REPORT MINI PROJECT
L = {aibjck:i=2j or j=2k}
PREPARED FOR:
DR ROSE HAFSAH ABD RAUF
PREPARED BY:
MOHAMED FAHRUL NIZAM BIN MAZURA@HASSAN
(2014285684)
MUHAMMAD FAIZ BIN MAT SEMAN
(2014457824)
CSC7071B
SUBMITTED ON:
10 JANUARY 2015
CONTENTS
1.0 INTRODUCTION.................................................................................................................................3
2.0 OBJECTIVE..........................................................................................................................................3
3.0 PROJECT DESCRIPTION...................................................................................................................4
4.0 BASIC IDEA OF PUSHDOWN AUTOMATA (PDA)........................................................................4
Formalities of PDA..................................................................................................................................5
Instantaneous description........................................................................................................................5
5.0 CONSTRUCTING PUSHDOWN AUTOMATA (PDA)......................................................................6
Algorithm of the language.......................................................................................................................6
Flowchart of the Pushdown Automata.....................................................................................................8
Formal Definition of PDA.......................................................................................................................9
Pushdown automata of the language........................................................................................................9
String Testing........................................................................................................................................10
6.0 SAMPLE OF INPUT AND OUTPUT FILE.......................................................................................12
7.0 JAVA SOURCE CODE.....................................................................................................................13
1.0 INTRODUCTION
This paper is prepared as documentation for Mini Project of Formal Language and Automata
Theory(CSC701). In a group of two persons, we were instructed to write a program that
constructs an automaton for a given language. A program that constructs automata must be tested
with strings of different possibilities cases. The output should be either REJECT or ACCEPT. If
the string is rejected, the word ‘REJECT’ should be displayed and if it is accepted the
computation of the string should be displayed followed by the word ‘ACCEPT’. The language
assigned for our group mini project is as the following language, L:
L = {aibjck : i=2j or j=2k}
2.0 OBJECTIVE
i) To make identify automata can be constructed based on ONE distinct language given
ii) To make the student understand how pushdown automata works and able to construct it in a
program
iii) To explain and understand how an automata chosen works
iv) To manage work and time due to the consuming in order to finish the task given
v) To work together in working environment as a team work based on the task distribution given
3.0 PROJECT DESCRIPTION
For this mini project, the pushdown automata (PDA) have been chosen. This is because of PDA
is able to read straight forward input string with push and pop the string and have minimal
running time and easy to get the result.
The language that has been assigned to our group is L = {aibjck:i=2j or j=2k} where this
language will accept three input string which ‘a’, ‘b’ and ‘c’. There are conditions given in the
language which are the number of ‘B’ must double to the number of ‘c’ and numbers of ‘a’ must
be double to the number of ‘b’. If these conditions are TRUE, then the tested string will be
accepted. Otherwise, it will reject the string that does not fulfill the conditions of this language.
4.0 BASIC IDEA OF PUSHDOWN AUTOMATA (PDA)
In computer science, a pushdown automaton (PDA) is a type of automaton that employs a stack.
State machine: can be in any state of finite states.
Infinite Stack: can be used to store a symbol
Pushdown automata choose a transition by indexing a table by input signal and the symbol at the
top of the stack. That means that those there parameters completely determine the transition path
that is chosen. Pushdown automata can also manipulate the stack, as part of performing a
transition and the manipulation can be to push a particular symbol to the stack or to pop off the
top of the stack.
Formalities of PDA
Instantaneous description
Generally, the following notation can be represented for PDA, P:
P = ( Q,Σ, Γ, δ,q0,Z0,F ):
Q: The finite set of states of the finite control Σ: input alphabet Γ: stack symbols δ: transition function q0: start state Z0: Initial stack top symbol F: Final/accepting states
5.0 CONSTRUCTING PUSHDOWN AUTOMATA (PDA)
Algorithm of the language
The PDA that accepts language L = {aibjck:i=2j or j=2k} is constructed by using the followingalgorithm:
1. Read:
a. Read ‘a’
b. Then and pop ‘λ’ push ‘aaZ’
2. Repeat:
a. Read ‘a’
b. Then and pop ‘λ’ push ‘aaZ’
c. Until no more ‘a’ found.
3. Repeat:
a. Read ‘b’
b. Then pop ‘aaa’
b. Until no more ‘b’ found
4. Repeat
a. Read ‘c’
b. Then pop ‘aa’
c. Until no more ‘c’ found
5. If read ‘λ’, then push ‘z’
Then the string is ACCEPTED
Else the string is REJECTED
Flowchart of the Pushdown Automata
Here, shows the flowchart for the pushdown automata for the language:
Formal Definition of PDA
The formal definition for constructed PDA:
P=({q0, q1, q2, q3, q4 }, {a,b,c}, {a,b,c,Z}, δ, q0, Z, {q4 }).
Pushdown automata of the language
Referring to the algorithm, the PDA transition automation is illustrated as the following diagram:
String Testing
Example of ACCEPTED string:
One example of the ACCEPTED string is ‘aaaabbc’. Below are the transitions for the accepted
string ‘aaabbcc’ in the NPDA from the initial state, q0 until the final state F:
String: aaaabbc
1. δ(q0, a, λ)= {(q1, aaZ)}
2. δ(q1, a, λ)= {(q1, aaaaZ)}
3. δ(q1, a, λ)= {(q1, aaaaaaZ)}
4. δ(q1, a, λ )= {(q1, aaaaaaaaZ)}
5. δ(q2, b, aaa)= {(q2, aaaaaZ)}
6. δ(q2, b, aaa)= {(q2, aaZ)}
7. δ(q3, c, aa)= {(q3, Z)}
input a a a a b b c
stack
aa
a aa a a
a a a aa a a a
a a a a a aa a a a a a
z z z z z z z zaccept
Example of REJECTED string:
Examples of REJECTED string are ‘aabc’. Below are the transitions for the rejected string of ‘aabc’ in
the NPDA from the initial state, q0 until the final state F:
String: aabc
1. δ(q0, a, λ)= {(q1, aaZ)}
2. δ(q1, a, λ)= {(q1, aaaaZ)}
3. δ(q1, b, aaa)= {(q2, aZ)}
4. δ(q2, c, aa )= HALT because there is no ‘aa’ in the stack.
input a a b c
stack
aa
a aa a a HALT because when the input is 'b',it will push
z z z z 'aaa'. But, there's only 'a' in the stack