Theory of Automata Finite Automata 4

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 15

Theory of Automata

Finite Automata, Transition table, Transition diagram


Finite Automata
• Finite automata are used to recognize patterns.
• It takes the string of symbol as input and changes its state accordingly.
When the desired symbol is found, then the transition occurs.
• At the time of transition, the automata can either move to the next state
or stay in the same state.
• Finite automata have two states, Accept state or Reject state. When
the input string is processed successfully, and the automata reached its
final state, then it will accept.
Formal Definition of FA
A Finite automaton (FA), is a collection of the followings
• Finite number of states, having one initial and some (maybe none)
final states.
• Finite set of input letters (Σ) from which input strings are formed.
• Finite set of transitions i.e. for each state and for each input letter there
is a transition showing how to move
• from one state to another.
A finite automaton is a collection of 5-tuple (Q, ∑, δ, q0, F), where:
• Q: finite set of states
• ∑: finite set of the input symbol
• q0: initial state
• F: final state
• δ: Transition function
Finite Automata Model
Finite automata can be represented by input
tape and finite control.
• Input tape: It is a linear tape having
some number of cells. Each input symbol
is placed in each cell.
• Finite control: The finite control decides
the next state on receiving particular input
from input tape. The tape reader reads the
cells one by one from left to right, and at
a time only one input symbol is read.
Types of Automata
There are two types of finite automata:
• DFA(deterministic finite automata)
• NFA(non-deterministic finite automata)
• 1. DFA
DFA refers to deterministic finite automata. Deterministic
refers to the uniqueness of the computation. In the DFA, the
machine goes to one state only for a particular input character.
DFA does not accept the null move.
• 2. NFA
NFA stands for non-deterministic finite automata. It is used to
transmit any number of states for a particular input. It can
accept the null move.
Important points
• Every DFA is NFA, but NFA is not DFA.
• There can be multiple final states in both NFA and DFA.
• DFA is used in Lexical Analysis in Compiler.
• NFA is more of a theoretical concept.
Transition Diagram
A transition diagram or state transition diagram is a directed graph
which can be constructed as follows:
• There is a node for each state in Q, which is represented by the circle.
• There is a directed edge from node q to node p labeled a if δ(q, a) = p.
• In the start state, there is an arrow with no source.
• Accepting states or final states are indicating by a double circle.
How DFA Operate?
1. In DFA, the input to the automata can be any string. Now, put a
pointer to the start state q and read the input string w from left to right
and move the pointer according to the transition function, δ. We can
read one symbol at a time. If the next symbol of string w is a and the
pointer is on state p, move the pointer to δ(p, a). When the end of the
input string w is encountered, then the pointer is on some state F.
2. The string w is said to be accepted by the DFA if r ∈ F that means the
input string w is processed successfully and the automata reached its
final state. The string is said to be rejected by DFA if r ∉ F.
Example
• DFA with ∑ = {0, 1} accepts all strings starting with 1.

The finite automata can be represented using a transition


graph. In the above diagram, the machine initially is in
start state q0 then on receiving input 1 the machine
changes its state to q1. From q0 on receiving 0, the
machine changes its state to q2, which is the dead state.
From q1 on receiving input 0, 1 the machine changes its
state to q1, which is the final state. The possible input
strings that can be generated are 10, 11, 110, 101,
111......., that means all string starts with 1.
Transition Table
The transition table is basically a tabular representation of the transition
function. It takes two arguments (a state and a symbol) and returns a
state (the "next state"). A transition table is represented by the following
things:
• Columns correspond to input symbols.
• Rows correspond to states.
• Entries correspond to the next state.
• The start state is denoted by an arrow with no source.
• The accept state is denoted by a star.
Example
Example
• Σ = {a,b}
• States: x, y, z where x is an initial state and z is final state.
Transitions
• At state x reading a, go to state z
• At state x reading b, go to state y
• At state y reading a, b go to state y
• At state z reading a, b go to state z
Transition table

It may be noted that the information of an FA, given in the


previous table, can also be depicted by the following
diagram, called the transition diagram, of the given FA

The above transition diagram is an FA accepting the


language of strings, defined over Σ = {a, b}, starting with
a. It may be noted that this language may be expressed by
the regular expression a(a + b)*

You might also like