17
BY: KRISHNA REDDY K 1304044 JAYESH BAFNA P 1304026 NITHIN RAJ D 1304027 ATCHAYA KUMAR 1304047 GNANESH V 1304028 MURUGESHWAR U 1304039 RIBERRO SILVA 1304020

Toc Project Report

Embed Size (px)

DESCRIPTION

TOC project report is the report for the toc project simulator

Citation preview

Page 1: Toc Project Report

BY:

KRISHNA REDDY K 1304044

JAYESH BAFNA P 1304026

NITHIN RAJ D 1304027

ATCHAYA KUMAR 1304047

GNANESH V 1304028

MURUGESHWAR U 1304039

RIBERRO SILVA 1304020

Page 2: Toc Project Report

INTRODUCTION:

The automaton simulation is done using an automaton simulator. The

automaton simulator allows us to draw and simulate a variety of theoretical

machines, including:

Deterministic finite automata

Non-deterministic finite automata

Deterministic push-down automata

Turing machines

An Automaton is an abstract computing device. A “device” need not even be a

physical hardware. The study of abstract computing devices, or “machines” is

called Automata Theory. A language is a collection of sentences of finite length

all constructed from a finite alphabet of symbols. In this simulation, we design

an abstract machine to simulate the working of a Deterministic finite automata

to accept a language of all strings ending with ‘ab’.

ABOUT THE PROJECT:

The automaton simulator is equipped with a GUI that is used to design the

Deterministic finite automata quickly and easily. The simulator has the

following tools:

State tool –to draw states and designate starting & final state.

Transition tool – to draw transitions between states and designate

symbols for which states the transitions apply.

Label tool – to name the states present in the automata.

Simulation tool – to run the simulation and either accept or reject the

language based on the input entered in the input field.

After designing the deterministic finite automata, the simulation is run. During

the simulation, input is given symbol by symbol and the transitions are seen

for each input symbol and whether the given language is accepted or rejected.

Page 3: Toc Project Report

DETERMINISTIC FINITE AUTOMATA (DFA):

A deterministic finite automaton (DFA) consists of:

1. A finite set of states (often denoted Q)

2. A finite set Σ of symbols (alphabet)

3. A transition function that takes as argument a state and a symbol and

returns a state(often denoted δ)

4. A start state often denoted q0

5. A set of final or accepting states(often denoted F)

Here q0 ∈ Q and F ⊆ Q.

So a DFA is mathematically represented as a quintuple (Q, Σ, δ, q0, F).

The transition function δ is a function in which

Q × Σ → Q

Q × Σ is the set of 2-tuples (q, a) with q ∈ Q and a ∈ Σ.

A DFA can be represented using:

Transition table

Transition diagram

Transition table:

0 1

q0 q2 q0

*q1 q1 q1

q2 q2 q1

The → indicates the start state: here q0.

The ∗ indicates the final state(s) (here only one final state q1).

The above transition table is a representation for the DFA given below.

Page 4: Toc Project Report

Transition table:

The following is a transition diagram for the same DFA represented as a

transition table above:

For this example,

Q = {q0, q1, q2}

Start state: q0

F = {q1}

Σ= {0, 1}

δ is a function from Q × Σ to Q

δ: Q × Σ → Q

δ (q0,1)= q0

δ (q0,0)= q2

Acceptance or Rejection in DFA:

A DFA accepts the given language if it reads the language and stops in the

accepting state. The DFA rejects the given language if there is also a stop or

dead state, in which case the DFA is not accepting the language or stopping at

the final state after the given language is finished reading.

An automaton is considered a DFA only if:

There is only 1 transition for a given symbol from any given state.

Each possible input determines the resulting state ‘q’ uniquely, unlike

NFA where some inputs may allow a choice of resulting states.

The automaton can change state only after reading an input.

Page 5: Toc Project Report

PROBLEM:

Design a DFA to accept a language of all strings containing Σ= {0, 1} and

ending with ‘ab’.

SOLUTION:

The solution is obtained by beginning with a starting state.

The starting state should be able to read the input symbol ‘a’ or ‘b’ and

determine its next state.

Each state should have 2 possible outcomes or state changes – 1 on

reading ‘a’ and 1 on reading ‘b’.

Before reaching the final state, the DFA should have read the preceding

‘a’ before the final ‘b’, in which case the DFA accepts the language.

The DFA is represented as a transition diagram and transitions are

drawn for each state showing what transitions are made on reading

each input symbol.

Transition diagram:

Fig. Transition diagram for the given DFA

Here, q is the starting state and q2 is the accepting state.

The language is accepted if the DFA stops in q2 after it finishes reading

the input string.

The language is rejected if the DFA does not stop in q2 but stops in

either q0 or q1 after it finishes reading the input string.

Page 6: Toc Project Report

The DFA is also represented as a transition table specifying the starting

state and accepting state and showing which state the automaton goes

to on reading each input symbol from a given state.

Transition table:

A b

q0 q1 q0

q1 q1 q2

*q2 q1 q2

Fig. Transition table for the given DFA

INPUT:

The input is given using the input field present in the simulator.

The input reads the string symbol by symbol.

For each symbol, if the symbol is part of Σ i.e if it’s a valid symbol for the

given DFA, it shows the transition for the symbol from the state to the

next state.

If the symbol is not part of Σ i.e if an invalid symbol is entered, it does

not show a transition and the state turns red in color and the language

is rejected.

SIMULATION:

The simulation is run to check if the designed DFA accepts or rejects the given

strings. The simulation is run for the following 2 example inputs i.e to accept

or reject the strings:

abbabab

abba

1. For the input string ‘abbabab’:

The DFA starts with the starting state and makes the transitions

according to the input symbols being read as the input from the string.

Page 7: Toc Project Report

The DFA is in the starting state q0.

The DFA reads ‘a’ and transitions to q1. Input read so far: a

The DFA reads ‘b’ and transitions to q2. Input read so far: ab

The DFA reads ‘b’ and transitions to q0. Input read so far: abb

Page 8: Toc Project Report

The DFA reads ‘a’ and transitions to q1. Input read so far: abba

The DFA reads ‘b’ and transitions to q2. Input read so far: abbab

The DFA reads ‘a’ and transitions to q1. Input read so far: abbaba

The DFA reads ‘b’ and transitions to q2. Input read so far: abbabab

STATUS: ACCEPTED [Since the DFA stopped in the accepting state after

it finished reading the input]

Page 9: Toc Project Report

2. For the input string ‘abba’:

The DFA starts with the starting state and makes the transitions

according to the input symbols being read as the input from the string.

The DFA is in the starting state q0.

The DFA reads ‘a’ and transitions to q1. Input read so far: a

The DFA reads ‘b’ and transitions to q2. Input read so far: ab

Page 10: Toc Project Report

The DFA reads ‘b’ and transitions to q0. Input read so far: abb

The DFA reads ‘a’ and transitions to q1. Input read so far: abba

STATUS: REJECTED [Since the DFA did not stop in the accepting state

after it finished reading the input. It stopped in q1 which is not an

accepting state]

SCREENSHOTS:

Page 11: Toc Project Report
Page 12: Toc Project Report
Page 13: Toc Project Report
Page 14: Toc Project Report
Page 15: Toc Project Report
Page 16: Toc Project Report
Page 17: Toc Project Report

CONCLUSION:

Thus the automaton simulation was done to design a Deterministic finite

automata and run the simulation to accept or reject the given language. This

simulation allowed us to read the input string symbol after symbol and

showed the transitions from each state as each input symbol was read. This

way, we were able to see the transitions and see how the DFA works. In the

case that the given language is not accepted, we can see where the transition

stops and why it is not being accepted. Also, being able to see the transitions

step by step, it becomes easier to debug the DFA and correct the design in the

case the DFA does not work as it was intended to. Therefore, the simulation is

the perfect way to understand how automata works and how the input strings

are processed by the abstract machine.

***END OF THE REPORT***