UNIT-I
Introduction to Finite Automata
RatnaKumari Challa
Assistant Professor
Dept of CSE,
RGUKT-RK Valley
RatnaKumari Challa
Syllabus
• UNIT-I: Introduction to Automata: Strings,
Alphabet, Language, Operations, Finite state
machine, definitions, finite automaton model,
acceptance of strings, and languages,
deterministic finite automaton and non-
deterministic finite automaton, transition
diagrams and Language recognizers
RatnaKumari Challa
Overview
• Basics: Alphabets, Strings and Language
• Finite state machine
• acceptance of strings and languages
• DFA and NFA
• transition diagrams
• Language recognizers
RatnaKumari Challa
Basics
• Alphabet: A finite nonempty set of symbols denoted
by
– elements are some kind of characters
– Members/elements of an alphabet are called symbols
letters and digits
– Example: ={a}, = {a, b, x, y}, ={0}, ={0, 1}
• String: Finite sequence of symbols from the
alphabet.
– written adjacent without commas
– Example: over Σ = {a,b,c,d}: aaa, bac, abab, abbba
– Examples over Σ = {0,1}: 000, 01011
– Typically represent strings with letters like u, v, w, x, y, z
• Examples: u = acb, x = 10110
RatnaKumari Challa
Operations on strings
• Concatenation: Join two or more strings and/or
symbols
– Ex: If u = abab, v= abbba then uv = abababbba
• Reverse of a string u is obtained by writing
symbols in the reverse order. Denoted by uR
• Ex: The reverse of u: uR = baba
• Length of string u is number of symbols in u and
is denoted as |u|
• Example: |u| = 4; |v|=5
RatnaKumari Challa
Conti…
• Empty String: string with no symbols is denoted by
( or or ) and its length is zero.
• If u and v are two strings it is true that |uv| = |u| +
|v|.
• Kleen closure and Kleen plus: If is an alphabet, *
is the set of strings obtained by concatenating zero
or more symbols from And += * - { }
– Ex: If ={a,b} then * = { , a,b,aa,ab,..} and += {
a,b,aa,ab,..}
RatnaKumari Challa
Language
• A set of strings (over an alphabet)
• language is defined as a subset of * . However
we define in a more meaningful way in the
coming sessions.
Examples:
– Over alphabet {a, b, c}:
• L1 = {aaa, aba}; L2 = {a, aa, aaa}
– Over alphabet {0, 1}:
• L1 = {0}; L2 = {0, 1, 010}
RatnaKumari Challa
Conti…
• set of all binary strings ending with 1
– Ex: L = {1, 01, 001, 011, 101, …}
• set of all strings over {a,b} having number of a’s equal
to number of b’s
– Ex: L = {, ab, ba, abba, aabb, baab, …}
• L: {an/n 1} over {a} ➔ {a, aa, aaaa, aaa, aaaaaa ….}
• L:{ an bn / n 1} over {a,b} ➔ {ab, aabb, aaabbb, … }
• L: { an bn cn / n 0 } over {a,b,c} ➔ {, abc, aabbcc, …}
• set of valid variable names in Fortran
• set of valid arithmeticRatnaKumari
expressions
Challa
in C
Automata
• An abstract machine – to solve computation
problems
• automaton consists of states and transitions.
The State is represented by circles, and
the Transitions is represented by arrows
• takes some string as input and this input goes
through a finite number of states and may enter
in the final state
RatnaKumari Challa
Example
a
q0 a
q1
RatnaKumari Challa
Finite Automata
• Finite automata are used to recognize strings
• 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
RatnaKumari Challa
Finite Automation
• A finite automation is a 5-tuple
M = (Q, , , q0 , F )
Q : a finite nonempty set of states
: input alphabet
: transition function, Q Q
q0 : initial state
F : set of final states, F Q
RatnaKumari Challa
Note
• is defined for each q Q and for each a
• Thus with each input alphabet the automation
moves from one state to another state as per
• (qi , a) = q j indicates,
q with input a the
automaton in the state i moves to state q j.
RatnaKumari Challa
Example
a
q0 a q1
Q = {q0 , q1}
= {a} δ a
q0 = q0 q0 q1
q1 q0
F = {q0 }
RatnaKumari Challa
Finite Automata Model
• input tape, finite control and tape reader
• 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.
• Tape reader reads the cells one by one from left to
right, and at a time only one input symbol is read.
RatnaKumari Challa
Working of FA
• Initially FA is in start state and the input head is on
the leftmost symbol of input.
• The input symbol is read (input head moves to the
next character) and FA assumes a new state
depending on the present state and the read input
symbol (transition function).
• Repeat the above step until the input is consumed.
• If FA is in a final state, announce accept,otherwise
announce reject.
RatnaKumari Challa
Example
a a b
a a, b
b a, b
q0 q1 q2
RatnaKumari Challa
a a b
a a, b
q0 b q1 a, b q2
RatnaKumari Challa
a a b
a a, b
q0 b q1 a, b q2
RatnaKumari Challa
a a b
a a, b
q0 b q1 a, b q2
RatnaKumari Challa
Input finished
a a b
a a, b
Output: “accept”
q0 b q1 a, b q2
RatnaKumari Challa
Example for Rejection
b a b
a a, b
q0 b q1 a, b q2
RatnaKumari Challa
b a b
a a, b
q0 b q1 a, b q2
RatnaKumari Challa
b a b
a a, b
q0 b q1 a, b q2
RatnaKumari Challa
b a b
a a, b
q0 b q1 a, b q2
RatnaKumari Challa
Input finished
b a b
a a, b
q0 b q1 a, b q2
Output: “reject”
RatnaKumari Challa
Types of Automata
• There are two types of finite automata:
– DFA (deterministic finite automata):
• Deterministic refers to the uniqueness of the computation
• machine goes to one state only for a particular input
character
• DFA does not accept the null move.
– NFA(non-deterministic finite automata):
• transmit any number of states for a particular input
• It can accept the null move
• Every DFA is NFA, but NFA is not DFA
• multiple final states in both NFA and DFA
RatnaKumari Challa
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.
RatnaKumari Challa
Transition Table
• 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
– Columns correspond to input symbols.
– Rows correspond to states.
– Entries correspond to the next state.
– start state is denoted by an arrow with no source.
– The accept state is denoted by a star.
RatnaKumari Challa
Example 1
RatnaKumari Challa
Example 2
RatnaKumari Challa
Example
• FA with ∑ = {0, 1} accepts the only input 101
• FA with ∑ = {0, 1} accepts those string which
starts with 1 and ends with 0
RatnaKumari Challa
DFA
• Deterministic -- uniqueness of the computation
• there is only one transition for specific input from
the current state to the next state
• does not accept the null move, i.e., the DFA
cannot change state without any input character
RatnaKumari Challa
Formal Definition of DFA
• A DFA is a 5-tuple
M = (Q, , , q0 , F )
Q : a finite nonempty set of states
: input alphabet
: transition function, Q Q
q0 : initial state
F : set of final states, F Q
RatnaKumari Challa
Example
RatnaKumari Challa
Examples
• DFA with ∑ = {0, 1} accepts all starting with 0
• DFA with ∑ = {0, 1} accepts all ending with 0
RatnaKumari Challa
NFA
• the exact state to which the machine moves
cannot be determined
• for a particular input symbol, the machine can
move to any combination of the states in the
machine
RatnaKumari Challa
Formal Definition of NFA
• A DFA is a 5-tuple
M = (Q, , , q0 , F )
Q : a finite nonempty set of states
: input alphabet
: transition function, Q 2 Q
q0 : initial state
F : set of final states, F Q
RatnaKumari Challa
Example
RatnaKumari Challa
Example
• NFA with ∑ = {0, 1} accepts all strings with 01
• NFA with ∑ = {0, 1} and accept all string of
length 2
• NFA with ∑ = {0, 1} accepts all string ending
with 01
RatnaKumari Challa
String/Language Recognizers
RatnaKumari Challa
Example
RatnaKumari Challa
Example – String Acceptance
RatnaKumari Challa