Cloud Computing
Cloud Computing
To Theory of
Computation
1
Theory of Computation
Objective
• This course is mainly about abstractions of what
we can compute.
• The treatment is mathematical, but the point of
view is that of Computer Science.
• Roughly speaking, the theory of computation can
be divided into three overlapping subareas such
as :
• formal languages and automata theory,
computability theory and complexity theory.
In this course:
• Fundamental capabilities and limitations of computers
• Mathematical properties of computer hardware and
software
• Relevance to practice, for example, in the design of
new programming languages, compilers, string
searching, pattern matching, computer security,
artificial intelligence, etc.
• Learn about problem solving through argue, prove,
express and abstract
• Assignments & problem sets after each unit
Academic Integrity
• You are encouraged to discuss the
assignments problems among yourselves.
• Each student must hand in her/his own
solution.
• no cheating or copying from any source
4
Grading
• Assignments: 25% (10%+15%)
• Midterm: 25%
• Final: 50%
5
Bibliography
Required: Michael Sipser: Introduction to the
Theory of Computation, Second Edition,
Thomson.
6
Introduction to Computability
Theory
Lecture1: Finite Automata and
Regular Languages
7
Origin
• Started in 1930’s by mathematicians and
logicians in an attempt to understand
computation
• Mainly, to find the answer that all
mathematical problems can be solved in a
systematic way
• These research led the computers we know
and use today
Introduction
Computer Science stems from two starting
points:
Mathematics: What can be computed?
And what cannot be computed?
Electrical Engineering: How can we build
computers?
Not in this course.
9
The theory of computation
• 3 central areas
• Automata Theory
• Complexity Theory
• Computability Theory
What is Automata Theory?
• Study of abstract computing devices, or “machines”
• Automaton = an abstract computing device
– Note: A “device” need not even be a physical hardware!
• A fundamental question in computer science:
– Find out what different models of machines can do and
cannot do
– Computability vs. Complexity
11
Complexity Theory
• Deals with the problem of
– What makes some problem computationally hard
or others easy
– The theory deals with the aspects of problem
which are the root causes of difficulty
– One solution is to alter the problem (easy one or
approximate one)
Example
Easy Problems (Efficiently solvable)
• Sorting a list of 1 million numbers
• Computing the fastest path from Quetta to
Karachi
Hard Problems
• Time table scheduling of all courses in a large
university
• Factoring a large integer number (say 250 digits)
into its prime factors
Introduction
Computability Theory deals with the profound
mathematical basis for Computer Science, yet
it has some interesting practical outcomes
that I will try to point out sometimes.
The question we will try to answer in this theory
is:
“What can be computed? What Cannot be
computed and where is the line between the
two?”
14
Computational Models
A Computational Model is a mathematical
object (Defined on paper) that enables us to
reason about computation and to study the
properties and limitations of computing.
We will deal with Three principal computational
models in increasing order of Computational
Power.
15
Computational Models
We will deal with three principal models of
computations:
1. Finite Automaton (in short FA).
recognizes Regular Languages .
2. Push Down Automaton (in short PDA).
recognizes Context Free Languages .
3. Turing Machines (in short TM).
recognizes Computable Languages .
16
Computation
CPU memory
17
temporary memory
input
CPU
output
Program memory
18
Example: f ( x) x 3
temporary memory
input
CPU
output
Program memory
compute xx
compute x x2
19
f ( x) x 3
temporary memory
input
x2
CPU
output
Program memory
compute xx
compute x x2
20
temporary memory f ( x) x 3
z 2*2 4
f ( x) z * 2 8
input
x2
CPU
output
Program memory
compute xx
compute x x2
21
temporary memory f ( x) x 3
z 2*2 4
f ( x) z * 2 8
input
x2
CPU
f ( x) 8
Program memory output
compute xx
compute x x2
22
Automaton
temporary memory
Automaton
input
CPU
output
Program memory
23
Automaton
temporary memory
Automaton
input
output
transition
state
24
Different Kinds of Automata
Automata are distinguished by the temporary memory
25
Finite Automaton
temporary memory
input
Finite
Automaton
output
Pushdown input
Automaton
output
Temp.
memory Random Access Memory
input
Turing
Machine
output
30
Finite Automata - A Short Example
• The control of a washing machine is a very
simple example of a finite automaton.
• The most simple washing machine accepts
quarters and operation does not start until at
least 3 quarters were inserted.
Control of a Simple Washing Machine
• Accepts quarters. 25
25,50
50 50
• Accepted words: 25,25,25; 25,50; …
Finite Automata - A Short Example
• The second washing machine accepts 50 cents
coins as well.
• The most complex washing machine accepts
$1 coins too. 100
50 50,100
25,50,100
Finite Automaton - An Example
0 q0 0,1
qs
1 q1 0,1
Initial State: qs
Final State: q0
35
Finite Automaton – An Example
0 q0 0,1
qs
1 q1 0,1
37
Observations
1. Each state has a single transition for each
symbol in the alphabet.
2. Every FA has a computation for every finite
string over the alphabet.
38
Examples
39
How to do it
1. Find some simple examples (short accepted and
rejected words)
2. Think what should each state “remember”
(represent).
3. Draw the states with a proper name.
4. Draw transitions that preserve the states’
“memory”.
5. Validate or correct.
6. Write a correctness argument.
The automaton
1 q1 1
qs
1 0
0 q0 0
Correctness Argument:
The FA’s states encode the last input bit and q1
is the only accepting state. The transition
function preserves the states encoding.
Examples
42
Deterministic Finite Automaton (DFA)
Input Tape
String
Output
“Accept”
Finite or
Automaton “Reject”
43
head
Initial Configuration
Input Tape
a b b a
Input String
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
Initial state
44
Scanning the Input
a b b a
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
45
a b b a
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
46
a b b a
•
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
47
Input finished
a b b a
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
accept
48
A Rejection Case
a b a
•
Input String
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
49
a b a
•
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
50
a b a
•
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
51
Input finished
a b a
a, b
reject
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
52
Another Rejection Case
Tape is empty
( )
•Input Finished
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
reject
53
Language Accepted: L abba
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
54
To accept a string:
all the input string is scanned
and the last state is accepting
To reject a string:
all the input string is scanned
and the last state is non-accepting
55
Another Example
•L , ab, abba
a, b
q5
b a a a, b
b
q0 a q1 b q2 b q3 a q4
Accept Accept Accept
state state state
56
Empty Tape
( )
Input Finished
a, b
q5
b a a a, b
b
q0 a q1 b q2 b q3 a q4
accept
57
Another Example
a a, b
q0 b q1 a, b q2
Accept trap state
state
58
a a b
Input String
a a, b
q0 b q1 a, b q2
59
a a b
a a, b
q0 b q1 a, b q2
60
a a b
a a, b
q0 b q1 a, b q2
61
Input finished
a a b
a a, b
accept
q0 b q1 a, b q2
62
A rejection case
b a b
Input String
a a, b
q0 b q1 a, b q2
63
b a b
a a, b
q0 b q1 a, b q2
64
b a b
a a, b
q0 b q1 a, b q2
65
Input finished
b a b
a a, b
q0 b q1 a, b q2
reject
66
Language Accepted:
L {a b : n 0}
n
a a, b
q0 b q1 a, b q2
67
Assignment
68
Assignment (cont)
69
Languages
• Definition: A language is a set of strings over
some alphabet .
• Examples:
– L1 0,1,10,1110001
– L2 0m1n | n, m are positive integers
bit strings whose binary
– L3
value is a multiple of 4
70
Language Accepted by DFA
Language of DFA :M
72
• Language rejected by : M
LM w : q0 ,w F
* *
q0 w q q F
73
More DFA Examples
{a , b }
a, b
a, b
q0 q0
L(M ) { } L (M ) *
74
{a , b }
a, b
q0 a, b q0
L(M ) { }
Language of the empty string
75
{a , b }
LM = { all strings with prefix ab}
a, b
q0 a q1 b q2
b a
accept
q3 a, b
76
LM = { all binary strings containing
• substring 001 }
0,1
1 0
1
0 0 00 1 001
0
77
LM = { all binary strings without
substring 001 }
1 0 0,1
1
0 1
0 00 001
0
78
L(M ) awa : w a , b
*
a
• b
b
q0 a q2 q3
b a
q4
a, b 79
Regular Languages
• Definition:
• A language L is regular if there is
a DFA M that accepts it ( L(M ) L )
80
Languages
81
Some Questions
Q1: How do you prove that a language La is regular?
A1: By presenting an FA, M , satisfying La LM .
Q2: Why is it important?
A2: Recognition of a regular language requires a
controller with bounded Memory.
Q3: How do you prove that a language La is not
regular?
A3: Hard! to be answered on Week3 of the course.
82
Wrap up
1. Motivated the course.
2. Defined Finite Automata.
3. Learned how to deal with construction of
automata and how to come up with a
correctness argument.
83
Assignment
• Read and understand with examples the
concept of finite state transducer and two-
tape finite automaton.
• You should also write and submit a one or two
page report about these topics.