Flat 1
Flat 1
Syllabus:-
Family of formal languages - Finite automata – Type 3 formalism - Deterministic finite automata (DFA) –
Language acceptance - Non-deterministic finite automata (NFA) – Finite automata with epsilon transitions
– Applications - Finite automata with output - NFA to DFA conversions - Equivalence theorem between
DFA and NFA - Minimization of DFA.
In automata theory, a formal language is a set of strings of symbols drawn from a finite alphabet. A
formal language can be specified either by a set of rules (such as regular expressions or a context-free
grammar) that generates the language, or by a formal machine that accepts (recognizes) the language.
Related Terminologies
Alphabet
String
Length of a String
Kleene Star
Definition − The Kleene star, ∑*, is a unary operator on a set of symbols or strings, ∑, that gives the
infinite set of all possible strings of all possible lengths over ∑ including λ.
Representation − ∑* = ∑0 ∪ ∑1 ∪ ∑2 ∪……. where ∑p is the set of all possible strings of length p.
Example − If ∑ = {a, b}, ∑* = {λ, a, b, aa, ab, ba, bb,………..}
Definition − The set ∑+ is the infinite set of all possible strings of all possible lengths over ∑ excluding
λ.
Representation − ∑+ = ∑1 ∪ ∑2 ∪ ∑3 ∪…….
∑+ = ∑* − { λ }
Example − If ∑ = { a, b } , ∑+ = { a, b, aa, ab, ba, bb,………..}
Language
3.DFA
Finite Automaton can be classified into two types −
• Deterministic Finite Automaton (DFA)
• Non-deterministic Finite Automaton (NDFA / NFA)
Deterministic Finite Automaton (DFA) In DFA, for each input symbol, one can determine the state to which
the machine will move. Hence, it is called Deterministic Automaton. As it has a finite number of states, the
machine is called Deterministic Finite Machine or Deterministic Finite Automaton.
4. Language acceptance
Let a deterministic finite automaton be →
• Q = {a, b, c},
• ∑ = {0, 1},
• q0 = {a},
• F = {c},
and Transition function δ as shown by the following table −
The following table lists the differences between DFA and NDFA
A Finite Automaton with null moves (FA-ε) does transit not only after giving input from the alphabet set
but also without any input symbol. This transition without input is called a null move.
An NFA-ε is represented formally by a 5-tuple (Q, ∑, δ, q0, F), consisting of
• Q − a finite set of states
• ∑ − a finite set of input symbols
• δ − a transition function δ : Q × (∑ ∪ {ε}) → 2Q
• q0 − an initial state q0 ∈ Q
• F − a set of final state/states of Q (F⊆Q).
7. Applications
1. A Finite Automata is highly useful in designing Lexical Analyzers.
2. A Finite Automata is highly useful in designing text editors.
3. A Finite Automata is highly useful in designing spell checkers.
4. A Finite Automata is highly useful in designing Sequential Cicrcuit design (Transducer).
Finite automata may have outputs corresponding to each transition. There are two types of finite state
machines that generate output −
• Mealy Machine
• Moore machine
Mealy Machine
A Mealy Machine is an FSM whose output depends on the present state as well as the present input.
It can be described by a 6 tuple (Q, ∑, O, δ, X, q0) where −
• Q is a finite set of states.
• ∑ is a finite set of symbols called the input alphabet
. • O is a finite set of symbols called the output alphabet
• δ is the input transition function where δ: Q × ∑ → Q
• X is the output transition function where X: Q × ∑ → O
• q0 is the initial state from where any input is processed (q0 ∈ Q).
The state table of a Mealy Machine is shown below
Moore Machine
Moore machine is an FSM whose outputs depend on only the present state. A Moore machine can be
described bya 6 tuple (Q, ∑, O, δ, X, q0) where −
• Q is a finite set of states.
• ∑ is a finite set of symbols called the input alphabet.
• O is a finite set of symbols called the output alphabet.
• δ is the input transition function where δ: Q × ∑ → Q
• X is the output transition function where X: Q → O
• q0 is the initial state from where any input is processed (q0 ∈ Q).
The state table of a Moore Machine is shown below
NEXT STATE
PRESENT INPUT 0 INPUT 1 Output
STATE
->a b C X2
B b D X1
C c D X2
D d D X3
Problem Statement
Let X = (Qx, ∑, δx, q0, Fx) be an NDFA which accepts the language L(X). We have to design an
equivalent DFA Y = (Qy, ∑, δy, q0, Fy) such that L(Y) = L(X). The following procedure converts the
NDFA to its equivalent DFA
− Algorithm Input − An NDFA
Output − An equivalent DFA
Step 1 − Create state table from the given NDFA.
Step 2 − Create a blank state table under possible input alphabets for the equivalent DFA.
Step 3 − Mark the start state of the DFA by q0 (Same as the NDFA).
Step 4 − Find out the combination of States {Q0, Q1,... , Qn} for each possible input alphabet.
Step 5 − Each time we generate a new DFA state under the input alphabet columns, we have to apply step
4 again, otherwise go to step 6.
Step 6 − The states which contain any of the final states of the NDFA are the final states of the equivalent
DFA. Example:- Let us consider the NDFA shown in the figure below
• P0 = {(c,d,e), (a,b,f)}
• P1 = {(c,d,e), (a,b),(f)}
• P2 = {(c,d,e), (a,b),(f)}
Hence, P1 = P2.There are three states in the reduced DFA.
The reduced DFA is as follows −