Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computation.

Similar presentations


Presentation on theme: "Computation."— Presentation transcript:

1 Computation

2 Binary Numbers Decimal numbers Binary numbers

3 Text Computers have revolutionized our world. They have changed the course of our daily lives, the way we do science, the way we entertain ourselves, the way that business is conducted, and the way we protect our security.

4 Text Computers have revolutionized our world. They have changed the course of our daily lives, the way we do science, the way we entertain ourselves, the way that business is conducted, and the way we protect our security. Les ordinateurs ont révolutionné notre monde. Ils ont changé le cours de notre vie quotidienne, notre façon de faire la science, la façon dont nous nous divertissons, la façon dont les affaires sont menées, et la façon dont nous protégeons notre sécurité.

5 Text Computers have revolutionized our world. They have changed the course of our daily lives, the way we do science, the way we entertain ourselves, the way that business is conducted, and the way we protect our security. Les ordinateurs ont révolutionné notre monde. Ils ont changé le cours de notre vie quotidienne, notre façon de faire la science, la façon dont nous nous divertissons, la façon dont les affaires sont menées, et la façon dont nous protégeons notre sécurité. 計算機已經徹底改變我們的世界。當然,他們已經改變了我們的日常生活中,我們這樣做科研,我們自娛自樂的方式,經營的方式進行的方式,以及我們保護我們的安全。

6 Representing Text Decide how many characters we need to represent.
Determine the required number of bits. Ascii: 7 bits. Can encode 27 = 128 different symbols.

7 Ascii http://www.krisl.net/cgi-bin/ascbin.pl

8 Representing Text F o u r

9 Representing Text T h e n u m b e r i s 1 7 .
E D E

10 When We Need More Characters
What about things like: 简体字 Chinese string means “simple writing”

11 When We Need More Characters
What about things like: 简体字 Answer: Unicode: 32 bits. Over 4 million characters. A conversion applet: Chinese string means “simple writing”

12 But What Do Symbols Look Like?
Computers have revolutionized our world. Computers have revolutionized our world. Computers have revolutionized our world. Computers have revolutionized our world. Computers have revolutionized our world.

13 The Basic Idea results = google(text, query)
So we keep the text in a form that is suitable for all these operations. But what does a font look like?

14 The Basic Idea results = google(text, query)
if word_count(text) > 5000: return(“Done!!”) else: return(“No sleep yet.”) So we keep the text in a form that is suitable for all these operations. But what does a font look like?

15 The Basic Idea results = google(text, query)
if word_count(text) > 5000: return(“Done!!”) else: return(“No sleep yet.” display = render(text, font) So we keep the text in a form that is suitable for all these operations. But what does a font look like?

16 The Basic Idea Computers have revolutionized our world.
Answer: fonts. Highlight the text and format font and watch it change.

17 Digital Images

18 Pixels

19 Pixels Now we must turn this 2-dimensional bit matrix into a string of bits.

20 Pixels

21 Digital Images

22 Two Color Models

23 RGB The red channel

24 RGB The green channel

25 RGB Red Green Blue

26 Experimenting with RGB
First one holds blue at 0. Second one hold green at 0. From:

27 Representing Sounds

28 Digitizing Sound

29 Representing Programs
public static TreeMap<String, Integer> create() throws IOException { Integer freq; String word; TreeMap<String, Integer> result = new TreeMap<String, Integer>(); 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;

30 Chess Boards Forsythe-Edwards Notation
This is just one example of a special purpose representation. rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1

31 Molecules It’s just a string: AUGACGGAGCUUCGGAGCUAG
Do we even need a whole byte for each symbol? It’s just a string: AUGACGGAGCUUCGGAGCUAG

32 The Roots of Modern Technology
Charles Babbage’s 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.” Picture from The picture is of a model built in the late 1800s by Babbage’s son from Babbage’s drawings.

33 Using Logic TaiShanHasTail SmokyHasTail PuffyHasTail ChumpyHasTail
SnowflakeHasTail

34 Using 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?

35 Search Start state Goal state
Images from:

36 What is a Heuristic?

37 What is a Heuristic? The word heuristic comes from the Greek word  (heuriskein), meaning “to discover”, which is also the origin of eureka, derived from Archimedes’ reputed exclamation, heurika (“I have found”), uttered when he had discovered that the volume of water displaced in the bath equals the volume of whatever (him) got put in the water. This could be used as a method for determining the purity of gold.

38 What is a Heuristic? The word heuristic comes from the Greek word  (heuriskein), meaning “to discover”, which is also the origin of eureka, derived from Archimedes’ reputed exclamation, heurika (“I have found”), uttered when he had discovered that the volume of water displaced in the bath equals the volume of whatever (him) got put in the water. This could be used as a method for determining the purity of gold. A heuristic is a rule that helps us find something.

39 An Aside on Checking Facts on the Web
Who invented the 15-puzzle? Sam Loyd did: ( ) Did he or didn’t he: ( ) No he didn’t: ( )

40 Breadth-First Search Is this a good idea?
Suppose the solution is at depth 4 at the right. Then we must explore almost all paths of length 5 before we find it. Suppose all paths of length 10 are solutions? Note how much memory this approach takes.

41 Depth-First Search Notice how much less memory this takes.
Note that we could have generated the answer but not noticed it. Is depth-first search optimal? (I.e., if it finds the solution, it’s the best one) no. Can miss a better one somewhere else in the tree. What’s the worst problem? Can go on forever. Can implement a cut off.

42 More Interesting Problems
Image from: The 20 legal initial moves

43 Scalability 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.

44 Growth Rates of Functions

45 Scalability To play one master-level game 21012 nodes
Seconds since Big Bang 3 1017 Number of sequential games since Big Bang 150,000 Assuming one move per second

46 Yet This Exists How?

47 A Heuristic Function for Chess
c1 * material + c2 * mobility + c3 * king safety + c4 * center control + ... Computing material: Pawn         Knight        Bishop       Rook         Queen        King      Recall that we saw this back in Computational Thinking. Evaluation function: Material:

48 The Advent of the Computer
1945 ENIAC The first electronic digital computer 1948 Modified to be a stored program machine

49 1949 EDVAC Possibly the first stored program computer

50 Moore’s Law

51 How It Has Happened

52 Can This Trend Continue?

53 How Much Compute Power Might It Take?
Moravec: Robot: Mere Machine to Transcendent Mind

54 How Much Compute Power is There?
Hans Moravec:

55 How Much Compute Power Is There?
A newer one from: Note that it puts people at 1000 times more compute power than Moravec, yet still projects matching them before 2020.

56 Kurweil’s Vision

57 Some Other People Agree

58 Countdown to Singularity
Note log log plot : (Kurzweil)

59 Law of Accelerating Returns
One more example:

60 Limits to What We Can Compute
Are there fundamentally uncomputable things? Does God exist? What’s the best way to run a country? Does this puzzle have a solution?

61 What Can We Do? Can we make all true statements theorems?
Can we decide whether a statement is a theorem?

62 The Halting Problem Does M halt on w? Program, M input string, w Yes
No

63 A Simple Example if name = “Elaine” then print “You win!!”
read name if name = “Elaine” then print “You win!!” else print “You lose ” Obviously halts. No loops.

64 Another Example read number set result to 1 set counter to 2
until counter > number do set result to result * counter add 1 to counter print result Easy to show this one halts because counter gets one step closer to number each time. Simulation on next slide.

65 Programs Debug Programs
Given an arbitrary program, can it be guaranteed to halt? read number set result to 1 set counter to 2 until counter > number do set result to result * counter add 1 to counter print result Suppose number = 5: result number counter Easy to show this one halts because counter gets one step closer to number each time.

66 Changing 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 > number do set number to number * counter add 1 to counter print result Suppose number = 5: result number counter Easy to show this one never halts.

67 How 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. Let’s try it.

68 The Halting Problem Is Undecidable
Program, M input string, w Does M halt on w? Yes No

69 Another Undecidable Problem
The Post Correspondence Problem

70 A PCP Instance With a Simple Solution
X Y 1 b aab 2 abb 3 aba a 4 baaa baba

71 A PCP Instance With a Simple Solution
X Y 1 b aab 2 abb 3 aba a 4 baaa baba Solution: 3, 4, 1

72 Another PCP Instance i X Y 1 11 011 2 01 3 001 110

73 Another PCP Instance i X Y 1 11 011 2 01 3 001 110

74 The Post Correspondence Problem
List 1 List 2 1 ba bab 2 abb bb 3 Let the students try this one. No solution exists.

75 A PCP Instance With No Simple Solution
X Y 1 1101 2 0110 11 3 110

76 A PCP Instance With No Simple Solution
X Y 1 1101 2 0110 11 3 110 Shortest solution has length 252.

77 Can 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.

78 What is a Program?

79 What is a Program? A procedure that can be performed by a computer.

80 The 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, we’ll try: 1, , , , ,5 2,1 …… 1,1,1 ….

81 Will This Work? If there is a solution: If there is no solution:

82 A Tiling Problem Explain the rules.

83 A Tiling Problem

84 A Tiling Problem

85 A Tiling Problem

86 A Tiling Problem

87 A Tiling Problem

88 A Tiling Problem

89 A Tiling Problem

90 A Tiling Problem

91 A Tiling Problem Now notice that we can tile forever because this 3 x 3 is the same top and bottom and right and left.

92 Try This One Easy to show there’s no solution.

93 Another Tiling Problem
Hand out cut out tiles and let the students try this one. There’s a 2 x 3 that is symmetric.

94 Another Tiling Problem

95 Is the Tiling Problem Decidable?
Wang’s 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 Wang’s conjecture is false.

96 Important Issues The halting problem is undecidable.
There’s 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?

97 Is Decidability Enough?

98 The 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.

99 The 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!

100 The Traveling Salesman Problem
Can we do better than n! ● First city doesn’t matter. ● Order doesn’t matter. So we get (n-1!)/2.

101 The Growth Rate of n! 2 11 3 6 12 4 24 13 5 120 14 720 15 7 5040 16 8 40320 17 9 362880 18 10 19 36 3.61041

102 Growth Rates of Functions, Again

103 Putting it into Perspective
Speed of light 3108 m/sec Width of a proton 10-15 m At one operation in the time it takes light to cross a proton 31023 ops/sec Since Big Bang 31017 sec Ops since Big Bang 91040 ops 36! = 3.61041 Neurons in brain 1011 Parallel ops since Big Bang 91051 43! = 61052

104 Does Complexity Doom AI?


Download ppt "Computation."

Similar presentations


Ads by Google