119
Computation

Computation

  • Upload
    banyan

  • View
    48

  • Download
    0

Embed Size (px)

DESCRIPTION

Computation. Binary Numbers. Decimal numbers Binary numbers. 905. 1110001001. Counting in Binary. http:// www.youtube.com/watch?v=zELAfmp3fXY. Binary Numbers. http://acc6.its.brooklyn.cuny.edu/~gurwitz/core5/nav2tool.html. Text. - PowerPoint PPT Presentation

Citation preview

Page 1: Computation

Computation

Page 2: Computation

Binary Numbers

• Decimal numbers

• Binary numbers

905

1110001001

Page 3: Computation

Counting in Binary

http://www.youtube.com/watch?v=zELAfmp3fXY

Page 4: Computation

Binary Numbers 0 1

1 2

2 4

3 8

4 16

5 32

6 64

7 128

8 256

9 512

10 1024

11 2048

12 4096

13 8192

14 16384

http://acc6.its.brooklyn.cuny.edu/~gurwitz/core5/nav2tool.html

Page 5: Computation

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.

Page 6: Computation

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é.

Page 7: Computation

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é.

Page 8: Computation

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.

Page 9: Computation

Ascii

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

Page 10: Computation

Representing Text

F o u r

01000110 01101111 01110101 01110010

Page 11: Computation

Representing Text

T h e n u m b e r i s 1 7 .

54 68 65 20 6E 75 6D 62 65 72 20 69 73 20 31 37 2E

Page 12: Computation

When We Need More Characters

简体字 What about things like:

Page 13: Computation

When We Need More Characters

简体字 What about things like:

Answer: Unicode: 32 bits. Over 4 million characters.

http://www.unicode.org/charts/

A conversion applet:http://www.pinyin.info/tools/converter/chars2uninumbers.html

Page 14: Computation

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.

Page 15: Computation

The Basic Idea

results = google(text, query)

Page 16: Computation

The Basic Idea

results = google(text, query)

if word_count(text) > 5000: return(“Done!!”)else:

return(“No sleep yet.”)

Page 17: Computation

The Basic Idea

results = google(text, query)

if word_count(text) > 5000: return(“Done!!”)else:

return(“No sleep yet.”

display = render(text, font)

Page 18: Computation

The Basic Idea

Computers have revolutionized our world.

Page 19: Computation

Digital Images

Page 20: Computation

Pixels

Page 21: Computation

Pixels

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

Page 22: Computation

Pixels

0000110000 0001111000 0011111100 0111111110 0111111110 01111111100111001110 0111001110 0111001110 0111001110

Page 23: Computation

Digital Images

Page 24: Computation

Two Color Models

Page 25: Computation

RGB

The red channel

Page 26: Computation

RGB

The green channel

Page 27: Computation

RGB

Red Green Blue

Page 28: Computation

Experimenting with RGB

http://www.jgiesen.de/ColorTheory/RGBColorApplet/rgbcolorapplet.html

Page 29: Computation

Representing Sounds

Page 30: Computation

Digitizing Sound

Page 31: Computation

Video

Page 32: Computation

Representing Programs

public static TreeMap<String, Integer> create() throws IOException 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;}

}

Page 33: Computation

Chess BoardsForsythe-Edwards Notation

http://en.wikipedia.org/wiki/Forsyth-Edwards_Notation

rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1

Page 34: Computation

Molecules

It’s just a string:

AUGACGGAGCUUCGGAGCUAG

Page 35: Computation

The Roots of Modern Technology

1834 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.”

The picture is of a model built in the late 1800s by Babbage’s son from Babbage’s drawings.

Page 36: Computation

Using Logic

• TaiShanHasTail

• SmokyHasTail

• PuffyHasTail

• ChumpyHasTail

• SnowflakeHasTail

Page 37: Computation

Using Logic

• TaiShanHasTail

• SmokyHasTail

• PuffyHasTail

• ChumpyHasTail

• SnowflakeHasTail

Page 38: Computation

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?

Page 39: Computation

Search

http://www.javaonthebrain.com/java/puzz15/

Start state Goal state

Page 40: Computation

What is a Heuristic?

Page 41: Computation

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.

Page 42: Computation

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.

Page 43: Computation

An 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 didn’t he:

(http://www.archimedes-lab.org/game_slide15/slide15_puzzle.html )

No he didn’t: (http://www.cut-the-knot.org/pythagoras/fifteen.shtml )

Page 44: Computation

Breadth-First Search

Is this a good idea?

Page 45: Computation

Depth-First Search

Page 46: Computation

More Interesting Problems

The 20 legal initial moves

Page 47: Computation

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 21012 nodes must be examined.

Page 48: Computation

Growth Rates of Functions

Page 49: Computation

Scalability

To play one master-level game

21012 nodes

Seconds since Big Bang 3 1017

Number of sequential games since Big Bang

150,000

Page 50: Computation

Yet This Exists

How?

Page 51: Computation

A Heuristic Function for Chessc1 * material + c2 * mobility + c3 * king safety + c4 * center control + ...

Computing material:

Pawn     100    Knight    320    Bishop   325    Rook     500    Queen    975    King      32767

Page 52: Computation

The Advent of the Computer

1945 ENIAC The first electronic digital computer

1948 Modified to be a stored program machine

Page 53: Computation

1949 EDVAC

Possibly the first stored program computer

Page 54: Computation

Moore’s Law

http://www.intel.com/technology/mooreslaw/

Page 55: Computation

How It Has Happened

Page 56: Computation

How It Has Happened

Page 57: Computation

Can This Trend Continue?

http://www.nytimes.com/2010/08/31/science/31compute.html?_r=1

Page 58: Computation

How Much Compute Power Might It Take?

http://www.frc.ri.cmu.edu/~hpm/book97/ch3/index.html

Page 59: Computation

How Much Compute Power is There?

Hans Moravec: http://www.frc.ri.cmu.edu/~hpm/talks/revo.slides/power.aug.curve/power.aug.gif

Page 60: Computation

How Much Compute Power Is There?

Page 62: Computation

Some Other People Agree

http://www.networkworld.com/news/2009/092109-intel-cto-interview.html

Page 63: Computation

Countdown to Singularity

Page 64: Computation

Law of Accelerating Returns

Page 65: Computation

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?

Page 66: Computation

What Can We Do?

1. Can we make all true statements theorems?

2. Can we decide whether a statement is a theorem?

Page 67: Computation

The Halting Problem

Program, M

input string, w

Does M halt on w?Yes

No

Page 68: Computation

A Simple Example

read nameif name = “Elaine” then print “You win!!” else print “You lose ”

Page 69: Computation

Another Example

read numberset result to 1set counter to 2until counter > number do

set result to result * counteradd 1 to counter

print result

Page 70: Computation

Programs Debug Programs

read numberset result to 1set counter to 2until counter > number do

set result to result * counteradd 1 to counter

print result

Given an arbitrary program, can it be guaranteed to halt?

Suppose number = 5:result number counter 1 5 2 2 5 3 6 5 4 24 5 5120 5 6

Page 71: Computation

Changing It a Bit

read numberset result to 1set counter to 2until counter > number do

set number to number * counteradd 1 to counter

print result

Given an arbitrary program, can it be guaranteed to halt?

Suppose number = 5:result number counter 1 5 2 1 10 3 1 30 4 1 120 5 1 600 6

Page 72: Computation

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.

Page 73: Computation

The Halting Problem Is Undecidable

Program, M

input string, w

Does M halt on w?Yes

No

Page 74: Computation

Another Undecidable Problem

The Post Correspondence Problem

Page 75: Computation

A PCP Instance With a Simple Solution

i X Y1 b aab

2 abb b

3 aba a

4 baaa baba

Page 76: Computation

A PCP Instance With a Simple Solution

i X Y1 b aab

2 abb b

3 aba a

4 baaa baba

Solution: 3, 4, 1

Page 77: Computation

Another PCP Instance i X Y

1 11 011

2 01 0

3 001 110

Page 78: Computation

Another PCP Instance i X Y

1 11 011

2 01 0

3 001 110

Page 79: Computation

The Post Correspondence Problem

List 1 List 21 ba bab2 abb bb3 bab abb

Page 80: Computation

A PCP Instance With No Simple Solution

i X Y1 1101 1

2 0110 11

3 1 110

Page 81: Computation

A PCP Instance With No Simple Solution

i X Y1 1101 1

2 0110 11

3 1 110

Shortest solution has length 252.

Page 82: Computation

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.

Page 83: Computation

What is a Program?

Page 84: Computation

What is a Program?

A procedure that can be performed by a computer.

Page 85: Computation

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 2 3 4 1,1 1,2 1,3 1,4 1,5 2,1 …… 1,1,1 ….

Page 86: Computation

Will This Work?

• If there is a solution:

• If there is no solution:

Page 87: Computation

A Tiling Problem

Page 88: Computation

A Tiling Problem

Page 89: Computation

A Tiling Problem

Page 90: Computation

A Tiling Problem

Page 91: Computation

A Tiling Problem

Page 92: Computation

A Tiling Problem

Page 93: Computation

A Tiling Problem

Page 94: Computation

A Tiling Problem

Page 95: Computation

A Tiling Problem

Page 96: Computation

A Tiling Problem

Page 97: Computation

Try This One

Page 98: Computation

Another Tiling Problem

Page 99: Computation

Another Tiling Problem

Page 100: Computation

Is the Tiling Problem Decidable?

Wang’s conjecture: If a given set of tiles can be used to tile anarbitrary surface, then it can always do so periodically. In otherwords, there must exist a finite area that can be tiled and thenrepeated infinitely often to cover any desired surface.

But Wang’s conjecture is false.

Page 101: Computation

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?

Page 102: Computation

Is Decidability Enough?

Page 103: Computation

The Traveling Salesman Problem

Given n cities and the distances between each pair ofthem, find the shortest tour that returns to its starting pointand visits each other city exactly once along the way.

15

20

25

89

23

40

10

4

73

28

Page 104: Computation

The Traveling Salesman Problem

15

20

25

89

23

40

10

4

73

28

Given n cities:

Choose a first city nChoose a second n-1Choose a third n-2

… n!

Page 105: Computation

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.

Page 106: Computation

The Growth Rate of n!

2 2 11 4790016003 6 12 62270208004 24 13 871782912005 120 14 13076743680006 720 15 209227898880007 5040 16 3556874280960008 40320 17 64023737057280009 362880 18 12164510040883200010 3628800 19 243290200817664000011 39916800 36 3.61041

Page 107: Computation

Growth Rates of Functions, Again

Page 108: Computation

Putting it into Perspective

Speed of light 3108 m/secWidth of a proton 10-15 mAt one operation in the time it takes light to cross a proton

31023 ops/sec

Since Big Bang 31017 secOps since Big Bang 91040 ops 36! = 3.61041

Neurons in brain 1011

Parallel ops since Big Bang

91051 43! = 61052

Page 109: Computation

Does Complexity Doom AI?

Page 110: Computation

The Prisoner’s Dilemma

Page 111: Computation

The Prisoner’s Dilemma

B cooperates B defects (rats)

A cooperates A: six monthsB: six months

A: 10 yearsB: goes free

A defects (rats) A: goes freeB: 10 years

A: 5 yearsB: 5 years

Page 112: Computation

The Prisoner’s Dilemma

B cooperates B defects (rats)

A cooperates A: six months A: 10 years

A defects (rats) A: goes free A: 5 years

Page 113: Computation

The Theory of Games

• Zero-sum games

• Nonzero-sum games• Prisoner’s Dilemma

Page 114: Computation

The Theory of Games

• Zero-sum games• Chess• The fight for page rank

• Nonzero-sum games• Prisoner’s Dilemma

Page 115: Computation

The Prisoner’s Dilemma

• Defect dominates cooperate.

• A single Nash equilibrium (defect/defect)• (No one can unilaterally

improve his position)

B cooperates B defects (rats)

A cooperates

A: six monthsB: six months

A: 10 yearsB: goes free

A defects (rats)

A: goes freeB: 10 years

A: 5 yearsB: 5 years

Page 116: Computation

The Prisoner’s Dilemma

• Defect dominates cooperate.

• A single Nash equilibrium (defect/defect)• (No one can unilaterally

improve his position)

• A single Pareto optimum• (There exists no

alternative that is better for at least one player and not worse for anyone.)

B cooperates B defects (rats)

A cooperates

A: six monthsB: six months

A: 10 yearsB: goes free

A defects (rats)

A: goes freeB: 10 years

A: 5 yearsB: 5 years

Page 117: Computation

The Prisoner’s Dilemma

• Defect dominates cooperate.

• A single Nash equilibrium (defect/defect)• (No one can unilaterally

improve his position)

• A single Pareto optimum• (There exists no

alternative that is better for at least one player and not worse for anyone.)

B cooperates B defects (rats)

A cooperates

A: six monthsB: six months

A: 10 yearsB: goes free

A defects (rats)

A: goes freeB: 10 years

A: 5 yearsB: 5 years

The Nash equilibrium is not Pareto optimal.

Page 118: Computation

The Invention of Lying

B tells truth B lies

A tells truth A: B:

A: B:

A lies A: B:

A: B:

• ______ dominates ______.

• Pareto optimum:

• Is it a Nash equilibrium?

Page 119: Computation

Landis, Admitting Doping, Accuses Top U.S. Cyclists

Floyd Landis, left, accused his former teammates, including Lance Armstrong, riding in the 2004 Tour de France, of doping.

http://www.nytimes.com/2010/05/21/sports/cycling/21landis.html?emc=eta1