Lecture 25: Computability - University of Virginia, Department of

Download Report

Transcript Lecture 25: Computability - University of Virginia, Department of

Class 25:
Computability
Halting Problems Hockey Team Logo
CS200: Computer Science
University of Virginia
Computer Science
David Evans
http://www.cs.virginia.edu/evans
Menu
• Quiz Answers
• Review:
– Gödel’s Theorem
– Proof in Axiomatic Systems
• Computability:
Are there some problems that it is
impossible to write a program to
solve?
22 March 2004
CS 200 Spring 2004
2
Quiz Answers
22 March 2004
CS 200 Spring 2004
3
1. How far have you read in GEB?
– Not through Chapter 5: 6
– Through Ch 5: 2
– Through Ch 6: 2, Through Ch 7: 2
– All of Part I: 3, Beyond Part I: 1
• Reading GEB might not be necessary to get
a good grade in this class, but I really hope
you will read it and enjoy reading it!
• Ch 13 is the last assigned reading in it for
this class (but I hope you’ll read the rest
during your summer vacation!)
22 March 2004
CS 200 Spring 2004
4
2. Problem Set 7
─ More practical (“Illiberal Students”)
12
─ More theoretical (“Liberal students”)
2
─ Write-in: both (“Jeffersonian students”) 1
Problem Set 7 will be both, but will
include learning some tools you will use
to build dynamic web sites in PS8.
22 March 2004
CS 200 Spring 2004
5
3. So far, class is going:
–Way too fast
–Too fast
–Just about right
–Too slow
22 March 2004
CS 200 Spring 2004
0
6.5
9.5
0
6
4. How far have you gotten in PS6:
– Finished
– Question 6
– Question 4
– Question 2
– Started
– Read it
– Haven’t started
22 March 2004
0
2
5
1
1
5
2
CS 200 Spring 2004
7
5. What should be different?
• “Maybe deal with stuff similar to our PS's
more in class???”
• “Notes more applicable to problem sets.”
• “Just use more concrete examples. I get very
lost on the abstract stuff, and can't put it
together with what we're learning until I sit in
the lab for 5 hours staring at the screen.”
• “I generally like how the class is going. More
discussion of GEB would be nice though (but
perhaps not "practically" useful).”
22 March 2004
CS 200 Spring 2004
8
“I mean the thing is, I always FEEL like I
don't know what's going on, so I think "ahhh!
slow down!" but, at the end of the day (or a
PS), I'm amazed at what I can do. So should
you do anything? I'm learning a lot, so maybe
it's good I'm confused. I do like language
stuff a lot though - I like it when we talk about
that. Sometimes it's hard for me to pick it
right up in class, though. I have to go home
and digest it.”
22 March 2004
CS 200 Spring 2004
9
• Perhaps a little less slower and a means for
practicing concepts beyond the problem
sets, on a smaller scale.
• Do more ourselves. Have simpler problems
but have us do more of them. One can
struggle through a PS without really
understanding what's going on; whereas if
we write it all ourselves, we must know
what's happening. Compensate for this
challenge with simpler problems to solve.
Just a thought; I'm actually quite content.
22 March 2004
CS 200 Spring 2004
10
6. What is Computer Science?
• A method of thinking about solving problems using
machines.
• Using machines (you can define that as you will) to solve
problems.
• A way of thinking about problems and their solutions,
then using computers to solve those problems which are
solvable.
• The engineering of problem solving strategies by way of
computer programs.
• Applying techniques of computer programming to solve
real world problems
Mechanized problem solving
22 March 2004
CS 200 Spring 2004
11
6. What is Computer Science?
• Applying a system of thought or logic according to its stated rules.
• Solving problems via a systematic way of thinking
• The study of the science of computation: the ways in which we find
solutions for problems.
• Solving problems the simplest way possible using a language.
• It is the study of command-based languages that solve a problem
and the examination of how these problems are solves.
• Basically, the study of solving problems in the most efficient and
accurate manner, generally using languages created for this
purpose.
• The application of multiple disciplines to design and construct
formalized systems of logic and evaluation.
Language/logic problem solving
22 March 2004
CS 200 Spring 2004
12
6. What is Computer Science?
• I'm more confused about its definition now
than I was before this class!
• A way of life
• A painstakingly annoying subject that uses
crazy computer languages that leave you
endlessly frustrated for hours, until you
figure out the last part of the code and feel
like a genius or realize you have
parentheses in the wrong spot and feel like
an idiot. But it's still ok I guess.
(Possibly) true statements, but not definitions
22 March 2004
CS 200 Spring 2004
13
What is Computer Science?
• My answer would be:
“Study of ways to describe procedures and
reason about the processes they produce.”
“Study of mechanized ways to solve symbolic
problems.”
Today’s topic fits, since it concerns
reasoning about whether or not a
procedure will terminate.
22 March 2004
CS 200 Spring 2004
14
8. Barber paradox
In Charlottansville, there is a barber who
shaves every man who does not shave
himself, and no one else. Who shaves the
barber?
Possible answers:
1. MU! Charlottansville doesn’t exist, there is a paradox since
either the barber shaves himself in which case he can’t
shave himself, or he doesn’t in which case he must.
2. The barber is a woman. She shaves herself just fine.
Link to Hofstadter’s satire on sexist language on today’s notes.
(Read it after you catch up on the GEB reading.)
22 March 2004
CS 200 Spring 2004
15
Computer Scientists
• Everyone should know these:
– Ada Byron, Countess of Lovelace
• First person to think about programming
– John Backus
• FORTRAN, replacement (BNF) grammars for describing
languages
– Admiral Grace Murray Hopper
• First compiler
– C. A. R. (Tony) Hoare
• Quicksort, language designer, verification
– Alan Turing (today)
• Everyone should list themselves too!
– 2 of you did on the quiz
22 March 2004
CS 200 Spring 2004
16
Review
• Axiomatic System
– Set of axioms
– Set of inference rules
• Example: MIU-System from GEB
– Axioms: MI
– Inference rules: 4 rules for making new strings
• An axiomatic system is a formal system
where the string we can generate are
meant to represent “true theorems”
22 March 2004
CS 200 Spring 2004
17
Proof
• A proof of S in an axiomatic system is
a sequence of strings, T0, T1, …, Tn
where:
– The first string is the axioms
– For all i from 1 to n, Tn is the result of
applying one of the inference rules to Tn-1
– Tn is S
• How much work is it to check a proof?
22 March 2004
CS 200 Spring 2004
18
Proof Checking Problem
• Input: an axiomatic system (a set of
axioms and inference rules), a statement
S, and a proof P containing n steps of S
• Output:
true if P is a valid proof of S
false otherwise
How much work is a proof-checking procedure?
We can write a proof-checking procedure that is  (n)
22 March 2004
CS 200 Spring 2004
19
Finite-Length Proof Finding Problem
• Input: an axiomatic system (a set of
axioms and inference rules), a statement
S, n (the maximum number of proof steps)
• Output: A valid proof of S with no more
then n steps if there is one. If there is no
proof of S with <= n steps, unprovable.
At worst, we can try all possible proofs:
How r inference rules, 0 - n steps ~ rn possible proofs
much Checking each proof is  (n)
work? So, there is a procedure that is  (nrn)
but, it might not be the best one.
22 March 2004
CS 200 Spring 2004
20
Proof Finding Problem
• Input: an axiomatic system, a statement S
• Output: If S is true, output a valid proof. If
S is not true, output false.
How much work?
It is impossible!
“It might take infinite work.”
Gödel’s theorem says it cannot be done.
22 March 2004
CS 200 Spring 2004
21
Gödel’s Statement
G: This statement of number
theory does not have any proof in
the system of Principia
Mathematica.
G is unprovable, but true!
22 March 2004
CS 200 Spring 2004
22
What does it mean for an axiomatic
system to be complete and consistent?
Derives all true
statements, and no false
statements starting from a
finite number of axioms
and following mechanical
inference rules.
22 March 2004
CS 200 Spring 2004
23
What does it mean for an axiomatic
system to be complete and consistent?
It means the axiomatic system is
weak.
Its is so weak, it cannot express
“This statement has no proof.”
22 March 2004
CS 200 Spring 2004
24
Computability
22 March 2004
CS 200 Spring 2004
25
Algorithms
Question 6 answer:
“Using algorithms to solve problems”
• What’s an algorithm?
A procedure that always terminates.
• What’s a procedure?
A precise (mechanizable) description of a
process.
22 March 2004
CS 200 Spring 2004
26
Computability
• Is there an algorithm that solves a problem?
• Decidable (computable) problems:
– There is an algorithm that solves the problem.
– Make a photomosaic, sorting, drug discovery,
winning chess (it doesn’t mean we know the
algorithm, but there is one)
• Undecidable problems:
– There is no algorithm that solves the problem.
There might be a procedure, but it
doesn’t always terminate.
22 March 2004
CS 200 Spring 2004
27
Are there any
undecidable problems?
The Proof-Finding Problem:
• Input: an axiomatic system, a
statement S
• Output: If S is true, output a valid
proof. If S is not true, output false.
22 March 2004
CS 200 Spring 2004
28
Any others?
How would you prove a problem is undecidable?
22 March 2004
CS 200 Spring 2004
29
Undecidable Problems
• We can prove a problem is undecidable by
showing it is at least as hard as the prooffinding problem
• Here’s a famous one:
Halting Problem
Input: a procedure P (described by a Scheme
program) and its input I
Output: true if executing P on I halts (finishes
execution), false otherwise.
22 March 2004
CS 200 Spring 2004
30
Charge
• Wednesday:
Why does this mean there cannot be a perfect
computer virus scanner?
22 March 2004
CS 200 Spring 2004
31