Automata Theory E-Content Document
Automata Theory E-Content Document
Prepared by
Sasmita Kumari Nayak
Assistant Professor, CSE Department
Centurion institute of Technology
Centurion University of Technology and management
Module 1
Chapter 1
1.1 Alphabet, languages and grammars
Languages:
A general definition of language must cover a variety of distinct categories: natural languages,
programming languages, mathematical languages, etc. The notion of natural languages like
English, Hindi, etc. is familiar to us. Informally, language can be defined as a system suitable for
expression of certain ideas, facts, or concepts, which includes a set of symbols and rules to
manipulate these. 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. We start with some basic concepts
and definitions required in this regard.
1.2 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. Usually,
characters from a typical keyboard are only used as symbols.
1.3 Alphabets:
An alphabet is a finite, nonempty set of symbols. The alphabet of a language is normally denoted
by . When more than one alphabets are considered for discussion, then subscripts may be used
(e.g.
etc) or sometimes other symbol like G may also be introduced.
Example:
and b. Hence, it is true that a string over an alphabet is also a string over any superset of that
alphabet.
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.
1.6 Concatenation:
Let
and
be
two
strings.
The
concatenation
, we use
as follows:
= e, if n = 0 ; otherwise
Example : If x = 011, then
= 011011011,
= 011 and
2.2
The set of all strings over an alphabet
is denoted by
. That is,
The set
contains all the strings that can be generated by iteratively concatenating symbols
from
any number of times.
Example: If
= {a, b}, then
= { e, a, b, aa, ab, ba, bb, aaa, aab, aba, abb, baa}.
Please note that if
, then
that is
. It may look odd that one can proceed from
the empty set to a non-empty set by iterated concatenation. But there is a reason for this and we
accept this convention.
2.3
The set of all nonempty strings over an alphabet
Note that
is denoted by
. That is,
2.4 Languages:
A language over an alphabet is a set of strings over that alphabet. Therefore, a language L is any
subset of . That is, any
Example :
1. F is the empty language.
2.
is a language for any
is a language.
2.5 Cont
3. {e} is a language for any . Note that,
. Because the language F does not
contain any string but {e} contains one string of length zero.
4. The set of all strings over { 0, 1 } containing equal number of 0's and 1's.
5. The set of all strings over {a, b, c} that starts with a.
Convention : Capital letters A, B, C, L, etc. with or without subscripts are normally used to
denote languages.
iff
or
Intersection : A string
iff
and
{ 1, 01, 110 } = { 01 }
2.7 Complement :
Usually,
is the universe that a complement is taken with respect to. Thus for a language L, the
complement is = {
}.
, is defined as:
Example :
1. Let L = {0, 11, 01, 011}. Then
2. Let L = {
| n is an integer }. Then
= {
| n is an integer }.
concatenation
of
languages
and
is
defined
as
= { xy |
and
}.
Example : { a, ab }{ b, ba } = { ab, aba, abb, abba }.
Note that ,
1.
2.
3.
in general.
3.3 Example :
Let L = { a, ab }. Then according to the definition, we have
and so on.
=
, i.e., all strings derivable by one or more concatenations of strings in L. That is
= (Union n in N and n >0)
=
3.5 Example :
Let L = { a, ab }. Then we have,
=
= {e}
{a, ab}
{aa, aab, aba, abab}
=
= {a, ab}
{aa, aab, aba, abab}
Note : e is in
, for every language L, including .
The previously introduced definition of
is an instance of Kleene star.
3.8 Cont
The most important feature of the automaton is its control unit, which can be in any one
of a finite number of interval states at any point. It can change state in some defined
manner determined by a transition function.
Chapter 2
Finite Automata
4.2 Finite Automata
An automaton (Plural: Automata) is defined as a system where information is transmitted and
used for performing some functions without direct participation of man.
4.4 Cont
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.
Finite-state transition systems can be modeled abstractly by a mathematical model called finite
automation.
in Q such
2.
for all
3.
(which is
i.e.
function on symbols)
to
a function on strings,
That is,
is the state the automation reaches when it starts from the state q and finish
processing the string w.
5.2 Cont
Formally, we can give an inductive definition as follows:
The language of the DFA M is the set of strings that can take the start state to one of the
accepting states i.e.
L(M) = {
={
| M accepts w }
|
5.3 Example:
5.4 Cont
It is a formal description of a DFA. But it is hard to comprehend. For example, 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:
5.5 Cont
State transition diagram :
Transition Table :
0
5.7 Cont
5.8 Cont
0
6.2 Cont
3. There is an arrow with no source into the start state.
4. Accepting states are indicated by double circle.
6.3 Cont
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
6.4 Cont
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.
A language
is said to be regular if L = L(M) for some DFA M.
6.5 Example:
Design a DFA which accepts the language L1 = {x {a, b}* | x ends with aa}
6.7 Property:
for all strings w and input symbols a
(q, xy) = ((q, x), y)
(q, yx) = ((q, y), x)
6.8 Example:
Let us consider a transition table as given below. Now let us consider the input string whether it
is accepted by a FA or not.
0
1
6.9 Cont
By using the above property (q0, 1010) = (q1, 010)= (q1, 10)= (q1, 0)= q1
Here q1is the final state so it concludes that the given string is accepted by the finite automata by
final state.
- Transitions.
Multiple Next State:
In contrast to a DFA, the next state is not necessarily uniquely determined by the current
state and input symbol in case of an NFA. (Recall that, in a DFA there is exactly one start
state and exactly one transition out of every state for each symbol in ).
This means that - in a state q and with input symbol a - there could be one, more than one
or zero next state to go, i.e. the value of
=
is a subset of Q. Thus
7.2 - Transitions:
In an -transition, the tape head doesn't do anything- it does not read and it does not move.
However, the state of the automata can be changed - that is can go to zero, one or more
states. This is written formally as
could by any one of
7.4 Example:
Obtain an NFA for a language consisting of all strings over {0, 1} containing a 1 in the third
position from the end.
Solution:
q1, q2, q3 are initial states and q4 is the final state.
Please note that this is an NFA as d(q2 ,0) = q3 and d(q2 ,1) = q3 .
7.5 Example:
Sketch the NFA state diagram for M = ({q0, q1 , q2 , q3},{0,1},d, q0 ,{q3}) with the state table as
given below.
7.6 Solution:
The NFA states are q0, q1, q2 and q3.
7.8 Cont
An elements of Q will be denoted by {q1, q2, q3... qn}, where q1, q2, q3... qn are in Q. Notice that
[q1, q2, q3... qn] is a single state of the DFA corresponding to a set of states of the NFA.
Note that q0= [ q0]
We can defined
([q1, q2, q3, ......, qn],a)=[ P1, P2, P3, ..., Pj] if and only if ([q1, q2, q3, ......, qn],a)=[ P1, P2, P3, ...,
Pj]
8.1 Cont
that is applied to an element [q1, q2, q3, ......, qn] of Q is computed by applying to reach
state of Q represented by [q1, q2, q3, ......, qn].
On applying to each of [q1, q2, q3... qn] and taking the unions, we get some new set of states, P1,
P2, P3... Pj. This new set of states has a representive, [P1, P2, P3... Pj] in Q, and the element is the
value o ([q1, q2, q3... qn],a)
The length of input string x, then (q0, .x)= { q1, q2, q3, ......, qn } if and only if (q0, .x)= { q1,
q2, q3, ......, qn }
8.2 Cont
The result is trivial for X=0, since q0= [q0] and X must be (Null).
So it is prove that for every NFA there is exist a DFA.
Procedure: For NFA their exist a DFA which simulates the behavior of NFA, i.e. if L is a set
accepted by a NFA then their exist DFA which also accepting L.
8.3 Cont
Let M be a NFA having M= (Q, , , q0, F)
Then the corresponding DFA M is
M= (Q, , , q0, F)
Where Q=2Q
i.e. if Q = { q0, q1}
Then Q= {, [q0], [q1] [q0, q1]}
= (input set)
q0=[ q0] (initial state)
F=set of state having any qi F for i=0,1,2,3....... n
= It is defined only for those states data reachable from initial states.
8.4 Example:
For the following NFA find equivalent DFA
8.5 Solution:
The state table can be represented by the state diagram as given below
First we make the starting state of NFA as the starting state of DFA. Apply 0 and 1 as input on
state q0. Now keep the outputs in 2nd and 3rd columns. Next take the new generated states which
we placed in 2nd and 3rd columns keep them in first column and again apply 0s and 1s as input.
Repeat the process until no new state is left.
8.6 Cont
Then draw the state diagram by using the above transition table of DFA.
8.7 Example:
Determine a deterministic Finite State Automaton from the given NFA.
M ({q0 , q1},{a, b}, , q0 ,{q1}) with the state table diagram for given below.
Solution:
8.8 Cont
It is to be noted that
Here any subset containing q1 is the final state in DFA. This is shown as below.
9.4 Cont
We can define separate function 0 , = 0 = {0 , 1 , 2 } rules for of
required of NFA.
(q, a) = (( , , ))
Where , = ()
whereas
and
in
case
be a DFA .
of
an NFA it
is
defined
from
9.6 Cont
We construct an equivalent NFA
as follows.
i. e
If
and
All other elements of N are as in D.
If
then
there
is
sequence
of
states
such
that
9.7 Cont
Then it is clear from the above construction of N that there is a sequence of states
(in N)
such
that
and
and
hence
Similarly we can show the converse.
Hence ,
9.8 Cont
Given any NFA we need to construct as equivalent DFA i.e. the DFA need to simulate the
behavior of the NFA. For this, the DFA have to keep track of all the states where the NFA could
be in at every step during processing a given input string.
There are
possible subsets of states for any NFA with n states. Every subset corresponds to
one of the possibilities that the equivalent DFA must keep track of. Thus, the
equivalent DFA will have
states.
10.1 Cont
The formal constructions of an equivalent DFA for any NFA is given below. We first consider
an NFA without transitions and then we incorporate the affects of transitions later.
Formal construction of an equivalent DFA for a given NFA without
transitions.
10.2 Cont
Given an
without
as follows
i.e.
10.3 Cont
for all
and
where
That is,
To show that this construction works we need to show that L(D)=L(N) i.e.
Or,
We will prove the following which is a stranger statement thus required.
10.4 Proof :
We will show by inductions on
Basis: If
=0, then w =
So,
by definition.
10.5 Cont
Now,
, then
with
of length less
10.6 Cont
Now, given any NFA with -transition, we can first construct an equivalent NFA without transition and then use the above construction process to construct an equivalent DFA , thus,
proving the equivalence of NFA s and DFAs.
10.7 Example:
Consider the NFA given below.
Transition table
0
10.8 Cont
Since there are 3 states in the NFA
There will be
states (representing all possible subset of states) in the equivalent DFA . The
transition table of the DFA constructed by using the subset constructions process is produced
here.
The start state of the DFA is
- closures
11.1 Cont
Let us compute one entry,
(since
in the NFA).
11.2 Cont
Corresponding transition fig. for the DFA is shown in below:
0
11.3 Cont
Note that states
are not accessible and hence can be
removed. This gives us the following simplified DFA with only 3 states.
11.4 Cont
It is interesting to note that we can avoid encountering all those inaccessible or unnecessary
states in the equivalent DFA by performing the following two steps inductively.
1. If
is the start state of the NFA, then make - closure (
equivalent DFA . This is definitely the only accessible state.
11.5 Cont
Following these steps in the above example, we get the transition table given below
0
11.7 Procedure:
Minimum DFA M1 is constructed from
final as follows:
Select one state in each set of the partition
final as the representative for the set. These
representatives are states of minimum DFA M1.
Let p and q be representatives i.e. states of minimum DFA M1. Let us also denote by p
and q the sets of states of the original DFA M represented by p and q, respectively. Let s
be a state in p and t a state in q. If a transition from s to t on symbol a exists in M, then
the minimum DFA M1 has a transition from p to q on symbol a.
11.8 Cont
The start state of M1 is the representative which contains the start state of M.
The accepting states of M1 are representatives that are in A.
Note that the sets of
final are either a subset of A or disjoint from A.
Remove from M1 the dead states and the states not reachable from the start state, if there are any.
Any transitions to a dead state become undefined. A state is a dead state if it is not an accepting
state and has no out-going transitions except to itself.
12.1 Example:
Let us
Initially
number
of
states
of
the
following
DFA.
12.2 Solution:
New partition is applied to . Since on b state 2 goes to state 1, state 3 goes to state 4 and 1 and
4 are in different sets in
, states 2 and 3 are going to be separated from each other in
new .
Also since on a sate 4 goes to sate 4, state 3 goes to state 5 and 4 and 5 are in different sets in
, states 3 and 4 are going to be separated from each other in
new.
12.3 Cont
Further, since on b 2 goes to 1, 4 goes to 4 and 1 and 4 are in different sets in
, 2 and 4 are
separated from each other in
new. On the other hand 1 and 5 make the same transitions. So
they are not going to be split.
Thus the new partition is { { 1 , 5 } , { 2 } , { 3 } , { 4 ] }. This becomes the
in the second
iteration.
12.4 Cont
When new partition is applied to this new
unchanged.
Thus
final
remains
= { { 1 , 5 } , { 2 } , { 3 } , { 4 ] }.
Select 1 as the representative for {1, 5}. Since the rest are singletons, they have the obvious
representatives.
Note here that state 4 is a dead state because the only transition out of it is to itself. Thus the set
of states for the minimized DFA is {1, 2, 3}. For the transitions, since 1 goes to 3 on a, and to 2
on b in the original DFA, in the minimized DFA transitions are added from 1 to 3 on a, and 1 to
2 on b. Also since 2 goes to 1 on b, and 3 goes to 1 on a in the original DFA, in the minimized
DFA transitions are added from 2 to 1 on b, and from 3 to 1 on a. Since the rest of the states are
singletons, all transitions between them are inherited for the minimized DFA. Thus the
minimized DFA is as given in the following figure:
12.6 Cont
Let there are two Finite Automata M and M' where number of input symbols are the same. To
test the equivalence of two finite automata over by using comparison method.
12.8 Cont
The row-wise construction is repeated. There are two cases:
Case 1: If we reach a pair (q, q') such that q is a final state of M, and q' is a non-final state of M'
or vice versa, we terminate the construction and conclude that M and M' are not equivalent.
Case 2: The construction is terminated when no new element appears in the second and
subsequent columns which are not in the first column. In this case we conclude that M and M'
are equivalent.
13.1Example:
Consider the following two DFAs M and M over {c, d} given in figure, find out whether M
and M are equivalent.
13.2 Solution:
The initial states in M and M are q1 and q4 respectively. Hence first element of the first column
in the comparison table must be {q1, q4} since both q1, q4 are c-reachable from the respective
initial states.
As we do not get a pair (q, q1), where q is a final state and q1 is non final state or vice-versa at
every row, therefore M and M are equivalent.
Comparison table
13.4 Cont
The output function can be a function of a state or a function of both state and input symbol. If
the output function depends on a state and input symbol, then it is called a Mealy automaton. If
the output function depends only on a state, then it called is a Moore automaton.
13.8 Cont
The transition table of moore machine as shown in below:
Mealy machine
14.1 Example:
Design Mealy machine for the following table and also find the output for the string abbabaaa.
14.2 Solution:
Moore machine
Mealy machine
14.6 Solution:
In Moore machine every input symbol (a) we form a pair consisting of the next state and the
corresponding output and reconstruct the table for mealy machine. For example the states q 0 and
q1 in the next state column should be associated with output 0 and 1.
The transition table for Mealy machine will be:
Mealy machine
14.7 Cont
14.8 Example:
Consider a Mealy machine described by the transition table. Construct a Moore machine which
is equivalent to the Mealy machine.
15.1 Solution:
we look into the next state column for any state, say q i and determine the number of different
outputs associated with qi in that column.
We break qi into several different states, the number of such states being equal to the number of
different outputs associated with qi, for example q2 is associated with two outputs 0 and 1 and
state q3 is associated only one output 1. So we will break state q 2 in two parts first one for output
0 and second one for output 1, but we cannot be break down because q1 have only one output.
New Table:
15.2 Cont
Note: State q20 means state q2 with output 0 and state q21 means state q2 with output 1. The
pair of states and outputs in the next column can be arranged as in table.
We observe that the initial state q1, is associated with output 1. This means that with input
(null). We get an output 1, if the machine starts at state q1. Thus the Moore machine accepts a
zero length sequence (null sequence) which is not accepted by the Mealy machine. To overcome
this situation, either we must neglect the response of Moore machine to input , or we must add a
new starting q0, whose state transition are same as state q1 but output will be zero (0).
Note: If we have m- outputs, n-state, Mealy machine the corresponding m-output Moore
machine has no more than mn+1 states.
15.3 Cont
15.4 Cont
15.5 Example:
Consider a Mealy machine. Construct a Moore machine equivalent to the Mealy machine.
15.6 Solution:
Chapter 3
16.1 Regular Expressions (RE)
Regular Expressions
A regular expression is a formula for representing a (complex) language in terms of
elementary" languages combined using the three operations union, concatenation and Kleene
closure.
16.4 Notation:
If r is a RE over some alphabet then L(r) is the language associate with r . We can define the
language L(r) associated with (or described by) a REs as follows.
1.
is the RE describing the empty language i.e. L( ) =
.
2. is a RE describing the language { } i.e. L( ) = { } .
3.
, a is a RE denoting the language {a} i.e . L(a) = {a} .
16.5 Cont
4. If
i)
ii)
iii)
and
) and L(
) respectively, then
) = L(
)=L(
) L(
) + L(
)
17.1 Cont
ii) It is also important to note that concatenation & union (+) operators are associative and
union operation is commutative.
Using these precedence rule, we find that the RE ab+c represents the language L(ab)
L(c) i.e.
it should be grouped as ((ab)+c).
We can, of course change the order of precedence by using parentheses. For example, the
language represented by the RE a(b+c) is L(a)L(b+c).
Example: The RE ab*+b is grouped as ((a(b*))+b) which describes the language L(a)(L(b))*
L(b)
Example: The RE (ab)*+b represents the language (L(a)L(b))* L(b).
17.2 Example:
It is easy to see that the RE (0+1)*(0+11) represents the language of all strings over {0,1} which
are either ended with 0 or 11.
Example: The regular expression r =(00)*(11)*1 denotes the set of all strings with an even
number of 0's followed by an odd number of 1's i.e.
Note: The notation
is used to represent the RE rr*. Similarly,
RE rr,
denotes r, and so on.
An arbitrary string over
= {0,1} is denoted as (0+1)*.
Example: Give a RE r over {0,1} s.t. L(r)={
represents the
Solution: Every string in L(r) must contain 00 somewhere, but what comes before and what goes
before is completely arbitrary. Considering these observations we can write the REs as
(0+1)*11(0+1)*.
Example : Considering the above example it becomes clear that the RE
(0+1)*11(0+1)*+(0+1)*00(0+1)* represents the set of string over {0,1} that contains the
substring 11 or 00.
17.6 Proof:
Now point out the statements in Arden's Theorem in General form.
(i) P and Q are two Regular Expressions.
(ii) P does not contain symbol.
(iii) R = Q + RP has a solution, i.e. R = QP*
(iv) This solution is the one and only one solution of the equation.
17.7 Cont
If R = QP* is a solution of the equation R = Q + RP then by putting the value of R in the given
equation we shall get the value
Q + (QP*) P
(R = Q + RP)
*
Q(+ P P )
((+ R* R = R* by I9)
*
QP
Hence equation (1) is satisfied when R = QP* this means R = QP* is a solution of the equation
(1). To prove uniqueness, consider equation (1). Here, replacing R by Q + RP on the R.H.S., we
get the equation.
17.8 Cont
18.1 Cont
We now show that any solution of equation (1) is equivalent to QP * suppose R satisfies equation
(1) than it satisfies equation (2). Let w be a string of length I in the set R, than w belongs to
the set
, as P does not contain , RPi+1 has no string of
length less than I + 1 and so w is not in the set RP i+1 this means w belongs to the set
and hence to QP*.
18.2 Example:
Solution:
18.4 RE to FA:
Lemma: If L(r) is a language described by the RE r, then it is regular i.e. there is a FA such
that L(M) L(r).
18.5 Proof:
To prove the lemma, we apply structured index on the expression r. First, we show how to
construct FA for the basis elements: ,
and for any
. Then we show how to combine
these Finite Automata into Complex Automata that accept the Union, Concatenation, Kleen
Closure of the languages accepted by the original smaller automata.
Use of NFAs is helpful in the case i.e. we construct NFAs for every REs which are represented
by transition diagram only.
18.6 Basis:
If R is an elementary regular expression, NFA NR is constructed as follows.
18.7 Induction:
If P and Q are regular expressions with corresponding finite automata MP and MQ, then we can
construct a finite automaton denoting P+Q in the following manner:
18.8 Cont
The transitions at the end are needed to maintain a unique accepting state. If P and Q are
regular expressions with corresponding finite automata MP and MQ, then we can construct a
finite automaton denoting PQ in the following manner:
19.1 Cont
Finally, if P is a regular expression with corresponding finite automaton MP, then we can
construct a finite automaton denoting P* in the following manner:
Again, the extra transitions are here to maintain a unique accepting state. It is clear that each
finite automaton described above accepts exactly the set of strings described by the
corresponding regular expression (assuming inductively that the submachines used in the
construction accept exactly the set of strings described by their corresponding regular
expressions)
.
19.2Cont
Since, for each constructor of regular expressions, we have a corresponding constructor of finite
automata, the induction step is proved and our proof is complete.
We have proved that for every regular expression, there exists an equivalent nondeterministic
finite automaton with transitions.
19.3 Example:
Construct transition graph for regular expression R=(0(0|1)*)+
Solution: 0.(0|1)*
19.4 Cont
(0.(0|1)*)+
19.6 Example:
Construct a FA equivalent to the regular expression,
19.7 Solution:
19.8 Cont
20.1 Cont
Note: Null move () in between q0 and q5 consider as the same state. Therefore q0 = q5.
20.6 FA to RE:
Lemma: If a language is regular, then there is a RE to describe it. i.e. if L = L(M) for some
DFA M, then there is a RE r such that L = L(r).
Proof: We need to construct a RE r such that
. Since M is a DFA, it has
a finite no of states. Let the set of states of M is Q = {1, 2, 3,..., n} for some integer n. [ Note : if
the n states of M were denoted by some other symbols, we can always rename those to indicate
as 1, 2, 3,..., n ]. The required RE is constructed inductively.
20.7 Cont
Notations:
is a RE denoting the language which is the set of all strings w such that w is the label of a
path from state i to state j
in M, and that path has no intermediate state whose
number is greater then k. ( i & j (begining and end pts) are not considered to be "intermediate"
so i and /or j can be greater than k )
We now construct
20.8 Cont
Basis: k = 0,
i.e. the paths must not have any intermediate state (since all states are
numbered 1 or above). There are only two possible paths meeting the above condition:
1. A direct transition from state i to state j.
o
symbols
o
21.1 Cont
2. All paths consisting of only one node i.e. when i = j. This gives the path of length 0 (i.e.
the RE
denoting the string
) and all self loops. By simply adding to various cases
above we get the corresponding REs i.e.
o
symbols
o
21.2 Cont
Induction:
Assume that there exists a path from state i to state j such that there is no intermediate state
whose number is greater than k. The corresponding Re for the label of the path is
21.3 Cont
There are only two possible cases:
1. The path dose not go through the state k at all i.e. number of all the intermediate states are
less than k. So, the label of the path from state i to state j is the language described by the
RE
.
2. The path goes through the state k at least once. The path may go from i to j and k may
appear more than once. We can break the into pieces as shown in the figure.
21.4 Cont
21.5 Cont
The first part from the state i to the state k which is the first recurrence. In this path, all
intermediate states are less than k and it starts at i and ends at k. So the RE
denotes
the language of the label of path.
The last part from the last occurrence of the state k in the path to state j. In this path also,
no intermediate state is numbered greater than k. Hence the RE
language of the label of the path.
denoting the
21.6 Cont
In the middle, for the first occurrence of k to the last occurrence of k , represents a loop
which may be taken zero times, once or any number of times. And all states between two
consecutive k's are numbered less than k.
21.7 Cont
Since either case 1 or case 2 may happen the labels of all paths from state i to j is denoted by the
following RE
.
We can construct
for all i, j
0 upto k = n since
available).
21.8 Cont
Assume that state 1 is the start state and
are the m final states where ji
{1, 2, ...
, n },
and
. According to the convention used, the language of the automata can
be denoted by the RE
Since
is the set of all strings that starts at start state 1 and finishes at final state
following
the transition of the FA with any value of the intermediate state (1, 2, ... , n) and hence accepted
by the automata.
22.2 Cont
ij denotes the regular expression representing the set of labels of edges from Vi to Vj,
when there is no such edge, ij = . Consequently, we can get the following set of
equations V1 Vn.
If there is more than one final states then we take union of all final states equations.
22.3 Example:
Consider the transition system, prove that the strings recognized are
22.4 Solution:
The three equations for q1, q2, and q3 can be written as
22.5 Cont
Put q2 from equation (4) to equation (1)
22.6 Cont
Since q3 is a final state, the set of strings recognised by the graph is given by
23.1 Theorem:
Let L be a regular language. Then the following property holds for L.
There exists a number
(called, the pumping length), where, if w is any string in L of length
at least k i.e.
, then w may be divided into three sub strings w = xyz, satisfying the
following conditions:
1.
i.e.
2.
3.
23.2 Proof:
Since L is regular, there exists a DFA
the number of states in M is n.
Say, w = a1a2am, mn
(q0, a1a2ai) = qi for i=1, 2, , m
; i.e. Q is the sequence of states in the path with path value w = a 1a2am.
As there are only n distinct states, at least two states in Q must coincide. Among the various pairs
of repeated states, we take the first pair. Let us take them as q j and qk (qj= qk). Then j and k
satisfy the condition 0j<kn.
23.3 Cont
The string w can be decomposed into 3 substrings a1a2aj, aj+1ak and ak+1am. Let x, y, z
denote these strings a1a2aj, aj+1ak and ak+1am respectively. As k n, and w=xyz.
The path with the path value w in the transition diagram of M as shown in figure.
The automaton M starts from the initial state q0. On applying the string x, it reaches qj(= qk). On
applying the string y, it comes back to qj(= qk). So after application of yi for each i0, the
automaton is in the same state qj. on applying z, it reaches qm, a final state. Hence xyiz L. as
every state in Q is obtained by applying an input symbol, y .
23.5 Example:
Show that L={aP|P is a prime} is not regular.
Solution: Prime numbers are 2, 3, 5, 7, 11, 13, 17,
L={aa, aaa, aaaaa, aaaaaaa,}
Let
y=aa (y )
x = , z =
w= (aa)i
w= (aa)i
When i=1, w = aa which is not in L
When i=2, w = aaaaa which is not L
Therefore L= {aP|P is a prime} is not regular.
23.7 Theorem:
Regular languages are closed under union operation and Kleen star operation.
Proof:
If L 1 and L 2 are regular, then there are regular expressions r 1 and r 2 denoting the languages L 1
and L 2 , respectively.
( r 1+ r 2) and (r 1*) are regular expressions denoting the languages L 1 L 2 and L 1*.
Therefore, L 1 L 2 and L 1* are regular.
23.8 Theorem:
Regular languages are closed under complement operation and intersection operation.
Proof:
Suppose that L 1 and L 2 are regular over an alphabet .
There is a DFA M=(Q, , , q 0, F) accepting L 1.
Design a DFA M = (Q, , , q 0, F), where F = Q - F.
Now, we have that L(M) = * - L 1. Hence, the complement of L 1 is regular.
Let L 1 = * - L 1 and L 2 = * - L 2.
The complement of L 1 L 2 is regular and is equal to L 1 L 2 .
Hence L 1 L 2 is regular.
The proof of regular languages are closed under intersection operation can be done by construct
a new DFA to accept the intersection. The construction is as follows.
Suppose that L 1 and L 2 are regular languages accepted by DFAs M 1=(Q 1, , 1, q 0 1, F 1) and
M 2 =(Q 2, , 2, q 0 2, F 2) such that L(M 1) = L 1 and L(M 2 )= L 2.
Construct a DFA M = (Q, , , q 0, F ), where Q = Q 1 Q 2,
q 0 = (q 0 1, q 0 2), F = F 1 F 2, and
((p i, q s), a) = ( 1(p i, a), 2(q s, a)).
It is not difficult to show that L(M) = L 1 L 2.
MODULE 2
Chapter 4
24.1 GRAMMAR
Introduction
A grammar is mechanism used for describing languages. This is one of the most simple but yet
powerful mechanism. There are four important components in a grammatical description of a
language.
A grammar G is defined as a quadruple.
24.2 Cont
Where,
N is a non-empty finite set of non-terminals or variables,
is a non-empty finite set of terminal symbols such that
, is a special non-terminal (or variable) called the start symbol
is a finite set of production rules.
24.4Example:
is a grammar
Where,
If A is any set, then A* denotes the set of all strings over A, A+ denotes A*- {}, where
is the empty string.
A, B, C, A1, A2, denote the variables.
a, b, c denote the terminals.
x, y, z, w, denote the strings of terminals.
, , , denote the elements of (V )*.
iff
is
where
finite
set
of
production
rules
of
the
form
and
24.7 Cont
The production rules specify how the grammar transforms one string to another.
In grammar no reverse substitution and no inverse operation is permitted.
24.8 Cont
25.1 Example:
25.2 Example:
25.4 Cont
A grammar G is left-linear if each production has one of the following three forms.
A Bc,
A c,
A
A right or left-linear grammar is called a regular grammar.
are as follows:
25.7 Cont
26.1 Example:
Let G be a grammar
. For the string
00110101, find a) the left most derivation, b) the right most derivation and c) the derivation tree.
Solution:
26.2 Cont
(c) The derivation tree is shown in below which yields 00110101:
26.4 Example:
If G is the grammar S SbS|a, show that G is ambiguous.
Solution: Let us consider w=abababa. Then we get two derivation trees for w as shown in
below:
26.5 Cont
26.7 Cont
Here we give the construction to eliminate:
1. Variables not deriving terminal strings.
2. Symbols not appearing in any sentential form
3. Null productions
4. Productions of the form AB
Theorem: if G is a CFG such that L(G) , we can find an equivalent grammar G such that
each variable derives some terminal string.
Proof: Let G=(N, , P, S), we define G=(N, , P, S) as follows:
27.2 Cont
By the definition of Wi, Wi Wi+1 for all i. As N has only a finite number of variables,
Wk = Wk+1 for some k . Therefore, Wk = Wk+j, for j 1. We define N = Wk.
b) Construction of P:
27.3 Example:
27.4 Cont
27.6 Cont
27.7 Example:
Consider G=({S, A, B, E}, {a, b, c}, P, S), where P consists of SAB, Aa, Bb, Ec.
Solution:
28.1 Example:
Reduce the grammar such that there are no - production, whose productions are SaS|AB,
A, B, Db.
28.2 Solution:
Step 1: Construction of the set W of all nullable variables:
Thus, W = W2 = {S, A, B}
28.3 Cont
Step 2: Construction of P:
Here we can not erase both the nullable variables A and B in SAB as we will get S in that
case.
Hence the required grammar without null productions is G1 = ({S, A, B, D}, {a, b}, P, S}
Where Pconsists of Db, SaS, SAB, Sa, SA, SB.
28.5 Example:
28.6 Cont
29.2 Cont
We define G1 = (VN, , P1, S), where P1 and VN are constructed as follows:
All the productions in P of the form Aa, or ABC are included in P1, all the variables
in VN are included in VN.
29.3 Cont
29.4 Cont
Step 3: Restricting the number of variables on R.H.S:
For any production in P1, the R.H.S consists of either a single terminal (or in S) or two or
more variables. We define G2 = (VN, , P2, S) as follows:
All productions in P1 are added to P2 if they are in the required form. All the variables in
VN are added to VN.
29.5 Cont
29.6 Example:
Reduce the following grammar G to CNF. G is SaAD, AaB|bAB, Bb, Dd.
Solution:
Step 1: As there are no null productions or unit productions, we can proceed to step 2.
29.7 Cont
29.8 Cont
30.2 Lemma 1:
Let
be a CFG. Let AB be an A-production in P and B-production be
B1|2||i.
Let G1 = (VN, , P1, S) be obtained from G by deleting the production AB from P and
adding the production, A1|2||i.
Then L(G) =L(G1)
30.3 Lemma 2:
Let
be a CFG. Let the set of A-productions be AA1|A2||Ar|1|2||i.
Note that Is do not start with A.
Let
be CFG formed by adding the variable Z to V and replacing all the
A-productions by the following points.
30.4 Cont
Where P1 is defined as follows:
(iii) The productions for the other variables are as in P. Then G 1 is a CFG and equivalent to G.
30.6 Cont
Step 3: Choose production such that left hand side variable subscript is greater than right hand
side starting variable subscript. Then apply lemma 1 or lemma 2 according to productions.
Step 4: Repeat applying lemma 1 or lemma 2 for all the productions till the grammar comes into
GNF.
30.7 Example:
Construct a grammar in GNF equivalent to the grammar
30.8 Solution:
The given grammar is in CNF. S and A are renamed as A1 and A2 respectively. So the
productions are
As the given grammar has no null productions and
is in CNF we need to carry out step 1. So we proceed to step 2.
31.1 Cont
31.2 Cont
31.3 Cont
31.4 Cont
Hence the equivalent grammar is
Where P1 consists of
31.6 Theorem 1:
The CFLs are closed under union operation.
31.7 Cont
We assume that the sets V1 and V2 are disjoint or V1 V2 = ( we can assume this because if
the sets are not disjoint we can make them so, by renaming variables in one of the grammars).
Consider the following grammar:
The above grammar is basically a combination of the grammars G1 and G2 in which we have
added the new start state S and a new production rule S S1| S2.
31.8 Theorem:
The CFLs are closed under concatenation operation.
Let L={ab}, s(a)=L1 and s(b)=L2. Then s(L)=L1L2
To get grammar for L1L2 :
Add new start symbol and rule S S1S2
We get G = (V, T, P, S) where
V = V1 V2 { S }, where S V1 V2
P = P1 P2 { S S1S2 }
32.1 Example:
L1 = { anbn | n 0 } with G1: S1 aS1b |
L2 = { bnan | n 0 } with G2 : S2 bS2a |
L1L2 = { anb{n+m}am | n, m 0 } with G = ({S, S1, S2}, {a, b}, {S S1S2, S1
aS1b | , S2 bS2a}, S)
32.2 Theorem:
The CFLs are closed under Kleen closure operation.
Use L={a}* or L={a}+, s(a)=L1. Then s(L)=L1* (or s(L)=L1+).
To get grammar for (L1)*
Add new start symbol S and rules S SS1 | .
We get G = (V, T, P, S) where
V = V1 { S }, where S V1
P = P1 { S SS1 | }
32.3 Example:
L1 = {anbn | n 0} (L1)*= { a{n1}b{n1} ... a{nk}b{nk} | k 0 and ni 0 for all i }
L2 = { a{n2} | n 1 }, (L2)*= a*
32.4 Theorem:
The CFLs are closed under homomorphism.
Closure under homomorphism of CFL L for every a . Suppose L is a CFL over alphabet
and h is a homomorphism on .
Let s be a substitution that replaces every a , by h(a). ie s(a) = {h(a)}.
Then h(L) = s(L).
h(L) ={h(a1)h(ak) | k 0} where h(ak) is a homomorphism for every ak .
32.5 Theorem:
The CFLs are closed under substitution.
If a substitution s assigns a CFL to every symbol in the alphabet of a CFL L, then s(L) is a CFL.
Proof:
Let G = (V, , P, S) be grammar for L
Let Ga= (Va, Ta, Pa, Sa) be the grammar for each a with VVa =
And G= (V, T, P, S) for s(L)
32.6 Cont
Where,
V = V Va
T = union of Ta for all a
P consists of
All productions in any Pa for a
In productions of P, each terminal a is replaced by Sa
A detailed proof that this construction works is in the reader.
Intuition: this replacement allows any string in La to take the place of any occurrence of a in any
string of L.
32.7 Example:
L = {0n1n| n 1}, generated by the grammar
S0S1|01,
n m
s(0) = {a b |m n}, generated by the grammar SaSb|A; AaA| ab,
s(1)={ab, abc}, generated by the grammar S abA, A c |
32.8 Cont
S0S1 | 01
S0aS0b | A; AaA | ab
S1abB; Bc |
In the first grammar replace 0 by S0 and 1 by S1. The combined grammar:
G = ({S, S0, S1, A, B}, {a, b}, P, S),
where P = {S S0SS1 | S0S1, S0 aS0b | A, A aA | ab, S1abB, B c | }
33.3 Example:
Show that L = {aP| P is prime} is not a CFL.
Solution: we use the following property of L: if w L, then is a prime.
Step 1: Suppose L = L(G) is context-free. Let n be the natural number obtained by using
pumping lemma.
33.4 Cont
Step 2: Let p be a prime number greater than n. then z = aP L. we write z = uvwxy.
Step 3: By pumping lemma, uv0wx0 y = uwy L. So uwy is a prime number, say Q. let vx = r.
Then, uv q wx q y = + . As q + qr is not a prime. uv q wx q y not belongs to L. this is a
contradiction. Therefore, L is not context-free.
be the given CFG in CNF. Consider the given string x and let
. Let
be the substring of x that begins at position i (i.e. i-th symbol of x) and has length j. Let
be the set of all nonterminals A such that
We write
. Where each
iff
is a terminal symbol.
for all
and
iff
i.e.
.
and
and
of length j,
in G such that
That is
iff
to divide,
and
and
i.e.
for some
, by inspecting the
for some
such that
into smaller substrings, using all possible ways (i.e. for different values of k), and
construct
from already constructed sets for smaller substrings (i.e.
inspecting the grammar.
These sets for longer substrings of x are constructed inductively until the set
is constructed.
It is clear from the construction that
Hence, we can determine whether
The CYK algorithm is presented next.
iff
by inspecting
33.6 CYK-Algorithm
Input: A CFG
Initialize:
. The idea is
and a string
and
) by
for the string
for j : = 2 to n do /* Determine
for all i */
for all i */
of length k */
33.7 Cont
The correctness of the algorithm can be proved by applying induction on j that whenever
the outer loop finishes for particular j, the set
derive
33.8 Example :
Consider the CFG:
S
AB | AC
A
BC | a
B
CB | b
C
AA | b
Let us decide the membership for the string x = baaaab using the CYK algorithm.
The table for
34.1 Cont
Word: b a a a a b
34.2 Cont
The top row is filled in by the first step of the algorithm e.g.
, because
is a
production. We can compute the contents of the second row by using the contents of the first row
(already done) and inspecting the grammar.
34.3 Cont
For example, to compute
if
or if
we have
or
) we notice that
34.4 Cont
Similarly since
is a production and
we put
).
and
34.5 Cont
Consider
Since
and
34.6 Cont
Figure
is a production, we put
we find that
.
and hence no more symbols
34.7 Cont
x = x16 = baaaab
since
Hence baaaab is a member of the language generated by the grammar.
Chapter 5
34.8 PUSHDOWN AUTOMATA (PDA)
Regular language can be characterized as the language accepted by finite automata. Similarly,
we can characterize the context-free language as the language accepted by a class of machines
called "Pushdown Automata" (PDA). Pushdown automation is an extension of the NFA.
35.2 Cont
This "Stack" or "pushdown store" can be used to record potentially unbounded information. It is
due to this memory management capability with the help of the stack that a PDA can overcome
the memory limitations that prevents a FA to accept many interesting languages like
.
(PDA model)
35.7 Cont
PDA are nondeterministic, by default. That is, - transitions are also allowed in which the PDA
can pop and push, and change state without reading the next input symbol or moving its readonly head. Besides this, there may be multiple options for possible next moves.
to subset of
go to state
pop z off the stack
36.3 Cont
Push
then
will be at the top and
at the bottom.)
Move read head right one cell past the current symbol a.
go to state
pop z off the stack
input
and
the
for
stack
and
operation.
The
transition
is depicted by
Final states are indicated by double circles and the start state is indicated by an arrow to it from
nowhere.
remaining to be read (i.e. under and to the right of the read head), and the current stack contents.
Only these three elements can affect the computation from that point on and, hence, are parts of
the ID.
36.7 Cont
The start or initial configuration (or ID) on input
in its start state,
is
with its read head pointing to the leftmost input symbol and the stack
36.8 Cont
Let A be a PDA. A move relation, denoted by
for some
and
37.4 Example:
Here is a PDA that accepts the language
37.5 Cont
and
37.6 Cont
The PDA can also be described by the adjacent transition diagram.
the top of the stack it pushes a onto the stack and changes state to
when M is on state , the symbol on the top of the stack can only be a. On state if it sees the
first b with a on the top of the stack, then it needs to start comparison of numbers of a's and b's,
since all the a's at the beginning of the input have already been pushed onto the stack. It start this
process by popping off the a from the top of the stack and enters in state q3 (to remember that the
comparison process has begun). On state , it expects only b's in the input (if it sees any more a
in the input thus the input will not be in the proper form of anbn). Hence there is no more on
input a when it is in state . On state it pops off an a from the top of the stack for every b in
the input. When it sees the last b on state q3, then the last a from the stack will be popped off and
the start symbol z is exposed. This is the only possible case when the input (i.e. on -input) the
PDA M will move to state
We can show the computation of the PDA on a given input using the IDs and next move
relations. For example, following are the computation on two input strings.
(Using transition 1)
(Using transition 2)
(Using transition 3)
(Using transition 4)
(Using
5)
is final state. Hence, accept. So the
stringtransition
aabb is rightly
accepted by M.
We can show the computation of the PDA on a given input using the IDs and next move
relations. For example, following are the computation on two input strings.
37.8 Cont
i) Let the input be aabab.
38.2 Cont
38.3 Cont
PDA reaches the centre only when the input symbol and the top most symbol of push down stack
are same.
Let L=abba
( q0, abba, z0)
(q0, bba, az0)
(By rule 1)
(q0, ba, baz0)
(By rule 4)
(q0, a, az0)
(By rule 6)
(q1, , z0)
(By rule 5)
(q2, z0)
(By rule 10)
Hence the string is accepted by final state in DPDA.
38.5 Cont
can be defines as:
1.
2.
3.
4.
5.
6.
7. ( q1, a, a) = (q1, )
8. ( q1, b, b) = (q1, )
9. ( q1, , z0) = (q2, z0)
38.6 Cont
Let L=abba
(q0, abba, z0)
38.8 Cont
The above rules can be explained as follows:
The pushdown symbols in A are variables and terminals. If the PDA reads a variable A on the
top of PDS (pushdown store or stack), it makes a -move by placing the R. H. S of any Aproduction (after erasing A). If the PDA reads a terminal a on PDS and if it matches with the
current input symbol, then the PDA erases a. In other cases the PDA halts.
39.1 Example:
Construct a PDA A equivalent to the following CFG: S 0BB, B0S|1S|0. Test whether 0104
is in PDA (A).
Solution:
Define PDA A as follows:
39.2 Cont
is defined by the following rules:
39.3 Cont
MODULE 3
Chapter 6
39.4 Turing machine
The Turing machine (TM) is a simple mathematical model of a general purpose computer. In
other words, TM models the computing power of a computer. i.e. the TM is capable of
performing any calculation, which can be performed by any computing machine.
39.5 Cont
Machine may take its own o/p as i/p for further operation, hence no distinction between i/p and
o/p set. The machine can choose the current location and also decide whether to move Left or
Right in the memory. The o/p of the machine may also be stored in the memory and can
sometimes be used as the i/p.
39.6 Model of TM
The model of Turing machine as shown in below:
39.8 Cont
In one move, the machine examines the present symbol under the R/w head o the tape and the
present state of an automaton to determine.
A new symbol to be written on the tape in the cell under the R/W head.
A motion of the R/W head along the tape, either the head moves one cell left (L) or one
cell Right (R).
The next state of the automaton.
Whether to halt or not.
40.2 Cont
40.3 Description
So, given the current state and tape symbol being read, the transition function describes the next
state, symbol to be written on the tape, and the direction in which to move the tape head ( L and
R denote left and right, respectively ).
Notes:
Here the symbols and are same. And the blank symbol B can also denote as b.
The acceptability of a string is decided by the reachability from the initial state to some
final state. So the final states are also called the accepting states.
may not be defined for some elements of Q.
40.6 ID of TM
The instantaneous description of TM is shown in below. Let us consider the given below TM.
(Turing Machine)
40.7 Description of TM ID
From the above figure it shown that the present symbol under the R/W head is a 1. The present
state is q3. The nonblank symbols to the left of a1 form the string a4a1a2a1a2a2, which is written to
the left of q3. The sequence of nonblank symbols to the right of a1 is a4a2.
40.8 Representation of ID
Thus the ID of the given TM is shown in below.
(Representation of ID)
41.2 Cont
If i = 1, the resulting ID is p y x2 x3. xn.
If (q, xi) = (p, y, R), then the change of ID is represented by,
41.8 Example:
Show the IDs of the TM is shown in table if the input tape contains: a) 01 and b) 1011010.
42.1 Solution:
a) Processing of the string 01# is as follows:
q001# 0q01# 01q1# 011p
b) Processing of the string 1011010# is as follows:
q01011010# 1q1011010#10q111010# 101q01010# 1011q1010#
10110q110# 101101q00# 1011010q0# 10110100p
42.4 Solution:
The actions that should be carried out are:
Search for 1s to the right.
The 0s in the sequence are read but ignored.
Maintain a count of whether the number of 1s is odd or even.
After a blank (#) is found, write the output to the right of the input string.
42.5 Cont
The set of states is as follows:
q0 searches to the right for a 1, indicates the number of 1s so far is even.
q1 searches to the right for a 1, indicates the number of 1s so far is odd.
42.6 Cont
The Turing machine is represented by the following state diagram:
42.7 Cont
TM=({q0,q1},{0,1},{0,1,#},,q0,{p}) where is given by:
43.6 Cont
The advantage of multi-tape TM is that the design of some functions like copying, reversing,
verifying whether a string is a palindrome or not etc, can be carried out in much easier way as
compared to the design of the corresponding standard TMs. The formal notation of multi-tape
TM is quite similar to standard TM except the transition function as shown in below:
43.7 Cont
The multi-tape TM is shown in figure with 3 tape for example.
(Multi-tape TM)
44.1 Multi-dimensional TM
A multi-dimensional TM is one in which the tape can be viewed as extending in more than one
dimensional grid. Initially the input is along one axis and the head is at the left end of the input.
Depending on the state and symbol scanned, the machine changes its states, writes a new symbol
and moves its tape head in one of the directions, either positively or negatively along one of the
K-axes.
44.2 Cont
At any time, in any dimension, only a finite number of rows contain non-blank symbols and each
of these rows has only a finite number of non-blank symbols. The transition function can be
defined as:
Q x Q x x {L,R, D1, D2}
44.5 Cont
It can only solve problems requiring memory that can fit within the tape used for the input. If the
input length is n, then the amount of memory available is linear in n, thus the name of this model
is LBA. LBA accepts a smaller class of languages than the class of r.e. languages.
44.6 Cont
An LBA is exactly similar to a TM except that on any input w
with |w| = n, it can use only
(n+2) numbers of cells of the input tape. The input string is always put between a left-end
marker, <, and a right-end marker, >, which are not puts of the input string. The read-write head
cannot move to the left of the left-end marker or to the right of the right-end marker. The two end
markers cannot be overwritten in any case.
44.8 Cont
2.
(q, <) can contain only element of the form ( p, <, R ) and (q, >) can contain only
elements of the form (p, >, L) for any q, p Q .
[ Note: All other elements are identical to the corresponding elements of a TM]
The language which is accepted by the LBA is called as context sensitive language (CSL).
45.2 Example:
The language
bBBb, aBaa|aaA.
45.3 Solution:
Derive a tree of string a3b3c3.
S aAbc
abAc
abBbcc
aBbbcc
aaAbbcc
aabAbcc
aabbAcc
aabbBbccc
aabBbbccc
aaBbbbccc
aaabbbccc
45.7 Cont
If f1, f2, fk are partial functions of n variables and g is a partial function of k variables, then
the composition of g with f1, f2, fk is a partial function of n variables defined by
If f1, f2, and f3 are partial function of two
variables and g is a partial function of 3-variables, then the composition of g with f1, f2, f3 is
given by
45.8 Example:
Let
46.2 Example:
Compute A (1, 1), A (2, 1), A(1, 2), A(2, 2).
Solution:
A (1, 1)
46.3 Cont
46.4 Cont
47.1 Cont
As long as our notation of computable places no bound on the number of steps or the amount of
storages, it seems that the partial recursive functions are computable, although some would argue
that a function is not computable unless we can bound the computation in advance or at least
establish whether or not the computation eventually terminates.
47.2 Cont
What is less clear is whether the class of partial recursive functions includes all computable
functions. Logic has presented many other form such as the -calculus, post system and general
recursive functions.
In addition, abstract computer models, such as the Random Access memory (RAM), also give
rise to the partial recursive functions.
47.3 Cont
The RAM consists of an infinite number of memory words, numbered 0, 1, each of which
can hold any integer, and a finite number of arithmetic registers capable of holding any integer.
Integers may be decided into usual sorts of computer instructions. It should be clear that if we
choose a suitable set of instructions the RAM may simulate any existing computer.
47.6 Cont
47.7 Cont
This turings greatest discovery that there is a TM which is so sensitive in the respect that by
properly adjusting the i/p representation, we can cause it to computer any turing computable
function i.e., any other function that can be computer by any other TM. The TM of the above
capability is known as UTM.
47.8 Cont
Turing has also indicated as how to construct the UTM which has a property that for every TM
T, there is a string of symbol dT description of Turing such that, if the number X is
written in Unary Notation on a blank tape followed by the string d T and UTM is strated in
state q0 on the left most symbol of dT then when the machine stops the number f(x) will
appear on the tape.
Where f(x) is the number that would have been computed. If the TM T had been started with
only X on the tape.
48.1 Cont
Thus the UTM is capable of any other TM when the following information is started on the tape.
A description of TM in terms of its finite automaton ( this will be the operation area or
the program area of the tape)
The initial configuration of TM i.e. the starting or the current state and the symbol
scanned. ( this will be the state area of the tape)
The processing data to be fed to the TM. (this will be the data area of the tape).
48.2 Cont
The finite automaton, the description of the TM is stored on the tape. This stored information is
nothing but the DATA to the UTM. The only difference in the input string and this data is that
the interpretation will be different.
The UTM actually keep, the complete account of the TM, which is to be simulated. It remembers
the current state of that TM, input scanned, the action which will be taken by that TM and so
on. But the whole process has a definite path.
48.4 Cont
Step 3: Find the required column i.e. the current state of TM and read the triplet from the table
i.e. new symbol, new state and direction of movement of the tape.
Step 4: Move the tape to the appropriate square on the data area of the tape, replace the symbol,
move the tape in the given direction, read the next symbol, reach the state and replace the state
by the current state and repeat from the step 1.
Chapter 9
48.5 Post's Correspondence Problem (PCP)
A post correspondence system consists of a finite set of ordered pairs
where
48.6 Example 1:
Consider the post correspondence system
The list 1,2,1,3 is a solution to it.
Because
i
xi
yi
1
2
3
48.7 Example 2:
The following PCP instance has no solution
i
xi
yi
1
2
48.8 Cont
This can be proved as follows. (x2, y2) can not be chosen at the start, since than the LHS and
RHS would differ in the first symbol (
in LHS and
49.1 Cont
If
RHS). If
next step.
in LHS and
in
is selected, instead, there will not be any choice to match the both side in the
49.2 Example 3:
The list 1,3,2,3 is a solution to the following PCP instance.
i
xi
yi
101
10
00
011
11
49.5 Cont
Languages (and the corresponding grammars) can be classified according to the minimal
automaton sufficient to recognize them. Such classification, known as Chomsky Hierarchy, has
been defined by Noam Chomsky, a distinguished linguist with major contributions to linguistics.
49.6 Cont
The Chomsky Hierarchy comprises four types of languages and their associated grammars and
machines.
The
types
of
languages
form
a
strict
hierarchy:
regular languages context-free languages context-sensitive languages recursive languages
recursively enumerable languages.
49.7 Cont
Language
Grammar
Machine
Example
Type 3
Regular languages
Regular grammars
Right-linear
grammars
Left-linear
grammars
Finite-state
automata
a*
Type 2
Context-free languages
Context-free
grammars
Push-down
automata
anbn
Type 1
Context-sensitive
languages
Context-sensitive
grammars
Linear-bound
automata
anbncn
Type 0
Recursive languages
Recursively
enumerable languages
Unrestricted
grammars
Turing machines
any computable
function
50.2 Cont
50.5 Cont
Since we allow more than one symbol on the left-hand-side, we refer to those symbols
other than the one we are replacing as the context of the replacement.
The automaton which recognizes a context-sensitive language is called a linear-bounded
automaton: an FSA with a memory to store symbols in a list.
50.6 Cont
Since the number of the symbols on the left-hand side is always smaller or equal to the
number of the symbols on the right-hand side, the length of each derivation string is
increased when applying a grammar rule. This length is bound by the length of the input
string. Thus a linear-bound automaton always needs a finite list as its store
Examples of context-sensitive languages are most programming languages
50.8 Theorem:
A language is generated by an unrestricted grammar if and only if it is recursively enumerable.