Escolar Documentos
Profissional Documentos
Cultura Documentos
Dr. N. R. Ansari
Theory of Computation
About Me
Education
2001, MCS Bahria Institute / Peshawar University 2005, M.S. (Software Engineering) NUST 2008, Ph.D. (Computer Engineering) Graz University of Technology, Austria.
Research Interests
Model-based and Qualitative Reasoning
Distributed Computing Verification and Validation
Theory of Computation
About Me
Work Experiences
Permanent Faculty Member, COMSATS IIT Islamabad. Visiting Faculty Member, COMSATS, AIOU Research Assistant, Graz University of Technology, Austria Senior Researcher in a Defence Organization Offshore Post-Doc Technology. Researcher, Graz University of
Contact
nransari@hotmail.com
0331-5260536
Dr. N. R. Ansari
Theory of Computation
Pragmatics
Pre-Requisites
No Pre-Requisite
Text book
Introduction to Computer Theory by Daniel I.A. Cohen
Quizzes
Roughly once every two weeks Marks Distribution Theoretical Course 40 % Mid-term, 40% Final, 20 % Quizzes
Dr. N. R. Ansari
Theory of Computation
Course Objectives
The major objective of this course is to introduce the student to the concepts of theory of computation in computer science. The student should acquire insights into the relationship among formal languages, formal grammars, and automata. Upon successful completion of this course, students will be able to: Apply a number of proof techniques to theorems in language design.
Understand the equivalence between Context-Free Grammars and Nondeterministic Pushdown Automata. Appreciate the power of the Turing Machine, as an abstract automaton, that describes computation, effectively and efficiently.
Dr. N. R. Ansari
Theory of Computation
Course Outline
(1) Introduction and Languages. (2) Regular Expressions. (3) Finite Automata. (4) Transition Graphs. (5) Kleene's Theorem. (6) Finite Automata with Output. (Moore /Mealy Machines) (7) Regular Languages. (8) Decidability. (9) Context-Free Grammars. (10)Grammatical Format. (11)Pushdown Automata. (12)CFG = PDA. (13)Context-Free Languages. (14)Decidability. (15)Turing Machines. (16)Minsky's Theorem. (17)Computers.
Dr. N. R. Ansari
Theory of Computation
Theory of Computation
The theory of computation is the branch of computer science and mathematics that deals with whether and how efficiently problems can be solved on a model of computation, using an algorithm.
A model of computation is the definition of the set of allowable operations used in computation and their respective costs The field is divided into two major branches computability theory and complexity theory
Computability theory deals primarily with the question of the extent to which a problem is solvable on a computer.
Complexity theory considers not only whether a problem can be solved at all on a computer, but also how efficiently the problem can be solved.
7
Dr. N. R. Ansari
Theory of Computation
Automata Theory
Automata theory is the study of abstract machines and problems which they are able to solve
A typical abstract machine consists of a definition in terms of input, output, and the set of allowable operations used to turn the former into the latter. Automata theory is a step in abstracting your attention away from any particular kind of computer or particular programming language In English we have letter, words and sentences (relationship) Not all collection of letters form a valid word, not all collections of words form a valid sentence
Dr. N. R. Ansari
Theory of Computation
Automata Theory
Dr. N. R. Ansari
Theory of Computation
Today, we will begin with only one finite set of fundamental units out of which we build structures, it is called alphabet.
A certain specified set of strings of characters from the alphabet is called the language.
The strings which are permissible in the language are called words.
We shall allow a string to have no letters. This we call the empty string or null string and denote with the symbol .
Dr. N. R. Ansari
Theory of Computation
Length() = 0
If a is a word in some language L, then reverse(a) is the same string of letters spelled backward, called the reverse of a. Reverse(xxx) = xxx Reverse(420) = 024
This language has some very interesting properties which we will examine later. Dr. N. R. Ansari
Theory of Computation
KLEENE CLOSURE
Given an alphabet , we wish to define a language in which any string of letters from is a word, even the null string
This is called closure of the alphabet and denoted by * This notation is sometimes known as kleene star * = L1 = { x xx xxx xxxx.}
If = {x}, then
If = {0 1} then
* = L2 = { 0 1 00 01 10 11 000 001.}
* = L3 = { a b c aa ab ac ba bb bc ca cb cc aaa ..}
If = {a b c} then
Dr. N. R. Ansari
12
Theory of Computation
KLEENE CLOSURE
If S is a set of words, then by S*, we mean the set of all finite string formed by concatenating words from S, where null string is also included.
If S = {aa b} then
If we wish to modify the concept of closure to refer to only the concatenation of some (non-zero) strings from a set S, we use the notation + instead of * If = {x} then + = {x xx xxx xxxx }
Dr. N. R. Ansari
13
Theory of Computation
Quiz # 0
This Quiz carries 0 marks and will provide you the idea of the quizzes you are going to get in this course.
Exercises at the end of the chapter are important.
Write out all the words in S* that have seven or fewer letters.
Let S = {ab bb} and let T = {ab bb bbbb}, show that S* = T* Let S = {ab bb} and let T = {ab bb bbb}, show that S* T*
14
Dr. N. R. Ansari
Theory of Computation
Dr. N. R. Ansari
15
Theory of Computation
Dr. N. R. Ansari
16
Theory of Computation
Grammars
Numerical numbers
1, 2, 3, I, II, III,.. ,,,.
Dr. N. R. Ansari
Theory of Computation
Dr. N. R. Ansari
18
Theory of Computation
Grammars
Grammars express languages Example: the English language
sentence noun _ phrase article predicate noun
verb
a the
cat dog
Theory of Computation
S aSb S
S aSb ab
S aSb
Dr. N. R. Ansari
S
20
Theory of Computation
3. A
3 4
4. B Bb 5. B
5
S aAB A bBb B A|
Leftmost derivation:
Theory of Computation
Theory of Computation
Dr. N. R. Ansari
S AB
A aaA |
Theory of Computation
B Bb |
S AB
S
Dr. N. R. Ansari
S AB
A aaA |
Theory of Computation
B Bb |
S AB aaAB
S
A
a a
B A
Dr. N. R. Ansari
S AB
A aaA |
Theory of Computation
B Bb |
S AB aaAB aaABb
S
A
a a
B A B
b
Dr. N. R. Ansari
S AB
A aaA |
Theory of Computation
B Bb |
A
a a
B A B
b
Dr. N. R. Ansari
S AB
A aaA |
Theory of Computation
B Bb |
A
a a
B A B
b
Dr. N. R. Ansari
S AB
A aaA |
Theory of Computation
B Bb |
A
a a
B
yield
aab aab
Dr. N. R. Ansari
Theory of Computation
Ambiguity
Dr. N. R. Ansari
E E E | E E | (E) | a a aa
E E
a
Theory of Computation
E E E a E a EE a a E a a*a
E
leftmost derivation
E
a
Dr. N. R. Ansari
E
a
E E E | E E | (E) | a a aa
Theory of Computation
E EE E EE a EE E a aE a aa
leftmost derivation
E E
a
E
a
E
a
Dr. N. R. Ansari
Theory of Computation
E E E | E E | (E) | a a aa
Two derivation trees
E E
a
E E
E E
a
E
a
E
a
Dr. N. R. Ansari
E
a
E
a
E E E | E E | (E) | a is ambiguous:
The grammar string
Theory of Computation
E
a
E
E E
E
a
a
Dr. N. R. Ansari
The grammar
E E E | E E | (E) | a is ambiguous:
string
Theory of Computation
E E E a E a EE a a E a a*a E EE E EE a EE a aE a aa
Dr. N. R. Ansari
Theory of Computation
a aa
E E
a
take
a2
E
E
a
E
a
Dr. N. R. Ansari
E
a
E
a
E
a
Theory of Computation
2 22 6
6 E
2 22 8
8 E
2 E 2
4 E
4 E 2 E 2 2 E 2
2 E 2
2 E 2
Dr. N. R. Ansari
2 E 2
Theory of Computation
Dr. N. R. Ansari
Theory of Computation
E E E | E E | (E) | a
New non-ambiguous grammar:
E E T E T T T F T F F (E) F a
Dr. N. R. Ansari
E E T T T F T a T a T F a F F a aF a aa
Theory of Computation
a aa
T
E E T E T T T F T F F (E) F a
Dr. N. R. Ansari
E T
F
a
T
F
a
F
a
Theory of Computation
Dr. N. R. Ansari