TOC Material
TOC Material
What is TOC?
In theoretical computer science, the theory of computation is the branch that deals with
whether and how efficiently problems can be solved on a model of computation, using an
algorithm. The field is divided into three major branches: automata theory, computability theory
and computational complexity theory.
In order to perform a rigorous study of computation, computer scientists work with a
mathematical abstraction of computers called a model of computation. There are several
models in use, but the most commonly examined is the Turing machine.
Automata theory
In theoretical computer science, automata theory is the study of abstract machines (or more
appropriately, abstract 'mathematical' machines or systems) and the computational problems that
can be solved using these machines. These abstract machines are called automata.
This automaton consists of
states (represented in the figure by circles),
and transitions (represented by arrows).
As the automaton sees a symbol of input, it makes a transition (or jump) to another state,
according to its transition function (which takes the current state and the recent symbol as its
inputs).
Uses of Automata: compiler design and parsing.
De Morgan’s Law:
(AUB)’ =A’ ∩ B’
(A∩B)’ = A’ U B’
Double compliment
(A’)’ =A
A ∩ A’ = Φ
Logic relations:
a b = > 7a U b
7(a∩b)=7a U 7b
Relations:
Let a and b be two sets a relation R contains aXb.
Relations used in TOC:
Reflexive:a=a
Symmetric: aRb = > bRa
Transition: aRb, bRc = > aRc
If a given relation is reflexive, symmentric and transitive then the relation is called equivalence
relation.
Deductive proof: Consists of sequence of statements whose truth lead us from some
initial statement called the hypothesis or the give statement to a conclusion statement.
Proof by contrapositive:
Proof by Contradiction:
Languages :
The languages we consider for our discussion is an abstraction of natural languages. That
is, our focus here is on formal languages that need precise and formal definitions.
Programming languages belong to this category.
Symbols :
Symbols are indivisible objects or entity that cannot be defined. That is, symbols are the
atoms of the world of languages. A symbol is any single object such as, a, 0, 1, #, begin,
or do.
Alphabets :
Example : 0110, 11, 001 are three strings over the binary alphabet { 0, 1 } .
It is not the case that a string over some alphabet should contain all the symbols from the
alphabet. For example, the string cc over the alphabet { a, b, c } does not contain the
symbols a and b. Hence, it is true that a string over an alphabet is also a string over any
superset of that alphabet.
Length of a string :
The number of symbols in a string w is called its length, denoted by |w|.
Convention : We will use small case letters towards the beginning of the English
alphabet to denote symbols of an alphabet and small case letters towards the end to
denote strings over an alphabet. That is, (symbols) and
are strings.
Example : Consider the string 011 over the binary alphabet. All the prefixes, suffixes and
substrings of this string are listed below.
Note that x is a prefix (suffix or substring) to x, for any string x and ε is a prefix (suffix or
substring) to any string.
Powers of Strings : For any string x and integer n>=0, we use xx to denote the string
formed by sequentially concatenating n copies of x. We can also give an inductive
definition of xx as follows: xx = e,
if n= 0 ; otherwise xx= xx-1.
Reversal :
For any string the reversal of the string is .
Languages
Defn: A language is a set of strings over an alphabet.
A more restricted definition requires some forms of restrictions on the
strings, i.e., strings that satisfy certain properties
Defn. The syntax of a language restricts the set of strings that satisfy
certain properties.
Convention : Capital letters A, B, C, L, etc. with or without subscripts are normally used
to denote languages.
Set operations on languages : Since languages are set of strings we can apply set
operations to languages. Here are some simple examples (though there is nothing new in
it).
(Generates) (Recognizes)
Grammar Language Automata
An automata is an abstract computing device (or machine). There are different varities of
such abstract machines (also called models of computation) which can be defined
mathematically.
of storage at any point defines the configuration of the automaton at that point. The
transition from one configuration to the next ( as defined by the transition function) is
called a move. Finite state machine or Finite Automation is the simplest type of abstract
machine we consider. Any system that is at any point of time in one of a finite number of
interval state and moves among these states in a defined manner in response to some
input, can be modeled by a finite automaton. It doesnot have any temporary storage and
hence a restricted model of computation.
Finite Automata
Let us first give some intuitive idea about a state of a system and state transitions before
describing finite automata.
Transitions are changes of states that can occur spontaneously or in response to inputs to
the states. Though transitions usually take time, we assume that state transitions are
instantaneous (which is an abstraction).
Some examples of state transition systems are: digital systems, vending machines, etc.
A system containing only a finite number of states and transitions among them is called a
finite-state transition system.
Informally, a DFA (Deterministic Finite State Automaton) is a simple machine that reads
an input string -- one symbol at a time -- and then, after the input has been completely
read, decides whether to accept or reject the input. As the symbols are read from the tape,
the automaton can change its state, to reflect how it reacts to what it has seen so far. A
machine for which a deterministic code can be formulated, and if there is only one unique
way to formulate the code, then the machine is called deterministic finite automata.
1. A tape to hold the input string. The tape is divided into a finite number of cells.
Each cell holds a symbol from ∑.
2. A tape head for reading symbols from the tape
3. A control , which itself consists of 3 things:
o finite number of states that the machine is allowed to be in (zero or more
states are designated as accept or final states),
o a current state, initially set to a start state, a state transition function for
changing the current state.
An automaton processes a string on the tape by repeating the following actions until the
tape head has traversed the entire string:
1. The tape head reads the current tape cell and sends the symbol s found there to the
control. Then the tape head moves to the next cell.
2. he control takes s and the current state and consults the state transition function to
get the next state, which becomes the new current state.
Once the entire string has been processed, the state in which the automation enters is
examined. If it is an accept state , the input string is accepted ; otherwise, the string is
rejected . Summarizing all the above we can formulate the following formal definition:
It is a formal description of a DFA. But it is hard to comprehend. For ex. The language of
the DFA is any string over { 0, 1} having at least one 1
We can describe the same DFA by transition table or state transition diagram as
following:
Explanation : We cannot reach find state or in the i/p string. There can be any
no. of 0's at the beginning. ( The self-loop at on label 0 indicates it ). Similarly there
can be any no. of 0's & 1's in any order at the end of the string.
Transition table :
It is basically a tabular representation of the transition function that takes two arguments
(a state and a symbol) and returns a value (the “next state”).
A state transition diagram or simply a transition diagram is a directed graph which can be
constructed as follows:
6. Here is an informal description how a DFA operates. An input to a DFA can be any
string . Put a pointer to the start state q. Read the input string w from left to
right, one symbol at a time, moving the pointer according to the transition function, . If
the next symbol of w is a and the pointer is on state p, move the pointer to .
When the end of the input string w is encountered, the pointer is on some state, r. The
string is said to be accepted by the DFA if and rejected if . Note that there
is no formal mechanism for moving the pointer.
7. A language is said to be regular if L = L(M) for some DFA M.
UNIT-I AUTOMATA
PART-A(2-MARKS)
30. Write Regular Expression for the language that have the set of all strings of 0’s
th
30 and 1’s whose 10 symbol from the right end is 1.
31 Write Regular Expression for the language that has the set of all strings of 0’s
and 1’s with at most one pair of consecutive 1’s.
32 Write Regular Expression for the language that have the set of all strings of 0’s
33 and 1’s such that every pair of adjacent 0’s appears before any pair of adjacent
34 1’s.
35 Write Regular Expression for the language that have the set of all strings of 0’s
and 1’s whose no of 0’s is divisible by 5.
36 Write Regular Expression for the language that has the set of all strings of 0’s
and 1’s not containing 101 as a substring.
37 Write Regular Expression for the language that have theset of all strings of 0’s
and 1’s such that no prefix has two more 0’s than 1’s, not two more 1’s than
0’s.
38. Write Regular Expression for the language that have the set of all
strings of 0’s and 1’s whose no of 0’s is divisible by 5 and no of 1’s is
even.
39. Give English descriptions of the languages of the regular expression (1+ ε)(00*1)*0*.
40. Give English descriptions of the languages of the regular expression
(0*1*)*000(0+1)*.
41. Give English descriptions of the languages of the regular expression (0+10)*1*.
42. Convert the following RE to ε-NFA.01*.
Part B
δ 0 1
p {q,s} {q}
q {r} {q,r}
r {s} {p}
s - {p}
n n
2. a)Show that the set L={a b /n>=1} is not a regular. (6) b)Construct a DFA equivalent to the
0 1
p {p,q} P
q r R
r s -
s s S
n n
3. a)Check whether the language L=(0 1 /n>=1) is regular or not? Justify your answer.
b) Let L be a set accepted by a NFA then show that there exists aDFA that accepts L.
4. Define NFA with ε-transition. Prove that if L is accepted by an NFA with ε-transition
then L is also accepted by a NFA without ε-transition.
+
5. a) Construct a NDFA accepting all string in {a,b} with either two consecutive
a’s or two consecutive b’s.
b) Give the DFA accepting the following language:set of all strings beginning with a 1 that
when interpretedas a binary integer is a multiple of 5.
(i) Set of Strings over alphabet {0,1,…….9} such that the final digit has
appeared before. (8)
(ii)Set of strings of 0’s and 1’s such that there are two 0’s separated by a number of
positions that is a multiple of 4.
7.a)Let L be a set accepted by an NFA.Then prove that there exists a deterministic finite
automaton that accepts L.Is the converse true? Justify your answer. (10)
8.a) Prove that a language L is accepted by some ε–NFA if and only if L is accepted by some
DFA. (8)
b) Consider the following ε–NFA.Compute the ε–closure of each state and find it’s equivalent
DFA. (8)
ε A b C
p {q} {p} Ф Ф
q {r} ф {q} Ф
*r Ф ф ф {r}
9.a) Prove that a language L is accepted by some DFA if L is accepted by some NFA.
0 1
p {p,q} {p}
q {r} {r}
r {s} ф
*s {s} {s}
10.a) Explain the construction of NFA with εtransition from any given regular
expression.
b) Let A=(Q,∑, δ, q0 ,{qf ) be a DFA and suppose that for all a in ∑wehave δ(q0, a)= δ(qf ,a).
k
Show that if x is a non empty string in L(A),then for all k>0,x is also in L(A).
PART-B
i i
b) Show that the set E={0 1 |i>=1} is not Regular. (6)
b)Obtain the regular expression that denotes the language accepted by the following DFA.
15.a)Obtain the regular expression denoting the language accepted by the following DFA (8)
b)Obtain the regular expression denoting the language accepted by the following DFA by
k
using the formula Rij
16. a)Show that every set accepted by a DFA is denoted by a regular Expression
2
17. a)Define a Regular set using pumping lemma Show that the language L={0i / i is an
integer,i>=1} is not regular
b)Verify whether the finite automata M1 and M2 given below are equivalent over {a,b}.
22..a)Find the regular expression corresponding to the finite automaton given below.
2
b)Find the regular expression for the set of all strings denoted by R 23 from the
deterministic finite automata given below.
k 2
23.a) Find whether the languages {ww,w is in (1+0)*} and {1 | k=n , n>=1} are regular
or not.