ATC Module 1 Notes 2022
ATC Module 1 Notes 2022
To impart high quality education in Engineering, Technology and Management with a difference, enablingstudents
to excel in their career by
1. Attracting quality Students and preparing them with a strong foundation in fundamentals so as to achieve
distinctions in various walks of life leading to outstanding contributions.
2. Imparting value based, need based, and choice based and skill based professional education to the aspiringyouth
and carving them into disciplined, World class Professionals with social responsibility.
3. Promoting excellence in Teaching, Research and Consultancy that galvanizes academic consciousnessamong
Faculty and Students.
4. Exposing Students to emerging frontiers of knowledge in various domains and make them suitable for
Industry, Entrepreneurship, Higher studies, and Research & Development.
5. Providing freedom of action and choice for all the Stake holders with better visibility.
Imparting high quality education in the area of Information Science so as to graduate the students with good
fundamentals, "Information System Integration", "Software Creation" capability & suitably train them to thrive in
Industries, higher schools of learning and R & D centers with a comprehensive perspective.
• PEO3: Obtained the capacity to investigate the necessities of the software Product, adapt to technological
advancement, promote collaboration and interdisciplinary activities, Protecting Environment and developing
Comprehensive leadership.
• PEO4: Enabled to be employed and provide innovative solutions to real-world problems across different
domains.
• PEO5: Possessed communication skills, ability to work in teams, professional ethics, social responsibility,
entrepreneur and management, to achieve higher career goals, and pursue higher studies.
PROGRAM OUTCOMES (POs)
• PO1: Engineering knowledge: Apply the knowledge of mathematics, science, engineering fundamentals,
and an engineering specialization for the solution of complex engineering problems
• PO2: Problem analysis: Identify, formulate, research literature, and analyze complex engineering
problems reaching substantiated conclusions using first principles of mathematics, natural sciences and
engineering sciences.
• PO3: Design/development of solutions: Design solutions for complex engineering problems and design
system components or processes that meet the specified needs with appropriate consideration for public
health and safety, and cultural, societal, and environmental considerations.
• PO4: Conduct investigations of complex problems: Use research-based knowledge and research
methods including design of experiments, analysis and interpretation of data, and synthesis of the
information to provide valid conclusions.
• PO5: Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern
engineering and IT tools, including prediction and modeling to complex engineering activities, with an
understanding of the limitations.
• PO6: The engineer and society: Apply reasoning informed by the contextual knowledge to assess
Societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to the
professional engineering practice.
• PO7: Environment and sustainability: Understand the impact of the professional engineering solutions
in societal and environmental contexts, and demonstrate the knowledge of, and need for sustainable
development.
• PO8: Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms of
the engineering practice.
• PO9: Individual and team work: Function effectively as an individual, and as a member or leader in
diverse teams, and in multidisciplinary settings.
• PO10: Communication: Communicate effectively on complex engineering activities with the engineering
community and with the society at large, such as, being able to comprehend and write effective reports and
design documentation, make effective presentations, and give and receive clear instructions.
• PO11: Project management and finance: Demonstrate knowledge and understanding of the engineering
and management principles and apply these to one’s own work, as a member and leader in a team, to
manage projects and in multidisciplinary environments.
• PO12: Life-long learning: Recognize the need for, and have the preparation and ability to engage in
independent and life-long learning in the broadest context of technological change.
HN, SSK & PM, Dept. of ISE, RNSIT 2022-2023 Page 2
Automata Theory & Computability [18CS54 CBCS]
• PSO2 – Applied Engineering Skills: Enable creative thinking, Ability to apply standard practices and
strategies, technical skills in software design, development, integration of systems and management for
improving the security, reliability and survivability of the infrastructure.
• PSO3 – General Expertise and Higher Learning: Ability to exchange knowledge effectively demonstrate
the ability of team work, documentation skills, professional ethics, entrepreneurial skills and continuing higher
education in the field of Information technology.
Topics: Why study the Theory of Computation, Languages and Strings: Strings, Languages. A Language
Hierarchy, Computation, Finite State Machines (FSM): Deterministic FSM, Regular languages,
Designing FSM, Nondeterministic FSMs, From FSMs to Operational Systems, Simulators for FSMs,
Minimizing FSMs, Canonical form of Regular languages, Finite State Transducers, Bidirectional
Transducers.
Programmers from the early days could never have imagined what a program of today would look like.
Today's programmers can't read code from 50 years ago. But there are mathematical properties, both of
problems and of algorithms for solving problems that depend on neither the details of today's technology
nor the programming fashion.
Theory of computation addresses some of those properties. It is useful in two key ways:
• It provides a set of abstract structures that are useful for solving certain classes of problems. These
abstract structures can be implemented on whatever hardware/ software platform is available.
• It defines provable limits to what can be computed, regardless of processor speed or memory size. An
understanding of these limits helps us to focus our design effort in areas in which it can pay off, rather
than on the computing equivalent of the search for a perpetual motion machine.
Our focus will be on analyzing problems, rather than on comparing solutions to problems. Our goal will be
to discover fundamental properties of the problems themselves:
• Is there any computational solution to the problem?
• If a solution exists, how efficient is it? More specifically, how do its time and space requirements grow
as the size of the problem grows?
• Are there groups of problems that are equivalent in the sense that if there is an efficient solution to
one member of the group there is an efficient solution to all the others?
• We would like to build programs to manage our words, check our grammar. search the World Wide
Web, and translate from one language to another. Programs to do that also rely on the theory of context-
free languages.
• Systems such as parity checkers, vending machines. communication protocols and building security
devices can be straightforwardly described as finite state machines.
• Many interactive video games are (large. often nondeterministic) designed using finite state machines.
• DNA molecules, as well as the proteins that they describe, are strings that are made up of symbols
drawn from small alphabets (nucleotides and amino acids, respectively). They rely on techniques that
are based on both finite state machines and context-free grammars.
HN, SSK & PM, Dept. of ISE, RNSIT 2022-2023 Page 4
Automata Theory & Computability [18CS54 CBCS]
• It is used in solving Artificial Intelligence problems, security designs, decidability & so on.
Terminologies
• An alphabet, often denoted Σ, is a finite set of input symbols or characters.
• A string is a finite sequence, possibly empty, of symbols drawn from some alphabet Σ. Given any
alphabet Σ, the shortest string that can be formed from Σ is the empty string, which we will write as
ε. The set of all possible strings over an alphabet Σ is written Σ *.
Ex:
Alphabet name Alphabet symbols Example strings
The English alphabet {a, b. c, ... ,z} ε, aabbcg, aaaaa
Functions on Strings
• The length of a string s, which we will write as |s|, is the total number of symbols in s.
Ex: |ε| = 0
|1001101| = 7
For any symbol c and string s, we define the function #c(s) to be the number of times that the symbol
c occurs in s.
Ex: #a(abbaaa) = 4.
• The concatenation of two strings s and t, written s||t or simply st, is the string formed by appending t to s.
Ex: If x = good and y = bye, then xy = goodbye. So |xy|=|x|+|y|. The empty string, ε, is the identity for
concatenation of strings. So 6 x (x ε = ε x = x).
Concatenation, as a function defined on strings is Associative. So 6 s, t, w ((st)w = s (tw)).
• The string replication is repetition of strings. For each string w and each natural number i, the string wi is
defined as:
w 0= ε
w i+1= w i w
Ex: a3 = aaa
(bye)2 =byebye
a0b3=bbb
• String reversal.
For each string w, the reverse of w, which we will write wR, is defined as: If |w| = 0 thenwR = w = ε
.If |w| ≥1 then < a ϵ Σ( < u C Σ* (w = ua)), (i.e., the last character of w is a.) Then define wR = auR.
Relations on Strings
A string s is a proper substring of a string t iff s is a substring of t and s ≠ t. Every string is a substring
(although not a proper substring) of itself. The empty string, ε, is a substring of every string.
A string s is a prefix of t iff Ǝx ϵ Σ* (t = sx). A string s is a proper prefix of a string t iff s is a prefix of t and
s≠ t. Every string is a prefix (although not a proper prefix) of itself. The empty string, ε, is a prefix of every
string.
Ex: The prefixes of abba are: ε, a, ab, abb, abba.
A string s is a suffix of t iff Ǝ x ϵ Σ* (t = xs). A string s is a proper suffix of a string iff s is a suffix of t and s
≠ t. Every string is a suffix (although not a proper suffix) of itself. The empty string, ε, is a suffix of every
string.
Ex: The suffixes of abba are: ε, a, ba, bba, abba.
Languages
A language is a (finite or infinite) set of strings over a finite alphabet Σ. When there are more than one
language that are considered, we will use the notation Σ L to mean the alphabet from which the strings in the
language L are formed.
Note:
• Let L = {} = Ø . L is the language that contains no strings. The Empty language is different from the Empty
String.
• Let L = { ε }, the language that contains a single string, ε. Note that L is different from Ø.
Relations on languages
Languages are sets. So, if we want to provide a computational definition of a language, we could specify
either:
• a language generator, which enumerates (lists) the elements of the language, or
• a language recognizer, which decides whether or not a candidate string is in the language and returns
True if it is and False if it isn't.
Ex: The logical definition. L = {x: Ǝy ϵ {a, b}* (x = ya )} can be turned into either a language generator
(enumerator) or a language recognizer.
In some cases, when considering an enumerator for a language we may care about the order in which the
elements of L are generated.
If there exists a total order D of the elements of Σ L , then we can use D to define on L a useful total order called
lexicographic order written as <L:
• Shorter strings precede longer ones: ∀x(∀ y(( |x| < |y|) → (x <L y))) and of strings that are the same
length sort them in dictionary order using D.
When we use lexicographic order, we will assume that D is the standard sort order on letters and numerals.
We will say that a program lexicographically enumerates the elements of L iff it enumerates them in
lexicographic order.
Ex: Lexicographic Enumeration
Let L = {x ϵ {a, b )*: all a's precede all b's }.
The lexicographic enumeration of L is:
{ε, a, b, aa, ab, bb, aaa, aab, abb, bbb, aaaa, aaab, aabb, abbb, bbbb, aaaaa...}
It is the size of the language. The smallest language over any alphabet is Ø whose cardinality is 0. The largest
language over any alphabet Σ is Σ*.
If Σ = Ø, then Σ* = { ε } and |Σ*| = 1.
The Cardinality of Σ*
If Σ is not Ø then Σ* is countably infinite.
The elements of Σ* can be lexicographically enumerated by a straightforward procedure that:
• Enumerates all strings of length 0, then length 1, then length 2 and so forth.
• Within the strings of a given length, enumerates them in dictionary order. This enumeration is infinite
since there is no longest string in Σ*.
Since any language over Σ is a subset of Σ *, the cardinality of every language is at least 0 and at most infinity.
So all languages are either finite or countably infinite.
Functions on languages
Since languages are sets, all of the standard set operations are well-defined on languages. In particular, we will
find union, intersection, difference, and complement to be useful.Complement will be defined with Σ* as the
universe unless we explicitly state otherwise.
Concatenation
Let L1 and L2 be two languages defined over some alphabet Σ. Then their concatenation, written L1L2 is:
L1L2 = { w ϵ Σ * : Ǝ s ϵL1 (Ǝ t ϵ L2 (w=st))}
Ex: Concatenation of Languages
Let L1 = {cat, dog, mouse, bird}
L2 = { bone, food}.
L1L2={ catbone, catfood, dogbone,dogfood, mousebone, mousefood,birdbone,birdfood}
The language { ε } is the identity for concatenation of languages.
So, for all languages L, L{ ε } = { ε }L = L.
The language Ø is a zero for concatenation of languages. So, for all languages L, LØ = ØL = Ø .
Concatenation, as a function defined on languages is associative. So,for all languages L1,L2,L3: ((L1,L2)L3
=L1,(L2,L3))
Suppose that L1 = {an : n ≥ 0} and L2 = { bn : n ≥ 0}. By the definition of language concatenation,
L1L2 = { w: w consists of a’s (possibly empty) followed by b’s (possibly empty)}.
L1L2 ≠ { an bn : n ≥ 0}, since every string in { an bn : n ≥ 0} must have the same number of b's as a's. The easiest
way to avoid confusion is simply to rename conflicting variables before attempting to concatenate the expressions
that contain them.So L1L2 = { an bm : n, m ≥ 0}.
Kleene star
Let L be a language defined over some alphabet Σ.
Then the Kleene star of L, written L* is:
L* = { ε} U {w ϵ Σ * : Ǝk ≥ 1 (Ǝw1 , w2, ... wk ϵ L (w = w1w2 ........... wk)) }
In other words, L* is the set of strings that can be formed by concatenating together zero or more strings from
L.
Ex:
Let L = {dog, cat, fish}. Then,
L* = { ε,dog, cat, fish, dogdog, dog cat, ...fishdog, . . , fishcatfish, fishdogfishcat..}
• L* always contains an infinite number of strings as long as L is not equal to either Ø or { ε } (i.e., as
long as there is at least one nonempty string any number of which can be concatenated together).
• If L = Ø , then L* = { ε }, since there are no strings that could be concatenated to ε to make it longer. If L
= { ε }. then L * is also { ε }.
• It is sometimes useful to require that at least one element of L be selected. So we define: L+ = LL*.
• Another way to describe L+ is that it is the closure of L under concatenation. Note that L+ = L*- { ε } iff ε Ø
L.
Reverse of a language
Let L = { 0, 1}+ be the set of binary strings. L does not include ε.
Let L be a language defined over some alphabet Σ. Then the reverse of L , written LR is:
LR = {w ϵ Σ*: w = xR for some x ϵ L}.
R
In other words, L is the set of strings that can be formed by taking some string in L and reversing it.
The class of languages that can be accepted by some PDA are called context-free languages.
Note some simple limitations to the power of the PDA.
Consider the language WW = { ww: w ϵ{a, b} *} Here,2nd half of the string is an exact copy of the first half .It
is not possible to build an accepting PDA for such problems where tracing back is required.
everything we can write programs to compute, we need a model that is stronger than the PDA.
To meet this need, we will introduce a third kind of machine called Turing machine .We will get rid
of the stack and replace it with an infinite tape. The tape will have a single read-write head. Only the tape
square under the read/write head can be accessed (for reading or for writing). The read/write head can be
moved one square in either direction on each move. The resulting machine is called a Turing machine. We
will also change the way that input is given to the machine. Instead of streaming it, one character at a time,
the way we did for FSMs and PDAs, we will simply write the input string onto the tape and then start the
machine with the read/write head just to the left of the first input character.
We show the structure of a Turing machine in Figure below. The arrow under the tape indicates the
location of the read/write head. At each step, a Turing machine M considers its current state and the character
that is, on the tape directly under its read/write head. Based on those two things, it chooses its next state,
chooses a character to write on the tape under the read/write head, and chooses whether to move the
read/write head one square to the right or one square to the left. A finite segment of M's tape contains the
input string. The rest is blank, but M may move the read/write head off the input string and write on the
blank squares of the tape.
• Finite state machines and pushdown automata are guaranteed to halt. They must do so when they run
out of input.
• Turing machines, on the other hand, carry no such guarantee. The input simply sits on the tape. A
Turing machine may move back and forth across its input many times. It may move back and forth
forever.
• Because of its flexibility in using its tape to record its computation, the Turing machine is a more
powerful model than either the FSM or the PDA.
• Any computation that can be written in any programming language or run on any modern computer can
be described as a Turing machine. However, when we work with Turing machines, we must be aware
of the fact that they cannot be guaranteed to halt.
• There exists no algorithm that can examine a Turing machine and tell whether or not it will halt (on any
one input or on all inputs). This fundamental result about the limits of computation is known as the
undecidability of the halting problem.
• We will use the Turing machine to define two new classes of languages:
• A language L is decidable iff there exists a Turing machine M that halts on all inputs, accepts all
strings that are in L,, and rejects all strings that are not in L. In other words, M can always say yes or
no, as appropriate.
• A language L is semidecidable iff there exists a Turing machine M that accepts all strings that are in L
and fails to accept every string that is not in L. Given a string that is not in L, M may reject or it may
loop forever. In other words. M can recognize a solution and then say yes. but it may not know when it
should give up looking for a solution and say no.
• Balanced parenthesis, AnBn, Palindrome, WW and AnBn Cn are all decidable languages. Every decidable
language is also semidecidable
• But there are languages that are semidecidable yet not decidable.
▪ As we move outward in the language hierarchy, we have access to tools with greater and greater
expressive power.
o So, for example: we can define AnBn as a context-free language but not as a regular one.
We can define AnBnCn as a decidable language but not as a context-free or a regular one.
▪ Decidability: There exist procedures to answer many useful questions about finite state machines. For
example. does an FSM accept some particular string? Is an FSM minimal Are two FSMs identical? A
subset of those questions can be answered for pushdown automata. None of them can be answered for
Turing machines.
▪ Clarity: There exist tools that enable designers to draw and analyze finite state machines. Every
regular language can also be described using the regular expression pattern language. Every context -
free language, in addition to being recognizable by some pushdown automaton, which can be described
with a context-free grammar. For many important kinds of languages. context-free grammars are
sufficiently natural that they are commonly used as documentation tools. No corresponding tools exist
for the broader classes of decidable and semi decidable languages.
Definition:
Formally, a deterministic FSM (or DFSM) M is a quintuple (K, Σ , δ, s, A) where:
HN, SSK & PM, Dept. of ISE, RNSIT 2022-2023 Page 13
Automata Theory & Computability [18CS54 CBCS]
The initial configuration of a DFSM M, on input w is (SM , w) where, SM is the start state of M. The transition
function δ defines the operation of a DFSM M one step at a time. We can use it to define the sequence of
configurations that M will enter. We start by defining the relation yields-in-one-step. written |-M· Yields-in- one-
step relates configuration1 to configuration2 iff M can move from configuration1 to configuration2 in one step.
Let c be any element of Σ and let w be any element of Σ*. Then,
(q1,cw) |- M (q2,w) iff ((q1,c),q2) ϵ δ
We can now define the relation yields, written |-M* to be the reflexive, transitive closure of |-M . So configuration
C1 yields configuration C2 iff M can go from C1 to C2 in zero or more steps. In this case, we will write: C1 |-M* C2
A computation by M is a finite sequence of configurations C0, C1, C2, ... , Cn for some n ≥ 0 such that:
• C0 is an initial configuration,
• Cn is of the form (q, ε), for some state q ϵ KM (i.e., the entire input string has been read}, and C0 |-M C1 |-M C2 |-
M ... |-M Cn.
Let w be an element of Σ*. Then we will say that:
• M accepts w iff (s, w) |-M* (q, ε), for some q C AM· Any configuration (q, ε), for some q C AM , is called an
accepting configuration of M.
• M rejects w iff (s, w) |-M* (q, ε), for some q Ø AM· Any configuration (q, ε), for some q Ø AM , is called a
rejecting configuration of M.
M halts whenever it enters either an accepting or a rejecting configuration. It will do so immediately after
reading the last character of its input.
The language accepted by M, denoted by L(M), is the set of all strings accepted by M.
Ex 1: Let L = {w ϵ {a, b}* : every a is immediately followed by a b}.
L can be accepted by the DFSM M = ( { q0, q1, q2}, {a, b }, δ, q0. {q0}), where:
The tuple notation that we have just used for δ is quite hard to read. We will generally find it useful to draw δ
as a transition diagram instead. When we do that. we will use two conventions:
1. The start state will be indicated with an unlabeled arrow pointing into it.
2. The accepting states will be indicated with double circles.
With those conventions, a DFSM can be completely specified by a transition diagram. So M is:
If we look at the three states in M, the machine that we just built, we see that they are of three different sorts:
1. State q0 is an accepting state. Every string that drives M to state q0 is in L .
2. State q1 is not an accepting state. But every string that drives M to state q1 could turn out to be in L if it is
followed by an appropriate continuation string, in this case, one that starts with a ‘b’.
State q2 is what we will call a dead state or trap state. Once M enters state q2, it will never leave. State q2 is
not an accepting state, so any string that drives M to state q2 has already been determined not to be in L, no
matter what comes next. We will often name our dead states d.
The languages accepted by DFSM are called Regular languages. All the above examples are regular
languages. Following are some more examples of Regular languages.
Ex 1:Let L = {w ϵ {a, b}* : w contains no more than one b}.
L is regular because it can be accepted by the DFSM M. L accepts { ε, a, b, ab, ba, aa, aba, baa,aab,aaaab,. }
L doesnot include { bb,abb,bab,. }
Any string with more than one b will drive M to the dead state d. All other strings will drive M to either q0 or
q1 both of which are accepting states.
In this diagram, we have used the shorthand d to stand for any one of the decimal digits (0 - 9). And we have
omitted the dead state to avoid arrows crossing over each other.
Every string in L begins with Open and ends with Close. In addition, every Request, except possibly the last
must be followed by Reply and no unsolicited Reply's may occur.
L is regular because it can be accepted by the DFSM:
Ex 5: Let L ={w C {a, b}*: w contains an even number of a's and an odd number of b's}.
Ex 7: A Substring that Doesn't Occur Let L =, {w C {a, b }*: w does not contain the substring aab }.
It is straightforward to design an FSM that looks for the substring aab. So we can begin building a machine to
accept L by building the following machine to accept ¬L:
Then we can convert this machine into one that accepts L by making states q0, q1 and q2 accepting and state q3
nonaccepting as shown:
Nondeterministic FSMs
Definition:
A nondeterministic FSM (or NDFSM) M is a quintuple ( K. Σ, ∆. s, A ) where:
• K is a finite set of states,
• Σ is an alphabet,
• s C K is the start state,
• A Š K is the set of final states, and
• ∆ is the transition relation. It is a finite subset of : ( K x (Σ U {ε}) x K.
ln other words, each element of ∆ contains a (state, input symbol or ε) pair, and a new state.
Let w be an element of Σ*. Then we will say that:
• M accepts w iff at least one of its computations accepts.
• M rejects w iff none of its computations accepts.
The language accepted by M, denoted L(M), is the set of all strings accepted by M.
Ex:
If M is in state q0 and the next input character is an a, then there are three moves that M could make:
1. It can take the ε -transition to q1 before it reads the next input character,
2. It can read the next input character and take the transition to q2, or
3. It can read the next input character and take the transition to q3.
The upper machine accepts {w ϵ {a, b}* : w = aba}. The lower one accepts { w ϵ {a, b} * : | w| is even}.
M works by guessing which letter is going to be the missing one. If any of its guesses is right, it will accept. If
all of them are wrong. then all paths will fail and M will reject.
Ex 4:
Let L = {w ϵ {a,b,c}*: Ǝ x,y ϵ{a,b,c}* (w = x abcabb y)}.
In other words, w must contain at least one occurrence of the substring abcabb.
The following DFSM M1 accepts L:
While M1 works, and it works efficiently, designing machines like M1 and getting them right is hard.
But now consider the following NDFSM M2, which also accepts L:
The idea here is that, whenever M2 sees an a, it may guess that it is at the beginning of the pattern abcabb. Or,
on any input character (including a), it may guess that it is not yet at the beginning of the pattern (so it stays in
q0). If it ever reaches q6, it will stay there until it has finished reading the input. Then it will accept.
So one effective way to build a correct and efficient string-searching machine is to build a simple NDFSM,
convert it to an equivalent DFSM, and then minimize the DFSM.
Ex 5: Multiple Keywords
Let L = { w ϵ {a, b} * : Ǝ x, y ϵ {a, b} * (( w = x abbaa y) ᴜ ( w = x baba y))}.
In other words, w contains at least one occurrence of the substring abbaa or the substring baba. The following
NDFSM M accepts L:
Handling ε-Transitions
The function eps: KM →Р (KM) is introduced to handle ε-Transitions in NFSM.
eps(q), where q is some state in M, is defined as the set of states of M that are reachable from q by following
zero or more ε -transitions.
eps(q) = {pϵK:(q,w) |-M * (p,w)}.
The following algorithm computes eps:
eps(q: state) =
1. result = {q }.
2. While there exists some p ϵ result and some r ∉ result and some transition (p, ε, r) ϵ Δ
do: Insert r into result.
3. Return result.
It will add all elements that are reachable from q following only ε -transitions.
4. K ' = active-states.
5. A'= {Q ϵ K': Q ∩ A ≠ Ø}.
Problem: Build a Deterministic FSM for the following NDFSM M using ndfsmtodfsm
3. Compute δ':
Initially active-states = {{q1, q2, q7} } which is s' .
Consider transition for {q1, q2, q7} for each input symbol and then apply eps( )
We get:
(( { q1, q2, q7 }, a), Ø) Since result is null ,we can ignore it.
(({q1, q2, q7}, b),{q1, q2, q3, q5, q7, q8}) New state { q1, q2, q3, q5, q7, q8}
(({q1, q2, q7}, c), Ø) It is null. So ignore it.
Now, updated active-states = { {q1, q2, q7}, {q1, q2, q3, q5, q7, q8} }
Consider new state {q1, q2, q3, q5, q7, q8} and repeat the above step:
We get:
(({q1, q2, q3, q5, q7, q8}, a), {q2, q4, q6, q7} ).
(({q1, q2, q3, q5, q7, q8}, b), {q1, q2, q3, q5, q6, q7, q8} ).
(({q1, q2, q3, q5, q7, q8}, c), { q4} ).
Now active-states = { q1, q2, q7},{q1, q2, q3, q5, q7, q8}, {q2, q4, q6, q7},{q1, q2, q3, q5, q6, q7, q8}, {q4}
}.
active-states={{ q1, q2, q7}, {q1, q2, q3, q5, q7, q8}, {q2, q4, q6, q7},{q1, q2, q3, q5, q6, q7, q8}, {q4},
{q3,q5,q8},{q2,q7}, {q2,q4,q7 } }.
Consider {q4}:
(( {q4}, a), Ø).
(({q4}, b). Ø).
(({q4}, c), {q2, q7}).
active-states did not change.
Consider {q3,q5,q8}:
(({q3,q5,q8}, a), {q2, q4, q6, q7} ).
( ({q3,q5,q8}, b), {q2, q6, q7}).
(({q3,q5,q8}, c), {q4} ).
active-states= { q1, q2, q7}, Ø, {q1, q2, q3, q5, q7, q8}, {q2, q4, q6, q7}, {q1, q2, q3, q5, q6, q7, q8}, {q4},
{q3,q5,q8}, {q2,q7}, {q2,q4,q7 }, {q2, q6, q7} }.
Consider {q2,q7}:
(( {q2, q7}, a), Ø ).
(({q2,q7}, b), {q3,q5,q8}).
(( { q2, q7}, c), Ø ).
active-states did not change.
4. K' = { q1, q2, q7}, {q1, q2, q3, q5, q7, q8}, {q2, q4, q6, q7}, {q1, q2, q3, q5, q6, q7, q8}, {q4},
{q3,q5,q8}, {q2,q7}, {q2,q4,q7 }, {q2, q6, q7} }.
Rename the states in the same order as K' ={ A, B, C, D, E, F,G, H, I }
5. A' = { {q1, q2, q3, q5, q7, q8}, {q1, q2, q3, q5, q6, q7, q8}, {q3,q5,q8}}
Simulators for FSMs
Once we have created an FSM to solve a problem, we may want to simulate its execution.
Simulating Deterministic FSMs
Consider the following deterministic FSM M that accepts the language L = { w ϵ {a, b} * : w contains no more
than one b}.
We could view M as a specification for the following program:
Until accept or reject do:
S: s =get-next-symbol.
If s=end-of-file then accept.
Else if s = a then go to S.
Else if s = b then go to T.
T: s =get-next-symbol.
If s = end-of-file then accept.
HN, SSK & PM, Dept. of ISE, RNSIT 2022-2023 Page 23
Automata Theory & Computability [18CS54 CBCS]
Else if s = a then go to T.
Else if s = b then reject.
End.
The biggest problem with this approach is that we must generate new code for every FSM that we wish to run.
Of course, we could write an FSM compiler that did that for us. But we don't need to. We can, instead, build an
interpreter that executes the FSM directly.
Minimizing FSMs
So, if x and y are distinguishable, then there exists at least one string z such that one but not both of xz and yz
HN, SSK & PM, Dept. of ISE, RNSIT 2022-2023 Page 24
Automata Theory & Computability [18CS54 CBCS]
is in L.
Since ≈L is an equivalence relation, its equivalence classes constitute a partition of the set Σ*. So:
• No equivalence class of ≈L is empty, and
• Every string in Σ* is in exactly one equivalence class of ≈L.
What we will see soon is that the equivalence classes of ≈ L, correspond exactly to the states of the minimum
DFSM that accepts L. So every string in Σ* will drive that DFSM to exactly one state.
Ex 1: Determining ≈L
Let Σ = {a, b }. Let L = {w ϵ Σ*: every a is immediately followed by a b }.
To determine the equivalence classes of ≈L, we begin by creating a first class [1] and arbitrarily assigning ε to
it.
Now consider a. It is distinguishable from ε since εab ϵ L but aab ∉ L. So we create a new equivalence class
[2] and put a in it.
Now consider b. b ≈L ε since every string is in L unless it has an a that is not followed by a b. Neither of these
has an a that could have that problem. So they are both in L as long as their continuation doesn't violate the
rule. If their continuation does violate the rule, they are both out. So b goes into [1 ).
Next we try aa. It is distinguishable from the strings in [1] because the strings in [1] are in L but aa is not. So,
consider ε as a continuation string. Take any string in [1] and concatenate ε. The result is still in L. But aaε is
not in L. We also notice that aa is distinguishable from a, and so cannot be in [2], because a still has a chance
to become in L if it is followed by a string that starts with a b. But aa is out, no matter what comes next. So, we
create a new equivalence class [3] and put aa in it.
We continue in this fashion until we discover the property that holds of each equivalence class.
The equivalence classes of ≈L are:
[1] [ε, b, abb, ... ] [all strings in L]
[2] [a, abbba, ... ] [all strings that end in a and have no prior a that is not followed
by a b]
[3] [aa, abaa,...] [all strings not in L which contain at least one instance of aa]
There are two different patterns, so we must split into two classes.[l, 3, 5] and [6].
Now, Classes= {[2,4], [1,3,5], [6]}
At step 2:
((2, a), [1, 3, 5]) ((4, a), [6]) These two must be split.
((2, b), [6]) ((4, b), [1,3, 5])
((1, a),[2, 4]) ((3, a), [2, 4]) ((5, a), [2, 4])
((1,b),[2, 4]) ((3, b),[2, 4]) ((5, b), [2,4])
No splitting required.
At step 3:
((l,a),[2]) ((3, a),[2]) ((5, a),[2])
((1, b), [4]) ((3, b), [4]) ((5, b), [4])
No splitting required. So, the process halts here.
So minDFSM returns M' =
A canonical form for some set of objects C assigns exactly one representation to each class of "equivalent"
objects in C. Further. each such representation is distinct, so two objects in C share the same representation iff
they arc "equivalent" in the sense for which we define the form.
Suppose that we had a canonical form for FSMs with the property that two FSMs share a canonical form iff
they accept the same language. Further suppose that we had an algorithm that on input M. constructed M's
canonical form. Then some questions about FSMs would become easy to answer. For example, we could test
whether two FSMs are equivalent (i.e, they accept the same language). It would suffice to construct the
canonical form for each of them and test whether the two forms are identical.
The algorithm minDFSM constructs, from any DFSM M, a minimal machine that accepts L(M). We know
that, all minimal machines for L(M) are identical except possibly for state names. So, if we could define a
standard way to name states, we could define a canonical machine to accept L(M) (and thus any regular
language). The following
algorithm does this by using the state-naming convention.
buildFSMcanonicalform(M: FSM) =
1. M' = ndfsmtodfsm(M).
2. M# = minDFSM(M').
3. Create a unique assignment of names to the states of M# as follows:
Call the start state q0
Define an order on the elements of Σ
3.3 Until all states have been named do:
Select the lowest numbered named state that has not yet been selected. Call it q.
Create an ordered list of the transitions out of q by the order imposed on their labels.
Create an ordered list of the as yet unnamed states that those transitions enter by doing the following: If the
HN, SSK & PM, Dept. of ISE, RNSIT 2022-2023 Page 27
Automata Theory & Computability [18CS54 CBCS]
first transition is (q, c1, p1 ), then put p1 first. If the second transition is (q, c2, p2) and p2 is not already on the
list, put it next. If it is already on the list, skip it. Continue until all transitions have been considered. Remove
from the list any states that have already been named.
Name the states on the list that was just created: Assign to the first one the name qk, where k is the smallest
index that hasn't yet been used. Assign the next name to the next state and so forth until all have been named.
4. Return M#.
Given two FSMs M1 and M2, buildFSMcanonicalform(M1) = buildFSMcanonicalform (M2) iff L(M1) = L
(M2). It provides the basis for a simple way to test whether an FSM accepts any strings or whether two FSMs
are equivalent.
Finite StateTransducers
Finite state machines are not used only as language recognizers but it also used to allow for output at each step
of a machine's operation which are called transducers. Many finite state transducers are loops that simply run
forever, processing inputs.
One simple kind of finite state transducer associates an output with each state of a machine M. That output is
generated whenever M enters the associated state. Deterministic finite state transducers of this sort are called
Moore machines ( named after their inventor Edward Moore).
Definition :
A Moore machine M is a seven-tuple (K, Σ , Ο, δ, D, s, A) where:
• K is a finite set of states,
• Σ is an input alphabet,
• Ο is an output alphabet,
• s ϵK is the start state,
• A⊆ K is the set of accepting states ,
• δ is the transition function. It is function from (K X Σ) to (K), and
• D is the display or output function. It is a function from (K) to (Ο*).
A Moore machine M computes a function f(w) iff, when it reads the input string w, its output sequence is f(w).
A different definition for a deterministic finite state transducer permits each machine to output any finite
sequence: of symbols as it makes each transition FSMs that associate outputs with transitions are called Mealy
machines (named after their inventor George Mealy).
Definition:
A Mealy machine M is a six-tuple (K, Σ, Ο, δ, s, A) where:
• K is a finite set of states,
• Σ is an input alphabet,
• Ο is an output alphabet,
• s ϵ K is the start state.
• A⊆K is the set of accepting states, and
It is composed of columns, each of the same width. A column can be either white or black. If two black
columns occur next to each other, it will look to us like a single, wide, black column, but the reader will see the
adjacent black columns of the standard width. The job of the white columns is to delimit the black ones. A
single black column encodes 0. A double black column encodes 1.
We can build a finite state transducer to read such a bar code and output a string of binary digits. We'll
represent a black bar with the symbol B and a white bar with the symbol W. The input to the transducer will be
a sequence or those symbols, corresponding to reading the bar code left to right. We'll assume that every
correct bar code starts with a black column, so white space ahead of the first black column is ignored. We'll
also assume that after every complete bar code there are atleast two white columns. So the reader should, at
that point, reset to be ready to read the next code. If the reader sees three or more black columns in a row, it
must indicate an error and stay in its error state until it is reset by seeing two white columns.
Bidirectional Transducers
A process that reads an input string and constructs a corresponding output string can be described in a variety
of different ways. Why should we choose the finite state transducer model? One reason is that it provides a
declarative, rather than a procedural, way to describe the relationship between inputs and outputs. Such a
declarative model can then be run in two directions. For example:
• To read an English text requires transforming a word like "liberties” into the root word "liberty" and the affix
PLURAL. To generate an English text requires transforming a root word like “liberty” and the semantic
marker "PLURAL” into the surface word "liberties". If we could specify, in a single declarative model, the
relationship between surface words and underlying root words and affixes.
The facts about English spelling rules and morphological analysis can be described with a bidirectional finite
state transducer.
• The Soundex system, described below, groups names that sound alike. To create the Soundex representation
of a name requires a set of rules for mapping the spelling of the name to a unique four character code. To find
other names that sound like the one that generated a particular code requires running those same rules
backwards.
• Many things we call translators need to run in both directions. For example, consider translating between
Roman numerals Q and Arabic ones. A nondeterministic Mealy machine can be thought of as defining a
relation between one set of strings (for example, English surface words) and a second set of strings (for
example, English underlying root words, along with affixes).
Of course, the real power of bidirectional finite state transducers comes from their ability to model more
complex processes.
The Soundex system is described by the following set of rules for mapping from a name to a Soundex code:
1. If two or more adjacent letters (including the first in the name) would map to the same number if rule 3.1
were applied to them, remove all but the first in the sequence.
2. The first character of the Soundex code will be the first letter of the name.
Here's an initial fragment of a finite-state transducer that implements the relationship between names and
Soundex codes. The complete version of this machine can input a name and output a code by interpreting each
transition labelled x/y as saying that the transition can be taken on input x and it will output y. Going the other
direction, it can input a code and output a name if it interprets each transition the other way: On input y, take
the transition and output x. To simplify the diagram, we've used two conventions:
The symbol # stands for any one of the letters A, E, I, O, U, Y, H, or W. And a label of the form x, y, z/a is a
shorthand for three transitions labelled x/a, y/a, and z/a. Also, the states are named to indicate how many code
symbols have been generated/read.
Note: For more problems w.r.t DFSM, NFDSM, Minimization of DFSM can be found in the class work
& practice the same