Module 13 • Studying the internal structure of REC, the

advertisement
Module 13
• Studying the internal structure of REC, the
set of solvable problems
– Complexity theory overview
– Automata theory preview
• Motivating Problem
– string searching
1
Studying REC
Complexity Theory
Automata Theory
2
Current picture of all languages
All Languages
REC RE-REC
Solvable
Half
Solvable
All languages - RE
Not even half solvable
Which language class should be studied further?
3
Complexity Theory
REC RE - All languages
REC
- RE
• In complexity theory, we differentiate problems
by how hard a problem is to solve
– Remember, all problems in REC are solvable
• Which problem is harder and why?
– Max:
• Input: list of n numbers
• Task: return largest of the n numbers
– Element
• Input: list of n numbers
• Task: return any of the n numbers
4
Resource Usage *
• How do we formally measure the hardness
of a problem?
– We measure the resources required to solve
input instances of the problem
• Typical resources are?
• Need a notion of size of an input instance
– Obviously larger input instances require more resources to
solve
5
Poly Language
Class *
Poly
REC RE - All languages
REC
- RE
Rest of REC
Informal Definition: A problem L1 is easier than problem L2
if problem L1 can be solved in less time than problem L2.
Poly: the set of problems which can be solved in polynomial time
(typically referred to as P, not Poly)
Major goal: Identify whether or not a problem belongs to Poly
6
Working with Poly
Poly
Rest of REC
• How do you prove a problem L is in Poly?
• How do you prove a problem L is not in
Poly?
– We are not very good at this.
– For a large class of interesting problems, we
have techniques (polynomial-time answerpreserving input transformations) that show a
problem L probably is not in Poly, but few
which prove it.
7
Examples
• Shortest Path Problem
• Input
– Graph G
– nodes s and t
• Task
– Find length of shortest
path from s to t in G
Poly
Rest of REC
• Longest Path Problem
• Input
– Graph G
– nodes s and t
• Task
– Find length of longest
path from s to t in G
Which problem is provably solvable in polynomial time?
8
Automata Theory
REC RE - All languages
REC
- RE
• In automata theory, we will define new models of
computation which we call automata
– Finite State Automata (FSA)
– Pushdown Automata (PDA)
• Key concept
– FSA’s and PDA’s are restricted models of computation
• FSA’s and PDA’s cannot solve all the problems that C++
programs can
– We then identify which problems can be solved using
FSA’s and PDA’s
9
New language
classes
REC RE - All languages
REC
- RE
• REC is the set of solvable languages when we
start with a general model of computation like
C++ programs
• We want to identify which problems in REC can
be solved when using these restricted automata
Solvable Solvable
by FSA’s by
and PDA’s PDA’s
Rest of REC
10
Recap *
• Complexity Theory
– Studies structure of the set of solvable problems
– Method: analyze resources (processing time) used to
solve a problem
• Automata Theory
– Studies structure of the set of solvable problems
– Method: define automata with restricted capabilities
and resources and see what they can solve (and what
they cannot solve)
– This theory also has important implications in the
development of programming languages and compilers
11
Motivating Problem
String Searching
12
String Searching
• Input
– String x
– String y
• Tasks
– Return location of y in
string x
– Does string y occur in
string x?
• Can you identify
applications of this
type of problem in real
life?
• Try and develop a
solution to this
problem.
13
String Searching II
• Input
– String x
– pattern y
• Tasks
– Return location of y in
string x
– Does pattern y occur in
string x?
• Pattern
– [anything].html
– $EN4$$
• Try and develop a
solution to this
problem.
14
String Searching
• We will show an easy way to solve these
string searching problems
• In particular, we will show that we can
solve these problems in the following
manner
– write down the pattern
– the computer automatically turns this into a
program which performs the actual string
search
15
Download