TOC Module-1 Notes
TOC Module-1 Notes
MODULE-1
INTRODUCTION TO AUTOMATA THEORY
Automata theory is the study of abstract computing devices or “machines”. Before there were
computers in the 1930’s, Allan Turing studied an abstract machine that had all the capabilities
of today’s computers at least as far as in what they could compute Turing’s goal was to describe
precisely the boundary between what a computing machine could do and what it could not do;
his conclusions apply not only to his abstract Turing machines but to today’s real machines.
Example: Perhaps the simplest nontrivial finite automaton is an on/off Switch. The device
remembers whether it is in the “on” state or the “off” state, and it allows the user to press a
button whose effect is different, depending on the state of the switch_ That is, if the switch is
in the on state, then pressing the button changes it to the on state, and if the switch is in the on
state, then pressing the same button turns it to the on state.
i) Alphabets:
An alphabet is a finite, nonempty set of symbols. Conventionally, we use the symbol ∑ for an
alphabet.
Common alphabets include:
1. ∑ = {0, 1} the binary alphabet.
2. ∑ = {a, b, …., z}, the set of all lower-case letters.
3. The set of all ASCII characters, or the set of all printable ASCII characters.
ii) Strings:
A string (or sometimes word) is a finite sequence of symbols chosen from some alphabet. For
example, 01101 is a string from the binary alphabet ∑={0, 1}. The string 111 is another string
chosen from this alphabet.
v) Powers of an Alphabet
If ∑ is an Alphabet we can express the set of all strings of a certain length from that alphabet
by using an exponential notation We define ∑k to be the set of strings of length k each of whose
symbols is in ∑.
If ∑={0,1}, then
∑1={0,1},
∑2={00,01,10,11}
∑3={000,001,010,011,100,101,110, 111} and so on.
Sometimes, we wish to exclude the empty string from the set of strings. The set of nonempty
strings from alphabet ∑ is denoted ∑+. Thus, two appropriate equivalences are:
∑+ = ∑0 U ∑1 U ∑2 U………………..
∑* = ∑0 U {ε}
vii) Languages
A set of strings all of which are chosen from some ∑*, where ∑ is a particular Alphabet, is
called a language. If ∑ is an alphabet, and L then L is a language over ∑.
Examples:
1. The language of all strings consisting of n 0’s followed by n 1’s, for some
n ≥ 0 :{ε, 01, 0011, 000111,……}
2. The set of strings of 0’s and 1’s with an equal number of each:
{ε, 01, 10, 0011, 0101, 1001, …..}
3. The set of binary numbers whose value is a prime:
{10, 11, 101, 111, 1011, …}
4. ∑* is a language for any alphabet ∑.
Dept. of CSE, EPCET 2024-25 3
TOC [BCS503] Module-1 Notes
FINITE AUTOMATA
A finite automaton is a mathematical model which is used to study the abstract machines or
abstract computing devices with inputs chosen from ∑, where ∑ stands for set of alphabets
using which any string can be obtained. On reading the string, the machine may accept or reject
the string.
How a DFA Processes Strings: Initially the DFA is in state q0. The DFA reads the input
string from left to right one symbol at a time. The changes to state of DFA is dictated by δ.
When the last symbol of input string is read, if this results in the DFA reaching any of its final
state, we say that the string is accepted by DFA, otherwise the string is rejected.
Simpler Notations for DFA’s: There are two preferred notations for describing automata.
a) A transition diagram, which is a graph.
b) A transition table, which is a tabular listing of the function δ which by
implication tells us the set of states and the input alphabet.
δ(qo,1)=q0,
δ(q1,0)=q1,
δ(q1,1)=q1,
δ(q2,0)=q2,
δ(q2,1)=q1 }
The transition diagram is,
Transition Tables:
A transition table is a conventional, tabular representation of a function like δ that takes two
arguments and returns a value. The rows of the table correspond to the states, and the columns
correspond to the inputs. The entry for the row corresponding to state q and the column
corresponding to input a is the state δ (q, a). The transition table for the above example is:
“The extended transition function is a function that takes a state q and a string w and
returns a state p - the state that the automaton reaches when starting in state q and
processing the sequence of inputs w”.
We define by induction on the length of the input string, as follows:
Suppose the input is 110101. Since this string has even numbers of 0’s and1’s both, we expect
it is in the language. Thus, we expect that (q0,110101)=q0 since q0 is the only accepting
state.
Ex: Let us design a NFA to accept all and only the strings of 0’s and 1’s that end in 01.
Here the possible strings are, L={01, 101, 001, 11101,101001,..}
Here the NFA has the option of going either to q0 or to q1 and in fact it does both, as we shall
see when we make the definitions precise. In state q1 the NFA checks that the next symbol is
1 and if so, it goes to state q2 and accepts. Notice that there is no arc out of q1 labeled 0, and
there are no arcs at all out of q2.
δ: Q X ∑→ 2Q
Example: Let us trace the input 00101 by the NFA to accept strings ending with 01.
Since we reached the end of the string and automata is in states {qo, q2} where q2 is the final
state, the given string is accepted.
Example:
Let us convert the following NFA to DFA using subset construction method.
Given NFA,
Since N’s set of states is {q0, q1, q2} the subset construction produces a DFA with 23 =8 states,
corresponding to all the subsets of these three states. Following figure shows the transition
table for these eight states.
Ex: Let us design a ε-NFA that accepts decimal numbers consisting of:
1. An optional + or – sign
2. A string of digits
3. A decimal point and
4. Another string of digits. Either this string of digits or the string (2) can be empty, but
both cannot be empty at the same time.
The ε-closure of any state q denoted by ECLOSE(q) is the set of all states which are reachable
from q on ε transitions only. Formally ε-closure ECLOSE(q) recursively, as follows:
Example:
ECLOSE(1) = {1, 2, 3, 4, 6}
ECLOSE(2)={2, 3, 6}
ECLOSE(3)={3, 6}
ECLOSE(4)={4}
ECLOSE(5)={5,7}
Ans:
Let us find ECLOSE of all the states of given NFA,
ECLOSE(p)={p, q, r}
ECLOSE(q)={q}
ECLOSE(r)={r}
Step 1: Since p is the start state of the given NFA, start state of DFA is,
ECLOSE(p)={p, q, r}
Step 2: Find transition function of the DFA as follows (use subset-construction method) :
The search engine uses a particular technology, called inverted indexes, where for each word
appearing on the Web (there are 100,000,000 different words), a list of all the places where
that word occurs is stored. Machines with very large amounts of main memory keep the most
common of these lists available, allowing many people to search for documents at once.
Inverted-index techniques do not make use of finite automata, but they also take very large
amounts of time for crawlers to copy the Web and set up the indexes. There are a number of
related applications that are unsuited for inverted indexes, but are good applications for
automaton-based techniques. The characteristics that make an application suitable for searches
that use automata are:
1. The repository on which the search is conducted is rapidly changing. For example:
(a) Every day, news analysts want to search the day’s online news articles for relevant
topics. For example, a financial analyst might search for certain stock ticker
symbols or names of companies.
(b) A “shopping robot” wants to search for the current prices charged for the items that
its clients request. The robot will retrieve current catalog pages from the Web and
then search those pages for words that suggest a price for a particular item.