Title: Computation
1Computation
2Binary Numbers
- Decimal numbers
- Binary numbers
http//faculty.mc3.edu/pvetere/Applets/APPLETS/NUM
SYS/applet_frame.htm
3Representing Text
- Decide how many characters we need to represent.
- Determine the required number of bits.
- Ascii 7 bits. Can encode 27 128 different
symbols.
4Ascii
http//www.krisl.net/cgi-bin/ascbin.pl
5Representing Text
Four 01000110 01101111 01110101 01110010
6When We Need More Characters
What about things like
???
7When We Need More Characters
What about things like
???
Answer Unicode 32 bits. Over 4 million
characters. http//www.unicode.org/charts/
Answer Unicode 32 bits. Over 4 million
characters. http//www.unicode.org/charts/
8Digital Images
9RGB
The red channel
10RGB
The green channel
11RGB
Red Green Blue
12Experimenting with RGB
http//www.cbu.edu/jvarrian/applets/color1/colors
_g.htm
13Representing Sounds
14Representing Programs
public static TreeMapltString, Integergt create()
throws IOException public static
TreeMapltString, Integergt create() throws
IOException Integer freq String word
TreeMapltString, Integergt result new
TreeMapltString, Integergt() JFileChooser c
new JFileChooser() int retval
c.showOpenDialog(null) if (retval
JFileChooser.APPROVE_OPTION) Scanner
s new Scanner( c.getSelectedFile()) while(
s.hasNext() ) word s.next().toLowerCase()
freq result.get(word)
result.put(word, (freq null ? 1 freq
1)) return result
15The Roots of Modern Technology
1834 Charles Babbages
Analytical Engine
Ada writes of the engine, The Analytical Engine
has no pretensions whatever to originate
anything. It can do whatever we know how to order
it to perform.
The picture is of a model built in the late 1800s
by Babbages son from Babbages drawings.
16Using Logic
- TaiShanHasTail
- SmokyHasTail
- PuffyHasTail
- ChumpyHasTail
- SnowflakeHasTail
17Using Logic
- Panda(TaiShan).
- Bear(Smoky).
- ?x (Panda(x) ? Bear(x).
- ?x (Bear(x) ? HasPart(x, Tail)).
- ?x (Bear(x) ? Animal(x)).
- ?x (Animal(x) ? Bear(x)).
- ?x (Animal(x) ? ?y (Mother-of(y, x))).
- ?x ((Animal(x) ? ?Dead(x)) ? Alive(x)).
Does TaiShan have a tail?
18Search
Start state Goal state
http//www.javaonthebrain.com/java/puzz15/
19An Aside on Checking Facts on the Web
Who invented the 15-puzzle?
Sam Loyd did (http//www.jimloy.com/puzz/15.htm
) Did he or didnt he (http//www.archimedes-lab.
org/game_slide15/slide15_puzzle.html ) No he
didnt (http//www.cut-the-knot.org/pythagoras/fif
teen.shtml )
20Breadth-First Search
Is this a good idea?
21Search
22More Interesting Problems
The 20 legal initial moves
23Scalability
Solving hard problems requires search in a large
space.
To play master-level chess requires searching
about 8 ply deep. So about 358 or 2?1012 nodes
must be examined.
24Growth Rates of Functions
25Scalability
26The Advent of the Computer
1945 ENIAC The first electronic digital
computer
271949 EDVAC
The first stored program computer
28Moores Law
http//www.intel.com/technology/mooreslaw/
29How It Has Happened
30Can This Trend Continue?
http//www.nytimes.com/2010/08/31/science/31comput
e.html?_r1
31How Much Computer Power Might It Take?
http//www.frc.ri.cmu.edu/hpm/book97/ch3/index.ht
ml
32How Much Compute Power is There?
Hans Moravec http//www.frc.ri.cmu.edu/hpm/talks
/revo.slides/power.aug.curve/power.aug.gif
33Kurweils Vision
http//www.pocket-lint.co.uk/news/news.phtml/12920
/13944/Computers-match-humans-by-2030.phtml
34Some Other People Agree
http//www.networkworld.com/news/2009/092109-intel
-cto-interview.html
35Limits to What We Can Compute
- Are there fundamentally uncomputable things?
- Does God exist?
- Whats the best way to run a country?
- Does this puzzle have a solution?
36What Can We Do?
- Can we make all true statements theorems?
- Can we decide whether a statement is a theorem?
37The Halting Problem
Program, M input string, w
Does M halt on w?
Yes No
38A Simple Example
read name if name Elaine then print
You win!! else print You lose ?
39Another Example
read number set result to 1 set counter to
2 until counter gt number do set result to result
counter add 1 to counter print result
40Programs Debug Programs
Given an arbitrary program, can it be guaranteed
to halt?
read number set result to 1 set counter to
2 until counter gt number do set result to result
counter add 1 to counter print result
Suppose number 5 result number
counter 1 5 2 2 5 3 6 5 4
24 5 5 120 5 6
41Changing It a Bit
Given an arbitrary program, can it be guaranteed
to halt?
read number set result to 1 set counter to
2 until counter gt number do set number to number
counter add 1 to counter print result
Suppose number 5 result number
counter 1 5 2 1 10 3 1
30 4 1 120 5 1 600 6
42How About this One?
Does this program halt on all inputs?
times3(x positive integer) While x ? 1
do If x is even then x x/2. Else x
3x 1.
Lets try it.
43The Halting Problem Is Undecidable
Program, M input string, w
Does M halt on w?
Yes No
44Another Undecidable Problem
The Post Correspondence Problem
45A PCP Instance With a Simple Solution
46A PCP Instance With a Simple Solution
Solution 3, 4, 1
47Another PCP Instance
48Another PCP Instance
49The Post Correspondence Problem
50A PCP Instance With No Simple Solution
51A PCP Instance With No Simple Solution
Shortest solution has length 252.
52Can A Program Do This?
Can we write a program to answer the following
question
Given a PCP instance P, decide whether or not P
has a solution. Return
True if it does. False if it does not.
53What is a Program?
54What is a Program?
A procedure that can be performed by a computer.
55The Post Correspondence Problem
A program to solve this problem Until a
solution or a dead end is found do If dead end,
halt and report no. Generate the next candidate
solution. Test it. If it is a solution, halt
and report yes. So, if there are say 4 rows in
the table, well try 1 2 3
4 1,1 1,2 1,3
1,4 1,5 2,1 1,1,1 .
56Will This Work?
- If there is a solution
- If there is no solution
57A Tiling Problem
58A Tiling Problem
59A Tiling Problem
60A Tiling Problem
61A Tiling Problem
62A Tiling Problem
63A Tiling Problem
64A Tiling Problem
65A Tiling Problem
66A Tiling Problem
67Try This One
68Another Tiling Problem
69Another Tiling Problem
70Is the Tiling Problem Decidable?
Wangs conjecture If a given set of
tiles can be used to tile an arbitrary surface,
then it can always do so periodically. In
other words, there must exist a finite area that
can be tiled and then repeated infinitely often
to cover any desired surface. But Wangs
conjecture is false.
71Important Issues
- The halting problem is undecidable.
- Theres no black box reasoning engine for
standard logic. - Would quantum computing change the picture?
- Does undecidability doom our attempt to make
artificial copies of ourselves?
72Is Decidability Enough?
73The Traveling Salesman Problem
15
25
10
28
20
4
8
40
9
7
3
23
Given n cities and the distances between each
pair of them, find the shortest tour that returns
to its starting point and visits each other city
exactly once along the way.
74The Traveling Salesman Problem
15
25
10
28
20
4
8
40
9
7
3
23
Given n cities Choose a first city n Choose
a second n-1 Choose a third n-2 n!
75The Traveling Salesman Problem
Can we do better than n! ? First city
doesnt matter. ? Order doesnt matter. So
we get (n-1!)/2.
76The Growth Rate of n!
77Growth Rates of Functions, Again
78Putting it into Perspective
79Does Complexity Doom AI?