UNIT - 1
Contents:-
1. Basic idea on Alphabets, Strings and Languages, Automata and Grammars, Regular
Languages, Deterministic finite Automata (DFA)-Formal Definition, Simplified notation, State
transition graph, Transition table, Language of DFA.
2. Nondeterministic finite Automata (NFA), NFA with epsilon transition, Language of NFA,
Equivalence of NFA and DFA.
3. Minimization of Finite Automata, Distinguishing one string from other.
4. FA with output - Moore and Mealy machine, Equivalence of Moore and Mealy Machine,
Applications and Limitation of FA.
1) Theory of Automata
Theory of Automata is the theoretical branch of computer science and
mathematics. It is the study of abstract machines and computation of problems
that can be solved using these machines.
2) Symbol - A symbol is an user defined entity.
3) Alphabet - An alphabet is finite set of symbols denoted by ∑ in automata.
Alphabets are a set of symbols that are used to construct a language.
Example:- {0,1} -> Binary Alphabet; {A….Z, a….z} is the alphabet set for
English language.
4) String - A string is defined as a sequence of symbols of finite length. It is
denoted by (W) in automata.
Example:- 000111 is a binary string, aabcd - is an alphabet string.
5) Length of a string(W) - It is denoted by |W|.
Example:- W = aaabscd
|W| = 7
6) Language - A language is a collection of appropriate string. A language which
is formed over ∑ can be finite or infinite.
7) Grammar - In theory of computation it is a set of formal rules, that are
generating syntactically correct sentences.
The formal definition of grammar is that it is defined as four tuples :-
G = (V,T,P,S)
I) G is a grammar
II) T is the final set of terminal symbols. It is denoted by lowercase symbols.
III) V is the final set of non-terminal symbols. It is denoted by uppercase
symbols.
IV) P is a set of production rules which is used for replacing the non-terminal
symbols (on the left side of the production) in a string with other terminals(on
the right side of the production).
V) S is the start of the symbol which is used to derive the string.
Grammar is composed of 2 basic elements:-
8) Terminal Symbols - Terminals Symbols are the components of the sentences
that are generated using grammar and are denoted by using small case
letters like a,b,c, etc.
9) Non-Terminal Symbols - Non-Terminal Symbols take part in the generation of
the sentence but are not the component of the sentence . These type of the
symbols are also Auxiliary symbols and variables. They are represented
using capital letters like A,B,C etc.
Note:- symbols denotes empty string.
Regular Expression
1. The language accepted by finite automata can easily be described by simple
expressions called Regular Expressions. It is the most effective way to represent
any language.
2. The languages accepted by regular expression is known as Regular Language.
3. A regular expression can also be defined as a sequence of pattern that defines a
string.
In a regular expression,
(i) X - It means zero or more occurrence of X. it can generate { Ɛ, X, XX, XXX,
*
XXXX, ……}
+
(ii) X - It means one or more occurrence of X. It can generate {X,XX,XXX,XXXX,
….}
Operations on Regular Language :-
(a) UNION (U) :- If L and M are two regular languages then their union L U M is
also a regular language.
For Example :-
L = { an | n >= 0 }, M = { bn | n >= 0 }
Then;
L U M = { an U bn | n >= 0 }
(b) INTERSECTION (∩) :- If L and M are two regular languages then their
intersection is also a regular language.
For Example :-
L = {am bn | n ≥ 0 and m ≥ 0}, M = {am bn ∪ bn am | n ≥ 0 and m ≥ 0}
Then;
L ∩ M = {am bn | n ≥ 0 and m ≥ 0}
(c) CONCATENATION (.) :- If L and M are two regular languages then their
concatenation L.M will also be regular language.
For Example :-
L = { an | n >= 0 }, M = { bn | n >= 0 }
Then;
L . M = { an . bn | n >= 0 }
*
(d) KLEENE CLOSURE ( X ) :- If L and M are two regular languages then its
kleene closure will also be a regular language. (Youtube -
https://youtu.be/4Q2rE6R31GU )
For Example :-
P=(LUM)
Then its kleene closure will be;
* *
P =(LUM)
FINITE AUTOMATA
Finite Automata (FA) - It is the simplest machine to recognize patterns. The finite
automata or finite state machine is an abstract machine that has five elements or
tuples.
Deterministic Finite Automata (DFA)
It is a Finite Automata, where there is only one path for a specific input from the
current state to the next state. They cannont change the state without any input. It
can contain multiple final states.
It has a collection of 5 tuples :-
Q : finite set of states
∑ : finite set of the input symbol
q0 : initial state
F : final state
δ : Transition function :- δ : Q X Σ --> Q
Example of DFA :
Final State - It is
represented by double-
circle
Graphical Representation :-
A DFA is represented by diagraphs known as State Diagram.
I) The circle represent the states
II) The lines labeled with inputs defines the transitions
III) The initial state is denoted by an empty single incoming arc
IV) The final state is indicated by double circles
Transition Table :-
PRESENT STATE INPUT = 0 INPUT = 1
a a b
b c a
c b c
Non-Deterministic Finite Automata (NFA)
It is a finite automata, where there exist many paths for a single specific input from
the current state to the next state. Every NFA is not DFA , but each NFA can be
translated to DFA.
It has a collection of 5 tuples :-
Q : finite set of states
∑ : finite set of the input symbol
q0 : initial state
F : final state
δ : Transition function :- δ : Q X Σ --> 2Q
Example of NFA :
Graphical Representation :-
A DFA is represented by diagraphs known as State Diagram.
I)The circle represent the states
II)The lines labeled with inputs defines the transitions
III)The initial state is denoted by an empty single incoming arc
IV) The final state is indicated by double circles
Transition Table :-
PRESENT STATE INPUT = a INPUT = b
q0 q2 q0,q1
q1 q1 -
q2 - -
NFA TO DFA CONVERSION
Minimization of DFA
(First Watch - https://youtu.be/0XaGAkY09Wc)
(Second Watch - https://youtu.be/A7eKj_GXam0)
Minimization of DFA is the process of transforming DFA into an equivalent DFA with
the minimium no.of states possible.
Steps for the Minimization of DFA:-
1) Create the transition table of DFA (if table not given)
2) Create two sets/groups - (a) Final States, (b) Non-Final States
3) Now create equivalency (π) [ Check the example done to understand how to
create equivalencies ]
4) Repeat step - 3 untill all the sets contains states that are equivalent.
5) At last you will get the states and then create the DFA.
Moore Machine
Moore machine is a finite state machine in which the output values depends on the
current state of the machine.
It has a collection of 6 tuples :-
(Q, q0, ∑, O, δ, λ)
Q : finite set of states
q0 : initial state of machine
∑ : finite set of input symbols
O : finite set of output symbols
δ : transition function is Q × ∑ → Q
λ : output function is Q → O
Example of Moore Machine :-
Mealy Machine
A Mealy machine is a finite state machine in which the output values depends on the
current input and the current state of the machine.
It has a collection of 6 tuples :-
(Q, q0, ∑, O, δ, λ)
Q : finite set of states
q0 : initial state of machine
∑ : finite set of input symbols
O : finite set of output symbols
δ : transition function is Q × ∑ → Q
λ : output function is Q × ∑ → Q
Example of Mealy machine :-
Conversion from Mealy to Moore machine
Applications of FA
For the designing of lexical analysis of a compiler.
For recognizing the pattern using regular expressions.
For the designing of the combination and sequential circuits using Mealy and
Moore Machines.
Used in text editors.
For the implementation of spell checkers.
Limitations of FA