the function

advertisement
Chapter 12
Theory of Computation
Introduction to CS
1st Semester, 2014 Sanghyun Park
Outline





Functions and Their Computation
Turing Machines
Universal Programming Languages
A Noncomputable Function
Complexity of Problems
Functions and Their Computation

A function is a ______________ between a collection of
possible input values and a collection of output values

The process of determining the particular output value
that a function assigns to a given input is called
_________ the function

Our question is whether we can always find a system
for computing functions, regardless of their _________

The answer is ___
Computable vs. Noncomputable
Functions

There are functions that are so _______ that there is no
well-defined, step-by-step process for determining their
outputs based on their input values; these functions are
said to be _____________

The functions whose output values can be determined
algorithmically from their input values are said to be
___________

The study of computable and noncomputable functions
is an important undertaking in computer science
Turing Machines

In an effort to understand the ________ of machines, the
Turing machine was proposed by Alan M. Turing in 1936

A Turing machine consists of a ______ unit that can read
and write symbols on a tape

The tape extends indefinitely at both ends and is divided
into ____, each of which can contain a symbol

At any time during a Turning machine’s computation,
the machine must be in one of a finite number of ______
Turing Machine’s Computation

A Turing machine’s computation consists of a sequence
of steps that are executed by the control unit

Each step consists of





_________ the symbol in the current tape cell
_______ a symbol in that cell
Possibly _______ the read/write head one cell to the left or right
________ states
The exact action to be performed is determined by a
program that tells the control unit what to do based on the
machine’s _____ and the ______ of the current tape ____
A Turing Machine for
Incrementing a Value
A Turing Machine Example (1/2)
*
1
0
1
Machine State = START
*
Current
Position
1
0
Machine State = ADD
*
Machine State = CARRY
*
1
*
Current
Position
1
0
Current
Position
0
*
A Turing Machine Example (2/2)
*
1
1
Machine State = RETURN
*
1
0
Current
Position
1
0
Machine State = RETURN
*
Machine State = HALT
1
*
*
Current
Position
1
0
*
Current
Position
The Church-Turing Thesis (1/2)

The Turing machine in the preceding example can be
used to compute the __________ function

A function that can be computed in this manner by a
Turing machine is said to be ______ computable

Turing’s conjecture was that the Turing-computable
functions were the same as the __________ functions;
this conjecture is referred to as the Church-Turing thesis
The Church-Turing Thesis (2/2)

Today this thesis is widely ________; that is,
the computable functions and the Turing-computable
functions are considered ____ and the same

If a computational system can compute all the Turingcomputable functions, it is considered to be as ________
as any computational system can be
Universal Programming Language

Most features in today’s high-level languages merely
enhance ___________ rather than contribute to the
fundamental _____ of the language

Our approach here is to describe a simple imperative
programming language powerful enough to express
programs for computing all the computable functions

A programming language with this power is called a
_________ programming language

The language we present is quite simple; we call it Bare
Bones in that it isolates a _______ set of requirements of
a universal programming language
The Bare Bones Languages



All variables are considered to be of type “___ pattern of
arbitrary length”
Variable names must begin with a letter, which can be
followed by any combination of letters and digits
Contains three assignment statements and one loop
structure




_____ name;
_____ name;
_____ name;
while name not 0 do;
.
.
end;
assignment
loop structure
Programming in Bare Bones
A Bare Bones program
for “copy Today to Tomorrow”
A Bare Bones program
for computing X * Y
The Universality of Bare Bones

Researchers have shown that the Bare Bones language
can be used to express algorithms for computing ___ the
Turing-computable functions

That is, any computable function can be computed by a
program written in Bare Bones

Thus Bare Bones is a ________ programming language;
if an algorithm exists for solving a problem, then that
problem can be solved by some Bare Bones program

Bare Bones could ___________ serve as a generalpurpose programming language
Halting Problem


The ______ problem is the problem of trying to predict in
advance whether a program will _________ if started
under certain conditions
Consider the simple Bare Bones program
while X not 0 do;
incr X;
end;

If the initial value of X is __, then the program will halt;
otherwise, the loop will be executed forever
It is easy in the above example to predict a program’s
behavior; however, this task may be more complicated
or even impossible in some cases
Self-Reference


Whether a program ultimately halts can depend on the
______ values of its variables
We assign a program’s variables an initial value
representing the _______ itself; that is, we assign the
_________ version of a program as the value of its
variables
Self-Termination

A Bare Bones program is self-terminating if its execution
terminates when started with _____ as its input

The ______ problem is now precisely described as the
problem of determining whether Bare Bones programs
are or are not self-terminating

There is ___ algorithm for answering this question in
general; thus, the solution to the halting problem lies
_______ the capabilities of computers
Unsolvability of the Halting Problem
(1/3)
Unsolvability of the Halting Problem
(2/3)
Unsolvability of the Halting Problem
(3/3)
Therefore, the halting problem is __________
Complexity of Problems (1/2)

We are interested in the question of whether a solvable
problem has a ________ solution

The complexity of a problem is determined by the
properties of the algorithms that solve that problem

More precisely, the complexity of the _______ algorithm
for solving a problem is considered to be the complexity
of the problem itself

We measure an algorithm’s complexity in terms of the
time required for its execution, which is proportional to
the number of ______ that must be performed
Complexity of Problems (2/2)

The complexity of a problem is Θ(f(n)) if there is an
algorithm with complexity of Θ(f(n)) for solving the
problem and no other algorithm has a _____ complexity

Finding the best solution to a problem and knowing that
it is the best is often a difficult problem itself;
in such situations, big O notation is used

The complexity of a problem is O(f(n)) if it has a solution
whose complexity is Θ(f(n)) but it could possibly have a
______ solution
Polynomial vs. Nonpolynomial
Problems





“g(n) is bounded by f(n)” means that the graph of f(n) will
be _______ the graph of g(n) for “large” values of n
A problem is a polynomial problem if the problem is in
O(f(n)), where the expression f(n) is either a polynomial
itself or bounded by a polynomial
The collection of all polynomial problems is denoted by P
Problems that are outside the class P are characterized
as having extremely _____ execution times
Identifying the problems that belong to P is of major
importance in computer science because it tells whether
problems have _________ solutions
NP Problems



A problem that can be solved in polynomial time by a
_______________ algorithm is called a nondeterministic
polynomial problem, or an NP problem
It is customary to denote the class of NP problems by NP
All the problems in P are also in NP;
However, whether all the NP problems are also in P is
an _____ question
Download