0% found this document useful (0 votes)
4 views

tcs-theory-tcs-lecture-notes_copy

The document contains lecture notes on the Theory of Computer Science, covering various topics such as Rice Theorem, applications of Push Down Automata (PDA), Chomsky Hierarchy, and the differences between various types of automata. It also discusses the Halting Problem, Turing Machines, and the distinctions between deterministic and non-deterministic automata. Key concepts are summarized with definitions, applications, and comparisons of different computational models.

Uploaded by

sawant.hemant11
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

tcs-theory-tcs-lecture-notes_copy

The document contains lecture notes on the Theory of Computer Science, covering various topics such as Rice Theorem, applications of Push Down Automata (PDA), Chomsky Hierarchy, and the differences between various types of automata. It also discusses the Halting Problem, Turing Machines, and the distinctions between deterministic and non-deterministic automata. Key concepts are summarized with definitions, applications, and comparisons of different computational models.

Uploaded by

sawant.hemant11
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

lOMoARcPSD|42824885

TCS Theory - TCS lecture notes

Theory Of Computer Science (University of Mumbai)

Scan to open on Studocu

Studocu is not sponsored or endorsed by any college or university


Downloaded by Pranjal Sawant ([email protected])
lOMoARcPSD|42824885

Theory of Computer Science (Theory Questions)

Q.1 Write short note on: Rice Theorem


(Dec. 2012, May 2013, May 2014, May 2015, Dec. 2015 May 2016. Dec. 2016, May
2017, Dec. 2017)
Ans:
Rice Theorem
"Every property that is satisfied by some but not all recursively enumerable
language is un-decidable". Any property that is satisfied by some recursively enumerable
language but not all is known as nontrivial property. We have seen many properties of
R.E. languages that are un-decidable. These properties include:
1. Given a TM M, is L(M) nonempty?
2. Given a TM M, is L(M) finite?
3. Given a TM M, is L(M) regular?
4. Given a TM M, is L(M) recursive?
The Rice's theorem can be proved by reducing some other unsolvable problem to
nontrivial property of recursively enumerable language.

Q.2. Write application of PDA. (Dec. 2012)


Ans.:
PDA Stands for Push Down Automata.
Applications of PDA -
1) PDA is a machine for CFL.
2) A string belonging to a CFL can be recognized by a PDA.
3) PDA is extensively used for parsing.
4) PDA is an abstract machine; it can also use for giving proofs of lemma on CFL.

Q.3. Give applications of regular expressions. (May14)


Ans:
1) Regular expression is used in finding patterns in text
2) Regular expression is used in search engine
3) Regular expression is used in specifying lexical analyser.
4) Common applications include data validation, data scraping (especially web scraping),
data wrangling, simple parsing, the production of syntax highlighting systems, and many
other tasks.

By Shri

Downloaded by Pranjal Sawant ([email protected])


lOMoARcPSD|42824885

Q.4. Write note on Chomsky Hierarchy.


(MU Dec. 2009, Dec. 2012, May 2013, May 2014, Dec. 2014, May 2015, Dec. 2016,
May 2017, Dec. 2017)
Ans: Chomsky Hierarchy
A grammar can be classified on the basis of production rules. Chomsky classified
grammars into the following types:
1. Type 3: Regular grammar
2. Type 2: Context free grammar
3. Type 1: Context sensitive grammar
4. Type 0: Unrestricted grammar.

No Grammar Grammar Accepted Language Accepted Automation


Type
1 Type 3 Regular grammar Regular Language Finite Automata (FA)
2 Type 2 Context free grammar Context free Language Pushdown Automata
(CFG) (CFL) (PDA)
3 Type 1 Context sensitive Context sensitive Linear Bounded
grammar (CSG) Language (CSL) Automation (LBA)
4 Type 0 Unrestricted Grammar Recursively enumerable Turing Machine (TM)
language (REL)

1. Type 3 or Regular Grammar


A grammar is called Type 3 or regular grammar if all its productions are of the
following forms:
A→ ε
A→ a
A→ aB
A → Ba
Where, a € Σ and A, B € V.
A language generated by Type 3 grammar is known as regular language.

2. Type 2 or Context Free Grammar


A grammar is called Type 2 or context free grammar if all its productions are of
the following form A→ α where A € V and α € (VUT) *.
V is a set of variables and T is a set of terminals.
The language generated by a Type 2 grammar is called a context free language, a
regular language but not the reverse.

By Shri

Downloaded by Pranjal Sawant ([email protected])


lOMoARcPSD|42824885

3. Type 1 or Context Sensitive Grammar


A grammar is called a Type 1 or context sensitive grammar if all its productions
are of the following form.
α→ẞ
Where, ẞ is atleast as long as α.
4. Type 0 or Unrestricted Grammar
Productions can be written without any restriction in a unrestricted grammar. If
there is production of the α→ ẞ, then length of α could be more than length of ẞ.
Every grammar also is a Type 0 grammar.
A Type 2 grammar is also a Type 1 grammar
A Type 3 grammar is also a Type 2 grammar.

Q.5. Difference between moore machine and mealy machine


Ans:
No Moore Machine Mealy Machine
1 In moore machine, output symbol is In mealy machine, output symbol is
associated with each state associated with each transition
2 Output is dependent on state Output is dependent on state and input
3 Output Mapping: Output Mapping:
:Q→ : Q× ∑ →
4 In this, if length of input sequence is n, In this, if length of input sequence is n,
then the length of output sequence is then the length of output sequence is
n+1 also n
5 Here we can get output on € Here we cannot get output on €
6 Example: Example:

By Shri

Downloaded by Pranjal Sawant ([email protected])


lOMoARcPSD|42824885

Q.6. Difference between NFA and DFA:


DFA NFA
1 DFA stands for Deterministic Finite NFA stands for Nondeterministic Finite
Automata. Automata.
2 DFA cannot use Empty String transition. NFA can use Empty String transition.
3 DFA is more difficult to construct. NFA is easier to construct.
4 Time needed for executing an input string Time needed for executing an input string is
is less. more.
5 All DFA are NFA. Not all NFA are DFA.
6 DFA requires more space. NFA requires less space then DFA.
7 Dead state may be required. Dead state is not required.
8 Backtracking is allowed in DFA. Backtracking is not always possible in NFA.
9 Conversion of Regular expression to DFA Conversion of Regular expression to NFA is
is difficult. simpler compared to DFA.

Q.7. Write Short Note On: Recursive and Recursively Enumerable Languages
(May 14,Dec 16) OR
Difference between Recursive and Recursively Enumerable Languages:

By Shri

Downloaded by Pranjal Sawant ([email protected])


lOMoARcPSD|42824885

Q.8. State and prove Halting Problem or Short note on Halting Problem
(Dec15, Dec16)
Ans:
Input − A Turing machine and an input string w.
Problem − Does the Turing machine finish computing of the string w in a finite number
of steps? The answer must be either yes or no.
Proof − At first, we will assume that such a Turing machine exists to solve this problem
and then we will show it is contradicting itself. We will call this Turing machine as a
Halting machine that produces a ‘yes’ or ‘no’ in a finite amount of time. If the halting
machine finishes in a finite amount of time, the output comes as ‘yes’, otherwise as ‘no’.
The following is the block diagram of a Halting machine:

Now we will design an inverted halting machine (HM)’ as −


• If H returns YES, then loop forever.
• If H returns NO, then halt.
The following is the block diagram of an ‘Inverted halting machine’:

Further, a machine (HM)2 which input itself is constructed as follows −


• If (HM)2 halts on input, loop forever.
• Else, halt.
Here, we have got a contradiction. Hence, the halting problem is undecidable.

By Shri

Downloaded by Pranjal Sawant ([email protected])


lOMoARcPSD|42824885

Q.9. Give formal definition of PDA / Mathematical Model of PDA (Dec16)


Ans:
i) PDA is used for recognizing context free language which is generated by
context free grammar.
ii) PDA is more powerful than finite automata because it has a stack which can be
used for remembering some information.
iii) Model of PDA is as follows:

iv) PDA consists of finite set of states, i/p tape, read head and stack.
v) Depending on the stack, i/p symbol and stack top symbol:
- PDA can change the stack/remain in the same stack.
- PDA moves the head to right of current cell.
- PDA can perform some stack operations.
vi) PDA can be represented mathematically as follows: (7 tuples)
M = ( Q, ∑, Γ, δ, q0 , Z0 , F)
Q: the finite set of states
∑: input alphabet
Γ: stack alphabet
q0 : initial state
Z0: initial stack top symbol
F: finite set of final states
δ: transition function
δ: Q × ∑ × Γ → Q × Γ*

By Shri

Downloaded by Pranjal Sawant ([email protected])


lOMoARcPSD|42824885

Q.10. State and explain power and limitation of turing machine. (Dec16)
Ans:
Power of Turing Machine:
➢ The turing machine has a great computational capabilities. So it can be used
as a general mathematical model for modern computers.
➢ Turing machine can model even recursively enumerable languages. Thus the
advantage of turing machine is that it can model all the computable
functions as well as the languages for which the algorithm is possible.
Limitations of turing machine:
➢ Computer scientists believe that a Turing machine encapsulates the idea of
computability. That is, if a function can be computed by any physical process, it
can be computed by a Turing machine. (This is known as the Church-Turing
thesis.)
➢ But we do know that many important functions are uncomputable. For
example:
- Determining if a program will ever halt on a given input
- Determining if two programs compute the same output
- Determining the size of the smallest program that computes a given
output (formally, this is known as Kolmogorov complexity)
Since none of these can be computed by a Turing machine, we believe that
they are uncomputable under any realizable model of computation.

Q.11. Write Short Note on Universal Turing Machine (Dec15)


Ans:
➢ Universal Turning Machine stimulates a Turning Machine.
➢ Universal Turing Machine can be considered as a subset of all the Turing machines,
it can match or surpass other Turing machines including itself.
➢ Programmable Turing Machine is called Universal Turing Machine
➢ Universal Turing Machine is like a single Turing Machine that has a solution to all
problems that is computable.
➢ It minimizes space complexity
➢ It contains a Turning Machine description as input along with an input string, runs
the Turning Machine on the input and returns a result.
➢ The transition function is Q × T → Q × T × {L, R}, where Q is a finite set of states, T
is the tape of the alphabet

By Shri

Downloaded by Pranjal Sawant ([email protected])


lOMoARcPSD|42824885

Q.12. Difference between pushdown automata and finite automata


Ans:
S.NO Pushdown automata finite automata
1. For Type-2 grammar we can design For Type-3 grammar we can design finite
pushdown automata. automata.
2. Non – Deterministic pushdown automata Non-Deterministic Finite Automata has same
has more powerful than Deterministic powers as in Deterministic Finite Automata.
pushdown automata.
3. Not every Non-Deterministic pushdown Every Non-Deterministic Finite Automata is
automata is transformed into its transformed into an equivalent Deterministic
equivalent Deterministic pushdown Finite Automata
Automata.
4. Context free languages can be recognized Regular languages can be recognized by finite
by pushdown automata. automata.
5. Pushdown automata has the additional Finite Automata doesn’t has any space to store
stack for storing long sequence of input alphabets.
alphabets.
6. It gives acceptance of input alphabhets by It accepts the input alphabets by going up to
going up to empty stack and final states. final states.

OR
S.NO Pushdown automata finite automata
1. PDA is more powerful than FA FA is less powerful as compare to PDA
2. It has additional memory in form of stack It has no memory
3. PDA accepts CFG(Context Free Grammar) FA accepts RL(Regular Language)
4. PDA is useful for parsing phase of FA is useful for lexical analysis phase of
compiler compiler
5. PDA transition based on current input or FA transition based on current input and
current stack on the top of stack symbol current state.

By Shri

Downloaded by Pranjal Sawant ([email protected])


lOMoARcPSD|42824885

Q.13. Describe Finite Automata (dec18)


Ans:
→Finite Automata (FA) is the simplest machine to recognize patterns.
→The finite automata or finite state machine is an abstract machine that has five
elements or tuples.
→ A finite automaton is a collection of 5-tuple (Q, ∑, δ, q0, F), where:

1. Q: finite set of states


2. ∑: finite set of the input symbol
3. q0: initial state
4. F: final state
5. δ: Transition function

→It has a set of states and rules for moving from one state to another but it depends upon
the applied input symbol.
→ The following figure shows some essential features of general automation.

→The above figure shows the following features of automata:


- Input
- Output
- States of automata
- State relation
- Output relation
→FA is characterized into two types:
1) Deterministic Finite Automata (DFA)
2) Nondeterministic Finite Automata(NFA)

Q.14. Give application of Finite Automata (may19)


➢ Design of the lexical analysis of a compiler.
➢ Recognize the pattern by using regular expressions.
➢ Use of the Mealy and Moore Machines for designing the combination and
sequential circuits.
➢ Helpful in text editors.
➢ Used for spell checkers.

By Shri

Downloaded by Pranjal Sawant ([email protected])


lOMoARcPSD|42824885

Q.15. Difference between DPDA and NPDA (explain npda – dec 18)
Ans:
S. DPDA (Deterministic Pushdown NDPA (Non-deterministic Pushdown
No Automata) Automata)
1. It is less powerful than NPDA. It is more powerful than DPDA.
2. It is possible to convert every DPDA to It is not possible to convert every NPDA to a
a corresponding NPDA. corresponding DPDA.
3. The language accepted by DPDA is a The language accepted by NPDA is not a
subset of the language accepted by subset of the language accepted by DPDA.
NDPA.
4. The language accepted by DPDA is The language accepted by NPDA is called
called DCFL (Deterministic Context- NCFL (Non-deterministic Context-free
free Language) which is a subset of Language).
NCFL (Non-deterministic Context-free
Language) accepted by NPDA.

Q. 16. Give formal definition of regular language. (Every year they ask this
question)
Ans:

By Shri

Downloaded by Pranjal Sawant ([email protected])


lOMoARcPSD|42824885

Q.17. Variants or Variations or Types of Turing Machine (Very IMP)


Ans:
Variants of Turing Machine are as follows:
1) Semi-infinite turing machine:
→It has no cells on the left-hand side of the initial position and infinite cells on the right-
hand side of the initial position.
→Here, head can only be move or is allowed to move in right hand side direction of the
initial position of the input on the tape.

2) Two way-infinite turing machine:


→The input and output tape is a two way indefinite tape i.e there are unlimited blank
cells on the left as well as on the right of the current non block portion on the tape
→Two way-infinite tape turing machine can be stimulated by Standard turing
machine(one way-infinite turing machine)

3) Multiple track turing machine:


→ This turing machine has multiple tracks but a single tape head that reads and writes
on all tracks.
→ Also, for every single-track turing machine, there exists an equivalent multi-track
turing machine.
→ Multiple track turing machine can be stimulated by Standard turing machine.

By Shri

Downloaded by Pranjal Sawant ([email protected])


lOMoARcPSD|42824885

4) Multiple tape turing machine:


→It has multiple tapes and is controlled by a single head.
→Multiple-tape turing machine is different from multi track turing machine but
expressive power is same.
→ Multiple-tape turing machine is simulated by single-tape turing machine.

5) Multi Dimensional Turing Machine:


→It has multi dimensional tape where head can move in any direction that is left,
right, up and down.
→ Multi dimensional turing machine can be stimulated by Standard turing machine.

By Shri

Downloaded by Pranjal Sawant ([email protected])


lOMoARcPSD|42824885

6) Non deterministic turing machine:


→A non-deterministic Turing machine has a single, one-way infinite tape.
→For a given state and input symbol has at least one choice to move (finite number
of choices for the next move), each choice has several choices of the path that it might
follow for a given input string.
→A non-deterministic Turing machine is equivalent to the deterministic Turing
machine.

Q.18. Closure properties of regular language (State and explain any 5 --- 5 marks)
Ans:
Closure properties on regular languages are defined as certain operations on regular
language which are guaranteed to produce regular language.
Closure properties of regular languages are as follows:
1. Union
2. Intersection
3. Concatenation
4. Kleen closure
5. Complement
6. Reversal
7. Let difference operator
8. Homomorphism
9. Inverse homomorphism
1.Union:
If L1 and If L2 are two regular languages, their union L1 U L2 will also be regular.

2.Intersection:
If L1 and If L2 are two regular languages, their intersection L1 ∩ L2 will also be regular.

By Shri

Downloaded by Pranjal Sawant ([email protected])


lOMoARcPSD|42824885

3.Concatenation:
If L1 and If L2 are two regular languages, their concatenation L1.L2 will also be regular.

4.Kleen closure:
If L1 is a regular language, its Kleene closure L1* will also be regular.

5.Complement:
If L(G) is a regular language, its complement L'(G) will also be regular. Complement of a
language can be found by subtracting strings which are in L(G) from all possible strings.

By Shri

Downloaded by Pranjal Sawant ([email protected])


lOMoARcPSD|42824885

Q.19. Decision properties of regular language


Ans:

Testing Emptiness of Regular Languages:


➢ The emptiness question is whether there is any path from the start
state to some accepting state. If so, the language is non empty, while
if accepting states are all separated from the start state, then the
language is empty.
➢ Deciding whether we can reach an accepting state from the start state
is a simple instance of graph reachability.

Testing Membership in a Regular Language:


➢ Here the question is given a string w and a regular language L, is w in L.
➢ If L is represented by a DFA, simulate the DFA processing the string
input symbols w, beginning in the start state. If the DFA ends in an
accepting state, the answer is yes otherwise the answer is no.
➢ If L has any other representation besides a DFA we could convert to a
DFA and then run the test above.

Testing Equivalence of States:


➢ To find states that are equivalent, we try to find pairs of states that are
distinguishable.Any pair of states that we do not find distinguishable
are equivalent.
➢ The table filling algorithm is a recursive discovery of distinguishable pairs in a
DFA.

Testing Equivalence of Regular Languages:


➢ The table filling algorithm gives us an easy way to test if two regular
languages are thesame. Suppose L and M are two languages
represented by their respective DFA’s.
➢ Now test if the start states of the two original DFA’s are equivalent,
using the tablefilling algorithm. If they are equivalent, then L = M
and if not then L ≠ M.

By Shri

Downloaded by Pranjal Sawant ([email protected])


lOMoARcPSD|42824885

Q.20. Post Correspondence Problem


Ans:
Post’s Correspondence Problem (PCP) was first introduced by Emil Post in 1946. Later, the
problem was found to have many applications in the theory of formal languages.

The problem over an alphabet  belongs to a class of yes / no problems and is stated as follows
:
Consider the two lists x = (x1 . . . . xn), y = (y1......... yn) of nonempty strings over
an alphabet  = (0, 1). The PCP is to determine whether or not there exist i1 .
. . .., im, where o  ij  n, such that xi1, . . . . xim = yi1, ........ yim

Note :
1) The indices ij’s need not be distinct and m may be greater than n.
2) if there exists a solution to PCP, there exists infinitely many solutions
3) PCP is undecidable.

By Shri

Downloaded by Pranjal Sawant ([email protected])

You might also like